annotate src/bar_gps.c @ 1672:831c79e50d34

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