[Xfce4-commits] <postler:master> Complete addresses in composer with Dexter
Christian Dywan
noreply at xfce.org
Tue Dec 7 19:48:02 CET 2010
Updating branch refs/heads/master
to 7be548d6016cba01b76b31a024f2806914675e5f (commit)
from e4079520f55034d50e3dce4c764af71ea5522171 (commit)
commit 7be548d6016cba01b76b31a024f2806914675e5f
Author: Christian Dywan <christian at twotoasts.de>
Date: Tue Dec 7 19:47:51 2010 +0100
Complete addresses in composer with Dexter
Fixes: https://bugs.launchpad.net/dexter-rolodex/+bug/686104
postler/dexter.vala | 8 ++++++++
postler/postler-composer.vala | 33 +++++++++++++++++++++++++++++++--
2 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/postler/dexter.vala b/postler/dexter.vala
index 7f9ec4a..515d9d0 100644
--- a/postler/dexter.vala
+++ b/postler/dexter.vala
@@ -14,6 +14,7 @@ namespace Dexter {
[DBus (name = "org.elementary.dexterservice")]
interface DexterService : Object {
public abstract string get_name (string email_address) throws IOError;
+ public abstract string[] search_contacts (string keywords) throws IOError;
public abstract void show_window () throws IOError;
}
@@ -34,6 +35,13 @@ namespace Dexter {
return null;
}
}
+ public string[] search_contacts (string keywords) {
+ try {
+ return service.search_contacts (keywords);
+ } catch (GLib.Error error) {
+ return {};
+ }
+ }
public void show_window () {
try {
service.show_window ();
diff --git a/postler/postler-composer.vala b/postler/postler-composer.vala
index df322be..63c9225 100644
--- a/postler/postler-composer.vala
+++ b/postler/postler-composer.vala
@@ -333,6 +333,35 @@ public class Postler.Composer : Gtk.Window {
N_("Insert a sad face"), action_insert_emoticon }
};
+ Gtk.Entry entry_with_address_completion () {
+ var entry = new Gtk.Entry ();
+ var completion = new Gtk.EntryCompletion ();
+ completion.model = new Gtk.ListStore (1, typeof (string));
+ completion.text_column = 0;
+ completion.inline_completion = true;
+ completion.inline_selection = true;
+ entry.set_completion (completion);
+ entry.changed.connect ((editable) => {
+ long input_length = entry.text.len;
+ if (input_length < 3)
+ return;
+ var model = entry.get_completion ().model as Gtk.ListStore;
+ long model_length = model.iter_n_children (null);
+ if (model_length > 0 && input_length < 4)
+ model.clear ();
+ if (model_length > 0 || input_length > 3)
+ return;
+ model.clear ();
+ string[] contacts = dexter.search_contacts (entry.text);
+ foreach (string contact in contacts) {
+ Gtk.TreeIter iter;
+ model.append (out iter);
+ model.set (iter, 0, contact);
+ }
+ });
+ return entry;
+ }
+
public Composer () {
GLib.Object (icon_name: STOCK_MAIL_MESSAGE_NEW,
title: _("Compose message"));
@@ -380,7 +409,7 @@ public class Postler.Composer : Gtk.Window {
label.xalign = 1.0f;
box.pack_start (label, false, false, 4);
sizegroup.add_widget (label);
- entry_to = new Gtk.Entry ();
+ entry_to = entry_with_address_completion ();
box.pack_start (entry_to, true, true, 4);
box = new Gtk.HBox (false, 0);
shelf.pack_start (box, false, false, 4);
@@ -388,7 +417,7 @@ public class Postler.Composer : Gtk.Window {
label.xalign = 1.0f;
box.pack_start (label, false, false, 4);
sizegroup.add_widget (label);
- entry_copy = new Gtk.Entry ();
+ entry_copy = entry_with_address_completion ();
box.pack_start (entry_copy, true, true, 4);
box = new Gtk.HBox (false, 0);
shelf.pack_start (box, false, false, 4);
More information about the Xfce4-commits
mailing list