formatting fixes; casts for GTK

This commit is contained in:
ehouse 2005-05-29 19:37:42 +00:00
parent 844cab6e5d
commit df8bfef99d
3 changed files with 122 additions and 168 deletions

View file

@ -110,7 +110,7 @@ loadCopyValues( GtkWidget* item, gpointer data )
{
LoadPair* lp = (LoadPair*)data;
LocalPlayer* player = lp->info;
char* entryText;
const char* entryText;
switch( lp->counter ) {
case 0: /* labels */
@ -137,7 +137,7 @@ loadCopyValues( GtkWidget* item, gpointer data )
} /* loadCopyValues */
static void
handle_ok( GtkWidget* widget, void* closure )
handle_ok( GtkWidget* widget, gpointer closure )
{
GtkNewGameState* state = (GtkNewGameState*)closure;
CurGameInfo* gi = &state->globals->cGlobals.params->gi;
@ -345,13 +345,15 @@ makeNewGameDialog( GtkNewGameState* state )
/* buttons at the bottom */
hbox = gtk_hbox_new( FALSE, 0 );
gtk_box_pack_start( GTK_BOX(hbox),
makeButton( "Ok", handle_ok, state ),
makeButton( "Ok", GTK_SIGNAL_FUNC(handle_ok) , state ),
FALSE, TRUE, 0 );
gtk_box_pack_start( GTK_BOX(hbox),
makeButton( "Revert", handle_revert, state ),
makeButton( "Revert", GTK_SIGNAL_FUNC(handle_revert),
state ),
FALSE, TRUE, 0 );
gtk_box_pack_start( GTK_BOX(hbox),
makeButton( "Cancel", handle_cancel, state ),
makeButton( "Cancel", GTK_SIGNAL_FUNC(handle_cancel),
state ),
FALSE, TRUE, 0 );
gtk_box_pack_start( GTK_BOX(vbox), hbox, FALSE, TRUE, 0 );
@ -381,56 +383,4 @@ newGameDialog( GtkAppGlobals* globals/* , GtkGameInfo* gameInfo */ )
return !state.cancelled;
} /* newGameDialog */
#if 0
gint
gtkask( GtkAppGlobals* globals, gchar *message, gint numButtons,
char* button1, ... )
{
GtkWidget* dialog;
GtkWidget* label;
GtkWidget* button;
short i;
gboolean* results = g_malloc( numButtons * sizeof(results[0]) );
char** butList = &button1;
/* Create the widgets */
dialog = gtk_dialog_new();
gtk_window_set_modal( GTK_WINDOW( dialog ), TRUE );
label = gtk_label_new( message );
for ( i = 0; i < numButtons; ++i ) {
button = gtk_button_new_with_label( *butList );
results[i] = 0;
gtk_signal_connect( GTK_OBJECT( button ), "clicked",
GTK_SIGNAL_FUNC(button_event), &results[i] );
gtk_container_add( GTK_CONTAINER( GTK_DIALOG(dialog)->action_area),
button );
++butList;
}
/* 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);
/* returns when button handler calls gtk_main_quit */
gtk_main();
gtk_widget_destroy( dialog );
for ( i = 0; i < numButtons; ++i ) {
if ( results[i] ) {
break;
}
}
g_free( results );
return i;
} /* gtkask */
#endif
#endif /* PLATFORM_GTK */

View file

@ -57,7 +57,8 @@ askNTiles( GtkAppGlobals* globals, XP_U16 max, XP_U16 deflt )
button = gtk_button_new_with_label( buf );
gtk_box_pack_start( GTK_BOX(hbox), button, FALSE, TRUE, 0 );
gtk_signal_connect( GTK_OBJECT(button), "clicked", button_event,
gtk_signal_connect( GTK_OBJECT(button), "clicked",
GTK_SIGNAL_FUNC(button_event),
&results[i] );
gtk_widget_show( button );
}
@ -67,8 +68,10 @@ askNTiles( GtkAppGlobals* globals, XP_U16 max, XP_U16 deflt )
sprintf( defbuf, "Default (%d)", deflt );
button = gtk_button_new_with_label( defbuf );
gtk_box_pack_start( GTK_BOX(GTK_DIALOG(dialog)->vbox), button, FALSE, TRUE, 0 );
gtk_signal_connect( GTK_OBJECT(button), "clicked", button_event,
gtk_box_pack_start( GTK_BOX(GTK_DIALOG(dialog)->vbox), button, FALSE,
TRUE, 0 );
gtk_signal_connect( GTK_OBJECT(button), "clicked",
GTK_SIGNAL_FUNC(button_event),
&results[deflt-1] );
gtk_widget_show( button );

View file

@ -66,7 +66,8 @@ gtkpasswdask( const char* name, char* outbuf, XP_U16* buflen )
for ( i = 0; i < 2; ++i ) {
GtkWidget* button = gtk_button_new_with_label( labels[i] );
gtk_signal_connect( GTK_OBJECT(button), "clicked", button_event,
gtk_signal_connect( GTK_OBJECT(button), "clicked",
GTK_SIGNAL_FUNC(button_event),
boolps[i] );
gtk_box_pack_start( GTK_BOX(hbox), button, FALSE, TRUE, 0 );
gtk_widget_show( button );
@ -81,7 +82,7 @@ gtkpasswdask( const char* name, char* outbuf, XP_U16* buflen )
gtk_main();
if ( ok ) {
char* text = gtk_entry_get_text( GTK_ENTRY(entry) );
const char* text = gtk_entry_get_text( GTK_ENTRY(entry) );
strncpy( outbuf, text, *buflen );
*buflen = strlen(outbuf);
}