updating gtk widget in child

updating gtk widget in child

Post by Pratap » Mon, 02 Jun 2003 23:41:12



hi....

i wanted to know if its possible to update a text view from a child
after a fork. i have tried it and it didnt work, also i had read the
same thing somewhere else. is there any other solution to this
problem?

thanks.
pratap

 
 
 

updating gtk widget in child

Post by Kasper Dupon » Tue, 03 Jun 2003 00:10:14



> hi....

> i wanted to know if its possible to update a text view from a child
> after a fork. i have tried it and it didnt work, also i had read the
> same thing somewhere else. is there any other solution to this
> problem?

In general you shouldn't access the same X connection from more than
one process. When calling fork you must choose who continues to use
the connection. It should not be a problem for the child to use the
connection, if the parent never uses it after calling fork.

If you need to update the window from multiple processes, you should
somehow send the update requests to a single process. Can't the child
send a request to the parent, and let the parent itself update the
window?

Otherwise an option could be to create a single process that handles
the X connection and communicates with all your processes.

Using the same X connection from multiple threads sharing the same
address space should work if you are able to avoid race conditions.
I don't know if the library you use is thread safe, but otherwise
you might be able to make a semaphore of your own and wrap all the
library calls with it.

--
Kasper Dupont -- der bruger for meget tid p? usenet.

for(_=52;_;(_%5)||(_/=5),(_%5)&&(_-=2))putchar(_);

 
 
 

1. Gtk widget update

I have  made a simple program in Gtk. It  has basic gtk_init & gtk_main
functions.
What I need to do is update my text widget outside of  gtk_init ....
gtk_main loop.
Something like

gtk_init( (&argc, &argv);
.
.
making_a_text_widget();
show_text_widget();
.
.
function(text_widget)
.
.
gtk_main();

function()
{
   need_to_update_text_widget_before_returning();

  return 0;

What happens is that text widget won't be updated until returning.
I did try to fork in function but that didn't work. I hope somebody has
ideas.

I guess this question  shoud belong to gtk mailing list but I haven't
been able to reach it for
a while. Thanks.

2. How does a computer boot?

3. how to create child window in gtk+/gtk-- ?

4. CD Rom problem

5. kconfig update, GTK+ updated

6. TekMetrics is offering free certifications to UNIX programmers through March...

7. gtk: how to draw arbitrary widgets

8. ufs logging kills linking performance

9. Changing widget color in GTK

10. Grid like widget for GTK or KDE

11. GTK+ Text widget

12. Gtk-CRITICAL **: file gtkwidget.c: line 3359 (gtk_widget_set_parent): assertion `widget->parent == NULL' failed.

13. Horrible gtk widgets.