[Glade-users] Sending events (somewhat OT)




---- Tristan Van Berkom <tristan.van.berkom at gmail.com> wrote: 
On Sat, Mar 14, 2009 at 12:28 AM, Steve Blackwell <zephod at cfl.rr.com> wrote:
I have written a program using glade 3 that has 2 threads. The main
thread handles user input from the GUI while the second thread monitors
a USB port for input. When data arrives at the USB port, it is processed
and written to a GtkTreeView widget.

The problem is that the data does not appear in the TreeView until I
move the mouse or press a key. I think that this is because the main
thread controlling the GUI is blocking in gtk_main() until an event
arrives. So I added code to the second thread to send a
GDK_CLIENT_EVENT to the GtkDialog widget that contains the TreeView.

It didn't work.

When you recieve data from your USB in your worker thread; call
g_idle_add() to schedule a one time idle function in the main thread.

From that function - call gtk_widget_queue_draw() on your treeview.

Unfortunately, that didn't work. I get the same results as before - ie the data is only displayed after a 
mouse or keyboard event is received. I also tried g_idle_add_full() and set the priority to 
G_PRIORITY_HIGH_IDLE but no luck there either.

Tomorrow I'll think about sending the data back to the UI thread and have that write to the treeview.

Thanks,
Steve





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