[gnome-software] trivial: Do not try to load remote icon URIs
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] trivial: Do not try to load remote icon URIs
- Date: Mon, 21 Oct 2013 07:29:44 +0000 (UTC)
commit 1d8d1655905d7aa13a20e722c9e195ec20839a70
Author: Richard Hughes <richard hughsie com>
Date: Mon Oct 21 08:17:04 2013 +0100
trivial: Do not try to load remote icon URIs
Making gs_app_set_icon() also load the icon was a dumb idea.
src/gs-app.c | 24 +++++++++++++++++-------
src/gs-app.h | 5 +++--
src/gs-plugin-loader.c | 3 ++-
src/gs-utils.c | 5 +++++
src/plugins/gs-plugin-appstream.c | 11 ++++++++---
src/plugins/gs-plugin-epiphany.c | 6 ++++--
6 files changed, 39 insertions(+), 15 deletions(-)
---
diff --git a/src/gs-app.c b/src/gs-app.c
index da45a39..9438ee6 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -589,21 +589,31 @@ gs_app_get_icon (GsApp *app)
/**
* gs_app_set_icon:
*/
+void
+gs_app_set_icon (GsApp *app, const gchar *icon)
+{
+ g_return_if_fail (GS_IS_APP (app));
+ g_return_if_fail (icon != NULL);
+
+ /* save icon */
+ g_free (app->priv->icon);
+ app->priv->icon = g_strdup (icon);
+}
+
+/**
+ * gs_app_load_icon:
+ */
gboolean
-gs_app_set_icon (GsApp *app, const gchar *icon, GError **error)
+gs_app_load_icon (GsApp *app, GError **error)
{
GdkPixbuf *pixbuf = NULL;
gboolean ret = TRUE;
g_return_val_if_fail (GS_IS_APP (app), FALSE);
- g_return_val_if_fail (icon != NULL, FALSE);
-
- /* save icon */
- g_free (app->priv->icon);
- app->priv->icon = g_strdup (icon);
+ g_return_val_if_fail (app->priv->icon != NULL, FALSE);
/* either load from the theme or from a file */
- pixbuf = gs_pixbuf_load (icon, 64, error);
+ pixbuf = gs_pixbuf_load (app->priv->icon, 64, error);
if (pixbuf == NULL) {
ret = FALSE;
goto out;
diff --git a/src/gs-app.h b/src/gs-app.h
index b05369f..99d72e2 100644
--- a/src/gs-app.h
+++ b/src/gs-app.h
@@ -166,8 +166,9 @@ GdkPixbuf *gs_app_get_pixbuf (GsApp *app);
void gs_app_set_pixbuf (GsApp *app,
GdkPixbuf *pixbuf);
const gchar *gs_app_get_icon (GsApp *app);
-gboolean gs_app_set_icon (GsApp *app,
- const gchar *icon,
+void gs_app_set_icon (GsApp *app,
+ const gchar *icon);
+gboolean gs_app_load_icon (GsApp *app,
GError **error);
GdkPixbuf *gs_app_get_featured_pixbuf (GsApp *app);
void gs_app_set_featured_pixbuf (GsApp *app,
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index 5a430ac..2ad8197 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -1212,7 +1212,8 @@ gs_plugin_loader_convert_unavailable_app (GsApp *app, const gchar *search)
gs_app_set_summary_missing (app, tmp->str);
gs_app_set_kind (app, GS_APP_KIND_MISSING);
gs_app_set_size (app, GS_APP_SIZE_MISSING);
- gs_app_set_icon (app, "dialog-question-symbolic", NULL);
+ gs_app_set_icon (app, "dialog-question-symbolic");
+ gs_app_load_icon (app, NULL);
g_string_free (tmp, TRUE);
return TRUE;
}
diff --git a/src/gs-utils.c b/src/gs-utils.c
index ced2160..697169b 100644
--- a/src/gs-utils.c
+++ b/src/gs-utils.c
@@ -311,6 +311,11 @@ gs_pixbuf_load (const gchar *icon_name, guint icon_size, GError **error)
GTK_ICON_LOOKUP_USE_BUILTIN |
GTK_ICON_LOOKUP_FORCE_SIZE,
error);
+ } else {
+ g_set_error (error,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_FAILED,
+ "Failed to load icon %s", icon_name);
}
return pixbuf;
}
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index c59e3d6..6504273 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -337,8 +337,11 @@ gs_plugin_refine_item_pixbuf (GsPlugin *plugin, GsApp *app, AppstreamApp *item)
icon = appstream_app_get_icon (item);
switch (appstream_app_get_icon_kind (item)) {
case APPSTREAM_APP_ICON_KIND_REMOTE:
+ gs_app_set_icon (app, icon);
+ break;
case APPSTREAM_APP_ICON_KIND_STOCK:
- ret = gs_app_set_icon (app, icon, &error);
+ gs_app_set_icon (app, icon);
+ ret = gs_app_load_icon (app, &error);
if (!ret) {
g_warning ("failed to load stock icon %s: %s",
icon, error->message);
@@ -351,7 +354,8 @@ gs_plugin_refine_item_pixbuf (GsPlugin *plugin, GsApp *app, AppstreamApp *item)
/* we assume <icon type="local">gnome-chess.png</icon> */
icon_dir = appstream_app_get_userdata (item);
icon_path = g_build_filename (icon_dir, icon, NULL);
- ret = gs_app_set_icon (app, icon_path, &error);
+ gs_app_set_icon (app, icon_path);
+ ret = gs_app_load_icon (app, &error);
if (!ret) {
g_warning ("falling back to searching for %s", icon_path);
g_error_free (error);
@@ -364,7 +368,8 @@ gs_plugin_refine_item_pixbuf (GsPlugin *plugin, GsApp *app, AppstreamApp *item)
g_warning ("failed to load cached icon %s", icon);
goto out;
}
- ret = gs_app_set_icon (app, icon_path, &error);
+ gs_app_set_icon (app, icon_path);
+ ret = gs_app_load_icon (app, &error);
g_warning ("failed to load cached icon %s: %s",
icon, error->message);
g_error_free (error);
diff --git a/src/plugins/gs-plugin-epiphany.c b/src/plugins/gs-plugin-epiphany.c
index 71f7255..7820bb8 100644
--- a/src/plugins/gs-plugin-epiphany.c
+++ b/src/plugins/gs-plugin-epiphany.c
@@ -164,7 +164,8 @@ gs_plugin_add_installed_file (GsPlugin *plugin,
gs_app_set_kind (*app, GS_APP_KIND_NORMAL);
gs_app_set_id_kind (*app, GS_APP_ID_KIND_WEBAPP);
gs_app_set_metadata (*app, "Epiphany::desktop-filename", path);
- ret = gs_app_set_icon (*app, icon, error);
+ gs_app_set_icon (*app, icon);
+ ret = gs_app_load_icon (*app, error);
if (!ret)
goto out;
out:
@@ -585,7 +586,8 @@ gs_plugin_refine_app (GsPlugin *plugin, GsApp *app, GError **error)
}
/* set local icon name */
- ret = gs_app_set_icon (app, filename_icon, error);
+ gs_app_set_icon (app, filename_icon);
+ ret = gs_app_load_icon (app, error);
if (!ret)
goto out;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]