diff options
Diffstat (limited to 'divelist.c')
-rw-r--r-- | divelist.c | 87 |
1 files changed, 68 insertions, 19 deletions
diff --git a/divelist.c b/divelist.c index d157849fd..a917889c4 100644 --- a/divelist.c +++ b/divelist.c @@ -402,7 +402,7 @@ static void depth_data_func(GtkTreeViewColumn *col, if (idx < 0) { *buffer = '\0'; } else { - switch (output_units.length) { + switch (prefs.output_units.length) { case METERS: /* To tenths of meters */ depth = (depth + 49) / 100; @@ -461,7 +461,7 @@ static void temperature_data_func(GtkTreeViewColumn *col, *buffer = 0; if (idx >= 0 && value) { double deg; - switch (output_units.temperature) { + switch (prefs.output_units.temperature) { case CELSIUS: deg = mkelvin_to_C(value); break; @@ -658,7 +658,7 @@ static void sac_data_func(GtkTreeViewColumn *col, } sac = value / 1000.0; - switch (output_units.volume) { + switch (prefs.output_units.volume) { case LITER: fmt = "%4.1f"; break; @@ -935,14 +935,14 @@ void update_dive_list_units(void) void update_dive_list_col_visibility(void) { - gtk_tree_view_column_set_visible(dive_list.cylinder, visible_cols.cylinder); - gtk_tree_view_column_set_visible(dive_list.temperature, visible_cols.temperature); - gtk_tree_view_column_set_visible(dive_list.totalweight, visible_cols.totalweight); - gtk_tree_view_column_set_visible(dive_list.suit, visible_cols.suit); - gtk_tree_view_column_set_visible(dive_list.nitrox, visible_cols.nitrox); - gtk_tree_view_column_set_visible(dive_list.sac, visible_cols.sac); - gtk_tree_view_column_set_visible(dive_list.otu, visible_cols.otu); - gtk_tree_view_column_set_visible(dive_list.maxcns, visible_cols.maxcns); + gtk_tree_view_column_set_visible(dive_list.cylinder, prefs.visible_cols.cylinder); + gtk_tree_view_column_set_visible(dive_list.temperature, prefs.visible_cols.temperature); + gtk_tree_view_column_set_visible(dive_list.totalweight, prefs.visible_cols.totalweight); + gtk_tree_view_column_set_visible(dive_list.suit, prefs.visible_cols.suit); + gtk_tree_view_column_set_visible(dive_list.nitrox, prefs.visible_cols.nitrox); + gtk_tree_view_column_set_visible(dive_list.sac, prefs.visible_cols.sac); + gtk_tree_view_column_set_visible(dive_list.otu, prefs.visible_cols.otu); + gtk_tree_view_column_set_visible(dive_list.maxcns, prefs.visible_cols.maxcns); return; } @@ -1289,14 +1289,14 @@ static struct divelist_column { [DIVE_RATING] = { UTF8_BLACKSTAR, star_data_func, NULL, ALIGN_LEFT }, [DIVE_DEPTH] = { N_("ft"), depth_data_func, NULL, ALIGN_RIGHT }, [DIVE_DURATION] = { N_("min"), duration_data_func, NULL, ALIGN_RIGHT }, - [DIVE_TEMPERATURE] = { UTF8_DEGREE "F", temperature_data_func, NULL, ALIGN_RIGHT, &visible_cols.temperature }, - [DIVE_TOTALWEIGHT] = { N_("lbs"), weight_data_func, NULL, ALIGN_RIGHT, &visible_cols.totalweight }, - [DIVE_SUIT] = { N_("Suit"), NULL, NULL, ALIGN_LEFT, &visible_cols.suit }, - [DIVE_CYLINDER] = { N_("Cyl"), NULL, NULL, 0, &visible_cols.cylinder }, - [DIVE_NITROX] = { "O" UTF8_SUBSCRIPT_2 "%", nitrox_data_func, nitrox_sort_func, 0, &visible_cols.nitrox }, - [DIVE_SAC] = { N_("SAC"), sac_data_func, NULL, 0, &visible_cols.sac }, - [DIVE_OTU] = { N_("OTU"), otu_data_func, NULL, 0, &visible_cols.otu }, - [DIVE_MAXCNS] = { N_("maxCNS"), cns_data_func, NULL, 0, &visible_cols.maxcns }, + [DIVE_TEMPERATURE] = { UTF8_DEGREE "F", temperature_data_func, NULL, ALIGN_RIGHT, &prefs.visible_cols.temperature }, + [DIVE_TOTALWEIGHT] = { N_("lbs"), weight_data_func, NULL, ALIGN_RIGHT, &prefs.visible_cols.totalweight }, + [DIVE_SUIT] = { N_("Suit"), NULL, NULL, ALIGN_LEFT, &prefs.visible_cols.suit }, + [DIVE_CYLINDER] = { N_("Cyl"), NULL, NULL, 0, &prefs.visible_cols.cylinder }, + [DIVE_NITROX] = { "O" UTF8_SUBSCRIPT_2 "%", nitrox_data_func, nitrox_sort_func, 0, &prefs.visible_cols.nitrox }, + [DIVE_SAC] = { N_("SAC"), sac_data_func, NULL, 0, &prefs.visible_cols.sac }, + [DIVE_OTU] = { N_("OTU"), otu_data_func, NULL, 0, &prefs.visible_cols.otu }, + [DIVE_MAXCNS] = { N_("maxCNS"), cns_data_func, NULL, 0, &prefs.visible_cols.maxcns }, [DIVE_LOCATION] = { N_("Location"), NULL, NULL, ALIGN_LEFT }, }; @@ -1408,6 +1408,48 @@ void edit_dive_from_path_cb(GtkWidget *menuitem, GtkTreePath *path) edit_multi_dive_info(dive); } +void edit_dive_when_cb(GtkWidget *menuitem, struct dive *dive) +{ + GtkWidget *dialog, *cal, *h, *m; + timestamp_t when; + + guint yval, mval, dval; + int success; + struct tm tm; + + if (!dive) + return; + + when = dive->when; + utc_mkdate(when, &tm); + dialog = create_date_time_widget(&tm, &cal, &h, &m); + + gtk_widget_show_all(dialog); + success = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT; + if (!success) { + gtk_widget_destroy(dialog); + return; + } + memset(&tm, 0, sizeof(tm)); + gtk_calendar_get_date(GTK_CALENDAR(cal), &yval, &mval, &dval); + tm.tm_year = yval; + tm.tm_mon = mval; + tm.tm_mday = dval; + tm.tm_hour = gtk_spin_button_get_value(GTK_SPIN_BUTTON(h)); + tm.tm_min = gtk_spin_button_get_value(GTK_SPIN_BUTTON(m)); + + gtk_widget_destroy(dialog); + when = utc_mktime(&tm); + if (dive->when != when) { + dive->when = when; + mark_divelist_changed(TRUE); + remember_tree_state(); + report_dives(FALSE, FALSE); + dive_list_update_dives(); + restore_tree_state(); + } +} + static void expand_all_cb(GtkWidget *menuitem, GtkTreeView *tree_view) { gtk_tree_view_expand_all(tree_view); @@ -2167,6 +2209,9 @@ static void popup_divelist_menu(GtkTreeView *tree_view, GtkTreeModel *model, int if (amount_selected == 1) { deletelabel = _(deletesinglelabel); editlabel = _(editsinglelabel); + menuitem = gtk_menu_item_new_with_label(_("Edit dive date/time")); + g_signal_connect(menuitem, "activate", G_CALLBACK(edit_dive_when_cb), dive); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); } else { deletelabel = _(deleteplurallabel); editlabel = _(editplurallabel); @@ -2183,6 +2228,10 @@ static void popup_divelist_menu(GtkTreeView *tree_view, GtkTreeModel *model, int if (amount_selected == 2) add_dive_merge_label(idx, GTK_MENU_SHELL(menu)); } else { + menuitem = gtk_menu_item_new_with_label(_("Edit dive date/time")); + g_signal_connect(menuitem, "activate", G_CALLBACK(edit_dive_when_cb), dive); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); + deletelabel = _(deletesinglelabel); menuitem = gtk_menu_item_new_with_label(deletelabel); g_signal_connect(menuitem, "activate", G_CALLBACK(delete_dive_cb), path); |