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"""
|
"""Return a list of selected cards"""
|
||||||
_selected = []
|
_selected = []
|
||||||
for wid in self.columns.widget_list:
|
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())
|
_selected.append(wid.getCard())
|
||||||
return _selected
|
return _selected
|
||||||
|
|
||||||
|
|
@ -169,7 +169,7 @@ class Table(urwid.FlowWidget):
|
||||||
@param location: where to put the card (top, left, bottom or right)
|
@param location: where to put the card (top, left, bottom or right)
|
||||||
@param card: Card to play or None"""
|
@param card: Card to play or None"""
|
||||||
assert location in ['top','left','bottom','right']
|
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 [getattr(self, place) for place in ['top','left','bottom','right']].count(None) == 0:
|
||||||
#If the table is full of card, we remove them
|
#If the table is full of card, we remove them
|
||||||
self.top = self.left = self.bottom = self.right = None
|
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
|
#it's not our turn, we ignore the click
|
||||||
card_wid.select(False)
|
card_wid.select(False)
|
||||||
return
|
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
|
self.center.widget_list[1] = urwid.Filler(self.table) #we show again the table
|
||||||
if self.state == "chien":
|
if self.state == "chien":
|
||||||
self.to_show = []
|
self.to_show = []
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ class Chat(urwid.WidgetWrap, QuickChat):
|
||||||
for wid in self.content:
|
for wid in self.content:
|
||||||
wid._invalidate()
|
wid._invalidate()
|
||||||
elif key == "meta l": #user wants to (un)hide widget decoration
|
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.showDecoration(show)
|
||||||
self._invalidate()
|
self._invalidate()
|
||||||
elif key == "meta s": #user wants to (un)hide group's subject
|
elif key == "meta s": #user wants to (un)hide group's subject
|
||||||
|
|
@ -223,7 +223,7 @@ class Chat(urwid.WidgetWrap, QuickChat):
|
||||||
self.host.redraw()
|
self.host.redraw()
|
||||||
|
|
||||||
def printMessage(self, from_jid, msg, profile, timestamp=""):
|
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']
|
my_jid = self.host.profiles[profile]['whoami']
|
||||||
self.content.append(ChatText(self, timestamp or None, my_jid, from_jid, msg))
|
self.content.append(ChatText(self, timestamp or None, my_jid, from_jid, msg))
|
||||||
self.text_list.set_focus(len(self.content)-1)
|
self.text_list.set_focus(len(self.content)-1)
|
||||||
|
|
|
||||||
|
|
@ -124,11 +124,12 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
||||||
def clear_contacts(self):
|
def clear_contacts(self):
|
||||||
"""clear all the contact list"""
|
"""clear all the contact list"""
|
||||||
self.groups={}
|
self.groups={}
|
||||||
|
self.selected = None
|
||||||
|
|
||||||
def replace(self, jid, groups=[None]):
|
def replace(self, jid, groups=[None]):
|
||||||
"""add a contact to the list if doesn't exist, else update it"""
|
"""add a contact to the list if doesn't exist, else update it"""
|
||||||
assert groups.__class__ == list
|
assert isinstance(groups, list)
|
||||||
assert jid.__class__ == JID
|
assert isinstance(jid, JID)
|
||||||
if not groups:
|
if not groups:
|
||||||
groups=[None]
|
groups=[None]
|
||||||
for group in groups:
|
for group in groups:
|
||||||
|
|
|
||||||
|
|
@ -37,16 +37,9 @@ from chat import Chat
|
||||||
from tools.jid import JID"""
|
from tools.jid import JID"""
|
||||||
import logging
|
import logging
|
||||||
from logging import debug, info, error
|
from logging import debug, info, error
|
||||||
#import locale
|
|
||||||
import sys, os
|
import sys, os
|
||||||
from tools.jid import JID
|
from tools.jid import JID
|
||||||
#from curses import ascii
|
from xmlui import XMLUI
|
||||||
#import locale
|
|
||||||
#from signal import signal, SIGWINCH
|
|
||||||
#import fcntl
|
|
||||||
#import struct
|
|
||||||
#import termios
|
|
||||||
#from boxsizer import BoxSizer
|
|
||||||
|
|
||||||
|
|
||||||
### logging configuration FIXME: put this elsewhere ###
|
### logging configuration FIXME: put this elsewhere ###
|
||||||
|
|
@ -125,7 +118,7 @@ class PrimitivusApp(QuickApp):
|
||||||
|
|
||||||
def inputFilter(self, input, raw):
|
def inputFilter(self, input, raw):
|
||||||
for i in input:
|
for i in input:
|
||||||
if i.__class__==tuple:
|
if isinstance(i,tuple):
|
||||||
if i[0] == 'mouse press':
|
if i[0] == 'mouse press':
|
||||||
if i[1] == 4: #Mouse wheel up
|
if i[1] == 4: #Mouse wheel up
|
||||||
input[input.index(i)] = 'up'
|
input[input.index(i)] = 'up'
|
||||||
|
|
@ -246,6 +239,33 @@ class PrimitivusApp(QuickApp):
|
||||||
if JID(self.contactList.selected).short != sender.short:
|
if JID(self.contactList.selected).short != sender.short:
|
||||||
self.contactList.putAlert(sender)
|
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):
|
def onJoinRoom(self, button, edit):
|
||||||
self.removePopUp()
|
self.removePopUp()
|
||||||
room_jid = JID(edit.get_edit_text())
|
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)
|
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)
|
self.showPopUp(pop_up_widget)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def onAboutRequest(self, menu):
|
def onAboutRequest(self, menu):
|
||||||
self.showPopUp(custom_widgets.Alert(_("About"), const_APP_NAME + " v" + self.bridge.getVersion(), ok_cb=self.removePopUp))
|
self.showPopUp(custom_widgets.Alert(_("About"), const_APP_NAME + " v" + self.bridge.getVersion(), ok_cb=self.removePopUp))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue