comparison frontends/src/quick_frontend/quick_menus.py @ 2070:58f0c96d60e5

quick frontend (menus): minor docstring fixes
author Goffi <goffi@goffi.org>
date Sun, 11 Sep 2016 11:03:25 +0200
parents 2daf7b4c6756
children 8b37a62336c3
comparison
equal deleted inserted replaced
2069:528e5fafc11b 2070:58f0c96d60e5
133 log.debug("data collected: %s" % data) 133 log.debug("data collected: %s" % data)
134 self.host.launchAction(self.id, data, profile=profile) 134 self.host.launchAction(self.id, data, profile=profile)
135 135
136 136
137 class MenuItemLocal(MenuItem): 137 class MenuItemLocal(MenuItem):
138 """A MenuItem with a distant callback""" 138 """A MenuItem with a local callback"""
139 CALLABLE=True 139 CALLABLE=True
140 140
141 def __init__(self, type_, name, name_i18n, callback, extra=None): 141 def __init__(self, type_, name, name_i18n, callback, extra=None):
142 """ 142 """
143 @param type_(unicode): same as in [sat.core.sat_main.SAT.importMenu] 143 @param type_(unicode): same as in [sat.core.sat_main.SAT.importMenu]
144 @param name(unicode): canonical name of the item 144 @param name(unicode): canonical name of the item
145 @param name_i18n(unicode): translated name of the item 145 @param name_i18n(unicode): translated name of the item
146 @param callback(callable): local callback. Will be called with the caller as only argument if data_collector is None, else with the caller + requested data + profile. 146 @param callback(callable): local callback.
147 Will be called with no argument if data_collector is None
148 and with caller, profile, and requested data otherwise
147 @param extra(dict[unicode, unicode], None): same as in [addMenus] 149 @param extra(dict[unicode, unicode], None): same as in [addMenus]
148 """ 150 """
149 MenuItem.__init__(self, name, name_i18n, extra, type_) 151 MenuItem.__init__(self, name, name_i18n, extra, type_)
150 self.callback = callback 152 self.callback = callback
151 153
152 def call(self, caller, profile=C.PROF_KEY_NONE): 154 def call(self, caller, profile=C.PROF_KEY_NONE):
153 data_collector = QuickMenusManager.getDataCollector(self.type) 155 data_collector = QuickMenusManager.getDataCollector(self.type)
154 if data_collector is None: 156 if data_collector is None:
157 # FIXME: would not it be better if caller and profile where used as arguments?
155 self.callback() 158 self.callback()
156 else: 159 else:
157 self.callback(caller, self.collectData(caller), profile) 160 self.callback(caller, self.collectData(caller), profile)
158 161
159 162
308 """Associate a data collector to a menu type 311 """Associate a data collector to a menu type
309 312
310 A data collector is a method or a map which allow to collect context data to construct the dictionnary which will be sent to the bridge method managing the menu item. 313 A data collector is a method or a map which allow to collect context data to construct the dictionnary which will be sent to the bridge method managing the menu item.
311 @param type_(unicode): same as in [sat.core.sat_main.SAT.importMenu] 314 @param type_(unicode): same as in [sat.core.sat_main.SAT.importMenu]
312 @param data_collector(dict[unicode,unicode], callable, None): can be: 315 @param data_collector(dict[unicode,unicode], callable, None): can be:
313 - a dict which map data name to local name. The attribute named after the dict values will be getted from caller, and put in data. e.g.: if data_collector={'room_jid':'target'}, then the "room_jid" data will be the value of the "target" attribute of the caller. 316 - a dict which map data name to local name.
317 The attribute named after the dict values will be getted from caller, and put in data.
318 e.g.: if data_collector={'room_jid':'target'}, then the "room_jid" data will be the value of the "target" attribute of the caller.
314 - a callable which must return the data dictionnary. callable will have caller and item name as argument 319 - a callable which must return the data dictionnary. callable will have caller and item name as argument
315 - None: an empty dict will be used 320 - None: an empty dict will be used
316 """ 321 """
317 QuickMenusManager._data_collectors[type_] = data_collector 322 QuickMenusManager._data_collectors[type_] = data_collector
318 323