? diff ? bool_tag1.diff ? num_traderoutes1.diff ? num_traderoutes2.diff Index: client/gui-gtk/citydlg.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/citydlg.c,v retrieving revision 1.118 diff -u -r1.118 citydlg.c --- client/gui-gtk/citydlg.c 2002/02/12 09:36:45 1.118 +++ client/gui-gtk/citydlg.c 2002/02/14 16:51:49 @@ -108,6 +108,7 @@ GtkWidget *progress_label; GtkWidget *improvement_list; GtkWidget *buy_command; + GtkWidget *buy_info_label; GtkWidget *change_command; GtkWidget *sell_command; @@ -174,7 +175,7 @@ short block_signal; } misc; - GtkWidget *buy_shell, *sell_shell; + GtkWidget *sell_shell; GtkWidget *change_shell, *change_list; GtkWidget *rename_shell, *rename_input; @@ -288,10 +289,6 @@ static void change_help_callback(GtkWidget * w, gpointer data); static void buy_callback(GtkWidget * w, gpointer data); -static gint buy_callback_delete(GtkWidget * w, GdkEvent * ev, - gpointer data); -static void buy_callback_no(GtkWidget * w, gpointer data); -static void buy_callback_yes(GtkWidget * w, gpointer data); static void sell_callback(GtkWidget * w, gpointer data); static gint sell_callback_delete(GtkWidget * w, GdkEvent * ev, @@ -601,7 +598,7 @@ static void create_and_append_overview_page(struct city_dialog *pdialog) { int i; - GtkWidget *halves, *hbox, *vbox, *page, *align; + GtkWidget *halves, *hbox, *vbox, *page, *align, *vbox2; GtkWidget *frame, *table, *label, *scrolledwin; char *improvement_title[] = { N_("City improvements"), @@ -809,9 +806,11 @@ pdialog->overview.currently_building_frame, FALSE, FALSE, 0); - hbox = gtk_hbox_new(FALSE, 0); + vbox2 = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER - (pdialog->overview.currently_building_frame), hbox); + (pdialog->overview.currently_building_frame), vbox2); + hbox = gtk_hbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(vbox2), hbox); pdialog->overview.progress_label = gtk_progress_bar_new(); gtk_box_pack_start(GTK_BOX(hbox), pdialog->overview.progress_label, @@ -824,15 +823,23 @@ (pdialog->overview.progress_label), _("%d/%d %d turns")); + pdialog->overview.change_command = + gtk_accelbutton_new(_("_Change"), pdialog->accel); + gtk_box_pack_start(GTK_BOX(hbox), pdialog->overview.change_command, + TRUE, TRUE, 0); + + hbox = gtk_hbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(vbox2), hbox); + + pdialog->overview.buy_info_label = gtk_label_new("56 / 56"); + gtk_box_pack_start(GTK_BOX(hbox), pdialog->overview.buy_info_label, + TRUE, TRUE, 0); + pdialog->overview.buy_command = gtk_accelbutton_new(_("_Buy"), pdialog->accel); gtk_box_pack_start(GTK_BOX(hbox), pdialog->overview.buy_command, TRUE, TRUE, 0); - pdialog->overview.change_command = - gtk_accelbutton_new(_("_Change"), pdialog->accel); - gtk_box_pack_start(GTK_BOX(hbox), pdialog->overview.change_command, - TRUE, TRUE, 0); /* city improvements */ @@ -1434,7 +1441,6 @@ pdialog = fc_malloc(sizeof(struct city_dialog)); pdialog->pcity = pcity; pdialog->change_shell = NULL; - pdialog->buy_shell = NULL; pdialog->sell_shell = NULL; pdialog->rename_shell = NULL; pdialog->happiness.map_canvas = NULL; /* make sure NULL if spy */ @@ -1890,7 +1896,7 @@ static void city_dialog_update_building(struct city_dialog *pdialog) { char buf[32], buf2[200], *descr; - int turns; + int turns, cost; struct city *pcity = pdialog->pcity; gfloat pct; @@ -1898,6 +1904,16 @@ gtk_widget_set_sensitive(pdialog->overview.sell_command, !pcity->did_sell); + cost = city_buy_cost(pdialog->pcity); + + my_snprintf(buf2, sizeof(buf2), _("costs %d, have %d"), cost, + game.player_ptr->economic.gold); + gtk_label_set_text(GTK_LABEL(pdialog->overview.buy_info_label), buf2); + + if (game.player_ptr->economic.gold < cost) { + gtk_widget_set_sensitive(pdialog->overview.buy_command, FALSE); + } + if (pcity->is_building_unit) { turns = city_turns_to_build(pcity, pcity->currently_building, TRUE, TRUE); @@ -2939,7 +2955,6 @@ struct city_dialog *pdialog; int value; char *name; - char buf[512]; pdialog = (struct city_dialog *) data; @@ -2952,67 +2967,16 @@ } value = city_buy_cost(pdialog->pcity); - if (game.player_ptr->economic.gold >= value) { - my_snprintf(buf, sizeof(buf), - _("Buy %s for %d gold?\nTreasury contains %d gold."), - name, value, game.player_ptr->economic.gold); + assert(game.player_ptr->economic.gold >= value); - pdialog->buy_shell = - popup_message_dialog(pdialog->shell, /*"buydialog" */ _("Buy It!"), - buf, _("_Yes"), buy_callback_yes, pdialog, - _("_No"), buy_callback_no, pdialog, 0); - } else { - my_snprintf(buf, sizeof(buf), - _("%s costs %d gold.\nTreasury contains %d gold."), - name, value, game.player_ptr->economic.gold); + { + struct packet_city_request packet; - pdialog->buy_shell = popup_message_dialog(pdialog->shell, - _("Buy It!"), buf, _("Darn"), - buy_callback_no, pdialog, 0); + packet.city_id = pdialog->pcity->id; + packet.name[0] = '\0'; + packet.worklist.name[0] = '\0'; + send_packet_city_request(&aconnection, &packet, PACKET_CITY_BUY); } - - gtk_signal_connect(GTK_OBJECT(pdialog->buy_shell), "delete_event", - GTK_SIGNAL_FUNC(buy_callback_delete), data); -} - -/**************************************************************** -... -*****************************************************************/ -static gint buy_callback_delete(GtkWidget * w, GdkEvent * ev, - gpointer data) -{ - struct city_dialog *pdialog = (struct city_dialog *) data; - pdialog->buy_shell = NULL; - return FALSE; -} - -/**************************************************************** -... -*****************************************************************/ -static void buy_callback_no(GtkWidget * w, gpointer data) -{ - struct city_dialog *pdialog = (struct city_dialog *) data; - destroy_message_dialog(w); - pdialog->buy_shell = NULL; -} - -/**************************************************************** -... -*****************************************************************/ -static void buy_callback_yes(GtkWidget * w, gpointer data) -{ - struct city_dialog *pdialog; - struct packet_city_request packet; - - pdialog = (struct city_dialog *) data; - - packet.city_id = pdialog->pcity->id; - packet.name[0] = '\0'; - packet.worklist.name[0] = '\0'; - send_packet_city_request(&aconnection, &packet, PACKET_CITY_BUY); - - destroy_message_dialog(w); - pdialog->buy_shell = NULL; } /**************************************************************** @@ -3625,8 +3589,6 @@ if (pdialog->change_shell) gtk_widget_destroy(pdialog->change_shell); - if (pdialog->buy_shell) - gtk_widget_destroy(pdialog->buy_shell); if (pdialog->sell_shell) gtk_widget_destroy(pdialog->sell_shell); if (pdialog->rename_shell)