diff --git a/po/POTFILES.in b/po/POTFILES.in index 35b8c704..6e2e5fc4 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -19,6 +19,7 @@ src/client/accounts/account-manager.vala src/client/accounts/account-spinner-page.vala src/client/accounts/accounts-editor.vala src/client/accounts/accounts-editor-edit-pane.vala +src/client/accounts/accounts-editor-remove-pane.vala src/client/accounts/accounts-editor-row.vala src/client/accounts/add-edit-page.vala src/client/accounts/editor.vala @@ -411,6 +412,7 @@ ui/account_list.glade ui/account_spinner.glade ui/accounts_editor.ui ui/accounts_editor_edit_pane.ui +ui/accounts_editor_remove_pane.ui ui/certificate_warning_dialog.glade ui/composer-headerbar.ui ui/composer-link-popover.ui diff --git a/src/client/accounts/accounts-editor-edit-pane.vala b/src/client/accounts/accounts-editor-edit-pane.vala index 932efd1b..2807eb51 100644 --- a/src/client/accounts/accounts-editor-edit-pane.vala +++ b/src/client/accounts/accounts-editor-edit-pane.vala @@ -12,6 +12,7 @@ public class Accounts.EditorEditPane : Gtk.Grid { + private weak Editor editor; // circular ref private Geary.AccountInformation account; [GtkChild] @@ -29,8 +30,9 @@ public class Accounts.EditorEditPane : Gtk.Grid { private Gtk.ListBox settings_list; - public EditorEditPane(GearyApplication application, + public EditorEditPane(Editor editor, Geary.AccountInformation account) { + this.editor = editor; this.account = account; PropertyRow nickname_row = new PropertyRow( @@ -63,7 +65,9 @@ public class Accounts.EditorEditPane : Gtk.Grid { this.addresses_list.add(new AddRow()); - this.signature_preview = new ClientWebView(application.config); + this.signature_preview = new ClientWebView( + ((GearyApplication) editor.application).config + ); this.signature_preview.load_html(account.email_signature); this.signature_preview.show(); @@ -83,6 +87,16 @@ public class Accounts.EditorEditPane : Gtk.Grid { return name; } + + [GtkCallback] + private void on_server_settings_clicked() { + + } + + [GtkCallback] + private void on_remove_account_clicked() { + this.editor.push(new EditorRemovePane(this.editor, this.account)); + } } diff --git a/src/client/accounts/accounts-editor-remove-pane.vala b/src/client/accounts/accounts-editor-remove-pane.vala new file mode 100644 index 00000000..13b63649 --- /dev/null +++ b/src/client/accounts/accounts-editor-remove-pane.vala @@ -0,0 +1,53 @@ +/* + * Copyright 2018 Michael Gratton + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +/** + * The main account editor window. + */ +[GtkTemplate (ui = "/org/gnome/Geary/accounts_editor_remove_pane.ui")] +public class Accounts.EditorRemovePane : Gtk.Grid { + + + private weak Editor editor; // circular ref + private Geary.AccountInformation account; + + [GtkChild] + private Gtk.Stack confirm_stack; + + [GtkChild] + private Gtk.Label warning_label; + + [GtkChild] + private Gtk.Spinner remove_spinner; + + [GtkChild] + private Gtk.Label remove_label; + + [GtkChild] + private Gtk.Button remove_button; + + + public EditorRemovePane(Editor editor, Geary.AccountInformation account) { + this.editor = editor; + this.account = account; + + this.warning_label.set_text( + this.warning_label.get_text().printf(account.nickname) + ); + this.remove_label.set_text( + this.remove_label.get_text().printf(account.nickname) + ); + } + + [GtkCallback] + private void on_remove_button_clicked() { + this.remove_button.set_sensitive(false); + this.remove_spinner.start(); + this.confirm_stack.set_visible_child_name("remove"); + } + +} diff --git a/src/client/accounts/accounts-editor.vala b/src/client/accounts/accounts-editor.vala index cdf46c4e..b4a5efe4 100644 --- a/src/client/accounts/accounts-editor.vala +++ b/src/client/accounts/accounts-editor.vala @@ -63,6 +63,10 @@ public class Accounts.Editor : Gtk.Dialog { [GtkChild] private Gtk.ListBox accounts_list; + private Gee.LinkedList editor_pane_stack = + new Gee.LinkedList(); + + public Editor(GearyApplication application, Gtk.Window parent) { this.application = application; @@ -78,6 +82,8 @@ public class Accounts.Editor : Gtk.Dialog { this.accounts_list.set_header_func(seperator_headers); this.accounts_list.set_sort_func(ordinal_sort); + this.editor_pane_stack.add(list_pane); + foreach (Geary.AccountInformation account in accounts.iterable()) { add_account(account, accounts.get_status(account)); } @@ -95,18 +101,49 @@ public class Accounts.Editor : Gtk.Dialog { this.accounts.account_removed.disconnect(on_account_removed); } + internal void push(Gtk.Widget child) { + // Since keep old, already-popped panes around (see pop for + // details), when a new pane is pushed on they need to be + // truncated. + Gtk.Widget current = this.editor_panes.get_visible_child(); + int target_length = this.editor_pane_stack.index_of(current) + 1; + while (target_length < this.editor_pane_stack.size) { + Gtk.Widget old = this.editor_pane_stack.remove_at(target_length); + this.editor_panes.remove(old); + } + + // Now push the new pane on + this.editor_pane_stack.add(child); + this.editor_panes.add(child); + this.editor_panes.set_visible_child(child); + this.back_button.show(); + } + + internal void pop() { + // We can't simply remove old panes fro the GTK stack since + // there won't be any transition between them - the old one + // will simply disappear. So we need to keep old, popped panes + // around until a new one is pushed on. + // + // XXX work out a way to reuse the old ones if we go back to + // them? + Gtk.Widget current = this.editor_panes.get_visible_child(); + int next = this.editor_pane_stack.index_of(current) - 1; + + this.editor_panes.set_visible_child(this.editor_pane_stack.get(next)); + + if (next == 0) { + this.back_button.hide(); + } + } + private void add_account(Geary.AccountInformation account, AccountManager.Status status) { this.accounts_list.add(new AccountRow(account, status)); } private void show_account(Geary.AccountInformation account) { - EditorEditPane account_pane = new EditorEditPane( - (GearyApplication) this.application,account - ); - this.editor_panes.add(account_pane); - this.editor_panes.set_visible_child(account_pane); - this.back_button.show(); + push(new EditorEditPane(this, account)); } private AccountRow? get_account_row(Geary.AccountInformation account) { @@ -150,12 +187,7 @@ public class Accounts.Editor : Gtk.Dialog { [GtkCallback] private void on_back_button_clicked() { - Gtk.Widget visible_pane = this.editor_panes.get_visible_child(); - if (visible_pane != list_pane) { - this.editor_panes.remove(visible_pane); - } else { - this.back_button.hide(); - } + pop(); } } diff --git a/src/client/meson.build b/src/client/meson.build index e248cf2e..619a41de 100644 --- a/src/client/meson.build +++ b/src/client/meson.build @@ -21,6 +21,7 @@ geary_client_vala_sources = files( 'accounts/account-spinner-page.vala', 'accounts/accounts-editor.vala', 'accounts/accounts-editor-edit-pane.vala', + 'accounts/accounts-editor-remove-pane.vala', 'accounts/accounts-editor-row.vala', 'accounts/add-edit-page.vala', 'accounts/goa-service-information.vala', diff --git a/ui/accounts_editor_edit_pane.ui b/ui/accounts_editor_edit_pane.ui index 5e0ce99b..0b2e817d 100644 --- a/ui/accounts_editor_edit_pane.ui +++ b/ui/accounts_editor_edit_pane.ui @@ -132,6 +132,7 @@ True True True + True @@ -147,6 +148,7 @@ True True Remove this account from Geary + diff --git a/ui/accounts_editor_remove_pane.ui b/ui/accounts_editor_remove_pane.ui new file mode 100644 index 00000000..33ddb612 --- /dev/null +++ b/ui/accounts_editor_remove_pane.ui @@ -0,0 +1,169 @@ + + + + + + diff --git a/ui/org.gnome.Geary.gresource.xml b/ui/org.gnome.Geary.gresource.xml index 975dbde7..5173427c 100644 --- a/ui/org.gnome.Geary.gresource.xml +++ b/ui/org.gnome.Geary.gresource.xml @@ -6,6 +6,7 @@ account_spinner.glade accounts_editor.ui accounts_editor_edit_pane.ui + accounts_editor_remove_pane.ui certificate_warning_dialog.glade client-web-view.js client-web-view-allow-remote-images.js