Skip to content
Browse files

Example 56: Fix up the OrkivRoot so that it keeps track of BuddyList …

…and ChatWindow objects such that they can be displayed without having to be reconstructed.
  • Loading branch information...
1 parent 401f2b5 commit 4393a01832e496cd0e8073c611970b579778075d @buchuki committed Jul 20, 2013
Showing with 12 additions and 3 deletions.
  1. +12 −3 orkiv/__main__.py
View
15 orkiv/__main__.py
@@ -110,15 +110,24 @@ class ChatWindow(BoxLayout):
class OrkivRoot(BoxLayout):
+ def __init__(self):
+ super(OrkivRoot, self).__init__()
+ self.buddy_list = None
+ self.chat_windows = {}
+
def show_buddy_list(self):
self.clear_widgets()
- self.buddy_list = BuddyList()
+ if not self.buddy_list:
+ self.buddy_list = BuddyList()
+ for buddy_list_item in self.buddy_list.list_view.adapter.selection:
+ buddy_list_item.deselect()
self.add_widget(self.buddy_list)
def show_buddy_chat(self, jabber_id):
self.remove_widget(self.buddy_list)
- chat_window = ChatWindow(jabber_id=jabber_id)
- self.add_widget(chat_window)
+ if jabber_id not in self.chat_windows:
+ self.chat_windows[jabber_id] = ChatWindow(jabber_id=jabber_id)
+ self.add_widget(self.chat_windows[jabber_id])
class Orkiv(App):

0 comments on commit 4393a01

Please sign in to comment.
Something went wrong with that request. Please try again.