Mercurial > libervia-web
annotate src/browser/panels.py @ 450:41aae13cab2b
browser_side: increase message box height for all characters to fit
author | souliane <souliane@mailoo.org> |
---|---|
date | Tue, 20 May 2014 07:22:10 +0200 |
parents | 981ed669d3b3 |
children | 1a0cec9b0f1e |
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 from sat_frontends.tools.games import SYMBOLS |
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
442
diff
changeset
|
26 from sat.core.i18n import _ |
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
442
diff
changeset
|
27 |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 from pyjamas.ui.SimplePanel import SimplePanel |
33 | 29 from pyjamas.ui.AbsolutePanel import AbsolutePanel |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 from pyjamas.ui.VerticalPanel import VerticalPanel |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 from pyjamas.ui.HorizontalPanel import HorizontalPanel |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 from pyjamas.ui.HTMLPanel import HTMLPanel |
181
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
33 from pyjamas.ui.Frame import Frame |
73
447dc8ac181b
Adrien's uniBox design integration + lastPopup style
Goffi <goffi@goffi.org>
parents:
71
diff
changeset
|
34 from pyjamas.ui.TextArea import TextArea |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 from pyjamas.ui.Label import Label |
83 | 36 from pyjamas.ui.Button import Button |
33 | 37 from pyjamas.ui.HTML import HTML |
83 | 38 from pyjamas.ui.Image import Image |
19 | 39 from pyjamas.ui.ClickListener import ClickHandler |
291
89818bca1a33
browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents:
289
diff
changeset
|
40 from pyjamas.ui.FlowPanel import FlowPanel |
282
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
41 from pyjamas.ui.KeyboardListener import KEY_ENTER, KEY_UP, KEY_DOWN, KeyboardHandler |
186
72bb1d845b6a
browser side: global resize on UniBox resize
Goffi <goffi@goffi.org>
parents:
185
diff
changeset
|
42 from pyjamas.ui.MouseListener import MouseHandler |
323
0b7934e75e76
misc: reorganization of the file panels.py + clean the modules import:
souliane <souliane@mailoo.org>
parents:
322
diff
changeset
|
43 from pyjamas.ui.FocusListener import FocusHandler |
33 | 44 from pyjamas.Timer import Timer |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
45 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
|
46 from pyjamas import Window |
0b7934e75e76
misc: reorganization of the file panels.py + clean the modules import:
souliane <souliane@mailoo.org>
parents:
322
diff
changeset
|
47 from __pyjamas__ import doc |
0b7934e75e76
misc: reorganization of the file panels.py + clean the modules import:
souliane <souliane@mailoo.org>
parents:
322
diff
changeset
|
48 |
0b7934e75e76
misc: reorganization of the file panels.py + clean the modules import:
souliane <souliane@mailoo.org>
parents:
322
diff
changeset
|
49 from datetime import datetime |
0b7934e75e76
misc: reorganization of the file panels.py + clean the modules import:
souliane <souliane@mailoo.org>
parents:
322
diff
changeset
|
50 from time import time |
449
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
442
diff
changeset
|
51 |
370
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
366
diff
changeset
|
52 from jid import JID |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
366
diff
changeset
|
53 from html_tools import html_sanitize |
401
ea03f898067f
browser_side: LightTextEditor renamed to HTMLTextEditor, new class LightTextEditor based on TextArea
souliane <souliane@mailoo.org>
parents:
400
diff
changeset
|
54 from base_panels import ChatText, OccupantsList, PopupMenuPanel, BaseTextEditor, LightTextEditor, HTMLTextEditor |
78
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
75
diff
changeset
|
55 from card_game import CardPanel |
127 | 56 from radiocol import RadioColPanel |
78
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
75
diff
changeset
|
57 from menu 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
|
58 import dialog |
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
442
diff
changeset
|
59 import base_widget |
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
442
diff
changeset
|
60 import richtext |
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
442
diff
changeset
|
61 import contact |
433
bbdbee25123a
import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents:
432
diff
changeset
|
62 from constants import Const as C |
223
624a87377412
browser_side, plugin XEP-0085: limit the number of bridge methods calls for "chatStateComposing".
souliane <souliane@mailoo.org>
parents:
218
diff
changeset
|
63 from plugin_xep_0085 import ChatStateMachine |
323
0b7934e75e76
misc: reorganization of the file panels.py + clean the modules import:
souliane <souliane@mailoo.org>
parents:
322
diff
changeset
|
64 |
279
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
65 |
442
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
66 # TODO: at some point we should decide which behaviors to keep and remove these two constants |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
67 TOGGLE_EDITION_USE_ICON = False # set to True to use an icon inside the "toggle syntax" button |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
68 NEW_MESSAGE_USE_BUTTON = False # set to True to display the "New message" button instead of an empty entry |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
69 |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
70 |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
231
diff
changeset
|
71 class UniBoxPanel(HorizontalPanel): |
33 | 72 """Panel containing the UniBox""" |
73 | |
74 def __init__(self, host): | |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
231
diff
changeset
|
75 HorizontalPanel.__init__(self) |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
231
diff
changeset
|
76 self.host = host |
33 | 77 self.setStyleName('uniBoxPanel') |
309
05e264e96a1c
browser_side: make unibox optional
souliane <souliane@mailoo.org>
parents:
307
diff
changeset
|
78 self.unibox = None |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
231
diff
changeset
|
79 |
326
36927be51481
browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
80 def refresh(self): |
36927be51481
browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
81 """Enable or disable this panel. Contained widgets are created when necessary.""" |
36927be51481
browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
82 enable = self.host.params_ui['unibox']['value'] |
36927be51481
browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
83 self.setVisible(enable) |
36927be51481
browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
84 if enable and not self.unibox: |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
85 self.button = Button('<img src="media/icons/tango/actions/32/format-text-italic.png" class="richTextIcon"/>') |
309
05e264e96a1c
browser_side: make unibox optional
souliane <souliane@mailoo.org>
parents:
307
diff
changeset
|
86 self.button.setTitle('Open the rich text editor') |
05e264e96a1c
browser_side: make unibox optional
souliane <souliane@mailoo.org>
parents:
307
diff
changeset
|
87 self.button.addStyleName('uniBoxButton') |
05e264e96a1c
browser_side: make unibox optional
souliane <souliane@mailoo.org>
parents:
307
diff
changeset
|
88 self.add(self.button) |
05e264e96a1c
browser_side: make unibox optional
souliane <souliane@mailoo.org>
parents:
307
diff
changeset
|
89 self.unibox = UniBox(self.host) |
05e264e96a1c
browser_side: make unibox optional
souliane <souliane@mailoo.org>
parents:
307
diff
changeset
|
90 self.add(self.unibox) |
05e264e96a1c
browser_side: make unibox optional
souliane <souliane@mailoo.org>
parents:
307
diff
changeset
|
91 self.setCellWidth(self.unibox, '100%') |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
92 self.button.addClickListener(self.openRichMessageEditor) |
309
05e264e96a1c
browser_side: make unibox optional
souliane <souliane@mailoo.org>
parents:
307
diff
changeset
|
93 self.unibox.addKey("@@: ") |
380
5e0e2032928c
browser_side: bug fixes microblogs:
souliane <souliane@mailoo.org>
parents:
370
diff
changeset
|
94 self.unibox.onSelectedChange(self.host.getSelected()) |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
231
diff
changeset
|
95 |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
96 def openRichMessageEditor(self): |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
231
diff
changeset
|
97 """Open the rich text editor.""" |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
231
diff
changeset
|
98 self.button.setVisible(False) |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
231
diff
changeset
|
99 self.unibox.setVisible(False) |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
231
diff
changeset
|
100 self.setCellWidth(self.unibox, '0px') |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
231
diff
changeset
|
101 self.host.panel._contactsMove(self) |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
231
diff
changeset
|
102 |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
103 def afterEditCb(): |
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
|
104 Window.removeWindowResizeListener(self) |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
231
diff
changeset
|
105 self.host.panel._contactsMove(self.host.panel._hpanel) |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
231
diff
changeset
|
106 self.setCellWidth(self.unibox, '100%') |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
231
diff
changeset
|
107 self.button.setVisible(True) |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
231
diff
changeset
|
108 self.unibox.setVisible(True) |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
231
diff
changeset
|
109 self.host.resize() |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
231
diff
changeset
|
110 |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
111 richtext.RichMessageEditor.getOrCreate(self.host, self, afterEditCb) |
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
|
112 Window.addWindowResizeListener(self) |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
231
diff
changeset
|
113 self.host.resize() |
33 | 114 |
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
|
115 def onWindowResized(self, width, height): |
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
|
116 right = self.host.panel.menu.getAbsoluteLeft() + self.host.panel.menu.getOffsetWidth() |
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
|
117 left = self.host.panel._contacts.getAbsoluteLeft() + self.host.panel._contacts.getOffsetWidth() |
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
|
118 ideal_width = right - left - 40 |
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
|
119 self.host.richtext.setWidth("%spx" % ideal_width) |
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
|
120 |
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
|
121 |
310
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
122 class MessageBox(TextArea): |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
123 """A basic text area for entering messages""" |
33 | 124 |
125 def __init__(self, host): | |
73
447dc8ac181b
Adrien's uniBox design integration + lastPopup style
Goffi <goffi@goffi.org>
parents:
71
diff
changeset
|
126 TextArea.__init__(self) |
310
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
127 self.host = 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
|
128 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
|
129 self.setStyleName('messageBox') |
83 | 130 self.addKeyboardListener(self) |
186
72bb1d845b6a
browser side: global resize on UniBox resize
Goffi <goffi@goffi.org>
parents:
185
diff
changeset
|
131 MouseHandler.__init__(self) |
72bb1d845b6a
browser side: global resize on UniBox resize
Goffi <goffi@goffi.org>
parents:
185
diff
changeset
|
132 self.addMouseListener(self) |
193
f2ae8e170c49
browser side: selected widget caching in UniBox, to avoid to ask the getter at each key pressed, which make the box very slow.
Goffi <goffi@goffi.org>
parents:
192
diff
changeset
|
133 self._selected_cache = None |
310
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
134 |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
135 def onBrowserEvent(self, event): |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
136 # 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
|
137 # 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
|
138 # 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
|
139 self.currentEvent = event |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
140 TextArea.onBrowserEvent(self, event) |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
141 |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
142 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
|
143 _txt = self.getText() |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
144 |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
145 def history_cb(text): |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
146 self.setText(text) |
422
20c508f9b32a
browser side: fixed bad use of Timer
Goffi <goffi@goffi.org>
parents:
414
diff
changeset
|
147 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
|
148 |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
149 if keycode == KEY_ENTER: |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
150 if _txt: |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
151 self._selected_cache.onTextEntered(_txt) |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
152 self.host._updateInputHistory(_txt) |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
153 self.setText('') |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
154 sender.cancelKey() |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
155 elif keycode == KEY_UP: |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
156 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
|
157 elif keycode == KEY_DOWN: |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
158 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
|
159 else: |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
160 self.__onComposing() |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
161 |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
162 def __onComposing(self): |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
163 """Callback when the user is composing a text.""" |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
164 if hasattr(self._selected_cache, "target"): |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
165 self._selected_cache.state_machine._onEvent("composing") |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
166 |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
167 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
|
168 size = (self.getOffsetWidth(), self.getOffsetHeight()) |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
169 if size != self.__size: |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
170 self.__size = size |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
171 self.host.resize() |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
172 |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
173 def onSelectedChange(self, selected): |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
174 self._selected_cache = selected |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
175 |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
176 |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
177 class UniBox(MessageBox, MouseHandler): #AutoCompleteTextBox): |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
178 """This text box is used as a main typing point, for message, microblog, etc""" |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
179 |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
180 def __init__(self, host): |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
181 MessageBox.__init__(self, host) |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
182 #AutoCompleteTextBox.__init__(self) |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
183 self.setStyleName('uniBox') |
193
f2ae8e170c49
browser side: selected widget caching in UniBox, to avoid to ask the getter at each key pressed, which make the box very slow.
Goffi <goffi@goffi.org>
parents:
192
diff
changeset
|
184 host.addSelectedListener(self.onSelectedChange) |
33 | 185 |
186 def addKey(self, key): | |
73
447dc8ac181b
Adrien's uniBox design integration + lastPopup style
Goffi <goffi@goffi.org>
parents:
71
diff
changeset
|
187 return |
447dc8ac181b
Adrien's uniBox design integration + lastPopup style
Goffi <goffi@goffi.org>
parents:
71
diff
changeset
|
188 #self.getCompletionItems().completions.append(key) |
33 | 189 |
55
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
190 def removeKey(self, key): |
255
da0487f0a2e7
browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents:
249
diff
changeset
|
191 return |
da0487f0a2e7
browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents:
249
diff
changeset
|
192 # TODO: investigate why AutoCompleteTextBox doesn't work here, |
da0487f0a2e7
browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents:
249
diff
changeset
|
193 # maybe it can work on a TextBox but no TextArea. Remove addKey |
da0487f0a2e7
browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents:
249
diff
changeset
|
194 # and removeKey methods if they don't serve anymore. |
55
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
195 try: |
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
196 self.getCompletionItems().completions.remove(key) |
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
197 except KeyError: |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
433
diff
changeset
|
198 log.warning("trying to remove an unknown key") |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
199 |
33 | 200 def _getTarget(self, txt): |
201
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
201 """ Say who will receive the messsage |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
202 @return: a tuple (selected, target_type, target info) with: |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
203 - 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)) |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
204 - target_type: one of PUBLIC, GROUP, ONE2ONE, STATUS, MISC |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
205 - msg: HTML message which will appear in the privacy warning banner """ |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
206 target = self._selected_cache |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
207 |
201
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
208 def getSelectedOrStatus(): |
294
a6b3715f0bd6
browser_side: bug fixes for switching between unibox and rich text editor:
souliane <souliane@mailoo.org>
parents:
293
diff
changeset
|
209 if target and target.isSelectable(): |
201
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
210 _type, msg = target.getWarningData() |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
223
diff
changeset
|
211 target_hook = None # we use the selected widget, not a hook |
201
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
212 else: |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
213 _type, msg = "STATUS", "This will be your new status message" |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
214 target_hook = (txt, None) |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
215 return (target_hook, _type, msg) |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
216 |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
217 if not txt.startswith('@'): |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
218 target_hook, _type, msg = getSelectedOrStatus() |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
219 elif txt.startswith('@@: '): |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
220 _type = "PUBLIC" |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
221 msg = MicroblogPanel.warning_msg_public |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
222 target_hook = (txt[4:], None) |
33 | 223 elif txt.startswith('@'): |
224 _end = txt.find(': ') | |
225 if _end == -1: | |
201
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
226 target_hook, _type, msg = getSelectedOrStatus() |
33 | 227 else: |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
223
diff
changeset
|
228 group = txt[1:_end] # only one target group is managed for the moment |
201
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
229 if not group or not group in self.host.contact_panel.getGroups(): |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
230 # the group doesn't exists, we ignore the key |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
231 group = None |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
232 target_hook, _type, msg = getSelectedOrStatus() |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
233 else: |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
234 _type = "GROUP" |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
235 msg = MicroblogPanel.warning_msg_group % group |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
223
diff
changeset
|
236 target_hook = (txt[_end + 2:], group) |
33 | 237 else: |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
433
diff
changeset
|
238 log.error("Unknown target") |
201
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
239 target_hook, _type, msg = getSelectedOrStatus() |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
240 |
201
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
241 return (target_hook, _type, msg) |
33 | 242 |
243 def onKeyPress(self, sender, keycode, modifiers): | |
244 _txt = self.getText() | |
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
|
245 target_hook, type_, msg = self._getTarget(_txt) |
33 | 246 |
83 | 247 if keycode == KEY_ENTER: |
33 | 248 if _txt: |
201
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
249 if target_hook: |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
250 parsed_txt, data = target_hook |
269
9eb9c7d41bdc
browser_side: added generic method "send" in SatWebFrontend
souliane <souliane@mailoo.org>
parents:
267
diff
changeset
|
251 self.host.send([(type_, data)], parsed_txt) |
310
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
252 self.host._updateInputHistory(_txt) |
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
253 self.setText('') |
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
|
254 self.host.showWarning(None, None) |
362
019e1e706e74
browser_side: display the popup notifying the message's recipient when you edit the blog entry's bubble.
souliane <souliane@mailoo.org>
parents:
361
diff
changeset
|
255 else: |
019e1e706e74
browser_side: display the popup notifying the message's recipient when you edit the blog entry's bubble.
souliane <souliane@mailoo.org>
parents:
361
diff
changeset
|
256 self.host.showWarning(type_, msg) |
310
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
257 MessageBox.onKeyPress(self, sender, keycode, modifiers) |
214
7b26be266ab1
plugin XEP-0085: Chat State Notifications
souliane <souliane@mailoo.org>
parents:
213
diff
changeset
|
258 |
231
fab7aa366576
browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents:
230
diff
changeset
|
259 def getTargetAndData(self): |
fab7aa366576
browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents:
230
diff
changeset
|
260 """For external use, to get information about the (hypothetical) message |
fab7aa366576
browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents:
230
diff
changeset
|
261 that would be sent if we press Enter right now in the unibox. |
fab7aa366576
browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents:
230
diff
changeset
|
262 @return a tuple (target, data) with: |
fab7aa366576
browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents:
230
diff
changeset
|
263 - data: what would be the content of the message (body) |
fab7aa366576
browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents:
230
diff
changeset
|
264 - target: JID, group with the prefix "@" or the public entity "@@" |
fab7aa366576
browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents:
230
diff
changeset
|
265 """ |
fab7aa366576
browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents:
230
diff
changeset
|
266 _txt = self.getText() |
fab7aa366576
browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents:
230
diff
changeset
|
267 target_hook, _type, _msg = self._getTarget(_txt) |
fab7aa366576
browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents:
230
diff
changeset
|
268 if target_hook: |
fab7aa366576
browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents:
230
diff
changeset
|
269 data, target = target_hook |
fab7aa366576
browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents:
230
diff
changeset
|
270 if target is None: |
fab7aa366576
browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents:
230
diff
changeset
|
271 return target_hook |
fab7aa366576
browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents:
230
diff
changeset
|
272 return (data, "@%s" % (target if target != "" else "@")) |
fab7aa366576
browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents:
230
diff
changeset
|
273 if isinstance(self._selected_cache, MicroblogPanel): |
fab7aa366576
browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents:
230
diff
changeset
|
274 groups = self._selected_cache.accepted_groups |
fab7aa366576
browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents:
230
diff
changeset
|
275 target = "@%s" % (groups[0] if len(groups) > 0 else "@") |
fab7aa366576
browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents:
230
diff
changeset
|
276 if len(groups) > 1: |
fab7aa366576
browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents:
230
diff
changeset
|
277 Window.alert("Sole the first group of the selected panel is taken in consideration: '%s'" % groups[0]) |
fab7aa366576
browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents:
230
diff
changeset
|
278 elif isinstance(self._selected_cache, ChatPanel): |
fab7aa366576
browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents:
230
diff
changeset
|
279 target = self._selected_cache.target |
294
a6b3715f0bd6
browser_side: bug fixes for switching between unibox and rich text editor:
souliane <souliane@mailoo.org>
parents:
293
diff
changeset
|
280 else: |
a6b3715f0bd6
browser_side: bug fixes for switching between unibox and rich text editor:
souliane <souliane@mailoo.org>
parents:
293
diff
changeset
|
281 target = None |
231
fab7aa366576
browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents:
230
diff
changeset
|
282 return (_txt, target) |
fab7aa366576
browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents:
230
diff
changeset
|
283 |
294
a6b3715f0bd6
browser_side: bug fixes for switching between unibox and rich text editor:
souliane <souliane@mailoo.org>
parents:
293
diff
changeset
|
284 def onWidgetClosed(self, lib_wid): |
a6b3715f0bd6
browser_side: bug fixes for switching between unibox and rich text editor:
souliane <souliane@mailoo.org>
parents:
293
diff
changeset
|
285 """Called when a libervia widget is closed""" |
a6b3715f0bd6
browser_side: bug fixes for switching between unibox and rich text editor:
souliane <souliane@mailoo.org>
parents:
293
diff
changeset
|
286 if self._selected_cache == lib_wid: |
a6b3715f0bd6
browser_side: bug fixes for switching between unibox and rich text editor:
souliane <souliane@mailoo.org>
parents:
293
diff
changeset
|
287 self.onSelectedChange(None) |
a6b3715f0bd6
browser_side: bug fixes for switching between unibox and rich text editor:
souliane <souliane@mailoo.org>
parents:
293
diff
changeset
|
288 |
73
447dc8ac181b
Adrien's uniBox design integration + lastPopup style
Goffi <goffi@goffi.org>
parents:
71
diff
changeset
|
289 """def complete(self): |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
290 |
33 | 291 #self.visible=False #XXX: self.visible is not unset in pyjamas when ENTER is pressed and a completion is done |
292 #XXX: fixed directly on pyjamas, if the patch is accepted, no need to walk around this | |
73
447dc8ac181b
Adrien's uniBox design integration + lastPopup style
Goffi <goffi@goffi.org>
parents:
71
diff
changeset
|
293 return AutoCompleteTextBox.complete(self)""" |
33 | 294 |
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
|
295 |
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 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
|
297 |
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 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
|
299 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
|
300 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
|
301 |
394
ee61b0765d6c
browser_side: radiocol supports MP3
souliane <souliane@mailoo.org>
parents:
383
diff
changeset
|
302 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
|
303 """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
|
304 If type_ is None, a popup being currently displayed will be hidden. |
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 @type_: a type determining the CSS style to be applied (see __showWarning) |
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 @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
|
307 """ |
f4efffb9627c
browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents:
351
diff
changeset
|
308 if 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
|
309 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
|
310 return |
f4efffb9627c
browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents:
351
diff
changeset
|
311 if not 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
|
312 self.__showWarning(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
|
313 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
|
314 self._timeCb(None) # we 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
|
315 self.__showWarning(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
|
316 |
394
ee61b0765d6c
browser_side: radiocol supports MP3
souliane <souliane@mailoo.org>
parents:
383
diff
changeset
|
317 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
|
318 |
f4efffb9627c
browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents:
351
diff
changeset
|
319 def __showWarning(self, 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
|
320 """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
|
321 @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
|
322 "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
|
323 @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
|
324 """ |
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 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
|
326 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
|
327 if not msg: |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
433
diff
changeset
|
328 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
|
329 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
|
330 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
|
331 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
|
332 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
|
333 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
|
334 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
|
335 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
|
336 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
|
337 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
|
338 else: |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
433
diff
changeset
|
339 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
|
340 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
|
341 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
|
342 |
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._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
|
344 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
|
345 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
|
346 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
|
347 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
|
348 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
|
349 |
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
|
350 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
|
351 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
|
352 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
|
353 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
|
354 |
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
|
355 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
|
356 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
|
357 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
|
358 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
|
359 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
|
360 |
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
|
361 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
|
362 """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
|
363 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
|
364 |
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
|
365 |
132
30d8e328559b
server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
366 class MicroblogItem(): |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
223
diff
changeset
|
367 # XXX: should be moved in a separated module |
132
30d8e328559b
server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
368 |
30d8e328559b
server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
369 def __init__(self, data): |
30d8e328559b
server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
370 self.id = data['id'] |
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
|
371 self.type = data.get('type', 'main_item') |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
372 self.empty = data.get('new', False) |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
373 self.title = data.get('title', '') |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
374 self.title_xhtml = data.get('title_xhtml', '') |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
375 self.content = data.get('content', '') |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
376 self.content_xhtml = data.get('content_xhtml', '') |
132
30d8e328559b
server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
377 self.author = data['author'] |
307
44b46db7dfef
browser_side (groupblog): order items using "published" instead of "updated"
souliane <souliane@mailoo.org>
parents:
306
diff
changeset
|
378 self.updated = float(data.get('updated', 0)) # XXX: int doesn't work here |
365
a74a2dfbe4f5
browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents:
362
diff
changeset
|
379 self.published = float(data.get('published', self.updated)) # XXX: int doesn't work here |
a74a2dfbe4f5
browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents:
362
diff
changeset
|
380 self.service = data.get('service', '') |
a74a2dfbe4f5
browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents:
362
diff
changeset
|
381 self.node = data.get('node', '') |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
382 self.comments = data.get('comments', False) |
365
a74a2dfbe4f5
browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents:
362
diff
changeset
|
383 self.comments_service = data.get('comments_service', '') |
a74a2dfbe4f5
browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents:
362
diff
changeset
|
384 self.comments_node = data.get('comments_node', '') |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
385 |
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
|
386 |
282
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
387 class MicroblogEntry(SimplePanel, ClickHandler, FocusHandler, KeyboardHandler): |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
388 |
350
f1b9ec412769
browser_side: MicroblogEntry defines properties to access MicroblogItem attributes (instead of overwriting __getattr__)
souliane <souliane@mailoo.org>
parents:
349
diff
changeset
|
389 def __init__(self, blog_panel, data): |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
390 """ |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
391 @param blog_panel: the parent panel |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
392 @param data: dict containing the blog item data, or a MicroblogItem instance. |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
393 """ |
350
f1b9ec412769
browser_side: MicroblogEntry defines properties to access MicroblogItem attributes (instead of overwriting __getattr__)
souliane <souliane@mailoo.org>
parents:
349
diff
changeset
|
394 self._base_item = data if isinstance(data, MicroblogItem) else MicroblogItem(data) |
f1b9ec412769
browser_side: MicroblogEntry defines properties to access MicroblogItem attributes (instead of overwriting __getattr__)
souliane <souliane@mailoo.org>
parents:
349
diff
changeset
|
395 for attr in ['id', 'type', 'empty', 'title', 'title_xhtml', 'content', 'content_xhtml', |
365
a74a2dfbe4f5
browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents:
362
diff
changeset
|
396 'author', 'updated', 'published', 'comments', 'service', 'node', |
a74a2dfbe4f5
browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents:
362
diff
changeset
|
397 'comments_service', 'comments_node']: |
350
f1b9ec412769
browser_side: MicroblogEntry defines properties to access MicroblogItem attributes (instead of overwriting __getattr__)
souliane <souliane@mailoo.org>
parents:
349
diff
changeset
|
398 getter = lambda attr: lambda inst: getattr(inst._base_item, attr) |
395
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
399 setter = lambda attr: lambda inst, value: setattr(inst._base_item, attr, value) |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
400 setattr(MicroblogEntry, attr, property(getter(attr), setter(attr))) |
350
f1b9ec412769
browser_side: MicroblogEntry defines properties to access MicroblogItem attributes (instead of overwriting __getattr__)
souliane <souliane@mailoo.org>
parents:
349
diff
changeset
|
401 |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
402 SimplePanel.__init__(self) |
199
39311c7dad77
browser side: it is now possible to select a microblog panel or an entry inside it
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
403 self._blog_panel = blog_panel |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
404 |
291
89818bca1a33
browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents:
289
diff
changeset
|
405 self.panel = FlowPanel() |
89818bca1a33
browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents:
289
diff
changeset
|
406 self.panel.setStyleName('mb_entry') |
307
44b46db7dfef
browser_side (groupblog): order items using "published" instead of "updated"
souliane <souliane@mailoo.org>
parents:
306
diff
changeset
|
407 |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
408 self.header = HTMLPanel('') |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
409 self.panel.add(self.header) |
291
89818bca1a33
browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents:
289
diff
changeset
|
410 |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
411 self.entry_actions = VerticalPanel() |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
412 self.entry_actions.setStyleName('mb_entry_actions') |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
413 self.panel.add(self.entry_actions) |
291
89818bca1a33
browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents:
289
diff
changeset
|
414 |
89818bca1a33
browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents:
289
diff
changeset
|
415 entry_avatar = SimplePanel() |
89818bca1a33
browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents:
289
diff
changeset
|
416 entry_avatar.setStyleName('mb_entry_avatar') |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
417 self.avatar = Image(self._blog_panel.host.getAvatar(self.author)) |
291
89818bca1a33
browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents:
289
diff
changeset
|
418 entry_avatar.add(self.avatar) |
89818bca1a33
browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents:
289
diff
changeset
|
419 self.panel.add(entry_avatar) |
89818bca1a33
browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents:
289
diff
changeset
|
420 |
442
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
421 if TOGGLE_EDITION_USE_ICON: |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
422 self.entry_dialog = HorizontalPanel() |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
423 else: |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
424 self.entry_dialog = VerticalPanel() |
291
89818bca1a33
browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents:
289
diff
changeset
|
425 self.entry_dialog.setStyleName('mb_entry_dialog') |
89818bca1a33
browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents:
289
diff
changeset
|
426 self.panel.add(self.entry_dialog) |
89818bca1a33
browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents:
289
diff
changeset
|
427 |
119 | 428 self.add(self.panel) |
199
39311c7dad77
browser side: it is now possible to select a microblog panel or an entry inside it
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
429 ClickHandler.__init__(self) |
39311c7dad77
browser side: it is now possible to select a microblog panel or an entry inside it
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
430 self.addClickListener(self) |
119 | 431 |
365
a74a2dfbe4f5
browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents:
362
diff
changeset
|
432 self.__pub_data = (self.service, self.node, self.id) |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
433 self.__setContent() |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
434 |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
435 def __setContent(self): |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
436 """Actually set the entry content (header, icons, bubble...)""" |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
437 self.delete_label = self.update_label = self.comment_label = None |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
438 self.bubble = self._current_comment = None |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
439 self.__setHeader() |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
440 self.__setBubble() |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
441 self.__setIcons() |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
442 |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
443 def __setHeader(self): |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
444 """Set the entry header""" |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
445 if self.empty: |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
446 return |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
447 update_text = u" — ✍ " + "<span class='mb_entry_timestamp'>%s</span>" % datetime.fromtimestamp(self.updated) |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
448 self.header.setHTML("""<div class='mb_entry_header'> |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
449 <span class='mb_entry_author'>%(author)s</span> on |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
450 <span class='mb_entry_timestamp'>%(published)s</span>%(updated)s |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
451 </div>""" % {'author': html_sanitize(self.author), |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
452 'published': datetime.fromtimestamp(self.published), |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
453 'updated': update_text if self.published != self.updated else '' |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
454 } |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
455 ) |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
456 |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
457 def __setIcons(self): |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
458 """Set the entry icons (delete, update, comment)""" |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
459 if self.empty: |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
460 return |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
461 |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
462 def addIcon(label, title): |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
463 label = Label(label) |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
464 label.setTitle(title) |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
465 label.addClickListener(self) |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
466 self.entry_actions.add(label) |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
467 return label |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
468 |
442
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
469 if self.comments: |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
470 self.comment_label = addIcon(u"↶", "Comment this message") |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
471 self.comment_label.setStyleName('mb_entry_action_larger') |
366
39ae5bf92786
browser_side: allow one blogger to moderate the comments made on his own blog messages.
souliane <souliane@mailoo.org>
parents:
365
diff
changeset
|
472 is_publisher = self.author == self._blog_panel.host.whoami.bare |
442
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
473 if is_publisher: |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
474 self.update_label = addIcon(u"✍", "Edit this message") |
366
39ae5bf92786
browser_side: allow one blogger to moderate the comments made on his own blog messages.
souliane <souliane@mailoo.org>
parents:
365
diff
changeset
|
475 if is_publisher or str(self.node).endswith(self._blog_panel.host.whoami.bare): |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
476 self.delete_label = addIcon(u"✗", "Delete this message") |
291
89818bca1a33
browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents:
289
diff
changeset
|
477 |
119 | 478 def updateAvatar(self, new_avatar): |
479 """Change the avatar of the entry | |
480 @param new_avatar: path to the new image""" | |
481 self.avatar.setUrl(new_avatar) | |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
482 |
199
39311c7dad77
browser side: it is now possible to select a microblog panel or an entry inside it
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
483 def onClick(self, sender): |
282
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
484 if sender == self: |
414
ae598511850d
browser_side: set microblog editor minimal width + fix the scrolling to comment
souliane <souliane@mailoo.org>
parents:
408
diff
changeset
|
485 try: # prevent re-selection of the main entry after a comment has been focused |
ae598511850d
browser_side: set microblog editor minimal width + fix the scrolling to comment
souliane <souliane@mailoo.org>
parents:
408
diff
changeset
|
486 if self.__ignoreNextEvent: |
ae598511850d
browser_side: set microblog editor minimal width + fix the scrolling to comment
souliane <souliane@mailoo.org>
parents:
408
diff
changeset
|
487 self.__ignoreNextEvent = False |
ae598511850d
browser_side: set microblog editor minimal width + fix the scrolling to comment
souliane <souliane@mailoo.org>
parents:
408
diff
changeset
|
488 return |
ae598511850d
browser_side: set microblog editor minimal width + fix the scrolling to comment
souliane <souliane@mailoo.org>
parents:
408
diff
changeset
|
489 except AttributeError: |
ae598511850d
browser_side: set microblog editor minimal width + fix the scrolling to comment
souliane <souliane@mailoo.org>
parents:
408
diff
changeset
|
490 pass |
322
971e3812903a
browser_side: scroll to the clicked microblog post and blink it (previous behavior is conserved when the unibox is enabled)
souliane <souliane@mailoo.org>
parents:
319
diff
changeset
|
491 self._blog_panel.setSelectedEntry(self) |
282
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
492 elif sender == self.delete_label: |
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
493 self._delete() |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
494 elif sender == self.update_label: |
395
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
495 self.edit(True) |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
496 elif sender == self.comment_label: |
414
ae598511850d
browser_side: set microblog editor minimal width + fix the scrolling to comment
souliane <souliane@mailoo.org>
parents:
408
diff
changeset
|
497 self.__ignoreNextEvent = True |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
498 self._comment() |
282
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
499 |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
500 def __modifiedCb(self, content): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
501 """Send the new content to the backend |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
502 @return: False to restore the original content if a deletion has been cancelled |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
503 """ |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
504 if not content['text']: # previous content has been emptied |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
505 self._delete(True) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
506 return False |
307
44b46db7dfef
browser_side (groupblog): order items using "published" instead of "updated"
souliane <souliane@mailoo.org>
parents:
306
diff
changeset
|
507 extra = {'published': str(self.published)} |
395
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
508 if isinstance(self.bubble, richtext.RichTextEditor): |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
509 # TODO: if the user change his parameters after the message edition started, |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
510 # the message syntax could be different then the current syntax: pass the |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
511 # message syntax in extra for the frontend to use it instead of current syntax. |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
512 extra.update({'content_rich': content['text'], 'title': content['title']}) |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
513 if self.empty: |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
514 if self.type == 'main_item': |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
515 self._blog_panel.host.bridge.call('sendMblog', None, None, self._blog_panel.accepted_groups, content['text'], extra) |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
516 else: |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
517 self._blog_panel.host.bridge.call('sendMblogComment', None, self._parent_entry.comments, content['text'], extra) |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
518 else: |
365
a74a2dfbe4f5
browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents:
362
diff
changeset
|
519 self._blog_panel.host.bridge.call('updateMblog', None, self.__pub_data, self.comments, content['text'], extra) |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
520 return True |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
521 |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
522 def __afterEditCb(self, content): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
523 """Remove the entry if it was an empty one (used for creating a new blog post). |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
524 Data for the actual new blog post will be received from the bridge""" |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
525 if self.empty: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
526 self._blog_panel.removeEntry(self.type, self.id) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
527 if self.type == 'main_item': # restore the "New message" button |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
528 self._blog_panel.refresh() |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
529 else: # allow to create a new comment |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
530 self._parent_entry._current_comment = None |
425
19bd203daa27
browser_side: set microblog editor width to 80%
souliane <souliane@mailoo.org>
parents:
422
diff
changeset
|
531 self.entry_dialog.setWidth('auto') |
395
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
532 try: |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
533 self.toggle_syntax_button.removeFromParent() |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
534 except TypeError: |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
535 pass |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
536 |
395
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
537 def __setBubble(self, edit=False): |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
538 """Set the bubble displaying the initial content.""" |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
539 content = {'text': self.content_xhtml if self.content_xhtml else self.content, |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
540 'title': self.title_xhtml if self.title_xhtml else self.title} |
395
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
541 if self.content_xhtml: |
433
bbdbee25123a
import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents:
432
diff
changeset
|
542 content.update({'syntax': C.SYNTAX_XHTML}) |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
543 if self.author != self._blog_panel.host.whoami.bare: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
544 options = ['read_only'] |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
545 else: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
546 options = [] if self.empty else ['update_msg'] |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
547 self.bubble = richtext.RichTextEditor(self._blog_panel.host, content, self.__modifiedCb, self.__afterEditCb, options) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
548 else: # assume raw text message have no title |
404
c393e7dc9ae6
browser_side: refactorize SimpleTextEditor init parameters
souliane <souliane@mailoo.org>
parents:
402
diff
changeset
|
549 self.bubble = LightTextEditor(content, self.__modifiedCb, self.__afterEditCb, options={'no_xhtml': True}) |
425
19bd203daa27
browser_side: set microblog editor width to 80%
souliane <souliane@mailoo.org>
parents:
422
diff
changeset
|
550 self.bubble.addStyleName("bubble") |
395
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
551 try: |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
552 self.toggle_syntax_button.removeFromParent() |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
553 except TypeError: |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
554 pass |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
555 self.entry_dialog.add(self.bubble) |
395
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
556 self.edit(edit) |
362
019e1e706e74
browser_side: display the popup notifying the message's recipient when you edit the blog entry's bubble.
souliane <souliane@mailoo.org>
parents:
361
diff
changeset
|
557 self.bubble.addEditListener(self.__showWarning) |
019e1e706e74
browser_side: display the popup notifying the message's recipient when you edit the blog entry's bubble.
souliane <souliane@mailoo.org>
parents:
361
diff
changeset
|
558 |
019e1e706e74
browser_side: display the popup notifying the message's recipient when you edit the blog entry's bubble.
souliane <souliane@mailoo.org>
parents:
361
diff
changeset
|
559 def __showWarning(self, sender, keycode): |
019e1e706e74
browser_side: display the popup notifying the message's recipient when you edit the blog entry's bubble.
souliane <souliane@mailoo.org>
parents:
361
diff
changeset
|
560 if keycode == KEY_ENTER: |
019e1e706e74
browser_side: display the popup notifying the message's recipient when you edit the blog entry's bubble.
souliane <souliane@mailoo.org>
parents:
361
diff
changeset
|
561 self._blog_panel.host.showWarning(None, None) |
019e1e706e74
browser_side: display the popup notifying the message's recipient when you edit the blog entry's bubble.
souliane <souliane@mailoo.org>
parents:
361
diff
changeset
|
562 else: |
019e1e706e74
browser_side: display the popup notifying the message's recipient when you edit the blog entry's bubble.
souliane <souliane@mailoo.org>
parents:
361
diff
changeset
|
563 self._blog_panel.host.showWarning(*self._blog_panel.getWarningData(self.type == 'comment')) |
282
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
564 |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
565 def _delete(self, empty=False): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
566 """Ask confirmation for deletion. |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
567 @return: False if the deletion has been cancelled.""" |
282
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
568 def confirm_cb(answer): |
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
569 if answer: |
365
a74a2dfbe4f5
browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents:
362
diff
changeset
|
570 self._blog_panel.host.bridge.call('deleteMblog', None, self.__pub_data, self.comments) |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
571 else: # restore the text if it has been emptied during the edition |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
572 self.bubble.setContent(self.bubble._original_content) |
282
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
573 |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
574 if self.empty: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
575 text = _("New ") + (_("message") if self.comments else _("comment")) + _(" without body has been cancelled.") |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
576 dialog.InfoDialog(_("Information"), text).show() |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
577 return |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
578 text = "" |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
579 if empty: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
580 text = (_("Message") if self.comments else _("Comment")) + _(" body has been emptied.<br/>") |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
581 target = _('message and all its comments') if self.comments else _('comment') |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
582 text += _("Do you really want to delete this %s?") % target |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
583 dialog.ConfirmDialog(confirm_cb, text=text).show() |
119 | 584 |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
585 def _comment(self): |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
586 """Add an empty entry for a new comment""" |
315
09205b410a53
browser_side: handle successive click on blog post "edit" and "comment" icons
souliane <souliane@mailoo.org>
parents:
314
diff
changeset
|
587 if self._current_comment: |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
588 self._current_comment.bubble.setFocus(True) |
414
ae598511850d
browser_side: set microblog editor minimal width + fix the scrolling to comment
souliane <souliane@mailoo.org>
parents:
408
diff
changeset
|
589 self._blog_panel.setSelectedEntry(self._current_comment) |
315
09205b410a53
browser_side: handle successive click on blog post "edit" and "comment" icons
souliane <souliane@mailoo.org>
parents:
314
diff
changeset
|
590 return |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
591 data = {'id': str(time()), |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
592 'new': True, |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
593 'type': 'comment', |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
594 'author': self._blog_panel.host.whoami.bare, |
365
a74a2dfbe4f5
browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents:
362
diff
changeset
|
595 'service': self.comments_service, |
a74a2dfbe4f5
browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents:
362
diff
changeset
|
596 'node': self.comments_node |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
597 } |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
598 entry = self._blog_panel.addEntry(data) |
365
a74a2dfbe4f5
browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents:
362
diff
changeset
|
599 if entry is None: |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
433
diff
changeset
|
600 log.info("The entry of id %s can not be commented" % self.id) |
365
a74a2dfbe4f5
browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents:
362
diff
changeset
|
601 return |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
602 entry._parent_entry = self |
315
09205b410a53
browser_side: handle successive click on blog post "edit" and "comment" icons
souliane <souliane@mailoo.org>
parents:
314
diff
changeset
|
603 self._current_comment = entry |
395
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
604 self.edit(True, entry) |
414
ae598511850d
browser_side: set microblog editor minimal width + fix the scrolling to comment
souliane <souliane@mailoo.org>
parents:
408
diff
changeset
|
605 self._blog_panel.setSelectedEntry(entry) |
395
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
606 |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
607 def edit(self, edit, entry=None): |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
608 """Toggle the bubble between display and edit mode |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
609 @edit: boolean value |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
610 @entry: MicroblogEntry instance, or None to use self |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
611 """ |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
612 if entry is None: |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
613 entry = self |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
614 try: |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
615 entry.toggle_syntax_button.removeFromParent() |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
616 except TypeError: |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
617 pass |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
618 entry.bubble.edit(edit) |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
619 if edit: |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
620 if isinstance(entry.bubble, richtext.RichTextEditor): |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
621 image = '<a class="richTextIcon">A</a>' |
442
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
622 html = '<a style="color: blue;">raw text</a>' |
395
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
623 title = _('Switch to raw text edition') |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
624 else: |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
625 image = '<img src="media/icons/tango/actions/32/format-text-italic.png" class="richTextIcon"/>' |
442
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
626 html = '<a style="color: blue;">rich text</a>' |
395
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
627 title = _('Switch to rich text edition') |
442
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
628 if TOGGLE_EDITION_USE_ICON: |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
629 entry.entry_dialog.setWidth('80%') |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
630 entry.toggle_syntax_button = Button(image, entry.toggleContentSyntax) |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
631 entry.toggle_syntax_button.setTitle(title) |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
632 entry.entry_dialog.add(entry.toggle_syntax_button) |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
633 else: |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
634 entry.toggle_syntax_button = HTML(html) |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
635 entry.toggle_syntax_button.addClickListener(entry.toggleContentSyntax) |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
636 entry.toggle_syntax_button.addStyleName('mb_entry_toggle_syntax') |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
637 entry.entry_dialog.add(entry.toggle_syntax_button) |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
638 entry.toggle_syntax_button.setStyleAttribute('top', '-20px') # XXX: need to force CSS |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
639 entry.toggle_syntax_button.setStyleAttribute('left', '-20px') |
395
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
640 |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
641 def toggleContentSyntax(self): |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
642 """Toggle the editor between raw and rich text""" |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
643 original_content = self.bubble.getOriginalContent() |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
644 rich = not isinstance(self.bubble, richtext.RichTextEditor) |
400
487dd238ab88
browser_side: bug fixes for microblog raw/rich edition toggle
souliane <souliane@mailoo.org>
parents:
397
diff
changeset
|
645 if rich: |
433
bbdbee25123a
import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents:
432
diff
changeset
|
646 original_content['syntax'] = C.SYNTAX_XHTML |
395
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
647 |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
648 def setBubble(text): |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
649 self.content = text |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
650 self.content_xhtml = text if rich else '' |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
651 self.content_title = self.content_title_xhtml = '' |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
652 self.bubble.removeFromParent() |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
653 self.__setBubble(True) |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
654 self.bubble.setOriginalContent(original_content) |
400
487dd238ab88
browser_side: bug fixes for microblog raw/rich edition toggle
souliane <souliane@mailoo.org>
parents:
397
diff
changeset
|
655 if rich: |
487dd238ab88
browser_side: bug fixes for microblog raw/rich edition toggle
souliane <souliane@mailoo.org>
parents:
397
diff
changeset
|
656 self.bubble.setDisplayContent() # needed in case the edition is aborted, to not end with an empty bubble |
395
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
657 |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
658 text = self.bubble.getContent()['text'] |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
659 if not text: |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
660 setBubble(' ') # something different than empty string is needed to initialize the rich text editor |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
661 return |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
662 if not rich: |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
663 def confirm_cb(answer): |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
664 if answer: |
433
bbdbee25123a
import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents:
432
diff
changeset
|
665 self._blog_panel.host.bridge.call('syntaxConvert', setBubble, text, C.SYNTAX_CURRENT, C.SYNTAX_TEXT) |
395
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
666 dialog.ConfirmDialog(confirm_cb, text=_("Do you really want to lose the title and text formatting?")).show() |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
667 else: |
433
bbdbee25123a
import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents:
432
diff
changeset
|
668 self._blog_panel.host.bridge.call('syntaxConvert', setBubble, text, C.SYNTAX_TEXT, C.SYNTAX_XHTML) |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
669 |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
670 |
195 | 671 class MicroblogPanel(base_widget.LiberviaWidget): |
201
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
672 warning_msg_public = "This message will be PUBLIC and everybody will be able to see it, even people you don't know" |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
673 warning_msg_group = "This message will be published for all the people of the group <span class='warningTarget'>%s</span>" |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
674 |
132
30d8e328559b
server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
675 def __init__(self, host, accepted_groups): |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
676 """Panel used to show microblog |
132
30d8e328559b
server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
677 @param accepted_groups: groups displayed in this panel, if empty, show all microblogs from all contacts |
30d8e328559b
server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
678 """ |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
679 base_widget.LiberviaWidget.__init__(self, host, ", ".join(accepted_groups), selectable=True) |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
680 self.setAcceptedGroup(accepted_groups) |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
681 self.host = host |
58
4fa3d57f72f8
browser side: microblog entries caching
Goffi <goffi@goffi.org>
parents:
57
diff
changeset
|
682 self.entries = {} |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
683 self.comments = {} |
199
39311c7dad77
browser side: it is now possible to select a microblog panel or an entry inside it
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
684 self.selected_entry = None |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
685 self.vpanel = VerticalPanel() |
83 | 686 self.vpanel.setStyleName('microblogPanel') |
34 | 687 self.setWidget(self.vpanel) |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
688 |
326
36927be51481
browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
689 def refresh(self): |
36927be51481
browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
690 """Refresh the display of this widget. If the unibox is disabled, |
442
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
691 display the 'New message' button or an empty bubble on top of the panel""" |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
692 if hasattr(self, 'new_button'): |
442
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
693 self.new_button.setVisible(self.host.uni_box is None) |
326
36927be51481
browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
694 return |
442
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
695 if self.host.uni_box is None: |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
696 def addBox(): |
442
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
697 if hasattr(self, 'new_button'): |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
698 self.new_button.setVisible(False) |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
699 data = {'id': str(time()), |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
700 'new': True, |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
701 'author': self.host.whoami.bare, |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
702 } |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
703 entry = self.addEntry(data) |
395
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
704 entry.edit(True) |
442
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
705 if NEW_MESSAGE_USE_BUTTON: |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
706 self.new_button = Button("New message", listener=addBox) |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
707 self.new_button.setStyleName("microblogNewButton") |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
708 self.vpanel.insert(self.new_button, 0) |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
709 else: |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
710 addBox() |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
711 |
195 | 712 @classmethod |
713 def registerClass(cls): | |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
714 base_widget.LiberviaWidget.addDropKey("GROUP", cls.createPanel) |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
715 base_widget.LiberviaWidget.addDropKey("CONTACT_TITLE", cls.createMetaPanel) |
195 | 716 |
717 @classmethod | |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
718 def createPanel(cls, host, item): |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
719 """Generic panel creation for one, several or all groups (meta). |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
720 @parem host: the SatWebFrontend instance |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
721 @param item: single group as a string, list of groups |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
722 (as an array) or None (for the meta group = "all groups") |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
723 @return: the created MicroblogPanel |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
724 """ |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
725 _items = item if isinstance(item, list) else ([] if item is None else [item]) |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
726 _type = 'ALL' if _items == [] else 'GROUP' |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
727 # XXX: pyjamas doesn't support use of cls directly |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
728 _new_panel = MicroblogPanel(host, _items) |
195 | 729 host.FillMicroblogPanel(_new_panel) |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
730 host.bridge.call('getMassiveLastMblogs', _new_panel.massiveInsert, _type, _items, 10) |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
731 host.setSelected(_new_panel) |
383
b90744ec426e
browser_side: refresh the ChatPanel and MicroblogPanel when they are opened from a drag and drop
souliane <souliane@mailoo.org>
parents:
380
diff
changeset
|
732 _new_panel.refresh() |
195 | 733 return _new_panel |
734 | |
735 @classmethod | |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
736 def createMetaPanel(cls, host, item): |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
737 """Needed for the drop keys to not be mixed between meta panel and panel for "Contacts" group""" |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
738 return MicroblogPanel.createPanel(host, None) |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
739 |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
740 @property |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
741 def accepted_groups(self): |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
742 return self._accepted_groups |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
743 |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
744 def matchEntity(self, entity): |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
745 """ |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
746 @param entity: single group as a string, list of groups |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
747 (as an array) or None (for the meta group = "all groups") |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
748 @return: True if self matches the given entity |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
749 """ |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
750 entity = entity if isinstance(entity, list) else ([] if entity is None else [entity]) |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
751 entity.sort() # sort() do not return the sorted list: do it here, not on the "return" line |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
752 return self.accepted_groups == entity |
195 | 753 |
362
019e1e706e74
browser_side: display the popup notifying the message's recipient when you edit the blog entry's bubble.
souliane <souliane@mailoo.org>
parents:
361
diff
changeset
|
754 def getWarningData(self, comment=None): |
019e1e706e74
browser_side: display the popup notifying the message's recipient when you edit the blog entry's bubble.
souliane <souliane@mailoo.org>
parents:
361
diff
changeset
|
755 """ |
019e1e706e74
browser_side: display the popup notifying the message's recipient when you edit the blog entry's bubble.
souliane <souliane@mailoo.org>
parents:
361
diff
changeset
|
756 @param comment: True if the composed message is a comment. If None, consider we are |
019e1e706e74
browser_side: display the popup notifying the message's recipient when you edit the blog entry's bubble.
souliane <souliane@mailoo.org>
parents:
361
diff
changeset
|
757 composing from the unibox and guess the message type from self.selected_entry |
019e1e706e74
browser_side: display the popup notifying the message's recipient when you edit the blog entry's bubble.
souliane <souliane@mailoo.org>
parents:
361
diff
changeset
|
758 @return: a couple (type, msg) for calling self.host.showWarning""" |
019e1e706e74
browser_side: display the popup notifying the message's recipient when you edit the blog entry's bubble.
souliane <souliane@mailoo.org>
parents:
361
diff
changeset
|
759 if comment is None: # composing from the unibox |
019e1e706e74
browser_side: display the popup notifying the message's recipient when you edit the blog entry's bubble.
souliane <souliane@mailoo.org>
parents:
361
diff
changeset
|
760 if self.selected_entry and not self.selected_entry.comments: |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
433
diff
changeset
|
761 log.error("an item without comment is selected") |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
762 return ("NONE", None) |
362
019e1e706e74
browser_side: display the popup notifying the message's recipient when you edit the blog entry's bubble.
souliane <souliane@mailoo.org>
parents:
361
diff
changeset
|
763 comment = self.selected_entry is not None |
019e1e706e74
browser_side: display the popup notifying the message's recipient when you edit the blog entry's bubble.
souliane <souliane@mailoo.org>
parents:
361
diff
changeset
|
764 if comment: |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
765 return ("PUBLIC", "This is a <span class='warningTarget'>comment</span> and keep the initial post visibility, so it is potentialy public") |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
766 elif not self._accepted_groups: |
201
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
767 # we have a meta MicroblogPanel, we publish publicly |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
768 return ("PUBLIC", self.warning_msg_public) |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
769 else: |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
770 # we only accept one group at the moment |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
771 # FIXME: manage several groups |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
772 return ("GROUP", self.warning_msg_group % self._accepted_groups[0]) |
201
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
773 |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
774 def onTextEntered(self, text): |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
775 if self.selected_entry: |
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
776 # we are entering a comment |
365
a74a2dfbe4f5
browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents:
362
diff
changeset
|
777 comments_url = self.selected_entry.comments |
a74a2dfbe4f5
browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents:
362
diff
changeset
|
778 if not comments_url: |
a74a2dfbe4f5
browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents:
362
diff
changeset
|
779 raise Exception("ERROR: the comments URL is empty") |
a74a2dfbe4f5
browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents:
362
diff
changeset
|
780 target = ("COMMENT", comments_url) |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
781 elif not self._accepted_groups: |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
782 # we are entering a public microblog |
269
9eb9c7d41bdc
browser_side: added generic method "send" in SatWebFrontend
souliane <souliane@mailoo.org>
parents:
267
diff
changeset
|
783 target = ("PUBLIC", None) |
201
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
784 else: |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
785 # we are entering a microblog restricted to a group |
201
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
786 # FIXME: manage several groups |
269
9eb9c7d41bdc
browser_side: added generic method "send" in SatWebFrontend
souliane <souliane@mailoo.org>
parents:
267
diff
changeset
|
787 target = ("GROUP", self._accepted_groups[0]) |
9eb9c7d41bdc
browser_side: added generic method "send" in SatWebFrontend
souliane <souliane@mailoo.org>
parents:
267
diff
changeset
|
788 self.host.send([target], text) |
201
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
789 |
132
30d8e328559b
server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
790 def accept_all(self): |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
791 return not self._accepted_groups # we accept every microblog only if we are not filtering by groups |
132
30d8e328559b
server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
792 |
30d8e328559b
server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
793 def getEntries(self): |
30d8e328559b
server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
794 """Ask all the entries for the currenly accepted groups, |
30d8e328559b
server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
795 and fill the panel""" |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
796 |
132
30d8e328559b
server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
797 def massiveInsert(self, mblogs): |
30d8e328559b
server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
798 """Insert several microblogs at once |
30d8e328559b
server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
799 @param mblogs: dictionary of microblogs, as the result of getMassiveLastGroupBlogs |
30d8e328559b
server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
800 """ |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
433
diff
changeset
|
801 log.debug("Massive insertion of %d microblogs" % len(mblogs)) |
132
30d8e328559b
server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
802 for publisher in mblogs: |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
433
diff
changeset
|
803 log.debug("adding blogs for [%s]" % publisher) |
132
30d8e328559b
server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
804 for mblog in mblogs[publisher]: |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
805 if not "content" in mblog: |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
433
diff
changeset
|
806 log.warning("No content found in microblog [%s]", mblog) |
132
30d8e328559b
server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
807 continue |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
808 self.addEntry(mblog) |
132
30d8e328559b
server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
809 |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
810 def mblogsInsert(self, mblogs): |
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
811 """ Insert several microblogs at once |
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
812 @param mblogs: list of microblogs |
132
30d8e328559b
server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
813 """ |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
814 for mblog in mblogs: |
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
815 if not "content" in mblog: |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
433
diff
changeset
|
816 log.warning("No content found in microblog [%s]", mblog) |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
817 continue |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
818 self.addEntry(mblog) |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
819 |
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
|
820 def _chronoInsert(self, vpanel, entry, reverse=True): |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
821 """ Insert an entry in chronological order |
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
822 @param vpanel: VerticalPanel instance |
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
823 @param entry: MicroblogEntry |
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
824 @param reverse: more recent entry on top if True, chronological order else""" |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
825 if entry.empty: |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
826 entry.published = time() |
135
ceef355156de
server + browser side: groupblog subscription + fixed blog insertion order
Goffi <goffi@goffi.org>
parents:
132
diff
changeset
|
827 # we look for the right index to insert our entry: |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
828 # if reversed, we insert the entry above the first entry |
135
ceef355156de
server + browser side: groupblog subscription + fixed blog insertion order
Goffi <goffi@goffi.org>
parents:
132
diff
changeset
|
829 # in the past |
ceef355156de
server + browser side: groupblog subscription + fixed blog insertion order
Goffi <goffi@goffi.org>
parents:
132
diff
changeset
|
830 idx = 0 |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
831 |
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
832 for child in vpanel.children: |
135
ceef355156de
server + browser side: groupblog subscription + fixed blog insertion order
Goffi <goffi@goffi.org>
parents:
132
diff
changeset
|
833 if not isinstance(child, MicroblogEntry): |
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
|
834 idx += 1 |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
835 continue |
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
836 if reverse: |
307
44b46db7dfef
browser_side (groupblog): order items using "published" instead of "updated"
souliane <souliane@mailoo.org>
parents:
306
diff
changeset
|
837 if child.published < entry.published: |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
838 break |
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
839 else: |
307
44b46db7dfef
browser_side (groupblog): order items using "published" instead of "updated"
souliane <souliane@mailoo.org>
parents:
306
diff
changeset
|
840 if child.published > entry.published: |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
841 break |
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
|
842 idx += 1 |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
843 |
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
844 vpanel.insert(entry, idx) |
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
845 |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
846 def addEntry(self, data): |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
847 """Add an entry to the panel |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
848 @param data: dict containing the item data |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
849 @return: the added entry, or None |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
850 """ |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
851 _entry = MicroblogEntry(self, data) |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
852 if _entry.type == "comment": |
365
a74a2dfbe4f5
browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents:
362
diff
changeset
|
853 comments_hash = (_entry.service, _entry.node) |
a74a2dfbe4f5
browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents:
362
diff
changeset
|
854 if not comments_hash in self.comments: |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
855 # The comments node is not known in this panel |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
856 return None |
365
a74a2dfbe4f5
browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents:
362
diff
changeset
|
857 parent = self.comments[comments_hash] |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
858 parent_idx = self.vpanel.getWidgetIndex(parent) |
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
859 # we find or create the panel where the comment must be inserted |
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
860 try: |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
223
diff
changeset
|
861 sub_panel = self.vpanel.getWidget(parent_idx + 1) |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
862 except IndexError: |
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
863 sub_panel = None |
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
864 if not sub_panel or not isinstance(sub_panel, VerticalPanel): |
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
865 sub_panel = VerticalPanel() |
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
866 sub_panel.setStyleName('microblogPanel') |
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
867 sub_panel.addStyleName('subPanel') |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
223
diff
changeset
|
868 self.vpanel.insert(sub_panel, parent_idx + 1) |
282
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
869 for idx in xrange(0, len(sub_panel.getChildren())): |
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
870 comment = sub_panel.getIndexedChild(idx) |
365
a74a2dfbe4f5
browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents:
362
diff
changeset
|
871 if comment.id == _entry.id: |
282
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
872 # update an existing comment |
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
873 sub_panel.remove(comment) |
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
874 sub_panel.insert(_entry, idx) |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
875 return _entry |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
876 # we want comments to be inserted in chronological order |
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
877 self._chronoInsert(sub_panel, _entry, reverse=False) |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
878 return _entry |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
879 |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
880 if _entry.id in self.entries: # update |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
881 idx = self.vpanel.getWidgetIndex(self.entries[_entry.id]) |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
882 self.vpanel.remove(self.entries[_entry.id]) |
282
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
883 self.vpanel.insert(_entry, idx) |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
884 else: # new entry |
282
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
885 self._chronoInsert(self.vpanel, _entry) |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
886 self.entries[_entry.id] = _entry |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
887 |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
888 if _entry.comments: |
365
a74a2dfbe4f5
browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents:
362
diff
changeset
|
889 # entry has comments, we keep the comments service/node as a reference |
a74a2dfbe4f5
browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents:
362
diff
changeset
|
890 comments_hash = (_entry.comments_service, _entry.comments_node) |
a74a2dfbe4f5
browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents:
362
diff
changeset
|
891 self.comments[comments_hash] = _entry |
a74a2dfbe4f5
browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents:
362
diff
changeset
|
892 self.host.bridge.call('getMblogComments', self.mblogsInsert, _entry.comments_service, _entry.comments_node) |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
893 |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
894 return _entry |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
895 |
282
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
896 def removeEntry(self, type_, id_): |
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
897 """Remove an entry from the panel |
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
898 @param type_: entry type ('main_item' or 'comment') |
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
899 @param id_: entry id |
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
900 """ |
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
901 for child in self.vpanel.getChildren(): |
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
902 if isinstance(child, MicroblogEntry) and type_ == 'main_item': |
365
a74a2dfbe4f5
browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents:
362
diff
changeset
|
903 if child.id == id_: |
282
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
904 main_idx = self.vpanel.getWidgetIndex(child) |
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
905 try: |
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
906 sub_panel = self.vpanel.getWidget(main_idx + 1) |
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
907 if isinstance(sub_panel, VerticalPanel): |
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
908 sub_panel.removeFromParent() |
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
909 except IndexError: |
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
910 pass |
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
911 child.removeFromParent() |
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
912 self.selected_entry = None |
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
913 break |
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
914 elif isinstance(child, VerticalPanel) and type_ == 'comment': |
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
915 for comment in child.getChildren(): |
365
a74a2dfbe4f5
browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents:
362
diff
changeset
|
916 if comment.id == id_: |
282
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
917 comment.removeFromParent() |
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
918 self.selected_entry = None |
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
919 break |
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
920 |
199
39311c7dad77
browser side: it is now possible to select a microblog panel or an entry inside it
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
921 def setSelectedEntry(self, entry): |
322
971e3812903a
browser_side: scroll to the clicked microblog post and blink it (previous behavior is conserved when the unibox is enabled)
souliane <souliane@mailoo.org>
parents:
319
diff
changeset
|
922 try: |
971e3812903a
browser_side: scroll to the clicked microblog post and blink it (previous behavior is conserved when the unibox is enabled)
souliane <souliane@mailoo.org>
parents:
319
diff
changeset
|
923 self.vpanel.getParent().ensureVisible(entry) # scroll to the clicked entry |
971e3812903a
browser_side: scroll to the clicked microblog post and blink it (previous behavior is conserved when the unibox is enabled)
souliane <souliane@mailoo.org>
parents:
319
diff
changeset
|
924 except AttributeError: |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
433
diff
changeset
|
925 log.warning("FIXME: MicroblogPanel.vpanel should be wrapped in a ScrollPanel!") |
322
971e3812903a
browser_side: scroll to the clicked microblog post and blink it (previous behavior is conserved when the unibox is enabled)
souliane <souliane@mailoo.org>
parents:
319
diff
changeset
|
926 removeStyle = lambda entry: entry.removeStyleName('selected_entry') |
971e3812903a
browser_side: scroll to the clicked microblog post and blink it (previous behavior is conserved when the unibox is enabled)
souliane <souliane@mailoo.org>
parents:
319
diff
changeset
|
927 if not self.host.uni_box or not entry.comments: |
971e3812903a
browser_side: scroll to the clicked microblog post and blink it (previous behavior is conserved when the unibox is enabled)
souliane <souliane@mailoo.org>
parents:
319
diff
changeset
|
928 entry.addStyleName('selected_entry') # blink the clicked entry |
971e3812903a
browser_side: scroll to the clicked microblog post and blink it (previous behavior is conserved when the unibox is enabled)
souliane <souliane@mailoo.org>
parents:
319
diff
changeset
|
929 clicked_entry = entry # entry may be None when the timer is done |
422
20c508f9b32a
browser side: fixed bad use of Timer
Goffi <goffi@goffi.org>
parents:
414
diff
changeset
|
930 Timer(500, lambda timer: removeStyle(clicked_entry)) |
322
971e3812903a
browser_side: scroll to the clicked microblog post and blink it (previous behavior is conserved when the unibox is enabled)
souliane <souliane@mailoo.org>
parents:
319
diff
changeset
|
931 if not self.host.uni_box: |
971e3812903a
browser_side: scroll to the clicked microblog post and blink it (previous behavior is conserved when the unibox is enabled)
souliane <souliane@mailoo.org>
parents:
319
diff
changeset
|
932 return # unibox is disabled |
971e3812903a
browser_side: scroll to the clicked microblog post and blink it (previous behavior is conserved when the unibox is enabled)
souliane <souliane@mailoo.org>
parents:
319
diff
changeset
|
933 # from here the previous behavior (toggle main item selection) is conserved |
971e3812903a
browser_side: scroll to the clicked microblog post and blink it (previous behavior is conserved when the unibox is enabled)
souliane <souliane@mailoo.org>
parents:
319
diff
changeset
|
934 entry = entry if entry.comments else None |
199
39311c7dad77
browser side: it is now possible to select a microblog panel or an entry inside it
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
935 if self.selected_entry == entry: |
39311c7dad77
browser side: it is now possible to select a microblog panel or an entry inside it
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
936 entry = None |
39311c7dad77
browser side: it is now possible to select a microblog panel or an entry inside it
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
937 if self.selected_entry: |
322
971e3812903a
browser_side: scroll to the clicked microblog post and blink it (previous behavior is conserved when the unibox is enabled)
souliane <souliane@mailoo.org>
parents:
319
diff
changeset
|
938 removeStyle(self.selected_entry) |
199
39311c7dad77
browser side: it is now possible to select a microblog panel or an entry inside it
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
939 if entry: |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
433
diff
changeset
|
940 log.debug("microblog entry selected (author=%s)" % entry.author) |
199
39311c7dad77
browser side: it is now possible to select a microblog panel or an entry inside it
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
941 entry.addStyleName('selected_entry') |
39311c7dad77
browser side: it is now possible to select a microblog panel or an entry inside it
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
942 self.selected_entry = entry |
39311c7dad77
browser side: it is now possible to select a microblog panel or an entry inside it
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
943 |
241
86055ccf69c3
browser_side: added class PopupMenuPanel to manage more complex context menu
souliane <souliane@mailoo.org>
parents:
239
diff
changeset
|
944 def updateValue(self, type_, jid, value): |
119 | 945 """Update a jid value in entries |
241
86055ccf69c3
browser_side: added class PopupMenuPanel to manage more complex context menu
souliane <souliane@mailoo.org>
parents:
239
diff
changeset
|
946 @param type_: one of 'avatar', 'nick' |
119 | 947 @param jid: jid concerned |
948 @param value: new value""" | |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
949 def updateVPanel(vpanel): |
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
950 for child in vpanel.children: |
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
951 if isinstance(child, MicroblogEntry) and child.author == jid: |
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
952 child.updateAvatar(value) |
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
953 elif isinstance(child, VerticalPanel): |
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
954 updateVPanel(child) |
241
86055ccf69c3
browser_side: added class PopupMenuPanel to manage more complex context menu
souliane <souliane@mailoo.org>
parents:
239
diff
changeset
|
955 if type_ == 'avatar': |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
956 updateVPanel(self.vpanel) |
119 | 957 |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
958 def setAcceptedGroup(self, group): |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
959 """Add one or more group(s) which can be displayed in this panel. |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
960 Prevent from duplicate values and keep the list sorted. |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
961 @param group: string of the group, or list of string |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
962 """ |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
963 if not hasattr(self, "_accepted_groups"): |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
964 self._accepted_groups = [] |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
965 groups = group if isinstance(group, list) else [group] |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
966 for _group in groups: |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
967 if _group not in self._accepted_groups: |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
968 self._accepted_groups.append(_group) |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
969 self._accepted_groups.sort() |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
970 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
971 def isJidAccepted(self, jid): |
163
b887186e8fc8
browser side: get entity's microblogs for newly added contacts
Goffi <goffi@goffi.org>
parents:
148
diff
changeset
|
972 """Tell if a jid is actepted and shown in this panel |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
973 @param jid: jid |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
974 @return: True if the jid is accepted""" |
132
30d8e328559b
server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
975 if self.accept_all(): |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
976 return True |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
977 for group in self._accepted_groups: |
27
d89982865c57
browser side: ContactsChooser is now used to ask for 3 others players when tarot game is launched + names refactoring
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
978 if self.host.contact_panel.isContactInGroup(group, jid): |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
979 return True |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
980 return False |
19 | 981 |
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
|
982 |
402
d7e78cb78dfc
browser_side: HTMLTextEditor and LightTextEditor factorization
souliane <souliane@mailoo.org>
parents:
401
diff
changeset
|
983 class StatusPanel(HTMLTextEditor): |
314
70ac3067d641
browser_side: status can be edited with a click on it
souliane <souliane@mailoo.org>
parents:
313
diff
changeset
|
984 |
349
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
985 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
|
986 |
20 | 987 def __init__(self, host, status=''): |
988 self.host = host | |
349
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
989 modifiedCb = lambda content: self.host.bridge.call('setStatus', None, self.host.status_panel.presence, content['text']) or True |
404
c393e7dc9ae6
browser_side: refactorize SimpleTextEditor init parameters
souliane <souliane@mailoo.org>
parents:
402
diff
changeset
|
990 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
|
991 self.edit(False) |
20 | 992 self.setStyleName('statusPanel') |
19 | 993 |
349
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
994 @property |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
995 def status(self): |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
996 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
|
997 |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
998 def __cleanContent(self, content): |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
999 status = content['text'] |
433
bbdbee25123a
import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents:
432
diff
changeset
|
1000 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
|
1001 content['text'] = '' |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
1002 return content |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
1003 |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
1004 def getContent(self): |
401
ea03f898067f
browser_side: LightTextEditor renamed to HTMLTextEditor, new class LightTextEditor based on TextArea
souliane <souliane@mailoo.org>
parents:
400
diff
changeset
|
1005 return self.__cleanContent(HTMLTextEditor.getContent(self)) |
19 | 1006 |
349
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
1007 def setContent(self, content): |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
1008 content = self.__cleanContent(content) |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
1009 BaseTextEditor.setContent(self, content) |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
1010 |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
1011 def setDisplayContent(self): |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
1012 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
|
1013 try: |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
1014 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
|
1015 except AttributeError: # during initialization |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
1016 presence = None |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
1017 if not status: |
433
bbdbee25123a
import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents:
432
diff
changeset
|
1018 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
|
1019 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
|
1020 else: |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
1021 status = self.EMPTY_STATUS |
402
d7e78cb78dfc
browser_side: HTMLTextEditor and LightTextEditor factorization
souliane <souliane@mailoo.org>
parents:
401
diff
changeset
|
1022 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
|
1023 |
279
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
1024 |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
1025 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
|
1026 |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
1027 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
|
1028 self.host = host |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
1029 HorizontalPanel.__init__(self, Width='100%') |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
1030 self.presence_button = Label(u"◉") |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
1031 self.presence_button.setStyleName("presence-button") |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
1032 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
|
1033 self.setPresence(presence) |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
1034 entries = {} |
433
bbdbee25123a
import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents:
432
diff
changeset
|
1035 for value in C.PRESENCE.keys(): |
bbdbee25123a
import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents:
432
diff
changeset
|
1036 entries.update({C.PRESENCE[value]: {"value": value}}) |
279
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
1037 |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
1038 def callback(sender, key): |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
1039 self.setPresence(entries[key]["value"]) # order matters |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
1040 self.host.send([("STATUS", None)], self.status_panel.status) |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
1041 |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
1042 self.presence_list = PopupMenuPanel(entries, callback=callback, style={"menu": "gwt-ListBox"}) |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
1043 self.presence_list.registerClickSender(self.presence_button) |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
1044 |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
1045 panel = HorizontalPanel() |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
1046 panel.add(self.presence_button) |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
1047 panel.add(self.status_panel) |
314
70ac3067d641
browser_side: status can be edited with a click on it
souliane <souliane@mailoo.org>
parents:
313
diff
changeset
|
1048 panel.setCellVerticalAlignment(self.presence_button, 'baseline') |
70ac3067d641
browser_side: status can be edited with a click on it
souliane <souliane@mailoo.org>
parents:
313
diff
changeset
|
1049 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
|
1050 panel.setStyleName("marginAuto") |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
1051 self.add(panel) |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
1052 |
349
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
1053 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
|
1054 |
279
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
1055 ClickHandler.__init__(self) |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
1056 self.addClickListener(self) |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
1057 |
349
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
1058 @property |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
1059 def presence(self): |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
1060 return self._presence |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
1061 |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
1062 @property |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
1063 def status(self): |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
1064 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
|
1065 |
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
1066 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
|
1067 self._presence = presence |
370
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
366
diff
changeset
|
1068 contact.setPresenceStyle(self.presence_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
|
1069 |
349
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
1070 def setStatus(self, status): |
f488692c4903
browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents:
347
diff
changeset
|
1071 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
|
1072 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
|
1073 |
62 | 1074 def onClick(self, sender): |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
223
diff
changeset
|
1075 # 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
|
1076 self.host.setSelected(None) |
20 | 1077 |
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
|
1078 |
195 | 1079 class ChatPanel(base_widget.LiberviaWidget): |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1080 |
179
8475a29d7214
closing a group chat widget now leave the muc room (bug 11)
Goffi <goffi@goffi.org>
parents:
178
diff
changeset
|
1081 def __init__(self, host, target, type_='one2one'): |
19 | 1082 """Panel used for conversation (one 2 one or group chat) |
1083 @param host: SatWebFrontend instance | |
1084 @param target: entity (JID) with who we have a conversation (contact's jid for one 2 one chat, or MUC room) | |
1085 @param type: one2one for simple conversation, group for MUC""" | |
407
6a6551de4414
browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
404
diff
changeset
|
1086 base_widget.LiberviaWidget.__init__(self, host, title=target.bare, selectable=True) |
34 | 1087 self.vpanel = VerticalPanel() |
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
|
1088 self.vpanel.setSize('100%', '100%') |
179
8475a29d7214
closing a group chat widget now leave the muc room (bug 11)
Goffi <goffi@goffi.org>
parents:
178
diff
changeset
|
1089 self.type = type_ |
33 | 1090 self.nick = None |
19 | 1091 if not target: |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
433
diff
changeset
|
1092 log.error("Empty target !") |
19 | 1093 return |
1094 self.target = target | |
84 | 1095 self.__body = AbsolutePanel() |
1096 self.__body.setStyleName('chatPanel_body') | |
33 | 1097 chat_area = HorizontalPanel() |
1098 chat_area.setStyleName('chatArea') | |
179
8475a29d7214
closing a group chat widget now leave the muc room (bug 11)
Goffi <goffi@goffi.org>
parents:
178
diff
changeset
|
1099 if type_ == 'group': |
33 | 1100 self.occupants_list = OccupantsList() |
1101 chat_area.add(self.occupants_list) | |
84 | 1102 self.__body.add(chat_area) |
33 | 1103 self.content = AbsolutePanel() |
1104 self.content.setStyleName('chatContent') | |
195 | 1105 self.content_scroll = base_widget.ScrollPanelWrapper(self.content) |
34 | 1106 chat_area.add(self.content_scroll) |
1107 chat_area.setCellWidth(self.content_scroll, '100%') | |
84 | 1108 self.vpanel.add(self.__body) |
311
3135ff840b8e
browser_side: message box below the ChatPanel when unibox is disabled
souliane <souliane@mailoo.org>
parents:
310
diff
changeset
|
1109 self.vpanel.setCellHeight(self.__body, '100%') |
84 | 1110 self.addStyleName('chatPanel') |
34 | 1111 self.setWidget(self.vpanel) |
223
624a87377412
browser_side, plugin XEP-0085: limit the number of bridge methods calls for "chatStateComposing".
souliane <souliane@mailoo.org>
parents:
218
diff
changeset
|
1112 self.state_machine = ChatStateMachine(self.host, str(self.target)) |
407
6a6551de4414
browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
404
diff
changeset
|
1113 self._state = None |
195 | 1114 |
1115 @classmethod | |
1116 def registerClass(cls): | |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
1117 base_widget.LiberviaWidget.addDropKey("CONTACT", cls.createPanel) |
195 | 1118 |
1119 @classmethod | |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
1120 def createPanel(cls, host, item): |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
1121 _contact = item if isinstance(item, JID) else JID(item) |
195 | 1122 host.contact_panel.setContactMessageWaiting(_contact.bare, False) |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
223
diff
changeset
|
1123 _new_panel = ChatPanel(host, _contact) # XXX: pyjamas doesn't seems to support creating with cls directly |
195 | 1124 _new_panel.historyPrint() |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
1125 host.setSelected(_new_panel) |
383
b90744ec426e
browser_side: refresh the ChatPanel and MicroblogPanel when they are opened from a drag and drop
souliane <souliane@mailoo.org>
parents:
380
diff
changeset
|
1126 _new_panel.refresh() |
195 | 1127 return _new_panel |
38
7bea2ae0c4fb
Tarot game: center_panel layout + chien can now be showed + fixed click event inheritance + card selection first draft
Goffi <goffi@goffi.org>
parents:
37
diff
changeset
|
1128 |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
1129 def refresh(self): |
326
36927be51481
browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
1130 """Refresh the display of this widget. If the unibox is disabled, |
36927be51481
browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
1131 add a message box at the bottom of the panel""" |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
1132 self.host.contact_panel.setContactMessageWaiting(self.target.bare, False) |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
1133 self.content_scroll.scrollToBottom() |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
1134 |
326
36927be51481
browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
1135 enable_box = self.host.uni_box is None |
36927be51481
browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
1136 if hasattr(self, 'message_box'): |
36927be51481
browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
1137 self.message_box.setVisible(enable_box) |
36927be51481
browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
1138 return |
36927be51481
browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
1139 if enable_box: |
36927be51481
browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
1140 self.message_box = MessageBox(self.host) |
36927be51481
browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
1141 self.message_box.onSelectedChange(self) |
36927be51481
browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
1142 self.vpanel.add(self.message_box) |
36927be51481
browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
1143 |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
1144 def matchEntity(self, entity): |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
1145 """ |
267
a76243c02074
browser_side: changes regarding widgets and tabs:
souliane <souliane@mailoo.org>
parents:
264
diff
changeset
|
1146 @param entity: target jid as a string or JID instance. |
a76243c02074
browser_side: changes regarding widgets and tabs:
souliane <souliane@mailoo.org>
parents:
264
diff
changeset
|
1147 Could also be a couple with a type in the second element. |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
1148 @return: True if self matches the given entity |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
1149 """ |
267
a76243c02074
browser_side: changes regarding widgets and tabs:
souliane <souliane@mailoo.org>
parents:
264
diff
changeset
|
1150 if isinstance(entity, tuple): |
a76243c02074
browser_side: changes regarding widgets and tabs:
souliane <souliane@mailoo.org>
parents:
264
diff
changeset
|
1151 entity, type_ = entity if len(entity) > 1 else (entity[0], self.type) |
a76243c02074
browser_side: changes regarding widgets and tabs:
souliane <souliane@mailoo.org>
parents:
264
diff
changeset
|
1152 else: |
a76243c02074
browser_side: changes regarding widgets and tabs:
souliane <souliane@mailoo.org>
parents:
264
diff
changeset
|
1153 type_ = self.type |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
1154 entity = entity if isinstance(entity, JID) else JID(entity) |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
1155 try: |
267
a76243c02074
browser_side: changes regarding widgets and tabs:
souliane <souliane@mailoo.org>
parents:
264
diff
changeset
|
1156 return self.target.bare == entity.bare and self.type == type_ |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
1157 except AttributeError as e: |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
1158 e.include_traceback() |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
1159 return False |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
1160 |
201
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
1161 def getWarningData(self): |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
1162 if self.type not in ["one2one", "group"]: |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
1163 raise Exception("Unmanaged type !") |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
1164 if self.type == "one2one": |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
1165 msg = "This message will be sent to your contact <span class='warningTarget'>%s</span>" % self.target |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
1166 elif self.type == "group": |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
1167 msg = "This message will be sent to all the participants of the multi-user room <span class='warningTarget'>%s</span>" % self.target |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
1168 return ("ONE2ONE" if self.type == "one2one" else "GROUP", msg) |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
1169 |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
1170 def onTextEntered(self, text): |
269
9eb9c7d41bdc
browser_side: added generic method "send" in SatWebFrontend
souliane <souliane@mailoo.org>
parents:
267
diff
changeset
|
1171 self.host.send([("groupchat" if self.type == 'group' else "chat", str(self.target))], text) |
223
624a87377412
browser_side, plugin XEP-0085: limit the number of bridge methods calls for "chatStateComposing".
souliane <souliane@mailoo.org>
parents:
218
diff
changeset
|
1172 self.state_machine._onEvent("active") |
201
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
1173 |
179
8475a29d7214
closing a group chat widget now leave the muc room (bug 11)
Goffi <goffi@goffi.org>
parents:
178
diff
changeset
|
1174 def onQuit(self): |
195 | 1175 base_widget.LiberviaWidget.onQuit(self) |
179
8475a29d7214
closing a group chat widget now leave the muc room (bug 11)
Goffi <goffi@goffi.org>
parents:
178
diff
changeset
|
1176 if self.type == 'group': |
8475a29d7214
closing a group chat widget now leave the muc room (bug 11)
Goffi <goffi@goffi.org>
parents:
178
diff
changeset
|
1177 self.host.bridge.call('mucLeave', None, self.target.bare) |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
1178 |
19 | 1179 def setUserNick(self, nick): |
1180 """Set the nick of the user, usefull for e.g. change the color of the user""" | |
1181 self.nick = nick | |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
1182 |
33 | 1183 def setPresents(self, nicks): |
1184 """Set the users presents in this room | |
1185 @param occupants: list of nicks (string)""" | |
35 | 1186 self.occupants_list.clear() |
33 | 1187 for nick in nicks: |
1188 self.occupants_list.addOccupant(nick) | |
1189 | |
35 | 1190 def userJoined(self, nick, data): |
1191 self.occupants_list.addOccupant(nick) | |
1192 self.printInfo("=> %s has joined the room" % nick) | |
1193 | |
1194 def userLeft(self, nick, data): | |
1195 self.occupants_list.removeOccupant(nick) | |
1196 self.printInfo("<= %s has left the room" % nick) | |
1197 | |
408
ee8ebfe23e16
browser_side: handle the signal "roomUserChangedNick"
souliane <souliane@mailoo.org>
parents:
407
diff
changeset
|
1198 def changeUserNick(self, old_nick, new_nick): |
ee8ebfe23e16
browser_side: handle the signal "roomUserChangedNick"
souliane <souliane@mailoo.org>
parents:
407
diff
changeset
|
1199 assert(self.type == "group") |
ee8ebfe23e16
browser_side: handle the signal "roomUserChangedNick"
souliane <souliane@mailoo.org>
parents:
407
diff
changeset
|
1200 self.occupants_list.removeOccupant(old_nick) |
ee8ebfe23e16
browser_side: handle the signal "roomUserChangedNick"
souliane <souliane@mailoo.org>
parents:
407
diff
changeset
|
1201 self.occupants_list.addOccupant(new_nick) |
ee8ebfe23e16
browser_side: handle the signal "roomUserChangedNick"
souliane <souliane@mailoo.org>
parents:
407
diff
changeset
|
1202 self.printInfo(_("%(old_nick)s is now known as %(new_nick)s") % {'old_nick': old_nick, 'new_nick': new_nick}) |
ee8ebfe23e16
browser_side: handle the signal "roomUserChangedNick"
souliane <souliane@mailoo.org>
parents:
407
diff
changeset
|
1203 |
19 | 1204 def historyPrint(self, size=20): |
1205 """Print the initial history""" | |
1206 def getHistoryCB(history): | |
213
8bbac49765d6
browser side: display the day change in chat window
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
1207 # display day change |
8bbac49765d6
browser side: display the day change in chat window
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
1208 day_format = "%A, %d %b %Y" |
8bbac49765d6
browser side: display the day change in chat window
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
1209 previous_day = datetime.now().strftime(day_format) |
123 | 1210 for line in history: |
235
b304cdf13a3b
browser and server side: XHTML handling, first draft:
Goffi <goffi@goffi.org>
parents:
232
diff
changeset
|
1211 timestamp, from_jid, to_jid, message, mess_type, extra = line |
213
8bbac49765d6
browser side: display the day change in chat window
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
1212 message_day = datetime.fromtimestamp(float(timestamp or time())).strftime(day_format) |
8bbac49765d6
browser side: display the day change in chat window
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
1213 if previous_day != message_day: |
8bbac49765d6
browser side: display the day change in chat window
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
1214 self.printInfo("* " + message_day) |
8bbac49765d6
browser side: display the day change in chat window
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
1215 previous_day = message_day |
235
b304cdf13a3b
browser and server side: XHTML handling, first draft:
Goffi <goffi@goffi.org>
parents:
232
diff
changeset
|
1216 self.printMessage(from_jid, message, extra, timestamp) |
123 | 1217 self.host.bridge.call('getHistory', getHistoryCB, self.host.whoami.bare, self.target.bare, size, True) |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
1218 |
397
6148e9063069
browser_side: radiocol displays who uploaded the file with ChatPanel.printInfo
souliane <souliane@mailoo.org>
parents:
395
diff
changeset
|
1219 def printInfo(self, msg, type_='normal', link_cb=None): |
35 | 1220 """Print general info |
1221 @param msg: message to print | |
397
6148e9063069
browser_side: radiocol displays who uploaded the file with ChatPanel.printInfo
souliane <souliane@mailoo.org>
parents:
395
diff
changeset
|
1222 @param type_: one of: |
6148e9063069
browser_side: radiocol displays who uploaded the file with ChatPanel.printInfo
souliane <souliane@mailoo.org>
parents:
395
diff
changeset
|
1223 "normal": general info like "toto has joined the room" |
6148e9063069
browser_side: radiocol displays who uploaded the file with ChatPanel.printInfo
souliane <souliane@mailoo.org>
parents:
395
diff
changeset
|
1224 "link": general info that is clickable like "click here to join the main room" |
6148e9063069
browser_side: radiocol displays who uploaded the file with ChatPanel.printInfo
souliane <souliane@mailoo.org>
parents:
395
diff
changeset
|
1225 "me": "/me" information like "/me clenches his fist" ==> "toto clenches his fist" |
6148e9063069
browser_side: radiocol displays who uploaded the file with ChatPanel.printInfo
souliane <souliane@mailoo.org>
parents:
395
diff
changeset
|
1226 @param link_cb: method to call when the info is clicked, ignored if type_ is not 'link' |
35 | 1227 """ |
397
6148e9063069
browser_side: radiocol displays who uploaded the file with ChatPanel.printInfo
souliane <souliane@mailoo.org>
parents:
395
diff
changeset
|
1228 _wid = HTML(msg) if type_ == 'link' else Label(msg) |
6148e9063069
browser_side: radiocol displays who uploaded the file with ChatPanel.printInfo
souliane <souliane@mailoo.org>
parents:
395
diff
changeset
|
1229 if type_ == 'normal': |
35 | 1230 _wid.setStyleName('chatTextInfo') |
397
6148e9063069
browser_side: radiocol displays who uploaded the file with ChatPanel.printInfo
souliane <souliane@mailoo.org>
parents:
395
diff
changeset
|
1231 elif type_ == 'link': |
6148e9063069
browser_side: radiocol displays who uploaded the file with ChatPanel.printInfo
souliane <souliane@mailoo.org>
parents:
395
diff
changeset
|
1232 _wid.setStyleName('chatTextInfo-link') |
6148e9063069
browser_side: radiocol displays who uploaded the file with ChatPanel.printInfo
souliane <souliane@mailoo.org>
parents:
395
diff
changeset
|
1233 if link_cb: |
6148e9063069
browser_side: radiocol displays who uploaded the file with ChatPanel.printInfo
souliane <souliane@mailoo.org>
parents:
395
diff
changeset
|
1234 _wid.addClickListener(link_cb) |
6148e9063069
browser_side: radiocol displays who uploaded the file with ChatPanel.printInfo
souliane <souliane@mailoo.org>
parents:
395
diff
changeset
|
1235 elif type_ == 'me': |
35 | 1236 _wid.setStyleName('chatTextMe') |
1237 else: | |
1238 _wid.setStyleName('chatTextInfo') | |
1239 self.content.add(_wid) | |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
1240 |
235
b304cdf13a3b
browser and server side: XHTML handling, first draft:
Goffi <goffi@goffi.org>
parents:
232
diff
changeset
|
1241 def printMessage(self, from_jid, msg, extra, timestamp=None): |
19 | 1242 """Print message in chat window. Must be implemented by child class""" |
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
|
1243 _jid = JID(from_jid) |
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
|
1244 nick = _jid.node if self.type == 'one2one' else _jid.resource |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
223
diff
changeset
|
1245 mymess = _jid.resource == self.nick if self.type == "group" else _jid.bare == self.host.whoami.bare # mymess = True if message comes from local user |
35 | 1246 if msg.startswith('/me '): |
397
6148e9063069
browser_side: radiocol displays who uploaded the file with ChatPanel.printInfo
souliane <souliane@mailoo.org>
parents:
395
diff
changeset
|
1247 self.printInfo('* %s %s' % (nick, msg[4:]), type_='me') |
35 | 1248 return |
235
b304cdf13a3b
browser and server side: XHTML handling, first draft:
Goffi <goffi@goffi.org>
parents:
232
diff
changeset
|
1249 self.content.add(ChatText(timestamp, nick, mymess, msg, extra.get('xhtml'))) |
34 | 1250 self.content_scroll.scrollToBottom() |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
1251 |
285
4f0c2fea358a
browser_side (plugin radiocol): use the status label to give more information
souliane <souliane@mailoo.org>
parents:
282
diff
changeset
|
1252 def startGame(self, game_type, waiting, referee, players, *args): |
36 | 1253 """Configure the chat window to start a game""" |
275
a763b2ac5d41
bridge + browser_side: bridge signals for games and their callbacks:
souliane <souliane@mailoo.org>
parents:
273
diff
changeset
|
1254 classes = {"Tarot": CardPanel, "RadioCol": RadioColPanel} |
a763b2ac5d41
bridge + browser_side: bridge signals for games and their callbacks:
souliane <souliane@mailoo.org>
parents:
273
diff
changeset
|
1255 if game_type not in classes.keys(): |
a763b2ac5d41
bridge + browser_side: bridge signals for games and their callbacks:
souliane <souliane@mailoo.org>
parents:
273
diff
changeset
|
1256 return # unknown game |
a763b2ac5d41
bridge + browser_side: bridge signals for games and their callbacks:
souliane <souliane@mailoo.org>
parents:
273
diff
changeset
|
1257 attr = game_type.lower() |
342
44491e963eee
browser_side: muc user symbols (used for showing who is playing) can also be removed
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
1258 self.occupants_list.updateSpecials(players, SYMBOLS[attr]) |
275
a763b2ac5d41
bridge + browser_side: bridge signals for games and their callbacks:
souliane <souliane@mailoo.org>
parents:
273
diff
changeset
|
1259 if waiting or not self.nick in players: |
a763b2ac5d41
bridge + browser_side: bridge signals for games and their callbacks:
souliane <souliane@mailoo.org>
parents:
273
diff
changeset
|
1260 return # waiting for player or not playing |
a763b2ac5d41
bridge + browser_side: bridge signals for games and their callbacks:
souliane <souliane@mailoo.org>
parents:
273
diff
changeset
|
1261 attr = "%s_panel" % attr |
a763b2ac5d41
bridge + browser_side: bridge signals for games and their callbacks:
souliane <souliane@mailoo.org>
parents:
273
diff
changeset
|
1262 if hasattr(self, attr): |
a763b2ac5d41
bridge + browser_side: bridge signals for games and their callbacks:
souliane <souliane@mailoo.org>
parents:
273
diff
changeset
|
1263 return |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
433
diff
changeset
|
1264 log.info("%s Game Started \o/" % game_type) |
285
4f0c2fea358a
browser_side (plugin radiocol): use the status label to give more information
souliane <souliane@mailoo.org>
parents:
282
diff
changeset
|
1265 panel = classes[game_type](self, referee, self.nick, players, *args) |
275
a763b2ac5d41
bridge + browser_side: bridge signals for games and their callbacks:
souliane <souliane@mailoo.org>
parents:
273
diff
changeset
|
1266 setattr(self, attr, panel) |
a763b2ac5d41
bridge + browser_side: bridge signals for games and their callbacks:
souliane <souliane@mailoo.org>
parents:
273
diff
changeset
|
1267 self.vpanel.insert(panel, 0) |
a763b2ac5d41
bridge + browser_side: bridge signals for games and their callbacks:
souliane <souliane@mailoo.org>
parents:
273
diff
changeset
|
1268 self.vpanel.setCellHeight(panel, panel.getHeight()) |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
1269 |
37
b306aa090438
Tarot game: game launching (first hand showed), and contract selection
Goffi <goffi@goffi.org>
parents:
36
diff
changeset
|
1270 def getGame(self, game_type): |
b306aa090438
Tarot game: game launching (first hand showed), and contract selection
Goffi <goffi@goffi.org>
parents:
36
diff
changeset
|
1271 """Return class managing the game type""" |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
223
diff
changeset
|
1272 # TODO: check that the game is launched, and manage errors |
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
|
1273 if game_type == "Tarot": |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
1274 return self.tarot_panel |
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
|
1275 elif game_type == "RadioCol": |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
1276 return self.radiocol_panel |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1277 |
407
6a6551de4414
browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
404
diff
changeset
|
1278 def setState(self, state, nick=None): |
6a6551de4414
browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
404
diff
changeset
|
1279 """Set the chat state (XEP-0085) of the contact. Leave nick to None |
6a6551de4414
browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
404
diff
changeset
|
1280 to set the state for a one2one conversation, or give a nickname or |
433
bbdbee25123a
import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents:
432
diff
changeset
|
1281 C.ALL_OCCUPANTS to set the state of a participant within a MUC. |
407
6a6551de4414
browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
404
diff
changeset
|
1282 @param state: the new chat state |
6a6551de4414
browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
404
diff
changeset
|
1283 @param nick: None for one2one, the MUC user nick or ALL_OCCUPANTS |
6a6551de4414
browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
404
diff
changeset
|
1284 """ |
6a6551de4414
browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
404
diff
changeset
|
1285 if nick: |
6a6551de4414
browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
404
diff
changeset
|
1286 assert(self.type == 'group') |
433
bbdbee25123a
import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents:
432
diff
changeset
|
1287 occupants = self.occupants_list.occupants_list.keys() if nick == C.ALL_OCCUPANTS else [nick] |
407
6a6551de4414
browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
404
diff
changeset
|
1288 for occupant in occupants: |
6a6551de4414
browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
404
diff
changeset
|
1289 self.occupants_list.occupants_list[occupant].setState(state) |
6a6551de4414
browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
404
diff
changeset
|
1290 else: |
6a6551de4414
browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
404
diff
changeset
|
1291 assert(self.type == 'one2one') |
6a6551de4414
browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
404
diff
changeset
|
1292 self._state = state |
6a6551de4414
browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
404
diff
changeset
|
1293 self.refreshTitle() |
6a6551de4414
browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
404
diff
changeset
|
1294 self.state_machine.started = not not state # start to send "composing" state from now |
6a6551de4414
browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
404
diff
changeset
|
1295 |
6a6551de4414
browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
404
diff
changeset
|
1296 def refreshTitle(self): |
6a6551de4414
browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
404
diff
changeset
|
1297 """Refresh the title of this ChatPanel dialog""" |
6a6551de4414
browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
404
diff
changeset
|
1298 if self._state: |
6a6551de4414
browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
404
diff
changeset
|
1299 self.setTitle(self.target.bare + " (" + self._state + ")") |
6a6551de4414
browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
404
diff
changeset
|
1300 else: |
6a6551de4414
browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
404
diff
changeset
|
1301 self.setTitle(self.target.bare) |
6a6551de4414
browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
404
diff
changeset
|
1302 |
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
|
1303 |
195 | 1304 class WebPanel(base_widget.LiberviaWidget): |
181
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
1305 """ (mini)browser like widget """ |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
1306 |
181
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
1307 def __init__(self, host, url=None): |
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
1308 """ |
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
1309 @param host: SatWebFrontend instance |
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
1310 """ |
195 | 1311 base_widget.LiberviaWidget.__init__(self, host) |
181
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
1312 self._vpanel = VerticalPanel() |
188
39936b83da9d
Browser Side: Web Panel widget position/size fix
Goffi <goffi@goffi.org>
parents:
187
diff
changeset
|
1313 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
|
1314 self._url = dialog.ExtTextBox(enter_cb=self.onUrlClick) |
181
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
1315 self._url.setText(url or "") |
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
1316 self._url.setWidth('100%') |
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
1317 hpanel = HorizontalPanel() |
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
1318 hpanel.add(self._url) |
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
1319 btn = Button("Go", self.onUrlClick) |
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
1320 hpanel.setCellWidth(self._url, "100%") |
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
1321 #self.setCellWidth(btn, "10%") |
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
1322 hpanel.add(self._url) |
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
1323 hpanel.add(btn) |
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
1324 self._vpanel.add(hpanel) |
188
39936b83da9d
Browser Side: Web Panel widget position/size fix
Goffi <goffi@goffi.org>
parents:
187
diff
changeset
|
1325 self._vpanel.setCellHeight(hpanel, '20px') |
181
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
1326 self._frame = Frame(url or "") |
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
1327 self._frame.setSize('100%', '100%') |
188
39936b83da9d
Browser Side: Web Panel widget position/size fix
Goffi <goffi@goffi.org>
parents:
187
diff
changeset
|
1328 DOM.setStyleAttribute(self._frame.getElement(), "position", "relative") |
181
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
1329 self._vpanel.add(self._frame) |
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
1330 self.setWidget(self._vpanel) |
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
1331 |
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
1332 def onUrlClick(self, sender): |
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
1333 self._frame.setUrl(self._url.getText()) |
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
1334 |
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
|
1335 |
33 | 1336 class MainPanel(AbsolutePanel): |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1337 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1338 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
|
1339 self.host = host |
33 | 1340 AbsolutePanel.__init__(self) |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1341 |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
223
diff
changeset
|
1342 # menu |
218
4e6467efd6bf
browser_side: small improvements for parameters panel
souliane <souliane@mailoo.org>
parents:
217
diff
changeset
|
1343 self.menu = Menu(host) |
184
97d5e9de1106
browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
1344 |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
223
diff
changeset
|
1345 # unibox |
309
05e264e96a1c
browser_side: make unibox optional
souliane <souliane@mailoo.org>
parents:
307
diff
changeset
|
1346 self.unibox_panel = UniBoxPanel(host) |
313
5ad70625867a
browser_side: save the unibox panel space when unibox is disabled
souliane <souliane@mailoo.org>
parents:
312
diff
changeset
|
1347 self.unibox_panel.setVisible(False) |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
1348 |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
223
diff
changeset
|
1349 # contacts |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
231
diff
changeset
|
1350 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
|
1351 self._contacts.addStyleName('globalLeftArea') |
255
da0487f0a2e7
browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents:
249
diff
changeset
|
1352 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
|
1353 self.contacts_switch.addStyleName('contactsSwitch') |
da0487f0a2e7
browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents:
249
diff
changeset
|
1354 self._contacts.add(self.contacts_switch) |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
231
diff
changeset
|
1355 self._contacts.add(self.host.contact_panel) |
184
97d5e9de1106
browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
1356 |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
223
diff
changeset
|
1357 # tabs |
195 | 1358 self.tab_panel = base_widget.MainTabPanel(host) |
1359 self.discuss_panel = base_widget.WidgetsPanel(self.host, locked=True) | |
23 | 1360 self.tab_panel.add(self.discuss_panel, "Discussions") |
1361 self.tab_panel.selectTab(0) | |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1362 |
426
77d8f55fc5f0
browser_side: hide the presence/status panel until the connection is made
souliane <souliane@mailoo.org>
parents:
425
diff
changeset
|
1363 self.header = AbsolutePanel() |
77d8f55fc5f0
browser_side: hide the presence/status panel until the connection is made
souliane <souliane@mailoo.org>
parents:
425
diff
changeset
|
1364 self.header.add(self.menu) |
77d8f55fc5f0
browser_side: hide the presence/status panel until the connection is made
souliane <souliane@mailoo.org>
parents:
425
diff
changeset
|
1365 self.header.add(self.unibox_panel) |
77d8f55fc5f0
browser_side: hide the presence/status panel until the connection is made
souliane <souliane@mailoo.org>
parents:
425
diff
changeset
|
1366 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
|
1367 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
|
1368 self.add(self.header) |
184
97d5e9de1106
browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
1369 |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
231
diff
changeset
|
1370 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
|
1371 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
|
1372 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
|
1373 self.add(self._hpanel) |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
1374 |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1375 self.setWidth("100%") |
33 | 1376 Window.addWindowResizeListener(self) |
1377 | |
255
da0487f0a2e7
browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents:
249
diff
changeset
|
1378 def _contactsSwitch(self, btn=None): |
184
97d5e9de1106
browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
1379 """ (Un)hide contacts panel """ |
255
da0487f0a2e7
browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents:
249
diff
changeset
|
1380 if btn is None: |
da0487f0a2e7
browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents:
249
diff
changeset
|
1381 btn = self.contacts_switch |
184
97d5e9de1106
browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
1382 cpanel = self.host.contact_panel |
97d5e9de1106
browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
1383 cpanel.setVisible(not cpanel.getVisible()) |
206
4d7054542751
browser side: contactBox doesn't use left margin anymore (avoid scrollbar issues) + some cosmetic changes to contact panel switch button
Goffi <goffi@goffi.org>
parents:
202
diff
changeset
|
1384 btn.setText(u"«" if cpanel.getVisible() else u"»") |
184
97d5e9de1106
browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
1385 self.host.resize() |
97d5e9de1106
browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
1386 |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
231
diff
changeset
|
1387 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
|
1388 """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
|
1389 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
|
1390 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
|
1391 """ |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
231
diff
changeset
|
1392 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
|
1393 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
|
1394 return |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
231
diff
changeset
|
1395 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
|
1396 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
|
1397 |
33 | 1398 def onWindowResized(self, width, height): |
1399 _elts = doc().getElementsByClassName('gwt-TabBar') | |
1400 if not _elts.length: | |
1401 tab_bar_h = 0 | |
1402 else: | |
1403 tab_bar_h = _elts.item(0).offsetHeight | |
1404 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
|
1405 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
|
1406 |
326
36927be51481
browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
1407 def refresh(self): |
36927be51481
browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
1408 """Refresh the main panel""" |
36927be51481
browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
1409 self.unibox_panel.refresh() |