1
0
ソースを参照

Redo accel group when modifier changes.

Signed-off-by: Bradley Smith <[email protected]>
Bradley Smith 15 年 前
コミット
7e4aa8c1f8
3 ファイル変更30 行追加3 行削除
  1. 23 0
      src/mssh-gconf.c
  2. 4 3
      src/mssh-window.c
  3. 3 0
      src/mssh-window.h

+ 23 - 0
src/mssh-gconf.c

@@ -1,4 +1,5 @@
 #include <vte/vte.h>
+#include <gdk/gdkkeysyms.h>
 
 #include "mssh-gconf.h"
 #include "mssh-window.h"
@@ -169,5 +170,27 @@ void mssh_gconf_notify_modifier(GConfClient *client, guint cnxn_id,
 
     value = gconf_entry_get_value(entry);
 
+    gtk_accel_group_disconnect_key(window->accel, GDK_Up,
+        window->modifier);
+    gtk_accel_group_disconnect_key(window->accel, GDK_Down,
+        window->modifier);
+    gtk_accel_group_disconnect_key(window->accel, GDK_Left,
+        window->modifier);
+    gtk_accel_group_disconnect_key(window->accel, GDK_Right,
+        window->modifier);
+
     window->modifier = gconf_value_get_int(value);
+
+    gtk_accel_group_connect(window->accel, GDK_Up, window->modifier,
+        GTK_ACCEL_VISIBLE, g_cclosure_new(
+        G_CALLBACK(mssh_window_focus), window, NULL));
+    gtk_accel_group_connect(window->accel, GDK_Down, window->modifier,
+        GTK_ACCEL_VISIBLE, g_cclosure_new(
+        G_CALLBACK(mssh_window_focus), window, NULL));
+    gtk_accel_group_connect(window->accel, GDK_Left, window->modifier,
+        GTK_ACCEL_VISIBLE, g_cclosure_new(
+        G_CALLBACK(mssh_window_focus), window, NULL));
+    gtk_accel_group_connect(window->accel, GDK_Right, window->modifier,
+        GTK_ACCEL_VISIBLE, g_cclosure_new(
+        G_CALLBACK(mssh_window_focus), window, NULL));
 }

+ 4 - 3
src/mssh-window.c

@@ -113,9 +113,8 @@ static gboolean mssh_window_entry_focused(GtkWidget *widget,
     return FALSE;
 }
 
-static gboolean mssh_window_focus(GtkWidget *widget,
-    GObject *acceleratable, guint keyval, GdkModifierType modifier,
-    gpointer data)
+gboolean mssh_window_focus(GtkWidget *widget, GObject *acceleratable,
+    guint keyval, GdkModifierType modifier, gpointer data)
 {
     MSSHWindow *window = MSSH_WINDOW(data);
     GtkWidget *focus;
@@ -446,6 +445,8 @@ static void mssh_window_init(MSSHWindow* window)
         GTK_ACCEL_VISIBLE, g_cclosure_new(
         G_CALLBACK(mssh_window_focus), window, NULL));
 
+    window->accel = accel;
+
     gtk_window_add_accel_group(GTK_WINDOW(window), accel);
 }
 

+ 3 - 0
src/mssh-window.h

@@ -24,6 +24,7 @@ typedef struct
     GtkWidget *table;
     GtkWidget *server_menu;
     GtkWidget *global_entry;
+    GtkAccelGroup *accel;
     GArray *terminals;
     char **env;
     int columns;
@@ -46,6 +47,8 @@ void mssh_window_start_session(MSSHWindow* window, char **env,
     GArray *hosts, long cols);
 void mssh_window_relayout(MSSHWindow *window);
 void mssh_window_session_closed(MSSHTerminal *terminal, gpointer data);
+gboolean mssh_window_focus(GtkWidget *widget, GObject *acceleratable,
+    guint keyval, GdkModifierType modifier, gpointer data);
 
 G_END_DECLS