Mercurial > libervia-web
view src/browser/sat_browser/base_widget.py @ 648:6d3142b782c3 frontends_multi_profiles
browser_side: classes reorganisation:
- moved widgets in dedicated modules (base, contact, editor, libervia) and a widget module for single classes
- same thing for panels (base, main, contact)
- libervia_widget mix main panels and widget and drag n drop for technical reasons (see comments)
- renamed WebPanel to WebWidget
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 26 Feb 2015 18:10:54 +0100 |
parents | e0021d571eef |
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