Mercurial > libervia-web
comparison src/browser/sat_browser/base_widget.py @ 536:048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
author | souliane <souliane@mailoo.org> |
---|---|
date | Sun, 07 Sep 2014 16:40:33 +0200 |
parents | 4c6d7db9b45c |
children | d02335553b5d |
comparison
equal
deleted
inserted
replaced
535:331cb6ea0235 | 536:048ae7314156 |
---|---|
21 from sat.core.log import getLogger | 21 from sat.core.log import getLogger |
22 log = getLogger(__name__) | 22 log = getLogger(__name__) |
23 from pyjamas.ui.SimplePanel import SimplePanel | 23 from pyjamas.ui.SimplePanel import SimplePanel |
24 from pyjamas.ui.AbsolutePanel import AbsolutePanel | 24 from pyjamas.ui.AbsolutePanel import AbsolutePanel |
25 from pyjamas.ui.VerticalPanel import VerticalPanel | 25 from pyjamas.ui.VerticalPanel import VerticalPanel |
26 from pyjamas.ui.HorizontalPanel import HorizontalPanel | |
26 from pyjamas.ui.ScrollPanel import ScrollPanel | 27 from pyjamas.ui.ScrollPanel import ScrollPanel |
27 from pyjamas.ui.FlexTable import FlexTable | 28 from pyjamas.ui.FlexTable import FlexTable |
28 from pyjamas.ui.TabPanel import TabPanel | 29 from pyjamas.ui.TabPanel import TabPanel |
29 from pyjamas.ui.HTMLPanel import HTMLPanel | 30 from pyjamas.ui.HTMLPanel import HTMLPanel |
30 from pyjamas.ui.Label import Label | 31 from pyjamas.ui.Label import Label |
197 return menu_name_i18n | 198 return menu_name_i18n |
198 | 199 |
199 | 200 |
200 class WidgetHeader(AbsolutePanel, LiberviaDragWidget): | 201 class WidgetHeader(AbsolutePanel, LiberviaDragWidget): |
201 | 202 |
202 def __init__(self, parent, host, title): | 203 def __init__(self, parent, host, title, info=None): |
204 """ | |
205 @param parent (LiberviaWidget): LiberWidget instance | |
206 @param host (SatWebFrontend): SatWebFrontend instance | |
207 @param title (Widget): text widget instance | |
208 @param info (Widget): text widget instance | |
209 """ | |
203 AbsolutePanel.__init__(self) | 210 AbsolutePanel.__init__(self) |
204 self.add(title) | 211 self.add(title) |
205 button_group_wrapper = SimplePanel() | 212 if info: |
213 # FIXME: temporary design to display the info near the menu | |
214 button_group_wrapper = HorizontalPanel() | |
215 button_group_wrapper.add(info) | |
216 else: | |
217 button_group_wrapper = SimplePanel() | |
206 button_group_wrapper.setStyleName('widgetHeader_buttonsWrapper') | 218 button_group_wrapper.setStyleName('widgetHeader_buttonsWrapper') |
207 button_group = WidgetMenuBar(parent, host) | 219 button_group = WidgetMenuBar(parent, host) |
208 button_group.addItem('<img src="media/icons/misc/settings.png"/>', True, base_menu.MenuCmd(parent, 'onSetting')) | 220 button_group.addItem('<img src="media/icons/misc/settings.png"/>', True, base_menu.MenuCmd(parent, 'onSetting')) |
209 button_group.addItem('<img src="media/icons/misc/close.png"/>', True, base_menu.MenuCmd(parent, 'onClose')) | 221 button_group.addItem('<img src="media/icons/misc/close.png"/>', True, base_menu.MenuCmd(parent, 'onClose')) |
210 button_group_wrapper.setWidget(button_group) | 222 button_group_wrapper.add(button_group) |
211 self.add(button_group_wrapper) | 223 self.add(button_group_wrapper) |
212 self.addStyleName('widgetHeader') | 224 self.addStyleName('widgetHeader') |
213 LiberviaDragWidget.__init__(self, "", "WIDGET", parent) | 225 LiberviaDragWidget.__init__(self, "", "WIDGET", parent) |
214 | 226 |
215 | 227 |
216 class LiberviaWidget(DropCell, VerticalPanel, ClickHandler): | 228 class LiberviaWidget(DropCell, VerticalPanel, ClickHandler): |
217 """Libervia's widget which can replace itself with a dropped widget on DnD""" | 229 """Libervia's widget which can replace itself with a dropped widget on DnD""" |
218 | 230 |
219 def __init__(self, host, title='', selectable=False): | 231 def __init__(self, host, title='', info='', selectable=False): |
220 """Init the widget | 232 """Init the widget |
221 @param host: SatWebFrontend object | 233 @param host (SatWebFrontend): SatWebFrontend instance |
222 @param title: title show in the header of the widget | 234 @param title (str): title shown in the header of the widget |
223 @param selectable: True is widget can be selected by user""" | 235 @param info (str): info shown in the header of the widget |
236 @param selectable (bool): True is widget can be selected by user""" | |
224 VerticalPanel.__init__(self) | 237 VerticalPanel.__init__(self) |
225 DropCell.__init__(self, host) | 238 DropCell.__init__(self, host) |
226 ClickHandler.__init__(self) | 239 ClickHandler.__init__(self) |
227 self.__selectable = selectable | 240 self.__selectable = selectable |
228 self.__title_id = HTMLPanel.createUniqueId() | 241 self.__title_id = HTMLPanel.createUniqueId() |
229 self.__setting_button_id = HTMLPanel.createUniqueId() | 242 self.__setting_button_id = HTMLPanel.createUniqueId() |
230 self.__close_button_id = HTMLPanel.createUniqueId() | 243 self.__close_button_id = HTMLPanel.createUniqueId() |
231 self.__title = Label(title) | 244 self.__title = Label(title) |
232 self.__title.setStyleName('widgetHeader_title') | 245 self.__title.setStyleName('widgetHeader_title') |
246 if info: | |
247 self.__info = Label(info) | |
248 self.__info.setStyleName('widgetHeader_info') | |
249 else: | |
250 self.__info = None | |
233 self._close_listeners = [] | 251 self._close_listeners = [] |
234 header = WidgetHeader(self, host, self.__title) | 252 header = WidgetHeader(self, host, self.__title, self.__info) |
235 self.add(header) | 253 self.add(header) |
236 self.setSize('100%', '100%') | 254 self.setSize('100%', '100%') |
237 self.addStyleName('widget') | 255 self.addStyleName('widget') |
238 if self.__selectable: | 256 if self.__selectable: |
239 self.addClickListener(self) | 257 self.addClickListener(self) |
367 | 385 |
368 def setTitle(self, text): | 386 def setTitle(self, text): |
369 """change the title in the header of the widget | 387 """change the title in the header of the widget |
370 @param text: text of the new title""" | 388 @param text: text of the new title""" |
371 self.__title.setText(text) | 389 self.__title.setText(text) |
390 | |
391 def setHeaderInfo(self, text): | |
392 """change the info in the header of the widget | |
393 @param text: text of the new title""" | |
394 try: | |
395 self.__info.setText(text) | |
396 except AttributeError: | |
397 log.error("LiberviaWidget.setInfo: info widget has not been initialized!") | |
372 | 398 |
373 def isSelectable(self): | 399 def isSelectable(self): |
374 return self.__selectable | 400 return self.__selectable |
375 | 401 |
376 def setSelectable(self, selectable): | 402 def setSelectable(self, selectable): |