Re: Delay in Displaying Dialog





On 1/16/07, Robert Pearce <rob bdt-home demon co uk> wrote:
On Tue, 16 Jan 2007, Matt Fischer <mattfischer84 gmail com> wrote :
>I believe it's also possible to tell the mainloop about a file
>descriptor which should be watched, and have it call a function
>whenever new data appears. I have never used this tactic (hopefully
>someone else can clarify this)

Yes - the GTK "IO Channel" structure allows this. I have used this
approach to asynchronously monitor incoming data on a serial port, and
it seems to work fairly well. It certainly gave me FAR fewer headaches
than trying to do a similar thing on Windows!

    chan = g_io_channel_unix_new ( fd );

    g_io_channel_set_encoding ( chan, NULL, &tErrPtr );

    EventSrc = g_io_add_watch ( chan, G_IO_IN, ParseRxData, user_data );

Where ParseRxData is the data handler function:

gboolean ParseRxData ( GIOChannel *source,
                       GIOCondition condition,
                       gpointer data )

The only oddity I'm left with is that once I've run that GTK
application, the serial port in question just blocks on open for all
other applications, though I can re-run the GTK app without problem.
--
Rob Pearce                       http://www.bdt-home.demon.co.uk

The contents of this | Windows NT crashed.
message are purely   | I am the Blue Screen of Death.
my opinion. Don't    | No one hears your screams.
believe a word.      |
_______________________________________________
gtk-list mailing list
gtk-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-list

Marshall--perhaps it would help if you could provide a little more info on the nature of the data coming into the dialog.  Does it come over a socket, or a file descriptor from some type of character device, or what?  It's likely that the I/O channel approach Robert describes can be coaxed into working for your situation.  It's certainly better than polling for new data using an idle handler as I described above (although worst-case scenario, that would probably be a fairly reliable fallback.)

--Matt


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