Skip to content

Drop broken GIR namespace directive - #967

Open
bugaevc wants to merge 6 commits into
elementary:mainfrom
bugaevc:drop-gir-namespace
Open

Drop broken GIR namespace directive#967
bugaevc wants to merge 6 commits into
elementary:mainfrom
bugaevc:drop-gir-namespace

Conversation

@bugaevc

@bugaevc bugaevc commented Mar 20, 2026

Copy link
Copy Markdown

Background: I'm hacking on Vala GIR generation (see https://gitlab.gnome.org/GNOME/vala/-/merge_requests/449). This line here is breaking things.

GIR doesn't quite support multiple namespace nodes inside the same GIR file. I don't believe having a separate GraniteServices.gir was ever the intention here, nor is it really possible.

The version bump to 9 is the high time to fix it.

GIR doesn't quite support multiple namespace nodes inside the same GIR
file. I don't believe having a separate GraniteServices.gir was ever the
intention here, nor is it really possible.

Removing this, coupled with https://gitlab.gnome.org/GNOME/vala/-/merge_requests/449
on the Vala side, makes the GIR for libgranite actually useable.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
@stsdc
stsdc requested a review from a team March 20, 2026 19:47
@stsdc stsdc added this to Granite 9 Mar 20, 2026
@github-project-automation github-project-automation Bot moved this to Backlog in Granite 9 Mar 20, 2026
@stsdc stsdc moved this from Backlog to In review in Granite 9 Mar 20, 2026
@stsdc

stsdc commented Jun 15, 2026

Copy link
Copy Markdown
Member

@davidmhewitt I know you were working on Granite and you're maintaining Rust bindings, could you please advice/review?

@bugaevc

bugaevc commented Jun 26, 2026

Copy link
Copy Markdown
Author

How do we move this forward?

@stsdc

stsdc commented Jun 26, 2026

Copy link
Copy Markdown
Member

@danirabbit maybe you'll be able to help?

@ryonakano

Copy link
Copy Markdown
Member

This line seemed to be added in #288.

@ryonakano

Copy link
Copy Markdown
Member

I compared the .gir file between the one generated from latest main (67750eb) and the one from this branch (edf4335) with the following steps:

git clone https://github.com/elementary/granite.git elementary-granite
cd elementary-granite/
meson setup builddir --prefix=/usr
meson compile -C builddir/
cd
git clone https://github.com/bugaevc/granite.git bugaevc-granite
cd bugaevc-granite/
git checkout drop-gir-namespace
meson setup builddir --prefix=/usr
meson compile -C builddir/
cd
diff -u --color $(find ~/elementary-granite/ -name *.gir) $(find ~/bugaevc-granite/ -name *.gir) > diff

Result:

Details
--- /home/user/elementary-granite/builddir/lib/Granite-9.0.gir	2026-08-02 10:06:15.688023027 +0900
+++ /home/user/bugaevc-granite/builddir/lib/Granite-9.0.gir	2026-08-02 10:07:09.962443521 +0900
@@ -251,20 +251,20 @@
 		</glib:signal>
 		<function name="get_instance" c:identifier="granite_services_contractor_proxy_get_instance" throws="1">
 			<return-value transfer-ownership="full">
-				<type name="Granite.GraniteServicesContractorProxy" c:type="GraniteServicesContractorProxy*"/>
+				<type name="Granite.ServicesContractorProxy" c:type="GraniteServicesContractorProxy*"/>
 			</return-value>
 		</function>
 		<function name="get_all_contracts" c:identifier="granite_services_contractor_proxy_get_all_contracts" throws="1">
 			<return-value transfer-ownership="full">
 				<type name="Gee.List" c:type="GeeList*">
-					<type name="Granite.GraniteServicesContract" c:type="GraniteServicesContract*"/>
+					<type name="Granite.ServicesContract" c:type="GraniteServicesContract*"/>
 				</type>
 			</return-value>
 		</function>
 		<function name="get_contracts_by_mime" c:identifier="granite_services_contractor_proxy_get_contracts_by_mime" throws="1">
 			<return-value transfer-ownership="full">
 				<type name="Gee.List" c:type="GeeList*">
-					<type name="Granite.GraniteServicesContract" c:type="GraniteServicesContract*"/>
+					<type name="Granite.ServicesContract" c:type="GraniteServicesContract*"/>
 				</type>
 			</return-value>
 			<parameters>
@@ -276,7 +276,7 @@
 		<function name="get_contracts_by_mimelist" c:identifier="granite_services_contractor_proxy_get_contracts_by_mimelist" throws="1">
 			<return-value transfer-ownership="full">
 				<type name="Gee.List" c:type="GeeList*">
-					<type name="Granite.GraniteServicesContract" c:type="GraniteServicesContract*"/>
+					<type name="Granite.ServicesContract" c:type="GraniteServicesContract*"/>
 				</type>
 			</return-value>
 			<parameters>
@@ -293,7 +293,7 @@
 		<function name="get_contracts_for_file" c:identifier="granite_services_contractor_proxy_get_contracts_for_file" throws="1">
 			<return-value transfer-ownership="full">
 				<type name="Gee.List" c:type="GeeList*">
-					<type name="Granite.GraniteServicesContract" c:type="GraniteServicesContract*"/>
+					<type name="Granite.ServicesContract" c:type="GraniteServicesContract*"/>
 				</type>
 			</return-value>
 			<parameters>
@@ -305,7 +305,7 @@
 		<function name="get_contracts_for_files" c:identifier="granite_services_contractor_proxy_get_contracts_for_files" throws="1">
 			<return-value transfer-ownership="full">
 				<type name="Gee.List" c:type="GeeList*">
-					<type name="Granite.GraniteServicesContract" c:type="GraniteServicesContract*"/>
+					<type name="Granite.ServicesContract" c:type="GraniteServicesContract*"/>
 				</type>
 			</return-value>
 			<parameters>
@@ -340,7 +340,7 @@
 		</function>
 		<constructor name="new" c:identifier="granite_services_system_new">
 			<return-value transfer-ownership="full">
-				<type name="Granite.GraniteServicesSystem" c:type="GraniteServicesSystem*"/>
+				<type name="Granite.ServicesSystem" c:type="GraniteServicesSystem*"/>
 			</return-value>
 		</constructor>
 		<field name="priv" readable="0" private="1">
@@ -361,7 +361,7 @@
 			</return-value>
 			<parameters>
 				<instance-parameter name="self" transfer-ownership="none">
-					<type name="Granite.GraniteServicesContract" c:type="GraniteServicesContract*"/>
+					<type name="Granite.ServicesContract" c:type="GraniteServicesContract*"/>
 				</instance-parameter>
 			</parameters>
 		</method>
@@ -371,7 +371,7 @@
 			</return-value>
 			<parameters>
 				<instance-parameter name="self" transfer-ownership="none">
-					<type name="Granite.GraniteServicesContract" c:type="GraniteServicesContract*"/>
+					<type name="Granite.ServicesContract" c:type="GraniteServicesContract*"/>
 				</instance-parameter>
 			</parameters>
 		</virtual-method>
@@ -381,7 +381,7 @@
 			</return-value>
 			<parameters>
 				<instance-parameter name="self" transfer-ownership="none">
-					<type name="Granite.GraniteServicesContract" c:type="GraniteServicesContract*"/>
+					<type name="Granite.ServicesContract" c:type="GraniteServicesContract*"/>
 				</instance-parameter>
 			</parameters>
 		</method>
@@ -391,7 +391,7 @@
 			</return-value>
 			<parameters>
 				<instance-parameter name="self" transfer-ownership="none">
-					<type name="Granite.GraniteServicesContract" c:type="GraniteServicesContract*"/>
+					<type name="Granite.ServicesContract" c:type="GraniteServicesContract*"/>
 				</instance-parameter>
 			</parameters>
 		</virtual-method>
@@ -401,7 +401,7 @@
 			</return-value>
 			<parameters>
 				<instance-parameter name="self" transfer-ownership="none">
-					<type name="Granite.GraniteServicesContract" c:type="GraniteServicesContract*"/>
+					<type name="Granite.ServicesContract" c:type="GraniteServicesContract*"/>
 				</instance-parameter>
 			</parameters>
 		</method>
@@ -411,7 +411,7 @@
 			</return-value>
 			<parameters>
 				<instance-parameter name="self" transfer-ownership="none">
-					<type name="Granite.GraniteServicesContract" c:type="GraniteServicesContract*"/>
+					<type name="Granite.ServicesContract" c:type="GraniteServicesContract*"/>
 				</instance-parameter>
 			</parameters>
 		</virtual-method>
@@ -421,7 +421,7 @@
 			</return-value>
 			<parameters>
 				<instance-parameter name="self" transfer-ownership="none">
-					<type name="Granite.GraniteServicesContract" c:type="GraniteServicesContract*"/>
+					<type name="Granite.ServicesContract" c:type="GraniteServicesContract*"/>
 				</instance-parameter>
 				<parameter name="file" transfer-ownership="none">
 					<type name="Gio.File" c:type="GFile*"/>
@@ -434,7 +434,7 @@
 			</return-value>
 			<parameters>
 				<instance-parameter name="self" transfer-ownership="none">
-					<type name="Granite.GraniteServicesContract" c:type="GraniteServicesContract*"/>
+					<type name="Granite.ServicesContract" c:type="GraniteServicesContract*"/>
 				</instance-parameter>
 				<parameter name="file" transfer-ownership="none">
 					<type name="Gio.File" c:type="GFile*"/>
@@ -447,7 +447,7 @@
 			</return-value>
 			<parameters>
 				<instance-parameter name="self" transfer-ownership="none">
-					<type name="Granite.GraniteServicesContract" c:type="GraniteServicesContract*"/>
+					<type name="Granite.ServicesContract" c:type="GraniteServicesContract*"/>
 				</instance-parameter>
 				<parameter name="files" transfer-ownership="none">
 					<array length="1" c:type="GFile**">
@@ -465,7 +465,7 @@
 			</return-value>
 			<parameters>
 				<instance-parameter name="self" transfer-ownership="none">
-					<type name="Granite.GraniteServicesContract" c:type="GraniteServicesContract*"/>
+					<type name="Granite.ServicesContract" c:type="GraniteServicesContract*"/>
 				</instance-parameter>
 				<parameter name="files" transfer-ownership="none">
 					<array length="1" c:type="GFile**">
@@ -489,7 +489,7 @@
 				</return-value>
 				<parameters>
 					<parameter name="self" transfer-ownership="none">
-						<type name="Granite.GraniteServicesContract" c:type="GraniteServicesContract*"/>
+						<type name="Granite.ServicesContract" c:type="GraniteServicesContract*"/>
 					</parameter>
 				</parameters>
 			</callback>
@@ -501,7 +501,7 @@
 				</return-value>
 				<parameters>
 					<parameter name="self" transfer-ownership="none">
-						<type name="Granite.GraniteServicesContract" c:type="GraniteServicesContract*"/>
+						<type name="Granite.ServicesContract" c:type="GraniteServicesContract*"/>
 					</parameter>
 				</parameters>
 			</callback>
@@ -513,7 +513,7 @@
 				</return-value>
 				<parameters>
 					<parameter name="self" transfer-ownership="none">
-						<type name="Granite.GraniteServicesContract" c:type="GraniteServicesContract*"/>
+						<type name="Granite.ServicesContract" c:type="GraniteServicesContract*"/>
 					</parameter>
 				</parameters>
 			</callback>
@@ -525,7 +525,7 @@
 				</return-value>
 				<parameters>
 					<parameter name="self" transfer-ownership="none">
-						<type name="Granite.GraniteServicesContract" c:type="GraniteServicesContract*"/>
+						<type name="Granite.ServicesContract" c:type="GraniteServicesContract*"/>
 					</parameter>
 					<parameter name="file" transfer-ownership="none">
 						<type name="Gio.File" c:type="GFile*"/>
@@ -540,7 +540,7 @@
 				</return-value>
 				<parameters>
 					<parameter name="self" transfer-ownership="none">
-						<type name="Granite.GraniteServicesContract" c:type="GraniteServicesContract*"/>
+						<type name="Granite.ServicesContract" c:type="GraniteServicesContract*"/>
 					</parameter>
 					<parameter name="files" transfer-ownership="none">
 						<array length="2" c:type="GFile**">
@@ -562,7 +562,7 @@
 			</return-value>
 			<parameters>
 				<instance-parameter name="self" transfer-ownership="none">
-					<type name="Granite.GraniteServicesSettingsSerializable" c:type="GraniteServicesSettingsSerializable*"/>
+					<type name="Granite.ServicesSettingsSerializable" c:type="GraniteServicesSettingsSerializable*"/>
 				</instance-parameter>
 			</parameters>
 		</method>
@@ -572,7 +572,7 @@
 			</return-value>
 			<parameters>
 				<instance-parameter name="self" transfer-ownership="none">
-					<type name="Granite.GraniteServicesSettingsSerializable" c:type="GraniteServicesSettingsSerializable*"/>
+					<type name="Granite.ServicesSettingsSerializable" c:type="GraniteServicesSettingsSerializable*"/>
 				</instance-parameter>
 			</parameters>
 		</virtual-method>
@@ -582,7 +582,7 @@
 			</return-value>
 			<parameters>
 				<instance-parameter name="self" transfer-ownership="none">
-					<type name="Granite.GraniteServicesSettingsSerializable" c:type="GraniteServicesSettingsSerializable*"/>
+					<type name="Granite.ServicesSettingsSerializable" c:type="GraniteServicesSettingsSerializable*"/>
 				</instance-parameter>
 				<parameter name="s" transfer-ownership="none">
 					<type name="utf8" c:type="const gchar*"/>
@@ -595,7 +595,7 @@
 			</return-value>
 			<parameters>
 				<instance-parameter name="self" transfer-ownership="none">
-					<type name="Granite.GraniteServicesSettingsSerializable" c:type="GraniteServicesSettingsSerializable*"/>
+					<type name="Granite.ServicesSettingsSerializable" c:type="GraniteServicesSettingsSerializable*"/>
 				</instance-parameter>
 				<parameter name="s" transfer-ownership="none">
 					<type name="utf8" c:type="const gchar*"/>
@@ -614,7 +614,7 @@
 				</return-value>
 				<parameters>
 					<parameter name="self" transfer-ownership="none">
-						<type name="Granite.GraniteServicesSettingsSerializable" c:type="GraniteServicesSettingsSerializable*"/>
+						<type name="Granite.ServicesSettingsSerializable" c:type="GraniteServicesSettingsSerializable*"/>
 					</parameter>
 				</parameters>
 			</callback>
@@ -626,7 +626,7 @@
 				</return-value>
 				<parameters>
 					<parameter name="self" transfer-ownership="none">
-						<type name="Granite.GraniteServicesSettingsSerializable" c:type="GraniteServicesSettingsSerializable*"/>
+						<type name="Granite.ServicesSettingsSerializable" c:type="GraniteServicesSettingsSerializable*"/>
 					</parameter>
 					<parameter name="s" transfer-ownership="none">
 						<type name="utf8" c:type="const gchar*"/>

@ryonakano

Copy link
Copy Markdown
Member

To check the effect of changes in this PR, I created a test GTK 4 / Granite 9 application that uses Granite.Services.ContractorProxy whose type name changed from Granite.GraniteServicesContractorProxy to Granite.ServicesContractorProxy in the above diff.

https://github.com/ryonakano/junk/blob/elementary-granite-967-test/src/MainWindow.vala

Of course first I built and installed this branch of Granite 9.

It builds, runs, and works as expected; it shows the "Compress" label in the button and presents the File Roller window when clicking it:

image

which is the same behavior that you can see from the context menu of a PDF file in Files:

Screenshot From 2026-08-02 11-20-32

@ryonakano

Copy link
Copy Markdown
Member

@bugaevc Hi, sorry for our late review. I wrote my understanding below so would you check if it's true?


The intended output of

[CCode (gir_namespace = "GraniteServices", gir_version = "1.0")]

would be like this ideally

<type name="GraniteServices.ContractorProxy" c:type="GraniteServicesContractorProxy*"/>

but that isn't possbile at the moment (requires larger changes in Vala) and the results is this at the moment

<type name="Granite.GraniteServicesContractorProxy" c:type="GraniteServicesContractorProxy*"/>

and this causes some problems once https://gitlab.gnome.org/GNOME/vala/-/merge_requests/449 is merged. So you removed the gir annotation which does not work as expected anyways.

@ryonakano

Copy link
Copy Markdown
Member

Also, does the following code also needs to be updated similar to here?

https://github.com/elementary/applications-menu/blob/bb5912dcd9436ebe3727db3f71dafe78e86687c1/src/synapse-core/utils.vala#L24

@bugaevc

bugaevc commented Aug 2, 2026

Copy link
Copy Markdown
Author

Hi, thanks for taking a look!

To check the effect of changes in this PR, I created a test GTK 4 / Granite 9 application

This change here is not supposed to have any effect on either Vala or C APIs, it only affects GIR, meaning what Granite looks like from e.g. Python.

The intended output of

[CCode (gir_namespace = "GraniteServices", gir_version = "1.0")]

would be like this ideally

<type name="GraniteServices.ContractorProxy" c:type="GraniteServicesContractorProxy*"/>

Yes, but moreover, the definition of ContractorProxy (and everything else defined in Granite.Services Vala namespace) would be in a different <namespace> block.

but that isn't possbile at the moment (requires larger changes in Vala)

Yes. But it's not just Vala: I seriously doubt that GIR is even meant to support having multiple namespaces defined in a single .gir file (so both <namespace name="Granite"> and <namespace name="GraniteServices">), and various tooling and other language bindings certainly don't support that.

What GTK and other projects that want to export multiple GIR namespaces do is they create multiple GIR files (e.g. Gtk-4.0.gir exporting the Gtk namespace, GdkWayland-4.0.gir exporting the GdkWayland namespace, and so on). I'm not sure how to do that with Vala either.

and the results is this at the moment

<type name="Granite.GraniteServicesContractorProxy" c:type="GraniteServicesContractorProxy*"/>

and this causes some problems once https://gitlab.gnome.org/GNOME/vala/-/merge_requests/449 is merged.

Well, for one thing having Granite.GraniteServicesContractorProxy makes no sense, even without the Vala-side changes. With that Vala work of mine, it does come out as GraniteServices.ContractorProxy, but it tries to define that still inside the <namespace name="Granite">, which is still broken — but now more "evidently" broken so it leads to immediate errors and not just a weird looking-name.

Another point here is that I don't see a reason to believe that @tintou ever intended that to be a separate GIR <namespace> or a separate .gir file. The line was just slipped in there, not commented upon in the code, nor discussed in the PR review, nor has anyone evidently tested that it actually produces a separate GIR namespace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

5 participants