primitivus: refactoring to use urwid-satext which is now a separate project

This commit is contained in:
Goffi 2010-12-28 23:10:13 +01:00
commit c8b5f1db90

View file

@ -22,11 +22,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import urwid
from quick_frontend.quick_contact_list import QuickContactList
from quick_frontend.quick_chat import QuickChat
import custom_widgets
from urwid_satext import sat_widgets
import time
from tools.jid import JID
from card_game import CardGame
from files_management import FileDialog
from urwid_satext.files_management import FileDialog
class ChatText(urwid.FlowWidget):
@ -107,7 +107,7 @@ class Chat(urwid.WidgetWrap, QuickChat):
for wid in self.content:
wid._invalidate()
elif key == "meta l": #user wants to (un)hide widget decoration
show = not isinstance(self._w, custom_widgets.LabelLine)
show = not isinstance(self._w, sat_widgets.LabelLine)
self.showDecoration(show)
self._invalidate()
elif key == "meta s": #user wants to (un)hide group's subject or change its apperance
@ -126,7 +126,7 @@ class Chat(urwid.WidgetWrap, QuickChat):
def getMenu(self):
"""Return Menu bar"""
menu = custom_widgets.Menu(self.host.loop)
menu = sat_widgets.Menu(self.host.loop)
if self.type == 'group':
game = _("Game")
menu.addMenu(game, "Tarot", self.onTarotRequest)
@ -141,11 +141,11 @@ class Chat(urwid.WidgetWrap, QuickChat):
elif type == 'group':
if len(self.chat_colums.widget_list) == 1:
present_widget = self.__buildPresentList()
self.present_panel = custom_widgets.VerticalSeparator(present_widget)
self.present_panel = sat_widgets.VerticalSeparator(present_widget)
self.__appendPresentPanel()
def __getDecoration(self, widget):
return custom_widgets.LabelLine(widget, custom_widgets.SurroundedText(unicode(self.target)))
return sat_widgets.LabelLine(widget, sat_widgets.SurroundedText(unicode(self.target)))
def showDecoration(self, show=True):
"""Show/Hide the decoration around the chat window"""
@ -157,7 +157,7 @@ class Chat(urwid.WidgetWrap, QuickChat):
def __buildPresentList(self):
self.present_wid = custom_widgets.GenericList([],option_type = custom_widgets.ClickableText)
self.present_wid = sat_widgets.GenericList([],option_type = sat_widgets.ClickableText)
return self.present_wid
def __appendPresentPanel(self):
@ -241,7 +241,7 @@ class Chat(urwid.WidgetWrap, QuickChat):
normal: general info like "toto has joined the room"
me: "/me" information like "/me clenches his fist" ==> "toto clenches his fist"
"""
self.content.append(custom_widgets.ClickableText(msg))
self.content.append(sat_widgets.ClickableText(msg))
self.text_list.set_focus(len(self.content)-1)
self.host.redraw()
@ -263,7 +263,7 @@ class Chat(urwid.WidgetWrap, QuickChat):
#MENU EVENTS#
def onTarotRequest(self, menu):
if len(self.occupants) != 4:
self.host.showPopUp(custom_widgets.Alert(_("Can't start game"), _("You need to be exactly 4 peoples in the room to start a Tarot game"), ok_cb=self.host.removePopUp))
self.host.showPopUp(sat_widgets.Alert(_("Can't start game"), _("You need to be exactly 4 peoples in the room to start a Tarot game"), ok_cb=self.host.removePopUp))
else:
self.host.bridge.tarotGameCreate(self.id, list(self.occupants), self.host.profile)