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 566733 - Add GIcon to GtkAction, GtkToolButton
Add GIcon to GtkAction, GtkToolButton
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
2.15.x
Other All
: Normal enhancement
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2009-01-06 06:27 UTC by A. Walton
Modified: 2009-01-08 05:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
the patch (9.15 KB, patch)
2009-01-06 06:27 UTC, A. Walton
needs-work Details | Review
v2 (14.96 KB, patch)
2009-01-07 03:59 UTC, A. Walton
none Details | Review

Description A. Walton 2009-01-06 06:27:13 UTC
Following is a patch to do just that. This was mentioned as necessary in the email thread here: http://mail.gnome.org/archives/gtk-devel-list/2008-January/msg00056.html But it was not picked up for the 2.14 cycle. Incidentally had to add GIcon support to GtkToolButton as necessary for GtkAction.
Comment 1 A. Walton 2009-01-06 06:27:41 UTC
Created attachment 125831 [details] [review]
the patch
Comment 2 Matthias Clasen 2009-01-06 16:57:11 UTC
There is some aspects here that need to be thought through

- This doesn't help for the ActionEntry apis we have. Not much that can be done there, though, and we already hack around this with the icon_name addition to GtkAction.

- Something needs to be done about the several alternative ways to specify icons here. What happens if stock_id, icon_name and gicon are all specified ? The current code seems to prefer the stock_id over the icon name...
Comment 3 A. Walton 2009-01-07 03:59:26 UTC
Created attachment 125897 [details] [review]
v2

-) The icon entry code probably complicates things, but otherwise the same strategy should be usable in both cases.

-) The GtkToolButton code has this to say on the subject: 
"  if the tool button has an icon_widget, then that widget
   will be used as the icon. Otherwise, if the tool button
   has a stock id, the corresponding stock icon will be
   used. Otherwise, if the tool button has an icon name,
   the corresponding icon from the theme will be used.
   Otherwise, the tool button will not have an icon."

Discarding the icon_widget part not applicable to GtkAction, similar priority is drawn for us. Stock ID has to have highest priority unless we had something like GtkStockIcon since the stock icons also have automatic labels and actions associated with them. Logically, it seems GIcon should come next, as we have GThemedIcon which provides the same functionality as icon-name but is more generic to include other icon sources.
Comment 4 A. Walton 2009-01-07 11:17:27 UTC
Okay so apparently I was really asleep when I wrote my last comment last night, and didn't realize that the action (not icon...) entry structs were actually public and had no padding, so there really isn't anything at all to be done there that isn't terribly hackish. (For some reason I was thinking we could just tack on the GIcon and handle it the same way as the icon-name is passed around, not exactly sure how I came to that conclusion...)

Pretty ugly situation to be in.
Comment 5 Matthias Clasen 2009-01-08 05:40:37 UTC
For now I have refrained from adding new api, and just added a GtkAction::gicon 
property. GtkToolButton is supported via its existing icon_widget api.

        * gtk/gtkaction.c: Add a ::gicon property to GtkAction and set the
        icon from it if specified. The stock icon is preferred if a stock id
        is given. Based on a patch by A. Walton