[geary/wip/714104-refine-account-dialog: 139/180] Add initial replacement account removal pane.



commit 284073507240ad5c5347039d6365ae63b7b18836
Author: Michael James Gratton <mike vee net>
Date:   Sun Jun 3 20:47:45 2018 +1000

    Add initial replacement account removal pane.

 po/POTFILES.in                                     |   2 +
 src/client/accounts/accounts-editor-edit-pane.vala |  18 ++-
 .../accounts/accounts-editor-remove-pane.vala      |  53 +++++++
 src/client/accounts/accounts-editor.vala           |  56 +++++--
 src/client/meson.build                             |   1 +
 ui/accounts_editor_edit_pane.ui                    |   2 +
 ui/accounts_editor_remove_pane.ui                  | 169 +++++++++++++++++++++
 ui/org.gnome.Geary.gresource.xml                   |   1 +
 8 files changed, 288 insertions(+), 14 deletions(-)
---
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 <mike vee net>
+ *
+ * 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<Gtk.Widget> editor_pane_stack =
+        new Gee.LinkedList<Gtk.Widget>();
+
+
 
     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 @@
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">True</property>
+                        <signal name="clicked" handler="on_server_settings_clicked" swapped="no"/>
                       </object>
                       <packing>
                         <property name="expand">True</property>
@@ -147,6 +148,7 @@
                         <property name="can_focus">True</property>
                         <property name="receives_default">True</property>
                         <property name="tooltip_text" translatable="yes">Remove this account from 
Geary</property>
+                        <signal name="clicked" handler="on_remove_account_clicked" swapped="no"/>
                         <style>
                           <class name="destructive-action"/>
                         </style>
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.0 -->
+<interface>
+  <requires lib="gtk+" version="3.20"/>
+  <template class="AccountsEditorRemovePane" parent="GtkGrid">
+    <property name="name">1</property>
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="valign">center</property>
+    <child>
+      <object class="GtkGrid">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="valign">start</property>
+        <property name="vexpand">True</property>
+        <property name="row_spacing">32</property>
+        <child>
+          <object class="GtkStack" id="confirm_stack">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkGrid">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="row_spacing">6</property>
+                <property name="column_spacing">18</property>
+                <child>
+                  <object class="GtkImage">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="icon_name">dialog-warning-symbolic</property>
+                    <property name="icon_size">6</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">0</property>
+                    <property name="height">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="warning_label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="halign">start</property>
+                    <property name="vexpand">True</property>
+                    <property name="label" translatable="yes" comments="This title is shown to users when 
confirming if they want to remove an account. The string substitution is replaced with the account's 
name.">Confirm removing: %s</property>
+                    <attributes>
+                      <attribute name="weight" value="bold"/>
+                    </attributes>
+                    <style>
+                      <class name="title"/>
+                    </style>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="halign">start</property>
+                    <property name="label" translatable="yes">Removing an account will delete it permanently 
from your computer. This cannot be un-done.</property>
+                    <property name="wrap">True</property>
+                    <property name="xalign">0</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="name">confirm</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkGrid">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="row_spacing">6</property>
+                <property name="column_spacing">18</property>
+                <child>
+                  <object class="GtkSpinner" id="remove_spinner">
+                    <property name="width_request">16</property>
+                    <property name="height_request">16</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="halign">center</property>
+                    <property name="valign">center</property>
+                    <property name="margin_left">16</property>
+                    <property name="margin_right">16</property>
+                    <property name="active">True</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="remove_label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="halign">start</property>
+                    <property name="hexpand">True</property>
+                    <property name="vexpand">True</property>
+                    <property name="label" translatable="yes" comments="This title is shown to users when 
actually deleting an account. The string substitution is replaced with the account's name.">Please wait, 
removing account %s…</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">0</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="name">remove</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkButtonBox">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="remove_button">
+                <property name="label" translatable="yes" comments="This is the remove account button in the 
account settings.">Remove Permanently</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="tooltip_text" translatable="yes">Remove this account from Geary</property>
+                <signal name="clicked" handler="on_remove_button_clicked" swapped="no"/>
+                <style>
+                  <class name="destructive-action"/>
+                </style>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <style>
+              <class name="geary-settings"/>
+            </style>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">1</property>
+          </packing>
+        </child>
+        <style>
+          <class name="geary-account-view"/>
+        </style>
+      </object>
+      <packing>
+        <property name="left_attach">0</property>
+        <property name="top_attach">0</property>
+      </packing>
+    </child>
+  </template>
+</interface>
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 @@
     <file compressed="true" preprocess="xml-stripblanks">account_spinner.glade</file>
     <file compressed="true" preprocess="xml-stripblanks">accounts_editor.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">accounts_editor_edit_pane.ui</file>
+    <file compressed="true" preprocess="xml-stripblanks">accounts_editor_remove_pane.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">certificate_warning_dialog.glade</file>
     <file compressed="true">client-web-view.js</file>
     <file compressed="true">client-web-view-allow-remote-images.js</file>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]