Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell/model
diff options
context:
space:
mode:
authorDan Winship <dwinship@redhat.com>2007-08-08 13:30:45 (GMT)
committer Dan Winship <dwinship@redhat.com>2007-08-08 13:30:45 (GMT)
commitc85c89ce839e952b05b20853b715abbf1b268ca5 (patch)
treed942f00da8725f17079de25a4456e720f71a16df /shell/model
parent6ca80a71461d414695dd83448d1d75d352be0438 (diff)
Make Journal active at startup. #2159
Also distinguish between "active" in the sense of "the user is actually using this activity" and "active" in the sense of "the activity would be active *if* the user switched to Activity view". It's the latter sense, now called "pending" that the Journal is in at startup. Pending is also used for the next-up activity when you quit the current active activity.
Diffstat (limited to 'shell/model')
-rw-r--r--shell/model/homemodel.py117
1 files changed, 76 insertions, 41 deletions
diff --git a/shell/model/homemodel.py b/shell/model/homemodel.py
index 7d1039b..c5e761c 100644
--- a/shell/model/homemodel.py
+++ b/shell/model/homemodel.py
@@ -51,7 +51,10 @@ class HomeModel(gobject.GObject):
([gobject.TYPE_PYOBJECT])),
'active-activity-changed': (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE,
- ([gobject.TYPE_PYOBJECT]))
+ ([gobject.TYPE_PYOBJECT])),
+ 'pending-activity-changed': (gobject.SIGNAL_RUN_FIRST,
+ gobject.TYPE_NONE,
+ ([gobject.TYPE_PYOBJECT]))
}
def __init__(self):
@@ -59,7 +62,8 @@ class HomeModel(gobject.GObject):
self._activities = []
self._bundle_registry = bundleregistry.get_registry()
- self._current_activity = None
+ self._active_activity = None
+ self._pending_activity = None
screen = wnck.screen_get_default()
screen.connect('window-opened', self._window_opened_cb)
@@ -67,8 +71,55 @@ class HomeModel(gobject.GObject):
screen.connect('active-window-changed',
self._active_window_changed_cb)
- def get_current_activity(self):
- return self._current_activity
+ def get_pending_activity(self):
+ """Returns the activity that would be seen in the Activity zoom level
+
+ In the Home (or Neighborhood or Groups) zoom level, this
+ indicates the activity that would become active if the user
+ switched to the Activity zoom level. (In the Activity zoom
+ level, this just returns the currently-active activity.)
+ Unlike get_active_activity(), this never returns None as long
+ as there is any activity running.
+ """
+ return self._pending_activity
+
+ def _set_pending_activity(self, activity):
+ if self._pending_activity == activity:
+ return
+
+ self._pending_activity = activity
+ self.emit('pending-activity-changed', self._pending_activity)
+
+ def get_active_activity(self):
+ """Returns the activity that the user is currently working in
+
+ In the Activity zoom level, this returns the currently-active
+ activity. In the other zoom levels, it returns the activity
+ that was most-recently active in the Activity zoom level, or
+ None if the most-recently-active activity is no longer
+ running.
+ """
+ return self._active_activity
+
+ def _set_active_activity(self, activity):
+ if self._active_activity == activity:
+ return
+
+ if self._active_activity:
+ service = self._active_activity.get_service()
+ if service:
+ service.set_active(False,
+ reply_handler=self._set_active_success,
+ error_handler=self._set_active_error)
+ if activity:
+ service = activity.get_service()
+ if service:
+ service.set_active(True,
+ reply_handler=self._set_active_success,
+ error_handler=self._set_active_error)
+
+ self._active_activity = activity
+ self.emit('active-activity-changed', self._active_activity)
def __iter__(self):
return iter(self._activities)
@@ -106,12 +157,12 @@ class HomeModel(gobject.GObject):
activity.props.launching = False
self.emit('activity-started', activity)
+ if self._pending_activity is None:
+ self._set_pending_activity(activity)
+
def _window_closed_cb(self, screen, window):
if window.get_window_type() == wnck.WINDOW_NORMAL:
self._remove_activity_by_xid(window.get_xid())
- if not self._activities:
- self.emit('active-activity-changed', None)
- self._notify_activity_activation(self._current_activity, None)
def _get_activity_by_xid(self, xid):
for activity in self._activities:
@@ -125,24 +176,6 @@ class HomeModel(gobject.GObject):
return activity
return None
- def _notify_activity_activation(self, old_activity, new_activity):
- if old_activity == new_activity:
- return
-
- if old_activity:
- service = old_activity.get_service()
- if service:
- service.set_active(False,
- reply_handler=self._set_active_success,
- error_handler=self._set_active_error)
-
- if new_activity:
- service = new_activity.get_service()
- if service:
- service.set_active(True,
- reply_handler=self._set_active_success,
- error_handler=self._set_active_error)
-
def _set_active_success(self):
pass
@@ -151,32 +184,34 @@ class HomeModel(gobject.GObject):
def _active_window_changed_cb(self, screen):
window = screen.get_active_window()
- if window == None:
- self.emit('active-activity-changed', None)
- self._notify_activity_activation(self._current_activity, None)
- return
- if window.get_window_type() != wnck.WINDOW_NORMAL:
+ if window is None or window.get_window_type() != wnck.WINDOW_NORMAL:
return
xid = window.get_xid()
- act = self._get_activity_by_xid(window.get_xid())
- if act:
- self._notify_activity_activation(self._current_activity, act)
- self._current_activity = act
- else:
- self._notify_activity_activation(self._current_activity, None)
- self._current_activity = None
+ act = self._get_activity_by_xid(xid)
+ if act is None:
logging.error('Model for window %d does not exist.' % xid)
-
- self.emit('active-activity-changed', self._current_activity)
+ self._set_pending_activity(act)
+ self._set_active_activity(act)
def _add_activity(self, activity):
self._activities.append(activity)
self.emit('activity-added', activity)
def _remove_activity(self, activity):
- if activity == self._current_activity:
- self._current_activity = None
+ if activity == self._active_activity:
+ self._set_active_activity(None)
+ # Figure out the new _pending_activity.
+ windows = wnck.screen_get_default().get_windows_stacked()
+ windows.reverse()
+ for window in windows:
+ new_activity = self._get_activity_by_xid(window.get_xid())
+ if new_activity is not None:
+ self._set_pending_activity(new_activity)
+ break
+ else:
+ logging.error('No activities are running')
+ self._set_pending_activity(None)
self.emit('activity-removed', activity)
self._activities.remove(activity)