/** boxinterface.c **/
#include <gtk/gtk.h>
void CloseTheApp ( GtkWidget * window, gpointer data ) { gtk_main_quit (); }
void CompareName ( GtkButton * OkButton, gpointer data ) { g_print ("This function compares user names\n" ); }
void ClearEntry ( GtkButton * CancelButton, gpointer data )
{
/* THIS FUNCTION KEEPS RETURNING AN ERROR. IT COMPILES FINE W/OUT ERRORS,
* I'D LIKE TO HAVE THIS FUNCTION CALLED WHEN A USER ENTERS SOMETHING AND WANTS TO
* TO CLEAR THE DISPLAY. THE PREVIOUS FUNCTION WORKS BUT OF COURSE DOESN'T RETURN
* ANYTHING TO THE GTK_ENTRY BOX */
GtkWidget * textentry ;
gtk_entry_set_text ( GTK_ENTRY ( textentry ), "" ) ;
}
GtkWidget * MakeWindow () { GtkWidget * window;
window = gtk_window_new ( GTK_WINDOW_TOPLEVEL ); gtk_container_set_border_width ( GTK_CONTAINER ( window ), 10 ); gtk_window_set_default_size ( GTK_WINDOW ( window ), 320, 80 ); gtk_window_set_title ( GTK_WINDOW ( window ), "Cervell 1.0" ); gtk_signal_connect ( GTK_OBJECT ( window ), "destroy", GTK_SIGNAL_FUNC ( CloseTheApp ), NULL );
return window; }
GtkWidget * MakeEntryBox () { GtkWidget * box; GtkWidget * widget; GtkWidget * textentry ;
box = gtk_hbox_new ( TRUE, 5 );
widget = gtk_label_new ( "Please enter your name" ); gtk_box_pack_start ( GTK_BOX ( box ), widget, FALSE, TRUE, 0 );
textentry = gtk_entry_new (); gtk_box_pack_start ( GTK_BOX ( box ), textentry, FALSE, TRUE, 0 );
return box; }
GtkWidget * MakeButtons () { GtkWidget * box; GtkWidget * OkButton; GtkWidget * CancelButton ;
box = gtk_hbox_new ( TRUE, 5 );
OkButton = gtk_button_new_with_label ( "Ok" ); gtk_box_pack_end ( GTK_BOX ( box ), OkButton, FALSE, TRUE, 0 );
CancelButton = gtk_button_new_with_label ( "Cancel" ); gtk_box_pack_end ( GTK_BOX ( box ), CancelButton, FALSE, TRUE, 0 );
gtk_signal_connect ( GTK_OBJECT ( OkButton ), "pressed", GTK_SIGNAL_FUNC ( CompareName ), "pressed" ) ;
gtk_signal_connect ( GTK_OBJECT ( CancelButton ), "pressed", GTK_SIGNAL_FUNC ( ClearEntry ), "pressed" ) ;
return box; }
gint main ( gint argc, gchar * argv [] ) { GtkWidget * window; GtkWidget * mainbox; GtkWidget * entrybox; GtkWidget * buttonbox;
gtk_init ( &argc, &argv );
window = MakeWindow (); entrybox = MakeEntryBox (); buttonbox = MakeButtons ();
mainbox = gtk_vbox_new ( FALSE, 10 ); gtk_box_pack_start ( GTK_BOX ( mainbox ), entrybox, FALSE, FALSE, 0 ); gtk_box_pack_start ( GTK_BOX ( mainbox ), buttonbox, FALSE, FALSE, 0 );
gtk_container_add ( GTK_CONTAINER ( window ), mainbox ); gtk_widget_show_all ( window ) ;
gtk_main (); return 0; }
_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963