Mercurial > libervia-web
annotate browser_side/richtext.py @ 360:9834136b15ed
added setup.py for the installation with setuptools
author | souliane <souliane@mailoo.org> |
---|---|
date | Tue, 18 Feb 2014 00:15:43 +0100 |
parents | 151bf1afd97e |
children | 019e1e706e74 |
rev | line source |
---|---|
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
1 #!/usr/bin/python |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
3 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
327
diff
changeset
|
4 # Libervia: a Salut à Toi frontend |
340 | 5 # Copyright (C) 2013, 2014 Adrien Cossa <souliane@mailoo.org> |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
6 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
327
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:
327
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:
327
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:
327
diff
changeset
|
10 # (at your option) any later version. |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
11 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
327
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:
327
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:
327
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:
327
diff
changeset
|
15 # GNU Affero General Public License for more details. |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
16 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
327
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:
327
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
19 |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
20 from pyjamas.ui.TextArea import TextArea |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
21 from pyjamas.ui.Button import Button |
353
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
22 from pyjamas.ui.CheckBox import CheckBox |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
23 from pyjamas.ui.DialogBox import DialogBox |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
24 from pyjamas.ui.Label import Label |
324
8131d0ccf21b
browser_side: prepare user input for microblog titles
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
25 from pyjamas.ui.HTML import HTML |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
26 from pyjamas.ui.FlexTable import FlexTable |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
27 from pyjamas.ui.HorizontalPanel import HorizontalPanel |
355
9bb78c09e9fc
browser_side: wysiwyg edition handles the toolbar buttons
souliane <souliane@mailoo.org>
parents:
353
diff
changeset
|
28 from pyjamas import Window |
9bb78c09e9fc
browser_side: wysiwyg edition handles the toolbar buttons
souliane <souliane@mailoo.org>
parents:
353
diff
changeset
|
29 from __pyjamas__ import doc |
323
0b7934e75e76
misc: reorganization of the file panels.py + clean the modules import:
souliane <souliane@mailoo.org>
parents:
319
diff
changeset
|
30 |
352
2610443b05a2
browser_side: misc improvements for RichTextEditor to prepare Wysiwyg edition
souliane <souliane@mailoo.org>
parents:
351
diff
changeset
|
31 from constants import Const |
323
0b7934e75e76
misc: reorganization of the file panels.py + clean the modules import:
souliane <souliane@mailoo.org>
parents:
319
diff
changeset
|
32 from dialog import ConfirmDialog, InfoDialog |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
33 from base_panels import TitlePanel, BaseTextEditor, LightTextEditor |
254
28d3315a8003
browser_side: isolate the basic stuff of RecipientManager in a new class ListManager:
souliane <souliane@mailoo.org>
parents:
234
diff
changeset
|
34 from list_manager import ListManager |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
35 import panels |
323
0b7934e75e76
misc: reorganization of the file panels.py + clean the modules import:
souliane <souliane@mailoo.org>
parents:
319
diff
changeset
|
36 |
276
aebb96bfa8d1
frontends tools: moved src/tools/frontends to frontends/src/tools
souliane <souliane@mailoo.org>
parents:
270
diff
changeset
|
37 from sat_frontends.tools import composition |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
38 from sat.core.i18n import _ |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
39 |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
40 |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
41 class RichTextEditor(BaseTextEditor, FlexTable): |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
42 """Panel for the rich text editor.""" |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
43 |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
44 def __init__(self, host, content=None, modifiedCb=None, afterEditCb=None, options=None, style=None): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
45 """ |
281
36ce989c73a5
browser_side: more customizable rich text editor
souliane <souliane@mailoo.org>
parents:
280
diff
changeset
|
46 @param host: the SatWebFrontend instance |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
47 @param content: dict with at least a 'text' key |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
48 @param modifiedCb: method to be called when the text has been modified |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
49 @param afterEditCb: method to be called when the edition is done |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
50 @param options: list of UI options (see self.readOptions) |
281
36ce989c73a5
browser_side: more customizable rich text editor
souliane <souliane@mailoo.org>
parents:
280
diff
changeset
|
51 """ |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
52 self.host = host |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
53 self._debug = False # TODO: don't forget to set it False before commit |
352
2610443b05a2
browser_side: misc improvements for RichTextEditor to prepare Wysiwyg edition
souliane <souliane@mailoo.org>
parents:
351
diff
changeset
|
54 self.wysiwyg = False |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
55 self.__readOptions(options) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
56 self.style = {'main': 'richTextEditor', |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
57 'title': 'richTextTitle', |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
58 'toolbar': 'richTextToolbaar', |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
59 'textarea': 'richTextArea'} |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
60 if isinstance(style, dict): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
61 self.style.update(style) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
62 self._prepareUI() |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
63 BaseTextEditor.__init__(self, content, None, modifiedCb, afterEditCb) |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
64 |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
65 def __readOptions(self, options): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
66 """Set the internal flags according to the given options.""" |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
67 if options is None: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
68 options = [] |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
69 self.read_only = 'read_only' in options |
281
36ce989c73a5
browser_side: more customizable rich text editor
souliane <souliane@mailoo.org>
parents:
280
diff
changeset
|
70 self.update_msg = 'update_msg' in options |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
71 self.no_title = 'no_title' in options or self.read_only |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
72 self.no_command = 'no_command' in options or self.read_only |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
73 |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
74 def _prepareUI(self, y_offset=0): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
75 """Prepare the UI to host title panel, toolbar, text area... |
359
151bf1afd97e
browser_side: fix error when displaying the microblogs of a contact
souliane <souliane@mailoo.org>
parents:
357
diff
changeset
|
76 @param y_offset: Y offset to start from (extra rows on top)""" |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
77 if not self.read_only: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
78 self.title_offset = y_offset |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
79 self.toolbar_offset = self.title_offset + (0 if self.no_title else 1) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
80 self.content_offset = self.toolbar_offset + (len(composition.RICH_SYNTAXES) if self._debug else 1) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
81 self.command_offset = self.content_offset + 1 |
359
151bf1afd97e
browser_side: fix error when displaying the microblogs of a contact
souliane <souliane@mailoo.org>
parents:
357
diff
changeset
|
82 else: |
151bf1afd97e
browser_side: fix error when displaying the microblogs of a contact
souliane <souliane@mailoo.org>
parents:
357
diff
changeset
|
83 self.title_offset = self.toolbar_offset = self.content_offset = y_offset |
151bf1afd97e
browser_side: fix error when displaying the microblogs of a contact
souliane <souliane@mailoo.org>
parents:
357
diff
changeset
|
84 self.command_offset = self.content_offset + 1 |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
85 FlexTable.__init__(self, self.command_offset + (0 if self.no_command else 1), 2) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
86 self.addStyleName(self.style['main']) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
87 |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
88 def refresh(self, edit=None): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
89 """Refresh the UI for edition/display mode |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
90 @param edit: set to True to display the edition mode""" |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
91 if edit is None: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
92 edit = hasattr(self, 'textarea') and self.textarea.getVisible() |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
93 |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
94 for widget in ['title_panel', 'command']: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
95 if hasattr(self, widget): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
96 getattr(self, widget).setVisible(edit) |
324
8131d0ccf21b
browser_side: prepare user input for microblog titles
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
97 |
352
2610443b05a2
browser_side: misc improvements for RichTextEditor to prepare Wysiwyg edition
souliane <souliane@mailoo.org>
parents:
351
diff
changeset
|
98 if hasattr(self, 'toolbar'): |
2610443b05a2
browser_side: misc improvements for RichTextEditor to prepare Wysiwyg edition
souliane <souliane@mailoo.org>
parents:
351
diff
changeset
|
99 self.toolbar.setVisible(False) |
2610443b05a2
browser_side: misc improvements for RichTextEditor to prepare Wysiwyg edition
souliane <souliane@mailoo.org>
parents:
351
diff
changeset
|
100 if not hasattr(self, 'display'): |
356
b95099a1d11b
browser_side: do not use addURLToText to display Microblog XHTML content
souliane <souliane@mailoo.org>
parents:
355
diff
changeset
|
101 self.display = LightTextEditor(enhance_display=False) # for display mode |
352
2610443b05a2
browser_side: misc improvements for RichTextEditor to prepare Wysiwyg edition
souliane <souliane@mailoo.org>
parents:
351
diff
changeset
|
102 if not self.read_only and not hasattr(self, 'textarea'): |
2610443b05a2
browser_side: misc improvements for RichTextEditor to prepare Wysiwyg edition
souliane <souliane@mailoo.org>
parents:
351
diff
changeset
|
103 self.textarea = TextArea() # for edition mode |
2610443b05a2
browser_side: misc improvements for RichTextEditor to prepare Wysiwyg edition
souliane <souliane@mailoo.org>
parents:
351
diff
changeset
|
104 self.textarea.addStyleName(self.style['textarea']) |
2610443b05a2
browser_side: misc improvements for RichTextEditor to prepare Wysiwyg edition
souliane <souliane@mailoo.org>
parents:
351
diff
changeset
|
105 |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
106 self.getFlexCellFormatter().setColSpan(self.content_offset, 0, 2) |
352
2610443b05a2
browser_side: misc improvements for RichTextEditor to prepare Wysiwyg edition
souliane <souliane@mailoo.org>
parents:
351
diff
changeset
|
107 if edit and not self.wysiwyg: |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
108 self.textarea.setWidth('100%') # CSS width doesn't do it, don't know why |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
109 self.setWidget(self.content_offset, 0, self.textarea) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
110 else: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
111 self.setWidget(self.content_offset, 0, self.display) |
352
2610443b05a2
browser_side: misc improvements for RichTextEditor to prepare Wysiwyg edition
souliane <souliane@mailoo.org>
parents:
351
diff
changeset
|
112 if not edit: |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
113 return |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
114 |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
115 if not self.no_title and not hasattr(self, 'title_panel'): |
324
8131d0ccf21b
browser_side: prepare user input for microblog titles
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
116 self.title_panel = TitlePanel() |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
117 self.title_panel.addStyleName(self.style['title']) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
118 self.getFlexCellFormatter().setColSpan(self.title_offset, 0, 2) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
119 self.setWidget(self.title_offset, 0, self.title_panel) |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
120 |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
121 if not self.no_command and not hasattr(self, 'command'): |
281
36ce989c73a5
browser_side: more customizable rich text editor
souliane <souliane@mailoo.org>
parents:
280
diff
changeset
|
122 self.command = HorizontalPanel() |
36ce989c73a5
browser_side: more customizable rich text editor
souliane <souliane@mailoo.org>
parents:
280
diff
changeset
|
123 self.command.addStyleName("marginAuto") |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
124 self.command.add(Button("Cancel", lambda: self.edit(True, True))) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
125 self.command.add(Button("Update" if self.update_msg else "Send message", lambda: self.edit(False))) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
126 self.getFlexCellFormatter().setColSpan(self.command_offset, 0, 2) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
127 self.setWidget(self.command_offset, 0, self.command) |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
128 |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
129 def setToolBar(self, syntax): |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
130 """This method is called asynchronously after the parameter |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
131 holding the rich text syntax is retrieved. It is called at |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
132 each call of self.edit(True) because the user may |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
133 have change his setting since the last time.""" |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
134 if syntax is None or syntax not in composition.RICH_SYNTAXES.keys(): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
135 syntax = composition.RICH_SYNTAXES.keys()[0] |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
136 if hasattr(self, "toolbar") and self.toolbar.syntax == syntax: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
137 self.toolbar.setVisible(True) |
352
2610443b05a2
browser_side: misc improvements for RichTextEditor to prepare Wysiwyg edition
souliane <souliane@mailoo.org>
parents:
351
diff
changeset
|
138 return |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
139 count = 0 |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
140 for syntax in composition.RICH_SYNTAXES.keys() if self._debug else [syntax]: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
141 self.toolbar = HorizontalPanel() |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
142 self.toolbar.syntax = syntax |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
143 self.toolbar.addStyleName(self.style['toolbar']) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
144 for key in composition.RICH_SYNTAXES[syntax].keys(): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
145 self.addToolbarButton(syntax, key) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
146 label = Label(_("Syntax: %s") % syntax) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
147 label.addStyleName("richTextSyntaxLabel") |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
148 self.toolbar.add(label) |
353
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
149 self.wysiwyg_button = CheckBox('Wysiwyg edition') |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
150 wysiywgCb = lambda sender: self.setWysiwyg(sender.getChecked()) |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
151 self.wysiwyg_button.addClickListener(wysiywgCb) |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
152 self.toolbar.add(self.wysiwyg_button) |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
153 self.getFlexCellFormatter().setColSpan(self.toolbar_offset + count, 0, 2) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
154 self.setWidget(self.toolbar_offset + count, 0, self.toolbar) |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
155 count += 1 |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
156 |
353
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
157 def setWysiwyg(self, wysiwyg, init=False): |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
158 """Toggle the edition mode between rich content syntax and wysiwyg. |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
159 @param wysiwyg: boolean value |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
160 @param init: set to True to re-init without switching the widgets.""" |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
161 def setWysiwyg(): |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
162 self.wysiwyg = wysiwyg |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
163 if hasattr(self, 'wysiwyg_button'): |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
164 self.wysiwyg_button.setChecked(wysiwyg) |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
165 if not wysiwyg: |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
166 self.display.removeStyleName('richTextWysiwyg') |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
167 |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
168 if init: |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
169 setWysiwyg() |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
170 return |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
171 |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
172 self.getFlexCellFormatter().setColSpan(self.content_offset, 0, 2) |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
173 if wysiwyg: |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
174 def syntaxConvertCb(text): |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
175 self.display.setContent({'text': text}) |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
176 self.textarea.removeFromParent() # XXX: force as it is not always done... |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
177 self.setWidget(self.content_offset, 0, self.display) |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
178 self.display.addStyleName('richTextWysiwyg') |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
179 self.display.edit(True) |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
180 content = self.getContent() |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
181 if content['text'] and content['syntax'] != Const.SYNTAX_XHTML: |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
182 self.host.bridge.call('syntaxConvert', syntaxConvertCb, content['text'], content['syntax'], Const.SYNTAX_XHTML) |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
183 else: |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
184 syntaxConvertCb(content['text']) |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
185 else: |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
186 syntaxConvertCb = lambda text: self.textarea.setText(text) |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
187 text = self.display.getContent()['text'] |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
188 if text and self.toolbar.syntax != Const.SYNTAX_XHTML: |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
189 self.host.bridge.call('syntaxConvert', syntaxConvertCb, text) |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
190 else: |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
191 syntaxConvertCb(text) |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
192 self.setWidget(self.content_offset, 0, self.textarea) |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
193 self.textarea.setWidth('100%') # CSS width doesn't do it, don't know why |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
194 |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
195 setWysiwyg() # do it in the end because it affects self.getContent |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
196 |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
197 def addToolbarButton(self, syntax, key): |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
198 """Add a button with the defined parameters.""" |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
199 button = Button('<img src="%s" class="richTextIcon" />' % |
254
28d3315a8003
browser_side: isolate the basic stuff of RecipientManager in a new class ListManager:
souliane <souliane@mailoo.org>
parents:
234
diff
changeset
|
200 composition.RICH_BUTTONS[key]["icon"]) |
28d3315a8003
browser_side: isolate the basic stuff of RecipientManager in a new class ListManager:
souliane <souliane@mailoo.org>
parents:
234
diff
changeset
|
201 button.setTitle(composition.RICH_BUTTONS[key]["tip"]) |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
202 button.addStyleName('richTextToolButton') |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
203 self.toolbar.add(button) |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
204 |
355
9bb78c09e9fc
browser_side: wysiwyg edition handles the toolbar buttons
souliane <souliane@mailoo.org>
parents:
353
diff
changeset
|
205 def buttonCb(): |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
206 """Generic callback for a toolbar button.""" |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
207 text = self.textarea.getText() |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
208 cursor_pos = self.textarea.getCursorPos() |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
209 selection_length = self.textarea.getSelectionLength() |
355
9bb78c09e9fc
browser_side: wysiwyg edition handles the toolbar buttons
souliane <souliane@mailoo.org>
parents:
353
diff
changeset
|
210 data = composition.RICH_SYNTAXES[syntax][key] |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
211 if selection_length == 0: |
355
9bb78c09e9fc
browser_side: wysiwyg edition handles the toolbar buttons
souliane <souliane@mailoo.org>
parents:
353
diff
changeset
|
212 middle_text = data[1] |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
213 else: |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
214 middle_text = text[cursor_pos:cursor_pos + selection_length] |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
215 self.textarea.setText(text[:cursor_pos] |
355
9bb78c09e9fc
browser_side: wysiwyg edition handles the toolbar buttons
souliane <souliane@mailoo.org>
parents:
353
diff
changeset
|
216 + data[0] |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
217 + middle_text |
355
9bb78c09e9fc
browser_side: wysiwyg edition handles the toolbar buttons
souliane <souliane@mailoo.org>
parents:
353
diff
changeset
|
218 + data[2] |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
219 + text[cursor_pos + selection_length:]) |
355
9bb78c09e9fc
browser_side: wysiwyg edition handles the toolbar buttons
souliane <souliane@mailoo.org>
parents:
353
diff
changeset
|
220 self.textarea.setCursorPos(cursor_pos + len(data[0]) + len(middle_text)) |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
221 self.textarea.setFocus(True) |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
222 |
355
9bb78c09e9fc
browser_side: wysiwyg edition handles the toolbar buttons
souliane <souliane@mailoo.org>
parents:
353
diff
changeset
|
223 def wysiwygCb(): |
9bb78c09e9fc
browser_side: wysiwyg edition handles the toolbar buttons
souliane <souliane@mailoo.org>
parents:
353
diff
changeset
|
224 """Callback for a toolbar button while wysiwyg mode is enabled.""" |
9bb78c09e9fc
browser_side: wysiwyg edition handles the toolbar buttons
souliane <souliane@mailoo.org>
parents:
353
diff
changeset
|
225 data = composition.COMMANDS[key] |
9bb78c09e9fc
browser_side: wysiwyg edition handles the toolbar buttons
souliane <souliane@mailoo.org>
parents:
353
diff
changeset
|
226 |
9bb78c09e9fc
browser_side: wysiwyg edition handles the toolbar buttons
souliane <souliane@mailoo.org>
parents:
353
diff
changeset
|
227 def execCommand(command, arg): |
9bb78c09e9fc
browser_side: wysiwyg edition handles the toolbar buttons
souliane <souliane@mailoo.org>
parents:
353
diff
changeset
|
228 self.display.setFocus(True) |
9bb78c09e9fc
browser_side: wysiwyg edition handles the toolbar buttons
souliane <souliane@mailoo.org>
parents:
353
diff
changeset
|
229 doc().execCommand(command, False, arg.strip() if arg else '') |
9bb78c09e9fc
browser_side: wysiwyg edition handles the toolbar buttons
souliane <souliane@mailoo.org>
parents:
353
diff
changeset
|
230 # use Window.prompt instead of dialog.PromptDialog to not loose the focus |
9bb78c09e9fc
browser_side: wysiwyg edition handles the toolbar buttons
souliane <souliane@mailoo.org>
parents:
353
diff
changeset
|
231 prompt = lambda command, text: execCommand(command, Window.prompt(text)) |
9bb78c09e9fc
browser_side: wysiwyg edition handles the toolbar buttons
souliane <souliane@mailoo.org>
parents:
353
diff
changeset
|
232 if isinstance(data, tuple) or isinstance(data, list): |
9bb78c09e9fc
browser_side: wysiwyg edition handles the toolbar buttons
souliane <souliane@mailoo.org>
parents:
353
diff
changeset
|
233 if data[1]: |
9bb78c09e9fc
browser_side: wysiwyg edition handles the toolbar buttons
souliane <souliane@mailoo.org>
parents:
353
diff
changeset
|
234 prompt(data[0], data[1]) |
9bb78c09e9fc
browser_side: wysiwyg edition handles the toolbar buttons
souliane <souliane@mailoo.org>
parents:
353
diff
changeset
|
235 else: |
9bb78c09e9fc
browser_side: wysiwyg edition handles the toolbar buttons
souliane <souliane@mailoo.org>
parents:
353
diff
changeset
|
236 execCommand(data[0], data[2]) |
9bb78c09e9fc
browser_side: wysiwyg edition handles the toolbar buttons
souliane <souliane@mailoo.org>
parents:
353
diff
changeset
|
237 else: |
9bb78c09e9fc
browser_side: wysiwyg edition handles the toolbar buttons
souliane <souliane@mailoo.org>
parents:
353
diff
changeset
|
238 execCommand(data, False, '') |
9bb78c09e9fc
browser_side: wysiwyg edition handles the toolbar buttons
souliane <souliane@mailoo.org>
parents:
353
diff
changeset
|
239 |
9bb78c09e9fc
browser_side: wysiwyg edition handles the toolbar buttons
souliane <souliane@mailoo.org>
parents:
353
diff
changeset
|
240 button.addClickListener(lambda: wysiwygCb() if self.wysiwyg else buttonCb()) |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
241 |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
242 def getContent(self): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
243 assert(hasattr(self, 'textarea')) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
244 assert(hasattr(self, 'toolbar')) |
353
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
245 if self.wysiwyg: |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
246 content = {'text': self.display.getContent()['text'], 'syntax': Const.SYNTAX_XHTML} |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
247 else: |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
248 content = {'text': self.strproc(self.textarea.getText()), 'syntax': self.toolbar.syntax} |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
249 if hasattr(self, 'title_panel'): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
250 content.update({'title': self.strproc(self.title_panel.getText())}) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
251 return content |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
252 |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
253 def edit(self, edit=False, abort=False, sync=False): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
254 """ |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
255 Remark: the editor must be visible before you call this method. |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
256 @param edit: set to True to edit the content or False to only display it |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
257 @param abort: set to True to cancel the edition and loose the changes. |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
258 If edit and abort are both True, self.abortEdition can be used to ask for a |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
259 confirmation. When edit is False and abort is True, abortion is actually done. |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
260 @param sync: set to True to cancel the edition after the content has been saved somewhere else |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
261 """ |
357
2b5503392fbd
browser_side: small fixes for RichTextEditor
souliane <souliane@mailoo.org>
parents:
356
diff
changeset
|
262 if not (edit and abort): |
2b5503392fbd
browser_side: small fixes for RichTextEditor
souliane <souliane@mailoo.org>
parents:
356
diff
changeset
|
263 self.refresh(edit) # not when we are asking for a confirmation |
2b5503392fbd
browser_side: small fixes for RichTextEditor
souliane <souliane@mailoo.org>
parents:
356
diff
changeset
|
264 BaseTextEditor.edit(self, edit, abort, sync) # after the UI has been refreshed |
353
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
265 if (edit and abort): |
357
2b5503392fbd
browser_side: small fixes for RichTextEditor
souliane <souliane@mailoo.org>
parents:
356
diff
changeset
|
266 return # self.avortEdition is called by BaseTextEditor.edit |
2b5503392fbd
browser_side: small fixes for RichTextEditor
souliane <souliane@mailoo.org>
parents:
356
diff
changeset
|
267 self.setWysiwyg(False, init=True) # after BaseTextEditor (it affects self.getContent) |
353
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
268 if sync: |
ddb909ab5cbc
browser_side: wysiwyg edtion, first steps (do not use the buttons yet)
souliane <souliane@mailoo.org>
parents:
352
diff
changeset
|
269 return |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
270 # the following must NOT be done at each UI refresh! |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
271 content = self._original_content |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
272 if edit: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
273 def getParamCb(syntax): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
274 # set the editable text in the current user-selected syntax |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
275 def syntaxConvertCb(text=None): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
276 if text is not None: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
277 # Important: this also update self._original_content |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
278 content.update({'text': text}) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
279 content.update({'syntax': syntax}) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
280 self.textarea.setText(content['text']) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
281 if hasattr(self, 'title_panel') and 'title' in content: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
282 self.title_panel.setText(content['title']) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
283 self.title_panel.setStackVisible(0, content['title'] != '') |
352
2610443b05a2
browser_side: misc improvements for RichTextEditor to prepare Wysiwyg edition
souliane <souliane@mailoo.org>
parents:
351
diff
changeset
|
284 self.setToolBar(syntax) |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
285 if content['text'] and content['syntax'] != syntax: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
286 self.host.bridge.call('syntaxConvert', syntaxConvertCb, content['text'], content['syntax']) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
287 else: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
288 syntaxConvertCb() |
352
2610443b05a2
browser_side: misc improvements for RichTextEditor to prepare Wysiwyg edition
souliane <souliane@mailoo.org>
parents:
351
diff
changeset
|
289 self.host.bridge.call('asyncGetParamA', getParamCb, composition.PARAM_NAME_SYNTAX, composition.PARAM_KEY_COMPOSITION) |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
290 else: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
291 if not self.initialized: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
292 # set the display text in XHTML only during init because a new MicroblogEntry instance is created after each modification |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
293 text = content['text'] |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
294 if 'title' in content and content['title']: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
295 text = '<h1>%s</h1>%s' % (content['title'], content['text']) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
296 self.display.setContent({'text': text}) |
357
2b5503392fbd
browser_side: small fixes for RichTextEditor
souliane <souliane@mailoo.org>
parents:
356
diff
changeset
|
297 self.display.edit(False) |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
298 |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
299 def setFocus(self, focus): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
300 self.textarea.setFocus(focus) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
301 |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
302 def abortEdition(self, content): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
303 """Ask for confirmation before closing the dialog.""" |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
304 def confirm_cb(answer): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
305 if answer: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
306 self.edit(False, True) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
307 _dialog = ConfirmDialog(confirm_cb, text="Do you really want to %s?" % ("cancel your changes" if self.update_msg else "cancel this message")) |
357
2b5503392fbd
browser_side: small fixes for RichTextEditor
souliane <souliane@mailoo.org>
parents:
356
diff
changeset
|
308 _dialog.cancel_button.setText(_("No")) |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
309 _dialog.show() |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
310 |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
311 |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
312 class RichMessageEditor(RichTextEditor): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
313 """Use the rich text editor for sending messages with extended addressing. |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
314 Recipient panels are on top and data may be synchronized from/to the unibox.""" |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
315 |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
316 @classmethod |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
317 def getOrCreate(cls, host, parent=None, callback=None): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
318 """Get or create the message editor associated to that host. |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
319 Add it to parent if parent is not None, otherwise display it |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
320 in a popup dialog. |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
321 @param host: the host |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
322 @param parent: parent panel (or None to display in a popup). |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
323 @return: the RichTextEditor instance if parent is not None, |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
324 otherwise a popup DialogBox containing the RichTextEditor. |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
325 """ |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
326 if not hasattr(host, 'richtext'): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
327 modifiedCb = lambda content: True |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
328 |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
329 def afterEditCb(content): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
330 if hasattr(host.richtext, 'popup'): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
331 host.richtext.popup.hide() |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
332 else: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
333 host.richtext.setVisible(False) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
334 callback() |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
335 options = ['no_title'] |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
336 style = {'main': 'richMessageEditor', 'textarea': 'richMessageArea'} |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
337 host.richtext = RichMessageEditor(host, None, modifiedCb, afterEditCb, options, style) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
338 |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
339 def add(widget, parent): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
340 if widget.getParent() is not None: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
341 if widget.getParent() != parent: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
342 widget.removeFromParent() |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
343 parent.add(widget) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
344 else: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
345 parent.add(widget) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
346 widget.setVisible(True) |
352
2610443b05a2
browser_side: misc improvements for RichTextEditor to prepare Wysiwyg edition
souliane <souliane@mailoo.org>
parents:
351
diff
changeset
|
347 widget.initialized = False # fake a new creation |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
348 widget.edit(True) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
349 |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
350 if parent is None: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
351 if not hasattr(host.richtext, 'popup'): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
352 host.richtext.popup = DialogBox(autoHide=False, centered=True) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
353 host.richtext.popup.setHTML("Compose your message") |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
354 host.richtext.popup.add(host.richtext) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
355 add(host.richtext, host.richtext.popup) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
356 host.richtext.popup.center() |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
357 else: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
358 add(host.richtext, parent) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
359 return host.richtext.popup if parent is None else host.richtext |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
360 |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
361 def _prepareUI(self, y_offset=0): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
362 """Prepare the UI to host recipients panel, toolbar, text area... |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
363 @param y_offset: Y offset to start from (extra rows on top)""" |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
364 self.recipient_offset = y_offset |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
365 self.recipient_spacer_offset = self.recipient_offset + len(composition.RECIPIENT_TYPES) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
366 RichTextEditor._prepareUI(self, self.recipient_spacer_offset + 1) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
367 |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
368 def refresh(self, edit=None): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
369 """Refresh the UI between edition/display mode |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
370 @param edit: set to True to display the edition mode""" |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
371 if edit is None: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
372 edit = hasattr(self, 'textarea') and self.textarea.getVisible() |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
373 RichTextEditor.refresh(self, edit) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
374 |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
375 for widget in ['recipient', 'recipient_spacer']: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
376 if hasattr(self, widget): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
377 getattr(self, widget).setVisible(edit) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
378 |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
379 if not edit: |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
380 return |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
381 |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
382 if not hasattr(self, 'recipient'): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
383 # recipient types sub-panels are automatically added by the manager |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
384 self.recipient = RecipientManager(self, self.recipient_offset) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
385 self.recipient.createWidgets(title_format="%s: ") |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
386 self.recipient_spacer = HTML('') |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
387 self.recipient_spacer.setStyleName('recipientSpacer') |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
388 self.getFlexCellFormatter().setColSpan(self.recipient_spacer_offset, 0, 2) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
389 self.setWidget(self.recipient_spacer_offset, 0, self.recipient_spacer) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
390 |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
391 if not hasattr(self, 'sync_button'): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
392 self.sync_button = Button("Back to quick box", lambda: self.edit(True, sync=True)) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
393 self.command.insert(self.sync_button, 1) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
394 |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
395 def syncToEditor(self): |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
396 """Synchronize from unibox.""" |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
397 def setContent(target, data): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
398 if hasattr(self, 'recipient'): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
399 self.recipient.setContacts({"To": [target]} if target else {}) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
400 self.setContent({'text': data if data else '', 'syntax': ''}) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
401 self.textarea.setText(data if data else '') |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
402 data, target = self.host.uni_box.getTargetAndData() if self.host.uni_box else (None, None) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
403 setContent(target, data) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
404 |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
405 def __syncToUniBox(self, recipients=None, emptyText=False): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
406 """Synchronize to unibox if a maximum of one recipient is set. |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
407 @return True if the sync could be done, False otherwise""" |
309
05e264e96a1c
browser_side: make unibox optional
souliane <souliane@mailoo.org>
parents:
282
diff
changeset
|
408 if not self.host.uni_box: |
05e264e96a1c
browser_side: make unibox optional
souliane <souliane@mailoo.org>
parents:
282
diff
changeset
|
409 return |
352
2610443b05a2
browser_side: misc improvements for RichTextEditor to prepare Wysiwyg edition
souliane <souliane@mailoo.org>
parents:
351
diff
changeset
|
410 setText = lambda: self.host.uni_box.setText("" if emptyText else self.getContent()['text']) |
281
36ce989c73a5
browser_side: more customizable rich text editor
souliane <souliane@mailoo.org>
parents:
280
diff
changeset
|
411 if not hasattr(self, 'recipient'): |
36ce989c73a5
browser_side: more customizable rich text editor
souliane <souliane@mailoo.org>
parents:
280
diff
changeset
|
412 setText() |
36ce989c73a5
browser_side: more customizable rich text editor
souliane <souliane@mailoo.org>
parents:
280
diff
changeset
|
413 return True |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
414 if recipients is None: |
254
28d3315a8003
browser_side: isolate the basic stuff of RecipientManager in a new class ListManager:
souliane <souliane@mailoo.org>
parents:
234
diff
changeset
|
415 recipients = self.recipient.getContacts() |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
416 target = "" |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
417 # we could eventually allow more in the future |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
418 allowed = 1 |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
419 for key in recipients: |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
420 count = len(recipients[key]) |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
421 if count == 0: |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
422 continue |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
423 allowed -= count |
280
1ccdc34cfb60
browser_side: changes related to the implementation of XEP-0033 (addressing)
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
424 if allowed < 0: |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
425 return False |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
426 # TODO: change this if later more then one recipients are allowed |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
427 target = recipients[key][0] |
281
36ce989c73a5
browser_side: more customizable rich text editor
souliane <souliane@mailoo.org>
parents:
280
diff
changeset
|
428 setText() |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
429 if target == "": |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
430 return True |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
431 if target.startswith("@"): |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
432 _class = panels.MicroblogPanel |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
433 target = None if target == "@@" else target[1:] |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
434 else: |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
435 _class = panels.ChatPanel |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
436 self.host.getOrCreateLiberviaWidget(_class, target) |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
437 return True |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
438 |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
439 def syncFromEditor(self, content): |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
440 """Synchronize to unibox and close the dialog afterward. Display |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
441 a message and leave the dialog open if the sync was not possible.""" |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
442 if self.__syncToUniBox(): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
443 self._afterEditCb(content) |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
444 return |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
445 InfoDialog("Too many recipients", |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
446 "A message with more than one direct recipient (To)," + |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
447 " or with any special recipient (Cc or Bcc), could not be" + |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
448 " stored in the quick box.\n\nPlease finish your composing" + |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
449 " in the rich text editor, and send your message directly" + |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
450 " from here.", Width="400px").center() |
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
451 |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
452 def edit(self, edit=True, abort=False, sync=False): |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
453 if not edit and not abort and not sync: # force sending message even when the text has not been modified |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
454 if not self.__sendMessage(): # message has not been sent (missing information), do nothing |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
455 return |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
456 RichTextEditor.edit(self, edit, abort, sync) |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
457 |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
458 def __sendMessage(self): |
232
0ed09cc0566f
browser_side: added UIs for rich text editor and addressing to multiple recipients
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
459 """Send the message.""" |
254
28d3315a8003
browser_side: isolate the basic stuff of RecipientManager in a new class ListManager:
souliane <souliane@mailoo.org>
parents:
234
diff
changeset
|
460 recipients = self.recipient.getContacts() |
280
1ccdc34cfb60
browser_side: changes related to the implementation of XEP-0033 (addressing)
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
461 targets = [] |
1ccdc34cfb60
browser_side: changes related to the implementation of XEP-0033 (addressing)
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
462 for addr in recipients: |
1ccdc34cfb60
browser_side: changes related to the implementation of XEP-0033 (addressing)
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
463 for recipient in recipients[addr]: |
1ccdc34cfb60
browser_side: changes related to the implementation of XEP-0033 (addressing)
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
464 if recipient.startswith("@"): |
1ccdc34cfb60
browser_side: changes related to the implementation of XEP-0033 (addressing)
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
465 targets.append(("PUBLIC", None, addr) if recipient == "@@" else ("GROUP", recipient[1:], addr)) |
1ccdc34cfb60
browser_side: changes related to the implementation of XEP-0033 (addressing)
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
466 else: |
1ccdc34cfb60
browser_side: changes related to the implementation of XEP-0033 (addressing)
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
467 targets.append(("chat", recipient, addr)) |
270
52e60dd2bc43
browser_side: send rich text to all the "To" recipients (groups and one2one)
souliane <souliane@mailoo.org>
parents:
263
diff
changeset
|
468 # check that we actually have a message target and data |
352
2610443b05a2
browser_side: misc improvements for RichTextEditor to prepare Wysiwyg edition
souliane <souliane@mailoo.org>
parents:
351
diff
changeset
|
469 content = self.getContent() |
2610443b05a2
browser_side: misc improvements for RichTextEditor to prepare Wysiwyg edition
souliane <souliane@mailoo.org>
parents:
351
diff
changeset
|
470 if content['text'] == "" or len(targets) == 0: |
270
52e60dd2bc43
browser_side: send rich text to all the "To" recipients (groups and one2one)
souliane <souliane@mailoo.org>
parents:
263
diff
changeset
|
471 InfoDialog("Missing information", |
52e60dd2bc43
browser_side: send rich text to all the "To" recipients (groups and one2one)
souliane <souliane@mailoo.org>
parents:
263
diff
changeset
|
472 "Some information are missing and the message hasn't been sent.", Width="400px").center() |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
473 return None |
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
474 self.__syncToUniBox(recipients, emptyText=True) |
352
2610443b05a2
browser_side: misc improvements for RichTextEditor to prepare Wysiwyg edition
souliane <souliane@mailoo.org>
parents:
351
diff
changeset
|
475 extra = {'content_rich': content['text']} |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
476 if hasattr(self, 'title_panel'): |
352
2610443b05a2
browser_side: misc improvements for RichTextEditor to prepare Wysiwyg edition
souliane <souliane@mailoo.org>
parents:
351
diff
changeset
|
477 extra.update({'title': content['title']}) |
2610443b05a2
browser_side: misc improvements for RichTextEditor to prepare Wysiwyg edition
souliane <souliane@mailoo.org>
parents:
351
diff
changeset
|
478 self.host.send(targets, content['text'], extra=extra) |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
346
diff
changeset
|
479 return True |
254
28d3315a8003
browser_side: isolate the basic stuff of RecipientManager in a new class ListManager:
souliane <souliane@mailoo.org>
parents:
234
diff
changeset
|
480 |
28d3315a8003
browser_side: isolate the basic stuff of RecipientManager in a new class ListManager:
souliane <souliane@mailoo.org>
parents:
234
diff
changeset
|
481 |
28d3315a8003
browser_side: isolate the basic stuff of RecipientManager in a new class ListManager:
souliane <souliane@mailoo.org>
parents:
234
diff
changeset
|
482 class RecipientManager(ListManager): |
28d3315a8003
browser_side: isolate the basic stuff of RecipientManager in a new class ListManager:
souliane <souliane@mailoo.org>
parents:
234
diff
changeset
|
483 """A manager for sub-panels to set the recipients for each recipient type.""" |
28d3315a8003
browser_side: isolate the basic stuff of RecipientManager in a new class ListManager:
souliane <souliane@mailoo.org>
parents:
234
diff
changeset
|
484 |
324
8131d0ccf21b
browser_side: prepare user input for microblog titles
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
485 def __init__(self, parent, y_offset=0): |
254
28d3315a8003
browser_side: isolate the basic stuff of RecipientManager in a new class ListManager:
souliane <souliane@mailoo.org>
parents:
234
diff
changeset
|
486 # TODO: be sure we also display empty groups and disconnected contacts + their groups |
28d3315a8003
browser_side: isolate the basic stuff of RecipientManager in a new class ListManager:
souliane <souliane@mailoo.org>
parents:
234
diff
changeset
|
487 # store the full list of potential recipients (groups and contacts) |
28d3315a8003
browser_side: isolate the basic stuff of RecipientManager in a new class ListManager:
souliane <souliane@mailoo.org>
parents:
234
diff
changeset
|
488 list_ = [] |
263
d3c734669577
browser_side: improvements for lists and contact groups manager:
souliane <souliane@mailoo.org>
parents:
254
diff
changeset
|
489 list_.append("@@") |
254
28d3315a8003
browser_side: isolate the basic stuff of RecipientManager in a new class ListManager:
souliane <souliane@mailoo.org>
parents:
234
diff
changeset
|
490 list_.extend("@%s" % group for group in parent.host.contact_panel.getGroups()) |
28d3315a8003
browser_side: isolate the basic stuff of RecipientManager in a new class ListManager:
souliane <souliane@mailoo.org>
parents:
234
diff
changeset
|
491 list_.extend(contact for contact in parent.host.contact_panel.getContacts()) |
324
8131d0ccf21b
browser_side: prepare user input for microblog titles
souliane <souliane@mailoo.org>
parents:
323
diff
changeset
|
492 ListManager.__init__(self, parent, composition.RECIPIENT_TYPES, list_, {'y': y_offset}) |
254
28d3315a8003
browser_side: isolate the basic stuff of RecipientManager in a new class ListManager:
souliane <souliane@mailoo.org>
parents:
234
diff
changeset
|
493 |
28d3315a8003
browser_side: isolate the basic stuff of RecipientManager in a new class ListManager:
souliane <souliane@mailoo.org>
parents:
234
diff
changeset
|
494 self.registerPopupMenuPanel(entries=composition.RECIPIENT_TYPES, |
28d3315a8003
browser_side: isolate the basic stuff of RecipientManager in a new class ListManager:
souliane <souliane@mailoo.org>
parents:
234
diff
changeset
|
495 hide=lambda sender, key: self.__children[key]["panel"].isVisible(), |
28d3315a8003
browser_side: isolate the basic stuff of RecipientManager in a new class ListManager:
souliane <souliane@mailoo.org>
parents:
234
diff
changeset
|
496 callback=self.setContactPanelVisible) |