[goffice] GOActionComboPixmap: handle icon names too.



commit 1e86338cc138a1014d5c2d296223569388c5cc65
Author: Morten Welinder <terra gnome org>
Date:   Fri Dec 26 19:03:00 2014 -0500

    GOActionComboPixmap: handle icon names too.

 ChangeLog                             |    5 +++++
 goffice/gtk/go-action-combo-pixmaps.c |   27 ++++++++++++++++++++++++++-
 2 files changed, 31 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 166657c..ec1367b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-12-26  Morten Welinder  <terra gnome org>
+
+       * goffice/gtk/go-action-combo-pixmaps.c (make_icon): Handle a
+       stock_id which is really an icon name.
+
 2014-12-25  Morten Welinder  <terra gnome org>
 
        * goffice/gtk/go-action-combo-stack.c (cb_reconfig): Simplify
diff --git a/goffice/gtk/go-action-combo-pixmaps.c b/goffice/gtk/go-action-combo-pixmaps.c
index c587fb7..c5e70d7 100644
--- a/goffice/gtk/go-action-combo-pixmaps.c
+++ b/goffice/gtk/go-action-combo-pixmaps.c
@@ -76,6 +76,8 @@ static GdkPixbuf *
 make_icon (GtkAction *a, const char *stock_id, GtkWidget *tool)
 {
        GtkIconSize size;
+       int isize;
+       GdkPixbuf *res;
 
        if (stock_id == NULL)
                return NULL;
@@ -84,7 +86,30 @@ make_icon (GtkAction *a, const char *stock_id, GtkWidget *tool)
                ? gtk_tool_item_get_icon_size (GTK_TOOL_ITEM (tool))
                : GTK_ICON_SIZE_MENU;
 
-       return gtk_widget_render_icon_pixbuf (tool, stock_id, size);
+       /* This should go away when we assume icon names.  */
+       res = gtk_widget_render_icon_pixbuf (tool, stock_id, size);
+       if (res)
+               return res;
+
+       switch (size) {
+       default:
+       case GTK_ICON_SIZE_MENU:
+       case GTK_ICON_SIZE_SMALL_TOOLBAR:
+       case GTK_ICON_SIZE_BUTTON:
+               isize = 16;
+               break;
+       case GTK_ICON_SIZE_LARGE_TOOLBAR:
+       case GTK_ICON_SIZE_DND:
+               isize = 24;
+               break;
+       case GTK_ICON_SIZE_DIALOG:
+               isize = 48;
+               break;
+       }
+
+       return gtk_icon_theme_load_icon
+               (gtk_icon_theme_get_default (),
+                stock_id, isize, 0, NULL);
 }
 
 


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