[Xfce4-commits] <terminal:master> Catch keybindings from previous and next tab when cycling is disabled (bug #3715).

Nick Schermer noreply at xfce.org
Sat Oct 10 17:50:01 CEST 2009


Updating branch refs/heads/master
         to 47ddbb38da0030ebc279e61b6a2414448d32126e (commit)
       from 98404d874aef480c8ff47edb61bd666396bb290b (commit)

commit 47ddbb38da0030ebc279e61b6a2414448d32126e
Author: Nick Schermer <nick at xfce.org>
Date:   Sat Oct 10 17:39:51 2009 +0200

    Catch keybindings from previous and next tab when cycling is disabled (bug #3715).
    
    Maybe not the best solution, therefore only activated for the next
    and previous tab actions. The idea is that if we receive an accel-activate
    event from the accel group after gtk has checked the group, we
    check if it is the same accelerator of the insensitive {next,prev}-tab, if
    so we return TRUE, so no odd characters are printed in vte with
    the default <Ctrl>+{Pageup,Pagedown} shortcuts.

 terminal/terminal-window.c |   37 +++++++++++++++++++++++++++++++++++++
 1 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/terminal/terminal-window.c b/terminal/terminal-window.c
index 895a1d0..672c8c3 100644
--- a/terminal/terminal-window.c
+++ b/terminal/terminal-window.c
@@ -91,6 +91,11 @@ static void            terminal_window_set_size_force_grid           (TerminalWi
                                                                       TerminalScreen         *screen,
                                                                       gint                    force_grid_width,
                                                                       gint                    force_grid_height);
+static gboolean        terminal_window_accel_activate                (GtkAccelGroup          *accel_group,
+                                                                      GObject                *acceleratable,
+                                                                      guint                   accel_key,
+                                                                      GdkModifierType         accel_mods,
+                                                                      TerminalWindow         *window);
 static void            terminal_window_update_actions                (TerminalWindow         *window);
 static void            terminal_window_rebuild_gomenu                (TerminalWindow         *window);
 static void            terminal_window_notebook_page_switched        (GtkNotebook            *notebook,
@@ -340,6 +345,8 @@ terminal_window_init (TerminalWindow *window)
 
   accel_group = gtk_ui_manager_get_accel_group (window->ui_manager);
   gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
+  g_signal_connect_after (G_OBJECT (accel_group), "accel-activate",
+      G_CALLBACK (terminal_window_accel_activate), window);
 
   vbox = gtk_vbox_new (FALSE, 0);
   gtk_container_add (GTK_CONTAINER (window), vbox);
@@ -651,6 +658,36 @@ terminal_window_set_size_force_grid (TerminalWindow *window,
 
 
 
+static gboolean
+terminal_window_accel_activate (GtkAccelGroup   *accel_group,
+                                GObject         *acceleratable,
+                                guint            accel_key,
+                                GdkModifierType  accel_mods,
+                                TerminalWindow  *window)
+{
+  GtkAction   *action;
+  const gchar *names[] = { "prev-tab", "next-tab" };
+  guint        n;
+  GtkAccelKey  key;
+
+  for (n = 0; n < G_N_ELEMENTS (names); n++)
+    {
+      /* pretend we handled the accelerator if the event matches one of
+       * the insensitive actions, so we don't send weird key events to vte
+       * see http://bugzilla.xfce.org/show_bug.cgi?id=3715 */
+      action = gtk_action_group_get_action (window->action_group, names[n]);
+      if (!gtk_action_is_sensitive (action)
+          && gtk_accel_map_lookup_entry (gtk_action_get_accel_path (action), &key)
+          && key.accel_key == accel_key
+          && key.accel_mods == accel_mods)
+        return TRUE;
+    }
+
+  return FALSE;
+}
+
+
+
 static void
 terminal_window_update_actions (TerminalWindow *window)
 {



More information about the Xfce4-commits mailing list