123 |
free(buf); |
free(buf); |
124 |
} |
} |
125 |
|
|
126 |
|
/* ------------ app specific gps helper functions, not part -------------- */ |
127 |
|
/* --------------------- of the generic gps.[ch] ------------------------ */ |
128 |
|
|
129 |
|
void gps_change_state(appdata_t *appdata) { |
130 |
|
gps_enable(appdata->gps_state, appdata->use_gps); |
131 |
|
} |
132 |
|
|
133 |
|
pos_t *gps_get_pos(appdata_t *appdata) { |
134 |
|
static pos_t pos; |
135 |
|
|
136 |
|
if(appdata->gps.set & FIX_LATLON_SET) { |
137 |
|
pos.lat = appdata->gps.fix.latitude; |
138 |
|
pos.lon = appdata->gps.fix.longitude; |
139 |
|
return &pos; |
140 |
|
} |
141 |
|
|
142 |
|
return NULL; |
143 |
|
} |
144 |
|
|
145 |
|
float gps_get_heading(appdata_t *appdata) { |
146 |
|
if(appdata->gps.set & FIX_TRACK_SET) |
147 |
|
return appdata->gps.fix.track; |
148 |
|
|
149 |
|
return NAN; |
150 |
|
} |
151 |
|
|
152 |
|
gint gps_get_satnum(appdata_t *appdata) { |
153 |
|
printf("set = %x/%x (snum = %d)\n", |
154 |
|
appdata->gps.set, FIX_SATELLITE_SET, |
155 |
|
appdata->gps.fix.sat_num); |
156 |
|
|
157 |
|
if(appdata->gps.set & FIX_SATELLITE_SET) |
158 |
|
return appdata->gps.fix.sat_num; |
159 |
|
|
160 |
|
return 0; |
161 |
|
} |
162 |
|
|
163 |
|
gps_sat_t *gps_get_sats(appdata_t *appdata) { |
164 |
|
if(appdata->gps.set & FIX_SATELLITE_SET) |
165 |
|
return appdata->gps.fix.sat_data; |
166 |
|
|
167 |
|
return NULL; |
168 |
|
} |
169 |
|
|
170 |
|
float gps_get_eph(appdata_t *appdata) { |
171 |
|
if(appdata->gps.set & FIX_HERR_SET) |
172 |
|
return appdata->gps.fix.eph; |
173 |
|
|
174 |
|
return NAN; |
175 |
|
} |
176 |
|
|
177 |
|
static void |
178 |
|
main_gps_cb(gps_mask_t set, struct gps_t *fix, void *data) { |
179 |
|
appdata_t *appdata = (appdata_t*)data; |
180 |
|
|
181 |
|
appdata->gps.set = set; |
182 |
|
memcpy(&appdata->gps.fix, fix, sizeof(struct gps_t)); |
183 |
|
} |
184 |
|
|
185 |
gpx_t *choose_file(appdata_t *appdata, gboolean whole_dir) { |
gpx_t *choose_file(appdata_t *appdata, gboolean whole_dir) { |
186 |
GtkWidget *dialog; |
GtkWidget *dialog; |
187 |
gpx_t *gpx = NULL; |
gpx_t *gpx = NULL; |
504 |
return FALSE; |
return FALSE; |
505 |
} |
} |
506 |
|
|
507 |
|
gboolean on_main_focus_change(GtkWidget *widget, GdkEventFocus *event, |
508 |
|
gpointer user_data) { |
509 |
|
appdata_t *appdata = (appdata_t*)user_data; |
510 |
|
g_assert(appdata->gps_state); |
511 |
|
|
512 |
|
printf("main/cachelist focus-%s event\n", event->in?"in":"out"); |
513 |
|
|
514 |
|
/* disconnect from gps if map looses focus */ |
515 |
|
/* this is to save energy if maep runs in background */ |
516 |
|
|
517 |
|
if(event->in) { |
518 |
|
/* request all GPS information required for map display */ |
519 |
|
gps_register_callback(appdata->gps_state, |
520 |
|
LATLON_CHANGED | TRACK_CHANGED | HERR_CHANGED | SATELLITE_CHANGED, |
521 |
|
main_gps_cb, appdata); |
522 |
|
} else |
523 |
|
gps_unregister_callback(appdata->gps_state, main_gps_cb); |
524 |
|
|
525 |
|
return FALSE; |
526 |
|
} |
527 |
|
|
528 |
static GtkWidget *cachelist_create(appdata_t *appdata, gpx_t *gpx, |
static GtkWidget *cachelist_create(appdata_t *appdata, gpx_t *gpx, |
529 |
cache_t *sel_cache) { |
cache_t *sel_cache) { |
530 |
GtkCellRenderer *renderer; |
GtkCellRenderer *renderer; |
716 |
g_signal_connect(G_OBJECT(view), "focus-out-event", |
g_signal_connect(G_OBJECT(view), "focus-out-event", |
717 |
G_CALLBACK(on_cachelist_focus_out), container); |
G_CALLBACK(on_cachelist_focus_out), container); |
718 |
|
|
719 |
|
/* make sure window can control gps */ |
720 |
|
g_signal_connect(G_OBJECT(appdata->window), "focus-in-event", |
721 |
|
G_CALLBACK(on_main_focus_change), appdata); |
722 |
|
|
723 |
|
g_signal_connect(G_OBJECT(appdata->window), "focus-out-event", |
724 |
|
G_CALLBACK(on_main_focus_change), appdata); |
725 |
|
|
726 |
#ifndef USE_PANNABLE_AREA |
#ifndef USE_PANNABLE_AREA |
727 |
g_signal_connect(gtk_scrolled_window_get_vadjustment( |
g_signal_connect(gtk_scrolled_window_get_vadjustment( |
728 |
GTK_SCROLLED_WINDOW(container)), |
GTK_SCROLLED_WINDOW(container)), |
2157 |
|
|
2158 |
gnome_vfs_shutdown(); |
gnome_vfs_shutdown(); |
2159 |
icons_free(); |
icons_free(); |
2160 |
gps_release(appdata); |
|
2161 |
|
gps_release(appdata->gps_state); |
2162 |
|
appdata->gps_state = NULL; |
2163 |
|
|
2164 |
if(appdata->search_results) { |
if(appdata->search_results) { |
2165 |
printf("freeing pending search\n"); |
printf("freeing pending search\n"); |
2596 |
appdata.gconf_client = gconf_client_get_default(); |
appdata.gconf_client = gconf_client_get_default(); |
2597 |
gconf_load_state(&appdata); |
gconf_load_state(&appdata); |
2598 |
|
|
2599 |
gps_init(&appdata); |
appdata.gps_state = gps_init(); |
2600 |
|
gps_change_state(&appdata); |
2601 |
|
|
2602 |
|
/* make sure window can control gps */ |
2603 |
|
g_signal_connect(G_OBJECT(appdata.window), "focus-in-event", |
2604 |
|
G_CALLBACK(on_main_focus_change), &appdata); |
2605 |
|
|
2606 |
|
g_signal_connect(G_OBJECT(appdata.window), "focus-out-event", |
2607 |
|
G_CALLBACK(on_main_focus_change), &appdata); |
2608 |
|
|
2609 |
|
|
2610 |
appdata.cur_view = gpxlist_create_view_and_model(&appdata, NULL); |
appdata.cur_view = gpxlist_create_view_and_model(&appdata, NULL); |
2611 |
#ifndef USE_STACKABLE_WINDOW |
#ifndef USE_STACKABLE_WINDOW |