diff frontends/src/primitivus/primitivus @ 1468:731fbed0b9cf

quick_frontend, primitivus: handling of actionNew signal
author Goffi <goffi@goffi.org>
date Tue, 18 Aug 2015 09:01:18 +0200
parents b06047e1c1fb
children 641cfd2faefe
line wrap: on
line diff
--- a/frontends/src/primitivus/primitivus	Tue Aug 18 09:01:18 2015 +0200
+++ b/frontends/src/primitivus/primitivus	Tue Aug 18 09:01:18 2015 +0200
@@ -280,7 +280,7 @@
 class PrimitivusApp(QuickApp, InputHistory):
 
     def __init__(self):
-        QuickApp.__init__(self, create_bridge=DBusBridgeFrontend, check_options=quick_utils.check_options)
+        QuickApp.__init__(self, create_bridge=DBusBridgeFrontend, xmlui=xmlui, check_options=quick_utils.check_options)
 
         ## main loop setup ##
         self.main_widget = ProfileManager(self)
@@ -583,6 +583,13 @@
             log.error(_('unmanaged dialog type: %s'), type_)
         self.showPopUp(popup)
 
+    def dialogFailure(self, failure):
+        """Show a failure that has been returned by an asynchronous bridge method.
+
+        @param failure (defer.Failure): Failure instance
+        """
+        self.showPopUp(sat_widgets.Alert(failure.classname, failure.message, ok_cb=self.removePopUp))
+
     def onNotification(self, notif_bar):
         """Called when a new notification has been received"""
         if not isinstance(self.main_widget, PrimitivusTopWidget):
@@ -594,43 +601,8 @@
         else:
             self.main_widget.show('notif_bar')
 
-    def launchAction(self, callback_id, data=None, callback=None, profile=C.PROF_KEY_NONE):
-        """ Launch a dynamic action
-        @param callback_id: id of the action to launch
-        @param data: data needed only for certain actions
-        @param callback: if not None and 'validated' key is present, it will be called with the following parameters:
-            - callback_id
-            - data
-            - profile
-        @param profile: %(doc_profile)s
-
-        """
-        if data is None:
-            data = dict()
-
-        def action_cb(data):
-            if not data:
-                # action was a one shot, nothing to do
-                pass
-            elif "xmlui" in data:
-                ui = xmlui.create(self, xml_data=data['xmlui'], callback=callback, profile=profile)
-                ui.show()
-            elif 'validated' in data:
-                pass # this key is managed below
-            else:
-                self.showPopUp(sat_widgets.Alert(_("Error"), _(u"Unmanaged action result"), ok_cb=self.removePopUp))
-
-            if callback and 'validated' in data:
-                callback(callback_id, data, profile)
-
-        self.bridge.launchAction(callback_id, data, profile, callback=action_cb, errback=self.showFailure)
-
-    def showFailure(self, failure):
-        """Show a failure that has been returned by an asynchronous bridge method.
-
-        @param failure (defer.Failure): Failure instance
-        """
-        self.showPopUp(sat_widgets.Alert(failure.classname, failure.message, ok_cb=self.removePopUp))
+    def _actionManagerUnknownError(self):
+        self.showPopUp(sat_widgets.Alert(_("Error"), _(u"Unmanaged action"), ok_cb=self.removePopUp))
 
     def askConfirmationHandler(self, confirmation_id, confirmation_type, data, profile):
         answer_data = {}
@@ -715,7 +687,7 @@
     def onJoinRoom(self, button, edit):
         self.removePopUp()
         room_jid = jid.JID(edit.get_edit_text())
-        self.bridge.joinMUC(room_jid, self.profiles[self.current_profile].whoami.node, {}, self.current_profile, callback=lambda dummy: None, errback=self.showFailure)
+        self.bridge.joinMUC(room_jid, self.profiles[self.current_profile].whoami.node, {}, self.current_profile, callback=lambda dummy: None, errback=self._notifyFailure)
 
     #MENU EVENTS#
     def onConnectRequest(self, menu):