aboutsummaryrefslogtreecommitdiffstats
path: root/gtk-gui.c
diff options
context:
space:
mode:
authorGravatar Terrance Stanfield <t@hollowcranium.com>2012-05-29 23:54:09 -0500
committerGravatar Terrance Stanfield <t@hollowcranium.com>2012-05-29 23:54:09 -0500
commit697435b249e1e2f308cc72c85180806cc0765249 (patch)
treec2e19bd5d8b6a350fb5007231e84d7e79b55a144 /gtk-gui.c
parent058b84cca0f876bf2221e248e4854905b0705210 (diff)
downloadsubsurface-697435b249e1e2f308cc72c85180806cc0765249.tar.gz
Save dive computer device name.
It is really annoying to have to type the device name each time you need to import a dive from your computer, if you are not using the default device name. This will save the device name in the configuration file and matches the logic currently used to save the dive computer name in the configuration file. Signed-off-by: Terrance Stanfield <t@hollowcranium.com>
Diffstat (limited to 'gtk-gui.c')
-rw-r--r--gtk-gui.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/gtk-gui.c b/gtk-gui.c
index 98c0111ea..1e053e52b 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -32,12 +32,18 @@ static GtkWidget *dive_profile;
visible_cols_t visible_cols = {TRUE, FALSE};
static const char *default_dive_computer;
+static const char *default_dive_computer_device;
static int is_default_dive_computer(const char *name)
{
return default_dive_computer && !strcmp(name, default_dive_computer);
}
+static int is_default_dive_computer_device(const char *name)
+{
+ return default_dive_computer_device && !strcmp(name, default_dive_computer_device);
+}
+
static void set_default_dive_computer(const char *name)
{
if (!name || !*name)
@@ -48,6 +54,16 @@ static void set_default_dive_computer(const char *name)
subsurface_set_conf("dive_computer", PREF_STRING, name);
}
+static void set_default_dive_computer_device(const char *name)
+{
+ if (!name || !*name)
+ return;
+ if (is_default_dive_computer_device(name))
+ return;
+ default_dive_computer_device = name;
+ subsurface_set_conf("dive_computer_device", PREF_STRING, name);
+}
+
void repaint_dive(void)
{
update_dive(current_dive);
@@ -709,6 +725,7 @@ void init_ui(int *argcp, char ***argvp)
divelist_font = subsurface_get_conf("divelist_font", PREF_STRING);
default_dive_computer = subsurface_get_conf("dive_computer", PREF_STRING);
+ default_dive_computer_device = subsurface_get_conf("dive_computer_device", PREF_STRING);
error_info_bar = NULL;
win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
@@ -939,6 +956,14 @@ static GtkComboBox *dive_computer_selector(GtkWidget *vbox)
return GTK_COMBO_BOX(combo_box);
}
+const char *subsurface_device_name()
+{
+ if (!default_dive_computer_device || !*default_dive_computer_device)
+ return subsurface_USB_name();
+ else
+ return default_dive_computer_device;
+}
+
static GtkEntry *dive_computer_device(GtkWidget *vbox)
{
GtkWidget *hbox, *entry, *frame;
@@ -951,7 +976,7 @@ static GtkEntry *dive_computer_device(GtkWidget *vbox)
entry = gtk_entry_new();
gtk_container_add(GTK_CONTAINER(frame), entry);
- gtk_entry_set_text(GTK_ENTRY(entry), subsurface_USB_name());
+ gtk_entry_set_text(GTK_ENTRY(entry), subsurface_device_name());
return GTK_ENTRY(entry);
}
@@ -1092,6 +1117,7 @@ repeat:
devicedata.name = comp;
devicedata.devname = gtk_entry_get_text(device);
set_default_dive_computer(devicedata.name);
+ set_default_dive_computer_device(devicedata.devname);
info = import_dive_computer(&devicedata, GTK_DIALOG(dialog));
if (info)
goto repeat;