[geary] Set the focus on a composer detached using the detach button



commit 9ec9913a55c162f44badaeb7a2f6f2d8d4fadc9e
Author: Robert Schroll <rschroll gmail com>
Date:   Sun Feb 8 14:36:30 2015 -0500

    Set the focus on a composer detached using the detach button
    
    Also, simplify the focus discovery code.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=744077

 src/client/composer/composer-box.vala       |    4 +---
 src/client/composer/composer-container.vala |    2 +-
 src/client/composer/composer-embed.vala     |    4 +---
 src/client/composer/composer-widget.vala    |    7 ++++---
 src/client/composer/composer-window.vala    |    5 ++---
 5 files changed, 9 insertions(+), 13 deletions(-)
---
diff --git a/src/client/composer/composer-box.vala b/src/client/composer/composer-box.vala
index afd7a7d..a5dfc38 100644
--- a/src/client/composer/composer-box.vala
+++ b/src/client/composer/composer-box.vala
@@ -30,16 +30,14 @@ public class ComposerBox : Gtk.Frame, ComposerContainer {
         }
     }
     
-    public Gtk.Widget? remove_composer() {
+    public void remove_composer() {
         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);
         close_container();
-        return focus;
     }
     
     
diff --git a/src/client/composer/composer-container.vala b/src/client/composer/composer-container.vala
index b4a138a..03d0f6c 100644
--- a/src/client/composer/composer-container.vala
+++ b/src/client/composer/composer-container.vala
@@ -11,5 +11,5 @@ public interface ComposerContainer {
     public abstract unowned Gtk.Widget get_focus();
     public abstract void vanish();
     public abstract void close_container();
-    public abstract Gtk.Widget? remove_composer();
+    public abstract void remove_composer();
 }
diff --git a/src/client/composer/composer-embed.vala b/src/client/composer/composer-embed.vala
index 8ef4be4..473678f 100644
--- a/src/client/composer/composer-embed.vala
+++ b/src/client/composer/composer-embed.vala
@@ -115,7 +115,7 @@ public class ComposerEmbed : Gtk.EventBox, ComposerContainer {
         get_style_context().changed.connect(update_style);
     }
     
-    public Gtk.Widget? remove_composer() {
+    public void remove_composer() {
         if (composer.editor.has_focus)
             on_focus_out();
         composer.editor.focus_in_event.disconnect(on_focus_in);
@@ -125,7 +125,6 @@ public class ComposerEmbed : Gtk.EventBox, ComposerContainer {
         disable_scroll_reroute(this);
         Gtk.ScrolledWindow win = (Gtk.ScrolledWindow) composer.editor.parent;
         win.get_vscrollbar().show();
-        Gtk.Widget? focus = top_window.get_focus();
         
         try {
             composer.editor.get_dom_document().body.get_class_list().remove("embedded");
@@ -135,7 +134,6 @@ public class ComposerEmbed : Gtk.EventBox, ComposerContainer {
         
         remove(composer);
         close_container();
-        return focus;
     }
     
     public bool set_position(ref Gdk.Rectangle allocation, double hscroll, double vscroll,
diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala
index 30a410e..7850fda 100644
--- a/src/client/composer/composer-widget.vala
+++ b/src/client/composer/composer-widget.vala
@@ -1074,16 +1074,17 @@ public class ComposerWidget : Gtk.EventBox {
     private void on_detach() {
         if (state == ComposerState.DETACHED)
             return;
-        Gtk.Widget? focus = container.remove_composer();
+        Gtk.Widget? focus = container.top_window.get_focus();
+        container.remove_composer();
         ComposerWindow window = new ComposerWindow(this);
-        if (focus != null) {
+        state = ComposerWidget.ComposerState.DETACHED;
+        if (focus != null && focus.parent.visible) {
             ComposerWindow focus_win = focus.get_toplevel() as ComposerWindow;
             if (focus_win != null && focus_win == window)
                 focus.grab_focus();
         } else {
             set_focus();
         }
-        state = ComposerWidget.ComposerState.DETACHED;
     }
     
     public void ensure_paned() {
diff --git a/src/client/composer/composer-window.vala b/src/client/composer/composer-window.vala
index 6f8b393..4c06cef 100644
--- a/src/client/composer/composer-window.vala
+++ b/src/client/composer/composer-window.vala
@@ -59,9 +59,8 @@ public class ComposerWindow : Gtk.Window, ComposerContainer {
         hide();
     }
     
-    public Gtk.Widget? remove_composer() {
-        warning(@"Detached composer received remove");
-        return null;
+    public void remove_composer() {
+        warning("Detached composer received remove");
     }
 }
 


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