Re: [gtk-list] Modal (blocking) dialogs



Robert.Mallozzi@msfc.nasa.gov asks:

<snip for space>

   I would like to have the code wait at the line x = ... until
   an event is received from the modal dialog, then continue to
   the next line, in this case popping up another dialog.  If
   I just use gtk_grab_add(), the code above will show two dialogs
   immediately, processing events only from the second dialog, then
   when it's dismissed, from the first dialog.

   In fact, I would like to be able to call show_dialog() from anywhere,
   e.g., a callback function, meaning my code would be idle in gtk_main().

After you create the first window, you can enter a loop

while (!global_flag)
   gtk_main_iteration();

This will keep processing events until global_flag goes false
(obviously, you would set it to false in your callback from your first
window).

All the same, that's probably not the best way to accomplish your
goal.  Better might be to create one or both windows, but only show
the first one, and use gtk_grab_add.  When you get the event you want
from the first one, create the second (if you haven't already), show
it, and use gtk_grab_add within the callback.  In almost all
circumstances, it just ends up being better to set up everything, and
then work completely from callbacks.

   PS. One comment about gtk, and I hope no offense is taken by
   the authors, as it's really a great piece of software, but the
   documentation needs some work.  This makes it difficult (at least
   for me :-) to use gtk.  That is one thing that was nice about 
   xforms - the manual was very helpful.  This might seem like a
   trivial point to the developers of gtk, but if you want people
   to use the code, it's nice to have documentation ;-).   Again, I am
   not trying to disparage gtk, I know how boring it is to write 
   documentation, but in my opinion, the version should 
   not have bumped to 1.0 without documentation of all functions.

As for documentation... that's the curse of working on a fast-moving
target.  I'm also pretty new to gtk+, and I'm finding myself digging
through a lot of source to figure out how to use stuff.  I'm actually
using Gtk--, which uses a very spiffy tool called perceps to extract
comments from code, and build html documentation from that.  It's
certainly not like having an O'Reilly book to work from, but it's
still a good way to work.
-- 
Joseph J. Pfeiffer, Jr., Ph.D.       Phone -- (505) 646-1605
Department of Computer Science       FAX   -- (505) 646-1002
New Mexico State University          http://www.cs.nmsu.edu/~pfeiffer



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