224 GtkWidget *frame, *page, *hbox, *vbox, *label, *table;
225 GtkWidget *sw, *hscale, *button;
227 GtkCellRenderer *rend;
229 GtkTreeViewColumn *column;
231 GtkEventController *controller;
237 pdialog->
pcity = pcity;
238 pdialog->
shell = gtk_grid_new();
239 gtk_orientable_set_orientation(GTK_ORIENTABLE(pdialog->
shell),
240 GTK_ORIENTATION_VERTICAL);
241 gtk_grid_set_row_spacing(GTK_GRID(pdialog->
shell), 8);
242 gtk_widget_set_margin_start(pdialog->
shell, 8);
243 gtk_widget_set_margin_end(pdialog->
shell, 8);
244 gtk_widget_set_margin_top(pdialog->
shell, 8);
245 gtk_widget_set_margin_bottom(pdialog->
shell, 8);
246 g_signal_connect(pdialog->
shell,
"destroy",
249 page = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
250 gtk_grid_attach(GTK_GRID(pdialog->
shell), page, 0, shell_row++, 1, 1);
252 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);
253 gtk_grid_set_row_spacing(GTK_GRID(pdialog->
shell), 2);
254 gtk_box_append(GTK_BOX(page), vbox);
256 sw = gtk_scrolled_window_new();
257 gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw),
TRUE);
258 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
259 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
261 store = gtk_list_store_new(1, G_TYPE_STRING);
262 pdialog->
store = store;
264 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
267 g_object_unref(store);
268 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(
view),
FALSE);
270 pdialog->
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(
view));
272 g_object_set_data(G_OBJECT(pdialog->
preset_list),
"dialog", pdialog);
273 controller = GTK_EVENT_CONTROLLER(gtk_gesture_click_new());
274 g_signal_connect(controller,
"pressed",
276 gtk_widget_add_controller(pdialog->
preset_list, controller);
278 gtk_widget_set_tooltip_text(
view,
279 _(
"For information on\n"
280 "the citizen governor and governor presets,\n"
281 "including sample presets,\n"
282 "see README.governor."));
284 rend = gtk_cell_renderer_text_new();
285 column = gtk_tree_view_column_new_with_attributes(NULL, rend,
287 gtk_tree_view_append_column(GTK_TREE_VIEW(
view), column);
288 gtk_tree_view_column_set_cell_data_func(column, rend,
cell_data_func,
291 label = g_object_new(GTK_TYPE_LABEL,
292 "use-underline",
TRUE,
293 "mnemonic-widget",
view,
294 "label",
_(
"Prese_ts:"),
295 "xalign", 0.0,
"yalign", 0.5, NULL);
296 gtk_box_append(GTK_BOX(vbox), label);
298 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw),
view);
299 gtk_box_append(GTK_BOX(vbox), sw);
301 g_signal_connect(
view,
"row_activated",
303 controller = gtk_event_controller_key_new();
304 g_signal_connect(controller,
"key-pressed",
306 gtk_widget_add_controller(
view, controller);
308 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
309 gtk_box_append(GTK_BOX(vbox), hbox);
312 gtk_box_append(GTK_BOX(hbox), button);
313 g_signal_connect(button,
"clicked",
324 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);
325 gtk_widget_set_margin_bottom(vbox, 2);
326 gtk_widget_set_margin_end(vbox, 2);
327 gtk_widget_set_margin_start(vbox, 2);
328 gtk_widget_set_margin_top(vbox, 2);
329 gtk_box_append(GTK_BOX(page), vbox);
333 frame = gtk_frame_new(
_(
"Results"));
334 gtk_widget_set_vexpand(frame,
TRUE);
335 gtk_widget_set_valign(frame, GTK_ALIGN_CENTER);
336 gtk_box_append(GTK_BOX(vbox), frame);
339 gtk_label_new(
"food\n prod\n trade\n\n people\n grow\n prod\n name");
340 gtk_widget_set_name(pdialog->
result_label,
"city_label");
341 gtk_frame_set_child(GTK_FRAME(frame), pdialog->
result_label);
342 gtk_label_set_justify(GTK_LABEL(pdialog->
result_label), GTK_JUSTIFY_LEFT);
348 table = gtk_grid_new();
349 gtk_widget_set_margin_bottom(table, 2);
350 gtk_widget_set_margin_end(table, 2);
351 gtk_widget_set_margin_start(table, 2);
352 gtk_widget_set_margin_top(table, 2);
353 gtk_box_append(GTK_BOX(vbox), table);
355 label = gtk_label_new(
_(
"Minimal Surplus"));
356 gtk_widget_set_halign(label, GTK_ALIGN_START);
357 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
358 gtk_grid_attach(GTK_GRID(table), label, 1, 0, 1, 1);
359 label = gtk_label_new(
_(
"Factor"));
360 gtk_widget_set_halign(label, GTK_ALIGN_START);
361 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
362 gtk_grid_attach(GTK_GRID(table), label, 2, 0, 1, 1);
366 gtk_grid_attach(GTK_GRID(table), label, 0, i + 1, 1, 1);
367 gtk_widget_set_halign(label, GTK_ALIGN_START);
368 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
371 gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, NULL);
372 gtk_range_set_range(GTK_RANGE(hscale),
375 gtk_range_set_increments(GTK_RANGE(hscale), 1, 1);
376 layout = gtk_scale_get_layout(GTK_SCALE(hscale));
378 pango_layout_get_pixel_size(
layout, &layout_width, NULL);
379 gtk_widget_set_size_request(hscale, layout_width + 51 * 2, -1);
382 gtk_grid_attach(GTK_GRID(table), hscale, 1, 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);
390 pdialog->
factor[i] = hscale
391 = gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, NULL);
392 gtk_range_set_range(GTK_RANGE(hscale), 0, 25);
393 gtk_range_set_increments(GTK_RANGE(hscale), 1, 1);
394 layout = gtk_scale_get_layout(GTK_SCALE(hscale));
396 pango_layout_get_pixel_size(
layout, &layout_width, NULL);
400 gtk_widget_set_size_request(hscale, layout_width + 26 * 2, -1);
402 gtk_grid_attach(GTK_GRID(table), hscale, 2, i + 1, 1, 1);
403 gtk_scale_set_digits(GTK_SCALE(hscale), 0);
404 gtk_scale_set_value_pos(GTK_SCALE(hscale), GTK_POS_LEFT);
406 g_signal_connect(pdialog->
factor[i],
"value-changed",
411 label = gtk_label_new(
_(
"Celebrate"));
412 gtk_grid_attach(GTK_GRID(table), label, 0,
O_LAST + 1, 1, 1);
413 gtk_widget_set_halign(label, GTK_ALIGN_START);
414 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
417 gtk_widget_set_halign(pdialog->
happy_button, GTK_ALIGN_END);
418 gtk_check_button_set_active(GTK_CHECK_BUTTON(pdialog->
happy_button),
426 gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, NULL);
427 gtk_range_set_range(GTK_RANGE(hscale), 0, 50);
428 gtk_range_set_increments(GTK_RANGE(hscale), 1, 1);
429 layout = gtk_scale_get_layout(GTK_SCALE(hscale));
431 pango_layout_get_pixel_size(
layout, &layout_width, NULL);
432 gtk_widget_set_size_request(hscale, layout_width + 51 * 2, -1);
435 gtk_grid_attach(GTK_GRID(table), hscale, 2,
O_LAST + 1, 1, 1);
436 gtk_scale_set_digits(GTK_SCALE(hscale), 0);
437 gtk_scale_set_value_pos(GTK_SCALE(hscale), GTK_POS_LEFT);
444 label = gtk_label_new(
_(
"Maximize growth"));
445 gtk_grid_attach(GTK_GRID(table), label, 0,
O_LAST + 2, 1, 1);
446 gtk_widget_set_halign(label, GTK_ALIGN_START);
447 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
450 gtk_widget_set_halign(pdialog->
growth_button, GTK_ALIGN_END);
451 gtk_check_button_set_active(GTK_CHECK_BUTTON(pdialog->
growth_button),
459 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
460 gtk_box_append(GTK_BOX(vbox), hbox);
463 g_signal_connect(button,
"clicked",
465 gtk_box_append(GTK_BOX(hbox), button);
472 gtk_widget_show(pdialog->
shell);