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

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

revision 48 by harbaum, Fri Aug 7 07:57:33 2009 UTC revision 53 by harbaum, Wed Aug 12 19:18:53 2009 UTC
# Line 123  cb_map_gps(GtkButton *button, map_contex Line 123  cb_map_gps(GtkButton *button, map_contex
123  }  }
124    
125  static GtkWidget  static GtkWidget
126  *map_add_button(const gchar *icon, GCallback cb, gpointer data,  *map_add_button(int icon, GCallback cb, gpointer data,
127                  char *tooltip) {                  char *tooltip) {
128    GtkWidget *button = gtk_button_new();    GtkWidget *button = gtk_button_new();
129    gtk_button_set_image(GTK_BUTTON(button),    gtk_button_set_image(GTK_BUTTON(button), icon_get_widget(ICON_MISC, icon));
                        gtk_image_new_from_stock(icon, GTK_ICON_SIZE_BUTTON));  
130    g_signal_connect(button, "clicked", cb, data);    g_signal_connect(button, "clicked", cb, data);
131  #ifndef USE_MAEMO  #ifndef USE_MAEMO
132    gtk_widget_set_tooltip_text(button, tooltip);    gtk_widget_set_tooltip_text(button, tooltip);
# Line 138  static GtkWidget Line 137  static GtkWidget
137  static gboolean map_gps_update(gpointer data) {  static gboolean map_gps_update(gpointer data) {
138    map_context_t *context = (map_context_t*)data;    map_context_t *context = (map_context_t*)data;
139    
140      /* get reference position ... */
141    pos_t *refpos = get_pos(context->appdata);    pos_t *refpos = get_pos(context->appdata);
142    gboolean ok = (refpos!= NULL) && !isnan(refpos->lat) && !isnan(refpos->lon);    gboolean ok = (refpos!= NULL) && !isnan(refpos->lat) && !isnan(refpos->lon);
143    
144    /* get reference position and go there */    /* ... and enable "goto" button if it's valid */
145    gtk_widget_set_sensitive(context->gps, ok);    gtk_widget_set_sensitive(context->gps, ok);
146    
147      if(ok) {
148        float heading = NAN;
149        int radius = 20;
150    
151        if(context->appdata->use_gps) {
152          heading = gps_get_heading(context->appdata);
153    
154          /* get error */
155          float eph = gps_get_eph(context->appdata);
156          if(!isnan(eph)) {
157    
158            /* world at zoom 1 == 512 pixels */
159            gint zoom;
160            g_object_get(OSM_GPS_MAP(context->widget), "zoom", &zoom, NULL);
161            float m_per_pix =
162              cos(DEG2RAD(refpos->lat))*2*M_PI*EQ_RADIUS/(1<<(8+zoom));
163    
164            radius = eph/m_per_pix;
165          }
166        }
167    
168        g_object_set(context->widget, "gps-track-highlight-radius", radius, NULL);
169        osm_gps_map_draw_gps(OSM_GPS_MAP(context->widget),
170                             refpos->lat, refpos->lon, heading);
171      } else
172        osm_gps_map_clear_gps(OSM_GPS_MAP(context->widget));
173    
174    return TRUE;    return TRUE;
175  }  }
176    
# Line 650  void map(appdata_t *appdata) { Line 677  void map(appdata_t *appdata) {
677    const char *proxy = get_proxy_uri(appdata);    const char *proxy = get_proxy_uri(appdata);
678    
679    context->widget = g_object_new(OSM_TYPE_GPS_MAP,    context->widget = g_object_new(OSM_TYPE_GPS_MAP,
680                  "repo-uri", MAP_SOURCE_OPENSTREETMAP,                   "repo-uri",             MAP_SOURCE_OPENSTREETMAP,
681                  "tile-cache", path,                   "tile-cache",           path,
682                  proxy?"proxy-uri":NULL, proxy,                   "auto-center",          FALSE,
683                     "record-trip-history",  FALSE,
684                     "show-trip-history",    FALSE,
685                   NULL);                   NULL);
686    
687      if(proxy)
688        g_object_set(OSM_GPS_MAP(context->widget), "proxy-uri", proxy, NULL);
689    
690    g_free(path);    g_free(path);
691    
692    char *name = NULL;    char *name = NULL;
# Line 711  void map(appdata_t *appdata) { Line 743  void map(appdata_t *appdata) {
743    GtkWidget *vbox = gtk_vbox_new(FALSE,0);    GtkWidget *vbox = gtk_vbox_new(FALSE,0);
744    
745    context->zoomin =    context->zoomin =
746      map_add_button(GTK_STOCK_ZOOM_IN, G_CALLBACK(cb_map_zoomin),      map_add_button(10, G_CALLBACK(cb_map_zoomin),
747                     context, _("Zoom in"));                     context, _("Zoom in"));
748    gtk_box_pack_start(GTK_BOX(vbox), context->zoomin, FALSE, FALSE, 0);    gtk_box_pack_start(GTK_BOX(vbox), context->zoomin, FALSE, FALSE, 0);
749    
750    context->zoomout =    context->zoomout =
751      map_add_button(GTK_STOCK_ZOOM_OUT, G_CALLBACK(cb_map_zoomout),      map_add_button(11, G_CALLBACK(cb_map_zoomout),
752                     context, _("Zoom out"));                     context, _("Zoom out"));
753    gtk_box_pack_start(GTK_BOX(vbox), context->zoomout, FALSE, FALSE, 0);    gtk_box_pack_start(GTK_BOX(vbox), context->zoomout, FALSE, FALSE, 0);
754    
755    context->gps =    context->gps =
756      map_add_button(GTK_STOCK_HOME, G_CALLBACK(cb_map_gps),      map_add_button(9, G_CALLBACK(cb_map_gps),
757                     context, _("Jump to GPS position"));                     context, _("Jump to GPS position"));
758    gtk_widget_set_sensitive(context->gps, FALSE);    gtk_widget_set_sensitive(context->gps, FALSE);
759    /* install handler for timed updates of the gps button */    /* install handler for timed updates of the gps button */

Legend:
Removed from v.48  
changed lines
  Added in v.53