summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dive.h2
-rw-r--r--info.c60
-rw-r--r--parse-xml.c2
-rw-r--r--save-xml.c2
-rw-r--r--statistics.c11
5 files changed, 74 insertions, 3 deletions
diff --git a/dive.h b/dive.h
index 940e5388a..c19016556 100644
--- a/dive.h
+++ b/dive.h
@@ -267,7 +267,7 @@ struct dive {
double latitude, longitude;
depth_t maxdepth, meandepth;
duration_t duration, surfacetime;
- depth_t visibility;
+ int visibility; /* 0 - 5 star rating */
temperature_t airtemp, watertemp;
cylinder_t cylinder[MAX_CYLINDERS];
weightsystem_t weightsystem[MAX_WEIGHTSYSTEMS];
diff --git a/info.c b/info.c
index 4c693e9b0..6501150a2 100644
--- a/info.c
+++ b/info.c
@@ -238,6 +238,19 @@ static GtkEntry *text_value(GtkWidget *box, const char *label)
return GTK_ENTRY(widget);
}
+static GtkEntry *single_text_entry(GtkWidget *box, const char *label, const char *text)
+{
+ GtkEntry *entry;
+ GtkWidget *frame = gtk_frame_new(label);
+
+ gtk_box_pack_start(GTK_BOX(box), frame, FALSE, TRUE, 0);
+ entry = GTK_ENTRY(gtk_entry_new());
+ gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(entry));
+ if (text && *text)
+ gtk_entry_set_text(entry, text);
+ return entry;
+}
+
static GtkComboBoxEntry *text_entry(GtkWidget *box, const char *label, GtkListStore *completions, const char *text)
{
GtkEntry *entry;
@@ -387,7 +400,8 @@ static int get_rating(const char *string)
}
struct dive_info {
- GtkComboBoxEntry *location, *divemaster, *buddy, *rating, *suit;
+ GtkComboBoxEntry *location, *divemaster, *buddy, *rating, *suit, *viz;
+ GtkEntry *airtemp;
GtkTextView *notes;
};
@@ -395,6 +409,7 @@ static void save_dive_info_changes(struct dive *dive, struct dive *master, struc
{
char *old_text, *new_text;
char *rating_string;
+ double newtemp;
int changed = 0;
new_text = get_combo_box_entry_text(info->location, &dive->location, master->location);
@@ -429,6 +444,33 @@ static void save_dive_info_changes(struct dive *dive, struct dive *master, struc
}
free(rating_string);
+ rating_string = strdup(star_strings[dive->visibility]);
+ new_text = get_combo_box_entry_text(info->viz, &rating_string, star_strings[master->visibility]);
+ if (new_text) {
+ dive->visibility = get_rating(rating_string);
+ changed = 1;
+ }
+ free(rating_string);
+
+ new_text = (char *)gtk_entry_get_text(info->airtemp);
+ if(sscanf(new_text, "%lf", &newtemp) == 1) {
+ unsigned long mkelvin;
+ switch (output_units.temperature) {
+ case CELSIUS:
+ mkelvin = C_to_mkelvin(newtemp);
+ break;
+ case FAHRENHEIT:
+ mkelvin = F_to_mkelvin(newtemp);
+ break;
+ default:
+ mkelvin = 0;
+ }
+ if (mkelvin != dive->airtemp.mkelvin) {
+ dive->airtemp.mkelvin = mkelvin;
+ changed = 1;
+ }
+ }
+
if (info->notes) {
old_text = dive->notes;
dive->notes = get_text(info->notes);
@@ -465,6 +507,9 @@ static void dive_info_widget(GtkWidget *box, struct dive *dive, struct dive_info
{
GtkWidget *hbox, *label, *frame, *equipment;
char buffer[128];
+ char airtemp[6];
+ const char *unit;
+ double value;
snprintf(buffer, sizeof(buffer), "%s", _("Edit multiple dives"));
@@ -487,6 +532,19 @@ static void dive_info_widget(GtkWidget *box, struct dive *dive, struct dive_info
info->rating = text_entry(hbox, _("Rating"), star_list, star_strings[dive->rating]);
info->suit = text_entry(hbox, _("Suit"), suit_list, dive->suit);
+ hbox = gtk_hbox_new(FALSE, 3);
+ gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, TRUE, 0);
+
+ info->viz = text_entry(hbox, _("Visibility"), star_list, star_strings[dive->visibility]);
+
+ value = get_temp_units(dive->airtemp.mkelvin, &unit);
+ snprintf(buffer, sizeof(buffer), _("Air Temp in %s"), unit);
+ if (dive->airtemp.mkelvin)
+ snprintf(airtemp, sizeof(airtemp), "%.1f", value);
+ else
+ airtemp[0] = '\0';
+ info->airtemp = single_text_entry(hbox, buffer, airtemp);
+
/* only show notes if editing a single dive */
if (multi) {
info->notes = NULL;
diff --git a/parse-xml.c b/parse-xml.c
index cb84cc26a..9429580e6 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -1126,6 +1126,8 @@ static void try_to_fill_dive(struct dive **divep, const char *name, char *buf)
return;
if (MATCH(".rating", get_index, &dive->rating))
return;
+ if (MATCH(".visibility", get_index, &dive->visibility))
+ return;
if (MATCH(".cylinder.size", cylindersize, &dive->cylinder[cur_cylinder_index].type.size))
return;
if (MATCH(".cylinder.workpressure", pressure, &dive->cylinder[cur_cylinder_index].type.workingpressure))
diff --git a/save-xml.c b/save-xml.c
index f386814f3..fb62651d6 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -329,6 +329,8 @@ static void save_dive(FILE *f, struct dive *dive)
fprintf(f, " tripflag='%s'", tripflag_names[dive->tripflag]);
if (dive->rating)
fprintf(f, " rating='%d'", dive->rating);
+ if (dive->visibility)
+ fprintf(f, " visibility='%d'", dive->visibility);
fprintf(f, " date='%04u-%02u-%02u'",
tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday);
fprintf(f, " time='%02u:%02u:%02u'",
diff --git a/statistics.c b/statistics.c
index c0b4a1eba..08fb73814 100644
--- a/statistics.c
+++ b/statistics.c
@@ -27,6 +27,7 @@ typedef struct {
*surf_intv,
*max_depth,
*avg_depth,
+ *viz,
*water_temp,
*air_temp,
*sac,
@@ -544,6 +545,7 @@ static void show_single_dive_stats(struct dive *dive)
set_label(single_w.max_depth, "%.*f %s", decimals, value, unit);
value = get_depth_units(dive->meandepth.mm, &decimals, &unit);
set_label(single_w.avg_depth, "%.*f %s", decimals, value, unit);
+ set_label(single_w.viz, star_strings[dive->visibility]);
if (dive->watertemp.mkelvin) {
value = get_temp_units(dive->watertemp.mkelvin, &unit);
set_label(single_w.water_temp, "%.1f %s", value, unit);
@@ -733,10 +735,16 @@ GtkWidget *single_stats_widget(void)
single_w.max_depth = new_info_label_in_frame(hbox, _("Max Depth"));
single_w.avg_depth = new_info_label_in_frame(hbox, _("Avg Depth"));
+ single_w.viz = new_info_label_in_frame(hbox, _("Visibility"));
+
+ /* third row */
+ hbox = gtk_hbox_new(FALSE, 3);
+ gtk_box_pack_start(GTK_BOX(framebox), hbox, TRUE, FALSE, 3);
+
single_w.water_temp = new_info_label_in_frame(hbox, _("Water Temp"));
single_w.air_temp = new_info_label_in_frame(hbox, _("Air Temp"));
- /* third row */
+ /* fourth row */
hbox = gtk_hbox_new(FALSE, 3);
gtk_box_pack_start(GTK_BOX(framebox), hbox, TRUE, FALSE, 3);
@@ -755,6 +763,7 @@ void clear_stats_widgets(void)
set_label(single_w.surf_intv, "");
set_label(single_w.max_depth, "");
set_label(single_w.avg_depth, "");
+ set_label(single_w.viz, "");
set_label(single_w.water_temp, "");
set_label(single_w.air_temp, "");
set_label(single_w.sac, "");