Re: convenience API for applying PangoAttributes to a GtkLabel



On Mon, 2007-03-12 at 18:09 -0400, Sven Neumann wrote:
> Hi,
> 
> libgimpwidgets includes an API for conveniently apply PangoAttributes to
> a GtkLabel and I wonder if I should propose it for inclusion in GTK+:
> 
> http://developer.gimp.org/api/2.0/libgimpwidgets/libgimpwidgets-GimpWidgets.html#gimp-label-set-attributes
> 
> It is IMO more convenient than using g_strdup_printf() to embed a string
> into PangoMarkup. Here's a short example to make a label large and bold:
> 
>   gimp_label_set_attributes (GTK_LABEL (label),
>                              PANGO_ATTR_SCALE,  PANGO_SCALE_LARGE,
>                              PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD,
>                              -1);
> 
> The implementation can be reviewed in
> http://svn.gnome.org/viewcvs/gimp/trunk/libgimpwidgets/gimpwidgets.c?view=markup
> 
> 
> Sven

This is nice.  Makes sense to have it in Pango in fact I guess.  As
pango_attr_list_new_something().  Probably a pango_attr_new(type, ...)
too.  The only inconsistency here is that currently the various color
attribute constructors take separate r, g, b, instead of a PangoColor *.


Feel free to file a bug.

I also spotted a typo in the implementation: For
PANGO_ATTR_STRIKETHROUGH, it's doing a pango_attr_underline_new()
instead of a pango_attr_strikethrough_new().

-- 
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]