Re: replacement for GtkImageMenuItem
- From: Emmanuele Bassi <ebassi gmail com>
- To: Yann Leboulanger <asterix lagaule org>
- Cc: ML-gtk <gtk-list gnome org>
- Subject: Re: replacement for GtkImageMenuItem
- Date: Sun, 23 Mar 2014 13:45:25 +0000
hi;
On 23 March 2014 13:21, Yann Leboulanger <asterix lagaule org> wrote:
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.
there is no need for you to become adversarial and aggressive.
considering that every GTK application is basically a collection of
boxes inside boxes, adding a box inside a menu item is not a huge
change in terms of semantics. it's even hardly comparable to pushing
pixels.
on top of that, you *can* still use the deprecated API. deprecated
just means that it won't be available in the next GTK+ major release,
which at this point is neither planned nor in progress.
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?
neither.
there are various reasons to move away from images inside menu items,
except for something fairly specific like "noun" menu items (e.g.
bookmarks to web pages, or files) instead of putting an icon
everywhere. there are various scientific studies that lend weight to
the fact that users do not actually use images to recognize items, and
that words hold a better usability. a quick summary with links can be
found here:
http://uxmyths.com/post/715009009/myth-icons-enhance-usability
again, the Human Interface Guidelines for menus I linked in my email
explains why and where you should use images in menu items.
For example, how can I be sure that all the images will be aligned, same
width, etc with all menuitems?
using the GtkBox and GtkWidget alignment details, like with everything
else dealing with boxes.
I think you're grossly overestimating what GtkImageMenuItem does: all
it does is just placing two items inside an horizontal container.
How can I handle images from glade?
you should be able to modify menus from Glade. you should even be able
to use templates to create menu item subclasses that have an image
packed as you wish.
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.
you don't "write them" in code: you can use XML to define your menus,
just like you did with GtkUIManager, or GtkBuilder.
I'm not sure if Glade supports the menu definition using GAction and
GMenu, yet; I'm sure if it doesn't, then it's planned and in progress.
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.
nothing wrong with that. you have to understand, though, that GTK+
also caters to application developers and designers that do *not* want
that to happen for a variety of reasons, all as valid as your own.
that's the main drive that led to the deprecation of the
gtk-menu-images and gtk-button-images settings: it's possible for you
to allow users to change these settings, but if the setting is
toolkit-wide then it becomes impossible for them to achieve what
*they* want.
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?
if you want your users to change the way your application behaves, and
possibly how it looks, just by toggling a setting then yes: you have
to catch a notification on the property change, and update the
visibility of the GtkImage you packed inside the menu item. you can
easily do this with your own GtkMenuItem subclass. this is what
GtkImageMenuItem does.
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.
if you're not running an XSETTINGS daemon that proxies settings to the
toolkits, then you'll have to use a settings.ini file inside
$XDG_CONFIG_HOME/gtk-3.0. I honestly don't remember if XFCE has that.
if it does not work, you should ask the XFCE developers.
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]