Re: Newbie from Hell



Hello,

I noticed another bug.  In the main function when you connect the
callback to the delete_event signal you need to pass a pointer to the
main window as the final argument:

g_signal_connect (G_OBJECT (main_window), "delete_event",
              G_CALLBACK (delete_event), main_window);

You can then use this pointer in your callback:

static gboolean delete_event( GtkWidget *widget,
                              GdkEvent  *event,
                              gpointer   data )
{
        GtkWidget *main_window = GTK_WIDGET (data);

        ....

        dialog = gtk_dialog_new_with_buttons ("Are you sure you want to quit?",
                                            GTK_WINDOW (main_window),
                                            NULL,
                                            GTK_DIALOG_DESTROY_WITH_PARENT,
                                            GTK_STOCK_CANCEL,
                                            GTK_RESPONSE_CANCEL,
                                            GTK_STOCK_QUIT,
                                            GTK_RESPONSE_ACCEPT,
                                            NULL);

....

This should fix the main_window undeclared problem.

Hope this helps,

Keith.





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