From 94ab7e5ac6b282e07edf8966da5c69e4fdba0cc8 Mon Sep 17 00:00:00 2001
From: Adrien Plazas <kekun.plazas@laposte.net>
Date: Sat, 18 Jan 2020 09:16:32 +0100
Subject: [PATCH 048/124] main-toolbar: Split the folder header

Split it into a folder header and a conversations header. This is needed
to properly split the 3 panes.

Fixes https://gitlab.gnome.org/GNOME/geary/issues/442.
---
 src/client/components/main-toolbar.vala |  12 ++-
 ui/main-toolbar.ui                      | 108 +++++++++++++++---------
 2 files changed, 77 insertions(+), 43 deletions(-)

diff --git a/src/client/components/main-toolbar.vala b/src/client/components/main-toolbar.vala
index aa263253..4ee02079 100644
--- a/src/client/components/main-toolbar.vala
+++ b/src/client/components/main-toolbar.vala
@@ -28,10 +28,14 @@ public class MainToolbar : Gtk.Box {
     [GtkChild]
     private Gtk.HeaderBar folder_header;
     [GtkChild]
-    private Gtk.ToggleButton search_conversations_button;
-    [GtkChild]
     private Gtk.MenuButton main_menu_button;
 
+    // Conversations header elements
+    [GtkChild]
+    private Gtk.HeaderBar conversations_header;
+    [GtkChild]
+    private Gtk.ToggleButton search_conversations_button;
+
     // Conversation header elements
     [GtkChild]
     private Gtk.HeaderBar conversation_header;
@@ -60,8 +64,8 @@ public class MainToolbar : Gtk.Box {
 
     public MainToolbar(Application.Configuration config) {
         if (config.desktop_environment != UNITY) {
-            this.bind_property("account", this.folder_header, "title", BindingFlags.SYNC_CREATE);
-            this.bind_property("folder", this.folder_header, "subtitle", BindingFlags.SYNC_CREATE);
+            this.bind_property("account", this.conversations_header, "title", BindingFlags.SYNC_CREATE);
+            this.bind_property("folder", this.conversations_header, "subtitle", BindingFlags.SYNC_CREATE);
         }
 
         // Assemble the main/mark menus
diff --git a/ui/main-toolbar.ui b/ui/main-toolbar.ui
index 874f5b4b..732a01b9 100644
--- a/ui/main-toolbar.ui
+++ b/ui/main-toolbar.ui
@@ -11,68 +11,97 @@
     <property name="visible">True</property>
     <property name="can_focus">False</property>
     <child>
-      <object class="GtkHeaderBar" id="folder_header">
+      <object class="GtkBox">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
-        <property name="show_close_button" bind-source="MainToolbar" bind-property="show_close_button" bind-flags="sync-create"/>
         <child>
-          <object class="GtkButton" id="compose_new_message_button">
+          <object class="GtkHeaderBar" id="folder_header">
             <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="focus_on_click">False</property>
-            <property name="receives_default">False</property>
-            <property name="tooltip_text" translatable="yes" context="tooltip">Compose Message</property>
-            <property name="action_name">app.compose</property>
-            <property name="always_show_image">True</property>
+            <property name="can_focus">False</property>
+            <property name="show_close_button" bind-source="MainToolbar" bind-property="show_close_button" bind-flags="sync-create"/>
+            <property name="title">Mail</property>
             <child>
-              <object class="GtkImage" id="compose_new_message_image">
+              <object class="GtkMenuButton" id="main_menu_button">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="icon_name">text-editor-symbolic</property>
+                <property name="can_focus">True</property>
+                <property name="focus_on_click">False</property>
+                <property name="receives_default">False</property>
+                <property name="always_show_image">True</property>
+                <child>
+                  <object class="GtkImage" id="main_menu_image">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="icon_name">open-menu-symbolic</property>
+                  </object>
+                </child>
               </object>
+              <packing>
+                <property name="pack_type">end</property>
+                <property name="position">1</property>
+              </packing>
             </child>
           </object>
         </child>
         <child>
-          <object class="GtkMenuButton" id="main_menu_button">
+          <object class="GtkSeparator" id="folder_separator">
             <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="focus_on_click">False</property>
-            <property name="receives_default">False</property>
-            <property name="always_show_image">True</property>
-            <child>
-              <object class="GtkImage" id="main_menu_image">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="icon_name">open-menu-symbolic</property>
-              </object>
-            </child>
+            <property name="can_focus">False</property>
+            <property name="orientation">vertical</property>
+            <style>
+              <class name="sidebar"/>
+            </style>
           </object>
           <packing>
-            <property name="pack_type">end</property>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
             <property name="position">1</property>
           </packing>
         </child>
         <child>
-          <object class="GtkToggleButton" id="search_conversations_button">
+          <object class="GtkHeaderBar" id="conversations_header">
             <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="focus_on_click">False</property>
-            <property name="receives_default">False</property>
-            <property name="tooltip_text" translatable="yes">Toggle search bar</property>
-            <property name="always_show_image">True</property>
+            <property name="can_focus">False</property>
+            <property name="show_close_button" bind-source="MainToolbar" bind-property="show_close_button" bind-flags="sync-create"/>
             <child>
-              <object class="GtkImage" id="search_conversations_image">
+              <object class="GtkButton" id="compose_new_message_button">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="icon_name">preferences-system-search-symbolic</property>
+                <property name="can_focus">True</property>
+                <property name="focus_on_click">False</property>
+                <property name="receives_default">False</property>
+                <property name="tooltip_text" translatable="yes" context="tooltip">Compose Message</property>
+                <property name="action_name">app.compose</property>
+                <property name="always_show_image">True</property>
+                <child>
+                  <object class="GtkImage" id="compose_new_message_image">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="icon_name">text-editor-symbolic</property>
+                  </object>
+                </child>
               </object>
             </child>
+            <child>
+              <object class="GtkToggleButton" id="search_conversations_button">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="focus_on_click">False</property>
+                <property name="receives_default">False</property>
+                <property name="tooltip_text" translatable="yes">Toggle search bar</property>
+                <property name="always_show_image">True</property>
+                <child>
+                  <object class="GtkImage" id="search_conversations_image">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="icon_name">preferences-system-search-symbolic</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="pack_type">end</property>
+                <property name="position">3</property>
+              </packing>
+            </child>
           </object>
-          <packing>
-            <property name="pack_type">end</property>
-            <property name="position">3</property>
-          </packing>
         </child>
       </object>
       <packing>
@@ -82,7 +111,7 @@
       </packing>
     </child>
     <child>
-      <object class="GtkSeparator" id="header_separator">
+      <object class="GtkSeparator" id="conversations_separator">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="orientation">vertical</property>
@@ -342,6 +371,7 @@
   <object class="HdyHeaderGroup" id="header_group">
     <headerbars>
       <headerbar name="folder_header"/>
+      <headerbar name="conversations_header"/>
       <headerbar name="conversation_header"/>
     </headerbars>
   </object>
-- 
2.29.2

