[epiphany] ephy-window: Fix the accelerators for back/forward in RTL



commit 1ff07bb8fb954d50561164e4060f4b597a5dea4e
Author: Yosef Or Boczko <yoseforb src gnome org>
Date:   Thu May 8 13:58:40 2014 +0300

    ephy-window: Fix the accelerators for back/forward in RTL
    
    http://bugzilla.gnome.org/show_bug.cgi?id=729726

 src/ephy-window.c |   38 +++++++++++++++++++++++++++++++++-----
 1 files changed, 33 insertions(+), 5 deletions(-)
---
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 0b279fe..597a0b7 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -294,11 +294,7 @@ static const struct
         * when NumLock is on they are KP_9/3 and with NumLock and Control+Shift
         * They're KP_PageUp/Down again!
         */
-       { GDK_KEY_Left,         GDK_MOD1_MASK /*Alt*/,  "NavigationBack",       TRUE },
-       { GDK_KEY_KP_Left,      GDK_MOD1_MASK /*Alt*/,  "NavigationBack",       TRUE },
        { GDK_KEY_KP_4,         GDK_MOD1_MASK /*Alt*/,  "NavigationBack",       TRUE },
-       { GDK_KEY_Right,        GDK_MOD1_MASK /*Alt*/,  "NavigationForward",    TRUE },
-       { GDK_KEY_KP_Right,     GDK_MOD1_MASK /*Alt*/,  "NavigationForward",    TRUE },
        { GDK_KEY_KP_6,         GDK_MOD1_MASK /*Alt*/,  "NavigationForward",    TRUE },
        { GDK_KEY_KP_Page_Up,   GDK_CONTROL_MASK,       "TabsPrevious",         FALSE },
        { GDK_KEY_KP_9,         GDK_CONTROL_MASK,       "TabsPrevious",         FALSE },
@@ -323,7 +319,17 @@ static const struct
        { XF86XK_ZoomOut,       0,                      "ViewZoomOut",          FALSE }
        /* FIXME: what about ScrollUp, ScrollDown, Menu*, Option, LogOff, Save,.. any others? */
 #endif /* HAVE_X11_XF86KEYSYM_H */
-};
+}, navigation_keybindings_ltr [] = {
+       { GDK_KEY_Left,         GDK_MOD1_MASK /*Alt*/,  "NavigationBack",       TRUE },
+       { GDK_KEY_KP_Left,      GDK_MOD1_MASK /*Alt*/,  "NavigationBack",       TRUE },
+       { GDK_KEY_Right,        GDK_MOD1_MASK /*Alt*/,  "NavigationForward",    TRUE },
+       { GDK_KEY_KP_Right,     GDK_MOD1_MASK /*Alt*/,  "NavigationForward",    TRUE }
+}, navigation_keybindings_rtl [] = {
+       { GDK_KEY_Left,         GDK_MOD1_MASK /*Alt*/,  "NavigationForward",    TRUE },
+       { GDK_KEY_KP_Left,      GDK_MOD1_MASK /*Alt*/,  "NavigationForward",    TRUE },
+       { GDK_KEY_Right,        GDK_MOD1_MASK /*Alt*/,  "NavigationBack",       TRUE },
+       { GDK_KEY_KP_Right,     GDK_MOD1_MASK /*Alt*/,  "NavigationBack",       TRUE }
+}, *navigation_keybindings_rtl_ltr;
 
 #define SETTINGS_CONNECTION_DATA_KEY   "EphyWindowSettings"
 
@@ -808,6 +814,9 @@ ephy_window_key_press_event (GtkWidget *widget,
        guint modifier = event->state & gtk_accelerator_get_default_mod_mask ();
        guint i;
 
+       navigation_keybindings_rtl_ltr = gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL ?
+                                        navigation_keybindings_rtl : navigation_keybindings_ltr;
+
        /* In an attempt to get the mozembed playing nice with things like emacs keybindings
         * we are passing important events to the focused child widget before letting the window's
         * base handler see them. This is *completely against* stated gtk2 policy but the 
@@ -878,6 +887,25 @@ ephy_window_key_press_event (GtkWidget *widget,
                }
        }
 
+       for (i = 0; i < G_N_ELEMENTS (navigation_keybindings_rtl); i++)
+       {
+               if (event->keyval == navigation_keybindings_rtl_ltr[i].keyval &&
+                   modifier == navigation_keybindings_rtl_ltr[i].modifier)
+               {
+                       GtkAction * action = gtk_action_group_get_action
+                               (navigation_keybindings_rtl_ltr[i].fromToolbar ?
+                                       priv->toolbar_action_group :
+                                       priv->action_group,
+                               navigation_keybindings_rtl_ltr[i].action);
+                       if (gtk_action_is_sensitive (action))
+                       {
+                               gtk_action_activate (action);
+                               return TRUE;
+                       }
+                       break;
+               }
+       }
+
        return GTK_WIDGET_CLASS (ephy_window_parent_class)->key_press_event (widget, event);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]