218 GtkWidget *frame, *page, *hbox, *label, *table;
219 GtkWidget *vbox, *sw, *hscale, *button;
221 GtkCellRenderer *rend;
223 GtkTreeViewColumn *column;
228 pdialog->
pcity = pcity;
229 pdialog->
shell = gtk_grid_new();
230 gtk_orientable_set_orientation(GTK_ORIENTABLE(pdialog->
shell),
231 GTK_ORIENTATION_VERTICAL);
232 gtk_grid_set_row_spacing(GTK_GRID(pdialog->
shell), 8);
233 gtk_container_set_border_width(GTK_CONTAINER(pdialog->
shell), 8);
234 g_signal_connect(pdialog->
shell,
"destroy",
237 page = gtk_grid_new();
238 gtk_grid_set_column_spacing(GTK_GRID(page), 12);
239 gtk_container_add(GTK_CONTAINER(pdialog->
shell), page);
241 vbox = gtk_grid_new();
242 gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox),
243 GTK_ORIENTATION_VERTICAL);
244 gtk_grid_set_row_spacing(GTK_GRID(pdialog->
shell), 2);
245 gtk_container_add(GTK_CONTAINER(page), vbox);
247 sw = gtk_scrolled_window_new(NULL, NULL);
248 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
249 GTK_SHADOW_ETCHED_IN);
250 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
251 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
253 store = gtk_list_store_new(1, G_TYPE_STRING);
254 pdialog->
store = store;
256 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
259 g_object_unref(store);
260 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(
view),
FALSE);
262 pdialog->
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(
view));
264 g_signal_connect(pdialog->
preset_list,
"button_press_event",
267 gtk_widget_set_tooltip_text(
view,
268 _(
"For information on\n"
269 "the citizen governor and governor presets,\n"
270 "including sample presets,\n"
271 "see README.governor."));
273 rend = gtk_cell_renderer_text_new();
274 column = gtk_tree_view_column_new_with_attributes(NULL, rend,
276 gtk_tree_view_append_column(GTK_TREE_VIEW(
view), column);
277 gtk_tree_view_column_set_cell_data_func(column, rend,
cell_data_func,
280 label = g_object_new(GTK_TYPE_LABEL,
281 "use-underline",
TRUE,
282 "mnemonic-widget",
view,
283 "label",
_(
"Prese_ts:"),
284 "xalign", 0.0,
"yalign", 0.5, NULL);
285 gtk_container_add(GTK_CONTAINER(vbox), label);
287 gtk_container_add(GTK_CONTAINER(sw),
view);
288 gtk_container_add(GTK_CONTAINER(vbox), sw);
290 g_signal_connect(
view,
"row_activated",
292 g_signal_connect(
view,
"key-press-event",
295 hbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
296 gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_EDGE);
297 gtk_container_add(GTK_CONTAINER(vbox), hbox);
300 gtk_container_add(GTK_CONTAINER(hbox), button);
301 g_signal_connect(button,
"clicked",
313 vbox = gtk_grid_new();
314 g_object_set(vbox,
"margin", 2, NULL);
315 gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox),
316 GTK_ORIENTATION_VERTICAL);
317 gtk_container_add(GTK_CONTAINER(page), vbox);
321 frame = gtk_frame_new(
_(
"Results"));
322 gtk_widget_set_vexpand(frame,
TRUE);
323 gtk_widget_set_valign(frame, GTK_ALIGN_CENTER);
324 gtk_container_add(GTK_CONTAINER(vbox), frame);
327 gtk_label_new(
"food\n prod\n trade\n\n people\n grow\n prod\n name");
328 gtk_widget_set_name(pdialog->
result_label,
"city_label");
329 gtk_container_add(GTK_CONTAINER(frame), pdialog->
result_label);
330 gtk_label_set_justify(GTK_LABEL(pdialog->
result_label), GTK_JUSTIFY_LEFT);
337 table = gtk_grid_new();
338 g_object_set(table,
"margin", 2, NULL);
339 gtk_container_add(GTK_CONTAINER(vbox), table);
341 label = gtk_label_new(
_(
"Minimal Surplus"));
342 gtk_widget_set_halign(label, GTK_ALIGN_START);
343 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
344 gtk_grid_attach(GTK_GRID(table), label, 1, 0, 1, 1);
345 label = gtk_label_new(
_(
"Factor"));
346 gtk_widget_set_halign(label, GTK_ALIGN_START);
347 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
348 gtk_grid_attach(GTK_GRID(table), label, 2, 0, 1, 1);
352 gtk_grid_attach(GTK_GRID(table), label, 0, i + 1, 1, 1);
353 gtk_widget_set_halign(label, GTK_ALIGN_START);
354 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
357 gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, NULL);
358 gtk_range_set_range(GTK_RANGE(hscale),
361 gtk_range_set_increments(GTK_RANGE(hscale), 1, 1);
362 pango_layout_get_pixel_size(gtk_scale_get_layout(GTK_SCALE(hscale)),
363 &layout_width, NULL);
364 gtk_widget_set_size_request(hscale, layout_width + 51 * 2, -1);
366 gtk_grid_attach(GTK_GRID(table), hscale, 1, i + 1, 1, 1);
367 gtk_scale_set_digits(GTK_SCALE(hscale), 0);
368 gtk_scale_set_value_pos(GTK_SCALE(hscale), GTK_POS_LEFT);
374 pdialog->
factor[i] = hscale =
375 gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, NULL);
376 gtk_range_set_range(GTK_RANGE(hscale), 0, 25);
377 gtk_range_set_increments(GTK_RANGE(hscale), 1, 1);
378 pango_layout_get_pixel_size(gtk_scale_get_layout(GTK_SCALE(hscale)),
379 &layout_width, NULL);
380 gtk_widget_set_size_request(hscale, layout_width + 26 * 2, -1);
382 gtk_grid_attach(GTK_GRID(table), hscale, 2, i + 1, 1, 1);
383 gtk_scale_set_digits(GTK_SCALE(hscale), 0);
384 gtk_scale_set_value_pos(GTK_SCALE(hscale), GTK_POS_LEFT);
386 g_signal_connect(pdialog->
factor[i],
"value-changed",
391 label = gtk_label_new(
_(
"Celebrate"));
392 gtk_grid_attach(GTK_GRID(table), label, 0,
O_LAST + 1, 1, 1);
393 gtk_widget_set_halign(label, GTK_ALIGN_START);
394 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
397 gtk_widget_set_halign(pdialog->
happy_button, GTK_ALIGN_END);
398 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pdialog->
happy_button),
406 gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, NULL);
407 gtk_range_set_range(GTK_RANGE(hscale), 0, 50);
408 gtk_range_set_increments(GTK_RANGE(hscale), 1, 1);
409 pango_layout_get_pixel_size(gtk_scale_get_layout(GTK_SCALE(hscale)),
410 &layout_width, NULL);
411 gtk_widget_set_size_request(hscale, layout_width + 51 * 2, -1);
413 gtk_grid_attach(GTK_GRID(table), hscale, 2,
O_LAST + 1, 1, 1);
414 gtk_scale_set_digits(GTK_SCALE(hscale), 0);
415 gtk_scale_set_value_pos(GTK_SCALE(hscale), GTK_POS_LEFT);
422 label = gtk_label_new(
_(
"Maximize growth"));
423 gtk_grid_attach(GTK_GRID(table), label, 0,
O_LAST + 2, 1, 1);
424 gtk_widget_set_halign(label, GTK_ALIGN_START);
425 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
428 gtk_widget_set_halign(pdialog->
growth_button, GTK_ALIGN_END);
429 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pdialog->
growth_button),
437 hbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
438 gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_EDGE);
439 gtk_container_add(GTK_CONTAINER(vbox), hbox);
442 g_signal_connect(button,
"clicked",
444 gtk_container_add(GTK_CONTAINER(hbox), button);
445 gtk_button_box_set_child_non_homogeneous(GTK_BUTTON_BOX(hbox),
450 gtk_button_set_image_position(GTK_BUTTON(pdialog->
active_command),
455 gtk_widget_show_all(pdialog->
shell);