Primitivus: begining of management for actionResult
This commit is contained in:
parent
e35ee355ba
commit
49a5f2de2c
4 changed files with 37 additions and 19 deletions
|
|
@ -94,7 +94,7 @@ class Hand(urwid.WidgetWrap):
|
|||
"""Return a list of selected cards"""
|
||||
_selected = []
|
||||
for wid in self.columns.widget_list:
|
||||
if wid.__class__ == CardDisplayer and wid.isSelected():
|
||||
if isinstance(wid, CardDisplayer) and wid.isSelected():
|
||||
_selected.append(wid.getCard())
|
||||
return _selected
|
||||
|
||||
|
|
@ -169,7 +169,7 @@ class Table(urwid.FlowWidget):
|
|||
@param location: where to put the card (top, left, bottom or right)
|
||||
@param card: Card to play or None"""
|
||||
assert location in ['top','left','bottom','right']
|
||||
assert card.__class__ == Card or card == None
|
||||
assert isinstance(card,Card) or card == None
|
||||
if [getattr(self, place) for place in ['top','left','bottom','right']].count(None) == 0:
|
||||
#If the table is full of card, we remove them
|
||||
self.top = self.left = self.bottom = self.right = None
|
||||
|
|
@ -290,7 +290,7 @@ class CardGame(QuickCardGame,urwid.WidgetWrap):
|
|||
#it's not our turn, we ignore the click
|
||||
card_wid.select(False)
|
||||
return
|
||||
if self.center.widget_list[1].original_widget.__class__ == Hand: #if we have a hand displayed
|
||||
if isinstance(self.center.widget_list[1].original_widget, Hand): #if we have a hand displayed
|
||||
self.center.widget_list[1] = urwid.Filler(self.table) #we show again the table
|
||||
if self.state == "chien":
|
||||
self.to_show = []
|
||||
|
|
|
|||
|
|
@ -108,7 +108,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 self._w.__class__ == custom_widgets.LabelLine
|
||||
show = not isinstance(self._w, custom_widgets.LabelLine)
|
||||
self.showDecoration(show)
|
||||
self._invalidate()
|
||||
elif key == "meta s": #user wants to (un)hide group's subject
|
||||
|
|
@ -223,7 +223,7 @@ class Chat(urwid.WidgetWrap, QuickChat):
|
|||
self.host.redraw()
|
||||
|
||||
def printMessage(self, from_jid, msg, profile, timestamp=""):
|
||||
assert (from_jid.__class__ == JID)
|
||||
assert isinstance(from_jid, JID)
|
||||
my_jid = self.host.profiles[profile]['whoami']
|
||||
self.content.append(ChatText(self, timestamp or None, my_jid, from_jid, msg))
|
||||
self.text_list.set_focus(len(self.content)-1)
|
||||
|
|
|
|||
|
|
@ -124,11 +124,12 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
def clear_contacts(self):
|
||||
"""clear all the contact list"""
|
||||
self.groups={}
|
||||
self.selected = None
|
||||
|
||||
def replace(self, jid, groups=[None]):
|
||||
"""add a contact to the list if doesn't exist, else update it"""
|
||||
assert groups.__class__ == list
|
||||
assert jid.__class__ == JID
|
||||
assert isinstance(groups, list)
|
||||
assert isinstance(jid, JID)
|
||||
if not groups:
|
||||
groups=[None]
|
||||
for group in groups:
|
||||
|
|
|
|||
|
|
@ -37,16 +37,9 @@ from chat import Chat
|
|||
from tools.jid import JID"""
|
||||
import logging
|
||||
from logging import debug, info, error
|
||||
#import locale
|
||||
import sys, os
|
||||
from tools.jid import JID
|
||||
#from curses import ascii
|
||||
#import locale
|
||||
#from signal import signal, SIGWINCH
|
||||
#import fcntl
|
||||
#import struct
|
||||
#import termios
|
||||
#from boxsizer import BoxSizer
|
||||
from xmlui import XMLUI
|
||||
|
||||
|
||||
### logging configuration FIXME: put this elsewhere ###
|
||||
|
|
@ -125,7 +118,7 @@ class PrimitivusApp(QuickApp):
|
|||
|
||||
def inputFilter(self, input, raw):
|
||||
for i in input:
|
||||
if i.__class__==tuple:
|
||||
if isinstance(i,tuple):
|
||||
if i[0] == 'mouse press':
|
||||
if i[1] == 4: #Mouse wheel up
|
||||
input[input.index(i)] = 'up'
|
||||
|
|
@ -246,6 +239,33 @@ class PrimitivusApp(QuickApp):
|
|||
if JID(self.contactList.selected).short != sender.short:
|
||||
self.contactList.putAlert(sender)
|
||||
|
||||
def actionResult(self, type, id, data):
|
||||
if not id in self.current_action_ids:
|
||||
debug (_('unknown id, ignoring'))
|
||||
return
|
||||
if type == "SUPPRESS":
|
||||
self.current_action_ids.remove(id)
|
||||
elif type == "XMLUI":
|
||||
self.current_action_ids.remove(id)
|
||||
debug (_("XML user interface received"))
|
||||
misc = {}
|
||||
#FIXME FIXME FIXME: must clean all this crap !
|
||||
title = _('Form')
|
||||
if data['type'] == _('registration'):
|
||||
title = _('Registration')
|
||||
misc['target'] = data['target']
|
||||
misc['action_back'] = self.bridge.gatewayRegister
|
||||
ui = XMLUI(self, title=title, xml_data = data['xml'], misc = misc)
|
||||
assert(len(self.center_part.widget_list)==2)
|
||||
self.center_part.widget_list[1] = ui
|
||||
self.menu_roller.removeMenu(_('Chat menu'))
|
||||
self.contactList.selected = None
|
||||
self.redraw()
|
||||
else:
|
||||
error (_("FIXME FIXME FIXME: type [%s] not implemented") % type)
|
||||
raise NotImplementedError
|
||||
|
||||
##DIALOGS CALLBACKS##
|
||||
def onJoinRoom(self, button, edit):
|
||||
self.removePopUp()
|
||||
room_jid = JID(edit.get_edit_text())
|
||||
|
|
@ -298,9 +318,6 @@ class PrimitivusApp(QuickApp):
|
|||
pop_up_widget = custom_widgets.ConfirmDialog(_("Are you sure you want to delete the contact [%s] ?" % contact), yes_cb=self.onRemoveContact, no_cb=self.removePopUp)
|
||||
self.showPopUp(pop_up_widget)
|
||||
|
||||
|
||||
|
||||
|
||||
def onAboutRequest(self, menu):
|
||||
self.showPopUp(custom_widgets.Alert(_("About"), const_APP_NAME + " v" + self.bridge.getVersion(), ok_cb=self.removePopUp))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue