[gnome-software/wip/ubuntu-master] snap: Correct the app origin



commit 072710fdd61ad9b28f1a289320feeb8e114ccb12
Author: Robert Ancell <robert ancell canonical com>
Date:   Wed Sep 6 11:09:45 2017 +1200

    snap: Correct the app origin

 plugins/snap/gs-plugin-snap.c |   21 +++++++++------------
 po/POTFILES.in                |    1 +
 2 files changed, 10 insertions(+), 12 deletions(-)
---
diff --git a/plugins/snap/gs-plugin-snap.c b/plugins/snap/gs-plugin-snap.c
index a624704..fa03794 100644
--- a/plugins/snap/gs-plugin-snap.c
+++ b/plugins/snap/gs-plugin-snap.c
@@ -22,11 +22,13 @@
 #include <config.h>
 
 #include <gio/gdesktopappinfo.h>
+#include <glib/gi18n.h>
 #include <snapd-glib/snapd-glib.h>
 #include <gnome-software.h>
 
 struct GsPluginData {
        SnapdClient             *client;
+       gchar                   *store_name;
        SnapdSystemConfinement   system_confinement;
        GsAuth                  *auth;
        GHashTable              *store_snaps;
@@ -172,6 +174,10 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
        system_information = snapd_client_get_system_information_sync (priv->client, cancellable, error);
        if (system_information == NULL)
                return FALSE;
+       priv->store_name = g_strdup (snapd_system_information_get_store (system_information));
+       if (priv->store_name == NULL)
+               priv->store_name = g_strdup (/* TRANSLATORS: default snap store name */
+                                            _("Snap Store"));
        priv->system_confinement = snapd_system_information_get_confinement (system_information);
 
        /* load from disk */
@@ -321,6 +327,7 @@ void
 gs_plugin_destroy (GsPlugin *plugin)
 {
        GsPluginData *priv = gs_plugin_get_data (plugin);
+       g_free (&priv->store_name);
        g_clear_object (&priv->auth);
        g_clear_pointer (&priv->store_snaps, g_hash_table_unref);
 }
@@ -658,7 +665,7 @@ gs_plugin_refine_app (GsPlugin *plugin,
        store_snap = get_store_snap (plugin, id, cancellable, NULL);
        if (store_snap != NULL) {
                GPtrArray *screenshots;
-               const gchar *name, *screenshot_url = NULL;
+               const gchar *name;
 
                if (gs_app_get_state (app) == AS_APP_STATE_UNKNOWN)
                        gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
@@ -704,20 +711,10 @@ gs_plugin_refine_app (GsPlugin *plugin,
                                as_image_set_height (image, snapd_screenshot_get_height (screenshot));
                                as_screenshot_add_image (ss, image);
                                gs_app_add_screenshot (app, ss);
-
-                               /* fall back to the screenshot */
-                               if (screenshot_url == NULL)
-                                       screenshot_url = snapd_screenshot_get_url (screenshot);
                        }
                }
 
-               /* use some heuristics to guess the application origin */
-               if (gs_app_get_origin_hostname (app) == NULL) {
-                       if (icon_url != NULL && !g_str_has_prefix (icon_url, "/"))
-                               gs_app_set_origin_hostname (app, icon_url);
-                       else if (screenshot_url != NULL)
-                               gs_app_set_origin_hostname (app, screenshot_url);
-               }
+               gs_app_set_origin (app, priv->store_name);
        }
 
        /* load icon if requested */
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 111da1d..965afbd 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -85,6 +85,7 @@ plugins/limba/org.gnome.Software.Plugin.Limba.metainfo.xml.in
 plugins/odrs/gs-plugin-odrs.c
 plugins/odrs/org.gnome.Software.Plugin.Odrs.metainfo.xml.in
 plugins/shell-extensions/gs-plugin-shell-extensions.c
+plugins/snap/gs-plugin-snap.c
 plugins/snap/org.gnome.Software.Plugin.Snap.metainfo.xml.in
 plugins/steam/gs-plugin-steam.c
 plugins/steam/org.gnome.Software.Plugin.Steam.metainfo.xml.in


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