comparison src/browser/sat_browser/blog.py @ 648:6d3142b782c3 frontends_multi_profiles

browser_side: classes reorganisation: - moved widgets in dedicated modules (base, contact, editor, libervia) and a widget module for single classes - same thing for panels (base, main, contact) - libervia_widget mix main panels and widget and drag n drop for technical reasons (see comments) - renamed WebPanel to WebWidget
author Goffi <goffi@goffi.org>
date Thu, 26 Feb 2015 18:10:54 +0100
parents 63697f082e8a
children 2df91d0308ac
comparison
equal deleted inserted replaced
647:e0021d571eef 648:6d3142b782c3
39 39
40 from datetime import datetime 40 from datetime import datetime
41 from time import time 41 from time import time
42 42
43 import html_tools 43 import html_tools
44 import base_panels
45 import dialog 44 import dialog
46 import base_widget
47 import richtext 45 import richtext
46 import editor_widget
47 import libervia_widget
48 from constants import Const as C 48 from constants import Const as C
49 from sat_frontends.quick_frontend import quick_widgets 49 from sat_frontends.quick_frontend import quick_widgets
50 from sat_frontends.tools import jid 50 from sat_frontends.tools import jid
51 51
52 # TODO: at some point we should decide which behaviors to keep and remove these two constants 52 # TODO: at some point we should decide which behaviors to keep and remove these two constants
231 options = ['read_only'] 231 options = ['read_only']
232 else: 232 else:
233 options = [] if self.empty else ['update_msg'] 233 options = [] if self.empty else ['update_msg']
234 self.bubble = richtext.RichTextEditor(self._blog_panel.host, content, self.__modifiedCb, self.__afterEditCb, options) 234 self.bubble = richtext.RichTextEditor(self._blog_panel.host, content, self.__modifiedCb, self.__afterEditCb, options)
235 else: # assume raw text message have no title 235 else: # assume raw text message have no title
236 self.bubble = base_panels.LightTextEditor(content, self.__modifiedCb, self.__afterEditCb, options={'no_xhtml': True}) 236 self.bubble = editor_widget.LightTextEditor(content, self.__modifiedCb, self.__afterEditCb, options={'no_xhtml': True})
237 self.bubble.addStyleName("bubble") 237 self.bubble.addStyleName("bubble")
238 try: 238 try:
239 self.toggle_syntax_button.removeFromParent() 239 self.toggle_syntax_button.removeFromParent()
240 except (AttributeError, TypeError): 240 except (AttributeError, TypeError):
241 pass 241 pass
353 dialog.ConfirmDialog(confirm_cb, text=_("Do you really want to lose the title and text formatting?")).show() 353 dialog.ConfirmDialog(confirm_cb, text=_("Do you really want to lose the title and text formatting?")).show()
354 else: 354 else:
355 self._blog_panel.host.bridge.call('syntaxConvert', setBubble, text, C.SYNTAX_TEXT, C.SYNTAX_XHTML) 355 self._blog_panel.host.bridge.call('syntaxConvert', setBubble, text, C.SYNTAX_TEXT, C.SYNTAX_XHTML)
356 356
357 357
358 class MicroblogPanel(quick_widgets.QuickWidget, base_widget.LiberviaWidget): 358 class MicroblogPanel(quick_widgets.QuickWidget, libervia_widget.LiberviaWidget):
359 warning_msg_public = "This message will be <b>PUBLIC</b> and everybody will be able to see it, even people you don't know" 359 warning_msg_public = "This message will be <b>PUBLIC</b> and everybody will be able to see it, even people you don't know"
360 warning_msg_group = "This message will be published for all the people of the group <span class='warningTarget'>%s</span>" 360 warning_msg_group = "This message will be published for all the people of the group <span class='warningTarget'>%s</span>"
361 # FIXME: all the generic parts must be moved to quick_frontends 361 # FIXME: all the generic parts must be moved to quick_frontends
362 362
363 def __init__(self, host, accepted_groups, profiles=None): 363 def __init__(self, host, accepted_groups, profiles=None):
365 365
366 @param accepted_groups: groups displayed in this panel, if empty, show all microblogs from all contacts 366 @param accepted_groups: groups displayed in this panel, if empty, show all microblogs from all contacts
367 """ 367 """
368 self.setAcceptedGroup(accepted_groups) 368 self.setAcceptedGroup(accepted_groups)
369 quick_widgets.QuickWidget.__init__(self, host, self.target, C.PROF_KEY_NONE) 369 quick_widgets.QuickWidget.__init__(self, host, self.target, C.PROF_KEY_NONE)
370 base_widget.LiberviaWidget.__init__(self, host, ", ".join(accepted_groups), selectable=True) 370 libervia_widget.LiberviaWidget.__init__(self, host, ", ".join(accepted_groups), selectable=True)
371 self.entries = {} 371 self.entries = {}
372 self.comments = {} 372 self.comments = {}
373 self.selected_entry = None 373 self.selected_entry = None
374 self.vpanel = VerticalPanel() 374 self.vpanel = VerticalPanel()
375 self.vpanel.setStyleName('microblogPanel') 375 self.vpanel.setStyleName('microblogPanel')
733 if self.host.contact_lists[self.profile].isEntityInGroup(jid_, group): 733 if self.host.contact_lists[self.profile].isEntityInGroup(jid_, group):
734 return True 734 return True
735 return False 735 return False
736 736
737 737
738 base_widget.LiberviaWidget.addDropKey("GROUP", MicroblogPanel.onGroupDrop) 738 libervia_widget.LiberviaWidget.addDropKey("GROUP", MicroblogPanel.onGroupDrop)
739 739
740 # Needed for the drop keys to not be mixed between meta panel and panel for "Contacts" group 740 # Needed for the drop keys to not be mixed between meta panel and panel for "Contacts" group
741 base_widget.LiberviaWidget.addDropKey("CONTACT_TITLE", lambda host, item: MicroblogPanel.onGroupDrop(host, None)) 741 libervia_widget.LiberviaWidget.addDropKey("CONTACT_TITLE", lambda host, item: MicroblogPanel.onGroupDrop(host, None))