Merge branch 'defaultfile'

By now the default file code seems quite matured, so in preparation for
2.0 we'll bring it back into master.

I made a few small clean-ups during the merge, but the merge itself is
very much straight forward.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2012-09-17 21:27:43 -04:00
commit 3835faa8fb
13 changed files with 444 additions and 136 deletions

25
info.c
View file

@ -112,6 +112,23 @@ void show_dive_info(struct dive *dive)
{
const char *text;
char buffer[80];
char title[80];
if (!dive) {
if (existing_filename) {
snprintf(title, 80, "Subsurface: %s", g_path_get_basename(existing_filename));
gtk_window_set_title(GTK_WINDOW(main_window), title);
} else {
gtk_window_set_title(GTK_WINDOW(main_window), "Subsurface");
}
SET_TEXT_VALUE(divemaster);
SET_TEXT_VALUE(buddy);
SET_TEXT_VALUE(location);
SET_TEXT_VALUE(suit);
gtk_entry_set_text(rating, star_strings[0]);
gtk_text_buffer_set_text(gtk_text_view_get_buffer(notes), "", -1);
return;
}
/* dive number and location (or lacking that, the date) go in the window title */
text = dive->location;
@ -125,8 +142,14 @@ void show_dive_info(struct dive *dive)
text = buffer;
if (!dive->number)
text += 10; /* Skip the "Dive #0 - " part */
gtk_window_set_title(GTK_WINDOW(main_window), text);
/* put it all together */
if (existing_filename) {
snprintf(title, 80, "%s: %s", g_path_get_basename(existing_filename), text);
gtk_window_set_title(GTK_WINDOW(main_window), title);
} else {
gtk_window_set_title(GTK_WINDOW(main_window), text);
}
SET_TEXT_VALUE(divemaster);
SET_TEXT_VALUE(buddy);
SET_TEXT_VALUE(location);