changeset 346:82f9e92379b0

browser_side: move TitlePanel from richtext.py to base_panels.py
author souliane <souliane@mailoo.org>
date Fri, 07 Feb 2014 20:08:28 +0100
parents 2109d7d30ffc
children f1ba38043d78
files browser_side/base_panels.py browser_side/richtext.py
diffstat 2 files changed, 25 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/browser_side/base_panels.py	Wed Feb 05 16:37:31 2014 +0100
+++ b/browser_side/base_panels.py	Fri Feb 07 20:08:28 2014 +0100
@@ -26,6 +26,7 @@
 from pyjamas.ui.HTML import HTML
 from pyjamas.ui.PopupPanel import PopupPanel
 from pyjamas.ui.StackPanel import StackPanel
+from pyjamas.ui.TextArea import TextArea
 from pyjamas.ui.Event import BUTTON_LEFT, BUTTON_MIDDLE, BUTTON_RIGHT
 from pyjamas import DOM
 
@@ -35,6 +36,7 @@
 from tools import html_sanitize, inlineRoot
 
 from sat_frontends.tools.strings import addURLToText
+from sat.core.i18n import _
 
 
 class ChatText(HTMLPanel):
@@ -261,3 +263,25 @@
         self.setStackVisible(index, visible)
         for listener in self.stackListeners:
             listener.onStackChanged(self, index, visible)
+
+
+class TitlePanel(ToggleStackPanel):
+    """A toggle panel to set the message title"""
+    def __init__(self):
+        ToggleStackPanel.__init__(self, Width="100%")
+        self.text_area = TextArea()
+        self.add(self.text_area, _("Title"))
+        self.addStackChangeListener(self)
+
+    def onStackChanged(self, sender, index, visible=None):
+        if visible is None:
+            visible = sender.getWidget(index).getVisible()
+        text = self.text_area.getText()
+        suffix = "" if (visible or not text) else (": %s" % text)
+        sender.setStackText(index, _("Title") + suffix)
+
+    def getText(self):
+        return self.text_area.getText()
+
+    def setText(self, text):
+        self.text_area.setText(text)
--- a/browser_side/richtext.py	Wed Feb 05 16:37:31 2014 +0100
+++ b/browser_side/richtext.py	Fri Feb 07 20:08:28 2014 +0100
@@ -26,11 +26,10 @@
 from pyjamas.ui.HorizontalPanel import HorizontalPanel
 
 from dialog import ConfirmDialog, InfoDialog
-from base_panels import ToggleStackPanel
+from base_panels import TitlePanel
 from list_manager import ListManager
 
 from sat_frontends.tools import composition
-from sat.core.i18n import _
 
 # used for onCloseCallback
 CANCEL, SYNC_NOT_SAVE, SAVE = xrange(0, 3)
@@ -331,19 +330,3 @@
         self.registerPopupMenuPanel(entries=composition.RECIPIENT_TYPES,
                                     hide=lambda sender, key: self.__children[key]["panel"].isVisible(),
                                     callback=self.setContactPanelVisible)
-
-
-class TitlePanel(ToggleStackPanel):
-    """A toggle panel to set the message title"""
-    def __init__(self):
-        ToggleStackPanel.__init__(self, Width="100%")
-        self.text_area = TextArea()
-        self.add(self.text_area, _("Title"))
-        self.addStackChangeListener(self)
-
-    def onStackChanged(self, sender, index, visible=None):
-        if visible is None:
-            visible = sender.getWidget(index).getVisible()
-        text = self.text_area.getText()
-        suffix = "" if (visible or not text) else (": %s" % text)
-        sender.setStackText(index, _("Title") + suffix)