Using delete_event callback to handle close button



Hi - 

I'd like the user of my app to confirm that they _really_ want to close
it if the close button is pressed when there are unsaved changes. I've
done this by setting up a signal handler on delete_event which calls a
function named eventDelete() to issue a dialog-box warning. Everything
works exactly as I hoped, except that every time the app is closed (when
the user selects OK from the confirmation dialog), the following Gtk
warnings show up:

        Gtk-CRITICAL **: file gtkstyle.c: line 568 (gtk_style_detach):
        assertion `style != NULL' failed.

        Gtk-CRITICAL **: file gtkaccelgroup.c: line 147
        (gtk_accel_group_unref): assertion `accel_group != NULL' failed.

        Gtk-CRITICAL **: file gtkcontainer.c: line 1247
        (gtk_container_unregister_toplevel): assertion `node != NULL' failed.

        Gtk-CRITICAL **: file gtkstyle.c: line 621 (gtk_style_unref):
        assertion `style != NULL' failed.

Without my signal handler, I never see these. Can anyone tell me what
I'm doing wrong? My code is below.

Thanks,
Harry
 
/* note that "window" is the main app window, and a global variable */

/* confirmation dialog callback */ 
void confirmQuitCB(gint reply, gpointer data)
{
        if(reply == GNOME_YES)
                gtk_signal_emit_by_name(GTK_OBJECT(window), "destroy");
}

void confirmQuit(void)
{
        gnome_ok_cancel_dialog_modal_parented("Really exit?",
                (GnomeReplyCallback)confirmQuitCB, NULL, 
                GTK_WINDOW(window));
}

static gint eventDelete(GtkWidget *widget, GdkEvent *event, gpointer
data)
{
        if(/* there are unsaved changes */)
        {
                confirmQuit();
                return TRUE;
        }
        return FALSE;
}

static gint eventDestroy(GtkWidget *widget, GdkEvent *event, gpointer
data)
{
        gtk_main_quit();
        return 0;
}

-- 





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