From b890f0c480e66a24935cae1b049a5021f3c7a557 Mon Sep 17 00:00:00 2001 From: joncruz Date: Wed, 11 Apr 2007 18:25:18 +0000 Subject: [PATCH] Adding icons to pop-up toolbar menus --- src/ink-action.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/ink-action.cpp b/src/ink-action.cpp index 6f7ea76e3..138adafd1 100644 --- a/src/ink-action.cpp +++ b/src/ink-action.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "icon-size.h" #include "ink-action.h" @@ -182,9 +183,37 @@ void ink_action_set_property( GObject* obj, guint propId, const GValue *value, G } } +#include + static GtkWidget* ink_action_create_menu_item( GtkAction* action ) { - GtkWidget* item = gInkActionParentClass->create_menu_item( action ); + InkAction* act = INK_ACTION( action ); + GtkWidget* item = 0; + + if ( act->private_data->iconId ) { + gchar* label = 0; + g_object_get( G_OBJECT(act), "label", &label, NULL ); + + item = gtk_image_menu_item_new_with_mnemonic( label ); + GtkWidget* child = sp_icon_new( Inkscape::ICON_SIZE_MENU, act->private_data->iconId ); + // TODO this work-around is until SPIcon will live properly inside of a popup menu + if ( SP_IS_ICON(child) ) { + SPIcon* icon = SP_ICON(child); + sp_icon_fetch_pixbuf( icon ); + GdkPixbuf* target = gtk_action_is_sensitive(action) ? icon->pb : icon->pb_faded; + if ( target ) { + child = gtk_image_new_from_pixbuf( target ); + gtk_widget_destroy( GTK_WIDGET(icon) ); + } + } + gtk_widget_show_all( child ); + gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(item), child ); + + g_free( label ); + label = 0; + } else { + item = gInkActionParentClass->create_menu_item( action ); + } return item; } -- 2.30.2