Mercurial > libervia-web
annotate src/browser/sat_browser/menu.py @ 589:a5019e62c3e9 frontends_multi_profiles
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
/!\ not finished, partially working and highly instable
- add collections module with an OrderedDict like class
- SatWebFrontend inherit from QuickApp
- general sat_frontends tools.jid module is used
- bridge/json methods have moved to json module
- UniBox is partially removed (should be totally removed before merge to trunk)
- Signals are now register with the generic registerSignal method (which is called mainly in QuickFrontend)
- the generic getOrCreateWidget method from QuickWidgetsManager is used instead of Libervia's specific methods
- all Widget are now based more or less directly on QuickWidget
- with the new QuickWidgetsManager.getWidgets method, it's no more necessary to check all widgets which are instance of a particular class
- ChatPanel and related moved to chat module
- MicroblogPanel and related moved to blog module
- global and overcomplicated send method has been disabled: each class should manage its own sending
- for consistency with other frontends, former ContactPanel has been renamed to ContactList and vice versa
- for the same reason, ChatPanel has been renamed to Chat
- for compatibility with QuickFrontend, a fake profile is used in several places, it is set to C.PROF_KEY_NONE (real profile is managed server side for obvious security reasons)
- changed default url for web panel to SàT website, and contact address to generic SàT contact address
- ContactList is based on QuickContactList, UI changes are done in update method
- bride call (now json module) have been greatly improved, in particular call can be done in the same way as for other frontends (bridge.method_name(arg1, arg2, ..., callback=cb, errback=eb). Blocking method must be called like async methods due to javascript architecture
- in bridge calls, a callback can now exists without errback
- hard reload on BridgeSignals remote error has been disabled, a better option should be implemented
- use of constants where that make sens, some style improvments
- avatars are temporarily disabled
- lot of code disabled, will be fixed or removed before merge
- various other changes, check diff for more details
server side: manage remote exception on getEntityData, removed getProfileJid call, added getWaitingConf, added getRoomsSubjects
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 24 Jan 2015 01:45:39 +0100 |
parents | b07f0fe2763a |
children | 6016c74ee323 |
rev | line source |
---|---|
78
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 #!/usr/bin/python |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
4 # Libervia: a Salut à Toi frontend |
340 | 5 # Copyright (C) 2011, 2012, 2013, 2014 Jérôme Poisson <goffi@goffi.org> |
78
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
10 # (at your option) any later version. |
78
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
15 # GNU Affero General Public License for more details. |
78
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
336
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
78
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 |
387
933bce4cb816
browser_side: factorize the code from AvatarUpload to a new class FileUploadPanel
souliane <souliane@mailoo.org>
parents:
377
diff
changeset
|
20 import pyjd # this is dummy in pyjs |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
21 from sat.core.log import getLogger |
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
22 log = getLogger(__name__) |
449
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
23 |
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
24 from sat.core.i18n import _ |
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
25 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
26 from sat_frontends.tools import jid |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
27 |
78
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 from pyjamas.ui.SimplePanel import SimplePanel |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 from pyjamas.ui.HTML import HTML |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 from pyjamas.ui.Frame import Frame |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 from pyjamas import Window |
449
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
32 |
494
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
492
diff
changeset
|
33 from constants import Const as C |
467 | 34 import file_tools |
35 import xmlui | |
449
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
36 import panels |
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
37 import dialog |
467 | 38 import contact_group |
494
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
492
diff
changeset
|
39 import base_menu |
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
492
diff
changeset
|
40 from base_menu import MenuCmd |
336
629c99bbd031
browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
41 |
629c99bbd031
browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
42 |
494
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
492
diff
changeset
|
43 class MainMenuBar(base_menu.GenericMenuBar): |
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
492
diff
changeset
|
44 """The main menu bar which is displayed on top of the document""" |
78
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
45 |
494
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
492
diff
changeset
|
46 ITEM_TPL = "<img src='media/icons/menu/%s_menu_red.png' />%s" |
218
4e6467efd6bf
browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents:
215
diff
changeset
|
47 |
494
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
492
diff
changeset
|
48 def __init__(self, host): |
498
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
49 styles = {'moved_popup': 'menuLastPopup', 'menu_bar': 'mainMenuBar'} |
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
50 base_menu.GenericMenuBar.__init__(self, host, vertical=False, styles=styles) |
494
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
492
diff
changeset
|
51 |
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
492
diff
changeset
|
52 @classmethod |
502
4aa627b059df
browser_side: categories of the menus can be "flattened":
souliane <souliane@mailoo.org>
parents:
500
diff
changeset
|
53 def getCategoryHTML(cls, menu_name_i18n, type_): |
494
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
492
diff
changeset
|
54 return cls.ITEM_TPL % (type_, menu_name_i18n) |
78
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 |
494
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
492
diff
changeset
|
57 class MainMenuPanel(SimplePanel): |
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
492
diff
changeset
|
58 """Container for the main menu bar""" |
78
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
59 |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
60 def __init__(self, host): |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
61 self.host = host |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
62 SimplePanel.__init__(self) |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
63 self.setStyleName('menuContainer') |
494
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
492
diff
changeset
|
64 self.menu_bar = MainMenuBar(self.host) |
336
629c99bbd031
browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
65 |
498
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
66 def addMenuItem(self, *args): |
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
67 self.menu_bar.addMenuItem(*args) |
78
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
68 |
509
35ccb3ff8245
browser_side: add method GenericMenuBar.addCategory + fixes MenuNode.addMenuItem when callback argument is a sub-menu
souliane <souliane@mailoo.org>
parents:
502
diff
changeset
|
69 def addCategory(self, *args): |
35ccb3ff8245
browser_side: add method GenericMenuBar.addCategory + fixes MenuNode.addMenuItem when callback argument is a sub-menu
souliane <souliane@mailoo.org>
parents:
502
diff
changeset
|
70 self.menu_bar.addCategory(*args) |
35ccb3ff8245
browser_side: add method GenericMenuBar.addCategory + fixes MenuNode.addMenuItem when callback argument is a sub-menu
souliane <souliane@mailoo.org>
parents:
502
diff
changeset
|
71 |
494
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
492
diff
changeset
|
72 def createMenus(self): |
498
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
73 self.addMenuItem("General", [_("General"), _("Web widget")], 'home', MenuCmd(self, "onWebWidget")) |
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
74 self.addMenuItem("General", [_("General"), _("Disconnect")], 'home', MenuCmd(self, "onDisconnect")) |
509
35ccb3ff8245
browser_side: add method GenericMenuBar.addCategory + fixes MenuNode.addMenuItem when callback argument is a sub-menu
souliane <souliane@mailoo.org>
parents:
502
diff
changeset
|
75 self.addCategory("Contacts", _("Contacts"), 'social') # save the position for this category |
498
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
76 self.addMenuItem("Groups", [_("Groups"), _("Discussion")], 'social', MenuCmd(self, "onJoinRoom")) |
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
77 self.addMenuItem("Groups", [_("Groups"), _("Collective radio")], 'social', MenuCmd(self, "onCollectiveRadio")) |
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
78 self.addMenuItem("Games", [_("Games"), _("Tarot")], 'games', MenuCmd(self, "onTarotGame")) |
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
79 self.addMenuItem("Games", [_("Games"), _("Xiangqi")], 'games', MenuCmd(self, "onXiangqiGame")) |
78
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
80 |
336
629c99bbd031
browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
81 # additional menus |
498
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
82 self.menu_bar.addCachedMenus(C.MENU_GLOBAL) |
218
4e6467efd6bf
browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents:
215
diff
changeset
|
83 |
431
4fcf9bac109c
browser_side: roster management menus are now imported from the backend
souliane <souliane@mailoo.org>
parents:
392
diff
changeset
|
84 # menu items that should be displayed after the automatically added ones |
498
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
85 self.addMenuItem("Contacts", [_("Contacts"), _("Manage groups")], 'social', MenuCmd(self, "onManageContactGroups")) |
431
4fcf9bac109c
browser_side: roster management menus are now imported from the backend
souliane <souliane@mailoo.org>
parents:
392
diff
changeset
|
86 |
494
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
492
diff
changeset
|
87 self.menu_bar.addSeparator() |
336
629c99bbd031
browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
88 |
498
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
89 self.addMenuItem("Help", [_("Help"), _("Social contract")], 'help', MenuCmd(self, "onSocialContract")) |
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
90 self.addMenuItem("Help", [_("Help"), _("About")], 'help', MenuCmd(self, "onAbout")) |
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
91 self.addMenuItem("Settings", [_("Settings"), _("Account")], 'settings', MenuCmd(self, "onAccount")) |
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
92 self.addMenuItem("Settings", [_("Settings"), _("Parameters")], 'settings', MenuCmd(self, "onParameters")) |
336
629c99bbd031
browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
93 |
218
4e6467efd6bf
browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents:
215
diff
changeset
|
94 # XXX: temporary, will change when a full profile will be managed in SàT |
498
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
95 self.addMenuItem("Settings", [_("Settings"), _("Upload avatar")], 'settings', MenuCmd(self, "onAvatarUpload")) |
218
4e6467efd6bf
browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents:
215
diff
changeset
|
96 |
494
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
492
diff
changeset
|
97 self.add(self.menu_bar) |
218
4e6467efd6bf
browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents:
215
diff
changeset
|
98 |
494
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
492
diff
changeset
|
99 # General menu |
181
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
100 def onWebWidget(self): |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
101 web_widget = self.host.widgets.getOrCreateWidget(panels.WebPanel, C.WEB_PANEL_DEFAULT_URL, profile=C.PROF_KEY_NONE) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
102 self.host.setSelected(web_widget) |
181
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
103 |
158
58442ed28f2b
browser side: basic disconnection management: hard reload is done on empty signal response
Goffi <goffi@goffi.org>
parents:
152
diff
changeset
|
104 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
|
105 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
|
106 if answer: |
529
9bfd71e2b35c
plugin OTR: disconnect the active OTR sessions on profile disconnection
souliane <souliane@mailoo.org>
parents:
509
diff
changeset
|
107 # FIXME: are we sure the triggers finished their jobs when the backend disconnect? |
9bfd71e2b35c
plugin OTR: disconnect the active OTR sessions on profile disconnection
souliane <souliane@mailoo.org>
parents:
509
diff
changeset
|
108 # FIXME: disconnection on timeout is not handled yet... |
547
dd43132684b9
browser_side: fixes bug at profile disconnection
souliane <souliane@mailoo.org>
parents:
529
diff
changeset
|
109 for plugin in self.host.plugins.values(): |
dd43132684b9
browser_side: fixes bug at profile disconnection
souliane <souliane@mailoo.org>
parents:
529
diff
changeset
|
110 if hasattr(plugin, 'profileDisconnected'): |
529
9bfd71e2b35c
plugin OTR: disconnect the active OTR sessions on profile disconnection
souliane <souliane@mailoo.org>
parents:
509
diff
changeset
|
111 plugin.profileDisconnected() |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
112 log.info("disconnection") |
158
58442ed28f2b
browser side: basic disconnection management: hard reload is done on empty signal response
Goffi <goffi@goffi.org>
parents:
152
diff
changeset
|
113 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
|
114 _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
|
115 _dialog.show() |
58442ed28f2b
browser side: basic disconnection management: hard reload is done on empty signal response
Goffi <goffi@goffi.org>
parents:
152
diff
changeset
|
116 |
78
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
117 def onSocialContract(self): |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
118 _frame = Frame('contrat_social.html') |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
119 _frame.setStyleName('infoFrame') |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
120 _dialog = dialog.GenericDialog("Contrat Social", _frame) |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
121 _dialog.setSize('80%', '80%') |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
122 _dialog.show() |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
123 |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
124 def onAbout(self): |
147
60ea800b7237
browser side: fixed about menu + updated website URL
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
125 _about = HTML("""<b>Libervia</b>, a Salut à Toi project<br /> |
78
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
126 <br /> |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
127 You can contact the authors at <a href="mailto:contact@salut-a-toi.org">contact@salut-a-toi.org</a><br /> |
78
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
128 Blog available (mainly in french) at <a href="http://www.goffi.org" target="_blank">http://www.goffi.org</a><br /> |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
129 Project page: <a href="http://salut-a-toi.org"target="_blank">http://salut-a-toi.org</a><br /> |
78
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
130 <br /> |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
131 Any help welcome :) |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
132 <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
|
133 """) |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
134 _dialog = dialog.GenericDialog("About", _about) |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
135 _dialog.show() |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
136 |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
137 #Contact menu |
256
0e7f3944bd27
browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents:
242
diff
changeset
|
138 def onManageContactGroups(self): |
0e7f3944bd27
browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents:
242
diff
changeset
|
139 """Open the contact groups manager.""" |
0e7f3944bd27
browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents:
242
diff
changeset
|
140 |
0e7f3944bd27
browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents:
242
diff
changeset
|
141 def onCloseCallback(): |
0e7f3944bd27
browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents:
242
diff
changeset
|
142 pass |
0e7f3944bd27
browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents:
242
diff
changeset
|
143 |
467 | 144 contact_group.ContactGroupEditor(self.host, None, onCloseCallback) |
256
0e7f3944bd27
browser_side: added contact group manager based on ListManager
souliane <souliane@mailoo.org>
parents:
242
diff
changeset
|
145 |
78
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
146 #Group menu |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
147 def onJoinRoom(self): |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
148 |
268
79970bf6af93
browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents:
257
diff
changeset
|
149 def invite(room_jid, contacts): |
79970bf6af93
browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents:
257
diff
changeset
|
150 for contact in contacts: |
79970bf6af93
browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents:
257
diff
changeset
|
151 self.host.bridge.call('inviteMUC', None, contact, room_jid) |
79970bf6af93
browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents:
257
diff
changeset
|
152 |
79970bf6af93
browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents:
257
diff
changeset
|
153 def join(room_jid, contacts): |
78
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
154 if self.host.whoami: |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
155 nick = self.host.whoami.node |
268
79970bf6af93
browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents:
257
diff
changeset
|
156 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
|
157 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
|
158 else: |
574
b07f0fe2763a
browser_side: safer attributes handling in getOrCreateLiberviaWidget + use it to create MUC panels
souliane <souliane@mailoo.org>
parents:
547
diff
changeset
|
159 self.host.getOrCreateLiberviaWidget(panels.ChatPanel, {'item': room_jid, 'type_': "group"}, True, jid.JID(room_jid).bare) |
268
79970bf6af93
browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents:
257
diff
changeset
|
160 invite(room_jid, contacts) |
78
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
161 |
268
79970bf6af93
browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents:
257
diff
changeset
|
162 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
|
163 |
125
f9d63624699f
radio collective integration, first draft
Goffi <goffi@goffi.org>
parents:
103
diff
changeset
|
164 def onCollectiveRadio(self): |
268
79970bf6af93
browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents:
257
diff
changeset
|
165 def callback(room_jid, contacts): |
79970bf6af93
browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents:
257
diff
changeset
|
166 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
|
167 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
|
168 |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
169 #Game menu |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
170 def onTarotGame(self): |
268
79970bf6af93
browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents:
257
diff
changeset
|
171 def onPlayersSelected(room_jid, other_players): |
79970bf6af93
browser_side: added class RoomAndContactsChooser:
souliane <souliane@mailoo.org>
parents:
257
diff
changeset
|
172 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
|
173 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
|
174 |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
175 def onXiangqiGame(self): |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
176 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
|
177 |
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
|
178 #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
|
179 |
391
c86d7a8d2c1e
browser_side: added a dialog in Settings/Account to update/delete the XMPP account
souliane <souliane@mailoo.org>
parents:
387
diff
changeset
|
180 def onAccount(self): |
467 | 181 def gotUI(xml_ui): |
182 if not xml_ui: | |
391
c86d7a8d2c1e
browser_side: added a dialog in Settings/Account to update/delete the XMPP account
souliane <souliane@mailoo.org>
parents:
387
diff
changeset
|
183 return |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
498
diff
changeset
|
184 body = xmlui.create(self.host, xml_ui) |
464
bea9788f3170
browser and server sides: don't handle the "connectionError" signal anymore, we now use asyncConnect errback:
souliane <souliane@mailoo.org>
parents:
449
diff
changeset
|
185 _dialog = dialog.GenericDialog("Manage your account", body, options=['NO_CLOSE']) |
391
c86d7a8d2c1e
browser_side: added a dialog in Settings/Account to update/delete the XMPP account
souliane <souliane@mailoo.org>
parents:
387
diff
changeset
|
186 body.setCloseCb(_dialog.close) |
c86d7a8d2c1e
browser_side: added a dialog in Settings/Account to update/delete the XMPP account
souliane <souliane@mailoo.org>
parents:
387
diff
changeset
|
187 _dialog.show() |
c86d7a8d2c1e
browser_side: added a dialog in Settings/Account to update/delete the XMPP account
souliane <souliane@mailoo.org>
parents:
387
diff
changeset
|
188 self.host.bridge.call('getAccountDialogUI', gotUI) |
c86d7a8d2c1e
browser_side: added a dialog in Settings/Account to update/delete the XMPP account
souliane <souliane@mailoo.org>
parents:
387
diff
changeset
|
189 |
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
|
190 def onParameters(self): |
467 | 191 def gotParams(xml_ui): |
192 if not xml_ui: | |
218
4e6467efd6bf
browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents:
215
diff
changeset
|
193 return |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
498
diff
changeset
|
194 body = xmlui.create(self.host, xml_ui) |
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
|
195 _dialog = dialog.GenericDialog("Parameters", body, options=['NO_CLOSE']) |
336
629c99bbd031
browser + server side: refactored menus:
Goffi <goffi@goffi.org>
parents:
300
diff
changeset
|
196 body.setCloseCb(_dialog.close) |
148
8635bc9db9bf
added parameter management to test XMLUI, but it's currently deactivated for security reasons (need some configuration options) + separated mainTabPanel CSS from LiberviaTabPanel
Goffi <goffi@goffi.org>
parents:
147
diff
changeset
|
197 _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
|
198 _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
|
199 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
|
200 |
218
4e6467efd6bf
browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents:
215
diff
changeset
|
201 def removeItemParams(self): |
4e6467efd6bf
browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents:
215
diff
changeset
|
202 """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
|
203 self.menu_settings.removeItem(self.item_params) |
4e6467efd6bf
browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents:
215
diff
changeset
|
204 |
152
7e87c87b7952
browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents:
148
diff
changeset
|
205 def onAvatarUpload(self): |
494
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
492
diff
changeset
|
206 body = file_tools.AvatarUpload() |
152
7e87c87b7952
browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents:
148
diff
changeset
|
207 _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
|
208 body.setCloseCb(_dialog.close) |
392
f539f6f8ee9c
browser_side: standardize the dialogs size and buttons display:
souliane <souliane@mailoo.org>
parents:
391
diff
changeset
|
209 _dialog.setWidth('40%') |
152
7e87c87b7952
browser side: temporary avatar upload dialog is added to setting menu
Goffi <goffi@goffi.org>
parents:
148
diff
changeset
|
210 _dialog.show() |