71 struct unit_list *potential_tgt_units,
72 struct unit *suggested_tgt_unit,
73 const gchar *dlg_title,
74 const gchar *actor_label,
75 const gchar *tgt_label,
76 const gchar *do_label,
77 GCallback do_callback)
81 GtkWidget *box, *grid;
86 GtkWidget *default_option = NULL;
87 GtkWidget *first_option = NULL;
91 const struct unit *default_unit = NULL;
95 dlg = gtk_dialog_new_with_buttons(dlg_title, NULL, 0,
96 _(
"Close"), GTK_RESPONSE_NO,
97 do_label, GTK_RESPONSE_YES,
100 gtk_dialog_set_default_response(GTK_DIALOG(dlg), GTK_RESPONSE_NO);
101 gtk_window_set_destroy_with_parent(GTK_WINDOW(dlg),
TRUE);
103 main_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);
104 box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
106 lbl = gtk_label_new(actor_label);
107 gtk_box_append(GTK_BOX(box), lbl);
113 icon = gtk_image_new();
115 gtk_widget_set_size_request(icon, tuw, tuh);
116 gtk_box_append(GTK_BOX(box), icon);
119 gtk_box_append(GTK_BOX(box), lbl);
121 gtk_box_append(GTK_BOX(main_box), box);
123 sep = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
124 gtk_box_append(GTK_BOX(main_box), sep);
126 lbl = gtk_label_new(tgt_label);
127 gtk_box_append(GTK_BOX(main_box), lbl);
129 grid = gtk_grid_new();
138 cbdata->
tp_id = ptgt->id;
141 radio = gtk_check_button_new();
142 gtk_check_button_set_group(GTK_CHECK_BUTTON(radio),
143 GTK_CHECK_BUTTON(first_option));
144 if (first_option == NULL) {
145 first_option = radio;
146 default_option = first_option;
149 g_signal_connect(radio,
"toggled",
151 g_signal_connect(radio,
"destroy",
153 if (ptgt == suggested_tgt_unit) {
154 default_option = radio;
155 default_unit = suggested_tgt_unit;
157 gtk_grid_attach(GTK_GRID(grid), radio, 0, tcount, 1, 1);
161 icon = gtk_image_new_from_pixbuf(tubuf);
162 g_object_unref(tubuf);
164 icon = gtk_image_new();
166 gtk_widget_set_size_request(icon, tuw, tuh);
167 gtk_grid_attach(GTK_GRID(grid), icon, 1, tcount, 1, 1);
170 gtk_grid_attach(GTK_GRID(grid), lbl, 2, tcount, 1, 1);
174 gtk_box_append(GTK_BOX(main_box), grid);
177 gtk_check_button_set_active(GTK_CHECK_BUTTON(default_option),
TRUE);
179 gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(
dlg))),
182 g_object_set_data(G_OBJECT(
dlg),
"actor", GINT_TO_POINTER(
actor->
id));
183 g_object_set_data(G_OBJECT(
dlg),
"tile", ptile);
188 if (default_unit != NULL) {
189 g_object_set_data(G_OBJECT(
dlg),
"target", GINT_TO_POINTER(default_unit->
id));
192 g_signal_connect(
dlg,
"response", do_callback,
actor);
194 gtk_widget_show(gtk_dialog_get_content_area(GTK_DIALOG(
dlg)));
195 gtk_widget_show(
dlg);
bool select_tgt_unit(struct unit *actor, struct tile *ptile, struct unit_list *potential_tgt_units, struct unit *suggested_tgt_unit, const gchar *dlg_title, const gchar *actor_label, const gchar *tgt_label, const gchar *do_label, GCallback do_callback)