Mercurial > libervia-web
annotate src/browser/sat_browser/panels.py @ 634:16a5da120b7f frontends_multi_profiles
browser side (contact list): Contact list improvments:
- removed optional arguments from getContactBox: they are now managed by the hosting panel, as the arguments should be same for all contacts in a panel
- contact name is no more specified on ContactBox creation, is gotten by the ContactLabel itself using the cache (TODO: "nick" listener)
- renamed setMessageXXX to setAlert for consitency with QuickFrontend (furthermore the alert could be used for something else than waiting messages)
- ContactBoxes are stored using bare jid
- parent is used in ContactBox instead of host
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 23 Feb 2015 18:44:57 +0100 |
parents | c2abadf31afb |
children | 7113d40533d6 |
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 | 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 |
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
442
diff
changeset
|
24 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
|
25 |
33 | 26 from pyjamas.ui.AbsolutePanel import AbsolutePanel |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 from pyjamas.ui.VerticalPanel import VerticalPanel |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 from pyjamas.ui.HorizontalPanel import HorizontalPanel |
73
447dc8ac181b
Adrien's uniBox design integration + lastPopup style
Goffi <goffi@goffi.org>
parents:
71
diff
changeset
|
29 from pyjamas.ui.TextArea import TextArea |
83 | 30 from pyjamas.ui.Button import Button |
33 | 31 from pyjamas.ui.HTML import HTML |
19 | 32 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
|
33 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
|
34 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
|
35 from pyjamas.ui.Frame import Frame |
33 | 36 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
|
37 from pyjamas import Window |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
38 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
|
39 from __pyjamas__ import doc |
0b7934e75e76
misc: reorganization of the file panels.py + clean the modules import:
souliane <souliane@mailoo.org>
parents:
322
diff
changeset
|
40 |
449
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
442
diff
changeset
|
41 |
467 | 42 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
|
43 import base_menu |
467 | 44 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
|
45 import dialog |
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
442
diff
changeset
|
46 import base_widget |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
47 import contact_list |
433
bbdbee25123a
import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents:
432
diff
changeset
|
48 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
|
49 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
|
50 |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
51 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
52 # class UniBoxPanel(HorizontalPanel): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
53 # """Panel containing the UniBox""" |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
54 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
55 # def __init__(self, host): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
56 # HorizontalPanel.__init__(self) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
57 # self.host = host |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
58 # self.setStyleName('uniBoxPanel') |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
59 # self.unibox = None |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
60 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
61 # def refresh(self): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
62 # """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
|
63 # 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
|
64 # self.setVisible(enable) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
65 # 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
|
66 # 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
|
67 # 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
|
68 # self.button.addStyleName('uniBoxButton') |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
69 # self.add(self.button) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
70 # 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
|
71 # self.add(self.unibox) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
72 # 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
|
73 # 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
|
74 # self.unibox.addKey("@@: ") |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
75 # 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
|
76 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
77 # def openRichMessageEditor(self): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
78 # """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
|
79 # self.button.setVisible(False) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
80 # self.unibox.setVisible(False) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
81 # 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
|
82 # 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
|
83 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
84 # def afterEditCb(): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
85 # Window.removeWindowResizeListener(self) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
86 # 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
|
87 # 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
|
88 # self.button.setVisible(True) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
89 # self.unibox.setVisible(True) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
90 # self.host.resize() |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
91 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
92 # 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
|
93 # Window.addWindowResizeListener(self) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
94 # self.host.resize() |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
95 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
96 # 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
|
97 # 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
|
98 # 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
|
99 # 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
|
100 # 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
|
101 |
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
|
102 |
310
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
103 class MessageBox(TextArea): |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
104 """A basic text area for entering messages""" |
33 | 105 |
106 def __init__(self, host): | |
73
447dc8ac181b
Adrien's uniBox design integration + lastPopup style
Goffi <goffi@goffi.org>
parents:
71
diff
changeset
|
107 TextArea.__init__(self) |
310
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
108 self.host = host |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
109 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
|
110 self.setStyleName('messageBox') |
83 | 111 self.addKeyboardListener(self) |
186
72bb1d845b6a
browser side: global resize on UniBox resize
Goffi <goffi@goffi.org>
parents:
185
diff
changeset
|
112 MouseHandler.__init__(self) |
72bb1d845b6a
browser side: global resize on UniBox resize
Goffi <goffi@goffi.org>
parents:
185
diff
changeset
|
113 self.addMouseListener(self) |
310
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
114 |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
115 def onBrowserEvent(self, event): |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
116 # 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
|
117 # 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
|
118 # 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
|
119 self.currentEvent = event |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
120 TextArea.onBrowserEvent(self, event) |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
121 |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
122 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
|
123 _txt = self.getText() |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
124 |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
125 def history_cb(text): |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
126 self.setText(text) |
422
20c508f9b32a
browser side: fixed bad use of Timer
Goffi <goffi@goffi.org>
parents:
414
diff
changeset
|
127 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
|
128 |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
129 if keycode == KEY_ENTER: |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
130 if _txt: |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
131 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
|
132 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
|
133 self.setText('') |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
134 sender.cancelKey() |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
135 elif keycode == KEY_UP: |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
136 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
|
137 elif keycode == KEY_DOWN: |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
138 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
|
139 else: |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
140 self._onComposing() |
310
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
141 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
142 def _onComposing(self): |
310
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
143 """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
|
144 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
|
145 |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
146 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
|
147 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
|
148 if size != self.size: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
149 self.size = size |
310
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
150 self.host.resize() |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
151 |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
152 def onSelectedChange(self, selected): |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
153 self._selected_cache = selected |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
154 |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
155 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
156 # 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
|
157 # """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
|
158 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
159 # def __init__(self, host): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
160 # MessageBox.__init__(self, host) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
161 # #AutoCompleteTextBox.__init__(self) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
162 # self.setStyleName('uniBox') |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
163 # # FIXME |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
164 # # host.addSelectedListener(self.onSelectedChange) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
165 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
166 # def addKey(self, key): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
167 # return |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
168 # #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
|
169 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
170 # def removeKey(self, key): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
171 # return |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
172 # # 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
|
173 # # 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
|
174 # # 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
|
175 # try: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
176 # 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
|
177 # except KeyError: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
178 # 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
|
179 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
180 # def _getTarget(self, txt): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
181 # """ 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
|
182 # @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
|
183 # - 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
|
184 # - 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
|
185 # - 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
|
186 # target = self._selected_cache |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
187 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
188 # def getSelectedOrStatus(): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
189 # 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
|
190 # _type, msg = target.getWarningData() |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
191 # 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
|
192 # else: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
193 # _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
|
194 # target_hook = (txt, None) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
195 # 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
|
196 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
197 # if not txt.startswith('@'): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
198 # 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
|
199 # elif txt.startswith('@@: '): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
200 # _type = "PUBLIC" |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
201 # 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
|
202 # 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
|
203 # elif txt.startswith('@'): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
204 # _end = txt.find(': ') |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
205 # if _end == -1: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
206 # 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
|
207 # else: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
208 # 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
|
209 # 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
|
210 # # 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
|
211 # group = None |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
212 # 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
|
213 # else: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
214 # _type = "GROUP" |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
215 # 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
|
216 # 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
|
217 # else: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
218 # log.error("Unknown target") |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
219 # 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
|
220 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
221 # 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
|
222 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
223 # 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
|
224 # _txt = self.getText() |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
225 # 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
|
226 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
227 # if keycode == KEY_ENTER: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
228 # if _txt: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
229 # if target_hook: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
230 # 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
|
231 # 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
|
232 # self.host._updateInputHistory(_txt) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
233 # self.setText('') |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
234 # 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
|
235 # else: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
236 # 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
|
237 # 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
|
238 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
239 # def getTargetAndData(self): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
240 # """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
|
241 # 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
|
242 # @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
|
243 # - 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
|
244 # - 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
|
245 # """ |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
246 # _txt = self.getText() |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
247 # 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
|
248 # if target_hook: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
249 # data, target = target_hook |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
250 # if target is None: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
251 # return target_hook |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
252 # 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
|
253 # 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
|
254 # 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
|
255 # 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
|
256 # if len(groups) > 1: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
257 # 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
|
258 # # 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
|
259 # # 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
|
260 # else: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
261 # target = None |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
262 # return (_txt, target) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
263 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
264 # 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
|
265 # """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
|
266 # 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
|
267 # self.onSelectedChange(None) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
268 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
269 # """def complete(self): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
270 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
271 # #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
|
272 # #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
|
273 # return AutoCompleteTextBox.complete(self)""" |
33 | 274 |
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
|
275 |
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
|
276 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
|
277 |
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 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
|
279 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
|
280 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
|
281 |
394
ee61b0765d6c
browser_side: radiocol supports MP3
souliane <souliane@mailoo.org>
parents:
383
diff
changeset
|
282 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
|
283 """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
|
284 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
|
285 @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
|
286 @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
|
287 """ |
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 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
|
289 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
|
290 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
|
291 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
|
292 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
|
293 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
|
294 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
|
295 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
|
296 |
394
ee61b0765d6c
browser_side: radiocol supports MP3
souliane <souliane@mailoo.org>
parents:
383
diff
changeset
|
297 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
|
298 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
299 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
|
300 """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
|
301 @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
|
302 "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
|
303 @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
|
304 """ |
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 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
|
306 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
|
307 if not msg: |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
433
diff
changeset
|
308 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
|
309 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
|
310 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
|
311 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
|
312 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
|
313 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
|
314 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
|
315 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
|
316 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
|
317 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
|
318 else: |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
433
diff
changeset
|
319 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
|
320 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
|
321 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
|
322 |
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 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
|
324 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
|
325 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
|
326 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
|
327 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
|
328 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
|
329 |
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 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
|
331 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
|
332 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
|
333 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
|
334 |
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 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
|
336 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
|
337 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
|
338 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
|
339 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
|
340 |
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 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
|
342 """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
|
343 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
|
344 |
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 |
467 | 346 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
|
347 |
349
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
348 EMPTY_STATUS = '<click to set a status>' |
314
70ac3067d641
browser_side: status can be edited with a click on it
souliane <souliane@mailoo.org>
parents:
313
diff
changeset
|
349 |
20 | 350 def __init__(self, host, status=''): |
351 self.host = host | |
349
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
352 modifiedCb = lambda content: self.host.bridge.call('setStatus', None, self.host.status_panel.presence, content['text']) or True |
467 | 353 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
|
354 self.edit(False) |
20 | 355 self.setStyleName('statusPanel') |
19 | 356 |
349
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
357 @property |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
358 def status(self): |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
359 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
|
360 |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
361 def __cleanContent(self, content): |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
362 status = content['text'] |
433
bbdbee25123a
import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents:
432
diff
changeset
|
363 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
|
364 content['text'] = '' |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
365 return content |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
366 |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
367 def getContent(self): |
467 | 368 return self.__cleanContent(base_panels.HTMLTextEditor.getContent(self)) |
19 | 369 |
349
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
370 def setContent(self, content): |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
371 content = self.__cleanContent(content) |
467 | 372 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
|
373 |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
374 def setDisplayContent(self): |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
375 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
|
376 try: |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
377 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
|
378 except AttributeError: # during initialization |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
379 presence = None |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
380 if not status: |
433
bbdbee25123a
import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents:
432
diff
changeset
|
381 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
|
382 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
|
383 else: |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
384 status = self.EMPTY_STATUS |
402
d7e78cb78dfc
browser_side: HTMLTextEditor and LightTextEditor factorization
souliane <souliane@mailoo.org>
parents:
401
diff
changeset
|
385 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
|
386 |
279
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
387 |
510
db3436c85fb1
browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents:
499
diff
changeset
|
388 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
|
389 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
|
390 styles = {'menu_bar': 'presence-button'} |
632
c2abadf31afb
browser side (menu): minor improvments:
Goffi <goffi@goffi.org>
parents:
615
diff
changeset
|
391 base_widget.WidgetMenuBar.__init__(self, parent, parent.host, styles=styles) |
510
db3436c85fb1
browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents:
499
diff
changeset
|
392 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
|
393 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
|
394 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
|
395 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
|
396 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
|
397 |
db3436c85fb1
browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents:
499
diff
changeset
|
398 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
|
399 """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
|
400 @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
|
401 """ |
db3436c85fb1
browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents:
499
diff
changeset
|
402 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
|
403 |
db3436c85fb1
browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents:
499
diff
changeset
|
404 @classmethod |
db3436c85fb1
browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents:
499
diff
changeset
|
405 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
|
406 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
|
407 |
db3436c85fb1
browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents:
499
diff
changeset
|
408 |
279
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
409 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
|
410 |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
411 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
|
412 self.host = host |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
413 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
|
414 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
|
415 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
|
416 self.setPresence(presence) |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
417 |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
418 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
|
419 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
|
420 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
|
421 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
|
422 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
|
423 panel.setStyleName("marginAuto") |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
424 self.add(panel) |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
425 |
349
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
426 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
|
427 |
279
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
428 ClickHandler.__init__(self) |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
429 self.addClickListener(self) |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
430 |
349
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
431 @property |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
432 def presence(self): |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
433 return self._presence |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
434 |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
435 @property |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
436 def status(self): |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
437 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
|
438 |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
439 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
|
440 self._presence = presence |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
441 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
|
442 |
349
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
443 def setStatus(self, status): |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
444 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
|
445 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
|
446 |
62 | 447 def onClick(self, sender): |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
223
diff
changeset
|
448 # 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
|
449 self.host.setSelected(None) |
20 | 450 |
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
|
451 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
452 class WebPanel(quick_widgets.QuickWidget, base_widget.LiberviaWidget): |
181
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
453 """ (mini)browser like widget """ |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
454 |
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
|
455 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
|
456 """ |
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
457 @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
|
458 @param target: url to open |
181
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
459 """ |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
460 quick_widgets.QuickWidget.__init__(self, host, target, C.PROF_KEY_NONE) |
195 | 461 base_widget.LiberviaWidget.__init__(self, host) |
181
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
462 self._vpanel = VerticalPanel() |
188
39936b83da9d
Browser Side: Web Panel widget position/size fix
Goffi <goffi@goffi.org>
parents:
187
diff
changeset
|
463 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
|
464 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
|
465 self._url.setText(target or "") |
181
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
466 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
|
467 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
|
468 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
|
469 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
|
470 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
|
471 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
|
472 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
|
473 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
|
474 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
|
475 self._frame = Frame(target or "") |
181
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
476 self._frame.setSize('100%', '100%') |
188
39936b83da9d
Browser Side: Web Panel widget position/size fix
Goffi <goffi@goffi.org>
parents:
187
diff
changeset
|
477 DOM.setStyleAttribute(self._frame.getElement(), "position", "relative") |
181
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
478 self._vpanel.add(self._frame) |
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
479 self.setWidget(self._vpanel) |
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
480 |
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
481 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
|
482 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
|
483 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
|
484 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
|
485 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
|
486 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
|
487 self._frame.setUrl(url) |
181
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
488 |
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
|
489 |
33 | 490 class MainPanel(AbsolutePanel): |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
491 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
492 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
|
493 self.host = host |
33 | 494 AbsolutePanel.__init__(self) |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
495 |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
223
diff
changeset
|
496 # menu |
495
587fe75d1b16
browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents:
482
diff
changeset
|
497 self.menu = menu.MainMenuPanel(host) |
184
97d5e9de1106
browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
498 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
499 # # unibox |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
500 # 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
|
501 # self.unibox_panel.setVisible(False) |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
502 |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
223
diff
changeset
|
503 # contacts |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
231
diff
changeset
|
504 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
|
505 self._contacts.addStyleName('globalLeftArea') |
255
da0487f0a2e7
browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents:
249
diff
changeset
|
506 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
|
507 self.contacts_switch.addStyleName('contactsSwitch') |
da0487f0a2e7
browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents:
249
diff
changeset
|
508 self._contacts.add(self.contacts_switch) |
184
97d5e9de1106
browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
509 |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
223
diff
changeset
|
510 # tabs |
195 | 511 self.tab_panel = base_widget.MainTabPanel(host) |
512 self.discuss_panel = base_widget.WidgetsPanel(self.host, locked=True) | |
23 | 513 self.tab_panel.add(self.discuss_panel, "Discussions") |
514 self.tab_panel.selectTab(0) | |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
515 |
426
77d8f55fc5f0
browser_side: hide the presence/status panel until the connection is made
souliane <souliane@mailoo.org>
parents:
425
diff
changeset
|
516 self.header = AbsolutePanel() |
77d8f55fc5f0
browser_side: hide the presence/status panel until the connection is made
souliane <souliane@mailoo.org>
parents:
425
diff
changeset
|
517 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
|
518 # 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
|
519 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
|
520 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
|
521 self.add(self.header) |
184
97d5e9de1106
browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
522 |
232
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 = HorizontalPanel() |
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._contacts) |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
231
diff
changeset
|
525 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
|
526 self.add(self._hpanel) |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
527 |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
528 self.setWidth("100%") |
33 | 529 Window.addWindowResizeListener(self) |
530 | |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
531 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
|
532 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
|
533 |
255
da0487f0a2e7
browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents:
249
diff
changeset
|
534 def _contactsSwitch(self, btn=None): |
184
97d5e9de1106
browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
535 """ (Un)hide contacts panel """ |
255
da0487f0a2e7
browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents:
249
diff
changeset
|
536 if btn is None: |
da0487f0a2e7
browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents:
249
diff
changeset
|
537 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
|
538 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
|
539 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
|
540 btn.setText(u"«" if clist.getVisible() else u"»") |
184
97d5e9de1106
browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
541 self.host.resize() |
97d5e9de1106
browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
542 |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
231
diff
changeset
|
543 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
|
544 """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
|
545 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
|
546 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
|
547 """ |
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(): |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
231
diff
changeset
|
549 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
|
550 return |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
231
diff
changeset
|
551 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
|
552 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
|
553 |
33 | 554 def onWindowResized(self, width, height): |
555 _elts = doc().getElementsByClassName('gwt-TabBar') | |
556 if not _elts.length: | |
557 tab_bar_h = 0 | |
558 else: | |
559 tab_bar_h = _elts.item(0).offsetHeight | |
560 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
|
561 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
|
562 |
326
36927be51481
browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
563 def refresh(self): |
36927be51481
browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
564 """Refresh the main panel""" |
36927be51481
browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
565 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
|
566 self.host.contact_panel.refresh() |