[gnome-software] Remove the concept of a short application ID



commit 5e4992f95c2af81ca909fae60b6749543c1b02f8
Author: Richard Hughes <richard hughsie com>
Date:   Sat Aug 9 10:38:30 2014 +0200

    Remove the concept of a short application ID
    
    The way this was implemented relied on the application ID having only one '.'
    char. This breaks heavily for new-style GNOME3 applications, and isn't actually
    required anyway.
    
    This solves org.gnome.Contacts being deduplicated with org.gnome.Nautilus.

 src/gs-app-folder-dialog.c                   |    2 +-
 src/gs-app-row.c                             |    2 +-
 src/gs-app.c                                 |   31 ++-----------------------
 src/gs-app.h                                 |    1 -
 src/gs-plugin-loader.c                       |    4 +-
 src/gs-plugin.c                              |    2 +-
 src/gs-shell-details.c                       |    2 +-
 src/gs-shell-installed.c                     |    4 +-
 src/gs-utils.c                               |    4 +-
 src/plugins/gs-plugin-appstream.c            |    2 +-
 src/plugins/gs-plugin-hardcoded-categories.c |    2 +-
 src/plugins/gs-plugin-moduleset.c            |    2 +-
 src/plugins/gs-plugin-packagekit-history.c   |    4 +-
 13 files changed, 18 insertions(+), 44 deletions(-)
---
diff --git a/src/gs-app-folder-dialog.c b/src/gs-app-folder-dialog.c
index b69b95d..aa90928 100644
--- a/src/gs-app-folder-dialog.c
+++ b/src/gs-app-folder-dialog.c
@@ -85,7 +85,7 @@ apply_changes (GsAppFolderDialog *dialog)
        for (l = priv->apps; l; l = l->next) {
                GsApp *app = l->data;
                gs_folders_set_app_folder (priv->folders,
-                                          gs_app_get_id_full (app),
+                                          gs_app_get_id (app),
                                           gs_app_get_categories (app),
                                           folder);
        }
diff --git a/src/gs-app-row.c b/src/gs-app-row.c
index c35b0a1..fa2870a 100644
--- a/src/gs-app-row.c
+++ b/src/gs-app-row.c
@@ -163,7 +163,7 @@ gs_app_row_refresh (GsAppRow *app_row)
                gtk_widget_hide (priv->folder_label);
        } else {
                folders = gs_folders_get ();
-               folder = gs_folders_get_app_folder (folders, gs_app_get_id_full (priv->app), 
gs_app_get_categories (priv->app));
+               folder = gs_folders_get_app_folder (folders, gs_app_get_id (priv->app), gs_app_get_categories 
(priv->app));
                if (folder)
                        folder = gs_folders_get_folder_name (folders, folder);
                gtk_label_set_label (GTK_LABEL (priv->folder_label), folder);
diff --git a/src/gs-app.c b/src/gs-app.c
index 8db004f..f594753 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -54,7 +54,6 @@ static void   gs_app_finalize (GObject        *object);
 struct GsAppPrivate
 {
        gchar                   *id;
-       gchar                   *id_full;
        gchar                   *name;
        GsAppQuality             name_quality;
        gchar                   *icon;
@@ -180,8 +179,8 @@ gs_app_to_string (GsApp *app)
        }
        g_string_append_printf (str, "\tstate:\t%s\n",
                                as_app_state_to_string (priv->state));
-       if (priv->id_full != NULL)
-               g_string_append_printf (str, "\tid:\t%s\n", priv->id_full);
+       if (priv->id != NULL)
+               g_string_append_printf (str, "\tid:\t%s\n", priv->id);
        if ((priv->kudos & GS_APP_KUDO_MY_LANGUAGE) > 0)
                g_string_append (str, "\tkudo:\tmy-language\n");
        if ((priv->kudos & GS_APP_KUDO_RECENT_RELEASE) > 0)
@@ -345,37 +344,14 @@ gs_app_get_id (GsApp *app)
 }
 
 /**
- * gs_app_get_id_full:
- **/
-const gchar *
-gs_app_get_id_full (GsApp *app)
-{
-       g_return_val_if_fail (GS_IS_APP (app), NULL);
-       return app->priv->id_full;
-}
-
-/**
  * gs_app_set_id:
  */
 void
 gs_app_set_id (GsApp *app, const gchar *id)
 {
-       gchar *tmp;
-
        g_return_if_fail (GS_IS_APP (app));
-
-       /* save this unmolested */
-       g_free (app->priv->id_full);
-       app->priv->id_full = g_strdup (id);
-
-       /* save the short form by default */
        g_free (app->priv->id);
        app->priv->id = g_strdup (id);
-       if (app->priv->id != NULL) {
-               tmp = g_strrstr (app->priv->id, ".");
-               if (tmp != NULL)
-                       *tmp = '\0';
-       }
 }
 
 /**
@@ -1520,7 +1496,7 @@ gs_app_add_related (GsApp *app, GsApp *app2)
        g_return_if_fail (GS_IS_APP (app));
 
        key = g_strdup_printf ("%s-%s",
-                              gs_app_get_id_full (app2),
+                              gs_app_get_id (app2),
                               gs_app_get_source_default (app2));
        found = g_hash_table_lookup (app->priv->related_hash, key);
        if (found != NULL) {
@@ -2033,7 +2009,6 @@ gs_app_finalize (GObject *object)
        GsAppPrivate *priv = app->priv;
 
        g_free (priv->id);
-       g_free (priv->id_full);
        g_free (priv->name);
        g_hash_table_unref (priv->urls);
        g_free (priv->icon);
diff --git a/src/gs-app.h b/src/gs-app.h
index cbd39c7..36ab2a6 100644
--- a/src/gs-app.h
+++ b/src/gs-app.h
@@ -117,7 +117,6 @@ void                 gs_app_subsume                 (GsApp          *app,
                                                 GsApp          *other);
 
 const gchar    *gs_app_get_id                  (GsApp          *app);
-const gchar    *gs_app_get_id_full             (GsApp          *app);
 void            gs_app_set_id                  (GsApp          *app,
                                                 const gchar    *id);
 GsAppKind       gs_app_get_kind                (GsApp          *app);
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index b95d4cd..b88b2dc 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -450,7 +450,7 @@ gs_plugin_loader_get_app_str (GsApp *app)
        const gchar *id;
 
        /* first try the actual id */
-       id = gs_app_get_id_full (app);
+       id = gs_app_get_id (app);
        if (id != NULL)
                return id;
 
@@ -1209,7 +1209,7 @@ gs_plugin_loader_get_popular_finish (GsPluginLoader *plugin_loader,
 static gboolean
 gs_plugin_loader_featured_debug (GsApp *app, gpointer user_data)
 {
-       if (g_strcmp0 (gs_app_get_id_full (app),
+       if (g_strcmp0 (gs_app_get_id (app),
            g_getenv ("GNOME_SOFTWARE_FEATURED")) == 0)
                return TRUE;
        return FALSE;
diff --git a/src/gs-plugin.c b/src/gs-plugin.c
index eca115b..53ad8c6 100644
--- a/src/gs-plugin.c
+++ b/src/gs-plugin.c
@@ -210,7 +210,7 @@ gs_plugin_list_filter_duplicates (GList **list)
        hash = g_hash_table_new (g_str_hash, g_str_equal);
        for (l = *list; l != NULL; l = l->next) {
                app = GS_APP (l->data);
-               id = gs_app_get_id_full (app);
+               id = gs_app_get_id (app);
                if (id == NULL) {
                        gs_plugin_add_app (&new, app);
                        continue;
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 2db1cd6..8f577b6 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -1229,7 +1229,7 @@ gs_shell_details_app_launch_button_cb (GtkWidget *widget, GsShellDetails *shell_
        GdkDisplay *display;
        const gchar *desktop_id;
 
-       desktop_id = gs_app_get_id_full (shell_details->priv->app);
+       desktop_id = gs_app_get_id (shell_details->priv->app);
        display = gdk_display_get_default ();
        appinfo = G_APP_INFO (g_desktop_app_info_new (desktop_id));
        if (appinfo == NULL) {
diff --git a/src/gs-shell-installed.c b/src/gs-shell-installed.c
index add0593..61bef65 100644
--- a/src/gs-shell-installed.c
+++ b/src/gs-shell-installed.c
@@ -655,7 +655,7 @@ selection_changed (GsShellInstalled *shell_installed)
        for (l = apps; l; l = l->next) {
                app = l->data;
                if (gs_folders_get_app_folder (folders,
-                                              gs_app_get_id_full (app),
+                                              gs_app_get_id (app),
                                               gs_app_get_categories (app))) {
                        has_folders = TRUE;
                } else {
@@ -704,7 +704,7 @@ remove_folders (GtkButton *button, GsShellInstalled *shell_installed)
        for (l = apps; l; l = l->next) {
                app = l->data;
                gs_folders_set_app_folder (folders,
-                                          gs_app_get_id_full (app),
+                                          gs_app_get_id (app),
                                           gs_app_get_categories (app),
                                           NULL);
        }
diff --git a/src/gs-utils.c b/src/gs-utils.c
index b8ff61e..b0d681a 100644
--- a/src/gs-utils.c
+++ b/src/gs-utils.c
@@ -134,10 +134,10 @@ gs_app_notify_installed (GsApp *app)
                /* TRANSLATORS: this is button that opens the newly installed application */
                g_notification_add_button_with_target (n, _("Launch"),
                                                       "app.launch", "s",
-                                                      gs_app_get_id_full (app));
+                                                      gs_app_get_id (app));
        }
        g_notification_set_default_action_and_target  (n, "app.details", "(ss)",
-                                                      gs_app_get_id_full (app), "");
+                                                      gs_app_get_id (app), "");
        g_application_send_notification (g_application_get_default (), "installed", n);
        g_object_unref (n);
        g_free (summary);
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index 5b8c037..fac6557 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -612,7 +612,7 @@ gs_plugin_refine_from_id (GsPlugin *plugin,
        AsApp *item = NULL;
 
        /* find anything that matches the ID */
-       id = gs_app_get_id_full (app);
+       id = gs_app_get_id (app);
        if (id == NULL)
                goto out;
        item = as_store_get_app_by_id (plugin->priv->store, id);
diff --git a/src/plugins/gs-plugin-hardcoded-categories.c b/src/plugins/gs-plugin-hardcoded-categories.c
index b241894..932910b 100644
--- a/src/plugins/gs-plugin-hardcoded-categories.c
+++ b/src/plugins/gs-plugin-hardcoded-categories.c
@@ -217,7 +217,7 @@ gs_plugin_refine (GsPlugin *plugin,
        for (i = 0; i < G_N_ELEMENTS (featured); i++) {
                for (l = *list; l != NULL; l = l->next) {
                        app = GS_APP (l->data);
-                       id = gs_app_get_id_full (app);
+                       id = gs_app_get_id (app);
                        if (g_strcmp0 (id, featured[i].app) != 0)
                                continue;
                        gs_app_add_kudo (app, GS_APP_KUDO_FEATURED_RECOMMENDED);
diff --git a/src/plugins/gs-plugin-moduleset.c b/src/plugins/gs-plugin-moduleset.c
index 65c4cca..13c69d6 100644
--- a/src/plugins/gs-plugin-moduleset.c
+++ b/src/plugins/gs-plugin-moduleset.c
@@ -169,7 +169,7 @@ gs_plugin_refine (GsPlugin *plugin,
        for (l = *list; l != NULL; l = l->next) {
                app = GS_APP (l->data);
                for (i = 0; apps[i] != NULL; i++) {
-                       if (g_strcmp0 (apps[i], gs_app_get_id_full (app)) == 0) {
+                       if (g_strcmp0 (apps[i], gs_app_get_id (app)) == 0) {
                                gs_app_set_kind (app, GS_APP_KIND_SYSTEM);
                                break;
                        }
diff --git a/src/plugins/gs-plugin-packagekit-history.c b/src/plugins/gs-plugin-packagekit-history.c
index 6670c5b..6de6c7a 100644
--- a/src/plugins/gs-plugin-packagekit-history.c
+++ b/src/plugins/gs-plugin-packagekit-history.c
@@ -87,7 +87,7 @@ gs_plugin_packagekit_refine_add_history (GsApp *app, GVariant *dict)
        PkInfoEnum info_enum;
 
        /* create new history item with same ID as parent */
-       history = gs_app_new (gs_app_get_id_full (app));
+       history = gs_app_new (gs_app_get_id (app));
        gs_app_set_kind (history, GS_APP_KIND_PACKAGE);
        gs_app_set_name (history, GS_APP_QUALITY_NORMAL, gs_app_get_name (app));
 
@@ -238,7 +238,7 @@ gs_plugin_packagekit_refine (GsPlugin *plugin,
                        /* make up a fake entry as we know this package was at
                         * least installed at some point in time */
                        if (gs_app_get_state (app) == AS_APP_STATE_INSTALLED) {
-                               app_dummy = gs_app_new (gs_app_get_id_full (app));
+                               app_dummy = gs_app_new (gs_app_get_id (app));
                                gs_app_set_install_date (app_dummy, GS_APP_INSTALL_DATE_UNKNOWN);
                                gs_app_set_kind (app_dummy, GS_APP_KIND_PACKAGE);
                                gs_app_set_state (app_dummy, AS_APP_STATE_INSTALLED);


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