mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Split up preference data structure definition into 'pref.h'
.. and rename the badly named 'output_units/input_units' variables. We used to have this confusing thing where we had two different units (input vs output) that *look* like they are mirror images, but in fact "output_units" was the user units, and "input_units" are the XML parsing units. So this renames them to be clearer. "output_units" is now just "units" (it's the units a user would ever see), and "input_units" is now "xml_parsing_units" and set by the XML file parsers to reflect the units of the parsed file. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
4c13f1f6b4
commit
868a2cc090
15 changed files with 143 additions and 115 deletions
|
@ -15,49 +15,6 @@ typedef struct {
|
|||
GtkWidget *bar;
|
||||
} progressbar_t;
|
||||
|
||||
typedef struct {
|
||||
gboolean cylinder;
|
||||
gboolean temperature;
|
||||
gboolean totalweight;
|
||||
gboolean suit;
|
||||
gboolean nitrox;
|
||||
gboolean sac;
|
||||
gboolean otu;
|
||||
gboolean maxcns;
|
||||
} visible_cols_t;
|
||||
|
||||
typedef struct {
|
||||
gboolean po2;
|
||||
gboolean pn2;
|
||||
gboolean phe;
|
||||
double po2_threshold;
|
||||
double pn2_threshold;
|
||||
double phe_threshold;
|
||||
} partial_pressure_graphs_t;
|
||||
|
||||
struct preferences {
|
||||
struct units output_units;
|
||||
visible_cols_t visible_cols;
|
||||
partial_pressure_graphs_t pp_graphs;
|
||||
gboolean profile_red_ceiling;
|
||||
gboolean profile_calc_ceiling;
|
||||
gboolean calc_ceiling_3m_incr;
|
||||
double gflow;
|
||||
double gfhigh;
|
||||
};
|
||||
|
||||
extern struct preferences prefs;
|
||||
|
||||
#define PP_GRAPHS_ENABLED (prefs.pp_graphs.po2 || prefs.pp_graphs.pn2 || prefs.pp_graphs.phe)
|
||||
|
||||
typedef enum {
|
||||
PREF_BOOL,
|
||||
PREF_STRING
|
||||
} pref_type_t;
|
||||
|
||||
#define BOOL_TO_PTR(_cond) ((_cond) ? (void *)1 : NULL)
|
||||
#define PTR_TO_BOOL(_ptr) ((_ptr) != NULL)
|
||||
|
||||
#if defined __APPLE__
|
||||
#define CTRLCHAR "<Meta>"
|
||||
#define SHIFTCHAR "<Shift>"
|
||||
|
@ -68,12 +25,6 @@ typedef enum {
|
|||
#define PREFERENCE_ACCEL NULL
|
||||
#endif
|
||||
|
||||
extern void subsurface_open_conf(void);
|
||||
extern void subsurface_set_conf(char *name, pref_type_t type, const void *value);
|
||||
extern const void *subsurface_get_conf(char *name, pref_type_t type);
|
||||
extern void subsurface_flush_conf(void);
|
||||
extern void subsurface_close_conf(void);
|
||||
|
||||
extern int subsurface_fill_device_list(GtkListStore *store);
|
||||
extern const char *subsurface_icon_name(void);
|
||||
extern void subsurface_ui_setup(GtkSettings *settings, GtkWidget *menubar,
|
||||
|
|
22
dive.c
22
dive.c
|
@ -34,9 +34,9 @@ int get_pressure_units(unsigned int mb, const char **units)
|
|||
{
|
||||
int pressure;
|
||||
const char* unit;
|
||||
struct units *output_units_p = get_output_units();
|
||||
struct units *units_p = get_units();
|
||||
|
||||
switch (output_units_p->pressure) {
|
||||
switch (units_p->pressure) {
|
||||
case PASCAL:
|
||||
pressure = mb * 100;
|
||||
unit = _("pascal");
|
||||
|
@ -59,9 +59,9 @@ double get_temp_units(unsigned int mk, const char **units)
|
|||
{
|
||||
double deg;
|
||||
const char *unit;
|
||||
struct units *output_units_p = get_output_units();
|
||||
struct units *units_p = get_units();
|
||||
|
||||
if (output_units_p->temperature == FAHRENHEIT) {
|
||||
if (units_p->temperature == FAHRENHEIT) {
|
||||
deg = mkelvin_to_F(mk);
|
||||
unit = UTF8_DEGREE "F";
|
||||
} else {
|
||||
|
@ -78,9 +78,9 @@ double get_volume_units(unsigned int ml, int *frac, const char **units)
|
|||
int decimals;
|
||||
double vol;
|
||||
const char *unit;
|
||||
struct units *output_units_p = get_output_units();
|
||||
struct units *units_p = get_units();
|
||||
|
||||
switch (output_units_p->volume) {
|
||||
switch (units_p->volume) {
|
||||
case LITER:
|
||||
vol = ml / 1000.0;
|
||||
unit = _("l");
|
||||
|
@ -104,9 +104,9 @@ double get_depth_units(unsigned int mm, int *frac, const char **units)
|
|||
int decimals;
|
||||
double d;
|
||||
const char *unit;
|
||||
struct units *output_units_p = get_output_units();
|
||||
struct units *units_p = get_units();
|
||||
|
||||
switch (output_units_p->length) {
|
||||
switch (units_p->length) {
|
||||
case METERS:
|
||||
d = mm / 1000.0;
|
||||
unit = _("m");
|
||||
|
@ -130,9 +130,9 @@ double get_weight_units(unsigned int grams, int *frac, const char **units)
|
|||
int decimals;
|
||||
double value;
|
||||
const char* unit;
|
||||
struct units *output_units_p = get_output_units();
|
||||
struct units *units_p = get_units();
|
||||
|
||||
if (output_units_p->weight == LBS) {
|
||||
if (units_p->weight == LBS) {
|
||||
value = grams_to_lbs(grams);
|
||||
unit = _("lbs");
|
||||
decimals = 0;
|
||||
|
@ -352,7 +352,7 @@ static void sanitize_cylinder_type(cylinder_type_t *type)
|
|||
if (!type->size.mliter)
|
||||
return;
|
||||
|
||||
if (input_units.volume == CUFT) {
|
||||
if (xml_parsing_units.volume == CUFT) {
|
||||
/* confusing - we don't really start from ml but millicuft !*/
|
||||
volume_of_air = cuft_to_l(type->size.mliter);
|
||||
atm = to_ATM(type->workingpressure); /* working pressure in atm */
|
||||
|
|
7
dive.h
7
dive.h
|
@ -426,9 +426,9 @@ struct units {
|
|||
.weight = LBS \
|
||||
}
|
||||
extern const struct units SI_units, IMPERIAL_units;
|
||||
extern struct units input_units;
|
||||
extern struct units xml_parsing_units;
|
||||
|
||||
extern struct units *get_output_units(void);
|
||||
extern struct units *get_units(void);
|
||||
extern int verbose;
|
||||
|
||||
struct dive_table {
|
||||
|
@ -613,4 +613,7 @@ void free_dps(struct divedatapoint *dp);
|
|||
extern char *debugfilename;
|
||||
extern FILE *debugfile;
|
||||
#endif
|
||||
|
||||
#include "pref.h"
|
||||
|
||||
#endif /* DIVE_H */
|
||||
|
|
|
@ -405,7 +405,7 @@ static void depth_data_func(GtkTreeViewColumn *col,
|
|||
if (idx < 0) {
|
||||
*buffer = '\0';
|
||||
} else {
|
||||
switch (prefs.output_units.length) {
|
||||
switch (prefs.units.length) {
|
||||
case METERS:
|
||||
/* To tenths of meters */
|
||||
depth = (depth + 49) / 100;
|
||||
|
@ -464,7 +464,7 @@ static void temperature_data_func(GtkTreeViewColumn *col,
|
|||
*buffer = 0;
|
||||
if (idx >= 0 && value) {
|
||||
double deg;
|
||||
switch (prefs.output_units.temperature) {
|
||||
switch (prefs.units.temperature) {
|
||||
case CELSIUS:
|
||||
deg = mkelvin_to_C(value);
|
||||
break;
|
||||
|
@ -661,7 +661,7 @@ static void sac_data_func(GtkTreeViewColumn *col,
|
|||
}
|
||||
|
||||
sac = value / 1000.0;
|
||||
switch (prefs.output_units.volume) {
|
||||
switch (prefs.units.volume) {
|
||||
case LITER:
|
||||
fmt = "%4.1f";
|
||||
break;
|
||||
|
|
16
equipment.c
16
equipment.c
|
@ -75,7 +75,7 @@ static int convert_pressure(int mbar, double *p)
|
|||
int decimals = 1;
|
||||
double pressure;
|
||||
|
||||
if (prefs.output_units.pressure == PSI) {
|
||||
if (prefs.units.pressure == PSI) {
|
||||
pressure = mbar_to_PSI(mbar);
|
||||
decimals = 0;
|
||||
} else {
|
||||
|
@ -92,12 +92,12 @@ static void convert_volume_pressure(int ml, int mbar, double *v, double *p)
|
|||
|
||||
volume = ml / 1000.0;
|
||||
if (mbar) {
|
||||
if (prefs.output_units.volume == CUFT) {
|
||||
if (prefs.units.volume == CUFT) {
|
||||
volume = ml_to_cuft(ml);
|
||||
volume *= bar_to_atm(mbar / 1000.0);
|
||||
}
|
||||
|
||||
if (prefs.output_units.pressure == PSI)
|
||||
if (prefs.units.pressure == PSI)
|
||||
pressure = mbar_to_PSI(mbar);
|
||||
else
|
||||
pressure = mbar / 1000.0;
|
||||
|
@ -111,7 +111,7 @@ static int convert_weight(int grams, double *m)
|
|||
int decimals = 1; /* not sure - do people do less than whole lbs/kg ? */
|
||||
double weight;
|
||||
|
||||
if (prefs.output_units.weight == LBS)
|
||||
if (prefs.units.weight == LBS)
|
||||
weight = grams_to_lbs(grams);
|
||||
else
|
||||
weight = grams / 1000.0;
|
||||
|
@ -631,14 +631,14 @@ static void fill_cylinder_info(struct cylinder_widget *cylinder, cylinder_t *cyl
|
|||
{
|
||||
int mbar, ml;
|
||||
|
||||
if (prefs.output_units.pressure == PSI) {
|
||||
if (prefs.units.pressure == PSI) {
|
||||
pressure = psi_to_bar(pressure);
|
||||
start = psi_to_bar(start);
|
||||
end = psi_to_bar(end);
|
||||
}
|
||||
|
||||
mbar = pressure * 1000 + 0.5;
|
||||
if (mbar && prefs.output_units.volume == CUFT) {
|
||||
if (mbar && prefs.units.volume == CUFT) {
|
||||
volume = cuft_to_l(volume);
|
||||
volume /= bar_to_atm(pressure);
|
||||
}
|
||||
|
@ -714,7 +714,7 @@ static void record_weightsystem_changes(weightsystem_t *ws, struct ws_widget *we
|
|||
desc = gtk_combo_box_get_active_text(box);
|
||||
value = gtk_spin_button_get_value(weightsystem_widget->weight);
|
||||
|
||||
if (prefs.output_units.weight == LBS)
|
||||
if (prefs.units.weight == LBS)
|
||||
grams = lbs_to_grams(value);
|
||||
else
|
||||
grams = value * 1000;
|
||||
|
@ -1041,7 +1041,7 @@ static void ws_widget(GtkWidget *vbox, struct ws_widget *ws_widget, GtkListStore
|
|||
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), frame, FALSE, TRUE, 0);
|
||||
|
||||
if ( prefs.output_units.weight == KG)
|
||||
if ( prefs.units.weight == KG)
|
||||
widget = create_spinbutton(hbox, _("kg"), 0, 50, 0.5);
|
||||
else
|
||||
widget = create_spinbutton(hbox, _("lbs"), 0, 110, 1);
|
||||
|
|
46
gtk-gui.c
46
gtk-gui.c
|
@ -53,9 +53,9 @@ static gboolean prefer_downloaded;
|
|||
|
||||
GtkActionGroup *action_group;
|
||||
|
||||
struct units *get_output_units()
|
||||
struct units *get_units()
|
||||
{
|
||||
return &prefs.output_units;
|
||||
return &prefs.units;
|
||||
}
|
||||
|
||||
static int is_default_dive_computer(const char *vendor, const char *product)
|
||||
|
@ -475,7 +475,7 @@ static void update_screen()
|
|||
static void name(GtkWidget *w, gpointer data) \
|
||||
{ \
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))) \
|
||||
prefs.output_units.type = value; \
|
||||
prefs.units.type = value; \
|
||||
update_screen(); \
|
||||
}
|
||||
|
||||
|
@ -631,28 +631,28 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
|
|||
gtk_container_add(GTK_CONTAINER(frame), box);
|
||||
|
||||
create_radio(box, _("Depth:"),
|
||||
_("Meter"), set_meter, (prefs.output_units.length == METERS),
|
||||
_("Feet"), set_feet, (prefs.output_units.length == FEET),
|
||||
_("Meter"), set_meter, (prefs.units.length == METERS),
|
||||
_("Feet"), set_feet, (prefs.units.length == FEET),
|
||||
NULL);
|
||||
|
||||
create_radio(box, _("Pressure:"),
|
||||
_("Bar"), set_bar, (prefs.output_units.pressure == BAR),
|
||||
_("PSI"), set_psi, (prefs.output_units.pressure == PSI),
|
||||
_("Bar"), set_bar, (prefs.units.pressure == BAR),
|
||||
_("PSI"), set_psi, (prefs.units.pressure == PSI),
|
||||
NULL);
|
||||
|
||||
create_radio(box, _("Volume:"),
|
||||
_("Liter"), set_liter, (prefs.output_units.volume == LITER),
|
||||
_("CuFt"), set_cuft, (prefs.output_units.volume == CUFT),
|
||||
_("Liter"), set_liter, (prefs.units.volume == LITER),
|
||||
_("CuFt"), set_cuft, (prefs.units.volume == CUFT),
|
||||
NULL);
|
||||
|
||||
create_radio(box, _("Temperature:"),
|
||||
_("Celsius"), set_celsius, (prefs.output_units.temperature == CELSIUS),
|
||||
_("Fahrenheit"), set_fahrenheit, (prefs.output_units.temperature == FAHRENHEIT),
|
||||
_("Celsius"), set_celsius, (prefs.units.temperature == CELSIUS),
|
||||
_("Fahrenheit"), set_fahrenheit, (prefs.units.temperature == FAHRENHEIT),
|
||||
NULL);
|
||||
|
||||
create_radio(box, _("Weight:"),
|
||||
_("kg"), set_kg, (prefs.output_units.weight == KG),
|
||||
_("lbs"), set_lbs, (prefs.output_units.weight == LBS),
|
||||
_("kg"), set_kg, (prefs.units.weight == KG),
|
||||
_("lbs"), set_lbs, (prefs.units.weight == LBS),
|
||||
NULL);
|
||||
|
||||
frame = gtk_frame_new(_("Show Columns"));
|
||||
|
@ -865,11 +865,11 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
|
|||
|
||||
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));
|
||||
subsurface_set_conf("cuft", PREF_BOOL, BOOL_TO_PTR(prefs.output_units.volume == CUFT));
|
||||
subsurface_set_conf("fahrenheit", PREF_BOOL, BOOL_TO_PTR(prefs.output_units.temperature == FAHRENHEIT));
|
||||
subsurface_set_conf("lbs", PREF_BOOL, BOOL_TO_PTR(prefs.output_units.weight == LBS));
|
||||
subsurface_set_conf("feet", PREF_BOOL, BOOL_TO_PTR(prefs.units.length == FEET));
|
||||
subsurface_set_conf("psi", PREF_BOOL, BOOL_TO_PTR(prefs.units.pressure == PSI));
|
||||
subsurface_set_conf("cuft", PREF_BOOL, BOOL_TO_PTR(prefs.units.volume == CUFT));
|
||||
subsurface_set_conf("fahrenheit", PREF_BOOL, BOOL_TO_PTR(prefs.units.temperature == FAHRENHEIT));
|
||||
subsurface_set_conf("lbs", PREF_BOOL, BOOL_TO_PTR(prefs.units.weight == LBS));
|
||||
|
||||
subsurface_set_conf("TEMPERATURE", PREF_BOOL, BOOL_TO_PTR(prefs.visible_cols.temperature));
|
||||
subsurface_set_conf("TOTALWEIGHT", PREF_BOOL, BOOL_TO_PTR(prefs.visible_cols.totalweight));
|
||||
|
@ -1282,15 +1282,15 @@ void init_ui(int *argcp, char ***argvp)
|
|||
|
||||
subsurface_open_conf();
|
||||
if (subsurface_get_conf("feet", PREF_BOOL))
|
||||
prefs.output_units.length = FEET;
|
||||
prefs.units.length = FEET;
|
||||
if (subsurface_get_conf("psi", PREF_BOOL))
|
||||
prefs.output_units.pressure = PSI;
|
||||
prefs.units.pressure = PSI;
|
||||
if (subsurface_get_conf("cuft", PREF_BOOL))
|
||||
prefs.output_units.volume = CUFT;
|
||||
prefs.units.volume = CUFT;
|
||||
if (subsurface_get_conf("fahrenheit", PREF_BOOL))
|
||||
prefs.output_units.temperature = FAHRENHEIT;
|
||||
prefs.units.temperature = FAHRENHEIT;
|
||||
if (subsurface_get_conf("lbs", PREF_BOOL))
|
||||
prefs.output_units.weight = LBS;
|
||||
prefs.units.weight = LBS;
|
||||
/* an unset key is FALSE - all these are hidden by default */
|
||||
prefs.visible_cols.cylinder = PTR_TO_BOOL(subsurface_get_conf("CYLINDER", PREF_BOOL));
|
||||
prefs.visible_cols.temperature = PTR_TO_BOOL(subsurface_get_conf("TEMPERATURE", PREF_BOOL));
|
||||
|
|
8
info.c
8
info.c
|
@ -450,7 +450,7 @@ static void save_dive_info_changes(struct dive *dive, struct dive *master, struc
|
|||
new_text = (char *)gtk_entry_get_text(info->airtemp);
|
||||
if(sscanf(new_text, "%lf", &newtemp) == 1) {
|
||||
unsigned long mkelvin;
|
||||
switch (prefs.output_units.temperature) {
|
||||
switch (prefs.units.temperature) {
|
||||
case CELSIUS:
|
||||
mkelvin = C_to_mkelvin(newtemp);
|
||||
break;
|
||||
|
@ -895,8 +895,8 @@ static timestamp_t dive_time_widget(struct dive *dive)
|
|||
gtk_box_pack_end(GTK_BOX(box), duration, FALSE, FALSE, 0);
|
||||
|
||||
/* Depth box */
|
||||
box = frame_box(hbox, _("Depth (%s):"), prefs.output_units.length == FEET ? _("ft") : _("m"));
|
||||
if (prefs.output_units.length == FEET) {
|
||||
box = frame_box(hbox, _("Depth (%s):"), prefs.units.length == FEET ? _("ft") : _("m"));
|
||||
if (prefs.units.length == FEET) {
|
||||
depthinterval = 1.0;
|
||||
} else {
|
||||
depthinterval = 0.1;
|
||||
|
@ -922,7 +922,7 @@ static timestamp_t dive_time_widget(struct dive *dive)
|
|||
tm.tm_min = gtk_spin_button_get_value(GTK_SPIN_BUTTON(m));
|
||||
|
||||
val = gtk_spin_button_get_value(GTK_SPIN_BUTTON(depth));
|
||||
if (prefs.output_units.length == FEET) {
|
||||
if (prefs.units.length == FEET) {
|
||||
dive->maxdepth.mm = feet_to_mm(val);
|
||||
} else {
|
||||
dive->maxdepth.mm = val * 1000 + 0.5;
|
||||
|
|
5
linux.c
5
linux.c
|
@ -23,6 +23,11 @@ void subsurface_open_conf(void)
|
|||
gconf = gconf_client_get_default();
|
||||
}
|
||||
|
||||
void subsurface_unset_conf(char *name)
|
||||
{
|
||||
gconf_client_unset(gconf, gconf_name(name), NULL);
|
||||
}
|
||||
|
||||
void subsurface_set_conf(char *name, pref_type_t type, const void *value)
|
||||
{
|
||||
switch (type) {
|
||||
|
|
5
macos.c
5
macos.c
|
@ -26,6 +26,11 @@ void subsurface_open_conf(void)
|
|||
/* nothing at this time */
|
||||
}
|
||||
|
||||
void subsurface_unset_conf(char *name)
|
||||
{
|
||||
CFPreferencesSetAppValue(CFSTR_VAR(name), NULL, SUBSURFACE_PREFERENCES);
|
||||
}
|
||||
|
||||
void subsurface_set_conf(char *name, pref_type_t type, const void *value)
|
||||
{
|
||||
switch (type) {
|
||||
|
|
4
main.c
4
main.c
|
@ -15,7 +15,7 @@ char *debugfilename;
|
|||
FILE *debugfile;
|
||||
#endif
|
||||
|
||||
struct units output_units;
|
||||
struct units units;
|
||||
|
||||
/* random helper functions, used here or elsewhere */
|
||||
static int sortfn(const void *_a, const void *_b)
|
||||
|
@ -253,7 +253,7 @@ int main(int argc, char **argv)
|
|||
bindtextdomain("subsurface", path);
|
||||
bind_textdomain_codeset("subsurface", "utf-8");
|
||||
textdomain("subsurface");
|
||||
output_units = SI_units;
|
||||
units = SI_units;
|
||||
|
||||
#if DEBUGFILE > 1
|
||||
debugfile = stderr;
|
||||
|
|
20
parse-xml.c
20
parse-xml.c
|
@ -128,7 +128,7 @@ static int match(const char *pattern, int plen,
|
|||
}
|
||||
|
||||
|
||||
struct units input_units;
|
||||
struct units xml_parsing_units;
|
||||
const struct units SI_units = SI_UNITS;
|
||||
const struct units IMPERIAL_units = IMPERIAL_UNITS;
|
||||
|
||||
|
@ -267,7 +267,7 @@ static void pressure(char *buffer, void *_press)
|
|||
/* Just ignore zero values */
|
||||
if (!val.fp)
|
||||
break;
|
||||
switch (input_units.pressure) {
|
||||
switch (xml_parsing_units.pressure) {
|
||||
case PASCAL:
|
||||
mbar = val.fp / 100;
|
||||
break;
|
||||
|
@ -311,7 +311,7 @@ static void depth(char *buffer, void *_depth)
|
|||
|
||||
switch (integer_or_float(buffer, &val)) {
|
||||
case FLOAT:
|
||||
switch (input_units.length) {
|
||||
switch (xml_parsing_units.length) {
|
||||
case METERS:
|
||||
depth->mm = val.fp * 1000 + 0.5;
|
||||
break;
|
||||
|
@ -332,7 +332,7 @@ static void weight(char *buffer, void *_weight)
|
|||
|
||||
switch (integer_or_float(buffer, &val)) {
|
||||
case FLOAT:
|
||||
switch (input_units.weight) {
|
||||
switch (xml_parsing_units.weight) {
|
||||
case KG:
|
||||
weight->grams = val.fp * 1000 + 0.5;
|
||||
break;
|
||||
|
@ -357,7 +357,7 @@ static void temperature(char *buffer, void *_temperature)
|
|||
if (!val.fp)
|
||||
break;
|
||||
/* Celsius */
|
||||
switch (input_units.temperature) {
|
||||
switch (xml_parsing_units.temperature) {
|
||||
case KELVIN:
|
||||
temperature->mkelvin = val.fp * 1000;
|
||||
break;
|
||||
|
@ -1364,15 +1364,15 @@ static void DivingLog_importer(void)
|
|||
*
|
||||
* Crazy f*%^ morons.
|
||||
*/
|
||||
input_units = SI_units;
|
||||
xml_parsing_units = SI_units;
|
||||
}
|
||||
|
||||
static void uddf_importer(void)
|
||||
{
|
||||
import_source = UDDF;
|
||||
input_units = SI_units;
|
||||
input_units.pressure = PASCAL;
|
||||
input_units.temperature = KELVIN;
|
||||
xml_parsing_units = SI_units;
|
||||
xml_parsing_units.pressure = PASCAL;
|
||||
xml_parsing_units.temperature = KELVIN;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1437,7 +1437,7 @@ static void reset_all(void)
|
|||
* data within one file, we might have to reset it per
|
||||
* dive for that format.
|
||||
*/
|
||||
input_units = SI_units;
|
||||
xml_parsing_units = SI_units;
|
||||
import_source = UNKNOWN;
|
||||
}
|
||||
|
||||
|
|
|
@ -667,7 +667,7 @@ static int validate_depth(const char *text, int *mm_p)
|
|||
while (isspace(*text))
|
||||
text++;
|
||||
|
||||
imperial = get_output_units()->length == FEET;
|
||||
imperial = get_units()->length == FEET;
|
||||
if (*text == 'm') {
|
||||
imperial = 0;
|
||||
text++;
|
||||
|
|
54
pref.h
Normal file
54
pref.h
Normal file
|
@ -0,0 +1,54 @@
|
|||
#ifndef PREF_H
|
||||
#define PREF_H
|
||||
|
||||
typedef struct {
|
||||
gboolean cylinder;
|
||||
gboolean temperature;
|
||||
gboolean totalweight;
|
||||
gboolean suit;
|
||||
gboolean nitrox;
|
||||
gboolean sac;
|
||||
gboolean otu;
|
||||
gboolean maxcns;
|
||||
} visible_cols_t;
|
||||
|
||||
typedef struct {
|
||||
gboolean po2;
|
||||
gboolean pn2;
|
||||
gboolean phe;
|
||||
double po2_threshold;
|
||||
double pn2_threshold;
|
||||
double phe_threshold;
|
||||
} partial_pressure_graphs_t;
|
||||
|
||||
struct preferences {
|
||||
struct units units;
|
||||
visible_cols_t visible_cols;
|
||||
partial_pressure_graphs_t pp_graphs;
|
||||
gboolean profile_red_ceiling;
|
||||
gboolean profile_calc_ceiling;
|
||||
gboolean calc_ceiling_3m_incr;
|
||||
double gflow;
|
||||
double gfhigh;
|
||||
};
|
||||
|
||||
extern struct preferences prefs, default_prefs;
|
||||
|
||||
#define PP_GRAPHS_ENABLED (prefs.pp_graphs.po2 || prefs.pp_graphs.pn2 || prefs.pp_graphs.phe)
|
||||
|
||||
typedef enum {
|
||||
PREF_BOOL,
|
||||
PREF_STRING
|
||||
} pref_type_t;
|
||||
|
||||
#define BOOL_TO_PTR(_cond) ((_cond) ? (void *)1 : NULL)
|
||||
#define PTR_TO_BOOL(_ptr) ((_ptr) != NULL)
|
||||
|
||||
extern void subsurface_open_conf(void);
|
||||
extern void subsurface_set_conf(char *name, pref_type_t type, const void *value);
|
||||
extern void subsurface_unset_conf(char *name);
|
||||
extern const void *subsurface_get_conf(char *name, pref_type_t type);
|
||||
extern void subsurface_flush_conf(void);
|
||||
extern void subsurface_close_conf(void);
|
||||
|
||||
#endif /* PREF_H */
|
|
@ -533,7 +533,7 @@ static void plot_depth_scale(struct graphics_context *gc, struct plot_info *pi)
|
|||
maxdepth = get_maxdepth(pi);
|
||||
gc->topy = 0; gc->bottomy = maxdepth;
|
||||
|
||||
switch (prefs.output_units.length) {
|
||||
switch (prefs.units.length) {
|
||||
case METERS: marker = 10000; break;
|
||||
case FEET: marker = 9144; break; /* 30 ft */
|
||||
}
|
||||
|
@ -721,7 +721,7 @@ static void plot_depth_profile(struct graphics_context *gc, struct plot_info *pi
|
|||
/* Depth markers: every 30 ft or 10 m*/
|
||||
gc->leftx = 0; gc->rightx = 1.0;
|
||||
gc->topy = 0; gc->bottomy = maxdepth;
|
||||
switch (prefs.output_units.length) {
|
||||
switch (prefs.units.length) {
|
||||
case METERS: marker = 10000; break;
|
||||
case FEET: marker = 9144; break; /* 30 ft */
|
||||
}
|
||||
|
|
10
windows.c
10
windows.c
|
@ -32,6 +32,16 @@ void subsurface_open_conf(void)
|
|||
printf("CreateKey Software\\subsurface failed %ld\n", success);
|
||||
}
|
||||
|
||||
void subsurface_unset_conf(char *name)
|
||||
{
|
||||
wchar_t *wname;
|
||||
|
||||
wname = (wchar_t *)g_utf8_to_utf16(name, -1, NULL, NULL, NULL);
|
||||
if (!wname)
|
||||
return;
|
||||
RegDeleteKey(hkey, (LPCWSTR)wname);
|
||||
}
|
||||
|
||||
void subsurface_set_conf(char *name, pref_type_t type, const void *value)
|
||||
{
|
||||
/* since we are using the pointer 'value' as both an actual
|
||||
|
|
Loading…
Add table
Reference in a new issue