Re: Click and DESTROY



Maya wrote:
I have taken on the opportunity to learn Gtk+. Part of my program calls a function that displays a Dialog 
box, but I don't know how to destroy the Dialog window when by pressing the OK button.

I have attached a copy of a file that has the function in question in the hope that someone here would be 
able to tell me how to go about it.



<snip>

        hbox = GTK_DIALOG(dialog)->action_area;
        gtk_box_pack_start(GTK_BOX(hbox),btnOK, FALSE, FALSE, NO_PADING);
        
        gtk_widget_show_all(dialog);
        
        /* Callback */

gtk_signal_connect_object( GTK_OBJECT(dialog),"activate",
                           GTK_SIGNAL_FUNC(eventBtnOK),NULL);
}

Ok, implement

void eventBtnOk(GtkButton *button)
{
/*do your event handling here*/
gtk_widget_destroy(button);
}

You should also define a "delete_event" handler for the dialog to cleanup things if there are any, but I assume there will be some, before the dialog is destroyed. Widgets within the dialog needn't to be destroyed explicitly. I'm talking about some dynamically allocated data or something else.

--
+------------------------------------------------+
| +----------------+ WOLFGANG DRAXINGER          |
| | ,-.   DARKSTAR | lead programmer             |
| |(   ) +---------+ wdraxinger darkstargames de |
| | `-' / GAMES /                                |
| +----+''''''''     http://www.darkstargames.de |
+------------------------------------------------+




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