/usr/share/sugar/activities/Calculate.activity/svgimage.py is in sugar-calculate-activity 43-3.
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 | # svgimage.py, svg image class by Reinier Heeres <reinier@heeres.eu>
#
# 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
#
# Change log:
# 2007-09-07: rwh, first version
import logging
_logger = logging.getLogger('SVGImage')
import gtk
import rsvg
class SVGImage:
def __init__(self, fn=None, data=None):
if fn is not None:
self.load(fn)
elif data is not None:
self.load_data(data)
def get_image(self):
return self._image
def get_svg_data(self):
return self._svg_data
def render_svg(self):
self._handle = rsvg.Handle(data=self._svg_data)
self._pixbuf = self._handle.get_pixbuf()
self._image = gtk.Image()
self._image.set_from_pixbuf(self._pixbuf)
self._image.set_alignment(0.5, 0)
return self._image
def load(self, fn):
f = open(fn, 'rb')
self._svg_data = f.read()
f.close()
return self.render_svg()
def load_data(self, svgdat):
self._svg_data = svgdat
return self.render_svg()
|