Mercurial > libervia-web
view src/browser/sat_browser/base_widget.py @ 656:4dbd99de3aaa frontends_multi_profiles
browser_side: only display "+" button when the tab bar contains only 1 tab, and display it over the contact list to not use vertical space
author | souliane <souliane@mailoo.org> |
---|---|
date | Fri, 27 Feb 2015 13:00:04 +0100 |
parents | 6d3142b782c3 |
children | 849ffb24d5bf |
line wrap: on
line source
#!/usr/bin/python # -*- coding: utf-8 -*- # Libervia: a Salut à Toi frontend # Copyright (C) 2011, 2012, 2013, 2014 Jérôme Poisson <goffi@goffi.org> # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import pyjd # this is dummy in pyjs from sat.core.log import getLogger log = getLogger(__name__) import base_menu ### Exceptions ### class NoLiberviaWidgetException(Exception): """A Libervia widget was expected""" pass ### Menus ### class WidgetMenuBar(base_menu.GenericMenuBar): ITEM_TPL = "<img src='media/icons/misc/%s.png' />" def __init__(self, parent, host, vertical=False, styles=None): """ @param parent (Widget): LiberviaWidget, or instance of another class implementing the method addMenus @param host (SatWebFrontend) @param vertical (bool): if True, set the menu vertically @param styles (dict): optional styles dict """ menu_styles = {'menu_bar': 'widgetHeader_buttonGroup'} if styles: menu_styles.update(styles) base_menu.GenericMenuBar.__init__(self, host, vertical=vertical, styles=menu_styles) # regroup all the dynamic menu categories in a sub-menu sub_menu = WidgetSubMenuBar(host, vertical=True) try: parent.addMenus(sub_menu) except (AttributeError, TypeError): # FIXME: pyjamas can throw a TypeError depending on compilation options pass else: if len(sub_menu.getCategories()) > 0: self.addCategory('', '', 'plugins', sub_menu) @classmethod def getCategoryHTML(cls, menu_name_i18n, type_): return cls.ITEM_TPL % type_ class WidgetSubMenuBar(base_menu.GenericMenuBar): def __init__(self, host, vertical=True): """ @param host (SatWebFrontend) @param vertical (bool): if True, set the menu vertically """ base_menu.GenericMenuBar.__init__(self, host, vertical=vertical, flat_level=1) @classmethod def getCategoryHTML(cls, menu_name_i18n, type_): return menu_name_i18n