From 3d248682eef1a200d5d992ca1a00abe810ca1a29 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 20 Jan 2013 17:32:55 -0800 Subject: 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 --- divelist.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'divelist.c') 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 ? "" : "", location, hasgps ? "" : ""); + 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 }, }; -- cgit v1.2.3-70-g09d2