Mercurial > libervia-web
comparison browser_side/menu.py @ 439:d52f529a6d42
browser side: use of new log system (first draft):
- configuration is hardcoded in libervia.py, it will change in the (hopefuly) near future
- log level is DEBUG for the moment, will be changed to INFO when configuration will not be hardcoded anymore
- the basic log backend is used, in the future, a console.debug/info/etc should be used instead. A log widget which HTML colors is also an option
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 08 May 2014 17:21:34 +0200 |
parents | 8ecc5a7062e4 |
children |
comparison
equal
deleted
inserted
replaced
438:582c435dab6b | 439:d52f529a6d42 |
---|---|
16 | 16 |
17 # You should have received a copy of the GNU Affero General Public License | 17 # You should have received a copy of the GNU Affero General Public License |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 |
20 import pyjd # this is dummy in pyjs | 20 import pyjd # this is dummy in pyjs |
21 from sat.core.log import getLogger | |
22 log = getLogger(__name__) | |
21 from pyjamas.ui.SimplePanel import SimplePanel | 23 from pyjamas.ui.SimplePanel import SimplePanel |
22 from pyjamas.ui.MenuBar import MenuBar | 24 from pyjamas.ui.MenuBar import MenuBar |
23 from pyjamas.ui.MenuItem import MenuItem | 25 from pyjamas.ui.MenuItem import MenuItem |
24 from pyjamas.ui.ListBox import ListBox | |
25 from pyjamas.ui.Label import Label | |
26 from pyjamas.ui.TextBox import TextBox | |
27 from pyjamas.ui.HTML import HTML | 26 from pyjamas.ui.HTML import HTML |
28 from pyjamas.ui.Frame import Frame | 27 from pyjamas.ui.Frame import Frame |
29 from pyjamas import Window | 28 from pyjamas import Window |
30 from jid import JID | 29 from jid import JID |
31 from html_tools import html_sanitize | |
32 from file_tools import FileUploadPanel | 30 from file_tools import FileUploadPanel |
33 from xmlui import XMLUI | 31 from xmlui import XMLUI |
34 from browser_side import panels | 32 from browser_side import panels |
35 from browser_side import dialog | 33 from browser_side import dialog |
36 from contact_group import ContactGroupEditor | 34 from contact_group import ContactGroupEditor |
37 import re | |
38 from sat.core.i18n import _ | 35 from sat.core.i18n import _ |
39 | 36 |
40 | 37 |
41 class MenuCmd: | 38 class MenuCmd: |
42 | 39 |
98 menus_dict = {} | 95 menus_dict = {} |
99 menus_order = [] | 96 menus_order = [] |
100 | 97 |
101 def addMenu(menu_name, menu_name_i18n, item_name_i18n, icon, menu_cmd): | 98 def addMenu(menu_name, menu_name_i18n, item_name_i18n, icon, menu_cmd): |
102 """ add a menu to menu_dict """ | 99 """ add a menu to menu_dict """ |
103 print "addMenu:", menu_name, menu_name_i18n, item_name_i18n, icon, menu_cmd | 100 log.info("addMenu: %s %s %s %s %s" % (menu_name, menu_name_i18n, item_name_i18n, icon, menu_cmd)) |
104 try: | 101 try: |
105 menu_bar = menus_dict[menu_name] | 102 menu_bar = menus_dict[menu_name] |
106 except KeyError: | 103 except KeyError: |
107 menu_bar = menus_dict[menu_name] = MenuBar(vertical=True) | 104 menu_bar = menus_dict[menu_name] = MenuBar(vertical=True) |
108 menus_order.append((menu_name, menu_name_i18n, icon)) | 105 menus_order.append((menu_name, menu_name_i18n, icon)) |
118 addMenu("Games", _("Games"), _("Xiangqi"), 'games', MenuCmd(self, "onXiangqiGame")) | 115 addMenu("Games", _("Games"), _("Xiangqi"), 'games', MenuCmd(self, "onXiangqiGame")) |
119 | 116 |
120 # additional menus | 117 # additional menus |
121 for action_id, type_, path, path_i18n in add_menus: | 118 for action_id, type_, path, path_i18n in add_menus: |
122 if not path: | 119 if not path: |
123 print "WARNING: skipping menu without path" | 120 log.warning("skipping menu without path") |
124 continue | 121 continue |
125 if len(path) != len(path_i18n): | 122 if len(path) != len(path_i18n): |
126 print "ERROR: inconsistency between menu paths" | 123 log.error("inconsistency between menu paths") |
127 continue | 124 continue |
128 menu_name = path[0] | 125 menu_name = path[0] |
129 menu_name_i18n = path_i18n[0] | 126 menu_name_i18n = path_i18n[0] |
130 item_name = path[1:] | 127 item_name = path[1:] |
131 if not item_name: | 128 if not item_name: |
132 print "WARNING: skipping menu with a path of lenght 1 [%s]" % path[0] | 129 log.warning("skipping menu with a path of lenght 1 [%s]" % path[0]) |
133 continue | 130 continue |
134 item_name_i18n = ' | '.join(path_i18n[1:]) | 131 item_name_i18n = ' | '.join(path_i18n[1:]) |
135 addMenu(menu_name, menu_name_i18n, item_name_i18n, 'plugins', PluginMenuCmd(self.host, action_id)) | 132 addMenu(menu_name, menu_name_i18n, item_name_i18n, 'plugins', PluginMenuCmd(self.host, action_id)) |
136 | 133 |
137 # menu items that should be displayed after the automatically added ones | 134 # menu items that should be displayed after the automatically added ones |
167 self.host.setSelected(web_panel) | 164 self.host.setSelected(web_panel) |
168 | 165 |
169 def onDisconnect(self): | 166 def onDisconnect(self): |
170 def confirm_cb(answer): | 167 def confirm_cb(answer): |
171 if answer: | 168 if answer: |
172 print "disconnection" | 169 log.info("disconnection") |
173 self.host.bridge.call('disconnect', None) | 170 self.host.bridge.call('disconnect', None) |
174 _dialog = dialog.ConfirmDialog(confirm_cb, text="Do you really want to disconnect ?") | 171 _dialog = dialog.ConfirmDialog(confirm_cb, text="Do you really want to disconnect ?") |
175 _dialog.show() | 172 _dialog.show() |
176 | 173 |
177 def onSocialContract(self): | 174 def onSocialContract(self): |