replace hardcoded keybindings with accelerators
I don't think this has been discussed before. In many ways it is an internal code related thing, but it will also benefit users who wish to change the keybindings. And they can also be added easily to a menu, like any other action entry.
I made a POC MR on my own fork, in that I replace the default keybindings that will spawn the context menu for inside the view (Menu
, Shift+F10
) and the keybindings that opens the location bar at a specific location, Home (~
) and root (/
).
As it is now, the ~
and /
are handled by view specific event listeners.
https://gitlab.xfce.org/xfce/thunar/-/blob/master/thunar/thunar-abstract-icon-view.c#L205
https://gitlab.xfce.org/xfce/thunar/-/blob/master/thunar/thunar-details-view.c#L226
That call functions:
thunar_abstract_icon_view_key_press_event()
and thunar_details_view_key_press_event()
https://gitlab.xfce.org/xfce/thunar/-/blob/master/thunar/thunar-abstract-icon-view.c#L579 https://gitlab.xfce.org/xfce/thunar/-/blob/master/thunar/thunar-details-view.c#L643
these two functions are more or less identical, and at first I tried "merging" them into standard-view.c. That is totally doable as well, however standard-view.c also have a _key_pressed_event()
this is where Menu
and Shift+F10
is tested.
https://gitlab.xfce.org/xfce/thunar/-/blob/master/thunar/thunar-standard-view.c#L2381
So my initial version where i combined the three functions into one, still looked really messy, and that's where i thought to try and see how it would work if i instead added the keys as Action_entries.
and it just werked! I could then remove the signals, and corresponding functions without any change in behavior (that I have noticed).
I think the reason it was implemented as it currently is (hardcoded keypress signal stuff) was to make sure that these keys had priority over the look-ahead search, and I'm guessing that the ActionEntries stuff worked different back then, maybe wasn't even present.
I think this is something that will benefit development of both #279 (closed) and #305 (since now a different function can easily be used when context menu is spawned with a key).
There are some more hardcoded keys (I know there is a thunar-window.c context menu thing).
A slightly different one is Ctrl+f
which is hardcoded in GTK and Exo on the treeview/iconview widgets, it starts the look-ahead search. I have found a way to do this here too, but that is so different it should be it's own issue.