[PATCH] ImLogViewer done
- From: Lukas Lipka <lukas pmad net>
- To: dashboard-hackers lists gnome org
- Cc:
- Subject: [PATCH] ImLogViewer done
- Date: Thu, 23 Sep 2004 14:08:43 +0200
Hello duders,
I was at home today so I decided to whip up a new version of my old Im
log viewer. This is a quite basic version althought it works already.
The presence notificator will get fixed after Chris does the Galago#
bindings. We will also hopefully be able to pull the persons photo from
e-d-s as soon as I get it all running. And the UI could use some love,
Im not really skilled with packing.
I would also like to clean up Util/ImLog.c sometimes because its quite a
mess (the same goes for this code aswell =).
Best,
Lukas
--- Tiles/TileImLog.cs.~1.6.~ 2004-09-15 17:02:46.000000000 +0200
+++ Tiles/TileImLog.cs 2004-09-23 11:43:58.632842112 +0200
@@ -40,6 +40,11 @@
hit = _hit;
}
+ private void ShowLog ()
+ {
+ new BU.ImLogViewer (hit ["fixme:file"]);
+ }
+
private string niceTime (string str)
{
DateTime dt = BU.StringFu.StringToDateTime (str);
@@ -57,5 +62,15 @@
return hit [key];
}
+
+ override protected bool RenderKey (string key, TileRenderContext ctx)
+ {
+ if (key == "Icon") {
+ ctx.Image ("gnome-gaim.png", new TileActionHandler (ShowLog));
+ return true;
+ }
+
+ return base.RenderKey (key, ctx);
+ }
}
}
--- Tiles/template-im-log.html.~1.4.~ 2004-09-15 17:02:46.000000000 +0200
+++ Tiles/template-im-log.html 2004-09-22 21:19:26.000000000 +0200
@@ -2,7 +2,7 @@
<tr valign="top"><td>
<table bgcolor="#e5f5e5" cellpadding="4" width="100%" height="100%">
<tr valign="top">
-<td><a href="@Uri@"><img src="gnome-gaim.png" border="0"></a></td>
+<td>@Icon@</td>
<td>
<font size="2">IM with <strong>@fixme:speakingto@</strong></font><br>
<font size="1">
--- /dev/null 1970-01-01 01:00:00.000000000 +0100
+++ Util/ImLogViewer.cs 2004-09-23 13:49:18.293679904 +0200
@@ -0,0 +1,172 @@
+//
+// ImLogViewer.cs
+//
+//
+// Copyright (C) 2004 Lukas Lipka
+// Copyright (C) 2004 Novell, Inc.
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Globalization;
+using System.Text;
+using System.Text.RegularExpressions;
+using Gtk;
+
+namespace Beagle.Util {
+
+ public class ImLogViewer {
+
+ private HTML html;
+ private HTMLStream stream;
+ private Gtk.Window window;
+
+ ImLog imLog;
+ IList utterances;
+
+ public ImLogViewer (String file)
+ {
+ if (file == null)
+ return;
+
+ ParseLog (file);
+
+ CreateWindow ();
+ }
+
+ private void ParseLog (String file)
+ {
+ ICollection logs = GaimLog.ScanLog (new FileInfo (file));
+
+ foreach (ImLog imlog in logs) {
+ imLog = imlog;
+ utterances = imlog.Utterances; //calls ImLog.Load
+ }
+ }
+
+ private void RenderConversation ()
+ {
+ string colorband;
+
+ stream = html.Begin ();
+
+ stream.Write ("<div>");
+
+ foreach (ImLog.Utterance utt in utterances) {
+ if (utt.Who == imLog.SpeakingTo)
+ colorband = "#ef0000";
+ else
+ colorband = "#0000ff";
+
+ stream.Write ("<font color=" + colorband + ">" + utt.Who +
+ ":</font> " + utt.Text + "<br/>");
+ }
+
+ stream.Write ("</div>");
+
+ html.End (stream, HTMLStreamStatus.Ok);
+ }
+
+ private string GetWindowCaption ()
+ {
+ string caption;
+
+ if (imLog != null)
+ caption = "IM with " + imLog.SpeakingTo;
+ else
+ caption = "IM viewer";
+
+ return caption;
+ }
+
+ private string GetDuration ()
+ {
+ TimeSpan duration = imLog.EndTime - imLog.StartTime;
+ String text = "";
+
+ if (duration.Hours > 0)
+ text = duration.Hours + " " + "hours" + " ";
+
+ text = text + duration.Minutes + " " + "minutes";
+
+ return text;
+ }
+
+ private void CreateWindow ()
+ {
+ window = new Gtk.Window (GetWindowCaption ());
+
+ window.DefaultWidth = 420;
+ window.DefaultHeight = 300;
+
+ VBox vbox = new VBox (false, 2);
+
+ //Nice header
+ HBox hbox = new HBox (false, 5);
+
+ //Icon
+ Button img = new Button ("Icon here");
+ hbox.PackStart (img, false, false, 3);
+
+ //Text
+ String text = "Speaking to:\n<b>" + imLog.SpeakingTo + "</b> (Online)\n" + "Date: " +
+ imLog.StartTime + "\n" + "Duration: " + GetDuration();
+ Label label = new Label (text);
+ label.Justify = Gtk.Justification.Left;
+ label.UseMarkup = true;
+ hbox.PackStart (label, false, false, 3);
+
+ vbox.PackStart (hbox, false, false, 3);
+
+ ScrolledWindow sw = new ScrolledWindow ();
+ sw.VscrollbarPolicy = PolicyType.Automatic;
+ sw.HscrollbarPolicy = PolicyType.Automatic;
+ vbox.PackStart (sw, true, true, 3);
+
+ html = new HTML ();
+ sw.Add (html);
+
+
+ HBox hbox2 = new HBox (false, 0);
+ Button button = new Button ("gtk-close");
+ button.Clicked += new EventHandler (OnCloseClicked);
+ hbox2.PackStart (button, false, false, 3);
+ hbox2.SetChildPacking (button, false, false, 3, Gtk.PackType.End);
+
+ vbox.PackStart (hbox2, false, false, 3);
+
+
+ window.Add (vbox);
+
+ RenderConversation ();
+
+ window.ShowAll ();
+ }
+
+ private void OnCloseClicked (object obj, EventArgs args)
+ {
+ window.Destroy ();
+ }
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]