GNOME Bugzilla – Bug 70961
Extension to change alignment of stock image/labels in gtkbuttons
Last modified: 2011-02-04 16:12:26 UTC
The current code hard codes stock icons as being centered within the button. This is unpleasant when aligning button. There are 2 simple solutions 1) Add stock_[xy]_alignment properties to gtkbutton. 2) Add a gtkbutton_get_stock_alignment The former is obviously more controlled than the later. Would either patch be accepted ? are there any preferences for which approach to take ?
http://mail.gnome.org/archives/gtk-devel-list/2002-February/msg00128.html
Here is a patch which adds stock_xalign plus getter and setter.
Created attachment 18047 [details] [review] stock alignment
* Big-picture-question; it seems a bit weird to me and probably to users that this property applies to stock items in particular, which don't seem on the face of it different than labels. It would be a bit hacky to implement, but maybe we should just have ::xalign ::yalign properties that magically hook up correctly if GTK_IS_MISC() or GTK_IS_ALIGNMENT() bin->child? (Or maybe they only hook up when GTK+ creates the immediate child and not in other cases; that would be easier to implement) * If the above isn't followed, then I think the text that appears in multiple places "horizontal alignment of the stock item" needs improvement. What is the stock item? Stock items aren't GUI objects. I'd say "the horizontal alignment of the stock image and label" or something like that. * I'd put the #define and the private structure typedef in the C file, not the H file. * IMO assigning priv variables at top of function is cleaner, rather than doing them where they are needed. (Referring in particular to gtk_button_init()) * I think the extra complexity to change the align of the alignment on the fly rather than reconstructing is worth it. It seems to me bad to have: gtk_button_new_from_stock() gtk_button_set_stock_xalign() create-destroy-create 3 widgets.
Here is a new patch which does things more in the way you proposed. It compiles, but I haven't tested it. Does gtk_button_add() look correct ?
Created attachment 18416 [details] [review] button child alignment
I've tested the patch now, and since it works fine, I went ahead and committed it.