[geary: 16/20] composer: close the composer when navigating back




commit d6c546e2d555d20e1dd259117822b4d4c8b7152c
Author: Julian Sparber <julian sparber net>
Date:   Tue Oct 6 17:31:49 2020 +0200

    composer: close the composer when navigating back

 src/client/application/application-main-window.vala | 11 +++++++++++
 src/client/composer/composer-widget.vala            |  5 +++++
 ui/application-main-window.ui                       |  2 ++
 3 files changed, 18 insertions(+)
---
diff --git a/src/client/application/application-main-window.vala 
b/src/client/application/application-main-window.vala
index 01b7b9c65..e1e55d0ed 100644
--- a/src/client/application/application-main-window.vala
+++ b/src/client/application/application-main-window.vala
@@ -1955,6 +1955,17 @@ public class Application.MainWindow :
         return Gdk.EVENT_STOP;
     }
 
+    [GtkCallback]
+    private void on_main_leaflet_visible_child_changed() {
+        if (main_leaflet.child_transition_running)
+            return;
+
+        if (main_leaflet.visible_child_name == "conversations" && main_leaflet.folded)
+            if (this.conversation_viewer.current_composer != null) {
+                this.conversation_viewer.current_composer.activate_close_action();
+            }
+    }
+
     private void on_offline_infobar_response() {
         this.info_bars.remove(this.offline_infobar);
     }
diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala
index 37e93fb43..17430021e 100644
--- a/src/client/composer/composer-widget.vala
+++ b/src/client/composer/composer-widget.vala
@@ -1361,6 +1361,11 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface {
         }
     }
 
+    /* Activate the close action */
+    public void activate_close_action() {
+        this.actions.activate_action(ACTION_CLOSE, null);
+    }
+
     internal void set_mode(PresentationMode new_mode) {
         this.current_mode = new_mode;
         this.header.set_mode(new_mode);
diff --git a/ui/application-main-window.ui b/ui/application-main-window.ui
index fe66491bd..cbaacbcf6 100644
--- a/ui/application-main-window.ui
+++ b/ui/application-main-window.ui
@@ -29,6 +29,8 @@
                 <property name="can_focus">True</property>
                 <property name="can_swipe_back">True</property>
                 <property name="transition_type">over</property>
+                <signal name="notify::visible-child" handler="on_main_leaflet_visible_child_changed" 
swapped="no"/>
+                <signal name="notify::child-transition-running" 
handler="on_main_leaflet_visible_child_changed" swapped="no"/>
                 <child>
                   <object class="HdyLeaflet" id="conversations_leaflet">
                     <property name="visible">True</property>


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