gtkmm - How to fill Gtk::TreeModelColumn with a large dataset without locking up the application -
i need fill in large (maybe not - several thousands of entries) dataset gtk::treemodelcolumn. how do without locking application. safe put processing separate thread? parts of application have protect lock then? gtk::treemodelcolumn class, or gtk::treeview widget placed in, or maybe surrounding frame or window?
there 2 general approaches take. (disclaimer: i've tried provide example code, use gtkmm - i'm more familiar gtk in c. principles remain same, however.)
one use idle function - runs whenever nothing's happening in gui. best results, small amount of calculation in idle function, adding 1 item treeview. if return true
idle function, called again whenever there more processing time available. if return false
, not called again. part idle functions don't have lock anything. can define idle function this:
bool fill_column(gtk::treemodelcolumn* column) { // add item column return !column_is_full(); }
then start process this:
glib::signal_idle().connect(sigc::bind(&fill_column, column));
the other approach use threads. in c api, involve gdk_threads_enter()
, friends, gather proper way in gtkmm, use glib::dispatcher
. haven't used before, here example of it. however, can still use c api gtkmm, pointed out here.
Comments
Post a Comment