/usr/share/pyshared/jarabe/journal/keepicon.py is in python-jarabe-0.98 0.98.8-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | # Copyright (C) 2006, 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
from gi.repository import Gtk
from gi.repository import GConf
from sugar3.graphics.icon import Icon
from sugar3.graphics import style
from sugar3.graphics.xocolor import XoColor
class KeepIcon(Gtk.ToggleButton):
__gtype_name__ = 'SugarKeepIcon'
def __init__(self):
Gtk.ToggleButton.__init__(self)
self.set_relief(Gtk.ReliefStyle.NONE)
self.set_focus_on_click(False)
self._icon = Icon(icon_name='emblem-favorite',
pixel_size=style.SMALL_ICON_SIZE)
self.set_image(self._icon)
self.connect('toggled', self.__toggled_cb)
self.connect('leave-notify-event', self.__leave_notify_event_cb)
self.connect('enter-notify-event', self.__enter_notify_event_cb)
self.connect('button-press-event', self.__button_press_event_cb)
self.connect('button-release-event', self.__button_release_event_cb)
client = GConf.Client.get_default()
self._xo_color = XoColor(client.get_string(
'/desktop/sugar/user/color'))
def do_get_preferred_width(self):
return 0, style.GRID_CELL_SIZE
def do_get_preferred_height(self):
return 0, style.GRID_CELL_SIZE
def __button_press_event_cb(self, widget, event):
# We need to use a custom CSS class because in togglebuttons
# the 'active' class doesn't only match the button press, they
# can be left in the active state.
style_context = self.get_style_context()
style_context.add_class('toggle-press')
def __button_release_event_cb(self, widget, event):
style_context = self.get_style_context()
style_context.remove_class('toggle-press')
def __toggled_cb(self, widget):
if self.get_active():
self._icon.props.xo_color = self._xo_color
else:
self._icon.props.stroke_color = style.COLOR_BUTTON_GREY.get_svg()
self._icon.props.fill_color = style.COLOR_TRANSPARENT.get_svg()
def __enter_notify_event_cb(self, icon, event):
if not self.get_active():
self._icon.props.xo_color = self._xo_color
def __leave_notify_event_cb(self, icon, event):
if not self.get_active():
self._icon.props.stroke_color = style.COLOR_BUTTON_GREY.get_svg()
self._icon.props.fill_color = style.COLOR_TRANSPARENT.get_svg()
|