Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2008-08-27 12:15:37 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2008-08-27 12:15:37 (GMT)
commit87ad16df0a0543c8634d6d3d881734aabcde4175 (patch)
treee2b9091ca15750211b45dd11851c5c2bb050c65a /src
parentee5470f7e046ccc94a6d78065af4565c72e707e5 (diff)
Make the launcher window a normal window with a special
type property. Fix #7293 Patch by Eben, small cleanups by me
Diffstat (limited to 'src')
-rw-r--r--src/model/homeactivity.py8
-rw-r--r--src/model/homemodel.py15
-rw-r--r--src/view/Shell.py26
-rw-r--r--src/view/launchwindow.py61
4 files changed, 57 insertions, 53 deletions
diff --git a/src/model/homeactivity.py b/src/model/homeactivity.py
index fa50932..34ebda3 100644
--- a/src/model/homeactivity.py
+++ b/src/model/homeactivity.py
@@ -73,9 +73,11 @@ class HomeActivity(gobject.GObject):
dbus_interface="org.freedesktop.DBus")
def set_window(self, window):
- """An activity is 'launched' once we get its window."""
- if self._window or self._xid:
- raise RuntimeError("Activity is already launched!")
+ """Set the window for the activity
+
+ We allow resetting the window for an activity so that we
+ can replace the launcher once we get its real window.
+ """
if not window:
raise ValueError("window must be valid")
diff --git a/src/model/homemodel.py b/src/model/homemodel.py
index 49f2a23..58da5b0 100644
--- a/src/model/homemodel.py
+++ b/src/model/homemodel.py
@@ -18,12 +18,21 @@ import logging
import gobject
import wnck
+import gtk
from sugar import wm
from sugar.activity import get_registry
from model.homeactivity import HomeActivity
+def _get_sugar_window_type(self, window):
+ window = gtk.gdk.window_foreign_new(window.get_xid())
+ prop_info = window.property_get('_SUGAR_WINDOW_TYPE', 'STRING')
+ if prop_info is None:
+ return None
+ else:
+ return prop_info[2]
+
class HomeModel(gobject.GObject):
"""Model of the "Home" view (activity management)
@@ -152,7 +161,7 @@ class HomeModel(gobject.GObject):
def index(self, obj):
return self._activities.index(obj)
-
+
def _window_opened_cb(self, screen, window):
if window.get_window_type() == wnck.WINDOW_NORMAL:
home_activity = None
@@ -175,8 +184,8 @@ class HomeModel(gobject.GObject):
home_activity.set_window(window)
- home_activity.props.launching = False
- self.emit('launch-completed', home_activity)
+ if self._get_sugar_window_type(window) != 'launcher':
+ self.emit('launch-completed', home_activity)
if self._active_activity is None:
self._set_active_activity(home_activity)
diff --git a/src/view/Shell.py b/src/view/Shell.py
index 514b500..e145991 100644
--- a/src/view/Shell.py
+++ b/src/view/Shell.py
@@ -53,6 +53,7 @@ class Shell(gobject.GObject):
self._model = shellmodel.get_instance()
self._hosts = {}
+ self._launchers = {}
self._screen = wnck.screen_get_default()
self._screen_rotation = 0
@@ -63,8 +64,6 @@ class Shell(gobject.GObject):
self.home_window = HomeWindow()
self.home_window.show()
- self._launch_window = LaunchWindow()
-
home_model = self._model.get_home()
home_model.connect('launch-started', self.__launch_started_cb)
home_model.connect('launch-failed', self.__launch_failed_cb)
@@ -94,17 +93,32 @@ class Shell(gobject.GObject):
def __launch_started_cb(self, home_model, home_activity):
if home_activity.get_type() != 'org.laptop.JournalActivity':
- self._launch_window.show()
+ launch_window = LaunchWindow(home_activity)
+ launch_window.show()
+
+ self._launchers[home_activity.get_activity_id()] = launch_window
+ self._model.set_zoom_level(shellmodel.ShellModel.ZOOM_ACTIVITY)
def __launch_failed_cb(self, home_model, home_activity):
- self._launch_window.hide()
+ activity_id = home_activity.get_activity_id()
- def __launch_completed_cb(self, home_model, home_activity):
- self._launch_window.hide()
+ launch_window = self._launchers[activity_id]
+ if launch_window:
+ launch_window.destroy()
+ else:
+ logging.error('Launcher for %s is missing') % activity_id
+ def __launch_completed_cb(self, home_model, home_activity):
activity_host = ActivityHost(home_activity)
self._hosts[activity_host.get_xid()] = activity_host
+ activity_id = home_activity.get_activity_id()
+ launch_window = self._launchers[activity_id]
+ if launch_window:
+ launch_window.destroy()
+ else:
+ logging.error('Launcher for %s is missing') % activity_id
+
def _activity_removed_cb(self, home_model, home_activity):
xid = home_activity.get_xid()
if self._hosts.has_key(xid):
diff --git a/src/view/launchwindow.py b/src/view/launchwindow.py
index ee3ccfa..b60bc9c 100644
--- a/src/view/launchwindow.py
+++ b/src/view/launchwindow.py
@@ -19,6 +19,7 @@ import hippo
import gobject
import logging
+from sugar import wm
from sugar.graphics import style
from sugar.graphics import animator
from sugar.graphics.xocolor import XoColor
@@ -27,14 +28,15 @@ from model import shellmodel
from view.pulsingicon import CanvasPulsingIcon
class LaunchWindow(hippo.CanvasWindow):
- def __init__(self):
+ def __init__(self, home_activity):
gobject.GObject.__init__(
- self, type_hint=gtk.gdk.WINDOW_TYPE_HINT_SPLASHSCREEN)
+ self, type_hint=gtk.gdk.WINDOW_TYPE_HINT_NORMAL)
- self._box = LaunchBox()
+ self._activity_id = home_activity.get_activity_id()
+ self._box = LaunchBox(home_activity)
self.set_root(self._box)
- self.connect('focus-out-event', self.__focus_out_event_cb)
+ self.connect('realize', self.__realize_cb)
screen = gtk.gdk.screen_get_default()
screen.connect('size-changed', self.__size_changed_cb)
@@ -48,18 +50,23 @@ class LaunchWindow(hippo.CanvasWindow):
def _update_size(self):
self.resize(gtk.gdk.screen_width(), gtk.gdk.screen_height())
- def __focus_out_event_cb(self, widget, event):
- self.hide()
-
+ def __realize_cb(self, widget):
+ wm.set_activity_id(widget.window, str(self._activity_id))
+ widget.window.property_change('_SUGAR_WINDOW_TYPE', 'STRING', 8,
+ gtk.gdk.PROP_MODE_REPLACE, 'launcher')
+
def __size_changed_cb(self, screen):
self._update_size()
class LaunchBox(hippo.CanvasBox):
- def __init__(self):
+ def __init__(self, home_activity):
gobject.GObject.__init__(self, orientation=hippo.ORIENTATION_VERTICAL,
background_color=style.COLOR_WHITE.get_int())
- self._activity_icon = CanvasPulsingIcon()
+ self._home_activity = home_activity
+ self._activity_icon = CanvasPulsingIcon(
+ file_name=home_activity.get_icon_path(),
+ pulse_color=home_activity.get_icon_color())
self.append(self._activity_icon, hippo.PACK_EXPAND)
# FIXME support non-xo colors in CanvasPulsingIcon
@@ -72,14 +79,8 @@ class LaunchBox(hippo.CanvasBox):
self._home = shellmodel.get_instance().get_home()
self._home.connect('active-activity-changed',
self.__active_activity_changed_cb)
- self._home.connect('launch-failed', self.__launch_ended_cb)
- self._home.connect('launch-completed', self.__launch_ended_cb)
-
- self._update_icon()
def zoom_in(self):
- logging.debug('zooming in to activity')
-
self._activity_icon.props.size = style.STANDARD_ICON_SIZE
self._animator.remove_all()
@@ -87,35 +88,13 @@ class LaunchBox(hippo.CanvasBox):
style.STANDARD_ICON_SIZE,
style.XLARGE_ICON_SIZE))
self._animator.start()
-
- logging.debug('starting pulse')
-
self._activity_icon.props.pulsing = True
- def suspend(self):
- self._activity_icon.props.paused = True
-
- def resume(self):
- self._activity_icon.props.paused = False
-
- def _update_icon(self):
- activity = self._home.get_active_activity()
- if activity is not None:
- self._activity_icon.props.file_name = activity.get_icon_path()
- self._activity_icon.props.pulse_color = activity.get_icon_color()
- else:
- self._activity_icon.props.file_name = None
-
- if activity is not None and activity.props.launching:
- self.resume()
- else:
- self.suspend()
-
def __active_activity_changed_cb(self, model, activity):
- self._update_icon()
-
- def __launch_ended_cb(self, model, activity):
- self._update_icon()
+ if activity == self._home_activity:
+ self._activity_icon.props.paused = False
+ else:
+ self._activity_icon.props.paused = True
class _Animation(animator.Animation):
def __init__(self, icon, start_size, end_size):