[gnome-software/wip/ubuntu-3-26: 12/15] snap: Correct the app origin
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/ubuntu-3-26: 12/15] snap: Correct the app origin
- Date: Wed, 24 Jan 2018 03:56:32 +0000 (UTC)
commit 12af2236e335468ba2cfce68ed0c1fc36189c832
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 | 22 ++++++++++------------
po/POTFILES.in | 1 +
2 files changed, 11 insertions(+), 12 deletions(-)
---
diff --git a/plugins/snap/gs-plugin-snap.c b/plugins/snap/gs-plugin-snap.c
index 963e021..faeec24 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 {
SnapdAuthData *auth_data;
+ gchar *store_name;
SnapdSystemConfinement system_confinement;
GsAuth *auth;
@@ -206,6 +208,10 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
system_information = snapd_client_get_system_information_sync (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 */
@@ -376,6 +382,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);
g_mutex_clear (&priv->store_snaps_lock);
@@ -675,6 +682,7 @@ gs_plugin_refine_app (GsPlugin *plugin,
GCancellable *cancellable,
GError **error)
{
+ GsPluginData *priv = gs_plugin_get_data (plugin);
g_autoptr(SnapdClient) client = NULL;
const gchar *id, *icon_url = NULL;
g_autoptr(SnapdSnap) local_snap = NULL;
@@ -721,7 +729,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);
@@ -767,20 +775,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]