After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 671912 - Adding image to button in GtkBuilder fails
Adding image to button in GtkBuilder fails
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Class: GtkBuilder
unspecified
Other Linux
: Normal normal
: ---
Assigned To: GtkBuilder maintainers
GtkBuilder maintainers
Depends on:
Blocks:
 
 
Reported: 2012-03-12 15:03 UTC by Bastien Nocera
Modified: 2018-04-14 23:59 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Bastien Nocera 2012-03-12 15:03:19 UTC
In cheese, until worked around, we would get errors like:
Gtk-WARNING **: Attempting to add a widget with type GtkImage to a GtkToggleButton, but as a GtkBin subclass a GtkToggleButton can only contain one widget at a time; it already contains a widget of type GtkLabel

This is caused by the order of the properties listed in the ui file.

This fails:
                           <object class="GtkToggleButton" id="burst_toggle_button">
                             <property name="related-action">burst_mode</property>
                             <property name="use-action-appearance">False</property>
                             <property name="tooltip_text" translatable="yes">Photo burst mode</property>
                             <child>
                               <object class="GtkImage" id="burst_toggle_button_image">
This works:

                           <object class="GtkToggleButton" id="burst_toggle_button">
                             <property name="use-action-appearance">False</property>
                             <property name="related-action">burst_mode</property>
                             <property name="tooltip_text" translatable="yes">Photo burst mode</property>
                             <child>
                               <object class="GtkImage" id="burst_toggle_button_image">

Because when setting related-action, the label will already have been synced, thus the GtkBin child spot taken, meaning we cannot add our own GtkImage child.

Thanks to Emmanuele for the debugging.
Comment 1 Paul Menzel 2013-05-01 10:40:24 UTC
For the record, the workaround for Cheese was discussed in bug #671913 [1].

Bastien, what is the wanted solution for this problem? GTK+ should not care about the ordering?


[1] https://bugzilla.gnome.org/show_bug.cgi?id=671913
Comment 2 Tristan Van Berkom 2013-05-01 10:55:20 UTC
I'm not sure I would call this a bug.

FWIW Glade takes special care to ensure that we serialize the
"use-action-appearance" property (if specified) before the
"related-action" property, specifically for this reason.
Comment 3 Tristan Van Berkom 2013-05-01 11:03:22 UTC
(In reply to comment #1)
> For the record, the workaround for Cheese was discussed in bug #671913 [1].
> 
> Bastien, what is the wanted solution for this problem? GTK+ should not care
> about the ordering?

That might not really be possible (not caring about ordering).

If they were construct properties, it would be possible to not care
about the ordering, and have the GObjectClass.constructed() vfunc
take care of setting things up correctly before children are ever
added.

However, since these are not construct properties they take effect
after the constructor runs, which means that one must be set before
the other is set.

But... in another light, perhaps what should be going on is that
setting use-action-appearance to FALSE *after* having set
"related-action", should undo the effects of having set
"related-action" in the first place (that would essentially make
the order of property settings more arbitrary).

This is a little spaghetti right now because, setting the related
action, causes the button to set label text on itself, setting the
label text causes a GtkLabel to be added to the button... (but unsetting
the label text of a button does not destroy the child GtkLabel to
my knowledge).
Comment 4 Matthias Clasen 2018-02-10 04:55:40 UTC
We're moving to gitlab! As part of this move, we are moving bugs to NEEDINFO if they haven't seen activity in more than a year. If this issue is still important to you and still relevant with GTK+ 3.22 or master, please reopen it and we will migrate it to gitlab.
Comment 5 Matthias Clasen 2018-04-14 23:59:44 UTC
As announced a while ago, we are migrating to gitlab, and bugs that haven't seen activity in the last year or so will be not be migrated, but closed out in bugzilla.

If this bug is still relevant to you, you can open a new issue describing the symptoms and how to reproduce it with gtk 3.22.x or master in gitlab:

https://gitlab.gnome.org/GNOME/gtk/issues/new