[Xfce4-commits] <terminal:master> Rename toolbars to toolbar and cache actions.

Nick Schermer noreply at xfce.org
Wed Dec 26 18:26:03 CET 2012


Updating branch refs/heads/master
         to 084826b48316735939b839151cd1f61612c5d42d (commit)
       from bebfb8a9abb964e83e858335b9b2a465f3ea999a (commit)

commit 084826b48316735939b839151cd1f61612c5d42d
Author: Nick Schermer <nick at xfce.org>
Date:   Wed Dec 26 17:54:24 2012 +0100

    Rename toolbars to toolbar and cache actions.

 terminal/main.c                        |    2 +-
 terminal/terminal-app.c                |    8 +-
 terminal/terminal-options.c            |    6 +-
 terminal/terminal-options.h            |    2 +-
 terminal/terminal-preferences-dialog.c |    2 +-
 terminal/terminal-preferences.c        |   12 ++--
 terminal/terminal-preferences.glade    |    6 +-
 terminal/terminal-window-ui.xml        |    2 +-
 terminal/terminal-window.c             |  121 ++++++++++++++++++--------------
 terminal/terminal-window.h             |    2 +-
 10 files changed, 89 insertions(+), 74 deletions(-)

diff --git a/terminal/main.c b/terminal/main.c
index 30bcafd..d634d91 100644
--- a/terminal/main.c
+++ b/terminal/main.c
@@ -132,7 +132,7 @@ usage (void)
            "  --display=%s; --geometry=%s; --role=%s;\n"
            "  --startup-id=%s; -I, --icon=%s; --fullscreen; --maximize;\n"
            "  --show-menubar, --hide-menubar; --show-borders, --hide-borders;\n"
-           "  --show-toolbars, --hide-toolbars\n\n",
+           "  --show-toolbar, --hide-toolbar\n\n",
            _("Window Options"),
            /* parameter of --display */
            _("display"),
diff --git a/terminal/terminal-app.c b/terminal/terminal-app.c
index 65d172a..4f5241c 100644
--- a/terminal/terminal-app.c
+++ b/terminal/terminal-app.c
@@ -55,7 +55,7 @@ static GtkWidget         *terminal_app_create_window            (TerminalApp
                                                                  gboolean            fullscreen,
                                                                  TerminalVisibility  menubar,
                                                                  TerminalVisibility  borders,
-                                                                 TerminalVisibility  toolbars);
+                                                                 TerminalVisibility  toolbar);
 static void               terminal_app_new_window               (TerminalWindow     *window,
                                                                  const gchar        *working_directory,
                                                                  TerminalApp        *app);
@@ -284,11 +284,11 @@ terminal_app_create_window (TerminalApp       *app,
                             gboolean           fullscreen,
                             TerminalVisibility menubar,
                             TerminalVisibility borders,
-                            TerminalVisibility toolbars)
+                            TerminalVisibility toolbar)
 {
   GtkWidget *window;
 
-  window = terminal_window_new (fullscreen, menubar, borders, toolbars);
+  window = terminal_window_new (fullscreen, menubar, borders, toolbar);
   g_signal_connect (G_OBJECT (window), "destroy",
                     G_CALLBACK (terminal_app_window_destroyed), app);
   g_signal_connect (G_OBJECT (window), "new-window",
@@ -541,7 +541,7 @@ terminal_app_open_window (TerminalApp        *app,
                                            attr->fullscreen,
                                            attr->menubar,
                                            attr->borders,
-                                           attr->toolbars);
+                                           attr->toolbar);
 
       if (attr->role != NULL)
         gtk_window_set_role (GTK_WINDOW (window), attr->role);
diff --git a/terminal/terminal-options.c b/terminal/terminal-options.c
index dffde6c..52633cf 100644
--- a/terminal/terminal-options.c
+++ b/terminal/terminal-options.c
@@ -395,9 +395,9 @@ terminal_window_attr_parse (gint              argc,
         {
           win_attr->borders = visible;
         }
-      else if (terminal_option_show_hide_cmp ("toolbars", argc, argv, &n, &visible))
+      else if (terminal_option_show_hide_cmp ("toolbar", argc, argv, &n, &visible))
         {
-          win_attr->toolbars = visible;
+          win_attr->toolbar = visible;
         }
       else if (terminal_option_cmp ("tab", 0, argc, argv, &n, NULL))
         {
@@ -490,7 +490,7 @@ terminal_window_attr_new (void)
   win_attr->fullscreen = FALSE;
   win_attr->menubar = TERMINAL_VISIBILITY_DEFAULT;
   win_attr->borders = TERMINAL_VISIBILITY_DEFAULT;
-  win_attr->toolbars = TERMINAL_VISIBILITY_DEFAULT;
+  win_attr->toolbar = TERMINAL_VISIBILITY_DEFAULT;
 
   tab_attr = g_slice_new0 (TerminalTabAttr);
   win_attr->tabs = g_slist_prepend (NULL, tab_attr);
diff --git a/terminal/terminal-options.h b/terminal/terminal-options.h
index b8d4074..4d72a3f 100644
--- a/terminal/terminal-options.h
+++ b/terminal/terminal-options.h
@@ -55,7 +55,7 @@ struct _TerminalWindowAttr
   guint                fullscreen : 1;
   TerminalVisibility   menubar;
   TerminalVisibility   borders;
-  TerminalVisibility   toolbars;
+  TerminalVisibility   toolbar;
   guint                maximize : 1;
   guint                reuse_last_window : 1;
 };
diff --git a/terminal/terminal-preferences-dialog.c b/terminal/terminal-preferences-dialog.c
index f05ee81..1c659dd 100644
--- a/terminal/terminal-preferences-dialog.c
+++ b/terminal/terminal-preferences-dialog.c
@@ -126,7 +126,7 @@ terminal_preferences_dialog_init (TerminalPreferencesDialog *dialog)
                                        "command-update-records", "scrolling-single-line",
                                        "scrolling-on-output", "scrolling-on-keystroke",
                                        "scrolling-bar", "font-allow-bold",
-                                       "misc-menubar-default", "misc-toolbars-default",
+                                       "misc-menubar-default", "misc-toolbar-default",
                                        "misc-borders-default",
                                        "shortcuts-no-mnemonics", "shortcuts-no-menukey",
                                        "binding-backspace", "binding-delete",
diff --git a/terminal/terminal-preferences.c b/terminal/terminal-preferences.c
index 2e7bf2d..26f6375 100644
--- a/terminal/terminal-preferences.c
+++ b/terminal/terminal-preferences.c
@@ -73,7 +73,7 @@ enum
   PROP_MISC_INHERIT_GEOMETRY,
   PROP_MISC_MENUBAR_DEFAULT,
   PROP_MISC_MOUSE_AUTOHIDE,
-  PROP_MISC_TOOLBARS_DEFAULT,
+  PROP_MISC_TOOLBAR_DEFAULT,
   PROP_MISC_CONFIRM_CLOSE,
   PROP_MISC_CYCLE_TABS,
   PROP_MISC_TAB_CLOSE_BUTTONS,
@@ -601,12 +601,12 @@ terminal_preferences_class_init (TerminalPreferencesClass *klass)
                             G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
   /**
-   * TerminalPreferences:misc-toolbars-default:
+   * TerminalPreferences:misc-toolbar-default:
    **/
-  preferences_props[PROP_MISC_TOOLBARS_DEFAULT] =
-      g_param_spec_boolean ("misc-toolbars-default",
-                            "misc-toolbars-default",
-                            "MiscToolbarsDefault",
+  preferences_props[PROP_MISC_TOOLBAR_DEFAULT] =
+      g_param_spec_boolean ("misc-toolbar-default",
+                            "misc-toolbar-default",
+                            "MiscToolbarDefault",
                             FALSE,
                             G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
diff --git a/terminal/terminal-preferences.glade b/terminal/terminal-preferences.glade
index 989b4e8..dcb7b37 100644
--- a/terminal/terminal-preferences.glade
+++ b/terminal/terminal-preferences.glade
@@ -862,13 +862,13 @@
                               </packing>
                             </child>
                             <child>
-                              <object class="GtkCheckButton" id="misc-toolbars-default">
-                                <property name="label" translatable="yes">Display _toolbars in new windows</property>
+                              <object class="GtkCheckButton" id="misc-toolbar-default">
+                                <property name="label" translatable="yes">Display _toolbar in new windows</property>
                                 <property name="use_action_appearance">False</property>
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">False</property>
-                                <property name="tooltip_text" translatable="yes">Enable this option to show the toolbars in newly created terminal windows.</property>
+                                <property name="tooltip_text" translatable="yes">Enable this option to show the toolbar in newly created terminal windows.</property>
                                 <property name="use_underline">True</property>
                                 <property name="draw_indicator">True</property>
                               </object>
diff --git a/terminal/terminal-window-ui.xml b/terminal/terminal-window-ui.xml
index fbb45ba..089a3ed 100644
--- a/terminal/terminal-window-ui.xml
+++ b/terminal/terminal-window-ui.xml
@@ -28,7 +28,7 @@
     </menu>
     <menu action="view-menu">
       <menuitem action="show-menubar"/>
-      <menuitem action="show-toolbars"/>
+      <menuitem action="show-toolbar"/>
       <menuitem action="show-borders"/>
       <menuitem action="fullscreen"/>
     </menu>
diff --git a/terminal/terminal-window.c b/terminal/terminal-window.c
index 57ffb46..297384b 100644
--- a/terminal/terminal-window.c
+++ b/terminal/terminal-window.c
@@ -154,7 +154,7 @@ static void            terminal_window_action_prefs                  (GtkAction
                                                                       TerminalWindow         *window);
 static void            terminal_window_action_show_menubar           (GtkToggleAction        *action,
                                                                       TerminalWindow         *window);
-static void            terminal_window_action_show_toolbars          (GtkToggleAction        *action,
+static void            terminal_window_action_show_toolbar           (GtkToggleAction        *action,
                                                                       TerminalWindow         *window);
 static void            terminal_window_action_show_borders           (GtkToggleAction        *action,
                                                                       TerminalWindow         *window);
@@ -197,7 +197,7 @@ struct _TerminalWindow
   guint                gomenu_merge_id;
 
   GtkWidget           *menubar;
-  GtkWidget           *toolbars;
+  GtkWidget           *toolbar;
   GtkWidget           *notebook;
 
   /* pushed size of screen */
@@ -207,6 +207,15 @@ struct _TerminalWindow
   GtkAction           *encoding_action;
 
   TerminalScreen      *active;
+
+  /* cached actions to avoid lookups */
+  GtkAction           *action_detah_tab;
+  GtkAction           *action_close_tab;
+  GtkAction           *action_prev_tab;
+  GtkAction           *action_next_tab;
+  GtkAction           *action_move_tab_left;
+  GtkAction           *action_move_tab_right;
+  GtkAction           *action_copy;
 };
 
 
@@ -251,7 +260,7 @@ static const GtkActionEntry action_entries[] =
 static const GtkToggleActionEntry toggle_action_entries[] =
 {
   { "show-menubar", NULL, N_ ("Show _Menubar"), NULL, N_ ("Show/hide the menubar"), G_CALLBACK (terminal_window_action_show_menubar), FALSE, },
-  { "show-toolbars", NULL, N_ ("Show _Toolbars"), NULL, N_ ("Show/hide the toolbars"), G_CALLBACK (terminal_window_action_show_toolbars), FALSE, },
+  { "show-toolbar", NULL, N_ ("Show _Toolbar"), NULL, N_ ("Show/hide the toolbar"), G_CALLBACK (terminal_window_action_show_toolbar), FALSE, },
   { "show-borders", NULL, N_ ("Show Window _Borders"), NULL, N_ ("Show/hide the window decorations"), G_CALLBACK (terminal_window_action_show_borders), TRUE, },
   { "fullscreen", GTK_STOCK_FULLSCREEN, N_ ("_Fullscreen"), "F11", N_ ("Toggle fullscreen mode"), G_CALLBACK (terminal_window_action_fullscreen), FALSE, },
 };
@@ -415,6 +424,15 @@ terminal_window_init (TerminalWindow *window)
   gtk_action_group_add_action (window->action_group, window->encoding_action);
   g_signal_connect (G_OBJECT (window->encoding_action), "encoding-changed",
       G_CALLBACK (terminal_window_action_set_encoding), window);
+
+  /* cache action pointers */
+  window->action_detah_tab = gtk_action_group_get_action (window->action_group, "detach-tab");
+  window->action_close_tab = gtk_action_group_get_action (window->action_group, "close-tab");
+  window->action_prev_tab = gtk_action_group_get_action (window->action_group, "prev-tab");
+  window->action_next_tab = gtk_action_group_get_action (window->action_group, "next-tab");
+  window->action_move_tab_left = gtk_action_group_get_action (window->action_group, "move-tab-left");
+  window->action_move_tab_right = gtk_action_group_get_action (window->action_group, "move-tab-right");
+  window->action_copy = gtk_action_group_get_action (window->action_group, "copy");
 }
 
 
@@ -704,14 +722,12 @@ terminal_window_update_actions (TerminalWindow *window)
 
   /* determine the number of pages */
   n_pages = gtk_notebook_get_n_pages (notebook);
-g_message (".");
+
   /* "Detach Tab" is only sensitive if we have atleast two pages */
-  action = gtk_action_group_get_action (window->action_group, "detach-tab");
-  gtk_action_set_sensitive (action, (n_pages > 1));
+  gtk_action_set_sensitive (window->action_detah_tab, (n_pages > 1));
 
   /* ... same for the "Close Tab" action */
-  action = gtk_action_group_get_action (window->action_group, "close-tab");
-  gtk_action_set_sensitive (action, (n_pages > 1));
+  gtk_action_set_sensitive (window->action_close_tab, (n_pages > 1));
 
   /* update the actions for the current terminal screen */
  if (G_LIKELY (window->active != NULL))
@@ -722,20 +738,16 @@ g_message (".");
                     "misc-cycle-tabs", &cycle_tabs,
                     NULL);
 
-      action = gtk_action_group_get_action (window->action_group, "prev-tab");
-      gtk_action_set_sensitive (action, (cycle_tabs && n_pages > 1) || (page_num > 0));
-
-      action = gtk_action_group_get_action (window->action_group, "next-tab");
-      gtk_action_set_sensitive (action, (cycle_tabs && n_pages > 1 ) || (page_num < n_pages - 1));
-
-      action = gtk_action_group_get_action (window->action_group, "move-tab-left");
-      gtk_action_set_sensitive (action, n_pages > 1);
+      gtk_action_set_sensitive (window->action_prev_tab,
+                                (cycle_tabs && n_pages > 1) || (page_num > 0));
+      gtk_action_set_sensitive (window->action_next_tab,
+                                (cycle_tabs && n_pages > 1 ) || (page_num < n_pages - 1));
 
-      action = gtk_action_group_get_action (window->action_group, "move-tab-right");
-      gtk_action_set_sensitive (action, n_pages > 1);
+      gtk_action_set_sensitive (window->action_move_tab_left, n_pages > 1);
+      gtk_action_set_sensitive (window->action_move_tab_right, n_pages > 1);
 
-      action = gtk_action_group_get_action (window->action_group, "copy");
-      gtk_action_set_sensitive (action, terminal_screen_has_selection (window->active));
+      gtk_action_set_sensitive (window->action_copy,
+                                terminal_screen_has_selection (window->active));
 
       /* update the "Go" menu */
       action = g_object_get_qdata (G_OBJECT (window->active), gomenu_action_quark);
@@ -1453,8 +1465,8 @@ terminal_window_action_show_menubar (GtkToggleAction *action,
 
 
 static void
-terminal_window_action_show_toolbars (GtkToggleAction *action,
-                                      TerminalWindow  *window)
+terminal_window_action_show_toolbar (GtkToggleAction *action,
+                                     TerminalWindow  *window)
 {
   GtkWidget *vbox;
 
@@ -1465,20 +1477,20 @@ terminal_window_action_show_toolbars (GtkToggleAction *action,
 
   if (gtk_toggle_action_get_active (action))
     {
-      if (window->toolbars == NULL)
+      if (window->toolbar == NULL)
         {
           vbox = gtk_bin_get_child (GTK_BIN (window));
-          window->toolbars = gtk_ui_manager_get_widget (window->ui_manager, "/main-toolbar");
-          gtk_box_pack_start (GTK_BOX (vbox), window->toolbars, FALSE, FALSE, 0);
-          gtk_box_reorder_child (GTK_BOX (vbox), window->toolbars, window->menubar != NULL ? 1 : 0);
+          window->toolbar = gtk_ui_manager_get_widget (window->ui_manager, "/main-toolbar");
+          gtk_box_pack_start (GTK_BOX (vbox), window->toolbar, FALSE, FALSE, 0);
+          gtk_box_reorder_child (GTK_BOX (vbox), window->toolbar, window->menubar != NULL ? 1 : 0);
         }
 
-      gtk_widget_show (window->toolbars);
+      gtk_widget_show (window->toolbar);
     }
-  else if (window->toolbars != NULL)
+  else if (window->toolbar != NULL)
     {
-      gtk_widget_destroy (window->toolbars);
-      window->toolbars = NULL;
+      gtk_widget_destroy (window->toolbar);
+      window->toolbar = NULL;
     }
 
   terminal_window_size_pop (window);
@@ -1736,7 +1748,7 @@ terminal_window_action_about (GtkAction      *action,
  * @fullscreen: Whether to set the window to fullscreen.
  * @menubar   : Visibility setting for the menubar.
  * @borders   : Visibility setting for the window borders.
- * @toolbars  : Visibility setting for the toolbars.
+ * @toolbar   : Visibility setting for the toolbar.
  *
  * Return value:
  **/
@@ -1744,42 +1756,45 @@ GtkWidget*
 terminal_window_new (gboolean           fullscreen,
                      TerminalVisibility menubar,
                      TerminalVisibility borders,
-                     TerminalVisibility toolbars)
+                     TerminalVisibility toolbar)
 {
   TerminalWindow *window;
   GtkAction      *action;
-  gboolean        setting;
+  gboolean        show_menubar;
+  gboolean        show_toolbar;
+  gboolean        show_borders;
 
   window = g_object_new (TERMINAL_TYPE_WINDOW, NULL);
 
+  /* read default preferences */
+  g_object_get (G_OBJECT (window->preferences),
+                "misc-menubar-default", &show_menubar,
+                "misc-toolbar-default", &show_toolbar,
+                "misc-borders-default", &show_borders,
+                NULL);
+
   /* setup full screen */
   action = gtk_action_group_get_action (window->action_group, "fullscreen");
   if (fullscreen && gtk_action_is_sensitive (action))
     gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
 
   /* setup menubar visibility */
-  if (G_LIKELY (menubar == TERMINAL_VISIBILITY_DEFAULT))
-    g_object_get (G_OBJECT (window->preferences), "misc-menubar-default", &setting, NULL);
-  else
-    setting = (menubar == TERMINAL_VISIBILITY_SHOW);
+  if (G_LIKELY (menubar != TERMINAL_VISIBILITY_DEFAULT))
+    show_menubar = (menubar == TERMINAL_VISIBILITY_SHOW);
   action = gtk_action_group_get_action (window->action_group, "show-menubar");
-  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), setting);
+  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), show_menubar);
 
-  /* setup toolbars visibility */
-  if (G_LIKELY (toolbars == TERMINAL_VISIBILITY_DEFAULT))
-    g_object_get (G_OBJECT (window->preferences), "misc-toolbars-default", &setting, NULL);
-  else
-    setting = (toolbars == TERMINAL_VISIBILITY_SHOW);
-  action = gtk_action_group_get_action (window->action_group, "show-toolbars");
-  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), setting);
+  /* setup toolbar visibility */
+  if (G_LIKELY (toolbar != TERMINAL_VISIBILITY_DEFAULT))
+    show_toolbar = (toolbar == TERMINAL_VISIBILITY_SHOW);
+  action = gtk_action_group_get_action (window->action_group, "show-toolbar");
+  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), show_toolbar);
 
   /* setup borders visibility */
-  if (G_LIKELY (borders == TERMINAL_VISIBILITY_DEFAULT))
-    g_object_get (G_OBJECT (window->preferences), "misc-borders-default", &setting, NULL);
-  else
-    setting = (borders == TERMINAL_VISIBILITY_SHOW);
+  if (G_LIKELY (borders != TERMINAL_VISIBILITY_DEFAULT))
+    show_borders = (borders == TERMINAL_VISIBILITY_SHOW);
   action = gtk_action_group_get_action (window->action_group, "show-borders");
-  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), setting);
+  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), show_borders);
 
   return GTK_WIDGET (window);
 }
@@ -1897,11 +1912,11 @@ terminal_window_get_restart_command (TerminalWindow *window)
   else
     result = g_slist_prepend (result, g_strdup ("--hide-borders"));
 
-  action = gtk_action_group_get_action (window->action_group, "show-toolbars");
+  action = gtk_action_group_get_action (window->action_group, "show-toolbar");
   if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
-    result = g_slist_prepend (result, g_strdup ("--show-toolbars"));
+    result = g_slist_prepend (result, g_strdup ("--show-toolbar"));
   else
-    result = g_slist_prepend (result, g_strdup ("--hide-toolbars"));
+    result = g_slist_prepend (result, g_strdup ("--hide-toolbar"));
 
   /* set restart commands of the tabs */
   children = gtk_container_get_children (GTK_CONTAINER (window->notebook));
diff --git a/terminal/terminal-window.h b/terminal/terminal-window.h
index 60c34f7..df57537 100644
--- a/terminal/terminal-window.h
+++ b/terminal/terminal-window.h
@@ -46,7 +46,7 @@ GType           terminal_window_get_type             (void) G_GNUC_CONST;
 GtkWidget      *terminal_window_new                  (gboolean            fullscreen,
                                                       TerminalVisibility  menubar,
                                                       TerminalVisibility  borders,
-                                                      TerminalVisibility  toolbars);
+                                                      TerminalVisibility  toolbar);
 
 void            terminal_window_add                  (TerminalWindow     *window,
                                                       TerminalScreen     *screen);


More information about the Xfce4-commits mailing list