Change the GC.GetTotalMemory() threshold to 10%; otherwise there are just too many...
[beagle.git] / search / Tiles / Contact.cs
blobafa32c3f4e3c44f6690c3aa737d7fed51fc94593
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 ();
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);
76 details.AddFinalLine ();
78 return details;
81 public static SafeProcess GetClientProcess (string client, string uri)
83 SafeProcess p = null;
85 if (client == "evolution") {
86 p = new SafeProcess ();
87 p.Arguments = new string [2];
88 p.Arguments [0] = "evolution";
89 p.Arguments [1] = uri;
90 } else if (client == "thunderbird") {
91 p = new SafeProcess ();
92 p.Arguments = new string [4];
93 p.Arguments [0] = "beagle-contactviewer";
94 p.Arguments [1] = "--manager";
95 p.Arguments [2] = "Thunderbird";
96 p.Arguments [3] = uri;
99 return p;
103 public override void Open ()
105 SafeProcess p = GetClientProcess (Hit.GetFirstProperty ("fixme:client"), Hit.EscapedUri);
107 try {
108 p.Start ();
109 } catch (SafeProcessException e) {
110 Console.WriteLine (e.Message);
114 private void SendMail ()
116 OpenFromUri ("mailto:" + Hit.GetFirstProperty ("fixme:Email"));