/* connectDlg.c

   Description: A simple application that display a dialog box with one button and one label.
                When the button is clicked, it prints "Cancel".
		This program is used by a small perl interface to pppd.
   Author: Laurentiu Cucos
   Date  : 01/25/02
 */

#include <unistd.h>
#include <stdlib.h>

#include <errno.h>
#include <gtk/gtk.h>


/* Cancel callback */
void destroy( GtkWidget *widget,
              gpointer   data )
{
    g_print ("Cancel\n");
    gtk_main_quit();
}

/* Function to open a dialog box displaying the message provided. */
void quick_message(gchar *message) 
{
    GtkWidget *dialog, *label, *cancel_button;

    /* Create the widgets */
    dialog = gtk_dialog_new();
    gtk_window_set_modal(GTK_WINDOW(dialog), false) ;
    gtk_window_set_default_size(GTK_WINDOW(dialog), 200,100);

    label = gtk_label_new (message);
    cancel_button = gtk_button_new_with_label("Cancel");
    
    /* Ensure that the dialog box is destroyed when the user clicks ok. */
    
    gtk_signal_connect_object (GTK_OBJECT (cancel_button), "clicked",
                               GTK_SIGNAL_FUNC (gtk_widget_destroy), (GtkObject*)dialog);
    gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->action_area),
                       cancel_button);

    /* destroy the application when the cancel button is pressed */
    gtk_signal_connect (GTK_OBJECT (cancel_button), "destroy",
			GTK_SIGNAL_FUNC (destroy), NULL);

    /* Add the label, and show everything we've added to the dialog. */
    gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox),
                       label);
    gtk_widget_show_all (dialog);
}

/*====================================================================*/
int main( int   argc,
          char *argv[] )
{
    /* This is called in all GTK applications. Arguments are parsed
     * from the command line and are returned to the application. */
    gtk_init(&argc, &argv);

    /* Start a dialog box for this */
    quick_message("Connecting to WMU ....");

    /* start main gtk loop */
    gtk_main ();

    return(0);
}
/* example-end */


