2006-04-25 Hendrik Brandt <heb@gnome-de.org>
[beagle.git] / search / Tiles / Note.cs
blobe112624c6e85849fca8823c9c91aa05d2737d75a
1 using System;
2 using System.Diagnostics;
3 using System.Runtime.InteropServices;
4 using Mono.Unix;
5 using Beagle.Util;
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");
29 protected override void LoadIcon (Gtk.Image image, int size)
31 image.Pixbuf = Beagle.Images.GetPixbuf ("note", size, size);
34 public override void Open ()
36 SafeProcess p = new SafeProcess ();
38 // This doesn't work very well if you have multiple
39 // terms that match. Tomboy doesn't seem to have a way
40 // to specify more than one thing to highlight.
41 p.Arguments = new string [] { "tomboy",
42 "--open-note", Hit.UriAsString,
43 "--highlight-search", Query.QuotedText };
45 try {
46 p.Start ();
47 } catch (Exception e) {
48 Console.WriteLine ("Could not invoke Tomboy to open note: " + e);
52 protected override DetailsPane GetDetails ()
54 DetailsPane details = new DetailsPane ();
56 details.AddLabelPair (Catalog.GetString ("Title:"),
57 Title,
58 0, 1);
59 details.AddLabelPair (Catalog.GetString ("Last Edited:"),
60 Utils.NiceLongDate (Timestamp),
61 1, 1);
63 details.AddSnippet (2, 1);
65 return details;