primitivus: fixed alert case + alert in profileManager

This commit is contained in:
Goffi 2015-11-16 08:57:36 +01:00
commit 909a54995e
2 changed files with 12 additions and 16 deletions

View file

@ -350,7 +350,7 @@ class PrimitivusApp(QuickApp, InputHistory):
config.applyConfig(self)
except Exception as e:
log.error(u"configuration error: {}".format(e))
popup = self.Alert(_(u"Configuration Error"), _(u"Something went wrong while reading the configuration, please check :messages"))
popup = self.alert(_(u"Configuration Error"), _(u"Something went wrong while reading the configuration, please check :messages"))
if self.options.profile:
self._early_popup = popup
else:
@ -479,13 +479,13 @@ class PrimitivusApp(QuickApp, InputHistory):
else:
del self._early_popup
def Alert(self, title, message):
def alert(self, title, message):
"""Shortcut method to create an alert message
Alert will have an "OK" button, which remove it if pressed
@param title(unicode): title of the dialog
@param message(unicode): body of the dialog
@return (urwid_satext.Alert): the create Alert instance
@return (urwid_satext.Alert): the created Alert instance
"""
popup = sat_widgets.Alert(title, message)
popup.setCallback('ok', lambda dummy: self.removePopUp(popup))
@ -594,11 +594,11 @@ class PrimitivusApp(QuickApp, InputHistory):
def showDialog(self, message, title="", type_="info", answer_cb = None, answer_data = None):
if type_ == 'info':
popup = sat_widgets.Alert(title, message, ok_cb=answer_cb)
popup = sat_widgets.alert(title, message, ok_cb=answer_cb)
if answer_cb is None:
popup.setCallback('ok', lambda dummy: self.removePopUp(popup))
elif type_ == 'error':
popup = sat_widgets.Alert(title, message, ok_cb=answer_cb)
popup = sat_widgets.alert(title, message, ok_cb=answer_cb)
if answer_cb is None:
popup.setCallback('ok', lambda dummy: self.removePopUp(popup))
elif type_ == 'yes/no':
@ -606,7 +606,7 @@ class PrimitivusApp(QuickApp, InputHistory):
yes_cb=self._dialogOkCb, yes_value = (popup, answer_cb, answer_data),
no_cb=self._dialogCancelCb, no_value = (popup, answer_cb, answer_data))
else:
popup = sat_widgets.Alert(title, message, ok_cb=answer_cb)
popup = sat_widgets.alert(title, message, ok_cb=answer_cb)
if answer_cb is None:
popup.setCallback('ok', lambda dummy: self.removePopUp(popup))
log.error(u'unmanaged dialog type: {}'.format(type_))
@ -617,7 +617,7 @@ class PrimitivusApp(QuickApp, InputHistory):
@param failure (defer.Failure): Failure instance
"""
self.Alert(failure.classname, failure.message)
self.alert(failure.classname, failure.message)
def onNotification(self, notif_bar):
"""Called when a new notification has been received"""
@ -631,7 +631,7 @@ class PrimitivusApp(QuickApp, InputHistory):
self.main_widget.show('notif_bar')
def _actionManagerUnknownError(self):
self.Alert(_("Error"), _(u"Unmanaged action"))
self.alert(_("Error"), _(u"Unmanaged action"))
def askConfirmationHandler(self, confirmation_id, confirmation_type, data, profile):
answer_data = {}
@ -688,7 +688,7 @@ class PrimitivusApp(QuickApp, InputHistory):
ui.show('window')
elif type_ == "ERROR":
self.current_action_ids.remove(id)
self.Alert(_("Error"), unicode(data["message"])) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore
self.alert(_("Error"), unicode(data["message"])) #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):
@ -731,7 +731,7 @@ class PrimitivusApp(QuickApp, InputHistory):
ui.show()
def failure(error):
self.Alert(_("Error"), _("Can't get parameters (%s)") % error)
self.alert(_("Error"), _("Can't get parameters (%s)") % error)
self.bridge.getParamsUI(app=C.APP_NAME, profile_key=self.current_profile, callback=success, errback=failure)
def onExitRequest(self, menu):
@ -745,7 +745,7 @@ class PrimitivusApp(QuickApp, InputHistory):
self.showPopUp(pop_up_widget)
def onAboutRequest(self, menu):
self.Alert(_("About"), C.APP_NAME + " v" + self.bridge.getVersion())
self.alert(_("About"), C.APP_NAME + " v" + self.bridge.getVersion())
#MISC CALLBACKS#

View file

@ -101,7 +101,7 @@ class ProfileManager(QuickProfileManager, urwid.WidgetWrap):
def profileCreationFailure(self, reason):
self.host.removePopUp()
message = self._getErrorMessage(reason)
self.alert(_("Can't create profile"), message)
self.host.alert(_("Can't create profile"), message)
def deleteProfile(self, button):
self._deleteProfile()
@ -152,10 +152,6 @@ class ProfileManager(QuickProfileManager, urwid.WidgetWrap):
self.current.password = password
self.host.redraw()
def alert(self, title, message):
popup = sat_widgets.Alert(title, message, ok_cb=self.host.removePopUp)
self.host.showPopUp(popup)
def onProfileChange(self, list_wid, widget=None, selected=None):
"""This is called when a profile is selected in the profile list.