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

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

revision 125 by harbaum, Sun Sep 27 19:11:37 2009 UTC revision 130 by harbaum, Wed Sep 30 12:11:22 2009 UTC
# Line 229  static cache_t *map_closest(map_context_ Line 229  static cache_t *map_closest(map_context_
229    cache_t *result = NULL;    cache_t *result = NULL;
230    float distance = NAN;    float distance = NAN;
231    
 #ifdef USE_MAEMO  
232    if(!context->appdata->cur_gpx && !context->appdata->cur_cache) {    if(!context->appdata->cur_gpx && !context->appdata->cur_cache) {
 #endif  
233      /* search all geocaches */      /* search all geocaches */
234      gpx_t *gpx = context->appdata->gpx;      gpx_t *gpx = context->appdata->gpx;
235      while(gpx) {      while(gpx) {
236        map_cachelist_nearest(gpx->cache, pos, &result, &distance);        map_cachelist_nearest(gpx->cache, pos, &result, &distance);
237        gpx = gpx->next;        gpx = gpx->next;
238      }      }
 #ifdef USE_MAEMO  
239    } else if(context->appdata->cur_gpx) {    } else if(context->appdata->cur_gpx) {
240      map_cachelist_nearest(context->appdata->cur_gpx->cache,      map_cachelist_nearest(context->appdata->cur_gpx->cache,
241                            pos, &result, &distance);                            pos, &result, &distance);
242    } else    } else
243      result = context->appdata->cur_gpx->cache;      result = context->appdata->cur_gpx->cache;
 #endif  
244    
245    return result;    return result;
246  }  }
# Line 529  on_window_realize(GtkWidget *widget, gpo Line 525  on_window_realize(GtkWidget *widget, gpo
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));  
   
 #ifdef USE_MAEMO  
528    if(!context->appdata->cur_gpx && !context->appdata->cur_cache) {    if(!context->appdata->cur_gpx && !context->appdata->cur_cache) {
529  #endif      if(context->state != MAP_ALL) {
530      /* draw all geocaches */        printf("map_setp(ALL)\n");
531      gpx_t *gpx = context->appdata->gpx;  
532      while(gpx) {        /* clear all existing ccahe images */
533        map_draw_gpx(context->appdata, context->widget, gpx);        osm_gps_map_clear_images (OSM_GPS_MAP(context->widget));
534        gpx = gpx->next;  
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"));  
 #ifdef USE_MAEMO  
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    
548          /* 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");
559    
560          /* clear all existing ccahe images */
561          osm_gps_map_clear_images (OSM_GPS_MAP(context->widget));
562    
563          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    }    }
 #endif  
568    
569    char *title = g_strdup_printf(_("Map - %s"), name);    if(name) {
570    g_free(name);      char *title = g_strdup_printf(_("Map - %s"), name);
571        g_free(name);
572    
573    gtk_window_set_title(GTK_WINDOW(context->window), title);      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 */
582    /* we only need to update the map window if its raised. on ordinary desktops this */
583    /* is different and we always update */
584    static gboolean on_focus_in(GtkWidget *widget, GdkEventFocus *event,
585                             gpointer data) {
586    
587    g_free(title);    map_setup((map_context_t*)data);
588      return FALSE;
589    }
590    #endif
591    
592    void map_update(appdata_t *appdata) {
593    #ifndef USE_MAEMO
594      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) {
# Line 574  void map(appdata_t *appdata) { Line 610  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);
# Line 638  void map(appdata_t *appdata) { Line 675  void map(appdata_t *appdata) {
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",
680                       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);
685    

Legend:
Removed from v.125  
changed lines
  Added in v.130