I added your code, and it DOES stop the display from resizing widgets when the labels display small values, but it DOES NOT drop cpu usage at all. so internally GTK+ is still going something with regards to the labels. If I comment out gtk_label_set_text() in my code cpu usage drops from 45% to 4%. (dual cpu AMD 2.1Ghz, 3GB ram) --- jcupitt@xxxxxxxxx wrote: > On 3/26/07, David J. Andruczyk <djandruczyk@xxxxxxxxx> wrote: > > I think the resizing is the culprit. I was tempted to use > > gtk_entries instead as you can assign them fixed size in > > charactors, which is easier to handle differences in font size. > > You can do that with a label too. Measure the size of the string > "8", > then call gtk_widget_set_size_request() to lock the label to 10 > (for > example) 8s across by 1 8 down. > > I do this with: > > -------------------- > /* Calculate the bounding box for a string rendered with a > widget's default > * font. Set geo to a rect with 0,0 positioned on the left-hand > baseline. > */ > void > get_geo( GtkWidget *widget, const char *text, Rect *geo ) > { > PangoLayout *layout; > int width, height; > > layout = gtk_widget_create_pango_layout( widget, text ); > pango_layout_get_pixel_size( layout, &width, &height ); > g_object_unref( layout ); > > /* FIXME ... we left/top to 0 for now. > */ > geo->width = width; > geo->height = height; > geo->left = 0; > geo->top = 0; > } > > /* Set a widget to a fixed size ... width in characters. > */ > void > set_fixed( GtkWidget *widget, int nchars ) > { > Rect geo; > > get_geo( widget, "8", &geo ); > gtk_widget_set_size_request( widget, geo.width * nchars, > geo.height ); > } > ------------ > > John > -- David J. Andruczyk ____________________________________________________________________________________ We won't tell. Get more on shows you hate to love (and love to hate): Yahoo! TV's Guilty Pleasures list. http://tv.yahoo.com/collections/265 _______________________________________________ gtk-list mailing list gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list