--- trunk/src/map-tool.c 2009/12/10 21:24:43 237 +++ trunk/src/map-tool.c 2009/12/12 12:54:37 238 @@ -390,63 +390,6 @@ printf("map_setup(keep)\n"); } -static gboolean on_map_configure(GtkWidget *widget, - GdkEventConfigure *event, - map_context_t *context) { - - /* for some reason there's a configure event with 1/1 */ - /* on diablo. We just ignore this! */ - - printf("on_map_configure %d %d\n", - widget->allocation.width, - widget->allocation.height); - - if(!context->map_complete && - (widget->allocation.width > 100) && - (widget->allocation.height > 100)) { - - /* setup cache state */ - map_setup(context); - - /* set default values if they are invalid */ - if(!context->appdata->map.zoom || - isnan(context->appdata->map.pos.lat) || - isnan(context->appdata->map.pos.lon)) { - printf("no valid map position found\n"); - - pos_t *refpos = get_pos(context->appdata); - if(refpos && !isnan(refpos->lat) && !isnan(refpos->lon)) { - printf("use refpos\n"); - - /* use gps position if present */ - context->appdata->map.pos = *refpos; - context->appdata->map.zoom = GPS_DEFAULT_ZOOM; - } else { - printf("use zero pos\n"); - - /* use world map otherwise */ - context->appdata->map.pos.lat = 0.0; - context->appdata->map.pos.lon = 0.0; - context->appdata->map.zoom = 1; - } - } - - /* jump to initial position */ - printf("osm_gps_map_set_mapcenter(%f,%f,%d)\n", - context->appdata->map.pos.lat, - context->appdata->map.pos.lon, - context->appdata->map.zoom); - - osm_gps_map_set_mapcenter(OSM_GPS_MAP(context->widget), - context->appdata->map.pos.lat, - context->appdata->map.pos.lon, - context->appdata->map.zoom); - context->map_complete = TRUE; - } - - return FALSE; -} - static void map_cachelist_nearest(cache_t *cache, pos_t *pos, cache_t **result, float *distance) { @@ -922,7 +865,6 @@ printf("allocated new context at %p\n", context); context->appdata = appdata; - context->map_complete = FALSE; context->state = MAP_NONE; /* cleanup old (pre 0.8.7) path if it exists */ @@ -967,6 +909,34 @@ osm_gps_map_osd_classic_init(OSM_GPS_MAP(context->widget)); + /* set default values if they are invalid */ + if(!context->appdata->map.zoom || + isnan(context->appdata->map.pos.lat) || + isnan(context->appdata->map.pos.lon)) { + printf("no valid map position found\n"); + + pos_t *refpos = get_pos(context->appdata); + if(refpos && !isnan(refpos->lat) && !isnan(refpos->lon)) { + printf("use refpos\n"); + + /* use gps position if present */ + context->appdata->map.pos = *refpos; + context->appdata->map.zoom = GPS_DEFAULT_ZOOM; + } else { + printf("use zero pos\n"); + + /* use world map otherwise */ + context->appdata->map.pos.lat = 0.0; + context->appdata->map.pos.lon = 0.0; + context->appdata->map.zoom = 1; + } + } + + osm_gps_map_set_mapcenter(OSM_GPS_MAP(context->widget), + context->appdata->map.pos.lat, + context->appdata->map.pos.lon, + context->appdata->map.zoom); + #ifdef USE_MAEMO /* we don't use a stackable window here on fremantle, since */ /* this leaves the main window independent from the map and */ @@ -991,9 +961,6 @@ g_signal_connect(G_OBJECT(context->widget), "focus-out-event", G_CALLBACK(on_focus_out), context); - g_signal_connect(G_OBJECT(context->widget), "configure-event", - G_CALLBACK(on_map_configure), context); - g_signal_connect(G_OBJECT(context->widget), "button-press-event", G_CALLBACK(on_map_button_press_event), context); @@ -1015,4 +982,7 @@ gtk_container_add(GTK_CONTAINER(context->window), context->widget); gtk_widget_show_all(GTK_WIDGET(context->window)); + + /* setup cache state */ + map_setup(context); }