[Freeciv-Dev] gtk city configuration radio button
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
G'day,
This cleans up the city configuration dialog code a little to
- explain what the first option displayed does (like the mui client)
- remove the "triggle" button, and replace it with three radio buttons
labelled correctly.
Richard
--------
Richard Atkins rja@xxxxxxxxxxx
http://www.pcug.org.au/~rja/
"All these moments will be lost in
time, like tears in the rain."
Blade Runner
--------
--- cvs-freeciv/client/gui-gtk/citydlg.c Tue Apr 11 20:54:53 2000
+++ mod-freeciv/client/gui-gtk/citydlg.c Tue Apr 25 13:09:39 2000
@@ -2091,12 +2091,13 @@
GtkWidget *create_cityopt_dialog(char *city_name);
void cityopt_ok_command_callback(GtkWidget *w, gpointer data);
void cityopt_cancel_command_callback(GtkWidget *w, gpointer data);
-void cityopt_newcit_triggle_callback(GtkWidget *w, gpointer data);
-
-char *newcitizen_labels[] = { N_("Workers"), N_("Scientists"), N_("Taxmen") };
+void cityopt_newcit_radio_callback(GtkWidget *w, gpointer data);
+char *newcitizen_labels[] = { N_("Elvises"), N_("Scientists"), N_("Taxmen") };
static GtkWidget *cityopt_shell = 0;
-static GtkWidget *cityopt_triggle;
+static GtkWidget *cityopt_lux_radio;
+static GtkWidget *cityopt_sci_radio;
+static GtkWidget *cityopt_tax_radio;
static GtkWidget *cityopt_toggles[NUM_CITYOPT_TOGGLES];
static int cityopt_city_id = 0;
static int newcitizen_index;
@@ -2122,14 +2123,14 @@
}
if (pcity->city_options & (1<<CITYO_NEW_EINSTEIN)) {
newcitizen_index = 1;
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cityopt_sci_radio), TRUE);
} else if (pcity->city_options & (1<<CITYO_NEW_TAXMAN)) {
newcitizen_index = 2;
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cityopt_tax_radio), TRUE);
} else {
newcitizen_index = 0;
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cityopt_lux_radio), TRUE);
}
- gtk_label_set_text (GTK_LABEL (GTK_BIN (cityopt_triggle)->child),
- _(newcitizen_labels[newcitizen_index]));
-
cityopt_city_id = pcity->id;
/* gtk_set_relative_position(toplevel, cityopt_shell, 15, 15);*/
@@ -2154,10 +2155,20 @@
gtk_box_pack_start (GTK_BOX (GTK_DIALOG(shell)->vbox),
label, FALSE, FALSE, 0);
-
- cityopt_triggle = gtk_check_button_new_with_label (_("Scientists"));
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG(shell)->vbox),
- cityopt_triggle, FALSE, FALSE, 0);
+ label = gtk_label_new(_("New specialists are"));
+ gtk_box_pack_start(GTK_BOX(GTK_DIALOG(shell)->vbox),
+ label, FALSE, FALSE, 0);
+ cityopt_lux_radio = gtk_radio_button_new_with_label(NULL, _("Elvises"));
+ gtk_box_pack_start(GTK_BOX (GTK_DIALOG(shell)->vbox),
+ cityopt_lux_radio, FALSE, FALSE, 0);
+
+ cityopt_sci_radio =
gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(cityopt_lux_radio)),
_("Scientists"));
+ gtk_box_pack_start(GTK_BOX (GTK_DIALOG(shell)->vbox),
+ cityopt_sci_radio, FALSE, FALSE, 0);
+
+ cityopt_tax_radio =
gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(cityopt_sci_radio)),
_("Taxmen"));
+ gtk_box_pack_start(GTK_BOX (GTK_DIALOG(shell)->vbox),
+ cityopt_tax_radio, FALSE, FALSE, 0);
/* NOTE: the ordering here is deliberately out of order;
want toggles[] to be in enum city_options order, but
@@ -2206,9 +2217,12 @@
gtk_signal_connect(GTK_OBJECT(cancel), "clicked",
GTK_SIGNAL_FUNC(cityopt_cancel_command_callback), shell);
- gtk_signal_connect(GTK_OBJECT(cityopt_triggle), "toggled",
- GTK_SIGNAL_FUNC(cityopt_newcit_triggle_callback), NULL);
-
+ gtk_signal_connect(GTK_OBJECT(cityopt_lux_radio), "toggled",
+ GTK_SIGNAL_FUNC(cityopt_newcit_radio_callback), NULL);
+ gtk_signal_connect(GTK_OBJECT(cityopt_sci_radio), "toggled",
+ GTK_SIGNAL_FUNC(cityopt_newcit_radio_callback), NULL);
+ gtk_signal_connect(GTK_OBJECT(cityopt_tax_radio), "toggled",
+ GTK_SIGNAL_FUNC(cityopt_newcit_radio_callback), NULL);
gtk_widget_show_all(GTK_DIALOG(shell)->vbox);
gtk_widget_show_all(GTK_DIALOG(shell)->action_area);
@@ -2254,17 +2268,16 @@
}
/**************************************************************************
- Changes the label of the toggle widget to between newcitizen_labels
- and increments (mod 3) newcitizen_index.
+ Sets newcitizen_index based on the selected radio button.
**************************************************************************/
-void cityopt_newcit_triggle_callback(GtkWidget *w, gpointer data)
+void cityopt_newcit_radio_callback(GtkWidget *w, gpointer data)
{
- newcitizen_index++;
- if (newcitizen_index>=3) {
+ if (w == cityopt_lux_radio)
newcitizen_index = 0;
- }
- gtk_label_set_text (GTK_LABEL (GTK_BIN (cityopt_triggle)->child),
- _(newcitizen_labels[newcitizen_index]));
+ else if (w == cityopt_sci_radio)
+ newcitizen_index = 1;
+ else
+ newcitizen_index = 2;
}
/**************************************************************************
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] gtk city configuration radio button,
Richard Atkins <=
|
|