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.
This commit is contained in:
Michael James Gratton 2016-05-29 23:25:49 +10:00
parent 54ba285ab8
commit 66928f73f6
3 changed files with 23 additions and 3 deletions

View file

@ -55,6 +55,14 @@
<td><p>Mark unread</p></td>
<td><p> <keyseq><key>Ctrl</key><key>U</key></keyseq> or <keyseq><key>Shift</key><key>U</key></keyseq> </p></td>
</tr>
<tr>
<td><p>Open the Label Conversation menu</p></td>
<td><p><key>L</key></p></td>
</tr>
<tr>
<td><p>Open the Move Conversation menu</p></td>
<td><p><key>M</key></p></td>
</tr>
<tr>
<td><p>Move focus to the next/previous pane</p></td>
<td><p> <keyseq><key>F6</key></keyseq> / <keyseq><key>Shift</key><key>F6</key></keyseq> </p></td>

View file

@ -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, "<Ctrl>N",
_("Compose new message (Ctrl+N, N)"), on_new_message };

View file

@ -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;
}