Re: replacement for GtkImageMenuItem



Hi,

Thanks Emmanuele for your answer.

On 03/23/2014 12:38 PM, Emmanuele Bassi wrote:
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.

Sure, and I can also stop using GTK and use X to draw pixel by pixel my
interface.
What I mean is that: is the idea to not have images at all in GTK? That
sounds a big go backward to me, no?
For example, how can I be sure that all the images will be aligned, same
width, etc with all menuitems?
How can I handle images from glade?

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 don't use GMenu for now, but I could switch to it, but my app is quite
big and have a lot a menus in defferent windows. And It doesn't seem
possible to draw those menus with Glade, or did I miss something? I
don't want to write them in code.

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.

If user don't want to see images, I have no problem with that, I don't
want my app to  override this decision. But I want that ppl who want to
see images can see them. Do I have to handle that myself? Check myself
what's the value of gtk-menu-images property and add the image or not
myself?

And I just checked, gtk-menu-images is true when I run my application.
But I still don't see the icon, nor in the close button of the
AboutDialog for example.
And it's the same thing with evince for example.
My Desktop environment is XFCE if that matters.

-- 
Yann


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