[geary/wip/730682-refine-convo-list] Fix conversation action bar copy and move shortcuts not working.



commit 0dd5bd6378fc1f46adbe88408365dba9fcc0c137
Author: Michael James Gratton <mike vee net>
Date:   Sat Jan 6 21:57:50 2018 +1100

    Fix conversation action bar copy and move shortcuts not working.

 src/client/components/conversation-action-bar.vala |   19 ++++----
 src/client/components/main-window.vala             |   49 +++++++++++--------
 ui/conversation-action-bar.ui                      |    6 +--
 3 files changed, 40 insertions(+), 34 deletions(-)
---
diff --git a/src/client/components/conversation-action-bar.vala 
b/src/client/components/conversation-action-bar.vala
index e5cce09..44ab7f5 100644
--- a/src/client/components/conversation-action-bar.vala
+++ b/src/client/components/conversation-action-bar.vala
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017 Michael Gratton <mike vee net>
+ * Copyright 2017-2018 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.
@@ -21,6 +21,11 @@ public class ConversationActionBar : Gtk.ActionBar {
         get; set; default = new FolderPopover();
     }
 
+    [GtkChild]
+    internal Gtk.MenuButton copy_menu;
+    [GtkChild]
+    internal Gtk.MenuButton move_menu;
+
     private Geary.Account? owner = null;
     private Geary.Folder? location = null;
 
@@ -44,10 +49,6 @@ public class ConversationActionBar : Gtk.ActionBar {
     private Gtk.Button archive_action;
     [GtkChild]
     private Gtk.Button restore_action;
-    [GtkChild]
-    private Gtk.MenuButton copy_action;
-    [GtkChild]
-    private Gtk.MenuButton move_action;
 
     [GtkChild]
     private Gtk.Grid destructive_actions;
@@ -60,8 +61,8 @@ public class ConversationActionBar : Gtk.ActionBar {
 
 
     public ConversationActionBar() {
-        this.copy_action.popover = copy_folder_menu;
-        this.move_action.popover = move_folder_menu;
+        this.copy_menu.popover = copy_folder_menu;
+        this.move_menu.popover = move_folder_menu;
     }
 
     public void set_account(Geary.Account account) {
@@ -149,9 +150,9 @@ public class ConversationActionBar : Gtk.ActionBar {
         this.folder_actions.set_visible(primary_action != null || show_folder_actions);
         this.archive_action.set_visible(primary_action == this.archive_action);
         this.restore_action.set_visible(primary_action == this.restore_action);
-        this.copy_action.set_visible(show_folder_actions);
+        this.copy_menu.set_visible(show_folder_actions);
         this.copy_folder_menu.enable_disable_folder(location, false);
-        this.move_action.set_visible(show_folder_actions);
+        this.move_menu.set_visible(show_folder_actions);
         this.move_folder_menu.enable_disable_folder(location, false);
 
         if (show_trash && !this.has_trash) {
diff --git a/src/client/components/main-window.vala b/src/client/components/main-window.vala
index 31e89e9..aeffce6 100644
--- a/src/client/components/main-window.vala
+++ b/src/client/components/main-window.vala
@@ -32,12 +32,12 @@ public class MainWindow : Gtk.ApplicationWindow {
     public const string ACTION_HIGHLIGHTED_RESTORE = "highlighted-restore";
     public const string ACTION_HIGHLIGHTED_TRASH = "highlighted-trash";
 
-    public const string ACTION_SHOW_COPY = "show-copy";
-    public const string ACTION_SHOW_MOVE = "show-move";
-
     public const string ACTION_SELECTION_MODE_DISABLE = "selection-mode-disable";
     public const string ACTION_SELECTION_MODE_ENABLE = "selection-mode-enable";
 
+    public const string ACTION_TOGGLE_COPY_MENU = "toggle-copy-menu";
+    public const string ACTION_TOGGLE_MOVE_MENU = "toggle-move-menu";
+
     internal const int CONVERSATION_PAGE_SIZE = 50;
 
     private const int STATUS_BAR_HEIGHT = 18;
@@ -71,11 +71,11 @@ public class MainWindow : Gtk.ApplicationWindow {
         { ACTION_HIGHLIGHTED_RESTORE,        on_highlighted_restore            },
         { ACTION_HIGHLIGHTED_TRASH,          on_highlighted_trash              },
 
-        { ACTION_SHOW_COPY },
-        { ACTION_SHOW_MOVE },
-
         { ACTION_SELECTION_MODE_DISABLE, on_selection_mode_disabled },
-        { ACTION_SELECTION_MODE_ENABLE,  on_selection_mode_enabled  }
+        { ACTION_SELECTION_MODE_ENABLE,  on_selection_mode_enabled  },
+
+        { ACTION_TOGGLE_COPY_MENU, on_toggle_copy_menu },
+        { ACTION_TOGGLE_MOVE_MENU, on_toggle_move_menu }
     };
 
 
@@ -501,8 +501,8 @@ public class MainWindow : Gtk.ApplicationWindow {
         add_window_accelerators(ACTION_HIGHLIGHTED_JUNK, { "<Ctrl>J", "exclam" }); // Exclamation mark (!)
         add_window_accelerators(ACTION_HIGHLIGHTED_TRASH, { "Delete", "BackSpace" });
 
-        add_window_accelerators(ACTION_SHOW_COPY, { "L" });
-        add_window_accelerators(ACTION_SHOW_MOVE, { "M" });
+        add_window_accelerators(ACTION_TOGGLE_COPY_MENU, { "L" });
+        add_window_accelerators(ACTION_TOGGLE_MOVE_MENU, { "M" });
 
         add_window_accelerators(ACTION_SELECTION_MODE_DISABLE, { "Escape", });
     }
@@ -572,6 +572,7 @@ public class MainWindow : Gtk.ApplicationWindow {
                 });
         } else if (highlighted.is_empty) {
             this.highlighted_policy = null;
+            update_highlighted_actions();
         }
     }
 
@@ -597,19 +598,15 @@ public class MainWindow : Gtk.ApplicationWindow {
             has_highlighted && policy.can_trash
         );
 
-        get_action(ACTION_HIGHLIGHTED_COPY).set_enabled(
-            has_highlighted && policy.can_copy
-        );
-        get_action(ACTION_SHOW_COPY).set_enabled(
-            has_highlighted && policy.can_copy
-        );
+        bool can_copy = has_highlighted && policy.can_copy;
+        get_action(ACTION_HIGHLIGHTED_COPY).set_enabled(can_copy);
+        get_action(ACTION_TOGGLE_COPY_MENU).set_enabled(can_copy);
+        this.conversation_list_actions.copy_menu.set_sensitive(can_copy);
 
-        get_action(ACTION_HIGHLIGHTED_MOVE).set_enabled(
-            has_highlighted && policy.can_move
-        );
-        get_action(ACTION_SHOW_MOVE).set_enabled(
-            has_highlighted && policy.can_move
-        );
+        bool can_move = has_highlighted && policy.can_move;
+        get_action(ACTION_HIGHLIGHTED_MOVE).set_enabled(can_move);
+        get_action(ACTION_TOGGLE_MOVE_MENU).set_enabled(can_move);
+        this.conversation_list_actions.move_menu.set_sensitive(can_move);
 
         SimpleAction mark_read = get_action(ACTION_HIGHLIGHTED_MARK_READ);
         SimpleAction mark_unread = get_action(ACTION_HIGHLIGHTED_MARK_UNREAD);
@@ -1463,6 +1460,16 @@ public class MainWindow : Gtk.ApplicationWindow {
         set_selection_mode_enabled(false);
     }
 
+    public void on_toggle_copy_menu() {
+        Gtk.MenuButton button = this.conversation_list_actions.copy_menu;
+        button.set_active(!button.active);
+    }
+
+    public void on_toggle_move_menu() {
+        Gtk.MenuButton button = this.conversation_list_actions.move_menu;
+        button.set_active(!button.active);
+    }
+
     private void on_visible_conversations_changed(Gee.Set<Geary.App.Conversation> visible) {
         this.application.controller.clear_new_messages("on_visible_conversations_changed", visible);
     }
diff --git a/ui/conversation-action-bar.ui b/ui/conversation-action-bar.ui
index 3dc8a77..82a7ddf 100644
--- a/ui/conversation-action-bar.ui
+++ b/ui/conversation-action-bar.ui
@@ -123,11 +123,10 @@
           </packing>
         </child>
         <child>
-          <object class="GtkMenuButton" id="copy_action">
+          <object class="GtkMenuButton" id="copy_menu">
             <property name="visible">True</property>
             <property name="can_focus">True</property>
             <property name="receives_default">True</property>
-            <property name="action_name">win.show-copy</property>
             <child>
               <object class="GtkImage">
                 <property name="visible">True</property>
@@ -142,11 +141,10 @@
           </packing>
         </child>
         <child>
-          <object class="GtkMenuButton" id="move_action">
+          <object class="GtkMenuButton" id="move_menu">
             <property name="visible">True</property>
             <property name="can_focus">True</property>
             <property name="receives_default">True</property>
-            <property name="action_name">win.show-move</property>
             <child>
               <object class="GtkImage">
                 <property name="visible">True</property>


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