Allow change of magic-spacebar accelerators
I would like to configure Evolution so that in the mail message list, hitting the BackSpace key deletes the current message. There are currently two problems with this:
- If one adds the line
(gtk_accel_path "<Actions>/mail/mail-delete" "BackSpace")
to .config/evolution/accels, it does not change the behavior of Evolution, unlike for example(gtk_accel_path "<Actions>/mail/mail-delete" "minus")
which does cause the minus key to delete the current message.
The difficulty appears to be that the following code in the function mail_shell_view_process_key_press_event() in modules/mail/e-mail-shell-view-private.c:
switch (event->keyval) {
case GDK_KEY_space:
action = ACTION (MAIL_SMART_FORWARD);
break;
case GDK_KEY_BackSpace:
action = ACTION (MAIL_SMART_BACKWARD);
break;
grabs and executes the "opposite" of the "magic space" when the BackSpace key is hit, regardless of any accels that may be in effect. (I can verify that this is the responsible code by replacing "BackSpace" with "minus" above; then minus executes the opposite magic space behavior, and I can no longer change the behavior of minus with an accel.)
It would seem to me it would be a more uniform method for providing the magic space and opposite magic space functionalities if they could be made Actions in the sense of the gtk_accels, and bound to their respective keys via accels. Then they could be rebound as the user desires just like any of the other accels. Unfortunately, I am not familiar enough with gtk to know how to do this, so I don't have a pull request to offer that would implement this.
- There is a further difficulty: if I comment out the last three lines in the code quote above, then the line mentioned above added to the accels config file does in fact cause BackSpace to delete the current message. However, the accel is then overactive in the following sense: when I am in the middle of typing in the search bar, hitting BackSpace does not delete the previous character in the search bar entry as one would expect, but ratherit still deletes the current message, which is of course not the desired behavior in this context. The accels should be enhanced to differentiate between the context of the message list being active vs the search bar being focused. Again, unfortunately I don't have detailed enough knowledge of gtk to be able to make a pull request for this.
I can only work around both of the issues above by changing the last three lines in the code quote above to:
case GDK_KEY_BackSpace:
if (gtk_widget_is_focus(e_shell_searchbar_get_search_entry(searchbar)))
return FALSE;
action = ACTION (MAIL_DELETE);
break;
(and not having an accel for BackSpace at all) but this simply hardcodes a different behavior for BackSpace, so I would not recommend this as a change to the general Evolution codebase at all. I am simply mentioning it as an illustration of the behavior I am trying to achieve and one way to do it. (Note that in addition to the above code, I have to declare the variable searchbar and assign it with searchbar = e_mail_shell_content_get_searchbar (E_MAIL_SHELL_CONTENT (shell_content));
earlier in the function; also the source file e-shell-searchbar.h did not actually provide an e_shell_searchbar_get_search_entry() function, so I created one closely modeled on e_shell_searchbar_get_search_box() function, simply not taking the parent of the entry widget as done in ..get_search_box().)
It would be very much appreciated if someone more knowledgeable about how gtk accels work would make it possible to rebind BackSpace if the user does not want it to have the opposite of magic space effect, and make it so that such a binding does not bleed over to be in effect when the searchbar is in focus. Thanks so much.