diff options
author | Niels De Graef <nielsdegraef@gmail.com> | 2023-02-11 23:51:32 +0100 |
---|---|---|
committer | Niels De Graef <nielsdegraef@gmail.com> | 2023-02-12 09:22:09 +0000 |
commit | cf0987c7dab429c86f3295c440dbfd0ad957c406 (patch) | |
tree | 8b9948feb5c4edebb3a42449fcc68109d22b9b7b /src | |
parent | 34869e2f15844bee8938df2a4ccde14fbe662e2b (diff) | |
download | gnome-contacts-cf0987c7dab429c86f3295c440dbfd0ad957c406.tar.gz |
Add shortcuts for saving/canceling contact edit
Allow saving a contact by pressing `<Ctrl>Enter` or cancelling by
pressing `Escape`.
Diffstat (limited to 'src')
-rw-r--r-- | src/contacts-main-window.vala | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/contacts-main-window.vala b/src/contacts-main-window.vala index 684d3bc..8d46b6b 100644 --- a/src/contacts-main-window.vala +++ b/src/contacts-main-window.vala @@ -24,7 +24,8 @@ public class Contacts.MainWindow : Adw.ApplicationWindow { private const GLib.ActionEntry[] ACTION_ENTRIES = { { "new-contact", new_contact }, { "edit-contact", edit_contact }, - { "stop-editing-contact", stop_editing_contact, "b" }, + { "edit-contact-cancel", edit_contact_cancel }, + { "edit-contact-save", edit_contact_save }, { "focus-search", focus_search }, { "toggle-favorite", toggle_favorite }, { "link-marked-contacts", link_marked_contacts }, @@ -347,19 +348,34 @@ public class Contacts.MainWindow : Adw.ApplicationWindow { }); } - private void stop_editing_contact (SimpleAction action, GLib.Variant? parameter) { - bool cancel = parameter.get_boolean (); + private void edit_contact_save (SimpleAction action, GLib.Variant? parameter) { + if (this.state != UiState.CREATING && this.state != UiState.UPDATING) + return; if (this.state == UiState.CREATING) { - if (cancel) { - show_list_pane (); - } this.state = UiState.NORMAL; } else { show_contact_pane (); this.state = UiState.SHOWING; } - this.contact_pane.stop_editing (cancel); + this.contact_pane.stop_editing (false); + this.contacts_list.scroll_to_selected (); + + this.right_header.title_widget = new Adw.WindowTitle ("", ""); + } + + private void edit_contact_cancel (SimpleAction action, GLib.Variant? parameter) { + if (this.state != UiState.CREATING && this.state != UiState.UPDATING) + return; + + if (this.state == UiState.CREATING) { + show_list_pane (); + this.state = UiState.NORMAL; + } else { + show_contact_pane (); + this.state = UiState.SHOWING; + } + this.contact_pane.stop_editing (true); this.contacts_list.scroll_to_selected (); this.right_header.title_widget = new Adw.WindowTitle ("", ""); |