2 using System
.Diagnostics
;
3 using System
.Runtime
.InteropServices
;
7 namespace Search
.Tiles
{
9 public class NoteActivator
: TileActivator
{
11 public NoteActivator () : base ()
13 AddSupportedFlavor (new HitFlavor (null, "Note", null));
16 public override Tile
BuildTile (Beagle
.Hit hit
, Beagle
.Query query
)
18 return new TileNote (hit
, query
);
22 public class TileNote
: TileTemplate
{
24 public TileNote (Beagle
.Hit hit
, Beagle
.Query query
) : base (hit
, query
)
26 Title
= Hit
.GetFirstProperty ("dc:title");
27 Description
= Utils
.NiceShortDate (Timestamp
);
30 protected override void LoadIcon (Gtk
.Image image
, int size
)
32 image
.Pixbuf
= Beagle
.Images
.GetPixbuf ("note", size
, size
);
35 public override void Open ()
37 SafeProcess p
= new SafeProcess ();
39 // This doesn't work very well if you have multiple
40 // terms that match. Tomboy doesn't seem to have a way
41 // to specify more than one thing to highlight.
42 if (Hit
.Source
== "Tomboy"){
43 p
.Arguments
= new string [] { "tomboy",
44 "--open-note", Hit
.EscapedUri
,
45 "--highlight-search", Query
.QuotedText
};
46 } else if (Hit
.Source
== "Labyrinth"){
47 p
.Arguments
= new string [] { "labyrinth",
48 "-m", Hit
.FileInfo
.Name
};
53 } catch (Exception e
) {
54 Console
.WriteLine ("Could not open note: " + e
);
58 protected override DetailsPane
GetDetails ()
60 DetailsPane details
= new DetailsPane ();
62 details
.AddLabelPair (Catalog
.GetString ("Title:"), Title
);
63 details
.AddLabelPair (Catalog
.GetString ("Last Edited:"), Utils
.NiceLongDate (Timestamp
));
64 details
.AddSnippet ();