Fix some issues with event handling on the client side and how arguments are handled in

DelugeEvents
This commit is contained in:
Andrew Resch 2009-02-04 02:48:50 +00:00
parent 3b6bee1508
commit 5fc4948ad2
3 changed files with 17 additions and 19 deletions

View File

@ -42,7 +42,9 @@ class DelugeEvent(object):
return self.__class__.__name__ return self.__class__.__name__
def _get_args(self): def _get_args(self):
return self.__dict__.values() if not hasattr(self, "_args"):
return []
return self._args
name = property(fget=_get_name) name = property(fget=_get_name)
args = property(fget=_get_args) args = property(fget=_get_args)
@ -55,7 +57,7 @@ class TorrentAddedEvent(DelugeEvent):
""" """
:param torrent_id: str, the torrent_id of the torrent that was added :param torrent_id: str, the torrent_id of the torrent that was added
""" """
self.torrent_id = torrent_id self._args = [torrent_id]
class TorrentRemovedEvent(DelugeEvent): class TorrentRemovedEvent(DelugeEvent):
""" """
@ -65,7 +67,7 @@ class TorrentRemovedEvent(DelugeEvent):
""" """
:param torrent_id: str, the torrent_id :param torrent_id: str, the torrent_id
""" """
self.torrent_id = torrent_id self._args = [torrent_id]
class TorrentStateChangedEvent(DelugeEvent): class TorrentStateChangedEvent(DelugeEvent):
""" """
@ -76,8 +78,7 @@ class TorrentStateChangedEvent(DelugeEvent):
:param torrent_id: str, the torrent_id :param torrent_id: str, the torrent_id
:param state: str, the new state :param state: str, the new state
""" """
self.torrent_id = torrent_id self._args = [torrent_id, state]
self.state = state
class TorrentQueueChangedEvent(DelugeEvent): class TorrentQueueChangedEvent(DelugeEvent):
""" """
@ -95,9 +96,7 @@ class TorrentFolderRenamedEvent(DelugeEvent):
:param old: str, the old folder name :param old: str, the old folder name
:param new: str, the new folder name :param new: str, the new folder name
""" """
self.torrent_id = torrent_id self._args = [torrent_id, old, new]
self.old = old
self.new = new
class TorrentFileRenamedEvent(DelugeEvent): class TorrentFileRenamedEvent(DelugeEvent):
""" """
@ -109,9 +108,7 @@ class TorrentFileRenamedEvent(DelugeEvent):
:param index: int, the index of the file :param index: int, the index of the file
:param name: str, the new filename :param name: str, the new filename
""" """
self.torrent_id = torrent_id self._args = [torrent_id, index, name]
self.index = index
self.name = name
class TorrentFinishedEvent(DelugeEvent): class TorrentFinishedEvent(DelugeEvent):
""" """
@ -121,7 +118,7 @@ class TorrentFinishedEvent(DelugeEvent):
""" """
:param torrent_id: str, the torrent_id :param torrent_id: str, the torrent_id
""" """
self.torrent_id = torrent_id self._args = [torrent_id]
class TorrentResumedEvent(DelugeEvent): class TorrentResumedEvent(DelugeEvent):
""" """
@ -131,7 +128,7 @@ class TorrentResumedEvent(DelugeEvent):
""" """
:param torrent_id: str, the torrent_id :param torrent_id: str, the torrent_id
""" """
self.torrent_id = torrent_id self._args = [torrent_id]
class NewVersionAvailableEvent(DelugeEvent): class NewVersionAvailableEvent(DelugeEvent):
""" """
@ -141,7 +138,7 @@ class NewVersionAvailableEvent(DelugeEvent):
""" """
:param new_release: str, the new version that is available :param new_release: str, the new version that is available
""" """
self.new_release = new_release self._args = [new_release]
class SessionPausedEvent(DelugeEvent): class SessionPausedEvent(DelugeEvent):
""" """
@ -164,5 +161,4 @@ class ConfigValueChangedEvent(DelugeEvent):
:param key: str, the key that changed :param key: str, the key that changed
:param value: the new value of the `:param:key` :param value: the new value of the `:param:key`
""" """
self.key = key self._args = [key, value]
self.value = value

View File

@ -265,8 +265,10 @@ class StatusBar(component.Component):
client.core.get_health().addCallback(self._on_get_health) client.core.get_health().addCallback(self._on_get_health)
def on_configvaluechanged_event(self, key, value): def on_configvaluechanged_event(self, key, value):
"""This is called when we received a config_value_changed signal from """
the core.""" This is called when we receive a ConfigValueChangedEvent from
the core.
"""
if key in self.config_value_changed_dict.keys(): if key in self.config_value_changed_dict.keys():
self.config_value_changed_dict[key](value) self.config_value_changed_dict[key](value)