Re: brand newbie question



On 1/26/06, Ryan Moszynski <ryan m lists gmail com> wrote:
> The first task i was given was to take the output from the program i
> have pasted at the end of this message, and, every time the program is
> run, have it present the information in the form of a gnome window
> with a chart plotting the output of the program, instead of just
> printing it down the terminal screen as it does now.

I think the cheater way to do this would be to write a little bit of
Perl to reformat the output for gnuplot, plot the data to a bitmap,
and then display the bitmap. You could make something that looked
rather slick in an afternoon.

If the idea is to get you to learn C and gtk, you can do as much of
that as you like in C I guess. Work through the tutorial first, then
maybe:

- use popen() to run the program and capture the output (see "man popen")
- attach the FILE* to your gtk program with an IO channel

    http://developer.gnome.org/doc/API/2.0/glib/glib-IO-Channels.html

- in the IO channel callback, parse the program output and build some
big datastructure of your devising
- when there's a useful amount of new data, trigger an expose event on
your main window

    http://developer.gnome.org/doc/API/2.0/gtk/GtkWidget.html#gtk-widget-queue-draw

- in your expose handler, use the gdk drawing API to draw a graph from your data

Good luck ... you'll probably find this all a bit painful after Java.



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