[gnome-software] Add the ability to set an icon name on a GsApp object
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Add the ability to set an icon name on a GsApp object
- Date: Wed, 16 Oct 2013 13:25:25 +0000 (UTC)
commit 379b131b5532f36fc058c4b900ec6816cd4f49ab
Author: Richard Hughes <richard hughsie com>
Date: Wed Oct 16 14:09:44 2013 +0100
Add the ability to set an icon name on a GsApp object
src/gs-app.c | 31 +++++++++++++++++++++++++++++++
src/gs-app.h | 3 +++
2 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-app.c b/src/gs-app.c
index 6b0c6d1..ae6a6ab 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -44,6 +44,7 @@
#include "config.h"
#include <string.h>
+#include <gtk/gtk.h>
#include "gs-app.h"
@@ -544,6 +545,36 @@ gs_app_get_pixbuf (GsApp *app)
}
/**
+ * gs_app_set_icon_name:
+ */
+gboolean
+gs_app_set_icon_name (GsApp *app, const gchar *icon_name, GError **error)
+{
+ GdkPixbuf *pixbuf;
+ gboolean ret = TRUE;
+
+ g_return_val_if_fail (GS_IS_APP (app), FALSE);
+ g_return_val_if_fail (icon_name != NULL, FALSE);
+
+ /* just load from the theme */
+ pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+ icon_name,
+ 64,
+ GTK_ICON_LOOKUP_USE_BUILTIN |
+ GTK_ICON_LOOKUP_FORCE_SIZE,
+ error);
+ if (pixbuf == NULL) {
+ ret = FALSE;
+ goto out;
+ }
+ gs_app_set_pixbuf (app, pixbuf);
+out:
+ if (pixbuf != NULL)
+ g_object_unref (pixbuf);
+ return ret;
+}
+
+/**
* gs_app_set_pixbuf:
*/
void
diff --git a/src/gs-app.h b/src/gs-app.h
index b5f1eb4..5d46a21 100644
--- a/src/gs-app.h
+++ b/src/gs-app.h
@@ -154,6 +154,9 @@ void gs_app_set_management_plugin (GsApp *app,
GdkPixbuf *gs_app_get_pixbuf (GsApp *app);
void gs_app_set_pixbuf (GsApp *app,
GdkPixbuf *pixbuf);
+gboolean gs_app_set_icon_name (GsApp *app,
+ const gchar *icon_name,
+ GError **error);
GdkPixbuf *gs_app_get_featured_pixbuf (GsApp *app);
void gs_app_set_featured_pixbuf (GsApp *app,
GdkPixbuf *pixbuf);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]