Composer window. Closes #3711

This commit is contained in:
Eric Gregory 2011-10-03 12:05:25 -07:00
parent 10d714d756
commit e6e1ca8357
4 changed files with 316 additions and 0 deletions

View file

@ -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);
}
}

View file

@ -9,6 +9,8 @@ public class MainWindow : Gtk.Window {
<ui>
<menubar name="MenuBar">
<menu name="FileMenu" action="FileMenu">
<menuitem name="NewMessage" action="FileNewMessage" />
<separator />
<menuitem name="Quit" action="FileQuit" />
</menu>
@ -154,6 +156,11 @@ public class MainWindow : Gtk.Window {
quit.label = _("_Quit");
entries += quit;
Gtk.ActionEntry new_message = { "FileNewMessage", Gtk.Stock.NEW, TRANSLATABLE, "<Ctrl>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();
}

View file

@ -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',

210
ui/composer.glade Normal file
View file

@ -0,0 +1,210 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkBox" id="composer">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">6</property>
<property name="margin_right">6</property>
<property name="margin_top">6</property>
<property name="margin_bottom">6</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkBox" id="box2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_bottom">6</property>
<child>
<object class="GtkButton" id="Send">
<property name="label" translatable="yes">_Send</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkGrid" id="grid1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="row_spacing">6</property>
<property name="column_spacing">6</property>
<property name="n_rows">4</property>
<property name="n_columns">2</property>
<child>
<object class="GtkLabel" id="to label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="xpad">6</property>
<property name="label" translatable="yes" comments="Address(es) e-mail is to be sent to">To:</property>
<property name="justify">right</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="cc label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="xpad">6</property>
<property name="label" translatable="yes">cc:</property>
<property name="justify">right</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="to">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="invisible_char">•</property>
<property name="invisible_char_set">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="cc">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="invisible_char">•</property>
<property name="invisible_char_set">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="subject">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="invisible_char">•</property>
<property name="invisible_char_set">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="subject label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="xpad">6</property>
<property name="label" translatable="yes">Subject:</property>
<property name="justify">right</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="bcc label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="xpad">6</property>
<property name="label" translatable="yes">bcc:</property>
<property name="justify">right</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="bcc">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="invisible_char">•</property>
<property name="invisible_char_set">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_top">6</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTextView" id="message">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="vscroll_policy">natural</property>
<property name="wrap_mode">word</property>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</interface>