X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=gtk-gui.c;h=371a0308fdb014c925d8e679f58b878ca765394d;hb=854bd0269c05adc56caf9667fd68f676520a2941;hp=6df8f419b13acad02fb3f3cb7b36f17c0fdeafc7;hpb=95cc317b087e863f6e0a4ab4db7ab68f06a9d969;p=ext%2Fsubsurface.git diff --git a/gtk-gui.c b/gtk-gui.c index 6df8f41..371a030 100644 --- a/gtk-gui.c +++ b/gtk-gui.c @@ -162,7 +162,7 @@ static void ask_save_changes() dialog = gtk_dialog_new_with_buttons("Save Changes?", GTK_WINDOW(main_window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_NO, GTK_RESPONSE_NO, NULL); content = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); label = gtk_label_new ("You have unsaved changes\nWould you like to save those before exiting the program?"); @@ -202,17 +202,25 @@ static void quit(GtkWidget *w, gpointer data) } GtkTreeViewColumn *tree_view_column(GtkWidget *tree_view, int index, const char *title, - data_func_t data_func, PangoAlignment align, gboolean visible) + data_func_t data_func, unsigned int flags) { GtkCellRenderer *renderer; GtkTreeViewColumn *col; double xalign = 0.0; /* left as default */ + PangoAlignment align; + gboolean visible; + + align = (flags & ALIGN_LEFT) ? PANGO_ALIGN_LEFT : + (flags & ALIGN_RIGHT) ? PANGO_ALIGN_RIGHT : + PANGO_ALIGN_CENTER; + visible = !(flags & INVISIBLE); renderer = gtk_cell_renderer_text_new(); col = gtk_tree_view_column_new(); gtk_tree_view_column_set_title(col, title); - gtk_tree_view_column_set_sort_column_id(col, index); + if (!(flags & UNSORTABLE)) + gtk_tree_view_column_set_sort_column_id(col, index); gtk_tree_view_column_set_resizable(col, TRUE); gtk_tree_view_column_pack_start(col, renderer, TRUE); if (data_func) @@ -288,6 +296,8 @@ UNITCALLBACK(set_liter, volume, LITER) UNITCALLBACK(set_cuft, volume, CUFT) UNITCALLBACK(set_celsius, temperature, CELSIUS) UNITCALLBACK(set_fahrenheit, temperature, FAHRENHEIT) +UNITCALLBACK(set_kg, weight, KG) +UNITCALLBACK(set_lbs, weight, LBS) #define OPTIONCALLBACK(name, option) \ static void name(GtkWidget *w, gpointer data) \ @@ -349,6 +359,11 @@ static void preferences_dialog(GtkWidget *w, gpointer data) "Fahrenheit", set_fahrenheit, (output_units.temperature == FAHRENHEIT), NULL); + create_radio(box, "Weight:", + "kg", set_kg, (output_units.weight == KG), + "lbs", set_lbs, (output_units.weight == LBS), + NULL); + frame = gtk_frame_new("Columns"); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), frame, FALSE, FALSE, 5); @@ -401,6 +416,7 @@ static void preferences_dialog(GtkWidget *w, gpointer data) 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("lbs", PREF_BOOL, BOOL_TO_PTR(output_units.weight == LBS)); 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)); @@ -668,6 +684,8 @@ void init_ui(int *argcp, char ***argvp) output_units.volume = CUFT; if (subsurface_get_conf("fahrenheit", PREF_BOOL)) output_units.temperature = FAHRENHEIT; + if (subsurface_get_conf("lbs", PREF_BOOL)) + output_units.weight = LBS; /* an unset key is FALSE - all these are hidden by default */ visible_cols.cylinder = PTR_TO_BOOL(subsurface_get_conf("CYLINDER", PREF_BOOL)); visible_cols.temperature = PTR_TO_BOOL(subsurface_get_conf("TEMPERATURE", PREF_BOOL)); @@ -850,7 +868,7 @@ int process_ui_events(void) break; } } - return(ret); + return ret; } @@ -905,7 +923,7 @@ static GtkEntry *dive_computer_device(GtkWidget *vbox) entry = gtk_entry_new(); gtk_container_add(GTK_CONTAINER(frame), entry); - gtk_entry_set_text(GTK_ENTRY(entry), "/dev/ttyUSB0"); + gtk_entry_set_text(GTK_ENTRY(entry), subsurface_USB_name()); return GTK_ENTRY(entry); }