diff browser_side/panels.py @ 179:8475a29d7214

closing a group chat widget now leave the muc room (bug 11)
author Goffi <goffi@goffi.org>
date Sat, 26 Jan 2013 00:36:57 +0100
parents 7a349be99a77
children c0b78a3af06d
line wrap: on
line diff
--- a/browser_side/panels.py	Fri Jan 25 00:49:34 2013 +0100
+++ b/browser_side/panels.py	Sat Jan 26 00:36:57 2013 +0100
@@ -114,6 +114,7 @@
             return False
         if isinstance(self, LiberviaWidget):
             self.host.unregisterWidget(self)
+            self.onQuit()
             if not isinstance(_new_panel, LiberviaWidget):
                 print ('WARNING: droping an object which is not a class of LiberviaWidget')
         _flextable = self.getParent()
@@ -183,8 +184,14 @@
         self.host.select(self)
 
     def onClose(self, sender):
+        """ Called when the close button is pushed """
         _widgetspanel = self._getWidgetsPanel()
         _widgetspanel.removeWidget(self)
+        self.onQuit()
+
+    def onQuit(self):
+        """ Called when the widget is actually ending """
+        pass
 
     def onSetting(self, sender):
         widpanel = self._getWidgetsPanel()
@@ -683,7 +690,7 @@
 
 class ChatPanel(LiberviaWidget):
 
-    def __init__(self, host, target, type='one2one'):
+    def __init__(self, host, target, type_='one2one'):
         """Panel used for conversation (one 2 one or group chat)
         @param host: SatWebFrontend instance
         @param target: entity (JID) with who we have a conversation (contact's jid for one 2 one chat, or MUC room)
@@ -691,7 +698,7 @@
         LiberviaWidget.__init__(self, host, target.bare, selectable = True)
         self.vpanel = VerticalPanel()
         self.vpanel.setSize('100%','100%')
-        self.type = type
+        self.type = type_
         self.nick = None
         if not target:
             print "ERROR: Empty target !"
@@ -701,7 +708,7 @@
         self.__body.setStyleName('chatPanel_body')
         chat_area = HorizontalPanel()
         chat_area.setStyleName('chatArea')
-        if type == 'group':
+        if type_ == 'group':
             self.occupants_list = OccupantsList()
             chat_area.add(self.occupants_list)
         self.__body.add(chat_area)
@@ -724,6 +731,12 @@
         #the event will not propagate to children
         ScrollPanelWrapper.doAttachChildren(self)"""
 
+    def onQuit(self):
+        LiberviaWidget.onQuit(self)
+        if self.type == 'group':
+            self.host.bridge.call('mucLeave', None, self.target.bare)
+        
+
     def setUserNick(self, nick):
         """Set the nick of the user, usefull for e.g. change the color of the user"""
         self.nick = nick