aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dive.h5
-rw-r--r--divelist.c10
2 files changed, 12 insertions, 3 deletions
diff --git a/dive.h b/dive.h
index 1cb0613ee..2c8f18b94 100644
--- a/dive.h
+++ b/dive.h
@@ -342,6 +342,11 @@ struct dive {
struct divecomputer dc;
};
+static inline int dive_has_location(struct dive *dive)
+{
+ return dive->latitude.udeg || dive->longitude.udeg;
+}
+
/* Pa = N/m^2 - so we determine the weight (in N) of the mass of 10m
* of water (and use standard salt water at 1.03kg per liter if we don't know salinity)
* and add that to the surface pressure (or to 1013 if that's unknown) */
diff --git a/divelist.c b/divelist.c
index c190d7d38..3705c62ad 100644
--- a/divelist.c
+++ b/divelist.c
@@ -2475,9 +2475,13 @@ static void popup_divelist_menu(GtkTreeView *tree_view, GtkTreeModel *model, int
g_signal_connect(menuitem, "activate", G_CALLBACK(edit_dive_from_path_cb), path);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
}
- menuitem = gtk_menu_item_new_with_label(_("Show in map"));
- g_signal_connect(menuitem, "activate", G_CALLBACK(show_gps_location_cb), dive);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
+
+ /* Only offer to show on map if it has a location. */
+ if (dive_has_location(dive)) {
+ menuitem = gtk_menu_item_new_with_label(_("Show in map"));
+ g_signal_connect(menuitem, "activate", G_CALLBACK(show_gps_location_cb), dive);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
+ }
/* only offer trip editing options when we are displaying the tree model */
if (dive_list.model == dive_list.treemodel) {