GNOME Bugzilla – Bug 112647
Add indicator-size style property for checkmenuitem
Last modified: 2011-02-04 16:12:26 UTC
Because gtk widgets call gtk_paint_check and gtk_paint_option directly, passing in a fixed size for the indicator, gtk engines cannot reliably scale these indicators. If they do, they have to explicitly override the size and probably clip mask that they were given, which is unlikely to be correct in all cases. Either gtk engines need to do this via gtkstyle (i.e. not passing in the desired actual checkbox size, but instead passing in the actual available area for the checkbox, and letting the engine decide how big to make the indicator) or else gtk+ itself needs to scale the size of the checkboxes and option buttons, i.e. passing larger checkboxes as the font size gets bigger (or adding a new gtkstyle param for indicator sizes). This is a significant accessibility bug.
Do you mean GtkCheckButton::indicator_size is not good enough?
Soeren: thanks, I had missed this feature since it's not documented in Gtk-Resource-Files.html at all, and there isn't a GTK_RC_TOKEN type for it in the docs. I will try this and see how it works for me, it sounds like the right fix. :-)
This works well for normal checkbuttons but not in menus. Is there something I can change in menus to fix this?
changing bug summary for now. Remaining issue seems to be menu-specific.
Thanks Owen. Any reason why this shouldn't just scale with the text requisition instead?
Apologies for spam... marking as GNOMEVER2.3 so it appears on the official GNOME bug list :)
The bug can be fixed with the following approach: Add support to gtkcheckmenuitem.c to handle indicator_size property and use this property value in drawing the indicator. We need to follow the gtkcheckbutton indicator_size property code. And later, change gnome-themes' gtkrc files, to have indicator_size property value set for GtkCheckMenuItem. Owen, Would highly appreciate if you can comment on the above approach. Although its unlikely that the changes go into next release of gtk+, it would be ideal if we could solidify the API/ABI of this change. So that this accessibility stopper can be fixed (locally) and the fix can later get into the soon-to-be-released version of gtk+. Thanks.
I have created a patch which adds indicator_size property to GtkCheckMenuItem. And used that property value in drawing the indicator. I will upload the patch soon. Note: The patch has been tested by adding indicator_size property value for GtkCheckMenuItem in gtkrc files under /usr/share/themes/*. These changes have to finally go to gnome-themes module. I will create a new bug against gnome-themes and upload a patch. This patch will go in once the gtk+ patch is accepted. For example, gtkrc file chnage will be like: --- gtkrc.org Mon Dec 29 15:47:35 2003 +++ gtkrc Fri Jan 16 15:22:27 2004 @@ -32,6 +32,7 @@ style "default" GtkTextView::cursor_color = "#00cccc" GtkEntry::cursor_aspect_ratio = 0.1 GtkCheckButton::indicator_size = 18 + GtkCheckMenuItem::indicator_size = 16 NautilusIconContainer::frame_text = 1 GtkExpander::expander-size = 24 GtkExpander::expander-spacing = 8
Created attachment 23434 [details] [review] proposed patch to add indicator_size property
Raised bug#131659 against gnome-themes to add indicator_size property in gtkrc files.
The patch is a start, but it is incomplete. You also have to ensure that the menu item allocates enough room to draw the check. See the attached screenshot for what I'm talking about.
Created attachment 23883 [details] too little space
GtkMenuItem already has "toggle_spacing" property installed. And the default value for the toggle_spacing is 5. So, after changing this property value (GtkCheckMenuItem::toggle_spacing) in gtkrc files, I did not see the problem. For example, I have seen the above problem with HighContrastLargePrint theme. The gtkrc file changes I have made for this theme are: --- HighContrastLargePrint/gtk-2.0/gtkrc.org Tue Feb 10 11:43:53 2004 +++ HighContrastLargePrint/gtk-2.0/gtkrc Tue Feb 10 11:27:39 2004 @@ -36,6 +36,8 @@ style "default" GtkEntry::cursor_aspect_ratio = 0.1 EelEditableLabel::cursor_aspect_ratio = 0.1 GtkCheckButton::indicator_size = 18 + GtkCheckMenuItem::indicator_size = 18 + GtkCheckMenuItem::toggle_spacing = 9 NautilusIconContainer::frame_text = 1 GtkExpander::expander-size = 24 GtkExpander::expander-spacing = 8 Please see the attached screenshot after changes to the gtkrc file. Could you please try adding toggle_spacing parameter value to the themes' gtkrc files on your system and see if it resolves the problem.
Created attachment 24260 [details] PNG file showing space between indicator and label
No, that is not a solution. The proposed GtkCheckMenuItem:: indicator_size style property must not depend on suitable values of other, unrelated style properties. How would you document that ? "If you increaes the size of ::indicator_size, you may also have to increase the value of ::toggle_spacing far enough so that the themes you care about don't draw overlapping indicators" ? That doesn't fly.
Matthias, Thanks for the update. Can I introduce GtkCheckMenuItem::indicator_spacing style property, similar to GtkCheckButton::indicator_spacing, to take care of the checkmenu item spacing ? I think this style property is a related one to ::indicator_size. Else, could you please suggest a better way of doing this.
What happens if you increase GtkCheckButton::indicator_size without increasing GtkCheckButton::indicator_spacing ? I think the button still allocates enough space to accomodate the larger indicator, and I would expect menuitems to behave similarly.
docs/widget_geometry.txt has a diagram showing exactly how the various parameters work for GtkCheckButton which may be a useful reference.
Matthias, Right, GtkCheckButton is allocating enough space if GtkCheckButton::indicator_size is increased without increasing the GtkCheckButton::indicator_spacing. I guess CheckButton is taking care of this by handling size_request and size_allocate signals to allocate size based on indicator_size and indicator_spacing. A default value of 2 is used for GtkCheckButton::indicator_spacing property, irrespective of indicator_size. If GtkCheckButton::indicator_spacing is made 0, then there is no space between indicator and label for themes like Simple, Crux, HighContrast, HighContrastInverse, HighContrastLargePrint, HighContrastLargePrintInverse etc. Should I be doing something similar for GtkCheckMenuItem to handle size_request and size_allocate, and use the new indicator_size property in those functions.
It might be enough to replace the hardcoded CHECK_TOGGLE_SIZE in gtk_check_menu_item_toggle_size_request() by the value of the style property.
I think it works fine if I replace hard-coded CHECK_TOGGLE_SIZE with the GtkCheckMenuItem::indicator_size value. I will attach a screenshot with this change. Please check if the spacing is fine. If so, I will upload the revised patch.
Created attachment 24338 [details] PNG showing the space after removing the toggle_check_size hardcoding
Looks good, lets see the patch.
Created attachment 24438 [details] [review] Patch after replacing hard coded toggle_size with indicator_size property value.
Hmm, I still see overlapping indicators if I make the indicator_size larger than the height of a typical menu item. I need something like the following patch to make it work (alternatively, one could add a gtk_check_menu_item_size_request() to enforce that the requested height is always at least as large as the indicator_size)
Created attachment 24503 [details] [review] make the menu items high enough