[gnome-software] datadir-filename: look in all system directories for desktop files



commit 702882ced25a382ff15369c0ab20ef00e58b3b95
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Sat Aug 31 16:01:01 2013 +0200

    datadir-filename: look in all system directories for desktop files
    
    This makes it possible to show information for applications installed
    in other locations or through systems different from PackageKit
    (for example jhbuild or listaller)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=707185

 src/plugins/gs-plugin-datadir-filename.c |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)
---
diff --git a/src/plugins/gs-plugin-datadir-filename.c b/src/plugins/gs-plugin-datadir-filename.c
index ab82d30..fd4bca7 100644
--- a/src/plugins/gs-plugin-datadir-filename.c
+++ b/src/plugins/gs-plugin-datadir-filename.c
@@ -79,6 +79,8 @@ gs_plugin_datadir_filename_find (GsPlugin *plugin,
        const gchar *path_tmp = NULL;
        gboolean ret;
        gchar *path = NULL;
+       const char * const *datadirs;
+       int i;
 
        /* try and get from cache */
        id = gs_app_get_id (app);
@@ -94,14 +96,20 @@ gs_plugin_datadir_filename_find (GsPlugin *plugin,
        }
 
        /* find if the file exists */
-       path = g_strdup_printf ("/usr/share/applications/%s.desktop",
-                               gs_app_get_id (app));
-       if (g_file_test (path, G_FILE_TEST_EXISTS)) {
-               path_tmp = g_strdup (path);
-               g_hash_table_insert (plugin->priv->cache,
-                                    g_strdup (id),
-                                    (gpointer) path_tmp);
-       } else {
+       datadirs = g_get_system_data_dirs ();
+       for (i = 0; datadirs[i]; i++) {
+               path = g_strdup_printf ("%s/applications/%s.desktop",
+                                       datadirs[i], gs_app_get_id (app));
+               if (g_file_test (path, G_FILE_TEST_EXISTS)) {
+                       path_tmp = g_strdup (path);
+                       g_hash_table_insert (plugin->priv->cache,
+                                            g_strdup (id),
+                                            (gpointer) path_tmp);
+                       break;
+               }
+       }
+
+       if (path_tmp == NULL) {
                /* add an empty key to the cache to avoid stat'ing again */
                g_hash_table_insert (plugin->priv->cache,
                                     g_strdup (id),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]