Re: dialog enhancements




Fritz Jetzek <fritz.jetzek@i-dmedia.com> writes:

> Tim Janik wrote:
> > 
> > /* gtk_dialog_run() shows the dialog and enters a recursive main loop
> >  * to be executed until the dialog is hidden. the return value is the
> >  * action_id of the child that was lastly activated or 0 if none.
> >  * gtk_dialog_run() is recommended to be used only with
> >  * GTK_AUX_DIALOG_MODAL dialogs.
> >  */
> > gint gtk_aux_dialog_run (GtkAuxDialog *aux_dialog);
> > 
> 
> Just my 0.2 cents:
> 
> I recently wrote an application that makes use of the expect library; as
> this library (just an example) often blocks (=freezes)the whole app
> temporarily, it was necessary to make my app multithreaded which in turn
> required the gtk_main() call in main() to be 'pre- and postfixed' by the
> relevant gdk_threads() functions, gdk_threads_enter() and
> gdk_threads_leave().
> 
> However, the gnome_dialog functions I used to create my dialogs call
> gtk_main() again for some reason (beyond me). This just let my app
> freeze again making all my multithreading efforts obsolete and I had to
> rip out the dialog altogether and write my own dialog routines
> (implementing much of Havoc's suggested var_args mechanism :P). 

gtk_main(), like any other GTK+ function when threading must be called
inside the GTK+ lock. Unlike most other functions, gtk_main()
releases the lock while waiting so other threads can get accses

So, as long as you are calling it from the main thread, and within
the main loop, a recursive gtk_main() will work with no problems
with threads.

(One thing that is NOT handled well now is doing the equivalent of a
recursive main from a different thread, since the GMain functions can
only be called from the main loop thread. To do this now, you
need to use a semaphore or some such mechanism in the secondary thread.
This would be nice address for GTK+-1.4.)

> So when rethinking the GtkDialog API one should possibly rethink whether
> the call to gtk_main is really necessary. Apart from not being able to
> use the preset dialog routines it also took me ages to actually find
> that bug...

I don't actually follow the problem. The only one I see is that
gnome_dialog_run() is only going to work in the main thread.

Regards,
                                        Owen



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