[Xfce4-commits] <xfce4-terminal:master> Add option to always show tabs in the drop-down window.

Nick Schermer noreply at xfce.org
Sun Dec 30 15:24:01 CET 2012


Updating branch refs/heads/master
         to 0a627860ef9a17c32b0e331665288db25f631390 (commit)
       from a9e840141ed18c4a2062e028a63c7acc767e1052 (commit)

commit 0a627860ef9a17c32b0e331665288db25f631390
Author: Nick Schermer <nick at xfce.org>
Date:   Sun Dec 30 15:21:48 2012 +0100

    Add option to always show tabs in the drop-down window.

 terminal/terminal-preferences-dropdown-dialog.c |    3 +-
 terminal/terminal-preferences-dropdown.glade    |   27 ++++++++--
 terminal/terminal-preferences.c                 |   11 ++++
 terminal/terminal-window-dropdown.c             |   48 +++++++++++------
 terminal/terminal-window.c                      |   67 ++++++++++++-----------
 terminal/terminal-window.h                      |    2 +
 6 files changed, 102 insertions(+), 56 deletions(-)

diff --git a/terminal/terminal-preferences-dropdown-dialog.c b/terminal/terminal-preferences-dropdown-dialog.c
index 8fd59af..388452a 100644
--- a/terminal/terminal-preferences-dropdown-dialog.c
+++ b/terminal/terminal-preferences-dropdown-dialog.c
@@ -91,7 +91,8 @@ terminal_preferences_dropdown_dialog_init (TerminalPreferencesDropdownDialog *di
                                        "dropdown-keep-above",
                                        "dropdown-toggle-focus",
                                        "dropdown-status-icon",
-                                       "dropdown-move-to-active" };
+                                       "dropdown-move-to-active",
+                                       "dropdown-always-show-tabs" };
   const gchar      *props_value[] = { "dropdown-height",
                                       "dropdown-width",
                                       "dropdown-position",
diff --git a/terminal/terminal-preferences-dropdown.glade b/terminal/terminal-preferences-dropdown.glade
index fbad2a8..a1adb1a 100644
--- a/terminal/terminal-preferences-dropdown.glade
+++ b/terminal/terminal-preferences-dropdown.glade
@@ -193,7 +193,7 @@
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="border_width">6</property>
-                        <property name="n_rows">4</property>
+                        <property name="n_rows">5</property>
                         <property name="n_columns">3</property>
                         <property name="column_spacing">2</property>
                         <property name="row_spacing">6</property>
@@ -202,13 +202,13 @@
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
                             <property name="xalign">0</property>
-                            <property name="xpad">6</property>
                             <property name="label" translatable="yes">_Width:</property>
                             <property name="use_underline">True</property>
                             <property name="mnemonic_widget">scale-width</property>
                           </object>
                           <packing>
                             <property name="x_options">GTK_FILL</property>
+                            <property name="x_padding">6</property>
                           </packing>
                         </child>
                         <child>
@@ -216,7 +216,6 @@
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
                             <property name="xalign">0</property>
-                            <property name="xpad">6</property>
                             <property name="label" translatable="yes">He_ight:</property>
                             <property name="use_underline">True</property>
                             <property name="mnemonic_widget">scale-height</property>
@@ -225,6 +224,7 @@
                             <property name="top_attach">1</property>
                             <property name="bottom_attach">2</property>
                             <property name="x_options">GTK_FILL</property>
+                            <property name="x_padding">6</property>
                           </packing>
                         </child>
                         <child>
@@ -232,7 +232,6 @@
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
                             <property name="xalign">0</property>
-                            <property name="xpad">6</property>
                             <property name="label" translatable="yes">_Opacity:</property>
                             <property name="use_underline">True</property>
                             <property name="mnemonic_widget">scale-opacity</property>
@@ -241,6 +240,7 @@
                             <property name="top_attach">2</property>
                             <property name="bottom_attach">3</property>
                             <property name="x_options">GTK_FILL</property>
+                            <property name="x_padding">6</property>
                           </packing>
                         </child>
                         <child>
@@ -248,7 +248,6 @@
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
                             <property name="xalign">0</property>
-                            <property name="xpad">6</property>
                             <property name="label" translatable="yes">D_uration:</property>
                             <property name="use_underline">True</property>
                             <property name="mnemonic_widget">scale-duration</property>
@@ -257,6 +256,7 @@
                             <property name="top_attach">3</property>
                             <property name="bottom_attach">4</property>
                             <property name="x_options">GTK_FILL</property>
+                            <property name="x_padding">6</property>
                           </packing>
                         </child>
                         <child>
@@ -378,6 +378,23 @@
                             <property name="x_options">GTK_FILL</property>
                           </packing>
                         </child>
+                        <child>
+                          <object class="GtkCheckButton" id="dropdown-always-show-tabs">
+                            <property name="label" translatable="yes">_Always show tabs</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="use_underline">True</property>
+                            <property name="draw_indicator">True</property>
+                          </object>
+                          <packing>
+                            <property name="right_attach">3</property>
+                            <property name="top_attach">4</property>
+                            <property name="bottom_attach">5</property>
+                            <property name="x_padding">6</property>
+                          </packing>
+                        </child>
                       </object>
                     </child>
                   </object>
diff --git a/terminal/terminal-preferences.c b/terminal/terminal-preferences.c
index cec7f9c..0f08c9b 100644
--- a/terminal/terminal-preferences.c
+++ b/terminal/terminal-preferences.c
@@ -71,6 +71,7 @@ enum
   PROP_DROPDOWN_OPACITY,
   PROP_DROPDOWN_POSITION,
   PROP_DROPDOWN_MOVE_TO_ACTIVE,
+  PROP_DROPDOWN_ALWAYS_SHOW_TABS,
   PROP_ENCODING,
   PROP_FONT_ALLOW_BOLD,
   PROP_FONT_NAME,
@@ -593,6 +594,16 @@ terminal_preferences_class_init (TerminalPreferencesClass *klass)
                             G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
   /**
+   * TerminalPreferences:dropdown-always-show-tabs:
+   **/
+  preferences_props[PROP_DROPDOWN_ALWAYS_SHOW_TABS] =
+      g_param_spec_boolean ("dropdown-always-show-tabs",
+                            NULL,
+                            "DropdownAlwaysShowTabs",
+                            TRUE,
+                            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+  /**
    * TerminalPreferences:encoding:
    **/
   preferences_props[PROP_ENCODING] =
diff --git a/terminal/terminal-window-dropdown.c b/terminal/terminal-window-dropdown.c
index b2701e5..2ec1285 100644
--- a/terminal/terminal-window-dropdown.c
+++ b/terminal/terminal-window-dropdown.c
@@ -60,6 +60,7 @@ enum
   PROP_DROPDOWN_STATUS_ICON,
   PROP_DROPDOWN_KEEP_ABOVE,
   PROP_DROPDOWN_ANIMATION_TIME,
+  PROP_DROPDOWN_ALWAYS_SHOW_TABS,
   N_PROPERTIES
 };
 
@@ -87,7 +88,7 @@ static void            terminal_window_dropdown_show                          (T
 static void            terminal_window_dropdown_toggle_real                   (TerminalWindowDropdown *dropdown,
                                                                                guint32                 timestamp);
 static void            terminal_window_dropdown_preferences                   (TerminalWindowDropdown *dropdown);
-
+static void            terminal_window_dropdown_update_geometry               (TerminalWindowDropdown *dropdown);
 
 
 struct _TerminalWindowDropdownClass
@@ -204,6 +205,12 @@ terminal_window_dropdown_class_init (TerminalWindowDropdownClass *klass)
                          0, 500, 0,
                          G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
 
+  dropdown_props[PROP_DROPDOWN_ALWAYS_SHOW_TABS] =
+      g_param_spec_boolean ("dropdown-always-show-tabs",
+                            NULL, NULL,
+                            TRUE,
+                            G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
+
   /* install all properties */
   g_object_class_install_properties (gobject_class, N_PROPERTIES, dropdown_props);
 }
@@ -221,7 +228,7 @@ terminal_window_dropdown_init (TerminalWindowDropdown *dropdown)
   guint           n;
   const gchar    *name;
   gboolean        keep_open;
-  GtkWidget      *child;;
+  GtkWidget      *child;
 
   dropdown->rel_width = 0.80;
   dropdown->rel_height = 0.50;
@@ -255,8 +262,9 @@ terminal_window_dropdown_init (TerminalWindowDropdown *dropdown)
   gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dropdown), TRUE);
 
   /* adjust notebook for drop-down usage */
-  gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->notebook), TRUE);
   gtk_notebook_set_tab_pos (GTK_NOTEBOOK (window->notebook), GTK_POS_BOTTOM);
+  gtk_notebook_set_show_border (GTK_NOTEBOOK (window->notebook), TRUE);
+  terminal_window_notebook_show_tabs (window);
   terminal_util_set_style_thinkess (window->notebook, 1);
 
   /* actions we don't want */
@@ -371,7 +379,11 @@ terminal_window_dropdown_set_property (GObject      *object,
 
     case PROP_DROPDOWN_ANIMATION_TIME:
       dropdown->animation_time = g_value_get_uint (value);
-      break;
+      return;
+
+    case PROP_DROPDOWN_ALWAYS_SHOW_TABS:
+      terminal_window_notebook_show_tabs (TERMINAL_WINDOW (dropdown));
+      return;
 
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -850,6 +862,19 @@ terminal_window_dropdown_preferences (TerminalWindowDropdown *dropdown)
 
 
 
+static void
+terminal_window_dropdown_update_geometry (TerminalWindowDropdown *dropdown)
+{
+  terminal_return_if_fail (TERMINAL_IS_WINDOW_DROPDOWN (dropdown));
+
+  /* update geometry if toolbar or menu is shown */
+  if (gtk_widget_get_visible (GTK_WIDGET (dropdown))
+      && dropdown->animation_dir == ANIMATION_DIR_NONE)
+    terminal_window_dropdown_show (dropdown, 0);
+}
+
+
+
 static guint32
 terminal_window_dropdown_get_timestamp (GtkWidget   *widget,
                                         const gchar *startup_id)
@@ -879,17 +904,6 @@ terminal_window_dropdown_get_timestamp (GtkWidget   *widget,
 
 
 
-static void
-terminal_window_dropdown_bar_visibility_changed (TerminalWindowDropdown *dropdown)
-{
-  /* update geometry if toolbar or menu is shown */
-  if (gtk_widget_get_visible (GTK_WIDGET (dropdown))
-      && dropdown->animation_dir == ANIMATION_DIR_NONE)
-    terminal_window_dropdown_show (dropdown, 0);
-}
-
-
-
 GtkWidget *
 terminal_window_dropdown_new (const gchar        *role,
                               TerminalVisibility  menubar,
@@ -917,7 +931,7 @@ terminal_window_dropdown_new (const gchar        *role,
   action = gtk_action_group_get_action (window->action_group, "show-menubar");
   gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), show_menubar);
   g_signal_connect_swapped (action, "activate",
-      G_CALLBACK (terminal_window_dropdown_bar_visibility_changed), window);
+      G_CALLBACK (terminal_window_dropdown_update_geometry), window);
 
   /* setup toolbar visibility */
   if (G_LIKELY (toolbar != TERMINAL_VISIBILITY_DEFAULT))
@@ -925,7 +939,7 @@ terminal_window_dropdown_new (const gchar        *role,
   action = gtk_action_group_get_action (window->action_group, "show-toolbar");
   gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), show_toolbar);
   g_signal_connect_swapped (action, "activate",
-      G_CALLBACK (terminal_window_dropdown_bar_visibility_changed), window);
+      G_CALLBACK (terminal_window_dropdown_update_geometry), window);
 
   return GTK_WIDGET (window);
 }
diff --git a/terminal/terminal-window.c b/terminal/terminal-window.c
index 8d499cd..56f07cb 100644
--- a/terminal/terminal-window.c
+++ b/terminal/terminal-window.c
@@ -96,7 +96,6 @@ static void            terminal_window_notebook_page_reordered       (GtkNoteboo
                                                                       GtkNotebookPage        *page,
                                                                       guint                   page_num,
                                                                       TerminalWindow         *window);
-static void            terminal_window_notebook_show_tabs            (TerminalWindow         *window);
 static void            terminal_window_notebook_page_added           (GtkNotebook            *notebook,
                                                                       GtkWidget              *child,
                                                                       guint                   page_num,
@@ -849,38 +848,6 @@ terminal_window_notebook_page_reordered (GtkNotebook     *notebook,
 
 
 static void
-terminal_window_notebook_show_tabs (TerminalWindow *window)
-{
-  GtkNotebook *notebook = GTK_NOTEBOOK (window->notebook);
-  gboolean     show_tabs = TRUE;
-  gint         npages;
-
-  /* handled by other widget */
-  if (window->drop_down)
-    return;
-
-  /* set the visibility of the tabs */
-  npages = gtk_notebook_get_n_pages (notebook);
-  if (npages < 2)
-    g_object_get (G_OBJECT (window->preferences),
-                  "misc-always-show-tabs", &show_tabs, NULL);
-
-  if (gtk_notebook_get_show_tabs (notebook) != show_tabs)
-    {
-      /* store size */
-      terminal_window_size_push (window);
-
-      /* show or hdie the tabs */
-      gtk_notebook_set_show_tabs (notebook, show_tabs);
-
-      /* update the window geometry */
-      terminal_window_size_pop (window);
-    }
-}
-
-
-
-static void
 terminal_window_notebook_page_added (GtkNotebook    *notebook,
                                      GtkWidget      *child,
                                      guint           page_num,
@@ -1927,6 +1894,40 @@ terminal_window_get_active (TerminalWindow *window)
 
 
 
+void
+terminal_window_notebook_show_tabs (TerminalWindow *window)
+{
+  GtkNotebook *notebook = GTK_NOTEBOOK (window->notebook);
+  gboolean     show_tabs = TRUE;
+  gint         npages;
+
+  terminal_return_if_fail (TERMINAL_IS_WINDOW (window));
+
+  /* check preferences */
+  npages = gtk_notebook_get_n_pages (notebook);
+  if (npages < 2)
+    {
+      g_object_get (G_OBJECT (window->preferences),
+                    window->drop_down ? "dropdown-always-show-tabs" :
+                    "misc-always-show-tabs", &show_tabs, NULL);
+    }
+
+  /* set the visibility of the tabs */
+  if (gtk_notebook_get_show_tabs (notebook) != show_tabs)
+    {
+      /* store size */
+      terminal_window_size_push (window);
+
+      /* show or hdie the tabs */
+      gtk_notebook_set_show_tabs (notebook, show_tabs);
+
+      /* update the window geometry */
+      terminal_window_size_pop (window);
+    }
+}
+
+
+
 /**
  * terminal_window_get_restart_command:
  * @window  : A #TerminalWindow.
diff --git a/terminal/terminal-window.h b/terminal/terminal-window.h
index bce7e5c..2cd0818 100644
--- a/terminal/terminal-window.h
+++ b/terminal/terminal-window.h
@@ -101,6 +101,8 @@ void            terminal_window_add                  (TerminalWindow     *window
 
 TerminalScreen *terminal_window_get_active           (TerminalWindow     *window);
 
+void            terminal_window_notebook_show_tabs   (TerminalWindow     *window);
+
 GSList         *terminal_window_get_restart_command  (TerminalWindow     *window);
 
 G_END_DECLS


More information about the Xfce4-commits mailing list