Dear Yann,
You can load data to tree store from a worker thread. I have done
this once where I am populating a tree store form a jumbo XML file
and showing percentage of loading on the UI. I suppose you are
also looking for the same.
For cooking this dish you'll need the following.
- A UI thread (which you already have),
- A worker thread to parse the file and add data to tree store
- a Glib::Dispatcher to send completion status updates from
worker thread to UI thread
- A member variable in your class where the worker thread
shares the completion status and
- a Glib::Mutex to protect to shared resource.
And this is how you cook it.
- Create a member function and connect it to the
Glib::Dispatcher object. This function starts with a
Glib::Mutex::Lock and displays the percentage completion.
- Disconnect the tree view from the tree store. Leaving it
connected brings you serious speed issues and additionally its
not a good idea to control any UI element from within a thread
other than the main thread (gdk_threads_enter and leave never
helped me! may be I was doing something wrong altogether).
- Start a worker thread (implemented as a private member
function of the same class) passing it the file from which to
load.
- Update the completion variable from the worker thread and
trigger the Glib::Dispatcher object as you progress (don't
forget about Glib::Mutex::Lock). I would do this once in 250
milliseconds.
- Once your loading is complete, connect the tree store back
to the tree view.
This should get you started.
regards
Mohith Manoj,
Asst. Manager (R&D),
Skanray Technologies PVT.LTD
Web: www.skanray.com
On 8/2/2013 6:47 PM, Yann Leydier wrote:
Thanks Kevin.
I know of the dispatcher but the problem is that I need to fill a
TreeStore: the data is very complex and hard to send through a
dispatcher.
Does anyone know if filing a store that is not bound to any
TreeView would be ok (out of the main thread, I mean)? Is so, I
could just swap the TreeView's store with the new one.
Thanks
yann
On 02/08/13 15:10, Kevin Brightwell
wrote:
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
https://mail.gnome.org/mailman/listinfo/gtkmm-list
---
avast! Antivirus: Inbound message clean.
Virus Database (VPS): 130802-2, 08/03/2013
Tested on: 8/3/2013 9:05:39 AM
avast! - copyright (c) 1988-2013 AVAST Software.
http://www.avast.com