annotate browser_side/menu.py @ 218:4e6467efd6bf

browser_side: small improvements for parameters panel - auto-select the first tab - remove the parameters item if there's nothing to display
author souliane <souliane@mailoo.org>
date Sat, 07 Sep 2013 19:54:41 +0200
parents e830a0c60d32
children 09e4de9df5b7
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
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
40 from xmlui import XMLUI
181
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 165
diff changeset
41 import panels
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
42 import dialog
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
43 import re
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
44
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
45
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
46 class MenuCmd:
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
47
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
48 def __init__(self, object, handler):
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
49 self._object = object
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
50 self._handler = handler
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
51
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
52 def execute(self):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
53 handler = getattr(self._object, self._handler)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
54 handler()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
55
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
56
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
57 class LiberviaMenuBar(MenuBar):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
58
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
59 def __init__(self):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
60 MenuBar.__init__(self, vertical=False)
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
61
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
62 def doItemAction(self, item, fireCommand):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
63 MenuBar.doItemAction(self, item, fireCommand)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
64 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
65 self.popup.setPopupPosition(Window.getClientWidth() -
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
66 self.popup.getOffsetWidth() - 22,
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
67 self.getAbsoluteTop() +
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
68 self.getOffsetHeight() - 1)
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
69 self.popup.addStyleName('menuLastPopup')
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
70
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
71
152
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
72 class AvatarUpload(FormPanel):
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
73
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
74 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
75 FormPanel.__init__(self)
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
76 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
77 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
78 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
79 self.setAction("upload_avatar")
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
80 self.vPanel = VerticalPanel()
183
a50ce9c06e0e browser side: fixed typo
Goffi <goffi@goffi.org>
parents: 181
diff changeset
81 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
82 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
83
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
84 hPanel = HorizontalPanel()
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
85 hPanel.setSpacing(5)
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
86 self.file_upload = FileUpload()
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
87 self.file_upload.setName("avatar_path")
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
88 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
89
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
90 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
91 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
92 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
93
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
94 self.status = Label()
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
95 hPanel.add(self.status)
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.vPanel.add(hPanel)
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
98
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
99 self.add(self.vPanel)
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
100 self.addFormHandler(self)
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 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
103 self.close_cb = close_cb
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
104
152
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
105 def onCloseBtnClick(self):
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
106 if self.close_cb:
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
107 self.close_cb()
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
108 else:
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
109 print ("WARNING: no close method defined")
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
110
152
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
111 def onSubmitBtnClick(self):
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
112 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
113 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
114 self.submit()
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
115
152
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
116 def onSubmit(self, event):
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
117 pass
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
118
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
119 def onSubmitComplete(self, event):
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
120 result = event.getResults()
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
121 if result != "OK":
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
122 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
123 self.close_cb()
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
124
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
125
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
126 class Menu(SimplePanel):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
127
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
128 def __init__(self, host):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
129 self.host = host
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
130 SimplePanel.__init__(self)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
131 self.setStyleName('menuContainer')
79
d57e0d6b1ced browser side: inclusion of Adrien's icons
Goffi <goffi@goffi.org>
parents: 78
diff changeset
132 _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
133
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
134 menu_general = MenuBar(vertical=True)
181
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 165
diff changeset
135 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
136 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
137
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
138 menu_contacts = MenuBar(vertical=True)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
139 menu_contacts.addItem("add contact", MenuCmd(self, "onAddContact"))
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
140 menu_contacts.addItem("update contact", MenuCmd(self, "onUpdateContact"))
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
141 menu_contacts.addItem("remove contact", MenuCmd(self, "onRemoveContact"))
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_group = MenuBar(vertical=True)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
144 menu_group.addItem("join room", MenuCmd(self, "onJoinRoom"))
125
f9d63624699f radio collective integration, first draft
Goffi <goffi@goffi.org>
parents: 103
diff changeset
145 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
146
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
147 menu_games = MenuBar(vertical=True)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
148 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
149 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
150
79
d57e0d6b1ced browser side: inclusion of Adrien's icons
Goffi <goffi@goffi.org>
parents: 78
diff changeset
151 menu_help = MenuBar(vertical=True)
103
500a1529c191 added Social contract & About to help menu
Goffi <goffi@goffi.org>
parents: 79
diff changeset
152 menu_help.addItem("Social contract", MenuCmd(self, "onSocialContract"))
500a1529c191 added Social contract & About to help menu
Goffi <goffi@goffi.org>
parents: 79
diff changeset
153 menu_help.addItem("About", MenuCmd(self, "onAbout"))
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
154
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
155 self.menu_settings = MenuBar(vertical=True)
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
156 self.item_params = self.menu_settings.addItem("Parameters",
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
157 MenuCmd(self, "onParameters"))
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
158 # 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
159 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
160
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
161 menubar = LiberviaMenuBar()
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
162
79
d57e0d6b1ced browser side: inclusion of Adrien's icons
Goffi <goffi@goffi.org>
parents: 78
diff changeset
163 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
164 ('Contacts', 'social', menu_contacts),
d57e0d6b1ced browser side: inclusion of Adrien's icons
Goffi <goffi@goffi.org>
parents: 78
diff changeset
165 ('Groups', 'social', menu_group),
d57e0d6b1ced browser side: inclusion of Adrien's icons
Goffi <goffi@goffi.org>
parents: 78
diff changeset
166 ('Games', 'games', menu_games)]:
d57e0d6b1ced browser side: inclusion of Adrien's icons
Goffi <goffi@goffi.org>
parents: 78
diff changeset
167 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
168
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
169 _separator = MenuItem('', None)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
170 _separator.setStyleName('menuSeparator')
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
171 menubar.addItem(_separator, None)
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
172
79
d57e0d6b1ced browser side: inclusion of Adrien's icons
Goffi <goffi@goffi.org>
parents: 78
diff changeset
173 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
174 ('Settings', 'settings', self.menu_settings)]:
79
d57e0d6b1ced browser side: inclusion of Adrien's icons
Goffi <goffi@goffi.org>
parents: 78
diff changeset
175 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
176
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
177 self.add(menubar)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
178
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
179 #General menu
181
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 165
diff changeset
180 def onWebWidget(self):
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 165
diff changeset
181 web_panel = panels.WebPanel(self.host, "http://www.goffi.org")
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 165
diff changeset
182 self.host.addTab(web_panel, "Web widget")
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 165
diff changeset
183
158
58442ed28f2b browser side: basic disconnection management: hard reload is done on empty signal response
Goffi <goffi@goffi.org>
parents: 152
diff changeset
184 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
185 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
186 if answer:
58442ed28f2b browser side: basic disconnection management: hard reload is done on empty signal response
Goffi <goffi@goffi.org>
parents: 152
diff changeset
187 print "déconnexion"
58442ed28f2b browser side: basic disconnection management: hard reload is done on empty signal response
Goffi <goffi@goffi.org>
parents: 152
diff changeset
188 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
189 _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
190 _dialog.show()
58442ed28f2b browser side: basic disconnection management: hard reload is done on empty signal response
Goffi <goffi@goffi.org>
parents: 152
diff changeset
191
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
192 def onSocialContract(self):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
193 _frame = Frame('contrat_social.html')
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
194 _frame.setStyleName('infoFrame')
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
195 _dialog = dialog.GenericDialog("Contrat Social", _frame)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
196 _dialog.setSize('80%', '80%')
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
197 _dialog.show()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
198
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
199 def onAbout(self):
147
60ea800b7237 browser side: fixed about menu + updated website URL
Goffi <goffi@goffi.org>
parents: 131
diff changeset
200 _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
201 <br />
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
202 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
203 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
204 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
205 <br />
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
206 Any help welcome :)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
207 <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
208 """)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
209 _dialog = dialog.GenericDialog("About", _about)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
210 _dialog.show()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
211
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
212 #Contact menu
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
213 def onAddContact(self):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
214 """Q&D contact addition"""
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
215 _dialog = None
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
216 edit = TextBox()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
217
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
218 def addContactCb(sender):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
219 if not re.match(r'^.+@.+\..+',edit.getText(), re.IGNORECASE):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
220 Window.alert('You must enter a valid contact JID (like "contact@libervia.org")')
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
221 _dialog.show()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
222 else:
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
223 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
224
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
225 label = Label("new contact identifier (JID):")
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
226 edit.setText('@libervia.org')
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
227 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
228 _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
229 "Add", addContactCb)
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
230 _dialog.setHTML('Adding contact')
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
231 _dialog.show()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
232
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
233 def onUpdateContact(self):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
234 _dialog = None
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
235 _contacts_list = ListBox()
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 updateContactCb(sender):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
238 _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
239 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
240
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
241 def onContactChange(_list):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
242 _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
243 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
244 _dialog.setGroupsSelected(groups)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
245
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
246 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
247 _contacts_list.addItem(contact)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
248 _contacts_list.addChangeListener(onContactChange)
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 _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
251 _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
252 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
253 "Update", updateContactCb)
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
254 _dialog.setHTML('Updating contact')
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
255 _dialog.show()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
256
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
257 def onRemoveContact(self):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
258 _dialog = None
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
259 _contacts_list = ListBox()
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
260
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
261 def secondConfirmCb(confirm):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
262 if confirm:
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
263 for contact in _contacts_list.getSelectedValues():
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
264 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
265 else:
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
266 _dialog.show()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
267
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
268 def dialogCb(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 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
271 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
272 dialog.ConfirmDialog(secondConfirmCb, html_body).show()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
273
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
274 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
275 _contacts_list.addItem(contact)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
276 _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
277 _dialog.show()
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 #Group menu
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
280 def onJoinRoom(self):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
281 _dialog = None
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
282 _edit = None
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 def onOK(sender):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
285 if not _edit.getText():
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
286 Window.alert('You must enter a room jid in the form libervia@conference.libervia.org')
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
287 if self.host.whoami:
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
288 nick = self.host.whoami.node
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
289 self.host.bridge.call('joinMUC', None, _edit.getText(), nick)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
290 _dialog.hide()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
291
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
292 def onCancel(sender):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
293 _dialog.hide()
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 _main_panel = VerticalPanel()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
296 _label = Label("Discussion room:")
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
297 _edit = TextBox()
162
6ebf7f872a38 browser side: changed default MUC room for sat@chat.jabberfr.org
Goffi <goffi@goffi.org>
parents: 158
diff changeset
298 _edit.setText('sat@chat.jabberfr.org')
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
299 hpanel = HorizontalPanel()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
300 hpanel.add(_label)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
301 hpanel.add(_edit)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
302 _main_panel.add(hpanel)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
303 button_panel = HorizontalPanel()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
304 button_panel.add(Button("Join", onOK))
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
305 button_panel.add(Button("Cancel", onCancel))
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
306 _main_panel.add(button_panel)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
307 _dialog = DialogBox(centered=True)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
308 _dialog.setHTML('Group discussions')
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
309 _dialog.setWidget(_main_panel)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
310 _dialog.show()
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):
f9d63624699f radio collective integration, first draft
Goffi <goffi@goffi.org>
parents: 103
diff changeset
313 def onContactsSelected(contacts):
f9d63624699f radio collective integration, first draft
Goffi <goffi@goffi.org>
parents: 103
diff changeset
314 print("let's go :)")
f9d63624699f radio collective integration, first draft
Goffi <goffi@goffi.org>
parents: 103
diff changeset
315 self.host.bridge.call('launchRadioCollective', None, contacts)
f9d63624699f radio collective integration, first draft
Goffi <goffi@goffi.org>
parents: 103
diff changeset
316 dialog.ContactsChooser(self.host, onContactsSelected, None, text="Please select contacts to invite").getContacts()
78
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
317
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
318 #Game menu
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
319
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
320 def onTarotGame(self):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
321 #Window.alert("Tarot selected")
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
322 #self.host.tab_panel.add(EmptyPanel(self.host), "Tarot")
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
323 def onPlayersSelected(other_players):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
324 self.host.bridge.call('launchTarotGame', None, other_players)
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
325 dialog.ContactsChooser(self.host, onPlayersSelected, 3, text="Please select 3 other players").getContacts()
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
326
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
327 def onXiangqiGame(self):
12680e220b35 browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff changeset
328 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
329
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
330 #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
331
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 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
333 def gotParams(xmlui):
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
334 if not xmlui:
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
335 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
336 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
337 _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
338 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
339 _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
340 _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
341 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
342
218
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
343 def removeItemParams(self):
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
344 """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
345 self.menu_settings.removeItem(self.item_params)
4e6467efd6bf browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents: 215
diff changeset
346
152
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
347 def onAvatarUpload(self):
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
348 body = AvatarUpload()
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
349 _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
350 body.setCloseCb(_dialog.close)
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
351 _dialog.setSize('40%', '40%')
7e87c87b7952 browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents: 148
diff changeset
352 _dialog.show()