[sugar] pango on xo question

Erik Blankinship erikb at mediamods.com
Thu Nov 8 10:06:28 EST 2007


I have a pango cairo question.

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.

    def createCountdownPng( self, num ):
        todisk = True

        w = 55
        h = w
        if (todisk):
            cimg = cairo.ImageSurface(cairo.FORMAT_ARGB32, w, h)
            ctx = cairo.Context(cimg)
        else:
            pixmap = gtk.gdk.Pixmap(None, w, h, 24)
            ctx = pixmap.cairo_create()
        ctx.rectangle(0, 0, w, h)
        ctx.set_source_rgb(0, 0, 0)
        ctx.fill()
        x = 0
        y = 4
        ctx.translate(x,y)
        ctx.set_source_surface (self.__class__.recCircleCairo, 0, 0) #a
cairo surface
        ctx.paint()
        ctx.translate(-x,-y)

        ctx.set_source_rgb(255, 255, 255)
        pctx = pangocairo.CairoContext(ctx)
        play = pctx.create_layout()
        font = pango.FontDescription("sans 30")
        play.set_font_description(font)
        play.set_text( ""+str(num) )
        dim = play.get_pixel_extents()
        ctx.translate( -dim[0][0], -dim[0][1] )
        xoff = (w-dim[0][2])/2
        yoff = (h-dim[0][3])/2
        ctx.translate( xoff, yoff )
        ctx.translate( -3, 0 )
        pctx.show_layout(play)

        img = gtk.Image()
        if (todisk):
            path = os.path.join(Instance.tmpPath, str(num)+".png")
            path = utils.getUniqueFilepath(path, 0)
            cimg.write_to_png(path)
            numPixbuf = gtk.gdk.pixbuf_new_from_file(path)
            img.set_from_pixbuf( numPixbuf )
        else:
            img.set_from_pixmap(pixmap, None)

        self.__class__.countdownImgs[int(num)] = img
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.laptop.org/pipermail/sugar/attachments/20071108/7919bfd9/attachment.htm 


More information about the Sugar mailing list