GNOME Bugzilla – Bug 131177
Accelerators only work for actions which have menu entries
Last modified: 2014-08-30 05:00:04 UTC
Accelerators only work for actions which have menu entries. See the attached test program. There are toolbar entries for bold and italic. Bold and italic both have accelerators. There's a menu command for bold, but not for italic. bold can be toggled through its accelerator, italic cannot.
Created attachment 23240 [details] Test program
This is with CVS HEAD
Error Between Chair And Keyboard. This works if I add <accelerator name="italic" action="italic">.
Hmm. On further reflection, I think this is a bug. Does it ever make sense to display a toolbar button with an accelerator, but not enable the accelerator?
The toolbar button doesn't "have" an accelerator, at least it doesn't give any visual hints about it. I believe that is the rationale for not enabling accelerators on actions whose only proxies are toolitems. But then, toolitem-only actions are kind of broken anyway. The idea of a toolbar is to give quick access to a small number of important menu items, isn't it ? Office applications have certainly perverted that idea...
Take the "Bold" example. Gnumeric has no menu command for bold, you can use the toolbar button, the accelerator or the format dialog, which *is* available from the menus. I hardly think that's perverting the idea.
Created attachment 94727 [details] Test for toggle tool items I don't know if its the same issue. The attached test programm creatas a toolbar with two toolitems - a play toggle button and a stop button. I've tried various ways to add accelerators. First I hit a gtkbug when trying to use an accel-path (it asserts). This is bad as I would like to make the accelerators changable and that requires this method. Second issue is that the accelerator seems to only invoke the closure but not the action on the widget. For a normal button its fine, but for the toggle button it fails, as the button does not get toggled. In the test programm, using the buttons with the mouse works. Using play with the mouse and stop with accelerator works, but triggering play with accelrator fails.
more details: pressing accelerator: Gtk-Message: GtkToggleToolButton::clicked : 0,0 klicking the button: Gtk-Message: GtkToggleButton::clicked : 0 Gtk-Message: GtkToggleToolButton::toggled : 0,1 Gtk-Message: GtkToggleToolButton::clicked : 1,1 the value is the ->active field. for toogl_tool_button is the one of itself and the child. That means the accelerator is triggering the click on the button itself and this is not synced wit the child. A real click would trigger the click on the child and sync the tool_button.
Created attachment 94814 [details] updated test for toggle tool items
Created attachment 94815 [details] [review] toggle the toggle button when pressing the accelerator This is a preliminary patch, that also add some g_message() to be see whats going on. If what the patch does sounds acceptable, I will apply the following changes before ommiting: * remove g_message() * cache signal_id for gtktoggletoolbutton::button_clicked() and use that for block/unblock()
Comment on attachment 94815 [details] [review] toggle the toggle button when pressing the accelerator Blocking signals like this is almost never a good thing to do. I think it would be better to add a separate ::activate signal.
GtkAction has been deprecated