diff 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
line wrap: on
line diff
--- a/frontends/src/primitivus/chat.py	Sat Feb 23 17:50:58 2013 +0100
+++ b/frontends/src/primitivus/chat.py	Sun Feb 24 13:57:37 2013 +0100
@@ -95,7 +95,7 @@
     def keypress(self, size, key):
         if key == "meta p": #user wants to (un)hide the presents panel
             if self.type == 'group':
-                widgets = self.chat_colums.widget_list
+                widgets = [widget for (widget, options) in self.chat_colums.contents]
                 if self.present_panel in widgets:
                     self.__removePresentPanel()
                 else:
@@ -141,7 +141,7 @@
         if type == 'one2one':
             self.historyPrint(profile=self.host.profile)
         elif type == 'group':
-            if len(self.chat_colums.widget_list) == 1:
+            if len(self.chat_colums.contents) == 1:
                 present_widget = self.__buildPresentList()
                 self.present_panel = sat_widgets.VerticalSeparator(present_widget)
                 self.__appendPresentPanel()
@@ -177,27 +177,23 @@
         return self.present_wid
 
     def __appendPresentPanel(self):
-        self.chat_colums.widget_list.append(self.present_panel)
-        self.chat_colums.column_types.append(('weight', 2))
+        self.chat_colums.contents.append((self.present_panel,('weight', 2, False)))
 
     def __removePresentPanel(self):
-        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
-        self.chat_colums.widget_list.remove(self.present_panel)
-        del self.chat_colums.column_types[-1]
+        for widget, options in self.chat_colums.contents:
+            if widget is self.present_panel:
+                self.chat_colums.contents.remove((widget, options))
+                break
 
     def __appendGamePanel(self, widget):
-        assert (len(self.pile.widget_list) == 1)
-        self.pile.widget_list.insert(0,widget)
-        self.pile.item_types.insert(0,('weight', 1))
-        self.pile.widget_list.insert(1,urwid.Filler(urwid.Divider('-')))
-        self.pile.item_types.insert(1,('fixed', 1))
+        assert (len(self.pile.contents) == 1)
+        self.pile.contents.insert(0,(widget,('weight', 1, False)))
+        self.pile.contents.insert(1,(urwid.Filler(urwid.Divider('-'),('fixed', 1))))
         self.host.redraw()
 
     def __removeGamePanel(self):
-        assert (len(self.pile.widget_list) == 3)
-        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
-        del self.pile.widget_list[0]
-        del self.pile.item_types[0]
+        assert (len(self.pile.contents) == 3)
+        del self.pile.contents[0]
         self.host.redraw()
 
     def setSubject(self, subject, wrap='space'):