Mercurial > libervia-web
comparison src/browser/sat_browser/base_widget.py @ 502:4aa627b059df
browser_side: categories of the menus can be "flattened":
- add the parameter "flat_level" to GenericMenuBar
- the items of flattened sub-menus are displayed in the parent menu
XXX: the implementation covers the current needs but is not fully completed:
- the flattened categories of all levels are displayed the same way
- items of flattened categories are appended to the parent menus instead of being inserted
author | souliane <souliane@mailoo.org> |
---|---|
date | Wed, 13 Aug 2014 15:06:40 +0200 |
parents | 60be99de3808 |
children | db3436c85fb1 |
comparison
equal
deleted
inserted
replaced
501:b483f1c88b7c | 502:4aa627b059df |
---|---|
172 def __init__(self, parent, host, vertical=False): | 172 def __init__(self, parent, host, vertical=False): |
173 styles = {'menu_bar': 'widgetHeader_buttonGroup'} | 173 styles = {'menu_bar': 'widgetHeader_buttonGroup'} |
174 base_menu.GenericMenuBar.__init__(self, host, vertical=vertical, styles=styles) | 174 base_menu.GenericMenuBar.__init__(self, host, vertical=vertical, styles=styles) |
175 | 175 |
176 # regroup all the dynamic menu categories in a sub-menu | 176 # regroup all the dynamic menu categories in a sub-menu |
177 item = WidgetSubMenuBar(host, vertical=True) | 177 sub_menu = WidgetSubMenuBar(host, vertical=True) |
178 parent.addMenus(item) | 178 parent.addMenus(sub_menu) |
179 if len(item.getCategories()) > 0: | 179 if len(sub_menu.getCategories()) > 0: |
180 self.addCategory('', '', 'plugins', item) | 180 self.addMenuItem('', '', 'plugins', sub_menu) |
181 | 181 |
182 @classmethod | 182 @classmethod |
183 def getCategoryHTML(cls, type_, menu_name_i18n): | 183 def getCategoryHTML(cls, menu_name_i18n, type_): |
184 return cls.ITEM_TPL % type_ | 184 return cls.ITEM_TPL % type_ |
185 | 185 |
186 | 186 |
187 class WidgetSubMenuBar(base_menu.GenericMenuBar): | 187 class WidgetSubMenuBar(base_menu.GenericMenuBar): |
188 | 188 |
189 def __init__(self, host, vertical=True): | 189 def __init__(self, host, vertical=True): |
190 base_menu.GenericMenuBar.__init__(self, host, vertical=vertical) | 190 base_menu.GenericMenuBar.__init__(self, host, vertical=vertical, flat_level=1) |
191 | 191 |
192 @classmethod | 192 @classmethod |
193 def getCategoryHTML(cls, type_, menu_name_i18n): | 193 def getCategoryHTML(cls, menu_name_i18n, type_): |
194 return menu_name_i18n | 194 return menu_name_i18n |
195 | 195 |
196 | 196 |
197 class WidgetHeader(AbsolutePanel, LiberviaDragWidget): | 197 class WidgetHeader(AbsolutePanel, LiberviaDragWidget): |
198 | 198 |