From b3d935716262382ec91e37faa8d8d43b5a5d7d44 Mon Sep 17 00:00:00 2001 From: Jesse van den Kieboom Date: Wed, 16 Aug 2006 10:31:55 +0000 Subject: [PATCH] * gnoemoe/gm-pixbuf.c: fixed save/close stock icon when there is no save 24x24 theme icon --- ChangeLog | 5 +++++ gnoemoe/gm-pixbuf.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/ChangeLog b/ChangeLog index 05f1d6f..53f7e4a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-15-08 Jesse van den Kieboom + + * gnoemoe/gm-pixbuf.c: fixed save/close stock icon when there is no + save 24x24 theme icon + 2006-15-08 Jesse van den Kieboom * data/gnoemoe.1: added manpage diff --git a/gnoemoe/gm-pixbuf.c b/gnoemoe/gm-pixbuf.c index 526eba8..f3d334b 100644 --- a/gnoemoe/gm-pixbuf.c +++ b/gnoemoe/gm-pixbuf.c @@ -74,12 +74,47 @@ gm_pixbuf_add_directory(const gchar *directory) { g_list_prepend(gm_pixbuf_directories, g_strdup(directory)); } +static GtkIconSource * +gm_pixbuf_create_stock24(GdkPixbuf *pixbuf) { + GtkIconSource *source; + GdkPixbuf *scaled; + gint w, h; + + scaled = gdk_pixbuf_new(gdk_pixbuf_get_colorspace(pixbuf), + gdk_pixbuf_get_has_alpha(pixbuf), + gdk_pixbuf_get_bits_per_sample(pixbuf), + 24, + 24); + + gdk_pixbuf_fill(scaled, 0xffffff00); + + w = gdk_pixbuf_get_width(pixbuf); + h = gdk_pixbuf_get_height(pixbuf); + + gdk_pixbuf_copy_area(pixbuf, 0, 0, w, h, scaled, (24 - w) / 2, (24 - h) / 2); + + source = gtk_icon_source_new(); + gtk_icon_source_set_pixbuf(source, scaled); + gtk_icon_source_set_size(source, GTK_ICON_SIZE_LARGE_TOOLBAR); + + return source; +} + void gm_pixbuf_populate_factory() { GdkPixbuf *pixbuf = gm_pixbuf_create_save_close(); GtkIconSet *set; + GtkIconSource *source; set = gtk_icon_set_new_from_pixbuf(pixbuf); + + if (gdk_pixbuf_get_width(pixbuf) < 24) { + source = gm_pixbuf_create_stock24(pixbuf); + gtk_icon_set_add_source(set, source); + + gtk_icon_source_free(source); + } + gtk_icon_factory_add(factory, GM_STOCK_SAVE_CLOSE, set); g_object_unref(pixbuf); }