Qball's Weblog

GTK Question

Tags gmpc  Grind My Gears 

I have a custom GtkContainer class that nicely  orders widgets in an array, supports headers etc.  (it is very simple)

See: http://images.sarine.nl/gmpc-metadata-search3.png and http://images.sarine.nl/gmpc-album-view-updated.png

but i am having the following issue:

if you: Remove the widget from a container (while keeping a reference around)

then: Add it to a container again it takes a long time. (up to several seconds.)

Now today I had a few minutes to hunt down where this time was spend, and it turns out to be spend in the:  “reset_rc_styles_recurse”, this is an internal GTK function. Further investigation turned out that this function takes around 1.3 ms (worstcase) for each widget packed in the container.   The widget it is called on consists out of a an eventbox, with a hbox in it, an image and 2 labels.  So not very big.  Removing the 2 labels reduces the time to 0.6,  removing the image and keeping the label causes a similar speedup.

But why does it take this long?  If  I have 1300 albums in the list it just takes crazy long, for something that hasn’t even changed…