Re: [gtk-list] Re: Modal Dialog Box



> 
> On Sun, 24 May 1998, Markus Minihold wrote:
> Just to give you a start point:
> 
>    dlgwin = gtk_dialog_new();
>    ...       /* set title and position a.s.o */
>    gtk_grab_add( dlgwin ); /* make dlgwindow modal to your application */
>    gtk_widget_realize( dlgwin );
>    ...
> 
> Regards
> Karsten

  Something similar to what I needed, with some tweeking I got the dialog
  to show up without any warnings, including the 1-2 buttons depending on
  the 'type'. Again, a pity that GtkDialog is missing a pixmap on the
  side :(. Is it possible to append this to the vbox member with 
  *pack_start() ?

  On the code example from above the gtk_widget_realize() didn't work, I
  took it out and used gtk_show_widget() instead.
  
  And ye a more important question (hammering until it works is not
  very productive) since the application code is actually waiting for
  a YES/NO confirmation the app code needs to wait until the dialog
  (or modal window) comes back with an answer. How do I achieve that?
  I mean, the callback does get to know the YES/NO but the other part
  right after the createDialog() should wait, but a simple while loop
  would work against GTK's event processing queue.

      answer_t createDialog(DLG_ENUM type, char *msg) 
      {
             answer_t answ = DLG_ANSWER_UNDEF;  

             // The dialog creation and signal connection stuff
	     // also the modal attribute 
	        :
	     // in signal_connect's client data I pass a pointer
	     // to answ for each button
	     gtk_signal_connect(...)
		:
	     gtk_show_widget(dlgwin);

             while (answ == DLG_ANSWER_UNDEF) {
	     	// if dlgwin gets killed ('delete' or 'destroy') the
		// associated callback to dlgwin is supposed to set
		// this to DLG_ANSWER_NONE or something like that.
		// Same principle as in the buttons.

		!!! need something to keep gtk events moving !!!
	     }
      }

      answer = createDialog(DLG_QUESTION,"sure you want to delete it?");
      if (answer == YES) {
          // you know what happens to bad files...
      }


   Well, that's the idea at least. It's a bit awkward doing it in 
   GTK when compared to Tcl/Tk, XForms and Fvwm95 toolkits.

   		Cheers,
				Emilio



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