static void fill_dive_list(void) { int i; GtkTreeIter iter; GtkListStore *store; store = GTK_LIST_STORE(dive_list.model); i = dive_table.nr; while (--i >= 0) { struct dive *dive = dive_table.dives[i]; update_cylinder_related_info(dive); gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, DIVE_INDEX, i, DIVE_NR, dive->number, DIVE_DATE, dive->when, DIVE_DEPTH, dive->maxdepth, DIVE_DURATION, dive->duration.seconds, DIVE_LOCATION, "location", DIVE_TEMPERATURE, dive->watertemp.mkelvin, DIVE_SAC, 0, -1); } update_dive_list_units(); if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(dive_list.model), &iter)) { GtkTreeSelection *selection; selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dive_list.tree_view)); gtk_tree_selection_select_iter(selection, &iter); } }
static void preferences_dialog(GtkWidget *w, gpointer data) { int result; GtkWidget *dialog, *font, *frame, *box, *vbox, *button; menu_units = output_units; dialog = gtk_dialog_new_with_buttons("Preferences", GTK_WINDOW(main_window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); frame = gtk_frame_new("Units"); vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5); box = gtk_vbox_new(FALSE, 6); gtk_container_add(GTK_CONTAINER(frame), box); create_radio(box, "Depth:", "Meter", set_meter, (output_units.length == METERS), "Feet", set_feet, (output_units.length == FEET), NULL); create_radio(box, "Pressure:", "Bar", set_bar, (output_units.pressure == BAR), "PSI", set_psi, (output_units.pressure == PSI), NULL); create_radio(box, "Volume:", "Liter", set_liter, (output_units.volume == LITER), "CuFt", set_cuft, (output_units.volume == CUFT), NULL); create_radio(box, "Temperature:", "Celsius", set_celsius, (output_units.temperature == CELSIUS), "Fahrenheit", set_fahrenheit, (output_units.temperature == FAHRENHEIT), NULL); frame = gtk_frame_new("Columns"); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), frame, FALSE, FALSE, 5); box = gtk_hbox_new(FALSE, 6); gtk_container_add(GTK_CONTAINER(frame), box); button = gtk_check_button_new_with_label("Show Temp"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), visible_cols.temperature); gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6); g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(temperature_toggle), NULL); button = gtk_check_button_new_with_label("Show Cyl"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), visible_cols.cylinder); gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6); g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(cylinder_toggle), NULL); button = gtk_check_button_new_with_label("Show O" UTF8_SUBSCRIPT_2 "%"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), visible_cols.nitrox); gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6); g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(nitrox_toggle), NULL); button = gtk_check_button_new_with_label("Show SAC"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), visible_cols.sac); gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6); g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(sac_toggle), NULL); button = gtk_check_button_new_with_label("Show OTU"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), visible_cols.otu); gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6); g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(otu_toggle), NULL); font = gtk_font_button_new_with_font(divelist_font); gtk_box_pack_start(GTK_BOX(vbox), font, FALSE, FALSE, 5); gtk_widget_show_all(dialog); result = gtk_dialog_run(GTK_DIALOG(dialog)); if (result == GTK_RESPONSE_ACCEPT) { /* Make sure to flush any modified old dive data with old units */ update_dive(NULL); divelist_font = strdup(gtk_font_button_get_font_name(GTK_FONT_BUTTON(font))); set_divelist_font(divelist_font); output_units = menu_units; update_dive_list_units(); repaint_dive(); update_dive_list_col_visibility(); subsurface_set_conf("feet", PREF_BOOL, BOOL_TO_PTR(output_units.length == FEET)); subsurface_set_conf("psi", PREF_BOOL, BOOL_TO_PTR(output_units.pressure == PSI)); subsurface_set_conf("cuft", PREF_BOOL, BOOL_TO_PTR(output_units.volume == CUFT)); subsurface_set_conf("fahrenheit", PREF_BOOL, BOOL_TO_PTR(output_units.temperature == FAHRENHEIT)); subsurface_set_conf("TEMPERATURE", PREF_BOOL, BOOL_TO_PTR(visible_cols.temperature)); subsurface_set_conf("CYLINDER", PREF_BOOL, BOOL_TO_PTR(visible_cols.cylinder)); subsurface_set_conf("NITROX", PREF_BOOL, BOOL_TO_PTR(visible_cols.nitrox)); subsurface_set_conf("SAC", PREF_BOOL, BOOL_TO_PTR(visible_cols.sac)); subsurface_set_conf("OTU", PREF_BOOL, BOOL_TO_PTR(visible_cols.otu)); subsurface_set_conf("divelist_font", PREF_STRING, divelist_font); subsurface_close_conf(); } gtk_widget_destroy(dialog); }