aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-01-20 17:32:55 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-01-20 17:32:55 -0800
commit3d248682eef1a200d5d992ca1a00abe810ca1a29 (patch)
treee9a513ecdcdabc3ec57856ef8111b0c57b224aa0
parent980ba9cb509d74a59fdb1145028b13c1beab6e49 (diff)
downloadsubsurface-3d248682eef1a200d5d992ca1a00abe810ca1a29.tar.gz
Mark locations that have GPS location data attached
This is rather lame - we simply turn the location text into italics for those dives where we have GPS location data. Underlining might be more natural, but Gtk plays games with the underline attribute if the mouse hovers over text. Ideally I would have prefered a little GPS logo next to the location text - but I couldn't figure out how to do that without writing my own cell renderer which seemed total overkill. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--divelist.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/divelist.c b/divelist.c
index 554fb8869..e46e8ea20 100644
--- a/divelist.c
+++ b/divelist.c
@@ -480,6 +480,30 @@ static void temperature_data_func(GtkTreeViewColumn *col,
g_object_set(renderer, "text", buffer, NULL);
}
+static void location_data_func(GtkTreeViewColumn *col,
+ GtkCellRenderer *renderer,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer data)
+{
+ int idx;
+ char *location;
+ char buffer[512];
+ struct dive *dive;
+ gboolean hasgps = FALSE;
+
+ gtk_tree_model_get(model, iter, DIVE_INDEX, &idx, DIVE_LOCATION, &location, -1);
+ if (idx >0 ) {
+ /* make locations with GPS data stand out */
+ dive = get_dive(idx);
+ if (dive && (dive->latitude.udeg || dive->longitude.udeg)) {
+ hasgps = TRUE;
+ }
+ }
+ snprintf(buffer, sizeof(buffer), "%s%s%s", hasgps ? "<i>" : "", location, hasgps ? "</i>" : "");
+ g_object_set(renderer, "markup", buffer, NULL);
+}
+
static void nr_data_func(GtkTreeViewColumn *col,
GtkCellRenderer *renderer,
GtkTreeModel *model,
@@ -1498,7 +1522,7 @@ static struct divelist_column {
[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 },
+ [DIVE_LOCATION] = { N_("Location"), location_data_func, NULL, ALIGN_LEFT },
};