mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Save default units using GConf
That seems to be the gtk2 way. Whatever. diveclog ends up defaulting to metric units, because we all know that's the right thing to do. However, I learnt to dive in the US, so I'm used to seeing psi and feet. So despite the sane defaults, I want diveclog to use the broken imperial units for me. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
91439f3aff
commit
a13d3172fa
3 changed files with 25 additions and 3 deletions
5
Makefile
5
Makefile
|
@ -6,7 +6,7 @@ OBJS=main.o dive.o profile.o info.o divelist.o parse-xml.o save-xml.o
|
|||
divelog: $(OBJS)
|
||||
$(CC) $(LDFLAGS) -o divelog $(OBJS) \
|
||||
`xml2-config --libs` \
|
||||
`pkg-config --libs gtk+-2.0 glib-2.0`
|
||||
`pkg-config --libs gtk+-2.0 glib-2.0 gconf-2.0`
|
||||
|
||||
parse-xml.o: parse-xml.c dive.h
|
||||
$(CC) $(CFLAGS) `pkg-config --cflags glib-2.0` -c `xml2-config --cflags` parse-xml.c
|
||||
|
@ -18,7 +18,8 @@ dive.o: dive.c dive.h
|
|||
$(CC) $(CFLAGS) `pkg-config --cflags glib-2.0` -c dive.c
|
||||
|
||||
main.o: main.c dive.h display.h divelist.h
|
||||
$(CC) $(CFLAGS) `pkg-config --cflags gtk+-2.0 glib-2.0` -c main.c
|
||||
$(CC) $(CFLAGS) `pkg-config --cflags gtk+-2.0 glib-2.0 gconf-2.0` \
|
||||
-c main.c
|
||||
|
||||
profile.o: profile.c dive.h display.h divelist.h
|
||||
$(CC) $(CFLAGS) `pkg-config --cflags gtk+-2.0 glib-2.0` -c profile.c
|
||||
|
|
2
README
2
README
|
@ -4,7 +4,7 @@ I'm tired of java programs that don't work etc.
|
|||
|
||||
License: GPLv2
|
||||
|
||||
You need libxml2-devel and gtk2-devel to build this.
|
||||
You need libxml2-devel, gtk2-devel and GConf2-devel to build this.
|
||||
|
||||
Usage:
|
||||
|
||||
|
|
21
main.c
21
main.c
|
@ -3,6 +3,8 @@
|
|||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <gconf/gconf-client.h>
|
||||
|
||||
#include "dive.h"
|
||||
#include "divelist.h"
|
||||
#include "display.h"
|
||||
|
@ -14,8 +16,11 @@ GtkWidget *error_label;
|
|||
int error_count;
|
||||
struct DiveList dive_list;
|
||||
|
||||
GConfClient *gconf;
|
||||
struct units output_units;
|
||||
|
||||
#define GCONF_NAME(x) "/apps/diveclog/" #x
|
||||
|
||||
static int sortfn(const void *_a, const void *_b)
|
||||
{
|
||||
const struct dive *a = *(void **)_a;
|
||||
|
@ -297,6 +302,10 @@ static void unit_dialog(GtkWidget *w, gpointer data)
|
|||
output_units = menu_units;
|
||||
update_dive_list_units(&dive_list);
|
||||
repaint_dive();
|
||||
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);
|
||||
}
|
||||
gtk_widget_destroy(dialog);
|
||||
}
|
||||
|
@ -358,6 +367,18 @@ int main(int argc, char **argv)
|
|||
|
||||
gtk_init(&argc, &argv);
|
||||
|
||||
g_type_init();
|
||||
gconf = gconf_client_get_default();
|
||||
|
||||
if (gconf_client_get_bool(gconf, GCONF_NAME(feet), NULL))
|
||||
output_units.length = FEET;
|
||||
if (gconf_client_get_bool(gconf, GCONF_NAME(psi), NULL))
|
||||
output_units.pressure = PSI;
|
||||
if (gconf_client_get_bool(gconf, GCONF_NAME(cuft), NULL))
|
||||
output_units.volume = CUFT;
|
||||
if (gconf_client_get_bool(gconf, GCONF_NAME(fahrenheit), NULL))
|
||||
output_units.temperature = FAHRENHEIT;
|
||||
|
||||
error_info_bar = NULL;
|
||||
win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(on_destroy), NULL);
|
||||
|
|
Loading…
Add table
Reference in a new issue