core: dynamics menus refactoring:
- menu now use generic callback system, with extra data
- asyncMenuCall is removed in favor of launchAction
- menu_id (== callback_id) is used to identify menu instead of category/name/type tuple
- i18n is managed throught deferred translation, and returned with _i18n suffix
e.g.: menu (D_('File'), D_('Open')): (u'File', u'Open') is menu_path, (u'Fichier', u'Ouvrir') is french menu_path_i18n.
- type actually can have the following values:
- NORMAL: classical menu
- JID_CONTEXT: contextual menu, used with any jid
- ROSTER_JID_CONTEXT: like JID_CONTEXT, but restricted to jids in roster.
- ROSTER_GROUP_CONTEXT: contextual menu, use with groups
- security_limit is used, in the same way as for parameters
- when using importMenu, callback can be an actual callback, or one already registered with registerCallback
This commit is contained in:
parent
f46a7bf23d
commit
b7bf434cd2
8 changed files with 129 additions and 132 deletions
|
|
@ -17,7 +17,7 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from sat.core.i18n import _
|
||||
from sat.core.i18n import _, D_
|
||||
from logging import debug, info, warning, error
|
||||
from twisted.words.protocols.jabber import jid
|
||||
from twisted.words.protocols.jabber import error as xmpp_error
|
||||
|
|
@ -212,7 +212,7 @@ class XEP_0050(object):
|
|||
method=self._requestCommandsList,
|
||||
async=True)
|
||||
self.__requesting_id = host.registerCallback(self._requestingEntity, with_data=True)
|
||||
host.importMenu("Service", "commands", self._commandsMenu, help_string=_("Execute ad-hoc commands"))
|
||||
host.importMenu((D_("Service"), D_("commands")), self._commandsMenu, help_string=D_("Execute ad-hoc commands"))
|
||||
|
||||
def getHandler(self, profile):
|
||||
return XEP_0050_handler(self)
|
||||
|
|
@ -322,7 +322,7 @@ class XEP_0050(object):
|
|||
|
||||
return d
|
||||
|
||||
def _commandsMenu(self, profile):
|
||||
def _commandsMenu(self, menu_data, profile):
|
||||
""" First XMLUI activated by menu: ask for target jid
|
||||
@param profile: %(doc_profile)s
|
||||
|
||||
|
|
@ -332,7 +332,7 @@ class XEP_0050(object):
|
|||
form_ui.changeLayout("pairs")
|
||||
form_ui.addLabel("jid")
|
||||
form_ui.addString("jid")
|
||||
return form_ui.toXml()
|
||||
return {'xmlui': form_ui.toXml()}
|
||||
|
||||
def _statusCallback(self, command_elt, session_data, action, node, profile):
|
||||
""" Ad-hoc command used to change the "show" part of status """
|
||||
|
|
|
|||
Loading…
Reference in a new issue