[gnome-software/wip/ubuntu-3-22: 27/27] snap: Correct the app origin
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/ubuntu-3-22: 27/27] snap: Correct the app origin
- Date: Fri, 27 Oct 2017 04:01:57 +0000 (UTC)
commit 88b9682c403e74eb8b91a1538e16def03c0a5f88
Author: Robert Ancell <robert ancell canonical com>
Date: Wed Sep 6 11:41:51 2017 +1200
snap: Correct the app origin
po/POTFILES.in | 1 +
src/plugins/gs-plugin-snap.c | 23 ++++++++++-------------
2 files changed, 11 insertions(+), 13 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 67f4677..b002baf 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -67,3 +67,4 @@ src/gs-shell-loading.c
[type: gettext/glade]src/gs-shell-loading.ui
src/plugins/gs-desktop-common.c
src/plugins/gs-plugin-fedora-distro-upgrades.c
+src/plugins/gs-plugin-snap.c
diff --git a/src/plugins/gs-plugin-snap.c b/src/plugins/gs-plugin-snap.c
index 53653e5..f73dab9 100644
--- a/src/plugins/gs-plugin-snap.c
+++ b/src/plugins/gs-plugin-snap.c
@@ -21,6 +21,7 @@
#include <config.h>
+#include <glib/gi18n.h>
#include <json-glib/json-glib.h>
#include <snapd-glib/snapd-glib.h>
#include <gnome-software.h>
@@ -28,6 +29,7 @@
#include "gs-snapd.h"
struct GsPluginData {
+ gchar *store_name;
gboolean system_is_confined;
GsAuth *auth;
@@ -77,6 +79,11 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
system_information = gs_snapd_get_system_info (cancellable, error);
if (system_information == NULL)
return FALSE;
+ if (json_object_has_member (system_information, "store"))
+ priv->store_name = g_strdup (json_object_get_string_member (system_information, "store"));
+ else
+ priv->store_name = g_strdup (/* TRANSLATORS: default snap store name */
+ _("Snap Store"));
priv->system_is_confined = g_strcmp0 (json_object_get_string_member (system_information,
"confinement"), "strict") == 0;
/* load from disk */
@@ -265,6 +272,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_hash_table_unref (priv->store_snaps);
g_mutex_clear (&priv->store_snaps_lock);
@@ -521,6 +529,7 @@ gs_plugin_refine_app (GsPlugin *plugin,
GCancellable *cancellable,
GError **error)
{
+ GsPluginData *priv = gs_plugin_get_data (plugin);
g_autofree gchar *macaroon = NULL;
g_auto(GStrv) discharges = NULL;
const gchar *id, *icon_url = NULL;
@@ -580,8 +589,6 @@ gs_plugin_refine_app (GsPlugin *plugin,
/* get information from snap store */
store_snap = get_store_snap (plugin, id, cancellable, NULL);
if (store_snap != NULL) {
- const gchar *screenshot_url = NULL;
-
if (gs_app_get_state (app) == AS_APP_STATE_UNKNOWN)
gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
@@ -630,20 +637,10 @@ gs_plugin_refine_app (GsPlugin *plugin,
as_image_set_height (image, json_object_get_int_member (screenshot,
"height"));
as_screenshot_add_image (ss, image);
gs_app_add_screenshot (app, ss);
-
- /* fall back to the screenshot */
- if (screenshot_url == NULL)
- screenshot_url = json_object_get_string_member (screenshot, "url");
}
}
- /* 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 */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]