Re: replacement for GtkImageMenuItem



hi;

On 23 March 2014 09:25, Yann Leboulanger <asterix lagaule org> wrote:

GtkImageMenuItem is now deprecated, but I see no replacement of it. So I
see no way to have a menuitem with an image. What am I missing?

GtkMenuItem is a GtkBin container, so you can pack a GtkBox with an
image and a label; this also has the benefit of always working
regardless of tweaks like show/hide images in menus.

if you're using GMenu to describe your menus then you can use
g_menu_item_set_icon() to add an icon to the menu item:

  https://developer.gnome.org/gio/unstable/GMenu.html#g-menu-item-set-icon

there's also the icon attribute in the XML. you should also read the
API documentation, and the HIG section on menus:

  https://wiki.gnome.org/Design/HIG/Menus

I also saw that in your documents:

Old:
item = gtk_image_menu_item_new_from_stock (GTK_STOCK_SAVE, NULL);

New:
item = gtk_menu_item_new_with_mnemonic (_(“_Save”));

I tried that (from python bindings):
item = Gtk.MenuItem.new_with_mnemonic(_("_Save"))

And I see no image.

icons in menus are hidden by default, by the gtk-menu-images
GtkSettings property. you can set the property to TRUE for your
application using:

    g_object_set (gtk_settings_get_default (), "gtk-menu-images", TRUE, NULL);

but gtk-menu-images is a deprecated tweak that will not be honoured by
newly written widgets.

the proper way to ensure that you control the visibility of images in
menus and buttons is to pack those images inside the widgets yourself.

ciao,
 Emmanuele.

-- 
W: http://www.emmanuelebassi.name
B: http://blogs.gnome.org/ebassi/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]