GNOME Bugzilla – Bug 675042
plugins/gtk+.xml.in: always store GtkButton [x|y]align properties
Last modified: 2012-05-04 19:25:19 UTC
gtk+ only set the alignment on the GtkButton child if the alignment has been explicitly set, so we always save the values of the [x|y]align properties.
Created attachment 213033 [details] [review] plugins/gtk+.xml.in: always store GtkButton [x|y]align properties
Yes, we only save properties if they are not on its default value. The save-always feature is only for properties that declares a default value in the parameter spec but have a different one in runtime. So why do you want to set GtkButton:[x|y]align properties to save always?¿
If you look at gtkbutton.c you can see that the alignment is only set on the child when (priv->align_set != 0), e.g. http://git.gnome.org/browse/gtk+/tree/gtk/gtkbutton.c#n1224. priv->align_set gets set to 1 in gtk_button_set_alignment which is called by the xalign/yalign property setters. The problem I'm having is with togglebuttons with draw_indicator=FALSE. Even though I set xalign to the default 0.5 the label get left aligned.
You should have started with that!, can you attach a glade file showing the bug? I created a tooglebutton which by default has draw_indicator=FALSE and the label is centered.
Created attachment 213240 [details] Testfile showing the problem The above glade file contains a GtkCheckButton which label is correctly horizontally centered when viewed in glade. But when you "preview" it the label is left-aligned. (You have to expand the window a bit horizontally to see it).
Ohh I see what you mean, now, why did not you mention checkbuttons before? The problem is that checkbutton set the halign value to 0, but if set it back to .5 (GtkButton default) it wont get saved! hmm we really need a way to override default values, in the mean time I set save-always but only in the checkbutton class
I also get the same problem using GtkRadioButton.
Right, its fixed in master. If you are not using glade master, I suggest you to set save always to xalign for radio and check buttons
Note, if I recall correctly, the 'radio' class derives from the 'check' class (hence the problem in both), so there should be no need to specify anything explicitly for the radio class (as the save-always attribute will be derived).