Re: Gtk::MenuToolButton icons not showing



Gtk::MenuToolButton, Gtk::ListBox, Gtk::ListBoxRow are all container widgets. When you add a Gtk::Image, it becomes a child of the parent container. A Gtk::Image is a widget, and a widget can be the child of at most one container. You can't add the same Gtk::Image to more than one Gtk::MenuToolButton or more than one Gtk::ListBoxRow.

Usually when you try to add a widget to more than one container, you get the g_warning() message
"Can't set a parent on widget which has a parent". Unfortunately gtk_tool_button_construct_contents() handles the situation in such a way that this message is not printed.

Kjell

2014-07-07 19:59, Phil Wolff skrev:
I have just discovered that this isn't confined to Gtk::MenuToolButton, it happens when attempting to re-use a Gtk::Image instance in multiple Gtk::ListBoxRows as well.

On 07/07/2014 12:27 AM, Kjell Ahlstedt wrote:

2014-07-05 23:08, Phil Wolff skrev:
I'm using GTKMM 3.10.1 on 64-bit Ubuntu 14.04. I've got three Gtk::MenuToolButtons in my UI, and I want the same icon to appear on all three of them. This seems not to work -- my icon appears only on the last button to be instantiated, and the first two have no icon, only the activate arrow. To get my icon to appear on all three buttons, I've had to fetch the icon as a Gdk::Pixmap and create from it three unique Gtk::Image instances, one for each button. Should I presume there's some arcane Gtk requirement that makes this necessary?

If you can give me a (preferably short) test case to experiment with, I can look into this. I don't know if it's a bug or by design.
And, in a closely related but extremely minor issue, I've noticed that run-time error messages related to Gtk::Image problems in Gtk::Builder mis-identify the source, e.g.

     gtkmm-CRITICAL **: gtkmm: Gtk::_Buidler_: widget `FolderIcon' was not found in the GtkBuilder file, or the specified part of it.
I've fixed the typo in Gtk::Builder.

Kjell




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