Add calendar items to beagle-search, and correctly handle dates in the future.
[beagle.git] / search / Tiles / Contact.cs
blob294ef4c74b748308f5cb27562fb01d2b93b1b8dd
1 using System;
2 using Mono.Unix;
3 using Beagle.Util;
5 namespace 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);
38 } else
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 ();
50 uint i = 0;
52 details.AddBoldLabel (Title, i++, 1);
54 string org = Hit.GetFirstProperty ("fixme:Org");
55 string title = Hit.GetFirstProperty ("fixme:Title");
56 string email = Hit.GetFirstProperty ("fixme:Email");
57 string mobile_phone = Hit.GetFirstProperty ("fixme:MobilePhone");
58 string work_phone = Hit.GetFirstProperty ("fixme:BusinessPhone");
59 string home_phone = Hit.GetFirstProperty ("fixme:HomePhone");
61 if (org != null && org != "")
62 details.AddLabel (org, i++, 1);
63 if (title != null && title != "")
64 details.AddLabel (title, i++, 1);
66 details.AddLabel ("", i++, 1);
68 if (email != null && email != "")
69 details.AddLabelPair (Catalog.GetString ("E-Mail:"), email, i++, 1);
70 if (mobile_phone != null && mobile_phone != "")
71 details.AddLabelPair (Catalog.GetString ("Mobile Phone:"), mobile_phone, i++, 1);
72 if (work_phone != null && work_phone != "")
73 details.AddLabelPair (Catalog.GetString ("Work Phone:"), work_phone, i++, 1);
74 if (home_phone != null && home_phone != "")
75 details.AddLabelPair (Catalog.GetString ("Home Phone:"), home_phone, i++, 1);
77 return details;
80 public override void Open ()
82 SafeProcess p = new SafeProcess ();
83 p.Arguments = new string [] { "evolution", Hit.UriAsString };
85 try {
86 p.Start ();
87 } catch (SafeProcessException e) {
88 Console.WriteLine (e.Message);
92 private void SendMail ()
94 OpenFromUri ("mailto:" + Hit.GetFirstProperty ("fixme:Email"));