mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Make the map provider choice a preference
Not all of the providers seem to work for me (Yahoo Satellite doesn't appear to give me any data), but for now I'll leave most of them in. We can later decide to offer only some of them. It might be more fun to be able to pick the provider directly from the map widget. But for now I kept this in the preferences which seemed to be a good place for it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
b24d0f2f60
commit
d1c394e51f
5 changed files with 66 additions and 14 deletions
17
prefs.c
17
prefs.c
|
|
@ -60,8 +60,18 @@ static void save_double_conf(char *name, double _val, double _def)
|
|||
subsurface_set_conf(name, string);
|
||||
}
|
||||
|
||||
static void save_int_conf(char *name, int value, int def)
|
||||
{
|
||||
if (value == def) {
|
||||
subsurface_unset_conf(name);
|
||||
return;
|
||||
}
|
||||
subsurface_set_conf_int(name, value);
|
||||
}
|
||||
|
||||
#define SAVE_DOUBLE(name, field) save_double_conf(name, prefs.field, default_prefs.field)
|
||||
#define SAVE_PERCENT(name, field) save_double_conf(name, prefs.field*100, default_prefs.field*100)
|
||||
#define SAVE_INT(name, field) save_int_conf(name, prefs.field, default_prefs.field)
|
||||
|
||||
void save_preferences(void)
|
||||
{
|
||||
|
|
@ -102,6 +112,8 @@ void save_preferences(void)
|
|||
|
||||
SAVE_STRING("default_filename", default_filename);
|
||||
|
||||
SAVE_INT("map_provider", map_provider);
|
||||
|
||||
/* Flush the changes out to the system */
|
||||
subsurface_flush_conf();
|
||||
}
|
||||
|
|
@ -122,6 +134,7 @@ static gboolean get_bool(char *name, gboolean def)
|
|||
void load_preferences(void)
|
||||
{
|
||||
const char *conf_value;
|
||||
int int_value;
|
||||
|
||||
GET_UNIT("feet", length, METERS, FEET);
|
||||
GET_UNIT("psi", pressure, BAR, PSI);
|
||||
|
|
@ -189,4 +202,8 @@ void load_preferences(void)
|
|||
conf_value = subsurface_get_conf("default_filename");
|
||||
if (conf_value)
|
||||
prefs.default_filename = conf_value;
|
||||
|
||||
int_value = subsurface_get_conf_int("map_provider");
|
||||
if(int_value >= 0)
|
||||
prefs.map_provider = int_value;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue