changeset 1609:66f0e877625b

primitivus: fixed alert case + alert in profileManager
author Goffi <goffi@goffi.org>
date Mon, 16 Nov 2015 08:57:36 +0100 (2015-11-16)
parents 05274b27e90e
children 1378ec04380f
files frontends/src/primitivus/primitivus frontends/src/primitivus/profile_manager.py
diffstat 2 files changed, 12 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/primitivus/primitivus	Mon Nov 16 08:57:02 2015 +0100
+++ b/frontends/src/primitivus/primitivus	Mon Nov 16 08:57:36 2015 +0100
@@ -350,7 +350,7 @@
             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 @@
         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 @@
 
     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 @@
                     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 @@
 
         @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 @@
             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 @@
                 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 @@
             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 @@
         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#
 
--- a/frontends/src/primitivus/profile_manager.py	Mon Nov 16 08:57:02 2015 +0100
+++ b/frontends/src/primitivus/profile_manager.py	Mon Nov 16 08:57:36 2015 +0100
@@ -101,7 +101,7 @@
     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 @@
         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.