Use rsvg wrapper while rsvg gains introspection support

Signed-off-by: Raul Gutierrez Segales <rgs@collabora.co.uk>
This commit is contained in:
Raul Gutierrez Segales 2011-10-30 23:08:51 +00:00 committed by Simon Schampijer
parent 3372317922
commit 82fcf0a0f0

View File

@ -32,6 +32,7 @@ import cairo
from sugar3.graphics.xocolor import XoColor from sugar3.graphics.xocolor import XoColor
from sugar3.util import LRU from sugar3.util import LRU
from gi.repository import SugarExt
_BADGE_SIZE = 0.45 _BADGE_SIZE = 0.45
@ -60,9 +61,7 @@ class _SVGLoader(object):
logging.error( logging.error(
'Icon %s, entity %s is invalid.', file_name, entity) 'Icon %s, entity %s is invalid.', file_name, entity)
# XXX this is very slow! why? return SugarExt.RsvgWrapper.new(icon)
import rsvg
return rsvg.Handle(data=icon)
class _IconInfo(object): class _IconInfo(object):
@ -165,9 +164,8 @@ class _IconBuffer(object):
if badge_file_name.endswith('.svg'): if badge_file_name.endswith('.svg'):
handle = self._loader.load(badge_file_name, {}, self.cache) handle = self._loader.load(badge_file_name, {}, self.cache)
dimensions = handle.get_dimension_data() icon_width = handle.get_width()
icon_width = int(dimensions[0]) icon_height = handle.get_height()
icon_height = int(dimensions[1])
pixbuf = handle.get_pixbuf() pixbuf = handle.get_pixbuf()
else: else:
@ -259,9 +257,8 @@ class _IconBuffer(object):
if is_svg: if is_svg:
handle = self._load_svg(icon_info.file_name) handle = self._load_svg(icon_info.file_name)
dimensions = handle.get_dimension_data() icon_width = handle.get_width()
icon_width = int(dimensions[0]) icon_height = handle.get_height()
icon_height = int(dimensions[1])
else: else:
pixbuf = GdkPixbuf.Pixbuf.new_from_file(icon_info.file_name) pixbuf = GdkPixbuf.Pixbuf.new_from_file(icon_info.file_name)
icon_width = pixbuf.get_width() icon_width = pixbuf.get_width()