Example #1
0
    def _draw_gi(self, cr):
        gtk.gdk.cairo_set_source_pixbuf(cr, self._pixbuf, 0, 0)
        cr.paint()

        cr.set_source_rgb(.1, .1, .1)
        layout = pangocairo.create_layout(cr)
        desc = pango.FontDescription('Sans 14')
        layout.set_font_description(desc)
        layout.set_markup(self._get_label(), -1)
        pangocairo.update_layout(cr, layout)
        w, h = layout.get_pixel_size()
        cr.move_to(WIDTH - w - BORDER, HEIGHT - h - BORDER)
        pangocairo.show_layout(cr, layout)
Example #2
0
    def _draw_gi(self, cr):
        gtk.gdk.cairo_set_source_pixbuf(cr, self._pixbuf, 0, 0)
        cr.paint()

        cr.set_source_rgb(.1, .1, .1)
        layout = pangocairo.create_layout(cr)
        desc = pango.FontDescription('Sans 14')
        layout.set_font_description(desc)
        layout.set_markup(self._get_label(), -1)
        pangocairo.update_layout(cr, layout)
        w, h = layout.get_pixel_size()
        cr.move_to(WIDTH - w - BORDER, HEIGHT - h - BORDER)
        pangocairo.show_layout(cr, layout)
Example #3
0
    def _draw_gi(self, cr):
        gtk.gdk.cairo_set_source_pixbuf(cr, self._pixbuf, 0, 0)
        cr.paint()

        cr.set_source_rgb(.8, .8, .8)
        layout = pangocairo.create_layout(cr)
        desc = pango.FontDescription('Sans 12')
        layout.set_font_description(desc)
        layout.set_alignment(pango.ALIGN_CENTER)
        layout.set_markup(self._get_label(), -1)
        pangocairo.update_layout(cr, layout)
        w, h = layout.get_pixel_size()
        cr.move_to((WIDTH - w) / 2, (HEIGHT / 2) + h)
        pangocairo.show_layout(cr, layout)
Example #4
0
    def _draw_gi(self, cr):
        gtk.gdk.cairo_set_source_pixbuf(cr, self._pixbuf, 0, 0)
        cr.paint()

        cr.set_source_rgb(.8, .8, .8)
        layout = pangocairo.create_layout(cr)
        desc = pango.FontDescription('Sans 12')
        layout.set_font_description(desc)
        layout.set_alignment(pango.ALIGN_CENTER)
        layout.set_markup(self._get_label(), -1)
        pangocairo.update_layout(cr, layout)
        w, h = layout.get_pixel_size()
        cr.move_to((WIDTH - w) / 2, (HEIGHT / 2) + h)
        pangocairo.show_layout(cr, layout)
Example #5
0
    def draw_text(x, y, text, font, text_color, spacing, c):
        c.save()
        c.set_source_rgba(*rgb_to_cairo(text_color))
        font = cairo_font(font)

        c.translate(x, y)

        if use_pygobject:
            status, attrs, plain_text, _ = pango.parse_markup(
                text, len(text), '\0')

            layout = pangocairo.create_layout(c)
            pctx = layout.get_context()
            fo = cairo.FontOptions()
            fo.set_antialias(cairo.ANTIALIAS_SUBPIXEL)
            pangocairo.context_set_font_options(pctx, fo)
            layout.set_font_description(font)
            layout.set_spacing(spacing * pango.SCALE)
            layout.set_text(plain_text, len(plain_text))
            layout.set_attributes(attrs)
            pangocairo.update_layout(c, layout)
            pangocairo.show_layout(c, layout)

        else:  # pyGtk
            attrs, plain_text, _ = pango.parse_markup(text)

            pctx = pangocairo.CairoContext(c)
            pctx.set_antialias(cairo.ANTIALIAS_SUBPIXEL)
            layout = pctx.create_layout()
            layout.set_font_description(font)
            layout.set_spacing(spacing * pango.SCALE)
            layout.set_text(plain_text)
            layout.set_attributes(attrs)
            pctx.update_layout(layout)
            pctx.show_layout(layout)

        c.restore()
Example #6
0
def show_layout(ctx, layout):
    if gtk_major_version == 3:
        pangocairo.show_layout(ctx, layout)
    else:
        ctx.show_layout(layout)