From 7cf1960336011b8ef702c3bc2458b27db0fc1a4e Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 10 Dec 2012 10:46:46 -0800 Subject: Apply preference changes right away This allows you to open the preference dialog, play with settings and see their effect right away. Press OK and you keep them, press Cancel and you are back to the previous state. As it should be. Signed-off-by: Dirk Hohndel --- gtk-gui.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/gtk-gui.c b/gtk-gui.c index 799613214..842a28740 100644 --- a/gtk-gui.c +++ b/gtk-gui.c @@ -451,11 +451,19 @@ static void create_radio(GtkWidget *vbox, const char *w_name, ...) va_end(args); } +static void update_screen() +{ + update_dive_list_units(); + repaint_dive(); + update_dive_list_col_visibility(); +} + #define UNITCALLBACK(name, type, value) \ static void name(GtkWidget *w, gpointer data) \ { \ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))) \ prefs.output_units.type = value; \ + update_screen(); \ } UNITCALLBACK(set_meter, length, METERS) @@ -474,6 +482,7 @@ static void name(GtkWidget *w, gpointer data) \ { \ GtkWidget **entry = data; \ option = GTK_TOGGLE_BUTTON(w)->active; \ + update_screen(); \ if (entry) \ gtk_widget_set_sensitive(*entry, option);\ } @@ -765,9 +774,7 @@ static void preferences_dialog(GtkWidget *w, gpointer data) sscanf(pn2_threshold_text, "%lf", &prefs.pp_graphs.pn2_threshold); phe_threshold_text = gtk_entry_get_text(GTK_ENTRY(entry_phe)); sscanf(phe_threshold_text, "%lf", &prefs.pp_graphs.phe_threshold); - update_dive_list_units(); - repaint_dive(); - update_dive_list_col_visibility(); + update_screen(); subsurface_set_conf("feet", PREF_BOOL, BOOL_TO_PTR(prefs.output_units.length == FEET)); subsurface_set_conf("psi", PREF_BOOL, BOOL_TO_PTR(prefs.output_units.pressure == PSI)); -- cgit v1.2.3-70-g09d2