[geary] Move detach button to bottom of compose widget



commit 35e3cdfd9b4ded12ee859d62ee7dce13376c5504
Author: Robert Schroll <rschroll gmail com>
Date:   Thu May 15 17:30:37 2014 -0700

    Move detach button to bottom of compose widget
    
    Also, remove the embed toolbar at the top.
    
    Note that the focus is stolen by the detach button when it's clicked, so
    we can't re-establish it in the window.  Instead, we use the existing
    set_focus() method to put in a (hopefully) appropriate place.

 src/client/composer/composer-embed.vala  |   37 ++++++-----------------------
 src/client/composer/composer-widget.vala |   16 +++++++++---
 ui/composer.glade                        |   17 +++++++++++++-
 3 files changed, 36 insertions(+), 34 deletions(-)
---
diff --git a/src/client/composer/composer-embed.vala b/src/client/composer/composer-embed.vala
index b025d10..d3bf44f 100644
--- a/src/client/composer/composer-embed.vala
+++ b/src/client/composer/composer-embed.vala
@@ -4,7 +4,7 @@
  * (version 2.1 or later).  See the COPYING file in this distribution.
  */
 
-public class ComposerEmbed : Gtk.Box, ComposerContainer {
+public class ComposerEmbed : Gtk.Bin, ComposerContainer {
     
     private ComposerWidget composer;
     private ConversationViewer conversation_viewer;
@@ -17,28 +17,12 @@ public class ComposerEmbed : Gtk.Box, ComposerContainer {
     
     public ComposerEmbed(ComposerWidget composer, ConversationViewer conversation_viewer,
         Geary.Email? referred) {
-        Object(orientation: Gtk.Orientation.VERTICAL);
+        //Object(orientation: Gtk.Orientation.VERTICAL);
         this.composer = composer;
         this.conversation_viewer = conversation_viewer;
         halign = Gtk.Align.FILL;
         valign = Gtk.Align.FILL;
         
-        Gtk.Toolbar toolbar = new Gtk.Toolbar();
-        toolbar.set_icon_size(Gtk.IconSize.MENU);
-        Gtk.ToolButton close = new Gtk.ToolButton.from_stock("gtk-close");
-        Gtk.ToolButton detach = new Gtk.ToolButton.from_stock("gtk-goto-top");
-        Gtk.SeparatorToolItem filler = new Gtk.SeparatorToolItem();
-        filler.set_expand(true);
-        filler.set_draw(false);
-        toolbar.insert(filler, -1);
-        toolbar.insert(detach, -1);
-        toolbar.insert(close, -1);
-        pack_start(toolbar, false, false);
-        toolbar.show_all();
-        
-        close.clicked.connect(on_close);
-        detach.clicked.connect(on_detach);
-        
         WebKit.DOM.HTMLElement? email_element = null;
         if (referred != null) {
             email_element = conversation_viewer.web_view.get_dom_document().get_element_by_id(
@@ -64,7 +48,8 @@ public class ComposerEmbed : Gtk.Box, ComposerContainer {
             debug("Error creating embed element: %s", error.message);
             return;
         }
-        pack_start(composer, true, true);
+        //pack_start(composer, true, true);
+        add(composer);
         composer.editor.focus_in_event.connect(on_focus_in);
         composer.editor.focus_out_event.connect(on_focus_out);
         conversation_viewer.compose_overlay.add_overlay(this);
@@ -72,23 +57,16 @@ public class ComposerEmbed : Gtk.Box, ComposerContainer {
         present();
     }
     
-    private void on_close() {
-        if (composer.should_close() == ComposerWidget.CloseStatus.DO_CLOSE)
-            close();
-    }
-    
     public void on_detach() {
+        composer.inline = false;
         if (composer.editor.has_focus)
             on_focus_out();
         composer.editor.focus_in_event.disconnect(on_focus_in);
         composer.editor.focus_out_event.disconnect(on_focus_out);
-        Gtk.Widget focus = top_window.get_focus();
         
         remove(composer);
-        ComposerWindow window = new ComposerWindow(composer);
-        ComposerWindow focus_win = focus.get_toplevel() as ComposerWindow;
-        if (focus_win != null && focus_win == window)
-            focus.grab_focus();
+        new ComposerWindow(composer);
+        composer.set_focus();
         close();
     }
     
@@ -125,6 +103,7 @@ public class ComposerEmbed : Gtk.Box, ComposerContainer {
     
     public void vanish() {
         hide();
+        composer.inline = false;
         composer.editor.focus_in_event.disconnect(on_focus_in);
         composer.editor.focus_out_event.disconnect(on_focus_out);
         
diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala
index 277436f..3b71f2c 100644
--- a/src/client/composer/composer-widget.vala
+++ b/src/client/composer/composer-widget.vala
@@ -134,9 +134,7 @@ public class ComposerWidget : Gtk.EventBox {
         set { ((Gtk.ToggleAction) actions.get_action(ACTION_COMPOSE_AS_HTML)).active = value; }
     }
     
-    public bool inline {
-        get { return parent is ComposerEmbed && visible; }
-    }
+    public bool inline { get; set; default = true; }
     
     public ComposeType compose_type { get; private set; default = ComposeType.NEW_MESSAGE; }
     
@@ -158,6 +156,7 @@ public class ComposerWidget : Gtk.EventBox {
     public Gtk.Entry subject_entry;
     private Gtk.Button close_button;
     private Gtk.Button send_button;
+    private Gtk.Button detach_button;
     private Gtk.Label message_overlay_label;
     private WebKit.DOM.Element? prev_selected_link = null;
     private Gtk.Box attachments_box;
@@ -221,6 +220,10 @@ public class ComposerWidget : Gtk.EventBox {
         close_button.clicked.connect(on_close);
         send_button = builder.get_object("Send") as Gtk.Button;
         send_button.clicked.connect(on_send);
+        detach_button = builder.get_object("Detach") as Gtk.Button;
+        detach_button.clicked.connect(on_detach);
+        bind_property("inline", detach_button, "visible",
+            BindingFlags.DEFAULT | BindingFlags.SYNC_CREATE);
         add_attachment_button  = builder.get_object("add_attachment_button") as Gtk.Button;
         add_attachment_button.clicked.connect(on_add_attachment_button_clicked);
         pending_attachments_button = builder.get_object("add_pending_attachments") as Gtk.Button;
@@ -519,7 +522,7 @@ public class ComposerWidget : Gtk.EventBox {
         }
     }
     
-    private void set_focus() {
+    public void set_focus() {
         if (Geary.String.is_empty(to)) {
             to_entry.grab_focus();
         } else if (Geary.String.is_empty(subject)) {
@@ -730,6 +733,11 @@ public class ComposerWidget : Gtk.EventBox {
             container.close();
     }
     
+    private void on_detach() {
+        if (parent is ComposerEmbed)
+            ((ComposerEmbed) parent).on_detach();
+    }
+    
     private bool email_contains_attachment_keywords() {
         // Filter out all content contained in block quotes
         string filtered = @"$subject\n";
diff --git a/ui/composer.glade b/ui/composer.glade
index ce585a7..47fc1da 100644
--- a/ui/composer.glade
+++ b/ui/composer.glade
@@ -602,6 +602,21 @@
                 <property name="fill">True</property>
                 <property name="padding">3</property>
                 <property name="pack_type">end</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="Detach">
+                <property name="label" translatable="yes">Detach</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="padding">3</property>
+                <property name="pack_type">end</property>
                 <property name="position">0</property>
               </packing>
             </child>
@@ -618,7 +633,7 @@
                 <property name="fill">True</property>
                 <property name="padding">3</property>
                 <property name="pack_type">end</property>
-                <property name="position">1</property>
+                <property name="position">2</property>
               </packing>
             </child>
           </object>


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