comparison browser_side/base_panels.py @ 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 44491e963eee
children f1ba38043d78
comparison
equal deleted inserted replaced
345:2109d7d30ffc 346:82f9e92379b0
24 from pyjamas.ui.HTMLPanel import HTMLPanel 24 from pyjamas.ui.HTMLPanel import HTMLPanel
25 from pyjamas.ui.Button import Button 25 from pyjamas.ui.Button import Button
26 from pyjamas.ui.HTML import HTML 26 from pyjamas.ui.HTML import HTML
27 from pyjamas.ui.PopupPanel import PopupPanel 27 from pyjamas.ui.PopupPanel import PopupPanel
28 from pyjamas.ui.StackPanel import StackPanel 28 from pyjamas.ui.StackPanel import StackPanel
29 from pyjamas.ui.TextArea import TextArea
29 from pyjamas.ui.Event import BUTTON_LEFT, BUTTON_MIDDLE, BUTTON_RIGHT 30 from pyjamas.ui.Event import BUTTON_LEFT, BUTTON_MIDDLE, BUTTON_RIGHT
30 from pyjamas import DOM 31 from pyjamas import DOM
31 32
32 from datetime import datetime 33 from datetime import datetime
33 from time import time 34 from time import time
34 35
35 from tools import html_sanitize, inlineRoot 36 from tools import html_sanitize, inlineRoot
36 37
37 from sat_frontends.tools.strings import addURLToText 38 from sat_frontends.tools.strings import addURLToText
39 from sat.core.i18n import _
38 40
39 41
40 class ChatText(HTMLPanel): 42 class ChatText(HTMLPanel):
41 43
42 def __init__(self, timestamp, nick, mymess, msg, xhtml=None): 44 def __init__(self, timestamp, nick, mymess, msg, xhtml=None):
259 return 261 return
260 visible = not self.getWidget(index).getVisible() 262 visible = not self.getWidget(index).getVisible()
261 self.setStackVisible(index, visible) 263 self.setStackVisible(index, visible)
262 for listener in self.stackListeners: 264 for listener in self.stackListeners:
263 listener.onStackChanged(self, index, visible) 265 listener.onStackChanged(self, index, visible)
266
267
268 class TitlePanel(ToggleStackPanel):
269 """A toggle panel to set the message title"""
270 def __init__(self):
271 ToggleStackPanel.__init__(self, Width="100%")
272 self.text_area = TextArea()
273 self.add(self.text_area, _("Title"))
274 self.addStackChangeListener(self)
275
276 def onStackChanged(self, sender, index, visible=None):
277 if visible is None:
278 visible = sender.getWidget(index).getVisible()
279 text = self.text_area.getText()
280 suffix = "" if (visible or not text) else (": %s" % text)
281 sender.setStackText(index, _("Title") + suffix)
282
283 def getText(self):
284 return self.text_area.getText()
285
286 def setText(self, text):
287 self.text_area.setText(text)