summaryrefslogtreecommitdiffstats
path: root/gtk-gui.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2012-12-21 20:00:20 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-12-21 20:58:47 -0800
commit8d2abc05f60cb9a5ec79db9a215fe8aa97e0c311 (patch)
tree1a3d4fe6f9abc3206cdf8a115edb954842e64e29 /gtk-gui.c
parenteb3e879030b0a29cc3f40d8df3e3eb6f7120c9ea (diff)
downloadsubsurface-8d2abc05f60cb9a5ec79db9a215fe8aa97e0c311.tar.gz
Remove nickname from divecomputer data structure
Having it there with the model information seemed to make sense but on second thought it's the wrong spot to keep that information, especially since we were storing it in the XML file in every single dive. This change removes the nickname member from the divecomputer and makes the rest of the code reasonably self consistent. It does not add much of the new code for the new design to handle nicknames. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'gtk-gui.c')
-rw-r--r--gtk-gui.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/gtk-gui.c b/gtk-gui.c
index c22d2b573..bb1142e41 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -2023,7 +2023,7 @@ void set_filename(const char *filename, gboolean force)
existing_filename = NULL;
}
-static const char *get_dc_nickname(uint32_t deviceid)
+const char *get_dc_nickname(uint32_t deviceid)
{
struct dcnicknamelist *known = nicknamelist;
while (known) {
@@ -2083,15 +2083,15 @@ void remember_dc(uint32_t deviceid, const char *nickname, gboolean change_conf)
void set_dc_nickname(struct dive *dive)
{
GtkWidget *dialog, *vbox, *entry, *frame, *label;
- char nickname[160];
- const char *name;
+ char nickname[160] = "";
+ const char *name = nickname;
if (!dive)
return;
- if ((name = get_dc_nickname(dive->dc.deviceid)) != NULL) {
- dive->dc.nickname = strdup(name);
- } else {
+ /* we should only do this if we already have a different dive computer
+ * with the same model -- TBI */
+ if (get_dc_nickname(dive->dc.deviceid) == NULL) {
dialog = gtk_dialog_new_with_buttons(
_("Dive Computer Nickname"),
GTK_WINDOW(main_window),
@@ -2117,10 +2117,10 @@ void set_dc_nickname(struct dive *dive)
gtk_widget_show_all(dialog);
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
if (strcmp(dive->dc.model, gtk_entry_get_text(GTK_ENTRY(entry))))
- dive->dc.nickname = cleanedup_nickname(gtk_entry_get_text(GTK_ENTRY(entry)),
- sizeof(nickname));
+ name = cleanedup_nickname(gtk_entry_get_text(GTK_ENTRY(entry)),
+ sizeof(nickname));
}
gtk_widget_destroy(dialog);
- remember_dc(dive->dc.deviceid, dive->dc.nickname, TRUE);
+ remember_dc(dive->dc.deviceid, name, TRUE);
}
}