Mercurial > libervia-web
diff src/browser/sat_browser/richtext.py @ 679:a90cc8fc9605
merged branch frontends_multi_profiles
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 18 Mar 2015 16:15:18 +0100 |
parents | 6d3142b782c3 |
children | 9877607c719a |
line wrap: on
line diff
--- a/src/browser/sat_browser/richtext.py Thu Feb 05 12:05:32 2015 +0100 +++ b/src/browser/sat_browser/richtext.py Wed Mar 18 16:15:18 2015 +0100 @@ -34,13 +34,15 @@ from constants import Const as C import dialog -import base_panels +import base_panel +import editor_widget import list_manager import html_tools -import panels +import blog +import chat -class RichTextEditor(base_panels.BaseTextEditor, FlexTable): +class RichTextEditor(editor_widget.BaseTextEditor, FlexTable): """Panel for the rich text editor.""" def __init__(self, host, content=None, modifiedCb=None, afterEditCb=None, options=None, style=None): @@ -51,6 +53,7 @@ @param afterEditCb: method to be called when the edition is done @param options: list of UI options (see self.readOptions) """ + FlexTable.__init__(self) # FIXME self.host = host self._debug = False # TODO: don't forget to set it False before commit self.wysiwyg = False @@ -62,7 +65,7 @@ if isinstance(style, dict): self.style.update(style) self._prepareUI() - base_panels.BaseTextEditor.__init__(self, content, None, modifiedCb, afterEditCb) + editor_widget.BaseTextEditor.__init__(self, content, None, modifiedCb, afterEditCb) def __readOptions(self, options): """Set the internal flags according to the given options.""" @@ -84,13 +87,13 @@ else: self.title_offset = self.toolbar_offset = self.content_offset = y_offset self.command_offset = self.content_offset + 1 - FlexTable.__init__(self, self.command_offset + (0 if self.no_command else 1), 2) + # FlexTable.__init__(self, rowspan=self.command_offset + (0 if self.no_command else 1), colspan=2) # FIXME self.addStyleName(self.style['main']) def addEditListener(self, listener): """Add a method to be called whenever the text is edited. @param listener: method taking two arguments: sender, keycode""" - base_panels.BaseTextEditor.addEditListener(self, listener) + editor_widget.BaseTextEditor.addEditListener(self, listener) if hasattr(self, 'display'): self.display.addEditListener(listener) @@ -107,7 +110,7 @@ if hasattr(self, 'toolbar'): self.toolbar.setVisible(False) if not hasattr(self, 'display'): - self.display = base_panels.HTMLTextEditor(options={'enhance_display': False, 'listen_keyboard': False}) # for display mode + self.display = editor_widget.HTMLTextEditor(options={'enhance_display': False, 'listen_keyboard': False}) # for display mode for listener in self.edit_listeners: self.display.addEditListener(listener) if not self.read_only and not hasattr(self, 'textarea'): @@ -124,7 +127,7 @@ return if not self.no_title and not hasattr(self, 'title_panel'): - self.title_panel = base_panels.TitlePanel() + self.title_panel = base_panel.TitlePanel() self.title_panel.addStyleName(self.style['title']) self.getFlexCellFormatter().setColSpan(self.title_offset, 0, 2) self.setWidget(self.title_offset, 0, self.title_panel) @@ -174,14 +177,14 @@ self.wysiwyg = wysiwyg try: self.wysiwyg_button.setChecked(wysiwyg) - except TypeError: + except (AttributeError, TypeError): pass try: if wysiwyg: self.syntax_label.addStyleName('transparent') else: self.syntax_label.removeStyleName('transparent') - except TypeError: + except (AttributeError, TypeError): pass if not wysiwyg: self.display.removeStyleName('richTextWysiwyg') @@ -284,10 +287,10 @@ """ if not (edit and abort): self.refresh(edit) # not when we are asking for a confirmation - base_panels.BaseTextEditor.edit(self, edit, abort, sync) # after the UI has been refreshed + editor_widget.BaseTextEditor.edit(self, edit, abort, sync) # after the UI has been refreshed if (edit and abort): - return # self.abortEdition is called by base_panels.BaseTextEditor.edit - self.setWysiwyg(False, init=True) # after base_panels.BaseTextEditor (it affects self.getContent) + return # self.abortEdition is called by editor_widget.BaseTextEditor.edit + self.setWysiwyg(False, init=True) # after editor_widget.BaseTextEditor (it affects self.getContent) if sync: return # the following must NOT be done at each UI refresh! @@ -317,7 +320,7 @@ self.display.edit(False) def setDisplayContent(self): - """Set the content of the base_panels.HTMLTextEditor which is used for display/wysiwyg""" + """Set the content of the editor_widget.HTMLTextEditor which is used for display/wysiwyg""" content = self._original_content text = content['text'] if 'title' in content and content['title']: @@ -440,7 +443,7 @@ setText() return True if recipients is None: - recipients = self.recipient.getContacts() + recipients = self.recipient.getItemsByKey() target = "" # we could eventually allow more in the future allowed = 1 @@ -457,11 +460,11 @@ if target == "": return True if target.startswith("@"): - _class = panels.MicroblogPanel + _class = blog.MicroblogPanel target = None if target == "@@" else target[1:] else: - _class = panels.ChatPanel - self.host.getOrCreateLiberviaWidget(_class, {'item': target}) + _class = chat.Chat + self.host.displayWidget(_class, target) return True def syncFromEditor(self, content): @@ -485,7 +488,7 @@ def __sendMessage(self): """Send the message.""" - recipients = self.recipient.getContacts() + recipients = self.recipient.getItemsByKey() targets = [] for addr in recipients: for recipient in recipients[addr]: @@ -516,7 +519,7 @@ list_ = [] list_.append("@@") list_.extend("@%s" % group for group in parent.host.contact_panel.getGroups()) - list_.extend(contact for contact in parent.host.contact_panel.getContacts()) + list_.extend(contact for contact in parent.host.contact_list.roster_entities) list_manager.ListManager.__init__(self, parent, composition.RECIPIENT_TYPES, list_, {'y': y_offset}) self.registerPopupMenuPanel(entries=composition.RECIPIENT_TYPES,