Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2007-07-02 12:53:50 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2007-07-02 12:53:50 (GMT)
commit41af9218267071a605c684fad90ca81fd4c10c3d (patch)
tree4aee73d1af40e955b02280e8d56412d08433a0ec
parent7024f93a43501ffe40ed6e696e1f1214c2216543 (diff)
Cleanup zoom level management
-rw-r--r--shell/model/shellmodel.py29
-rw-r--r--shell/view/Shell.py32
2 files changed, 38 insertions, 23 deletions
diff --git a/shell/model/shellmodel.py b/shell/model/shellmodel.py
index 1117ea5..4c3dfea 100644
--- a/shell/model/shellmodel.py
+++ b/shell/model/shellmodel.py
@@ -16,6 +16,7 @@
import os
+import wnck
import gobject
from sugar.presence import presenceservice
@@ -37,9 +38,12 @@ class ShellModel(gobject.GObject):
ZOOM_ACTIVITY = 3
__gproperties__ = {
- 'state' : (int, None, None,
- 0, 2, STATE_RUNNING,
- gobject.PARAM_READWRITE)
+ 'state' : (int, None, None,
+ 0, 2, STATE_RUNNING,
+ gobject.PARAM_READWRITE),
+ 'zoom-level' : (int, None, None,
+ 0, 3, ZOOM_HOME,
+ gobject.PARAM_READABLE)
}
def __init__(self):
@@ -47,6 +51,7 @@ class ShellModel(gobject.GObject):
self._current_activity = None
self._state = self.STATE_RUNNING
+ self._zoom_level = self.ZOOM_HOME
self._pservice = presenceservice.get_instance()
@@ -57,6 +62,19 @@ class ShellModel(gobject.GObject):
self._home = HomeModel()
self._devices = DevicesModel()
+ self._screen = wnck.screen_get_default()
+ self._screen.connect('showing-desktop-changed',
+ self._showing_desktop_changed_cb)
+
+ def set_zoom_level(self, level):
+ self._zoom_level = level
+
+ def get_zoom_level(self):
+ if self._screen.get_showing_desktop():
+ return self._zoom_level
+ else:
+ return self.ZOOM_ACTIVITY
+
def do_set_property(self, pspec, value):
if pspec.name == 'state':
self._state = value
@@ -64,6 +82,8 @@ class ShellModel(gobject.GObject):
def do_get_property(self, pspec):
if pspec.name == 'state':
return self._state
+ elif pspec.name == 'zoom-level':
+ return self.get_zoom_level()
def get_mesh(self):
return self._mesh
@@ -82,3 +102,6 @@ class ShellModel(gobject.GObject):
def get_devices(self):
return self._devices
+
+ def _showing_desktop_changed_cb(self, screen):
+ self.notify('zoom-level')
diff --git a/shell/view/Shell.py b/shell/view/Shell.py
index 4f75241..1be2b6b 100644
--- a/shell/view/Shell.py
+++ b/shell/view/Shell.py
@@ -59,6 +59,9 @@ class Shell(gobject.GObject):
self._zoom_level = ShellModel.ZOOM_HOME
+ self._model.connect('notify::zoom-level',
+ self._zoom_level_changed_cb)
+
home_model = self._model.get_home()
home_model.connect('activity-started', self._activity_started_cb)
home_model.connect('activity-removed', self._activity_removed_cb)
@@ -99,12 +102,6 @@ class Shell(gobject.GObject):
self._current_host = host
- if self._current_host:
- self._current_host.set_active(True)
- self.set_zoom_level(ShellModel.ZOOM_ACTIVITY)
- else:
- self.set_zoom_level(ShellModel.ZOOM_HOME)
-
def get_model(self):
return self._model
@@ -150,24 +147,19 @@ class Shell(gobject.GObject):
self._activities_starting.add(activity_type)
activityfactory.create(activity_type)
- def set_zoom_level(self, level):
- if self._zoom_level == level:
- return
- if len(self._hosts) == 0 and level == ShellModel.ZOOM_ACTIVITY:
- return
-
- self._zoom_level = level
+ def _zoom_level_changed_cb(self, model, pspec):
+ if model.get_zoom_level() == ShellModel.ZOOM_HOME:
+ self._frame.show()
+ else:
+ self._frame.hide()
- if self._zoom_level == ShellModel.ZOOM_ACTIVITY:
+ def set_zoom_level(self, level):
+ if level == ShellModel.ZOOM_ACTIVITY:
self._screen.toggle_showing_desktop(False)
else:
+ self._model.set_zoom_level(level)
self._screen.toggle_showing_desktop(True)
- self._home_window.set_zoom_level(self._zoom_level)
-
- if self._zoom_level == ShellModel.ZOOM_HOME:
- self._frame.show()
- else:
- self._frame.hide()
+ self._home_window.set_zoom_level(level)
def get_current_activity(self):
return self._current_host