88 |
cb_map_gps(osd_button_t but, map_context_t *context) { |
cb_map_gps(osd_button_t but, map_context_t *context) { |
89 |
|
|
90 |
if(but == OSD_GPS) { |
if(but == OSD_GPS) { |
91 |
|
printf("clicked OSD_GPS %p\n", context); |
92 |
|
printf("clicked OSD_GPS a %p\n", context->appdata); |
93 |
|
|
94 |
pos_t *refpos = get_pos(context->appdata); |
pos_t *refpos = get_pos(context->appdata); |
95 |
if(refpos && !isnan(refpos->lat) && !isnan(refpos->lon)) { |
if(refpos && !isnan(refpos->lat) && !isnan(refpos->lon)) { |
96 |
gint zoom; |
gint zoom; |
118 |
|
|
119 |
static gboolean map_gps_update(gpointer data) { |
static gboolean map_gps_update(gpointer data) { |
120 |
map_context_t *context = (map_context_t*)data; |
map_context_t *context = (map_context_t*)data; |
121 |
static gboolean goto_is_enabled = FALSE; |
|
122 |
|
#ifdef USE_MAEMO |
123 |
|
if(context->appdata->goto_disable_screensaver) |
124 |
|
if(osso_display_blanking_pause(context->appdata->osso_context) != OSSO_OK) |
125 |
|
fprintf(stderr, "error with display blank\n"); |
126 |
|
#endif |
127 |
|
|
128 |
/* get reference position ... */ |
/* get reference position ... */ |
129 |
pos_t *refpos = get_pos(context->appdata); |
pos_t *refpos = get_pos(context->appdata); |
130 |
gboolean ok = (refpos!= NULL) && !isnan(refpos->lat) && !isnan(refpos->lon); |
gboolean ok = (refpos!= NULL) && !isnan(refpos->lat) && !isnan(refpos->lon); |
131 |
|
|
132 |
/* ... and enable "goto" button if it's valid */ |
/* ... and enable "goto" button if it's valid */ |
133 |
if(ok != goto_is_enabled) { |
if(ok != context->goto_is_enabled) { |
134 |
osm_gps_map_osd_enable_gps (OSM_GPS_MAP(context->widget), |
osm_gps_map_osd_enable_gps (OSM_GPS_MAP(context->widget), |
135 |
OSM_GPS_MAP_OSD_CALLBACK(ok?cb_map_gps:NULL), context); |
OSM_GPS_MAP_OSD_CALLBACK(ok?cb_map_gps:NULL), context); |
136 |
goto_is_enabled = ok; |
context->goto_is_enabled = ok; |
137 |
} |
} |
138 |
|
|
139 |
if(ok) { |
if(ok) { |
368 |
|
|
369 |
/* remove all existing appearances of this icon first */ |
/* remove all existing appearances of this icon first */ |
370 |
osm_gps_map_remove_image(OSM_GPS_MAP(context->widget), |
osm_gps_map_remove_image(OSM_GPS_MAP(context->widget), |
371 |
icon_get(ICON_MISC, 6)); |
icon_get(ICON_MISC, 4)); |
372 |
|
|
373 |
if(!isnan(context->appdata->geomath.lat) && |
if(!isnan(context->appdata->geomath.lat) && |
374 |
!isnan(context->appdata->geomath.lon)) { |
!isnan(context->appdata->geomath.lon)) { |
376 |
osm_gps_map_add_image(OSM_GPS_MAP(context->widget), |
osm_gps_map_add_image(OSM_GPS_MAP(context->widget), |
377 |
context->appdata->geomath.lat, |
context->appdata->geomath.lat, |
378 |
context->appdata->geomath.lon, |
context->appdata->geomath.lon, |
379 |
icon_get(ICON_MISC, 6)); |
icon_get(ICON_MISC, 4)); |
380 |
} |
} |
381 |
|
|
382 |
if(name) { |
if(name) { |
828 |
context->caches_displayed = NULL; |
context->caches_displayed = NULL; |
829 |
} |
} |
830 |
|
|
831 |
|
printf("destroy map context\n"); |
832 |
g_free(context); |
g_free(context); |
833 |
appdata->map.context = NULL; |
appdata->map.context = NULL; |
834 |
} |
} |
919 |
} |
} |
920 |
|
|
921 |
context = appdata->map.context = g_new0(map_context_t, 1); |
context = appdata->map.context = g_new0(map_context_t, 1); |
922 |
|
printf("allocated new context at %p\n", context); |
923 |
|
|
924 |
context->appdata = appdata; |
context->appdata = appdata; |
925 |
context->map_complete = FALSE; |
context->map_complete = FALSE; |
926 |
context->state = MAP_NONE; |
context->state = MAP_NONE; |