frontends: fixed /me usage + renamed a couple of "type" parameters to type_
This commit is contained in:
parent
2ca6efd8cc
commit
4d14048f8c
6 changed files with 44 additions and 44 deletions
|
|
@ -76,9 +76,9 @@ class ChatText(urwid.FlowWidget):
|
|||
|
||||
class Chat(urwid.WidgetWrap, QuickChat):
|
||||
|
||||
def __init__(self, target, host, type='one2one'):
|
||||
def __init__(self, target, host, type_='one2one'):
|
||||
self.target = target
|
||||
QuickChat.__init__(self, target, host, type)
|
||||
QuickChat.__init__(self, target, host, type_)
|
||||
self.content = urwid.SimpleListWalker([])
|
||||
self.text_list = urwid.ListBox(self.content)
|
||||
self.chat_widget = urwid.Frame(self.text_list)
|
||||
|
|
@ -86,7 +86,7 @@ class Chat(urwid.WidgetWrap, QuickChat):
|
|||
self.chat_colums = urwid.Columns([('weight', 8, self.chat_widget)])
|
||||
self.pile = urwid.Pile([self.chat_colums])
|
||||
urwid.WidgetWrap.__init__(self, self.__getDecoration(self.pile))
|
||||
self.setType(type)
|
||||
self.setType(type_)
|
||||
self.day_change = time.strptime(time.strftime("%a %b %d 00:00:00 %Y")) #struct_time of day changing time
|
||||
self.show_timestamp = True
|
||||
self.show_short_nick = False
|
||||
|
|
@ -139,11 +139,11 @@ class Chat(urwid.WidgetWrap, QuickChat):
|
|||
menu.addMenu(_("Action"), _("Send file"), self.onSendFileRequest)
|
||||
return menu
|
||||
|
||||
def setType(self, type):
|
||||
QuickChat.setType(self, type)
|
||||
if type == 'one2one':
|
||||
def setType(self, type_):
|
||||
QuickChat.setType(self, type_)
|
||||
if type_ == 'one2one':
|
||||
self.historyPrint(profile=self.host.profile)
|
||||
elif type == 'group':
|
||||
elif type_ == 'group':
|
||||
if len(self.chat_colums.contents) == 1:
|
||||
present_widget = self.__buildPresentList()
|
||||
self.present_panel = sat_widgets.VerticalSeparator(present_widget)
|
||||
|
|
@ -293,7 +293,7 @@ class Chat(urwid.WidgetWrap, QuickChat):
|
|||
def printInfo(self, msg, type_='normal', timestamp=""):
|
||||
"""Print general info
|
||||
@param msg: message to print
|
||||
@type: one of:
|
||||
@type_: one of:
|
||||
normal: general info like "toto has joined the room"
|
||||
me: "/me" information like "/me clenches his fist" ==> "toto clenches his fist"
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -270,8 +270,8 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
|
||||
def setSpecial(self, special_jid, special_type, show=False):
|
||||
"""Set entity as a special
|
||||
@param jid: jid of the entity
|
||||
@param _type: special type (e.g.: "MUC")
|
||||
@param special_jid: jid of the entity
|
||||
@param special_type: special type (e.g.: "MUC")
|
||||
@param show: True to display the dialog to chat with this entity
|
||||
"""
|
||||
QuickContactList.setSpecial(self, special_jid, special_type, show)
|
||||
|
|
|
|||
|
|
@ -406,18 +406,18 @@ class PrimitivusApp(QuickApp, InputHistory):
|
|||
answer_cb(False, *answer_data)
|
||||
|
||||
|
||||
def showDialog(self, message, title="", type="info", answer_cb = None, answer_data = None):
|
||||
if type == 'info':
|
||||
def showDialog(self, message, title="", type_="info", answer_cb = None, answer_data = None):
|
||||
if type_ == 'info':
|
||||
popup = sat_widgets.Alert(unicode(title), unicode(message), ok_cb=answer_cb or self.removePopUp) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore
|
||||
elif type == 'error':
|
||||
elif type_ == 'error':
|
||||
popup = sat_widgets.Alert(unicode(title), unicode(message), ok_cb=answer_cb or self.removePopUp) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore
|
||||
elif type == 'yes/no':
|
||||
elif type_ == 'yes/no':
|
||||
popup = sat_widgets.ConfirmDialog(unicode(message),
|
||||
yes_cb=self._dialogOkCb, yes_value = (answer_cb, answer_data),
|
||||
no_cb=self._dialogCancelCb, no_value = (answer_cb, answer_data))
|
||||
else:
|
||||
popup = sat_widgets.Alert(unicode(title), unicode(message), ok_cb=answer_cb or self.removePopUp) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore
|
||||
error(_('unmanaged dialog type: %s'), type)
|
||||
error(_('unmanaged dialog type: %s'), type_)
|
||||
self.showPopUp(popup)
|
||||
|
||||
def onNotification(self, notBar):
|
||||
|
|
@ -493,7 +493,7 @@ class PrimitivusApp(QuickApp, InputHistory):
|
|||
pop_up_widget = sat_widgets.ConfirmDialog(data["message"], no_cb=refuse_cb, yes_cb=accept_cb)
|
||||
self.showPopUp(pop_up_widget)
|
||||
|
||||
def actionResult(self, type, id, data, profile):
|
||||
def actionResult(self, type_, id, data, profile):
|
||||
# FIXME: to be removed
|
||||
if not self.check_profile(profile):
|
||||
return
|
||||
|
|
@ -501,9 +501,9 @@ class PrimitivusApp(QuickApp, InputHistory):
|
|||
if not id in self.current_action_ids:
|
||||
debug (_('unknown id, ignoring'))
|
||||
return
|
||||
if type == "SUPPRESS":
|
||||
if type_ == "SUPPRESS":
|
||||
self.current_action_ids.remove(id)
|
||||
elif type == "XMLUI":
|
||||
elif type_ == "XMLUI":
|
||||
self.current_action_ids.remove(id)
|
||||
debug (_("XML user interface received"))
|
||||
misc = {}
|
||||
|
|
@ -518,23 +518,23 @@ class PrimitivusApp(QuickApp, InputHistory):
|
|||
ui.show('popup')
|
||||
else:
|
||||
ui.show('window')
|
||||
elif type == "ERROR":
|
||||
elif type_ == "ERROR":
|
||||
self.current_action_ids.remove(id)
|
||||
self.showPopUp(sat_widgets.Alert(_("Error"), unicode(data["message"]), ok_cb=self.removePopUp)) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore
|
||||
elif type == "RESULT":
|
||||
elif type_ == "RESULT":
|
||||
self.current_action_ids.remove(id)
|
||||
if self.current_action_ids_cb.has_key(id):
|
||||
callback = self.current_action_ids_cb[id]
|
||||
del self.current_action_ids_cb[id]
|
||||
callback(data)
|
||||
elif type == "DICT_DICT":
|
||||
elif type_ == "DICT_DICT":
|
||||
self.current_action_ids.remove(id)
|
||||
if self.current_action_ids_cb.has_key(id):
|
||||
callback = self.current_action_ids_cb[id]
|
||||
del self.current_action_ids_cb[id]
|
||||
callback(data)
|
||||
else:
|
||||
error (_("FIXME FIXME FIXME: type [%s] not implemented") % type)
|
||||
error (_("FIXME FIXME FIXME: type [%s] not implemented") % type_)
|
||||
raise NotImplementedError
|
||||
|
||||
##DIALOGS CALLBACKS##
|
||||
|
|
|
|||
|
|
@ -26,19 +26,19 @@ from sat_frontends.quick_frontend.constants import Const
|
|||
|
||||
class QuickChat(object):
|
||||
|
||||
def __init__(self, target, host, type='one2one'):
|
||||
def __init__(self, target, host, type_='one2one'):
|
||||
self.target = target
|
||||
self.host = host
|
||||
self.type = type
|
||||
self.type = type_
|
||||
self.id = ""
|
||||
self.nick = None
|
||||
self.occupants = set()
|
||||
|
||||
def setType(self, type):
|
||||
def setType(self, type_):
|
||||
"""Set the type of the chat
|
||||
@param type: can be 'one2one' for single conversation or 'group' for chat à la IRC
|
||||
"""
|
||||
self.type = type
|
||||
self.type = type_
|
||||
|
||||
def setPresents(self, nicks):
|
||||
"""Set the users presents in the contact list for a group chat
|
||||
|
|
@ -130,14 +130,14 @@ class QuickChat(object):
|
|||
nick = self._get_nick(jid)
|
||||
mymess = (jid.resource == self.nick) if self.type == "group" else (jid.bare == self.host.profiles[profile]['whoami'].bare) #mymess = True if message comes from local user
|
||||
if msg.startswith('/me '):
|
||||
self.printInfo('* %s %s' % (nick, msg[4:]),type='me', timestamp=timestamp)
|
||||
self.printInfo('* %s %s' % (nick, msg[4:]), type_='me', timestamp=timestamp)
|
||||
return
|
||||
return jid, nick, mymess
|
||||
|
||||
def printInfo(self, msg, type='normal'):
|
||||
def printInfo(self, msg, type_='normal'):
|
||||
"""Print general info
|
||||
@param msg: message to print
|
||||
@type: one of:
|
||||
@type_: one of:
|
||||
normal: general info like "toto has joined the room"
|
||||
me: "/me" information like "/me clenches his fist" ==> "toto clenches his fist"
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@ idTAROT = 2
|
|||
class Chat(wx.Frame, QuickChat):
|
||||
"""The chat Window for one to one conversations"""
|
||||
|
||||
def __init__(self, target, host, type='one2one'):
|
||||
def __init__(self, target, host, type_='one2one'):
|
||||
wx.Frame.__init__(self, None, title=target, pos=(0,0), size=(400,200))
|
||||
QuickChat.__init__(self, target, host, type)
|
||||
QuickChat.__init__(self, target, host, type_)
|
||||
|
||||
self.sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
self.SetSizer(self.sizer)
|
||||
|
|
@ -80,21 +80,21 @@ class Chat(wx.Frame, QuickChat):
|
|||
"""Create a list of present people in a group chat"""
|
||||
self.present_panel = wx.Panel(self.splitter)
|
||||
self.present_panel.sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
self.present_panel.presents = ContactList(self.present_panel, self.host, type='nicks')
|
||||
self.present_panel.presents = ContactList(self.present_panel, self.host, type_='nicks')
|
||||
self.present_panel.presents.SetMinSize(wx.Size(80,20))
|
||||
self.present_panel.sizer.Add(self.present_panel.presents, 1, wx.EXPAND)
|
||||
self.present_panel.SetSizer(self.present_panel.sizer)
|
||||
self.splitter.SplitVertically(self.present_panel, self.conv_panel, 80)
|
||||
|
||||
def setType(self, type):
|
||||
QuickChat.setType(self, type)
|
||||
if type is 'group' and not self.splitter.IsSplit():
|
||||
def setType(self, type_):
|
||||
QuickChat.setType(self, type_)
|
||||
if type_ is 'group' and not self.splitter.IsSplit():
|
||||
self.__createPresents()
|
||||
self.subjectBox.Show()
|
||||
self.__eraseMenus()
|
||||
self.__createMenus_group()
|
||||
self.sizer.Layout()
|
||||
elif type is 'one2one' and self.splitter.IsSplit():
|
||||
elif type_ is 'one2one' and self.splitter.IsSplit():
|
||||
self.splitter.Unsplit(self.present_panel)
|
||||
del self.present_panel
|
||||
self.GetMenuBar().Show()
|
||||
|
|
@ -236,18 +236,18 @@ class Chat(wx.Frame, QuickChat):
|
|||
if not mymess:
|
||||
self.__blink()
|
||||
|
||||
def printInfo(self, msg, type='normal'):
|
||||
def printInfo(self, msg, type_='normal'):
|
||||
"""Print general info
|
||||
@param msg: message to print
|
||||
@type: one of:
|
||||
@type_: one of:
|
||||
normal: general info like "toto has joined the room"
|
||||
me: "/me" information like "/me clenches his fist" ==> "toto clenches his fist"
|
||||
"""
|
||||
_font_bold = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.BOLD)
|
||||
_font_normal = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.NORMAL)
|
||||
self.chatWindow.SetDefaultStyle(wx.TextAttr("BLACK", font=_font_bold if type == 'normal' else _font_normal))
|
||||
self.chatWindow.SetDefaultStyle(wx.TextAttr("BLACK", font=_font_bold if type_ == 'normal' else _font_normal))
|
||||
self.chatWindow.AppendText("%s\n" % msg)
|
||||
if type=="me":
|
||||
if type_=="me":
|
||||
self.__blink()
|
||||
|
||||
### events ###
|
||||
|
|
|
|||
|
|
@ -36,17 +36,17 @@ class Contact(unicode):
|
|||
class ContactList(wx.SimpleHtmlListBox, QuickContactList):
|
||||
"""Customized control to manage contacts."""
|
||||
|
||||
def __init__(self, parent, host, type="JID"):
|
||||
def __init__(self, parent, host, type_="JID"):
|
||||
"""init the contact list
|
||||
@param parent: WxWidgets parent of the widget
|
||||
@param host: wix main app class
|
||||
@param type: type of contact list: "JID" for the usual big jid contact list
|
||||
@param type_: type of contact list: "JID" for the usual big jid contact list
|
||||
"CUSTOM" for a customized contact list (self.__presentItem must then be overrided)
|
||||
"""
|
||||
wx.SimpleHtmlListBox.__init__(self, parent, -1)
|
||||
QuickContactList.__init__(self)
|
||||
self.host = host
|
||||
self.type = type
|
||||
self.type = type_
|
||||
self.__typeSwitch()
|
||||
self.groups = {} #list contacts in each groups, key = group
|
||||
self.empty_avatar = join(host.media_dir, 'misc/empty_avatar')
|
||||
|
|
@ -59,7 +59,7 @@ class ContactList(wx.SimpleHtmlListBox, QuickContactList):
|
|||
def __typeSwitch(self):
|
||||
if self.type == "JID":
|
||||
self.__presentItem = self.__presentItemJID
|
||||
elif type != "CUSTOM":
|
||||
elif type_ != "CUSTOM":
|
||||
self.__presentItem = self.__presentItemDefault
|
||||
|
||||
def __find_idx(self, entity):
|
||||
|
|
|
|||
Loading…
Reference in a new issue