107 bv_extras potential_tgt_extras,
109 const gchar *dlg_title,
110 const gchar *actor_label,
111 const gchar *tgt_label,
112 const gchar *do_label,
113 GCallback do_callback)
122 GtkWidget *default_option = NULL;
123 GtkWidget *first_option = NULL;
127 const struct extra_type *default_extra = NULL;
129 dlg = gtk_dialog_new_with_buttons(dlg_title, NULL, 0,
130 _(
"Close"), GTK_RESPONSE_NO,
131 do_label, GTK_RESPONSE_YES,
134 gtk_dialog_set_default_response(GTK_DIALOG(dlg), GTK_RESPONSE_NO);
135 gtk_window_set_destroy_with_parent(GTK_WINDOW(dlg),
TRUE);
137 main_box = gtk_grid_new();
138 gtk_orientable_set_orientation(GTK_ORIENTABLE(main_box),
139 GTK_ORIENTATION_VERTICAL);
140 box = gtk_grid_new();
141 gtk_orientable_set_orientation(GTK_ORIENTABLE(box),
142 GTK_ORIENTATION_HORIZONTAL);
144 lbl = gtk_label_new(actor_label);
145 gtk_grid_attach(GTK_GRID(box), lbl, 0, 0, 1, 1);
151 icon = gtk_image_new();
153 gtk_grid_attach(GTK_GRID(box), icon, 1, 0, 1, 1);
156 gtk_grid_attach(GTK_GRID(box), lbl, 2, 0, 1, 1);
158 gtk_container_add(GTK_CONTAINER(main_box), box);
160 sep = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
161 gtk_container_add(GTK_CONTAINER(main_box), sep);
163 lbl = gtk_label_new(tgt_label);
164 gtk_container_add(GTK_CONTAINER(main_box), lbl);
166 box = gtk_grid_new();
179 cbdata->
tp_id = ptgt->id;
182 radio = gtk_radio_button_new_from_widget(
183 GTK_RADIO_BUTTON(first_option));
184 if (first_option == NULL) {
185 first_option = radio;
186 default_option = first_option;
187 default_extra = ptgt;
192 GTK_RADIO_BUTTON(radio)))
193 == g_slist_length(gtk_radio_button_get_group(
194 GTK_RADIO_BUTTON(first_option))),
195 "The radio button for '%s' is broken.",
197 g_signal_connect(radio,
"toggled",
199 g_signal_connect(radio,
"destroy",
201 if (ptgt == suggested_tgt_extra) {
202 default_option = radio;
203 default_extra = suggested_tgt_extra;
205 gtk_grid_attach(GTK_GRID(box), radio, 0, tcount, 1, 1);
209 icon = gtk_image_new_from_pixbuf(tubuf);
210 g_object_unref(tubuf);
212 icon = gtk_image_new();
214 gtk_grid_attach(GTK_GRID(box), icon, 1, tcount, 1, 1);
217 gtk_grid_attach(GTK_GRID(box), lbl, 2, tcount, 1, 1);
221 gtk_container_add(GTK_CONTAINER(main_box), box);
224 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(default_option),
TRUE);
227 GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(
dlg))),
230 g_object_set_data(G_OBJECT(
dlg),
"actor", GINT_TO_POINTER(
actor->
id));
231 g_object_set_data(G_OBJECT(
dlg),
"tile", ptile);
236 if (default_extra != NULL) {
237 g_object_set_data(G_OBJECT(
dlg),
"target", GINT_TO_POINTER(default_extra->
id));
240 g_signal_connect(
dlg,
"response", do_callback,
actor);
242 gtk_widget_show_all(gtk_dialog_get_content_area(GTK_DIALOG(
dlg)));
243 gtk_widget_show(
dlg);