--- trunk/src/map-tool.c 2009/09/23 11:23:45 123 +++ trunk/src/map-tool.c 2009/09/27 19:11:37 125 @@ -525,12 +525,49 @@ } #endif +/* draw geocaches and set window title */ +static void map_setup(map_context_t *context) { + char *name = NULL; + + /* clear all existing ccahe images */ + osm_gps_map_clear_images (OSM_GPS_MAP(context->widget)); + +#ifdef USE_MAEMO + if(!context->appdata->cur_gpx && !context->appdata->cur_cache) { +#endif + /* 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")); +#ifdef USE_MAEMO + } else if(!context->appdata->cur_cache) { + map_draw_gpx(context->appdata, context->widget, context->appdata->cur_gpx); + name = g_strdup(context->appdata->cur_gpx->name); + } else { + map_draw_cache(context->widget, context->appdata->cur_cache); + name = g_strdup(context->appdata->cur_cache->name); + } +#endif + + char *title = g_strdup_printf(_("Map - %s"), name); + g_free(name); + + gtk_window_set_title(GTK_WINDOW(context->window), title); + + g_free(title); +} + void map(appdata_t *appdata) { map_context_t *context = NULL; /* if the map window already exists, just raise it */ if(appdata->map.context) { + printf("using existing map!\n"); gtk_window_present(GTK_WINDOW(appdata->map.context->window)); + map_setup(appdata->map.context); return; } @@ -579,55 +616,28 @@ g_free(path); osm_gps_map_osd_classic_init(OSM_GPS_MAP(context->widget)); - - char *name = NULL; -#ifdef USE_MAEMO - if(!appdata->cur_gpx && !appdata->cur_cache) { -#endif - /* draw all geocaches */ - gpx_t *gpx = appdata->gpx; - while(gpx) { - map_draw_gpx(appdata, context->widget, gpx); - gpx = gpx->next; - } - name = g_strdup(_("all")); -#ifdef USE_MAEMO - } else if(!appdata->cur_cache) { - map_draw_gpx(appdata, context->widget, appdata->cur_gpx); - name = g_strdup(appdata->cur_gpx->name); - } else { - map_draw_cache(context->widget, appdata->cur_cache); - name = g_strdup(appdata->cur_cache->name); - } -#endif - - char *title = g_strdup_printf(_("Map - %s"), name); - g_free(name); #ifdef USE_MAEMO -#ifdef USE_STACKABLE_WINDOW - context->window = hildon_stackable_window_new(); - /* try to enable the zoom buttons. don't do this on x86 as it breaks */ - /* at runtime with cygwin x */ -#ifndef __i386__ + /* we don't use a stackable window here on fremantle, since */ + /* this leaves the main window independent from the map and */ + /* the user can e.g. still navigate the main menu */ + context->window = hildon_window_new(); + +#if (MAEMO_VERSION_MAJOR == 5) && !defined(__i386__) g_signal_connect(G_OBJECT(context->window), "realize", G_CALLBACK(on_window_realize), NULL); #endif // MAEMO_VERSION #else - context->window = hildon_window_new(); -#endif -#else context->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); #endif - gtk_window_set_title(GTK_WINDOW(context->window), title); + /* setup cache state */ + map_setup(context); #ifndef USE_MAEMO gtk_window_set_default_size(GTK_WINDOW(context->window), 640, 480); #endif - g_free(title); - g_signal_connect(G_OBJECT(context->widget), "configure-event", G_CALLBACK(on_map_configure), context);