GNOME Bugzilla – Bug 436360
support "image" property of GtkButton
Last modified: 2007-07-30 22:24:15 UTC
Currently, if you want a custom GtkButton with an image (ie. non-stock image and/or label) you have to use the standard container facilities. This leads to unnecessary copmplex layouts and additionally makes such buttons ignore the gtk-button-images xsetting, for example. As a work-around you can set the image through code instead of through glade, but that's far from nice. The following patch adds support to libglade to simply use an internal child image using gtk_button_set_image (). Prior to tha patch you had to do it like this: <widget class="GtkButton" id="some_button"> <property name="visible">True</property> ... <child> <widget class="GtkAlignment" id="alignment"> <child> <widget class="GtkHBox" id="hbox"> <property name="visible">True</property> <property name="homogeneous">False</property> <property name="spacing">2</property> <child> <widget class="GtkImage" id="some_image"> <property name="visible">True</property> <property name="stock">gtk-revert-to-saved</property> <property name="icon_size">4</property> </widget> </child> <child> <widget class="GtkLabel" id="label"> <property name="visible">True</property> <property name="label" translatable="yes">_Awesome</property> ... </widget> </child> </widget> </child> </widget> </child> </widget> With the patch applied it becomes much simpler and works correctly with the xsetting: <widget class="GtkButton" id="some_button"> <property name="visible">True</property> <property name="label" translatable="yes">_Awesome</property> ... <child internal-child="image"> <widget class="GtkImage" id="some_image"> <property name="visible">True</property> <property name="stock">gtk-bla</property> <property name="icon_size">4</property> </widget> </child> </widget>
Created attachment 87655 [details] [review] add support for gtk_button_set_image
Comment on attachment 87655 [details] [review] add support for gtk_button_set_image This patch is not necessary you can use GtkButton::image to point to a GtkImage widget
Let's not leave this hanging around, then. It would still be nice if GtkBuilder supported this without jumping through the extra hoop of defining additonal out-of-tree widgets.