2006-09-10 Francisco Javier F. Serrador <serrador@openshine.com>
[beagle.git] / search / Tiles / Calendar.cs
blobf8f9316b1d3025966739eb3c672f064341c761af
1 using System;
2 using Mono.Unix;
3 using Beagle.Util;
5 namespace Search.Tiles {
7 public class CalendarActivator : TileActivator {
9 public CalendarActivator () : base ()
11 AddSupportedFlavor (new HitFlavor (null, "Calendar", null));
14 public override Tile BuildTile (Beagle.Hit hit, Beagle.Query query)
16 return new Calendar (hit, query);
20 public class Calendar : TileTemplate {
22 public Calendar (Beagle.Hit hit, Beagle.Query query) : base (hit, query)
24 Group = TileGroup.Calendar;
26 string summary = hit.GetFirstProperty ("fixme:summary");
27 string time = Utils.NiceShortDate (hit.GetFirstProperty ("fixme:starttime"));
29 Title = (time == "") ? summary : time + ": " + summary;
31 string description = hit.GetFirstProperty ("fixme:description");
33 if (description != null && description != "") {
34 int newline = description.IndexOf ('\n');
35 if (newline == -1)
36 Description = description;
37 else
38 Description = String.Format ("{0}...", description.Substring (0, newline));
42 protected override void LoadIcon (Gtk.Image image, int size)
44 image.Pixbuf = WidgetFu.LoadThemeIcon ("stock_calendar", size);
47 protected override DetailsPane GetDetails ()
49 DetailsPane details = new DetailsPane ();
51 details.AddLabelPair (Catalog.GetString ("Title:"), Title);
53 if (Description != null && Description != "")
54 details.AddLabelPair (Catalog.GetString ("Description:"), Description);
56 if (Hit.GetFirstProperty ("fixme:location") != null)
57 details.AddLabelPair (Catalog.GetString ("Location:"), Hit.GetFirstProperty ("fixme:location"));
59 string[] attendees = Hit.GetProperties ("fixme:attendee");
60 if (attendees != null && attendees.Length > 0)
61 details.AddLabelPair (Catalog.GetString ("Attendees:"), String.Join (", ", attendees));
63 details.AddFinalLine ();
65 return details;
68 public override void Open ()
70 SafeProcess p = new SafeProcess ();
71 p.Arguments = new string [] { "evolution", Hit.EscapedUri };
73 try {
74 p.Start ();
75 } catch (SafeProcessException e) {
76 Console.WriteLine (e.Message);