From 80e65d5b8450620f4b591850f5f51d6d1f3d9452 Mon Sep 17 00:00:00 2001 From: Goffi Date: Tue, 17 Mar 2015 19:33:05 +0100 Subject: [PATCH] core, quick_frontends: added an "extra" item in getMenus + use of new quick_menus module in QuickApp --- frontends/src/primitivus/primitivus | 2 +- frontends/src/quick_frontend/quick_app.py | 8 +++++--- frontends/src/quick_frontend/quick_chat.py | 1 - src/bridge/DBus.py | 2 +- src/bridge/bridge_constructor/bridge_template.ini | 3 ++- src/core/sat_main.py | 8 ++++++-- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/frontends/src/primitivus/primitivus b/frontends/src/primitivus/primitivus index 259f6d56..26514f0e 100755 --- a/frontends/src/primitivus/primitivus +++ b/frontends/src/primitivus/primitivus @@ -425,7 +425,7 @@ class PrimitivusApp(QuickApp, InputHistory): """ 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: diff --git a/frontends/src/quick_frontend/quick_app.py b/frontends/src/quick_frontend/quick_app.py index 04df767e..cbccd20b 100644 --- a/frontends/src/quick_frontend/quick_app.py +++ b/frontends/src/quick_frontend/quick_app.py @@ -25,7 +25,8 @@ from sat.core import exceptions 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 @@ class QuickApp(object): @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 @@ class QuickApp(object): 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 diff --git a/frontends/src/quick_frontend/quick_chat.py b/frontends/src/quick_frontend/quick_chat.py index 516f4e35..09e96e86 100644 --- a/frontends/src/quick_frontend/quick_chat.py +++ b/frontends/src/quick_frontend/quick_chat.py @@ -38,7 +38,6 @@ class QuickChat(quick_widgets.QuickWidget): """ @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: diff --git a/src/bridge/DBus.py b/src/bridge/DBus.py index be64acf2..66714023 100755 --- a/src/bridge/DBus.py +++ b/src/bridge/DBus.py @@ -301,7 +301,7 @@ class DbusObject(dbus.service.Object): 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) diff --git a/src/bridge/bridge_constructor/bridge_template.ini b/src/bridge/bridge_constructor/bridge_template.ini index f60c54e4..bdbbe189 100644 --- a/src/bridge/bridge_constructor/bridge_template.ini +++ b/src/bridge/bridge_constructor/bridge_template.ini @@ -586,7 +586,7 @@ doc_return=dict with progress information: 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 @@ doc_return=list of tuple with the following value: * 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 diff --git a/src/core/sat_main.py b/src/core/sat_main.py index 856bee34..aa98ef97 100644 --- a/src/core/sat_main.py +++ b/src/core/sat_main.py @@ -858,6 +858,7 @@ class SAT(service.Service): 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 @@ class SAT(service.Service): - 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 @@ class SAT(service.Service): 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