annotate src/browser/sat_browser/panels.py @ 538:3317e5d0ac1d

browser_side (plugin OTR): put all the text messages into constants
author souliane <souliane@mailoo.org>
date Sun, 07 Sep 2014 22:33:28 +0200
parents 048ae7314156
children d02335553b5d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/python
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
3
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 334
diff changeset
4 # Libervia: a Salut à Toi frontend
340
ce5b33f499c5 dates update
Goffi <goffi@goffi.org>
parents: 339
diff changeset
5 # Copyright (C) 2011, 2012, 2013, 2014 Jérôme Poisson <goffi@goffi.org>
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
6
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 334
diff changeset
7 # This program is free software: you can redistribute it and/or modify
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 334
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 334
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 334
diff changeset
10 # (at your option) any later version.
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
11
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 334
diff changeset
12 # This program is distributed in the hope that it will be useful,
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 334
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 334
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 334
diff changeset
15 # GNU Affero General Public License for more details.
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
16
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 334
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 334
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
19
226
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
diff changeset
20 import pyjd # this is dummy in pyjs
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
diff changeset
21 from sat.core.log import getLogger
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
diff changeset
22 log = getLogger(__name__)
449
981ed669d3b3 /!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents: 442
diff changeset
23
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
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
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
68d360caeecb New widget system: first draft
Goffi <goffi@goffi.org>
parents: 78
diff changeset
36 from pyjamas.ui.Button import Button
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
37 from pyjamas.ui.HTML import HTML
83
68d360caeecb New widget system: first draft
Goffi <goffi@goffi.org>
parents: 78
diff changeset
38 from pyjamas.ui.Image import Image
19
e8e3704eb97f Added basic chat panel
Goffi <goffi@goffi.org>
parents: 18
diff changeset
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
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
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
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 463
diff changeset
52 import jid
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 463
diff changeset
53 import html_tools
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 463
diff changeset
54 import base_panels
510
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
55 import base_menu
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 463
diff changeset
56 import card_game
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 463
diff changeset
57 import radiocol
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 463
diff changeset
58 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
59 import dialog
981ed669d3b3 /!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents: 442
diff changeset
60 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
61 import richtext
981ed669d3b3 /!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents: 442
diff changeset
62 import contact
433
bbdbee25123a import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents: 432
diff changeset
63 from constants import Const as C
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 463
diff changeset
64 import plugin_xep_0085
323
0b7934e75e76 misc: reorganization of the file panels.py + clean the modules import:
souliane <souliane@mailoo.org>
parents: 322
diff changeset
65
279
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
66
442
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
67 # 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
68 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
69 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
70
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
71
232
0ed09cc0566f browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents: 231
diff changeset
72 class UniBoxPanel(HorizontalPanel):
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
73 """Panel containing the UniBox"""
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
74
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
75 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
76 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
77 self.host = host
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
78 self.setStyleName('uniBoxPanel')
309
05e264e96a1c browser_side: make unibox optional
souliane <souliane@mailoo.org>
parents: 307
diff changeset
79 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
80
326
36927be51481 browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents: 323
diff changeset
81 def refresh(self):
36927be51481 browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents: 323
diff changeset
82 """Enable or disable this panel. Contained widgets are created when necessary."""
478
992b900ab876 browser side: rename and refactor constant UI_PARAMS to CACHED_PARAMS, from a dict of dict to a list of 2-tuple
souliane <souliane@mailoo.org>
parents: 467
diff changeset
83 enable = self.host.getCachedParam(C.COMPOSITION_KEY, C.ENABLE_UNIBOX_PARAM) == 'true'
326
36927be51481 browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents: 323
diff changeset
84 self.setVisible(enable)
36927be51481 browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents: 323
diff changeset
85 if enable and not self.unibox:
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
86 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
87 self.button.setTitle('Open the rich text editor')
05e264e96a1c browser_side: make unibox optional
souliane <souliane@mailoo.org>
parents: 307
diff changeset
88 self.button.addStyleName('uniBoxButton')
05e264e96a1c browser_side: make unibox optional
souliane <souliane@mailoo.org>
parents: 307
diff changeset
89 self.add(self.button)
05e264e96a1c browser_side: make unibox optional
souliane <souliane@mailoo.org>
parents: 307
diff changeset
90 self.unibox = UniBox(self.host)
05e264e96a1c browser_side: make unibox optional
souliane <souliane@mailoo.org>
parents: 307
diff changeset
91 self.add(self.unibox)
05e264e96a1c browser_side: make unibox optional
souliane <souliane@mailoo.org>
parents: 307
diff changeset
92 self.setCellWidth(self.unibox, '100%')
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
93 self.button.addClickListener(self.openRichMessageEditor)
309
05e264e96a1c browser_side: make unibox optional
souliane <souliane@mailoo.org>
parents: 307
diff changeset
94 self.unibox.addKey("@@: ")
380
5e0e2032928c browser_side: bug fixes microblogs:
souliane <souliane@mailoo.org>
parents: 370
diff changeset
95 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
96
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
97 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
98 """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
99 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
100 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
101 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
102 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
103
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
104 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
105 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
106 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
107 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
108 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
109 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
110 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
111
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
112 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
113 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
114 self.host.resize()
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
115
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
116 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
117 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
118 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
119 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
120 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
121
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
122
310
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
123 class MessageBox(TextArea):
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
124 """A basic text area for entering messages"""
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
125
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
126 def __init__(self, host):
73
447dc8ac181b Adrien's uniBox design integration + lastPopup style
Goffi <goffi@goffi.org>
parents: 71
diff changeset
127 TextArea.__init__(self)
310
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
128 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
129 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
130 self.setStyleName('messageBox')
83
68d360caeecb New widget system: first draft
Goffi <goffi@goffi.org>
parents: 78
diff changeset
131 self.addKeyboardListener(self)
186
72bb1d845b6a browser side: global resize on UniBox resize
Goffi <goffi@goffi.org>
parents: 185
diff changeset
132 MouseHandler.__init__(self)
72bb1d845b6a browser side: global resize on UniBox resize
Goffi <goffi@goffi.org>
parents: 185
diff changeset
133 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
134 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
135
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
136 def onBrowserEvent(self, event):
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
137 # 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
138 # 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
139 # 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
140 self.currentEvent = event
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
141 TextArea.onBrowserEvent(self, event)
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
142
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
143 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
144 _txt = self.getText()
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
145
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
146 def history_cb(text):
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
147 self.setText(text)
422
20c508f9b32a browser side: fixed bad use of Timer
Goffi <goffi@goffi.org>
parents: 414
diff changeset
148 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
149
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
150 if keycode == KEY_ENTER:
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
151 if _txt:
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
152 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
153 self.host._updateInputHistory(_txt)
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
154 self.setText('')
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
155 sender.cancelKey()
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
156 elif keycode == KEY_UP:
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
157 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
158 elif keycode == KEY_DOWN:
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
159 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
160 else:
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
161 self.__onComposing()
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
162
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
163 def __onComposing(self):
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
164 """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
165 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
166 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
167
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
168 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
169 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
170 if size != self.__size:
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
171 self.__size = size
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
172 self.host.resize()
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
173
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
174 def onSelectedChange(self, selected):
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
175 self._selected_cache = selected
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
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
178 class UniBox(MessageBox, MouseHandler): # AutoCompleteTextBox):
310
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
179 """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
180
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
181 def __init__(self, host):
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
182 MessageBox.__init__(self, host)
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
183 #AutoCompleteTextBox.__init__(self)
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
184 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
185 host.addSelectedListener(self.onSelectedChange)
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
186
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
187 def addKey(self, key):
73
447dc8ac181b Adrien's uniBox design integration + lastPopup style
Goffi <goffi@goffi.org>
parents: 71
diff changeset
188 return
447dc8ac181b Adrien's uniBox design integration + lastPopup style
Goffi <goffi@goffi.org>
parents: 71
diff changeset
189 #self.getCompletionItems().completions.append(key)
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
190
55
d5266c41ca24 Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents: 54
diff changeset
191 def removeKey(self, key):
255
da0487f0a2e7 browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents: 249
diff changeset
192 return
da0487f0a2e7 browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents: 249
diff changeset
193 # 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
194 # 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
195 # 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
196 try:
d5266c41ca24 Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents: 54
diff changeset
197 self.getCompletionItems().completions.remove(key)
d5266c41ca24 Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents: 54
diff changeset
198 except KeyError:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
diff changeset
199 log.warning("trying to remove an unknown key")
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
200
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
201 def _getTarget(self, txt):
201
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
202 """ Say who will receive the messsage
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
203 @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
204 - 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
205 - 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
206 - 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
207 target = self._selected_cache
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
208
201
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
209 def getSelectedOrStatus():
294
a6b3715f0bd6 browser_side: bug fixes for switching between unibox and rich text editor:
souliane <souliane@mailoo.org>
parents: 293
diff changeset
210 if target and target.isSelectable():
201
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
211 _type, msg = target.getWarningData()
226
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
diff changeset
212 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
213 else:
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
214 _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
215 target_hook = (txt, None)
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
216 return (target_hook, _type, msg)
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
217
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
218 if not txt.startswith('@'):
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
219 target_hook, _type, msg = getSelectedOrStatus()
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
220 elif txt.startswith('@@: '):
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
221 _type = "PUBLIC"
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
222 msg = MicroblogPanel.warning_msg_public
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
223 target_hook = (txt[4:], None)
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
224 elif txt.startswith('@'):
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
225 _end = txt.find(': ')
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
226 if _end == -1:
201
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
227 target_hook, _type, msg = getSelectedOrStatus()
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
228 else:
226
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
diff changeset
229 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
230 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
231 # 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
232 group = None
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
233 target_hook, _type, msg = getSelectedOrStatus()
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
234 else:
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
235 _type = "GROUP"
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
236 msg = MicroblogPanel.warning_msg_group % group
226
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
diff changeset
237 target_hook = (txt[_end + 2:], group)
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
238 else:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
diff changeset
239 log.error("Unknown target")
201
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
240 target_hook, _type, msg = getSelectedOrStatus()
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
241
201
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
242 return (target_hook, _type, msg)
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
243
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
244 def onKeyPress(self, sender, keycode, modifiers):
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
245 _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
246 target_hook, type_, msg = self._getTarget(_txt)
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
247
83
68d360caeecb New widget system: first draft
Goffi <goffi@goffi.org>
parents: 78
diff changeset
248 if keycode == KEY_ENTER:
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
249 if _txt:
201
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
250 if target_hook:
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
251 parsed_txt, data = target_hook
269
9eb9c7d41bdc browser_side: added generic method "send" in SatWebFrontend
souliane <souliane@mailoo.org>
parents: 267
diff changeset
252 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
253 self.host._updateInputHistory(_txt)
5d11ec1f2c22 browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents: 309
diff changeset
254 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
255 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
256 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
257 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
258 MessageBox.onKeyPress(self, sender, keycode, modifiers)
214
7b26be266ab1 plugin XEP-0085: Chat State Notifications
souliane <souliane@mailoo.org>
parents: 213
diff changeset
259
231
fab7aa366576 browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents: 230
diff changeset
260 def getTargetAndData(self):
fab7aa366576 browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents: 230
diff changeset
261 """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
262 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
263 @return a tuple (target, data) with:
fab7aa366576 browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents: 230
diff changeset
264 - 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
265 - 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
266 """
fab7aa366576 browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents: 230
diff changeset
267 _txt = self.getText()
fab7aa366576 browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents: 230
diff changeset
268 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
269 if target_hook:
fab7aa366576 browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents: 230
diff changeset
270 data, target = target_hook
fab7aa366576 browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents: 230
diff changeset
271 if target is None:
fab7aa366576 browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents: 230
diff changeset
272 return target_hook
fab7aa366576 browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents: 230
diff changeset
273 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
274 if isinstance(self._selected_cache, MicroblogPanel):
fab7aa366576 browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents: 230
diff changeset
275 groups = self._selected_cache.accepted_groups
fab7aa366576 browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents: 230
diff changeset
276 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
277 if len(groups) > 1:
fab7aa366576 browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents: 230
diff changeset
278 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
279 elif isinstance(self._selected_cache, ChatPanel):
fab7aa366576 browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents: 230
diff changeset
280 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
281 else:
a6b3715f0bd6 browser_side: bug fixes for switching between unibox and rich text editor:
souliane <souliane@mailoo.org>
parents: 293
diff changeset
282 target = None
231
fab7aa366576 browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents: 230
diff changeset
283 return (_txt, target)
fab7aa366576 browser_side: dialogs take **kwargs arguments + unibox helper method
souliane <souliane@mailoo.org>
parents: 230
diff changeset
284
294
a6b3715f0bd6 browser_side: bug fixes for switching between unibox and rich text editor:
souliane <souliane@mailoo.org>
parents: 293
diff changeset
285 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
286 """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
287 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
288 self.onSelectedChange(None)
a6b3715f0bd6 browser_side: bug fixes for switching between unibox and rich text editor:
souliane <souliane@mailoo.org>
parents: 293
diff changeset
289
73
447dc8ac181b Adrien's uniBox design integration + lastPopup style
Goffi <goffi@goffi.org>
parents: 71
diff changeset
290 """def complete(self):
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
291
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
292 #self.visible=False #XXX: self.visible is not unset in pyjamas when ENTER is pressed and a completion is done
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
293 #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
294 return AutoCompleteTextBox.complete(self)"""
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
295
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
296
361
f4efffb9627c browser_side: the popup notifying the message's recipient is no more dependent to the unibox.
souliane <souliane@mailoo.org>
parents: 351
diff changeset
297 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
298
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 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
300 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
301 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
302
394
ee61b0765d6c browser_side: radiocol supports MP3
souliane <souliane@mailoo.org>
parents: 383
diff changeset
303 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
304 """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
305 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
306 @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
307 @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
308 """
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 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
310 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
311 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
312 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
313 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
314 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
315 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
316 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
317
394
ee61b0765d6c browser_side: radiocol supports MP3
souliane <souliane@mailoo.org>
parents: 383
diff changeset
318 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
319
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 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
321 """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
322 @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
323 "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
324 @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
325 """
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 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
327 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
328 if not msg:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
diff changeset
329 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
330 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
331 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
332 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
333 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
334 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
335 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
336 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
337 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
338 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
339 else:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
diff changeset
340 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
341 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
342 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
343
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 = 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
345 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
346 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
347 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
348 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
349 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
350
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 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
352 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
353 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
354 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
355
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 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
357 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
358 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
359 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
360 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
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
362 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
363 """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
364 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
365
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
366
132
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
367 class MicroblogItem():
226
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
diff changeset
368 # 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
369
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
370 def __init__(self, data):
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
371 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
372 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
373 self.empty = data.get('new', False)
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
374 self.title = data.get('title', '')
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
375 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
376 self.content = data.get('content', '')
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
377 self.content_xhtml = data.get('content_xhtml', '')
132
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
378 self.author = data['author']
307
44b46db7dfef browser_side (groupblog): order items using "published" instead of "updated"
souliane <souliane@mailoo.org>
parents: 306
diff changeset
379 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
380 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
381 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
382 self.node = data.get('node', '')
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
383 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
384 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
385 self.comments_node = data.get('comments_node', '')
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
386
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
387
282
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
388 class MicroblogEntry(SimplePanel, ClickHandler, FocusHandler, KeyboardHandler):
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
389
350
f1b9ec412769 browser_side: MicroblogEntry defines properties to access MicroblogItem attributes (instead of overwriting __getattr__)
souliane <souliane@mailoo.org>
parents: 349
diff changeset
390 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
391 """
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 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
393 @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
394 """
350
f1b9ec412769 browser_side: MicroblogEntry defines properties to access MicroblogItem attributes (instead of overwriting __getattr__)
souliane <souliane@mailoo.org>
parents: 349
diff changeset
395 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
396 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
397 '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
398 '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
399 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
400 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
401 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
402
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
403 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
404 self._blog_panel = blog_panel
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
405
291
89818bca1a33 browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents: 289
diff changeset
406 self.panel = FlowPanel()
89818bca1a33 browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents: 289
diff changeset
407 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
408
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
409 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
410 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
411
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
412 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
413 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
414 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
415
89818bca1a33 browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents: 289
diff changeset
416 entry_avatar = SimplePanel()
89818bca1a33 browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents: 289
diff changeset
417 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
418 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
419 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
420 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
421
442
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
422 if TOGGLE_EDITION_USE_ICON:
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
423 self.entry_dialog = HorizontalPanel()
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
424 else:
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
425 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
426 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
427 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
428
119
a8d11fdea090 microblog avatar update
Goffi <goffi@goffi.org>
parents: 114
diff changeset
429 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
430 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
431 self.addClickListener(self)
119
a8d11fdea090 microblog avatar update
Goffi <goffi@goffi.org>
parents: 114
diff changeset
432
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
433 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
434 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
435
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
436 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
437 """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
438 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
439 self.bubble = self._current_comment = None
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
440 self.__setHeader()
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
441 self.__setBubble()
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
442 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
443
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
444 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
445 """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
446 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
447 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
448 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
449 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
450 <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
451 <span class='mb_entry_timestamp'>%(published)s</span>%(updated)s
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 463
diff changeset
452 </div>""" % {'author': html_tools.html_sanitize(self.author),
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
453 '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
454 '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
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 )
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
457
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
458 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
459 """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
460 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
461 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
462
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 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
464 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
465 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
466 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
467 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
468 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
469
442
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
470 if self.comments:
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
471 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
472 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
473 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
474 if is_publisher:
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
475 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
476 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
477 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
478
119
a8d11fdea090 microblog avatar update
Goffi <goffi@goffi.org>
parents: 114
diff changeset
479 def updateAvatar(self, new_avatar):
a8d11fdea090 microblog avatar update
Goffi <goffi@goffi.org>
parents: 114
diff changeset
480 """Change the avatar of the entry
a8d11fdea090 microblog avatar update
Goffi <goffi@goffi.org>
parents: 114
diff changeset
481 @param new_avatar: path to the new image"""
a8d11fdea090 microblog avatar update
Goffi <goffi@goffi.org>
parents: 114
diff changeset
482 self.avatar.setUrl(new_avatar)
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
483
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
484 def onClick(self, sender):
282
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
485 if sender == self:
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
486 self._blog_panel.setSelectedEntry(self)
282
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
487 elif sender == self.delete_label:
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
488 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
489 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
490 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
491 elif sender == self.comment_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
492 self._comment()
282
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
493
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
494 def __modifiedCb(self, content):
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
495 """Send the new content to the backend
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
496 @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
497 """
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
498 if not content['text']: # previous content has been emptied
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
499 self._delete(True)
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
500 return False
307
44b46db7dfef browser_side (groupblog): order items using "published" instead of "updated"
souliane <souliane@mailoo.org>
parents: 306
diff changeset
501 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
502 if isinstance(self.bubble, richtext.RichTextEditor):
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
503 # 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
504 # 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
505 # 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
506 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
507 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
508 if self.type == 'main_item':
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
509 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
510 else:
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
511 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
512 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
513 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
514 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
515
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
516 def __afterEditCb(self, content):
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
517 """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
518 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
519 if self.empty:
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
520 self._blog_panel.removeEntry(self.type, self.id)
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
521 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
522 self._blog_panel.refresh()
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
523 else: # allow to create a new comment
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
524 self._parent_entry._current_comment = None
425
19bd203daa27 browser_side: set microblog editor width to 80%
souliane <souliane@mailoo.org>
parents: 422
diff changeset
525 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
526 try:
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
527 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
528 except TypeError:
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
529 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
530
395
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
531 def __setBubble(self, edit=False):
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
532 """Set the bubble displaying the initial content."""
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
533 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
534 '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
535 if self.content_xhtml:
433
bbdbee25123a import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents: 432
diff changeset
536 content.update({'syntax': C.SYNTAX_XHTML})
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
537 if self.author != self._blog_panel.host.whoami.bare:
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
538 options = ['read_only']
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
539 else:
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
540 options = [] if self.empty else ['update_msg']
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
541 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
542 else: # assume raw text message have no title
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 463
diff changeset
543 self.bubble = base_panels.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
544 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
545 try:
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
546 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
547 except TypeError:
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
548 pass
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
549 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
550 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
551 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
552
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
553 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
554 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
555 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
556 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
557 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
558
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
559 def _delete(self, empty=False):
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
560 """Ask confirmation for deletion.
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
561 @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
562 def confirm_cb(answer):
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
563 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
564 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
565 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
566 self.bubble.setContent(self.bubble._original_content)
282
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
567
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
568 if self.empty:
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
569 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
570 dialog.InfoDialog(_("Information"), text).show()
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
571 return
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
572 text = ""
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
573 if empty:
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
574 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
575 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
576 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
577 dialog.ConfirmDialog(confirm_cb, text=text).show()
119
a8d11fdea090 microblog avatar update
Goffi <goffi@goffi.org>
parents: 114
diff changeset
578
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
579 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
580 """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
581 if self._current_comment:
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
582 self._current_comment.bubble.setFocus(True)
496
0924710b666a browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents: 495
diff changeset
583 self._blog_panel.setSelectedEntry(self._current_comment, True)
315
09205b410a53 browser_side: handle successive click on blog post "edit" and "comment" icons
souliane <souliane@mailoo.org>
parents: 314
diff changeset
584 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
585 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
586 '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
587 '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
588 '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
589 '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
590 '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
591 }
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 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
593 if entry is None:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
diff changeset
594 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
595 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
596 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
597 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
598 self.edit(True, entry)
496
0924710b666a browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents: 495
diff changeset
599 self._blog_panel.setSelectedEntry(entry, True)
395
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
600
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
601 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
602 """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
603 @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
604 @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
605 """
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
606 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
607 entry = self
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
608 try:
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
609 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
610 except TypeError:
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
611 pass
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
612 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
613 if edit:
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
614 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
615 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
616 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
617 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
618 else:
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
619 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
620 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
621 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
622 if TOGGLE_EDITION_USE_ICON:
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
623 entry.entry_dialog.setWidth('80%')
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
624 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
625 entry.toggle_syntax_button.setTitle(title)
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
626 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
627 else:
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
628 entry.toggle_syntax_button = HTML(html)
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
629 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
630 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
631 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
632 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
633 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
634
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
635 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
636 """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
637 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
638 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
639 if rich:
433
bbdbee25123a import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents: 432
diff changeset
640 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
641
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
642 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
643 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
644 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
645 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
646 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
647 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
648 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
649 if rich:
487dd238ab88 browser_side: bug fixes for microblog raw/rich edition toggle
souliane <souliane@mailoo.org>
parents: 397
diff changeset
650 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
651
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
652 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
653 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
654 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
655 return
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
656 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
657 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
658 if answer:
433
bbdbee25123a import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents: 432
diff changeset
659 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
660 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
661 else:
433
bbdbee25123a import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents: 432
diff changeset
662 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
663
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
664
195
dd27072d8ae0 browser side: widgets refactoring:
Goffi <goffi@goffi.org>
parents: 194
diff changeset
665 class MicroblogPanel(base_widget.LiberviaWidget):
499
ec3f30253040 browser_side: also display the warning banner when writing to a single contact and unibox is disabled
souliane <souliane@mailoo.org>
parents: 498
diff changeset
666 warning_msg_public = "This message will be <b>PUBLIC</b> and everybody will be able to see it, even people you don't know"
201
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
667 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
668
132
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
669 def __init__(self, host, accepted_groups):
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
670 """Panel used to show microblog
132
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
671 @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
672 """
230
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
673 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
674 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
675 self.host = host
58
4fa3d57f72f8 browser side: microblog entries caching
Goffi <goffi@goffi.org>
parents: 57
diff changeset
676 self.entries = {}
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
677 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
678 self.selected_entry = None
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
679 self.vpanel = VerticalPanel()
83
68d360caeecb New widget system: first draft
Goffi <goffi@goffi.org>
parents: 78
diff changeset
680 self.vpanel.setStyleName('microblogPanel')
34
ed935f763cc8 browser side: misc css/layout fixes
Goffi <goffi@goffi.org>
parents: 33
diff changeset
681 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
682
326
36927be51481 browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents: 323
diff changeset
683 def refresh(self):
36927be51481 browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents: 323
diff changeset
684 """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
685 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
686 if hasattr(self, 'new_button'):
442
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
687 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
688 return
442
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
689 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
690 def addBox():
442
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
691 if hasattr(self, 'new_button'):
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
692 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
693 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
694 '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
695 '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
696 }
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
697 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
698 entry.edit(True)
442
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
699 if NEW_MESSAGE_USE_BUTTON:
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
700 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
701 self.new_button.setStyleName("microblogNewButton")
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
702 self.vpanel.insert(self.new_button, 0)
461
4f25aa5039b3 browser_side: avoid adding more than one new message bubble on top of the microblog panel
souliane <souliane@mailoo.org>
parents: 451
diff changeset
703 elif not self.getNewMainEntry():
442
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
704 addBox()
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
705
461
4f25aa5039b3 browser_side: avoid adding more than one new message bubble on top of the microblog panel
souliane <souliane@mailoo.org>
parents: 451
diff changeset
706 def getNewMainEntry(self):
4f25aa5039b3 browser_side: avoid adding more than one new message bubble on top of the microblog panel
souliane <souliane@mailoo.org>
parents: 451
diff changeset
707 """Get the new entry being edited, or None if it doesn't exists.
4f25aa5039b3 browser_side: avoid adding more than one new message bubble on top of the microblog panel
souliane <souliane@mailoo.org>
parents: 451
diff changeset
708
4f25aa5039b3 browser_side: avoid adding more than one new message bubble on top of the microblog panel
souliane <souliane@mailoo.org>
parents: 451
diff changeset
709 @return (MicroblogEntry): the new entry being edited.
4f25aa5039b3 browser_side: avoid adding more than one new message bubble on top of the microblog panel
souliane <souliane@mailoo.org>
parents: 451
diff changeset
710 """
4f25aa5039b3 browser_side: avoid adding more than one new message bubble on top of the microblog panel
souliane <souliane@mailoo.org>
parents: 451
diff changeset
711 try:
4f25aa5039b3 browser_side: avoid adding more than one new message bubble on top of the microblog panel
souliane <souliane@mailoo.org>
parents: 451
diff changeset
712 first = self.vpanel.children[0]
4f25aa5039b3 browser_side: avoid adding more than one new message bubble on top of the microblog panel
souliane <souliane@mailoo.org>
parents: 451
diff changeset
713 except IndexError:
4f25aa5039b3 browser_side: avoid adding more than one new message bubble on top of the microblog panel
souliane <souliane@mailoo.org>
parents: 451
diff changeset
714 return None
4f25aa5039b3 browser_side: avoid adding more than one new message bubble on top of the microblog panel
souliane <souliane@mailoo.org>
parents: 451
diff changeset
715 assert(first.type == 'main_item')
4f25aa5039b3 browser_side: avoid adding more than one new message bubble on top of the microblog panel
souliane <souliane@mailoo.org>
parents: 451
diff changeset
716 return first if first.empty else None
4f25aa5039b3 browser_side: avoid adding more than one new message bubble on top of the microblog panel
souliane <souliane@mailoo.org>
parents: 451
diff changeset
717
195
dd27072d8ae0 browser side: widgets refactoring:
Goffi <goffi@goffi.org>
parents: 194
diff changeset
718 @classmethod
dd27072d8ae0 browser side: widgets refactoring:
Goffi <goffi@goffi.org>
parents: 194
diff changeset
719 def registerClass(cls):
230
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
720 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
721 base_widget.LiberviaWidget.addDropKey("CONTACT_TITLE", cls.createMetaPanel)
195
dd27072d8ae0 browser side: widgets refactoring:
Goffi <goffi@goffi.org>
parents: 194
diff changeset
722
dd27072d8ae0 browser side: widgets refactoring:
Goffi <goffi@goffi.org>
parents: 194
diff changeset
723 @classmethod
230
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
724 def createPanel(cls, host, item):
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
725 """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
726 @parem host: the SatWebFrontend instance
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
727 @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
728 (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
729 @return: the created MicroblogPanel
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
730 """
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
731 _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
732 _type = 'ALL' if _items == [] else 'GROUP'
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
733 # 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
734 _new_panel = MicroblogPanel(host, _items)
195
dd27072d8ae0 browser side: widgets refactoring:
Goffi <goffi@goffi.org>
parents: 194
diff changeset
735 host.FillMicroblogPanel(_new_panel)
230
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
736 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
737 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
738 _new_panel.refresh()
195
dd27072d8ae0 browser side: widgets refactoring:
Goffi <goffi@goffi.org>
parents: 194
diff changeset
739 return _new_panel
dd27072d8ae0 browser side: widgets refactoring:
Goffi <goffi@goffi.org>
parents: 194
diff changeset
740
dd27072d8ae0 browser side: widgets refactoring:
Goffi <goffi@goffi.org>
parents: 194
diff changeset
741 @classmethod
230
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
742 def createMetaPanel(cls, host, item):
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
743 """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
744 return MicroblogPanel.createPanel(host, None)
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 @property
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
747 def accepted_groups(self):
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
748 return self._accepted_groups
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 def matchEntity(self, entity):
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
751 """
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
752 @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
753 (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
754 @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
755 """
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
756 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
757 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
758 return self.accepted_groups == entity
195
dd27072d8ae0 browser side: widgets refactoring:
Goffi <goffi@goffi.org>
parents: 194
diff changeset
759
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
760 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
761 """
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
762 @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
763 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
764 @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
765 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
766 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
767 log.error("an item without comment is selected")
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
768 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
769 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
770 if comment:
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
771 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
772 elif not self._accepted_groups:
201
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
773 # we have a meta MicroblogPanel, we publish publicly
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
774 return ("PUBLIC", self.warning_msg_public)
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
775 else:
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
776 # we only accept one group at the moment
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
777 # FIXME: manage several groups
230
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
778 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
779
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
780 def onTextEntered(self, text):
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
781 if self.selected_entry:
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
782 # 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
783 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
784 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
785 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
786 target = ("COMMENT", comments_url)
230
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
787 elif not self._accepted_groups:
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
788 # we are entering a public microblog
269
9eb9c7d41bdc browser_side: added generic method "send" in SatWebFrontend
souliane <souliane@mailoo.org>
parents: 267
diff changeset
789 target = ("PUBLIC", None)
201
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
790 else:
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
791 # 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
792 # FIXME: manage several groups
269
9eb9c7d41bdc browser_side: added generic method "send" in SatWebFrontend
souliane <souliane@mailoo.org>
parents: 267
diff changeset
793 target = ("GROUP", self._accepted_groups[0])
9eb9c7d41bdc browser_side: added generic method "send" in SatWebFrontend
souliane <souliane@mailoo.org>
parents: 267
diff changeset
794 self.host.send([target], text)
201
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
795
132
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
796 def accept_all(self):
230
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
797 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
798
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
799 def getEntries(self):
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
800 """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
801 and fill the panel"""
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
802
132
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
803 def massiveInsert(self, mblogs):
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
804 """Insert several microblogs at once
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
805 @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
806 """
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
diff changeset
807 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
808 for publisher in mblogs:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
diff changeset
809 log.debug("adding blogs for [%s]" % publisher)
132
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
810 for mblog in mblogs[publisher]:
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
811 if not "content" in mblog:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
diff changeset
812 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
813 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
814 self.addEntry(mblog)
132
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
815
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
816 def mblogsInsert(self, mblogs):
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
817 """ Insert several microblogs at once
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
818 @param mblogs: list of microblogs
132
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
819 """
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
820 for mblog in mblogs:
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
821 if not "content" in mblog:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
diff changeset
822 log.warning("No content found in microblog [%s]", mblog)
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
823 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
824 self.addEntry(mblog)
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
825
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
826 def _chronoInsert(self, vpanel, entry, reverse=True):
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
827 """ Insert an entry in chronological order
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
828 @param vpanel: VerticalPanel instance
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
829 @param entry: MicroblogEntry
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
830 @param reverse: more recent entry on top if True, chronological order else"""
463
b62c1cf0dbf7 browser side: a new message being edited should always stay on top position (or last position for a comment)
souliane <souliane@mailoo.org>
parents: 462
diff changeset
831 assert(isinstance(reverse, bool))
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
832 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
833 entry.published = time()
135
ceef355156de server + browser side: groupblog subscription + fixed blog insertion order
Goffi <goffi@goffi.org>
parents: 132
diff changeset
834 # we look for the right index to insert our entry:
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
835 # 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
836 # in the past
ceef355156de server + browser side: groupblog subscription + fixed blog insertion order
Goffi <goffi@goffi.org>
parents: 132
diff changeset
837 idx = 0
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
838
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
839 for child in vpanel.children:
135
ceef355156de server + browser side: groupblog subscription + fixed blog insertion order
Goffi <goffi@goffi.org>
parents: 132
diff changeset
840 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
841 idx += 1
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
842 continue
463
b62c1cf0dbf7 browser side: a new message being edited should always stay on top position (or last position for a comment)
souliane <souliane@mailoo.org>
parents: 462
diff changeset
843 condition_to_stop = child.empty or (child.published > entry.published)
b62c1cf0dbf7 browser side: a new message being edited should always stay on top position (or last position for a comment)
souliane <souliane@mailoo.org>
parents: 462
diff changeset
844 if condition_to_stop != reverse: # != is XOR
b62c1cf0dbf7 browser side: a new message being edited should always stay on top position (or last position for a comment)
souliane <souliane@mailoo.org>
parents: 462
diff changeset
845 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
846 idx += 1
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
847
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
848 vpanel.insert(entry, idx)
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
849
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
850 def addEntry(self, data):
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
851 """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
852 @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
853 @return: the added entry, or None
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
854 """
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
855 _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
856 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
857 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
858 if not comments_hash in self.comments:
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
859 # 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
860 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
861 parent = self.comments[comments_hash]
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
862 parent_idx = self.vpanel.getWidgetIndex(parent)
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
863 # 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
864 try:
226
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
diff changeset
865 sub_panel = self.vpanel.getWidget(parent_idx + 1)
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
866 except IndexError:
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
867 sub_panel = None
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
868 if not sub_panel or not isinstance(sub_panel, VerticalPanel):
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
869 sub_panel = VerticalPanel()
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
870 sub_panel.setStyleName('microblogPanel')
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
871 sub_panel.addStyleName('subPanel')
226
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
diff changeset
872 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
873 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
874 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
875 if comment.id == _entry.id:
282
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
876 # update an existing comment
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
877 sub_panel.remove(comment)
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
878 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
879 return _entry
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
880 # we want comments to be inserted in chronological order
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
881 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
882 return _entry
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
883
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 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
885 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
886 self.vpanel.remove(self.entries[_entry.id])
282
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
887 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
888 else: # new entry
282
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
889 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
890 self.entries[_entry.id] = _entry
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
891
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
892 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
893 # 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
894 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
895 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
896 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
897
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
898 return _entry
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
899
282
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
900 def removeEntry(self, type_, id_):
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
901 """Remove an entry from the panel
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
902 @param type_: entry type ('main_item' or 'comment')
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
903 @param id_: entry id
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
904 """
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
905 for child in self.vpanel.getChildren():
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
906 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
907 if child.id == id_:
282
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
908 main_idx = self.vpanel.getWidgetIndex(child)
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
909 try:
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
910 sub_panel = self.vpanel.getWidget(main_idx + 1)
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
911 if isinstance(sub_panel, VerticalPanel):
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
912 sub_panel.removeFromParent()
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
913 except IndexError:
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
914 pass
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
915 child.removeFromParent()
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
916 self.selected_entry = None
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
917 break
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
918 elif isinstance(child, VerticalPanel) and type_ == 'comment':
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
919 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
920 if comment.id == id_:
282
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
921 comment.removeFromParent()
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
922 self.selected_entry = None
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
923 break
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
924
496
0924710b666a browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents: 495
diff changeset
925 def ensureVisible(self, entry):
0924710b666a browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents: 495
diff changeset
926 """Scroll to an entry to ensure its visibility
0924710b666a browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents: 495
diff changeset
927
0924710b666a browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents: 495
diff changeset
928 @param entry (MicroblogEntry): the entry
0924710b666a browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents: 495
diff changeset
929 """
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
930 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
931 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
932 except AttributeError:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
diff changeset
933 log.warning("FIXME: MicroblogPanel.vpanel should be wrapped in a ScrollPanel!")
496
0924710b666a browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents: 495
diff changeset
934
0924710b666a browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents: 495
diff changeset
935 def setSelectedEntry(self, entry, ensure_visible=False):
0924710b666a browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents: 495
diff changeset
936 """Select an entry.
0924710b666a browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents: 495
diff changeset
937
0924710b666a browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents: 495
diff changeset
938 @param entry (MicroblogEntry): the entry to select
0924710b666a browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents: 495
diff changeset
939 @param ensure_visible (boolean): if True, also scroll to the entry
0924710b666a browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents: 495
diff changeset
940 """
0924710b666a browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents: 495
diff changeset
941 if ensure_visible:
0924710b666a browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents: 495
diff changeset
942 self.ensureVisible(entry)
0924710b666a browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents: 495
diff changeset
943
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
944 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
945 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
946 clicked_entry = entry # entry may be None when the timer is done
496
0924710b666a browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents: 495
diff changeset
947 Timer(500, lambda timer: clicked_entry.removeStyleName('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
948 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
949 return # unibox is disabled
496
0924710b666a browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents: 495
diff changeset
950
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
951 # 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
952 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
953 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
954 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
955 if self.selected_entry:
496
0924710b666a browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents: 495
diff changeset
956 self.selected_entry.removeStyleName('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
957 if entry:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
diff changeset
958 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
959 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
960 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
961
241
86055ccf69c3 browser_side: added class PopupMenuPanel to manage more complex context menu
souliane <souliane@mailoo.org>
parents: 239
diff changeset
962 def updateValue(self, type_, jid, value):
119
a8d11fdea090 microblog avatar update
Goffi <goffi@goffi.org>
parents: 114
diff changeset
963 """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
964 @param type_: one of 'avatar', 'nick'
119
a8d11fdea090 microblog avatar update
Goffi <goffi@goffi.org>
parents: 114
diff changeset
965 @param jid: jid concerned
a8d11fdea090 microblog avatar update
Goffi <goffi@goffi.org>
parents: 114
diff changeset
966 @param value: new value"""
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
967 def updateVPanel(vpanel):
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
968 for child in vpanel.children:
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
969 if isinstance(child, MicroblogEntry) and child.author == jid:
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
970 child.updateAvatar(value)
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
971 elif isinstance(child, VerticalPanel):
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
972 updateVPanel(child)
241
86055ccf69c3 browser_side: added class PopupMenuPanel to manage more complex context menu
souliane <souliane@mailoo.org>
parents: 239
diff changeset
973 if type_ == 'avatar':
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
974 updateVPanel(self.vpanel)
119
a8d11fdea090 microblog avatar update
Goffi <goffi@goffi.org>
parents: 114
diff changeset
975
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
976 def setAcceptedGroup(self, group):
230
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
977 """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
978 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
979 @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
980 """
230
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
981 if not hasattr(self, "_accepted_groups"):
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
982 self._accepted_groups = []
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
983 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
984 for _group in groups:
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
985 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
986 self._accepted_groups.append(_group)
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
987 self._accepted_groups.sort()
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
988
482
437eefa53a01 misc: remove some pylint errors and warnings
souliane <souliane@mailoo.org>
parents: 478
diff changeset
989 def isJidAccepted(self, jid_s):
163
b887186e8fc8 browser side: get entity's microblogs for newly added contacts
Goffi <goffi@goffi.org>
parents: 148
diff changeset
990 """Tell if a jid is actepted and shown in this panel
482
437eefa53a01 misc: remove some pylint errors and warnings
souliane <souliane@mailoo.org>
parents: 478
diff changeset
991 @param jid_s: jid
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
992 @return: True if the jid is accepted"""
132
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
993 if self.accept_all():
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
994 return True
230
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
995 for group in self._accepted_groups:
482
437eefa53a01 misc: remove some pylint errors and warnings
souliane <souliane@mailoo.org>
parents: 478
diff changeset
996 if self.host.contact_panel.isContactInGroup(group, jid_s):
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
997 return True
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
998 return False
19
e8e3704eb97f Added basic chat panel
Goffi <goffi@goffi.org>
parents: 18
diff changeset
999
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
1000
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 463
diff changeset
1001 class StatusPanel(base_panels.HTMLTextEditor):
314
70ac3067d641 browser_side: status can be edited with a click on it
souliane <souliane@mailoo.org>
parents: 313
diff changeset
1002
349
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1003 EMPTY_STATUS = '&lt;click to set a status&gt;'
314
70ac3067d641 browser_side: status can be edited with a click on it
souliane <souliane@mailoo.org>
parents: 313
diff changeset
1004
20
8f4b1a8914c3 - User status is now updated
Goffi <goffi@goffi.org>
parents: 19
diff changeset
1005 def __init__(self, host, status=''):
8f4b1a8914c3 - User status is now updated
Goffi <goffi@goffi.org>
parents: 19
diff changeset
1006 self.host = host
349
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1007 modifiedCb = lambda content: self.host.bridge.call('setStatus', None, self.host.status_panel.presence, content['text']) or True
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 463
diff changeset
1008 base_panels.HTMLTextEditor.__init__(self, {'text': status}, modifiedCb, options={'no_xhtml': True, 'listen_focus': True, 'listen_click': True})
349
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1009 self.edit(False)
20
8f4b1a8914c3 - User status is now updated
Goffi <goffi@goffi.org>
parents: 19
diff changeset
1010 self.setStyleName('statusPanel')
19
e8e3704eb97f Added basic chat panel
Goffi <goffi@goffi.org>
parents: 18
diff changeset
1011
349
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1012 @property
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1013 def status(self):
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1014 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
1015
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1016 def __cleanContent(self, content):
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1017 status = content['text']
433
bbdbee25123a import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents: 432
diff changeset
1018 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
1019 content['text'] = ''
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1020 return content
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1021
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1022 def getContent(self):
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 463
diff changeset
1023 return self.__cleanContent(base_panels.HTMLTextEditor.getContent(self))
19
e8e3704eb97f Added basic chat panel
Goffi <goffi@goffi.org>
parents: 18
diff changeset
1024
349
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1025 def setContent(self, content):
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1026 content = self.__cleanContent(content)
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 463
diff changeset
1027 base_panels.BaseTextEditor.setContent(self, content)
349
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1028
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1029 def setDisplayContent(self):
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1030 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
1031 try:
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1032 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
1033 except AttributeError: # during initialization
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1034 presence = None
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1035 if not status:
433
bbdbee25123a import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents: 432
diff changeset
1036 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
1037 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
1038 else:
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1039 status = self.EMPTY_STATUS
402
d7e78cb78dfc browser_side: HTMLTextEditor and LightTextEditor factorization
souliane <souliane@mailoo.org>
parents: 401
diff changeset
1040 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
1041
279
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
1042
510
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
1043 class PresenceStatusMenuBar(base_widget.WidgetMenuBar):
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
1044 def __init__(self, parent):
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
1045 styles = {'menu_bar': 'presence-button'}
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
1046 base_widget.WidgetMenuBar.__init__(self, None, parent.host, styles=styles)
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
1047 self.button = self.addCategory(u"◉", u"◉", '')
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
1048 for presence, presence_i18n in C.PRESENCE.items():
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
1049 html = u'<span class="%s">◉</span> %s' % (contact.buildPresenceStyle(presence), presence_i18n)
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
1050 self.addMenuItem([u"◉", presence], [u"◉", html], '', base_menu.MenuCmd(self, 'changePresenceCb', presence), asHTML=True)
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
1051 self.parent_panel = parent
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
1052
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
1053 def changePresenceCb(self, presence):
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
1054 """Callback to notice the backend of a new presence set by the user.
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
1055 @param presence (str): the new presence is a value in ('', 'chat', 'away', 'dnd', 'xa')
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
1056 """
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
1057 self.host.bridge.call('setStatus', None, presence, self.parent_panel.status_panel.status)
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
1058
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
1059 @classmethod
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
1060 def getCategoryHTML(cls, menu_name_i18n, type_):
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
1061 return menu_name_i18n
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
1062
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
1063
279
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
1064 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
1065
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
1066 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
1067 self.host = host
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
1068 HorizontalPanel.__init__(self, Width='100%')
510
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
1069 self.menu = PresenceStatusMenuBar(self)
279
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
1070 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
1071 self.setPresence(presence)
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
1072
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
1073 panel = HorizontalPanel()
510
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
1074 panel.add(self.menu)
279
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
1075 panel.add(self.status_panel)
510
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
1076 panel.setCellVerticalAlignment(self.menu, 'baseline')
314
70ac3067d641 browser_side: status can be edited with a click on it
souliane <souliane@mailoo.org>
parents: 313
diff changeset
1077 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
1078 panel.setStyleName("marginAuto")
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
1079 self.add(panel)
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
1080
349
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1081 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
1082
279
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
1083 ClickHandler.__init__(self)
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
1084 self.addClickListener(self)
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
1085
349
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1086 @property
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1087 def presence(self):
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1088 return self._presence
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1089
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1090 @property
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1091 def status(self):
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1092 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
1093
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
1094 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
1095 self._presence = presence
510
db3436c85fb1 browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents: 499
diff changeset
1096 contact.setPresenceStyle(self.menu.button, self._presence)
279
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
1097
349
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1098 def setStatus(self, status):
f488692c4903 browser_side: LightTextEditor inheritates from BaseTextEditor + display URL in the status
souliane <souliane@mailoo.org>
parents: 347
diff changeset
1099 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
1100 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
1101
62
12e889a683ce server side: misc stuff:
Goffi <goffi@goffi.org>
parents: 58
diff changeset
1102 def onClick(self, sender):
226
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
diff changeset
1103 # 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
1104 self.host.setSelected(None)
20
8f4b1a8914c3 - User status is now updated
Goffi <goffi@goffi.org>
parents: 19
diff changeset
1105
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
1106
499
ec3f30253040 browser_side: also display the warning banner when writing to a single contact and unibox is disabled
souliane <souliane@mailoo.org>
parents: 498
diff changeset
1107 class ChatPanel(base_widget.LiberviaWidget, KeyboardHandler):
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
1108
179
8475a29d7214 closing a group chat widget now leave the muc room (bug 11)
Goffi <goffi@goffi.org>
parents: 178
diff changeset
1109 def __init__(self, host, target, type_='one2one'):
19
e8e3704eb97f Added basic chat panel
Goffi <goffi@goffi.org>
parents: 18
diff changeset
1110 """Panel used for conversation (one 2 one or group chat)
e8e3704eb97f Added basic chat panel
Goffi <goffi@goffi.org>
parents: 18
diff changeset
1111 @param host: SatWebFrontend instance
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 463
diff changeset
1112 @param target: entity (jid.JID) with who we have a conversation (contact's jid for one 2 one chat, or MUC room)
19
e8e3704eb97f Added basic chat panel
Goffi <goffi@goffi.org>
parents: 18
diff changeset
1113 @param type: one2one for simple conversation, group for MUC"""
34
ed935f763cc8 browser side: misc css/layout fixes
Goffi <goffi@goffi.org>
parents: 33
diff changeset
1114 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
1115 self.vpanel.setSize('100%', '100%')
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
1116 self.nick = None
19
e8e3704eb97f Added basic chat panel
Goffi <goffi@goffi.org>
parents: 18
diff changeset
1117 if not target:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
diff changeset
1118 log.error("Empty target !")
19
e8e3704eb97f Added basic chat panel
Goffi <goffi@goffi.org>
parents: 18
diff changeset
1119 return
e8e3704eb97f Added basic chat panel
Goffi <goffi@goffi.org>
parents: 18
diff changeset
1120 self.target = target
495
587fe75d1b16 browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents: 482
diff changeset
1121 self.type = type_
536
048ae7314156 browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents: 534
diff changeset
1122
048ae7314156 browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents: 534
diff changeset
1123 # FIXME: temporary dirty initialization to display the OTR state
048ae7314156 browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents: 534
diff changeset
1124 header_info = _('Encryption: none') if type_ == 'one2one' else None
048ae7314156 browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents: 534
diff changeset
1125
048ae7314156 browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents: 534
diff changeset
1126 base_widget.LiberviaWidget.__init__(self, host, title=target.bare, info=header_info, selectable=True)
84
8f35e9970e7f browser side: new widget handling:
Goffi <goffi@goffi.org>
parents: 83
diff changeset
1127 self.__body = AbsolutePanel()
8f35e9970e7f browser side: new widget handling:
Goffi <goffi@goffi.org>
parents: 83
diff changeset
1128 self.__body.setStyleName('chatPanel_body')
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
1129 chat_area = HorizontalPanel()
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
1130 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
1131 if type_ == 'group':
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 463
diff changeset
1132 self.occupants_list = base_panels.OccupantsList()
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
1133 chat_area.add(self.occupants_list)
84
8f35e9970e7f browser side: new widget handling:
Goffi <goffi@goffi.org>
parents: 83
diff changeset
1134 self.__body.add(chat_area)
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
1135 self.content = AbsolutePanel()
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
1136 self.content.setStyleName('chatContent')
195
dd27072d8ae0 browser side: widgets refactoring:
Goffi <goffi@goffi.org>
parents: 194
diff changeset
1137 self.content_scroll = base_widget.ScrollPanelWrapper(self.content)
34
ed935f763cc8 browser side: misc css/layout fixes
Goffi <goffi@goffi.org>
parents: 33
diff changeset
1138 chat_area.add(self.content_scroll)
ed935f763cc8 browser side: misc css/layout fixes
Goffi <goffi@goffi.org>
parents: 33
diff changeset
1139 chat_area.setCellWidth(self.content_scroll, '100%')
84
8f35e9970e7f browser side: new widget handling:
Goffi <goffi@goffi.org>
parents: 83
diff changeset
1140 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
1141 self.vpanel.setCellHeight(self.__body, '100%')
84
8f35e9970e7f browser side: new widget handling:
Goffi <goffi@goffi.org>
parents: 83
diff changeset
1142 self.addStyleName('chatPanel')
34
ed935f763cc8 browser side: misc css/layout fixes
Goffi <goffi@goffi.org>
parents: 33
diff changeset
1143 self.setWidget(self.vpanel)
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 463
diff changeset
1144 self.state_machine = plugin_xep_0085.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
1145 self._state = None
195
dd27072d8ae0 browser side: widgets refactoring:
Goffi <goffi@goffi.org>
parents: 194
diff changeset
1146
dd27072d8ae0 browser side: widgets refactoring:
Goffi <goffi@goffi.org>
parents: 194
diff changeset
1147 @classmethod
dd27072d8ae0 browser side: widgets refactoring:
Goffi <goffi@goffi.org>
parents: 194
diff changeset
1148 def registerClass(cls):
230
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
1149 base_widget.LiberviaWidget.addDropKey("CONTACT", cls.createPanel)
195
dd27072d8ae0 browser side: widgets refactoring:
Goffi <goffi@goffi.org>
parents: 194
diff changeset
1150
dd27072d8ae0 browser side: widgets refactoring:
Goffi <goffi@goffi.org>
parents: 194
diff changeset
1151 @classmethod
230
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
1152 def createPanel(cls, host, item):
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 463
diff changeset
1153 _contact = item if isinstance(item, jid.JID) else jid.JID(item)
195
dd27072d8ae0 browser side: widgets refactoring:
Goffi <goffi@goffi.org>
parents: 194
diff changeset
1154 host.contact_panel.setContactMessageWaiting(_contact.bare, False)
226
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
diff changeset
1155 _new_panel = ChatPanel(host, _contact) # XXX: pyjamas doesn't seems to support creating with cls directly
195
dd27072d8ae0 browser side: widgets refactoring:
Goffi <goffi@goffi.org>
parents: 194
diff changeset
1156 _new_panel.historyPrint()
230
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
1157 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
1158 _new_panel.refresh()
195
dd27072d8ae0 browser side: widgets refactoring:
Goffi <goffi@goffi.org>
parents: 194
diff changeset
1159 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
1160
230
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
1161 def refresh(self):
326
36927be51481 browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents: 323
diff changeset
1162 """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
1163 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
1164 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
1165 self.content_scroll.scrollToBottom()
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
1166
326
36927be51481 browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents: 323
diff changeset
1167 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
1168 if hasattr(self, 'message_box'):
36927be51481 browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents: 323
diff changeset
1169 self.message_box.setVisible(enable_box)
36927be51481 browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents: 323
diff changeset
1170 return
36927be51481 browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents: 323
diff changeset
1171 if enable_box:
36927be51481 browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents: 323
diff changeset
1172 self.message_box = MessageBox(self.host)
36927be51481 browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents: 323
diff changeset
1173 self.message_box.onSelectedChange(self)
499
ec3f30253040 browser_side: also display the warning banner when writing to a single contact and unibox is disabled
souliane <souliane@mailoo.org>
parents: 498
diff changeset
1174 self.message_box.addKeyboardListener(self)
326
36927be51481 browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents: 323
diff changeset
1175 self.vpanel.add(self.message_box)
36927be51481 browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents: 323
diff changeset
1176
499
ec3f30253040 browser_side: also display the warning banner when writing to a single contact and unibox is disabled
souliane <souliane@mailoo.org>
parents: 498
diff changeset
1177 def onKeyDown(self, sender, keycode, modifiers):
ec3f30253040 browser_side: also display the warning banner when writing to a single contact and unibox is disabled
souliane <souliane@mailoo.org>
parents: 498
diff changeset
1178 if keycode == KEY_ENTER:
ec3f30253040 browser_side: also display the warning banner when writing to a single contact and unibox is disabled
souliane <souliane@mailoo.org>
parents: 498
diff changeset
1179 self.host.showWarning(None, None)
ec3f30253040 browser_side: also display the warning banner when writing to a single contact and unibox is disabled
souliane <souliane@mailoo.org>
parents: 498
diff changeset
1180 else:
ec3f30253040 browser_side: also display the warning banner when writing to a single contact and unibox is disabled
souliane <souliane@mailoo.org>
parents: 498
diff changeset
1181 self.host.showWarning(*self.getWarningData())
ec3f30253040 browser_side: also display the warning banner when writing to a single contact and unibox is disabled
souliane <souliane@mailoo.org>
parents: 498
diff changeset
1182
230
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
1183 def matchEntity(self, entity):
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
1184 """
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 463
diff changeset
1185 @param entity: target jid as a string or jid.JID instance.
267
a76243c02074 browser_side: changes regarding widgets and tabs:
souliane <souliane@mailoo.org>
parents: 264
diff changeset
1186 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
1187 @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
1188 """
267
a76243c02074 browser_side: changes regarding widgets and tabs:
souliane <souliane@mailoo.org>
parents: 264
diff changeset
1189 if isinstance(entity, tuple):
a76243c02074 browser_side: changes regarding widgets and tabs:
souliane <souliane@mailoo.org>
parents: 264
diff changeset
1190 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
1191 else:
a76243c02074 browser_side: changes regarding widgets and tabs:
souliane <souliane@mailoo.org>
parents: 264
diff changeset
1192 type_ = self.type
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 463
diff changeset
1193 entity = entity if isinstance(entity, jid.JID) else jid.JID(entity)
230
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
1194 try:
267
a76243c02074 browser_side: changes regarding widgets and tabs:
souliane <souliane@mailoo.org>
parents: 264
diff changeset
1195 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
1196 except AttributeError as e:
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
1197 e.include_traceback()
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
1198 return False
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
1199
498
60be99de3808 browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents: 496
diff changeset
1200 def addMenus(self, menu_bar):
495
587fe75d1b16 browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents: 482
diff changeset
1201 """Add cached menus to the header.
587fe75d1b16 browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents: 482
diff changeset
1202
587fe75d1b16 browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents: 482
diff changeset
1203 @param menu_bar (GenericMenuBar): menu bar of the widget's header
587fe75d1b16 browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents: 482
diff changeset
1204 """
587fe75d1b16 browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents: 482
diff changeset
1205 if self.type == 'group':
587fe75d1b16 browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents: 482
diff changeset
1206 menu_bar.addCachedMenus(C.MENU_ROOM, {'room_jid': self.target.bare})
587fe75d1b16 browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents: 482
diff changeset
1207 elif self.type == 'one2one':
587fe75d1b16 browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents: 482
diff changeset
1208 menu_bar.addCachedMenus(C.MENU_SINGLE, {'jid': self.target})
587fe75d1b16 browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents: 482
diff changeset
1209
201
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
1210 def getWarningData(self):
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
1211 if self.type not in ["one2one", "group"]:
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
1212 raise Exception("Unmanaged type !")
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
1213 if self.type == "one2one":
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
1214 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
1215 elif self.type == "group":
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
1216 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
1217 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
1218
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
1219 def onTextEntered(self, text):
269
9eb9c7d41bdc browser_side: added generic method "send" in SatWebFrontend
souliane <souliane@mailoo.org>
parents: 267
diff changeset
1220 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
1221 self.state_machine._onEvent("active")
201
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
1222
179
8475a29d7214 closing a group chat widget now leave the muc room (bug 11)
Goffi <goffi@goffi.org>
parents: 178
diff changeset
1223 def onQuit(self):
195
dd27072d8ae0 browser side: widgets refactoring:
Goffi <goffi@goffi.org>
parents: 194
diff changeset
1224 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
1225 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
1226 self.host.bridge.call('mucLeave', None, self.target.bare)
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
1227
19
e8e3704eb97f Added basic chat panel
Goffi <goffi@goffi.org>
parents: 18
diff changeset
1228 def setUserNick(self, nick):
e8e3704eb97f Added basic chat panel
Goffi <goffi@goffi.org>
parents: 18
diff changeset
1229 """Set the nick of the user, usefull for e.g. change the color of the user"""
e8e3704eb97f Added basic chat panel
Goffi <goffi@goffi.org>
parents: 18
diff changeset
1230 self.nick = nick
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
1231
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
1232 def setPresents(self, nicks):
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
1233 """Set the users presents in this room
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
1234 @param occupants: list of nicks (string)"""
35
d43d6e4b9dc8 room user joining/leaving
Goffi <goffi@goffi.org>
parents: 34
diff changeset
1235 self.occupants_list.clear()
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
1236 for nick in nicks:
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
1237 self.occupants_list.addOccupant(nick)
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
1238
35
d43d6e4b9dc8 room user joining/leaving
Goffi <goffi@goffi.org>
parents: 34
diff changeset
1239 def userJoined(self, nick, data):
d43d6e4b9dc8 room user joining/leaving
Goffi <goffi@goffi.org>
parents: 34
diff changeset
1240 self.occupants_list.addOccupant(nick)
d43d6e4b9dc8 room user joining/leaving
Goffi <goffi@goffi.org>
parents: 34
diff changeset
1241 self.printInfo("=> %s has joined the room" % nick)
d43d6e4b9dc8 room user joining/leaving
Goffi <goffi@goffi.org>
parents: 34
diff changeset
1242
d43d6e4b9dc8 room user joining/leaving
Goffi <goffi@goffi.org>
parents: 34
diff changeset
1243 def userLeft(self, nick, data):
d43d6e4b9dc8 room user joining/leaving
Goffi <goffi@goffi.org>
parents: 34
diff changeset
1244 self.occupants_list.removeOccupant(nick)
d43d6e4b9dc8 room user joining/leaving
Goffi <goffi@goffi.org>
parents: 34
diff changeset
1245 self.printInfo("<= %s has left the room" % nick)
d43d6e4b9dc8 room user joining/leaving
Goffi <goffi@goffi.org>
parents: 34
diff changeset
1246
408
ee8ebfe23e16 browser_side: handle the signal "roomUserChangedNick"
souliane <souliane@mailoo.org>
parents: 407
diff changeset
1247 def changeUserNick(self, old_nick, new_nick):
ee8ebfe23e16 browser_side: handle the signal "roomUserChangedNick"
souliane <souliane@mailoo.org>
parents: 407
diff changeset
1248 assert(self.type == "group")
ee8ebfe23e16 browser_side: handle the signal "roomUserChangedNick"
souliane <souliane@mailoo.org>
parents: 407
diff changeset
1249 self.occupants_list.removeOccupant(old_nick)
ee8ebfe23e16 browser_side: handle the signal "roomUserChangedNick"
souliane <souliane@mailoo.org>
parents: 407
diff changeset
1250 self.occupants_list.addOccupant(new_nick)
ee8ebfe23e16 browser_side: handle the signal "roomUserChangedNick"
souliane <souliane@mailoo.org>
parents: 407
diff changeset
1251 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
1252
19
e8e3704eb97f Added basic chat panel
Goffi <goffi@goffi.org>
parents: 18
diff changeset
1253 def historyPrint(self, size=20):
e8e3704eb97f Added basic chat panel
Goffi <goffi@goffi.org>
parents: 18
diff changeset
1254 """Print the initial history"""
e8e3704eb97f Added basic chat panel
Goffi <goffi@goffi.org>
parents: 18
diff changeset
1255 def getHistoryCB(history):
213
8bbac49765d6 browser side: display the day change in chat window
souliane <souliane@mailoo.org>
parents: 210
diff changeset
1256 # display day change
8bbac49765d6 browser side: display the day change in chat window
souliane <souliane@mailoo.org>
parents: 210
diff changeset
1257 day_format = "%A, %d %b %Y"
8bbac49765d6 browser side: display the day change in chat window
souliane <souliane@mailoo.org>
parents: 210
diff changeset
1258 previous_day = datetime.now().strftime(day_format)
123
5cb852d9757e use of async history
Goffi <goffi@goffi.org>
parents: 120
diff changeset
1259 for line in history:
518
3d8e8f693576 browser_side: avoid some confusions between jid object 1. as an instance of JID or 2. as a str
souliane <souliane@mailoo.org>
parents: 510
diff changeset
1260 timestamp, from_jid_s, to_jid_s, message, mess_type, extra = line
213
8bbac49765d6 browser side: display the day change in chat window
souliane <souliane@mailoo.org>
parents: 210
diff changeset
1261 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
1262 if previous_day != message_day:
8bbac49765d6 browser side: display the day change in chat window
souliane <souliane@mailoo.org>
parents: 210
diff changeset
1263 self.printInfo("* " + message_day)
8bbac49765d6 browser side: display the day change in chat window
souliane <souliane@mailoo.org>
parents: 210
diff changeset
1264 previous_day = message_day
518
3d8e8f693576 browser_side: avoid some confusions between jid object 1. as an instance of JID or 2. as a str
souliane <souliane@mailoo.org>
parents: 510
diff changeset
1265 self.printMessage(jid.JID(from_jid_s), message, extra, timestamp)
123
5cb852d9757e use of async history
Goffi <goffi@goffi.org>
parents: 120
diff changeset
1266 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
1267
397
6148e9063069 browser_side: radiocol displays who uploaded the file with ChatPanel.printInfo
souliane <souliane@mailoo.org>
parents: 395
diff changeset
1268 def printInfo(self, msg, type_='normal', link_cb=None):
35
d43d6e4b9dc8 room user joining/leaving
Goffi <goffi@goffi.org>
parents: 34
diff changeset
1269 """Print general info
d43d6e4b9dc8 room user joining/leaving
Goffi <goffi@goffi.org>
parents: 34
diff changeset
1270 @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
1271 @param type_: one of:
534
d2bf317b2d28 browser_side: printInfo fixes:
Goffi <goffi@goffi.org>
parents: 518
diff changeset
1272 "normal": general info like "toto has joined the room" (will be sanitized)
d2bf317b2d28 browser_side: printInfo fixes:
Goffi <goffi@goffi.org>
parents: 518
diff changeset
1273 "link": general info that is clickable like "click here to join the main room" (no sanitize done)
d2bf317b2d28 browser_side: printInfo fixes:
Goffi <goffi@goffi.org>
parents: 518
diff changeset
1274 "me": "/me" information like "/me clenches his fist" ==> "toto clenches his fist" (will stay on one line)
397
6148e9063069 browser_side: radiocol displays who uploaded the file with ChatPanel.printInfo
souliane <souliane@mailoo.org>
parents: 395
diff changeset
1275 @param link_cb: method to call when the info is clicked, ignored if type_ is not 'link'
35
d43d6e4b9dc8 room user joining/leaving
Goffi <goffi@goffi.org>
parents: 34
diff changeset
1276 """
397
6148e9063069 browser_side: radiocol displays who uploaded the file with ChatPanel.printInfo
souliane <souliane@mailoo.org>
parents: 395
diff changeset
1277 if type_ == 'normal':
534
d2bf317b2d28 browser_side: printInfo fixes:
Goffi <goffi@goffi.org>
parents: 518
diff changeset
1278 _wid = HTML(addURLToText(html_tools.XHTML2Text(msg)))
35
d43d6e4b9dc8 room user joining/leaving
Goffi <goffi@goffi.org>
parents: 34
diff changeset
1279 _wid.setStyleName('chatTextInfo')
397
6148e9063069 browser_side: radiocol displays who uploaded the file with ChatPanel.printInfo
souliane <souliane@mailoo.org>
parents: 395
diff changeset
1280 elif type_ == 'link':
534
d2bf317b2d28 browser_side: printInfo fixes:
Goffi <goffi@goffi.org>
parents: 518
diff changeset
1281 _wid = HTML(msg)
397
6148e9063069 browser_side: radiocol displays who uploaded the file with ChatPanel.printInfo
souliane <souliane@mailoo.org>
parents: 395
diff changeset
1282 _wid.setStyleName('chatTextInfo-link')
6148e9063069 browser_side: radiocol displays who uploaded the file with ChatPanel.printInfo
souliane <souliane@mailoo.org>
parents: 395
diff changeset
1283 if link_cb:
6148e9063069 browser_side: radiocol displays who uploaded the file with ChatPanel.printInfo
souliane <souliane@mailoo.org>
parents: 395
diff changeset
1284 _wid.addClickListener(link_cb)
6148e9063069 browser_side: radiocol displays who uploaded the file with ChatPanel.printInfo
souliane <souliane@mailoo.org>
parents: 395
diff changeset
1285 elif type_ == 'me':
534
d2bf317b2d28 browser_side: printInfo fixes:
Goffi <goffi@goffi.org>
parents: 518
diff changeset
1286 _wid = Label(msg)
35
d43d6e4b9dc8 room user joining/leaving
Goffi <goffi@goffi.org>
parents: 34
diff changeset
1287 _wid.setStyleName('chatTextMe')
d43d6e4b9dc8 room user joining/leaving
Goffi <goffi@goffi.org>
parents: 34
diff changeset
1288 else:
534
d2bf317b2d28 browser_side: printInfo fixes:
Goffi <goffi@goffi.org>
parents: 518
diff changeset
1289 raise ValueError("Unknown printInfo type %s" % type_)
35
d43d6e4b9dc8 room user joining/leaving
Goffi <goffi@goffi.org>
parents: 34
diff changeset
1290 self.content.add(_wid)
534
d2bf317b2d28 browser_side: printInfo fixes:
Goffi <goffi@goffi.org>
parents: 518
diff changeset
1291 self.content_scroll.scrollToBottom()
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
1292
235
b304cdf13a3b browser and server side: XHTML handling, first draft:
Goffi <goffi@goffi.org>
parents: 232
diff changeset
1293 def printMessage(self, from_jid, msg, extra, timestamp=None):
19
e8e3704eb97f Added basic chat panel
Goffi <goffi@goffi.org>
parents: 18
diff changeset
1294 """Print message in chat window. Must be implemented by child class"""
518
3d8e8f693576 browser_side: avoid some confusions between jid object 1. as an instance of JID or 2. as a str
souliane <souliane@mailoo.org>
parents: 510
diff changeset
1295 nick = from_jid.node if self.type == 'one2one' else from_jid.resource
3d8e8f693576 browser_side: avoid some confusions between jid object 1. as an instance of JID or 2. as a str
souliane <souliane@mailoo.org>
parents: 510
diff changeset
1296 mymess = from_jid.resource == self.nick if self.type == "group" else from_jid.bare == self.host.whoami.bare # mymess = True if message comes from local user
35
d43d6e4b9dc8 room user joining/leaving
Goffi <goffi@goffi.org>
parents: 34
diff changeset
1297 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
1298 self.printInfo('* %s %s' % (nick, msg[4:]), type_='me')
35
d43d6e4b9dc8 room user joining/leaving
Goffi <goffi@goffi.org>
parents: 34
diff changeset
1299 return
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 463
diff changeset
1300 self.content.add(base_panels.ChatText(timestamp, nick, mymess, msg, extra.get('xhtml')))
34
ed935f763cc8 browser side: misc css/layout fixes
Goffi <goffi@goffi.org>
parents: 33
diff changeset
1301 self.content_scroll.scrollToBottom()
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
1302
285
4f0c2fea358a browser_side (plugin radiocol): use the status label to give more information
souliane <souliane@mailoo.org>
parents: 282
diff changeset
1303 def startGame(self, game_type, waiting, referee, players, *args):
36
1d406077b49b Tarot Game: first draft
Goffi <goffi@goffi.org>
parents: 35
diff changeset
1304 """Configure the chat window to start a game"""
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 463
diff changeset
1305 classes = {"Tarot": card_game.CardPanel, "RadioCol": radiocol.RadioColPanel}
275
a763b2ac5d41 bridge + browser_side: bridge signals for games and their callbacks:
souliane <souliane@mailoo.org>
parents: 273
diff changeset
1306 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
1307 return # unknown game
a763b2ac5d41 bridge + browser_side: bridge signals for games and their callbacks:
souliane <souliane@mailoo.org>
parents: 273
diff changeset
1308 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
1309 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
1310 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
1311 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
1312 attr = "%s_panel" % attr
a763b2ac5d41 bridge + browser_side: bridge signals for games and their callbacks:
souliane <souliane@mailoo.org>
parents: 273
diff changeset
1313 if hasattr(self, attr):
a763b2ac5d41 bridge + browser_side: bridge signals for games and their callbacks:
souliane <souliane@mailoo.org>
parents: 273
diff changeset
1314 return
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
diff changeset
1315 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
1316 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
1317 setattr(self, attr, panel)
a763b2ac5d41 bridge + browser_side: bridge signals for games and their callbacks:
souliane <souliane@mailoo.org>
parents: 273
diff changeset
1318 self.vpanel.insert(panel, 0)
a763b2ac5d41 bridge + browser_side: bridge signals for games and their callbacks:
souliane <souliane@mailoo.org>
parents: 273
diff changeset
1319 self.vpanel.setCellHeight(panel, panel.getHeight())
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
1320
37
b306aa090438 Tarot game: game launching (first hand showed), and contract selection
Goffi <goffi@goffi.org>
parents: 36
diff changeset
1321 def getGame(self, game_type):
b306aa090438 Tarot game: game launching (first hand showed), and contract selection
Goffi <goffi@goffi.org>
parents: 36
diff changeset
1322 """Return class managing the game type"""
226
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
diff changeset
1323 # 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
1324 if game_type == "Tarot":
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
1325 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
1326 elif game_type == "RadioCol":
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
1327 return self.radiocol_panel
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
1328
407
6a6551de4414 browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 404
diff changeset
1329 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
1330 """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
1331 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
1332 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
1333 @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
1334 @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
1335 """
6a6551de4414 browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 404
diff changeset
1336 if nick:
6a6551de4414 browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 404
diff changeset
1337 assert(self.type == 'group')
433
bbdbee25123a import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents: 432
diff changeset
1338 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
1339 for occupant in occupants:
6a6551de4414 browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 404
diff changeset
1340 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
1341 else:
6a6551de4414 browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 404
diff changeset
1342 assert(self.type == 'one2one')
6a6551de4414 browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 404
diff changeset
1343 self._state = state
6a6551de4414 browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 404
diff changeset
1344 self.refreshTitle()
6a6551de4414 browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 404
diff changeset
1345 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
1346
6a6551de4414 browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 404
diff changeset
1347 def refreshTitle(self):
6a6551de4414 browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 404
diff changeset
1348 """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
1349 if self._state:
6a6551de4414 browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 404
diff changeset
1350 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
1351 else:
6a6551de4414 browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 404
diff changeset
1352 self.setTitle(self.target.bare)
6a6551de4414 browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 404
diff changeset
1353
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
1354
195
dd27072d8ae0 browser side: widgets refactoring:
Goffi <goffi@goffi.org>
parents: 194
diff changeset
1355 class WebPanel(base_widget.LiberviaWidget):
181
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
1356 """ (mini)browser like widget """
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
1357
181
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
1358 def __init__(self, host, url=None):
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
1359 """
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
1360 @param host: SatWebFrontend instance
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
1361 """
195
dd27072d8ae0 browser side: widgets refactoring:
Goffi <goffi@goffi.org>
parents: 194
diff changeset
1362 base_widget.LiberviaWidget.__init__(self, host)
181
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
1363 self._vpanel = VerticalPanel()
188
39936b83da9d Browser Side: Web Panel widget position/size fix
Goffi <goffi@goffi.org>
parents: 187
diff changeset
1364 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
1365 self._url = dialog.ExtTextBox(enter_cb=self.onUrlClick)
181
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
1366 self._url.setText(url or "")
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
1367 self._url.setWidth('100%')
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
1368 hpanel = HorizontalPanel()
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
1369 hpanel.add(self._url)
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
1370 btn = Button("Go", self.onUrlClick)
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
1371 hpanel.setCellWidth(self._url, "100%")
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
1372 #self.setCellWidth(btn, "10%")
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
1373 hpanel.add(self._url)
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
1374 hpanel.add(btn)
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
1375 self._vpanel.add(hpanel)
188
39936b83da9d Browser Side: Web Panel widget position/size fix
Goffi <goffi@goffi.org>
parents: 187
diff changeset
1376 self._vpanel.setCellHeight(hpanel, '20px')
181
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
1377 self._frame = Frame(url or "")
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
1378 self._frame.setSize('100%', '100%')
188
39936b83da9d Browser Side: Web Panel widget position/size fix
Goffi <goffi@goffi.org>
parents: 187
diff changeset
1379 DOM.setStyleAttribute(self._frame.getElement(), "position", "relative")
181
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
1380 self._vpanel.add(self._frame)
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
1381 self.setWidget(self._vpanel)
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
1382
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
1383 def onUrlClick(self, sender):
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
1384 self._frame.setUrl(self._url.getText())
c0b78a3af06d browser side: web widget first draft
Goffi <goffi@goffi.org>
parents: 179
diff changeset
1385
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
1386
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
1387 class MainPanel(AbsolutePanel):
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
1388
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
1389 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
1390 self.host = host
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
1391 AbsolutePanel.__init__(self)
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
1392
226
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
diff changeset
1393 # menu
495
587fe75d1b16 browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents: 482
diff changeset
1394 self.menu = menu.MainMenuPanel(host)
184
97d5e9de1106 browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents: 181
diff changeset
1395
226
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
diff changeset
1396 # unibox
309
05e264e96a1c browser_side: make unibox optional
souliane <souliane@mailoo.org>
parents: 307
diff changeset
1397 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
1398 self.unibox_panel.setVisible(False)
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
1399
226
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
diff changeset
1400 # contacts
232
0ed09cc0566f browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents: 231
diff changeset
1401 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
1402 self._contacts.addStyleName('globalLeftArea')
255
da0487f0a2e7 browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents: 249
diff changeset
1403 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
1404 self.contacts_switch.addStyleName('contactsSwitch')
da0487f0a2e7 browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents: 249
diff changeset
1405 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
1406 self._contacts.add(self.host.contact_panel)
184
97d5e9de1106 browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents: 181
diff changeset
1407
226
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
diff changeset
1408 # tabs
195
dd27072d8ae0 browser side: widgets refactoring:
Goffi <goffi@goffi.org>
parents: 194
diff changeset
1409 self.tab_panel = base_widget.MainTabPanel(host)
dd27072d8ae0 browser side: widgets refactoring:
Goffi <goffi@goffi.org>
parents: 194
diff changeset
1410 self.discuss_panel = base_widget.WidgetsPanel(self.host, locked=True)
23
0ce2a57b34ca added tab panel
Goffi <goffi@goffi.org>
parents: 22
diff changeset
1411 self.tab_panel.add(self.discuss_panel, "Discussions")
0ce2a57b34ca added tab panel
Goffi <goffi@goffi.org>
parents: 22
diff changeset
1412 self.tab_panel.selectTab(0)
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
1413
426
77d8f55fc5f0 browser_side: hide the presence/status panel until the connection is made
souliane <souliane@mailoo.org>
parents: 425
diff changeset
1414 self.header = AbsolutePanel()
77d8f55fc5f0 browser_side: hide the presence/status panel until the connection is made
souliane <souliane@mailoo.org>
parents: 425
diff changeset
1415 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
1416 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
1417 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
1418 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
1419 self.add(self.header)
184
97d5e9de1106 browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents: 181
diff changeset
1420
232
0ed09cc0566f browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents: 231
diff changeset
1421 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
1422 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
1423 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
1424 self.add(self._hpanel)
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
1425
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
1426 self.setWidth("100%")
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
1427 Window.addWindowResizeListener(self)
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
1428
255
da0487f0a2e7 browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents: 249
diff changeset
1429 def _contactsSwitch(self, btn=None):
184
97d5e9de1106 browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents: 181
diff changeset
1430 """ (Un)hide contacts panel """
255
da0487f0a2e7 browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents: 249
diff changeset
1431 if btn is None:
da0487f0a2e7 browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents: 249
diff changeset
1432 btn = self.contacts_switch
184
97d5e9de1106 browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents: 181
diff changeset
1433 cpanel = self.host.contact_panel
97d5e9de1106 browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents: 181
diff changeset
1434 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
1435 btn.setText(u"«" if cpanel.getVisible() else u"»")
184
97d5e9de1106 browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents: 181
diff changeset
1436 self.host.resize()
97d5e9de1106 browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents: 181
diff changeset
1437
232
0ed09cc0566f browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents: 231
diff changeset
1438 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
1439 """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
1440 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
1441 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
1442 """
0ed09cc0566f browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents: 231
diff changeset
1443 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
1444 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
1445 return
0ed09cc0566f browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents: 231
diff changeset
1446 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
1447 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
1448
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
1449 def onWindowResized(self, width, height):
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
1450 _elts = doc().getElementsByClassName('gwt-TabBar')
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
1451 if not _elts.length:
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
1452 tab_bar_h = 0
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
1453 else:
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
1454 tab_bar_h = _elts.item(0).offsetHeight
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
1455 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
1456 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
1457
326
36927be51481 browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents: 323
diff changeset
1458 def refresh(self):
36927be51481 browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents: 323
diff changeset
1459 """Refresh the main panel"""
36927be51481 browser_side: fixed the behavior regarding "Enable unibox" parameter:
souliane <souliane@mailoo.org>
parents: 323
diff changeset
1460 self.unibox_panel.refresh()