diff src/browser/sat_browser/base_widget.py @ 589:a5019e62c3e9 frontends_multi_profiles

browser side: big refactoring to base Libervia on QuickFrontend, first draft: /!\ not finished, partially working and highly instable - add collections module with an OrderedDict like class - SatWebFrontend inherit from QuickApp - general sat_frontends tools.jid module is used - bridge/json methods have moved to json module - UniBox is partially removed (should be totally removed before merge to trunk) - Signals are now register with the generic registerSignal method (which is called mainly in QuickFrontend) - the generic getOrCreateWidget method from QuickWidgetsManager is used instead of Libervia's specific methods - all Widget are now based more or less directly on QuickWidget - with the new QuickWidgetsManager.getWidgets method, it's no more necessary to check all widgets which are instance of a particular class - ChatPanel and related moved to chat module - MicroblogPanel and related moved to blog module - global and overcomplicated send method has been disabled: each class should manage its own sending - for consistency with other frontends, former ContactPanel has been renamed to ContactList and vice versa - for the same reason, ChatPanel has been renamed to Chat - for compatibility with QuickFrontend, a fake profile is used in several places, it is set to C.PROF_KEY_NONE (real profile is managed server side for obvious security reasons) - changed default url for web panel to SàT website, and contact address to generic SàT contact address - ContactList is based on QuickContactList, UI changes are done in update method - bride call (now json module) have been greatly improved, in particular call can be done in the same way as for other frontends (bridge.method_name(arg1, arg2, ..., callback=cb, errback=eb). Blocking method must be called like async methods due to javascript architecture - in bridge calls, a callback can now exists without errback - hard reload on BridgeSignals remote error has been disabled, a better option should be implemented - use of constants where that make sens, some style improvments - avatars are temporarily disabled - lot of code disabled, will be fixed or removed before merge - various other changes, check diff for more details server side: manage remote exception on getEntityData, removed getProfileJid call, added getWaitingConf, added getRoomsSubjects
author Goffi <goffi@goffi.org>
date Sat, 24 Jan 2015 01:45:39 +0100
parents b07f0fe2763a
children a099990f77a6
line wrap: on
line diff
--- a/src/browser/sat_browser/base_widget.py	Thu Oct 23 16:56:36 2014 +0200
+++ b/src/browser/sat_browser/base_widget.py	Sat Jan 24 01:45:39 2015 +0100
@@ -177,12 +177,13 @@
             menu_styles.update(styles)
         base_menu.GenericMenuBar.__init__(self, host, vertical=vertical, styles=menu_styles)
 
-        if hasattr(parent, 'addMenus'):
-            # regroup all the dynamic menu categories in a sub-menu
-            sub_menu = WidgetSubMenuBar(host, vertical=True)
-            parent.addMenus(sub_menu)
-            if len(sub_menu.getCategories()) > 0:
-                self.addCategory('', '', 'plugins', sub_menu)
+        # FIXME
+        # if hasattr(parent, 'addMenus'):
+        #     # regroup all the dynamic menu categories in a sub-menu
+        #     sub_menu = WidgetSubMenuBar(host, vertical=True)
+        #     parent.addMenus(sub_menu)
+        #     if len(sub_menu.getCategories()) > 0:
+        #         self.addCategory('', '', 'plugins', sub_menu)
 
     @classmethod
     def getCategoryHTML(cls, menu_name_i18n, type_):
@@ -231,35 +232,37 @@
 
     def __init__(self, host, title='', info=None, selectable=False):
         """Init the widget
+
         @param host (SatWebFrontend): SatWebFrontend instance
         @param title (str): title shown in the header of the widget
         @param info (str, callable): info shown in the header of the widget
-        @param selectable (bool): True is widget can be selected by user"""
+        @param selectable (bool): True is widget can be selected by user
+        """
         VerticalPanel.__init__(self)
         DropCell.__init__(self, host)
         ClickHandler.__init__(self)
-        self.__selectable = selectable
-        self.__title_id = HTMLPanel.createUniqueId()
-        self.__setting_button_id = HTMLPanel.createUniqueId()
-        self.__close_button_id = HTMLPanel.createUniqueId()
-        self.__title = Label(title)
-        self.__title.setStyleName('widgetHeader_title')
+        self._selectable = selectable
+        self._title_id = HTMLPanel.createUniqueId()
+        self._setting_button_id = HTMLPanel.createUniqueId()
+        self._close_button_id = HTMLPanel.createUniqueId()
+        self._title = Label(title)
+        self._title.setStyleName('widgetHeader_title')
         if info is not None:
             if isinstance(info, str):
-                self.__info = HTML(info)
+                self._info = HTML(info)
             else:  # the info will be set by a callback
-                assert(callable(info))
-                self.__info = HTML()
-                info(self.__info.setHTML)
-            self.__info.setStyleName('widgetHeader_info')
+                assert callable(info)
+                self._info = HTML()
+                info(self._info.setHTML)
+            self._info.setStyleName('widgetHeader_info')
         else:
-            self.__info = None
+            self._info = None
         self._close_listeners = []
-        header = WidgetHeader(self, host, self.__title, self.__info)
+        header = WidgetHeader(self, host, self._title, self._info)
         self.add(header)
         self.setSize('100%', '100%')
         self.addStyleName('widget')
-        if self.__selectable:
+        if self._selectable:
             self.addClickListener(self)
 
             def onClose(sender):
@@ -268,10 +271,10 @@
                     self.host.uni_box.onWidgetClosed(sender)
 
             self.addCloseListener(onClose)
-        self.host.registerWidget(self)
+        # self.host.registerWidget(self) # FIXME
 
     def getDebugName(self):
-        return "%s (%s)" % (self, self.__title.getText())
+        return "%s (%s)" % (self, self._title.getText())
 
     def getWidgetsPanel(self, expect=True):
         return self.getParent(WidgetsPanel, expect)
@@ -392,28 +395,28 @@
     def setTitle(self, text):
         """change the title in the header of the widget
         @param text: text of the new title"""
-        self.__title.setText(text)
+        self._title.setText(text)
 
     def setHeaderInfo(self, text):
         """change the info in the header of the widget
         @param text: text of the new title"""
         try:
-            self.__info.setHTML(text)
+            self._info.setHTML(text)
         except TypeError:
             log.error("LiberviaWidget.setInfo: info widget has not been initialized!")
 
     def isSelectable(self):
-        return self.__selectable
+        return self._selectable
 
     def setSelectable(self, selectable):
-        if not self.__selectable:
+        if not self._selectable:
             try:
                 self.removeClickListener(self)
             except ValueError:
                 pass
         if self.selectable and not self in self._clickListeners:
             self.addClickListener(self)
-        self.__selectable = selectable
+        self._selectable = selectable
 
     def getWarningData(self):
         """ Return exposition warning level when this widget is selected and something is sent to it
@@ -425,7 +428,7 @@
             - MISC
             - NONE
         """
-        if not self.__selectable:
+        if not self._selectable:
             log.error("getWarningLevel must not be called for an unselectable widget")
             raise Exception
         # TODO: cleaner warning types (more general constants)