Re: Any toy code showing use of fork & pipes & GTK+ together anywhere? (e.g. real time EKG simulation!!!)



The key to using data from external sources is by turning the
arrival of the data into events. This is the essense of event
driven programming. The way you do this for your own input
sources is by calling the gdk_input_add_call() function:

  gint        gdk_input_add                 (gint source,
                                             GdkInputCondition condition,
                                             GdkInputFunction function,
                                             gpointer data);

  Establish a callback when a condition becomes true on a file descriptor.

The 'function' is just like any other function that you connect to
with signal_connect().

So, the scenario of what you want to do is the following:

   1. Set up your widgets.
   2. open up the pipe (with or without forking yourself)
   3. call gdk_input_add() on the pipe filedescriptor
   4. call gtk_main()

It is of course also possible to call gdk_input_add in one of the
normal signal callback functions. Please let me know if this isn't 
enough to get you going, and I'll try to put together an example.

Regards,
--
                                                        ___   ___
                                                      /  o  \   o \
Dov Grobgeld                                         ( o  o  ) o   |
The Weizmann Institute of Science, Israel             \  o  /o  o /
"Where the tree of wisdom carries oranges"              | |   | |
                                                       _| |_ _| |_

 
On Thu, Jan 17, 2002 at 11:56:44PM -0800, Chris Seberino wrote:
> This list is giving me great advice on lots of stuff
> but I am nowhere near some of the GTK+ gods on this
> list and won't be for a long time if ever.
> 
> Does anyone know of any sample GTK+ programs that
> fork off a data generating program and then collect
> that data with pipes to affect GUI????
> 
> e.g. Imagine simulating an EKG for a hospital in GTK+.
> The EKG object would keep getting data from a patient's
> heart and we would need to read it and update a plot
> of that data constantly.
> 
> Similarly, one could simulate a tape that kept
> blaring stock quotes across it.  There would
> be a forked process that read stock data and
> GUI would read it as an event.
> 
> 
> Chris
> 
> 
> -- 
> =======================================================
> | Dr. Christian Seberino  || (619) 553-7940  (office) |
> | SPAWARSYSCEN 2363       || (619) 553-2836  (fax)    |
> | 53560 HULL ST           ||                          |
> | SAN DIEGO CA 92152-5001 || seberino spawar navy mil |
> =======================================================
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list



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