[gnome-software/gnome-3-10] Support the Ubuntu extension 'X-AppInstall-Package' in desktop files



commit a254a6c8f4ae450875d1a2b348173fc4aef8fd01
Author: Richard Hughes <richard hughsie com>
Date:   Mon Sep 30 11:13:26 2013 +0100

    Support the Ubuntu extension 'X-AppInstall-Package' in desktop files

 src/plugins/gs-plugin-datadir-apps.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/src/plugins/gs-plugin-datadir-apps.c b/src/plugins/gs-plugin-datadir-apps.c
index 71da090..5faecff 100644
--- a/src/plugins/gs-plugin-datadir-apps.c
+++ b/src/plugins/gs-plugin-datadir-apps.c
@@ -31,6 +31,7 @@ struct GsPluginPrivate {
 
 typedef struct {
        gchar           *id;
+       gchar           *pkgname;
        gchar           *name;
        gchar           *summary;
        GdkPixbuf       *pixbuf;
@@ -103,6 +104,8 @@ gs_plugin_datadir_apps_set_from_cache_item (GsApp *app,
        gs_app_set_id (app, cache_item->id);
        if (cache_item->name != NULL)
                gs_app_set_name (app, cache_item->name);
+       if (cache_item->pkgname != NULL)
+               gs_app_set_source (app, cache_item->pkgname);
        if (cache_item->summary != NULL)
                gs_app_set_summary (app, cache_item->summary);
        if (cache_item->pixbuf != NULL)
@@ -133,6 +136,7 @@ gs_plugin_datadir_apps_extract_desktop_data (GsPlugin *plugin,
        gchar *basename = NULL;
        gchar *comment = NULL;
        gchar *name = NULL;
+       gchar *pkgname = NULL;
        gchar *icon = NULL;
        gchar *dot;
        GKeyFile *key_file = NULL;
@@ -207,6 +211,14 @@ gs_plugin_datadir_apps_extract_desktop_data (GsPlugin *plugin,
        cache_item->summary = g_strdup (comment);
        cache_item->pixbuf = g_object_ref (pixbuf);
 
+       /* set pkgname if set (only Ubuntu) */
+       pkgname = g_key_file_get_string (key_file,
+                                        G_KEY_FILE_DESKTOP_GROUP,
+                                        "X-AppInstall-Package",
+                                        NULL);
+       if (pkgname != NULL && pkgname[0] != '\0')
+               cache_item->pkgname = g_strdup (pkgname);
+
        /* set new id */
        basename = g_path_get_basename (desktop_file);
        dot = strrchr (basename, '.');
@@ -230,6 +242,7 @@ out:
        if (pixbuf != NULL)
                g_object_unref (pixbuf);
        g_free (basename);
+       g_free (pkgname);
        g_free (icon);
        g_free (name);
        g_free (comment);


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