[evolution] I#2039 - Add option to disable use of header bars



commit c12bb7fa4380a28992fb99ad9e7173305b5065bc
Author: Milan Crha <mcrha redhat com>
Date:   Thu Sep 22 11:09:19 2022 +0200

    I#2039 - Add option to disable use of header bars
    
    Users can use:
    
       gsettings set org.gnome.evolution.shell use-header-bar false
    
    to turn off header bars.
    
    Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/2039

 data/org.gnome.evolution.shell.gschema.xml.in      |  16 ++
 data/ui/evolution-calendars.ui                     |   6 +-
 data/ui/evolution-mail-reader.ui                   |  21 +-
 .../evolution-util/evolution-util-docs.sgml.in     |   2 +
 .../gui/contact-editor/contact-editor.ui           | 148 +++++------
 .../gui/contact-editor/e-contact-editor-fullname.c |   2 +-
 .../gui/contact-editor/e-contact-editor.c          |  86 ++++++-
 src/calendar/gui/e-comp-editor.c                   |  20 +-
 src/composer/e-composer-actions.c                  |  18 ++
 src/composer/e-composer-actions.h                  |   4 +
 src/composer/e-composer-private.c                  |  28 ++-
 src/composer/evolution-composer.ui                 |  10 +
 src/e-util/CMakeLists.txt                          |   8 +-
 src/e-util/e-attachment-dialog.c                   |   3 +-
 src/e-util/e-categories-dialog.c                   |   3 +-
 src/e-util/e-categories-editor.c                   |   2 +-
 src/e-util/e-category-editor.c                     |   2 +-
 src/e-util/e-html-editor.c                         |   4 +-
 src/e-util/e-image-chooser-dialog.c                |   2 +-
 src/e-util/e-import-assistant.c                    |   2 +-
 src/e-util/e-mail-signature-editor.c               |  56 +++--
 src/e-util/e-mail-signature-script-dialog.c        |   4 +-
 src/e-util/e-markdown-editor.c                     |   2 +-
 src/e-util/e-menu-tool-action.c                    |  57 +++++
 src/e-util/e-menu-tool-action.h                    |  73 ++++++
 src/e-util/e-menu-tool-button.c                    | 275 +++++++++++++++++++++
 src/e-util/e-menu-tool-button.h                    |  78 ++++++
 src/e-util/e-misc-utils.c                          |  40 +++
 src/e-util/e-misc-utils.h                          |   3 +
 src/e-util/e-preferences-window.c                  |  63 ++++-
 src/e-util/e-source-selector-dialog.c              |   3 +-
 src/e-util/e-tree-view-frame.c                     |   2 +-
 src/e-util/e-util-enums.h                          |   6 +
 src/e-util/e-util.h                                |   4 +-
 src/mail/e-mail-browser.c                          |  15 +-
 src/mail/e-mail-folder-create-dialog.c             |   2 +-
 src/mail/e-mail-folder-sort-order-dialog.c         |   5 +-
 src/mail/e-mail-label-dialog.c                     |   3 +-
 src/mail/e-mail-notes.c                            |  51 ++--
 src/mail/e-mail-reader.c                           |  47 +++-
 src/mail/em-folder-selector.c                      |   2 +-
 src/mail/em-subscription-editor.c                  |  24 +-
 src/modules/calendar/e-cal-shell-view-private.c    |  25 +-
 src/modules/mail/e-mail-shell-view-private.c       | 155 ++++++++----
 src/modules/mail/e-mail-shell-view-private.h       |   3 +
 src/shell/e-shell-window-actions.c                 |   2 +-
 src/shell/e-shell-window-private.c                 |  62 +++--
 src/shell/e-shell-window.c                         | 116 ++++++++-
 src/shell/e-shell.c                                |   8 +
 49 files changed, 1315 insertions(+), 258 deletions(-)
---
diff --git a/data/org.gnome.evolution.shell.gschema.xml.in b/data/org.gnome.evolution.shell.gschema.xml.in
index dd1291e7a4..6a9b10356a 100644
--- a/data/org.gnome.evolution.shell.gschema.xml.in
+++ b/data/org.gnome.evolution.shell.gschema.xml.in
@@ -1,4 +1,10 @@
 <schemalist>
+  <!-- Keep this synchronized with EToolbarIconSize. -->
+  <enum id="org.gnome.evolution.shell.ToolbarIconSize">
+    <value nick='default' value='0'/>
+    <value nick='small'   value='1'/>
+    <value nick='large'   value='2'/>
+  </enum>
   <schema gettext-domain="evolution" id="org.gnome.evolution.shell" path="/org/gnome/evolution/shell/">
     <key name="skip-warning-dialog" type="b">
       <default>false</default>
@@ -140,6 +146,16 @@
       <_summary>Set of additional illegal characters in the filename</_summary>
       <_description>When generating file names from custom strings some non-printable or reserved characters 
are replaced with an underscore. Here's a set of additional characters to be replaced.</_description>
     </key>
+    <key name="toolbar-icon-size" enum="org.gnome.evolution.shell.ToolbarIconSize">
+      <default>'default'</default>
+      <_summary>Override toolbar icon size</_summary>
+      <_description>Controls the toolbar icon size. The 'default' value lets the system/code decide what is 
the best icon size for the toolbar. Changing the option requires application restart.</_description>
+    </key>
+    <key name="use-header-bar" type="b">
+      <default>true</default>
+      <_summary>Whether to use header bar in the application</_summary>
+      <_description>When enabled, adds buttons to the header bar and uses it also for the dialogs. Changing 
the option requires application restart.</_description>
+    </key>
     <child name="window" schema="org.gnome.evolution.window"/>
   </schema>
 </schemalist>
diff --git a/data/ui/evolution-calendars.ui b/data/ui/evolution-calendars.ui
index 7aa1ca3159..9c9d5cc6ec 100644
--- a/data/ui/evolution-calendars.ui
+++ b/data/ui/evolution-calendars.ui
@@ -1,4 +1,4 @@
-<ui evolution-ui-version="1.1">
+<ui evolution-ui-version="1.2">
   <menubar name='main-menu'>
     <menu action='file-menu'>
       <placeholder name='file-actions'>
@@ -59,6 +59,10 @@
     <toolitem action='calendar-print'/>
     <toolitem action='delete-selection'/>
     <separator/>
+    <toolitem action='calendar-go-back'/>
+    <toolitem action='calendar-go-today'/>
+    <toolitem action='calendar-go-forward'/>
+    <separator/>
     <toolitem action='calendar-jump-to'/>
     <separator/>
     <toolitem action='calendar-view-day'/>
diff --git a/data/ui/evolution-mail-reader.ui b/data/ui/evolution-mail-reader.ui
index f135d7c355..b8f4e45d0a 100644
--- a/data/ui/evolution-mail-reader.ui
+++ b/data/ui/evolution-mail-reader.ui
@@ -1,4 +1,4 @@
-<ui evolution-ui-version="1.2">
+<ui evolution-ui-version="1.3">
   <accelerator action='mail-smart-backward'/>
   <accelerator action='mail-smart-forward'/>
 
@@ -137,6 +137,25 @@
   </menubar>
   <toolbar name='main-toolbar'>
     <placeholder name='mail-toolbar-common'>
+      <toolitem action='mail-reply-sender'/>
+      <toolitem action='toolbar-mail-reply-group'>
+        <menu action='mail-reply-group-menu'>
+          <menuitem action='mail-reply-all'/>
+          <menuitem action='mail-reply-list'/>
+          <menu action='mail-reply-template'/>
+          <menuitem action='mail-reply-alternative'/>
+        </menu>
+      </toolitem>
+      <toolitem action='toolbar-mail-forward'>
+        <menu action='mail-forward-as-menu'>
+          <menuitem action='mail-forward-attached-full'/>
+          <menuitem action='mail-forward-inline-full'/>
+          <menuitem action='mail-forward-quoted-full'/>
+          <separator/>
+          <menuitem action='mail-redirect'/>
+        </menu>
+      </toolitem>
+      <separator/>
       <toolitem action='mail-print'/>
       <toolitem action='mail-delete'/>
       <toolitem action='mail-mark-junk'/>
diff --git a/docs/reference/evolution-util/evolution-util-docs.sgml.in 
b/docs/reference/evolution-util/evolution-util-docs.sgml.in
index 1f13919787..55639790cf 100644
--- a/docs/reference/evolution-util/evolution-util-docs.sgml.in
+++ b/docs/reference/evolution-util/evolution-util-docs.sgml.in
@@ -285,6 +285,8 @@
     <xi:include href="xml/e-map.xml"/>
     <xi:include href="xml/e-markdown-editor.xml"/>
     <xi:include href="xml/e-menu-bar.xml"/>
+    <xi:include href="xml/e-menu-tool-action.xml"/>
+    <xi:include href="xml/e-menu-tool-button.xml"/>
     <xi:include href="xml/e-mktemp.xml"/>
     <xi:include href="xml/e-month-widget.xml"/>
     <xi:include href="xml/e-name-selector-dialog.xml"/>
diff --git a/src/addressbook/gui/contact-editor/contact-editor.ui 
b/src/addressbook/gui/contact-editor/contact-editor.ui
index 3fc8996e8b..86600c4eef 100644
--- a/src/addressbook/gui/contact-editor/contact-editor.ui
+++ b/src/addressbook/gui/contact-editor/contact-editor.ui
@@ -119,93 +119,66 @@
       <column type="gchararray"/>
     </columns>
   </object>
-  <object class="GtkDialog" id="contact editor">
-    <property name="can_focus">False</property>
-    <property name="title" translatable="yes">Contact Editor</property>
-    <property name="window_position">center</property>
-    <property name="type_hint">dialog</property>
-    <property name="use-header-bar">1</property>
-    <child internal-child="vbox">
-      <object class="GtkBox" id="dialog-vbox1">
+  <object class="GtkMenuButton" id="button-config">
+    <property name="visible">True</property>
+    <property name="can_focus">True</property>
+    <property name="can_default">True</property>
+    <property name="receives_default">False</property>
+    <property name="tooltip_text" translatable="yes">Options</property>
+    <property name="halign">end</property>
+    <property name="valign">center</property>
+    <property name="use_underline">True</property>
+    <property name="direction">up</property>
+    <child>
+      <object class="GtkImage" id="gears-icon">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="icon_name">emblem-system-symbolic</property>
+        <property name="icon_size">1</property>
+      </object>
+    </child>
+    <style>
+      <class name="image-button"/>
+    </style>
+  </object>
+  <object class="GtkButton" id="button-cancel">
+    <property name="label" translatable="yes">_Cancel</property>
+    <property name="visible">True</property>
+    <property name="can_focus">True</property>
+    <property name="can_default">True</property>
+    <property name="receives_default">False</property>
+    <property name="use_underline">True</property>
+  </object>
+  <object class="GtkButton" id="button-ok">
+    <property name="label" translatable="yes">_Save</property>
+    <property name="visible">True</property>
+    <property name="can_focus">True</property>
+    <property name="can_default">True</property>
+    <property name="receives_default">False</property>
+    <property name="use_underline">True</property>
+  </object>
+  <object class="GtkButton" id="button-help">
+    <property name="visible">True</property>
+    <property name="can_focus">True</property>
+    <property name="can_default">True</property>
+    <property name="receives_default">False</property>
+    <property name="use_underline">True</property>
+    <child>
+      <object class="GtkImage" id="help-icon">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="icon_name">help-browser</property>
+        <property name="icon_size">1</property>
+      </object>
+    </child>
+    <style>
+      <class name="image-button"/>
+    </style>
+  </object>
+      <object class="GtkBox" id="contact-editor-box">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="orientation">vertical</property>
-        <child internal-child="headerbar">
-          <object class="GtkButtonBox" id="dialog-action_area1">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <child>
-              <object class="GtkButton" id="button-ok">
-                <property name="label" translatable="yes">_Save</property>
-                <property name="visible">True</property>
-                <property name="can-focus">True</property>
-                <property name="can-default">True</property>
-                <property name="has-default">True</property>
-                <property name="receives-default">False</property>
-                <property name="use-underline">True</property>
-                <accelerator key="s" signal="clicked" modifiers="GDK_CONTROL_MASK"/>
-                <style>
-                  <class name="suggested-action"/>
-                </style>
-              </object>
-              <packing>
-                <property name="pack-type">start</property>
-                <property name="position">1</property>
-             </packing>
-            </child>
-            <child>
-              <object class="GtkMenuButton" id="button-config">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">False</property>
-                <property name="tooltip_text" translatable="yes">Options</property>
-                <property name="halign">end</property>
-                <property name="use_underline">True</property>
-                <property name="direction">up</property>
-                <child>
-                  <object class="GtkImage" id="gears-icon">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="icon_name">emblem-system-symbolic</property>
-                    <property name="icon_size">1</property>
-                  </object>
-                </child>
-                <style>
-                  <class name="image-button"/>
-                </style>
-              </object>
-              <packing>
-                <property name="pack-type">end</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="button-help">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">False</property>
-                <property name="use_underline">True</property>
-                <child>
-                  <object class="GtkImage" id="help-icon">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="icon_name">help-browser</property>
-                    <property name="icon_size">1</property>
-                  </object>
-                </child>
-                <style>
-                  <class name="image-button"/>
-                </style>
-              </object>
-              <packing>
-                <property name="pack-type">end</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-          </object>
-        </child>
         <child>
           <object class="GtkNotebook" id="notebook11">
             <property name="visible">True</property>
@@ -2361,12 +2334,7 @@
           </packing>
         </child>
       </object>
-    </child>
-    <action-widgets>
-      <action-widget response="-5">button-ok</action-widget>
-      <action-widget response="-11">button-help</action-widget>
-    </action-widgets>
-  </object>
+
   <object class="GtkListStore" id="model2">
     <columns>
       <!-- column-name gchararray -->
diff --git a/src/addressbook/gui/contact-editor/e-contact-editor-fullname.c 
b/src/addressbook/gui/contact-editor/e-contact-editor-fullname.c
index 08fb26e907..283305d795 100644
--- a/src/addressbook/gui/contact-editor/e-contact-editor-fullname.c
+++ b/src/addressbook/gui/contact-editor/e-contact-editor-fullname.c
@@ -244,7 +244,7 @@ e_contact_editor_fullname_new (GtkWindow *parent,
 {
        GtkWidget *widget = g_object_new (E_TYPE_CONTACT_EDITOR_FULLNAME,
                "transient-for", parent,
-               "use-header-bar", TRUE,
+               "use-header-bar", e_util_get_use_header_bar (),
                NULL);
 
        g_object_set (
diff --git a/src/addressbook/gui/contact-editor/e-contact-editor.c 
b/src/addressbook/gui/contact-editor/e-contact-editor.c
index 40258a9adb..7f816865d3 100644
--- a/src/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/src/addressbook/gui/contact-editor/e-contact-editor.c
@@ -3945,8 +3945,7 @@ init_all (EContactEditor *editor)
                GdkRectangle monitor_area;
                gint x = 0, y = 0, monitor, width, height;
 
-               window = e_builder_get_widget (
-                       editor->priv->builder, "contact editor");
+               window = editor->priv->app;
 
                gtk_widget_get_preferred_size (window, &tab_req, NULL);
                width = tab_req.width - 320 + 24;
@@ -4844,6 +4843,13 @@ file_save_and_close_cb (GtkWidget *widget,
        save_contact (ce, TRUE);
 }
 
+static void
+file_cancel_cb (GtkWidget *widget,
+                EContactEditor *ce)
+{
+       eab_editor_close (EAB_EDITOR (ce));
+}
+
 /* Callback used when the dialog box is destroyed */
 static gint
 app_delete_event_cb (GtkWidget *widget,
@@ -5044,6 +5050,7 @@ e_contact_editor_init (EContactEditor *e_contact_editor)
        GtkWidget *container;
        GtkWidget *widget, *label, *dyntable;
        GtkEntryCompletion *completion;
+       GtkAccelGroup *accel_group;
 
        e_contact_editor->priv = G_TYPE_INSTANCE_GET_PRIVATE (
                e_contact_editor, E_TYPE_CONTACT_EDITOR, EContactEditorPrivate);
@@ -5080,14 +5087,62 @@ e_contact_editor_init (EContactEditor *e_contact_editor)
 
        setup_tab_order (builder);
 
-       e_contact_editor->priv->app =
-               e_builder_get_widget (builder, "contact editor");
-       widget = e_contact_editor->priv->app;
+       e_contact_editor->priv->app = g_object_new (GTK_TYPE_DIALOG,
+               "window-position", GTK_WIN_POS_CENTER,
+               "can-focus", FALSE,
+               "title", _("Contact Editor"),
+               "use-header-bar", e_util_get_use_header_bar (),
+               NULL);
 
-       gtk_window_set_type_hint (
-               GTK_WINDOW (widget), GDK_WINDOW_TYPE_HINT_NORMAL);
-       container = gtk_dialog_get_content_area (GTK_DIALOG (widget));
+       gtk_window_set_type_hint (GTK_WINDOW (e_contact_editor->priv->app), GDK_WINDOW_TYPE_HINT_NORMAL);
+       container = gtk_dialog_get_action_area (GTK_DIALOG (e_contact_editor->priv->app));
+       gtk_container_set_border_width (GTK_CONTAINER (container), 12);
+       container = gtk_dialog_get_content_area (GTK_DIALOG (e_contact_editor->priv->app));
        gtk_container_set_border_width (GTK_CONTAINER (container), 0);
+       widget = e_builder_get_widget (builder, "contact-editor-box");
+       gtk_container_add (GTK_CONTAINER (container), widget);
+
+       if (e_util_get_use_header_bar ()) {
+               container = gtk_dialog_get_header_bar (GTK_DIALOG (e_contact_editor->priv->app));
+
+               widget = e_builder_get_widget (builder, "button-ok");
+               gtk_header_bar_pack_start (GTK_HEADER_BAR (container), widget);
+
+               widget = e_builder_get_widget (builder, "button-config");
+               gtk_header_bar_pack_end (GTK_HEADER_BAR (container), widget);
+
+               widget = e_builder_get_widget (builder, "button-help");
+               gtk_header_bar_pack_end (GTK_HEADER_BAR (container), widget);
+       } else {
+               container = gtk_dialog_get_action_area (GTK_DIALOG (e_contact_editor->priv->app));
+
+               widget = e_builder_get_widget (builder, "button-config");
+               gtk_box_pack_end (GTK_BOX (container), widget, FALSE, FALSE, 0);
+               gtk_widget_set_valign (widget, GTK_ALIGN_FILL);
+
+               widget = e_builder_get_widget (builder, "button-cancel");
+               gtk_dialog_add_action_widget (GTK_DIALOG (e_contact_editor->priv->app), widget, 
GTK_RESPONSE_CANCEL);
+               gtk_widget_set_valign (widget, GTK_ALIGN_FILL);
+
+               widget = e_builder_get_widget (builder, "button-ok");
+               gtk_dialog_add_action_widget (GTK_DIALOG (e_contact_editor->priv->app), widget, 
GTK_RESPONSE_OK);
+               gtk_widget_set_valign (widget, GTK_ALIGN_FILL);
+
+               widget = e_builder_get_widget (builder, "button-help");
+               gtk_button_set_label (GTK_BUTTON (widget), _("_Help"));
+               gtk_style_context_remove_class (gtk_widget_get_style_context (widget), "image-button");
+               gtk_dialog_add_action_widget (GTK_DIALOG (e_contact_editor->priv->app), widget, 
GTK_RESPONSE_HELP);
+               gtk_widget_set_valign (widget, GTK_ALIGN_FILL);
+       }
+
+       accel_group = gtk_accel_group_new ();
+       widget = e_builder_get_widget (builder, "button-ok");
+       gtk_widget_grab_default (widget);
+       gtk_widget_add_accelerator (
+               widget, "clicked", accel_group,
+               's', GDK_CONTROL_MASK, 0);
+       gtk_window_add_accel_group (GTK_WINDOW (e_contact_editor->priv->app), accel_group);
+       g_clear_object (&accel_group);
 
        init_all (e_contact_editor);
 
@@ -5118,13 +5173,20 @@ e_contact_editor_init (EContactEditor *e_contact_editor)
        gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
        widget = e_builder_get_widget (
                e_contact_editor->priv->builder, "button-ok");
-       /* Already set in UI file but not working */
-       gtk_style_context_add_class (
-               gtk_widget_get_style_context (widget),
-               "suggested-action");
+       if (e_util_get_use_header_bar ()) {
+               /* Already set in the .ui file, but does not work */
+               gtk_style_context_add_class (
+                       gtk_widget_get_style_context (widget),
+                       "suggested-action");
+       }
        g_signal_connect (
                widget, "clicked",
                G_CALLBACK (file_save_and_close_cb), e_contact_editor);
+       widget = e_builder_get_widget (
+               e_contact_editor->priv->builder, "button-cancel");
+       g_signal_connect (
+               widget, "clicked",
+               G_CALLBACK (file_cancel_cb), e_contact_editor);
        widget = e_builder_get_widget (
                e_contact_editor->priv->builder, "button-help");
        g_signal_connect (
diff --git a/src/calendar/gui/e-comp-editor.c b/src/calendar/gui/e-comp-editor.c
index 2192c5f6eb..89399e1fbc 100644
--- a/src/calendar/gui/e-comp-editor.c
+++ b/src/calendar/gui/e-comp-editor.c
@@ -2153,6 +2153,8 @@ e_comp_editor_constructed (GObject *object)
                "    </menu>"
                "  </menubar>"
                "  <toolbar name='main-toolbar'>"
+               "    <toolitem action='save-and-close'/>"
+               "    <toolitem action='save'/>"
                "    <toolitem action='print'/>"
                "    <separator/>"
                "    <toolitem action='undo'/>"
@@ -2437,14 +2439,26 @@ e_comp_editor_constructed (GObject *object)
        comp_editor->priv->menu_bar = e_menu_bar_new (GTK_MENU_BAR (widget), GTK_WINDOW (comp_editor), 
&menu_button);
        gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
 
-       widget = comp_editor_construct_header_bar (comp_editor, menu_button);
-       gtk_window_set_titlebar (GTK_WINDOW (comp_editor), widget);
+       if (e_util_get_use_header_bar ()) {
+               widget = comp_editor_construct_header_bar (comp_editor, menu_button);
+               gtk_window_set_titlebar (GTK_WINDOW (comp_editor), widget);
+
+               /* Destroy items from the toolbar, which are in the header bar */
+               widget = e_comp_editor_get_managed_widget (comp_editor, "/main-toolbar/save-and-close");
+               gtk_widget_destroy (widget);
+
+               widget = e_comp_editor_get_managed_widget (comp_editor, "/main-toolbar/save");
+               gtk_widget_destroy (widget);
+       } else if (menu_button) {
+               g_object_ref_sink (menu_button);
+               gtk_widget_destroy (menu_button);
+       }
 
        widget = e_comp_editor_get_managed_widget (comp_editor, "/main-toolbar");
        gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
        gtk_widget_show (widget);
 
-       gtk_toolbar_set_icon_size (GTK_TOOLBAR (widget), GTK_ICON_SIZE_BUTTON);
+       e_util_setup_toolbar_icon_size (GTK_TOOLBAR (widget), GTK_ICON_SIZE_BUTTON);
 
        gtk_style_context_add_class (
                gtk_widget_get_style_context (widget),
diff --git a/src/composer/e-composer-actions.c b/src/composer/e-composer-actions.c
index 9db085be45..d168f9202e 100644
--- a/src/composer/e-composer-actions.c
+++ b/src/composer/e-composer-actions.c
@@ -501,6 +501,22 @@ static GtkToggleActionEntry toggle_entries[] = {
          NULL,
          FALSE },
 
+       { "toolbar-prioritize-message",
+         "emblem-important",
+         NULL,
+         NULL,
+         NULL,
+         NULL,
+         FALSE },
+
+       { "toolbar-request-read-receipt",
+         "mail-forward",
+         NULL,
+         NULL,
+         NULL,
+         NULL,
+         FALSE },
+
        { "toolbar-smime-encrypt",
          "security-high",
          NULL,
@@ -670,6 +686,8 @@ e_composer_actions_init (EMsgComposer *composer)
 
        init_toolbar_option (PGP_SIGN, FALSE);
        init_toolbar_option (PGP_ENCRYPT, FALSE);
+       init_toolbar_option (PRIORITIZE_MESSAGE, TRUE);
+       init_toolbar_option (REQUEST_READ_RECEIPT, TRUE);
        init_toolbar_option (SMIME_SIGN, FALSE);
        init_toolbar_option (SMIME_ENCRYPT, FALSE);
 
diff --git a/src/composer/e-composer-actions.h b/src/composer/e-composer-actions.h
index 32bddbc470..07195e73c0 100644
--- a/src/composer/e-composer-actions.h
+++ b/src/composer/e-composer-actions.h
@@ -64,6 +64,10 @@
        E_COMPOSER_ACTION ((composer), "toolbar-pgp-encrypt")
 #define E_COMPOSER_ACTION_TOOLBAR_PGP_SIGN(composer) \
        E_COMPOSER_ACTION ((composer), "toolbar-pgp-sign")
+#define E_COMPOSER_ACTION_TOOLBAR_PRIORITIZE_MESSAGE(composer) \
+       E_COMPOSER_ACTION ((composer), "toolbar-prioritize-message")
+#define E_COMPOSER_ACTION_TOOLBAR_REQUEST_READ_RECEIPT(composer) \
+       E_COMPOSER_ACTION ((composer), "toolbar-request-read-receipt")
 #define E_COMPOSER_ACTION_TOOLBAR_SMIME_ENCRYPT(composer) \
        E_COMPOSER_ACTION ((composer), "toolbar-smime-encrypt")
 #define E_COMPOSER_ACTION_TOOLBAR_SMIME_SIGN(composer) \
diff --git a/src/composer/e-composer-private.c b/src/composer/e-composer-private.c
index 563547448f..6de29fad88 100644
--- a/src/composer/e-composer-private.c
+++ b/src/composer/e-composer-private.c
@@ -308,8 +308,32 @@ e_composer_private_constructed (EMsgComposer *composer)
        priv->menu_bar = e_menu_bar_new (GTK_MENU_BAR (widget), window, &menu_button);
        gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
 
-       widget = composer_construct_header_bar (composer, menu_button);
-       gtk_window_set_titlebar (window, widget);
+       if (e_util_get_use_header_bar ()) {
+               widget = composer_construct_header_bar (composer, menu_button);
+               gtk_window_set_titlebar (window, widget);
+
+               /* Destroy items from the toolbar, which are in the header bar */
+               widget = gtk_ui_manager_get_widget (ui_manager, "/main-toolbar/pre-main-toolbar/send");
+               gtk_widget_destroy (widget);
+
+               widget = gtk_ui_manager_get_widget (ui_manager, "/main-toolbar/pre-main-toolbar/save-draft");
+               gtk_widget_destroy (widget);
+
+               widget = gtk_ui_manager_get_widget (ui_manager, "/main-toolbar/toolbar-prioritize-message");
+               gtk_widget_destroy (widget);
+
+               widget = gtk_ui_manager_get_widget (ui_manager, "/main-toolbar/toolbar-request-read-receipt");
+               gtk_widget_destroy (widget);
+       } else {
+               /* We set the send button as important to have a label */
+               widget = gtk_ui_manager_get_widget (ui_manager, "/main-toolbar/pre-main-toolbar/send");
+               gtk_tool_item_set_is_important (GTK_TOOL_ITEM (widget), TRUE);
+
+               if (menu_button) {
+                       g_object_ref_sink (menu_button);
+                       gtk_widget_destroy (menu_button);
+               }
+       }
 
        widget = e_html_editor_get_managed_widget (editor, "/main-toolbar");
        gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
diff --git a/src/composer/evolution-composer.ui b/src/composer/evolution-composer.ui
index 3937287796..ae0367a82d 100644
--- a/src/composer/evolution-composer.ui
+++ b/src/composer/evolution-composer.ui
@@ -60,6 +60,16 @@
     </menu>
   </menubar>
   <toolbar name='main-toolbar'>
+    <placeholder name='pre-main-toolbar'>
+      <toolitem action='send'/>
+      <separator/>
+      <toolitem action='save-draft'/>
+      <separator/>
+    </placeholder>
+    <separator/>
+    <toolitem action='toolbar-prioritize-message'/>
+    <toolitem action='toolbar-request-read-receipt'/>
+    <separator/>
     <toolitem action='toolbar-pgp-sign'/>
     <toolitem action='toolbar-pgp-encrypt'/>
     <toolitem action='toolbar-smime-sign'/>
diff --git a/src/e-util/CMakeLists.txt b/src/e-util/CMakeLists.txt
index bf79e18567..66cae708c5 100644
--- a/src/e-util/CMakeLists.txt
+++ b/src/e-util/CMakeLists.txt
@@ -139,6 +139,7 @@ set(SOURCES
        e-focus-tracker.c
        e-gtkemojichooser.h
        e-gtkemojichooser.c
+       e-headerbar-button.c
        e-html-editor-actions.c
        e-html-editor-cell-dialog.c
        e-html-editor-dialog.c
@@ -172,8 +173,9 @@ set(SOURCES
        e-markdown-editor.c
        e-markdown-utils.c
        e-marshal.c
-       e-headerbar-button.c
        e-menu-bar.c
+       e-menu-tool-action.c
+       e-menu-tool-button.c
        e-misc-utils.c
        e-mktemp.c
        e-month-widget.c
@@ -419,6 +421,7 @@ set(HEADERS
        e-filter-part.h
        e-filter-rule.h
        e-focus-tracker.h
+       e-headerbar-button.h
        e-html-editor-actions.h
        e-html-editor-cell-dialog.h
        e-html-editor-dialog.h
@@ -450,8 +453,9 @@ set(HEADERS
        e-map.h
        e-markdown-editor.h
        e-markdown-utils.h
-       e-headerbar-button.h
        e-menu-bar.h
+       e-menu-tool-action.h
+       e-menu-tool-button.h
        e-misc-utils.h
        e-mktemp.h
        e-month-widget.h
diff --git a/src/e-util/e-attachment-dialog.c b/src/e-util/e-attachment-dialog.c
index 5cc94107b4..e21bcf8aae 100644
--- a/src/e-util/e-attachment-dialog.c
+++ b/src/e-util/e-attachment-dialog.c
@@ -20,6 +20,7 @@
 
 #include "evolution-config.h"
 
+#include "e-misc-utils.h"
 #include "e-attachment-dialog.h"
 
 #include <glib/gi18n.h>
@@ -377,7 +378,7 @@ e_attachment_dialog_new (GtkWindow *parent,
        return g_object_new (
                E_TYPE_ATTACHMENT_DIALOG,
                "transient-for", parent,
-               "use-header-bar", TRUE,
+               "use-header-bar", e_util_get_use_header_bar (),
                "attachment", attachment, NULL);
 }
 
diff --git a/src/e-util/e-categories-dialog.c b/src/e-util/e-categories-dialog.c
index f34e512af1..8d31831fad 100644
--- a/src/e-util/e-categories-dialog.c
+++ b/src/e-util/e-categories-dialog.c
@@ -29,6 +29,7 @@
 #include "e-categories-selector.h"
 #include "e-category-completion.h"
 #include "e-category-editor.h"
+#include "e-misc-utils.h"
 
 #define E_CATEGORIES_DIALOG_GET_PRIVATE(obj) \
        (G_TYPE_INSTANCE_GET_PRIVATE \
@@ -102,7 +103,7 @@ e_categories_dialog_new (const gchar *categories)
        ECategoriesDialog *dialog;
 
        dialog = g_object_new (E_TYPE_CATEGORIES_DIALOG,
-               "use-header-bar", TRUE,
+               "use-header-bar", e_util_get_use_header_bar (),
                NULL);
 
        if (categories)
diff --git a/src/e-util/e-categories-editor.c b/src/e-util/e-categories-editor.c
index b547dfc89b..d12bf2dd9f 100644
--- a/src/e-util/e-categories-editor.c
+++ b/src/e-util/e-categories-editor.c
@@ -157,7 +157,7 @@ edit_button_clicked_cb (GtkButton *button,
 
        cat_editor = g_object_new (E_TYPE_CATEGORY_EDITOR,
                "transient-for", parent,
-               "use-header-bar", TRUE,
+               "use-header-bar", e_util_get_use_header_bar (),
                NULL);
 
        category = e_categories_selector_get_selected (
diff --git a/src/e-util/e-category-editor.c b/src/e-util/e-category-editor.c
index d6559c12a6..7c45a37abf 100644
--- a/src/e-util/e-category-editor.c
+++ b/src/e-util/e-category-editor.c
@@ -279,7 +279,7 @@ ECategoryEditor *
 e_category_editor_new (void)
 {
        return g_object_new (E_TYPE_CATEGORY_EDITOR,
-               "use-header-bar", TRUE,
+               "use-header-bar", e_util_get_use_header_bar (),
                NULL);
 }
 
diff --git a/src/e-util/e-html-editor.c b/src/e-util/e-html-editor.c
index b2358e4a92..63d56a2cda 100644
--- a/src/e-util/e-html-editor.c
+++ b/src/e-util/e-html-editor.c
@@ -916,7 +916,7 @@ html_editor_constructed (GObject *object)
        widget = e_html_editor_get_managed_widget (editor, "/edit-toolbar");
        gtk_widget_set_hexpand (widget, TRUE);
        gtk_toolbar_set_style (GTK_TOOLBAR (widget), GTK_TOOLBAR_BOTH_HORIZ);
-       gtk_toolbar_set_icon_size (GTK_TOOLBAR (widget), GTK_ICON_SIZE_BUTTON);
+       e_util_setup_toolbar_icon_size (GTK_TOOLBAR (widget), GTK_ICON_SIZE_BUTTON);
        gtk_grid_attach (GTK_GRID (editor), widget, 0, 0, 1, 1);
        priv->edit_toolbar = g_object_ref (widget);
        gtk_widget_show (widget);
@@ -924,7 +924,7 @@ html_editor_constructed (GObject *object)
        widget = e_html_editor_get_managed_widget (editor, "/html-toolbar");
        gtk_widget_set_hexpand (widget, TRUE);
        gtk_toolbar_set_style (GTK_TOOLBAR (widget), GTK_TOOLBAR_BOTH_HORIZ);
-       gtk_toolbar_set_icon_size (GTK_TOOLBAR (widget), GTK_ICON_SIZE_BUTTON);
+       e_util_setup_toolbar_icon_size (GTK_TOOLBAR (widget), GTK_ICON_SIZE_BUTTON);
        gtk_grid_attach (GTK_GRID (editor), widget, 0, 1, 1, 1);
        priv->html_toolbar = g_object_ref (widget);
 
diff --git a/src/e-util/e-image-chooser-dialog.c b/src/e-util/e-image-chooser-dialog.c
index a0cc98a719..bbf1a8835c 100644
--- a/src/e-util/e-image-chooser-dialog.c
+++ b/src/e-util/e-image-chooser-dialog.c
@@ -228,7 +228,7 @@ e_image_chooser_dialog_new (const gchar *title,
                E_TYPE_IMAGE_CHOOSER_DIALOG,
                "action", GTK_FILE_CHOOSER_ACTION_OPEN,
                "title", title,
-               "use-header-bar", TRUE,
+               "use-header-bar", e_util_get_use_header_bar (),
                "transient-for", parent, NULL);
 }
 
diff --git a/src/e-util/e-import-assistant.c b/src/e-util/e-import-assistant.c
index 987515def1..a0eaa9794e 100644
--- a/src/e-util/e-import-assistant.c
+++ b/src/e-util/e-import-assistant.c
@@ -1510,7 +1510,7 @@ e_import_assistant_new (GtkWindow *parent)
 
        assistant = g_object_new (
                        E_TYPE_IMPORT_ASSISTANT,
-                       "use-header-bar", TRUE,
+                       "use-header-bar", e_util_get_use_header_bar (),
                        "transient-for", parent, NULL);
 
        import_assistant_construct (E_IMPORT_ASSISTANT (assistant));
diff --git a/src/e-util/e-mail-signature-editor.c b/src/e-util/e-mail-signature-editor.c
index deeea264dc..a1bd8bd670 100644
--- a/src/e-util/e-mail-signature-editor.c
+++ b/src/e-util/e-mail-signature-editor.c
@@ -23,6 +23,7 @@
 #include "e-alert-dialog.h"
 #include "e-alert-sink.h"
 #include "e-alert-bar.h"
+#include "e-misc-utils.h"
 #include "e-simple-async-result.h"
 
 #include "e-mail-signature-editor.h"
@@ -79,6 +80,11 @@ static const gchar *ui =
 "      </menu>\n"
 "    </placeholder>\n"
 "  </menubar>\n"
+"  <toolbar name='main-toolbar'>\n"
+"    <placeholder name='pre-main-toolbar'>\n"
+"      <toolitem action='save-and-close'/>\n"
+"    </placeholder>\n"
+"  </toolbar>\n"
 "</ui>";
 
 G_DEFINE_TYPE (
@@ -567,27 +573,43 @@ mail_signature_editor_constructed (GObject *object)
 
        container = widget;
 
-       /* Construct the main menu and toolbar. */
-
-       widget = gtk_header_bar_new ();
-       gtk_widget_show (widget);
-       header_bar = GTK_HEADER_BAR (widget);
-       gtk_header_bar_set_show_close_button (header_bar, TRUE);
-       gtk_header_bar_set_title (header_bar, _("Edit Signature"));
-       gtk_window_set_titlebar (GTK_WINDOW (window), widget);
-
-       action = gtk_action_group_get_action (window->priv->action_group, "save-and-close");
-       button = e_header_bar_button_new (_("Save"), action);
-       e_header_bar_button_css_add_class (E_HEADER_BAR_BUTTON (button), "suggested-action");
-       gtk_widget_show (button);
-       gtk_header_bar_pack_start (header_bar, button);
-
        widget = e_html_editor_get_managed_widget (editor, "/main-menu");
        window->priv->menu_bar = e_menu_bar_new (GTK_MENU_BAR (widget), GTK_WINDOW (window), &menu_button);
        gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
 
-       if (menu_button)
-               gtk_header_bar_pack_end (header_bar, menu_button);
+       /* Construct the main menu and toolbar. */
+
+       if (e_util_get_use_header_bar ()) {
+               widget = gtk_header_bar_new ();
+               gtk_widget_show (widget);
+               header_bar = GTK_HEADER_BAR (widget);
+               gtk_header_bar_set_show_close_button (header_bar, TRUE);
+               gtk_header_bar_set_title (header_bar, _("Edit Signature"));
+               gtk_window_set_titlebar (GTK_WINDOW (window), widget);
+
+               action = gtk_action_group_get_action (window->priv->action_group, "save-and-close");
+               button = e_header_bar_button_new (_("Save"), action);
+               e_header_bar_button_css_add_class (E_HEADER_BAR_BUTTON (button), "suggested-action");
+               gtk_widget_show (button);
+               gtk_header_bar_pack_start (header_bar, button);
+
+               if (menu_button)
+                       gtk_header_bar_pack_end (header_bar, menu_button);
+
+               widget = e_html_editor_get_managed_widget (editor, 
"/main-toolbar/pre-main-toolbar/save-and-close");
+               gtk_widget_destroy (widget);
+       } else {
+               gtk_window_set_title (GTK_WINDOW (window), _("Edit Signature"));
+
+               widget = e_html_editor_get_managed_widget (editor, "/main-toolbar");
+               gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+               gtk_widget_show (widget);
+
+               if (menu_button) {
+                       g_object_ref_sink (menu_button);
+                       gtk_widget_destroy (menu_button);
+               }
+       }
 
        /* Construct the signature name entry. */
 
diff --git a/src/e-util/e-mail-signature-script-dialog.c b/src/e-util/e-mail-signature-script-dialog.c
index d1d9044177..9f45e84ca3 100644
--- a/src/e-util/e-mail-signature-script-dialog.c
+++ b/src/e-util/e-mail-signature-script-dialog.c
@@ -19,6 +19,8 @@
 
 #include <glib/gi18n-lib.h>
 
+#include "e-misc-utils.h"
+
 #include "e-mail-signature-script-dialog.h"
 
 #define E_MAIL_SIGNATURE_SCRIPT_DIALOG_GET_PRIVATE(obj) \
@@ -554,7 +556,7 @@ e_mail_signature_script_dialog_new (ESourceRegistry *registry,
        return g_object_new (
                E_TYPE_MAIL_SIGNATURE_SCRIPT_DIALOG,
                "registry", registry,
-               "use-header-bar", TRUE,
+               "use-header-bar", e_util_get_use_header_bar (),
                "transient-for", parent,
                "source", source, NULL);
 }
diff --git a/src/e-util/e-markdown-editor.c b/src/e-util/e-markdown-editor.c
index 0aa5ada38c..256363c232 100644
--- a/src/e-util/e-markdown-editor.c
+++ b/src/e-util/e-markdown-editor.c
@@ -1854,7 +1854,7 @@ e_markdown_editor_constructed (GObject *object)
        #endif /* HAVE_MARKDOWN */
 
        widget = gtk_toolbar_new ();
-       gtk_toolbar_set_icon_size (GTK_TOOLBAR (widget), GTK_ICON_SIZE_SMALL_TOOLBAR);
+       e_util_setup_toolbar_icon_size (GTK_TOOLBAR (widget), GTK_ICON_SIZE_SMALL_TOOLBAR);
        gtk_widget_show (widget);
        gtk_notebook_set_action_widget (self->priv->notebook, widget, GTK_PACK_END);
 
diff --git a/src/e-util/e-menu-tool-action.c b/src/e-util/e-menu-tool-action.c
new file mode 100644
index 0000000000..97e52765b6
--- /dev/null
+++ b/src/e-util/e-menu-tool-action.c
@@ -0,0 +1,57 @@
+/*
+ * e-menu-tool-action.c
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "evolution-config.h"
+
+#include "e-menu-tool-action.h"
+
+G_DEFINE_TYPE (
+       EMenuToolAction,
+       e_menu_tool_action,
+       GTK_TYPE_ACTION)
+
+static void
+e_menu_tool_action_class_init (EMenuToolActionClass *class)
+{
+       GtkActionClass *action_class;
+
+       action_class = GTK_ACTION_CLASS (class);
+       action_class->toolbar_item_type = GTK_TYPE_MENU_TOOL_BUTTON;
+}
+
+static void
+e_menu_tool_action_init (EMenuToolAction *action)
+{
+}
+
+EMenuToolAction *
+e_menu_tool_action_new (const gchar *name,
+                        const gchar *label,
+                        const gchar *tooltip)
+{
+       g_return_val_if_fail (name != NULL, NULL);
+
+       return g_object_new (
+               E_TYPE_MENU_TOOL_ACTION,
+               "name", name,
+               "label", label,
+               "tooltip", tooltip,
+               NULL);
+}
diff --git a/src/e-util/e-menu-tool-action.h b/src/e-util/e-menu-tool-action.h
new file mode 100644
index 0000000000..1cb16a77aa
--- /dev/null
+++ b/src/e-util/e-menu-tool-action.h
@@ -0,0 +1,73 @@
+/*
+ * e-menu-tool-action.h
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+/* This is a trivial GtkAction subclass that sets the toolbar
+ * item type to GtkMenuToolButton instead of GtkToolButton. */
+
+#if !defined (__E_UTIL_H_INSIDE__) && !defined (LIBEUTIL_COMPILATION)
+#error "Only <e-util/e-util.h> should be included directly."
+#endif
+
+#ifndef E_MENU_TOOL_ACTION_H
+#define E_MENU_TOOL_ACTION_H
+
+#include <gtk/gtk.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MENU_TOOL_ACTION \
+       (e_menu_tool_action_get_type ())
+#define E_MENU_TOOL_ACTION(obj) \
+       (G_TYPE_CHECK_INSTANCE_CAST \
+       ((obj), E_TYPE_MENU_TOOL_ACTION, EMenuToolAction))
+#define E_MENU_TOOL_ACTION_CLASS(cls) \
+       (G_TYPE_CHECK_CLASS_CAST \
+       ((cls), E_TYPE_MENU_TOOL_ACTION, EMenuToolActionClass))
+#define E_IS_MENU_TOOL_ACTION(obj) \
+       (G_TYPE_CHECK_INSTANCE_TYPE \
+       ((obj), E_TYPE_MENU_TOOL_ACTION))
+#define E_IS_MENU_TOOL_ACTION_CLASS(cls) \
+       (G_TYPE_CHECK_CLASS_TYPE \
+       ((cls), E_TYPE_MENU_TOOL_ACTION))
+#define E_MENU_TOOL_ACTION_GET_CLASS(obj) \
+       (G_TYPE_INSTANCE_GET_CLASS \
+       ((obj), E_TYPE_MENU_TOOL_ACTION, EMenuToolActionClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EMenuToolAction EMenuToolAction;
+typedef struct _EMenuToolActionClass EMenuToolActionClass;
+
+struct _EMenuToolAction {
+       GtkAction parent;
+};
+
+struct _EMenuToolActionClass {
+       GtkActionClass parent_class;
+};
+
+GType          e_menu_tool_action_get_type     (void) G_GNUC_CONST;
+EMenuToolAction *
+               e_menu_tool_action_new          (const gchar *name,
+                                                const gchar *label,
+                                                const gchar *tooltip);
+
+G_END_DECLS
+
+#endif /* E_MENU_TOOL_ACTION_H */
diff --git a/src/e-util/e-menu-tool-button.c b/src/e-util/e-menu-tool-button.c
new file mode 100644
index 0000000000..235cfbf01b
--- /dev/null
+++ b/src/e-util/e-menu-tool-button.c
@@ -0,0 +1,275 @@
+/*
+ * e-menu-tool-button.c
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "evolution-config.h"
+
+#include "e-menu-tool-button.h"
+#include "e-misc-utils.h"
+
+#define E_MENU_TOOL_BUTTON_GET_PRIVATE(obj) \
+       (G_TYPE_INSTANCE_GET_PRIVATE \
+       ((obj), E_TYPE_MENU_TOOL_BUTTON, EMenuToolButtonPrivate))
+
+struct _EMenuToolButtonPrivate {
+       gchar *prefer_item;
+};
+
+enum {
+       PROP_0,
+       PROP_PREFER_ITEM
+};
+
+G_DEFINE_TYPE (
+       EMenuToolButton,
+       e_menu_tool_button,
+       GTK_TYPE_MENU_TOOL_BUTTON)
+
+static GtkWidget *
+menu_tool_button_clone_image (GtkWidget *source)
+{
+       GtkIconSize size;
+       GtkImageType image_type;
+       const gchar *icon_name;
+
+       /* XXX This isn't general purpose because it requires that the
+        *     source image be using a named icon.  Somewhat surprised
+        *     GTK+ doesn't offer something like this. */
+       image_type = gtk_image_get_storage_type (GTK_IMAGE (source));
+       g_return_val_if_fail (image_type == GTK_IMAGE_ICON_NAME, NULL);
+       gtk_image_get_icon_name (GTK_IMAGE (source), &icon_name, &size);
+
+       return gtk_image_new_from_icon_name (icon_name, size);
+}
+
+static GtkMenuItem *
+menu_tool_button_get_prefer_menu_item (GtkMenuToolButton *menu_tool_button)
+{
+       GtkWidget *menu;
+       GtkMenuItem *item = NULL;
+       GList *children;
+       const gchar *prefer_item;
+
+       menu = gtk_menu_tool_button_get_menu (menu_tool_button);
+       if (!GTK_IS_MENU (menu))
+               return NULL;
+
+       children = gtk_container_get_children (GTK_CONTAINER (menu));
+       if (children == NULL)
+               return NULL;
+
+       prefer_item = e_menu_tool_button_get_prefer_item (
+               E_MENU_TOOL_BUTTON (menu_tool_button));
+       if (prefer_item != NULL && *prefer_item != '\0') {
+               GtkAction *action;
+               GList *link;
+
+               for (link = children; link != NULL; link = g_list_next (link)) {
+                       GtkWidget *child;
+                       const gchar *name;
+
+                       child = GTK_WIDGET (link->data);
+
+                       if (!GTK_IS_MENU_ITEM (child))
+                               continue;
+
+                       action = gtk_activatable_get_related_action (
+                               GTK_ACTIVATABLE (child));
+
+                       if (action != NULL)
+                               name = gtk_action_get_name (action);
+                       else
+                               name = gtk_widget_get_name (child);
+
+                       if (g_strcmp0 (name, prefer_item) == 0) {
+                               item = GTK_MENU_ITEM (child);
+                               break;
+                       }
+               }
+       }
+
+       if (item == NULL)
+               item = GTK_MENU_ITEM (children->data);
+
+       g_list_free (children);
+
+       return item;
+}
+
+static void
+menu_tool_button_update_button (GtkToolButton *tool_button)
+{
+       GtkMenuItem *menu_item;
+       GtkMenuToolButton *menu_tool_button;
+       GtkImageMenuItem *image_menu_item;
+       GtkAction *action;
+       GtkWidget *image;
+       gchar *tooltip = NULL;
+
+       menu_tool_button = GTK_MENU_TOOL_BUTTON (tool_button);
+       menu_item = menu_tool_button_get_prefer_menu_item (menu_tool_button);
+       if (!GTK_IS_IMAGE_MENU_ITEM (menu_item))
+               return;
+
+       image_menu_item = GTK_IMAGE_MENU_ITEM (menu_item);
+       image = gtk_image_menu_item_get_image (image_menu_item);
+       if (!GTK_IS_IMAGE (image))
+               return;
+
+       image = menu_tool_button_clone_image (image);
+       gtk_tool_button_set_icon_widget (tool_button, image);
+       gtk_widget_show (image);
+
+       /* If the menu item is a proxy for a GtkAction, extract
+        * the action's tooltip and use it as our own tooltip. */
+       action = gtk_activatable_get_related_action (
+               GTK_ACTIVATABLE (menu_item));
+       if (action != NULL)
+               g_object_get (action, "tooltip", &tooltip, NULL);
+       gtk_widget_set_tooltip_text (GTK_WIDGET (tool_button), tooltip);
+       g_free (tooltip);
+}
+
+static void
+menu_tool_button_clicked (GtkToolButton *tool_button)
+{
+       GtkMenuItem *menu_item;
+       GtkMenuToolButton *menu_tool_button;
+
+       menu_tool_button = GTK_MENU_TOOL_BUTTON (tool_button);
+       menu_item = menu_tool_button_get_prefer_menu_item (menu_tool_button);
+
+       if (GTK_IS_MENU_ITEM (menu_item))
+               gtk_menu_item_activate (menu_item);
+}
+
+static void
+menu_tool_button_set_property (GObject *object,
+                               guint property_id,
+                               const GValue *value,
+                               GParamSpec *pspec)
+{
+       switch (property_id) {
+               case PROP_PREFER_ITEM:
+                       e_menu_tool_button_set_prefer_item (
+                               E_MENU_TOOL_BUTTON (object),
+                               g_value_get_string (value));
+                       return;
+       }
+
+       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+menu_tool_button_get_property (GObject *object,
+                               guint property_id,
+                               GValue *value,
+                               GParamSpec *pspec)
+{
+       switch (property_id) {
+               case PROP_PREFER_ITEM:
+                       g_value_set_string (
+                               value, e_menu_tool_button_get_prefer_item (
+                               E_MENU_TOOL_BUTTON (object)));
+                       return;
+       }
+
+       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+menu_tool_button_finalize (GObject *object)
+{
+       EMenuToolButtonPrivate *priv;
+
+       priv = E_MENU_TOOL_BUTTON_GET_PRIVATE (object);
+
+       g_free (priv->prefer_item);
+
+       /* Chain up to parent's finalize() method. */
+       G_OBJECT_CLASS (e_menu_tool_button_parent_class)->finalize (object);
+}
+
+static void
+e_menu_tool_button_class_init (EMenuToolButtonClass *class)
+{
+       GObjectClass *object_class;
+       GtkToolButtonClass *tool_button_class;
+
+       g_type_class_add_private (class, sizeof (EMenuToolButtonPrivate));
+
+       object_class = G_OBJECT_CLASS (class);
+       object_class->set_property = menu_tool_button_set_property;
+       object_class->get_property = menu_tool_button_get_property;
+       object_class->finalize = menu_tool_button_finalize;
+
+       tool_button_class = GTK_TOOL_BUTTON_CLASS (class);
+       tool_button_class->clicked = menu_tool_button_clicked;
+
+       g_object_class_install_property (
+               object_class,
+               PROP_PREFER_ITEM,
+               g_param_spec_string (
+                       "prefer-item",
+                       "Prefer Item",
+                       "Name of an item to show instead of the first",
+                       NULL,
+                       G_PARAM_READWRITE));
+}
+
+static void
+e_menu_tool_button_init (EMenuToolButton *button)
+{
+       button->priv = E_MENU_TOOL_BUTTON_GET_PRIVATE (button);
+
+       button->priv->prefer_item = NULL;
+
+       e_signal_connect_notify (
+               button, "notify::menu",
+               G_CALLBACK (menu_tool_button_update_button), NULL);
+}
+
+GtkToolItem *
+e_menu_tool_button_new (const gchar *label)
+{
+       return g_object_new (E_TYPE_MENU_TOOL_BUTTON, "label", label, NULL);
+}
+
+const gchar *
+e_menu_tool_button_get_prefer_item (EMenuToolButton *button)
+{
+       g_return_val_if_fail (E_IS_MENU_TOOL_BUTTON (button), NULL);
+
+       return button->priv->prefer_item;
+}
+
+void
+e_menu_tool_button_set_prefer_item (EMenuToolButton *button,
+                                    const gchar *prefer_item)
+{
+       g_return_if_fail (E_IS_MENU_TOOL_BUTTON (button));
+
+       if (g_strcmp0 (button->priv->prefer_item, prefer_item) == 0)
+               return;
+
+       g_free (button->priv->prefer_item);
+       button->priv->prefer_item = g_strdup (prefer_item);
+
+       g_object_notify (G_OBJECT (button), "prefer-item");
+}
diff --git a/src/e-util/e-menu-tool-button.h b/src/e-util/e-menu-tool-button.h
new file mode 100644
index 0000000000..e8c276b565
--- /dev/null
+++ b/src/e-util/e-menu-tool-button.h
@@ -0,0 +1,78 @@
+/*
+ * e-menu-tool-button.h
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+/* EMenuToolButton is a variation of GtkMenuToolButton where the
+ * button icon always reflects the first menu item, and clicking
+ * the button activates the first menu item. */
+
+#if !defined (__E_UTIL_H_INSIDE__) && !defined (LIBEUTIL_COMPILATION)
+#error "Only <e-util/e-util.h> should be included directly."
+#endif
+
+#ifndef E_MENU_TOOL_BUTTON_H
+#define E_MENU_TOOL_BUTTON_H
+
+#include <gtk/gtk.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MENU_TOOL_BUTTON \
+       (e_menu_tool_button_get_type ())
+#define E_MENU_TOOL_BUTTON(obj) \
+       (G_TYPE_CHECK_INSTANCE_CAST \
+       ((obj), E_TYPE_MENU_TOOL_BUTTON, EMenuToolButton))
+#define E_MENU_TOOL_BUTTON_CLASS(cls) \
+       (G_TYPE_CHECK_CLASS_CAST \
+       ((cls), E_TYPE_MENU_TOOL_BUTTON, EMenuToolButtonClass))
+#define E_IS_MENU_TOOL_BUTTON(obj) \
+       (G_TYPE_CHECK_INSTANCE_TYPE \
+       ((obj), E_TYPE_MENU_TOOL_BUTTON))
+#define E_IS_MENU_TOOL_BUTTON_CLASS(cls) \
+       (G_TYPE_CHECK_CLASS_TYPE \
+       ((cls), E_TYPE_MENU_TOOL_BUTTON))
+#define E_MENU_TOOL_BUTTON_GET_CLASS(obj) \
+       (G_TYPE_INSTANCE_GET_CLASS \
+       ((obj), E_TYPE_MENU_TOOL_BUTTON, EMenuToolButtonClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EMenuToolButton EMenuToolButton;
+typedef struct _EMenuToolButtonPrivate EMenuToolButtonPrivate;
+typedef struct _EMenuToolButtonClass EMenuToolButtonClass;
+
+struct _EMenuToolButton {
+       GtkMenuToolButton parent;
+       EMenuToolButtonPrivate *priv;
+};
+
+struct _EMenuToolButtonClass {
+       GtkMenuToolButtonClass parent_class;
+};
+
+GType          e_menu_tool_button_get_type     (void) G_GNUC_CONST;
+GtkToolItem *  e_menu_tool_button_new          (const gchar *label);
+const gchar *  e_menu_tool_button_get_prefer_item
+                                               (EMenuToolButton *button);
+void           e_menu_tool_button_set_prefer_item
+                                               (EMenuToolButton *button,
+                                                const gchar *prefer_item);
+
+G_END_DECLS
+
+#endif /* E_MENU_TOOL_BUTTON_H */
diff --git a/src/e-util/e-misc-utils.c b/src/e-util/e-misc-utils.c
index 1b44aa88a7..557c452cd4 100644
--- a/src/e-util/e-misc-utils.c
+++ b/src/e-util/e-misc-utils.c
@@ -4925,3 +4925,43 @@ e_util_make_safe_filename (gchar *filename)
 
        g_free (illegal_chars);
 }
+
+gboolean
+e_util_setup_toolbar_icon_size (GtkToolbar *toolbar,
+                               GtkIconSize default_size)
+{
+       GSettings *settings;
+       EToolbarIconSize icon_size;
+
+       g_return_val_if_fail (GTK_IS_TOOLBAR (toolbar), FALSE);
+
+       settings = e_util_ref_settings ("org.gnome.evolution.shell");
+       icon_size = g_settings_get_enum (settings, "toolbar-icon-size");
+       g_object_unref (settings);
+
+       if (icon_size == E_TOOLBAR_ICON_SIZE_SMALL)
+               gtk_toolbar_set_icon_size (toolbar, GTK_ICON_SIZE_SMALL_TOOLBAR);
+       else if (icon_size == E_TOOLBAR_ICON_SIZE_LARGE)
+               gtk_toolbar_set_icon_size (toolbar, GTK_ICON_SIZE_LARGE_TOOLBAR);
+       else if (default_size != GTK_ICON_SIZE_INVALID && e_util_get_use_header_bar ())
+               gtk_toolbar_set_icon_size (toolbar, default_size);
+
+       return icon_size == E_TOOLBAR_ICON_SIZE_SMALL ||
+              icon_size == E_TOOLBAR_ICON_SIZE_LARGE;
+}
+
+gboolean
+e_util_get_use_header_bar (void)
+{
+       static gchar use_header_bar = -1;
+
+       if (use_header_bar == -1) {
+               GSettings *settings;
+
+               settings = e_util_ref_settings ("org.gnome.evolution.shell");
+               use_header_bar = g_settings_get_boolean (settings, "use-header-bar") ? 1 : 0;
+               g_object_unref (settings);
+       }
+
+       return use_header_bar != 0;
+}
diff --git a/src/e-util/e-misc-utils.h b/src/e-util/e-misc-utils.h
index 18819e27d6..79a0422ba6 100644
--- a/src/e-util/e-misc-utils.h
+++ b/src/e-util/e-misc-utils.h
@@ -354,6 +354,9 @@ const ESupportedLocales *
 void           e_util_ensure_scrolled_window_height
                                                (GtkScrolledWindow *scrolled_window);
 void           e_util_make_safe_filename       (gchar *filename);
+gboolean       e_util_setup_toolbar_icon_size  (GtkToolbar *toolbar,
+                                                GtkIconSize default_size);
+gboolean       e_util_get_use_header_bar       (void);
 
 G_END_DECLS
 
diff --git a/src/e-util/e-preferences-window.c b/src/e-util/e-preferences-window.c
index 1663aa1cc2..5df1c3061f 100644
--- a/src/e-util/e-preferences-window.c
+++ b/src/e-util/e-preferences-window.c
@@ -250,19 +250,22 @@ e_preferences_window_class_init (EPreferencesWindowClass *class)
 static void
 e_preferences_window_init (EPreferencesWindow *window)
 {
-       GtkWidget *header;
+       GtkWidget *header = NULL;
        GtkWidget *widget;
        GtkWidget *hbox;
+       GtkWidget *vbox;
 
        window->priv = E_PREFERENCES_WINDOW_GET_PRIVATE (window);
 
-       widget = gtk_header_bar_new ();
-       g_object_set (G_OBJECT (widget),
-               "show-close-button", TRUE,
-               "visible", TRUE,
-               NULL);
-       gtk_window_set_titlebar (GTK_WINDOW (window), widget);
-       header = widget;
+       if (e_util_get_use_header_bar ()) {
+               widget = gtk_header_bar_new ();
+               g_object_set (G_OBJECT (widget),
+                       "show-close-button", TRUE,
+                       "visible", TRUE,
+                       NULL);
+               gtk_window_set_titlebar (GTK_WINDOW (window), widget);
+               header = widget;
+       }
 
        widget = gtk_stack_new ();
        gtk_widget_show (widget);
@@ -288,11 +291,16 @@ e_preferences_window_init (EPreferencesWindow *window)
                NULL);
        gtk_container_add (GTK_CONTAINER (widget), window->priv->listbox);
 
+       vbox = g_object_new (GTK_TYPE_BOX,
+               "orientation", GTK_ORIENTATION_VERTICAL,
+               "visible", TRUE,
+               NULL);
        hbox = g_object_new (GTK_TYPE_BOX,
                "orientation", GTK_ORIENTATION_HORIZONTAL,
                "visible", TRUE,
                NULL);
-       gtk_container_add (GTK_CONTAINER (window), hbox);
+       gtk_container_add (GTK_CONTAINER (window), vbox);
+       gtk_container_add (GTK_CONTAINER (vbox), hbox);
        gtk_container_add (GTK_CONTAINER (hbox), widget);
        gtk_container_add (GTK_CONTAINER (hbox), window->priv->stack);
 
@@ -302,7 +310,42 @@ e_preferences_window_init (EPreferencesWindow *window)
        g_signal_connect_swapped (
                widget, "clicked",
                G_CALLBACK (preferences_window_help_clicked_cb), window);
-       gtk_header_bar_pack_end (GTK_HEADER_BAR (header), widget);
+       if (header) {
+               gtk_header_bar_pack_end (GTK_HEADER_BAR (header), widget);
+       } else {
+               GtkAccelGroup *accel_group;
+               GtkWidget *bbox;
+
+               bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
+               g_object_set (bbox,
+                       "layout-style", GTK_BUTTONBOX_END,
+                       "visible", TRUE,
+                       "margin-start", 6,
+                       "margin-end", 6,
+                       "margin-top", 6,
+                       "margin-bottom", 6,
+                       NULL);
+               gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_END);
+               gtk_container_add (GTK_CONTAINER (vbox), bbox);
+
+               gtk_box_pack_start (GTK_BOX (bbox), widget, FALSE, FALSE, 0);
+               gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (bbox), widget, TRUE);
+
+               widget = e_dialog_button_new_with_icon ("window-close", _("_Close"));
+               g_signal_connect_swapped (
+                       widget, "clicked",
+                       G_CALLBACK (gtk_widget_hide), window);
+               gtk_widget_set_can_default (widget, TRUE);
+               gtk_box_pack_start (GTK_BOX (bbox), widget, FALSE, FALSE, 0);
+               accel_group = gtk_accel_group_new ();
+               gtk_widget_add_accelerator (
+                       widget, "activate", accel_group,
+                       GDK_KEY_Escape, (GdkModifierType) 0,
+                       GTK_ACCEL_VISIBLE);
+               gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
+               gtk_widget_grab_default (widget);
+               gtk_widget_show (widget);
+       }
 
        gtk_window_set_title (GTK_WINDOW (window), _("Evolution Preferences"));
        gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
diff --git a/src/e-util/e-source-selector-dialog.c b/src/e-util/e-source-selector-dialog.c
index f5c86dd8f8..437dfb062b 100644
--- a/src/e-util/e-source-selector-dialog.c
+++ b/src/e-util/e-source-selector-dialog.c
@@ -22,6 +22,7 @@
 
 #include <glib/gi18n-lib.h>
 
+#include "e-misc-utils.h"
 #include "e-tree-view-frame.h"
 #include "e-source-selector.h"
 #include "e-source-selector-dialog.h"
@@ -362,7 +363,7 @@ e_source_selector_dialog_new (GtkWindow *parent,
 
        return g_object_new (
                E_TYPE_SOURCE_SELECTOR_DIALOG,
-               "use-header-bar", TRUE,
+               "use-header-bar", e_util_get_use_header_bar (),
                "transient-for", parent,
                "registry", registry,
                "extension-name", extension_name,
diff --git a/src/e-util/e-tree-view-frame.c b/src/e-util/e-tree-view-frame.c
index 8052e5d145..b801f604b3 100644
--- a/src/e-util/e-tree-view-frame.c
+++ b/src/e-util/e-tree-view-frame.c
@@ -584,7 +584,7 @@ tree_view_frame_constructed (GObject *object)
        widget = gtk_toolbar_new ();
        gtk_toolbar_set_show_arrow (GTK_TOOLBAR (widget), FALSE);
        gtk_toolbar_set_style (GTK_TOOLBAR (widget), GTK_TOOLBAR_ICONS);
-       gtk_toolbar_set_icon_size (GTK_TOOLBAR (widget), GTK_ICON_SIZE_MENU);
+       e_util_setup_toolbar_icon_size (GTK_TOOLBAR (widget), GTK_ICON_SIZE_MENU);
        gtk_box_pack_start (GTK_BOX (tree_view_frame), widget, FALSE, FALSE, 0);
        tree_view_frame->priv->inline_toolbar = g_object_ref (widget);
        gtk_widget_show (widget);
diff --git a/src/e-util/e-util-enums.h b/src/e-util/e-util-enums.h
index 18cd855ca0..32b553c7d4 100644
--- a/src/e-util/e-util-enums.h
+++ b/src/e-util/e-util-enums.h
@@ -658,6 +658,12 @@ typedef enum { /*< flags >*/
        E_MARKDOWN_HTML_TO_TEXT_FLAG_COMPOSER_QUIRKS    = 1 << 1
 } EMarkdownHTMLToTextFlags;
 
+typedef enum {
+       E_TOOLBAR_ICON_SIZE_DEFAULT     = 0,
+       E_TOOLBAR_ICON_SIZE_SMALL       = 1,
+       E_TOOLBAR_ICON_SIZE_LARGE       = 2
+} EToolbarIconSize;
+
 G_END_DECLS
 
 #endif /* E_UTIL_ENUMS_H */
diff --git a/src/e-util/e-util.h b/src/e-util/e-util.h
index 673293d9c3..ed9e9061d5 100644
--- a/src/e-util/e-util.h
+++ b/src/e-util/e-util.h
@@ -120,6 +120,7 @@
 #include <e-util/e-filter-part.h>
 #include <e-util/e-filter-rule.h>
 #include <e-util/e-focus-tracker.h>
+#include <e-util/e-headerbar-button.h>
 #ifndef E_UTIL_INCLUDE_WITHOUT_WEBKIT
 #include <e-util/e-html-editor-actions.h>
 #include <e-util/e-html-editor-cell-dialog.h>
@@ -155,8 +156,9 @@
 #include <e-util/e-map.h>
 #include <e-util/e-markdown-editor.h>
 #include <e-util/e-markdown-utils.h>
-#include <e-util/e-headerbar-button.h>
 #include <e-util/e-menu-bar.h>
+#include <e-util/e-menu-tool-action.h>
+#include <e-util/e-menu-tool-button.h>
 #include <e-util/e-misc-utils.h>
 #include <e-util/e-mktemp.h>
 #include <e-util/e-month-widget.h>
diff --git a/src/mail/e-mail-browser.c b/src/mail/e-mail-browser.c
index 90e61afacd..05241c5470 100644
--- a/src/mail/e-mail-browser.c
+++ b/src/mail/e-mail-browser.c
@@ -952,8 +952,17 @@ mail_browser_constructed (GObject *object)
        gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
        browser->priv->menu_bar = e_menu_bar_new (GTK_MENU_BAR (widget), GTK_WINDOW (browser), &menu_button);
 
-       widget = mail_browser_construct_header_bar (reader, menu_button);
-       gtk_window_set_titlebar (GTK_WINDOW (object), widget);
+       if (e_util_get_use_header_bar ()) {
+               widget = mail_browser_construct_header_bar (reader, menu_button);
+               gtk_window_set_titlebar (GTK_WINDOW (object), widget);
+
+               widget = gtk_ui_manager_get_widget (ui_manager, 
"/main-toolbar/mail-toolbar-common/mail-reply-sender");
+               if (widget)
+                       gtk_widget_destroy (widget);
+       } else if (menu_button) {
+               g_object_ref_sink (menu_button);
+               gtk_widget_destroy (menu_button);
+       }
 
        widget = gtk_ui_manager_get_widget (ui_manager, "/main-toolbar");
        gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
@@ -964,7 +973,7 @@ mail_browser_constructed (GObject *object)
                gtk_widget_get_style_context (widget),
                GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
 
-       gtk_toolbar_set_icon_size (GTK_TOOLBAR (widget), GTK_ICON_SIZE_BUTTON);
+       e_util_setup_toolbar_icon_size (GTK_TOOLBAR (widget), GTK_ICON_SIZE_BUTTON);
 
        gtk_box_pack_start (
                GTK_BOX (container),
diff --git a/src/mail/e-mail-folder-create-dialog.c b/src/mail/e-mail-folder-create-dialog.c
index c7cb30df62..152c867529 100644
--- a/src/mail/e-mail-folder-create-dialog.c
+++ b/src/mail/e-mail-folder-create-dialog.c
@@ -482,7 +482,7 @@ e_mail_folder_create_dialog_new (GtkWindow *parent,
        dialog = g_object_new (
                E_TYPE_MAIL_FOLDER_CREATE_DIALOG,
                "transient-for", parent,
-               "use-header-bar", TRUE,
+               "use-header-bar", e_util_get_use_header_bar (),
                "model", model,
                "session", session, NULL);
 
diff --git a/src/mail/e-mail-folder-sort-order-dialog.c b/src/mail/e-mail-folder-sort-order-dialog.c
index 8b143a552b..29f9a288d3 100644
--- a/src/mail/e-mail-folder-sort-order-dialog.c
+++ b/src/mail/e-mail-folder-sort-order-dialog.c
@@ -749,6 +749,9 @@ e_mail_folder_sort_order_dialog_constructed (GObject *object)
        g_clear_object (&session);
        g_clear_object (&model);
 
+       if (!e_util_get_use_header_bar ())
+               gtk_dialog_add_buttons (GTK_DIALOG (dialog), _("_Close"), GTK_RESPONSE_CANCEL, NULL);
+
        gtk_drag_source_set (dialog->priv->folder_tree, GDK_BUTTON1_MASK, row_targets, G_N_ELEMENTS 
(row_targets), GDK_ACTION_MOVE);
        gtk_drag_dest_set (dialog->priv->folder_tree, GTK_DEST_DEFAULT_MOTION, row_targets, G_N_ELEMENTS 
(row_targets), GDK_ACTION_MOVE);
 
@@ -856,7 +859,7 @@ e_mail_folder_sort_order_dialog_new (GtkWindow *parent,
 
        return g_object_new (E_TYPE_MAIL_FOLDER_SORT_ORDER_DIALOG,
                "transient-for", parent,
-               "use-header-bar", TRUE,
+               "use-header-bar", e_util_get_use_header_bar (),
                "store", store,
                "folder-uri", folder_uri,
                NULL);
diff --git a/src/mail/e-mail-label-dialog.c b/src/mail/e-mail-label-dialog.c
index 1286915b20..9f7849cc5e 100644
--- a/src/mail/e-mail-label-dialog.c
+++ b/src/mail/e-mail-label-dialog.c
@@ -20,6 +20,7 @@
 
 #include "evolution-config.h"
 
+#include "e-util/e-util.h"
 #include "e-mail-label-dialog.h"
 
 #include <glib/gi18n.h>
@@ -231,7 +232,7 @@ e_mail_label_dialog_new (GtkWindow *parent)
        return g_object_new (
                E_TYPE_MAIL_LABEL_DIALOG,
                "transient-for", parent,
-               "use-header-bar", TRUE,
+               "use-header-bar", e_util_get_use_header_bar (),
                 NULL);
 }
 
diff --git a/src/mail/e-mail-notes.c b/src/mail/e-mail-notes.c
index b30274dbef..8c464f070e 100644
--- a/src/mail/e-mail-notes.c
+++ b/src/mail/e-mail-notes.c
@@ -1095,6 +1095,11 @@ e_mail_notes_editor_new_with_editor (EHTMLEditor *html_editor,
                "      </menu>\n"
                "    </placeholder>\n"
                "  </menubar>\n"
+               "  <toolbar name='main-toolbar'>\n"
+               "    <placeholder name='pre-main-toolbar'>\n"
+               "      <toolitem action='save-and-close'/>\n"
+               "    </placeholder>\n"
+               "  </toolbar>\n"
                "</ui>";
 
        GtkActionEntry entries[] = {
@@ -1177,25 +1182,41 @@ e_mail_notes_editor_new_with_editor (EHTMLEditor *html_editor,
 
        /* Construct the window content. */
 
-       widget = gtk_header_bar_new ();
-       gtk_widget_show (widget);
-       header_bar = GTK_HEADER_BAR (widget);
-       gtk_header_bar_set_show_close_button (header_bar, TRUE);
-       gtk_header_bar_set_title (header_bar, _("Edit Message Note"));
-       gtk_window_set_titlebar (GTK_WINDOW (notes_editor), widget);
-
-       action = gtk_action_group_get_action (notes_editor->action_group, "save-and-close");
-       button = e_header_bar_button_new (_("Save"), action);
-       e_header_bar_button_css_add_class (E_HEADER_BAR_BUTTON (button), "suggested-action");
-       gtk_widget_show (button);
-       gtk_header_bar_pack_start (header_bar, button);
-
        widget = e_html_editor_get_managed_widget (notes_editor->editor, "/main-menu");
        notes_editor->menu_bar = e_menu_bar_new (GTK_MENU_BAR (widget), GTK_WINDOW (notes_editor), 
&menu_button);
        gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
 
-       if (menu_button)
-               gtk_header_bar_pack_end (header_bar, menu_button);
+       if (e_util_get_use_header_bar ()) {
+               widget = gtk_header_bar_new ();
+               gtk_widget_show (widget);
+               header_bar = GTK_HEADER_BAR (widget);
+               gtk_header_bar_set_show_close_button (header_bar, TRUE);
+               gtk_header_bar_set_title (header_bar, _("Edit Message Note"));
+               gtk_window_set_titlebar (GTK_WINDOW (notes_editor), widget);
+
+               action = gtk_action_group_get_action (notes_editor->action_group, "save-and-close");
+               button = e_header_bar_button_new (_("Save"), action);
+               e_header_bar_button_css_add_class (E_HEADER_BAR_BUTTON (button), "suggested-action");
+               gtk_widget_show (button);
+               gtk_header_bar_pack_start (header_bar, button);
+
+               widget = e_html_editor_get_managed_widget (notes_editor->editor, 
"/main-toolbar/pre-main-toolbar/save-and-close");
+               gtk_widget_destroy (widget);
+
+               if (menu_button)
+                       gtk_header_bar_pack_end (header_bar, menu_button);
+       } else {
+               gtk_window_set_title (GTK_WINDOW (notes_editor), _("Edit Message Note"));
+
+               widget = e_html_editor_get_managed_widget (notes_editor->editor, "/main-toolbar");
+               gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
+               gtk_widget_show (widget);
+
+               if (menu_button) {
+                       g_object_ref_sink (menu_button);
+                       gtk_widget_destroy (menu_button);
+               }
+       }
 
        widget = GTK_WIDGET (notes_editor->editor);
        g_object_set (G_OBJECT (widget),
diff --git a/src/mail/e-mail-reader.c b/src/mail/e-mail-reader.c
index 5b696e8dd3..dc3e6d1dd9 100644
--- a/src/mail/e-mail-reader.c
+++ b/src/mail/e-mail-reader.c
@@ -5178,6 +5178,7 @@ e_mail_reader_init (EMailReader *reader,
        GtkAction *action;
        const gchar *action_name;
        EMailDisplay *display;
+       EMenuToolAction *menu_tool_action;
        GSettings *settings;
 
        g_return_if_fail (E_IS_MAIL_READER (reader));
@@ -5216,6 +5217,44 @@ e_mail_reader_init (EMailReader *reader,
 
        mail_reader_init_charset_actions (reader, action_group);
 
+
+       /* The "mail-forward" action is special: it uses a GtkMenuToolButton
+        * for its toolbar item type.  So we have to create it separately. */
+
+       menu_tool_action = e_menu_tool_action_new (
+               "toolbar-mail-forward", _("_Forward"),
+               _("Forward the selected message to someone"));
+
+       gtk_action_set_icon_name (GTK_ACTION (menu_tool_action), "mail-forward");
+       gtk_action_set_visible (GTK_ACTION (menu_tool_action), !e_util_get_use_header_bar ());
+
+       g_signal_connect (
+               menu_tool_action, "activate",
+               G_CALLBACK (action_mail_forward_cb), reader);
+
+       gtk_action_group_add_action_with_accel (
+               action_group, GTK_ACTION (menu_tool_action), "<Control>f");
+
+       /* Likewise the "mail-reply-group" action. */
+
+       menu_tool_action = e_menu_tool_action_new (
+               /* Translators: "Group Reply" will reply either to a mailing list
+                * (if possible and if that configuration option is enabled), or else
+                * it will reply to all. The word "Group" was chosen because it covers
+                * either of those, without too strongly implying one or the other. */
+               "toolbar-mail-reply-group", _("Group Reply"),
+               _("Reply to the mailing list, or to all recipients"));
+
+       gtk_action_set_icon_name (GTK_ACTION (menu_tool_action), "mail-reply-all");
+       gtk_action_set_visible (GTK_ACTION (menu_tool_action), !e_util_get_use_header_bar ());
+
+       g_signal_connect (
+               menu_tool_action, "activate",
+               G_CALLBACK (action_mail_reply_group_cb), reader);
+
+       gtk_action_group_add_action_with_accel (
+               action_group, GTK_ACTION (menu_tool_action), "<Control>g");
+
        /* Add EMailReader actions for Search Folders.  The action group
         * should be made invisible if Search Folders are disabled. */
 
@@ -5259,11 +5298,13 @@ e_mail_reader_init (EMailReader *reader,
        action = e_mail_reader_get_action (reader, action_name);
        gtk_action_set_short_label (action, _("Delete"));
 
-       action_name = "mail-forward";
+       action_name = "toolbar-mail-forward";
        action = e_mail_reader_get_action (reader, action_name);
+       gtk_action_set_is_important (action, TRUE);
 
-       action_name = "mail-reply-group";
+       action_name = "toolbar-mail-reply-group";
        action = e_mail_reader_get_action (reader, action_name);
+       gtk_action_set_is_important (action, TRUE);
 
        action_name = "mail-next";
        action = e_mail_reader_get_action (reader, action_name);
@@ -5275,9 +5316,11 @@ e_mail_reader_init (EMailReader *reader,
 
        action_name = "mail-reply-all";
        action = e_mail_reader_get_action (reader, action_name);
+       gtk_action_set_is_important (action, TRUE);
 
        action_name = "mail-reply-sender";
        action = e_mail_reader_get_action (reader, action_name);
+       gtk_action_set_is_important (action, TRUE);
        gtk_action_set_short_label (action, _("Reply"));
 
        action_name = "add-to-address-book";
diff --git a/src/mail/em-folder-selector.c b/src/mail/em-folder-selector.c
index d93c6af16c..fcf3501543 100644
--- a/src/mail/em-folder-selector.c
+++ b/src/mail/em-folder-selector.c
@@ -558,7 +558,7 @@ em_folder_selector_new (GtkWindow *parent,
        return g_object_new (
                EM_TYPE_FOLDER_SELECTOR,
                "transient-for", parent,
-               "use-header-bar", TRUE,
+               "use-header-bar", e_util_get_use_header_bar (),
                "model", model, NULL);
 }
 
diff --git a/src/mail/em-subscription-editor.c b/src/mail/em-subscription-editor.c
index dd0b1df7f7..37531fba8a 100644
--- a/src/mail/em-subscription-editor.c
+++ b/src/mail/em-subscription-editor.c
@@ -1441,6 +1441,16 @@ subscription_editor_add_store (EMSubscriptionEditor *editor,
        g_ptr_array_add (editor->priv->stores, data);
 }
 
+static void
+emse_notebook_sensitive_changed_cb (GtkWidget *notebook,
+                                    GParamSpec *param,
+                                    GtkDialog *editor)
+{
+       gtk_dialog_set_response_sensitive (
+               editor, GTK_RESPONSE_CLOSE,
+               gtk_widget_get_sensitive (notebook));
+}
+
 static gboolean
 subscription_editor_delete_event_cb (EMSubscriptionEditor *editor,
                                      GdkEvent *event,
@@ -1719,6 +1729,12 @@ em_subscription_editor_init (EMSubscriptionEditor *editor)
                "/org/gnome/evolution/mail/subscription-window/",
                E_RESTORE_WINDOW_SIZE);
 
+       if (!e_util_get_use_header_bar ()) {
+               gtk_dialog_add_button (
+                       GTK_DIALOG (editor),
+                       _("_Close"), GTK_RESPONSE_CLOSE);
+       }
+
        container = gtk_dialog_get_content_area (GTK_DIALOG (editor));
 
        widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
@@ -1800,6 +1816,12 @@ em_subscription_editor_init (EMSubscriptionEditor *editor)
                G_BINDING_BIDIRECTIONAL |
                G_BINDING_SYNC_CREATE);
 
+       if (!e_util_get_use_header_bar ()) {
+               e_signal_connect_notify (
+                       widget, "notify::sensitive",
+                       G_CALLBACK (emse_notebook_sensitive_changed_cb), editor);
+       }
+
        widget = gtk_button_box_new (GTK_ORIENTATION_VERTICAL);
        gtk_box_set_spacing (GTK_BOX (widget), 6);
        gtk_button_box_set_layout (
@@ -1960,7 +1982,7 @@ em_subscription_editor_new (GtkWindow *parent,
                EM_TYPE_SUBSCRIPTION_EDITOR,
                "session", session,
                "store", initial_store,
-               "use-header-bar", TRUE,
+               "use-header-bar", e_util_get_use_header_bar (),
                "transient-for", parent,
                NULL);
 }
diff --git a/src/modules/calendar/e-cal-shell-view-private.c b/src/modules/calendar/e-cal-shell-view-private.c
index f01e288253..47ba997ba4 100644
--- a/src/modules/calendar/e-cal-shell-view-private.c
+++ b/src/modules/calendar/e-cal-shell-view-private.c
@@ -314,16 +314,21 @@ cal_shell_view_update_header_bar (ECalShellView *cal_shell_view)
 {
        EShellWindow *shell_window;
        EShellView *shell_view;
-       EShellHeaderBar *shell_headerbar;
+       EShellHeaderBar *shell_headerbar = NULL;
        GtkWidget *widget;
        GtkAction *action;
 
        shell_view = E_SHELL_VIEW (cal_shell_view);
        shell_window = e_shell_view_get_shell_window (shell_view);
-       shell_headerbar = E_SHELL_HEADER_BAR (gtk_window_get_titlebar (GTK_WINDOW (shell_window)));
+       widget = gtk_window_get_titlebar (GTK_WINDOW (shell_window));
+       if (E_IS_SHELL_HEADER_BAR (widget))
+               shell_headerbar = E_SHELL_HEADER_BAR (widget);
 
-       e_shell_header_bar_clear (shell_headerbar, "e-cal-shell-view");
-       if (!e_shell_view_is_active (shell_view))
+       if (shell_headerbar)
+               e_shell_header_bar_clear (shell_headerbar, "e-cal-shell-view");
+
+       if (!e_util_get_use_header_bar () ||
+           !e_shell_view_is_active (shell_view))
                return;
 
        action = ACTION (CALENDAR_GO_BACK);
@@ -338,6 +343,18 @@ cal_shell_view_update_header_bar (ECalShellView *cal_shell_view)
        e_header_bar_button_add_action (E_HEADER_BAR_BUTTON (widget), NULL, action);
 
        e_shell_header_bar_pack_end (shell_headerbar, widget);
+
+       widget = e_shell_window_get_managed_widget (shell_window, "/main-toolbar/calendar-go-back");
+       if (widget)
+               gtk_widget_destroy (widget);
+
+       widget = e_shell_window_get_managed_widget (shell_window, "/main-toolbar/calendar-go-today");
+       if (widget)
+               gtk_widget_destroy (widget);
+
+       widget = e_shell_window_get_managed_widget (shell_window, "/main-toolbar/calendar-go-forward");
+       if (widget)
+               gtk_widget_destroy (widget);
 }
 
 void
diff --git a/src/modules/mail/e-mail-shell-view-private.c b/src/modules/mail/e-mail-shell-view-private.c
index 55efd17c64..2c785a339e 100644
--- a/src/modules/mail/e-mail-shell-view-private.c
+++ b/src/modules/mail/e-mail-shell-view-private.c
@@ -1469,7 +1469,7 @@ e_mail_shell_view_update_send_receive_menus (EMailShellView *mail_shell_view)
        EShellWindow *shell_window;
        EShellView *shell_view;
        EMailView *mail_view;
-       EShellHeaderBar *shell_headerbar;
+       EShellHeaderBar *shell_headerbar = NULL;
        GtkWidget *widget;
        GtkAction *action;
        const gchar *action_name;
@@ -1479,11 +1479,33 @@ e_mail_shell_view_update_send_receive_menus (EMailShellView *mail_shell_view)
 
        shell_view = E_SHELL_VIEW (mail_shell_view);
        shell_window = e_shell_view_get_shell_window (shell_view);
-       shell_headerbar = E_SHELL_HEADER_BAR (gtk_window_get_titlebar (GTK_WINDOW (shell_window)));
-
-       e_shell_header_bar_clear (shell_headerbar, "e-mail-shell-view");
-       if (!e_shell_view_is_active (shell_view))
+       widget = gtk_window_get_titlebar (GTK_WINDOW (shell_window));
+       if (E_IS_SHELL_HEADER_BAR (widget))
+               shell_headerbar = E_SHELL_HEADER_BAR (widget);
+
+       if (shell_headerbar)
+               e_shell_header_bar_clear (shell_headerbar, "e-mail-shell-view");
+
+       if (!e_shell_view_is_active (shell_view)) {
+               if (mail_shell_view->priv->send_receive_tool_item) {
+                       GtkWidget *toolbar;
+
+                       toolbar = e_shell_window_get_managed_widget (
+                               shell_window, "/main-toolbar");
+                       g_return_if_fail (toolbar != NULL);
+
+                       gtk_container_remove (
+                               GTK_CONTAINER (toolbar),
+                               GTK_WIDGET (mail_shell_view->priv->send_receive_tool_item));
+                       gtk_container_remove (
+                               GTK_CONTAINER (toolbar),
+                               GTK_WIDGET (mail_shell_view->priv->send_receive_tool_separator));
+
+                       mail_shell_view->priv->send_receive_tool_item = NULL;
+                       mail_shell_view->priv->send_receive_tool_separator = NULL;
+               }
                return;
+       }
 
        mail_shell_content = mail_shell_view->priv->mail_shell_content;
        mail_view = e_mail_shell_content_get_mail_view (mail_shell_content);
@@ -1497,45 +1519,90 @@ e_mail_shell_view_update_send_receive_menus (EMailShellView *mail_shell_view)
                        GTK_MENU_ITEM (widget),
                        create_send_receive_submenu (mail_shell_view));
 
-       widget = e_header_bar_button_new (NULL, ACTION (MAIL_SEND_RECEIVE));
-       gtk_widget_set_name (widget, "e-mail-shell-view-send-receive");
-       e_header_bar_button_take_menu (
-               E_HEADER_BAR_BUTTON (widget),
-               create_send_receive_submenu (mail_shell_view));
-       gtk_widget_show (widget);
-
-       e_shell_header_bar_pack_start (shell_headerbar, widget);
-
-       action_name = "mail-forward";
-       action = e_mail_reader_get_action (E_MAIL_READER (mail_view), action_name);
-       widget = e_header_bar_button_new (NULL, action);
-       gtk_widget_set_name (widget, "e-mail-shell-view-forward");
-       e_header_bar_button_take_menu (
-               E_HEADER_BAR_BUTTON (widget),
-               e_mail_reader_create_forward_menu (E_MAIL_READER (mail_view)));
-       gtk_widget_show (widget);
-
-       e_shell_header_bar_pack_end (shell_headerbar, widget);
-
-       action_name = "mail-reply-group";
-       action = e_mail_reader_get_action (E_MAIL_READER (mail_view), action_name);
-       widget = e_header_bar_button_new (NULL, action);
-       gtk_widget_set_name (widget, "e-mail-shell-view-reply-group");
-       gtk_widget_show (widget);
-
-       e_header_bar_button_take_menu (
-               E_HEADER_BAR_BUTTON (widget),
-               e_mail_reader_create_reply_menu (E_MAIL_READER (mail_view)));
-
-       e_shell_header_bar_pack_end (shell_headerbar, widget);
-
-       action_name = "mail-reply-sender";
-       action = e_mail_reader_get_action (E_MAIL_READER (mail_view), action_name);
-       widget = e_header_bar_button_new (NULL, action);
-       gtk_widget_set_name (widget, "e-mail-shell-view-reply-sender");
-       gtk_widget_show (widget);
-
-       e_shell_header_bar_pack_end (shell_headerbar, widget);
+       if (e_util_get_use_header_bar ()) {
+               widget = e_header_bar_button_new (NULL, ACTION (MAIL_SEND_RECEIVE));
+               gtk_widget_set_name (widget, "e-mail-shell-view-send-receive");
+               e_header_bar_button_take_menu (
+                       E_HEADER_BAR_BUTTON (widget),
+                       create_send_receive_submenu (mail_shell_view));
+               gtk_widget_show (widget);
+
+               e_shell_header_bar_pack_start (shell_headerbar, widget);
+
+               action_name = "mail-forward";
+               action = e_mail_reader_get_action (E_MAIL_READER (mail_view), action_name);
+               widget = e_header_bar_button_new (NULL, action);
+               gtk_widget_set_name (widget, "e-mail-shell-view-forward");
+               e_header_bar_button_take_menu (
+                       E_HEADER_BAR_BUTTON (widget),
+                       e_mail_reader_create_forward_menu (E_MAIL_READER (mail_view)));
+               gtk_widget_show (widget);
+
+               e_shell_header_bar_pack_end (shell_headerbar, widget);
+
+               action_name = "mail-reply-group";
+               action = e_mail_reader_get_action (E_MAIL_READER (mail_view), action_name);
+               widget = e_header_bar_button_new (NULL, action);
+               gtk_widget_set_name (widget, "e-mail-shell-view-reply-group");
+               gtk_widget_show (widget);
+
+               e_header_bar_button_take_menu (
+                       E_HEADER_BAR_BUTTON (widget),
+                       e_mail_reader_create_reply_menu (E_MAIL_READER (mail_view)));
+
+               e_shell_header_bar_pack_end (shell_headerbar, widget);
+
+               action_name = "mail-reply-sender";
+               action = e_mail_reader_get_action (E_MAIL_READER (mail_view), action_name);
+               widget = e_header_bar_button_new (NULL, action);
+               gtk_widget_set_name (widget, "e-mail-shell-view-reply-sender");
+               gtk_widget_show (widget);
+
+               e_shell_header_bar_pack_end (shell_headerbar, widget);
+
+               widget = e_shell_window_get_managed_widget (shell_window, 
"/main-toolbar/mail-toolbar-common/mail-reply-sender");
+               if (widget)
+                       gtk_widget_destroy (widget);
+       } else {
+               if (!mail_shell_view->priv->send_receive_tool_item) {
+                       GtkWidget *toolbar;
+                       GtkToolItem *tool_item;
+                       gint index;
+
+                       toolbar = e_shell_window_get_managed_widget (shell_window, "/main-toolbar");
+                       g_return_if_fail (toolbar != NULL);
+
+                       widget_path = "/main-toolbar/toolbar-actions/mail-send-receiver";
+                       widget = e_shell_window_get_managed_widget (shell_window, widget_path);
+                       g_return_if_fail (widget != NULL);
+
+                       index = gtk_toolbar_get_item_index (
+                               GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (widget));
+
+                       tool_item = gtk_separator_tool_item_new ();
+                       gtk_toolbar_insert (GTK_TOOLBAR (toolbar), tool_item, index);
+                       gtk_widget_show (GTK_WIDGET (tool_item));
+                       mail_shell_view->priv->send_receive_tool_separator = tool_item;
+
+                       tool_item = GTK_TOOL_ITEM (
+                               e_menu_tool_button_new (_("Send / Receive")));
+                       gtk_tool_item_set_is_important (tool_item, TRUE);
+                       gtk_toolbar_insert (GTK_TOOLBAR (toolbar), tool_item, index);
+                       gtk_widget_show (GTK_WIDGET (tool_item));
+                       mail_shell_view->priv->send_receive_tool_item = tool_item;
+
+                       e_binding_bind_property (
+                               ACTION (MAIL_SEND_RECEIVE), "sensitive",
+                               tool_item, "sensitive",
+                               G_BINDING_SYNC_CREATE);
+               }
+
+               if (mail_shell_view->priv->send_receive_tool_item) {
+                       gtk_menu_tool_button_set_menu (
+                               GTK_MENU_TOOL_BUTTON (mail_shell_view->priv->send_receive_tool_item),
+                               create_send_receive_submenu (mail_shell_view));
+               }
+       }
 }
 
 static void
diff --git a/src/modules/mail/e-mail-shell-view-private.h b/src/modules/mail/e-mail-shell-view-private.h
index 6a7a44bd4b..093c7592ad 100644
--- a/src/modules/mail/e-mail-shell-view-private.h
+++ b/src/modules/mail/e-mail-shell-view-private.h
@@ -135,6 +135,9 @@ struct _EMailShellViewPrivate {
        CamelVeeFolder *search_account_current;
        GCancellable *search_account_cancel;
 
+       GtkToolItem *send_receive_tool_item;
+       GtkToolItem *send_receive_tool_separator;
+
        gboolean vfolder_allow_expunge;
        gboolean ignore_folder_popup_selection_done;
 
diff --git a/src/shell/e-shell-window-actions.c b/src/shell/e-shell-window-actions.c
index 44901b93f7..72ace75608 100644
--- a/src/shell/e-shell-window-actions.c
+++ b/src/shell/e-shell-window-actions.c
@@ -350,7 +350,7 @@ action_categories_cb (GtkAction *action,
        dialog = g_object_new (
                GTK_TYPE_DIALOG,
                "transient-for", GTK_WINDOW (shell_window),
-               "use-header-bar", TRUE,
+               "use-header-bar", e_util_get_use_header_bar (),
                "title", _("Categories Editor"),
                NULL);
 
diff --git a/src/shell/e-shell-window-private.c b/src/shell/e-shell-window-private.c
index 1a7f7b1cad..5b9a6eb22f 100644
--- a/src/shell/e-shell-window-private.c
+++ b/src/shell/e-shell-window-private.c
@@ -362,9 +362,14 @@ e_shell_window_private_constructed (EShellWindow *shell_window)
        if (menubar)
                shell_window->priv->menu_bar = e_menu_bar_new (GTK_MENU_BAR (menubar), window, &menu_button);
 
-       priv->headerbar = e_shell_header_bar_new (shell_window, menu_button);
-       gtk_window_set_titlebar (window, priv->headerbar);
-       gtk_widget_show (priv->headerbar);
+       if (e_util_get_use_header_bar ()) {
+               priv->headerbar = e_shell_header_bar_new (shell_window, menu_button);
+               gtk_window_set_titlebar (window, priv->headerbar);
+               gtk_widget_show (priv->headerbar);
+       } else if (menu_button) {
+               g_object_ref_sink (menu_button);
+               gtk_widget_destroy (menu_button);
+       }
 
        widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
        gtk_container_add (GTK_CONTAINER (shell_window), widget);
@@ -589,25 +594,27 @@ e_shell_window_private_constructed (EShellWindow *shell_window)
        g_signal_connect (shell_window, "key-press-event",
                G_CALLBACK (e_shell_window_key_press_event_cb), NULL);
 
-       /* XXX The ECalShellBackend has a hack where it forces the
-        *     EMenuButton to update its button image by forcing
-        *     a "notify::active-view" signal emission on the window.
-        *     This will trigger the property binding, which will set
-        *     EMenuButton's "prefer-item" property, which will
-        *     invoke header_bar_update_new_menu(), which
-        *     will cause EMenuButton to update its button image.
-        *
-        *     It's a bit of a Rube Goldberg machine and should be
-        *     reworked, but it's just serving one (now documented)
-        *     corner case and works for now. */
-       e_binding_bind_property_full (
-               shell_window, "active-view",
-               e_shell_header_bar_get_new_button (E_SHELL_HEADER_BAR (priv->headerbar)),
-               "prefer-item",
-               G_BINDING_SYNC_CREATE,
-               shell_window_active_view_to_prefer_item,
-               (GBindingTransformFunc) NULL,
-               NULL, (GDestroyNotify) NULL);
+       if (e_util_get_use_header_bar ()) {
+               /* XXX The ECalShellBackend has a hack where it forces the
+                *     EMenuButton to update its button image by forcing
+                *     a "notify::active-view" signal emission on the window.
+                *     This will trigger the property binding, which will set
+                *     EMenuButton's "prefer-item" property, which will
+                *     invoke header_bar_update_new_menu(), which
+                *     will cause EMenuButton to update its button image.
+                *
+                *     It's a bit of a Rube Goldberg machine and should be
+                *     reworked, but it's just serving one (now documented)
+                *     corner case and works for now. */
+               e_binding_bind_property_full (
+                       shell_window, "active-view",
+                       e_shell_header_bar_get_new_button (E_SHELL_HEADER_BAR (priv->headerbar)),
+                       "prefer-item",
+                       G_BINDING_SYNC_CREATE,
+                       shell_window_active_view_to_prefer_item,
+                       (GBindingTransformFunc) NULL,
+                       NULL, (GDestroyNotify) NULL);
+       }
 }
 
 void
@@ -755,5 +762,14 @@ e_shell_window_update_title (EShellWindow *shell_window)
        shell_view = e_shell_window_get_shell_view (shell_window, view_name);
        view_title = e_shell_view_get_title (shell_view);
 
-       gtk_window_set_title (GTK_WINDOW (shell_window), view_title);
+       if (e_util_get_use_header_bar ()) {
+               gtk_window_set_title (GTK_WINDOW (shell_window), view_title);
+       } else {
+               gchar *window_title;
+
+               /* Translators: This is used for the main window title. */
+               window_title = g_strdup_printf (_("%s — Evolution"), view_title);
+               gtk_window_set_title (GTK_WINDOW (shell_window), window_title);
+               g_free (window_title);
+       }
 }
diff --git a/src/shell/e-shell-window.c b/src/shell/e-shell-window.c
index 7ef3f8e57f..a587463627 100644
--- a/src/shell/e-shell-window.c
+++ b/src/shell/e-shell-window.c
@@ -109,6 +109,49 @@ shell_window_menubar_update_new_menu (EShellWindow *shell_window)
        gtk_widget_show (widget);
 }
 
+static void
+shell_window_toolbar_update_new_menu (EShellWindow *shell_window,
+                                     GtkMenuToolButton *menu_tool_button)
+{
+       GtkWidget *menu;
+
+       /* Update the "New" menu tool button submenu. */
+       menu = e_shell_window_create_new_menu (shell_window);
+       gtk_menu_tool_button_set_menu (menu_tool_button, menu);
+}
+
+static void
+shell_window_toolbar_prefer_item_cb (GtkMenuToolButton *menu_tool_button,
+                                    GParamSpec *pspec,
+                                    EShellWindow *shell_window)
+{
+       shell_window_toolbar_update_new_menu (shell_window, menu_tool_button);
+}
+
+static gboolean
+shell_window_active_view_to_prefer_item (GBinding *binding,
+                                         const GValue *source_value,
+                                         GValue *target_value,
+                                         gpointer user_data)
+{
+       GObject *source_object;
+       EShell *shell;
+       EShellBackend *shell_backend;
+       const gchar *active_view;
+       const gchar *prefer_item;
+
+       active_view = g_value_get_string (source_value);
+
+       source_object = g_binding_get_source (binding);
+       shell = e_shell_window_get_shell (E_SHELL_WINDOW (source_object));
+       shell_backend = e_shell_get_backend_by_name (shell, active_view);
+       prefer_item = e_shell_backend_get_prefer_new_item (shell_backend);
+
+       g_value_set_string (target_value, prefer_item);
+
+       return TRUE;
+}
+
 static void
 shell_window_set_notebook_page (EShellWindow *shell_window,
                                 GParamSpec *pspec,
@@ -453,23 +496,83 @@ shell_window_construct_toolbar (EShellWindow *shell_window)
 
        toolbar = e_shell_window_get_managed_widget (
                shell_window, "/main-toolbar");
-       gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_BUTTON);
+       e_util_setup_toolbar_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_BUTTON);
 
        gtk_style_context_add_class (
                gtk_widget_get_style_context (toolbar),
                GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
 
+       if (!e_util_get_use_header_bar ()) {
+               GtkUIManager *ui_manager;
+               GtkToolItem *item;
+
+               ui_manager = e_shell_window_get_ui_manager (shell_window);
+               /* XXX Having this separator in the UI definition doesn't work
+                *     because GtkUIManager is unaware of the "New" button, so
+                *     it makes the separator invisible.  One possibility is to
+                *     define a GtkAction subclass for which create_tool_item()
+                *     return an EMenuToolButton.  Then both this separator
+                *     and the "New" button could be added to the UI definition.
+                *     Tempting, but the "New" button and its dynamically
+                *     generated menu is already a complex beast, and I'm not
+                *     convinced having it proxy some new type of GtkAction
+                *     is worth the extra effort. */
+               item = gtk_separator_tool_item_new ();
+               gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, 0);
+               gtk_widget_show (GTK_WIDGET (item));
+
+               /* Translators: a 'New' toolbar button caption which is context sensitive and
+                  runs one of the actions under File->New menu */
+               item = e_menu_tool_button_new (C_("toolbar-button", "New"));
+               gtk_tool_item_set_is_important (GTK_TOOL_ITEM (item), TRUE);
+               gtk_widget_add_accelerator (
+                       GTK_WIDGET (item), "clicked",
+                       gtk_ui_manager_get_accel_group (ui_manager),
+                       GDK_KEY_N, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
+               gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, 0);
+               gtk_widget_show (GTK_WIDGET (item));
+
+               /* XXX The ECalShellBackend has a hack where it forces the
+                *     EMenuToolButton to update its button image by forcing
+                *     a "notify::active-view" signal emission on the window.
+                *     This will trigger the property binding, which will set
+                *     EMenuToolButton's "prefer-item" property, which will
+                *     invoke shell_window_toolbar_update_new_menu(), which
+                *     will cause EMenuToolButton to update its button image.
+                *
+                *     It's a bit of a Rube Goldberg machine and should be
+                *     reworked, but it's just serving one (now documented)
+                *     corner case and works for now. */
+               e_binding_bind_property_full (
+                       shell_window, "active-view",
+                       item, "prefer-item",
+                       G_BINDING_SYNC_CREATE,
+                       shell_window_active_view_to_prefer_item,
+                       (GBindingTransformFunc) NULL,
+                       NULL, (GDestroyNotify) NULL);
+
+               g_signal_connect_object (
+                       item, "notify::prefer-item",
+                       G_CALLBACK (shell_window_toolbar_prefer_item_cb),
+                       shell_window, 0);
+
+               g_signal_connect_object (
+                       shell_window, "update-new-menu",
+                       G_CALLBACK (shell_window_toolbar_update_new_menu),
+                       item, 0);
+       }
+
        gtk_box_pack_start (GTK_BOX (box), toolbar, TRUE, TRUE, 0);
 
        toolbar = e_shell_window_get_managed_widget (
                shell_window, "/search-toolbar");
        gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), FALSE);
-       gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_BUTTON);
+       e_util_setup_toolbar_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_BUTTON);
 
        toolbar = e_shell_window_get_managed_widget (
                shell_window, "/close-toolbar");
        gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), FALSE);
-       gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_BUTTON);
+       e_util_setup_toolbar_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_BUTTON);
 
        return box;
 }
@@ -1388,17 +1491,12 @@ e_shell_window_get_managed_widget (EShellWindow *shell_window,
                                    const gchar *widget_path)
 {
        GtkUIManager *ui_manager;
-       GtkWidget *widget;
 
        g_return_val_if_fail (E_IS_SHELL_WINDOW (shell_window), NULL);
        g_return_val_if_fail (widget_path != NULL, NULL);
 
        ui_manager = e_shell_window_get_ui_manager (shell_window);
-       widget = gtk_ui_manager_get_widget (ui_manager, widget_path);
-
-       g_return_val_if_fail (widget != NULL, NULL);
-
-       return widget;
+       return gtk_ui_manager_get_widget (ui_manager, widget_path);
 }
 
 /**
diff --git a/src/shell/e-shell.c b/src/shell/e-shell.c
index 578ab2046f..981326d9ad 100644
--- a/src/shell/e-shell.c
+++ b/src/shell/e-shell.c
@@ -1868,6 +1868,14 @@ shell_initable_init (GInitable *initable,
        g_object_unref (proxy_source);
        g_object_unref (registry);
 
+       if (!e_util_get_use_header_bar ()) {
+               /* Forbid header bars in stock GTK+ dialogs.
+                * They look very out of place in Evolution. */
+               g_object_set (
+                       gtk_settings_get_default (),
+                       "gtk-dialogs-use-header", FALSE, NULL);
+       }
+
        return TRUE;
 }
 


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