Re: watching a file descriptor in gtk3




 
Hi Roger,

I put together a test example of GSubprocess. It starts Gnuplot, sets up the pipes and callbacks, and then 
when Gnuplot is done it opens the graph in an image widget. The GSubprocess will take care of the file 
descripters for you. Also, if I run valgrind with multiple plots being created it doesn't leak memory over 
time. It looks like the subprocess holds everything you need and when it is unreferenced everything gets 
cleaned up. If you want to just run one plot, comment out the plot_data() function in the subprocess finish 
callback. Also to get an error back to the program you can do something like changing "set ylabel" to "et 
ylabel" or something of the sort. Change things around to get an idea of how they work.

https://github.com/cecashon/OrderedSetVelociRaptor/blob/master/Misc/Pipes/gnuplot5.c

This might not be what you are looking for since it is a little higher level than using a spawn function but 
there are a lot of things set up with GSubprocess that make it worth consideration. Options. You can do some 
nice plotting with GTK+ and Gnuplot also.

Eric 

 

 





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