Implementation of pixbufs for use with X11 window icons.

This commit is contained in:
Sebastian Silva 2014-03-23 22:21:40 -05:00
parent a082cf1cca
commit 2a7d4da38a

View File

@ -100,6 +100,7 @@ class _IconBuffer(object):
self.height = None self.height = None
self.cache = False self.cache = False
self.scale = 1.0 self.scale = 1.0
self.pixbuf = None
def _get_cache_key(self, sensitive): def _get_cache_key(self, sensitive):
if self.background_color is None: if self.background_color is None:
@ -107,7 +108,8 @@ class _IconBuffer(object):
else: else:
color = (self.background_color.red, self.background_color.green, color = (self.background_color.red, self.background_color.green,
self.background_color.blue) self.background_color.blue)
return (self.icon_name, self.file_name, self.fill_color,
return (self.icon_name, self.file_name, self.pixbuf, self.fill_color,
self.stroke_color, self.badge_name, self.width, self.height, self.stroke_color, self.badge_name, self.width, self.height,
color, sensitive) color, sensitive)
@ -252,6 +254,14 @@ class _IconBuffer(object):
if cache_key in self._surface_cache: if cache_key in self._surface_cache:
return self._surface_cache[cache_key] return self._surface_cache[cache_key]
if self.pixbuf:
# We alredy have the pixbuf for this icon.
pixbuf = self.pixbuf
icon_width = pixbuf.get_width()
icon_height = pixbuf.get_height()
icon_info = self._get_icon_info(self.file_name, self.icon_name)
is_svg = False
else:
# We run two attempts at finding the icon. First, we try the icon # We run two attempts at finding the icon. First, we try the icon
# requested by the user. If that fails, we fall back on # requested by the user. If that fails, we fall back on
# document-generic. If that doesn't work out, bail. # document-generic. If that doesn't work out, bail.
@ -365,6 +375,14 @@ class Icon(Gtk.Image):
file = GObject.property(type=object, setter=set_file, getter=get_file) file = GObject.property(type=object, setter=set_file, getter=get_file)
def get_pixbuf(self):
return self._buffer.pixbuf
def set_pixbuf(self, pixbuf):
self._buffer.pixbuf = pixbuf
pixbuf = GObject.property(type=object, setter=set_pixbuf, getter=get_pixbuf)
def _sync_image_properties(self): def _sync_image_properties(self):
if self._buffer.icon_name != self.props.icon_name: if self._buffer.icon_name != self.props.icon_name:
self._buffer.icon_name = self.props.icon_name self._buffer.icon_name = self.props.icon_name