133
135
height == self.texture.get_height():
136
source = os.path.splitext(self.source)[0]
138
# Source filename and extension
139
source_name = os.path.splitext(self.source)[0]
137
140
source_ext = os.path.splitext(self.source)[1]
139
142
theme = Theme.get_default()
140
143
if source_ext == '.py':
141
144
source_path = os.path.join(theme.get_path(), 'resources')
145
elif os.path.exists(self.source):
146
source_path = os.path.dirname(self.source)
143
149
source_path = os.path.join(theme.get_path(), 'resources')
150
source = os.path.join(source_path, self.source)
145
152
if os.path.exists(source_path):
146
153
if source_ext == '.png':
147
self.texture = PixbufImage(
148
os.path.join(source_path, self.source)
155
self.texture = clutter.Texture(filename=source)
156
self.add(self.texture)
150
158
self.texture.set_width(width)
151
159
self.texture.set_height(height)
152
160
elif source_ext == '.svg':
154
162
self.remove(self.texture)
155
163
del(self.texture)
156
self.texture = SVGImage(os.path.join(source_path, self.source), width, height)
164
self.texture = SVGImage(source, width, height)
165
self.add(self.texture)
157
167
elif source_ext == '.py':
159
169
self.remove(self.texture)
160
170
del(self.texture)
161
source_import = os.path.basename(source)
171
source_import = os.path.basename(source_name)
162
172
sys.path[1] = source_path
163
173
cairotexture = __import__(source_import)
164
174
self.texture = cairotexture.Texture(width, height)
165
self.add(self.texture)
175
self.add(self.texture)
168
178
raise AttributeError, "source doesn't exist: %s" % source_path