comparison src/browser/sat_browser/panels.py @ 495:587fe75d1b16

browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
author souliane <souliane@mailoo.org>
date Tue, 15 Jul 2014 18:45:33 +0200
parents 437eefa53a01
children 0924710b666a
comparison
equal deleted inserted replaced
494:5d8632a7bfde 495:587fe75d1b16
1091 def __init__(self, host, target, type_='one2one'): 1091 def __init__(self, host, target, type_='one2one'):
1092 """Panel used for conversation (one 2 one or group chat) 1092 """Panel used for conversation (one 2 one or group chat)
1093 @param host: SatWebFrontend instance 1093 @param host: SatWebFrontend instance
1094 @param target: entity (jid.JID) with who we have a conversation (contact's jid for one 2 one chat, or MUC room) 1094 @param target: entity (jid.JID) with who we have a conversation (contact's jid for one 2 one chat, or MUC room)
1095 @param type: one2one for simple conversation, group for MUC""" 1095 @param type: one2one for simple conversation, group for MUC"""
1096 base_widget.LiberviaWidget.__init__(self, host, title=target.bare, selectable=True)
1097 self.vpanel = VerticalPanel() 1096 self.vpanel = VerticalPanel()
1098 self.vpanel.setSize('100%', '100%') 1097 self.vpanel.setSize('100%', '100%')
1099 self.type = type_
1100 self.nick = None 1098 self.nick = None
1101 if not target: 1099 if not target:
1102 log.error("Empty target !") 1100 log.error("Empty target !")
1103 return 1101 return
1104 self.target = target 1102 self.target = target
1103 self.type = type_
1104 base_widget.LiberviaWidget.__init__(self, host, title=target.bare, selectable=True)
1105 self.__body = AbsolutePanel() 1105 self.__body = AbsolutePanel()
1106 self.__body.setStyleName('chatPanel_body') 1106 self.__body.setStyleName('chatPanel_body')
1107 chat_area = HorizontalPanel() 1107 chat_area = HorizontalPanel()
1108 chat_area.setStyleName('chatArea') 1108 chat_area.setStyleName('chatArea')
1109 if type_ == 'group': 1109 if type_ == 'group':
1165 try: 1165 try:
1166 return self.target.bare == entity.bare and self.type == type_ 1166 return self.target.bare == entity.bare and self.type == type_
1167 except AttributeError as e: 1167 except AttributeError as e:
1168 e.include_traceback() 1168 e.include_traceback()
1169 return False 1169 return False
1170
1171 def addCachedMenus(self, menu_bar):
1172 """Add cached menus to the header.
1173
1174 @param menu_bar (GenericMenuBar): menu bar of the widget's header
1175 """
1176 if self.type == 'group':
1177 menu_bar.addCachedMenus(C.MENU_ROOM, {'room_jid': self.target.bare})
1178 elif self.type == 'one2one':
1179 menu_bar.addCachedMenus(C.MENU_SINGLE, {'jid': self.target})
1170 1180
1171 def getWarningData(self): 1181 def getWarningData(self):
1172 if self.type not in ["one2one", "group"]: 1182 if self.type not in ["one2one", "group"]:
1173 raise Exception("Unmanaged type !") 1183 raise Exception("Unmanaged type !")
1174 if self.type == "one2one": 1184 if self.type == "one2one":
1348 def __init__(self, host): 1358 def __init__(self, host):
1349 self.host = host 1359 self.host = host
1350 AbsolutePanel.__init__(self) 1360 AbsolutePanel.__init__(self)
1351 1361
1352 # menu 1362 # menu
1353 self.menu = menu.Menu(host) 1363 self.menu = menu.MainMenuPanel(host)
1354 1364
1355 # unibox 1365 # unibox
1356 self.unibox_panel = UniBoxPanel(host) 1366 self.unibox_panel = UniBoxPanel(host)
1357 self.unibox_panel.setVisible(False) 1367 self.unibox_panel.setVisible(False)
1358 1368