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');
36 Description
= description
;
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 ();
68 public override void Open ()
70 SafeProcess p
= new SafeProcess ();
71 p
.Arguments
= new string [] { "evolution", Hit.EscapedUri }
;
75 } catch (SafeProcessException e
) {
76 Console
.WriteLine (e
.Message
);