GNOME Bugzilla – Bug 143924
'Show trailing zeroes' option cannot be selected
Last modified: 2004-12-22 21:47:04 UTC
1. Launch Programs->Accessories->Calculator 2. Click on View->Basic Mode. 3. Click on View. Actual Results: The option 'Show Trailing Zeroes' cannot be selected using the mouse. Using the keyboard, typing CTRL+T enables this option. Expected Results: The option 'Show Trailing Zeroes' should be enabled for selecting using a mouse. How often does this happen? Always Additional Information: This problem is seen only in Basic/Financial mode. I have found that the option can be re-enabled as follows: - Do a calculation which results in an error ( e.g: divide by zero ) - Click on 'Clr' to re-enable the option. Now it can be selected/deselected using a mouse. Once re-enabled, switching to Scientific mode and back to Basic, would again disable this option.
Bug #108226 is the bug where the inclusion of the "Show Trailing Zeroes" menu item was added. The assumption was the this should only be available to "power users". In hindsight, I think this option should always be active (default: not ticked) in all three modes (Basic, Financial and Scientific) and it should be up to the user to decide whether they want it. I've cc:'ed my HCI guy on this, to get his input.
I guess the question to answer here is what's the use case for enabling trailing zeroes in basic (or financial) mode, given that there's no way to set the accuracy in those modes anyway. The reporter doesn't say why they wanted to do it. Either way, the fact that Ctrl-T currently works when its menu item is disabled is certainly a bug, though-- disabling a menu item should disable its keyboard shortcut, too.
Here's what I plan to do. We made the decision that you shouldn't be able to set trailing zeroes in Basic or Financial modes, so I need to fix the following two problems: 1/ Control-T shouldn't work in Basic or Financial modes. 2/ Generating an "Error", then clicking on Clr shouldn't active the "Show Trailing Zeroes" menu item if you are in Basic or Financial modes.
Sounds reasonable to me.
Created attachment 28607 [details] Fix for the second part of the problem. I've attached a fix for the second part of the problem. The first part of the problem (the fact that Control-t works even though the menu item is grayed out), would appear to be a problem with the gtk_ui_manager.
I've checked in the fix for the second part to CVS HEAD (bumping the version number to 4.4.12 in configure.in). I've added Matthias to the cc: for this bug, for his comments on whether the fact that Control-t works (as the keyboard accelerator for the inactive menu item) is a gtk_ui_manager() or a gtk_action bug.
I'm transferring this bug to gtk+/uimanager. I believe it's a bug in the gtk_ui_manager or gtk_action. Matthias, here's a simple way for you to test it. I made the following change to: .../gtk+-2.4.1/demos/gtk-demo/ui_manager.c --- ui_manager.c.orig 2004-06-14 09:23:45.754734000 -0700 +++ ui_manager.c 2004-06-14 09:26:14.364525000 -0700 @@ -195,6 +195,9 @@ do_ui_manager (GtkWidget *do_widget) g_error_free (error); } + gtk_widget_set_sensitive(gtk_ui_manager_get_widget(ui, + "/MenuBar/FileMenu/Quit"), FALSE); + box1 = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (window), box1); Now if you startup gtk-demo, select the uimanager demo, you'll see that the Quit menu entry in the File menu in the menubar is inactive. Yes, typing "Control-q" still activates it.
Widgets obtained by gtk_ui_manager_get_widget() are proxies for actions and derive their visibility and sensitivity from that of their action. You shouldn't directly modify the visibility or sensitivity of a proxy. Use g_object_set (action, "sensitive", FALSE, NULL) instead
Hmmm. I can (and will) do that - thanks, but surely if it lets me do the change visually using gtk_widget_set_sensitive() then shouldn't it also do the [in]sensitivity of the action, especially as the "old" way of doing this (with GtkItemFactory) worked that way?
Okay, I just tried (I think) what you suggested. I made the following change to the uimanager gtk-demo example: --- ui_manager.c.orig 2004-06-14 09:23:45.754734000 -0700 +++ ui_manager.c 2004-06-14 09:56:05.747405000 -0700 @@ -195,6 +195,9 @@ do_ui_manager (GtkWidget *do_widget) g_error_free (error); } + g_object_set(gtk_ui_manager_get_widget(ui, + "/MenuBar/FileMenu/Quit"), FALSE, NULL); + box1 = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (window), box1); I still see exactly the same behaviour. The menu item is inactive, but Control-Q is still seen and actioned. What am I doing wrong?
You have to set the property on the action, not on the widget
Got it. Thanks, it's working fine. I'll take the bug back.
Changes checked into CVS HEAD. Version number in configure.in bumped to 4.4.13. Matthias, thanks for your help.