Updating branch refs/heads/master to 05a94279f92794b2ee843f31ef77ac5121e9e437 (commit) from 8eed4867ba0b87fdd0586ca31d745bd388e80045 (commit)
commit 05a94279f92794b2ee843f31ef77ac5121e9e437 Author: Christian Dywan <christ...@twotoasts.de> Date: Sat Jul 17 16:34:52 2010 +0200 Introduce AcountSetup class and add a 'New Account' button postler/postler-accountsetup.vala | 78 +++++++++++++++++++++++++++++++++++++ postler/postler-app.vala | 2 + postler/postler-bureau.vala | 17 ++++++++- 3 files changed, 96 insertions(+), 1 deletions(-) diff --git a/postler/postler-accountsetup.vala b/postler/postler-accountsetup.vala new file mode 100644 index 0000000..9f00e76 --- /dev/null +++ b/postler/postler-accountsetup.vala @@ -0,0 +1,78 @@ +/* + Copyright (C) 2010 Christian Dywan <christ...@twotoasts.de> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + See the file COPYING for the full license text. +*/ + +public class Postler.AccountSetup : Gtk.Dialog { + Gtk.SizeGroup sizegroup; + Gtk.Box content_area; + + Gtk.Entry realname; + Gtk.Entry address; + Gtk.Entry password; + + AccountInfo info; + + public signal void done (AccountInfo info); + + private AccountSetup (AccountInfo info) { + this.info = info; + + sizegroup = new Gtk.SizeGroup (Gtk.SizeGroupMode.HORIZONTAL); + content_area = get_content_area () as Gtk.Box; + + realname = new Gtk.Entry (); + add_label_entry (_("Full Name"), realname); + address = new Gtk.Entry (); + add_label_entry (_("Electronic Mail Address"), address); + password = new Gtk.Entry (); + password.visibility = false; + add_label_entry (_("Password"), password); + content_area.show_all (); + + add_buttons (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, + _("_Create Account"), Gtk.ResponseType.APPLY); + set_default_response (Gtk.ResponseType.APPLY); + + response.connect (responded); + } + + void add_label_entry (string text, Gtk.Entry entry) { + var hbox = new Gtk.HBox (false, 0); + content_area.pack_start (hbox, false, false, 4); + var label = new Gtk.Label.with_mnemonic (text); + label.xalign = 0; + sizegroup.add_widget (label); + hbox.pack_start (label, false, false, 4); + entry.activate.connect ((entry) => { + responded (Gtk.ResponseType.APPLY); }); + hbox.pack_start (entry, false, false, 4); + } + + void responded (int response) { + if (response == Gtk.ResponseType.APPLY) { + info.name = address.text; + info.realname = realname.text; + info.address = address.text; + info.password = password.text; + done (info); + } + destroy (); + } + + public static AccountSetup new_account () { + var info = new AccountInfo (); + info.type = AccountType.IMAP; + + var setup = new AccountSetup (info); + setup.show (); + return setup; + } +} + diff --git a/postler/postler-app.vala b/postler/postler-app.vala index b120249..1576aff 100644 --- a/postler/postler-app.vala +++ b/postler/postler-app.vala @@ -10,6 +10,7 @@ */ namespace Postler { + const string STOCK_ACCOUNT_NEW = "contact-new"; const string STOCK_ADDRESSBOOK = "stock_addressbook"; const string STOCK_ARCHIVE = "gnome-mime-application-x-archive"; const string STOCK_EMBLEM_DRAFT = "emblem-draft"; @@ -46,6 +47,7 @@ public class Postler.App : Unique.App { } const Gtk.StockItem[] stock_items = { + { STOCK_ACCOUNT_NEW, N_("New _Account"), 0, 0, "list-add" }, { STOCK_ADDRESSBOOK, N_("_Addressbook") }, { STOCK_ARCHIVE, N_("Archi_ve") }, { STOCK_EMBLEM_DRAFT }, diff --git a/postler/postler-bureau.vala b/postler/postler-bureau.vala index cdb982c..a63a4f6 100644 --- a/postler/postler-bureau.vala +++ b/postler/postler-bureau.vala @@ -275,6 +275,13 @@ public class Postler.Bureau : Gtk.Window { Postler.App.spawn_module ("source", content.last_location); } + void action_account_new () { + AccountSetup.new_account ().done.connect ((setup, info) => { + accounts.add_info (info); + folders.populate (); + } ); + } + void action_preferences () { /* TODO */ } @@ -332,6 +339,8 @@ public class Postler.Bureau : Gtk.Window { N_("View the message in fullscreen"), action_fullscreen }, { "ViewSource", null, N_("View _Source"), "<Ctrl><Alt>u", N_("View the source of the message"), action_view_source }, + { "AccountNew", STOCK_ACCOUNT_NEW, null, "", + N_("Setup a new account"), action_account_new }, { "Preferences", Gtk.STOCK_PREFERENCES, null, "<Ctrl><Alt>p", N_("Configure the application preferences"), action_preferences }, { "Help", null, N_("_Help") }, @@ -479,10 +488,16 @@ public class Postler.Bureau : Gtk.Window { actions.get_action ("ViewSource").sensitive = state; }); - vpaned.pack2 (new Postler.Viewer (content), false, true); + var viewer = new Postler.Viewer (content); + vpaned.pack2 (viewer, false, true); shelf.show_all (); search_options.hide (); + var button = new Gtk.Button.from_stock (STOCK_ACCOUNT_NEW); + button.clicked.connect ((button) => { action_account_new (); } ); + viewer.dashboard.pack_start (button, false, false, 0); + viewer.dashboard.show_all (); + folders.set_headers_visible (false); messages.set_headers_visible (false); vpaned.set_position ((int)(monitor.height / 1.7 / 3)); _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org http://foo-projects.org/mailman/listinfo/xfce4-commits