Re: GUI app design questions



1. I'm not used to giving up program flow by calling gtk_main.  I see
there is a function to interrupt gtk_main in a timely manner, is there
also a function to interrupt gtk_main when a file handle becomes
available?  Or more likely a series of file handles (like the select
function)?

In
http://developer.gnome.org/doc/API/2.0/glib/glib-The-Main-Event-Loop.html you have timeout and idle callbacks.

The select encapsulation is called IO Channel, see
http://developer.gnome.org/doc/API/2.0/glib/glib-IO-Channels.html where
you create a channel for a fd and then set a callback on e.g. the
readable condition with g_io_add_watch.

2. Obviously I have to do a lot of drawing and displaying graphics. 
What I want is to be able to draw in a window just like the old Borland
BGI interface.  I realize that this sort of direct pixel access is not
allowed under the GTK (or 'X') model. So considering that my graphic is
not going to be a particular file format (PNG, BMP, etc), what widget
would lend itself to this kind of display.  I'm not sure this is clear,
but basically I'm thinking I will draw my waveforms in a buffer and tell
the widget about the buffer and then display it.

See http://developer.gnome.org/doc/API/2.0/gdk/gdk-GdkRGB.html, with
gdk_draw_rgb_image you can draw raw rgb pixel data from your personal
drawing buffer into an (offscreen) pixmap, which is copied onto the
drawing area widget in the expose callback.  This "drawing area with
pixmap" stuff is explained in
http://www.gtk.org/tutorial/ch-scribble.html.

Carsten




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