[Xfce4-commits] <postler:master> Insert fields from the command line into entries
Christian Dywan
noreply at xfce.org
Mon May 31 00:26:04 CEST 2010
Updating branch refs/heads/master
to 31b22e071e18d11f05070463ef78b14bd509fec8 (commit)
from 55e546b6ff4f05d5048b8f6980985aaf52a0f0c7 (commit)
commit 31b22e071e18d11f05070463ef78b14bd509fec8
Author: Christian Dywan <christian at twotoasts.de>
Date: Sun May 30 23:32:08 2010 +0200
Insert fields from the command line into entries
postler/postler-composer.vala | 32 ++++++++++++++++++++++++++++----
postler/postler-reader.vala | 13 ++++++++++++-
2 files changed, 40 insertions(+), 5 deletions(-)
diff --git a/postler/postler-composer.vala b/postler/postler-composer.vala
index 8f32b75..cd5dfd5 100644
--- a/postler/postler-composer.vala
+++ b/postler/postler-composer.vala
@@ -19,6 +19,11 @@ public class Postler.Composer : Gtk.Window {
Gtk.Toolbar toolbar;
Postler.Content content;
+ Gtk.Entry entry_from;
+ Gtk.Entry entry_to;
+ Gtk.Entry entry_copy;
+ Gtk.Entry entry_subject;
+
const string ui_markup = """
<ui>
<menubar>
@@ -129,28 +134,28 @@ public class Postler.Composer : Gtk.Window {
var label = new Gtk.Label.with_mnemonic (_("_From:"));
box.pack_start (label, false, false, 4);
sizegroup.add_widget (label);
- var entry_from = new Gtk.Entry ();
+ entry_from = new Gtk.Entry ();
box.pack_start (entry_from, true, true, 4);
box = new Gtk.HBox (false, 0);
shelf.pack_start (box, false, false, 4);
label = new Gtk.Label.with_mnemonic (_("_To:"));
box.pack_start (label, false, false, 4);
sizegroup.add_widget (label);
- var entry_to = new Gtk.Entry ();
+ entry_to = new Gtk.Entry ();
box.pack_start (entry_to, true, true, 4);
box = new Gtk.HBox (false, 0);
shelf.pack_start (box, false, false, 4);
label = new Gtk.Label.with_mnemonic (_("_Copy:"));
box.pack_start (label, false, false, 4);
sizegroup.add_widget (label);
- var entry_copy = new Gtk.Entry ();
+ entry_copy = new Gtk.Entry ();
box.pack_start (entry_copy, true, true, 4);
box = new Gtk.HBox (false, 0);
shelf.pack_start (box, false, false, 4);
label = new Gtk.Label.with_mnemonic (_("_Subject:"));
box.pack_start (label, false, false, 4);
sizegroup.add_widget (label);
- var entry_subject = new Gtk.Entry ();
+ entry_subject = new Gtk.Entry ();
box.pack_start (entry_subject, true, true, 4);
content = new Postler.Content ();
var scrolled = new Postler.ScrolledWindow (content);
@@ -177,6 +182,25 @@ public class Postler.Composer : Gtk.Window {
content.load_string (body,
"text/plain", "UTF-8", "about:blank");
}
+
+ public bool add_field (string field, string data) {
+ string name = field.down ();
+ Gtk.Entry entry = null;
+ if (name == "from")
+ entry = entry_from;
+ else if (name == "to")
+ entry = entry_to;
+ else if (name == "cc")
+ entry = entry_copy;
+ else if (name == "subject")
+ entry = entry_subject;
+ else
+ return false;
+
+ string current = entry.get_text ();
+ entry.set_text (current != "" ? current + "," + data : data);
+ return true;
+ }
}
diff --git a/postler/postler-reader.vala b/postler/postler-reader.vala
index 7b1b9c8..5ff816e 100644
--- a/postler/postler-reader.vala
+++ b/postler/postler-reader.vala
@@ -81,7 +81,18 @@ public class Postler.Reader {
instance = new Postler.Composer ();
if (filenames != null && filenames[0] != null) {
Postler.Composer composer = (Postler.Composer)instance;
- /* FIXME: add addresses or files */
+ string[] fields = filenames[0].split_set ("?&");
+ foreach (var field in fields) {
+ string[] pieces = field.split ("=");
+ bool success;
+ if (pieces[1] != null)
+ success = composer.add_field (pieces[0], pieces[1]);
+ else
+ success = composer.add_field ("to", field);
+ if (!success)
+ GLib.warning (_("Invalid field \"%s\" was ignored."),
+ pieces[1] != null ? pieces[0] : field);
+ }
}
instance.destroy.connect (Gtk.main_quit);
instance.show ();
More information about the Xfce4-commits
mailing list