Mercurial > geeqie
diff src/pixbuf_util.c @ 1341:63eb48237608
load icons for external editors
author | nadvornik |
---|---|
date | Sat, 28 Feb 2009 18:51:25 +0000 |
parents | f97450e632a1 |
children | 6fb0c1829b76 |
line wrap: on
line diff
--- a/src/pixbuf_util.c Sat Feb 28 18:01:16 2009 +0000 +++ b/src/pixbuf_util.c Sat Feb 28 18:51:25 2009 +0000 @@ -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) {