41 |
#include <X11/Xatom.h> |
#include <X11/Xatom.h> |
42 |
#endif |
#endif |
43 |
|
|
44 |
|
/* any defined key enables key support */ |
45 |
|
#if (defined(MAP_KEY_FULLSCREEN) || \ |
46 |
|
defined(MAP_KEY_ZOOMIN) || \ |
47 |
|
defined(MAP_KEY_ZOOMOUT) || \ |
48 |
|
defined(MAP_KEY_UP) || \ |
49 |
|
defined(MAP_KEY_DOWN) || \ |
50 |
|
defined(MAP_KEY_LEFT) || \ |
51 |
|
defined(MAP_KEY_RIGHT)) |
52 |
|
#include <gdk/gdkkeysyms.h> |
53 |
|
#endif |
54 |
|
|
55 |
/* default values */ |
/* default values */ |
56 |
#define MAP_SOURCE OSM_GPS_MAP_SOURCE_OPENCYCLEMAP |
#define MAP_SOURCE OSM_GPS_MAP_SOURCE_OPENCYCLEMAP |
57 |
#define GPS_DEFAULT_ZOOM 13 |
#define GPS_DEFAULT_ZOOM 13 |
132 |
} |
} |
133 |
|
|
134 |
float map_gps_get_eph(map_context_t *context) { |
float map_gps_get_eph(map_context_t *context) { |
135 |
if(context->gps.set & FIX_LATLON_SET) |
if(context->gps.set & FIX_HERR_SET) |
136 |
return context->gps.fix.eph; |
return context->gps.fix.eph; |
137 |
|
|
138 |
return NAN; |
return NAN; |
153 |
cb_map_gps(osd_button_t but, map_context_t *context) { |
cb_map_gps(osd_button_t but, map_context_t *context) { |
154 |
|
|
155 |
if(but == OSD_GPS) { |
if(but == OSD_GPS) { |
|
printf("clicked OSD_GPS %p\n", context); |
|
|
printf("clicked OSD_GPS a %p\n", context->appdata); |
|
|
|
|
156 |
pos_t *refpos = get_pos(context->appdata); |
pos_t *refpos = get_pos(context->appdata); |
157 |
if(refpos && !isnan(refpos->lat) && !isnan(refpos->lon)) { |
if(refpos && !isnan(refpos->lat) && !isnan(refpos->lon)) { |
158 |
gint zoom; |
gint zoom; |
906 |
#endif |
#endif |
907 |
|
|
908 |
gtk_timeout_remove(context->handler_id); |
gtk_timeout_remove(context->handler_id); |
|
gps_unregister_callback(appdata->gps_state, gps_callback); |
|
909 |
|
|
910 |
if(context->caches_displayed) { |
if(context->caches_displayed) { |
911 |
g_free(context->caches_displayed); |
g_free(context->caches_displayed); |
952 |
context->handler_id = gtk_timeout_add(1000, map_gps_update, context); |
context->handler_id = gtk_timeout_add(1000, map_gps_update, context); |
953 |
#endif |
#endif |
954 |
|
|
955 |
|
gps_register_callback(context->appdata->gps_state, |
956 |
|
LATLON_CHANGED | HERR_CHANGED | TRACK_CHANGED, |
957 |
|
gps_callback, context); |
958 |
|
|
959 |
map_setup(context); |
map_setup(context); |
960 |
return FALSE; |
return FALSE; |
961 |
} |
} |
978 |
context->handler_id = 0; |
context->handler_id = 0; |
979 |
#endif |
#endif |
980 |
|
|
981 |
|
gps_unregister_callback(context->appdata->gps_state, gps_callback); |
982 |
|
|
983 |
return FALSE; |
return FALSE; |
984 |
} |
} |
985 |
|
|
991 |
#endif |
#endif |
992 |
} |
} |
993 |
|
|
994 |
|
static gboolean |
995 |
|
on_map_window_key_press(GtkWidget *window, GdkEventKey *event, GtkWidget *map) { |
996 |
|
#ifdef USE_MAEMO |
997 |
|
if((event->keyval == HILDON_HARDKEY_FULLSCREEN) || |
998 |
|
(event->keyval == HILDON_HARDKEY_INCREASE) || |
999 |
|
(event->keyval == HILDON_HARDKEY_DECREASE)) |
1000 |
|
#else |
1001 |
|
if(event->keyval == GDK_F11) |
1002 |
|
#endif |
1003 |
|
{ |
1004 |
|
gboolean return_val; |
1005 |
|
g_signal_emit_by_name(GTK_OBJECT(map), "key_press_event", |
1006 |
|
event, &return_val); |
1007 |
|
return return_val; |
1008 |
|
} |
1009 |
|
|
1010 |
|
return FALSE; |
1011 |
|
} |
1012 |
|
|
1013 |
void map(appdata_t *appdata) { |
void map(appdata_t *appdata) { |
1014 |
map_context_t *context = NULL; |
map_context_t *context = NULL; |
1015 |
|
|
1092 |
context->appdata->map.zoom = 1; |
context->appdata->map.zoom = 1; |
1093 |
} |
} |
1094 |
} |
} |
1095 |
|
|
1096 |
|
int key_maps[][2] = { |
1097 |
|
{ OSM_GPS_MAP_KEY_FULLSCREEN, MAP_KEY_FULLSCREEN }, |
1098 |
|
{ OSM_GPS_MAP_KEY_ZOOMIN, MAP_KEY_ZOOMIN }, |
1099 |
|
{ OSM_GPS_MAP_KEY_ZOOMOUT, MAP_KEY_ZOOMOUT }, |
1100 |
|
{ OSM_GPS_MAP_KEY_UP, MAP_KEY_UP }, |
1101 |
|
{ OSM_GPS_MAP_KEY_DOWN, MAP_KEY_DOWN }, |
1102 |
|
{ OSM_GPS_MAP_KEY_LEFT, MAP_KEY_LEFT }, |
1103 |
|
{ OSM_GPS_MAP_KEY_RIGHT, MAP_KEY_RIGHT }, |
1104 |
|
{ OSM_GPS_MAP_KEY_MAX, 0 } }; |
1105 |
|
|
1106 |
|
int i; |
1107 |
|
for(i=0;key_maps[i][0] != OSM_GPS_MAP_KEY_MAX;i++) |
1108 |
|
osm_gps_map_set_keyboard_shortcut(OSM_GPS_MAP(context->widget), |
1109 |
|
key_maps[i][0], key_maps[i][1]); |
1110 |
|
|
1111 |
osm_gps_map_set_mapcenter(OSM_GPS_MAP(context->widget), |
osm_gps_map_set_mapcenter(OSM_GPS_MAP(context->widget), |
1112 |
context->appdata->map.pos.lat, |
context->appdata->map.pos.lat, |
1113 |
context->appdata->map.pos.lon, |
context->appdata->map.pos.lon, |
1145 |
|
|
1146 |
/* install handler for timed updates of the gps button */ |
/* install handler for timed updates of the gps button */ |
1147 |
context->handler_id = gtk_timeout_add(1000, map_gps_update, context); |
context->handler_id = gtk_timeout_add(1000, map_gps_update, context); |
|
gps_register_callback(appdata->gps_state, LATLON_CHANGED | HERR_CHANGED, |
|
|
gps_callback, context); |
|
1148 |
|
|
1149 |
#if MAEMO_VERSION_MAJOR == 5 |
#if MAEMO_VERSION_MAJOR == 5 |
1150 |
/* prevent some of the main screen things */ |
/* prevent some of the main screen things */ |
1155 |
g_signal_connect(G_OBJECT(context->window), "destroy", |
g_signal_connect(G_OBJECT(context->window), "destroy", |
1156 |
G_CALLBACK(on_window_destroy), context); |
G_CALLBACK(on_window_destroy), context); |
1157 |
|
|
1158 |
|
/* connect a key handler to forward global shortcuts (function keys) */ |
1159 |
|
/* to the ap widget */ |
1160 |
|
g_signal_connect(G_OBJECT(context->window), "key_press_event", |
1161 |
|
G_CALLBACK(on_map_window_key_press), context->widget); |
1162 |
|
|
1163 |
gtk_container_add(GTK_CONTAINER(context->window), context->widget); |
gtk_container_add(GTK_CONTAINER(context->window), context->widget); |
1164 |
gtk_widget_show_all(GTK_WIDGET(context->window)); |
gtk_widget_show_all(GTK_WIDGET(context->window)); |
1165 |
|
|