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

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

revision 144 by harbaum, Tue Oct 27 08:38:31 2009 UTC revision 149 by harbaum, Thu Oct 29 13:59:16 2009 UTC
# Line 109  static int dist2pixel(map_context_t *con Line 109  static int dist2pixel(map_context_t *con
109    
110  static gboolean map_gps_update(gpointer data) {  static gboolean map_gps_update(gpointer data) {
111    map_context_t *context = (map_context_t*)data;    map_context_t *context = (map_context_t*)data;
112      static gboolean goto_is_enabled = FALSE;
113    
114    /* get reference position ... */    /* get reference position ... */
115    pos_t *refpos = get_pos(context->appdata);    pos_t *refpos = get_pos(context->appdata);
116    gboolean ok = (refpos!= NULL) && !isnan(refpos->lat) && !isnan(refpos->lon);    gboolean ok = (refpos!= NULL) && !isnan(refpos->lat) && !isnan(refpos->lon);
117    
118    /* ... and enable "goto" button if it's valid */    /* ... and enable "goto" button if it's valid */
119    osm_gps_map_osd_enable_gps (OSM_GPS_MAP(context->widget),    if(ok != goto_is_enabled) {
120                   OSM_GPS_MAP_OSD_CALLBACK(ok?cb_map_gps:NULL), context);      osm_gps_map_osd_enable_gps (OSM_GPS_MAP(context->widget),
121                    OSM_GPS_MAP_OSD_CALLBACK(ok?cb_map_gps:NULL), context);
122        goto_is_enabled = ok;
123      }
124    
125    if(ok) {    if(ok) {
126      float heading = NAN;      float heading = NAN;
# Line 131  static gboolean map_gps_update(gpointer Line 135  static gboolean map_gps_update(gpointer
135          radius = dist2pixel(context, eph/1000, refpos->lat);          radius = dist2pixel(context, eph/1000, refpos->lat);
136      }      }
137    
138        /* TODO: in order to save energy: only draw if state actually changed */
139    
140      g_object_set(context->widget, "gps-track-highlight-radius", radius, NULL);      g_object_set(context->widget, "gps-track-highlight-radius", radius, NULL);
141      osm_gps_map_draw_gps(OSM_GPS_MAP(context->widget),      osm_gps_map_draw_gps(OSM_GPS_MAP(context->widget),
142                           refpos->lat, refpos->lon, heading);                           refpos->lat, refpos->lon, heading);
# Line 664  static void on_window_destroy(GtkWidget Line 670  static void on_window_destroy(GtkWidget
670  #endif  #endif
671    
672    gtk_timeout_remove(context->handler_id);    gtk_timeout_remove(context->handler_id);
673      gps_unregister_callback(appdata, context->cb_id);
674    
675    g_free(context);    g_free(context);
676    appdata->map.context = NULL;    appdata->map.context = NULL;
# Line 707  void map_update(appdata_t *appdata) { Line 714  void map_update(appdata_t *appdata) {
714  #endif  #endif
715  }  }
716    
717    /* callback called by the gps layer whenever gps state changes */
718    static void
719    gps_callback(struct gps_state *state, gpointer data) {
720      printf("map: gps callback\n");
721    }
722    
723  void map(appdata_t *appdata) {  void map(appdata_t *appdata) {
724    map_context_t *context = NULL;    map_context_t *context = NULL;
725    
# Line 797  void map(appdata_t *appdata) { Line 810  void map(appdata_t *appdata) {
810    
811    /* install handler for timed updates of the gps button */    /* install handler for timed updates of the gps button */
812    context->handler_id = gtk_timeout_add(1000, map_gps_update, context);    context->handler_id = gtk_timeout_add(1000, map_gps_update, context);
813      context->cb_id = gps_register_callback(appdata, gps_callback, context);
814    
815  #if MAEMO_VERSION_MAJOR == 5  #if MAEMO_VERSION_MAJOR == 5
816    /* prevent some of the main screen things */    /* prevent some of the main screen things */

Legend:
Removed from v.144  
changed lines
  Added in v.149