[geary/mjog/1193-conversation-buttons-resize-race: 7/11] client: Invoke the correct menu for move or copy shortcuts




commit 7628e5d00c0c965b2f6af4036697534b256f599d
Author: Michael Gratton <mike vee net>
Date:   Sun Apr 11 11:20:04 2021 +1000

    client: Invoke the correct menu for move or copy shortcuts

 src/client/application/application-main-window.vala    | 18 ++++++++++++++++--
 .../components/components-conversation-actions.vala    |  8 ++++++++
 src/client/components/components-main-toolbar.vala     |  8 ++++++++
 ui/components-main-toolbar.ui                          |  2 +-
 4 files changed, 33 insertions(+), 3 deletions(-)
---
diff --git a/src/client/application/application-main-window.vala 
b/src/client/application/application-main-window.vala
index ec4416194..41f022358 100644
--- a/src/client/application/application-main-window.vala
+++ b/src/client/application/application-main-window.vala
@@ -2332,11 +2332,25 @@ public class Application.MainWindow :
     }
 
     private void on_show_copy_menu() {
-        this.conversation_actions.copy_message_button.clicked();
+        if (this.is_conversation_list_shown &&
+            this.conversation_list_actions_revealer.child_revealed) {
+            this.conversation_list_actions.show_copy_menu();
+        } else if (this.is_conversation_viewer_shown) {
+            this.main_toolbar.shown_actions.show_copy_menu();
+        } else {
+            this.error_bell();
+        }
     }
 
     private void on_show_move_menu() {
-        this.conversation_actions.move_message_button.clicked();
+        if (this.is_conversation_list_shown &&
+            this.conversation_list_actions_revealer.child_revealed) {
+            this.conversation_list_actions.show_move_menu();
+        } else if (this.is_conversation_viewer_shown) {
+            this.main_toolbar.shown_actions.show_move_menu();
+        } else {
+            this.error_bell();
+        }
     }
 
     private void on_conversation_up() {
diff --git a/src/client/components/components-conversation-actions.vala 
b/src/client/components/components-conversation-actions.vala
index c30e33800..b52416ee7 100644
--- a/src/client/components/components-conversation-actions.vala
+++ b/src/client/components/components-conversation-actions.vala
@@ -70,6 +70,14 @@ public class Components.ConversationActions : Gtk.Grid {
         }
     }
 
+    public void show_copy_menu() {
+        this.copy_message_button.clicked();
+    }
+
+    public void show_move_menu() {
+        this.move_message_button.clicked();
+    }
+
     public void update_trash_button(bool show_trash) {
         this.show_trash_button = show_trash;
         update_conversation_buttons();
diff --git a/src/client/components/components-main-toolbar.vala 
b/src/client/components/components-main-toolbar.vala
index 98a62730a..90e6f79d6 100644
--- a/src/client/components/components-main-toolbar.vala
+++ b/src/client/components/components-main-toolbar.vala
@@ -1,5 +1,6 @@
 /*
  * Copyright © 2017 Software Freedom Conservancy Inc.
+ * Copyright © 2021 Michael Gratton <mike vee net>
  *
  * This software is licensed under the GNU Lesser General Public License
  * (version 2.1 or later). See the COPYING file in this distribution.
@@ -25,6 +26,12 @@ public class Components.MainToolbar : Hdy.Leaflet {
 
     public bool find_open { get; set; default = false; }
 
+    public ConversationActions shown_actions {
+        get {
+            return (ConversationActions) this.actions_squeezer.visible_child;
+        }
+    }
+
     [GtkChild] public unowned ConversationActions full_actions;
     [GtkChild] public unowned ConversationActions compact_actions;
 
@@ -44,6 +51,7 @@ public class Components.MainToolbar : Hdy.Leaflet {
 
     // Conversation viewer header elements
     [GtkChild] private unowned Hdy.HeaderBar conversation_header;
+    [GtkChild] private unowned Hdy.Squeezer actions_squeezer;
     [GtkChild] private unowned Gtk.ToggleButton find_button;
 
     [GtkChild] private unowned Hdy.HeaderGroup header_group;
diff --git a/ui/components-main-toolbar.ui b/ui/components-main-toolbar.ui
index f40880ce6..d0caf8508 100644
--- a/ui/components-main-toolbar.ui
+++ b/ui/components-main-toolbar.ui
@@ -168,7 +168,7 @@
           </object>
         </child>
         <child>
-          <object class="HdySqueezer">
+          <object class="HdySqueezer" id="actions_squeezer">
             <property name="visible">True</property>
             <property name="transition_type">crossfade</property>
             <child>


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