gtk_label_set_attributes



How can I set attributes to text in gtk_label using Pango attribute
list? I tried follwing approach:

#include <gtk/gtk.h>

int main(int argc, char **argv)
{
    GtkWidget *window;
    GtkWidget *label;
    PangoAttrList       *attr_lst;
    PangoAttribute      *attr;
    
    gtk_init (&argc, &argv);
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_container_set_border_width (GTK_CONTAINER (window), 10);
   

    label = gtk_label_new("label");
    
    gtk_label_set_use_markup(GTK_LABEL(label), FALSE);
    gtk_label_set_use_underline(GTK_LABEL(label), FALSE);
    
    /* i want *bold* text */
    attr = pango_attr_weight_new(PANGO_WEIGHT_HEAVY);
    attr_lst = pango_attr_list_new();
    
    /* add my attribute to the list */
    pango_attr_list_insert(attr_lst, attr);
    /* and set my label to use this list */
    gtk_label_set_attributes(GTK_LABEL(label), attr_lst);
    
    /* blablabla... */
    gtk_container_add (GTK_CONTAINER (window), label);
    gtk_widget_show (label);
    gtk_widget_show (window);
    gtk_main ();
    
    return 0;
}

gtk_label_set_attributes() seems to have no effect, the text has always
normal weight. What am I doing wrong? Can anyone point me to some
examples and/or documentation about using pango attr lists?

-- 
[Krzysztof Luks]
[kluks<at>iq.pl]




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