core, quick_frontends: added an "extra" item in getMenus + use of new quick_menus module in QuickApp

This commit is contained in:
Goffi 2015-03-17 19:33:05 +01:00
commit 80e65d5b84
6 changed files with 15 additions and 9 deletions

View file

@ -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:

View file

@ -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

View file

@ -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:

View file

@ -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)

View file

@ -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

View file

@ -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