diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala index 754ee573..a3f619b0 100644 --- a/src/client/composer/composer-widget.vala +++ b/src/client/composer/composer-widget.vala @@ -91,8 +91,7 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface { ACTION_OLIST, ACTION_ULIST }; - private const ActionEntry[] action_entries = { - // Editor commands + private const ActionEntry[] editor_action_entries = { {ACTION_UNDO, on_undo }, {ACTION_REDO, on_redo }, {ACTION_CUT, on_cut }, @@ -116,18 +115,20 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface { {ACTION_COLOR, on_select_color }, {ACTION_INSERT_IMAGE, on_insert_image }, {ACTION_INSERT_LINK, on_insert_link }, - // Composer commands - {ACTION_COMPOSE_AS_HTML, on_toggle_action, null, "true", on_compose_as_html_toggled }, - {ACTION_SHOW_EXTENDED, on_toggle_action, null, "false", on_show_extended_toggled }, - {ACTION_CLOSE, on_close }, - {ACTION_CLOSE_AND_SAVE, on_close_and_save }, - {ACTION_CLOSE_AND_DISCARD, on_close_and_discard }, - {ACTION_DETACH, on_detach }, - {ACTION_SEND, on_send }, + {ACTION_OPEN_INSPECTOR, on_open_inspector }, + }; + + private const ActionEntry[] composer_action_entries = { {ACTION_ADD_ATTACHMENT, on_add_attachment }, {ACTION_ADD_ORIGINAL_ATTACHMENTS, on_pending_attachments }, + {ACTION_CLOSE, on_close }, + {ACTION_CLOSE_AND_DISCARD, on_close_and_discard }, + {ACTION_CLOSE_AND_SAVE, on_close_and_save }, + {ACTION_COMPOSE_AS_HTML, on_toggle_action, null, "true", on_compose_as_html_toggled }, + {ACTION_DETACH, on_detach }, {ACTION_SELECT_DICTIONARY, on_select_dictionary }, - {ACTION_OPEN_INSPECTOR, on_open_inspector }, + {ACTION_SEND, on_send }, + {ACTION_SHOW_EXTENDED, on_toggle_action, null, "false", on_show_extended_toggled }, }; public static Gee.MultiMap action_accelerators = new Gee.HashMultiMap(); @@ -250,6 +251,9 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface { [GtkChild] internal Gtk.Grid editor_container; + [GtkChild] + internal Gtk.Grid body_container; + [GtkChild] private Gtk.Label from_label; [GtkChild] @@ -320,7 +324,8 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface { [GtkChild] private Gtk.Box message_area; - private SimpleActionGroup actions = new SimpleActionGroup(); + private SimpleActionGroup composer_actions = new SimpleActionGroup(); + private SimpleActionGroup editor_actions = new SimpleActionGroup(); private Menu html_menu; private Menu plain_menu; @@ -457,7 +462,7 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface { this.editor.set_vexpand(true); this.editor.show(); - this.editor_container.add(this.editor); + this.body_container.add(this.editor); // Initialize menus Gtk.Builder builder = new Gtk.Builder.from_resource( @@ -807,18 +812,31 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface { // Initializes all actions and adds them to the action group private void initialize_actions() { - this.actions.add_action_entries(action_entries, this); + // Composer actions + this.composer_actions.add_action_entries( + ComposerWidget.composer_action_entries, this + ); + // Main actions use 'win' prefix so they override main window + // action. But for some reason, we can't use the same prefix + // for the headerbar. + insert_action_group("win", this.composer_actions); + this.header.insert_action_group("cmh", this.composer_actions); - // Main actions should use 'win' prefix so they override main - // window action. But for some reason, we can't use the same - // prefix for the headerbar. - insert_action_group("win", this.actions); - this.header.insert_action_group("cmh", this.actions); + // Editor actions - scoped to the editor only. Need to include + // composer actions however since if not found in this group, + // ancestors (including the composer's) will not be consulted. + this.editor_actions.add_action_entries( + ComposerWidget.composer_action_entries, this + ); + this.editor_actions.add_action_entries( + ComposerWidget.editor_action_entries, this + ); + this.editor_container.insert_action_group("win", this.editor_actions); - this.actions.change_action_state( + this.composer_actions.change_action_state( ACTION_SHOW_EXTENDED, false ); - this.actions.change_action_state( + this.composer_actions.change_action_state( ACTION_COMPOSE_AS_HTML, this.config.compose_as_html ); @@ -1183,7 +1201,7 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface { // conversation back in the main window. The workaround here // sets a new menu model and hence the menu_button constructs // a new popover. - this.actions.change_action_state(ACTION_COMPOSE_AS_HTML, + this.composer_actions.change_action_state(ACTION_COMPOSE_AS_HTML, GearyApplication.instance.config.compose_as_html); this.state = ComposerWidget.ComposerState.DETACHED; @@ -1672,7 +1690,7 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface { // the Enter leaking through to the controls, but only // send if send is available if ((event.state & Gdk.ModifierType.CONTROL_MASK) != 0) { - this.actions.activate_action(ACTION_SEND, null); + this.composer_actions.activate_action(ACTION_SEND, null); ret = Gdk.EVENT_STOP; } break; @@ -2019,8 +2037,12 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface { * Helper method, returns a composer action. * @param action_name - The name of the action (as found in action_entries) */ - public SimpleAction? get_action(string action_name) { - return this.actions.lookup_action(action_name) as SimpleAction; + public GLib.SimpleAction? get_action(string action_name) { + GLib.Action? action = this.composer_actions.lookup_action(action_name); + if (action == null) { + action = this.editor_actions.lookup_action(action_name); + } + return action as SimpleAction; } private bool add_account_emails_to_from_list(Geary.Account other_account, bool set_active = false) { @@ -2240,7 +2262,8 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface { // without the popover immediately appearing and raining on // their text selection parade. if (this.pointer_url != null && - this.actions.get_action_state(ACTION_COMPOSE_AS_HTML).get_boolean()) { + this.composer_actions.get_action_state(ACTION_COMPOSE_AS_HTML) + .get_boolean()) { Gdk.EventButton? button = (Gdk.EventButton) event; Gdk.Rectangle location = Gdk.Rectangle(); location.x = (int) button.x; @@ -2262,31 +2285,33 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface { this.cursor_url = context.is_link ? context.link_url : null; update_cursor_actions(); - this.actions.change_action_state(ACTION_FONT_FAMILY, context.font_family); + this.editor_actions.change_action_state( + ACTION_FONT_FAMILY, context.font_family + ); if (context.font_size < 11) - this.actions.change_action_state(ACTION_FONT_SIZE, "small"); + this.editor_actions.change_action_state(ACTION_FONT_SIZE, "small"); else if (context.font_size > 20) - this.actions.change_action_state(ACTION_FONT_SIZE, "large"); + this.editor_actions.change_action_state(ACTION_FONT_SIZE, "large"); else - this.actions.change_action_state(ACTION_FONT_SIZE, "medium"); + this.editor_actions.change_action_state(ACTION_FONT_SIZE, "medium"); } private void on_typing_attributes_changed() { uint mask = this.editor.get_editor_state().get_typing_attributes(); - this.actions.change_action_state( + this.editor_actions.change_action_state( ACTION_BOLD, (mask & WebKit.EditorTypingAttributes.BOLD) == WebKit.EditorTypingAttributes.BOLD ); - this.actions.change_action_state( + this.editor_actions.change_action_state( ACTION_ITALIC, (mask & WebKit.EditorTypingAttributes.ITALIC) == WebKit.EditorTypingAttributes.ITALIC ); - this.actions.change_action_state( + this.editor_actions.change_action_state( ACTION_UNDERLINE, (mask & WebKit.EditorTypingAttributes.UNDERLINE) == WebKit.EditorTypingAttributes.UNDERLINE ); - this.actions.change_action_state( + this.editor_actions.change_action_state( ACTION_STRIKETHROUGH, (mask & WebKit.EditorTypingAttributes.STRIKETHROUGH) == WebKit.EditorTypingAttributes.STRIKETHROUGH ); diff --git a/ui/composer-widget.ui b/ui/composer-widget.ui index d22e881c..6b9eb834 100644 --- a/ui/composer-widget.ui +++ b/ui/composer-widget.ui @@ -329,33 +329,71 @@ - + True False - 6 - 6 - 6 - + True False + 6 + 6 + 6 - + True - True - False - False - Undo last edit (Ctrl+Z) - win.undo - True + False - + True - False - 16 - edit-undo-symbolic + True + False + False + Undo last edit (Ctrl+Z) + win.undo + True + + + True + False + 16 + edit-undo-symbolic + + + + False + True + 0 + + + + True + True + False + False + Redo last edit (Ctrl+Shift+Z) + win.redo + True + + + True + False + 16 + edit-redo-symbolic + + + + + False + True + 1 + + + False @@ -364,84 +402,108 @@ - + True - True - False - False - Redo last edit (Ctrl+Shift+Z) - win.redo - True + False - + True - False - 16 - edit-redo-symbolic + True + False + False + Bold (Ctrl+B) + win.bold + True + + + True + False + 16 + format-text-bold-symbolic + + + + False + True + 0 + - - - False - True - 1 - - - - - - False - True - 0 - - - - - True - False - - - True - True - False - False - Bold (Ctrl+B) - win.bold - True - + True - False - 16 - format-text-bold-symbolic + True + False + False + Italic (Ctrl+I) + win.italic + True + + + True + False + 16 + format-text-italic-symbolic + + + + False + True + 1 + - - - False - True - 0 - - - - - True - True - False - False - Italic (Ctrl+I) - win.italic - True - + True - False - 16 - format-text-italic-symbolic + True + False + False + Underline (Ctrl+U) + win.underline + True + + + True + False + 16 + format-text-underline-symbolic + + + + False + True + 2 + + + + True + True + False + False + Strikethrough (Ctrl+K) + win.strikethrough + True + + + True + False + 16 + format-text-strikethrough-symbolic + + + + + False + True + 3 + + + False @@ -450,22 +512,60 @@ - + True - True - False - False - Underline (Ctrl+U) - win.underline - True + False - + True - False - 16 - format-text-underline-symbolic + True + False + False + Insert unordered list + win.ulist + True + + + True + False + 16 + format-unordered-list-symbolic + + + + False + True + 0 + + + + True + True + False + False + Insert ordered list + win.olist + True + + + True + False + 16 + format-ordered-list-symbolic + + + + + False + True + 1 + + + False @@ -474,22 +574,60 @@ - + True - True - False - False - Strikethrough (Ctrl+K) - win.strikethrough - True + False - + True - False - 16 - format-text-strikethrough-symbolic + True + False + False + Quote text (Ctrl+]) + win.indent + True + + + True + False + 16 + format-indent-more-symbolic + + + + False + True + 0 + + + + True + True + False + False + Unquote text (Ctrl+[) + win.outdent + True + + + True + False + 16 + format-indent-less-symbolic + + + + + False + True + 1 + + + False @@ -497,285 +635,241 @@ 3 - - - - False - True - 1 - - - - - True - False - - True - True - False - False - Insert unordered list - win.ulist - True - - - True - False - 16 - format-unordered-list-symbolic - - - - - False - True - 0 - - - - - True - True - False - False - Insert ordered list - win.olist - True - - - True - False - 16 - format-ordered-list-symbolic - - - - - False - True - 1 - - - - - - False - True - 2 - - - - - True - False - - - True - True - False - False - Quote text (Ctrl+]) - win.indent - True - - - True - False - 16 - format-indent-more-symbolic - - - - - False - True - 0 - - - - - True - True - False - False - Unquote text (Ctrl+[) - win.outdent - True - - - True - False - 16 - format-indent-less-symbolic - - - - - False - True - 1 - - - - - - False - True - 3 - - - - - True - False - - - True - True - False - False - Insert or update selection link (Ctrl+L) - win.insert-link - True - - - True - False - 16 - insert-link-symbolic - - - - - False - True - 0 - - - - - True - True - False - False - Insert an image (Ctrl+G) - win.insert-image - True - - - True - False - 16 - insert-image-symbolic - - - - - False - True - 1 - - - - - - False - True - 4 - - - - - True - True - False - False - Remove selection formatting (Ctrl+Space) - win.remove-format - True - - + True False - 16 - format-text-remove-symbolic + + + True + True + False + False + Insert or update selection link (Ctrl+L) + win.insert-link + True + + + True + False + 16 + insert-link-symbolic + + + + + False + True + 0 + + + + + True + True + False + False + Insert an image (Ctrl+G) + win.insert-image + True + + + True + False + 16 + insert-image-symbolic + + + + + False + True + 1 + + + + + False + True + 4 + - - - False - True - 5 - - - - - True - True - False - False - Select spell checking languages - win.select-dictionary - True - + + True + True + False + False + Remove selection formatting (Ctrl+Space) + win.remove-format + True + + + True + False + 16 + format-text-remove-symbolic + + + + + False + True + 5 + + + + + True + True + False + False + Select spell checking languages + win.select-dictionary + True + + + True + False + 16 + accessories-dictionary-symbolic + + + + + False + True + 6 + + + + True False - 16 - accessories-dictionary-symbolic + False + False + + + + + False + True + end + 7 + + + + + True + True + end + 6 + 0 + + + + False + True + end + 8 + - False - True - 6 + 0 + 0 - + True False - False - False + 0 + in - + + True + False + + + True + False + + + 250 + True + False + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -1 + + + + + False + True + start + end + middle + + + + + + True + True + 0 + + + - - - False - True - end - 7 - - - - - True - True - end - 6 - 0 - False - True - end - 8 + 0 + 1 + + + False @@ -783,92 +877,12 @@ 3 - - - True - False - 0 - in - - - True - False - - - True - False - - - 250 - True - False - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -1 - - - - - False - True - start - end - middle - - - - - - True - True - 0 - - - - - - - - True - True - 4 - - True False + 6 + 6 6 6 6 @@ -882,7 +896,7 @@ False True - 5 + 4