Remove trailing whitespaces.
This commit is contained in:
parent
310e2cc347
commit
27b3592e16
10 changed files with 899 additions and 899 deletions
|
|
@ -48,9 +48,9 @@ class CardDisplayer(urwid.Text):
|
|||
self.select(not self.__selected)
|
||||
self._emit('click')
|
||||
return True
|
||||
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def select(self, state=True):
|
||||
self.__selected = state
|
||||
attr,txt = self.card.getAttrText()
|
||||
|
|
@ -183,7 +183,7 @@ class Table(urwid.FlowWidget):
|
|||
self.top = self.left = self.bottom = self.right = None
|
||||
setattr(self, location, card)
|
||||
self._invalidate()
|
||||
|
||||
|
||||
def rows(self,size,focus=False):
|
||||
return self.display_widget(size, focus).rows(size, focus)
|
||||
|
||||
|
|
@ -203,11 +203,11 @@ class Table(urwid.FlowWidget):
|
|||
urwid.Text([margin_center,cards['left'],separator,cards['right']]),
|
||||
urwid.Text([margin,cards['bottom']])]
|
||||
return urwid.Pile(render_wid)
|
||||
|
||||
|
||||
|
||||
class CardGame(QuickCardGame,urwid.WidgetWrap):
|
||||
"""Widget for card games"""
|
||||
|
||||
|
||||
def __init__(self, parent, referee, players, player_nick):
|
||||
QuickCardGame.__init__(self, parent, referee, players, player_nick)
|
||||
self.loadCards()
|
||||
|
|
@ -248,13 +248,13 @@ class CardGame(QuickCardGame,urwid.WidgetWrap):
|
|||
QuickCardGame.newGame(self, hand)
|
||||
self.hand_wid.update(self.hand)
|
||||
self.parent.host.redraw()
|
||||
|
||||
|
||||
def contratSelected(self, data):
|
||||
"""Called when the contrat has been choosed
|
||||
@param data: form result"""
|
||||
contrat = data[0][1]
|
||||
QuickCardGame.contratSelected(self, contrat)
|
||||
|
||||
|
||||
def chooseContrat(self, xml_data):
|
||||
"""Called when the player as to select his contrat
|
||||
@param xml_data: SàT xml representation of the form"""
|
||||
|
|
@ -297,14 +297,14 @@ class CardGame(QuickCardGame,urwid.WidgetWrap):
|
|||
if self._autoplay==None: #No dialog if there is autoplay
|
||||
self.parent.host.notify(_('Cards played are invalid !'))
|
||||
self.parent.host.redraw()
|
||||
|
||||
|
||||
def cardsPlayed(self, player, cards):
|
||||
"""A card has been played by player"""
|
||||
QuickCardGame.cardsPlayed(self, player, cards)
|
||||
self.table.putCard(self.getPlayerLocation(player),self.played[player])
|
||||
self._checkState()
|
||||
self.parent.host.redraw()
|
||||
|
||||
|
||||
def _checkState(self):
|
||||
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
|
||||
|
|
@ -317,7 +317,7 @@ class CardGame(QuickCardGame,urwid.WidgetWrap):
|
|||
self.hand.sort()
|
||||
self.to_show = []
|
||||
self.hand_wid.update(self.hand)
|
||||
|
||||
|
||||
|
||||
##EVENTS##
|
||||
def onClick(self, hand, card_wid):
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ from sat.tools.jid import JID
|
|||
|
||||
class ChatText(urwid.FlowWidget):
|
||||
"""Manage the printing of chat message"""
|
||||
|
||||
|
||||
def __init__(self, parent, timestamp, nick, my_mess, message, align='left', is_info=False):
|
||||
self.parent = parent
|
||||
self.timestamp = time.localtime(timestamp)
|
||||
|
|
@ -124,8 +124,8 @@ class Chat(urwid.WidgetWrap, QuickChat):
|
|||
self._invalidate()
|
||||
|
||||
|
||||
return super(Chat, self).keypress(size, key)
|
||||
|
||||
return super(Chat, self).keypress(size, key)
|
||||
|
||||
def getMenu(self):
|
||||
"""Return Menu bar"""
|
||||
menu = sat_widgets.Menu(self.host.loop)
|
||||
|
|
@ -145,7 +145,7 @@ class Chat(urwid.WidgetWrap, QuickChat):
|
|||
present_widget = self.__buildPresentList()
|
||||
self.present_panel = sat_widgets.VerticalSeparator(present_widget)
|
||||
self.__appendPresentPanel()
|
||||
|
||||
|
||||
def __getDecoration(self, widget):
|
||||
return sat_widgets.LabelLine(widget, sat_widgets.SurroundedText(unicode(unescapePrivate(self.target))))
|
||||
|
||||
|
|
@ -175,16 +175,16 @@ class Chat(urwid.WidgetWrap, QuickChat):
|
|||
def __buildPresentList(self):
|
||||
self.present_wid = sat_widgets.GenericList([],option_type = sat_widgets.ClickableText, on_click=self._presentClicked)
|
||||
return self.present_wid
|
||||
|
||||
|
||||
def __appendPresentPanel(self):
|
||||
self.chat_colums.widget_list.append(self.present_panel)
|
||||
self.chat_colums.widget_list.append(self.present_panel)
|
||||
self.chat_colums.column_types.append(('weight', 2))
|
||||
|
||||
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]
|
||||
|
||||
|
||||
def __appendGamePanel(self, widget):
|
||||
assert (len(self.pile.widget_list) == 1)
|
||||
self.pile.widget_list.insert(0,widget)
|
||||
|
|
@ -245,13 +245,13 @@ class Chat(urwid.WidgetWrap, QuickChat):
|
|||
return
|
||||
|
||||
new_text = ChatText(self, timestamp or None, nick, mymess, msg)
|
||||
|
||||
|
||||
if timestamp and self.content:
|
||||
for idx in range(len(self.content)-1,-1,-1):
|
||||
current_text = self.content[idx]
|
||||
if new_text.timestamp < current_text.timestamp and idx > 0:
|
||||
continue #the new message is older, we need to insert it upper
|
||||
|
||||
|
||||
#we discard double messages, to avoid backlog / history conflict
|
||||
if ((idx and self.content[idx-1].message == msg) or
|
||||
(self.content[idx].message == msg) or
|
||||
|
|
@ -262,7 +262,7 @@ class Chat(urwid.WidgetWrap, QuickChat):
|
|||
break
|
||||
else:
|
||||
self.content.append(new_text)
|
||||
|
||||
|
||||
if self.text_list.get_focus()[1] == len(self.content)-2:
|
||||
#we don't change focus if user is not at the bottom
|
||||
#as that mean that he is probably watching discussion history
|
||||
|
|
@ -271,9 +271,9 @@ class Chat(urwid.WidgetWrap, QuickChat):
|
|||
if not self.host.x_notify.hasFocus():
|
||||
if self.type=="one2one":
|
||||
self.host.x_notify.sendNotification(_("Primitivus: %s is talking to you") % from_jid)
|
||||
elif self.getUserNick().lower() in msg.lower():
|
||||
elif self.getUserNick().lower() in msg.lower():
|
||||
self.host.x_notify.sendNotification(_("Primitivus: Somebody pinged your name in %s room") % self.target)
|
||||
|
||||
|
||||
def printInfo(self, msg, type='normal', timestamp=""):
|
||||
"""Print general info
|
||||
@param msg: message to print
|
||||
|
|
@ -292,28 +292,28 @@ class Chat(urwid.WidgetWrap, QuickChat):
|
|||
if not self.host.x_notify.hasFocus():
|
||||
if self.type=="one2one":
|
||||
self.host.x_notify.sendNotification(_("Primitivus: there is a message about you"))
|
||||
elif self.getUserNick().lower() in msg.lower():
|
||||
elif self.getUserNick().lower() in msg.lower():
|
||||
self.host.x_notify.sendNotification(_("Primitivus: Somebody is talking about you in %s room") % self.target)
|
||||
|
||||
|
||||
def startGame(self, game_type, referee, players):
|
||||
"""Configure the chat window to start a game"""
|
||||
if game_type=="Tarot":
|
||||
self.tarot_wid = CardGame(self, referee, players, self.nick)
|
||||
self.__appendGamePanel(self.tarot_wid)
|
||||
|
||||
|
||||
def getGame(self, game_type):
|
||||
"""Return class managing the game type"""
|
||||
#TODO: check that the game is launched, and manage errors
|
||||
if game_type=="Tarot":
|
||||
return self.tarot_wid
|
||||
return self.tarot_wid
|
||||
|
||||
#MENU EVENTS#
|
||||
def onTarotRequest(self, menu):
|
||||
if len(self.occupants) != 4:
|
||||
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))
|
||||
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)
|
||||
|
||||
|
||||
def onSendFileRequest(self, menu):
|
||||
dialog = FileDialog(ok_cb=self.onFileSelected, cancel_cb=self.host.removePopUp)
|
||||
self.host.showPopUp(dialog, 80, 80)
|
||||
|
|
@ -328,4 +328,4 @@ class Chat(urwid.WidgetWrap, QuickChat):
|
|||
else:
|
||||
full_jid = self.target
|
||||
progress_id = self.host.bridge.sendFile(full_jid, filepath, {}, self.host.profile)
|
||||
self.host.addProgress(progress_id,filepath)
|
||||
self.host.addProgress(progress_id,filepath)
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ __builtin__.__dict__['const_PALETTE'] = [
|
|||
('status', 'yellow', 'default'),
|
||||
('status_focus', 'yellow, bold', 'default'),
|
||||
]
|
||||
__builtin__.__dict__['const_SHOW_ICON'] = {"unavailable": (u'⨯', "show_disconnected"),
|
||||
__builtin__.__dict__['const_SHOW_ICON'] = {"unavailable": (u'⨯', "show_disconnected"),
|
||||
"": (u'✔', "show_normal"),
|
||||
"chat": (u'✆', "show_chat"),
|
||||
"away": (u'✈', "show_away"),
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
self.alert_jid=set()
|
||||
self.show_status = False
|
||||
self.show_disconnected = False
|
||||
|
||||
|
||||
#we now build the widget
|
||||
self.frame = urwid.Frame(self.__buildList())
|
||||
self.main_widget = sat_widgets.LabelLine(self.frame, sat_widgets.SurroundedText(_("Contacts")))
|
||||
|
|
@ -65,8 +65,8 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
elif key == "meta d": #user wants to (un)hide disconnected contacts
|
||||
self.show_disconnected = not self.show_disconnected
|
||||
self.update()
|
||||
return super(ContactList, self).keypress(size, key)
|
||||
|
||||
return super(ContactList, self).keypress(size, key)
|
||||
|
||||
def __contains__(self, jid):
|
||||
for group in self.groups:
|
||||
if jid.short in self.groups[group][1]:
|
||||
|
|
@ -116,9 +116,9 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
@param content: widget list, e.g. SimpleListWalker
|
||||
@param contacts: list of JID"""
|
||||
contacts = list(param_contacts)
|
||||
|
||||
|
||||
widgets = [] #list of built widgets
|
||||
|
||||
|
||||
for contact in contacts:
|
||||
if contact.startswith(const_PRIVATE_PREFIX):
|
||||
contact_disp = ('alert' if contact in self.alert_jid else "show_normal", unescapePrivate(contact))
|
||||
|
|
@ -148,7 +148,7 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
widget.data = contact
|
||||
widget.comp = contact_disp[1].lower() #value to use for sorting
|
||||
widgets.append(widget)
|
||||
|
||||
|
||||
widgets.sort(key=lambda widget: widget.comp)
|
||||
|
||||
for widget in widgets:
|
||||
|
|
@ -160,7 +160,7 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
specials = self.specials.keys()
|
||||
specials.sort()
|
||||
for special in specials:
|
||||
jid=JID(special)
|
||||
jid=JID(special)
|
||||
name = self.getCache(jid, 'name')
|
||||
nick = self.getCache(jid, 'nick')
|
||||
special_disp = ('alert' if special in self.alert_jid else 'default', nick or name or jid.node or jid.short)
|
||||
|
|
@ -176,7 +176,7 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
def __buildList(self):
|
||||
"""Build the main contact list widget"""
|
||||
content = urwid.SimpleListWalker([])
|
||||
|
||||
|
||||
self.__buildSpecials(content)
|
||||
if self.specials:
|
||||
content.append(urwid.Divider('='))
|
||||
|
|
@ -205,7 +205,7 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
def getContact(self):
|
||||
"""Return contact currently selected"""
|
||||
return self.selected
|
||||
|
||||
|
||||
def clearContacts(self):
|
||||
"""clear all the contact list"""
|
||||
QuickContactList.clearContacts(self)
|
||||
|
|
@ -238,7 +238,7 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
contacts.sort()
|
||||
self.list_wid.changeValues(contacts)
|
||||
self._emit('change')"""
|
||||
|
||||
|
||||
def remove(self, jid):
|
||||
"""remove a contact from the list"""
|
||||
QuickContactList.remove(self, jid)
|
||||
|
|
@ -252,7 +252,7 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
for group in groups_to_remove:
|
||||
del self.groups[group]
|
||||
self.update()
|
||||
|
||||
|
||||
def add(self, jid, param_groups=[None]):
|
||||
"""add a contact to the list"""
|
||||
self.replace(jid,param_groups)
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class GatewaysManager(urwid.WidgetWrap, QuickGatewaysManager):
|
|||
list_wid = urwid.ListBox(widget_list)
|
||||
decorated = sat_widgets.LabelLine(list_wid, sat_widgets.SurroundedText(title))
|
||||
urwid.WidgetWrap.__init__(self, decorated)
|
||||
|
||||
|
||||
def browseExternalServer(self, button):
|
||||
"""Open the gateway manager on given server"""
|
||||
server = self.ext_serv.get_edit_text()
|
||||
|
|
@ -58,15 +58,15 @@ class GatewaysManager(urwid.WidgetWrap, QuickGatewaysManager):
|
|||
self.host.removeWindow()
|
||||
|
||||
def addGateway(self, widget_list, gateway, param):
|
||||
|
||||
|
||||
widget_col = []
|
||||
widget_col.append(('weight',4,urwid.Text(unicode(param['name'])))) #FIXME: unicode to be remove when DBus bridge will not give dbus.String anymore
|
||||
|
||||
|
||||
#Then the transport type message
|
||||
widget_col.append(('weight',6,urwid.Text(self.getGatewayDesc(param['type']))))
|
||||
|
||||
#The buttons
|
||||
|
||||
|
||||
reg_button = sat_widgets.CustomButton( _("Register"), self.onRegister)
|
||||
reg_button.gateway_jid = JID(gateway)
|
||||
widget_col.append(('fixed',reg_button.getSize(),reg_button))
|
||||
|
|
@ -74,7 +74,7 @@ class GatewaysManager(urwid.WidgetWrap, QuickGatewaysManager):
|
|||
unreg_button.gateway_jid = JID(gateway)
|
||||
widget_col.append(('fixed',unreg_button.getSize(),unreg_button))
|
||||
widget_list.append(urwid.Columns(widget_col,1))
|
||||
|
||||
|
||||
def onRegister(self, button):
|
||||
"""Called when register button is clicked"""
|
||||
gateway_jid = button.gateway_jid
|
||||
|
|
|
|||
|
|
@ -23,13 +23,13 @@ import dbus
|
|||
|
||||
class Notify:
|
||||
"""Used to send notification and detect if we have focus"""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
|
||||
#X11 stuff
|
||||
self.display = None
|
||||
self.X11_id = -1
|
||||
|
||||
|
||||
try:
|
||||
from Xlib import display as X_display
|
||||
self.display = X_display.Display()
|
||||
|
|
@ -44,7 +44,7 @@ class Notify:
|
|||
self.freedesktop_int = dbus.Interface(db_object, dbus_interface='org.freedesktop.Notifications')
|
||||
except:
|
||||
self.freedesktop_int = None
|
||||
|
||||
|
||||
|
||||
def getFocus(self):
|
||||
if not self.display:
|
||||
|
|
@ -62,15 +62,15 @@ class Notify:
|
|||
#TODO: check options before sending notifications
|
||||
if self.freedesktop_int:
|
||||
self.sendFDNotification(summ_mess, body_mess)
|
||||
|
||||
|
||||
def sendFDNotification(self, summ_mess, body_mess=""):
|
||||
"""Send notification with the FreeDesktop D-Bus API"""
|
||||
if self.freedesktop_int:
|
||||
app_name = "Primitivus"
|
||||
app_name = "Primitivus"
|
||||
replaces_id = 0
|
||||
app_icon = ""
|
||||
summary = summ_mess
|
||||
body = body_mess
|
||||
body = body_mess
|
||||
actions = dbus.Array(signature='s')
|
||||
hints = dbus.Dictionary(signature='sv')
|
||||
expire_timeout = -1
|
||||
|
|
|
|||
|
|
@ -44,18 +44,18 @@ from os.path import join
|
|||
logging.basicConfig(level=logging.CRITICAL, #TODO: configure it to put messages in a log file
|
||||
format='%(message)s')
|
||||
###
|
||||
|
||||
|
||||
class ChatList(QuickChatList):
|
||||
"""This class manage the list of chat windows"""
|
||||
|
||||
|
||||
def createChat(self, target):
|
||||
return Chat(target, self.host)
|
||||
|
||||
class PrimitivusApp(QuickApp):
|
||||
|
||||
|
||||
def __init__(self):
|
||||
QuickApp.__init__(self)
|
||||
|
||||
|
||||
## main loop setup ##
|
||||
self.main_widget = ProfileManager(self)
|
||||
self.loop = urwid.MainLoop(self.main_widget, const_PALETTE, event_loop=urwid.GLibEventLoop(), input_filter=self.inputFilter, unhandled_input=self.keyHandler)
|
||||
|
|
@ -82,7 +82,7 @@ class PrimitivusApp(QuickApp):
|
|||
"""Change mode if make sens (i.e.: if there is nothing in the editBar"""
|
||||
if not self.editBar.get_edit_text():
|
||||
self.mode = value
|
||||
|
||||
|
||||
def debug(self):
|
||||
"""convenient method to reset screen and launch p(u)db"""
|
||||
try:
|
||||
|
|
@ -209,9 +209,9 @@ class PrimitivusApp(QuickApp):
|
|||
category,item,type = new_menu
|
||||
assert(type=="NORMAL") #TODO: manage other types
|
||||
menu.addMenu(unicode(category), unicode(item), add_menu_cb)
|
||||
|
||||
|
||||
menu_roller = sat_widgets.MenuRoller([(_('Main menu'),menu)])
|
||||
return menu_roller
|
||||
return menu_roller
|
||||
|
||||
def __buildMainWidget(self):
|
||||
self.contact_list = ContactList(self, on_click = self.contactSelected, on_change=lambda w: self.redraw())
|
||||
|
|
@ -257,14 +257,14 @@ class PrimitivusApp(QuickApp):
|
|||
completion_data['last_nick'] = nicks[idx]
|
||||
return text[:space+1] + nicks[idx] + (': ' if space < 0 else '')
|
||||
return text
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def plug_profile(self, profile_key='@DEFAULT@'):
|
||||
self.loop.widget = self.__buildMainWidget()
|
||||
self.redraw()
|
||||
QuickApp.plug_profile(self, profile_key)
|
||||
|
||||
|
||||
def removePopUp(self, widget=None):
|
||||
"Remove current pop-up, and if there is other in queue, show it"
|
||||
self.loop.widget = self.main_widget
|
||||
|
|
@ -305,7 +305,7 @@ class PrimitivusApp(QuickApp):
|
|||
self.center_part.widget_list[wid_idx] = urwid.Filler(urwid.Text(''))
|
||||
self.center_part.set_focus(0)
|
||||
self.redraw()
|
||||
|
||||
|
||||
def addProgress (self, id, message):
|
||||
"""Follow a SàT progress bar
|
||||
@param id: SàT id of the progression
|
||||
|
|
@ -342,13 +342,13 @@ class PrimitivusApp(QuickApp):
|
|||
|
||||
def newMessage(self, from_jid, to_jid, msg, _type, extra, profile):
|
||||
QuickApp.newMessage(self, from_jid, to_jid, msg, _type, extra, profile)
|
||||
|
||||
|
||||
if not from_jid in self.contact_list and from_jid.short != self.profiles[profile]['whoami'].short:
|
||||
#XXX: needed to show entities which haven't sent any
|
||||
# presence information and which are not in roster
|
||||
#TODO: put these entities in a "not in roster" list
|
||||
self.contact_list.replace(from_jid)
|
||||
|
||||
|
||||
if JID(self.contact_list.selected).short != from_jid.short:
|
||||
self.contact_list.putAlert(from_jid)
|
||||
|
||||
|
|
@ -363,22 +363,22 @@ class PrimitivusApp(QuickApp):
|
|||
answer_cb = data[0]
|
||||
answer_data = [data[1]] if data[1] else []
|
||||
answer_cb(False, *answer_data)
|
||||
|
||||
|
||||
|
||||
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
|
||||
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':
|
||||
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
|
||||
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':
|
||||
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
|
||||
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)
|
||||
self.showPopUp(popup)
|
||||
|
||||
|
||||
def onNotification(self, notBar):
|
||||
"""Called when a new notification has been received"""
|
||||
if not isinstance(self.main_widget, sat_widgets.FocusFrame):
|
||||
|
|
@ -401,26 +401,26 @@ class PrimitivusApp(QuickApp):
|
|||
if not self.check_profile(profile):
|
||||
return
|
||||
answer_data={}
|
||||
|
||||
|
||||
def dir_selected_cb(path):
|
||||
dest_path = join(path, data['filename'])
|
||||
answer_data["dest_path"] = getNewPath(dest_path)
|
||||
self.addProgress(confirmation_id, dest_path)
|
||||
answer_data["dest_path"] = getNewPath(dest_path)
|
||||
self.addProgress(confirmation_id, dest_path)
|
||||
accept_cb(None)
|
||||
|
||||
def accept_file_transfer_cb(widget):
|
||||
self.removePopUp()
|
||||
pop_up_widget = FileDialog(dir_selected_cb, refuse_cb, title=_(u"Where do you want to save the file ?"), style=['dir'])
|
||||
pop_up_widget = FileDialog(dir_selected_cb, refuse_cb, title=_(u"Where do you want to save the file ?"), style=['dir'])
|
||||
self.showPopUp(pop_up_widget)
|
||||
|
||||
def accept_cb(widget):
|
||||
self.removePopUp()
|
||||
self.bridge.confirmationAnswer(confirmation_id, True, answer_data, profile)
|
||||
|
||||
|
||||
def refuse_cb(widget):
|
||||
self.removePopUp()
|
||||
self.bridge.confirmationAnswer(confirmation_id, False, answer_data, profile)
|
||||
|
||||
|
||||
if confirmation_type == "FILE_TRANSFER":
|
||||
pop_up_widget = sat_widgets.ConfirmDialog(_("The contact %(jid)s wants to send you the file %(filename)s\nDo you accept ?") % {'jid':data["from"], 'filename':data["filename"]}, no_cb=refuse_cb, yes_cb=accept_file_transfer_cb)
|
||||
self.showPopUp(pop_up_widget)
|
||||
|
|
@ -432,7 +432,7 @@ class PrimitivusApp(QuickApp):
|
|||
def actionResult(self, type, id, data, profile):
|
||||
if not self.check_profile(profile):
|
||||
return
|
||||
|
||||
|
||||
if not id in self.current_action_ids:
|
||||
debug (_('unknown id, ignoring'))
|
||||
return
|
||||
|
|
@ -455,7 +455,7 @@ class PrimitivusApp(QuickApp):
|
|||
ui.show('window')
|
||||
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
|
||||
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":
|
||||
self.current_action_ids.remove(id)
|
||||
if self.current_action_ids_cb.has_key(id):
|
||||
|
|
@ -481,7 +481,7 @@ class PrimitivusApp(QuickApp):
|
|||
else:
|
||||
message = _("'%s' is an invalid JID !") % room_jid
|
||||
error (message)
|
||||
self.showPopUp(sat_widgets.Alert(_("Error"), message, ok_cb=self.removePopUp))
|
||||
self.showPopUp(sat_widgets.Alert(_("Error"), message, ok_cb=self.removePopUp))
|
||||
|
||||
def onAddContact(self, button, edit):
|
||||
self.removePopUp()
|
||||
|
|
@ -511,7 +511,7 @@ class PrimitivusApp(QuickApp):
|
|||
def failure(error):
|
||||
self.showPopUp(sat_widgets.Alert(_("Error"), _("Can't get parameters"), ok_cb=self.removePopUp))
|
||||
self.bridge.getParamsUI(self.profile, callback=success, errback=failure)
|
||||
|
||||
|
||||
|
||||
def onExitRequest(self, menu):
|
||||
QuickApp.onExit(self)
|
||||
|
|
@ -541,8 +541,8 @@ class PrimitivusApp(QuickApp):
|
|||
self.showPopUp(pop_up_widget)
|
||||
|
||||
def onAboutRequest(self, menu):
|
||||
self.showPopUp(sat_widgets.Alert(_("About"), const_APP_NAME + " v" + self.bridge.getVersion(), ok_cb=self.removePopUp))
|
||||
|
||||
self.showPopUp(sat_widgets.Alert(_("About"), const_APP_NAME + " v" + self.bridge.getVersion(), ok_cb=self.removePopUp))
|
||||
|
||||
#MISC CALLBACKS#
|
||||
|
||||
def onGatewaysFound(self, data):
|
||||
|
|
|
|||
|
|
@ -31,11 +31,11 @@ class ProfileManager(urwid.WidgetWrap):
|
|||
#profiles list
|
||||
profiles = self.host.bridge.getProfilesList()
|
||||
profiles.sort()
|
||||
|
||||
|
||||
#login & password box must be created before list because of onProfileChange
|
||||
self.login_wid = AdvancedEdit(_('Login:'),align='center')
|
||||
self.pass_wid = Password(_('Password:'),align='center')
|
||||
|
||||
|
||||
self.list_profile = List(profiles, style=['single'], align='center', on_change=self.onProfileChange)
|
||||
|
||||
#new & delete buttons
|
||||
|
|
@ -96,7 +96,7 @@ class ProfileManager(urwid.WidgetWrap):
|
|||
self.host.bridge.deleteProfile(profile_name)
|
||||
self.__refillProfiles()
|
||||
self.host.removePopUp()
|
||||
|
||||
|
||||
def onNewProfile(self, e):
|
||||
pop_up_widget = InputDialog(_("New profile"), _("Please enter a new profile name"), cancel_cb=self.cancelDialog, ok_cb=self.newProfile)
|
||||
self.host.showPopUp(pop_up_widget)
|
||||
|
|
@ -117,7 +117,7 @@ class ProfileManager(urwid.WidgetWrap):
|
|||
if profile_name:
|
||||
self.host.bridge.asyncGetParamA("JabberID", "Connection", profile_key=profile_name, callback=setJID, errback=self.getParamError)
|
||||
self.host.bridge.asyncGetParamA("Password", "Connection", profile_key=profile_name, callback=setPassword, errback=self.getParamError)
|
||||
|
||||
|
||||
def onConnectProfile(self, button):
|
||||
profile_name = self.list_profile.getSelectedValue()
|
||||
if not profile_name:
|
||||
|
|
@ -136,7 +136,7 @@ class ProfileManager(urwid.WidgetWrap):
|
|||
def __old_jidReceived(self, old_jid, profile):
|
||||
self.host.bridge.asyncGetParamA("Password", "Connection", profile_key=profile,
|
||||
callback=lambda old_pass: self.__old_passReceived(old_jid, old_pass, profile), errback=self.getParamError)
|
||||
|
||||
|
||||
def __old_passReceived(self, old_jid, old_pass, profile):
|
||||
"""Check if we have new jid/pass, save them if it is the case, and plug profile"""
|
||||
new_jid = self.login_wid.get_edit_text()
|
||||
|
|
@ -148,7 +148,7 @@ class ProfileManager(urwid.WidgetWrap):
|
|||
if old_pass != new_pass:
|
||||
self.host.bridge.setParam("Password", new_pass, "Connection", profile)
|
||||
self.host.plug_profile(profile)
|
||||
|
||||
|
||||
def getParamError(self, ignore):
|
||||
popup = Alert("Error", _("Can't get profile parameter"), ok_cb=self.host.removePopUp)
|
||||
self.host.showPopUp(popup)
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class Progress(urwid.WidgetWrap):
|
|||
#first answer, we must construct the bar
|
||||
self.progress_dict[(progress_id, profile)]['state'] = 'progress'
|
||||
pbar.done = float(data['size'])
|
||||
|
||||
|
||||
pbar.set_completion(float(data['position']))
|
||||
self.updateNotBar()
|
||||
else:
|
||||
|
|
@ -93,4 +93,4 @@ class Progress(urwid.WidgetWrap):
|
|||
nb_bars+=1
|
||||
av_progress = progress/float(nb_bars)
|
||||
self.host.setProgress(av_progress)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -44,12 +44,12 @@ class Pairs(urwid.WidgetWrap):
|
|||
pile.widget_list.append(widget)
|
||||
pile.item_types.append(('weight',getattr(self,'weight_'+str(self.idx))))
|
||||
self.idx = (self.idx + 1) % 2
|
||||
|
||||
|
||||
class InvalidXMLUI(Exception):
|
||||
pass
|
||||
|
||||
class XMLUI(urwid.WidgetWrap):
|
||||
|
||||
|
||||
def __init__(self, host, xml_data, title = None, options = None, misc = None):
|
||||
self.host = host
|
||||
self.title = title
|
||||
|
|
@ -72,7 +72,7 @@ class XMLUI(urwid.WidgetWrap):
|
|||
type = elem.getAttribute("type")
|
||||
value = elem.getAttribute("value") if elem.hasAttribute('value') else u''
|
||||
if type=="empty":
|
||||
ctrl = urwid.Text('')
|
||||
ctrl = urwid.Text('')
|
||||
elif type=="text":
|
||||
try:
|
||||
value = elem.childNodes[0].wholeText
|
||||
|
|
@ -135,10 +135,10 @@ class XMLUI(urwid.WidgetWrap):
|
|||
warning(_("Unknown layout, using default one"))
|
||||
self.__parseElems(node, current)
|
||||
elif node.nodeName == "category":
|
||||
name = node.getAttribute('name')
|
||||
label = node.getAttribute('label')
|
||||
name = node.getAttribute('name')
|
||||
label = node.getAttribute('label')
|
||||
if not name or not isinstance(data,sat_widgets.TabsContainer):
|
||||
raise InvalidXMLUI
|
||||
raise InvalidXMLUI
|
||||
if self.type == 'param':
|
||||
self._current_category = name #XXX: awful hack because params need category and we don't keep parent
|
||||
tab_cont = data
|
||||
|
|
@ -150,9 +150,9 @@ class XMLUI(urwid.WidgetWrap):
|
|||
raise NotImplementedError
|
||||
|
||||
def constructUI(self, xml_data):
|
||||
|
||||
|
||||
ret_wid = urwid.ListBox(urwid.SimpleListWalker([]))
|
||||
|
||||
|
||||
cat_dom = minidom.parseString(xml_data.encode('utf-8'))
|
||||
top=cat_dom.documentElement
|
||||
self.type = top.getAttribute("type")
|
||||
|
|
@ -166,11 +166,11 @@ class XMLUI(urwid.WidgetWrap):
|
|||
self.__parseChilds(ret_wid.body, cat_dom.documentElement)
|
||||
|
||||
assert ret_wid.body
|
||||
|
||||
|
||||
if isinstance(ret_wid.body[0],sat_widgets.TabsContainer):
|
||||
ret_wid = ret_wid.body[0] #xxx: awfull hack cause TabsContainer is a BoxWidget, can't be inside a ListBox
|
||||
|
||||
|
||||
|
||||
|
||||
if self.type == 'form':
|
||||
buttons = []
|
||||
buttons.append(urwid.Button(_('Submit'),self.onFormSubmitted))
|
||||
|
|
@ -195,7 +195,7 @@ class XMLUI(urwid.WidgetWrap):
|
|||
- popup
|
||||
- window"""
|
||||
self.__dest = "popup"
|
||||
decorated = sat_widgets.LabelLine(self, sat_widgets.SurroundedText(self.title or ''))
|
||||
decorated = sat_widgets.LabelLine(self, sat_widgets.SurroundedText(self.title or ''))
|
||||
if show_type == 'popup':
|
||||
self.host.showPopUp(decorated)
|
||||
elif show_type == 'window':
|
||||
|
|
@ -244,7 +244,7 @@ class XMLUI(urwid.WidgetWrap):
|
|||
else:
|
||||
warning (_("The form data is not sent back, the type is not managed properly"))
|
||||
self.host.removePopUp()
|
||||
|
||||
|
||||
def onFormCancelled(self, button):
|
||||
if self.__dest == 'window':
|
||||
self.host.removeWindow()
|
||||
|
|
|
|||
Loading…
Reference in a new issue