annotate browser_side/menu.py @ 283:0eba1c4f9c6f

browser_side (plugins radiocol, xep-0054): check for file size or type before uploading
author souliane <souliane@mailoo.org>
date Mon, 25 Nov 2013 20:39:28 +0100
parents 0cb9869b42b6
children 7316a5696366
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
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
4 """
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
5 Libervia: a Salut à Toi frontend
165
9763dec220ed dates update
Goffi <goffi@goffi.org>
parents: 162
diff changeset
6 Copyright (C) 2011, 2012, 2013 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
7
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
8 This program is free software: you can redistribute it and/or modify
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
9 it under the terms of the GNU Affero General Public License as published by
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
11 (at your option) any later version.
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
12
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
13 This program is distributed in the hope that it will be useful,
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
16 GNU Affero General Public License for more details.
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
17
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
18 You should have received a copy of the GNU Affero General Public License
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
20 """
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
21
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
22 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
23 from pyjamas.ui.SimplePanel import SimplePanel
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from pyjamas.ui.VerticalPanel import VerticalPanel
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from pyjamas.ui.HorizontalPanel import HorizontalPanel
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
26 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
27 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
28 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
29 from pyjamas.ui.MenuBar import MenuBar
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
30 from pyjamas.ui.MenuItem import MenuItem
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
31 from pyjamas.ui.ListBox import ListBox
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
32 from pyjamas.ui.Label import Label
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
33 from pyjamas.ui.TextBox import TextBox
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
34 from pyjamas.ui.Button import Button
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
35 from pyjamas.ui.HTML import HTML
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
36 from pyjamas.ui.Frame import Frame
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
37 from pyjamas import Window
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
38 from jid import JID
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
39 from tools import html_sanitize
283
0eba1c4f9c6f browser_side (plugins radiocol, xep-0054): check for file size or type before uploading
souliane <souliane@mailoo.org>
parents: 272
diff changeset
40 from 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
41 from xmlui import XMLUI
181
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 165
diff changeset
42 import panels
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
43 import dialog
256
0e7f3944bd27 browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents: 242
diff changeset
44 from contact_group import ContactGroupEditor
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
45 import re
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
46
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
47
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
48 class MenuCmd:
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
49
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
50 def __init__(self, object, handler):
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
51 self._object = object
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
52 self._handler = handler
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
53
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
54 def execute(self):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
55 handler = getattr(self._object, self._handler)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
56 handler()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
57
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
58
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
59 class LiberviaMenuBar(MenuBar):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
60
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
61 def __init__(self):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
62 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
63 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
64 # 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
65
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
66 def doItemAction(self, item, fireCommand):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
67 MenuBar.doItemAction(self, item, fireCommand)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
68 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
69 self.popup.setPopupPosition(Window.getClientWidth() -
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
70 self.popup.getOffsetWidth() - 22,
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
71 self.getAbsoluteTop() +
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
72 self.getOffsetHeight() - 1)
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
73 self.popup.addStyleName('menuLastPopup')
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
74
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
75
152
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
76 class AvatarUpload(FormPanel):
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
77
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
78 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
79 FormPanel.__init__(self)
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
80 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
81 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
82 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
83 self.setAction("upload_avatar")
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
84 self.vPanel = VerticalPanel()
183
a50ce9c06e0e browser side: fixed typo
Goffi <goffi@goffi.org>
parents: 181
diff changeset
85 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
86 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
87
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
88 hPanel = HorizontalPanel()
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
89 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
90 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
91 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
92
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
93 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
94 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
95 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
96
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
97 self.status = Label()
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
98 hPanel.add(self.status)
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
99
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
100 self.vPanel.add(hPanel)
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 self.add(self.vPanel)
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
103 self.addFormHandler(self)
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
104
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
105 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
106 self.close_cb = close_cb
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
107
152
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
108 def onCloseBtnClick(self):
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
109 if self.close_cb:
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
110 self.close_cb()
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
111 else:
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
112 print ("WARNING: no close method defined")
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
113
152
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
114 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
115 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
116 return
152
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
117 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
118 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
119 self.submit()
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
120
152
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
121 def onSubmit(self, event):
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
122 pass
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
123
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
124 def onSubmitComplete(self, event):
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
125 result = event.getResults()
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
126 if result != "OK":
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
127 Window.alert('Something went wrong while submitting file')
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
128 self.close_cb()
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
129
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
130
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
131 class Menu(SimplePanel):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
132
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
133 def __init__(self, host):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
134 self.host = host
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
135 SimplePanel.__init__(self)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
136 self.setStyleName('menuContainer')
79
d57e0d6b1ced browser side: inclusion of Adrien's icons
Goffi <goffi@goffi.org>
parents: 78
diff changeset
137 _item_tpl = "<img src='media/icons/menu/%s_menu_red.png' />%s"
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
138
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
139 menu_general = MenuBar(vertical=True)
181
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 165
diff changeset
140 menu_general.addItem("Web widget", MenuCmd(self, "onWebWidget"))
158
58442ed28f2b browser side: basic disconnection management: hard reload is done on empty signal response
Goffi <goffi@goffi.org>
parents: 152
diff changeset
141 menu_general.addItem("Disconnect", MenuCmd(self, "onDisconnect"))
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
142
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
143 menu_contacts = MenuBar(vertical=True)
256
0e7f3944bd27 browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents: 242
diff changeset
144 menu_contacts.addItem("Add contact", MenuCmd(self, "onAddContact"))
0e7f3944bd27 browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents: 242
diff changeset
145 menu_contacts.addItem("Update contact", MenuCmd(self, "onUpdateContact"))
0e7f3944bd27 browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents: 242
diff changeset
146 menu_contacts.addItem("Remove contact", MenuCmd(self, "onRemoveContact"))
0e7f3944bd27 browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents: 242
diff changeset
147 menu_contacts.addItem("Manage groups", MenuCmd(self, "onManageContactGroups"))
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
148
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
149 menu_group = MenuBar(vertical=True)
256
0e7f3944bd27 browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents: 242
diff changeset
150 menu_group.addItem("Join room", MenuCmd(self, "onJoinRoom"))
125
f9d63624699f radio collective integration, first draft
Goffi <goffi@goffi.org>
parents: 103
diff changeset
151 menu_group.addItem("Collective radio", MenuCmd(self, "onCollectiveRadio"))
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
152
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
153 menu_games = MenuBar(vertical=True)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
154 menu_games.addItem("Tarot", MenuCmd(self, "onTarotGame"))
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
155 menu_games.addItem("Xiangqi", MenuCmd(self, "onXiangqiGame"))
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
156
79
d57e0d6b1ced browser side: inclusion of Adrien's icons
Goffi <goffi@goffi.org>
parents: 78
diff changeset
157 menu_help = MenuBar(vertical=True)
103
500a1529c191 added Social contract & About to help menu
Goffi <goffi@goffi.org>
parents: 79
diff changeset
158 menu_help.addItem("Social contract", MenuCmd(self, "onSocialContract"))
500a1529c191 added Social contract & About to help menu
Goffi <goffi@goffi.org>
parents: 79
diff changeset
159 menu_help.addItem("About", MenuCmd(self, "onAbout"))
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
160
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
161 self.menu_settings = MenuBar(vertical=True)
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
162 self.item_params = self.menu_settings.addItem("Parameters",
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
163 MenuCmd(self, "onParameters"))
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
164 # XXX: temporary, will change when a full profile will be managed in SàT
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
165 self.menu_settings.addItem("Upload avatar", MenuCmd(self, "onAvatarUpload"))
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
166
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
167 menubar = LiberviaMenuBar()
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
168
79
d57e0d6b1ced browser side: inclusion of Adrien's icons
Goffi <goffi@goffi.org>
parents: 78
diff changeset
169 for _name, _icon, _menu in [('General', 'home', menu_general),
d57e0d6b1ced browser side: inclusion of Adrien's icons
Goffi <goffi@goffi.org>
parents: 78
diff changeset
170 ('Contacts', 'social', menu_contacts),
d57e0d6b1ced browser side: inclusion of Adrien's icons
Goffi <goffi@goffi.org>
parents: 78
diff changeset
171 ('Groups', 'social', menu_group),
d57e0d6b1ced browser side: inclusion of Adrien's icons
Goffi <goffi@goffi.org>
parents: 78
diff changeset
172 ('Games', 'games', menu_games)]:
d57e0d6b1ced browser side: inclusion of Adrien's icons
Goffi <goffi@goffi.org>
parents: 78
diff changeset
173 menubar.addItem(MenuItem(_item_tpl % (_icon, _name), True, _menu))
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
174
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
175 _separator = MenuItem('', None)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
176 _separator.setStyleName('menuSeparator')
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
177 menubar.addItem(_separator, None)
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
178
79
d57e0d6b1ced browser side: inclusion of Adrien's icons
Goffi <goffi@goffi.org>
parents: 78
diff changeset
179 for _name, _icon, _menu in [('Help', 'help', menu_help),
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
180 ('Settings', 'settings', self.menu_settings)]:
79
d57e0d6b1ced browser side: inclusion of Adrien's icons
Goffi <goffi@goffi.org>
parents: 78
diff changeset
181 menubar.addItem(MenuItem(_item_tpl % (_icon, _name), True, _menu))
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
182
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
183 self.add(menubar)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
184
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
185 #General menu
181
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 165
diff changeset
186 def onWebWidget(self):
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 165
diff changeset
187 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
188 self.host.addWidget(web_panel)
377de26d5bc2 browser_side: open the web widget in the current tab
souliane <souliane@mailoo.org>
parents: 256
diff changeset
189 self.host.setSelected(web_panel)
181
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 165
diff changeset
190
158
58442ed28f2b browser side: basic disconnection management: hard reload is done on empty signal response
Goffi <goffi@goffi.org>
parents: 152
diff changeset
191 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
192 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
193 if answer:
242
a25aa882e09a browser_side: add context menu for contact:
souliane <souliane@mailoo.org>
parents: 238
diff changeset
194 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
195 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
196 _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
197 _dialog.show()
58442ed28f2b browser side: basic disconnection management: hard reload is done on empty signal response
Goffi <goffi@goffi.org>
parents: 152
diff changeset
198
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
199 def onSocialContract(self):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
200 _frame = Frame('contrat_social.html')
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
201 _frame.setStyleName('infoFrame')
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
202 _dialog = dialog.GenericDialog("Contrat Social", _frame)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
203 _dialog.setSize('80%', '80%')
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
204 _dialog.show()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
205
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
206 def onAbout(self):
147
60ea800b7237 browser side: fixed about menu + updated website URL
Goffi <goffi@goffi.org>
parents: 131
diff changeset
207 _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
208 <br />
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
209 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
210 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
211 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
212 <br />
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
213 Any help welcome :)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
214 <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
215 """)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
216 _dialog = dialog.GenericDialog("About", _about)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
217 _dialog.show()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
218
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
219 #Contact menu
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
220 def onAddContact(self):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
221 """Q&D contact addition"""
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
222 _dialog = None
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
223 edit = TextBox()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
224
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
225 def addContactCb(sender):
242
a25aa882e09a browser_side: add context menu for contact:
souliane <souliane@mailoo.org>
parents: 238
diff changeset
226 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
227 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
228 _dialog.show()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
229 else:
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
230 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
231
268
79970bf6af93 browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents: 257
diff changeset
232 label = Label("New contact identifier (JID):")
242
a25aa882e09a browser_side: add context menu for contact:
souliane <souliane@mailoo.org>
parents: 238
diff changeset
233 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
234 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
235 _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
236 "Add", addContactCb)
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
237 _dialog.setHTML('Adding contact')
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
238 _dialog.show()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
239
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
240 def onUpdateContact(self):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
241 _dialog = None
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
242 _contacts_list = ListBox()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
243
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
244 def updateContactCb(sender):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
245 _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
246 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
247
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
248 def onContactChange(_list):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
249 _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
250 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
251 _dialog.setGroupsSelected(groups)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
252
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
253 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
254 _contacts_list.addItem(contact)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
255 _contacts_list.addChangeListener(onContactChange)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
256 _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
257 _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
258 _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
259 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
260 "Update", updateContactCb)
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
261 _dialog.setHTML('Updating contact')
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
262 _dialog.show()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
263
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
264 def onRemoveContact(self):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
265 _dialog = None
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
266 _contacts_list = ListBox()
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
267
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
268 def secondConfirmCb(confirm):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
269 if confirm:
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
270 for contact in _contacts_list.getSelectedValues():
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
271 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
272 else:
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
273 _dialog.show()
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 dialogCb(confirm):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
276 if confirm:
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
277 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
278 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
279 dialog.ConfirmDialog(secondConfirmCb, html_body).show()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
280
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
281 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
282 _contacts_list.addItem(contact)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
283 _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
284 _dialog.show()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
285
256
0e7f3944bd27 browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents: 242
diff changeset
286 def onManageContactGroups(self):
0e7f3944bd27 browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents: 242
diff changeset
287 """Open the contact groups manager."""
0e7f3944bd27 browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents: 242
diff changeset
288
0e7f3944bd27 browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents: 242
diff changeset
289 def onCloseCallback():
0e7f3944bd27 browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents: 242
diff changeset
290 pass
0e7f3944bd27 browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents: 242
diff changeset
291
0e7f3944bd27 browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents: 242
diff changeset
292 ContactGroupEditor(self.host, None, onCloseCallback)
0e7f3944bd27 browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents: 242
diff changeset
293
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
294 #Group menu
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
295 def onJoinRoom(self):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
296
268
79970bf6af93 browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents: 257
diff changeset
297 def invite(room_jid, contacts):
79970bf6af93 browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents: 257
diff changeset
298 for contact in contacts:
79970bf6af93 browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents: 257
diff changeset
299 self.host.bridge.call('inviteMUC', None, contact, room_jid)
79970bf6af93 browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents: 257
diff changeset
300
79970bf6af93 browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents: 257
diff changeset
301 def join(room_jid, contacts):
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
302 if self.host.whoami:
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
303 nick = self.host.whoami.node
268
79970bf6af93 browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents: 257
diff changeset
304 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
305 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
306 else:
79970bf6af93 browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents: 257
diff changeset
307 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
308 invite(room_jid, contacts)
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
309
268
79970bf6af93 browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents: 257
diff changeset
310 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
311
125
f9d63624699f radio collective integration, first draft
Goffi <goffi@goffi.org>
parents: 103
diff changeset
312 def onCollectiveRadio(self):
268
79970bf6af93 browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents: 257
diff changeset
313 def callback(room_jid, contacts):
79970bf6af93 browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents: 257
diff changeset
314 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
315 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
316
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
317 #Game menu
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
318 def onTarotGame(self):
268
79970bf6af93 browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents: 257
diff changeset
319 def onPlayersSelected(room_jid, other_players):
79970bf6af93 browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents: 257
diff changeset
320 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
321 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
322
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
323 def onXiangqiGame(self):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
324 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
325
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
326 #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
327
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
328 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
329 def gotParams(xmlui):
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
330 if not xmlui:
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
331 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
332 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
333 _dialog = dialog.GenericDialog("Parameters", body, options=['NO_CLOSE'])
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
334 body.setCloseCb(_dialog.close)
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
335 _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
336 _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
337 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
338
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
339 def removeItemParams(self):
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
340 """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
341 self.menu_settings.removeItem(self.item_params)
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
342
152
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
343 def onAvatarUpload(self):
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
344 body = AvatarUpload()
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
345 _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
346 body.setCloseCb(_dialog.close)
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
347 _dialog.setSize('40%', '40%')
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
348 _dialog.show()