gtk_main question
- From: A Dark Elf <drow DarkElf net>
- To: gtk-list redhat com
- Subject: gtk_main question
- Date: Mon, 6 Apr 1998 20:43:50 -0500 (CDT)
Ok I messed with GTK for a while, but it seems I can't quit gtk_main() the
way I need to. I have an app that simply needs to call a message box
(dialog) at one time, wait for the user to press OK, destroy the message
box and continue its execution. How would I do that? I made the dialog
appear, but when the user press OK, either the window stays there (if I
use gtk_widget_destroy and gtk_main_quit) and the program can continue, or
the window disapears but everything hang there (if I use only
gtk_widget_destroy) while gtk probably stays in the gtk_main loop.
What am I doing wrong here?
Relating code:
int destroy_msgbox(GtkWidget *widget, GtkWidget *entry)
{
gtk_widget_destroy(widget);
gtk_main_quit();
return(FALSE);
}
main(int argc, char *argv[])
{
msgbox(argc,argv);
sleep(5);
printf("Widget *should* be gone by now...\n");
}
int msgbox(int argc, char *argv[])
{
gtk_init (&argc, &argv);
dialog_window = gtk_dialog_new ();
gtk_signal_connect (GTK_OBJECT (dialog_window), "destroy",
GTK_SIGNAL_FUNC(destroy_msgbox), &dialog_window);
gtk_signal_connect (GTK_OBJECT (dialog_window), "delete_event",
GTK_SIGNAL_FUNC(destroy_msgbox), &dialog_window);
gtk_window_set_title (GTK_WINDOW (dialog_window), "Socket Script");
gtk_container_border_width (GTK_CONTAINER (dialog_window), 0);
label = gtk_label_new ("This would be our message");
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog_window)->vbox),
label, TRUE, TRUE, 0);
gtk_widget_show (label);
button = gtk_button_new_with_label ("OK");
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC(destroy_msgbox), GTK_OBJECT (dialog_window));
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog_window)->action_area),
button, TRUE, TRUE, 0);
gtk_widget_show (button);
gtk_widget_show (dialog_window);
gtk_main();
}
Drow@DarkElf.net
----------------------------------------------------------------------
DarkElf Network SysAdmin http://www.darkelf.net
OKC.OK.US.UnderNet.Org Operator http://www.undernet.org
Check the main resource for developers at www.fastethernet.net
----------------------------------------------------------------------
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]