[Xfce4-commits] <postler:master> Move account removal into account setup

Christian Dywan noreply at xfce.org
Thu Dec 30 06:00:03 CET 2010


Updating branch refs/heads/master
         to d6d468f583b2acd06b055e91f0183720ee2b7ff1 (commit)
       from c9fd438a3638ae951bc654c5d93da4bbcb0a31a9 (commit)

commit d6d468f583b2acd06b055e91f0183720ee2b7ff1
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sun Dec 26 21:49:28 2010 +0100

    Move account removal into account setup

 postler/postler-accountsetup.vala |   31 ++++++++++++++++++++++++++++---
 postler/postler-folders.vala      |   28 ++++------------------------
 2 files changed, 32 insertions(+), 27 deletions(-)

diff --git a/postler/postler-accountsetup.vala b/postler/postler-accountsetup.vala
index 4ecc048..6868f91 100644
--- a/postler/postler-accountsetup.vala
+++ b/postler/postler-accountsetup.vala
@@ -112,7 +112,7 @@ public class Postler.AccountWidget : Gtk.VBox {
 public class Postler.AccountSetup : Gtk.Dialog {
     AccountWidget widget;
 
-    public signal void done (AccountInfo info);
+    public signal void done (AccountInfo? info);
 
     private AccountSetup (AccountInfo? info=null) {
         widget = new AccountWidget (info);
@@ -123,7 +123,6 @@ public class Postler.AccountSetup : Gtk.Dialog {
         });
         (get_content_area () as Gtk.Box).pack_start (widget, true, true, 0);
         widget.show ();
-        add_button (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL);
         response.connect (responded);
     }
 
@@ -135,6 +134,7 @@ public class Postler.AccountSetup : Gtk.Dialog {
 
     public static AccountSetup new_account () {
         var setup = new AccountSetup ();
+        setup.add_button (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL);
         setup.add_button (_("_Create Account"), Gtk.ResponseType.APPLY);
         setup.set_default_response (Gtk.ResponseType.APPLY);
         setup.set_response_sensitive (Gtk.ResponseType.APPLY, false);
@@ -148,7 +148,32 @@ public class Postler.AccountSetup : Gtk.Dialog {
 
     public static AccountSetup edit_account (AccountInfo info) {
         var setup = new AccountSetup (info);
-        setup.add_button (_("_Save Account"), Gtk.ResponseType.APPLY);
+        var remove = new Gtk.Button.with_mnemonic (_("Remove account"));
+        remove.set_image (new Gtk.Image.from_stock (Gtk.STOCK_DELETE,
+                                                    Gtk.IconSize.BUTTON));
+        remove.relief = Gtk.ReliefStyle.NONE;
+        remove.show ();
+        remove.image.show ();
+        (setup.action_area as Gtk.Box).pack_start (remove, false, false, 0);
+        remove.clicked.connect ((button) => {
+            var toplevel = setup.get_toplevel () as Gtk.Window;
+            var dialog = new Gtk.MessageDialog (toplevel, 0,
+                Gtk.MessageType.WARNING, Gtk.ButtonsType.NONE,
+                _("You are about to remove the account \"%s\"."), info.name);
+                dialog.add_buttons (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
+                    _("_Remove Account"), Gtk.ResponseType.OK);
+                dialog.set_default_response (Gtk.ResponseType.CANCEL);
+                int response = dialog.run ();
+                dialog.destroy ();
+                if (response == Gtk.ResponseType.OK) {
+                    setup.hide ();
+                    setup.done (null);
+                    setup.destroy ();
+                }
+        });
+        var apply = setup.add_button (_("_Update Account"), Gtk.ResponseType.APPLY);
+        (setup.action_area as Gtk.Box).set_child_packing (apply,
+            true, true, 0, Gtk.PackType.END);
         setup.set_default_response (Gtk.ResponseType.APPLY);
         setup.widget.address.changed.connect ((editable) => {
              setup.set_response_sensitive (Gtk.ResponseType.APPLY,
diff --git a/postler/postler-folders.vala b/postler/postler-folders.vala
index 9089295..e300264 100644
--- a/postler/postler-folders.vala
+++ b/postler/postler-folders.vala
@@ -527,29 +527,6 @@ public class Postler.Folders : Gtk.TreeView {
         else if (!is_local) {
             menu.append (new Gtk.SeparatorMenuItem ());
 
-            menuitem = new Gtk.MenuItem.with_mnemonic (_("_Remove Account"));
-            menuitem.activate.connect ((menuitem) => {
-                Gtk.TreeIter iter;
-                if (get_selection ().get_selected (null, out iter)) {
-                    AccountInfo? account_info;
-                    store.get (iter, Columns.INFO, out account_info);
-                    var toplevel = get_toplevel () as Gtk.Window;
-                    var dialog = new Gtk.MessageDialog (toplevel, 0,
-                        Gtk.MessageType.WARNING, Gtk.ButtonsType.NONE,
-                        _("You are about to remove the account \"%s\"."),
-                        account_info.name);
-                    dialog.add_buttons (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
-                        _("_Remove Account"), Gtk.ResponseType.OK);
-                    dialog.set_default_response (Gtk.ResponseType.CANCEL);
-                    int response = dialog.run ();
-                    dialog.destroy ();
-                    if (response == Gtk.ResponseType.OK) {
-                        accounts.remove_info (account_info);
-                        populate ();
-                    }
-                }
-            });
-            menu.append (menuitem);
             menuitem = new Gtk.MenuItem.with_mnemonic (_("Account _Properties"));
             menuitem.activate.connect ((menuitem) => {
                 Gtk.TreeIter iter;
@@ -558,7 +535,10 @@ public class Postler.Folders : Gtk.TreeView {
                      store.get (iter, Columns.INFO, out account_info);
                      AccountSetup.edit_account (account_info).done.connect (
                          (setup, info) => {
-                         accounts.update ();
+                         if (info == null)
+                             accounts.remove_info (account_info);
+                         else
+                             accounts.update ();
                          populate ();
                      } );
                  }



More information about the Xfce4-commits mailing list