[Xfce4-commits] <thunar:master> Allow override Backspace as open-parent action (bug #5922).

Nick Schermer noreply at xfce.org
Fri Sep 28 19:38:01 CEST 2012


Updating branch refs/heads/master
         to b1599bc6b8fd64588468d88387e1ea20bcbe889d (commit)
       from 3ee371cfd06dcf78d7766e10cb462b1bcc422f46 (commit)

commit b1599bc6b8fd64588468d88387e1ea20bcbe889d
Author: Nick Schermer <nick at xfce.org>
Date:   Fri Sep 28 19:33:30 2012 +0200

    Allow override Backspace as open-parent action (bug #5922).
    
    If you don't want Backspace event result in a back action, but
    in a parent-folder action. You can set Backspace as an accelerator
    for the open-parent action, without conflicts.

 thunar/thunar-window.c |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/thunar/thunar-window.c b/thunar/thunar-window.c
index 0ab4b05..5908713 100644
--- a/thunar/thunar-window.c
+++ b/thunar/thunar-window.c
@@ -1036,10 +1036,34 @@ thunar_window_set_property (GObject            *object,
 static gboolean
 thunar_window_back (ThunarWindow *window)
 {
-  GtkAction *action;
+  GtkAction   *action;
+  GdkEvent    *event;
+  const gchar *accel_path;
+  GtkAccelKey  key;
 
   _thunar_return_val_if_fail (THUNAR_IS_WINDOW (window), FALSE);
 
+  /* check source event */
+  event = gtk_get_current_event ();
+  if (event != NULL
+      && event->type == GDK_KEY_PRESS)
+    {
+      action = thunar_gtk_ui_manager_get_action_by_name (window->ui_manager, "open-parent");
+      if (G_LIKELY (action != NULL))
+        {
+          /* check if the current event (back) is different then the open-parent
+           * accelerator. this way a user can override the default backspace action
+           * of back in open-parent, without backspace resulting in a back action
+           * if open-parent is insensitive in the menu */
+          accel_path = gtk_action_get_accel_path (action);
+          if (accel_path != NULL
+              && gtk_accel_map_lookup_entry (accel_path, &key)
+              && key.accel_key == ((GdkEventKey *) event)->keyval
+              && key.accel_mods == 0)
+            return FALSE;
+        }
+    }
+
   /* activate the "back" action */
   action = thunar_gtk_ui_manager_get_action_by_name (window->ui_manager, "back");
   if (G_LIKELY (action != NULL))


More information about the Xfce4-commits mailing list