[gnome-software] Set the GsApp ID from the DesktopDb if it is not set



commit 3c6a31649ded0f5467bd333074d68674fd006592
Author: Richard Hughes <richard hughsie com>
Date:   Sun Sep 1 16:24:53 2013 +0100

    Set the GsApp ID from the DesktopDb if it is not set

 src/plugins/gs-plugin-desktopdb.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/src/plugins/gs-plugin-desktopdb.c b/src/plugins/gs-plugin-desktopdb.c
index dd25a3e..95b6176 100644
--- a/src/plugins/gs-plugin-desktopdb.c
+++ b/src/plugins/gs-plugin-desktopdb.c
@@ -84,6 +84,7 @@ gs_plugin_desktopdb_set_metadata (GsPlugin *plugin,
                                  const gchar *pkg_name)
 {
        const gchar *desktop_file;
+       gchar *id = NULL;
        GError *error = NULL;
        GPtrArray *files = NULL;
 
@@ -114,10 +115,19 @@ gs_plugin_desktopdb_set_metadata (GsPlugin *plugin,
                                     g_strdup (pkg_name),
                                     g_strdup (desktop_file));
        }
+
+       /* also set the ID if it's missing */
+       if (gs_app_get_id (app) == NULL) {
+               id = g_path_get_basename (desktop_file);
+               g_strdelimit (id, ".", '\0');
+               gs_app_set_id (app, id);
+       }
+
        gs_app_set_metadata (app,
                             "datadir-desktop-filename",
                             desktop_file);
 out:
+       g_free (id);
        if (files != NULL)
                g_ptr_array_unref (files);
 }


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