Re: Modal Dialog Box
- From: Owen Taylor <otaylor gtk org>
- To: "Didimo E. Grimaldo T." <grimaldo panama iaehv nl>
- Cc: gtk-list redhat com
- Subject: Re: Modal Dialog Box
- Date: 25 May 1998 17:04:02 -0400
"Didimo E. Grimaldo T." <grimaldo@panama.iaehv.nl> writes:
> >
> > 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() ?
Well, you can put a hbox inside the vbox, and put the pixmap
as the first thing in the HBox.
You should realize that GtkDialog is not meant to be a complete
"yes/no" dialog. But just a simple framework for constructing
all sorts of dialogs.
> On the code example from above the gtk_widget_realize() didn't work, I
> took it out and used gtk_show_widget() instead.
gtk_widget_show() is in fact the right thing to do here.
> 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.
Here's an easier/better way of doing it.
dialog = gtk_dialog_new (...)
[ ... fill in the dialog, connect buttons to functions that
destroy the dialog ....]
gtk_signal_connect (dialog, "destroy",
GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
gtk_widget_show (dialog);
gtk_grab_add (dialog);
gtk_main();
gtk_grab_remove (dialog);
That is, just use the capability of GTK to do a recursive
call to gtk_main();
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]