Mercurial > libervia-backend
comparison frontends/src/quick_frontend/quick_app.py @ 2126:2f264f3df280
core (menus): improvments:
- use the new convention for bridge names (getMenus ==> menusGet, etc.)
- menu now use canonical path, which is the untranslated path with each element stripped and lowercase, it must be unique by menu type
- added menuLaunch method to manually launch a menu like an action, canonical path is used instead of id
- added SECURITY_LIMIT_MAX constant
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 26 Jan 2017 20:29:48 +0100 |
parents | c42aab22c2c0 |
children | aa94f33fd2ad |
comparison
equal
deleted
inserted
replaced
2125:ca82c97db195 | 2126:2f264f3df280 |
---|---|
855 action_data = {k:v for k,v in action_data.iteritems() if not k.startswith("meta_")} | 855 action_data = {k:v for k,v in action_data.iteritems() if not k.startswith("meta_")} |
856 | 856 |
857 if action_data: | 857 if action_data: |
858 raise exceptions.DataError(u"Not all keys in action_data are managed ({keys})".format(keys=', '.join(action_data.keys()))) | 858 raise exceptions.DataError(u"Not all keys in action_data are managed ({keys})".format(keys=', '.join(action_data.keys()))) |
859 | 859 |
860 | |
861 def _actionCb(self, data, callback, callback_id, profile): | |
862 if callback is None: | |
863 self.actionManager(data, profile=profile) | |
864 else: | |
865 callback(data=data, cb_id=callback_id, profile=profile) | |
866 | |
860 def launchAction(self, callback_id, data=None, callback=None, profile=C.PROF_KEY_NONE): | 867 def launchAction(self, callback_id, data=None, callback=None, profile=C.PROF_KEY_NONE): |
861 """ Launch a dynamic action | 868 """Launch a dynamic action |
862 | 869 |
863 @param callback_id: id of the action to launch | 870 @param callback_id: id of the action to launch |
864 @param data: data needed only for certain actions | 871 @param data: data needed only for certain actions |
865 @param callback(callable, None): will be called with the resut | 872 @param callback(callable, None): will be called with the resut |
866 if None, self.actionManager will be called | 873 if None, self.actionManager will be called |
871 @param profile: %(doc_profile)s | 878 @param profile: %(doc_profile)s |
872 | 879 |
873 """ | 880 """ |
874 if data is None: | 881 if data is None: |
875 data = dict() | 882 data = dict() |
876 | 883 action_cb = lambda data: self._actionCb(data, callback, callback_id, profile) |
877 | |
878 def action_cb(data): | |
879 if callback is None: | |
880 self.actionManager(data, profile=profile) | |
881 else: | |
882 callback(data=data, cb_id=callback_id, profile=profile) | |
883 | |
884 self.bridge.launchAction(callback_id, data, profile, callback=action_cb, errback=self.dialogFailure) | 884 self.bridge.launchAction(callback_id, data, profile, callback=action_cb, errback=self.dialogFailure) |
885 | |
886 def launchMenu(self, menu_type, path, data=None, callback=None, security_limit=C.SECURITY_LIMIT_MAX, profile=C.PROF_KEY_NONE): | |
887 """Launch a menu manually | |
888 | |
889 @param menu_type(unicode): type of the menu to launch | |
890 @param path(iterable[unicode]): path to the menu | |
891 @param data: data needed only for certain actions | |
892 @param callback(callable, None): will be called with the resut | |
893 if None, self.actionManager will be called | |
894 else the callable will be called with the following kw parameters: | |
895 - data: action_data | |
896 - cb_id: (menu_type, path) tuple | |
897 - profile: %(doc_profile)s | |
898 @param profile: %(doc_profile)s | |
899 | |
900 """ | |
901 if data is None: | |
902 data = dict() | |
903 action_cb = lambda data: self._actionCb(data, callback, (menu_type, path), profile) | |
904 self.bridge.menuLaunch(menu_type, path, data, security_limit, profile, callback=action_cb, errback=self.dialogFailure) | |
885 | 905 |
886 def _avatarGetCb(self, avatar_path, entity, contact_list, profile): | 906 def _avatarGetCb(self, avatar_path, entity, contact_list, profile): |
887 path = avatar_path or self.getDefaultAvatar(entity) | 907 path = avatar_path or self.getDefaultAvatar(entity) |
888 contact_list.setCache(entity, "avatar", path) | 908 contact_list.setCache(entity, "avatar", path) |
889 self.callListeners('avatar', entity, path, profile=profile) | 909 self.callListeners('avatar', entity, path, profile=profile) |