diff options
author | Ted Gould <ted@canonical.com> | 2009-09-23 12:52:33 -0500 |
---|---|---|
committer | Ted Gould <ted@canonical.com> | 2009-09-23 12:52:33 -0500 |
commit | 2028ebaab038fb0692e23083bff8c0ee7e63790e (patch) | |
tree | daa60202af203367dbf260dc6841b6862c4f89d1 | |
parent | 8d9485c57e4e9ef10c6cc77ccf775c113f5f7d58 (diff) | |
parent | 5a40fa084024e174cd1e76781102d1c366a13d0a (diff) | |
download | ayatana-indicator-messages-2028ebaab038fb0692e23083bff8c0ee7e63790e.tar.gz ayatana-indicator-messages-2028ebaab038fb0692e23083bff8c0ee7e63790e.tar.bz2 ayatana-indicator-messages-2028ebaab038fb0692e23083bff8c0ee7e63790e.zip |
Merging in icon scaling code.
-rw-r--r-- | debian/changelog | 6 | ||||
-rw-r--r-- | src/indicator-messages.c | 22 |
2 files changed, 27 insertions, 1 deletions
diff --git a/debian/changelog b/debian/changelog index 4fc46c8..ed865b9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +indicator-messages (0.2.3-0ubuntu1~ppa2~icon1) UNRELEASED; urgency=low + + * Merging in icon scaling code. + + -- Ted Gould <ted@ubuntu.com> Wed, 23 Sep 2009 12:51:43 -0500 + indicator-messages (0.2.3-0ubuntu1~ppa1) karmic; urgency=low * Upstream release 0.2.3 diff --git a/src/indicator-messages.c b/src/indicator-messages.c index a3f22aa..070b2be 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -194,7 +194,27 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm mi_data->icon = gtk_image_new(); GdkPixbuf * pixbuf = dbusmenu_menuitem_property_get_image(newitem, INDICATOR_MENUITEM_PROP_ICON); if (pixbuf != NULL) { - gtk_image_set_from_pixbuf(GTK_IMAGE(mi_data->icon), pixbuf); + /* If we've got a pixbuf we need to make sure it's of a reasonable + size to fit in the menu. If not, rescale it. */ + GdkPixbuf * resized_pixbuf; + gint width, height; + gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); + if (gdk_pixbuf_get_width(pixbuf) > width || + gdk_pixbuf_get_height(pixbuf) > height) { + resized_pixbuf = gdk_pixbuf_scale_simple(pixbuf, + width, + height, + GDK_INTERP_BILINEAR); + } else { + resized_pixbuf = pixbuf; + } + + gtk_image_set_from_pixbuf(GTK_IMAGE(mi_data->icon), resized_pixbuf); + + /* The other pixbuf should be free'd by the dbusmenu. */ + if (resized_pixbuf != pixbuf) { + g_object_unref(resized_pixbuf); + } } gtk_misc_set_alignment(GTK_MISC(mi_data->icon), 0.0, 0.5); gtk_box_pack_start(GTK_BOX(hbox), mi_data->icon, FALSE, FALSE, 0); |