[gnome-terminal] window: Move new-tab button into headerbar



commit 04d9400bbb5ea759a908713934f874800be84544
Author: Florian Müllner <fmuellner gnome org>
Date:   Mon Dec 10 22:00:33 2018 +0100

    window: Move new-tab button into headerbar
    
    Opening a new tab is a very frequent action, which is currently
    exposed in the tab bar itself. However that means that it only
    becomes available when more than one tab is used. Moving the
    control to the headerbar instead makes the action always readily
    available and leaves a bit more space for tabs.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=756798

 src/terminal-headerbar.ui | 22 ++++++++++++++++++++++
 src/terminal-window.c     | 18 +++++++++++-------
 2 files changed, 33 insertions(+), 7 deletions(-)
---
diff --git a/src/terminal-headerbar.ui b/src/terminal-headerbar.ui
index 3f8c5965..804f520b 100644
--- a/src/terminal-headerbar.ui
+++ b/src/terminal-headerbar.ui
@@ -20,5 +20,27 @@
     <property name="can-focus">False</property>
     <property name="visible">True</property>
     <property name="show-close-button">True</property>
+    <child>
+      <object class="GtkButton">
+        <property name="visible">True</property>
+        <property name="focus_on_click">False</property>
+        <property name="can_focus">True</property>
+        <property name="receives_default">False</property>
+        <property name="action-name">win.new-terminal</property>
+        <property name="action-target">('tab','current')</property>
+        <style>
+          <class name="image-button"/>
+        </style>
+        <child>
+          <object class="GtkImage">
+            <property name="visible">True</property>
+            <property name="icon_name">tab-new-symbolic</property>
+          </object>
+        </child>
+      </object>
+      <packing>
+        <property name="pack_type">end</property>
+      </packing>
+    </child>
   </template>
 </interface>
diff --git a/src/terminal-window.c b/src/terminal-window.c
index 2f53e0fb..f6dce67d 100644
--- a/src/terminal-window.c
+++ b/src/terminal-window.c
@@ -1876,7 +1876,8 @@ notebook_update_tabs_menu_cb (GtkMenuButton *button,
 }
 
 static void
-terminal_window_fill_notebook_action_box (TerminalWindow *window)
+terminal_window_fill_notebook_action_box (TerminalWindow *window,
+                                          gboolean add_new_tab_button)
 {
   TerminalWindowPrivate *priv = window->priv;
   GtkWidget *box, *new_tab_button, *tabs_menu_button;
@@ -1884,11 +1885,14 @@ terminal_window_fill_notebook_action_box (TerminalWindow *window)
   box = terminal_notebook_get_action_box (TERMINAL_NOTEBOOK (priv->mdi_container), GTK_PACK_END);
 
   /* Create the NewTerminal button */
-  new_tab_button = terminal_icon_button_new ("tab-new-symbolic");
-  gtk_actionable_set_action_name (GTK_ACTIONABLE (new_tab_button), "win.new-terminal");
-  gtk_actionable_set_action_target (GTK_ACTIONABLE (new_tab_button), "(ss)", "tab", "current");
-  gtk_box_pack_start (GTK_BOX (box), new_tab_button, FALSE, FALSE, 0);
-  gtk_widget_show (new_tab_button);
+  if (add_new_tab_button)
+    {
+      new_tab_button = terminal_icon_button_new ("tab-new-symbolic");
+      gtk_actionable_set_action_name (GTK_ACTIONABLE (new_tab_button), "win.new-terminal");
+      gtk_actionable_set_action_target (GTK_ACTIONABLE (new_tab_button), "(ss)", "tab", "current");
+      gtk_box_pack_start (GTK_BOX (box), new_tab_button, FALSE, FALSE, 0);
+      gtk_widget_show (new_tab_button);
+    }
 
   /* Create Tabs menu button */
   tabs_menu_button = terminal_menu_button_new ();
@@ -2224,7 +2228,7 @@ terminal_window_init (TerminalWindow *window)
   g_signal_connect (app, "clipboard-targets-changed",
                     G_CALLBACK (clipboard_targets_changed_cb), window);
 
-  terminal_window_fill_notebook_action_box (window);
+  terminal_window_fill_notebook_action_box (window, !use_headerbar);
 
   /* We have to explicitly call this, since screen-changed is NOT
    * emitted for the toplevel the first time!


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