From: <bi...@us...> - 2008-09-28 15:50:47
|
Revision: 10523 http://amsn.svn.sourceforge.net/amsn/?rev=10523&view=rev Author: billiob Date: 2008-09-28 15:50:37 +0000 (Sun, 28 Sep 2008) Log Message: ----------- add register/unregister to the contact_manager remove some trailing spaces Modified Paths: -------------- trunk/amsn2/amsn2/core/amsn.py trunk/amsn2/amsn2/core/contact_manager.py Modified: trunk/amsn2/amsn2/core/amsn.py =================================================================== --- trunk/amsn2/amsn2/core/amsn.py 2008-09-26 23:55:14 UTC (rev 10522) +++ trunk/amsn2/amsn2/core/amsn.py 2008-09-28 15:50:37 UTC (rev 10523) @@ -6,7 +6,7 @@ from views import * from contact_manager import * from conversation_manager import * - + class aMSNCore(object): def __init__(self, options): """ @@ -46,24 +46,24 @@ def run(self): self._main.show(); self._loop.run(); - + def mainWindowShown(self): # TODO : load the profiles from disk and all settings # then show the login window if autoconnect is disabled - + self._main.setTitle("aMSN 2 - Loading") - + splash = self._gui.gui.aMSNSplashScreen(self, self._main) image = self._gui.gui.Image(self, self._main) image.load("File","/path/to/image/here") - + splash.setImage(image) splash.setText("Loading...") splash.show() - + login = self._gui.gui.aMSNLoginWindow(self, self._main) - + profile = None if self._options.account is not None: if self._profile_manager.profileExists(self._options.account): @@ -83,20 +83,20 @@ if profile is None: profile = self._profile_manager.addProfile("") profile.password = "" - + login.switch_to_profile(profile) - + splash.hide() self._main.setTitle("aMSN 2 - Login") login.show() - + menu = self.createMainMenuView() self._main.setMenu(menu) def getMainWindow(self): return self._main - + def addProfile(self, account): return self._profile_manager.addProfile(account) @@ -136,8 +136,7 @@ self._conversation_manager.newConversation([contact]) clwin._clwidget.setContactCallback(startConversation_cb) - #TODO: use a method for that in aMSNContactManager - self._contact_manager._cl_listeners.append(clwin._clwidget) + self._contact_manager.register(clwin._clwidget) self._contact_manager.onCLDownloaded(profile.client.address_book) @@ -158,7 +157,7 @@ = self.quit) mainMenu = MenuItemView(MenuItemView.CASCADE_MENU, label="Main") mainMenu.addItem(quitMenuItem) - + menu.addItem(mainMenu) return menu Modified: trunk/amsn2/amsn2/core/contact_manager.py =================================================================== --- trunk/amsn2/amsn2/core/contact_manager.py 2008-09-26 23:55:14 UTC (rev 10522) +++ trunk/amsn2/amsn2/core/contact_manager.py 2008-09-28 15:50:37 UTC (rev 10523) @@ -7,7 +7,7 @@ def __init__(self, core): self._core = core - #TODO: cl_listeners should be a weakref list + #TODO: listeners should be a priority weakref list or smthg like that """ Listeners are objects with the following methods: - groupAdded(groupView) @@ -15,13 +15,13 @@ TODO: listeners should return the views they were given (so they change it, useful for plugins...) """ - self._cl_listeners = [] + self._listeners = [] #Events def onContactPresenceChanged(self, contact): c = self.buildContactView(contact) - for l in self._cl_listeners: + for l in self._listeners: l.contactUpdated(c) def onCLDownloaded(self, address_book): @@ -34,7 +34,7 @@ contactV = self.buildContactView(contact) groupV.contacts.append(contactV) - for l in self._cl_listeners: + for l in self._listeners: l.groupAdded(groupV) groupV = self.buildGroupView(None, 0, 0) @@ -49,10 +49,18 @@ if len(groupV.contacts) > 0: groupV = self.buildGroupView(None, 0, len(groupV.contacts)) - for l in self._cl_listeners: + for l in self._listeners: l.groupAdded(groupV) + def register(self, obj, priority = 0): + #TODO: priority + self._listeners.append(obj) + def unregister(self, obj): + if obj in self._listeners: + self._listeners.remove(obj) + + def buildGroupView(self, group, active, total): groupV = GroupView.getGroup(group.id if group else 0) groupV.icon = None # TODO : expanded/collapsed icon This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |