[tbo] Disabled accel keys in text tool.



commit d81553244154238bb0d9007b0436b50f60a52792
Author: danigm <dani danigm net>
Date:   Sun Sep 26 23:40:20 2010 +0200

    Disabled accel keys in text tool.

 src/tbo-window.c |    4 ++++
 src/ui-menu.c    |   28 +++++++++++++++++++++++++---
 src/ui-menu.h    |    2 ++
 3 files changed, 31 insertions(+), 3 deletions(-)
---
diff --git a/src/tbo-window.c b/src/tbo-window.c
index 6216bc8..0ed91ca 100644
--- a/src/tbo-window.c
+++ b/src/tbo-window.c
@@ -307,6 +307,10 @@ void
 tbo_window_set_key_binder (TboWindow *tbo, gboolean keyb)
 {
     KEY_BINDER = keyb;
+    if (keyb)
+        tbo_menu_enable_accel_keys (tbo);
+    else
+        tbo_menu_disable_accel_keys (tbo);
 }
 
 void
diff --git a/src/ui-menu.c b/src/ui-menu.c
index b378d0e..68d8c11 100644
--- a/src/ui-menu.c
+++ b/src/ui-menu.c
@@ -36,6 +36,8 @@
 #include "tbo-object-base.h"
 
 static GtkActionGroup *MENU_ACTION_GROUP = NULL;
+static GtkAccelGroup *ACCEL = NULL;
+static gboolean ACCEL_SET = FALSE;
 
 void
 update_menubar (TboWindow *tbo)
@@ -306,7 +308,6 @@ static const GtkActionEntry tbo_menu_entries [] = {
 GtkWidget *generate_menu (TboWindow *window){
     GtkWidget *menu;
     GtkUIManager *manager;
-    GtkAccelGroup *accel;
     GError *error = NULL;
 
     manager = gtk_ui_manager_new ();
@@ -326,9 +327,30 @@ GtkWidget *generate_menu (TboWindow *window){
 
     menu = gtk_ui_manager_get_widget (manager, "/menubar");
 
-    accel = gtk_ui_manager_get_accel_group (manager);
-    gtk_window_add_accel_group (GTK_WINDOW (window->window), accel);
+    ACCEL = gtk_ui_manager_get_accel_group (manager);
+    gtk_window_add_accel_group (GTK_WINDOW (window->window), ACCEL);
+    ACCEL_SET = TRUE;
 
     return menu;
 }
 
+
+void
+tbo_menu_enable_accel_keys (TboWindow *tbo)
+{
+    if (ACCEL && !ACCEL_SET)
+    {
+        gtk_window_add_accel_group (GTK_WINDOW (tbo->window), ACCEL);
+        ACCEL_SET = TRUE;
+    }
+}
+
+void
+tbo_menu_disable_accel_keys (TboWindow *tbo)
+{
+    if (ACCEL && ACCEL_SET)
+    {
+        gtk_window_remove_accel_group (GTK_WINDOW (tbo->window), ACCEL);
+        ACCEL_SET = FALSE;
+    }
+}
diff --git a/src/ui-menu.h b/src/ui-menu.h
index 8dffe22..3d3d51f 100644
--- a/src/ui-menu.h
+++ b/src/ui-menu.h
@@ -25,5 +25,7 @@
 
 GtkWidget *generate_menu (TboWindow *window);
 void update_menubar (TboWindow *tbo);
+void tbo_menu_disable_accel_keys (TboWindow *tbo);
+void tbo_menu_enable_accel_keys (TboWindow *tbo);
 
 #endif



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