changeset 1365:ba87b940f07a frontends_multi_profiles

core, quick_frontends: added an "extra" item in getMenus + use of new quick_menus module in QuickApp
author Goffi <goffi@goffi.org>
date Tue, 17 Mar 2015 19:33:05 +0100
parents 28f0b33ca17c
children 584d45bb36d9
files frontends/src/primitivus/primitivus frontends/src/quick_frontend/quick_app.py frontends/src/quick_frontend/quick_chat.py src/bridge/DBus.py src/bridge/bridge_constructor/bridge_template.ini src/core/sat_main.py
diffstat 6 files changed, 15 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/primitivus/primitivus	Tue Mar 17 19:33:05 2015 +0100
+++ b/frontends/src/primitivus/primitivus	Tue Mar 17 19:33:05 2015 +0100
@@ -425,7 +425,7 @@
         """
         def add_menu_cb(callback_id):
             self.launchAction(callback_id, menu_data, profile=self.current_profile)
-        for id_, type_, path, path_i18n  in self.bridge.getMenus("", C.NO_SECURITY_LIMIT ):
+        for id_, type_, path, path_i18n, extra  in self.bridge.getMenus("", C.NO_SECURITY_LIMIT ): # TODO: manage extra
             if type_ != type_filter:
                 continue
             if len(path) != 2:
--- a/frontends/src/quick_frontend/quick_app.py	Tue Mar 17 19:33:05 2015 +0100
+++ b/frontends/src/quick_frontend/quick_app.py	Tue Mar 17 19:33:05 2015 +0100
@@ -25,7 +25,8 @@
 from sat.tools.misc import TriggerManager
 
 from sat_frontends.tools import jid
-from sat_frontends.quick_frontend.quick_widgets import QuickWidgetsManager
+from sat_frontends.quick_frontend import quick_widgets
+from sat_frontends.quick_frontend import quick_menus
 from sat_frontends.quick_frontend import quick_chat, quick_games
 from sat_frontends.quick_frontend.constants import Const as C
 
@@ -203,12 +204,13 @@
         @param create_bridge: method to use to create the Bridge
         @param check_options: method to call to check options (usually command line arguments)
         """
+        self.menus = quick_menus.QuickMenusManager(self)
         ProfileManager.host = self
         self.profiles = ProfilesManager()
         self.ready_profiles = set() # profiles which are connected and ready
         self.signals_cache = {} # used to keep signal received between start of plug_profile and when the profile is actualy ready
         self.contact_lists = {}
-        self.widgets = QuickWidgetsManager(self)
+        self.widgets = quick_widgets.QuickWidgetsManager(self)
         if check_options is not None:
             self.options = check_options()
         else:
@@ -656,7 +658,7 @@
     def actionResultHandler(self, type, id, data, profile):
         raise NotImplementedError
 
-    def launchAction(self, callback_id, data=None, callback=None, profile="@NONE@"):
+    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
--- a/frontends/src/quick_frontend/quick_chat.py	Tue Mar 17 19:33:05 2015 +0100
+++ b/frontends/src/quick_frontend/quick_chat.py	Tue Mar 17 19:33:05 2015 +0100
@@ -38,7 +38,6 @@
         """
         @param type_: can be C.CHAT_ONE2ONE for single conversation or C.CHAT_GROUP for chat à la IRC
         """
-
         quick_widgets.QuickWidget.__init__(self, host, target, profiles=profiles)
         assert type_ in (C.CHAT_ONE2ONE, C.CHAT_GROUP)
         if type_ == C.CHAT_GROUP and target.resource:
--- a/src/bridge/DBus.py	Tue Mar 17 19:33:05 2015 +0100
+++ b/src/bridge/DBus.py	Tue Mar 17 19:33:05 2015 +0100
@@ -301,7 +301,7 @@
         return self._callback("getMenuHelp", unicode(menu_id), unicode(language))
 
     @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
-                         in_signature='si', out_signature='a(ssasas)',
+                         in_signature='si', out_signature='a(ssasasa{ss})',
                          async_callbacks=None)
     def getMenus(self, language, security_limit):
         return self._callback("getMenus", unicode(language), security_limit)
--- a/src/bridge/bridge_constructor/bridge_template.ini	Tue Mar 17 19:33:05 2015 +0100
+++ b/src/bridge/bridge_constructor/bridge_template.ini	Tue Mar 17 19:33:05 2015 +0100
@@ -586,7 +586,7 @@
 type=method
 category=core
 sig_in=si
-sig_out=a(ssasas)
+sig_out=a(ssasasa{ss})
 doc=Get all additional menus
 doc_param_0=language: language in which the menu should be translated (empty string for default)
 doc_param_1=security_limit: %(doc_security_limit)s
@@ -596,6 +596,7 @@
     * NORMAL: Classical application menu
  - menu_path: raw path of the menu
  - menu_path_i18n: translated path of the menu
+ - extra: extra data, like icon name
 
 [getMenuHelp]
 type=method
--- a/src/core/sat_main.py	Tue Mar 17 19:33:05 2015 +0100
+++ b/src/core/sat_main.py	Tue Mar 17 19:33:05 2015 +0100
@@ -858,6 +858,7 @@
 
     def getMenus(self, language='', security_limit=C.NO_SECURITY_LIMIT):
         """Return all menus registered
+
         @param language: language used for translation, or empty string for default
         @param security_limit: %(doc_security_limit)s
         @return: array of tuple with:
@@ -865,7 +866,9 @@
             - menu type
             - raw menu path (array of strings)
             - translated menu path
-
+            - extra (dict(unicode, unicode)): extra data where key can be:
+                - icon: name of the icon to use (TODO)
+                - help_url: link to a page with more complete documentation (TODO)
         """
         ret = []
         for menu_id, menu_data in self._menus.iteritems():
@@ -877,7 +880,8 @@
             languageSwitch(language)
             path_i18n = [_(elt) for elt in path]
             languageSwitch()
-            ret.append((menu_id, type_, path, path_i18n))
+            extra = {} # TODO: manage extra data like icon
+            ret.append((menu_id, type_, path, path_i18n, extra))
 
         return ret