annotate browser_side/menu.py @ 377:603fa314880e

browser side: fixed bad variable reference in menus management
author Goffi <goffi@goffi.org>
date Tue, 25 Feb 2014 09:42:52 +0100
parents 30d03d9f07e4
children 933bce4cb816
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/python
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
3
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
4 # Libervia: a Salut à Toi frontend
340
ce5b33f499c5 dates update
Goffi <goffi@goffi.org>
parents: 339
diff changeset
5 # Copyright (C) 2011, 2012, 2013, 2014 Jérôme Poisson <goffi@goffi.org>
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
6
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
7 # This program is free software: you can redistribute it and/or modify
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
10 # (at your option) any later version.
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
11
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
12 # This program is distributed in the hope that it will be useful,
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
15 # GNU Affero General Public License for more details.
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
16
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
19
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
20 import pyjd # this is dummy in pyjs
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
21 from pyjamas.ui.SimplePanel import SimplePanel
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
22 from pyjamas.ui.VerticalPanel import VerticalPanel
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
23 from pyjamas.ui.HorizontalPanel import HorizontalPanel
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from pyjamas.ui.DialogBox import DialogBox
152
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
25 from pyjamas.ui.FormPanel import FormPanel
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
26 from pyjamas.ui.FileUpload import FileUpload
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
27 from pyjamas.ui.MenuBar import MenuBar
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
28 from pyjamas.ui.MenuItem import MenuItem
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
29 from pyjamas.ui.ListBox import ListBox
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
30 from pyjamas.ui.Label import Label
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
31 from pyjamas.ui.TextBox import TextBox
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
32 from pyjamas.ui.Button import Button
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
33 from pyjamas.ui.HTML import HTML
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
34 from pyjamas.ui.Frame import Frame
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
35 from pyjamas import Window
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
36 from jid import JID
370
30d03d9f07e4 browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents: 340
diff changeset
37 from html_tools import html_sanitize
30d03d9f07e4 browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents: 340
diff changeset
38 from file_tools import FilterFileUpload
148
8635bc9db9bf added parameter management to test XMLUI, but it's currently deactivated for security reasons (need some configuration options) + separated mainTabPanel CSS from LiberviaTabPanel
Goffi <goffi@goffi.org>
parents: 147
diff changeset
39 from xmlui import XMLUI
181
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 165
diff changeset
40 import panels
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
41 import dialog
256
0e7f3944bd27 browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents: 242
diff changeset
42 from contact_group import ContactGroupEditor
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
43 import re
336
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
44 from sat.core.i18n import _
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
45
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
46
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
47 class MenuCmd:
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
48
336
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
49 def __init__(self, object_, handler):
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
50 self._object = object_
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
51 self._handler = handler
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
52
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
53 def execute(self):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
54 handler = getattr(self._object, self._handler)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
55 handler()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
56
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
57
336
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
58 class PluginMenuCmd:
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
59
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
60 def __init__(self, host, action_id):
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
61 self.host = host
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
62 self.action_id = action_id
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
63
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
64 def execute(self):
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
65 self.host.launchAction(self.action_id, None)
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
66
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
67
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
68 class LiberviaMenuBar(MenuBar):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
69
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
70 def __init__(self):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
71 MenuBar.__init__(self, vertical=False)
220
09e4de9df5b7 browser side: enforced "gwt-MenuBar-horizontal" style in LiberviaMenuBar to workaround a class name fix in Pyjamas' MenuBar which was causing troubles with CSS.
Goffi <goffi@goffi.org>
parents: 218
diff changeset
72 self.setStyleName('gwt-MenuBar-horizontal') # XXX: workaround for the Pyjamas' class name fix (it's now "gwt-MenuBar gwt-MenuBar-horizontal")
09e4de9df5b7 browser side: enforced "gwt-MenuBar-horizontal" style in LiberviaMenuBar to workaround a class name fix in Pyjamas' MenuBar which was causing troubles with CSS.
Goffi <goffi@goffi.org>
parents: 218
diff changeset
73 # TODO: properly adapt CSS to the new class name
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
74
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
75 def doItemAction(self, item, fireCommand):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
76 MenuBar.doItemAction(self, item, fireCommand)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
77 if item == self.items[-1] and self.popup:
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
78 self.popup.setPopupPosition(Window.getClientWidth() -
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
79 self.popup.getOffsetWidth() - 22,
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
80 self.getAbsoluteTop() +
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
81 self.getOffsetHeight() - 1)
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
82 self.popup.addStyleName('menuLastPopup')
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
83
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
84
152
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
85 class AvatarUpload(FormPanel):
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
86
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
87 def __init__(self, close_cb=None):
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
88 FormPanel.__init__(self)
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
89 self.close_cb = close_cb
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
90 self.setEncoding(FormPanel.ENCODING_MULTIPART)
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
91 self.setMethod(FormPanel.METHOD_POST)
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
92 self.setAction("upload_avatar")
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
93 self.vPanel = VerticalPanel()
183
a50ce9c06e0e browser side: fixed typo
Goffi <goffi@goffi.org>
parents: 181
diff changeset
94 self.message = HTML('Please select an image to show as your avatar...<br>Your picture must be a square and will be resized to 64x64 pixels if necessary')
152
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
95 self.vPanel.add(self.message)
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
96
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
97 hPanel = HorizontalPanel()
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
98 hPanel.setSpacing(5)
283
0eba1c4f9c6f browser_side (plugins radiocol, xep-0054): check for file size or type before uploading
souliane <souliane@mailoo.org>
parents: 272
diff changeset
99 self.file_upload = FilterFileUpload("avatar_path", 2)
152
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
100 self.vPanel.add(self.file_upload)
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
101
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
102 hPanel.add(Button("Cancel", getattr(self, "onCloseBtnClick")))
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
103 self.upload_btn = Button("Upload avatar", getattr(self, "onSubmitBtnClick"))
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
104 hPanel.add(self.upload_btn)
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
105
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
106 self.status = Label()
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
107 hPanel.add(self.status)
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
108
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
109 self.vPanel.add(hPanel)
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
110
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
111 self.add(self.vPanel)
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
112 self.addFormHandler(self)
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
113
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
114 def setCloseCb(self, close_cb):
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
115 self.close_cb = close_cb
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
116
152
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
117 def onCloseBtnClick(self):
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
118 if self.close_cb:
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
119 self.close_cb()
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
120 else:
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
121 print ("WARNING: no close method defined")
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
122
152
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
123 def onSubmitBtnClick(self):
283
0eba1c4f9c6f browser_side (plugins radiocol, xep-0054): check for file size or type before uploading
souliane <souliane@mailoo.org>
parents: 272
diff changeset
124 if not self.file_upload.check():
0eba1c4f9c6f browser_side (plugins radiocol, xep-0054): check for file size or type before uploading
souliane <souliane@mailoo.org>
parents: 272
diff changeset
125 return
152
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
126 self.message.setHTML('<strong>Submitting, please wait...</strong>')
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
127 self.upload_btn.setEnabled(False)
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
128 self.submit()
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
129
152
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
130 def onSubmit(self, event):
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
131 pass
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
132
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
133 def onSubmitComplete(self, event):
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
134 result = event.getResults()
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
135 if result != "OK":
300
4f221f34bdc7 browser_side (plugins radiocol, xep-0054): handle upload errors
souliane <souliane@mailoo.org>
parents: 288
diff changeset
136 Window.alert("Can't open image... did you actually submit an image?")
4f221f34bdc7 browser_side (plugins radiocol, xep-0054): handle upload errors
souliane <souliane@mailoo.org>
parents: 288
diff changeset
137 self.message.setHTML('Please select another image file')
4f221f34bdc7 browser_side (plugins radiocol, xep-0054): handle upload errors
souliane <souliane@mailoo.org>
parents: 288
diff changeset
138 self.upload_btn.setEnabled(True)
4f221f34bdc7 browser_side (plugins radiocol, xep-0054): handle upload errors
souliane <souliane@mailoo.org>
parents: 288
diff changeset
139 else:
4f221f34bdc7 browser_side (plugins radiocol, xep-0054): handle upload errors
souliane <souliane@mailoo.org>
parents: 288
diff changeset
140 Window.alert("Your new profile picture has been set!")
4f221f34bdc7 browser_side (plugins radiocol, xep-0054): handle upload errors
souliane <souliane@mailoo.org>
parents: 288
diff changeset
141 self.close_cb()
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
142
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
143
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
144 class Menu(SimplePanel):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
145
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
146 def __init__(self, host):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
147 self.host = host
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
148 SimplePanel.__init__(self)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
149 self.setStyleName('menuContainer')
336
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
150
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
151 def createMenus(self, add_menus):
79
d57e0d6b1ced browser side: inclusion of Adrien's icons
Goffi <goffi@goffi.org>
parents: 78
diff changeset
152 _item_tpl = "<img src='media/icons/menu/%s_menu_red.png' />%s"
336
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
153 menus_dict = {}
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
154 menus_order = []
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
155
336
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
156 def addMenu(menu_name, menu_name_i18n, item_name_i18n, icon, menu_cmd):
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
157 """ add a menu to menu_dict """
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
158 print "addMenu:",menu_name, menu_name_i18n, item_name_i18n, icon, menu_cmd
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
159 try:
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
160 menu_bar = menus_dict[menu_name]
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
161 except KeyError:
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
162 menu_bar = menus_dict[menu_name] = MenuBar(vertical=True)
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
163 menus_order.append((menu_name, menu_name_i18n, icon))
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
164 menu_bar.addItem(item_name_i18n, menu_cmd)
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
165
336
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
166 addMenu("General", _("General"), _("Web widget"), 'home', MenuCmd(self, "onWebWidget"))
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
167 addMenu("General", _("General"), _("Disconnect"), 'home', MenuCmd(self, "onDisconnect"))
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
168 addMenu("Contacts", _("Contacts"), _("Add contact"), 'social', MenuCmd(self, "onAddContact"))
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
169 addMenu("Contacts", _("Contacts"), _("Update contact"), 'social', MenuCmd(self, "onUpdateContact"))
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
170 addMenu("Contacts", _("Contacts"), _("Remove contact"), 'social', MenuCmd(self, "onRemoveContact"))
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
171 addMenu("Contacts", _("Contacts"), _("Manage groups"), 'social', MenuCmd(self, "onManageContactGroups"))
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
172 addMenu("Groups", _("Groups"), _("Discussion"), 'social', MenuCmd(self, "onJoinRoom"))
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
173 addMenu("Groups", _("Groups"), _("Collective radio"), 'social', MenuCmd(self, "onCollectiveRadio"))
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
174 addMenu("Games", _("Games"), _("Tarot"), 'games', MenuCmd(self, "onTarotGame"))
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
175 addMenu("Games", _("Games"), _("Xiangqi"), 'games', MenuCmd(self, "onXiangqiGame"))
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
176
336
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
177 # additional menus
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
178 for action_id, type_, path, path_i18n in add_menus:
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
179 if not path:
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
180 print "WARNING: skipping menu without path"
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
181 continue
377
603fa314880e browser side: fixed bad variable reference in menus management
Goffi <goffi@goffi.org>
parents: 370
diff changeset
182 if len(path) != len(path_i18n):
603fa314880e browser side: fixed bad variable reference in menus management
Goffi <goffi@goffi.org>
parents: 370
diff changeset
183 print "ERROR: inconsistency between menu paths"
603fa314880e browser side: fixed bad variable reference in menus management
Goffi <goffi@goffi.org>
parents: 370
diff changeset
184 continue
336
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
185 menu_name = path[0]
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
186 menu_name_i18n = path_i18n[0]
377
603fa314880e browser side: fixed bad variable reference in menus management
Goffi <goffi@goffi.org>
parents: 370
diff changeset
187 item_name = path[1:]
336
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
188 if not item_name:
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
189 print "WARNING: skipping menu with a path of lenght 1 [%s]" % path[0]
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
190 continue
377
603fa314880e browser side: fixed bad variable reference in menus management
Goffi <goffi@goffi.org>
parents: 370
diff changeset
191 item_name_i18n = ' | '.join(path_i18n[1:])
336
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
192 addMenu(menu_name, menu_name_i18n, item_name_i18n, 'plugins', PluginMenuCmd(self.host, action_id))
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
193
336
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
194 menus_order.append(None) # we add separator
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
195
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
196 addMenu("Help", _("Help"), _("Social contract"), 'help', MenuCmd(self, "onSocialContract"))
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
197 addMenu("Help", _("Help"), _("About"), 'help', MenuCmd(self, "onAbout"))
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
198 addMenu("Settings", _("Settings"), _("Parameters"), 'settings', MenuCmd(self, "onParameters"))
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
199
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
200 # XXX: temporary, will change when a full profile will be managed in SàT
336
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
201 addMenu("Settings", _("Settings"), _("Upload avatar"), 'settings', MenuCmd(self, "onAvatarUpload"))
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
202
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
203 menubar = LiberviaMenuBar()
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
204
336
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
205 for menu_data in menus_order:
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
206 if menu_data is None:
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
207 _separator = MenuItem('', None)
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
208 _separator.setStyleName('menuSeparator')
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
209 menubar.addItem(_separator, None)
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
210 else:
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
211 menu_name, menu_name_i18n, icon = menu_data
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
212 menubar.addItem(MenuItem(_item_tpl % (icon, menu_name_i18n), True, menus_dict[menu_name]))
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
213
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
214 self.add(menubar)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
215
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
216 #General menu
181
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 165
diff changeset
217 def onWebWidget(self):
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 165
diff changeset
218 web_panel = panels.WebPanel(self.host, "http://www.goffi.org")
257
377de26d5bc2 browser_side: open the web widget in the current tab
souliane <souliane@mailoo.org>
parents: 256
diff changeset
219 self.host.addWidget(web_panel)
377de26d5bc2 browser_side: open the web widget in the current tab
souliane <souliane@mailoo.org>
parents: 256
diff changeset
220 self.host.setSelected(web_panel)
181
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 165
diff changeset
221
158
58442ed28f2b browser side: basic disconnection management: hard reload is done on empty signal response
Goffi <goffi@goffi.org>
parents: 152
diff changeset
222 def onDisconnect(self):
58442ed28f2b browser side: basic disconnection management: hard reload is done on empty signal response
Goffi <goffi@goffi.org>
parents: 152
diff changeset
223 def confirm_cb(answer):
58442ed28f2b browser side: basic disconnection management: hard reload is done on empty signal response
Goffi <goffi@goffi.org>
parents: 152
diff changeset
224 if answer:
242
a25aa882e09a browser_side: add context menu for contact:
souliane <souliane@mailoo.org>
parents: 238
diff changeset
225 print "disconnection"
158
58442ed28f2b browser side: basic disconnection management: hard reload is done on empty signal response
Goffi <goffi@goffi.org>
parents: 152
diff changeset
226 self.host.bridge.call('disconnect', None)
58442ed28f2b browser side: basic disconnection management: hard reload is done on empty signal response
Goffi <goffi@goffi.org>
parents: 152
diff changeset
227 _dialog = dialog.ConfirmDialog(confirm_cb, text="Do you really want to disconnect ?")
58442ed28f2b browser side: basic disconnection management: hard reload is done on empty signal response
Goffi <goffi@goffi.org>
parents: 152
diff changeset
228 _dialog.show()
58442ed28f2b browser side: basic disconnection management: hard reload is done on empty signal response
Goffi <goffi@goffi.org>
parents: 152
diff changeset
229
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
230 def onSocialContract(self):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
231 _frame = Frame('contrat_social.html')
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
232 _frame.setStyleName('infoFrame')
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
233 _dialog = dialog.GenericDialog("Contrat Social", _frame)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
234 _dialog.setSize('80%', '80%')
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
235 _dialog.show()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
236
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
237 def onAbout(self):
147
60ea800b7237 browser side: fixed about menu + updated website URL
Goffi <goffi@goffi.org>
parents: 131
diff changeset
238 _about = HTML("""<b>Libervia</b>, a Salut &agrave; Toi project<br />
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
239 <br />
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
240 You can contact the author at <a href="mailto:goffi@goffi.org">goffi@goffi.org</a><br />
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
241 Blog available (mainly in french) at <a href="http://www.goffi.org" target="_blank">http://www.goffi.org</a><br />
147
60ea800b7237 browser side: fixed about menu + updated website URL
Goffi <goffi@goffi.org>
parents: 131
diff changeset
242 Project page: <a href="http://sat.goffi.org"target="_blank">http://sat.goffi.org</a><br />
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
243 <br />
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
244 Any help welcome :)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
245 <p style='font-size:small;text-align:center'>This project is dedicated to Roger Poisson</p>
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
246 """)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
247 _dialog = dialog.GenericDialog("About", _about)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
248 _dialog.show()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
249
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
250 #Contact menu
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
251 def onAddContact(self):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
252 """Q&D contact addition"""
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
253 _dialog = None
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
254 edit = TextBox()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
255
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
256 def addContactCb(sender):
242
a25aa882e09a browser_side: add context menu for contact:
souliane <souliane@mailoo.org>
parents: 238
diff changeset
257 if not re.match(r'^.+@.+\..+', edit.getText(), re.IGNORECASE):
a25aa882e09a browser_side: add context menu for contact:
souliane <souliane@mailoo.org>
parents: 238
diff changeset
258 Window.alert('You must enter a valid contact JID (like "contact@%s")' % self.host._defaultDomain)
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
259 _dialog.show()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
260 else:
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
261 self.host.bridge.call('addContact', None, edit.getText(), '', _dialog.getSelectedGroups() )
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
262
268
79970bf6af93 browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents: 257
diff changeset
263 label = Label("New contact identifier (JID):")
242
a25aa882e09a browser_side: add context menu for contact:
souliane <souliane@mailoo.org>
parents: 238
diff changeset
264 edit.setText('@%s' % self.host._defaultDomain)
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
265 edit.setWidth('100%')
210
3092f6b1710c browser side: make the OK button title for group selector configureable + few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents: 183
diff changeset
266 _dialog = dialog.GroupSelector([label, edit], self.host.contact_panel.getGroups(), [],
3092f6b1710c browser side: make the OK button title for group selector configureable + few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents: 183
diff changeset
267 "Add", addContactCb)
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
268 _dialog.setHTML('Adding contact')
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
269 _dialog.show()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
270
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
271 def onUpdateContact(self):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
272 _dialog = None
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
273 _contacts_list = ListBox()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
274
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
275 def updateContactCb(sender):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
276 _jid = _contacts_list.getValue(_contacts_list.getSelectedIndex())
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
277 self.host.bridge.call('updateContact', None, _jid, '', _dialog.getSelectedGroups())
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
278
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
279 def onContactChange(_list):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
280 _jid = _contacts_list.getValue(_contacts_list.getSelectedIndex())
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
281 groups = self.host.contact_panel.getContactGroups(_jid)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
282 _dialog.setGroupsSelected(groups)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
283
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
284 for contact in self.host.contact_panel.getContacts():
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
285 _contacts_list.addItem(contact)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
286 _contacts_list.addChangeListener(onContactChange)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
287 _jid = _contacts_list.getValue(_contacts_list.getSelectedIndex())
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
288 _selected_groups = self.host.contact_panel.getContactGroups(_jid)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
289 _dialog = dialog.GroupSelector([Label('Which contact do you want to update ?'), _contacts_list],
210
3092f6b1710c browser side: make the OK button title for group selector configureable + few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents: 183
diff changeset
290 self.host.contact_panel.getGroups(), _selected_groups,
3092f6b1710c browser side: make the OK button title for group selector configureable + few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents: 183
diff changeset
291 "Update", updateContactCb)
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
292 _dialog.setHTML('Updating contact')
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
293 _dialog.show()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
294
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
295 def onRemoveContact(self):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
296 _dialog = None
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
297 _contacts_list = ListBox()
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
298
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
299 def secondConfirmCb(confirm):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
300 if confirm:
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
301 for contact in _contacts_list.getSelectedValues():
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
302 self.host.bridge.call('delContact', None, contact)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
303 else:
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
304 _dialog.show()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
305
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
306 def dialogCb(confirm):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
307 if confirm:
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
308 html_list = ''.join(['<li>%s</li>' % html_sanitize(contact) for contact in _contacts_list.getSelectedValues()])
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
309 html_body = "Are you sure to remove the following contacts from your contact list ?<ul>%s</ul>" % html_list
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
310 dialog.ConfirmDialog(secondConfirmCb, html_body).show()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
311
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
312 for contact in self.host.contact_panel.getContacts():
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
313 _contacts_list.addItem(contact)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
314 _dialog = dialog.GenericConfirmDialog([_contacts_list], dialogCb, "Who do you want to remove from your contacts ?")
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
315 _dialog.show()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
316
256
0e7f3944bd27 browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents: 242
diff changeset
317 def onManageContactGroups(self):
0e7f3944bd27 browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents: 242
diff changeset
318 """Open the contact groups manager."""
0e7f3944bd27 browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents: 242
diff changeset
319
0e7f3944bd27 browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents: 242
diff changeset
320 def onCloseCallback():
0e7f3944bd27 browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents: 242
diff changeset
321 pass
0e7f3944bd27 browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents: 242
diff changeset
322
0e7f3944bd27 browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents: 242
diff changeset
323 ContactGroupEditor(self.host, None, onCloseCallback)
0e7f3944bd27 browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents: 242
diff changeset
324
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
325 #Group menu
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
326 def onJoinRoom(self):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
327
268
79970bf6af93 browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents: 257
diff changeset
328 def invite(room_jid, contacts):
79970bf6af93 browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents: 257
diff changeset
329 for contact in contacts:
79970bf6af93 browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents: 257
diff changeset
330 self.host.bridge.call('inviteMUC', None, contact, room_jid)
79970bf6af93 browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents: 257
diff changeset
331
79970bf6af93 browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents: 257
diff changeset
332 def join(room_jid, contacts):
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
333 if self.host.whoami:
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
334 nick = self.host.whoami.node
268
79970bf6af93 browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents: 257
diff changeset
335 if room_jid not in [room.bare for room in self.host.room_list]:
79970bf6af93 browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents: 257
diff changeset
336 self.host.bridge.call('joinMUC', lambda room_jid: invite(room_jid, contacts), room_jid, nick)
79970bf6af93 browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents: 257
diff changeset
337 else:
79970bf6af93 browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents: 257
diff changeset
338 self.host.getOrCreateLiberviaWidget(panels.ChatPanel, (room_jid, "group"), True, JID(room_jid).bare)
79970bf6af93 browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents: 257
diff changeset
339 invite(room_jid, contacts)
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
340
268
79970bf6af93 browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents: 257
diff changeset
341 dialog.RoomAndContactsChooser(self.host, join, ok_button="Join", visible=(True, False))
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
342
125
f9d63624699f radio collective integration, first draft
Goffi <goffi@goffi.org>
parents: 103
diff changeset
343 def onCollectiveRadio(self):
268
79970bf6af93 browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents: 257
diff changeset
344 def callback(room_jid, contacts):
79970bf6af93 browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents: 257
diff changeset
345 self.host.bridge.call('launchRadioCollective', None, contacts, room_jid)
272
0cb9869b42b6 browser_side: bug fix for RoomAndContactsChooser (do not display the MUCs in the list)
souliane <souliane@mailoo.org>
parents: 268
diff changeset
346 dialog.RoomAndContactsChooser(self.host, callback, ok_button="Choose", title="Collective Radio", visible=(False, True))
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
347
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
348 #Game menu
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
349 def onTarotGame(self):
268
79970bf6af93 browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents: 257
diff changeset
350 def onPlayersSelected(room_jid, other_players):
79970bf6af93 browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents: 257
diff changeset
351 self.host.bridge.call('launchTarotGame', None, other_players, room_jid)
272
0cb9869b42b6 browser_side: bug fix for RoomAndContactsChooser (do not display the MUCs in the list)
souliane <souliane@mailoo.org>
parents: 268
diff changeset
352 dialog.RoomAndContactsChooser(self.host, onPlayersSelected, 3, title="Tarot", title_invite="Please select 3 other players", visible=(False, True))
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
353
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
354 def onXiangqiGame(self):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
355 Window.alert("A Xiangqi game is planed, but not available yet")
148
8635bc9db9bf added parameter management to test XMLUI, but it's currently deactivated for security reasons (need some configuration options) + separated mainTabPanel CSS from LiberviaTabPanel
Goffi <goffi@goffi.org>
parents: 147
diff changeset
356
8635bc9db9bf added parameter management to test XMLUI, but it's currently deactivated for security reasons (need some configuration options) + separated mainTabPanel CSS from LiberviaTabPanel
Goffi <goffi@goffi.org>
parents: 147
diff changeset
357 #Settings menu
8635bc9db9bf added parameter management to test XMLUI, but it's currently deactivated for security reasons (need some configuration options) + separated mainTabPanel CSS from LiberviaTabPanel
Goffi <goffi@goffi.org>
parents: 147
diff changeset
358
8635bc9db9bf added parameter management to test XMLUI, but it's currently deactivated for security reasons (need some configuration options) + separated mainTabPanel CSS from LiberviaTabPanel
Goffi <goffi@goffi.org>
parents: 147
diff changeset
359 def onParameters(self):
8635bc9db9bf added parameter management to test XMLUI, but it's currently deactivated for security reasons (need some configuration options) + separated mainTabPanel CSS from LiberviaTabPanel
Goffi <goffi@goffi.org>
parents: 147
diff changeset
360 def gotParams(xmlui):
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
361 if not xmlui:
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
362 return
148
8635bc9db9bf added parameter management to test XMLUI, but it's currently deactivated for security reasons (need some configuration options) + separated mainTabPanel CSS from LiberviaTabPanel
Goffi <goffi@goffi.org>
parents: 147
diff changeset
363 body = XMLUI(self.host, xmlui)
8635bc9db9bf added parameter management to test XMLUI, but it's currently deactivated for security reasons (need some configuration options) + separated mainTabPanel CSS from LiberviaTabPanel
Goffi <goffi@goffi.org>
parents: 147
diff changeset
364 _dialog = dialog.GenericDialog("Parameters", body, options=['NO_CLOSE'])
336
629c99bbd031 browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents: 300
diff changeset
365 body.setCloseCb(_dialog.close)
148
8635bc9db9bf added parameter management to test XMLUI, but it's currently deactivated for security reasons (need some configuration options) + separated mainTabPanel CSS from LiberviaTabPanel
Goffi <goffi@goffi.org>
parents: 147
diff changeset
366 _dialog.setSize('80%', '80%')
8635bc9db9bf added parameter management to test XMLUI, but it's currently deactivated for security reasons (need some configuration options) + separated mainTabPanel CSS from LiberviaTabPanel
Goffi <goffi@goffi.org>
parents: 147
diff changeset
367 _dialog.show()
8635bc9db9bf added parameter management to test XMLUI, but it's currently deactivated for security reasons (need some configuration options) + separated mainTabPanel CSS from LiberviaTabPanel
Goffi <goffi@goffi.org>
parents: 147
diff changeset
368 self.host.bridge.call('getParamsUI', gotParams)
8635bc9db9bf added parameter management to test XMLUI, but it's currently deactivated for security reasons (need some configuration options) + separated mainTabPanel CSS from LiberviaTabPanel
Goffi <goffi@goffi.org>
parents: 147
diff changeset
369
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
370 def removeItemParams(self):
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
371 """Remove the Parameters item from the Settings menu bar."""
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
372 self.menu_settings.removeItem(self.item_params)
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
373
152
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
374 def onAvatarUpload(self):
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
375 body = AvatarUpload()
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
376 _dialog = dialog.GenericDialog("Avatar upload", body, options=['NO_CLOSE'])
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
377 body.setCloseCb(_dialog.close)
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
378 _dialog.setSize('40%', '40%')
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
379 _dialog.show()