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 |
|
|
|
printf("get_proxy_uri in\n"); |
|
|
|
|
48 |
/* use environment settings if preset */ |
/* use environment settings if preset */ |
49 |
const char *proxy = g_getenv("http_proxy"); |
const char *proxy = g_getenv("http_proxy"); |
50 |
if(proxy) { |
if(proxy) { |
75 |
return proxy_buffer; |
return proxy_buffer; |
76 |
} |
} |
77 |
|
|
|
printf("get_proxy_uri out\n"); |
|
78 |
return NULL; |
return NULL; |
79 |
} |
} |
80 |
|
|
81 |
static void |
static void |
82 |
cb_map_gps(osd_button_t but, map_context_t *context) { |
cb_map_gps(osd_button_t but, map_context_t *context) { |
|
printf("cb_map_gps in\n"); |
|
83 |
|
|
84 |
if(but == OSD_GPS) { |
if(but == OSD_GPS) { |
85 |
pos_t *refpos = get_pos(context->appdata); |
pos_t *refpos = get_pos(context->appdata); |
101 |
0.0, 0.0, 1); |
0.0, 0.0, 1); |
102 |
} |
} |
103 |
} |
} |
|
printf("cb_map_gps out\n"); |
|
104 |
} |
} |
105 |
|
|
106 |
static int dist2pixel(map_context_t *context, float km, float lat) { |
static int dist2pixel(map_context_t *context, float km, float lat) { |
110 |
static gboolean map_gps_update(gpointer data) { |
static gboolean map_gps_update(gpointer data) { |
111 |
map_context_t *context = (map_context_t*)data; |
map_context_t *context = (map_context_t*)data; |
112 |
|
|
|
printf("map_gps_update in\n"); |
|
|
|
|
113 |
/* get reference position ... */ |
/* get reference position ... */ |
114 |
pos_t *refpos = get_pos(context->appdata); |
pos_t *refpos = get_pos(context->appdata); |
115 |
gboolean ok = (refpos!= NULL) && !isnan(refpos->lat) && !isnan(refpos->lon); |
gboolean ok = (refpos!= NULL) && !isnan(refpos->lat) && !isnan(refpos->lon); |
137 |
} else |
} else |
138 |
osm_gps_map_clear_gps(OSM_GPS_MAP(context->widget)); |
osm_gps_map_clear_gps(OSM_GPS_MAP(context->widget)); |
139 |
|
|
|
printf("map_gps_update out\n"); |
|
140 |
return TRUE; |
return TRUE; |
141 |
} |
} |
142 |
|
|
143 |
static void map_draw_cache(GtkWidget *map, cache_t *cache) { |
static void map_draw_cache(GtkWidget *map, cache_t *cache) { |
|
printf("map_draw_cache in\n"); |
|
|
|
|
144 |
GdkPixbuf *icon = icon_get(ICON_CACHE_TYPE, cache->type); |
GdkPixbuf *icon = icon_get(ICON_CACHE_TYPE, cache->type); |
145 |
|
|
146 |
/* check if there's also an overwritten coordinate */ |
/* check if there's also an overwritten coordinate */ |
157 |
osm_gps_map_add_image(OSM_GPS_MAP(map), |
osm_gps_map_add_image(OSM_GPS_MAP(map), |
158 |
cache->pos.lat, cache->pos.lon, icon); |
cache->pos.lat, cache->pos.lon, icon); |
159 |
} |
} |
|
printf("map_draw_cache out\n"); |
|
160 |
} |
} |
161 |
|
|
162 |
static void map_draw_gpx(appdata_t *appdata, GtkWidget *map, gpx_t *gpx) { |
static void map_draw_gpx(appdata_t *appdata, GtkWidget *map, gpx_t *gpx) { |
|
printf("map_draw_gpx in\n"); |
|
|
|
|
163 |
if(!gpx->notes_loaded) { |
if(!gpx->notes_loaded) { |
164 |
notes_load_all(appdata, gpx); |
notes_load_all(appdata, gpx); |
165 |
gpx->notes_loaded = TRUE; |
gpx->notes_loaded = TRUE; |
170 |
map_draw_cache(map, cache); |
map_draw_cache(map, cache); |
171 |
cache = cache->next; |
cache = cache->next; |
172 |
} |
} |
|
printf("map_draw_gpx out\n"); |
|
173 |
} |
} |
174 |
|
|
175 |
/* draw geocaches and set window title */ |
/* draw geocaches and set window title */ |
176 |
static void map_setup(map_context_t *context) { |
static void map_setup(map_context_t *context) { |
177 |
char *name = NULL; |
char *name = NULL; |
178 |
|
|
|
printf("map_setup in\n"); |
|
|
|
|
179 |
if(!context->appdata->cur_gpx && !context->appdata->cur_cache) { |
if(!context->appdata->cur_gpx && !context->appdata->cur_cache) { |
180 |
if(context->state != MAP_ALL) { |
if(context->state != MAP_ALL) { |
181 |
printf("map_setup(ALL)\n"); |
printf("map_setup(ALL)\n"); |
251 |
g_free(title); |
g_free(title); |
252 |
} else |
} else |
253 |
printf("map_setup(keep)\n"); |
printf("map_setup(keep)\n"); |
|
|
|
|
printf("map_setup out\n"); |
|
254 |
} |
} |
255 |
|
|
256 |
static gboolean on_map_configure(GtkWidget *widget, |
static gboolean on_map_configure(GtkWidget *widget, |
307 |
context->map_complete = TRUE; |
context->map_complete = TRUE; |
308 |
} |
} |
309 |
|
|
|
printf("map configure done\n"); |
|
310 |
return FALSE; |
return FALSE; |
311 |
} |
} |
312 |
|
|
313 |
static void |
static void |
314 |
map_cachelist_nearest(cache_t *cache, pos_t *pos, |
map_cachelist_nearest(cache_t *cache, pos_t *pos, |
315 |
cache_t **result, float *distance) { |
cache_t **result, float *distance) { |
316 |
printf("map_cachelist_nearest in\n"); |
|
317 |
while(cache) { |
while(cache) { |
318 |
pos_t cpos = gpx_cache_pos(cache); |
pos_t cpos = gpx_cache_pos(cache); |
319 |
|
|
328 |
|
|
329 |
cache = cache->next; |
cache = cache->next; |
330 |
} |
} |
|
printf("map_cachelist_nearest out\n"); |
|
331 |
} |
} |
332 |
|
|
333 |
static cache_t *map_closest(map_context_t *context, pos_t *pos) { |
static cache_t *map_closest(map_context_t *context, pos_t *pos) { |
334 |
cache_t *result = NULL; |
cache_t *result = NULL; |
335 |
float distance = NAN; |
float distance = NAN; |
336 |
|
|
|
printf("map_closest in\n"); |
|
|
|
|
337 |
if(!context->appdata->cur_gpx && !context->appdata->cur_cache) { |
if(!context->appdata->cur_gpx && !context->appdata->cur_cache) { |
338 |
/* search all geocaches */ |
/* search all geocaches */ |
339 |
gpx_t *gpx = context->appdata->gpx; |
gpx_t *gpx = context->appdata->gpx; |
347 |
} else |
} else |
348 |
result = context->appdata->cur_gpx->cache; |
result = context->appdata->cur_gpx->cache; |
349 |
|
|
|
printf("map_closest out\n"); |
|
350 |
return result; |
return result; |
351 |
} |
} |
352 |
|
|
363 |
static gboolean |
static gboolean |
364 |
on_map_button_press_event(GtkWidget *widget, |
on_map_button_press_event(GtkWidget *widget, |
365 |
GdkEventButton *event, map_context_t *context) { |
GdkEventButton *event, map_context_t *context) { |
|
printf("on_map_button_press_event in\n"); |
|
366 |
|
|
367 |
OsmGpsMap *map = OSM_GPS_MAP(context->widget); |
OsmGpsMap *map = OSM_GPS_MAP(context->widget); |
368 |
|
|
369 |
/* check if we actually clicked parts of the OSD */ |
/* check if we actually clicked parts of the OSD */ |
370 |
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) |
|
printf("on_map_button_press_event out 1\n"); |
|
371 |
return FALSE; |
return FALSE; |
|
} |
|
372 |
|
|
373 |
/* got a press event without release event? eat it! */ |
/* got a press event without release event? eat it! */ |
374 |
if(context->press_on != NULL) { |
if(context->press_on != NULL) { |
388 |
context->press_on = nearest; |
context->press_on = nearest; |
389 |
} |
} |
390 |
|
|
|
printf("on_map_button_press_event out\n"); |
|
391 |
return FALSE; |
return FALSE; |
392 |
} |
} |
393 |
|
|
395 |
cairo_draw_pixbuf(cairo_t *cr, GdkPixbuf *buf, gint x, gint y) { |
cairo_draw_pixbuf(cairo_t *cr, GdkPixbuf *buf, gint x, gint y) { |
396 |
/* convert the pixbuf into something cairo can handle */ |
/* convert the pixbuf into something cairo can handle */ |
397 |
|
|
|
printf("cairo_draw_pixbuf in\n"); |
|
|
|
|
398 |
// Create a new ImageSurface |
// Create a new ImageSurface |
399 |
cairo_surface_t *image_surface = |
cairo_surface_t *image_surface = |
400 |
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, |
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, |
412 |
cairo_set_source_surface(cr, image_surface, x, y); |
cairo_set_source_surface(cr, image_surface, x, y); |
413 |
|
|
414 |
cairo_paint(cr); |
cairo_paint(cr); |
|
printf("cairo_draw_pixbuf out\n"); |
|
415 |
} |
} |
416 |
|
|
417 |
#ifndef BIG_BALLOONS |
#ifndef BIG_BALLOONS |
422 |
|
|
423 |
static void |
static void |
424 |
balloon_cb(osm_gps_map_balloon_event_t *event, gpointer data) { |
balloon_cb(osm_gps_map_balloon_event_t *event, gpointer data) { |
425 |
printf("balloon event:\n"); |
printf("balloon event: "); |
426 |
|
|
427 |
map_context_t *context = (map_context_t*)data; |
map_context_t *context = (map_context_t*)data; |
428 |
cache_t *cache = context->balloon; |
cache_t *cache = context->balloon; |
598 |
printf("removed\n"); |
printf("removed\n"); |
599 |
context->balloon = NULL; |
context->balloon = NULL; |
600 |
} |
} |
|
printf("balloon out\n"); |
|
601 |
} |
} |
602 |
|
|
603 |
static gboolean |
static gboolean |
605 |
GdkEventButton *event, map_context_t *context) { |
GdkEventButton *event, map_context_t *context) { |
606 |
OsmGpsMap *map = OSM_GPS_MAP(context->widget); |
OsmGpsMap *map = OSM_GPS_MAP(context->widget); |
607 |
|
|
|
printf("on_map_button_release_event in\n"); |
|
|
|
|
608 |
/* in "MAP_CACHE" state only one cache is visible */ |
/* in "MAP_CACHE" state only one cache is visible */ |
609 |
/* and the map is in navigation mode. the balloon is */ |
/* and the map is in navigation mode. the balloon is */ |
610 |
/* pretty useless there */ |
/* pretty useless there */ |
637 |
context->appdata->map.pos.lon = lon; |
context->appdata->map.pos.lon = lon; |
638 |
} |
} |
639 |
|
|
|
printf("on_map_button_release_event out\n"); |
|
640 |
return FALSE; |
return FALSE; |
641 |
} |
} |
642 |
|
|
643 |
static void on_window_destroy(GtkWidget *widget, map_context_t *context) { |
static void on_window_destroy(GtkWidget *widget, map_context_t *context) { |
644 |
appdata_t *appdata = context->appdata; |
appdata_t *appdata = context->appdata; |
645 |
|
|
|
printf("destroy map window\n"); |
|
|
|
|
646 |
/* save map parameters */ |
/* save map parameters */ |
647 |
OsmGpsMap *map = OSM_GPS_MAP(context->widget); |
OsmGpsMap *map = OSM_GPS_MAP(context->widget); |
648 |
gint zoom; |
gint zoom; |
710 |
void map(appdata_t *appdata) { |
void map(appdata_t *appdata) { |
711 |
map_context_t *context = NULL; |
map_context_t *context = NULL; |
712 |
|
|
|
printf("map 1\n"); |
|
|
|
|
713 |
/* if the map window already exists, just raise it */ |
/* if the map window already exists, just raise it */ |
714 |
if(appdata->map.context) { |
if(appdata->map.context) { |
715 |
printf("using existing map!\n"); |
printf("using existing map!\n"); |
718 |
return; |
return; |
719 |
} |
} |
720 |
|
|
|
printf("map 2\n"); |
|
|
|
|
721 |
context = appdata->map.context = g_new0(map_context_t, 1); |
context = appdata->map.context = g_new0(map_context_t, 1); |
722 |
context->appdata = appdata; |
context->appdata = appdata; |
723 |
context->map_complete = FALSE; |
context->map_complete = FALSE; |
730 |
rmdir_recursive(old_path); |
rmdir_recursive(old_path); |
731 |
} |
} |
732 |
|
|
|
printf("map 3\n"); |
|
|
|
|
733 |
/* It is recommanded that all applications share these same */ |
/* It is recommanded that all applications share these same */ |
734 |
/* map path, so data is only cached once. The path should be: */ |
/* map path, so data is only cached once. The path should be: */ |
735 |
/* ~/.osm-gps-map on standard PC (users home) */ |
/* ~/.osm-gps-map on standard PC (users home) */ |
752 |
gint source = context->appdata->map.source; |
gint source = context->appdata->map.source; |
753 |
if(!source) source = MAP_SOURCE; |
if(!source) source = MAP_SOURCE; |
754 |
|
|
|
printf("map 4\n"); |
|
|
|
|
755 |
context->widget = g_object_new(OSM_TYPE_GPS_MAP, |
context->widget = g_object_new(OSM_TYPE_GPS_MAP, |
756 |
"map-source", source, |
"map-source", source, |
757 |
"tile-cache", path, |
"tile-cache", path, |
765 |
|
|
766 |
osm_gps_map_osd_classic_init(OSM_GPS_MAP(context->widget)); |
osm_gps_map_osd_classic_init(OSM_GPS_MAP(context->widget)); |
767 |
|
|
|
printf("map 5\n"); |
|
|
|
|
768 |
#ifdef USE_MAEMO |
#ifdef USE_MAEMO |
769 |
/* we don't use a stackable window here on fremantle, since */ |
/* we don't use a stackable window here on fremantle, since */ |
770 |
/* this leaves the main window independent from the map and */ |
/* this leaves the main window independent from the map and */ |
779 |
context->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
context->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
780 |
#endif |
#endif |
781 |
|
|
|
printf("map 6\n"); |
|
|
|
|
782 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
783 |
gtk_window_set_default_size(GTK_WINDOW(context->window), 640, 480); |
gtk_window_set_default_size(GTK_WINDOW(context->window), 640, 480); |
784 |
#endif |
#endif |
798 |
/* install handler for timed updates of the gps button */ |
/* install handler for timed updates of the gps button */ |
799 |
context->handler_id = gtk_timeout_add(1000, map_gps_update, context); |
context->handler_id = gtk_timeout_add(1000, map_gps_update, context); |
800 |
|
|
|
printf("map 7\n"); |
|
|
|
|
801 |
#if MAEMO_VERSION_MAJOR == 5 |
#if MAEMO_VERSION_MAJOR == 5 |
802 |
/* prevent some of the main screen things */ |
/* prevent some of the main screen things */ |
803 |
context->old_view = appdata->cur_view; |
context->old_view = appdata->cur_view; |
804 |
appdata->cur_view = NULL; |
appdata->cur_view = NULL; |
805 |
#endif |
#endif |
806 |
|
|
|
printf("map 8\n"); |
|
|
|
|
807 |
g_signal_connect(G_OBJECT(context->window), "destroy", |
g_signal_connect(G_OBJECT(context->window), "destroy", |
808 |
G_CALLBACK(on_window_destroy), context); |
G_CALLBACK(on_window_destroy), context); |
809 |
|
|
|
printf("map 9\n"); |
|
810 |
gtk_container_add(GTK_CONTAINER(context->window), context->widget); |
gtk_container_add(GTK_CONTAINER(context->window), context->widget); |
|
printf("map 10\n"); |
|
811 |
gtk_widget_show_all(GTK_WIDGET(context->window)); |
gtk_widget_show_all(GTK_WIDGET(context->window)); |
|
|
|
|
printf("map 11\n"); |
|
812 |
} |
} |