Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell/view
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2006-12-24 14:39:00 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2006-12-24 14:39:00 (GMT)
commitb3c2368eaccd666066ba57bb496091f2631d64dc (patch)
tree4d8acda2b466c94548d76dc24e1fb531c6935415 /shell/view
parent0d1e07d9c34a4e1c24cc5f374963ad55b7ee035b (diff)
Complete the shell model/view split, finally
Diffstat (limited to 'shell/view')
-rw-r--r--shell/view/Shell.py53
-rw-r--r--shell/view/frame/FriendsBox.py11
-rw-r--r--shell/view/frame/ZoomBox.py32
3 files changed, 36 insertions, 60 deletions
diff --git a/shell/view/Shell.py b/shell/view/Shell.py
index 684f4da..c4b4b1e 100644
--- a/shell/view/Shell.py
+++ b/shell/view/Shell.py
@@ -34,11 +34,6 @@ from _sugar import KeyGrabber
import sugar
class Shell(gobject.GObject):
- __gsignals__ = {
- 'activity-changed': (gobject.SIGNAL_RUN_FIRST,
- gobject.TYPE_NONE, ([gobject.TYPE_PYOBJECT])),
- }
-
def __init__(self, model):
gobject.GObject.__init__(self)
@@ -65,9 +60,8 @@ class Shell(gobject.GObject):
home_model = self._model.get_home()
home_model.connect('activity-added', self._activity_added_cb)
home_model.connect('activity-removed', self._activity_removed_cb)
-
- self._screen.connect('active-window-changed',
- self.__active_window_changed_cb)
+ home_model.connect('active-activity-changed',
+ self._active_activity_changed_cb)
self._frame = Frame(self)
self._frame.show_and_hide(3)
@@ -141,37 +135,14 @@ class Shell(gobject.GObject):
activity_host = ActivityHost(home_activity)
self._hosts[activity_host.get_xid()] = activity_host
- def __active_window_changed_cb(self, screen):
- logging.debug('Shell.__active_window_changed_cb')
- window = screen.get_active_window()
- if not window or window.get_window_type() != wnck.WINDOW_NORMAL:
- return
- if not self._hosts.has_key(window.get_xid()):
- return
-
- activity_host = self._hosts[window.get_xid()]
- current = self._model.get_current_activity()
- if activity_host.get_id() == current:
- return
-
- self._set_current_activity(activity_host)
-
def _activity_removed_cb(self, home_model, home_activity):
- xid = home_activity.get_window().get_xid()
- if not self._hosts.has_key(xid):
- return
+ xid = home_activity.get_xid()
+ if self._hosts.has_key(xid):
+ self._hosts[xid].destroy()
+ del self._hosts[xid]
- self._hosts[xid].destroy()
- del self._hosts[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)
+ def _active_activity_changed_cb(self, home_model, home_activity):
+ host = self._hosts[home_activity.get_xid()]
if self._current_host:
self._current_host.set_active(False)
@@ -181,8 +152,6 @@ class Shell(gobject.GObject):
if self._current_host:
self._current_host.set_active(True)
- self.emit('activity-changed', host)
-
def get_model(self):
return self._model
@@ -229,11 +198,7 @@ class Shell(gobject.GObject):
self._home_window.set_zoom_level(level)
def get_current_activity(self):
- activity_id = self._model.get_current_activity()
- if activity_id:
- return self.get_activity(activity_id)
- else:
- return None
+ return self._current_host
def get_activity(self, activity_id):
for host in self._hosts.values():
diff --git a/shell/view/frame/FriendsBox.py b/shell/view/frame/FriendsBox.py
index cdc07ad..a0e5f92 100644
--- a/shell/view/frame/FriendsBox.py
+++ b/shell/view/frame/FriendsBox.py
@@ -41,7 +41,9 @@ class FriendsBox(hippo.CanvasBox):
for activity in self._pservice.get_activities():
self.__activity_appeared_cb(self._pservice, activity)
- shell.connect('activity-changed', self.__activity_changed_cb)
+ home_model = shell.get_model().get_home()
+ home_model.connect('active-activity-changed',
+ self._active_activity_changed_cb)
def add_buddy(self, buddy):
if self._buddies.has_key(buddy.get_name()):
@@ -94,9 +96,10 @@ class FriendsBox(hippo.CanvasBox):
self._left_hid = activity_ps.connect(
'buddy-left', self.__buddy_left_cb)
- def __activity_changed_cb(self, group, activity):
- if activity:
- ps = self._pservice.get_activity(activity.get_id())
+ def _active_activity_changed_cb(self, home_model, home_activity):
+ if home_activity:
+ activity_id = home_activity.get_id()
+ ps = self._pservice.get_activity(activity_id)
self._set_activity_ps(ps)
else:
self._set_activity_ps(None)
diff --git a/shell/view/frame/ZoomBox.py b/shell/view/frame/ZoomBox.py
index 5f103c1..484ee4e 100644
--- a/shell/view/frame/ZoomBox.py
+++ b/shell/view/frame/ZoomBox.py
@@ -14,6 +14,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+import logging
+
import hippo
from sugar.graphics.canvasicon import CanvasIcon
@@ -43,10 +45,9 @@ class ActivityMenu(Menu):
self.add_action(icon, ActivityMenu.ACTION_CLOSE)
class ActivityIcon(MenuIcon):
- def __init__(self, shell, menu_shell, activity):
+ def __init__(self, shell, menu_shell, activity_model):
self._shell = shell
- self._activity = activity
- self._activity_model = activity.get_model()
+ self._activity_model = activity_model
icon_name = self._activity_model.get_icon_name()
icon_color = self._activity_model.get_icon_color()
@@ -62,10 +63,15 @@ class ActivityIcon(MenuIcon):
def _action_cb(self, menu, action):
self.popdown()
+ activity = self._shell.get_current_activity()
+ if activity == None:
+ logging.error('No active activity.')
+ return
+
if action == ActivityMenu.ACTION_SHARE:
- self._activity.share()
+ activity.share()
if action == ActivityMenu.ACTION_CLOSE:
- self._activity.close()
+ activity.close()
class ZoomBox(hippo.CanvasBox):
def __init__(self, shell, menu_shell):
@@ -95,23 +101,25 @@ class ZoomBox(hippo.CanvasBox):
icon.connect('activated', self._level_clicked_cb, sugar.ZOOM_ACTIVITY)
self.append(icon)
- shell.connect('activity-changed', self._activity_changed_cb)
- self._set_current_activity(shell.get_current_activity())
+ home_model = shell.get_model().get_home()
+ home_model.connect('active-activity-changed',
+ self._activity_changed_cb)
+ self._set_current_activity(home_model.get_current_activity())
- def _set_current_activity(self, activity):
+ def _set_current_activity(self, home_activity):
if self._activity_icon:
self.remove(self._activity_icon)
- if activity:
- icon = ActivityIcon(self._shell, self._menu_shell, activity)
+ if home_activity:
+ icon = ActivityIcon(self._shell, self._menu_shell, home_activity)
style.apply_stylesheet(icon, 'frame.ZoomIcon')
self.append(icon, 0)
self._activity_icon = icon
else:
self._activity_icon = None
- def _activity_changed_cb(self, shell_model, activity):
- self._set_current_activity(activity)
+ def _activity_changed_cb(self, home_model, home_activity):
+ self._set_current_activity(home_activity)
def _level_clicked_cb(self, item, level):
self._shell.set_zoom_level(level)