96 |
|
|
97 |
//where downloaded tiles are cached |
//where downloaded tiles are cached |
98 |
char *cache_dir; |
char *cache_dir; |
|
gboolean cache_dir_is_full_path; |
|
99 |
|
|
100 |
//contains flags indicating the various special characters |
//contains flags indicating the various special characters |
101 |
//the uri string contains, that will be replaced when calculating |
//the uri string contains, that will be replaced when calculating |
188 |
PROP_REPO_URI, |
PROP_REPO_URI, |
189 |
PROP_PROXY_URI, |
PROP_PROXY_URI, |
190 |
PROP_TILE_CACHE_DIR, |
PROP_TILE_CACHE_DIR, |
|
PROP_TILE_CACHE_DIR_IS_FULL_PATH, |
|
191 |
PROP_ZOOM, |
PROP_ZOOM, |
192 |
PROP_MAX_ZOOM, |
PROP_MAX_ZOOM, |
193 |
PROP_MIN_ZOOM, |
PROP_MIN_ZOOM, |
1496 |
gboolean handled = FALSE; |
gboolean handled = FALSE; |
1497 |
int step = GTK_WIDGET(widget)->allocation.width/OSM_GPS_MAP_SCROLL_STEP; |
int step = GTK_WIDGET(widget)->allocation.width/OSM_GPS_MAP_SCROLL_STEP; |
1498 |
|
|
1499 |
printf("key event with keyval %x\n", event->keyval); |
// printf("key event with keyval %x\n", event->keyval); |
1500 |
|
|
1501 |
// the map handles some keys on its own ... |
// the map handles some keys on its own ... |
1502 |
switch(event->keyval) { |
switch(event->keyval) { |
1564 |
#endif |
#endif |
1565 |
|
|
1566 |
default: |
default: |
1567 |
printf("unhandled key event with keyval %x\n", event->keyval); |
// printf("unhandled key event with keyval %x\n", event->keyval); |
1568 |
break; |
break; |
1569 |
} |
} |
1570 |
|
|
1689 |
} |
} |
1690 |
} |
} |
1691 |
|
|
1692 |
if (!priv->cache_dir_is_full_path) { |
const char *fname = osm_gps_map_source_get_friendly_name(priv->map_source); |
1693 |
const char *fname = osm_gps_map_source_get_friendly_name(priv->map_source); |
if(!fname) fname = "_unknown_"; |
1694 |
if(!fname) fname = "_unknown_"; |
|
1695 |
|
if (priv->cache_dir) { |
1696 |
if (priv->cache_dir) { |
char *old = priv->cache_dir; |
1697 |
char *old = priv->cache_dir; |
//the new cachedir is the given cache dir + the md5 of the repo_uri |
1698 |
//the new cachedir is the given cache dir + the md5 of the repo_uri |
priv->cache_dir = g_strdup_printf("%s%c%s", old, G_DIR_SEPARATOR, fname); |
1699 |
priv->cache_dir = g_strdup_printf("%s%c%s", old, G_DIR_SEPARATOR, fname); |
g_debug("Adjusting cache dir %s -> %s", old, priv->cache_dir); |
1700 |
g_debug("Adjusting cache dir %s -> %s", old, priv->cache_dir); |
g_free(old); |
|
g_free(old); |
|
|
} else { |
|
|
//the new cachedir is the current dir + the md5 of the repo_uri |
|
|
priv->cache_dir = g_strdup(fname); |
|
|
} |
|
1701 |
} |
} |
1702 |
|
|
1703 |
inspect_map_uri(map); |
inspect_map_uri(map); |
1821 |
if ( g_value_get_string(value) ) |
if ( g_value_get_string(value) ) |
1822 |
priv->cache_dir = g_value_dup_string (value); |
priv->cache_dir = g_value_dup_string (value); |
1823 |
break; |
break; |
|
case PROP_TILE_CACHE_DIR_IS_FULL_PATH: |
|
|
priv->cache_dir_is_full_path = g_value_get_boolean (value); |
|
|
break; |
|
1824 |
case PROP_ZOOM: |
case PROP_ZOOM: |
1825 |
priv->map_zoom = g_value_get_int (value); |
priv->map_zoom = g_value_get_int (value); |
1826 |
break; |
break; |
1890 |
case PROP_TILE_CACHE_DIR: |
case PROP_TILE_CACHE_DIR: |
1891 |
g_value_set_string(value, priv->cache_dir); |
g_value_set_string(value, priv->cache_dir); |
1892 |
break; |
break; |
|
case PROP_TILE_CACHE_DIR_IS_FULL_PATH: |
|
|
g_value_set_boolean(value, priv->cache_dir_is_full_path); |
|
|
break; |
|
1893 |
case PROP_ZOOM: |
case PROP_ZOOM: |
1894 |
g_value_set_int(value, priv->map_zoom); |
g_value_set_int(value, priv->map_zoom); |
1895 |
break; |
break; |
2183 |
GdkDrawable *drawable = widget->window; |
GdkDrawable *drawable = widget->window; |
2184 |
#endif |
#endif |
2185 |
|
|
2186 |
gdk_draw_drawable (drawable, |
if (!priv->dragging) |
2187 |
widget->style->fg_gc[GTK_WIDGET_STATE (widget)], |
{ |
2188 |
priv->pixmap, |
gdk_draw_drawable (drawable, |
2189 |
0,0, |
widget->style->fg_gc[GTK_WIDGET_STATE (widget)], |
2190 |
priv->drag_mouse_dx - EXTRA_BORDER, |
priv->pixmap, |
2191 |
priv->drag_mouse_dy - EXTRA_BORDER, |
event->area.x + EXTRA_BORDER, event->area.y + EXTRA_BORDER, |
2192 |
-1,-1); |
event->area.x, event->area.y, |
2193 |
|
event->area.width, event->area.height); |
2194 |
//Paint white outside of the map if dragging. Its less |
} |
2195 |
//ugly than painting the corrupted map |
else |
2196 |
if(priv->drag_mouse_dx>EXTRA_BORDER) { |
{ |
2197 |
gdk_draw_rectangle (drawable, |
gdk_draw_drawable (drawable, |
2198 |
widget->style->white_gc, |
widget->style->fg_gc[GTK_WIDGET_STATE (widget)], |
2199 |
TRUE, |
priv->pixmap, |
2200 |
0, 0, |
0,0, |
2201 |
priv->drag_mouse_dx - EXTRA_BORDER, |
priv->drag_mouse_dx - EXTRA_BORDER, |
2202 |
widget->allocation.height); |
priv->drag_mouse_dy - EXTRA_BORDER, |
2203 |
} |
-1,-1); |
2204 |
else if (-priv->drag_mouse_dx > EXTRA_BORDER) |
|
2205 |
{ |
//Paint white outside of the map if dragging. Its less |
2206 |
gdk_draw_rectangle (drawable, |
//ugly than painting the corrupted map |
2207 |
widget->style->white_gc, |
if(priv->drag_mouse_dx>EXTRA_BORDER) { |
2208 |
TRUE, |
gdk_draw_rectangle (drawable, |
2209 |
priv->drag_mouse_dx + widget->allocation.width + EXTRA_BORDER, 0, |
widget->style->white_gc, |
2210 |
-priv->drag_mouse_dx - EXTRA_BORDER, |
TRUE, |
2211 |
widget->allocation.height); |
0, 0, |
2212 |
} |
priv->drag_mouse_dx - EXTRA_BORDER, |
2213 |
|
widget->allocation.height); |
2214 |
if (priv->drag_mouse_dy>EXTRA_BORDER) { |
} |
2215 |
gdk_draw_rectangle (drawable, |
else if (-priv->drag_mouse_dx > EXTRA_BORDER) |
2216 |
widget->style->white_gc, |
{ |
2217 |
TRUE, |
gdk_draw_rectangle (drawable, |
2218 |
0, 0, |
widget->style->white_gc, |
2219 |
widget->allocation.width, |
TRUE, |
2220 |
priv->drag_mouse_dy - EXTRA_BORDER); |
priv->drag_mouse_dx + widget->allocation.width + EXTRA_BORDER, 0, |
2221 |
} |
-priv->drag_mouse_dx - EXTRA_BORDER, |
2222 |
else if (-priv->drag_mouse_dy > EXTRA_BORDER) |
widget->allocation.height); |
2223 |
{ |
} |
2224 |
gdk_draw_rectangle (drawable, |
|
2225 |
widget->style->white_gc, |
if (priv->drag_mouse_dy>EXTRA_BORDER) { |
2226 |
TRUE, |
gdk_draw_rectangle (drawable, |
2227 |
0, priv->drag_mouse_dy + widget->allocation.height + EXTRA_BORDER, |
widget->style->white_gc, |
2228 |
widget->allocation.width, |
TRUE, |
2229 |
-priv->drag_mouse_dy - EXTRA_BORDER); |
0, 0, |
2230 |
|
widget->allocation.width, |
2231 |
|
priv->drag_mouse_dy - EXTRA_BORDER); |
2232 |
|
} |
2233 |
|
else if (-priv->drag_mouse_dy > EXTRA_BORDER) |
2234 |
|
{ |
2235 |
|
gdk_draw_rectangle (drawable, |
2236 |
|
widget->style->white_gc, |
2237 |
|
TRUE, |
2238 |
|
0, priv->drag_mouse_dy + widget->allocation.height + EXTRA_BORDER, |
2239 |
|
widget->allocation.width, |
2240 |
|
-priv->drag_mouse_dy - EXTRA_BORDER); |
2241 |
|
} |
2242 |
} |
} |
2243 |
|
|
2244 |
#ifdef ENABLE_OSD |
#ifdef ENABLE_OSD |
2336 |
G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); |
G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); |
2337 |
|
|
2338 |
g_object_class_install_property (object_class, |
g_object_class_install_property (object_class, |
|
PROP_TILE_CACHE_DIR_IS_FULL_PATH, |
|
|
g_param_spec_boolean ("tile-cache-is-full-path", |
|
|
"tile cache is full path", |
|
|
"if true, the path passed to tile-cache is interpreted as the full cache path", |
|
|
FALSE, |
|
|
G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); |
|
|
|
|
|
g_object_class_install_property (object_class, |
|
2339 |
PROP_ZOOM, |
PROP_ZOOM, |
2340 |
g_param_spec_int ("zoom", |
g_param_spec_int ("zoom", |
2341 |
"zoom", |
"zoom", |
2475 |
return "OpenStreetMap"; |
return "OpenStreetMap"; |
2476 |
case OSM_GPS_MAP_SOURCE_OPENSTREETMAP_RENDERER: |
case OSM_GPS_MAP_SOURCE_OPENSTREETMAP_RENDERER: |
2477 |
return "OpenStreetMap Renderer"; |
return "OpenStreetMap Renderer"; |
2478 |
case OSM_GPS_MAP_SOURCE_OPENAERIALMAP: |
case OSM_GPS_MAP_SOURCE_OPENCYCLEMAP: |
2479 |
return "OpenAerialMap"; |
return "OpenCycleMap"; |
2480 |
case OSM_GPS_MAP_SOURCE_MAPS_FOR_FREE: |
case OSM_GPS_MAP_SOURCE_MAPS_FOR_FREE: |
2481 |
return "Maps-For-Free"; |
return "Maps-For-Free"; |
2482 |
case OSM_GPS_MAP_SOURCE_GOOGLE_STREET: |
case OSM_GPS_MAP_SOURCE_GOOGLE_STREET: |
2518 |
return OSM_REPO_URI; |
return OSM_REPO_URI; |
2519 |
case OSM_GPS_MAP_SOURCE_OPENSTREETMAP_RENDERER: |
case OSM_GPS_MAP_SOURCE_OPENSTREETMAP_RENDERER: |
2520 |
return "http://tah.openstreetmap.org/Tiles/tile/#Z/#X/#Y.png"; |
return "http://tah.openstreetmap.org/Tiles/tile/#Z/#X/#Y.png"; |
2521 |
case OSM_GPS_MAP_SOURCE_OPENAERIALMAP: |
case OSM_GPS_MAP_SOURCE_OPENCYCLEMAP: |
2522 |
return "http://tile.openaerialmap.org/tiles/1.0.0/openaerialmap-900913/#Z/#X/#Y.jpg"; |
return "http://c.andy.sandbox.cloudmade.com/tiles/cycle/#Z/#X/#Y.png"; |
2523 |
case OSM_GPS_MAP_SOURCE_MAPS_FOR_FREE: |
case OSM_GPS_MAP_SOURCE_MAPS_FOR_FREE: |
2524 |
return "http://maps-for-free.com/layer/relief/z#Z/row#Y/#Z_#X-#Y.jpg"; |
return "http://maps-for-free.com/layer/relief/z#Z/row#Y/#Z_#X-#Y.jpg"; |
2525 |
case OSM_GPS_MAP_SOURCE_GOOGLE_STREET: |
case OSM_GPS_MAP_SOURCE_GOOGLE_STREET: |
2557 |
case OSM_GPS_MAP_SOURCE_NULL: |
case OSM_GPS_MAP_SOURCE_NULL: |
2558 |
case OSM_GPS_MAP_SOURCE_OPENSTREETMAP: |
case OSM_GPS_MAP_SOURCE_OPENSTREETMAP: |
2559 |
case OSM_GPS_MAP_SOURCE_OPENSTREETMAP_RENDERER: |
case OSM_GPS_MAP_SOURCE_OPENSTREETMAP_RENDERER: |
2560 |
|
case OSM_GPS_MAP_SOURCE_OPENCYCLEMAP: |
2561 |
return "png"; |
return "png"; |
|
case OSM_GPS_MAP_SOURCE_OPENAERIALMAP: |
|
2562 |
case OSM_GPS_MAP_SOURCE_GOOGLE_STREET: |
case OSM_GPS_MAP_SOURCE_GOOGLE_STREET: |
2563 |
case OSM_GPS_MAP_SOURCE_GOOGLE_HYBRID: |
case OSM_GPS_MAP_SOURCE_GOOGLE_HYBRID: |
2564 |
case OSM_GPS_MAP_SOURCE_VIRTUAL_EARTH_STREET: |
case OSM_GPS_MAP_SOURCE_VIRTUAL_EARTH_STREET: |
2592 |
case OSM_GPS_MAP_SOURCE_OPENSTREETMAP: |
case OSM_GPS_MAP_SOURCE_OPENSTREETMAP: |
2593 |
return OSM_MAX_ZOOM; |
return OSM_MAX_ZOOM; |
2594 |
case OSM_GPS_MAP_SOURCE_OPENSTREETMAP_RENDERER: |
case OSM_GPS_MAP_SOURCE_OPENSTREETMAP_RENDERER: |
2595 |
case OSM_GPS_MAP_SOURCE_OPENAERIALMAP: |
case OSM_GPS_MAP_SOURCE_OPENCYCLEMAP: |
2596 |
case OSM_GPS_MAP_SOURCE_GOOGLE_STREET: |
case OSM_GPS_MAP_SOURCE_GOOGLE_STREET: |
2597 |
case OSM_GPS_MAP_SOURCE_GOOGLE_HYBRID: |
case OSM_GPS_MAP_SOURCE_GOOGLE_HYBRID: |
2598 |
case OSM_GPS_MAP_SOURCE_VIRTUAL_EARTH_STREET: |
case OSM_GPS_MAP_SOURCE_VIRTUAL_EARTH_STREET: |