Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gtk menu with icons

Tags:

gtk

This is critical part of my run-time created menu:

GtkWidget *menu, *menu_item;
menu = gtk_menu_new();

menu_item = gtk_image_menu_item_new_with_label("Uredi...");

//approach1 - icon don't work
//gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), gtk_image_new_from_stock(GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU));

//approach2 - icon also don't work
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), GTK_WIDGET(gtk_image_new_from_stock(GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU)));

gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
g_signal_connect(G_OBJECT(menu_item), "button-release-event", G_CALLBACK(menu_RELEASE), (gpointer)"");

gtk_menu_attach_to_widget(GTK_MENU(menu), button, NULL);
gtk_widget_show_all(menu);

Menu works OK but this is only one "imagemenuitem" on which I see label but don't see image. What can be wrong here?

Gtk2, Ubuntu 11.10

like image 894
Wine Too Avatar asked Jan 24 '12 15:01

Wine Too


1 Answers

I'm not 100% sure, but I believe icons in menus and buttons are no longer enabled by default. You need to turn them on to make them show up.

gconftool-2 --type bool --set /desktop/gnome/interface/menus_have_icons true

Or using dconf:

dconf write /org/gnome/desktop/interface/menus-have-icons true
like image 153
Sean Bright Avatar answered Sep 19 '22 04:09

Sean Bright