Re: pixmaps and retreiving data from another process




br0ke@shells.clipboard.com (Erik Greenwald) writes:

> Hi, I got two quick questions
 
> I can't seem to get pixmaps to work using
> gdk_pixmap_create_from_xpm_d for my toolbar. I've found that the
> documentation and header files for gtk_toolbar_append differ, the
> docs sayins GtkPixmap and the header saying GtkWidget (gtk+ 1.0.4)
> an dthe gdk documentation is just the names of some of the function
> w/o anyt hing in it! *strusfration*
 
Someone else has responded with some sample code. I'll just point
out that I think what is confusing you is the difference between
GdkPixmap and GtkPixmap. A GtkPixmap is a widget that draws
a GdkPixmap on the screen.

> My second question; I have to call another program (gcc) and get the
> output (STDOUT and STDERR) into data for my program. What would be
> the best way to approach this? is there a better way than to call
> the program redirecting to a /tmp file, then read that? I also need
> my program to stay functional while that runs, but know when the
> program terminates, is there a signal handler?

There are other ways of doing it. Whether they are better may
depend on what you want to do.

For an example of how to do something sort of like what you
are trying to do, see:

 http://www.gtk.org/~otaylor/kanjipad/

That program execs a child process with STDIN and STDOUT redirected
to pipes with the parent process. The parent process then does
a gdk_input_add() on file descriptor for the output pipe, to
get the output of the child.

[ 
  Note that program does not wait for its child process, because
  it terminates when its child process does. If you want the
  parent process to stay around, you'll need to worry about that,
  or you'll get zombie processes. If the above statement is unclear
  to you, you might want to look at a book like Al Steven's
  "Advanced Programming in the UNIX Environment" 
]

As for determining when the child process exits, in some cases
it may be sufficient to look for an EOF on the output pipe.
[ At that point, you could do a waitpid() to avoid zombies ]

Otherwise, you'll need to do something like set up a SIGCHLD
handler that sets a flag, and then check the flag in a 
gtk_timeout_add() timeout.

Regards,
                                        Owen







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