Re: Piping text onto text widget



Marco Quezada <mquezada nlxcorp com> writes:

I am working on a "launch pad" utility to help development of our
software. It basically works like a start menu but it shows only source
code files and other data files essential to the development of our
product. On of it's functions includes running the compiler to build the
packages. Right now the compiler launches with a rudimentary system()
call that executes make on the Makefile but all the compiling
information goes to the window that opened the "launch utility". Is
there a way to capture that information and send it to a text widget
inside the launch utility to be displayed?


Sure, you need to redirect stdout and stderr to pipes. The primitive
and rather sucky UNIX popen() call does this.

Most real programs reimplement popen() since it's inflexible and a
security problem; see
http://developer.gnome.org/doc/API/2.0/glib/glib-spawning-processes.html
for docs on the reimplementation that will come with GLib 2, you may
want to copy that code. The security problem with popen() is the same
as system(), it runs a shell which lets attackers do all kinds of fun
stuff if they can figure out how to affect your passed-in string.

Normally you would use popen() or g_spawn_* in a GTK program by
connecting an input handler to the read end of the pipe, using
g_io_add_watch().

BTW a cool and fast way to get nice display of compiler output is to 
use the GtkHTML widget (separate package from GTK) and insert HTML
tags in the output. You can then do click-on-errors-to-jump-to-them as
links in the HTML. Note that GtkHTML is a somewhat moving target
compared to GTK though, not sure the API is frozen and not sure what
the future upgrade path from it is.

Havoc





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