annotate src/bar_gps.c @ 1757:8ecdf8445ef5

fixed and simplified sidecar grouping code
author nadvornik
date Thu, 24 Sep 2009 21:52:44 +0000
parents a4f3c93294c9
children 8b9bbf92725f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1604
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
1 /*
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
2 * Geeqie
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
3 * (C) 2004 John Ellis
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
4 * Copyright (C) 2008 - 2009 The Geeqie Team
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
5 *
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
6 * Author: Colin Clark
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
7 *
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
8 * This software is released under the GNU General Public License (GNU GPL).
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
9 * Please read the included file COPYING for more information.
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
10 * This software comes with no warranty of any kind, use at your own risk!
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
11 */
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
12
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
13 #include "main.h"
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
14 #ifdef HAVE_LIBCHAMPLAIN
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
15 #ifdef HAVE_LIBCHAMPLAIN_GTK
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
16
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
17 #include "bar_gps.h"
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
18
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
19 #include "bar.h"
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
20 #include "filedata.h"
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
21 #include "layout.h"
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
22 #include "metadata.h"
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
23 #include "menu.h"
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
24 #include "rcfile.h"
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
25 #include "thumb.h"
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
26 #include "ui_menu.h"
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
27
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
28 #include <clutter-gtk/gtk-clutter-embed.h>
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
29 #include <champlain/champlain.h>
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
30 #include <champlain-gtk/champlain-gtk.h>
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
31
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
32 #define MARKER_COLOUR 0x00, 0x00, 0xff, 0xff
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
33 #define TEXT_COLOUR 0x00, 0x00, 0x00, 0xff
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
34 #define THUMB_COLOUR 0xff, 0xff, 0xff, 0xff
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
35 #define THUMB_SIZE 100
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
36
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
37 /*
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
38 *-------------------------------------------------------------------
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
39 * GPS Map utils
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
40 *-------------------------------------------------------------------
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
41 */
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
42
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
43 typedef struct _PaneGPSData PaneGPSData;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
44 struct _PaneGPSData
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
45 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
46 PaneData pane;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
47 GtkWidget *widget;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
48 FileData *fd;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
49 gchar *map_source;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
50 gint height;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
51 ClutterActor *gps_view;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
52 ChamplainLayer *icon_layer;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
53 GList *selection_list;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
54 GPtrArray *marker_list;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
55 guint create_markers_id;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
56 GtkWidget *progress;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
57 GtkWidget *slider;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
58 GtkWidget *state;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
59 gint selection_count;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
60 gboolean centre_map_checked;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
61 gboolean enable_markers_checked;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
62 };
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
63
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
64 static void bar_pane_gps_thumb_done_cb(ThumbLoader *tl, gpointer data)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
65 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
66 FileData *fd;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
67 ClutterActor *marker;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
68 ClutterActor *actor;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
69
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
70 marker = CLUTTER_ACTOR(data);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
71 fd = g_object_get_data(G_OBJECT(marker), "file_fd");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
72 if (fd->thumb_pixbuf != NULL)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
73 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
74 actor = clutter_texture_new();
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
75 gtk_clutter_texture_set_from_pixbuf(CLUTTER_TEXTURE(actor), fd->thumb_pixbuf);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
76 champlain_marker_set_image(CHAMPLAIN_MARKER(marker), actor);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
77 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
78 thumb_loader_free(tl);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
79 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
80
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
81 static void bar_pane_gps_thumb_error_cb(ThumbLoader *tl, gpointer data)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
82 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
83 thumb_loader_free(tl);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
84 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
85
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
86 static gboolean bar_pane_gps_marker_keypress_cb(GtkWidget *widget, ClutterButtonEvent *bevent, gpointer data)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
87 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
88 //PaneGPSData *pgd = data;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
89 FileData *fd;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
90 ClutterActor *marker;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
91 ClutterColor marker_colour = { MARKER_COLOUR };
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
92 ClutterColor text_colour = { TEXT_COLOUR };
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
93 ClutterColor thumb_colour = { THUMB_COLOUR };
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
94 gchar *current_text;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
95 ClutterActor *actor;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
96 ClutterActor *current_image;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
97 GString *text;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
98 gint height, width, rotate;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
99 gchar *altitude = NULL;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
100 ThumbLoader *tl;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
101
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
102 if (bevent->button == MOUSE_BUTTON_LEFT)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
103 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
104 marker = CLUTTER_ACTOR(widget);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
105 fd = g_object_get_data(G_OBJECT(marker), "file_fd");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
106
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
107 /* If the marker is showing a thumbnail, delete it
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
108 */
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
109 current_image = champlain_marker_get_image(CHAMPLAIN_MARKER(marker));
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
110 if (current_image != NULL)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
111 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
112 clutter_actor_destroy(CLUTTER_ACTOR(current_image));
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
113 champlain_marker_set_image(CHAMPLAIN_MARKER(marker), NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
114 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
115
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
116 current_text = g_strdup(champlain_marker_get_text(CHAMPLAIN_MARKER(marker)));
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
117
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
118 /* If the marker is showing only the text character, replace it with a
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
119 * thumbnail and date and altitude
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
120 */
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
121 if (g_strcmp0(current_text, "i") == 0)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
122 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
123 /* If a thumbail has already been generated, use that. If not try the pixbuf of the full image.
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
124 * If not, call the thumb_loader to generate a thumbnail and update the marker later in the
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
125 * thumb_loader callback
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
126 */
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
127 if (fd->thumb_pixbuf != NULL)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
128 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
129 actor = clutter_texture_new();
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
130 gtk_clutter_texture_set_from_pixbuf(CLUTTER_TEXTURE(actor), fd->thumb_pixbuf);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
131 champlain_marker_set_image(CHAMPLAIN_MARKER(marker), actor);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
132 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
133 else if (fd->pixbuf != NULL)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
134 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
135 actor = clutter_texture_new();
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
136 width = gdk_pixbuf_get_width (fd->pixbuf);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
137 height = gdk_pixbuf_get_height (fd->pixbuf);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
138 switch (fd->exif_orientation)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
139 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
140 case 8:
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
141 rotate = GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
142 break;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
143 case 3:
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
144 rotate = GDK_PIXBUF_ROTATE_UPSIDEDOWN;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
145 break;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
146 case 6:
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
147 rotate = GDK_PIXBUF_ROTATE_CLOCKWISE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
148 break;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
149 default:
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
150 rotate = GDK_PIXBUF_ROTATE_NONE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
151 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
152
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
153 gtk_clutter_texture_set_from_pixbuf(CLUTTER_TEXTURE(actor),
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
154 gdk_pixbuf_rotate_simple(gdk_pixbuf_scale_simple(fd->pixbuf, THUMB_SIZE, height * THUMB_SIZE / width,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
155 GDK_INTERP_NEAREST), rotate));
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
156 champlain_marker_set_image(CHAMPLAIN_MARKER(marker), actor);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
157 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
158 else
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
159 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
160 tl = thumb_loader_new(THUMB_SIZE, THUMB_SIZE);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
161 thumb_loader_set_callbacks(tl,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
162 bar_pane_gps_thumb_done_cb,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
163 bar_pane_gps_thumb_error_cb,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
164 NULL,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
165 marker);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
166 thumb_loader_start(tl, fd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
167 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
168
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
169 text = g_string_new(fd->name);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
170 g_string_append(text, "\n");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
171 g_string_append(text, text_from_time(fd->date));
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
172 g_string_append(text, "\n");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
173 altitude = metadata_read_string(fd, "formatted.GPSAltitude", METADATA_FORMATTED);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
174 if (altitude != NULL)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
175 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
176 g_string_append(text, altitude);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
177 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
178
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
179 champlain_marker_set_text(CHAMPLAIN_MARKER(marker), text->str);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
180 champlain_marker_set_color(CHAMPLAIN_MARKER(marker), &thumb_colour);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
181 champlain_marker_set_text_color(CHAMPLAIN_MARKER(marker), &text_colour);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
182 champlain_marker_set_font_name(CHAMPLAIN_MARKER(marker), "sans 8");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
183
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
184 g_free(altitude);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
185 g_string_free(text, TRUE);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
186 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
187 /* otherwise, revert to the hidden text marker
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
188 */
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
189 else
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
190 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
191 champlain_marker_set_text(CHAMPLAIN_MARKER(marker), "i");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
192 champlain_marker_set_color(CHAMPLAIN_MARKER(marker), &marker_colour);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
193 champlain_marker_set_text_color(CHAMPLAIN_MARKER(marker), &marker_colour);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
194 champlain_marker_set_font_name(CHAMPLAIN_MARKER(marker), "courier 5");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
195 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
196
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
197 g_free(current_text);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
198
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
199 return TRUE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
200 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
201 return TRUE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
202 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
203
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
204 static gboolean bar_pane_gps_create_markers_cb(gpointer data)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
205 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
206 PaneGPSData *pgd = data;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
207 gdouble latitude;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
208 gdouble longitude;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
209 GList *work;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
210 ClutterActor *marker;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
211 FileData *fd;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
212 ClutterColor marker_colour = { MARKER_COLOUR };
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
213 GString *message;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
214
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
215 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(pgd->progress),
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
216 (gdouble)(pgd->selection_count - g_list_length(pgd->selection_list)) /
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
217 (gdouble)pgd->selection_count);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
218
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
219 message = g_string_new("");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
220 g_string_printf(message, "%i/%i", (pgd->selection_count - g_list_length(pgd->selection_list)),
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
221 pgd->selection_count);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
222 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(pgd->progress), message->str);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
223 g_string_free(message, TRUE);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
224
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
225 work = pgd->selection_list;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
226 while (work)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
227 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
228 fd = work->data;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
229 pgd->selection_list = g_list_remove(pgd->selection_list, work->data);
1708
fc147a2d8aaf do not process sidecar files in bar_gps
nadvornik
parents: 1679
diff changeset
230 /* If the file has a parent, it must be a sidecar file. Do not process sidecar files
fc147a2d8aaf do not process sidecar files in bar_gps
nadvornik
parents: 1679
diff changeset
231 */
fc147a2d8aaf do not process sidecar files in bar_gps
nadvornik
parents: 1679
diff changeset
232 if (fd != NULL && fd->parent == NULL)
1604
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
233 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
234 latitude = metadata_read_GPS_coord(fd, "Xmp.exif.GPSLatitude", 1000);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
235 longitude = metadata_read_GPS_coord(fd, "Xmp.exif.GPSLongitude", 1000);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
236
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
237 if ((latitude != 1000) && (longitude != 1000))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
238 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
239 marker = champlain_marker_new_with_text("i","courier 5", &marker_colour, &marker_colour);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
240
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
241 champlain_base_marker_set_position(CHAMPLAIN_BASE_MARKER(marker), latitude, longitude);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
242 clutter_container_add(CLUTTER_CONTAINER(pgd->icon_layer), marker, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
243 clutter_actor_set_reactive(marker, TRUE);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
244
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
245 g_signal_connect(G_OBJECT(marker), "button_press_event",
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
246 G_CALLBACK(bar_pane_gps_marker_keypress_cb), pgd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
247
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
248 g_object_set_data(G_OBJECT(marker), "file_fd", fd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
249
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
250 g_ptr_array_add(pgd->marker_list, marker);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
251 if (pgd->centre_map_checked)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
252 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
253 g_ptr_array_add(pgd->marker_list, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
254 champlain_view_ensure_markers_visible(CHAMPLAIN_VIEW(pgd->gps_view),
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
255 (void *)pgd->marker_list->pdata, FALSE);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
256 g_ptr_array_remove(pgd->marker_list, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
257 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
258 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
259 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
260 return TRUE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
261 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
262
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
263 if (pgd->marker_list->len >= 1)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
264 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
265 g_ptr_array_add(pgd->marker_list, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
266
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
267 if (pgd->centre_map_checked)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
268 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
269 champlain_view_ensure_markers_visible(CHAMPLAIN_VIEW(pgd->gps_view), (void *)pgd->marker_list->pdata, FALSE);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
270 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
271 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
272
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
273 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(pgd->progress), 0);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
274 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(pgd->progress), NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
275 g_list_free(pgd->selection_list);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
276 g_ptr_array_free(pgd->marker_list, TRUE);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
277 pgd->create_markers_id = 0;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
278
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
279 return FALSE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
280 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
281
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
282 static void bar_pane_gps_update(PaneGPSData *pgd)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
283 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
284 GList *list;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
285 GList *work;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
286
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
287 /* The widget does not have a parent during bar_pane_gps_new, so calling gtk_widget_show_all there gives a
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
288 * "Gtk-CRITICAL **: gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed"
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
289 * error. gtk_widget_show_all can be given after it has been added to the bar.
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
290 */
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
291 if (gtk_widget_get_parent(pgd->widget) != NULL)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
292 gtk_widget_show_all(pgd->widget);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
293
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
294 /* If a create-marker background process is running, kill it
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
295 * and start again
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
296 */
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
297 if (pgd->create_markers_id != 0)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
298 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
299 if (g_idle_remove_by_data(pgd))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
300 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
301 pgd->create_markers_id = 0;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
302 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
303 else
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
304 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
305 return;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
306 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
307 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
308
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
309 /* Delete any markers currently displayed
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
310 */
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
311 work = clutter_container_get_children(CLUTTER_CONTAINER(pgd->icon_layer));
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
312 while (work)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
313 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
314 clutter_container_remove(CLUTTER_CONTAINER(pgd->icon_layer), work->data, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
315 work = work->next;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
316 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
317 g_list_free(work);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
318
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
319 if (!pgd->enable_markers_checked)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
320 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
321 return;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
322 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
323
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
324 /* For each selected photo that has GPS data, create a marker containing
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
325 * a single, small text character the same colour as the marker background.
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
326 * Use a background process in case the user selects a large number of files.
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
327 */
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
328 list = layout_selection_list(pgd->pane.lw);
1754
a4f3c93294c9 fixed selection handling in sidebar
nadvornik
parents: 1733
diff changeset
329 list = file_data_process_groups_in_selection(list, FALSE, NULL);
1604
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
330
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
331 if (list != NULL)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
332 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
333 pgd->selection_list = g_list_copy(list);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
334 pgd->marker_list = g_ptr_array_new();
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
335 pgd->selection_count = g_list_length(pgd->selection_list);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
336 pgd->create_markers_id = g_idle_add(bar_pane_gps_create_markers_cb, pgd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
337 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
338
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
339 g_list_free(list);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
340 g_list_free(work);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
341 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
342
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
343 void bar_pane_gps_set_map_source(PaneGPSData *pgd, const gchar *map_id)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
344 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
345 ChamplainMapSource *map_source;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
346 ChamplainMapSourceFactory *map_factory;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
347
1733
b52deba688e9 Fix up compilation issues related to libchamplain.
zas_
parents: 1708
diff changeset
348 #if CHAMPLAIN_CHECK_VERSION(0,3,2)
b52deba688e9 Fix up compilation issues related to libchamplain.
zas_
parents: 1708
diff changeset
349 map_factory = champlain_map_source_factory_dup_default();
b52deba688e9 Fix up compilation issues related to libchamplain.
zas_
parents: 1708
diff changeset
350 #else
1604
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
351 map_factory = champlain_map_source_factory_get_default();
1733
b52deba688e9 Fix up compilation issues related to libchamplain.
zas_
parents: 1708
diff changeset
352 #endif
1604
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
353 map_source = champlain_map_source_factory_create(map_factory, map_id);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
354
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
355 if (map_source != NULL)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
356 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
357 g_object_set(G_OBJECT(pgd->gps_view), "map-source", map_source, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
358 g_object_unref(map_factory);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
359 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
360
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
361 g_object_unref(map_source);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
362 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
363
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
364 void bar_pane_gps_enable_markers_checked_toggle_cb(GtkWidget *menu_widget, gpointer data)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
365 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
366 PaneGPSData *pgd = data;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
367
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
368 if (pgd->enable_markers_checked)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
369 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
370 pgd->enable_markers_checked = FALSE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
371 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
372 else
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
373 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
374 pgd->enable_markers_checked = TRUE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
375 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
376 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
377
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
378 static void bar_pane_gps_centre_map_checked_toggle_cb(GtkWidget *menu_widget, gpointer data)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
379 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
380 PaneGPSData *pgd = data;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
381
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
382 if (pgd->centre_map_checked)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
383 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
384 pgd->centre_map_checked = FALSE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
385 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
386 else
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
387 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
388 pgd->centre_map_checked = TRUE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
389 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
390 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
391
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
392 static void bar_pane_gps_change_map_cb(GtkWidget *widget, gpointer data)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
393 {
1667
0806ccdfe06b simplified menu_item_add_radio usage
nadvornik
parents: 1604
diff changeset
394 PaneGPSData *pgd = data;
1604
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
395 gchar *mapsource;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
396
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
397 if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
398 return;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
399
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
400 if (!pgd) return;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
401
1667
0806ccdfe06b simplified menu_item_add_radio usage
nadvornik
parents: 1604
diff changeset
402 mapsource = g_object_get_data(G_OBJECT(widget), "menu_item_radio_data");
1604
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
403 bar_pane_gps_set_map_source(pgd, mapsource);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
404 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
405
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
406 static void bar_pane_gps_notify_selection(GtkWidget *bar, gint count)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
407 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
408 PaneGPSData *pgd;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
409
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
410 if (count == 0) return;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
411
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
412 pgd = g_object_get_data(G_OBJECT(bar), "pane_data");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
413 if (!pgd) return;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
414
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
415 bar_pane_gps_update(pgd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
416 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
417
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
418 static void bar_pane_gps_set_fd(GtkWidget *bar, FileData *fd)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
419 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
420 PaneGPSData *pgd;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
421
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
422 pgd = g_object_get_data(G_OBJECT(bar), "pane_data");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
423 if (!pgd) return;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
424
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
425 file_data_unref(pgd->fd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
426 pgd->fd = file_data_ref(fd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
427
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
428 bar_pane_gps_update(pgd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
429 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
430
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
431 static gint bar_pane_gps_event(GtkWidget *bar, GdkEvent *event)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
432 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
433 PaneGPSData *pgd;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
434
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
435 pgd = g_object_get_data(G_OBJECT(bar), "pane_data");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
436 if (!pgd) return FALSE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
437
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
438 if (GTK_WIDGET_HAS_FOCUS(pgd->widget)) return gtk_widget_event(GTK_WIDGET(pgd->widget), event);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
439
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
440 return FALSE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
441 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
442
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
443 static void bar_pane_gps_write_config(GtkWidget *pane, GString *outstr, gint indent)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
444 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
445 PaneGPSData *pgd;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
446 gint zoom;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
447 ChamplainMapSource *mapsource;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
448 const gchar *map_id;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
449 gchar *str = NULL;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
450 GString *buffer = g_string_new(str);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
451 gdouble position;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
452 gint int_position;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
453
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
454 pgd = g_object_get_data(G_OBJECT(pane), "pane_data");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
455 if (!pgd) return;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
456
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
457 WRITE_NL();
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
458 WRITE_STRING("<pane_gps ");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
459 write_char_option(outstr, indent, "id", pgd->pane.id);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
460 write_char_option(outstr, indent, "title", gtk_label_get_text(GTK_LABEL(pgd->pane.title)));
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
461 WRITE_BOOL(pgd->pane, expanded);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
462 WRITE_INT(*pgd, height);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
463 indent++;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
464
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
465 g_object_get(G_OBJECT(pgd->gps_view), "map-source", &mapsource, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
466 map_id = champlain_map_source_get_id(mapsource);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
467 WRITE_NL();
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
468 write_char_option(outstr, indent, "map-id", map_id);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
469
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
470 g_object_get(G_OBJECT(pgd->gps_view), "zoom-level", &zoom, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
471 g_string_printf(buffer, "%d", zoom);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
472 WRITE_NL();
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
473 write_char_option(outstr, indent, "zoom-level", buffer->str);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
474
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
475 g_object_get(G_OBJECT(pgd->gps_view), "latitude", &position, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
476 int_position = position * 1000000;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
477 g_string_printf(buffer, "%i", int_position);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
478 WRITE_NL();
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
479 write_char_option(outstr, indent, "latitude", buffer->str);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
480
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
481 g_object_get(G_OBJECT(pgd->gps_view), "longitude", &position, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
482 int_position = position * 1000000;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
483 g_string_printf(buffer, "%i", int_position);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
484 WRITE_NL();
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
485 write_char_option(outstr, indent, "longitude", buffer->str);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
486
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
487 indent--;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
488 WRITE_NL();
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
489 WRITE_STRING("/>");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
490
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
491 g_object_unref(mapsource);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
492
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
493 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
494
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
495 static void bar_pane_gps_slider_changed_cb(GtkScaleButton *slider,
1733
b52deba688e9 Fix up compilation issues related to libchamplain.
zas_
parents: 1708
diff changeset
496 gdouble zoom,
b52deba688e9 Fix up compilation issues related to libchamplain.
zas_
parents: 1708
diff changeset
497 gpointer data)
1604
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
498 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
499 PaneGPSData *pgd = data;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
500 GString *message;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
501
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
502 message = g_string_new("");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
503 g_string_printf(message, _("Zoom %i"), (gint)zoom);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
504
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
505 g_object_set(G_OBJECT(CHAMPLAIN_VIEW(pgd->gps_view)), "zoom-level", (gint)zoom, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
506 gtk_widget_set_tooltip_text(GTK_WIDGET(slider), message->str);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
507 g_string_free(message, TRUE);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
508
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
509 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
510 static void bar_pane_gps_view_state_changed_cb(ChamplainView *view,
1733
b52deba688e9 Fix up compilation issues related to libchamplain.
zas_
parents: 1708
diff changeset
511 GParamSpec *gobject,
b52deba688e9 Fix up compilation issues related to libchamplain.
zas_
parents: 1708
diff changeset
512 gpointer data)
1604
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
513 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
514 PaneGPSData *pgd = data;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
515 ChamplainState status;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
516 gint zoom;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
517 GString *message;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
518
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
519 g_object_get(G_OBJECT(view), "zoom-level", &zoom, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
520 message = g_string_new("");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
521 g_string_printf(message, _("Zoom level %i"), zoom);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
522
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
523 g_object_get(G_OBJECT(view), "state", &status, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
524 if (status == CHAMPLAIN_STATE_LOADING)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
525 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
526 gtk_label_set_text(GTK_LABEL(pgd->state), _("Loading map"));
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
527 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
528 else
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
529 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
530 gtk_label_set_text(GTK_LABEL(pgd->state), message->str);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
531 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
532
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
533 gtk_widget_set_tooltip_text(GTK_WIDGET(pgd->slider), message->str);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
534 gtk_scale_button_set_value(GTK_SCALE_BUTTON(pgd->slider), (gdouble)zoom);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
535
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
536 g_string_free(message, TRUE);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
537 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
538
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
539 static void bar_pane_gps_notify_cb(FileData *fd, NotifyType type, gpointer data)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
540 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
541 PaneGPSData *pgd = data;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
542
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
543 if ((type & (NOTIFY_REREAD | NOTIFY_CHANGE | NOTIFY_METADATA)) && fd == pgd->fd)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
544 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
545 bar_pane_gps_update(pgd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
546 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
547 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
548
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
549 const gchar *bar_pane_gps_get_map_id(PaneGPSData *pgd)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
550 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
551 const gchar *map_id;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
552 ChamplainMapSource *mapsource;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
553
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
554 g_object_get(G_OBJECT(pgd->gps_view), "map-source", &mapsource, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
555 map_id = champlain_map_source_get_id(mapsource);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
556
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
557 g_object_unref(mapsource);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
558
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
559 return map_id;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
560 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
561
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
562 static GtkWidget *bar_pane_gps_menu(PaneGPSData *pgd)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
563 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
564 GtkWidget *menu;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
565 GtkWidget *map_centre;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
566 GtkWidget *parent;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
567 ChamplainMapSourceFactory *map_factory;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
568 GSList *map_list;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
569 ChamplainMapSourceDesc *map_desc;
1667
0806ccdfe06b simplified menu_item_add_radio usage
nadvornik
parents: 1604
diff changeset
570 const gchar *current;
1604
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
571
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
572 menu = popup_menu_short_lived();
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
573
1733
b52deba688e9 Fix up compilation issues related to libchamplain.
zas_
parents: 1708
diff changeset
574 #if CHAMPLAIN_CHECK_VERSION(0,3,2)
b52deba688e9 Fix up compilation issues related to libchamplain.
zas_
parents: 1708
diff changeset
575 map_factory = champlain_map_source_factory_dup_default();
b52deba688e9 Fix up compilation issues related to libchamplain.
zas_
parents: 1708
diff changeset
576 map_list = champlain_map_source_factory_dup_list(map_factory);
b52deba688e9 Fix up compilation issues related to libchamplain.
zas_
parents: 1708
diff changeset
577 #else
1604
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
578 map_factory = champlain_map_source_factory_get_default();
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
579 map_list = champlain_map_source_factory_get_list(map_factory);
1733
b52deba688e9 Fix up compilation issues related to libchamplain.
zas_
parents: 1708
diff changeset
580 #endif
1667
0806ccdfe06b simplified menu_item_add_radio usage
nadvornik
parents: 1604
diff changeset
581 current = bar_pane_gps_get_map_id(pgd);
1604
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
582
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
583 while (map_list)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
584 {
1667
0806ccdfe06b simplified menu_item_add_radio usage
nadvornik
parents: 1604
diff changeset
585 map_desc = (ChamplainMapSourceDesc *)(map_list->data);
0806ccdfe06b simplified menu_item_add_radio usage
nadvornik
parents: 1604
diff changeset
586
0806ccdfe06b simplified menu_item_add_radio usage
nadvornik
parents: 1604
diff changeset
587 menu_item_add_radio(menu, map_desc->name, map_desc->id, strcmp(map_desc->id, current) == 0, G_CALLBACK(bar_pane_gps_change_map_cb), pgd);
0806ccdfe06b simplified menu_item_add_radio usage
nadvornik
parents: 1604
diff changeset
588
1604
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
589 map_list = g_slist_next(map_list);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
590 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
591
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
592 menu_item_add_divider(menu);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
593 menu_item_add_check(menu, _("Enable markers"), pgd->enable_markers_checked,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
594 G_CALLBACK(bar_pane_gps_enable_markers_checked_toggle_cb), pgd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
595 map_centre = menu_item_add_check(menu, _("Centre map on marker"), pgd->centre_map_checked,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
596 G_CALLBACK(bar_pane_gps_centre_map_checked_toggle_cb), pgd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
597 if (!pgd->enable_markers_checked)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
598 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
599 gtk_widget_set_sensitive(map_centre, FALSE);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
600 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
601
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
602 g_slist_free(map_list);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
603 g_object_unref(map_factory);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
604 //g_object_unref(map_centre);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
605
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
606 return menu;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
607 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
608
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
609 /* Determine if the map is to be re-centred on the marker when another photo is selected
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
610 */
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
611 void bar_pane_gps_map_centreing(PaneGPSData *pgd)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
612 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
613 GtkWidget *dialog;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
614 GString *message = g_string_new("");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
615
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
616 if (pgd->centre_map_checked)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
617 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
618 message = g_string_append(message, _("Move map centre to marker\n is disabled"));
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
619 pgd->centre_map_checked = FALSE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
620 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
621 else
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
622 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
623 message = g_string_append(message, _("Move map centre to marker\n is enabled"));
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
624 pgd->centre_map_checked = TRUE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
625 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
626
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
627 dialog = gtk_message_dialog_new(NULL,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
628 GTK_DIALOG_DESTROY_WITH_PARENT,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
629 GTK_MESSAGE_INFO,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
630 GTK_BUTTONS_CLOSE,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
631 "%s", message->str);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
632 gtk_window_set_title(GTK_WINDOW(dialog), _("Map Centreing"));
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
633 gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
634 gtk_dialog_run(GTK_DIALOG(dialog));
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
635
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
636 gtk_widget_destroy(dialog);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
637 g_string_free(message, TRUE);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
638 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
639
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
640 static gboolean bar_pane_gps_map_keypress_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
641 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
642 PaneGPSData *pgd = data;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
643 GtkWidget *menu;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
644
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
645 if (bevent->button == MOUSE_BUTTON_RIGHT)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
646 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
647 menu = bar_pane_gps_menu(pgd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
648 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, bevent->button, bevent->time);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
649 return TRUE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
650 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
651 else if (bevent->button == MOUSE_BUTTON_MIDDLE)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
652 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
653 bar_pane_gps_map_centreing(pgd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
654 return TRUE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
655 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
656 else if (bevent->button == MOUSE_BUTTON_LEFT)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
657 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
658 return FALSE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
659 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
660 else
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
661 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
662 return FALSE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
663 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
664 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
665
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
666 static void bar_pane_gps_destroy(GtkWidget *widget, gpointer data)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
667 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
668 PaneGPSData *pgd = data;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
669
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
670 file_data_unregister_notify_func(bar_pane_gps_notify_cb, pgd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
671
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
672 file_data_unref(pgd->fd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
673 g_free(pgd->map_source);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
674 g_free(pgd->pane.id);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
675 clutter_actor_destroy(pgd->gps_view);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
676 g_free(pgd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
677 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
678
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
679
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
680 GtkWidget *bar_pane_gps_new(const gchar *id, const gchar *title, const gchar *map_id,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
681 const gint zoom, const gdouble latitude, const gdouble longitude,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
682 gboolean expanded, gint height)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
683 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
684 PaneGPSData *pgd;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
685 GtkWidget *vbox, *scrolled;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
686 GtkWidget *gpswidget, *viewport;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
687 GtkWidget *status, *state, *progress, *slider;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
688 ChamplainLayer *layer;
1733
b52deba688e9 Fix up compilation issues related to libchamplain.
zas_
parents: 1708
diff changeset
689 ChamplainView *view;
1604
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
690 const gchar *slider_list[] = {GTK_STOCK_ZOOM_IN, GTK_STOCK_ZOOM_OUT, NULL};
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
691 const gchar **slider_icons = slider_list;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
692
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
693 pgd = g_new0(PaneGPSData, 1);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
694
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
695 pgd->pane.pane_set_fd = bar_pane_gps_set_fd;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
696 pgd->pane.pane_notify_selection = bar_pane_gps_notify_selection;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
697 pgd->pane.pane_event = bar_pane_gps_event;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
698 pgd->pane.pane_write_config = bar_pane_gps_write_config;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
699 pgd->pane.title = bar_pane_expander_title(title);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
700 pgd->pane.id = g_strdup(id);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
701 pgd->pane.type = PANE_GPS;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
702 pgd->pane.expanded = expanded;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
703 pgd->height = height;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
704
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
705 scrolled = gtk_scrolled_window_new(NULL, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
706 vbox = gtk_vbox_new(FALSE, 0);
1667
0806ccdfe06b simplified menu_item_add_radio usage
nadvornik
parents: 1604
diff changeset
707
1679
1867687f2fcb libchamplain compatibility fix
nadvornik
parents: 1667
diff changeset
708 #ifdef GTK_CHAMPLAIN_EMBED
1733
b52deba688e9 Fix up compilation issues related to libchamplain.
zas_
parents: 1708
diff changeset
709 gpswidget = gtk_champlain_embed_new();
b52deba688e9 Fix up compilation issues related to libchamplain.
zas_
parents: 1708
diff changeset
710 view = gtk_champlain_embed_get_view(GTK_CHAMPLAIN_EMBED(gpswidget));
1679
1867687f2fcb libchamplain compatibility fix
nadvornik
parents: 1667
diff changeset
711 #else
1867687f2fcb libchamplain compatibility fix
nadvornik
parents: 1667
diff changeset
712 view = champlain_view_new();
1733
b52deba688e9 Fix up compilation issues related to libchamplain.
zas_
parents: 1708
diff changeset
713 gpswidget = champlain_view_embed_new(view);
1679
1867687f2fcb libchamplain compatibility fix
nadvornik
parents: 1667
diff changeset
714 #endif
1604
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
715 viewport = gtk_viewport_new(NULL, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
716
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
717 gtk_container_add(GTK_CONTAINER(viewport), gpswidget);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
718 gtk_box_pack_start(GTK_BOX(vbox),viewport, TRUE, TRUE, 0);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
719 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled), vbox);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
720
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
721 status = gtk_hbox_new(FALSE,0);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
722 slider = gtk_scale_button_new(GTK_ICON_SIZE_SMALL_TOOLBAR, 1, 17, 1, slider_icons);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
723 gtk_widget_set_tooltip_text(slider, "Zoom");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
724 gtk_scale_button_set_value(GTK_SCALE_BUTTON(slider), (gdouble)zoom);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
725
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
726 progress = gtk_progress_bar_new();
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
727 state = gtk_label_new("");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
728 gtk_label_set_justify(GTK_LABEL(state), GTK_JUSTIFY_CENTER);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
729
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
730 gtk_box_pack_start(GTK_BOX(status), GTK_WIDGET(slider), FALSE, FALSE, 0);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
731 gtk_box_pack_start(GTK_BOX(status), GTK_WIDGET(state), FALSE, FALSE, 5);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
732 gtk_box_pack_end(GTK_BOX(status), GTK_WIDGET(progress), FALSE, FALSE, 0);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
733 gtk_box_pack_end(GTK_BOX(vbox),GTK_WIDGET(status), FALSE, FALSE, 0);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
734
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
735 layer = champlain_layer_new();
1733
b52deba688e9 Fix up compilation issues related to libchamplain.
zas_
parents: 1708
diff changeset
736 champlain_view_add_layer(view, layer);
1604
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
737
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
738 pgd->icon_layer = layer;
1733
b52deba688e9 Fix up compilation issues related to libchamplain.
zas_
parents: 1708
diff changeset
739 pgd->gps_view = CLUTTER_ACTOR(view);
1604
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
740 pgd->widget = scrolled;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
741 pgd->progress = progress;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
742 pgd->slider = slider;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
743 pgd->state = state;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
744
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
745 bar_pane_gps_set_map_source(pgd, map_id);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
746
1733
b52deba688e9 Fix up compilation issues related to libchamplain.
zas_
parents: 1708
diff changeset
747 g_object_set(G_OBJECT(view), "scroll-mode", CHAMPLAIN_SCROLL_MODE_KINETIC,
b52deba688e9 Fix up compilation issues related to libchamplain.
zas_
parents: 1708
diff changeset
748 "zoom-level", zoom,
b52deba688e9 Fix up compilation issues related to libchamplain.
zas_
parents: 1708
diff changeset
749 "keep-center-on-resize", TRUE,
b52deba688e9 Fix up compilation issues related to libchamplain.
zas_
parents: 1708
diff changeset
750 "decel-rate", 1.0,
b52deba688e9 Fix up compilation issues related to libchamplain.
zas_
parents: 1708
diff changeset
751 "show-license", TRUE,
b52deba688e9 Fix up compilation issues related to libchamplain.
zas_
parents: 1708
diff changeset
752 "zoom-on-double-click", FALSE,
b52deba688e9 Fix up compilation issues related to libchamplain.
zas_
parents: 1708
diff changeset
753 "max-zoom-level", 17,
b52deba688e9 Fix up compilation issues related to libchamplain.
zas_
parents: 1708
diff changeset
754 "min-zoom-level", 1,
b52deba688e9 Fix up compilation issues related to libchamplain.
zas_
parents: 1708
diff changeset
755 NULL);
b52deba688e9 Fix up compilation issues related to libchamplain.
zas_
parents: 1708
diff changeset
756 champlain_view_center_on(view, latitude, longitude);
1604
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
757 pgd->centre_map_checked = TRUE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
758 g_object_set_data(G_OBJECT(pgd->widget), "pane_data", pgd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
759 g_signal_connect(G_OBJECT(pgd->widget), "destroy", G_CALLBACK(bar_pane_gps_destroy), pgd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
760
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
761 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
762 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
763
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
764 gtk_widget_set_size_request(pgd->widget, -1, height);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
765
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
766 clutter_set_motion_events_enabled(TRUE);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
767 g_signal_connect(G_OBJECT(vbox), "button_press_event", G_CALLBACK(bar_pane_gps_map_keypress_cb), pgd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
768 g_signal_connect(pgd->gps_view, "notify::state", G_CALLBACK(bar_pane_gps_view_state_changed_cb), pgd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
769 g_signal_connect(pgd->gps_view, "notify::zoom-level", G_CALLBACK(bar_pane_gps_view_state_changed_cb), pgd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
770 g_signal_connect(G_OBJECT(slider), "value-changed", G_CALLBACK(bar_pane_gps_slider_changed_cb), pgd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
771
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
772 file_data_register_notify_func(bar_pane_gps_notify_cb, pgd, NOTIFY_PRIORITY_LOW);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
773
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
774 pgd->create_markers_id = 0;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
775 pgd->enable_markers_checked = TRUE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
776 pgd->centre_map_checked = TRUE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
777
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
778 return pgd->widget;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
779 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
780
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
781 GtkWidget *bar_pane_gps_new_from_config(const gchar **attribute_names, const gchar **attribute_values)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
782 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
783 gchar *title = g_strdup(_("GPS Map"));
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
784 gchar *map_id = NULL;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
785 gboolean expanded = TRUE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
786 gint height = 350;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
787 gint zoom = 7;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
788 gdouble latitude;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
789 gdouble longitude;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
790 /* Latitude and longitude are stored in the config file as an integer of
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
791 * (actual value * 1,000,000). There is no READ_DOUBLE utilty function.
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
792 */
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
793 gint int_latitude = 54000000;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
794 gint int_longitude = -4000000;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
795 gchar *id = g_strdup("gps");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
796 GtkWidget *ret;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
797
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
798 while (*attribute_names)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
799 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
800 const gchar *option = *attribute_names++;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
801 const gchar *value = *attribute_values++;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
802
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
803 if (READ_CHAR_FULL("title", title))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
804 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
805 if (READ_CHAR_FULL("map-id", map_id))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
806 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
807 /* There is a bug in the libchamplain libraries which prevents correct
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
808 * initialisation if the zoom level starts higher than 8
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
809 */
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
810 if (READ_INT_CLAMP_FULL("zoom-level", zoom, 1, 8))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
811 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
812 if (READ_INT_CLAMP_FULL("latitude", int_latitude, -90000000, +90000000))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
813 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
814 if (READ_INT_CLAMP_FULL("longitude", int_longitude, -90000000, +90000000))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
815 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
816 if (READ_BOOL_FULL("expanded", expanded))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
817 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
818 if (READ_INT_FULL("height", height))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
819 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
820 if (READ_CHAR_FULL("id", id))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
821 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
822
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
823 log_printf("unknown attribute %s = %s\n", option, value);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
824 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
825
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
826 bar_pane_translate_title(PANE_COMMENT, id, &title);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
827 latitude = int_latitude / 1000000;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
828 longitude = int_longitude / 1000000;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
829 ret = bar_pane_gps_new(id, title, map_id, zoom, latitude, longitude, expanded, height);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
830 g_free(title);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
831 g_free(map_id);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
832 g_free(id);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
833 return ret;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
834 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
835
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
836 void bar_pane_gps_update_from_config(GtkWidget *pane, const gchar **attribute_names,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
837 const gchar **attribute_values)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
838 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
839 PaneGPSData *pgd;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
840 gint zoom;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
841 gint int_longitude, int_latitude;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
842 gdouble longitude, latitude;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
843
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
844 pgd = g_object_get_data(G_OBJECT(pane), "pane_data");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
845 if (!pgd)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
846 return;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
847
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
848 gchar *title = NULL;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
849
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
850 while (*attribute_names)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
851 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
852 const gchar *option = *attribute_names++;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
853 const gchar *value = *attribute_values++;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
854
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
855 if (READ_CHAR_FULL("title", title))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
856 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
857 if (READ_CHAR_FULL("map-id", pgd->map_source))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
858 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
859 if (READ_BOOL_FULL("expanded", pgd->pane.expanded))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
860 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
861 if (READ_INT_FULL("height", pgd->height))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
862 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
863 if (READ_CHAR_FULL("id", pgd->pane.id))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
864 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
865 if (READ_INT_CLAMP_FULL("zoom-level", zoom, 1, 8))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
866 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
867 g_object_set(G_OBJECT(CHAMPLAIN_VIEW(pgd->gps_view)), "zoom-level", zoom, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
868 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
869 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
870 if (READ_INT_CLAMP_FULL("longitude", int_longitude, -90000000, +90000000))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
871 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
872 longitude = int_longitude / 1000000;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
873 g_object_set(G_OBJECT(CHAMPLAIN_VIEW(pgd->gps_view)), "longitude", longitude, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
874 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
875 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
876 if (READ_INT_CLAMP_FULL("latitude", int_latitude, -90000000, +90000000))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
877 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
878 latitude = int_latitude / 1000000;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
879 g_object_set(G_OBJECT(CHAMPLAIN_VIEW(pgd->gps_view)), "latitude", latitude, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
880 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
881 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
882 log_printf("unknown attribute %s = %s\n", option, value);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
883 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
884
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
885 if (title)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
886 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
887 bar_pane_translate_title(PANE_COMMENT, pgd->pane.id, &title);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
888 gtk_label_set_text(GTK_LABEL(pgd->pane.title), title);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
889 g_free(title);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
890 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
891
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
892 gtk_widget_set_size_request(pgd->widget, -1, pgd->height);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
893 bar_update_expander(pane);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
894 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
895
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
896 #endif
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
897 #endif
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
898
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
899 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */