2
# -*- coding: utf-8 -*-
6
__authors__ = ["Jan Jokela <janjokela@gmail.com>"]
7
__licenses__ = ["LICENSE.LGPL"]
8
__description__ = "Pixbuf image"
14
class PixbufImage(clutter.Texture):
16
""" A clutter.Texture based on a gtk.gdk.pixbuf """
18
__gproperties__ = {'uri': (gobject.TYPE_STRING,
20
'pixbuf uri, standard uri formats apply',
22
gobject.PARAM_READWRITE),
23
'ratio': (gobject.TYPE_FLOAT,
25
'width-height ratio, if value is 0, no ratio '
30
gobject.PARAM_READWRITE),
31
'ratio_lock': (gobject.TYPE_STRING,
32
'lock ratio to width or height',
33
'lock ratio to width or height',
35
gobject.PARAM_READWRITE)
38
def __init__(self, uri, ratio=1.0, ratio_lock='width'):
41
uri (str) -- source location, standard uri format
42
ratio (float) -- ratio depending on ratio_lock, 0.0 none is applied
43
ratio_lock (str) -- locks ratio to width or height
48
self.ratio_lock = ratio_lock
50
self.__gobject_init__(uri=self.uri, ratio=self.ratio, ratio_lock=self.ratio_lock)
52
clutter.Texture.__init__(self)
56
def do_get_property(self, property):
57
""" Get GObject property """
59
if property.name == 'uri':
61
elif property.name == 'ratio':
63
elif property.name == 'ratio-lock':
64
return self.ratio_lock
66
raise AttributeError, 'unknown property: %s' % property.name
68
def do_set_property(self, property, value):
69
""" Set GObject property """
71
if property.name == 'uri':
73
elif property.name == 'ratio':
75
elif property.name == 'ratio-lock':
76
self.ratio_lock = value
78
raise AttributeError, 'unknown property: %s' % property.name
80
def _set_pixbuf(self):
81
""" Sets pixbuf based on source """
83
pixbuf = gdk.pixbuf_new_from_file(self.uri)
84
self.set_pixbuf(pixbuf)
87
gobject.type_register(PixbufImage)