[Xfce4-commits] <terminal:master> Disable mnemonics in GtkSettings (bug #5714).
Nick Schermer
nick at xfce.org
Mon Aug 31 09:04:01 CEST 2009
Updating branch refs/heads/master
to 8a5ee0f30d8ca1f093e798a2635332f78b742150 (commit)
from 94320f13ea0695a357f5544cad259cb98112a330 (commit)
commit 8a5ee0f30d8ca1f093e798a2635332f78b742150
Author: Nick Schermer <nick at xfce.org>
Date: Mon Aug 31 09:00:27 2009 +0200
Disable mnemonics in GtkSettings (bug #5714).
terminal/terminal-app.c | 24 +++++++++++++++++--
terminal/terminal-window.c | 53 +------------------------------------------
2 files changed, 23 insertions(+), 54 deletions(-)
diff --git a/terminal/terminal-app.c b/terminal/terminal-app.c
index b96d86b..86cf506 100644
--- a/terminal/terminal-app.c
+++ b/terminal/terminal-app.c
@@ -48,6 +48,7 @@
static void terminal_app_finalize (GObject *object);
static void terminal_app_update_accels (TerminalApp *app);
+static void terminal_app_update_mnemonics (TerminalApp *app);
static GtkWidget *terminal_app_create_window (TerminalApp *app,
gboolean fullscreen,
TerminalVisibility menubar,
@@ -118,6 +119,8 @@ terminal_app_init (TerminalApp *app)
app->preferences = terminal_preferences_get ();
g_signal_connect_swapped (G_OBJECT (app->preferences), "notify::shortcuts-no-menukey",
G_CALLBACK (terminal_app_update_accels), app);
+ g_signal_connect_swapped (G_OBJECT (app->preferences), "notify::shortcuts-no-mnemonics",
+ G_CALLBACK (terminal_app_update_mnemonics), app);
/* remember the original menu bar accel */
g_object_get (G_OBJECT (gtk_settings_get_default ()),
@@ -125,6 +128,7 @@ terminal_app_init (TerminalApp *app)
NULL);
terminal_app_update_accels (app);
+ terminal_app_update_mnemonics (app);
/* connect the accel map */
app->accel_map = g_object_new (TERMINAL_TYPE_ACCEL_MAP, NULL);
@@ -146,9 +150,8 @@ terminal_app_finalize (GObject *object)
}
g_slist_free (app->windows);
- g_signal_handlers_disconnect_by_func (G_OBJECT (app->preferences),
- G_CALLBACK (terminal_app_update_accels),
- app);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (app->preferences), G_CALLBACK (terminal_app_update_accels), app);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (app->preferences), G_CALLBACK (terminal_app_update_mnemonics), app);
g_object_unref (G_OBJECT (app->preferences));
if (app->initial_menu_bar_accel != NULL)
@@ -186,6 +189,21 @@ terminal_app_update_accels (TerminalApp *app)
+static void
+terminal_app_update_mnemonics (TerminalApp *app)
+{
+ gboolean no_mnemonics;
+
+ g_object_get (G_OBJECT (app->preferences),
+ "shortcuts-no-mnemonics", &no_mnemonics,
+ NULL);
+ g_object_set (G_OBJECT (gtk_settings_get_default ()),
+ "gtk-enable-mnemonics", !no_mnemonics,
+ NULL);
+}
+
+
+
static GtkWidget*
terminal_app_create_window (TerminalApp *app,
gboolean fullscreen,
diff --git a/terminal/terminal-window.c b/terminal/terminal-window.c
index 738b6bd..7d02572 100644
--- a/terminal/terminal-window.c
+++ b/terminal/terminal-window.c
@@ -92,7 +92,6 @@ static void terminal_window_set_size_force_grid (TerminalWi
gint force_grid_width,
gint force_grid_height);
static void terminal_window_update_actions (TerminalWindow *window);
-static void terminal_window_update_mnemonics (TerminalWindow *window);
static void terminal_window_rebuild_gomenu (TerminalWindow *window);
static void terminal_window_notebook_page_switched (GtkNotebook *notebook,
GtkNotebookPage *page,
@@ -309,7 +308,7 @@ terminal_window_init (TerminalWindow *window)
GtkAccelGroup *accel_group;
GtkAction *action;
GtkWidget *vbox;
- gboolean no_mnemonics, always_show_tabs;
+ gboolean always_show_tabs;
gchar *role;
GtkRcStyle *style;
@@ -322,8 +321,6 @@ terminal_window_init (TerminalWindow *window)
G_CALLBACK (terminal_window_set_size), window);
g_signal_connect_swapped (G_OBJECT (window->preferences), "notify::scrolling-bar",
G_CALLBACK (terminal_window_set_size), window);
- g_signal_connect_swapped (G_OBJECT (window->preferences), "notify::shortcuts-no-mnemonics",
- G_CALLBACK (terminal_window_update_mnemonics), window);
window->action_group = gtk_action_group_new ("terminal-window");
gtk_action_group_set_translation_domain (window->action_group,
@@ -348,15 +345,6 @@ terminal_window_init (TerminalWindow *window)
gtk_container_add (GTK_CONTAINER (window), vbox);
gtk_widget_show (vbox);
- /* get some preferences */
- g_object_get (G_OBJECT (window->preferences),
- "shortcuts-no-mnemonics", &no_mnemonics,
- "misc-always-show-tabs", &always_show_tabs, NULL);
-
- /* setup mnemonics */
- if (G_UNLIKELY (no_mnemonics))
- terminal_window_update_mnemonics (window);
-
#if defined(GDK_WINDOWING_X11)
/* setup fullscreen mode */
if (!gdk_net_wm_supports (gdk_atom_intern ("_NET_WM_STATE_FULLSCREEN", FALSE)))
@@ -367,6 +355,7 @@ terminal_window_init (TerminalWindow *window)
#endif
/* allocate the notebook for the terminal screens */
+ g_object_get (G_OBJECT (window->preferences), "misc-always-show-tabs", &always_show_tabs, NULL);
window->notebook = g_object_new (GTK_TYPE_NOTEBOOK,
"homogeneous", TRUE,
"scrollable", TRUE,
@@ -708,44 +697,6 @@ terminal_window_update_actions (TerminalWindow *window)
}
-
-static void
-terminal_window_update_mnemonics (TerminalWindow *window)
-{
- gboolean disable;
- GSList *wp;
- GList *actions;
- GList *ap;
- gchar *label;
- gchar *tmp;
-
- g_object_get (G_OBJECT (window->preferences),
- "shortcuts-no-mnemonics", &disable,
- NULL);
-
- actions = gtk_action_group_list_actions (window->action_group);
- for (ap = actions; ap != NULL; ap = ap->next)
- for (wp = gtk_action_get_proxies (ap->data); wp != NULL; wp = wp->next)
- if (G_TYPE_CHECK_INSTANCE_TYPE (wp->data, GTK_TYPE_MENU_ITEM))
- {
- g_object_get (G_OBJECT (ap->data), "label", &label, NULL);
- if (disable)
- {
- tmp = exo_str_elide_underscores (label);
- g_free (label);
- label = tmp;
- }
-
- g_object_set (G_OBJECT (GTK_BIN (wp->data)->child),
- "label", label, NULL);
-
- g_free (label);
- }
- g_list_free (actions);
-}
-
-
-
static void
terminal_window_rebuild_gomenu (TerminalWindow *window)
{
More information about the Xfce4-commits
mailing list