[gnome-software/wip/hughsie/fwupd] Add icons to the firmware items



commit 1b78cd919a4f043cf4811a03adfc08151eff81b0
Author: Richard Hughes <richard hughsie com>
Date:   Thu Mar 12 14:28:54 2015 +0000

    Add icons to the firmware items

 src/gs-app.c                  |   16 ++++++++++++----
 src/plugins/gs-plugin-fwupd.c |   19 ++++++++++++++++++-
 2 files changed, 30 insertions(+), 5 deletions(-)
---
diff --git a/src/gs-app.c b/src/gs-app.c
index 1271def..4c17452 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -804,9 +804,18 @@ 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;
+       /* has an icon */
+       if (app->priv->pixbuf == NULL &&
+           app->priv->icon != NULL &&
+           as_icon_get_kind (app->priv->icon) == AS_ICON_KIND_STOCK) {
+               app->priv->pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+                                                             as_icon_get_name (app->priv->icon), 64,
+                                                             GTK_ICON_LOOKUP_USE_BUILTIN |
+                                                             GTK_ICON_LOOKUP_FORCE_SIZE,
+                                                             NULL);
 
+       } else 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))
@@ -818,9 +827,8 @@ gs_app_get_pixbuf (GsApp *app)
                                                              GTK_ICON_LOOKUP_USE_BUILTIN |
                                                              GTK_ICON_LOOKUP_FORCE_SIZE,
                                                              NULL);
-       }
 
-       if (app->priv->pixbuf == NULL && gs_app_get_kind (app) == GS_APP_KIND_MISSING) {
+       } else if (app->priv->pixbuf == NULL && gs_app_get_kind (app) == GS_APP_KIND_MISSING) {
                app->priv->pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
                                                              "dialog-question-symbolic", 16,
                                                              GTK_ICON_LOOKUP_USE_BUILTIN |
diff --git a/src/plugins/gs-plugin-fwupd.c b/src/plugins/gs-plugin-fwupd.c
index 1fef812..f85e6f9 100644
--- a/src/plugins/gs-plugin-fwupd.c
+++ b/src/plugins/gs-plugin-fwupd.c
@@ -213,6 +213,7 @@ gs_plugin_fwupd_add_device (GsPlugin *plugin,
        _cleanup_free_ gchar *filename_cache = NULL;
        _cleanup_free_ gchar *update_location = NULL;
        _cleanup_free_ gchar *update_version = NULL;
+       _cleanup_object_unref_ AsIcon *icon = NULL;
        _cleanup_object_unref_ GsApp *app = NULL;
        _cleanup_string_free_ GString *update_desc = NULL;
 
@@ -305,6 +306,7 @@ gs_plugin_fwupd_add_device (GsPlugin *plugin,
        app = gs_app_new (guid);
        gs_app_set_management_plugin (app, "fwupd");
        gs_app_set_state (app, AS_APP_STATE_UPDATABLE);
+       gs_app_set_id_kind (app, AS_ID_KIND_FIRMWARE);
        gs_app_set_update_details (app, update_desc->str);
        gs_app_set_update_version (app, update_version);
        gs_app_add_source_id (app, filename_cache);
@@ -314,6 +316,13 @@ gs_plugin_fwupd_add_device (GsPlugin *plugin,
        gs_app_set_metadata (app, "fwupd::DeviceID", device_id);
        gs_app_set_metadata (app, "DataDir::desktop-icon", "firmware");
        gs_plugin_add_app (list, app);
+
+       /* create icon */
+       icon = as_icon_new ();
+       as_icon_set_kind (icon, AS_ICON_KIND_STOCK);
+       as_icon_set_name (icon, "firmware", -1);
+       gs_app_set_icon (app, icon);
+
        return TRUE;
 }
 
@@ -637,6 +646,7 @@ gs_plugin_filename_to_app (GsPlugin *plugin,
        gboolean supported;
        gint fd;
        gint retval;
+       _cleanup_object_unref_ AsIcon *icon = NULL;
        _cleanup_object_unref_ GDBusConnection *conn = NULL;
        _cleanup_object_unref_ GDBusMessage *message = NULL;
        _cleanup_object_unref_ GDBusMessage *request = NULL;
@@ -704,8 +714,9 @@ gs_plugin_filename_to_app (GsPlugin *plugin,
        /* get results */
        app = gs_app_new (NULL);
        gs_app_set_metadata (app, "DataDir::desktop-icon", "firmware");
+       gs_app_set_id_kind (app, AS_ID_KIND_FIRMWARE);
        gs_app_set_management_plugin (app, "fwupd");
-       gs_app_set_kind (app, GS_APP_KIND_PACKAGE);
+       gs_app_set_kind (app, GS_APP_KIND_SYSTEM);
        gs_app_set_state (app, AS_APP_STATE_AVAILABLE_LOCAL);
        gs_app_add_source_id (app, filename);
        gs_app_add_category (app, "System");
@@ -741,6 +752,12 @@ gs_plugin_filename_to_app (GsPlugin *plugin,
                g_variant_unref (variant);
        }
 
+       /* create icon */
+       icon = as_icon_new ();
+       as_icon_set_kind (icon, AS_ICON_KIND_STOCK);
+       as_icon_set_name (icon, "firmware", -1);
+       gs_app_set_icon (app, icon);
+
        gs_plugin_add_app (list, app);
        return TRUE;
 }


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