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; |
|
static gboolean goto_is_enabled = FALSE; |
|
121 |
|
|
122 |
/* get reference position ... */ |
/* get reference position ... */ |
123 |
pos_t *refpos = get_pos(context->appdata); |
pos_t *refpos = get_pos(context->appdata); |
124 |
gboolean ok = (refpos!= NULL) && !isnan(refpos->lat) && !isnan(refpos->lon); |
gboolean ok = (refpos!= NULL) && !isnan(refpos->lat) && !isnan(refpos->lon); |
125 |
|
|
126 |
/* ... and enable "goto" button if it's valid */ |
/* ... and enable "goto" button if it's valid */ |
127 |
if(ok != goto_is_enabled) { |
if(ok != context->goto_is_enabled) { |
128 |
osm_gps_map_osd_enable_gps (OSM_GPS_MAP(context->widget), |
osm_gps_map_osd_enable_gps (OSM_GPS_MAP(context->widget), |
129 |
OSM_GPS_MAP_OSD_CALLBACK(ok?cb_map_gps:NULL), context); |
OSM_GPS_MAP_OSD_CALLBACK(ok?cb_map_gps:NULL), context); |
130 |
goto_is_enabled = ok; |
context->goto_is_enabled = ok; |
131 |
} |
} |
132 |
|
|
133 |
if(ok) { |
if(ok) { |
183 |
} |
} |
184 |
|
|
185 |
static void map_draw_wpt(GtkWidget *map, cache_t *cache, wpt_t *wpt) { |
static void map_draw_wpt(GtkWidget *map, cache_t *cache, wpt_t *wpt) { |
|
|
|
186 |
/* only draw wpts that don't equal the main point */ |
/* only draw wpts that don't equal the main point */ |
187 |
if(pos_differ(&cache->pos, &wpt->pos)) { |
if(pos_differ(&cache->pos, &wpt->pos)) { |
188 |
GdkPixbuf *icon = |
if(!isnan(wpt->pos.lat) && !isnan(wpt->pos.lon)) { |
189 |
icon_get(ICON_WPT, (wpt->sym!=WPT_SYM_UNKNOWN)? |
GdkPixbuf *icon = |
190 |
wpt->sym:WPT_SYM_REFPOINT); |
icon_get(ICON_WPT, (wpt->sym!=WPT_SYM_UNKNOWN)? |
191 |
|
wpt->sym:WPT_SYM_REFPOINT); |
192 |
if(!isnan(wpt->pos.lat) && !isnan(wpt->pos.lon)) |
|
193 |
osm_gps_map_add_image(OSM_GPS_MAP(map), |
osm_gps_map_add_image(OSM_GPS_MAP(map), |
194 |
wpt->pos.lat, wpt->pos.lon, icon); |
wpt->pos.lat, wpt->pos.lon, icon); |
195 |
|
} |
196 |
} |
} |
197 |
} |
} |
198 |
|
|
358 |
#endif |
#endif |
359 |
} |
} |
360 |
|
|
361 |
|
/* also mark geomath position */ |
362 |
|
|
363 |
|
/* remove all existing appearances of this icon first */ |
364 |
|
osm_gps_map_remove_image(OSM_GPS_MAP(context->widget), |
365 |
|
icon_get(ICON_MISC, 6)); |
366 |
|
|
367 |
|
if(!isnan(context->appdata->geomath.lat) && |
368 |
|
!isnan(context->appdata->geomath.lon)) { |
369 |
|
|
370 |
|
osm_gps_map_add_image(OSM_GPS_MAP(context->widget), |
371 |
|
context->appdata->geomath.lat, |
372 |
|
context->appdata->geomath.lon, |
373 |
|
icon_get(ICON_MISC, 6)); |
374 |
|
} |
375 |
|
|
376 |
if(name) { |
if(name) { |
377 |
char *title = g_strdup_printf(_("Map - %s"), name); |
char *title = g_strdup_printf(_("Map - %s"), name); |
378 |
g_free(name); |
g_free(name); |
822 |
context->caches_displayed = NULL; |
context->caches_displayed = NULL; |
823 |
} |
} |
824 |
|
|
825 |
|
printf("destroy map context\n"); |
826 |
g_free(context); |
g_free(context); |
827 |
appdata->map.context = NULL; |
appdata->map.context = NULL; |
828 |
} |
} |
913 |
} |
} |
914 |
|
|
915 |
context = appdata->map.context = g_new0(map_context_t, 1); |
context = appdata->map.context = g_new0(map_context_t, 1); |
916 |
|
printf("allocated new context at %p\n", context); |
917 |
|
|
918 |
context->appdata = appdata; |
context->appdata = appdata; |
919 |
context->map_complete = FALSE; |
context->map_complete = FALSE; |
920 |
context->state = MAP_NONE; |
context->state = MAP_NONE; |