diff options
author | Marco Pesenti Gritti <marco@localhost.localdomain> | 2008-06-10 08:39:45 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <marco@localhost.localdomain> | 2008-06-10 08:39:45 (GMT) |
commit | caa8b4ff5ae93b625cb1990cc6a62d6b3a18bb53 (patch) | |
tree | 51aa8e2a4ca9591d622680e3e28bc7f955fe8c71 /src/view | |
parent | 550aa20e5f2672c1f47f07fdd47ece9e1dcf1d16 (diff) | |
parent | f91746f68e327660c6ec2ebc51608fe4eda3f60f (diff) |
Merge branch 'master' of git://dev.laptop.org/users/marco/sugar
Diffstat (limited to 'src/view')
-rw-r--r-- | src/view/Shell.py | 49 | ||||
-rw-r--r-- | src/view/frame/activitiestray.py | 6 | ||||
-rw-r--r-- | src/view/frame/friendstray.py | 6 | ||||
-rw-r--r-- | src/view/home/HomeWindow.py | 11 | ||||
-rw-r--r-- | src/view/home/Makefile.am | 1 | ||||
-rw-r--r-- | src/view/home/activitiesring.py | 12 | ||||
-rw-r--r-- | src/view/home/launchbox.py | 94 |
7 files changed, 141 insertions, 38 deletions
diff --git a/src/view/Shell.py b/src/view/Shell.py index 875e9a5..1095878 100644 --- a/src/view/Shell.py +++ b/src/view/Shell.py @@ -56,7 +56,6 @@ class Shell(gobject.GObject): self._hosts = {} self._screen = wnck.screen_get_default() self._current_host = None - self._pending_host = None self._screen_rotation = 0 self._key_handler = KeyHandler() @@ -67,12 +66,12 @@ class Shell(gobject.GObject): self._home_window.show() home_model = self._model.get_home() - home_model.connect('activity-started', self._activity_started_cb) + home_model.connect('launch-started', self.__launch_started_cb) + home_model.connect('launch-failed', self.__launch_failed_cb) + home_model.connect('launch-completed', self.__launch_completed_cb) home_model.connect('activity-removed', self._activity_removed_cb) home_model.connect('active-activity-changed', self._active_activity_changed_cb) - home_model.connect('pending-activity-changed', - self._pending_activity_changed_cb) gobject.idle_add(self._start_journal_idle) @@ -95,7 +94,19 @@ class Shell(gobject.GObject): if registry.get_activity('org.laptop.JournalActivity'): self.start_activity('org.laptop.JournalActivity') - def _activity_started_cb(self, home_model, home_activity): + def __launch_started_cb(self, home_model, home_activity): + if home_activity.get_type() == 'org.laptop.JournalActivity': + return + + self._screen.toggle_showing_desktop(True) + self._home_window.set_zoom_level(shellmodel.ShellModel.ZOOM_ACTIVITY) + self._home_window.launch_box.zoom_in() + + def __launch_failed_cb(self, home_model, home_activity): + if self._screen.get_showing_desktop(): + self._home_window.set_zoom_level(shellmodel.ShellModel.ZOOM_HOME) + + def __launch_completed_cb(self, home_model, home_activity): activity_host = ActivityHost(home_activity) self._hosts[activity_host.get_xid()] = activity_host if home_activity.get_type() in self._activities_starting: @@ -110,22 +121,17 @@ class Shell(gobject.GObject): del self._hosts[xid] def _active_activity_changed_cb(self, home_model, home_activity): + host = None if home_activity: - host = self._hosts[home_activity.get_xid()] - else: - host = None + xid = home_activity.get_xid() + if xid: + host = self._hosts[home_activity.get_xid()] if self._current_host: self._current_host.set_active(False) self._current_host = host - def _pending_activity_changed_cb(self, home_model, home_activity): - if home_activity: - self._pending_host = self._hosts[home_activity.get_xid()] - else: - self._pending_host = None - def get_model(self): return self._model @@ -150,17 +156,6 @@ class Shell(gobject.GObject): handle = ActivityHandle(activity_id) activityfactory.create(bundle_id, handle) - def notify_launch(self, bundle_id, activity_id): - # Zoom to Home for launch feedback - self.set_zoom_level(shellmodel.ShellModel.ZOOM_HOME) - - home_model = self._model.get_home() - home_model.notify_activity_launch(activity_id, bundle_id) - - def notify_launch_failure(self, activity_id): - home_model = self._model.get_home() - home_model.notify_activity_launch_failed(activity_id) - def start_activity(self, activity_type): if activity_type in self._activities_starting: logging.debug("This activity is still launching.") @@ -192,8 +187,8 @@ class Shell(gobject.GObject): self.take_activity_screenshot() if level == shellmodel.ShellModel.ZOOM_ACTIVITY: - if self._pending_host is not None: - self._pending_host.present() + if self._current_host is not None: + self._current_host.present() self._screen.toggle_showing_desktop(False) else: self._model.set_zoom_level(level) diff --git a/src/view/frame/activitiestray.py b/src/view/frame/activitiestray.py index 020cb68..90be6e9 100644 --- a/src/view/frame/activitiestray.py +++ b/src/view/frame/activitiestray.py @@ -191,7 +191,7 @@ class ActivitiesTray(HTray): self._home_model = shellmodel.get_instance().get_home() self._home_model.connect('activity-added', self.__activity_added_cb) self._home_model.connect('activity-removed', self.__activity_removed_cb) - self._home_model.connect('pending-activity-changed', + self._home_model.connect('active-activity-changed', self.__activity_changed_cb) self._invites = shellmodel.get_instance().get_invites() @@ -227,7 +227,9 @@ class ActivitiesTray(HTray): def __activity_clicked_cb(self, button, home_activity): if button.props.active: logging.debug('ActivitiesTray.__activity_clicked_cb') - home_activity.get_window().activate(gtk.get_current_event_time()) + window = home_activity.get_window() + if window: + window.activate(gtk.get_current_event_time()) def __invite_clicked_cb(self, icon, invite): self._invites.remove_invite(invite) diff --git a/src/view/frame/friendstray.py b/src/view/frame/friendstray.py index 86decaa..b9d8c07 100644 --- a/src/view/frame/friendstray.py +++ b/src/view/frame/friendstray.py @@ -54,8 +54,8 @@ class FriendsTray(VTray): reply_handler=self._get_activities_cb) home_model = shellmodel.get_instance().get_home() - home_model.connect('pending-activity-changed', - self._pending_activity_changed_cb) + home_model.connect('active-activity-changed', + self._active_activity_changed_cb) def _get_activities_cb(self, activities_list): for act in activities_list: @@ -117,7 +117,7 @@ class FriendsTray(VTray): self._left_hid = activity_ps.connect( 'buddy-left', self.__buddy_left_cb) - def _pending_activity_changed_cb(self, home_model, home_activity): + def _active_activity_changed_cb(self, home_model, home_activity): if home_activity is None: return diff --git a/src/view/home/HomeWindow.py b/src/view/home/HomeWindow.py index 7e0a0c5..9151d46 100644 --- a/src/view/home/HomeWindow.py +++ b/src/view/home/HomeWindow.py @@ -24,12 +24,14 @@ from view.home.MeshBox import MeshBox from view.home.HomeBox import HomeBox from view.home.FriendsBox import FriendsBox from view.home.transitionbox import TransitionBox +from view.home.launchbox import LaunchBox from model.shellmodel import ShellModel _HOME_PAGE = 0 _FRIENDS_PAGE = 1 _MESH_PAGE = 2 _TRANSITION_PAGE = 3 +_LAUNCH_PAGE = 4 class HomeWindow(gtk.Window): def __init__(self): @@ -65,6 +67,7 @@ class HomeWindow(gtk.Window): self._friends_box = FriendsBox() self._mesh_box = MeshBox() self._transition_box = TransitionBox() + self.launch_box = LaunchBox() self._activate_view() self._canvas.set_root(self._home_box) @@ -98,12 +101,16 @@ class HomeWindow(gtk.Window): self._home_box.suspend() elif self._level == ShellModel.ZOOM_MESH: self._mesh_box.suspend() + elif self._level == ShellModel.ZOOM_ACTIVITY: + self.launch_box.suspend() def _activate_view(self): if self._level == ShellModel.ZOOM_HOME: self._home_box.resume() elif self._level == ShellModel.ZOOM_MESH: self._mesh_box.resume() + elif self._level == ShellModel.ZOOM_ACTIVITY: + self.launch_box.resume() def _visibility_notify_event_cb(self, window, event): if event.state == gtk.gdk.VISIBILITY_FULLY_OBSCURED: @@ -124,6 +131,8 @@ class HomeWindow(gtk.Window): size = style.LARGE_ICON_SIZE elif level == ShellModel.ZOOM_MESH: size = style.STANDARD_ICON_SIZE + elif level == ShellModel.ZOOM_ACTIVITY: + size = style.XLARGE_ICON_SIZE self._transition_box.set_size(size) @@ -135,6 +144,8 @@ class HomeWindow(gtk.Window): elif self._level == ShellModel.ZOOM_MESH: self._canvas.set_root(self._mesh_box) self._mesh_box.focus_search_entry() + elif self._level == ShellModel.ZOOM_ACTIVITY: + self._canvas.set_root(self.launch_box) def get_home_box(self): return self._home_box diff --git a/src/view/home/Makefile.am b/src/view/home/Makefile.am index 4ae3410..5306e2b 100644 --- a/src/view/home/Makefile.am +++ b/src/view/home/Makefile.am @@ -5,6 +5,7 @@ sugar_PYTHON = \ activitiesring.py \ FriendView.py \ FriendsBox.py \ + launchbox.py \ HomeBox.py \ HomeWindow.py \ MeshBox.py \ diff --git a/src/view/home/activitiesring.py b/src/view/home/activitiesring.py index 1d3c9d3..dccb066 100644 --- a/src/view/home/activitiesring.py +++ b/src/view/home/activitiesring.py @@ -172,16 +172,16 @@ class CurrentActivityIcon(CanvasIcon, hippo.CanvasItem): CanvasIcon.__init__(self, cache=True) self._home_model = shellmodel.get_instance().get_home() - if self._home_model.get_pending_activity() is not None: - self._update(self._home_model.get_pending_activity()) + if self._home_model.get_active_activity() is not None: + self._update(self._home_model.get_active_activity()) - self._home_model.connect('pending-activity-changed', - self.__pending_activity_changed_cb) + self._home_model.connect('active-activity-changed', + self.__active_activity_changed_cb) self.connect('button-release-event', self.__button_release_event_cb) def __button_release_event_cb(self, icon, event): - self._home_model.get_pending_activity().get_window().activate(1) + self._home_model.get_active_activity().get_window().activate(1) def _update(self, home_activity): _logger.debug('CurrentActivityIcon._update') @@ -195,7 +195,7 @@ class CurrentActivityIcon(CanvasIcon, hippo.CanvasItem): palette = CurrentActivityPalette(home_activity) self.set_palette(palette) - def __pending_activity_changed_cb(self, home_model, home_activity): + def __active_activity_changed_cb(self, home_model, home_activity): self._update(home_activity) class RingLayout(gobject.GObject, hippo.CanvasLayout): diff --git a/src/view/home/launchbox.py b/src/view/home/launchbox.py new file mode 100644 index 0000000..a70cb61 --- /dev/null +++ b/src/view/home/launchbox.py @@ -0,0 +1,94 @@ +# Copyright (C) 2008, Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +import hippo +import gobject +import logging + +from sugar.graphics import style +from sugar.graphics import animator +from sugar.graphics.xocolor import XoColor + +from model import shellmodel +from view.pulsingicon import CanvasPulsingIcon + +class LaunchBox(hippo.CanvasBox): + def __init__(self): + gobject.GObject.__init__( + self, background_color=style.COLOR_WHITE.get_int()) + + self._activity_icon = CanvasPulsingIcon() + + # FIXME support non-xo colors in CanvasPulsingIcon + self._activity_icon.props.base_color = \ + XoColor('%s,%s' % (style.COLOR_BUTTON_GREY.get_svg(), + style.COLOR_TRANSPARENT.get_svg())) + + vbox = hippo.CanvasBox(orientation=hippo.ORIENTATION_VERTICAL) + vbox.append(self._activity_icon, hippo.PACK_EXPAND) + self.append(vbox, hippo.PACK_EXPAND) + + self._animator = animator.Animator(1.0) + + self._home = shellmodel.get_instance().get_home() + self._home.connect('active-activity-changed', + self.__active_activity_changed_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() + self._animator.add(_Animation(self._activity_icon, + 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: + 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 + + def __active_activity_changed_cb(self, model, activity): + self._update_icon() + +class _Animation(animator.Animation): + def __init__(self, icon, start_size, end_size): + animator.Animation.__init__(self, 0.0, 1.0) + + self._icon = icon + self.start_size = start_size + self.end_size = end_size + + def next_frame(self, current): + d = (self.end_size - self.start_size) * current + self._icon.props.size = self.start_size + d |