diff --git a/src/client/ui/composer-window.vala b/src/client/ui/composer-window.vala new file mode 100644 index 00000000..2295b16e --- /dev/null +++ b/src/client/ui/composer-window.vala @@ -0,0 +1,70 @@ +/* Copyright 2011 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +// Window for sending messages. +public class ComposerWindow : Gtk.Window { + + private Gtk.Entry to_entry; + private Gtk.Entry cc_entry; + private Gtk.Entry bcc_entry; + private Gtk.Entry subject_entry; + private Gtk.TextView message_text; + + public string to { + get { return to_entry.get_text(); } + set { to_entry.set_text(value); } + } + + public string cc { + get { return cc_entry.get_text(); } + set { cc_entry.set_text(value); } + } + + public string bcc { + get { return bcc_entry.get_text(); } + set { bcc_entry.set_text(value); } + } + + public string subject { + get { return subject_entry.get_text(); } + set { subject_entry.set_text(value); } + } + + public string message { + owned get { return message_text.buffer.text; } + set { message_text.buffer.text = value; } + } + + // Signal sent when the "Send" button is clicked. + public signal void send(ComposerWindow composer); + + public ComposerWindow() { + Gtk.Builder builder = YorbaApplication.instance.create_builder("composer.glade"); + + Gtk.Box box = builder.get_object("composer") as Gtk.Box; + Gtk.Button send_button = builder.get_object("Send") as Gtk.Button; + send_button.clicked.connect(on_send); + + to_entry = builder.get_object("to") as Gtk.Entry; + cc_entry = builder.get_object("cc") as Gtk.Entry; + bcc_entry = builder.get_object("bcc") as Gtk.Entry; + subject_entry = builder.get_object("subject") as Gtk.Entry; + message_text = builder.get_object("message") as Gtk.TextView; + + add(box); + } + + public override void show_all() { + set_default_size(400, 550); + + base.show_all(); + } + + private void on_send() { + send(this); + } + +} diff --git a/src/client/ui/main-window.vala b/src/client/ui/main-window.vala index 45f7b9a8..7b2d7e58 100644 --- a/src/client/ui/main-window.vala +++ b/src/client/ui/main-window.vala @@ -9,6 +9,8 @@ public class MainWindow : Gtk.Window { + + @@ -154,6 +156,11 @@ public class MainWindow : Gtk.Window { quit.label = _("_Quit"); entries += quit; + Gtk.ActionEntry new_message = { "FileNewMessage", Gtk.Stock.NEW, TRANSLATABLE, "N", null, + on_new_message }; + new_message.label = _("_New Message"); + entries += new_message; + // // Help // @@ -205,6 +212,34 @@ public class MainWindow : Gtk.Window { add(main_layout); } + private void on_new_message() { + ComposerWindow w = new ComposerWindow(); + w.send.connect(on_send); + w.show_all(); + } + + private void on_send(ComposerWindow cw) { + string username; + try { + // TODO: Multiple accounts. + username = Geary.Engine.get_usernames().get(0); + } catch (Error e) { + error("Unable to get username. Error: %s", e.message); + } + + Geary.ComposedEmail email = new Geary.ComposedEmail(new DateTime.now_local(), username); + + email.to = cw.to; + email.cc = cw.cc; + email.bcc = cw.bcc; + email.subject = cw.subject; + email.body = cw.message; + + account.send_email_async.begin(email); + + cw.destroy(); + } + private void on_quit() { GearyApplication.instance.exit(); } diff --git a/src/client/wscript_build b/src/client/wscript_build index 9c55392d..d356652a 100644 --- a/src/client/wscript_build +++ b/src/client/wscript_build @@ -8,6 +8,7 @@ client_src = [ 'geary-config.vala', 'main.vala', +'ui/composer-window.vala', 'ui/geary-login.vala', 'ui/folder-list-store.vala', 'ui/folder-list-view.vala', diff --git a/ui/composer.glade b/ui/composer.glade new file mode 100644 index 00000000..60a85aca --- /dev/null +++ b/ui/composer.glade @@ -0,0 +1,210 @@ + + + + + True + False + 6 + 6 + 6 + 6 + vertical + 6 + + + True + False + 6 + + + _Send + True + True + True + False + True + + + False + True + 0 + + + + + + + + + + + False + True + 0 + + + + + True + False + 6 + 6 + 4 + 2 + + + True + False + 1 + 6 + To: + right + + + 0 + 0 + 1 + 1 + + + + + True + False + 1 + 6 + cc: + right + + + 0 + 1 + 1 + 1 + + + + + True + True + True + + True + + + 1 + 0 + 1 + 1 + + + + + True + True + True + + True + + + 1 + 1 + 1 + 1 + + + + + True + True + True + + True + + + 1 + 3 + 1 + 1 + + + + + True + False + 1 + 6 + Subject: + right + + + 0 + 3 + 1 + 1 + + + + + True + False + 1 + 6 + bcc: + right + + + 0 + 2 + 1 + 1 + + + + + True + True + True + + True + + + 1 + 2 + 1 + 1 + + + + + False + True + 1 + + + + + True + True + 6 + never + in + + + True + True + True + True + natural + word + + + + + True + True + 2 + + + +