Diff of /trunk/src/map-tool.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 237 by harbaum, Wed Dec 9 19:45:36 2009 UTC revision 238 by harbaum, Sat Dec 12 12:54:37 2009 UTC
# Line 390  static void map_setup(map_context_t *con Line 390  static void map_setup(map_context_t *con
390      printf("map_setup(keep)\n");      printf("map_setup(keep)\n");
391  }  }
392    
 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;  
 }  
   
393  static void  static void
394  map_cachelist_nearest(cache_t *cache, pos_t *pos,  map_cachelist_nearest(cache_t *cache, pos_t *pos,
395                        cache_t **result, float *distance) {                        cache_t **result, float *distance) {
# Line 922  void map(appdata_t *appdata) { Line 865  void map(appdata_t *appdata) {
865    printf("allocated new context at %p\n", context);    printf("allocated new context at %p\n", context);
866    
867    context->appdata = appdata;    context->appdata = appdata;
   context->map_complete = FALSE;  
868    context->state = MAP_NONE;    context->state = MAP_NONE;
869    
870    /* cleanup old (pre 0.8.7) path if it exists */    /* cleanup old (pre 0.8.7) path if it exists */
# Line 967  void map(appdata_t *appdata) { Line 909  void map(appdata_t *appdata) {
909    
910    osm_gps_map_osd_classic_init(OSM_GPS_MAP(context->widget));    osm_gps_map_osd_classic_init(OSM_GPS_MAP(context->widget));
911    
912      /* set default values if they are invalid */
913      if(!context->appdata->map.zoom ||
914         isnan(context->appdata->map.pos.lat) ||
915         isnan(context->appdata->map.pos.lon)) {
916        printf("no valid map position found\n");
917    
918        pos_t *refpos = get_pos(context->appdata);
919        if(refpos && !isnan(refpos->lat) && !isnan(refpos->lon)) {
920          printf("use refpos\n");
921    
922            /* use gps position if present */
923          context->appdata->map.pos = *refpos;
924          context->appdata->map.zoom = GPS_DEFAULT_ZOOM;
925        } else {
926          printf("use zero pos\n");
927    
928          /* use world map otherwise */
929          context->appdata->map.pos.lat = 0.0;
930          context->appdata->map.pos.lon = 0.0;
931          context->appdata->map.zoom = 1;
932        }
933      }
934    
935      osm_gps_map_set_mapcenter(OSM_GPS_MAP(context->widget),
936                                context->appdata->map.pos.lat,
937                                context->appdata->map.pos.lon,
938                                context->appdata->map.zoom);
939    
940  #ifdef USE_MAEMO  #ifdef USE_MAEMO
941    /* we don't use a stackable window here on fremantle, since */    /* we don't use a stackable window here on fremantle, since */
942    /* this leaves the main window independent from the map and */    /* this leaves the main window independent from the map and */
# Line 991  void map(appdata_t *appdata) { Line 961  void map(appdata_t *appdata) {
961    g_signal_connect(G_OBJECT(context->widget), "focus-out-event",    g_signal_connect(G_OBJECT(context->widget), "focus-out-event",
962                     G_CALLBACK(on_focus_out), context);                     G_CALLBACK(on_focus_out), context);
963    
   g_signal_connect(G_OBJECT(context->widget), "configure-event",  
                    G_CALLBACK(on_map_configure), context);  
   
964    g_signal_connect(G_OBJECT(context->widget), "button-press-event",    g_signal_connect(G_OBJECT(context->widget), "button-press-event",
965                     G_CALLBACK(on_map_button_press_event), context);                     G_CALLBACK(on_map_button_press_event), context);
966    
# Line 1015  void map(appdata_t *appdata) { Line 982  void map(appdata_t *appdata) {
982    
983    gtk_container_add(GTK_CONTAINER(context->window), context->widget);    gtk_container_add(GTK_CONTAINER(context->window), context->widget);
984    gtk_widget_show_all(GTK_WIDGET(context->window));    gtk_widget_show_all(GTK_WIDGET(context->window));
985    
986      /* setup cache state */
987      map_setup(context);
988  }  }

Legend:
Removed from v.237  
changed lines
  Added in v.238