45 |
static const char *get_proxy_uri(appdata_t *appdata) { |
static const char *get_proxy_uri(appdata_t *appdata) { |
46 |
static char proxy_buffer[64] = ""; |
static char proxy_buffer[64] = ""; |
47 |
|
|
48 |
|
printf("get_proxy_uri in\n"); |
49 |
|
|
50 |
/* use environment settings if preset */ |
/* use environment settings if preset */ |
51 |
const char *proxy = g_getenv("http_proxy"); |
const char *proxy = g_getenv("http_proxy"); |
52 |
if(proxy) { |
if(proxy) { |
77 |
return proxy_buffer; |
return proxy_buffer; |
78 |
} |
} |
79 |
|
|
80 |
|
printf("get_proxy_uri out\n"); |
81 |
return NULL; |
return NULL; |
82 |
} |
} |
83 |
|
|
84 |
static void |
static void |
85 |
cb_map_gps(osd_button_t but, map_context_t *context) { |
cb_map_gps(osd_button_t but, map_context_t *context) { |
86 |
|
printf("cb_map_gps in\n"); |
87 |
|
|
88 |
if(but == OSD_GPS) { |
if(but == OSD_GPS) { |
89 |
pos_t *refpos = get_pos(context->appdata); |
pos_t *refpos = get_pos(context->appdata); |
90 |
if(refpos && !isnan(refpos->lat) && !isnan(refpos->lon)) { |
if(refpos && !isnan(refpos->lat) && !isnan(refpos->lon)) { |
105 |
0.0, 0.0, 1); |
0.0, 0.0, 1); |
106 |
} |
} |
107 |
} |
} |
108 |
|
printf("cb_map_gps out\n"); |
109 |
} |
} |
110 |
|
|
111 |
static int dist2pixel(map_context_t *context, float km, float lat) { |
static int dist2pixel(map_context_t *context, float km, float lat) { |
115 |
static gboolean map_gps_update(gpointer data) { |
static gboolean map_gps_update(gpointer data) { |
116 |
map_context_t *context = (map_context_t*)data; |
map_context_t *context = (map_context_t*)data; |
117 |
|
|
118 |
|
printf("map_gps_update in\n"); |
119 |
|
|
120 |
/* get reference position ... */ |
/* get reference position ... */ |
121 |
pos_t *refpos = get_pos(context->appdata); |
pos_t *refpos = get_pos(context->appdata); |
122 |
gboolean ok = (refpos!= NULL) && !isnan(refpos->lat) && !isnan(refpos->lon); |
gboolean ok = (refpos!= NULL) && !isnan(refpos->lat) && !isnan(refpos->lon); |
144 |
} else |
} else |
145 |
osm_gps_map_clear_gps(OSM_GPS_MAP(context->widget)); |
osm_gps_map_clear_gps(OSM_GPS_MAP(context->widget)); |
146 |
|
|
147 |
|
printf("map_gps_update out\n"); |
148 |
return TRUE; |
return TRUE; |
149 |
} |
} |
150 |
|
|
151 |
|
static void map_draw_cache(GtkWidget *map, cache_t *cache) { |
152 |
|
printf("map_draw_cache in\n"); |
153 |
|
|
154 |
|
GdkPixbuf *icon = icon_get(ICON_CACHE_TYPE, cache->type); |
155 |
|
|
156 |
|
/* check if there's also an overwritten coordinate */ |
157 |
|
if(cache->notes && cache->notes->override) { |
158 |
|
GdkPixbuf *over = icon_get(ICON_MISC, 1); |
159 |
|
|
160 |
|
osm_gps_map_add_image(OSM_GPS_MAP(map), |
161 |
|
cache->notes->pos.lat, cache->notes->pos.lon, icon); |
162 |
|
|
163 |
|
osm_gps_map_add_image(OSM_GPS_MAP(map), |
164 |
|
cache->notes->pos.lat, cache->notes->pos.lon, over); |
165 |
|
} else { |
166 |
|
if(!isnan(cache->pos.lat) && !isnan(cache->pos.lon)) |
167 |
|
osm_gps_map_add_image(OSM_GPS_MAP(map), |
168 |
|
cache->pos.lat, cache->pos.lon, icon); |
169 |
|
} |
170 |
|
printf("map_draw_cache out\n"); |
171 |
|
} |
172 |
|
|
173 |
|
static void map_draw_gpx(appdata_t *appdata, GtkWidget *map, gpx_t *gpx) { |
174 |
|
printf("map_draw_gpx in\n"); |
175 |
|
|
176 |
|
if(!gpx->notes_loaded) { |
177 |
|
notes_load_all(appdata, gpx); |
178 |
|
gpx->notes_loaded = TRUE; |
179 |
|
} |
180 |
|
|
181 |
|
cache_t *cache = gpx->cache; |
182 |
|
while(cache) { |
183 |
|
map_draw_cache(map, cache); |
184 |
|
cache = cache->next; |
185 |
|
} |
186 |
|
printf("map_draw_gpx out\n"); |
187 |
|
} |
188 |
|
|
189 |
|
/* draw geocaches and set window title */ |
190 |
|
static void map_setup(map_context_t *context) { |
191 |
|
char *name = NULL; |
192 |
|
|
193 |
|
printf("map_setup in\n"); |
194 |
|
|
195 |
|
if(!context->appdata->cur_gpx && !context->appdata->cur_cache) { |
196 |
|
if(context->state != MAP_ALL) { |
197 |
|
printf("map_setup(ALL)\n"); |
198 |
|
|
199 |
|
#ifdef OSD_NAV |
200 |
|
/* no navigation in this mode */ |
201 |
|
osm_gps_map_osd_clear_nav (OSM_GPS_MAP(context->widget)); |
202 |
|
#endif |
203 |
|
|
204 |
|
/* clear all existing ccahe images */ |
205 |
|
osm_gps_map_clear_images (OSM_GPS_MAP(context->widget)); |
206 |
|
|
207 |
|
/* draw all geocaches */ |
208 |
|
gpx_t *gpx = context->appdata->gpx; |
209 |
|
while(gpx) { |
210 |
|
map_draw_gpx(context->appdata, context->widget, gpx); |
211 |
|
gpx = gpx->next; |
212 |
|
} |
213 |
|
name = g_strdup(_("all")); |
214 |
|
context->state = MAP_ALL; |
215 |
|
} |
216 |
|
} else if(!context->appdata->cur_cache) { |
217 |
|
if(context->state != MAP_GPX) { |
218 |
|
printf("map_setup(GPX)\n"); |
219 |
|
|
220 |
|
#ifdef OSD_NAV |
221 |
|
/* no navigation in this mode */ |
222 |
|
osm_gps_map_osd_clear_nav (OSM_GPS_MAP(context->widget)); |
223 |
|
#endif |
224 |
|
|
225 |
|
/* clear all existing ccahe images */ |
226 |
|
osm_gps_map_clear_images (OSM_GPS_MAP(context->widget)); |
227 |
|
|
228 |
|
map_draw_gpx(context->appdata, context->widget, |
229 |
|
context->appdata->cur_gpx); |
230 |
|
name = g_strdup(context->appdata->cur_gpx->name); |
231 |
|
context->state = MAP_GPX; |
232 |
|
} |
233 |
|
} else { |
234 |
|
cache_t *cache = context->appdata->cur_cache; |
235 |
|
|
236 |
|
printf("map_setp(CACHE)\n"); |
237 |
|
|
238 |
|
/* no balloons in this mode */ |
239 |
|
context->balloon = NULL; |
240 |
|
osm_gps_map_osd_clear_balloon (OSM_GPS_MAP(context->widget)); |
241 |
|
|
242 |
|
/* clear all existing ccahe images */ |
243 |
|
osm_gps_map_clear_images (OSM_GPS_MAP(context->widget)); |
244 |
|
|
245 |
|
map_draw_cache(context->widget, cache); |
246 |
|
name = g_strdup(cache->name); |
247 |
|
context->state = MAP_CACHE; |
248 |
|
|
249 |
|
/* navigation in this mode! */ |
250 |
|
pos_t cpos = gpx_cache_pos(cache); |
251 |
|
|
252 |
|
#ifdef OSD_NAV |
253 |
|
osm_gps_map_osd_draw_nav (OSM_GPS_MAP(context->widget), |
254 |
|
context->appdata->imperial, |
255 |
|
cpos.lat, cpos.lon, cache->name); |
256 |
|
#else |
257 |
|
#warning OSD_NAV not defined! |
258 |
|
#endif |
259 |
|
} |
260 |
|
|
261 |
|
if(name) { |
262 |
|
char *title = g_strdup_printf(_("Map - %s"), name); |
263 |
|
g_free(name); |
264 |
|
|
265 |
|
gtk_window_set_title(GTK_WINDOW(context->window), title); |
266 |
|
|
267 |
|
g_free(title); |
268 |
|
} else |
269 |
|
printf("map_setup(keep)\n"); |
270 |
|
|
271 |
|
printf("map_setup out\n"); |
272 |
|
} |
273 |
|
|
274 |
static gboolean on_map_configure(GtkWidget *widget, |
static gboolean on_map_configure(GtkWidget *widget, |
275 |
GdkEventConfigure *event, |
GdkEventConfigure *event, |
276 |
map_context_t *context) { |
map_context_t *context) { |
277 |
|
|
278 |
if(!context->map_complete) { |
/* for some reason there's a configure event with 1/1 */ |
279 |
|
/* on diablo. We just ignore this! */ |
280 |
|
|
281 |
|
printf("on_map_configure %d %d\n", |
282 |
|
widget->allocation.width, |
283 |
|
widget->allocation.height); |
284 |
|
|
285 |
|
if(!context->map_complete && |
286 |
|
(widget->allocation.width > 100) && |
287 |
|
(widget->allocation.height > 100)) { |
288 |
|
|
289 |
|
/* setup cache state */ |
290 |
|
map_setup(context); |
291 |
|
|
292 |
/* set default values if they are invalid */ |
/* set default values if they are invalid */ |
293 |
if(!context->appdata->map.zoom || |
if(!context->appdata->map.zoom || |
297 |
|
|
298 |
pos_t *refpos = get_pos(context->appdata); |
pos_t *refpos = get_pos(context->appdata); |
299 |
if(refpos && !isnan(refpos->lat) && !isnan(refpos->lon)) { |
if(refpos && !isnan(refpos->lat) && !isnan(refpos->lon)) { |
300 |
|
printf("use refpos\n"); |
301 |
|
|
302 |
/* use gps position if present */ |
/* use gps position if present */ |
303 |
context->appdata->map.pos = *refpos; |
context->appdata->map.pos = *refpos; |
304 |
context->appdata->map.zoom = GPS_DEFAULT_ZOOM; |
context->appdata->map.zoom = GPS_DEFAULT_ZOOM; |
305 |
} else { |
} else { |
306 |
|
printf("use zero pos\n"); |
307 |
|
|
308 |
/* use world map otherwise */ |
/* use world map otherwise */ |
309 |
context->appdata->map.pos.lat = 0.0; |
context->appdata->map.pos.lat = 0.0; |
310 |
context->appdata->map.pos.lon = 0.0; |
context->appdata->map.pos.lon = 0.0; |
313 |
} |
} |
314 |
|
|
315 |
/* jump to initial position */ |
/* jump to initial position */ |
316 |
|
printf("osm_gps_map_set_mapcenter(%f,%f,%d)\n", |
317 |
|
context->appdata->map.pos.lat, |
318 |
|
context->appdata->map.pos.lon, |
319 |
|
context->appdata->map.zoom); |
320 |
|
|
321 |
osm_gps_map_set_mapcenter(OSM_GPS_MAP(context->widget), |
osm_gps_map_set_mapcenter(OSM_GPS_MAP(context->widget), |
322 |
context->appdata->map.pos.lat, |
context->appdata->map.pos.lat, |
323 |
context->appdata->map.pos.lon, |
context->appdata->map.pos.lon, |
325 |
context->map_complete = TRUE; |
context->map_complete = TRUE; |
326 |
} |
} |
327 |
|
|
328 |
|
printf("map configure done\n"); |
329 |
return FALSE; |
return FALSE; |
330 |
} |
} |
331 |
|
|
|
static void map_draw_cache(GtkWidget *map, cache_t *cache) { |
|
|
GdkPixbuf *icon = icon_get(ICON_CACHE_TYPE, cache->type); |
|
|
|
|
|
/* check if there's also an overwritten coordinate */ |
|
|
if(cache->notes && cache->notes->override) { |
|
|
GdkPixbuf *over = icon_get(ICON_MISC, 1); |
|
|
|
|
|
osm_gps_map_add_image(OSM_GPS_MAP(map), |
|
|
cache->notes->pos.lat, cache->notes->pos.lon, icon); |
|
|
|
|
|
osm_gps_map_add_image(OSM_GPS_MAP(map), |
|
|
cache->notes->pos.lat, cache->notes->pos.lon, over); |
|
|
} else |
|
|
osm_gps_map_add_image(OSM_GPS_MAP(map), |
|
|
cache->pos.lat, cache->pos.lon, icon); |
|
|
|
|
|
} |
|
|
|
|
|
static void map_draw_gpx(appdata_t *appdata, GtkWidget *map, gpx_t *gpx) { |
|
|
if(!gpx->notes_loaded) { |
|
|
notes_load_all(appdata, gpx); |
|
|
gpx->notes_loaded = TRUE; |
|
|
} |
|
|
|
|
|
cache_t *cache = gpx->cache; |
|
|
while(cache) { |
|
|
map_draw_cache(map, cache); |
|
|
cache = cache->next; |
|
|
} |
|
|
} |
|
|
|
|
332 |
static void |
static void |
333 |
map_cachelist_nearest(cache_t *cache, pos_t *pos, |
map_cachelist_nearest(cache_t *cache, pos_t *pos, |
334 |
cache_t **result, float *distance) { |
cache_t **result, float *distance) { |
335 |
|
printf("map_cachelist_nearest in\n"); |
336 |
while(cache) { |
while(cache) { |
337 |
pos_t cpos = gpx_cache_pos(cache); |
pos_t cpos = gpx_cache_pos(cache); |
338 |
|
|
347 |
|
|
348 |
cache = cache->next; |
cache = cache->next; |
349 |
} |
} |
350 |
|
printf("map_cachelist_nearest out\n"); |
351 |
} |
} |
352 |
|
|
353 |
static cache_t *map_closest(map_context_t *context, pos_t *pos) { |
static cache_t *map_closest(map_context_t *context, pos_t *pos) { |
354 |
cache_t *result = NULL; |
cache_t *result = NULL; |
355 |
float distance = NAN; |
float distance = NAN; |
356 |
|
|
357 |
|
printf("map_closest in\n"); |
358 |
|
|
359 |
if(!context->appdata->cur_gpx && !context->appdata->cur_cache) { |
if(!context->appdata->cur_gpx && !context->appdata->cur_cache) { |
360 |
/* search all geocaches */ |
/* search all geocaches */ |
361 |
gpx_t *gpx = context->appdata->gpx; |
gpx_t *gpx = context->appdata->gpx; |
369 |
} else |
} else |
370 |
result = context->appdata->cur_gpx->cache; |
result = context->appdata->cur_gpx->cache; |
371 |
|
|
372 |
|
printf("map_closest out\n"); |
373 |
return result; |
return result; |
374 |
} |
} |
375 |
|
|
386 |
static gboolean |
static gboolean |
387 |
on_map_button_press_event(GtkWidget *widget, |
on_map_button_press_event(GtkWidget *widget, |
388 |
GdkEventButton *event, map_context_t *context) { |
GdkEventButton *event, map_context_t *context) { |
389 |
|
printf("on_map_button_press_event in\n"); |
390 |
|
|
391 |
OsmGpsMap *map = OSM_GPS_MAP(context->widget); |
OsmGpsMap *map = OSM_GPS_MAP(context->widget); |
392 |
|
|
393 |
/* check if we actually clicked parts of the OSD */ |
/* check if we actually clicked parts of the OSD */ |
394 |
if(osm_gps_map_osd_check(map, event->x, event->y) != OSD_NONE) |
if(osm_gps_map_osd_check(map, event->x, event->y) != OSD_NONE) { |
395 |
|
printf("on_map_button_press_event out 1\n"); |
396 |
return FALSE; |
return FALSE; |
397 |
|
} |
398 |
|
|
399 |
/* got a press event without release event? eat it! */ |
/* got a press event without release event? eat it! */ |
400 |
if(context->press_on != NULL) { |
if(context->press_on != NULL) { |
414 |
context->press_on = nearest; |
context->press_on = nearest; |
415 |
} |
} |
416 |
|
|
417 |
|
printf("on_map_button_press_event out\n"); |
418 |
return FALSE; |
return FALSE; |
419 |
} |
} |
420 |
|
|
422 |
cairo_draw_pixbuf(cairo_t *cr, GdkPixbuf *buf, gint x, gint y) { |
cairo_draw_pixbuf(cairo_t *cr, GdkPixbuf *buf, gint x, gint y) { |
423 |
/* convert the pixbuf into something cairo can handle */ |
/* convert the pixbuf into something cairo can handle */ |
424 |
|
|
425 |
|
printf("cairo_draw_pixbuf in\n"); |
426 |
|
|
427 |
// Create a new ImageSurface |
// Create a new ImageSurface |
428 |
cairo_surface_t *image_surface = |
cairo_surface_t *image_surface = |
429 |
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, |
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, |
441 |
cairo_set_source_surface(cr, image_surface, x, y); |
cairo_set_source_surface(cr, image_surface, x, y); |
442 |
|
|
443 |
cairo_paint(cr); |
cairo_paint(cr); |
444 |
|
printf("cairo_draw_pixbuf out\n"); |
445 |
} |
} |
446 |
|
|
447 |
#ifndef BIG_BALLOONS |
#ifndef BIG_BALLOONS |
452 |
|
|
453 |
static void |
static void |
454 |
balloon_cb(osm_gps_map_balloon_event_t *event, gpointer data) { |
balloon_cb(osm_gps_map_balloon_event_t *event, gpointer data) { |
455 |
|
printf("balloon event:\n"); |
456 |
|
|
457 |
map_context_t *context = (map_context_t*)data; |
map_context_t *context = (map_context_t*)data; |
458 |
cache_t *cache = context->balloon; |
cache_t *cache = context->balloon; |
459 |
|
|
|
printf("balloon event: "); |
|
|
|
|
460 |
if(event->type == OSM_GPS_MAP_BALLOON_EVENT_TYPE_DRAW) { |
if(event->type == OSM_GPS_MAP_BALLOON_EVENT_TYPE_DRAW) { |
461 |
printf("draw\n"); |
printf("draw\n"); |
462 |
|
|
628 |
printf("removed\n"); |
printf("removed\n"); |
629 |
context->balloon = NULL; |
context->balloon = NULL; |
630 |
} |
} |
631 |
|
printf("balloon out\n"); |
632 |
} |
} |
633 |
|
|
634 |
static gboolean |
static gboolean |
636 |
GdkEventButton *event, map_context_t *context) { |
GdkEventButton *event, map_context_t *context) { |
637 |
OsmGpsMap *map = OSM_GPS_MAP(context->widget); |
OsmGpsMap *map = OSM_GPS_MAP(context->widget); |
638 |
|
|
639 |
|
printf("on_map_button_release_event in\n"); |
640 |
|
|
641 |
/* in "MAP_CACHE" state only one cache is visible */ |
/* in "MAP_CACHE" state only one cache is visible */ |
642 |
/* and the map is in navigation mode. the balloon is */ |
/* and the map is in navigation mode. the balloon is */ |
643 |
/* pretty useless there */ |
/* pretty useless there */ |
670 |
context->appdata->map.pos.lon = lon; |
context->appdata->map.pos.lon = lon; |
671 |
} |
} |
672 |
|
|
673 |
|
printf("on_map_button_release_event out\n"); |
674 |
return FALSE; |
return FALSE; |
675 |
} |
} |
676 |
|
|
724 |
} |
} |
725 |
#endif |
#endif |
726 |
|
|
727 |
/* draw geocaches and set window title */ |
/* on maemo a window is either on top or completely invisible. this */ |
728 |
static void map_setup(map_context_t *context) { |
/* means that we only need to update the map window if its raised. */ |
729 |
char *name = NULL; |
/* on ordinary desktops this is different and we always update */ |
|
|
|
|
if(!context->appdata->cur_gpx && !context->appdata->cur_cache) { |
|
|
if(context->state != MAP_ALL) { |
|
|
printf("map_setp(ALL)\n"); |
|
|
|
|
|
/* no navigation in this mode */ |
|
|
osm_gps_map_osd_clear_nav (OSM_GPS_MAP(context->widget)); |
|
730 |
|
|
|
/* clear all existing ccahe images */ |
|
|
osm_gps_map_clear_images (OSM_GPS_MAP(context->widget)); |
|
|
|
|
|
/* draw all geocaches */ |
|
|
gpx_t *gpx = context->appdata->gpx; |
|
|
while(gpx) { |
|
|
map_draw_gpx(context->appdata, context->widget, gpx); |
|
|
gpx = gpx->next; |
|
|
} |
|
|
name = g_strdup(_("all")); |
|
|
context->state = MAP_ALL; |
|
|
} |
|
|
} else if(!context->appdata->cur_cache) { |
|
|
if(context->state != MAP_GPX) { |
|
|
printf("map_setp(GPX)\n"); |
|
|
|
|
|
/* no navigation in this mode */ |
|
|
osm_gps_map_osd_clear_nav (OSM_GPS_MAP(context->widget)); |
|
|
|
|
|
/* clear all existing ccahe images */ |
|
|
osm_gps_map_clear_images (OSM_GPS_MAP(context->widget)); |
|
|
|
|
|
map_draw_gpx(context->appdata, context->widget, |
|
|
context->appdata->cur_gpx); |
|
|
name = g_strdup(context->appdata->cur_gpx->name); |
|
|
context->state = MAP_GPX; |
|
|
} |
|
|
} else { |
|
|
cache_t *cache = context->appdata->cur_cache; |
|
|
|
|
|
printf("map_setp(CACHE)\n"); |
|
|
|
|
|
/* no balloons in this mode */ |
|
|
context->balloon = NULL; |
|
|
osm_gps_map_osd_clear_balloon (OSM_GPS_MAP(context->widget)); |
|
|
|
|
|
/* clear all existing ccahe images */ |
|
|
osm_gps_map_clear_images (OSM_GPS_MAP(context->widget)); |
|
|
|
|
|
map_draw_cache(context->widget, cache); |
|
|
name = g_strdup(cache->name); |
|
|
context->state = MAP_CACHE; |
|
|
|
|
|
/* navigation in this mode! */ |
|
|
pos_t cpos = gpx_cache_pos(cache); |
|
|
osm_gps_map_osd_draw_nav (OSM_GPS_MAP(context->widget), |
|
|
context->appdata->imperial, |
|
|
cpos.lat, cpos.lon, cache->name); |
|
|
} |
|
|
|
|
|
if(name) { |
|
|
char *title = g_strdup_printf("%s - %s", _("Map"), name); |
|
|
g_free(name); |
|
|
|
|
|
gtk_window_set_title(GTK_WINDOW(context->window), title); |
|
|
|
|
|
g_free(title); |
|
|
} else |
|
|
printf("map_setup(keep)\n"); |
|
|
} |
|
|
|
|
|
/* on maemo a window is either on top or completely invisible. this means that */ |
|
|
/* we only need to update the map window if its raised. on ordinary desktops this */ |
|
|
/* is different and we always update */ |
|
731 |
static gboolean on_focus_in(GtkWidget *widget, GdkEventFocus *event, |
static gboolean on_focus_in(GtkWidget *widget, GdkEventFocus *event, |
732 |
gpointer data) { |
gpointer data) { |
733 |
printf("map got focus\n"); |
printf("map got focus\n"); |
736 |
} |
} |
737 |
|
|
738 |
void map_update(appdata_t *appdata) { |
void map_update(appdata_t *appdata) { |
739 |
|
printf("map_update\n"); |
740 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
741 |
if(appdata->map.context) |
if(appdata->map.context) |
742 |
map_setup(appdata->map.context); |
map_setup(appdata->map.context); |
746 |
void map(appdata_t *appdata) { |
void map(appdata_t *appdata) { |
747 |
map_context_t *context = NULL; |
map_context_t *context = NULL; |
748 |
|
|
749 |
|
printf("map 1\n"); |
750 |
|
|
751 |
/* if the map window already exists, just raise it */ |
/* if the map window already exists, just raise it */ |
752 |
if(appdata->map.context) { |
if(appdata->map.context) { |
753 |
printf("using existing map!\n"); |
printf("using existing map!\n"); |
756 |
return; |
return; |
757 |
} |
} |
758 |
|
|
759 |
|
printf("map 2\n"); |
760 |
|
|
761 |
context = appdata->map.context = g_new0(map_context_t, 1); |
context = appdata->map.context = g_new0(map_context_t, 1); |
762 |
context->appdata = appdata; |
context->appdata = appdata; |
763 |
context->map_complete = FALSE; |
context->map_complete = FALSE; |
770 |
rmdir_recursive(old_path); |
rmdir_recursive(old_path); |
771 |
} |
} |
772 |
|
|
773 |
|
printf("map 3\n"); |
774 |
|
|
775 |
/* It is recommanded that all applications share these same */ |
/* It is recommanded that all applications share these same */ |
776 |
/* map path, so data is only cached once. The path should be: */ |
/* map path, so data is only cached once. The path should be: */ |
777 |
/* ~/.osm-gps-map on standard PC (users home) */ |
/* ~/.osm-gps-map on standard PC (users home) */ |
794 |
gint source = context->appdata->map.source; |
gint source = context->appdata->map.source; |
795 |
if(!source) source = MAP_SOURCE; |
if(!source) source = MAP_SOURCE; |
796 |
|
|
797 |
|
printf("map 4\n"); |
798 |
|
|
799 |
context->widget = g_object_new(OSM_TYPE_GPS_MAP, |
context->widget = g_object_new(OSM_TYPE_GPS_MAP, |
800 |
"map-source", source, |
"map-source", source, |
801 |
"tile-cache", path, |
"tile-cache", path, |
809 |
|
|
810 |
osm_gps_map_osd_classic_init(OSM_GPS_MAP(context->widget)); |
osm_gps_map_osd_classic_init(OSM_GPS_MAP(context->widget)); |
811 |
|
|
812 |
|
printf("map 5\n"); |
813 |
|
|
814 |
#ifdef USE_MAEMO |
#ifdef USE_MAEMO |
815 |
/* we don't use a stackable window here on fremantle, since */ |
/* we don't use a stackable window here on fremantle, since */ |
816 |
/* this leaves the main window independent from the map and */ |
/* this leaves the main window independent from the map and */ |
825 |
context->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
context->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
826 |
#endif |
#endif |
827 |
|
|
828 |
/* setup cache state */ |
printf("map 6\n"); |
|
map_setup(context); |
|
829 |
|
|
830 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
831 |
gtk_window_set_default_size(GTK_WINDOW(context->window), 640, 480); |
gtk_window_set_default_size(GTK_WINDOW(context->window), 640, 480); |
846 |
/* install handler for timed updates of the gps button */ |
/* install handler for timed updates of the gps button */ |
847 |
context->handler_id = gtk_timeout_add(1000, map_gps_update, context); |
context->handler_id = gtk_timeout_add(1000, map_gps_update, context); |
848 |
|
|
849 |
|
printf("map 7\n"); |
850 |
|
|
851 |
#if MAEMO_VERSION_MAJOR == 5 |
#if MAEMO_VERSION_MAJOR == 5 |
852 |
/* prevent some of the main screen things */ |
/* prevent some of the main screen things */ |
853 |
context->old_view = appdata->cur_view; |
context->old_view = appdata->cur_view; |
854 |
appdata->cur_view = NULL; |
appdata->cur_view = NULL; |
855 |
#endif |
#endif |
856 |
|
|
857 |
|
printf("map 8\n"); |
858 |
|
|
859 |
g_signal_connect(G_OBJECT(context->window), "destroy", |
g_signal_connect(G_OBJECT(context->window), "destroy", |
860 |
G_CALLBACK(on_window_destroy), context); |
G_CALLBACK(on_window_destroy), context); |
861 |
|
|
862 |
|
printf("map 9\n"); |
863 |
gtk_container_add(GTK_CONTAINER(context->window), context->widget); |
gtk_container_add(GTK_CONTAINER(context->window), context->widget); |
864 |
|
printf("map 10\n"); |
865 |
gtk_widget_show_all(GTK_WIDGET(context->window)); |
gtk_widget_show_all(GTK_WIDGET(context->window)); |
866 |
|
|
867 |
|
printf("map 11\n"); |
868 |
} |
} |