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 436360 - support "image" property of GtkButton
support "image" property of GtkButton
Status: RESOLVED WONTFIX
Product: libglade
Classification: Deprecated
Component: gtk
2.6.x
Other All
: Normal enhancement
: ---
Assigned To: James Henstridge
James Henstridge
Depends on:
Blocks:
 
 
Reported: 2007-05-06 14:22 UTC by Jens Granseuer
Modified: 2007-07-30 22:24 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
add support for gtk_button_set_image (1.17 KB, patch)
2007-05-06 14:23 UTC, Jens Granseuer
rejected Details | Review

Description Jens Granseuer 2007-05-06 14:22:45 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>
Comment 1 Jens Granseuer 2007-05-06 14:23:31 UTC
Created attachment 87655 [details] [review]
add support for gtk_button_set_image
Comment 2 Johan (not receiving bugmail) Dahlin 2007-07-30 21:46:32 UTC
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
Comment 3 Jens Granseuer 2007-07-30 22:24:15 UTC
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.