From c6c65f3efac4a3c967f30d623030ab462581d9d1 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 25 Apr 2006 11:47:19 -0400 Subject: [PATCH] Fix up chat sending/receiving --- chat/chat.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/chat/chat.py b/chat/chat.py index c48ade15..2abb2f1b 100755 --- a/chat/chat.py +++ b/chat/chat.py @@ -120,7 +120,7 @@ class ChatRequestHandler(object): if buddy: chat = buddy.chat() if not chat: - chat = BuddyChat(self, buddy, self._chat_view, self._chat_label) + chat = BuddyChat(self._parent, buddy, self._chat_view, self._chat_label) buddy.set_chat(chat) chat.recv_message(message) return True @@ -254,7 +254,7 @@ class ChatActivity(activity.Activity): aniter = self._buddy_list_model.append(None) self._buddy_list_model.set(aniter, self._MODEL_COL_NICK, "Group", self._MODEL_COL_ICON, self._pixbuf_active_chat, self._MODEL_COL_BUDDY, None) - self._activate_chat(None) + self._activate_chat_for_buddy(None) plug.add(vbox) vbox.show() @@ -327,14 +327,10 @@ class ChatActivity(activity.Activity): (model, aniter) = widget.get_selection().get_selected() chat = None buddy = self._buddy_list_model.get_value(aniter, self._MODEL_COL_BUDDY) - if not buddy: - chat = self._group_chat - else: - chat = buddy.chat() - if not chat: - chat = BuddyChat(self, buddy, self._chat_view, self._chat_label) - buddy.set_chat(chat) - self._activate_chat(chat) + if buddy and not buddy.chat(): + chat = BuddyChat(self, buddy, self._chat_view, self._chat_label) + buddy.set_chat(chat) + self._activate_chat_for_buddy(buddy) def _on_buddy_presence_event(self, action, buddy): if action == BuddyList.ACTION_BUDDY_ADDED: @@ -365,7 +361,7 @@ class ChatActivity(activity.Activity): def local_name(self): return (self._nick, self._realname) - def _activate_chat(self, buddy): + def _activate_chat_for_buddy(self, buddy): self._active_chat_buddy = buddy # Clear the "new message" icon when the user activates the chat @@ -376,7 +372,7 @@ class ChatActivity(activity.Activity): # Actually activate the chat chat = self._group_chat - if buddy: + if self._active_chat_buddy: chat = buddy.chat() chat.activate() @@ -387,6 +383,7 @@ class ChatActivity(activity.Activity): chat = self._group_chat if self._active_chat_buddy: chat = self._active_chat_buddy.chat() + return chat def run(self): try: