[Code-review] [sugar] [PATCH] Reset activity icons when clicked/launched (#7273, #7274)

Tomeu Vizoso tomeu at tomeuvizoso.net
Sun Jun 22 03:16:15 EDT 2008


r+ Thanks!

On Sun, Jun 22, 2008 at 4:05 AM, Eben Eliason <eben.eliason at gmail.com> wrote:
> Good points.  This new patch addresses the points brought up, and also
> cleans things up a bit by naming the hovering event appropriately, and
> by homogenizing the classes in the two files a bit.
>
> ---
>  src/view/home/activitieslist.py |   31 +++++++++++++++++++++----------
>  src/view/home/favoritesview.py  |   22 ++++++++++++++--------
>  2 files changed, 35 insertions(+), 18 deletions(-)
>
> diff --git a/src/view/home/activitieslist.py b/src/view/home/activitieslist.py
> index 5dab09d..e542859 100644
> --- a/src/view/home/activitieslist.py
> +++ b/src/view/home/activitieslist.py
> @@ -105,22 +105,33 @@ class ActivitiesList(gtk.ScrolledWindow):
>  class ActivityIcon(CanvasIcon):
>     def __init__(self, activity_info):
>         CanvasIcon.__init__(self, size=style.STANDARD_ICON_SIZE, cache=True,
> -                            file_name=activity_info.icon,
> -                            stroke_color=style.COLOR_BUTTON_GREY.get_svg(),
> -                            fill_color=style.COLOR_TRANSPARENT.get_svg())
> +                            file_name=activity_info.icon)
>         self._activity_info = activity_info
> +        self._uncolor()
>         self.connect('hovering-changed', self.__hovering_changed_event_cb)
> -
> -    def __hovering_changed_event_cb(self, icon, event):
> -        if event:
> -            self.props.xo_color = profile.get_color()
> -        else:
> -            self.props.stroke_color = style.COLOR_BUTTON_GREY.get_svg()
> -            self.props.fill_color = style.COLOR_TRANSPARENT.get_svg()
> +        self.connect('button-release-event', self.__button_release_event_cb)
>
>     def create_palette(self):
>         return ActivityPalette(self._activity_info)
>
> +    def _color(self):
> +        self.props.xo_color = profile.get_color()
> +
> +    def _uncolor(self):
> +        self.props.stroke_color = style.COLOR_BUTTON_GREY.get_svg()
> +        self.props.fill_color = style.COLOR_TRANSPARENT.get_svg()
> +
> +    def __hovering_changed_event_cb(self, icon, hovering):
> +        if hovering:
> +            self._color()
> +        else:
> +            self._uncolor()
> +
> +    def __button_release_event_cb(self, icon, event):
> +        self.palette.popdown(immediate=True)
> +        self._uncolor()
> +
> +
>  class ActivityEntry(hippo.CanvasBox, hippo.CanvasItem):
>     __gtype_name__ = 'SugarActivityEntry'
>
> diff --git a/src/view/home/favoritesview.py b/src/view/home/favoritesview.py
> index a6e2268..1c948e8 100644
> --- a/src/view/home/favoritesview.py
> +++ b/src/view/home/favoritesview.py
> @@ -268,23 +268,29 @@ class ActivityIcon(CanvasIcon):
>     def __init__(self, activity_info):
>         CanvasIcon.__init__(self, cache=True, file_name=activity_info.icon)
>         self._activity_info = activity_info
> +        self._uncolor()
>         self.connect('hovering-changed', self.__hovering_changed_event_cb)
>         self.connect('button-release-event', self.__button_release_event_cb)
>
> -        self.props.stroke_color = style.COLOR_BUTTON_GREY.get_svg()
> -        self.props.fill_color = style.COLOR_TRANSPARENT.get_svg()
> -
>     def create_palette(self):
>         return ActivityPalette(self._activity_info)
>
> -    def __hovering_changed_event_cb(self, icon, event):
> -        if event:
> -            self.props.xo_color = get_profile().color
> +    def _color(self):
> +        self.props.xo_color = get_profile().color
> +
> +    def _uncolor(self):
> +        self.props.stroke_color = style.COLOR_BUTTON_GREY.get_svg()
> +        self.props.fill_color = style.COLOR_TRANSPARENT.get_svg()
> +
> +    def __hovering_changed_event_cb(self, icon, hovering):
> +        if hovering:
> +            self._color()
>         else:
> -            self.props.stroke_color = style.COLOR_BUTTON_GREY.get_svg()
> -            self.props.fill_color = style.COLOR_TRANSPARENT.get_svg()
> +            self._uncolor()
>
>     def __button_release_event_cb(self, icon, event):
> +        self.palette.popdown(immediate=True)
> +        self._uncolor()
>         view.Shell.get_instance().start_activity(self._activity_info.bundle_id)
>
>     def get_bundle_id(self):
> --
>
> Thanks!
>
> - Eben
>
>
>
> On Sat, Jun 21, 2008 at 4:56 AM, Tomeu Vizoso <tomeu at tomeuvizoso.net> wrote:
>> On Sat, Jun 21, 2008 at 1:14 AM, Eben Eliason <eben.eliason at gmail.com> wrote:
>>> The act of clicking on an activity icon in Home to launch it
>>> switches the view to the launcher, eliminating the expected
>>> hovering-changed event (leave).  This commit hides the palette
>>> instantly (it used to remain visible in the launcher) and
>>> un-colors the icon (which used to remain colored when returning
>>> to Home).
>>>
>>> ---
>>>  src/view/home/activitieslist.py |   11 ++++++++++-
>>>  src/view/home/favoritesview.py  |    8 +++++++-
>>>  2 files changed, 17 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/src/view/home/activitieslist.py b/src/view/home/activitieslist.py
>>> index 5dab09d..8086b7b 100644
>>> --- a/src/view/home/activitieslist.py
>>> +++ b/src/view/home/activitieslist.py
>>> @@ -110,6 +110,9 @@ class ActivityIcon(CanvasIcon):
>>>                             fill_color=style.COLOR_TRANSPARENT.get_svg())
>>>         self._activity_info = activity_info
>>>         self.connect('hovering-changed', self.__hovering_changed_event_cb)
>>> +        self.connect('button-release-event', self.__button_release_event_cb)
>>> +
>>> +        self._palette = None
>>
>> No need to keep track of the palette, we can access it with
>> self.palette (is a property of CanvasIcon).
>>
>>>     def __hovering_changed_event_cb(self, icon, event):
>>>         if event:
>>> @@ -118,8 +121,14 @@ class ActivityIcon(CanvasIcon):
>>>             self.props.stroke_color = style.COLOR_BUTTON_GREY.get_svg()
>>>             self.props.fill_color = style.COLOR_TRANSPARENT.get_svg()
>>>
>>> +    def __button_release_event_cb(self, icon, event):
>>> +        self._palette.popdown(immediate=True)
>>> +        self.props.stroke_color = style.COLOR_BUTTON_GREY.get_svg()
>>> +        self.props.fill_color = style.COLOR_TRANSPARENT.get_svg()
>>
>> Perhaps we shouldn't duplicate this set of colors, maybe a
>> _restore_colors() method could be created?
>>
>>> +
>>>     def create_palette(self):
>>> -        return ActivityPalette(self._activity_info)
>>> +        self._palette = ActivityPalette(self._activity_info)
>>> +        return self._palette
>>>
>>>  class ActivityEntry(hippo.CanvasBox, hippo.CanvasItem):
>>>     __gtype_name__ = 'SugarActivityEntry'
>>> diff --git a/src/view/home/favoritesview.py b/src/view/home/favoritesview.py
>>> index a6e2268..6e56db5 100644
>>> --- a/src/view/home/favoritesview.py
>>> +++ b/src/view/home/favoritesview.py
>>> @@ -274,8 +274,11 @@ class ActivityIcon(CanvasIcon):
>>>         self.props.stroke_color = style.COLOR_BUTTON_GREY.get_svg()
>>>         self.props.fill_color = style.COLOR_TRANSPARENT.get_svg()
>>>
>>> +        self._palette = None
>>> +
>>>     def create_palette(self):
>>> -        return ActivityPalette(self._activity_info)
>>> +        self._palette = ActivityPalette(self._activity_info)
>>> +        return self._palette
>>>
>>>     def __hovering_changed_event_cb(self, icon, event):
>>>         if event:
>>> @@ -285,6 +288,9 @@ class ActivityIcon(CanvasIcon):
>>>             self.props.fill_color = style.COLOR_TRANSPARENT.get_svg()
>>>
>>>     def __button_release_event_cb(self, icon, event):
>>> +        self._palette.popdown(immediate=True)
>>> +        self.props.stroke_color = style.COLOR_BUTTON_GREY.get_svg()
>>> +        self.props.fill_color = style.COLOR_TRANSPARENT.get_svg()
>>>         view.Shell.get_instance().start_activity(self._activity_info.bundle_id)
>>>
>>>     def get_bundle_id(self):
>>
>> Same for favorites as for the list.
>>
>> Thanks,
>>
>> Tomeu
>>
>


More information about the Code-review mailing list