Mercurial > libervia-backend
diff frontends/src/primitivus/primitivus @ 587:952322b1d490
Remove trailing whitespaces.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 18 Jan 2013 17:55:34 +0100 |
parents | ca13633d3b6b |
children | c8b129a3c209 |
line wrap: on
line diff
--- a/frontends/src/primitivus/primitivus Fri Jan 18 17:55:27 2013 +0100 +++ b/frontends/src/primitivus/primitivus Fri Jan 18 17:55:34 2013 +0100 @@ -44,18 +44,18 @@ 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 @@ """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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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):