A small update this time.  I rewrote the launchbox.py file.  This
version uses a simple CanvasBox, eliminating the need for a complex
layout class for what amounts to a centered icon.  I also eliminated
some old code that was leftover from my early tests.  Finally, I
implemented the suspend/resume methods for the class, so that the icon
only pulses when it's visible.  Note that the suspend/resume methods
require a small patch to HomeWindow.py, which calls them, but I'm not
going to resend the entire patch to change those two lines at the
moment...I just wanted those looking over this work in progress to see
the cleaner launchbox code.

- Eben

On Fri, Apr 18, 2008 at 1:21 PM, Eben Eliason <[EMAIL PROTECTED]> wrote:
> Here's my second pass at the launcher patch.  This version changes
>  little in the actual behavior of the code, but substantially cleans up
>  the code itself.  I pulled all of the "pending_activity" code out,
>  simplifying the model a good deal, as we no longer need it with the
>  new Home design.  I also re-factored the flow of the launch (and
>  launch failed) notifications, unifying so that everything occurs first
>  in the model which then sends signals to the view, rather than having
>  the view call the model in some cases and vice versa, which led to
>  inconsistencies.
>
>  These changes also made the calls to notify_launch in the shell
>  cleaner, passing the home_activity object instead of several other
>  parameters, which in turn cleaned up the call stack for
>  setting/changing the launching activity icon.  I'm much more satisfied
>  here.
>
>  The main problem that remains is that the launching activity feedback
>  is still mostly maintained within the view.  The model remains
>  unchanged from before.  We need to clean this up so that a launching
>  activity (which doesn't yet have a window) can still be considered
>  active in the model, so that the view always properly reflects the
>  model instead of tiptoeing around it to achieve the launching feedback
>  effect.
>
>  Thoughts on how to best achieve this goal are welcomed, as it gets a
>  bit more intimate with the window management business that I'm
>  unfamiliar with.
>
>  - Eben
>
>
>
>
>  On Thu, Apr 17, 2008 at 1:19 AM, Eben Eliason <[EMAIL PROTECTED]> wrote:
>  > This patch is mainly for Marco, who plans to help me finish and clean
>  >  up the new activity launcher.  It's currently full of TODOs, comments,
>  >  temporary hacks, etc, but it's in a "nearly complete" state inasmuch
>  >  as it will run smoothly despite the partially unfinished and poorly
>  >  styled implementation.
>  >
>  >  Also, launchbox.py is a new file to be added to src/view/home/ in
>  >  addition to applying the patch, and of course you'll need to edit the
>  >  Makefile to include it as well.
>  >
>  >  Marco, take a peek at the various comments I've made; I look forward
>  >  to hearing your thoughts on the remainder.  It's looking good so far.
>  >
>  >  - Eben
>  >
>
# Copyright (C) 2007, 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

from sugar.graphics import style
from sugar.graphics import animator
from sugar.graphics.xocolor import XoColor

from view.pulsingicon import CanvasPulsingIcon

class LaunchBox(hippo.CanvasBox):
    def __init__(self):
        hippo.CanvasBox.__init__(self, 
                                 background_color=style.COLOR_WHITE.get_int())

        self._suspended = True

        self._activity_icon = 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(0.3)
        #self._animator.connect('completed', self._animation_completed_cb)

    # We could initiate pulsing after the zoom, if it has caching benefits
    #def _animation_completed_cb(self, anim):
    #    self._activity_icon.props.pulsing = True

    def set_activity(self, home_activity, zoom=False):
        self._activity_icon.props.file_name = home_activity.get_icon_path()
        self._activity_icon.props.pulse_color = home_activity.get_icon_color()
        if zoom:
            self._zoom_in()

    def _zoom_in(self):
        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()
        self._activity_icon.props.pulsing = True

    def suspend(self):
        if not self._suspended:
            self._suspended = True
            self._activity_icon.props.paused = True

    def resume(self):
        if self._suspended:
            self._suspended = False
            self._activity_icon.props.paused = True


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
_______________________________________________
Sugar mailing list
[email protected]
http://lists.laptop.org/listinfo/sugar

Reply via email to