After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 527304 - Allow for drop-in applications files
Allow for drop-in applications files
Status: RESOLVED FIXED
Product: gnome-control-center
Classification: Core
Component: [obsolete] Preferred applications
unspecified
Other All
: Normal enhancement
: ---
Assigned To: Control-Center Maintainers
Control-Center Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-04-10 08:52 UTC by Bastien Nocera
Modified: 2008-07-15 22:06 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Adds processing of additional application specification files, allowing third party applications to register themselves (1.09 KB, patch)
2008-07-10 22:34 UTC, Aprotim Sanyal
needs-work Details | Review
Updated path (1.18 KB, patch)
2008-07-15 20:31 UTC, Aprotim Sanyal
none Details | Review

Description Bastien Nocera 2008-04-10 08:52:55 UTC
It would be useful for 3rd party applications to be able to add themselves to the list of preferred applications.

In this case, a 3rd-party repository wants to add mplayer to the list:
https://bugzilla.redhat.com/show_bug.cgi?id=441587
Comment 1 Jens Granseuer 2008-04-10 16:31:27 UTC
Sounds like a candidate for gnome-love.

You can look at the keybindings capplet which works with modular configuration files in a similar way.
Comment 2 Aprotim Sanyal 2008-07-10 22:34:04 UTC
Created attachment 114354 [details] [review]
Adds processing of additional application specification files, allowing third party applications to register themselves
Comment 3 Aprotim Sanyal 2008-07-10 22:34:53 UTC
I've created a patch to fix this. (I'm also happy that there was an existing bug for this, so I'm not alone.

Currently, I've added code to load any files found in $GNOMECC_DATA_DIR/default-apps, in addition to the normal defaults.  I didn't add any extra validation of the files, as that should be taken care of by the existing functions.

The end result is that a third-party maintainer can drop an XML file (of the same format as gnome-default-applications.xml) into /usr/share/gnome-control-center/default-apps and have their application appear in the dropdown for preferred applications.

This (as well as the existing solution) strikes me as something of a hack, as URL handlers really should be handled the same way as file handlers, but until the freedesktop "standard" is extended to handle URI schemes as well as MIME types, this will have to do.
Comment 4 Jens Granseuer 2008-07-14 18:56:55 UTC
Thanks for your patch. A few comments:

@@ -296,6 +299,20 @@
 
     if (capplet->web_browsers == NULL)
 	gnome_da_xml_load_xml (capplet, "./gnome-default-applications.xml");
+
+    dirname = g_build_filename (GNOMECC_DATA_DIR, "default-apps", NULL);
+    app_dir = g_dir_open(dirname, 0, NULL);

Please use the same coding style as the rest of the code, ie. put a space before the opening brace,

+    if (app_dir != NULL) {
+        while ((extra_file = g_dir_read_name(app_dir)) != NULL) {
+            filename = g_build_filename (dirname,
+                    extra_file,
+                    NULL);
+            g_print("%s\n", filename);

Looks like you forgot some debug spew.

+            gnome_da_xml_load_xml (capplet, filename);

It might also be a good idea to check for a proper suffix on the file before trying to parse it.

+        }

And you're leaking the file descriptor.

+    }
+    g_free(dirname);
 }

And finally, you should add the directory to the pkg-config .pc file so that other applications can figure out where to dump their files (plus, we should move the file with the defaults there as well).
Comment 5 Aprotim Sanyal 2008-07-15 20:31:32 UTC
Created attachment 114623 [details] [review]
Updated path

Fixed a few memory leaks, added file extension checking.

Did not patch .pc file because there isn't one yet and I or somebody else can create that as a separate patch.
Comment 6 Jens Granseuer 2008-07-15 22:06:19 UTC
The new patch still needed some fixing wrt coding style and resource cleanup but I have committed it now. Thanks.

I have also added the pc file and moved the default file list.