5
namespace Beagle.Search.Tiles {
7
public class ContactActivator : TileActivator {
9
public ContactActivator () : base ()
11
AddSupportedFlavor (new HitFlavor (null, "Contact", null));
14
public override Tile BuildTile (Beagle.Hit hit, Beagle.Query query)
16
return new Contact (hit, query);
20
public class Contact : TileTemplate {
22
public Contact (Beagle.Hit hit, Beagle.Query query) : base (hit, query)
24
Group = TileGroup.Contact;
26
Title = hit.GetFirstProperty ("fixme:Name");
27
Description = hit.GetFirstProperty ("fixme:Email");
29
if (Hit.GetFirstProperty ("fixme:Email") != null)
30
AddAction (new TileAction (Catalog.GetString ("Send Mail"), SendMail));
33
private Gdk.Pixbuf GetIcon (int size)
35
if (Hit.GetFirstProperty ("beagle:Photo") != null) {
36
Gdk.Pixbuf icon = new Gdk.Pixbuf (Hit.GetFirstProperty ("beagle:Photo"));
37
return icon.ScaleSimple (size, size, Gdk.InterpType.Bilinear);
39
return WidgetFu.LoadThemeIcon ("stock_person", size);
42
protected override void LoadIcon (Gtk.Image image, int size)
44
image.Pixbuf = GetIcon (size);
47
protected override DetailsPane GetDetails ()
49
DetailsPane details = new DetailsPane ();
51
details.AddTitleLabel (Title);
53
string org = Hit.GetFirstProperty ("fixme:Org");
54
string title = Hit.GetFirstProperty ("fixme:Title");
55
string email = Hit.GetFirstProperty ("fixme:Email");
56
string mobile_phone = Hit.GetFirstProperty ("fixme:MobilePhone");
57
string work_phone = Hit.GetFirstProperty ("fixme:BusinessPhone");
58
string home_phone = Hit.GetFirstProperty ("fixme:HomePhone");
60
if (org != null && org != "")
61
details.AddTextLabel (org);
62
if (title != null && title != "")
63
details.AddTextLabel (title);
65
details.AddNewLine ();
67
if (email != null && email != "")
68
details.AddLabelPair (Catalog.GetString ("E-Mail:"), email);
69
if (mobile_phone != null && mobile_phone != "")
70
details.AddLabelPair (Catalog.GetString ("Mobile Phone:"), mobile_phone);
71
if (work_phone != null && work_phone != "")
72
details.AddLabelPair (Catalog.GetString ("Work Phone:"), work_phone);
73
if (home_phone != null && home_phone != "")
74
details.AddLabelPair (Catalog.GetString ("Home Phone:"), home_phone);
79
public static SafeProcess GetClientProcess (string client, string uri)
83
if (client == "evolution" || (client == null && uri.StartsWith ("contacts:"))) {
84
p = new SafeProcess ();
85
p.Arguments = new string [2];
86
p.Arguments [0] = "evolution";
87
p.Arguments [1] = uri;
88
} else if (client == "thunderbird") {
89
p = new SafeProcess ();
90
p.Arguments = new string [4];
91
p.Arguments [0] = "beagle-contactviewer";
92
p.Arguments [1] = "--manager";
93
p.Arguments [2] = "Thunderbird";
94
p.Arguments [3] = uri;
101
public override void Open ()
103
SafeProcess p = GetClientProcess (Hit.GetFirstProperty ("fixme:client"), Hit.EscapedUri);
106
Console.WriteLine ("Opening contact '{0}' is unsupported!", Hit.EscapedUri);
112
} catch (SafeProcessException e) {
113
Console.WriteLine (e.Message);
117
private void SendMail ()
119
OpenFromUri ("mailto:" + Hit.GetFirstProperty ("fixme:Email"));