annotate src/browser/sat_browser/panels.py @ 620:ac5881d683d3 frontends_multi_profiles

browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
author souliane <souliane@mailoo.org>
date Fri, 20 Feb 2015 19:38:11 +0100
parents 70872a83ef15
children 7113d40533d6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/python
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
3
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 334
diff changeset
4 # Libervia: a Salut à Toi frontend
340
ce5b33f499c5 dates update
Goffi <goffi@goffi.org>
parents: 339
diff changeset
5 # Copyright (C) 2011, 2012, 2013, 2014 Jérôme Poisson <goffi@goffi.org>
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
6
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 334
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: 334
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: 334
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: 334
diff changeset
10 # (at your option) any later version.
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
11
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 334
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: 334
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: 334
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: 334
diff changeset
15 # GNU Affero General Public License for more details.
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
16
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 334
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: 334
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
19
226
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
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: 433
diff changeset
21 from sat.core.log import getLogger
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
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: 442
diff changeset
23
620
ac5881d683d3 browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents: 615
diff changeset
24 from sat.core.i18n import _
449
981ed669d3b3 /!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents: 442
diff changeset
25 from sat_frontends.tools.strings import addURLToText
981ed669d3b3 /!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents: 442
diff changeset
26
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
27 from pyjamas.ui.AbsolutePanel import AbsolutePanel
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
28 from pyjamas.ui.VerticalPanel import VerticalPanel
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
29 from pyjamas.ui.HorizontalPanel import HorizontalPanel
73
447dc8ac181b Adrien's uniBox design integration + lastPopup style
Goffi <goffi@goffi.org>
parents: 71
diff changeset
30 from pyjamas.ui.TextArea import TextArea
83
68d360caeecb New widget system: first draft
Goffi <goffi@goffi.org>
parents: 78
diff changeset
31 from pyjamas.ui.Button import Button
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
32 from pyjamas.ui.HTML import HTML
19
e8e3704eb97f Added basic chat panel
Goffi <goffi@goffi.org>
parents: 18
diff changeset
33 from pyjamas.ui.ClickListener import ClickHandler
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
34 from pyjamas.ui.KeyboardListener import KEY_ENTER, KEY_UP, KEY_DOWN
186
72bb1d845b6a browser side: global resize on UniBox resize
Goffi <goffi@goffi.org>
parents: 185
diff changeset
35 from pyjamas.ui.MouseListener import MouseHandler
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
36 from pyjamas.ui.Frame import Frame
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
37 from pyjamas.Timer import Timer
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
38 from pyjamas import Window
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
39 from pyjamas import DOM
323
0b7934e75e76 misc: reorganization of the file panels.py + clean the modules import:
souliane <souliane@mailoo.org>
parents: 322
diff changeset
40 from __pyjamas__ import doc
0b7934e75e76 misc: reorganization of the file panels.py + clean the modules import:
souliane <souliane@mailoo.org>
parents: 322
diff changeset
41
449
981ed669d3b3 /!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents: 442
diff changeset
42
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 463
diff changeset
43 import base_panels
510
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
44 import base_menu
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 463
diff changeset
45 import menu
449
981ed669d3b3 /!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents: 442
diff changeset
46 import dialog
981ed669d3b3 /!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents: 442
diff changeset
47 import base_widget
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
48 import contact_list
433
bbdbee25123a import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents: 432
diff changeset
49 from constants import Const as C
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
50 from sat_frontends.quick_frontend import quick_widgets
442
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
51
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
52
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
53 # class UniBoxPanel(HorizontalPanel):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
54 # """Panel containing the UniBox"""
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
55 #
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
56 # def __init__(self, host):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
57 # HorizontalPanel.__init__(self)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
58 # self.host = host
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
59 # self.setStyleName('uniBoxPanel')
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
60 # self.unibox = None
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
61 #
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
62 # def refresh(self):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
63 # """Enable or disable this panel. Contained widgets are created when necessary."""
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
64 # enable = self.host.getCachedParam(C.COMPOSITION_KEY, C.ENABLE_UNIBOX_PARAM) == 'true'
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
65 # self.setVisible(enable)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
66 # if enable and not self.unibox:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
67 # self.button = Button('<img src="media/icons/tango/actions/32/format-text-italic.png" class="richTextIcon"/>')
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
68 # self.button.setTitle('Open the rich text editor')
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
69 # self.button.addStyleName('uniBoxButton')
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
70 # self.add(self.button)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
71 # self.unibox = UniBox(self.host)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
72 # self.add(self.unibox)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
73 # self.setCellWidth(self.unibox, '100%')
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
74 # self.button.addClickListener(self.openRichMessageEditor)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
75 # self.unibox.addKey("@@: ")
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
76 # self.unibox.onSelectedChange(self.host.getSelected())
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
77 #
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
78 # def openRichMessageEditor(self):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
79 # """Open the rich text editor."""
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
80 # self.button.setVisible(False)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
81 # self.unibox.setVisible(False)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
82 # self.setCellWidth(self.unibox, '0px')
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
83 # self.host.panel._contactsMove(self)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
84 #
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
85 # def afterEditCb():
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
86 # Window.removeWindowResizeListener(self)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
87 # self.host.panel._contactsMove(self.host.panel._hpanel)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
88 # self.setCellWidth(self.unibox, '100%')
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
89 # self.button.setVisible(True)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
90 # self.unibox.setVisible(True)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
91 # self.host.resize()
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
92 #
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
93 # richtext.RichMessageEditor.getOrCreate(self.host, self, afterEditCb)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
94 # Window.addWindowResizeListener(self)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
95 # self.host.resize()
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
96 #
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
97 # def onWindowResized(self, width, height):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
98 # right = self.host.panel.menu.getAbsoluteLeft() + self.host.panel.menu.getOffsetWidth()
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
99 # left = self.host.panel._contacts.getAbsoluteLeft() + self.host.panel._contacts.getOffsetWidth()
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
100 # ideal_width = right - left - 40
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
101 # self.host.richtext.setWidth("%spx" % ideal_width)
292
1a5dc08c2749 browser_side: set the ideal width for the rich text dialog when displayed in the unibox panel
souliane <souliane@mailoo.org>
parents: 291
diff changeset
102
210
3092f6b1710c browser side: make the OK button title for group selector configureable + few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents: 206
diff changeset
103
310
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
104 class MessageBox(TextArea):
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
105 """A basic text area for entering messages"""
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
106
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
107 def __init__(self, host):
73
447dc8ac181b Adrien's uniBox design integration + lastPopup style
Goffi <goffi@goffi.org>
parents: 71
diff changeset
108 TextArea.__init__(self)
310
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
109 self.host = host
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
110 self.size = (0, 0)
310
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
111 self.setStyleName('messageBox')
83
68d360caeecb New widget system: first draft
Goffi <goffi@goffi.org>
parents: 78
diff changeset
112 self.addKeyboardListener(self)
186
72bb1d845b6a browser side: global resize on UniBox resize
Goffi <goffi@goffi.org>
parents: 185
diff changeset
113 MouseHandler.__init__(self)
72bb1d845b6a browser side: global resize on UniBox resize
Goffi <goffi@goffi.org>
parents: 185
diff changeset
114 self.addMouseListener(self)
310
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
115
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
116 def onBrowserEvent(self, event):
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
117 # XXX: woraroung a pyjamas bug: self.currentEvent is not set
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
118 # so the TextBox's cancelKey doens't work. This is a workaround
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
119 # FIXME: fix the bug upstream
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
120 self.currentEvent = event
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
121 TextArea.onBrowserEvent(self, event)
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
122
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
123 def onKeyPress(self, sender, keycode, modifiers):
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
124 _txt = self.getText()
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
125
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
126 def history_cb(text):
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
127 self.setText(text)
422
20c508f9b32a browser side: fixed bad use of Timer
Goffi <goffi@goffi.org>
parents: 414
diff changeset
128 Timer(5, lambda timer: self.setCursorPos(len(text)))
310
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
129
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
130 if keycode == KEY_ENTER:
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
131 if _txt:
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
132 self.host.selected_widget.onTextEntered(_txt)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
133 self.host._updateInputHistory(_txt) # FIXME: why using a global variable ?
310
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
134 self.setText('')
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
135 sender.cancelKey()
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
136 elif keycode == KEY_UP:
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
137 self.host._updateInputHistory(_txt, -1, history_cb)
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
138 elif keycode == KEY_DOWN:
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
139 self.host._updateInputHistory(_txt, +1, history_cb)
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
140 else:
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
141 self._onComposing()
310
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
142
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
143 def _onComposing(self):
310
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
144 """Callback when the user is composing a text."""
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
145 self.host.selected_widget.state_machine._onEvent("composing")
310
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
146
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
147 def onMouseUp(self, sender, x, y):
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
148 size = (self.getOffsetWidth(), self.getOffsetHeight())
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
149 if size != self.size:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
150 self.size = size
310
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
151 self.host.resize()
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
152
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
153 def onSelectedChange(self, selected):
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
154 self._selected_cache = selected
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
155
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
156
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
157 # class UniBox(MessageBox, MouseHandler): # AutoCompleteTextBox):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
158 # """This text box is used as a main typing point, for message, microblog, etc"""
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
159 #
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
160 # def __init__(self, host):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
161 # MessageBox.__init__(self, host)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
162 # #AutoCompleteTextBox.__init__(self)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
163 # self.setStyleName('uniBox')
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
164 # # FIXME
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
165 # # host.addSelectedListener(self.onSelectedChange)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
166 #
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
167 # def addKey(self, key):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
168 # return
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
169 # #self.getCompletionItems().completions.append(key)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
170 #
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
171 # def removeKey(self, key):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
172 # return
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
173 # # TODO: investigate why AutoCompleteTextBox doesn't work here,
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
174 # # maybe it can work on a TextBox but no TextArea. Remove addKey
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
175 # # and removeKey methods if they don't serve anymore.
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
176 # try:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
177 # self.getCompletionItems().completions.remove(key)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
178 # except KeyError:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
179 # log.warning("trying to remove an unknown key")
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
180 #
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
181 # def _getTarget(self, txt):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
182 # """ Say who will receive the messsage
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
183 # @return: a tuple (selected, target_type, target info) with:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
184 # - target_hook: None if we use the selected widget, (msg, data) if we have a hook (e.g. "@@: " for a public blog), where msg is the parsed message (i.e. without the "hook key: "@@: bla" become ("bla", None))
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
185 # - target_type: one of PUBLIC, GROUP, ONE2ONE, STATUS, MISC
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
186 # - msg: HTML message which will appear in the privacy warning banner """
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
187 # target = self._selected_cache
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
188 #
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
189 # def getSelectedOrStatus():
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
190 # if target and target.isSelectable():
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
191 # _type, msg = target.getWarningData()
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
192 # target_hook = None # we use the selected widget, not a hook
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
193 # else:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
194 # _type, msg = "STATUS", "This will be your new status message"
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
195 # target_hook = (txt, None)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
196 # return (target_hook, _type, msg)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
197 #
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
198 # if not txt.startswith('@'):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
199 # target_hook, _type, msg = getSelectedOrStatus()
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
200 # elif txt.startswith('@@: '):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
201 # _type = "PUBLIC"
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
202 # msg = MicroblogPanel.warning_msg_public
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
203 # target_hook = (txt[4:], None)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
204 # elif txt.startswith('@'):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
205 # _end = txt.find(': ')
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
206 # if _end == -1:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
207 # target_hook, _type, msg = getSelectedOrStatus()
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
208 # else:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
209 # group = txt[1:_end] # only one target group is managed for the moment
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
210 # if not group or not group in self.host.contact_panel.getGroups():
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
211 # # the group doesn't exists, we ignore the key
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
212 # group = None
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
213 # target_hook, _type, msg = getSelectedOrStatus()
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
214 # else:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
215 # _type = "GROUP"
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
216 # msg = MicroblogPanel.warning_msg_group % group
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
217 # target_hook = (txt[_end + 2:], group)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
218 # else:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
219 # log.error("Unknown target")
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
220 # target_hook, _type, msg = getSelectedOrStatus()
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
221 #
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
222 # return (target_hook, _type, msg)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
223 #
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
224 # def onKeyPress(self, sender, keycode, modifiers):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
225 # _txt = self.getText()
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
226 # target_hook, type_, msg = self._getTarget(_txt)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
227 #
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
228 # if keycode == KEY_ENTER:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
229 # if _txt:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
230 # if target_hook:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
231 # parsed_txt, data = target_hook
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
232 # self.host.send([(type_, data)], parsed_txt)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
233 # self.host._updateInputHistory(_txt)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
234 # self.setText('')
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
235 # self.host.showWarning(None, None)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
236 # else:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
237 # self.host.showWarning(type_, msg)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
238 # MessageBox.onKeyPress(self, sender, keycode, modifiers)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
239 #
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
240 # def getTargetAndData(self):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
241 # """For external use, to get information about the (hypothetical) message
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
242 # that would be sent if we press Enter right now in the unibox.
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
243 # @return a tuple (target, data) with:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
244 # - data: what would be the content of the message (body)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
245 # - target: JID, group with the prefix "@" or the public entity "@@"
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
246 # """
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
247 # _txt = self.getText()
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
248 # target_hook, _type, _msg = self._getTarget(_txt)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
249 # if target_hook:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
250 # data, target = target_hook
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
251 # if target is None:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
252 # return target_hook
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
253 # return (data, "@%s" % (target if target != "" else "@"))
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
254 # if isinstance(self._selected_cache, MicroblogPanel):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
255 # groups = self._selected_cache.accepted_groups
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
256 # target = "@%s" % (groups[0] if len(groups) > 0 else "@")
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
257 # if len(groups) > 1:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
258 # Window.alert("Sole the first group of the selected panel is taken in consideration: '%s'" % groups[0])
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
259 # # elif isinstance(self._selected_cache, ChatPanel): # FIXME
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
260 # # target = self._selected_cache.target
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
261 # else:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
262 # target = None
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
263 # return (_txt, target)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
264 #
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
265 # def onWidgetClosed(self, lib_wid):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
266 # """Called when a libervia widget is closed"""
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
267 # if self._selected_cache == lib_wid:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
268 # self.onSelectedChange(None)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
269 #
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
270 # """def complete(self):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
271 #
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
272 # #self.visible=False #XXX: self.visible is not unset in pyjamas when ENTER is pressed and a completion is done
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
273 # #XXX: fixed directly on pyjamas, if the patch is accepted, no need to walk around this
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
274 # return AutoCompleteTextBox.complete(self)"""
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
275
210
3092f6b1710c browser side: make the OK button title for group selector configureable + few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents: 206
diff changeset
276
361
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
277 class WarningPopup():
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
278
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
279 def __init__(self):
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
280 self._popup = None
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
281 self._timer = Timer(notify=self._timeCb)
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
282
394
ee61b0765d6c browser_side: radiocol supports MP3
souliane <souliane@mailoo.org>
parents: 383
diff changeset
283 def showWarning(self, type_=None, msg=None, duration=2000):
361
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
284 """Display a popup information message, e.g. to notify the recipient of a message being composed.
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
285 If type_ is None, a popup being currently displayed will be hidden.
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
286 @type_: a type determining the CSS style to be applied (see _showWarning)
361
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
287 @msg: message to be displayed
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
288 """
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
289 if type_ is None:
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
290 self.__removeWarning()
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
291 return
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
292 if not self._popup:
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
293 self._showWarning(type_, msg)
361
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
294 elif (type_, msg) != self._popup.target_data:
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
295 self._timeCb(None) # we remove the popup
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
296 self._showWarning(type_, msg)
361
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
297
394
ee61b0765d6c browser_side: radiocol supports MP3
souliane <souliane@mailoo.org>
parents: 383
diff changeset
298 self._timer.schedule(duration)
361
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
299
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
300 def _showWarning(self, type_, msg):
361
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
301 """Display a popup information message, e.g. to notify the recipient of a message being composed.
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
302 @type_: a type determining the CSS style to be applied. For now the defined styles are
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
303 "NONE" (will do nothing), "PUBLIC", "GROUP", "STATUS" and "ONE2ONE".
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
304 @msg: message to be displayed
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
305 """
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
306 if type_ == "NONE":
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
307 return
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
308 if not msg:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
diff changeset
309 log.warning("no msg set uniBox warning")
361
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
310 return
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
311 if type_ == "PUBLIC":
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
312 style = "targetPublic"
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
313 elif type_ == "GROUP":
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
314 style = "targetGroup"
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
315 elif type_ == "STATUS":
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
316 style = "targetStatus"
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
317 elif type_ == "ONE2ONE":
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
318 style = "targetOne2One"
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
319 else:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
diff changeset
320 log.error("unknown message type")
361
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
321 return
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
322 contents = HTML(msg)
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
323
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
324 self._popup = dialog.PopupPanelWrapper(autoHide=False, modal=False)
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
325 self._popup.target_data = (type_, msg)
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
326 self._popup.add(contents)
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
327 self._popup.setStyleName("warningPopup")
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
328 if style:
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
329 self._popup.addStyleName(style)
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
330
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
331 left = 0
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
332 top = 0 # max(0, self.getAbsoluteTop() - contents.getOffsetHeight() - 2)
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
333 self._popup.setPopupPosition(left, top)
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
334 self._popup.show()
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
335
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
336 def _timeCb(self, timer):
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
337 if self._popup:
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
338 self._popup.hide()
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
339 del self._popup
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
340 self._popup = None
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
341
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
342 def __removeWarning(self):
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
343 """Remove the popup"""
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
344 self._timeCb(None)
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
345
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
346
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 463
diff changeset
347 class StatusPanel(base_panels.HTMLTextEditor):
314
70ac3067d641 browser_side: status can be edited with a click on it
souliane <souliane@mailoo.org>
parents: 313
diff changeset
348
349
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
349 EMPTY_STATUS = '&lt;click to set a status&gt;'
314
70ac3067d641 browser_side: status can be edited with a click on it
souliane <souliane@mailoo.org>
parents: 313
diff changeset
350
20
8f4b1a8914c3 - User status is now updated
Goffi <goffi@goffi.org>
parents: 19
diff changeset
351 def __init__(self, host, status=''):
8f4b1a8914c3 - User status is now updated
Goffi <goffi@goffi.org>
parents: 19
diff changeset
352 self.host = host
349
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
353 modifiedCb = lambda content: self.host.bridge.call('setStatus', None, self.host.status_panel.presence, content['text']) or True
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 463
diff changeset
354 base_panels.HTMLTextEditor.__init__(self, {'text': status}, modifiedCb, options={'no_xhtml': True, 'listen_focus': True, 'listen_click': True})
349
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
355 self.edit(False)
20
8f4b1a8914c3 - User status is now updated
Goffi <goffi@goffi.org>
parents: 19
diff changeset
356 self.setStyleName('statusPanel')
19
e8e3704eb97f Added basic chat panel
Goffi <goffi@goffi.org>
parents: 18
diff changeset
357
349
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
358 @property
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
359 def status(self):
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
360 return self._original_content['text']
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
361
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
362 def __cleanContent(self, content):
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
363 status = content['text']
433
bbdbee25123a import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents: 432
diff changeset
364 if status == self.EMPTY_STATUS or status in C.PRESENCE.values():
349
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
365 content['text'] = ''
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
366 return content
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
367
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
368 def getContent(self):
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 463
diff changeset
369 return self.__cleanContent(base_panels.HTMLTextEditor.getContent(self))
19
e8e3704eb97f Added basic chat panel
Goffi <goffi@goffi.org>
parents: 18
diff changeset
370
349
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
371 def setContent(self, content):
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
372 content = self.__cleanContent(content)
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 463
diff changeset
373 base_panels.BaseTextEditor.setContent(self, content)
349
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
374
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
375 def setDisplayContent(self):
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
376 status = self._original_content['text']
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
377 try:
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
378 presence = self.host.status_panel.presence
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
379 except AttributeError: # during initialization
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
380 presence = None
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
381 if not status:
433
bbdbee25123a import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents: 432
diff changeset
382 if presence and presence in C.PRESENCE:
bbdbee25123a import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents: 432
diff changeset
383 status = C.PRESENCE[presence]
349
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
384 else:
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
385 status = self.EMPTY_STATUS
402
d7e78cb78dfc browser_side: HTMLTextEditor and LightTextEditor factorization
souliane <souliane@mailoo.org>
parents: 401
diff changeset
386 self.display.setHTML(addURLToText(status))
314
70ac3067d641 browser_side: status can be edited with a click on it
souliane <souliane@mailoo.org>
parents: 313
diff changeset
387
279
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
388
510
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
389 class PresenceStatusMenuBar(base_widget.WidgetMenuBar):
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
390 def __init__(self, parent):
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
391 styles = {'menu_bar': 'presence-button'}
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
392 base_widget.WidgetMenuBar.__init__(self, None, parent.host, styles=styles)
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
393 self.button = self.addCategory(u"◉", u"◉", '')
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
394 for presence, presence_i18n in C.PRESENCE.items():
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
395 html = u'<span class="%s">◉</span> %s' % (contact_list.buildPresenceStyle(presence), presence_i18n)
510
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
396 self.addMenuItem([u"◉", presence], [u"◉", html], '', base_menu.MenuCmd(self, 'changePresenceCb', presence), asHTML=True)
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
397 self.parent_panel = parent
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
398
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
399 def changePresenceCb(self, presence):
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
400 """Callback to notice the backend of a new presence set by the user.
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
401 @param presence (str): the new presence is a value in ('', 'chat', 'away', 'dnd', 'xa')
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
402 """
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
403 self.host.bridge.call('setStatus', None, presence, self.parent_panel.status_panel.status)
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
404
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
405 @classmethod
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
406 def getCategoryHTML(cls, menu_name_i18n, type_):
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
407 return menu_name_i18n
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
408
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
409
279
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
410 class PresenceStatusPanel(HorizontalPanel, ClickHandler):
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
411
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
412 def __init__(self, host, presence="", status=""):
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
413 self.host = host
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
414 HorizontalPanel.__init__(self, Width='100%')
510
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
415 self.menu = PresenceStatusMenuBar(self)
279
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
416 self.status_panel = StatusPanel(host, status=status)
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
417 self.setPresence(presence)
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
418
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
419 panel = HorizontalPanel()
510
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
420 panel.add(self.menu)
279
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
421 panel.add(self.status_panel)
510
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
422 panel.setCellVerticalAlignment(self.menu, 'baseline')
314
70ac3067d641 browser_side: status can be edited with a click on it
souliane <souliane@mailoo.org>
parents: 313
diff changeset
423 panel.setCellVerticalAlignment(self.status_panel, 'baseline')
279
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
424 panel.setStyleName("marginAuto")
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
425 self.add(panel)
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
426
349
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
427 self.status_panel.edit(False)
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
428
279
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
429 ClickHandler.__init__(self)
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
430 self.addClickListener(self)
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
431
349
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
432 @property
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
433 def presence(self):
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
434 return self._presence
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
435
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
436 @property
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
437 def status(self):
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
438 return self.status_panel._original_content['text']
279
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
439
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
440 def setPresence(self, presence):
349
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
441 self._presence = presence
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
442 contact_list.setPresenceStyle(self.menu.button, self._presence)
279
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
443
349
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
444 def setStatus(self, status):
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
445 self.status_panel.setContent({'text': status})
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
446 self.status_panel.setDisplayContent()
279
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
447
62
12e889a683ce server side: misc stuff:
Goffi <goffi@goffi.org>
parents: 58
diff changeset
448 def onClick(self, sender):
226
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
diff changeset
449 # As status is the default target of uniBar, we don't want to select anything if click on it
192
cf5c83e7d515 browser side: per tab selected widget management
Goffi <goffi@goffi.org>
parents: 191
diff changeset
450 self.host.setSelected(None)
20
8f4b1a8914c3 - User status is now updated
Goffi <goffi@goffi.org>
parents: 19
diff changeset
451
210
3092f6b1710c browser side: make the OK button title for group selector configureable + few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents: 206
diff changeset
452
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
453 class WebPanel(quick_widgets.QuickWidget, base_widget.LiberviaWidget):
181
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
454 """ (mini)browser like widget """
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
455
615
70872a83ef15 browser side (web panel): add an option to hide url headed + use it for public blog
Goffi <goffi@goffi.org>
parents: 612
diff changeset
456 def __init__(self, host, target, show_url=True, profiles=None):
181
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
457 """
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
458 @param host: SatWebFrontend instance
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
459 @param target: url to open
181
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
460 """
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
461 quick_widgets.QuickWidget.__init__(self, host, target, C.PROF_KEY_NONE)
195
dd27072d8ae0 browser side: widgets refactoring:
Goffi <goffi@goffi.org>
parents: 194
diff changeset
462 base_widget.LiberviaWidget.__init__(self, host)
181
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
463 self._vpanel = VerticalPanel()
188
39936b83da9d Browser Side: Web Panel widget position/size fix
Goffi <goffi@goffi.org>
parents: 187
diff changeset
464 self._vpanel.setSize('100%', '100%')
210
3092f6b1710c browser side: make the OK button title for group selector configureable + few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents: 206
diff changeset
465 self._url = dialog.ExtTextBox(enter_cb=self.onUrlClick)
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
466 self._url.setText(target or "")
181
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
467 self._url.setWidth('100%')
615
70872a83ef15 browser side (web panel): add an option to hide url headed + use it for public blog
Goffi <goffi@goffi.org>
parents: 612
diff changeset
468 if show_url:
70872a83ef15 browser side (web panel): add an option to hide url headed + use it for public blog
Goffi <goffi@goffi.org>
parents: 612
diff changeset
469 hpanel = HorizontalPanel()
70872a83ef15 browser side (web panel): add an option to hide url headed + use it for public blog
Goffi <goffi@goffi.org>
parents: 612
diff changeset
470 hpanel.add(self._url)
70872a83ef15 browser side (web panel): add an option to hide url headed + use it for public blog
Goffi <goffi@goffi.org>
parents: 612
diff changeset
471 btn = Button("Go", self.onUrlClick)
70872a83ef15 browser side (web panel): add an option to hide url headed + use it for public blog
Goffi <goffi@goffi.org>
parents: 612
diff changeset
472 hpanel.setCellWidth(self._url, "100%")
70872a83ef15 browser side (web panel): add an option to hide url headed + use it for public blog
Goffi <goffi@goffi.org>
parents: 612
diff changeset
473 hpanel.add(btn)
70872a83ef15 browser side (web panel): add an option to hide url headed + use it for public blog
Goffi <goffi@goffi.org>
parents: 612
diff changeset
474 self._vpanel.add(hpanel)
70872a83ef15 browser side (web panel): add an option to hide url headed + use it for public blog
Goffi <goffi@goffi.org>
parents: 612
diff changeset
475 self._vpanel.setCellHeight(hpanel, '20px')
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
476 self._frame = Frame(target or "")
181
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
477 self._frame.setSize('100%', '100%')
188
39936b83da9d Browser Side: Web Panel widget position/size fix
Goffi <goffi@goffi.org>
parents: 187
diff changeset
478 DOM.setStyleAttribute(self._frame.getElement(), "position", "relative")
181
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
479 self._vpanel.add(self._frame)
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
480 self.setWidget(self._vpanel)
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
481
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
482 def onUrlClick(self, sender):
612
5983d6be4f07 browser side (web panel): schemes are now checked, if no scheme is given (or a not accepted one), http:// is used
Goffi <goffi@goffi.org>
parents: 589
diff changeset
483 url = self._url.getText()
5983d6be4f07 browser side (web panel): schemes are now checked, if no scheme is given (or a not accepted one), http:// is used
Goffi <goffi@goffi.org>
parents: 589
diff changeset
484 scheme_end = url.find(':')
5983d6be4f07 browser side (web panel): schemes are now checked, if no scheme is given (or a not accepted one), http:// is used
Goffi <goffi@goffi.org>
parents: 589
diff changeset
485 scheme = "" if scheme_end == -1 else url[:scheme_end]
5983d6be4f07 browser side (web panel): schemes are now checked, if no scheme is given (or a not accepted one), http:// is used
Goffi <goffi@goffi.org>
parents: 589
diff changeset
486 if scheme not in C.WEB_PANEL_SCHEMES:
5983d6be4f07 browser side (web panel): schemes are now checked, if no scheme is given (or a not accepted one), http:// is used
Goffi <goffi@goffi.org>
parents: 589
diff changeset
487 url = "http://" + url
5983d6be4f07 browser side (web panel): schemes are now checked, if no scheme is given (or a not accepted one), http:// is used
Goffi <goffi@goffi.org>
parents: 589
diff changeset
488 self._frame.setUrl(url)
181
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
489
210
3092f6b1710c browser side: make the OK button title for group selector configureable + few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents: 206
diff changeset
490
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
491 class MainPanel(AbsolutePanel):
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
492
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
493 def __init__(self, host):
210
3092f6b1710c browser side: make the OK button title for group selector configureable + few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents: 206
diff changeset
494 self.host = host
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
495 AbsolutePanel.__init__(self)
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
496
226
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
diff changeset
497 # menu
495
587fe75d1b16 browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents: 482
diff changeset
498 self.menu = menu.MainMenuPanel(host)
184
97d5e9de1106 browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents: 181
diff changeset
499
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
500 # # unibox
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
501 # self.unibox_panel = UniBoxPanel(host)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
502 # self.unibox_panel.setVisible(False)
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
503
226
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
diff changeset
504 # contacts
232
0ed09cc0566f browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents: 231
diff changeset
505 self._contacts = HorizontalPanel()
0ed09cc0566f browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents: 231
diff changeset
506 self._contacts.addStyleName('globalLeftArea')
255
da0487f0a2e7 browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents: 249
diff changeset
507 self.contacts_switch = Button(u'«', self._contactsSwitch)
da0487f0a2e7 browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents: 249
diff changeset
508 self.contacts_switch.addStyleName('contactsSwitch')
da0487f0a2e7 browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents: 249
diff changeset
509 self._contacts.add(self.contacts_switch)
184
97d5e9de1106 browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents: 181
diff changeset
510
226
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
diff changeset
511 # tabs
195
dd27072d8ae0 browser side: widgets refactoring:
Goffi <goffi@goffi.org>
parents: 194
diff changeset
512 self.tab_panel = base_widget.MainTabPanel(host)
620
ac5881d683d3 browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents: 615
diff changeset
513 self.tab_panel.addWidgetsTab(_(u"Discussions"), select=True, locked=True)
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
514
426
77d8f55fc5f0 browser_side: hide the presence/status panel until the connection is made
souliane <souliane@mailoo.org>
parents: 425
diff changeset
515 self.header = AbsolutePanel()
77d8f55fc5f0 browser_side: hide the presence/status panel until the connection is made
souliane <souliane@mailoo.org>
parents: 425
diff changeset
516 self.header.add(self.menu)
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
517 # self.header.add(self.unibox_panel)
426
77d8f55fc5f0 browser_side: hide the presence/status panel until the connection is made
souliane <souliane@mailoo.org>
parents: 425
diff changeset
518 self.header.add(self.host.status_panel)
77d8f55fc5f0 browser_side: hide the presence/status panel until the connection is made
souliane <souliane@mailoo.org>
parents: 425
diff changeset
519 self.header.setStyleName('header')
77d8f55fc5f0 browser_side: hide the presence/status panel until the connection is made
souliane <souliane@mailoo.org>
parents: 425
diff changeset
520 self.add(self.header)
184
97d5e9de1106 browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents: 181
diff changeset
521
232
0ed09cc0566f browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents: 231
diff changeset
522 self._hpanel = HorizontalPanel()
0ed09cc0566f browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents: 231
diff changeset
523 self._hpanel.add(self._contacts)
0ed09cc0566f browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents: 231
diff changeset
524 self._hpanel.add(self.tab_panel)
0ed09cc0566f browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents: 231
diff changeset
525 self.add(self._hpanel)
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
526
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
527 self.setWidth("100%")
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
528 Window.addWindowResizeListener(self)
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
529
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
530 def addContactList(self, contact_list):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
531 self._contacts.add(contact_list)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
532
255
da0487f0a2e7 browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents: 249
diff changeset
533 def _contactsSwitch(self, btn=None):
184
97d5e9de1106 browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents: 181
diff changeset
534 """ (Un)hide contacts panel """
255
da0487f0a2e7 browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents: 249
diff changeset
535 if btn is None:
da0487f0a2e7 browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents: 249
diff changeset
536 btn = self.contacts_switch
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
537 clist = self.host.contact_list
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
538 clist.setVisible(not clist.getVisible())
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
539 btn.setText(u"«" if clist.getVisible() else u"»")
184
97d5e9de1106 browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents: 181
diff changeset
540 self.host.resize()
97d5e9de1106 browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents: 181
diff changeset
541
232
0ed09cc0566f browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents: 231
diff changeset
542 def _contactsMove(self, parent):
0ed09cc0566f browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents: 231
diff changeset
543 """Move the contacts container (containing the contact list and
0ed09cc0566f browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents: 231
diff changeset
544 the "hide/show" button) to another parent, but always as the
0ed09cc0566f browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents: 231
diff changeset
545 first child position (insert at index 0).
0ed09cc0566f browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents: 231
diff changeset
546 """
0ed09cc0566f browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents: 231
diff changeset
547 if self._contacts.getParent():
0ed09cc0566f browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents: 231
diff changeset
548 if self._contacts.getParent() == parent:
0ed09cc0566f browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents: 231
diff changeset
549 return
0ed09cc0566f browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents: 231
diff changeset
550 self._contacts.removeFromParent()
0ed09cc0566f browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents: 231
diff changeset
551 parent.insert(self._contacts, 0)
0ed09cc0566f browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents: 231
diff changeset
552
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
553 def onWindowResized(self, width, height):
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
554 _elts = doc().getElementsByClassName('gwt-TabBar')
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
555 if not _elts.length:
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
556 tab_bar_h = 0
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
557 else:
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
558 tab_bar_h = _elts.item(0).offsetHeight
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
559 ideal_height = Window.getClientHeight() - tab_bar_h
210
3092f6b1710c browser side: make the OK button title for group selector configureable + few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents: 206
diff changeset
560 self.setHeight("%s%s" % (ideal_height, "px"))
241
86055ccf69c3 browser_side: added class PopupMenuPanel to manage more complex context menu
souliane <souliane@mailoo.org>
parents: 239
diff changeset
561
326
36927be51481 browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents: 323
diff changeset
562 def refresh(self):
36927be51481 browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents: 323
diff changeset
563 """Refresh the main panel"""
36927be51481 browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents: 323
diff changeset
564 self.unibox_panel.refresh()
567
ee9c7bd266ad browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents: 564
diff changeset
565 self.host.contact_panel.refresh()