summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile5
-rw-r--r--display-gtk.h3
-rw-r--r--divelist.c79
-rw-r--r--gtk-gui.c14
-rw-r--r--satellite.h29
-rw-r--r--satellite.pngbin0 -> 379 bytes
-rw-r--r--satellite.svg143
7 files changed, 252 insertions, 21 deletions
diff --git a/Makefile b/Makefile
index 2e264c90d..1610443b4 100644
--- a/Makefile
+++ b/Makefile
@@ -250,7 +250,10 @@ statistics.o: statistics.c dive.h display.h divelist.h
gps.o: gps.c dive.h display.h divelist.h
$(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) $(OSMGPSMAPFLAGS) -c gps.c
-divelist.o: divelist.c dive.h display.h divelist.h
+#satellite.h: satellite.png
+# gdk-pixbuf-csource --struct satellite.png > satellite.h
+
+divelist.o: divelist.c dive.h display.h divelist.h satellite.h
$(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) -c divelist.c
print.o: print.c dive.h display.h display-gtk.h
diff --git a/display-gtk.h b/display-gtk.h
index b889ff1a2..df29ff1d8 100644
--- a/display-gtk.h
+++ b/display-gtk.h
@@ -72,6 +72,8 @@ extern GtkWidget *weightsystem_list_widget(int w_idx);
extern GtkWidget *dive_list_create(void);
extern void dive_list_destroy(void);
+extern gboolean icon_click_cb(GtkWidget *w, GdkEventButton *event, gpointer data);
+
unsigned int amount_selected;
extern void process_selected_dives(void);
@@ -95,6 +97,7 @@ typedef gint (*sort_func_t)(GtkTreeModel *model,
extern GtkTreeViewColumn *tree_view_column(GtkWidget *tree_view, int index, const char *title,
data_func_t data_func, unsigned int flags);
+extern GtkTreeViewColumn *tree_view_column_add_pixbuf(GtkWidget *tree_view, data_func_t data_func, GtkTreeViewColumn *col);
GError *uemis_download(const char *path, progressbar_t *progress, GtkDialog *dialog, gboolean force_download);
diff --git a/divelist.c b/divelist.c
index e46e8ea20..b3c5417b8 100644
--- a/divelist.c
+++ b/divelist.c
@@ -23,6 +23,9 @@
#include "display.h"
#include "display-gtk.h"
+#include <gdk-pixbuf/gdk-pixdata.h>
+#include "satellite.h"
+
struct DiveList {
GtkWidget *tree_view;
GtkWidget *container_widget;
@@ -63,6 +66,7 @@ enum {
DIVE_OTU, /* int: in OTUs */
DIVE_MAXCNS, /* int: in % */
DIVE_LOCATION, /* "2nd Cathedral, Lanai" */
+ DIVE_LOC_ICON, /* pixbuf for gps icon */
DIVELIST_COLUMNS
};
@@ -480,28 +484,17 @@ static void temperature_data_func(GtkTreeViewColumn *col,
g_object_set(renderer, "text", buffer, NULL);
}
-static void location_data_func(GtkTreeViewColumn *col,
+static void gpsicon_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;
+ GdkPixbuf *icon;
- 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);
+ gtk_tree_model_get(model, iter, DIVE_INDEX, &idx, DIVE_LOC_ICON, &icon, -1);
+ g_object_set(renderer, "pixbuf", icon, NULL);
}
static void nr_data_func(GtkTreeViewColumn *col,
@@ -987,6 +980,14 @@ static void get_suit(struct dive *dive, char **str)
get_string(str, dive->suit);
}
+static GdkPixbuf *get_gps_icon(struct dive *dive)
+{
+ if (dive->latitude.udeg || dive->longitude.udeg)
+ return gdk_pixbuf_from_pixdata(&my_pixbuf, TRUE, NULL);
+ else
+ return NULL;
+}
+
/*
* Set up anything that could have changed due to editing
* of dive information; we need to do this for both models,
@@ -1004,14 +1005,16 @@ static void fill_one_dive(struct dive *dive,
{
char *location, *cylinder, *suit;
GtkTreeModel *othermodel;
+ GdkPixbuf *icon;
get_cylinder(dive, &cylinder);
get_location(dive, &location);
get_suit(dive, &suit);
-
+ icon = get_gps_icon(dive);
gtk_tree_store_set(GTK_TREE_STORE(model), iter,
DIVE_NR, dive->number,
DIVE_LOCATION, location,
+ DIVE_LOC_ICON, icon,
DIVE_CYLINDER, cylinder,
DIVE_RATING, dive->rating,
DIVE_SAC, dive->sac,
@@ -1359,6 +1362,7 @@ static void fill_dive_list(void)
int i, trip_index = 0;
GtkTreeIter iter, parent_iter, lookup, *parent_ptr = NULL;
GtkTreeStore *liststore, *treestore;
+ GdkPixbuf *icon;
/* Do we need to create any dive groups automatically? */
if (autogroup)
@@ -1409,6 +1413,7 @@ static void fill_dive_list(void)
/* store dive */
update_cylinder_related_info(dive);
gtk_tree_store_append(treestore, &iter, parent_ptr);
+ icon = get_gps_icon(dive);
gtk_tree_store_set(treestore, &iter,
DIVE_INDEX, i,
DIVE_NR, dive->number,
@@ -1416,6 +1421,7 @@ static void fill_dive_list(void)
DIVE_DEPTH, dive->maxdepth,
DIVE_DURATION, dive->duration.seconds,
DIVE_LOCATION, dive->location,
+ DIVE_LOC_ICON, icon,
DIVE_RATING, dive->rating,
DIVE_TEMPERATURE, dive->watertemp.mkelvin,
DIVE_SAC, 0,
@@ -1428,6 +1434,7 @@ static void fill_dive_list(void)
DIVE_DEPTH, dive->maxdepth,
DIVE_DURATION, dive->duration.seconds,
DIVE_LOCATION, dive->location,
+ DIVE_LOC_ICON, icon,
DIVE_RATING, dive->rating,
DIVE_TEMPERATURE, dive->watertemp.mkelvin,
DIVE_TOTALWEIGHT, 0,
@@ -1522,7 +1529,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"), location_data_func, NULL, ALIGN_LEFT },
+ [DIVE_LOCATION] = { N_("Location"), NULL, NULL, ALIGN_LEFT },
};
@@ -1690,6 +1697,33 @@ static void show_gps_location_cb(GtkWidget *menuitem, struct dive *dive)
}
#endif
+gboolean icon_click_cb(GtkWidget *w, GdkEventButton *event, gpointer data)
+{
+#if HAVE_OSM_GPS_MAP
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ GtkTreeViewColumn *col;
+ int idx;
+ struct dive *dive;
+
+ /* left click ? */
+ if (event->button == 1) {
+ gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(dive_list.tree_view), event->x, event->y, &path, &col, NULL, NULL);
+ /* is it the icon column ? (we passed the correct column in when registering the callback) */
+ if (col == data) {
+ gtk_tree_model_get_iter(MODEL(dive_list), &iter, path);
+ gtk_tree_model_get(MODEL(dive_list), &iter, DIVE_INDEX, &idx, -1);
+ dive = get_dive(idx);
+ if (dive->latitude.udeg || dive->longitude.udeg)
+ show_gps_location(dive);
+ }
+ gtk_tree_path_free(path);
+ }
+#endif
+ /* keep processing the click */
+ return FALSE;
+}
+
static void expand_all_cb(GtkWidget *menuitem, GtkTreeView *tree_view)
{
gtk_tree_view_expand_all(tree_view);
@@ -1706,6 +1740,7 @@ static int copy_tree_node(GtkTreeIter *a, GtkTreeIter *b)
struct dive store_dive;
int totalweight, idx;
char *cylinder_text;
+ GdkPixbuf *icon;
gtk_tree_model_get(MODEL(dive_list), a,
DIVE_INDEX, &idx,
@@ -1722,6 +1757,7 @@ static int copy_tree_node(GtkTreeIter *a, GtkTreeIter *b)
DIVE_OTU, &store_dive.otu,
DIVE_MAXCNS, &store_dive.maxcns,
DIVE_LOCATION, &store_dive.location,
+ DIVE_LOC_ICON, &icon,
-1);
gtk_tree_store_set(STORE(dive_list), b,
DIVE_INDEX, idx,
@@ -1738,6 +1774,7 @@ static int copy_tree_node(GtkTreeIter *a, GtkTreeIter *b)
DIVE_OTU, store_dive.otu,
DIVE_MAXCNS, store_dive.maxcns,
DIVE_LOCATION, store_dive.location,
+ DIVE_LOC_ICON, &icon,
-1);
free(cylinder_text);
free(store_dive.location);
@@ -2682,7 +2719,8 @@ GtkWidget *dive_list_create(void)
G_TYPE_INT, /* SAC */
G_TYPE_INT, /* OTU */
G_TYPE_INT, /* MAXCNS */
- G_TYPE_STRING /* Location */
+ G_TYPE_STRING, /* Location */
+ GDK_TYPE_PIXBUF /* GPS icon */
);
dive_list.treemodel = gtk_tree_store_new(DIVELIST_COLUMNS,
G_TYPE_INT, /* index */
@@ -2699,7 +2737,8 @@ GtkWidget *dive_list_create(void)
G_TYPE_INT, /* SAC */
G_TYPE_INT, /* OTU */
G_TYPE_INT, /* MAXCNS */
- G_TYPE_STRING /* Location */
+ G_TYPE_STRING, /* Location */
+ GDK_TYPE_PIXBUF /* GPS icon */
);
dive_list.model = dive_list.treemodel;
dive_list.tree_view = gtk_tree_view_new_with_model(TREEMODEL(dive_list));
@@ -2728,6 +2767,8 @@ GtkWidget *dive_list_create(void)
dive_list.otu = divelist_column(&dive_list, dl_column + DIVE_OTU);
dive_list.maxcns = divelist_column(&dive_list, dl_column + DIVE_MAXCNS);
dive_list.location = divelist_column(&dive_list, dl_column + DIVE_LOCATION);
+ /* now add the GPS icon to the location column */
+ tree_view_column_add_pixbuf(dive_list.tree_view, gpsicon_data_func, dive_list.location);
fill_dive_list();
diff --git a/gtk-gui.c b/gtk-gui.c
index 7a8f10c68..01615976c 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -343,6 +343,15 @@ void quit(GtkWidget *w, gpointer data)
}
}
+GtkTreeViewColumn *tree_view_column_add_pixbuf(GtkWidget *tree_view, data_func_t data_func, GtkTreeViewColumn *col)
+{
+ GtkCellRenderer *renderer = gtk_cell_renderer_pixbuf_new();
+ gtk_tree_view_column_pack_start(col, renderer, FALSE);
+ gtk_tree_view_column_set_cell_data_func(col, renderer, data_func, NULL, NULL);
+ g_signal_connect(tree_view, "button-press-event", G_CALLBACK(icon_click_cb), col);
+ return col;
+}
+
GtkTreeViewColumn *tree_view_column(GtkWidget *tree_view, int index, const char *title,
data_func_t data_func, unsigned int flags)
{
@@ -370,7 +379,10 @@ GtkTreeViewColumn *tree_view_column(GtkWidget *tree_view, int index, const char
if (!(flags & UNSORTABLE))
gtk_tree_view_column_set_sort_column_id(col, index);
gtk_tree_view_column_set_resizable(col, TRUE);
- gtk_tree_view_column_pack_start(col, renderer, TRUE);
+ /* all but one column have only one renderer - so packing from the end
+ * makes no difference; for the location column we want to be able to
+ * prepend the icon in front of the text - so this works perfectly */
+ gtk_tree_view_column_pack_end(col, renderer, TRUE);
if (data_func)
gtk_tree_view_column_set_cell_data_func(col, renderer, data_func, (void *)(long)index, NULL);
else
diff --git a/satellite.h b/satellite.h
new file mode 100644
index 000000000..c13bb0cf4
--- /dev/null
+++ b/satellite.h
@@ -0,0 +1,29 @@
+/* GdkPixbuf RGBA C-Source image dump 1-byte-run-length-encoded */
+
+static const GdkPixdata my_pixbuf = {
+ 0x47646b50, /* Pixbuf magic: 'GdkP' */
+ 24 + 458, /* header length + pixel_data length */
+ 0x2010002, /* pixdata_type */
+ 44, /* rowstride */
+ 11, /* width */
+ 16, /* height */
+ /* pixel_data: */
+ "\12\0\0\0\0\0\0\0""4\0\0\0\216\0\0\0\1\0\0\0\34\0\0\0\254\0\0\0\261\0"
+ "\0\0\274\0\0\0\207\0\0\0\17\202\0\0\0\0\5\0\0\0\301\0\0\0\377\0\0\0\235"
+ "\0\0\0\6\0\0\0\14\202\0\0\0\20\4\0\0\0=\0\0\0\260\0\0\0\5\0\0\0.\203"
+ "\0\0\0\377\10\0\0\0\263\0\0\0\27\0\0\0\234\0\0\0\260\0\0\0M\0\0\0Z\0"
+ "\0\0e\0\0\0w\204\0\0\0\377\7\0\0\0\265\0\0\0\11\0\0\0\3\0\0\0\257\0\0"
+ "\0\7\0\0\0\242\0\0\0\245\205\0\0\0\377\6\0\0\0\277\0\0\0\15\0\0\0\222"
+ "\0\0\0\6\0\0\0\243\0\0\0\261\206\0\0\0\377\5\0\0\0\311\0\0\0\22\0\0\0"
+ "\15\0\0\0C\0\0\0\232\207\0\0\0\377\4\0\0\0\330\0\0\0\35\0\0\0\0\0\0\0"
+ "^\210\0\0\0\377\4\0\0\0\332\0\0\0\37\0\0\0\13\0\0\0\345\210\0\0\0\377"
+ "\4\0\0\0\306\0\0\0\0\0\0\0H\0\0\0\371\206\0\0\0\377\6\0\0\0\341\0\0\0"
+ "&\0\0\0\0\0\0\0e\0\0\0z\0\0\0\320\203\0\0\0\377\3\0\0\0\371\0\0\0\236"
+ "\0\0\0\22\202\0\0\0\0\7\0\0\0\272\0\0\0\377\0\0\0\300\0\0\0""0\0\0\0"
+ "U\0\0\0G\0\0\0\20\203\0\0\0\0\2\0\0\0\14\0\0\0\371\202\0\0\0\377\1\0"
+ "\0\0R\206\0\0\0\0\1\0\0\0M\203\0\0\0\377\1\0\0\0\256\206\0\0\0\0\1\0"
+ "\0\0\224\203\0\0\0\377\2\0\0\0\371\0\0\0\23\205\0\0\0\0\1\0\0\0\334\204"
+ "\0\0\0\377\1\0\0\0h\205\0\0\0\0",
+};
+
+
diff --git a/satellite.png b/satellite.png
new file mode 100644
index 000000000..b85b396dc
--- /dev/null
+++ b/satellite.png
Binary files differ
diff --git a/satellite.svg b/satellite.svg
new file mode 100644
index 000000000..3e4c2c578
--- /dev/null
+++ b/satellite.svg
@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="134.4245"
+ height="187.00729"
+ id="svg3695"
+ sodipodi:version="0.32"
+ inkscape:version="0.48.4 r9939"
+ version="1.0"
+ sodipodi:docname="satellite.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ inkscape:export-filename="/home/bpavie/Documents/Images/geolocalisation_satellite.png"
+ inkscape:export-xdpi="29.639999"
+ inkscape:export-ydpi="29.639999">
+ <defs
+ id="defs3697">
+ <linearGradient
+ id="linearGradient49770">
+ <stop
+ offset="0"
+ id="stop49772"
+ style="stop-color: rgb(149, 149, 149); stop-opacity: 1;" />
+ <stop
+ offset="1"
+ id="stop49774"
+ style="stop-color: black; stop-opacity: 1;" />
+ </linearGradient>
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective3703" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="2"
+ inkscape:cx="74.420662"
+ inkscape:cy="127.07939"
+ inkscape:document-units="px"
+ inkscape:current-layer="g108374"
+ showgrid="true"
+ inkscape:window-width="1507"
+ inkscape:window-height="1119"
+ inkscape:window-x="921"
+ inkscape:window-y="251"
+ inkscape:window-maximized="0"
+ fit-margin-top="0"
+ fit-margin-left="0"
+ fit-margin-right="0"
+ fit-margin-bottom="0" />
+ <metadata
+ id="metadata3700">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <cc:license
+ rdf:resource="http://creativecommons.org/licenses/publicdomain/" />
+ </cc:Work>
+ <cc:License
+ rdf:about="http://creativecommons.org/licenses/publicdomain/">
+ <cc:permits
+ rdf:resource="http://creativecommons.org/ns#Reproduction" />
+ <cc:permits
+ rdf:resource="http://creativecommons.org/ns#Distribution" />
+ <cc:permits
+ rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
+ </cc:License>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-782.66331,-422.76616)">
+ <g
+ id="g108374"
+ transform="matrix(1.22961,0,0,1.22961,261.37024,2463.4334)"
+ inkscape:export-filename="/home/ben/Documents/programmation/javascript/google_map/images/sat.png"
+ inkscape:export-xdpi="10.76"
+ inkscape:export-ydpi="10.76"
+ style="fill:#000000">
+ <path
+ sodipodi:nodetypes="ccccc"
+ id="path101559"
+ d="m 479.34671,-1507.5186 -55.39678,0 16.66803,-56.6225 c 6.91443,6.0951 14.07395,10.9645 22.21396,13.138 l 16.51479,43.4845 z"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none"
+ inkscape:connector-curvature="0" />
+ <path
+ sodipodi:nodetypes="ccc"
+ id="path101561"
+ d="m 444.53989,-1659.4921 c 29.57763,26.9631 59.15529,53.9261 88.73292,80.8892 -56.54068,65.6919 -144.45653,0.9803 -88.73292,-80.8892 z"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none"
+ inkscape:connector-curvature="0" />
+ <path
+ sodipodi:type="arc"
+ style="fill:none;stroke:#000000;stroke-width:8;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+ id="path4201"
+ sodipodi:cx="86.5"
+ sodipodi:cy="56.785934"
+ sodipodi:rx="43.5"
+ sodipodi:ry="43"
+ d="m 64.75,19.546842 c 20.805729,-11.874122 47.40991,-4.82749 59.4221,15.739092 6.42915,11.007612 7.60232,24.26291 3.20453,36.206868"
+ transform="matrix(0.81326599,0,0,0.81326599,421.1035,-1667.558)"
+ sodipodi:start="4.1887902"
+ sodipodi:end="6.6322512"
+ sodipodi:open="true" />
+ <path
+ sodipodi:type="arc"
+ style="fill:none;stroke:#000000;stroke-width:8;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+ id="path4205"
+ sodipodi:cx="91.25"
+ sodipodi:cy="52.035934"
+ sodipodi:rx="19.75"
+ sodipodi:ry="21.75"
+ d="m 81.375,33.199882 c 9.446279,-6.006097 21.52519,-2.441812 26.979,7.961052 2.91898,5.567804 3.45163,12.272519 1.45493,18.313939"
+ transform="matrix(0.81326599,0,0,0.81326599,418.6637,-1663.4916)"
+ sodipodi:start="4.1887902"
+ sodipodi:end="6.6322512"
+ sodipodi:open="true" />
+ </g>
+ </g>
+</svg>