Revision: 1437
          http://geeqie.svn.sourceforge.net/geeqie/?rev=1437&view=rev
Author:   nadvornik
Date:     2009-02-28 18:51:25 +0000 (Sat, 28 Feb 2009)

Log Message:
-----------
load icons for external editors

Modified Paths:
--------------
    trunk/src/layout_util.c
    trunk/src/pixbuf_util.c
    trunk/src/pixbuf_util.h

Modified: trunk/src/layout_util.c
===================================================================
--- trunk/src/layout_util.c     2009-02-28 18:01:16 UTC (rev 1436)
+++ trunk/src/layout_util.c     2009-02-28 18:51:25 UTC (rev 1437)
@@ -1651,6 +1651,11 @@
                GList *path;
                EditorDescription *editor = work->data;
                GtkActionEntry entry = { editor->key, NULL, editor->name, 
editor->hotkey, NULL, G_CALLBACK(layout_menu_edit_cb) };
+               
+               if (register_theme_icon_as_stock(editor->key, editor->icon))
+                       {
+                       entry.stock_id = editor->key;
+                       }
                gtk_action_group_add_actions(lw->action_group_external, &entry, 
1, lw);
                
                path = layout_actions_editor_menu_path(editor);

Modified: trunk/src/pixbuf_util.c
===================================================================
--- trunk/src/pixbuf_util.c     2009-02-28 18:01:16 UTC (rev 1436)
+++ trunk/src/pixbuf_util.c     2009-02-28 18:51:25 UTC (rev 1437)
@@ -131,7 +131,7 @@
        return NULL;
 }
 
-static void pixbuf_inline_register_icon(const gchar *key)
+static void register_stock_icon(const gchar *key, GdkPixbuf *pixbuf)
 {
        static GtkIconFactory *icon_factory = NULL;
        GtkIconSet *icon_set;
@@ -142,7 +142,7 @@
                gtk_icon_factory_add_default(icon_factory);
                }
        
-       icon_set = gtk_icon_set_new_from_pixbuf(pixbuf_inline(key));
+       icon_set = gtk_icon_set_new_from_pixbuf(pixbuf);
        gtk_icon_factory_add(icon_factory, key, icon_set);
 }
 
@@ -154,11 +154,34 @@
        i = 0;
        while (inline_pixbuf_data[i].key)
                {
-               pixbuf_inline_register_icon(inline_pixbuf_data[i].key);
+               register_stock_icon(inline_pixbuf_data[i].key, 
pixbuf_inline(inline_pixbuf_data[i].key));
                i++;
                }
 }
 
+gboolean register_theme_icon_as_stock(const gchar *key, const gchar *icon)
+{
+       GtkIconTheme *icon_theme;
+       GdkPixbuf *pixbuf;
+       GError *error = NULL;
+
+       icon_theme = gtk_icon_theme_get_default();
+       pixbuf = gtk_icon_theme_load_icon (icon_theme,
+                           icon, /* icon name */
+                           64, /* size */
+                           0,  /* flags */
+                           &error);
+       if (!pixbuf) 
+               {
+               DEBUG_1("Couldn't load icon: %s", error->message);
+               g_error_free(error);
+               return FALSE;
+               }
+       
+       register_stock_icon(key, pixbuf);
+       return TRUE;
+}
+
 gint pixbuf_scale_aspect(gint req_w, gint req_h, gint old_w, gint old_h,
                                          gint *new_w, gint *new_h)
 {

Modified: trunk/src/pixbuf_util.h
===================================================================
--- trunk/src/pixbuf_util.h     2009-02-28 18:01:16 UTC (rev 1436)
+++ trunk/src/pixbuf_util.h     2009-02-28 18:51:25 UTC (rev 1437)
@@ -19,6 +19,7 @@
 gboolean pixbuf_to_file_as_jpg(GdkPixbuf *pixbuf, const gchar *filename, gint 
quality);
 
 void pixbuf_inline_register_stock_icons(void);
+gboolean register_theme_icon_as_stock(const gchar *key, const gchar *icon);
 
 GdkPixbuf *pixbuf_inline(const gchar *key);
 GdkPixbuf *pixbuf_fallback(FileData *fd, gint requested_width, gint 
requested_height);


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Geeqie-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geeqie-svn

Reply via email to