changeset 19419:6df41719037c

Utilize the message-history in dbus-gnt. So now, if you run pidgin (with dbus-support), and at a later time start dbus-gnt, it will contain all the message history for the conversations, which is really cool. Note: Samurai Jack is awesome!
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 25 Aug 2007 10:33:00 +0000
parents b33c2b085e78
children c1c260d41365
files finch/libgnt/pygnt/dbus-gnt finch/libgnt/pygnt/gendef.sh
diffstat 2 files changed, 26 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/finch/libgnt/pygnt/dbus-gnt	Sat Aug 25 10:02:21 2007 +0000
+++ b/finch/libgnt/pygnt/dbus-gnt	Sat Aug 25 10:33:00 2007 +0000
@@ -13,7 +13,7 @@
 import gnt
 import sys
 
-from time import strftime
+import time
 
 convwins = {}
 
@@ -27,19 +27,26 @@
     # if a conv window is closed, then reopened, this thing crashes
     convwins[key] = None
 
-def wrote_msg(account, who, msg, conv, flags):
-    stuff = show_conversation(conv)
+def add_message(conv, who, msg, flags, timestamp):
+    stuff = show_conversation(conv, False)
     tv = stuff[1]
     tv.append_text_with_flags("\n", 0)
-    tv.append_text_with_flags(strftime("(%X) "), 8)
+    if timestamp:
+        tv.append_text_with_flags(time.strftime("(%X) ", time.localtime(timestamp)), 8)
+    else:
+        tv.append_text_with_flags(time.strftime("(%X) "), 8)
     if flags & 3:
         tv.append_text_with_flags(who + ": ", 1)
+        msg = purple.PurpleMarkupStripHtml(msg)
         tv.append_text_with_flags(msg, 0)
         stuff[0].set_urgent()
     else:
         tv.append_text_with_flags(msg, 8)
     tv.scroll(0)
 
+def wrote_msg(account, who, msg, conv, flags):
+    add_message(conv, who, msg, flags, None)
+
 bus = dbus.SessionBus()
 obj = bus.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject")
 purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface")
@@ -79,7 +86,7 @@
 def conv_window_destroyed(win, key):
     del convwins[key]
 
-def show_conversation(conv):
+def show_conversation(conv, history):
     key = get_dict_key(conv)
     if key in convwins:
         return convwins[key]
@@ -96,9 +103,20 @@
     vbox.add_widget(entry)
     entry.connect("key_pressed", send_im_cb, conv)
     tv.clear()
+    tv.attach_scroll_widget(entry)
     win.show()
     convwins[key] = [win, tv, entry]
     win.connect("destroy", conv_window_destroyed, key)
+    
+    if history:
+        msgs = purple.PurpleConversationGetMessageHistory(conv)
+        for msg in msgs:
+            who = purple.PurpleConversationMessageGetSender(msg)
+            what = purple.PurpleConversationMessageGetMessage(msg)
+            flags = purple.PurpleConversationMessageGetFlags(msg)
+            when = purple.PurpleConversationMessageGetTimestamp(msg)
+            add_message(conv, who, what, flags, when)
+
     return convwins[key]
 
 def show_buddylist():
@@ -127,7 +145,7 @@
 
 convs = purple.PurpleGetConversations()
 for conv in convs:
-    show_conversation(conv)
+    show_conversation(conv, True)
 
 gnt.gnt_main()
 
--- a/finch/libgnt/pygnt/gendef.sh	Sat Aug 25 10:02:21 2007 +0000
+++ b/finch/libgnt/pygnt/gendef.sh	Sat Aug 25 10:33:00 2007 +0000
@@ -31,7 +31,9 @@
 rm -f gnt.def
 for file in $FILES
 do
+	echo -n "Generating definitions for ${file} ... "
 	python /usr/share/pygtk/2.0/codegen/h2def.py ../$file >> gnt.def
+	echo "Done"
 done
 
 # Remove the definitions about the enums