summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-09-27 11:05:39 -0700
committerGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-09-27 11:05:39 -0700
commit30ee87be92f0a0fffc98106852d9623a65dfe4ed (patch)
tree8a2f2f8ee4ce9c6db1167269bad04ff369a38a5d
parent1bf28b68c9dc9b929b1372b79920311a9c10e4cc (diff)
parentf3134cbb8995267e6a18b9564f3022e7fe7314a9 (diff)
downloadsubsurface-30ee87be92f0a0fffc98106852d9623a65dfe4ed.tar.gz
Merge branch 'otu-tracking-v2' of git://github.com/dirkhh/subsurface
* 'otu-tracking-v2' of git://github.com/dirkhh/subsurface: Store options in gconf Add preference option to chose if SAC and/or OTU should be in divelist Fix up trivial conflicts in gtk-gui.c (cleanup in gtk dialog wrt gtk_dialog_get_content_area() having introduced a new 'vbox' widget)
-rw-r--r--display-gtk.h7
-rw-r--r--divelist.c13
-rw-r--r--divelist.h1
-rw-r--r--gtk-gui.c38
-rw-r--r--main.c1
5 files changed, 55 insertions, 5 deletions
diff --git a/display-gtk.h b/display-gtk.h
index dee66368a..ad437465c 100644
--- a/display-gtk.h
+++ b/display-gtk.h
@@ -11,6 +11,13 @@ typedef struct {
GtkWidget *bar;
} progressbar_t;
+typedef struct {
+ gboolean sac;
+ gboolean otu;
+} visible_cols_t;
+
+extern visible_cols_t visible_cols;
+
extern const char *divelist_font;
extern void set_divelist_font(const char *);
diff --git a/divelist.c b/divelist.c
index bb2a3e3a1..b43adfd0c 100644
--- a/divelist.c
+++ b/divelist.c
@@ -26,7 +26,7 @@ struct DiveList {
GtkWidget *container_widget;
GtkListStore *model;
GtkTreeViewColumn *date, *depth, *duration, *location;
- GtkTreeViewColumn *temperature, *cylinder, *nitrox, *sac;
+ GtkTreeViewColumn *temperature, *cylinder, *nitrox, *sac, *otu;
int changed;
};
@@ -422,6 +422,13 @@ void update_dive_list_units(void)
gtk_tree_model_foreach(model, set_one_dive, NULL);
}
+void update_dive_list_col_visibility(void)
+{
+ 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;
+}
+
static void fill_dive_list(void)
{
int i;
@@ -543,8 +550,8 @@ GtkWidget *dive_list_create(void)
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.sac = divelist_column(&dive_list, DIVE_SAC, "SAC", sac_data_func, PANGO_ALIGN_CENTER, TRUE);
- dive_list.sac = divelist_column(&dive_list, DIVE_OTU, "OTU", otu_data_func, PANGO_ALIGN_CENTER, FALSE);
+ 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);
fill_dive_list();
diff --git a/divelist.h b/divelist.h
index 3151a69db..2635b7541 100644
--- a/divelist.h
+++ b/divelist.h
@@ -4,6 +4,7 @@
struct dive;
extern void dive_list_update_dives(void);
+extern void update_dive_list_col_visibility(void);
extern void update_dive_list_units(void);
extern void flush_divelist(struct dive *);
diff --git a/gtk-gui.c b/gtk-gui.c
index 0c235b492..4b6795621 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -33,6 +33,8 @@ struct units output_units;
static GtkWidget *dive_profile;
+visible_cols_t visible_cols = {TRUE, FALSE};
+
void repaint_dive(void)
{
update_dive(current_dive);
@@ -253,10 +255,19 @@ UNITCALLBACK(set_cuft, volume, CUFT)
UNITCALLBACK(set_celsius, temperature, CELSIUS)
UNITCALLBACK(set_fahrenheit, temperature, FAHRENHEIT)
+#define OPTIONCALLBACK(name, option) \
+static void name(GtkWidget *w, gpointer data) \
+{ \
+ option = GTK_TOGGLE_BUTTON(w)->active; \
+}
+
+OPTIONCALLBACK(otu_toggle, visible_cols.otu)
+OPTIONCALLBACK(sac_toggle, visible_cols.sac)
+
static void preferences_dialog(GtkWidget *w, gpointer data)
{
int result;
- GtkWidget *dialog, *font, *frame, *box, *vbox;
+ GtkWidget *dialog, *font, *frame, *box, *vbox, *button;
menu_units = output_units;
@@ -294,6 +305,22 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
"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 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);
@@ -309,10 +336,13 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
output_units = menu_units;
update_dive_list_units();
repaint_dive();
+ update_dive_list_col_visibility();
gconf_client_set_bool(gconf, GCONF_NAME(feet), output_units.length == FEET, NULL);
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(OTU), visible_cols.otu, NULL);
gconf_client_set_string(gconf, GCONF_NAME(divelist_font), divelist_font, NULL);
}
gtk_widget_destroy(dialog);
@@ -485,7 +515,11 @@ 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 */
+ visible_cols.otu = gconf_client_get_bool(gconf, GCONF_NAME(OTU), NULL);
+ visible_cols.sac = ! gconf_client_get_bool(gconf, GCONF_NAME(SAC), NULL);
+
divelist_font = gconf_client_get_string(gconf, GCONF_NAME(divelist_font), NULL);
if (!divelist_font)
divelist_font = DIVELIST_DEFAULT_FONT;
diff --git a/main.c b/main.c
index ef6212ae2..92eb9ee09 100644
--- a/main.c
+++ b/main.c
@@ -126,6 +126,7 @@ int main(int argc, char **argv)
int i;
output_units = SI_units;
+
parse_xml_init();
init_ui(argc, argv);