[Glade-users] Sending events (somewhat OT)

Steve zephod at cfl.rr.com
Tue Mar 17 16:33:17 EDT 2009


---- Lukasz Gromotowicz <gromot at gmail.com> wrote: 
> Trivial question - do you enable gtk threads in your application and do you
> use gdk_thread_enter() and gdk_threads_leave() before accessing TreeView
> from the second (USB) thread?

Trivial answer - no.

But seriously, I have since chenged my code so that I don't access the TreeView or any other GTK code from the 2nd thread. I now send the data to the 1st thread via a client event. My problem still exists though. I still have to move the mouse or press a key to get the data to show up.

Steve.

> Regards,
> LUK
> 
> 
> 2009/3/15 Steve <zephod at cfl.rr.com>
> 
> >
> > ---- 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
> >
> > _______________________________________________
> > Glade-users maillist  -  Glade-users at lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/glade-users
> >



More information about the Glade-users mailing list