[gnome-software: 10/10] GsApp: move local package icon loading here



commit 3a2b3afe85ae7fecc3c3f8c4e1b5ffd0368ee9cd
Author: Kalev Lember <kalevlember gmail com>
Date:   Mon Feb 9 13:13:16 2015 +0100

    GsApp: move local package icon loading here
    
    ... so that it can be shared between the details and the extra pages.

 src/gs-app.c           |   32 ++++++++++++++++++++++++++++++++
 src/gs-shell-details.c |   28 ----------------------------
 2 files changed, 32 insertions(+), 28 deletions(-)
---
diff --git a/src/gs-app.c b/src/gs-app.c
index 2b54992..655dd5d 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -781,12 +781,44 @@ gs_app_set_project_group (GsApp *app, const gchar *project_group)
 }
 
 /**
+ * gs_app_is_addon_id_kind
+ **/
+static gboolean
+gs_app_is_addon_id_kind (GsApp *app)
+{
+       AsIdKind id_kind;
+       id_kind = gs_app_get_id_kind (app);
+       if (id_kind == AS_ID_KIND_DESKTOP)
+               return FALSE;
+       if (id_kind == AS_ID_KIND_WEB_APP)
+               return FALSE;
+       return TRUE;
+}
+
+/**
  * gs_app_get_pixbuf:
  */
 GdkPixbuf *
 gs_app_get_pixbuf (GsApp *app)
 {
        g_return_val_if_fail (GS_IS_APP (app), NULL);
+
+       if (app->priv->pixbuf == NULL && gs_app_get_state (app) == AS_APP_STATE_AVAILABLE_LOCAL) {
+               const gchar *icon_name;
+
+               if (gs_app_get_kind (app) == GS_APP_KIND_SOURCE)
+                       icon_name = "x-package-repository";
+               else if (gs_app_is_addon_id_kind (app))
+                       icon_name = "application-x-addon";
+               else
+                       icon_name = "application-x-executable";
+               app->priv->pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+                                                             icon_name, 96,
+                                                             GTK_ICON_LOOKUP_USE_BUILTIN |
+                                                             GTK_ICON_LOOKUP_FORCE_SIZE,
+                                                             NULL);
+       }
+
        return app->priv->pixbuf;
 }
 
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 58531f0..6e58097 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -493,21 +493,6 @@ gs_shell_details_set_description (GsShellDetails *shell_details, const gchar *tm
 }
 
 /**
- * gs_shell_details_is_addon_id_kind
- **/
-static gboolean
-gs_shell_details_is_addon_id_kind (GsApp *app)
-{
-       AsIdKind id_kind;
-       id_kind = gs_app_get_id_kind (app);
-       if (id_kind == AS_ID_KIND_DESKTOP)
-               return FALSE;
-       if (id_kind == AS_ID_KIND_WEB_APP)
-               return FALSE;
-       return TRUE;
-}
-
-/**
  * gs_shell_details_refresh_all:
  **/
 static void
@@ -561,19 +546,6 @@ gs_shell_details_refresh_all (GsShellDetails *shell_details)
        }
        if (pixbuf == NULL)
                pixbuf = gs_app_get_pixbuf (priv->app);
-       if (pixbuf == NULL && gs_app_get_state (priv->app) == AS_APP_STATE_AVAILABLE_LOCAL) {
-               if (gs_app_get_kind (priv->app) == GS_APP_KIND_SOURCE)
-                       tmp = "x-package-repository";
-               else if (gs_shell_details_is_addon_id_kind (priv->app))
-                       tmp = "application-x-addon";
-               else
-                       tmp = "application-x-executable";
-               pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
-                                                  tmp, 96,
-                                                  GTK_ICON_LOOKUP_USE_BUILTIN |
-                                                  GTK_ICON_LOOKUP_FORCE_SIZE,
-                                                  NULL);
-       }
        if (pixbuf != NULL) {
                gs_image_set_from_pixbuf (GTK_IMAGE (priv->application_details_icon), pixbuf);
                gtk_widget_set_visible (priv->application_details_icon, TRUE);


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