[sugar] [PATCH 2/6] Implement API to handle tabbing.

Benjamin Berg benjamin
Thu Jun 19 15:08:56 EDT 2008


This adds some functions to to start/stop the tabbing and to switch to the
next and previous activity. It also takes care of raising the activities
window after a short delay.
---

 src/view/Shell.py |   63 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 63 insertions(+), 0 deletions(-)

diff --git a/src/view/Shell.py b/src/view/Shell.py
index b77465d..35f4073 100644
--- a/src/view/Shell.py
+++ b/src/view/Shell.py
@@ -57,6 +57,7 @@ class Shell(gobject.GObject):
         self._screen = wnck.screen_get_default()
         self._current_host = None
         self._screen_rotation = 0
+        self._tabbing_timeout = None
 
         self._key_handler = KeyHandler()
 
@@ -222,6 +223,68 @@ class Shell(gobject.GObject):
             self.take_activity_screenshot()
             next_activity.get_window().activate(gtk.get_current_event_time())
 
+    def tabbing_activate_current(self):
+        home_model = self._model.get_home()
+        activity = home_model.get_active_activity()
+        if activity and activity.get_window():
+            activity.get_window().activate(1)
+
+    def __tabbing_timeout_cb(self):
+        self._tabbing_timeout = None
+        self.tabbing_activate_current()
+        return False
+
+    def tabbing_previous_activity(self, first_switch):
+        home_model = self._model.get_home()
+        zoom_level = self._model.get_zoom_level()
+
+        if first_switch and zoom_level != shellmodel.ShellModel.ZOOM_ACTIVITY:
+            activity = home_model.get_active_activity()
+        else:
+            activity = home_model.get_previous_activity()
+
+        home_model.tabbing_set_activity(activity)
+
+        if self._tabbing_timeout:
+            gobject.source_remove(self._tabbing_timeout)
+        self._tabbing_timeout = \
+            gobject.timeout_add(250, self.__tabbing_timeout_cb)
+
+    def tabbing_next_activity(self, first_switch):
+        home_model = self._model.get_home()
+        zoom_level = self._model.get_zoom_level()
+
+        if first_switch and zoom_level != shellmodel.ShellModel.ZOOM_ACTIVITY:
+            activity = home_model.get_active_activity()
+        else:
+            activity = home_model.get_next_activity()
+
+        home_model.tabbing_set_activity(activity)
+
+        if self._tabbing_timeout:
+            gobject.source_remove(self._tabbing_timeout)
+        self._tabbing_timeout = \
+            gobject.timeout_add(250, self.__tabbing_timeout_cb)
+
+    def tabbing_start(self):
+        self.take_activity_screenshot()
+        self._frame.show(self._frame.MODE_NON_INTERACTIVE)
+
+        home_model = self._model.get_home()
+        home_model.tabbing_start()
+
+    def tabbing_stop(self):
+        self._frame.hide()
+
+        if self._tabbing_timeout:
+            gobject.source_remove(self._tabbing_timeout)
+
+        self.tabbing_activate_current()
+        self._model.get_home().tabbing_stop()
+
+        home_model = self._model.get_home()
+        home_model.tabbing_stop()
+
     def close_current_activity(self):
         if self._model.get_zoom_level() != shellmodel.ShellModel.ZOOM_ACTIVITY:
             return




More information about the Sugar-devel mailing list