Re: [gtk-list] Various questions (gtk_text and thread)
- From: kosinski ugrad cs ualberta ca
- To: Emmanuel Varagnat <discoman club-internet fr>
- cc: gtk-list redhat com, recipient list not shown: ;
- Subject: Re: [gtk-list] Various questions (gtk_text and thread)
- Date: Sat, 24 Jul 1999 12:12:24 -0600 (MDT)
> I've created a log window with a GTK_TEXT widget, and 2 pipes to
> redirect
> normal output and error output of program launch via execvp.
>
> For reading pipes I've created 2 threads which only consist in:
>
> void log_text_normal_output() {
> char buff[100];
> int n;
>
> while(n=read(pipe2[0], buff, 100)) {
> gtk_text_insert(GTK_TEXT(log_text), NULL, NULL, NULL, buff, n);
> }
> }
>
> It seems to work well but I would like to know if it cause some
> problems,
> of synchronisation with X11 for example or if Gtk manage with that well.
First of all, at the beginning of your code, you have to call
g_thread_init() to make glib thread-safe. Then, around any calls to GTK,
you have to insert a GTK_THREADS_ENTER before the calls and
GTK_THREADS_LEAVE after the calls... and yes, you can have multiple gtk
calls inside these blocks.
>
> I also would like to know if I could limit the size/buffer of the
> gtk_text
> widget ? Or must I verify the size of it when I add something and delete
> the oldest lines ? Could I know the number of lines or only number of
> characters ?
I don't know for sure, but I'd imagine this is limited only by your
memory, since the GtkText widget uses glib dynamic memory allocation
(glist's, IIRC) to store the lines in the widget.
Brett.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]