annotate src/bar_gps.c @ 1604:c6d522fe3e5e

added GPS map support - patch by Colin Clark
author nadvornik
date Tue, 12 May 2009 18:25:18 +0000
parents
children 0806ccdfe06b
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);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
230 if (fd != NULL)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
231 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
232 latitude = metadata_read_GPS_coord(fd, "Xmp.exif.GPSLatitude", 1000);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
233 longitude = metadata_read_GPS_coord(fd, "Xmp.exif.GPSLongitude", 1000);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
234
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
235 if ((latitude != 1000) && (longitude != 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 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
238
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
239 champlain_base_marker_set_position(CHAMPLAIN_BASE_MARKER(marker), latitude, longitude);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
240 clutter_container_add(CLUTTER_CONTAINER(pgd->icon_layer), marker, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
241 clutter_actor_set_reactive(marker, TRUE);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
242
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
243 g_signal_connect(G_OBJECT(marker), "button_press_event",
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
244 G_CALLBACK(bar_pane_gps_marker_keypress_cb), pgd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
245
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
246 g_object_set_data(G_OBJECT(marker), "file_fd", fd);
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_ptr_array_add(pgd->marker_list, marker);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
249 if (pgd->centre_map_checked)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
250 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
251 g_ptr_array_add(pgd->marker_list, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
252 champlain_view_ensure_markers_visible(CHAMPLAIN_VIEW(pgd->gps_view),
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
253 (void *)pgd->marker_list->pdata, FALSE);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
254 g_ptr_array_remove(pgd->marker_list, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
255 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
256 }
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 return TRUE;
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
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
261 if (pgd->marker_list->len >= 1)
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 g_ptr_array_add(pgd->marker_list, NULL);
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 if (pgd->centre_map_checked)
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 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
268 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
269 }
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 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(pgd->progress), 0);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
272 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(pgd->progress), NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
273 g_list_free(pgd->selection_list);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
274 g_ptr_array_free(pgd->marker_list, TRUE);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
275 pgd->create_markers_id = 0;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
276
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
277 return FALSE;
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
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
280 static void bar_pane_gps_update(PaneGPSData *pgd)
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 GList *list;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
283 GList *work;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
284
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
285 /* 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
286 * "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
287 * 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
288 */
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
289 if (gtk_widget_get_parent(pgd->widget) != NULL)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
290 gtk_widget_show_all(pgd->widget);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
291
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
292 /* If a create-marker background process is running, kill it
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
293 * and start again
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
294 */
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
295 if (pgd->create_markers_id != 0)
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 (g_idle_remove_by_data(pgd))
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 pgd->create_markers_id = 0;
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 else
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 return;
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 }
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 /* Delete any markers currently displayed
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 work = clutter_container_get_children(CLUTTER_CONTAINER(pgd->icon_layer));
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
310 while (work)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
311 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
312 clutter_container_remove(CLUTTER_CONTAINER(pgd->icon_layer), work->data, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
313 work = work->next;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
314 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
315 g_list_free(work);
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 if (!pgd->enable_markers_checked)
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 return;
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
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
322 /* 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
323 * 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
324 * 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
325 */
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
326 list = layout_selection_list(pgd->pane.lw);
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 if (list != NULL)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
329 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
330 pgd->selection_list = g_list_copy(list);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
331 pgd->marker_list = g_ptr_array_new();
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
332 pgd->selection_count = g_list_length(pgd->selection_list);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
333 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
334 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
335
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
336 g_list_free(list);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
337 g_list_free(work);
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
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
340 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
341 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
342 ChamplainMapSource *map_source;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
343 ChamplainMapSourceFactory *map_factory;
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 map_factory = champlain_map_source_factory_get_default();
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
346 map_source = champlain_map_source_factory_create(map_factory, map_id);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
347
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
348 if (map_source != NULL)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
349 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
350 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
351 g_object_unref(map_factory);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
352 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
353
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
354 g_object_unref(map_source);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
355 }
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 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
358 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
359 PaneGPSData *pgd = data;
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 if (pgd->enable_markers_checked)
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 pgd->enable_markers_checked = FALSE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
364 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
365 else
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
366 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
367 pgd->enable_markers_checked = TRUE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
368 }
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
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
371 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
372 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
373 PaneGPSData *pgd = data;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
374
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
375 if (pgd->centre_map_checked)
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 pgd->centre_map_checked = FALSE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
378 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
379 else
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
380 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
381 pgd->centre_map_checked = TRUE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
382 }
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
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
385 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
386 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
387 PaneGPSData *pgd;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
388 gchar *mapsource;
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 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
391 return;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
392
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
393 pgd = (PaneGPSData *) submenu_item_get_data(widget);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
394
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
395 if (!pgd) return;
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 mapsource = data;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
398 bar_pane_gps_set_map_source(pgd, mapsource);
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
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
401 static void bar_pane_gps_notify_selection(GtkWidget *bar, gint count)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
402 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
403 PaneGPSData *pgd;
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 if (count == 0) return;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
406
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
407 pgd = g_object_get_data(G_OBJECT(bar), "pane_data");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
408 if (!pgd) return;
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 bar_pane_gps_update(pgd);
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
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
413 static void bar_pane_gps_set_fd(GtkWidget *bar, FileData *fd)
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 PaneGPSData *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 pgd = g_object_get_data(G_OBJECT(bar), "pane_data");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
418 if (!pgd) return;
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 file_data_unref(pgd->fd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
421 pgd->fd = file_data_ref(fd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
422
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
423 bar_pane_gps_update(pgd);
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
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
426 static gint bar_pane_gps_event(GtkWidget *bar, GdkEvent *event)
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 PaneGPSData *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 pgd = g_object_get_data(G_OBJECT(bar), "pane_data");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
431 if (!pgd) return FALSE;
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 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
434
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
435 return FALSE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
436 }
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 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
439 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
440 PaneGPSData *pgd;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
441 gint zoom;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
442 ChamplainMapSource *mapsource;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
443 const gchar *map_id;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
444 gchar *str = NULL;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
445 GString *buffer = g_string_new(str);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
446 gdouble position;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
447 gint int_position;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
448
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
449 pgd = g_object_get_data(G_OBJECT(pane), "pane_data");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
450 if (!pgd) return;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
451
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
452 WRITE_NL();
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
453 WRITE_STRING("<pane_gps ");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
454 write_char_option(outstr, indent, "id", pgd->pane.id);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
455 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
456 WRITE_BOOL(pgd->pane, expanded);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
457 WRITE_INT(*pgd, height);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
458 indent++;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
459
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
460 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
461 map_id = champlain_map_source_get_id(mapsource);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
462 WRITE_NL();
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
463 write_char_option(outstr, indent, "map-id", map_id);
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), "zoom-level", &zoom, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
466 g_string_printf(buffer, "%d", zoom);
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, "zoom-level", buffer->str);
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), "latitude", &position, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
471 int_position = position * 1000000;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
472 g_string_printf(buffer, "%i", int_position);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
473 WRITE_NL();
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
474 write_char_option(outstr, indent, "latitude", buffer->str);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
475
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
476 g_object_get(G_OBJECT(pgd->gps_view), "longitude", &position, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
477 int_position = position * 1000000;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
478 g_string_printf(buffer, "%i", int_position);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
479 WRITE_NL();
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
480 write_char_option(outstr, indent, "longitude", buffer->str);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
481
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
482 indent--;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
483 WRITE_NL();
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
484 WRITE_STRING("/>");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
485
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
486 g_object_unref(mapsource);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
487
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
488 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
489
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
490 static void bar_pane_gps_slider_changed_cb(GtkScaleButton *slider,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
491 gdouble zoom,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
492 gpointer data)
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 PaneGPSData *pgd = data;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
495 GString *message;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
496
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
497 message = g_string_new("");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
498 g_string_printf(message, _("Zoom %i"), (gint)zoom);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
499
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
500 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
501 gtk_widget_set_tooltip_text(GTK_WIDGET(slider), message->str);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
502 g_string_free(message, TRUE);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
503
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 static void bar_pane_gps_view_state_changed_cb(ChamplainView *view,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
506 GParamSpec *gobject,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
507 gpointer data)
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 PaneGPSData *pgd = data;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
510 ChamplainState status;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
511 gint zoom;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
512 GString *message;
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 g_object_get(G_OBJECT(view), "zoom-level", &zoom, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
515 message = g_string_new("");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
516 g_string_printf(message, _("Zoom level %i"), zoom);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
517
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
518 g_object_get(G_OBJECT(view), "state", &status, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
519 if (status == CHAMPLAIN_STATE_LOADING)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
520 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
521 gtk_label_set_text(GTK_LABEL(pgd->state), _("Loading map"));
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 else
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
524 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
525 gtk_label_set_text(GTK_LABEL(pgd->state), message->str);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
526 }
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 gtk_widget_set_tooltip_text(GTK_WIDGET(pgd->slider), message->str);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
529 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
530
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
531 g_string_free(message, TRUE);
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
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
534 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
535 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
536 PaneGPSData *pgd = data;
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 if ((type & (NOTIFY_REREAD | NOTIFY_CHANGE | NOTIFY_METADATA)) && fd == pgd->fd)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
539 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
540 bar_pane_gps_update(pgd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
541 }
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
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
544 const gchar *bar_pane_gps_get_map_id(PaneGPSData *pgd)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
545 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
546 const gchar *map_id;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
547 ChamplainMapSource *mapsource;
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 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
550 map_id = champlain_map_source_get_id(mapsource);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
551
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
552 g_object_unref(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 return map_id;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
555 }
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 static GtkWidget *bar_pane_gps_add_radio(GtkWidget *menu, GtkWidget *parent,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
558 const gchar *label, GCallback func, gchar *value,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
559 gboolean show_current, const gchar *current_value)
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 GtkWidget *item;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
562
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
563 if (show_current)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
564 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
565 item = menu_item_add_radio(menu, parent,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
566 label, (g_strcmp0(value, current_value) == 0), func, value);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
567 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
568 else
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
569 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
570 item = menu_item_add(menu, label, func, value);
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
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
573 return item;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
574 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
575
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
576 static GtkWidget *bar_pane_gps_menu(PaneGPSData *pgd)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
577 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
578 GtkWidget *menu;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
579 GtkWidget *map_centre;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
580 static gboolean show_current = TRUE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
581 GtkWidget *parent;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
582 ChamplainMapSourceFactory *map_factory;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
583 GSList *map_list;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
584 ChamplainMapSourceDesc *map_desc;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
585
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
586 menu = popup_menu_short_lived();
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
587
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
588 map_factory = champlain_map_source_factory_get_default();
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
589 map_list = champlain_map_source_factory_get_list(map_factory);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
590 map_desc = (ChamplainMapSourceDesc *)(map_list->data);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
591 map_list = g_slist_next(map_list);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
592
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
593 g_object_set_data(G_OBJECT(menu), "submenu_data", pgd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
594
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
595 parent = bar_pane_gps_add_radio(menu, NULL, (map_desc->name), G_CALLBACK(bar_pane_gps_change_map_cb), map_desc->id, show_current, bar_pane_gps_get_map_id(pgd));
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
596
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
597 while (map_list)
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 map_desc = (ChamplainMapSourceDesc *)(map_list->data);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
600 bar_pane_gps_add_radio(menu, parent, (map_desc->name), G_CALLBACK(bar_pane_gps_change_map_cb), map_desc->id,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
601 show_current, bar_pane_gps_get_map_id(pgd));
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
602 map_list = g_slist_next(map_list);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
603 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
604
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
605 menu_item_add_divider(menu);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
606 menu_item_add_check(menu, _("Enable markers"), pgd->enable_markers_checked,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
607 G_CALLBACK(bar_pane_gps_enable_markers_checked_toggle_cb), pgd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
608 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
609 G_CALLBACK(bar_pane_gps_centre_map_checked_toggle_cb), pgd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
610 if (!pgd->enable_markers_checked)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
611 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
612 gtk_widget_set_sensitive(map_centre, FALSE);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
613 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
614
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
615 g_slist_free(map_list);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
616 g_object_unref(map_factory);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
617 //g_object_unref(map_centre);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
618
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
619 return menu;
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
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
622 /* 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
623 */
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
624 void bar_pane_gps_map_centreing(PaneGPSData *pgd)
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 GtkWidget *dialog;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
627 GString *message = g_string_new("");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
628
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
629 if (pgd->centre_map_checked)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
630 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
631 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
632 pgd->centre_map_checked = FALSE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
633 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
634 else
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 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
637 pgd->centre_map_checked = 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 dialog = gtk_message_dialog_new(NULL,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
641 GTK_DIALOG_DESTROY_WITH_PARENT,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
642 GTK_MESSAGE_INFO,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
643 GTK_BUTTONS_CLOSE,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
644 "%s", message->str);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
645 gtk_window_set_title(GTK_WINDOW(dialog), _("Map Centreing"));
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
646 gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
647 gtk_dialog_run(GTK_DIALOG(dialog));
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
648
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
649 gtk_widget_destroy(dialog);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
650 g_string_free(message, TRUE);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
651 }
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 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
654 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
655 PaneGPSData *pgd = data;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
656 GtkWidget *menu;
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 if (bevent->button == MOUSE_BUTTON_RIGHT)
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 menu = bar_pane_gps_menu(pgd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
661 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
662 return TRUE;
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 else if (bevent->button == MOUSE_BUTTON_MIDDLE)
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 bar_pane_gps_map_centreing(pgd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
667 return TRUE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
668 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
669 else if (bevent->button == MOUSE_BUTTON_LEFT)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
670 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
671 return FALSE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
672 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
673 else
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
674 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
675 return FALSE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
676 }
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 static void bar_pane_gps_destroy(GtkWidget *widget, gpointer data)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
680 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
681 PaneGPSData *pgd = data;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
682
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
683 file_data_unregister_notify_func(bar_pane_gps_notify_cb, pgd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
684
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
685 file_data_unref(pgd->fd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
686 g_free(pgd->map_source);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
687 g_free(pgd->pane.id);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
688 clutter_actor_destroy(pgd->gps_view);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
689 g_free(pgd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
690 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
691
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 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
694 const gint zoom, const gdouble latitude, const gdouble longitude,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
695 gboolean expanded, gint height)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
696 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
697 PaneGPSData *pgd;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
698 GtkWidget *vbox, *scrolled;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
699 GtkWidget *gpswidget, *viewport;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
700 GtkWidget *status, *state, *progress, *slider;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
701 ChamplainLayer *layer;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
702 ClutterActor *view;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
703 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
704 const gchar **slider_icons = slider_list;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
705
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
706 pgd = g_new0(PaneGPSData, 1);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
707
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
708 pgd->pane.pane_set_fd = bar_pane_gps_set_fd;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
709 pgd->pane.pane_notify_selection = bar_pane_gps_notify_selection;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
710 pgd->pane.pane_event = bar_pane_gps_event;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
711 pgd->pane.pane_write_config = bar_pane_gps_write_config;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
712 pgd->pane.title = bar_pane_expander_title(title);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
713 pgd->pane.id = g_strdup(id);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
714 pgd->pane.type = PANE_GPS;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
715 pgd->pane.expanded = expanded;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
716 pgd->height = height;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
717
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
718 scrolled = gtk_scrolled_window_new(NULL, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
719 vbox = gtk_vbox_new(FALSE, 0);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
720 view = champlain_view_new();
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
721 gpswidget = champlain_view_embed_new(CHAMPLAIN_VIEW(view));
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
722 viewport = gtk_viewport_new(NULL, NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
723
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
724 gtk_container_add(GTK_CONTAINER(viewport), gpswidget);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
725 gtk_box_pack_start(GTK_BOX(vbox),viewport, TRUE, TRUE, 0);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
726 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled), vbox);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
727
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
728 status = gtk_hbox_new(FALSE,0);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
729 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
730 gtk_widget_set_tooltip_text(slider, "Zoom");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
731 gtk_scale_button_set_value(GTK_SCALE_BUTTON(slider), (gdouble)zoom);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
732
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
733 progress = gtk_progress_bar_new();
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
734 state = gtk_label_new("");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
735 gtk_label_set_justify(GTK_LABEL(state), GTK_JUSTIFY_CENTER);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
736
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
737 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
738 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
739 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
740 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
741
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
742 layer = champlain_layer_new();
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
743 champlain_view_add_layer(CHAMPLAIN_VIEW(view), layer);
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 pgd->icon_layer = layer;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
746 pgd->gps_view = view;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
747 pgd->widget = scrolled;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
748 pgd->progress = progress;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
749 pgd->slider = slider;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
750 pgd->state = state;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
751
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
752 bar_pane_gps_set_map_source(pgd, map_id);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
753
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
754 g_object_set(G_OBJECT(CHAMPLAIN_VIEW(view)), "scroll-mode", CHAMPLAIN_SCROLL_MODE_KINETIC,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
755 "zoom-level", zoom,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
756 "keep-center-on-resize", TRUE,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
757 "decel-rate", 1.0,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
758 "show-license", TRUE,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
759 "zoom-on-double-click", FALSE,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
760 "max-zoom-level", 17,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
761 "min-zoom-level", 1,
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
762 NULL);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
763 champlain_view_center_on(CHAMPLAIN_VIEW(view), latitude, longitude);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
764 pgd->centre_map_checked = TRUE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
765 g_object_set_data(G_OBJECT(pgd->widget), "pane_data", pgd);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
766 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
767
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
768 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
769 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
770
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
771 gtk_widget_set_size_request(pgd->widget, -1, height);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
772
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
773 clutter_set_motion_events_enabled(TRUE);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
774 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
775 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
776 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
777 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
778
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
779 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
780
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
781 pgd->create_markers_id = 0;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
782 pgd->enable_markers_checked = TRUE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
783 pgd->centre_map_checked = TRUE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
784
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
785 return pgd->widget;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
786 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
787
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
788 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
789 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
790 gchar *title = g_strdup(_("GPS Map"));
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
791 gchar *map_id = NULL;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
792 gboolean expanded = TRUE;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
793 gint height = 350;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
794 gint zoom = 7;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
795 gdouble latitude;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
796 gdouble longitude;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
797 /* 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
798 * (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
799 */
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
800 gint int_latitude = 54000000;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
801 gint int_longitude = -4000000;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
802 gchar *id = g_strdup("gps");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
803 GtkWidget *ret;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
804
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
805 while (*attribute_names)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
806 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
807 const gchar *option = *attribute_names++;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
808 const gchar *value = *attribute_values++;
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_CHAR_FULL("title", title))
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_CHAR_FULL("map-id", map_id))
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 /* There is a bug in the libchamplain libraries which prevents correct
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
815 * initialisation if the zoom level starts higher than 8
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
816 */
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
817 if (READ_INT_CLAMP_FULL("zoom-level", zoom, 1, 8))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
818 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
819 if (READ_INT_CLAMP_FULL("latitude", int_latitude, -90000000, +90000000))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
820 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
821 if (READ_INT_CLAMP_FULL("longitude", int_longitude, -90000000, +90000000))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
822 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
823 if (READ_BOOL_FULL("expanded", expanded))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
824 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
825 if (READ_INT_FULL("height", height))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
826 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
827 if (READ_CHAR_FULL("id", id))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
828 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
829
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
830 log_printf("unknown attribute %s = %s\n", option, value);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
831 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
832
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
833 bar_pane_translate_title(PANE_COMMENT, id, &title);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
834 latitude = int_latitude / 1000000;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
835 longitude = int_longitude / 1000000;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
836 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
837 g_free(title);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
838 g_free(map_id);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
839 g_free(id);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
840 return ret;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
841 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
842
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
843 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
844 const gchar **attribute_values)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
845 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
846 PaneGPSData *pgd;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
847 gint zoom;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
848 gint int_longitude, int_latitude;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
849 gdouble longitude, latitude;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
850
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
851 pgd = g_object_get_data(G_OBJECT(pane), "pane_data");
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
852 if (!pgd)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
853 return;
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 gchar *title = NULL;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
856
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
857 while (*attribute_names)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
858 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
859 const gchar *option = *attribute_names++;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
860 const gchar *value = *attribute_values++;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
861
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
862 if (READ_CHAR_FULL("title", title))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
863 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
864 if (READ_CHAR_FULL("map-id", pgd->map_source))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
865 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
866 if (READ_BOOL_FULL("expanded", pgd->pane.expanded))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
867 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
868 if (READ_INT_FULL("height", pgd->height))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
869 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
870 if (READ_CHAR_FULL("id", pgd->pane.id))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
871 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
872 if (READ_INT_CLAMP_FULL("zoom-level", zoom, 1, 8))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
873 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
874 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
875 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
876 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
877 if (READ_INT_CLAMP_FULL("longitude", int_longitude, -90000000, +90000000))
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
878 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
879 longitude = int_longitude / 1000000;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
880 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
881 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
882 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
883 if (READ_INT_CLAMP_FULL("latitude", int_latitude, -90000000, +90000000))
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 latitude = int_latitude / 1000000;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
886 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
887 continue;
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
888 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
889 log_printf("unknown attribute %s = %s\n", option, value);
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 if (title)
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
893 {
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
894 bar_pane_translate_title(PANE_COMMENT, pgd->pane.id, &title);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
895 gtk_label_set_text(GTK_LABEL(pgd->pane.title), title);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
896 g_free(title);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
897 }
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 gtk_widget_set_size_request(pgd->widget, -1, pgd->height);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
900 bar_update_expander(pane);
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
901 }
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
902
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
903 #endif
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
904 #endif
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
905
c6d522fe3e5e added GPS map support - patch by Colin Clark
nadvornik
parents:
diff changeset
906 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */