From 66928f73f6cbaf3d57ca58ab9b0998ab5a7bcd88 Mon Sep 17 00:00:00 2001 From: Michael James Gratton Date: Sun, 29 May 2016 23:25:49 +1000 Subject: [PATCH] Enable L/M keyboard shortcut for label/moving messages. Fixes Bug 731737. * help/C/shortcuts.page: Document new shortcuts. * src/client/application/geary-controller.vala: Add shortcuts for copy and move actions. * src/client/components/pill-toolbar.vala (PillBar::create_menu_button): Hook up the button's related action to invoke the button's popup menu, taking care not to cause an infinte loop. (PillBar::setup_button): Connect to the related_action's tooltip notify signal via a local variable rather than via the button, so it does not get lost when it changes for Gtk.MenuButton actions. --- help/C/shortcuts.page | 8 ++++++++ src/client/application/geary-controller.vala | 2 ++ src/client/components/pill-toolbar.vala | 16 +++++++++++++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/help/C/shortcuts.page b/help/C/shortcuts.page index ea691638..67a0f688 100644 --- a/help/C/shortcuts.page +++ b/help/C/shortcuts.page @@ -55,6 +55,14 @@

Mark unread

CtrlU or ShiftU

+ +

Open the Label Conversation menu

+

L

+ + +

Open the Move Conversation menu

+

M

+

Move focus to the next/previous pane

F6 / ShiftF6

diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala index 25d76426..1e698cf3 100644 --- a/src/client/application/geary-controller.vala +++ b/src/client/application/geary-controller.vala @@ -429,10 +429,12 @@ public class GearyController : Geary.BaseObject { _("Add label"), null }; copy_menu.label = _("_Label"); entries += copy_menu; + add_accelerator("l", ACTION_COPY_MENU); Gtk.ActionEntry move_menu = { ACTION_MOVE_MENU, null, TRANSLATABLE, "M", _("Move conversation"), null }; move_menu.label = _("_Move"); entries += move_menu; + add_accelerator("m", ACTION_MOVE_MENU); Gtk.ActionEntry new_message = { ACTION_NEW_MESSAGE, null, null, "N", _("Compose new message (Ctrl+N, N)"), on_new_message }; diff --git a/src/client/components/pill-toolbar.vala b/src/client/components/pill-toolbar.vala index 0bde8c25..79f4b506 100644 --- a/src/client/components/pill-toolbar.vala +++ b/src/client/components/pill-toolbar.vala @@ -35,9 +35,10 @@ public interface PillBar : Gtk.Container { public virtual void setup_button(Gtk.Button b, string? icon_name, string action_name, bool show_label = false) { - b.related_action = action_group.get_action(action_name); - b.tooltip_text = b.related_action.tooltip; - b.related_action.notify["tooltip"].connect(() => { b.tooltip_text = b.related_action.tooltip; }); + Gtk.Action related_action = action_group.get_action(action_name); + b.tooltip_text = related_action.tooltip; + related_action.notify["tooltip"].connect(() => { b.tooltip_text = related_action.tooltip; }); + b.related_action = related_action; // Load icon by name with this fallback order: specified icon name, the action's icon name, // the action's stock ID ... although stock IDs are being deprecated, that's how we specify @@ -88,6 +89,15 @@ public interface PillBar : Gtk.Container { Gtk.MenuButton b = new Gtk.MenuButton(); setup_button(b, icon_name, action_name); b.popup = menu; + + if (b.related_action != null) { + b.related_action.activate.connect(() => { + b.clicked(); + }); + // Null out the action since by connecting it to clicked + // above, invoking would cause an infinite loop otherwise. + b.related_action = null; + } return b; }