How to force the refresh of a GTKTreeView in a multithreaded app?

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

 



I've developed a very simple application in GTK2. This application 
receives events from a socket and based on them, updates the values in a 
GTKTreeView.

The problem that arises is that the items displayed in the TreeView are 
not updated until I move the mouse.

The application is something like this:


main()
{
   g_thread_init (NULL);
   gdk_threads_init ();
   gdk_threads_enter ();
   gtk_init (&argc, &argv);

   ...

   // Create the window Widget
   createWindow(gtkWindow);
   createThread(SocketEvents);  // NOTICE THIS, A NEW THREAD IS CREATED
                                // TO UPDATE THE GUI
   gtk_widget_show_all(gtkWindow);
   ...

   gtk_main();
   gdk_threads_leave ();
}

and inside the SocketEvents thread function, I update the GTKListStore 
associated to the GTKTreeView with no luck. The code looks like this:

SocketEvents()
{
   ...
   while(1){
     <receive an event from a socket>
     ....
     gdk_threads_enter();
     gtk_list_store_set(....);
     gtk_widget_queue_draw(GTK_WIDGET(gtkTreeView));
     while (gtk_events_pending ())
       gtk_main_iteration ();
     gdk_threads_leave();
   }
}

However, in this case, I receive the following error:

(MyAPP:12142): GLib-WARNING **: g_main_context_prepare(): main loop 
already active in another thread
Xlib: unexpected async reply (sequence 0x1ee7)!

GLib-ERROR **: file gmain.c: line 1906 (g_main_dispatch): assertion 
failed: (source)
aborting...

Can anybody give me a clue about how do I have to update the list store
to be able to see my changes reflected in the screen right away?

Thanks a lot for your attention and help.

-- 
Attn.
Alvaro Palma
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux