diff -u freeciv-Mar-31/client/gui-gtk/dialogs.c freeciv/client/gui-gtk/dialogs.c --- freeciv-Mar-31/client/gui-gtk/dialogs.c Fri Mar 22 02:14:36 2002 +++ freeciv/client/gui-gtk/dialogs.c Mon Apr 1 21:20:05 2002 @@ -54,6 +54,7 @@ /******************************************************************/ static GtkWidget *races_dialog_shell=NULL; static GtkWidget *races_toggles_form; +static GtkWidget *races_by_name; static GtkWidget *races_sex_toggles_form; static GtkWidget *city_style_toggles_form; static GtkWidget *races_ok_command; /* ok button */ @@ -104,6 +105,7 @@ static void races_buttons_callback ( GtkWidget *w, gpointer data ); static void races_toggles_callback(GtkWidget * w, gpointer race_id_p); static void races_sex_toggles_callback ( GtkWidget *w, gpointer data ); +static void races_by_name_callback ( GtkWidget *w, gpointer data ); static void races_name_callback ( GtkWidget *w, gpointer data ); static void city_style_toggles_callback ( GtkWidget *w, gpointer data ); @@ -1834,8 +1836,14 @@ *****************************************************************/ void popdown_races_dialog(void) { + int i; if (races_dialog_shell) { gtk_widget_set_sensitive (top_vbox, TRUE); + for(i=0;i 8){ + per_row=sqrt(game.playable_nation_count)*18/15; + }else{ + /*Multiple rows would look silly here*/ + per_row=game.playable_nation_count; + } + races_dialog_shell = gtk_dialog_new(); - gtk_signal_connect( GTK_OBJECT(races_dialog_shell),"delete_event", - GTK_SIGNAL_FUNC(deleted_callback),NULL ); + gtk_signal_connect( GTK_OBJECT(races_dialog_shell),"delete_event", + GTK_SIGNAL_FUNC(deleted_callback),NULL ); gtk_window_set_title( GTK_WINDOW( races_dialog_shell ), _(" What Nation Will You Be?") ); f = gtk_frame_new(_("Select nation and name")); gtk_box_pack_start( GTK_BOX( GTK_DIALOG( races_dialog_shell )->vbox ), - f, FALSE, FALSE, 0 ); + f, FALSE, FALSE, 0 ); /* ------- nation name toggles ------- */ @@ -1948,20 +1968,45 @@ sorted_races_list=g_list_sort(sorted_races_list,cmp_func); for(i=0; iflag_sprite; + sprite_get_bounding_box(s, &x1, &y1, &x2, &y2); + s=crop_sprite(s, x1, y1, x2+1, y2+1); + flag=gtk_pixmap_new(s->pixmap,s->mask); + gtk_misc_set_alignment(GTK_MISC(flag),0,1); + gtk_container_add(GTK_CONTAINER(races_toggles[i]),flag); gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(races_toggles[i]), FALSE); group = gtk_radio_button_group( GTK_RADIO_BUTTON( races_toggles[i] ) ); gtk_table_attach_defaults(GTK_TABLE(races_toggles_form),races_toggles[i], i%per_row, i%per_row+1, i/per_row, i/per_row+1); } - /* ------- nation leader combo ------- */ - + /* ------ choose nation by name -- and choose leader ------ */ + + pop_downs_box=gtk_hbox_new(0,0); + gtk_box_pack_start( GTK_BOX( GTK_DIALOG( races_dialog_shell )->vbox ), + pop_downs_box, FALSE, FALSE, 0 ); + + pop_downs_label=gtk_label_new(_("Nation:")); + races_by_name = gtk_combo_new(); + race_names = NULL; + for(i=0; iname); + } + gtk_combo_set_popdown_strings(GTK_COMBO(races_by_name), race_names); + gtk_combo_set_value_in_list(GTK_COMBO(races_by_name), TRUE, FALSE); + gtk_box_pack_start( GTK_BOX( pop_downs_box ), pop_downs_label, FALSE, FALSE, 0); + gtk_box_pack_start( GTK_BOX( pop_downs_box ), races_by_name, FALSE, FALSE, 0); + races_name = gtk_combo_new(); + pop_downs_label=gtk_label_new(_(" Leader:")); + gtk_box_pack_end( GTK_BOX( pop_downs_box ), races_name, FALSE, FALSE, 0); + gtk_box_pack_end( GTK_BOX( pop_downs_box ), pop_downs_label, FALSE, FALSE, 0); - gtk_box_pack_start( GTK_BOX( GTK_DIALOG( races_dialog_shell )->vbox ), - races_name, FALSE, FALSE, 0 ); GTK_WIDGET_SET_FLAGS( races_name, GTK_CAN_DEFAULT ); gtk_widget_grab_default( races_name ); @@ -2066,6 +2111,11 @@ gtk_signal_connect( GTK_OBJECT( races_quit_command ), "clicked", GTK_SIGNAL_FUNC( races_buttons_callback ), NULL ); + gtk_signal_connect( GTK_OBJECT( GTK_COMBO(races_by_name)->list ), + "selection_changed", + GTK_SIGNAL_FUNC( races_by_name_callback ), NULL ); + + /* ------- set initial selections ------- */ select_random_race(); @@ -2089,6 +2139,27 @@ */ /************************************************************************** + ... +**************************************************************************/ +static void races_by_name_callback( GtkWidget *w, gpointer data ) +{ + int i; + for(i=0; ientry )), + get_nation_by_idx((int)g_list_nth_data(sorted_races_list,i))->name)==0){ + if (GTK_WIDGET_SENSITIVE(races_toggles[i])){ + gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(races_toggles[i]), TRUE); + break; + }else{ + /*That one's taken*/ + select_random_race(); + } + } + } +} + + +/************************************************************************** ... **************************************************************************/ void races_toggles_set_sensitive(struct packet_nations_used *packet) @@ -2140,6 +2211,9 @@ static void races_toggles_callback( GtkWidget *w, gpointer race_id_p ) { selected_nation = GPOINTER_TO_INT(race_id_p); + + gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(races_by_name)->entry), + get_nation_by_idx(selected_nation)->name); select_random_leader();