comparison frontends/wix/main_window.py @ 68:9b842086d915

multiple profiles update - Wix: new profile managed, it appear at launch in place of the contact list, and disappear once the profile is choosen - SàT: default profile is now saved, first one is choosed is no default profile - Bridge: new delete profile method
author Goffi <goffi@goffi.org>
date Thu, 25 Feb 2010 17:09:18 +1100
parents 0e50dd3a234a
children 8f2ed279784b
comparison
equal deleted inserted replaced
67:0e50dd3a234a 68:9b842086d915
24 from chat import Chat 24 from chat import Chat
25 from param import Param 25 from param import Param
26 from form import Form 26 from form import Form
27 from gateways import GatewaysManager 27 from gateways import GatewaysManager
28 from profile import Profile 28 from profile import Profile
29 from profile_manager import ProfileManager
29 import gobject 30 import gobject
30 import os.path 31 import os.path
31 import pdb 32 import pdb
32 from tools.jid import JID 33 from tools.jid import JID
33 from logging import debug, info, error 34 from logging import debug, info, error
217 218
218 class MainWindow(wx.Frame, QuickApp): 219 class MainWindow(wx.Frame, QuickApp):
219 """main app window""" 220 """main app window"""
220 221
221 def __init__(self): 222 def __init__(self):
222 wx.Frame.__init__(self,None, title="SAT Wix", size=(300,500)) 223 wx.Frame.__init__(self,None, title="SàT Wix", size=(300,500))
223 self.CM = QuickContactManagement() #FIXME: not the best place 224 self.CM = QuickContactManagement() #FIXME: not the best place
224 225
225 226 #sizer
226 227 self.sizer = wx.BoxSizer(wx.VERTICAL)
228 self.SetSizer(self.sizer)
229
227 #Frame elements 230 #Frame elements
228 self.contactList = ContactList(self, self.CM) 231 self.contactList = ContactList(self, self.CM)
229 self.contactList.registerActivatedCB(self.onContactActivated) 232 self.contactList.registerActivatedCB(self.onContactActivated)
233 self.contactList.Hide()
234 self.sizer.Add(self.contactList, 1, flag=wx.EXPAND)
235
230 self.chat_wins=ChatList(self) 236 self.chat_wins=ChatList(self)
231 self.CreateStatusBar() 237 self.CreateStatusBar()
232 self.createMenus() 238 self.createMenus()
239 for i in range(self.menuBar.GetMenuCount()):
240 self.menuBar.EnableTop(i, False)
233 241
234 #ToolBar 242 #ToolBar
235 self.tools=self.CreateToolBar() 243 self.tools=self.CreateToolBar()
236 self.statusBox = wx.ComboBox(self.tools, -1, "Online", choices=[status[1] for status in const_STATUS], 244 self.statusBox = wx.ComboBox(self.tools, -1, "Online", choices=[status[1] for status in const_STATUS],
237 style=wx.CB_DROPDOWN | wx.CB_READONLY) 245 style=wx.CB_DROPDOWN | wx.CB_READONLY)
252 260
253 #events 261 #events
254 self.Bind(wx.EVT_CLOSE, self.onClose, self) 262 self.Bind(wx.EVT_CLOSE, self.onClose, self)
255 263
256 QuickApp.__init__(self) 264 QuickApp.__init__(self)
257 self.plug_profile() 265 #self.plug_profile() #gof:
266
267 #profile panel
268 self.profile_pan = ProfileManager(self)
269 #self.profile_pan.Hide() #gof:
270 self.sizer.Add(self.profile_pan, 1, flag=wx.EXPAND)
258 271
259 self.Show() 272 self.Show()
273
274 def plug_profile(self, profile_key='@DEFAULT@'):
275 """Hide profile panel then plug profile"""
276 self.profile_pan.Hide()
277 self.contactList.Show()
278 self.sizer.Layout()
279 for i in range(self.menuBar.GetMenuCount()):
280 self.menuBar.EnableTop(i, True)
281 super(MainWindow, self).plug_profile(profile_key)
282 if not self.bridge.isConnected(profile_key):
283 self.bridge.connect(profile_key)
260 284
261 def createMenus(self): 285 def createMenus(self):
262 info("Creating menus") 286 info("Creating menus")
263 connectMenu = wx.Menu() 287 connectMenu = wx.Menu()
264 connectMenu.Append(idCONNECT, "&Connect CTRL-c"," Connect to the server") 288 connectMenu.Append(idCONNECT, "&Connect CTRL-c"," Connect to the server")
271 contactMenu.Append(idREMOVE_CONTACT, "&Remove contact"," Remove the selected contact from your list") 295 contactMenu.Append(idREMOVE_CONTACT, "&Remove contact"," Remove the selected contact from your list")
272 contactMenu.AppendSeparator() 296 contactMenu.AppendSeparator()
273 contactMenu.Append(idSHOW_PROFILE, "&Show profile", " Show contact's profile") 297 contactMenu.Append(idSHOW_PROFILE, "&Show profile", " Show contact's profile")
274 communicationMenu = wx.Menu() 298 communicationMenu = wx.Menu()
275 communicationMenu.Append(idFIND_GATEWAYS, "&Find Gateways"," Find gateways to legacy IM") 299 communicationMenu.Append(idFIND_GATEWAYS, "&Find Gateways"," Find gateways to legacy IM")
276 menuBar = wx.MenuBar() 300 self.menuBar = wx.MenuBar()
277 menuBar.Append(connectMenu,"&General") 301 self.menuBar.Append(connectMenu,"&General")
278 menuBar.Append(contactMenu,"&Contacts") 302 self.menuBar.Append(contactMenu,"&Contacts")
279 menuBar.Append(communicationMenu,"&Communication") 303 self.menuBar.Append(communicationMenu,"&Communication")
280 self.SetMenuBar(menuBar) 304 self.SetMenuBar(self.menuBar)
281 305
282 #events 306 #events
283 wx.EVT_MENU(self, idCONNECT, self.onConnectRequest) 307 wx.EVT_MENU(self, idCONNECT, self.onConnectRequest)
284 wx.EVT_MENU(self, idDISCONNECT, self.onDisconnectRequest) 308 wx.EVT_MENU(self, idDISCONNECT, self.onDisconnectRequest)
285 wx.EVT_MENU(self, idPARAM, self.onParam) 309 wx.EVT_MENU(self, idPARAM, self.onParam)
446 self.chat_wins[jid.short].Hide() 470 self.chat_wins[jid.short].Hide()
447 else: 471 else:
448 self.chat_wins[jid.short].Show() 472 self.chat_wins[jid.short].Show()
449 473
450 def onConnectRequest(self, e): 474 def onConnectRequest(self, e):
451 self.bridge.connect() 475 self.bridge.connect(self.profile)
452 476
453 def onDisconnectRequest(self, e): 477 def onDisconnectRequest(self, e):
454 self.bridge.disconnect() 478 self.bridge.disconnect(self.profile)
455 479
456 def __updateStatus(self): 480 def __updateStatus(self):
457 show = filter(lambda x:x[1] == self.statusBox.GetValue(), const_STATUS)[0][0] 481 show = filter(lambda x:x[1] == self.statusBox.GetValue(), const_STATUS)[0][0]
458 status = self.statusTxt.GetValue() 482 status = self.statusTxt.GetValue()
459 self.bridge.setPresence(show=show, statuses={'default':status}) #FIXME: manage multilingual statuses 483 self.bridge.setPresence(show=show, statuses={'default':status}) #FIXME: manage multilingual statuses