comparison frontends/src/primitivus/chat.py @ 607:c123dddaea6b

primitivus: fixed urwid issues with recent urwid versions fix bug 18
author Goffi <goffi@goffi.org>
date Sun, 24 Feb 2013 13:57:37 +0100
parents 952322b1d490
children 84a6e83157c2
comparison
equal deleted inserted replaced
606:21ddafccf32d 607:c123dddaea6b
93 self.subject = None 93 self.subject = None
94 94
95 def keypress(self, size, key): 95 def keypress(self, size, key):
96 if key == "meta p": #user wants to (un)hide the presents panel 96 if key == "meta p": #user wants to (un)hide the presents panel
97 if self.type == 'group': 97 if self.type == 'group':
98 widgets = self.chat_colums.widget_list 98 widgets = [widget for (widget, options) in self.chat_colums.contents]
99 if self.present_panel in widgets: 99 if self.present_panel in widgets:
100 self.__removePresentPanel() 100 self.__removePresentPanel()
101 else: 101 else:
102 self.__appendPresentPanel() 102 self.__appendPresentPanel()
103 elif key == "meta t": #user wants to (un)hide timestamp 103 elif key == "meta t": #user wants to (un)hide timestamp
139 def setType(self, type): 139 def setType(self, type):
140 QuickChat.setType(self, type) 140 QuickChat.setType(self, type)
141 if type == 'one2one': 141 if type == 'one2one':
142 self.historyPrint(profile=self.host.profile) 142 self.historyPrint(profile=self.host.profile)
143 elif type == 'group': 143 elif type == 'group':
144 if len(self.chat_colums.widget_list) == 1: 144 if len(self.chat_colums.contents) == 1:
145 present_widget = self.__buildPresentList() 145 present_widget = self.__buildPresentList()
146 self.present_panel = sat_widgets.VerticalSeparator(present_widget) 146 self.present_panel = sat_widgets.VerticalSeparator(present_widget)
147 self.__appendPresentPanel() 147 self.__appendPresentPanel()
148 148
149 def __getDecoration(self, widget): 149 def __getDecoration(self, widget):
175 def __buildPresentList(self): 175 def __buildPresentList(self):
176 self.present_wid = sat_widgets.GenericList([],option_type = sat_widgets.ClickableText, on_click=self._presentClicked) 176 self.present_wid = sat_widgets.GenericList([],option_type = sat_widgets.ClickableText, on_click=self._presentClicked)
177 return self.present_wid 177 return self.present_wid
178 178
179 def __appendPresentPanel(self): 179 def __appendPresentPanel(self):
180 self.chat_colums.widget_list.append(self.present_panel) 180 self.chat_colums.contents.append((self.present_panel,('weight', 2, False)))
181 self.chat_colums.column_types.append(('weight', 2))
182 181
183 def __removePresentPanel(self): 182 def __removePresentPanel(self):
184 self.chat_colums.set_focus(0) #necessary as the focus change to the next object, we can go out of range if we are on the last object of self.chat_colums 183 for widget, options in self.chat_colums.contents:
185 self.chat_colums.widget_list.remove(self.present_panel) 184 if widget is self.present_panel:
186 del self.chat_colums.column_types[-1] 185 self.chat_colums.contents.remove((widget, options))
186 break
187 187
188 def __appendGamePanel(self, widget): 188 def __appendGamePanel(self, widget):
189 assert (len(self.pile.widget_list) == 1) 189 assert (len(self.pile.contents) == 1)
190 self.pile.widget_list.insert(0,widget) 190 self.pile.contents.insert(0,(widget,('weight', 1, False)))
191 self.pile.item_types.insert(0,('weight', 1)) 191 self.pile.contents.insert(1,(urwid.Filler(urwid.Divider('-'),('fixed', 1))))
192 self.pile.widget_list.insert(1,urwid.Filler(urwid.Divider('-')))
193 self.pile.item_types.insert(1,('fixed', 1))
194 self.host.redraw() 192 self.host.redraw()
195 193
196 def __removeGamePanel(self): 194 def __removeGamePanel(self):
197 assert (len(self.pile.widget_list) == 3) 195 assert (len(self.pile.contents) == 3)
198 self.pile.set_focus(0) #necessary as the focus change to the next object, we can go out of range if we are on the last object of self.chat_colums 196 del self.pile.contents[0]
199 del self.pile.widget_list[0]
200 del self.pile.item_types[0]
201 self.host.redraw() 197 self.host.redraw()
202 198
203 def setSubject(self, subject, wrap='space'): 199 def setSubject(self, subject, wrap='space'):
204 """Set title for a group chat""" 200 """Set title for a group chat"""
205 QuickChat.setSubject(self, subject) 201 QuickChat.setSubject(self, subject)