2 using System
.Diagnostics
;
3 using System
.Runtime
.InteropServices
;
6 namespace Search
.Tiles
{
8 public class FileActivator
: TileActivator
{
10 public FileActivator () : base ()
12 AddSupportedFlavor (new HitFlavor (null, "File", null));
15 public override Tile
BuildTile (Beagle
.Hit hit
, Beagle
.Query query
)
17 return new TileFile (hit
, query
);
21 public class TileFile
: TileTemplate
{
23 public TileFile (Beagle
.Hit hit
, Beagle
.Query query
) : base (hit
, query
)
26 EnableOpenWith
= true;
28 if (Hit
.FileInfo
!= null) {
29 Timestamp
= Hit
.FileInfo
.LastWriteTime
;
30 Description
= Utils
.NiceShortDate (Timestamp
);
33 AddAction (new TileAction (Catalog
.GetString ("Reveal in Folder"), RevealInFolder
));
34 AddAction (new TileAction (Catalog
.GetString ("E-Mail"), Email
));
35 // AddAction (new TileAction (Catalog.GetString ("Instant-Message"), InstantMessage));
36 AddAction (new TileAction (Catalog
.GetString ("Move to Trash"), Gtk
.Stock
.Delete
, MoveToTrash
));
39 static ThumbnailFactory thumbnailer
= new ThumbnailFactory ();
41 protected override void LoadIcon (Gtk
.Image image
, int size
)
43 if (!thumbnailer
.SetThumbnailIcon (image
, Hit
, size
))
44 base.LoadIcon (image
, size
);
47 private string GetTitle ()
49 string title
= Hit
.GetFirstProperty ("dc:title");
51 if (title
== null || title
== "")
52 title
= Hit
.GetFirstProperty ("beagle:ExactFilename");
57 public override void Open ()
59 base.OpenFromMime (Hit
);
62 public void OpenWith ()
64 // FIXME: base.OpenWith
67 public void RevealInFolder ()
69 string path
= Hit
.FileInfo
.DirectoryName
;
71 Process p
= new Process ();
72 p
.StartInfo
.UseShellExecute
= false;
74 if ((! path
.StartsWith ("\"")) && (! path
.EndsWith ("\"")))
75 path
= "\"" + path
+ "\"";
77 // FIXME: When nautilus implements this, then we should
78 // also select the file in the folder.
80 #if ENABLE_DESKTOP_LAUNCH
81 p
.StartInfo
.FileName
= "desktop-launch";
82 p
.StartInfo
.Arguments
= path
;
84 p
.StartInfo
.FileName
= "nautilus";
85 p
.StartInfo
.Arguments
= "--no-desktop " + path
;
89 } catch (Exception e
) {
90 Console
.WriteLine ("Cannot open folder: " + e
);
96 Process p
= new Process ();
97 p
.StartInfo
.UseShellExecute
= false;
98 p
.StartInfo
.FileName
= "evolution";
99 p
.StartInfo
.Arguments
= String
.Format ("\"mailto:?attach={0}\"", Hit
.FileInfo
.FullName
);
103 } catch (Exception e
) {
104 Console
.WriteLine ("Error launching Evolution composer: " + e
);
108 public void InstantMessage ()
110 // FIXME: base.InstantMessage
113 public void MoveToTrash ()
115 // FIXME: Ask for confirmation
118 // FIXME: Check if KDE uses ~/.Trash too (there is a spec at fd.o)
119 string trash_dir
= System
.IO
.Path
.Combine (Beagle
.Util
.PathFinder
.HomeDir
, ".Trash");
121 // FIXME: This throws an exception if the file exists
122 Hit
.FileInfo
.MoveTo (System
.IO
.Path
.Combine (trash_dir
, Hit
.FileInfo
.Name
));
123 } catch (Exception e
) {
124 Console
.WriteLine (e
);
128 protected override DetailsPane
GetDetails ()
130 DetailsPane details
= new DetailsPane ();
132 details
.AddLabelPair (Catalog
.GetString ("Title:"),
135 details
.AddLabelPair (Catalog
.GetString ("Last Edited:"),
136 Utils
.NiceLongDate (Timestamp
),
138 if (Hit
["dc:author"] != null) {
139 details
.AddLabelPair (Catalog
.GetString ("Author:"),
143 details
.AddLabelPair (Catalog
.GetString ("Full Path:"),
146 details
.AddSnippet (3, 1);