1 # Copyright (C) 2006, Red Hat, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 from sugar
.graphics
.icon
import CanvasIcon
21 from sugar
.graphics
import style
22 from sugar
import profile
24 class KeepIcon(CanvasIcon
):
26 'keep' : (bool, None, None, False,
27 gobject
.PARAM_READWRITE
)
30 def __init__(self
, keep
):
31 CanvasIcon
.__init
__(self
, icon_name
='emblem-favorite',
32 box_width
=style
.GRID_CELL_SIZE
* 3 / 5,
33 size
=style
.SMALL_ICON_SIZE
)
34 self
.connect('motion-notify-event', self
.__motion
_notify
_event
_cb
)
39 def _set_keep(self
, keep
):
40 if keep
== self
._keep
:
45 self
.props
.xo_color
= profile
.get_color()
47 self
.props
.stroke_color
= style
.COLOR_BUTTON_GREY
.get_svg()
48 self
.props
.fill_color
= style
.COLOR_TRANSPARENT
.get_svg()
50 def do_set_property(self
, pspec
, value
):
51 if pspec
.name
== 'keep':
54 CanvasIcon
.do_set_property(self
, pspec
, value
)
56 def do_get_property(self
, pspec
):
57 if pspec
.name
== 'keep':
60 return CanvasIcon
.do_get_property(self
, pspec
)
62 def __motion_notify_event_cb(self
, icon
, event
):
64 if event
.detail
== hippo
.MOTION_DETAIL_ENTER
:
65 icon
.props
.fill_color
= style
.COLOR_BUTTON_GREY
.get_svg()
66 elif event
.detail
== hippo
.MOTION_DETAIL_LEAVE
:
67 icon
.props
.fill_color
= style
.COLOR_TRANSPARENT
.get_svg()