How to wait for a destruction of a dialog?



Hello, everybody!

I want to open a dialog and then wait for it to get closed before any other
action is attempted (see source code below), is there any way to do so?
This is only part of the source code, function quit() is a callback function,
dlg_result_ptr is declared as static.
 
---[source]---

void dlg_button_pressed(GtkWidget *widget, gpointer data) {
    if (dlg_result_ptr) *dlg_result_ptr = (gint) data;
}

void open_dialog(gchar *message, gchar *title, gchar **btnLabels,
                               gint btnDflt, gint *btnPressed) {

    GtkWidget   *dialog, *label, *button;
    gint        i = 0;

    dlg_result_ptr = btnPressed;

    dialog = gtk_dialog_new();
    gtk_window_set_default_size(GTK_WINDOW(dialog), 400, 150);
    if (title) gtk_window_set_title(GTK_WINDOW(dialog), title);
    gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);

    label = gtk_label_new(message);
    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label);

    while (btnLabels[i]) {
        button = gtk_button_new_with_label(btnLabels[i]);
        gtk_signal_connect(GTK_OBJECT(button), "clicked",
                GTK_SIGNAL_FUNC(dlg_button_pressed), (gpointer) i);
        gtk_signal_connect_object(GTK_OBJECT(button), "clicked",
                GTK_SIGNAL_FUNC(gtk_widget_destroy), (gpointer) dialog);
        gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), button,
                                           FALSE, FALSE, 0);
        if (btnDflt == i) gtk_widget_grab_focus(button);
        i++;
    }

    gtk_widget_show_all(dialog);
}

void quit(GtkWidget *widget, gpointer data) {

    gint    retval = 1;
    
    open_dialog(QUIT_CONFIRM, CONFIRM_TITLE, yn_dialog_btns, 1, &retval);
    
    /* 
     * I want it to wait here for dialog to get closed
     * before checking the retval
     */

    if (!retval) gtk_main_quit();
}

---[end source]---

Any ideas would be greatly appreciated.
Thanks.

--
Bye, Warrior.

ICQ #24496762

-------------
Tagline for Sunday, November 05, 2000, 16:58
--- A neat desk is a sign of a sick mind.




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