From fdb9243ae536a49ba6bd76839da2a669814fef18 Mon Sep 17 00:00:00 2001 From: Michael Gratton Date: Wed, 9 Jan 2019 10:20:51 +1100 Subject: [PATCH] Move common account editor pane in-app notification impl to the editor This moves the individual in-app notification implementation on each of the editor panes to the editor itself, reducing redundancy and allowing the editor to issue notifications if needed (spoiler: it will). --- po/POTFILES.in | 1 + .../accounts/accounts-editor-add-pane.vala | 10 +- .../accounts/accounts-editor-list-pane.vala | 12 +- .../accounts-editor-servers-pane.vala | 10 +- src/client/accounts/accounts-editor.vala | 40 ++-- ui/accounts_editor.ui | 64 +++++ ui/accounts_editor_add_pane.ui | 193 +++++++-------- ui/accounts_editor_list_pane.ui | 225 +++++++++--------- ui/accounts_editor_servers_pane.ui | 219 ++++++++--------- ui/org.gnome.Geary.gresource.xml | 1 + 10 files changed, 393 insertions(+), 382 deletions(-) create mode 100644 ui/accounts_editor.ui diff --git a/po/POTFILES.in b/po/POTFILES.in index 50387e02..f93c1690 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -401,6 +401,7 @@ src/engine/util/util-time.vala src/engine/util/util-timeout-manager.vala src/engine/util/util-trillian.vala src/mailer/main.vala +ui/accounts_editor.ui ui/accounts_editor_add_pane.ui ui/accounts_editor_edit_pane.ui ui/accounts_editor_list_pane.ui diff --git a/src/client/accounts/accounts-editor-add-pane.vala b/src/client/accounts/accounts-editor-add-pane.vala index cee7d989..3d7a5610 100644 --- a/src/client/accounts/accounts-editor-add-pane.vala +++ b/src/client/accounts/accounts-editor-add-pane.vala @@ -27,9 +27,6 @@ internal class Accounts.EditorAddPane : Gtk.Grid, EditorPane { [GtkChild] private Gtk.HeaderBar header; - [GtkChild] - private Gtk.Overlay osd_overlay; - [GtkChild] private Gtk.Grid pane_content; @@ -148,11 +145,6 @@ internal class Accounts.EditorAddPane : Gtk.Grid, EditorPane { return this.header; } - private void add_notification(InAppNotification notification) { - this.osd_overlay.add_overlay(notification); - notification.show(); - } - private async void validate_account(GLib.Cancellable? cancellable) { this.create_spinner.show(); this.create_spinner.start(); @@ -271,7 +263,7 @@ internal class Accounts.EditorAddPane : Gtk.Grid, EditorPane { if (to_focus != null) { to_focus.grab_focus(); } - add_notification( + this.editor.add_notification( new InAppNotification( // Translators: In-app notification label, the // string substitution is a more detailed reason. diff --git a/src/client/accounts/accounts-editor-list-pane.vala b/src/client/accounts/accounts-editor-list-pane.vala index db8092d8..5aa0975b 100644 --- a/src/client/accounts/accounts-editor-list-pane.vala +++ b/src/client/accounts/accounts-editor-list-pane.vala @@ -54,9 +54,6 @@ internal class Accounts.EditorListPane : Gtk.Grid, EditorPane, CommandPane { [GtkChild] private Gtk.HeaderBar header; - [GtkChild] - private Gtk.Overlay osd_overlay; - [GtkChild] private Gtk.Grid pane_content; @@ -165,11 +162,6 @@ internal class Accounts.EditorListPane : Gtk.Grid, EditorPane, CommandPane { this.accounts_list.add(row); } - private void add_notification(InAppNotification notification) { - this.osd_overlay.add_overlay(notification); - notification.show(); - } - private void update_welcome_panel() { if (this.show_welcome) { // No accounts are available, so show only the welcome @@ -241,7 +233,7 @@ internal class Accounts.EditorListPane : Gtk.Grid, EditorPane, CommandPane { if (command.executed_label != null) { InAppNotification ian = new InAppNotification(command.executed_label); ian.set_button(_("Undo"), "win." + GearyController.ACTION_UNDO); - add_notification(ian); + this.editor.add_notification(ian); } } @@ -249,7 +241,7 @@ internal class Accounts.EditorListPane : Gtk.Grid, EditorPane, CommandPane { if (command.undone_label != null) { InAppNotification ian = new InAppNotification(command.undone_label); ian.set_button(_("Redo"), "win." + GearyController.ACTION_REDO); - add_notification(ian); + this.editor.add_notification(ian); } } diff --git a/src/client/accounts/accounts-editor-servers-pane.vala b/src/client/accounts/accounts-editor-servers-pane.vala index 6c4e410a..1718ea03 100644 --- a/src/client/accounts/accounts-editor-servers-pane.vala +++ b/src/client/accounts/accounts-editor-servers-pane.vala @@ -44,9 +44,6 @@ internal class Accounts.EditorServersPane : [GtkChild] private Gtk.HeaderBar header; - [GtkChild] - private Gtk.Overlay osd_overlay; - [GtkChild] private Gtk.Grid pane_content; @@ -283,7 +280,7 @@ internal class Accounts.EditorServersPane : debug("Validation complete, is valid: %s", is_valid.to_string()); if (!is_valid) { - add_notification( + this.editor.add_notification( new InAppNotification( // Translators: In-app notification label, the // string substitution is a more detailed reason. @@ -329,11 +326,6 @@ internal class Accounts.EditorServersPane : return has_changed; } - private void add_notification(InAppNotification notification) { - this.osd_overlay.add_overlay(notification); - notification.show(); - } - private void add_row(Gtk.ListBox list, EditorRow row) { list.add(row); ValidatingRow? validating = row as ValidatingRow; diff --git a/src/client/accounts/accounts-editor.vala b/src/client/accounts/accounts-editor.vala index 30eee914..a27c4db9 100644 --- a/src/client/accounts/accounts-editor.vala +++ b/src/client/accounts/accounts-editor.vala @@ -8,6 +8,7 @@ /** * The main account editor window. */ +[GtkTemplate (ui = "/org/gnome/Geary/accounts_editor.ui")] public class Accounts.Editor : Gtk.Dialog { @@ -32,7 +33,12 @@ public class Accounts.Editor : Gtk.Dialog { private SimpleActionGroup actions = new SimpleActionGroup(); - private Gtk.Stack editor_panes = new Gtk.Stack(); + [GtkChild] + private Gtk.Overlay notifications_pane; + + [GtkChild] + private Gtk.Stack editor_panes; + private EditorListPane editor_list_pane; private Gee.LinkedList editor_pane_stack = @@ -41,23 +47,13 @@ public class Accounts.Editor : Gtk.Dialog { public Editor(GearyApplication application, Gtk.Window parent) { this.application = application; + this.transient_for = parent; + + // Can't set this in Glade 3.22.1 :( + this.get_content_area().border_width = 0; + this.accounts = application.controller.account_manager; - set_default_size(700, 450); - set_icon_name(GearyApplication.APP_ID); - set_modal(true); - set_title(_("Accounts")); - set_transient_for(parent); - - get_content_area().border_width = 0; - get_content_area().add(this.editor_panes); - - this.editor_panes.set_transition_type( - Gtk.StackTransitionType.SLIDE_LEFT_RIGHT - ); - this.editor_panes.notify["visible-child"].connect_after(on_pane_changed); - this.editor_panes.show(); - this.actions.add_action_entries(ACTION_ENTRIES, this); insert_action_group("win", this.actions); @@ -94,11 +90,6 @@ public class Accounts.Editor : Gtk.Dialog { return ret; } - public override void destroy() { - this.editor_panes.notify["visible-child"].disconnect(on_pane_changed); - base.destroy(); - } - internal void push(EditorPane pane) { // Since we keep old, already-popped panes around (see pop for // details), when a new pane is pushed on they need to be @@ -127,6 +118,12 @@ public class Accounts.Editor : Gtk.Dialog { this.editor_panes.set_visible_child(prev); } + /** Displays an in-app notification in the dialog. */ + internal void add_notification(InAppNotification notification) { + this.notifications_pane.add_overlay(notification); + notification.show(); + } + internal void remove_account(Geary.AccountInformation account) { this.editor_panes.set_visible_child(this.editor_list_pane); this.editor_list_pane.remove_account(account); @@ -168,6 +165,7 @@ public class Accounts.Editor : Gtk.Dialog { } } + [GtkCallback] private void on_pane_changed() { EditorPane? visible = get_current_pane(); Gtk.Widget? header = null; diff --git a/ui/accounts_editor.ui b/ui/accounts_editor.ui new file mode 100644 index 00000000..22d41852 --- /dev/null +++ b/ui/accounts_editor.ui @@ -0,0 +1,64 @@ + + + + + + diff --git a/ui/accounts_editor_add_pane.ui b/ui/accounts_editor_add_pane.ui index 4e4921f3..8d942c33 100644 --- a/ui/accounts_editor_add_pane.ui +++ b/ui/accounts_editor_add_pane.ui @@ -81,27 +81,65 @@ True False - + True - False + True + True + True + pane_adjustment + never + in - + True - True - True - True - pane_adjustment - never - in + False + none - + True False - none - + True False + 0 + in + + + True + False + none + + + + + + 0 + 0 + + + + + True + False + + + True + False + start + Receiving + + + + + + + 0 + 0 + + True @@ -109,7 +147,7 @@ 0 in - + True False none @@ -117,52 +155,52 @@ + + 0 + 1 + + + + + 0 + 1 + + + + + True + False + + + True + False + start + Sending + + + + + 0 0 - + True False + 0 + in - + True False - start - Receiving - - - - + none + - - 0 - 0 - - - - - True - False - 0 - in - - - True - False - none - - - - - - 0 - 1 - @@ -170,65 +208,18 @@ 1 - - - True - False - - - True - False - start - Sending - - - - - - - 0 - 0 - - - - - True - False - 0 - in - - - True - False - none - - - - - - 0 - 1 - - - - - 0 - 2 - - - + + 0 + 2 + + - - -1 - diff --git a/ui/accounts_editor_list_pane.ui b/ui/accounts_editor_list_pane.ui index 36a4d3d3..85e7944a 100644 --- a/ui/accounts_editor_list_pane.ui +++ b/ui/accounts_editor_list_pane.ui @@ -18,171 +18,160 @@ True False - + True - False + True True True + pane_adjustment + never + 400 - + True - True - True - True - pane_adjustment - never - 400 + False - + True False - + True False + center + 12 - + True False - center - 12 - - - True - False - 64 - org.gnome.Geary - True - - - 0 - 0 - 2 - - - - - True - False - start - start - To get started, select an email provider below. - - - 1 - 1 - - - - - True - False - start - end - Welcome to Geary - - - - - - 1 - 0 - - - + 64 + org.gnome.Geary + True 0 0 + 2 - + True False + start start - True - True - 0 - in - - - True - False - none - - - - - - - + To get started, select an email provider below. - 0 + 1 1 - + True False start - Add an account + end + Welcome to Geary - - 0 - 2 - - - - - True - False - start - True - True - 0 - in - - - 0 - True - False - start - none - - - - - - - - - - 0 - 3 + 1 + 0 + + 0 + 0 + + + + True + False + start + True + True + 0 + in + + + True + False + none + + + + + + + + + + 0 + 1 + + + + + True + False + start + Add an account + + + + + + + 0 + 2 + + + + + True + False + start + True + True + 0 + in + + + 0 + True + False + start + none + + + + + + + + + + 0 + 3 + + + - - -1 - diff --git a/ui/accounts_editor_servers_pane.ui b/ui/accounts_editor_servers_pane.ui index d49704be..1a1234a3 100644 --- a/ui/accounts_editor_servers_pane.ui +++ b/ui/accounts_editor_servers_pane.ui @@ -76,142 +76,133 @@ True False - + True - False + True + True + True + pane_adjustment + never + 400 - + True - True - True - True - pane_adjustment - never - 400 + False - + True False - + True False + True + 0 + in - + True False - True - 0 - in - - - True - False - none - - - - - - - + none + + - - 0 - 2 - - - - True - False - start - Receiving - - - - 0 - 1 - - - - - True - False - True - 0 - in - - - True - False - none - - - - - - - - - - 0 - 4 - - - - - True - False - start - Sending - - - - 0 - 3 - - - - - True - False - True - 0 - in - - - True - False - none - - - - - - - - - - 0 - 0 - + + + + + 0 + 2 + + + + + True + False + start + Receiving + + 0 + 1 + + + + True + False + True + 0 + in + + + True + False + none + + + + + + + + + + 0 + 4 + + + + + True + False + start + Sending + + + + 0 + 3 + + + + + True + False + True + 0 + in + + + True + False + none + + + + + + + + + + 0 + 0 + + + - - -1 - diff --git a/ui/org.gnome.Geary.gresource.xml b/ui/org.gnome.Geary.gresource.xml index 38fce5d8..9aa268bb 100644 --- a/ui/org.gnome.Geary.gresource.xml +++ b/ui/org.gnome.Geary.gresource.xml @@ -1,6 +1,7 @@ + accounts_editor.ui accounts_editor_add_pane.ui accounts_editor_edit_pane.ui accounts_editor_list_pane.ui