diff options
author | Marco Pesenti Gritti <marco@localhost.localdomain> | 2006-10-19 13:22:42 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <marco@localhost.localdomain> | 2006-10-19 13:22:42 (GMT) |
commit | cd29967c2ece4e5569bbc5e11752e415ab971fda (patch) | |
tree | 80fb706635a11ca0f7f11874276b420d0eb0ed2a /shell | |
parent | cf13a7ff5bcf4987d23d56669e6c984142033338 (diff) |
Refactor a bit to keep host independent from the shell
Diffstat (limited to 'shell')
-rw-r--r-- | shell/view/ActivityHost.py | 18 | ||||
-rw-r--r-- | shell/view/Shell.py | 26 |
2 files changed, 27 insertions, 17 deletions
diff --git a/shell/view/ActivityHost.py b/shell/view/ActivityHost.py index eacb30f..61b7078 100644 --- a/shell/view/ActivityHost.py +++ b/shell/view/ActivityHost.py @@ -42,9 +42,7 @@ class ActivityChatWindow(gtk.Window): self.add(chat_widget) class ActivityHost: - def __init__(self, shell, window): - self._shell = shell - + def __init__(self, window): self._window = window self._xid = window.get_xid() self._pservice = PresenceService.get_instance() @@ -73,8 +71,6 @@ class ActivityHost: self._chat_window = ActivityChatWindow(win, self._chat_widget) self._frame_was_visible = False - self._shell.connect('activity-changed', self._activity_changed_cb) - self._shell.connect('activity-closed', self._activity_closed_cb) def get_id(self): return self._id @@ -143,13 +139,11 @@ class ActivityHost: def is_chat_visible(self): return self._chat_window.get_property('visible') - def _activity_changed_cb(self, shell, activity): - if activity != self: + def set_active(self, active): + if not active: self.chat_hide() self._frame_was_visible = False - def _activity_closed_cb(self, shell, activity): - if activity == self: - self._chat_window.destroy() - self._frame_was_visible = False - + def destroy(self): + self._chat_window.destroy() + self._frame_was_visible = False diff --git a/shell/view/Shell.py b/shell/view/Shell.py index b2d9d73..29305cd 100644 --- a/shell/view/Shell.py +++ b/shell/view/Shell.py @@ -45,6 +45,7 @@ class Shell(gobject.GObject): self._model = model self._hosts = {} self._screen = wnck.screen_get_default() + self._current_host = None style.load_stylesheet(view.stylesheet) @@ -95,7 +96,7 @@ class Shell(gobject.GObject): def __window_opened_cb(self, screen, window): if window.get_window_type() == wnck.WINDOW_NORMAL: - activity_host = ActivityHost(self, window) + activity_host = ActivityHost(window) self._hosts[activity_host.get_xid()] = activity_host self.emit('activity-opened', activity_host) @@ -104,24 +105,39 @@ class Shell(gobject.GObject): if window and window.get_window_type() == wnck.WINDOW_NORMAL: activity_host = self._hosts[window.get_xid()] - current = self._model.get_current_activity() if activity_host.get_id() == current: return - self._model.set_current_activity(activity_host.get_id()) - self.emit('activity-changed', activity_host) + self._set_current_activity(activity_host) def __window_closed_cb(self, screen, window): if window.get_window_type() == wnck.WINDOW_NORMAL: if self._hosts.has_key(window.get_xid()): host = self._hosts[window.get_xid()] + host.destroy() + self.emit('activity-closed', host) del self._hosts[window.get_xid()] if len(self._hosts) == 0: + self._set_current_activity(None) + + def _set_current_activity(self, host): + if host: + self._model.set_current_activity(host.get_id()) + else: self._model.set_current_activity(None) - self.emit('activity-changed', None) + + if self._current_host: + self._current_host.set_active(False) + + self._current_host = host + + if self._current_host: + self._current_host.set_active(True) + + self.emit('activity-changed', host) def get_model(self): return self._model |