=== modified file 'applets/maintained/cairo-menu/gnome-menu-builder.c' --- applets/maintained/cairo-menu/gnome-menu-builder.c 2010-09-03 16:27:39 +0000 +++ applets/maintained/cairo-menu/gnome-menu-builder.c 2010-09-03 17:22:56 +0000 @@ -193,6 +193,7 @@ static GVolumeMonitor* vol_monitor = NULL; static DesktopAgnosticVFSGtkBookmarks *bookmarks_parser = NULL; static DesktopAgnosticVFSTrash* trash_handler = NULL; + static GtkIconTheme *icon_theme = NULL; GtkWidget *item = NULL; GError *error = NULL; @@ -205,7 +206,7 @@ gtk_container_foreach (GTK_CONTAINER (menu),(GtkCallback)_remove_menu_item,menu); add_special_item (menu,_("Computer"),"nautilus","computer:///","computer",NULL); - add_special_item (menu,_("Home"),XDG_OPEN,homedir,"stock-folder","stock_home",NULL); + add_special_item (menu,_("Home"),XDG_OPEN,homedir,"folder-home","stock_home",NULL); add_special_item (menu,_("Desktop"),XDG_OPEN,desktop_dir?desktop_dir:homedir,"desktop",NULL); if (trash_handler) @@ -225,6 +226,7 @@ these actions once.*/ vol_monitor = g_volume_monitor_get(); bookmarks_parser = desktop_agnostic_vfs_gtk_bookmarks_new (NULL, TRUE); + icon_theme = gtk_icon_theme_get_default (); trash_handler = desktop_agnostic_vfs_trash_get_default (&error); if (error) { @@ -241,6 +243,7 @@ g_signal_handlers_disconnect_by_func (vol_monitor, G_CALLBACK(_get_places_menu), menu); g_signal_handlers_disconnect_by_func (G_OBJECT (bookmarks_parser), G_CALLBACK (_get_places_menu), menu); g_signal_handlers_disconnect_by_func (trash_handler, G_CALLBACK(_get_places_menu), menu); + g_signal_handlers_disconnect_by_func (icon_theme, G_CALLBACK(_get_places_menu), menu); g_signal_connect_swapped(vol_monitor, "volume-changed", G_CALLBACK(_get_places_menu), menu); g_signal_connect_swapped(vol_monitor, "drive-changed", G_CALLBACK(_get_places_menu), menu); @@ -252,6 +255,7 @@ g_signal_connect_swapped (G_OBJECT (bookmarks_parser), "changed", G_CALLBACK (_get_places_menu), menu); g_signal_connect_swapped(trash_handler, "file-count-changed", G_CALLBACK(_get_places_menu), menu); + g_signal_connect_swapped(icon_theme, "changed", G_CALLBACK(_get_places_menu), menu); /*process mount etc*/ GList *drives = g_volume_monitor_get_connected_drives(vol_monitor); === modified file 'applets/maintained/cairo-menu/misc.c' --- applets/maintained/cairo-menu/misc.c 2010-09-03 14:12:36 +0000 +++ applets/maintained/cairo-menu/misc.c 2010-09-03 17:18:38 +0000 @@ -29,10 +29,6 @@ #include "cairo-menu-applet.h" -#if !GTK_CHECK_VERSION(2,14,0) -#define GTK_ICON_LOOKUP_FORCE_SIZE 0 -#endif - static GtkWidget * clear_recent_dialog = NULL; static GtkWidget * _get_recent_menu (GtkWidget * menu); @@ -197,55 +193,42 @@ g_object_unref (entry); } +/* Get icon image from name. + * If icon name is + * 1) a named icon, we return a themed icon image that is automatically + * updated at theme change, + * 2) a path to an image, we return the image, + * 3) else we return NULL. + */ GtkWidget * get_gtk_image (const gchar const * icon_name) { GtkWidget *image = NULL; - GdkPixbuf *pbuf = NULL; + GdkPixbuf *pbuf = NULL; gint width,height; - if (icon_name) - { - gtk_icon_size_lookup (GTK_ICON_SIZE_MENU,&width,&height); - /*TODO Need to listen for icon theme changes*/ - if ( gtk_icon_theme_has_icon (gtk_icon_theme_get_default(),icon_name) ) - { - pbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default(), - icon_name, - height, - GTK_ICON_LOOKUP_FORCE_SIZE, - NULL); - } - - if (!image) - { - if (!pbuf) - { - pbuf = gdk_pixbuf_new_from_file_at_scale (icon_name, - -1, - height, - TRUE, - NULL); - } - } - if (pbuf && GDK_IS_PIXBUF (pbuf)&&gdk_pixbuf_get_width(pbuf) > width) - { - GdkPixbuf *scaled; - height = height * ( (gdouble)width / gdk_pixbuf_get_width(pbuf) ); - scaled = gdk_pixbuf_scale_simple (pbuf, - width, - height, - GDK_INTERP_BILINEAR); - g_object_unref (pbuf); - pbuf = scaled; - } - - if (pbuf && GDK_IS_PIXBUF (pbuf)) + if (!icon_name) + { + /* do nothing, skip to return */ + } + else if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default(), icon_name)) + { + image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU); + } + else + { + gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, &height); + if (pbuf = gdk_pixbuf_new_from_file_at_scale (icon_name, + width, + height, + TRUE, /* Preserve aspect ratio */ + NULL) ) { image = gtk_image_new_from_pixbuf (pbuf); g_object_unref (pbuf); - } - } + } + } + return image; }