31 |
#include "custom_rating_renderer.h" |
#include "custom_rating_renderer.h" |
32 |
#include "custom_type_renderer.h" |
#include "custom_type_renderer.h" |
33 |
|
|
34 |
|
#ifdef ESPEAK |
35 |
|
#include <espeak/speak_lib.h> |
36 |
|
#endif |
37 |
|
|
38 |
#ifdef USE_MAEMO |
#ifdef USE_MAEMO |
39 |
#include <hildon/hildon-banner.h> |
#include <hildon/hildon-banner.h> |
40 |
#if MAEMO_VERSION_MAJOR >= 5 |
#if MAEMO_VERSION_MAJOR >= 5 |
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; |
471 |
static gboolean on_cachelist_focus_in(GtkWidget *widget, GdkEventFocus *event, |
static gboolean on_cachelist_focus_in(GtkWidget *widget, GdkEventFocus *event, |
472 |
gpointer data) { |
gpointer data) { |
473 |
|
|
|
|
|
474 |
/* we don't want a runnign timer yet */ |
/* we don't want a runnign timer yet */ |
475 |
if(!g_object_get_data(G_OBJECT(data), "handler_id")) { |
if(!g_object_get_data(G_OBJECT(data), "handler_id")) { |
476 |
printf("focus received: restarting cachelist timer\n"); |
printf("focus received: restarting cachelist timer\n"); |
481 |
|
|
482 |
g_object_set_data(G_OBJECT(data), "handler_id", (gpointer) |
g_object_set_data(G_OBJECT(data), "handler_id", (gpointer) |
483 |
gtk_timeout_add(CACHELIST_UPDATE_TIMEOUT, cachelist_update, data)); |
gtk_timeout_add(CACHELIST_UPDATE_TIMEOUT, cachelist_update, data)); |
484 |
|
|
485 |
|
/* and redo list immediately */ |
486 |
|
cachelist_redraw(appdata); |
487 |
} |
} |
488 |
|
|
489 |
return FALSE; |
return FALSE; |
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; |
791 |
hildon_window_set_app_menu(HILDON_WINDOW(window), |
hildon_window_set_app_menu(HILDON_WINDOW(window), |
792 |
menu_create(appdata, MENU_CACHELIST)); |
menu_create(appdata, MENU_CACHELIST)); |
793 |
|
|
794 |
|
/* make sure window can control gps */ |
795 |
|
g_signal_connect(G_OBJECT(window), "focus-in-event", |
796 |
|
G_CALLBACK(on_main_focus_change), appdata); |
797 |
|
|
798 |
|
g_signal_connect(G_OBJECT(window), "focus-out-event", |
799 |
|
G_CALLBACK(on_main_focus_change), appdata); |
800 |
|
|
801 |
g_signal_connect(G_OBJECT(window), "destroy", |
g_signal_connect(G_OBJECT(window), "destroy", |
802 |
G_CALLBACK(on_cachelist_destroy), appdata); |
G_CALLBACK(on_cachelist_destroy), appdata); |
803 |
|
|
1580 |
g_signal_connect(G_OBJECT(context.in_finds), "toggled", |
g_signal_connect(G_OBJECT(context.in_finds), "toggled", |
1581 |
G_CALLBACK(callback_finds_toggled), &context); |
G_CALLBACK(callback_finds_toggled), &context); |
1582 |
|
|
1583 |
#ifndef USE_MAEMO |
context.spinner = number_editor_new(appdata->search_days, 0, 99); |
|
GtkObject *adj = gtk_adjustment_new(appdata->search_days, 0, 99, 1, 10, 10); |
|
|
context.spinner = gtk_spin_button_new(GTK_ADJUSTMENT(adj), 1, 0); |
|
|
#else |
|
|
context.spinner = hildon_number_editor_new(0, 99); |
|
|
hildon_number_editor_set_value(HILDON_NUMBER_EDITOR(context.spinner), |
|
|
appdata->search_days); |
|
|
#endif |
|
1584 |
gtk_box_pack_start_defaults(GTK_BOX(hbox), context.spinner); |
gtk_box_pack_start_defaults(GTK_BOX(hbox), context.spinner); |
1585 |
|
|
1586 |
gtk_box_pack_start_defaults(GTK_BOX(hbox), gtk_label_new(_("days"))); |
gtk_box_pack_start_defaults(GTK_BOX(hbox), gtk_label_new(_("days"))); |
1587 |
|
|
1588 |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox); |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox); |
1600 |
if(strlen(p) > 0) |
if(strlen(p) > 0) |
1601 |
appdata->search_str = strdup(p); |
appdata->search_str = strdup(p); |
1602 |
|
|
1603 |
#ifndef USE_MAEMO |
appdata->search_days = number_editor_get_value(context.spinner); |
|
appdata->search_days = gtk_spin_button_get_value_as_int( |
|
|
GTK_SPIN_BUTTON(context.spinner)); |
|
|
#else |
|
|
appdata->search_days = hildon_number_editor_get_value( |
|
|
HILDON_NUMBER_EDITOR(context.spinner)); |
|
|
#endif |
|
1604 |
|
|
1605 |
if(check_button_get_active(context.in_finds)) |
if(check_button_get_active(context.in_finds)) |
1606 |
appdata->search |= SEARCH_FINDS; |
appdata->search |= SEARCH_FINDS; |
1636 |
printf("Search for %s (flags = %x)...\n", p, appdata->search); |
printf("Search for %s (flags = %x)...\n", p, appdata->search); |
1637 |
|
|
1638 |
#if !defined(USE_BREAD_CRUMB_TRAIL) && !defined(BCT) |
#if !defined(USE_BREAD_CRUMB_TRAIL) && !defined(BCT) |
1639 |
gpx_t *found = |
|
1640 |
search_do(appdata, appdata->gpx, p, appdata->search, FALSE); |
if(appdata->cur_gpx) |
1641 |
|
appdata->search_results = |
1642 |
|
search_do(appdata, appdata->cur_gpx, p, appdata->search, TRUE); |
1643 |
|
else |
1644 |
|
appdata->search_results = |
1645 |
|
search_do(appdata, appdata->gpx, p, appdata->search, FALSE); |
1646 |
|
|
1647 |
/* do search result dialog here ... */ |
/* do search result dialog here ... */ |
1648 |
cachelist_dialog(appdata, found); |
cachelist_dialog(appdata, appdata->search_results); |
1649 |
|
|
1650 |
#ifndef USE_STACKABLE_WINDOW |
#ifndef USE_STACKABLE_WINDOW |
1651 |
search_result_free(found); |
search_result_free(appdata->search_results); |
1652 |
#else |
appdata->search_results = NULL; |
|
appdata->search_results = found; |
|
1653 |
#endif |
#endif |
1654 |
#else |
#else |
1655 |
gpx_t *found = NULL; |
gpx_t *found = NULL; |
2146 |
|
|
2147 |
gpx_free_all(appdata->gpx); |
gpx_free_all(appdata->gpx); |
2148 |
|
|
2149 |
|
#ifdef ESPEAK |
2150 |
|
espeak_Terminate(); |
2151 |
|
#endif |
2152 |
|
|
2153 |
#ifdef USE_STACKABLE_WINDOW |
#ifdef USE_STACKABLE_WINDOW |
2154 |
if(appdata->export_menu) submenu_cleanup(appdata->export_menu); |
if(appdata->export_menu) submenu_cleanup(appdata->export_menu); |
2155 |
if(appdata->tools_menu) submenu_cleanup(appdata->tools_menu); |
if(appdata->tools_menu) submenu_cleanup(appdata->tools_menu); |
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"); |
2482 |
|
|
2483 |
curl_global_init(CURL_GLOBAL_ALL); |
curl_global_init(CURL_GLOBAL_ALL); |
2484 |
|
|
2485 |
|
#ifdef ESPEAK |
2486 |
|
#if ESPEAK_API_REVISION == 1 |
2487 |
|
appdata.espeak.sample_rate = |
2488 |
|
espeak_Initialize(AUDIO_OUTPUT_PLAYBACK, 512, NULL); |
2489 |
|
#else |
2490 |
|
appdata.espeak.sample_rate = |
2491 |
|
espeak_Initialize(AUDIO_OUTPUT_PLAYBACK, 512, NULL, 0); |
2492 |
|
#endif |
2493 |
|
if(appdata.espeak.sample_rate < 0) |
2494 |
|
printf("espeak: init error\n"); |
2495 |
|
else |
2496 |
|
printf("espeak: running at %dhz\n", appdata.espeak.sample_rate); |
2497 |
|
|
2498 |
|
/* set language */ |
2499 |
|
espeak_VOICE voice_spec; |
2500 |
|
voice_spec.name = NULL; |
2501 |
|
voice_spec.languages = _("en"); |
2502 |
|
voice_spec.gender = 0; |
2503 |
|
voice_spec.age = 0; |
2504 |
|
voice_spec.variant = 0; |
2505 |
|
if(EE_OK != espeak_SetVoiceByProperties(&voice_spec)) { |
2506 |
|
printf("failed to set voice spec for %s\n", voice_spec.languages); |
2507 |
|
appdata.espeak.sample_rate = -1; |
2508 |
|
} |
2509 |
|
#endif |
2510 |
|
|
2511 |
#ifdef USE_MAEMO |
#ifdef USE_MAEMO |
2512 |
printf("Installing osso context for \"org.harbaum." APP "\"\n"); |
printf("Installing osso context for \"org.harbaum." APP "\"\n"); |
2513 |
appdata.osso_context = osso_initialize("org.harbaum."APP, |
appdata.osso_context = osso_initialize("org.harbaum."APP, |
2595 |
|
|
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 |
gps_init(&appdata); |
|
2599 |
|
appdata.gps_state = gps_init(); |
2600 |
|
gps_change_state(&appdata); |
2601 |
|
|
2602 |
|
gps_register_callback(appdata.gps_state, |
2603 |
|
LATLON_CHANGED | TRACK_CHANGED | HERR_CHANGED | SATELLITE_CHANGED, |
2604 |
|
main_gps_cb, &appdata); |
2605 |
|
|
2606 |
|
/* make sure window can control gps */ |
2607 |
|
g_signal_connect(G_OBJECT(appdata.window), "focus-in-event", |
2608 |
|
G_CALLBACK(on_main_focus_change), &appdata); |
2609 |
|
|
2610 |
|
g_signal_connect(G_OBJECT(appdata.window), "focus-out-event", |
2611 |
|
G_CALLBACK(on_main_focus_change), &appdata); |
2612 |
|
|
2613 |
|
|
2614 |
appdata.cur_view = gpxlist_create_view_and_model(&appdata, NULL); |
appdata.cur_view = gpxlist_create_view_and_model(&appdata, NULL); |
2615 |
#ifndef USE_STACKABLE_WINDOW |
#ifndef USE_STACKABLE_WINDOW |