--- freeciv-1.13.0/client/gui-gtk/dialogs.c Thu Jul 11 09:00:42 2002 +++ freeciv-1.13.0-mine/client/gui-gtk/dialogs.c Sun Jul 21 09:18:08 2002 @@ -53,6 +53,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 */ @@ -103,6 +104,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 ); @@ -1786,7 +1788,13 @@ void popdown_races_dialog(void) { if (races_dialog_shell) { + int i; 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 ------- */ @@ -1912,20 +1931,47 @@ 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-2, x2-x1+10, y2-y1+4); + 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(); - gtk_box_pack_start( GTK_BOX( GTK_DIALOG( races_dialog_shell )->vbox ), - races_name, FALSE, FALSE, 0 ); + 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_WIDGET_SET_FLAGS( races_name, GTK_CAN_DEFAULT ); gtk_widget_grab_default( races_name ); @@ -2030,6 +2076,10 @@ 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(); @@ -2044,6 +2094,28 @@ /************************************************************************** ... **************************************************************************/ + +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) { int i; @@ -2100,6 +2172,8 @@ /* don't do anything if signal is untoggling the button */ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))) { 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(); selected_city_style =