Mercurial > libervia-web
comparison browser_side/richtext.py @ 309:05e264e96a1c
browser_side: make unibox optional
author | souliane <souliane@mailoo.org> |
---|---|
date | Sun, 29 Dec 2013 23:07:28 +0100 |
parents | ae3ec654836d |
children | 462a0a8894e3 |
comparison
equal
deleted
inserted
replaced
308:0ca441ba4317 | 309:05e264e96a1c |
---|---|
69 if not self.no_main_style: | 69 if not self.no_main_style: |
70 self.addStyleName('richTextEditor') | 70 self.addStyleName('richTextEditor') |
71 | 71 |
72 self._parent = parent | 72 self._parent = parent |
73 self._on_close_callback = onCloseCallback | 73 self._on_close_callback = onCloseCallback |
74 self.original_text = '' | |
74 | 75 |
75 if not self.no_recipient: | 76 if not self.no_recipient: |
76 # recipient types sub-panels are automatically added by the manager | 77 # recipient types sub-panels are automatically added by the manager |
77 self.recipient = RecipientManager(self) | 78 self.recipient = RecipientManager(self) |
78 self.recipient.createWidgets(title_format="%s: ") | 79 self.recipient.createWidgets(title_format="%s: ") |
207 | 208 |
208 button.addClickListener(button_callback) | 209 button.addClickListener(button_callback) |
209 | 210 |
210 def syncFromUniBox(self): | 211 def syncFromUniBox(self): |
211 """Synchronize from unibox.""" | 212 """Synchronize from unibox.""" |
213 if not self.host.uni_box: | |
214 return | |
212 data, target = self.host.uni_box.getTargetAndData() | 215 data, target = self.host.uni_box.getTargetAndData() |
213 if hasattr(self, 'recipient'): | 216 if hasattr(self, 'recipient'): |
214 self.recipient.setContacts({"To": [target]} if target else {}) | 217 self.recipient.setContacts({"To": [target]} if target else {}) |
215 self.textarea.setText(data if data else "") | 218 self.textarea.setText(data if data else "") |
216 | 219 |
218 """Synchronize to unibox if a maximum of one recipient is set. | 221 """Synchronize to unibox if a maximum of one recipient is set. |
219 @return True if the sync could be done, False otherwise""" | 222 @return True if the sync could be done, False otherwise""" |
220 def setText(): | 223 def setText(): |
221 self.host.uni_box.setText("" if emptyText else self.textarea.getText()) | 224 self.host.uni_box.setText("" if emptyText else self.textarea.getText()) |
222 | 225 |
226 if not self.host.uni_box: | |
227 return | |
223 if not hasattr(self, 'recipient'): | 228 if not hasattr(self, 'recipient'): |
224 setText() | 229 setText() |
225 return True | 230 return True |
226 if recipients is None: | 231 if recipients is None: |
227 recipients = self.recipient.getContacts() | 232 recipients = self.recipient.getContacts() |
249 self.host.getOrCreateLiberviaWidget(_class, target) | 254 self.host.getOrCreateLiberviaWidget(_class, target) |
250 return True | 255 return True |
251 | 256 |
252 def cancelWithoutSaving(self): | 257 def cancelWithoutSaving(self): |
253 """Ask for confirmation before closing the dialog.""" | 258 """Ask for confirmation before closing the dialog.""" |
254 if self.update_msg and self.original_text and self.textarea.getText() == self.original_text: | 259 if self.update_msg and self.textarea.getText() == self.original_text: |
255 self.__close(CANCEL) | 260 self.__close(CANCEL) |
256 return | 261 return |
257 | 262 |
258 def confirm_cb(answer): | 263 def confirm_cb(answer): |
259 if answer: | 264 if answer: |