mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
eb3e879030
commit
8d2abc05f6
6 changed files with 21 additions and 26 deletions
18
gtk-gui.c
18
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue