218 GtkWidget *frame, *page, *hbox, *label, *table;
219 GtkWidget *vbox, *sw, *hscale, *button, *image;
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);
299 button = gtk_button_new_with_mnemonic(
_(
"Ne_w"));
300 image = gtk_image_new_from_stock(GTK_STOCK_NEW, GTK_ICON_SIZE_BUTTON);
301 gtk_button_set_image(GTK_BUTTON(button), image);
302 gtk_container_add(GTK_CONTAINER(hbox), button);
303 g_signal_connect(button,
"clicked",
314 vbox = gtk_grid_new();
315 g_object_set(vbox,
"margin", 2, NULL);
316 gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox),
317 GTK_ORIENTATION_VERTICAL);
318 gtk_container_add(GTK_CONTAINER(page), vbox);
322 frame = gtk_frame_new(
_(
"Results"));
323 gtk_widget_set_vexpand(frame,
TRUE);
324 gtk_widget_set_valign(frame, GTK_ALIGN_CENTER);
325 gtk_container_add(GTK_CONTAINER(vbox), frame);
328 gtk_label_new(
"food\n prod\n trade\n\n people\n grow\n prod\n name");
329 gtk_widget_set_name(pdialog->
result_label,
"city_label");
330 gtk_container_add(GTK_CONTAINER(frame), pdialog->
result_label);
331 gtk_label_set_justify(GTK_LABEL(pdialog->
result_label), GTK_JUSTIFY_LEFT);
338 table = gtk_grid_new();
339 g_object_set(table,
"margin", 2, NULL);
340 gtk_container_add(GTK_CONTAINER(vbox), table);
342 label = gtk_label_new(
_(
"Minimal Surplus"));
343 gtk_widget_set_halign(label, GTK_ALIGN_START);
344 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
345 gtk_grid_attach(GTK_GRID(table), label, 1, 0, 1, 1);
346 label = gtk_label_new(
_(
"Factor"));
347 gtk_widget_set_halign(label, GTK_ALIGN_START);
348 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
349 gtk_grid_attach(GTK_GRID(table), label, 2, 0, 1, 1);
353 gtk_grid_attach(GTK_GRID(table), label, 0, i + 1, 1, 1);
354 gtk_widget_set_halign(label, GTK_ALIGN_START);
355 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
358 gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, NULL);
359 gtk_range_set_range(GTK_RANGE(hscale),
362 gtk_range_set_increments(GTK_RANGE(hscale), 1, 1);
363 pango_layout_get_pixel_size(gtk_scale_get_layout(GTK_SCALE(hscale)),
364 &layout_width, NULL);
365 gtk_widget_set_size_request(hscale, layout_width + 51 * 2, -1);
367 gtk_grid_attach(GTK_GRID(table), hscale, 1, i + 1, 1, 1);
368 gtk_scale_set_digits(GTK_SCALE(hscale), 0);
369 gtk_scale_set_value_pos(GTK_SCALE(hscale), GTK_POS_LEFT);
375 pdialog->
factor[i] = hscale =
376 gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, NULL);
377 gtk_range_set_range(GTK_RANGE(hscale), 0, 25);
378 gtk_range_set_increments(GTK_RANGE(hscale), 1, 1);
379 pango_layout_get_pixel_size(gtk_scale_get_layout(GTK_SCALE(hscale)),
380 &layout_width, NULL);
381 gtk_widget_set_size_request(hscale, layout_width + 26 * 2, -1);
383 gtk_grid_attach(GTK_GRID(table), hscale, 2, i + 1, 1, 1);
384 gtk_scale_set_digits(GTK_SCALE(hscale), 0);
385 gtk_scale_set_value_pos(GTK_SCALE(hscale), GTK_POS_LEFT);
387 g_signal_connect(pdialog->
factor[i],
"value-changed",
392 label = gtk_label_new(
_(
"Celebrate"));
393 gtk_grid_attach(GTK_GRID(table), label, 0,
O_LAST + 1, 1, 1);
394 gtk_widget_set_halign(label, GTK_ALIGN_START);
395 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
398 gtk_widget_set_halign(pdialog->
happy_button, GTK_ALIGN_END);
399 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pdialog->
happy_button),
407 gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, NULL);
408 gtk_range_set_range(GTK_RANGE(hscale), 0, 50);
409 gtk_range_set_increments(GTK_RANGE(hscale), 1, 1);
410 pango_layout_get_pixel_size(gtk_scale_get_layout(GTK_SCALE(hscale)),
411 &layout_width, NULL);
412 gtk_widget_set_size_request(hscale, layout_width + 51 * 2, -1);
414 gtk_grid_attach(GTK_GRID(table), hscale, 2,
O_LAST + 1, 1, 1);
415 gtk_scale_set_digits(GTK_SCALE(hscale), 0);
416 gtk_scale_set_value_pos(GTK_SCALE(hscale), GTK_POS_LEFT);
423 label = gtk_label_new(
_(
"Maximize growth"));
424 gtk_grid_attach(GTK_GRID(table), label, 0,
O_LAST + 2, 1, 1);
425 gtk_widget_set_halign(label, GTK_ALIGN_START);
426 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
429 gtk_widget_set_halign(pdialog->
growth_button, GTK_ALIGN_END);
430 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pdialog->
growth_button),
438 hbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
439 gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_EDGE);
440 gtk_container_add(GTK_CONTAINER(vbox), hbox);
442 button = gtk_button_new_from_stock(GTK_STOCK_HELP);
443 g_signal_connect(button,
"clicked",
445 gtk_container_add(GTK_CONTAINER(hbox), button);
446 gtk_button_box_set_child_non_homogeneous(GTK_BUTTON_BOX(hbox),
451 gtk_button_set_image_position(GTK_BUTTON(pdialog->
active_command),
456 gtk_widget_show_all(pdialog->
shell);