if ico==None:
ico=getIconPath(idef, iconsize)
- ret=gtk.gdk.pixbuf_new_from_file_at_size(ico, iconsize, iconsize)
+ try:
+ ret=gtk.gdk.pixbuf_new_from_file_at_size(ico, iconsize, iconsize)
+ except:
+ # On error use the default icon
+ ico=getIconPath(idef, iconsize)
+ ret=gtk.gdk.pixbuf_new_from_file_at_size(ico, iconsize, iconsize)
+ print "Icon with unhandled format:", iname
return(ret)
self.name=None
self.icon=None
self.sicon=None
+ self.sthemebg1=None
+ self.sthemebg2=None
self.lastpress=0
self.ispressed=False
return(s)
+ def get_sthemebg(self, pressed):
+ """ Return the theme's background icon as a surface. Cache it. """
+ if not pressed and self.sthemebg1!=None:
+ return(self.sthemebg1)
+ if pressed and self.sthemebg2!=None:
+ return(self.sthemebg2)
+
+ fn="/etc/hildon/theme/images/"
+ if pressed:
+ fn+="ApplicationShortcutAppletPressed.png"
+ else:
+ fn+="ApplicationShortcutApplet.png"
+
+ w=self.config.themebgsize
+ buf=gtk.gdk.pixbuf_new_from_file_at_size(fn, w, w)
+ s=cairo.ImageSurface(cairo.FORMAT_ARGB32, w, w)
+ cr0=cairo.Context(s)
+ cr=gtk.gdk.CairoContext(cr0)
+
+ cr.set_source_pixbuf(buf, 0, 0)
+ cr.paint()
+
+ if not pressed:
+ self.sthemebg1=s
+ else:
+ self.sthemebg2=s
+
+ return(s)
+
def get_sicon(self):
""" Return the icon as a surface. Cache it. """
if self.sicon!=None:
cr=gtk.gdk.CairoContext(cr0)
# Paint the background
- s2=self.mkbg(t)
- cr.save()
- cr.set_source_surface(s2, 0, 0)
- cr.paint()
- cr.restore()
+ if self.config.getNoBg():
+ pass
+ elif self.config.getThemeBg(): # Use theme bg
+ s2=self.get_sthemebg(pressed)
+
+ # have in mind the size difference of iconsize+iconspace with
+ # the fixed themebgsize
+ xy0=int((w-self.config.themebgsize)/2)
+
+ cr.save()
+ cr.set_source_surface(s2, xy0, xy0)
+ cr.paint()
+ cr.restore()
+ else:
+ s2=self.mkbg(t)
+ cr.save()
+ cr.set_source_surface(s2, 0, 0)
+ cr.paint()
+ cr.restore()
# If there is no icon then don't do anything more
if self.icon!=None:
return
if self.draw_queued:
- print "queued"
+# print "queued"
return
+
self.draw_queued=True
w=self.config.iconsize + self.config.iconspace
rect=gdk.Rectangle(self.x, self.y, w, w)