gnome-terminal r2796 - trunk/src
- From: chpe svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-terminal r2796 - trunk/src
- Date: Thu, 29 May 2008 19:55:07 +0000 (UTC)
Author: chpe
Date: Thu May 29 19:55:07 2008
New Revision: 2796
URL: http://svn.gnome.org/viewvc/gnome-terminal?rev=2796&view=rev
Log:
Update the encoding menu state on tab switch, instead of rebuilding the whole menu on activating the parent menu.
Modified:
trunk/src/terminal-window.c
Modified: trunk/src/terminal-window.c
==============================================================================
--- trunk/src/terminal-window.c (original)
+++ trunk/src/terminal-window.c Thu May 29 19:55:07 2008
@@ -112,8 +112,6 @@
TerminalWindow *window);
/* Menu action callbacks */
-static void terminal_menu_activate_callback (GtkAction *action,
- TerminalWindow *window);
static void file_new_window_callback (GtkAction *action,
TerminalWindow *window);
static void file_new_tab_callback (GtkAction *action,
@@ -624,16 +622,16 @@
priv->encodings_action_group = NULL;
}
- if (priv->active_screen == NULL)
- return;
-
action_group = priv->encodings_action_group = gtk_action_group_new ("Encodings");
gtk_ui_manager_insert_action_group (priv->ui_manager, action_group, -1);
g_object_unref (action_group);
priv->encodings_ui_id = gtk_ui_manager_new_merge_id (priv->ui_manager);
- charset = vte_terminal_get_encoding (VTE_TERMINAL (priv->active_screen));
+ if (priv->active_screen)
+ charset = vte_terminal_get_encoding (VTE_TERMINAL (priv->active_screen));
+ else
+ charset = NULL;
encodings = terminal_get_active_encodings ();
@@ -661,7 +659,7 @@
gtk_radio_action_set_group (encoding_action, group);
group = gtk_radio_action_get_group (encoding_action);
- if (strcmp (e->charset, charset) == 0)
+ if (charset && strcmp (e->charset, charset) == 0)
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (encoding_action), TRUE);
g_signal_connect (encoding_action, "toggled",
@@ -680,6 +678,29 @@
g_slist_free (encodings);
}
+static void
+terminal_window_update_encoding_menu_active_encoding (TerminalWindow *window)
+{
+ TerminalWindowPrivate *priv = window->priv;
+ GtkAction *action;
+ char name[128];
+
+ if (!priv->active_screen)
+ return;
+ if (!priv->encodings_action_group)
+ return;
+
+ g_snprintf (name, sizeof (name), SET_ENCODING_ACTION_NAME_PREFIX "%s",
+ vte_terminal_get_encoding (VTE_TERMINAL (priv->active_screen)));
+ action = gtk_action_group_get_action (priv->encodings_action_group, name);
+ if (!action)
+ return;
+
+ g_signal_handlers_block_by_func (action, G_CALLBACK (terminal_set_encoding_callback), window);
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
+ g_signal_handlers_unblock_by_func (action, G_CALLBACK (terminal_set_encoding_callback), window);
+}
+
/* Actions stuff */
static void
@@ -735,16 +756,6 @@
}
static void
-terminal_menu_activate_callback (GtkAction *action,
- TerminalWindow *window)
-{
- /* FIXMEchpe: make the encoding list a prop on TerminalApp instead,
- * and listen for notifications to update the menu instead of this hack.
- */
- terminal_window_update_encoding_menu (window);
-}
-
-static void
edit_menu_activate_callback (GtkMenuItem *menuitem,
gpointer user_data)
{
@@ -1409,9 +1420,6 @@
action = gtk_action_group_get_action (action_group, "Edit");
g_signal_connect (action, "activate",
G_CALLBACK (edit_menu_activate_callback), window);
- action = gtk_action_group_get_action (action_group, "Terminal");
- g_signal_connect (action, "activate",
- G_CALLBACK (terminal_menu_activate_callback), window);
action = gtk_action_group_get_action (action_group, "ViewFullscreen");
gtk_action_set_sensitive (action,
@@ -2052,6 +2060,7 @@
#endif
terminal_window_set_size (window, screen, TRUE);
+ terminal_window_update_encoding_menu_active_encoding (window);
terminal_window_update_set_profile_menu_active_profile (window);
terminal_window_update_copy_sensitivity (window);
terminal_window_update_zoom_sensitivity (window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]