comparison browser_side/panels.py @ 313:5ad70625867a

browser_side: save the unibox panel space when unibox is disabled
author souliane <souliane@mailoo.org>
date Mon, 30 Dec 2013 13:00:41 +0100
parents b4781a350483
children 70ac3067d641
comparison
equal deleted inserted replaced
312:b4781a350483 313:5ad70625867a
74 self.unibox = None 74 self.unibox = None
75 75
76 def setUniBox(self, enable): 76 def setUniBox(self, enable):
77 """Enable or disable the unibox widget. 77 """Enable or disable the unibox widget.
78 @param enable: boolean 78 @param enable: boolean
79 @return: UniBox instance or None if disabled
79 """ 80 """
80 if enable: 81 if enable:
81 self.button = Button ('<img src="media/icons/tango/actions/32/format-text-italic.png" class="richTextIcon"/>') 82 self.button = Button ('<img src="media/icons/tango/actions/32/format-text-italic.png" class="richTextIcon"/>')
82 self.button.setTitle('Open the rich text editor') 83 self.button.setTitle('Open the rich text editor')
83 self.button.addStyleName('uniBoxButton') 84 self.button.addStyleName('uniBoxButton')
85 self.unibox = UniBox(self.host) 86 self.unibox = UniBox(self.host)
86 self.add(self.unibox) 87 self.add(self.unibox)
87 self.setCellWidth(self.unibox, '100%') 88 self.setCellWidth(self.unibox, '100%')
88 self.button.addClickListener(self.openRichTextEditor) 89 self.button.addClickListener(self.openRichTextEditor)
89 self.unibox.addKey("@@: ") 90 self.unibox.addKey("@@: ")
91 return self.unibox
90 else: 92 else:
91 if self.unibox: 93 if self.unibox:
92 self.remove(self.unibox) 94 self.remove(self.unibox)
93 self.unibox = None 95 self.unibox = None
96 return None
94 97
95 def openRichTextEditor(self): 98 def openRichTextEditor(self):
96 """Open the rich text editor.""" 99 """Open the rich text editor."""
97 self.button.setVisible(False) 100 self.button.setVisible(False)
98 self.unibox.setVisible(False) 101 self.unibox.setVisible(False)
1259 # menu 1262 # menu
1260 self.menu = Menu(host) 1263 self.menu = Menu(host)
1261 1264
1262 # unibox 1265 # unibox
1263 self.unibox_panel = UniBoxPanel(host) 1266 self.unibox_panel = UniBoxPanel(host)
1267 self.unibox_panel.setVisible(False)
1264 1268
1265 # status bar 1269 # status bar
1266 status = host.status_panel 1270 status = host.status_panel
1267 1271
1268 # contacts 1272 # contacts
1320 tab_bar_h = 0 1324 tab_bar_h = 0
1321 else: 1325 else:
1322 tab_bar_h = _elts.item(0).offsetHeight 1326 tab_bar_h = _elts.item(0).offsetHeight
1323 ideal_height = Window.getClientHeight() - tab_bar_h 1327 ideal_height = Window.getClientHeight() - tab_bar_h
1324 self.setHeight("%s%s" % (ideal_height, "px")) 1328 self.setHeight("%s%s" % (ideal_height, "px"))
1329
1330 def setUniBoxPanel(self, enable):
1331 """Enable or disable the unibox
1332 @param enable: boolean
1333 @return: UniBox instance or None if disabled
1334 """
1335 self.unibox_panel.setVisible(enable)
1336 return self.unibox_panel.setUniBox(enable)
1325 1337
1326 1338
1327 class PopupMenuPanel(PopupPanel): 1339 class PopupMenuPanel(PopupPanel):
1328 """This implementation of a popup menu (context menu) allow you to assign 1340 """This implementation of a popup menu (context menu) allow you to assign
1329 two special methods which are common to all the items, in order to hide 1341 two special methods which are common to all the items, in order to hide