2 using System
.Diagnostics
;
3 using System
.Collections
;
6 namespace Search
.Tiles
{
8 public class IMLogActivator
: TileActivator
{
10 public IMLogActivator () : base ()
12 AddSupportedFlavor (new HitFlavor (null, "IMLog", null));
15 public override Tile
BuildTile (Beagle
.Hit hit
, Beagle
.Query query
)
17 return new IMLog (hit
, query
);
21 public class IMLog
: TileFlat
{
23 private static Hashtable all_icons
= new Hashtable ();
25 public IMLog (Beagle
.Hit hit
, Beagle
.Query query
) : base (hit
, query
)
27 Group
= TileGroup
.Conversations
;
29 subject
.LabelProp
= Catalog
.GetString ("IM Conversation");
30 from.LabelProp
= "<b>" + hit
.GetFirstProperty ("fixme:speakingto") + "</b>";
33 Timestamp
= Utils
.ParseTimestamp (hit
.GetFirstProperty ("fixme:starttime"));
34 date
.LabelProp
= Utils
.NiceShortDate (Timestamp
);
38 private Hashtable
IconsForSize (int size
)
40 Hashtable icons
= new Hashtable ();
42 icons
["aim"] = WidgetFu
.LoadThemeIcon ("im-aim", size
);
43 icons
["icq"] = WidgetFu
.LoadThemeIcon ("im-icq", size
);
44 icons
["jabber"] = WidgetFu
.LoadThemeIcon ("im-jabber", size
);
45 icons
["msn"] = WidgetFu
.LoadThemeIcon ("im-msn", size
);
46 icons
["novell"] = WidgetFu
.LoadThemeIcon ("im-nov", size
);
47 icons
["yahoo"] = WidgetFu
.LoadThemeIcon ("im-yahoo", size
);
52 protected override void LoadIcon (Gtk
.Image image
, int size
)
55 // FIXME: We do not respect the icon size request
56 Gdk
.Pixbuf icon
= LoadBuddyIcon ();
64 Hashtable icons
= (Hashtable
)all_icons
[size
];
66 all_icons
[size
] = icons
= IconsForSize (size
);
68 string protocol
= Hit
.GetFirstProperty ("fixme:protocol");
69 if (icons
[protocol
] != null)
70 image
.Pixbuf
= (Gdk
.Pixbuf
)icons
[protocol
];
72 image
.Pixbuf
= WidgetFu
.LoadThemeIcon ("im", size
);
75 private Gdk
.Pixbuf
LoadBuddyIcon ()
77 Gdk
.Pixbuf icon
= null;
79 if (Hit
["fixme:speakingto_icon"] != null && System
.IO
.File
.Exists (Hit
["fixme:speakingto_icon"]))
80 icon
= new Gdk
.Pixbuf (Hit
["fixme:speakingto_icon"]);
85 protected override DetailsPane
GetDetails ()
87 DetailsPane details
= new DetailsPane ();
89 details
.AddLabelPair (Catalog
.GetString ("Name:"), FromLabel
.Text
, 0, 1);
90 details
.AddLabelPair (Catalog
.GetString ("Date Received:"), DateLabel
.Text
, 1, 1);
92 GotSnippet
+= SetSubject
;
93 details
.AddSnippet (2, 1);
98 private void SetSubject (string snippet
)
100 subject
.Markup
= snippet
;
103 public override void Open ()
105 Process p
= new Process ();
106 p
.StartInfo
.UseShellExecute
= true;
107 p
.StartInfo
.FileName
= "beagle-imlogviewer";
108 p
.StartInfo
.Arguments
= String
.Format ("--client \"{0}\" --highlight-search \"{1}\" {2}",
109 Hit
["fixme:client"], Query
.QuotedText
, Hit
.Uri
.LocalPath
);
113 } catch (Exception e
) {
114 Console
.WriteLine ("Unable to run {0}: {1}", p
.StartInfo
.FileName
, e
.Message
);