summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2011-10-23 13:36:37 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2011-10-23 13:36:37 -0700
commitbf13c14d16fdb1aa0230f688ff88635f395c6887 (patch)
tree25c32aa31bbd79f5b0b7d84057a3ae7b89a63ec5
parentb091916249c940666b249d253f082ef5dad75411 (diff)
downloadsubsurface-bf13c14d16fdb1aa0230f688ff88635f395c6887.tar.gz
Make columns for temperature, cylinder, and nitrox optional
Just like SAC and OTU these can now be turned on and off through the preferences. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--display-gtk.h3
-rw-r--r--divelist.c9
-rw-r--r--gtk-gui.c29
3 files changed, 35 insertions, 6 deletions
diff --git a/display-gtk.h b/display-gtk.h
index fe373a14f..fb2b9af5b 100644
--- a/display-gtk.h
+++ b/display-gtk.h
@@ -12,6 +12,9 @@ typedef struct {
} progressbar_t;
typedef struct {
+ gboolean cylinder;
+ gboolean temperature;
+ gboolean nitrox;
gboolean sac;
gboolean otu;
} visible_cols_t;
diff --git a/divelist.c b/divelist.c
index 4146deca7..948332f4e 100644
--- a/divelist.c
+++ b/divelist.c
@@ -451,6 +451,9 @@ void update_dive_list_units(void)
void update_dive_list_col_visibility(void)
{
+ gtk_tree_view_column_set_visible(dive_list.cylinder, visible_cols.cylinder);
+ gtk_tree_view_column_set_visible(dive_list.temperature, visible_cols.temperature);
+ gtk_tree_view_column_set_visible(dive_list.nitrox, visible_cols.nitrox);
gtk_tree_view_column_set_visible(dive_list.sac, visible_cols.sac);
gtk_tree_view_column_set_visible(dive_list.otu, visible_cols.otu);
return;
@@ -541,9 +544,9 @@ GtkWidget *dive_list_create(void)
dive_list.date = divelist_column(&dive_list, DIVE_DATE, "Date", date_data_func, PANGO_ALIGN_LEFT, TRUE);
dive_list.depth = divelist_column(&dive_list, DIVE_DEPTH, "ft", depth_data_func, PANGO_ALIGN_RIGHT, TRUE);
dive_list.duration = divelist_column(&dive_list, DIVE_DURATION, "min", duration_data_func, PANGO_ALIGN_RIGHT, TRUE);
- dive_list.temperature = divelist_column(&dive_list, DIVE_TEMPERATURE, UTF8_DEGREE "F", temperature_data_func, PANGO_ALIGN_RIGHT, TRUE);
- dive_list.cylinder = divelist_column(&dive_list, DIVE_CYLINDER, "Cyl", NULL, PANGO_ALIGN_CENTER, TRUE);
- dive_list.nitrox = divelist_column(&dive_list, DIVE_NITROX, "O" UTF8_SUBSCRIPT_2 "%", nitrox_data_func, PANGO_ALIGN_CENTER, TRUE);
+ dive_list.temperature = divelist_column(&dive_list, DIVE_TEMPERATURE, UTF8_DEGREE "F", temperature_data_func, PANGO_ALIGN_RIGHT, visible_cols.temperature);
+ dive_list.cylinder = divelist_column(&dive_list, DIVE_CYLINDER, "Cyl", NULL, PANGO_ALIGN_CENTER, visible_cols.cylinder);
+ dive_list.nitrox = divelist_column(&dive_list, DIVE_NITROX, "O" UTF8_SUBSCRIPT_2 "%", nitrox_data_func, PANGO_ALIGN_CENTER, visible_cols.nitrox);
dive_list.sac = divelist_column(&dive_list, DIVE_SAC, "SAC", sac_data_func, PANGO_ALIGN_CENTER, visible_cols.sac);
dive_list.otu = divelist_column(&dive_list, DIVE_OTU, "OTU", otu_data_func, PANGO_ALIGN_CENTER, visible_cols.otu);
dive_list.location = divelist_column(&dive_list, DIVE_LOCATION, "Location", NULL, PANGO_ALIGN_LEFT, TRUE);
diff --git a/gtk-gui.c b/gtk-gui.c
index 39703ff60..9eb23ab18 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -301,6 +301,9 @@ static void name(GtkWidget *w, gpointer data) \
OPTIONCALLBACK(otu_toggle, visible_cols.otu)
OPTIONCALLBACK(sac_toggle, visible_cols.sac)
+OPTIONCALLBACK(nitrox_toggle, visible_cols.nitrox)
+OPTIONCALLBACK(temperature_toggle, visible_cols.temperature)
+OPTIONCALLBACK(cylinder_toggle, visible_cols.cylinder)
static void preferences_dialog(GtkWidget *w, gpointer data)
{
@@ -349,6 +352,21 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
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);
@@ -379,7 +397,10 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
gconf_client_set_bool(gconf, GCONF_NAME(psi), output_units.pressure == PSI, NULL);
gconf_client_set_bool(gconf, GCONF_NAME(cuft), output_units.volume == CUFT, NULL);
gconf_client_set_bool(gconf, GCONF_NAME(fahrenheit), output_units.temperature == FAHRENHEIT, NULL);
- gconf_client_set_bool(gconf, GCONF_NAME(SAC), ! visible_cols.sac, NULL); /* inverted to get the correct default */
+ gconf_client_set_bool(gconf, GCONF_NAME(TEMPERATURE), visible_cols.temperature, NULL);
+ gconf_client_set_bool(gconf, GCONF_NAME(CYLINDER), visible_cols.cylinder, NULL);
+ gconf_client_set_bool(gconf, GCONF_NAME(NITROX), visible_cols.nitrox, NULL);
+ gconf_client_set_bool(gconf, GCONF_NAME(SAC), visible_cols.sac, NULL);
gconf_client_set_bool(gconf, GCONF_NAME(OTU), visible_cols.otu, NULL);
gconf_client_set_string(gconf, GCONF_NAME(divelist_font), divelist_font, NULL);
}
@@ -625,8 +646,10 @@ void init_ui(int argc, char **argv)
output_units.volume = CUFT;
if (gconf_client_get_bool(gconf, GCONF_NAME(fahrenheit), NULL))
output_units.temperature = FAHRENHEIT;
- /* an unset key is FALSE - so in order to get the default behavior right we
- invert the meaning of the SAC key */
+ /* an unset key is FALSE - all these are hidden by default */
+ visible_cols.cylinder = gconf_client_get_bool(gconf, GCONF_NAME(CYLINDER), NULL);
+ visible_cols.temperature = gconf_client_get_bool(gconf, GCONF_NAME(TEMPERATURE), NULL);
+ visible_cols.nitrox = ! gconf_client_get_bool(gconf, GCONF_NAME(NITROX), NULL);
visible_cols.otu = gconf_client_get_bool(gconf, GCONF_NAME(OTU), NULL);
visible_cols.sac = ! gconf_client_get_bool(gconf, GCONF_NAME(SAC), NULL);