cvsimport
[beagle.git] / search / Tiles / Calendar.cs
blob0ba17c2222ce5fcc4dbd2e9517ad3e7ca5ae10e6
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 return details;
66 public override void Open ()
68 SafeProcess p = new SafeProcess ();
69 p.Arguments = new string [] { "evolution", Hit.EscapedUri };
71 try {
72 p.Start ();
73 } catch (SafeProcessException e) {
74 Console.WriteLine (e.Message);