I have a pango cairo question.<br><br>Can someone help me to understand why my variable "todisk" can be False in sugar-jhbuild, but has to be True on an xo? It would be nice to avoid writing to disk on the xo. Thanks.
<span style="font-family: courier new,monospace;"><br><br> def createCountdownPng( self, num ):</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> todisk = True
</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> w = 55</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> h = w</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> if (todisk):</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> cimg = cairo.ImageSurface(cairo.FORMAT_ARGB32, w, h)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ctx =
cairo.Context(cimg)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> else:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
pixmap = gtk.gdk.Pixmap(None, w, h, 24)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ctx = pixmap.cairo_create()</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> ctx.rectangle(0, 0, w, h)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ctx.set_source_rgb(0, 0, 0)
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ctx.fill()</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
x = 0</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> y = 4</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
ctx.translate(x,y)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ctx.set_source_surface (self.__class__.recCircleCairo, 0, 0) #a cairo surface</span>
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ctx.paint()</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
ctx.translate(-x,-y)</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ctx.set_source_rgb(255, 255, 255)
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> pctx = pangocairo.CairoContext(ctx)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
play = pctx.create_layout()</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> font = pango.FontDescription("sans 30")</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> play.set_font_description(font)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> play.set_text( ""+str(num) )
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> dim = play.get_pixel_extents()</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
ctx.translate( -dim[0][0], -dim[0][1] )</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> xoff = (w-dim[0][2])/2</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> yoff = (h-dim[0][3])/2</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ctx.translate( xoff, yoff )</span>
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ctx.translate( -3, 0 )</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
pctx.show_layout(play)</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> img = gtk.Image()</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if (todisk):</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> path = os.path.join(Instance.tmpPath
, str(num)+".png")</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> path = utils.getUniqueFilepath(path, 0)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> cimg.write_to_png(path)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> numPixbuf = gtk.gdk.pixbuf_new_from_file
(path)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> img.set_from_pixbuf( numPixbuf )</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
else:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> img.set_from_pixmap(pixmap, None)</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> self.__class__.countdownImgs[int(num)] = img</span>