525 |
static void map_setup(map_context_t *context) { |
static void map_setup(map_context_t *context) { |
526 |
char *name = NULL; |
char *name = NULL; |
527 |
|
|
|
/* clear all existing ccahe images */ |
|
|
osm_gps_map_clear_images (OSM_GPS_MAP(context->widget)); |
|
|
|
|
528 |
if(!context->appdata->cur_gpx && !context->appdata->cur_cache) { |
if(!context->appdata->cur_gpx && !context->appdata->cur_cache) { |
529 |
/* draw all geocaches */ |
if(context->state != MAP_ALL) { |
530 |
gpx_t *gpx = context->appdata->gpx; |
printf("map_setp(ALL)\n"); |
531 |
while(gpx) { |
|
532 |
map_draw_gpx(context->appdata, context->widget, gpx); |
/* clear all existing ccahe images */ |
533 |
gpx = gpx->next; |
osm_gps_map_clear_images (OSM_GPS_MAP(context->widget)); |
534 |
|
|
535 |
|
/* draw all geocaches */ |
536 |
|
gpx_t *gpx = context->appdata->gpx; |
537 |
|
while(gpx) { |
538 |
|
map_draw_gpx(context->appdata, context->widget, gpx); |
539 |
|
gpx = gpx->next; |
540 |
|
} |
541 |
|
name = g_strdup(_("all")); |
542 |
|
context->state = MAP_ALL; |
543 |
} |
} |
|
name = g_strdup(_("all")); |
|
|
context->state = MAP_ALL; |
|
|
context->gpx = context->appdata->gpx; |
|
544 |
} else if(!context->appdata->cur_cache) { |
} else if(!context->appdata->cur_cache) { |
545 |
map_draw_gpx(context->appdata, context->widget, context->appdata->cur_gpx); |
if(context->state != MAP_GPX) { |
546 |
name = g_strdup(context->appdata->cur_gpx->name); |
printf("map_setp(GPX)\n"); |
547 |
context->state = MAP_GPX; |
|
548 |
context->gpx = context->appdata->cur_gpx; |
/* clear all existing ccahe images */ |
549 |
|
osm_gps_map_clear_images (OSM_GPS_MAP(context->widget)); |
550 |
|
|
551 |
|
map_draw_gpx(context->appdata, context->widget, |
552 |
|
context->appdata->cur_gpx); |
553 |
|
name = g_strdup(context->appdata->cur_gpx->name); |
554 |
|
context->state = MAP_GPX; |
555 |
|
} |
556 |
} else { |
} else { |
557 |
map_draw_cache(context->widget, context->appdata->cur_cache); |
if(context->state != MAP_CACHE) { |
558 |
name = g_strdup(context->appdata->cur_cache->name); |
printf("map_setp(CACHE)\n"); |
|
context->state = MAP_CACHE; |
|
|
context->cache = context->appdata->cur_cache; |
|
|
} |
|
559 |
|
|
560 |
char *title = g_strdup_printf(_("Map - %s"), name); |
/* clear all existing ccahe images */ |
561 |
g_free(name); |
osm_gps_map_clear_images (OSM_GPS_MAP(context->widget)); |
562 |
|
|
563 |
gtk_window_set_title(GTK_WINDOW(context->window), title); |
map_draw_cache(context->widget, context->appdata->cur_cache); |
564 |
|
name = g_strdup(context->appdata->cur_cache->name); |
565 |
|
context->state = MAP_CACHE; |
566 |
|
} |
567 |
|
} |
568 |
|
|
569 |
g_free(title); |
if(name) { |
570 |
|
char *title = g_strdup_printf(_("Map - %s"), name); |
571 |
|
g_free(name); |
572 |
|
|
573 |
|
gtk_window_set_title(GTK_WINDOW(context->window), title); |
574 |
|
|
575 |
|
g_free(title); |
576 |
|
} else |
577 |
|
printf("map_setup(keep)\n"); |
578 |
} |
} |
579 |
|
|
580 |
|
#ifdef USE_MAEMO |
581 |
/* on maemo a window is either on top or completely invisible. this means that */ |
/* on maemo a window is either on top or completely invisible. this means that */ |
582 |
/* we only need to update the map window if its raised. on ordinary desktops this */ |
/* we only need to update the map window if its raised. on ordinary desktops this */ |
583 |
/* is different and we always update */ |
/* is different and we always update */ |
584 |
static gboolean on_focus_in(GtkWidget *widget, GdkEventFocus *event, |
static gboolean on_focus_in(GtkWidget *widget, GdkEventFocus *event, |
585 |
gpointer data) { |
gpointer data) { |
|
map_context_t *context = (map_context_t*)data; |
|
|
|
|
|
printf("map focus in!\n"); |
|
586 |
|
|
587 |
|
map_setup((map_context_t*)data); |
588 |
return FALSE; |
return FALSE; |
589 |
} |
} |
590 |
|
#endif |
591 |
|
|
592 |
void map_update(appdata_t *appdata) { |
void map_update(appdata_t *appdata) { |
593 |
if(appdata->map.context) { |
#ifndef USE_MAEMO |
594 |
printf("map update\n"); |
if(appdata->map.context) |
595 |
} |
map_setup(appdata->map.context); |
596 |
|
#endif |
597 |
} |
} |
598 |
|
|
599 |
void map(appdata_t *appdata) { |
void map(appdata_t *appdata) { |
610 |
context = appdata->map.context = g_new0(map_context_t, 1); |
context = appdata->map.context = g_new0(map_context_t, 1); |
611 |
context->appdata = appdata; |
context->appdata = appdata; |
612 |
context->map_complete = FALSE; |
context->map_complete = FALSE; |
613 |
|
context->state = MAP_NONE; |
614 |
|
|
615 |
/* cleanup old (pre 0.8.7) path if it exists */ |
/* cleanup old (pre 0.8.7) path if it exists */ |
616 |
char *old_path = g_strdup_printf("%s/map/", appdata->image_path); |
char *old_path = g_strdup_printf("%s/map/", appdata->image_path); |
675 |
gtk_window_set_default_size(GTK_WINDOW(context->window), 640, 480); |
gtk_window_set_default_size(GTK_WINDOW(context->window), 640, 480); |
676 |
#endif |
#endif |
677 |
|
|
678 |
|
#ifdef USE_MAEMO |
679 |
g_signal_connect(G_OBJECT(context->widget), "focus-in-event", |
g_signal_connect(G_OBJECT(context->widget), "focus-in-event", |
680 |
G_CALLBACK(on_focus_in), context); |
G_CALLBACK(on_focus_in), context); |
681 |
|
#endif |
682 |
|
|
683 |
g_signal_connect(G_OBJECT(context->widget), "configure-event", |
g_signal_connect(G_OBJECT(context->widget), "configure-event", |
684 |
G_CALLBACK(on_map_configure), context); |
G_CALLBACK(on_map_configure), context); |