15 |
* along with GPXView. If not, see <http://www.gnu.org/licenses/>. |
* along with GPXView. If not, see <http://www.gnu.org/licenses/>. |
16 |
*/ |
*/ |
17 |
|
|
18 |
#include <stdio.h> |
#define __USE_GNU |
19 |
#include <string.h> |
#include <string.h> |
20 |
|
|
21 |
|
#include <stdio.h> |
22 |
#include <math.h> |
#include <math.h> |
23 |
|
|
24 |
|
#include <curl/curl.h> |
25 |
|
|
26 |
#include <time.h> |
#include <time.h> |
27 |
#include <sys/time.h> |
#include <sys/time.h> |
28 |
|
|
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 |
41 |
|
#include <hildon/hildon-note.h> |
42 |
|
#include <hildon/hildon-entry.h> |
43 |
|
#endif |
44 |
#endif |
#endif |
45 |
|
|
46 |
#include <locale.h> |
#include <locale.h> |
47 |
|
|
48 |
extern char *strcasestr (__const char *__haystack, __const char *__needle); |
extern char *strcasestr (__const char *__haystack, __const char *__needle); |
49 |
|
|
50 |
#ifdef USE_BREAD_CRUMB_TRAIL |
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
51 |
static void crumb_add(appdata_t *appdata, char *name, int level, |
static void crumb_add(appdata_t *appdata, char *name, int level, |
52 |
gpointer user_data); |
gpointer user_data); |
53 |
|
|
104 |
} |
} |
105 |
} |
} |
106 |
|
|
107 |
|
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
108 |
GtkWidget *dialog = gtk_message_dialog_new( |
GtkWidget *dialog = gtk_message_dialog_new( |
109 |
GTK_WINDOW(NULL), |
GTK_WINDOW(NULL), |
110 |
GTK_DIALOG_DESTROY_WITH_PARENT, |
GTK_DIALOG_DESTROY_WITH_PARENT, |
111 |
GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, |
GTK_MESSAGE_ERROR, |
112 |
buf); |
GTK_BUTTONS_CLOSE, buf); |
113 |
|
|
114 |
gtk_window_set_title(GTK_WINDOW(dialog), _("ERROR")); |
gtk_window_set_title(GTK_WINDOW(dialog), _("ERROR")); |
115 |
|
#else |
116 |
|
GtkWidget *dialog = |
117 |
|
hildon_note_new_information(GTK_WINDOW(NULL), buf); |
118 |
|
#endif |
119 |
|
|
120 |
gtk_dialog_run(GTK_DIALOG(dialog)); |
gtk_dialog_run(GTK_DIALOG(dialog)); |
121 |
gtk_widget_destroy(dialog); |
gtk_widget_destroy(dialog); |
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; |
214 |
gtk_widget_show_all (GTK_WIDGET(dialog)); |
gtk_widget_show_all (GTK_WIDGET(dialog)); |
215 |
if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_FM_OK) { |
if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_FM_OK) { |
216 |
char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); |
char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); |
217 |
|
|
218 |
|
if(filename) { |
219 |
|
gpx_dialog_t *dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window)); |
220 |
|
|
221 |
gpx_dialog_t *dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window)); |
if(!whole_dir) |
222 |
|
gpx = gpx_parse(dialog, filename, appdata->username); |
223 |
if(!whole_dir) |
else { |
224 |
gpx = gpx_parse(dialog, filename); |
/* cur trailing '/' if present */ |
225 |
else { |
if(strlastchr(filename) == '/') |
226 |
/* cur trailing '/' if present */ |
filename[strlen(filename)] = 0; |
227 |
if(strlastchr(filename) == '/') |
|
228 |
filename[strlen(filename)] = 0; |
gpx = gpx_parse_dir(dialog, filename, appdata->username); |
|
|
|
|
gpx = gpx_parse_dir(dialog, filename); |
|
|
} |
|
|
|
|
|
gpx_busy_dialog_destroy(dialog); |
|
|
|
|
|
/* save path if gpx was successfully loaded */ |
|
|
if(gpx) { |
|
|
char *r = strrchr(filename, '/'); |
|
|
|
|
|
/* there is a delimiter, use everything left of it as path */ |
|
|
if(r && !whole_dir) { |
|
|
*r = 0; |
|
|
if(appdata->path) free(appdata->path); |
|
|
appdata->path = strdup(filename); |
|
|
/* restore path ... just in case ... */ |
|
|
*r = '/'; |
|
229 |
} |
} |
230 |
|
|
231 |
if(whole_dir) |
gpx_busy_dialog_destroy(dialog); |
232 |
appdata->path = strdup(filename); |
|
233 |
} |
/* save path if gpx was successfully loaded */ |
234 |
|
if(gpx) { |
235 |
|
char *r = strrchr(filename, '/'); |
236 |
|
|
237 |
|
/* there is a delimiter, use everything left of it as path */ |
238 |
|
if(r && !whole_dir) { |
239 |
|
*r = 0; |
240 |
|
if(appdata->path) free(appdata->path); |
241 |
|
appdata->path = strdup(filename); |
242 |
|
/* restore path ... just in case ... */ |
243 |
|
*r = '/'; |
244 |
|
} |
245 |
|
|
246 |
|
if(whole_dir) |
247 |
|
appdata->path = strdup(filename); |
248 |
|
} else |
249 |
|
errorf(_("Load error")); |
250 |
|
|
251 |
g_free (filename); |
g_free (filename); |
252 |
|
} else { |
253 |
|
#ifndef USE_MAEMO |
254 |
|
errorf(_("Error accessing the file.")); |
255 |
|
#else |
256 |
|
errorf(_("Error accessing the file. This may happen if the file " |
257 |
|
"resides on a remote file system. Please copy the file onto " |
258 |
|
"the device (e.g. onto the memory card) and try again.")); |
259 |
|
#endif |
260 |
|
} |
261 |
} |
} |
262 |
|
|
263 |
gtk_widget_destroy (dialog); |
gtk_widget_destroy (dialog); |
281 |
CACHELIST_NUM_COLS |
CACHELIST_NUM_COLS |
282 |
} ; |
} ; |
283 |
|
|
284 |
void cachelist_view_onRowActivated(GtkTreeView *treeview, |
void cachelist_goto_cache(appdata_t *appdata, cache_t *cache) { |
285 |
|
#if !defined(USE_BREAD_CRUMB_TRAIL) && !defined(BCT) |
286 |
|
cache_dialog(appdata, cache); |
287 |
|
#else |
288 |
|
crumb_add(appdata, cache->name, CRUMB_CACHE, cache); |
289 |
|
|
290 |
|
gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
291 |
|
appdata->cur_view = cache_view(appdata, cache); |
292 |
|
gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view); |
293 |
|
gtk_widget_show_all(appdata->vbox); |
294 |
|
#endif |
295 |
|
} |
296 |
|
|
297 |
|
static void cachelist_view_onRowActivated(GtkTreeView *treeview, |
298 |
GtkTreePath *path, |
GtkTreePath *path, |
299 |
GtkTreeViewColumn *col, |
GtkTreeViewColumn *col, |
300 |
gpointer userdata) { |
gpointer userdata) { |
302 |
GtkTreeIter iter; |
GtkTreeIter iter; |
303 |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
304 |
|
|
305 |
|
#ifdef USE_MAEMO |
306 |
|
/* check if a cache is already selected and ignore click if yes */ |
307 |
|
/* (was probably a double click) */ |
308 |
|
if(appdata->cur_cache) return; |
309 |
|
#endif |
310 |
|
|
311 |
if(gtk_tree_model_get_iter(model, &iter, path)) { |
if(gtk_tree_model_get_iter(model, &iter, path)) { |
312 |
cache_t *cache; |
cache_t *cache; |
313 |
gtk_tree_model_get(model, &iter, CACHELIST_COL_DATA, &cache, -1); |
gtk_tree_model_get(model, &iter, CACHELIST_COL_DATA, &cache, -1); |
314 |
#ifndef USE_BREAD_CRUMB_TRAIL |
cachelist_goto_cache(appdata, cache); |
|
cache_dialog(appdata, cache); |
|
|
#else |
|
|
gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
|
|
appdata->cur_view = cache_view(appdata, cache); |
|
|
gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view); |
|
|
gtk_widget_show_all(appdata->vbox); |
|
|
|
|
|
crumb_add(appdata, cache->name, CRUMB_CACHE, cache); |
|
|
#endif |
|
315 |
} |
} |
316 |
} |
} |
317 |
|
|
319 |
appdata_t *appdata; |
appdata_t *appdata; |
320 |
GtkTreePath *path; |
GtkTreePath *path; |
321 |
gboolean done; |
gboolean done; |
322 |
} cachelist_expose_t; |
} cachelist_context_t; |
323 |
|
|
324 |
static gboolean cachelist_expose(GtkWidget *widget, GdkEventExpose *event, |
static gboolean cachelist_expose(GtkWidget *widget, GdkEventExpose *event, |
325 |
gpointer user_data) { |
gpointer user_data) { |
326 |
cachelist_expose_t *ce = (cachelist_expose_t*)user_data; |
cachelist_context_t *ce = (cachelist_context_t*)user_data; |
327 |
|
|
328 |
if(event->type == GDK_EXPOSE) { |
if(event->type == GDK_EXPOSE) { |
329 |
if(ce->path && !ce->done) { |
if(ce->path && !ce->done) { |
338 |
} |
} |
339 |
|
|
340 |
static void cachelist_destroy(GtkWidget *widget, gpointer user_data) { |
static void cachelist_destroy(GtkWidget *widget, gpointer user_data) { |
|
cachelist_expose_t *ce = (cachelist_expose_t*)user_data; |
|
341 |
|
|
342 |
printf("cachelist timer removed\n"); |
guint handler_id = |
343 |
g_assert(ce->appdata->cachelist_handler_id); |
(guint)g_object_get_data(G_OBJECT(user_data), "handler_id"); |
344 |
gtk_timeout_remove(ce->appdata->cachelist_handler_id); |
|
345 |
ce->appdata->cachelist_handler_id = 0; |
if(handler_id) { |
346 |
|
gtk_timeout_remove(handler_id); |
347 |
|
g_object_set_data(G_OBJECT(user_data), "handler_id", NULL); |
348 |
|
|
349 |
|
printf("cachelist timer removed\n"); |
350 |
|
} |
351 |
|
|
352 |
|
gpointer *ce = |
353 |
|
g_object_get_data(G_OBJECT(user_data), "ce"); |
354 |
|
g_assert(ce); |
355 |
|
|
356 |
free(user_data); |
free(ce); |
357 |
} |
} |
358 |
|
|
359 |
#define CACHELIST_UPDATE_TIMEOUT (30000) |
#define CACHELIST_UPDATE_TIMEOUT (30000) |
362 |
cache_t *sel_cache); |
cache_t *sel_cache); |
363 |
|
|
364 |
void cachelist_redraw(appdata_t *appdata) { |
void cachelist_redraw(appdata_t *appdata) { |
365 |
#ifndef USE_MAEMO |
printf("redrawing cachelist\n"); |
|
// gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
|
|
// appdata->cur_view = gpxlist_create_view_and_model(appdata, NULL); |
|
|
// gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view); |
|
|
// gtk_widget_show_all(appdata->vbox); |
|
|
#else |
|
366 |
|
|
367 |
if(!appdata->cur_view) { |
if(!appdata->cur_view) { |
368 |
printf("cachelist redraw: no active view\n"); |
printf("cachelist redraw: no active view\n"); |
379 |
} |
} |
380 |
|
|
381 |
if(redraw) { |
if(redraw) { |
|
GtkWidget *container = appdata->vbox; |
|
|
|
|
|
printf("redraw %d\n", redraw); |
|
|
|
|
382 |
#ifdef USE_STACKABLE_WINDOW |
#ifdef USE_STACKABLE_WINDOW |
383 |
HildonWindowStack *stack = hildon_window_stack_get_default(); |
HildonWindowStack *stack = hildon_window_stack_get_default(); |
384 |
container = hildon_window_stack_peek(stack); |
GtkWidget *container = hildon_window_stack_peek(stack); |
385 |
|
#else |
386 |
|
GtkWidget *container = appdata->vbox; |
387 |
#endif |
#endif |
388 |
|
|
389 |
gtk_container_remove(GTK_CONTAINER(container), appdata->cur_view); |
gtk_container_remove(GTK_CONTAINER(container), appdata->cur_view); |
399 |
} |
} |
400 |
|
|
401 |
#ifdef USE_STACKABLE_WINDOW |
#ifdef USE_STACKABLE_WINDOW |
402 |
if(container != appdata->vbox) |
gtk_container_add(GTK_CONTAINER(container), appdata->cur_view); |
403 |
gtk_container_add(GTK_CONTAINER(container), appdata->cur_view); |
#else |
404 |
else |
gtk_box_pack_start_defaults(GTK_BOX(container), appdata->cur_view); |
405 |
#endif |
#endif |
|
gtk_box_pack_start_defaults(GTK_BOX(container), appdata->cur_view); |
|
406 |
|
|
407 |
gtk_widget_show_all(container); |
gtk_widget_show_all(container); |
408 |
} |
} |
|
#endif |
|
409 |
} |
} |
410 |
|
|
411 |
|
|
412 |
static gboolean cachelist_update(gpointer data) { |
static gboolean cachelist_update(gpointer data) { |
413 |
|
appdata_t *appdata = |
414 |
|
(appdata_t*)g_object_get_data(G_OBJECT(data), "appdata"); |
415 |
|
g_assert(appdata); |
416 |
|
|
417 |
printf("cachelist timer fired!\n"); |
printf("cachelist timer fired!\n"); |
418 |
|
|
419 |
#ifdef USE_MAEMO |
/* check if the widget the timer fired for is the currently */ |
420 |
appdata_t *appdata = (appdata_t*)data; |
/* visible one (if a search result is being shown, a cachlist */ |
421 |
|
/* may also be present below it) */ |
422 |
|
if(appdata->cur_view != data) { |
423 |
|
printf("-> widget is not the one currently on top, don't redraw\n"); |
424 |
|
return TRUE; |
425 |
|
} |
426 |
|
|
427 |
if(appdata->cur_cache) |
if(appdata->cur_cache) |
428 |
return TRUE; |
return TRUE; |
429 |
|
|
430 |
|
#ifdef USE_MAEMO |
431 |
if(appdata->cachelist_disable_screensaver) |
if(appdata->cachelist_disable_screensaver) |
432 |
if (osso_display_blanking_pause(appdata->osso_context) != OSSO_OK) |
if (osso_display_blanking_pause(appdata->osso_context) != OSSO_OK) |
433 |
fprintf(stderr, "error with display blank\n"); |
fprintf(stderr, "error with display blank\n"); |
434 |
|
#endif |
435 |
|
|
436 |
if(appdata->cachelist_update) |
if(appdata->cachelist_update) |
437 |
cachelist_redraw(appdata); |
cachelist_redraw(appdata); |
438 |
#endif |
else |
439 |
|
printf("update disabled\n"); |
440 |
|
|
441 |
return TRUE; |
return TRUE; |
442 |
} |
} |
443 |
|
|
444 |
static void cachelist_timer_reset(appdata_t *appdata) { |
static void cachelist_timer_reset(GtkWidget *widget) { |
445 |
|
guint handler_id = |
446 |
|
(guint)g_object_get_data(G_OBJECT(widget), "handler_id"); |
447 |
|
g_assert(handler_id); |
448 |
|
|
449 |
|
appdata_t *appdata = |
450 |
|
(appdata_t*)g_object_get_data(G_OBJECT(widget), "appdata"); |
451 |
|
g_assert(appdata); |
452 |
|
|
453 |
printf("cachelist timer reset\n"); |
printf("cachelist timer reset\n"); |
454 |
g_assert(appdata->cachelist_handler_id); |
gtk_timeout_remove(handler_id); |
455 |
gtk_timeout_remove(appdata->cachelist_handler_id); |
g_object_set_data(G_OBJECT(widget), "handler_id", (gpointer) |
456 |
appdata->cachelist_handler_id = |
gtk_timeout_add(CACHELIST_UPDATE_TIMEOUT, cachelist_update, widget)); |
|
gtk_timeout_add(CACHELIST_UPDATE_TIMEOUT, cachelist_update, appdata); |
|
457 |
} |
} |
458 |
|
|
459 |
static gboolean cachelist_update_reset0(GtkWidget *widget, |
static gboolean cachelist_update_reset0(GtkWidget *widget, |
460 |
GdkEventButton *event, |
GdkEventButton *event, |
461 |
gpointer user_data) { |
gpointer user_data) { |
462 |
cachelist_timer_reset((appdata_t*)user_data); |
cachelist_timer_reset(GTK_WIDGET(user_data)); |
463 |
return FALSE; |
return FALSE; |
464 |
} |
} |
465 |
|
|
466 |
static void cachelist_update_reset1(GtkAdjustment *adj, |
static void cachelist_update_reset1(GtkAdjustment *adj, |
467 |
gpointer user_data) { |
gpointer user_data) { |
468 |
cachelist_timer_reset((appdata_t*)user_data); |
cachelist_timer_reset(GTK_WIDGET(user_data)); |
469 |
|
} |
470 |
|
|
471 |
|
static gboolean on_cachelist_focus_in(GtkWidget *widget, GdkEventFocus *event, |
472 |
|
gpointer data) { |
473 |
|
|
474 |
|
/* we don't want a runnign timer yet */ |
475 |
|
if(!g_object_get_data(G_OBJECT(data), "handler_id")) { |
476 |
|
printf("focus received: restarting cachelist timer\n"); |
477 |
|
|
478 |
|
appdata_t *appdata = |
479 |
|
(appdata_t*)g_object_get_data(G_OBJECT(data), "appdata"); |
480 |
|
g_assert(appdata); |
481 |
|
|
482 |
|
g_object_set_data(G_OBJECT(data), "handler_id", (gpointer) |
483 |
|
gtk_timeout_add(CACHELIST_UPDATE_TIMEOUT, cachelist_update, data)); |
484 |
|
|
485 |
|
/* and redo list immediately */ |
486 |
|
cachelist_redraw(appdata); |
487 |
|
} |
488 |
|
|
489 |
|
return FALSE; |
490 |
|
} |
491 |
|
|
492 |
|
static gboolean on_cachelist_focus_out(GtkWidget *widget, GdkEventFocus *event, |
493 |
|
gpointer data) { |
494 |
|
|
495 |
|
guint handler_id = |
496 |
|
(guint)g_object_get_data(G_OBJECT(data), "handler_id"); |
497 |
|
g_assert(handler_id); |
498 |
|
|
499 |
|
gtk_timeout_remove(handler_id); |
500 |
|
g_object_set_data(G_OBJECT(data), "handler_id", NULL); |
501 |
|
|
502 |
|
printf("focus lost: cachelist timer removed\n"); |
503 |
|
|
504 |
|
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, |
622 |
if(tint > 8) tint = 8; |
if(tint > 8) tint = 8; |
623 |
|
|
624 |
/* cache type includes "solved" flag in lowest bit */ |
/* cache type includes "solved" flag in lowest bit */ |
625 |
int type = (cache->type<<8) + |
int type = cache->type<<8; |
626 |
(cache->notes?4:0) + |
if(cache->notes) type |= 4; |
627 |
((cache->notes && cache->notes->override)?1:0) + |
if(cache->notes && cache->notes->override) type |= 1; |
628 |
((cache->notes && cache->notes->found)?2:0); |
if(cache->notes && cache->notes->found) type |= 2; |
629 |
|
if(cache->found) type |= 2; |
630 |
|
if(cache->mine) type |= 8; |
631 |
|
|
632 |
if((!(type & 2)) || !appdata->cachelist_hide_found) { |
if((!(type & 2)) || !appdata->cachelist_hide_found) { |
633 |
|
|
670 |
g_signal_connect(view, "row-activated", |
g_signal_connect(view, "row-activated", |
671 |
(GCallback)cachelist_view_onRowActivated, appdata); |
(GCallback)cachelist_view_onRowActivated, appdata); |
672 |
|
|
673 |
cachelist_expose_t *ce = malloc(sizeof(cachelist_expose_t)); |
cachelist_context_t *ce = g_new0(cachelist_context_t, 1); |
674 |
ce->appdata = appdata; |
ce->appdata = appdata; |
675 |
ce->path = path; |
ce->path = path; |
676 |
ce->done = FALSE; |
ce->done = FALSE; |
677 |
|
|
678 |
g_signal_connect(view, "expose-event", |
g_signal_connect(view, "expose-event", |
679 |
(GCallback)cachelist_expose, ce); |
(GCallback)cachelist_expose, ce); |
|
g_signal_connect(view, "destroy", |
|
|
(GCallback)cachelist_destroy, ce); |
|
680 |
|
|
681 |
/* put this inside a scrolled view */ |
/* put this inside a scrolled view */ |
682 |
#ifndef USE_PANNABLE_AREA |
#ifndef USE_PANNABLE_AREA |
683 |
GtkWidget *scrolled_window = gtk_scrolled_window_new (NULL, NULL); |
GtkWidget *container = gtk_scrolled_window_new (NULL, NULL); |
684 |
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), |
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(container), |
685 |
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); |
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); |
686 |
gtk_container_add(GTK_CONTAINER(scrolled_window), view); |
gtk_container_add(GTK_CONTAINER(container), view); |
687 |
#else |
#else |
688 |
GtkWidget *pannable_area = hildon_pannable_area_new(); |
GtkWidget *container = hildon_pannable_area_new(); |
689 |
|
gtk_container_add(GTK_CONTAINER(container), view); |
|
gtk_container_add(GTK_CONTAINER(pannable_area), view); |
|
690 |
#endif |
#endif |
691 |
|
|
692 |
/* add a timer for automatic update */ |
g_signal_connect(view, "destroy", |
693 |
g_assert(!appdata->cachelist_handler_id); |
(GCallback)cachelist_destroy, container); |
|
appdata->cachelist_handler_id = |
|
|
gtk_timeout_add(CACHELIST_UPDATE_TIMEOUT, cachelist_update, appdata); |
|
694 |
|
|
695 |
/* update timer is being reset if the user scrolls or selects */ |
/* update timer is being reset if the user scrolls or selects */ |
696 |
g_signal_connect(view, "button-press-event", |
g_signal_connect(view, "button-press-event", |
697 |
(GCallback)cachelist_update_reset0, appdata); |
(GCallback)cachelist_update_reset0, container); |
698 |
|
|
699 |
|
/* add a timer for automatic update */ |
700 |
|
g_object_set_data(G_OBJECT(container), "handler_id", (gpointer) |
701 |
|
gtk_timeout_add(CACHELIST_UPDATE_TIMEOUT, cachelist_update, container)); |
702 |
|
|
703 |
|
printf("cachelist timer created\n"); |
704 |
|
|
705 |
|
g_object_set_data(G_OBJECT(container), "appdata", (gpointer)appdata); |
706 |
|
|
707 |
|
g_object_set_data(G_OBJECT(container), "ce", (gpointer)ce); |
708 |
|
|
709 |
|
/* the timer is removed and re-enabled on every focus change event */ |
710 |
|
/* for the main top window */ |
711 |
|
// GtkWidget *root = gtk_widget_get_toplevel(GTK_WIDGET(button))) |
712 |
|
|
713 |
|
g_signal_connect(G_OBJECT(view), "focus-in-event", |
714 |
|
G_CALLBACK(on_cachelist_focus_in), container); |
715 |
|
|
716 |
|
g_signal_connect(G_OBJECT(view), "focus-out-event", |
717 |
|
G_CALLBACK(on_cachelist_focus_out), container); |
718 |
|
|
719 |
#ifndef USE_PANNABLE_AREA |
#ifndef USE_PANNABLE_AREA |
720 |
g_signal_connect(gtk_scrolled_window_get_vadjustment( |
g_signal_connect(gtk_scrolled_window_get_vadjustment( |
721 |
GTK_SCROLLED_WINDOW(scrolled_window)), |
GTK_SCROLLED_WINDOW(container)), |
722 |
"value-changed", |
"value-changed", |
723 |
(GCallback)cachelist_update_reset1, appdata); |
(GCallback)cachelist_update_reset1, container); |
|
|
|
|
return scrolled_window; |
|
724 |
#else |
#else |
725 |
g_signal_connect(hildon_pannable_area_get_vadjustment( |
g_signal_connect(hildon_pannable_area_get_vadjustment( |
726 |
HILDON_PANNABLE_AREA(pannable_area)), |
HILDON_PANNABLE_AREA(container)), |
727 |
"value-changed", |
"value-changed", |
728 |
(GCallback)cachelist_update_reset1, appdata); |
(GCallback)cachelist_update_reset1, container); |
|
|
|
729 |
|
|
|
return pannable_area; |
|
730 |
#endif |
#endif |
731 |
|
return container; |
732 |
} |
} |
733 |
|
|
734 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
755 |
static void search_result_free(gpx_t *result); |
static void search_result_free(gpx_t *result); |
756 |
|
|
757 |
void on_cachelist_destroy(GtkWidget *widget, appdata_t *appdata) { |
void on_cachelist_destroy(GtkWidget *widget, appdata_t *appdata) { |
758 |
|
printf("cachelist destroy\n"); |
759 |
|
|
760 |
|
HildonWindowStack *stack = hildon_window_stack_get_default(); |
761 |
|
appdata->window = HILDON_WINDOW(hildon_window_stack_peek(stack)); |
762 |
|
|
763 |
if(appdata->search_results) { |
if(appdata->search_results) { |
764 |
search_result_free(appdata->search_results); |
search_result_free(appdata->search_results); |
765 |
appdata->search_results = NULL; |
appdata->search_results = NULL; |
766 |
} |
} |
767 |
appdata->cur_gpx = NULL; |
appdata->cur_gpx = NULL; |
768 |
|
|
769 |
|
#ifdef ENABLE_OSM_GPS_MAP |
770 |
|
map_update(appdata); |
771 |
|
#endif |
772 |
|
|
773 |
/* restore cur_view */ |
/* restore cur_view */ |
774 |
appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view"); |
appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view"); |
775 |
} |
} |
776 |
|
|
777 |
void cachelist_dialog(appdata_t *appdata, gpx_t *gpx) { |
void cachelist_dialog(appdata_t *appdata, gpx_t *gpx) { |
778 |
GtkWidget *window = hildon_stackable_window_new(); |
GtkWidget *window = hildon_stackable_window_new(); |
779 |
|
appdata->window = HILDON_WINDOW(window); |
780 |
|
|
781 |
/* store last "cur_view" in window */ |
/* store last "cur_view" in window */ |
782 |
g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view); |
g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view); |
783 |
|
|
784 |
appdata->cur_gpx = gpx; |
appdata->cur_gpx = gpx; |
785 |
char *title = g_strdup_printf("GPXView - %s", gpx->name); |
gtk_window_set_title(GTK_WINDOW(window), gpx->name); |
|
gtk_window_set_title(GTK_WINDOW(window), title); |
|
|
g_free(title); |
|
786 |
|
|
787 |
appdata->cur_view = cachelist_create(appdata, gpx, NULL); |
appdata->cur_view = cachelist_create(appdata, gpx, NULL); |
788 |
gtk_container_add(GTK_CONTAINER(window), appdata->cur_view); |
gtk_container_add(GTK_CONTAINER(window), appdata->cur_view); |
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 |
|
|
804 |
gtk_widget_show_all(window); |
gtk_widget_show_all(window); |
805 |
|
|
806 |
|
#ifdef ENABLE_OSM_GPS_MAP |
807 |
|
map_update(appdata); |
808 |
|
#endif |
809 |
} |
} |
810 |
#endif |
#endif |
811 |
#endif |
#endif |
838 |
return icon_get(ICON_FILE, 0); |
return icon_get(ICON_FILE, 0); |
839 |
} |
} |
840 |
|
|
841 |
static void gpxlist_set(GtkListStore *store, GtkTreeIter *iter, gpx_t *gpx) { |
void gpxlist_set(GtkListStore *store, GtkTreeIter *iter, gpx_t *gpx) { |
842 |
char date_str[32], cnum[32]; |
char date_str[32], cnum[32]; |
843 |
|
|
844 |
if(gpx->year && gpx->month && gpx->day) { |
if(gpx->year && gpx->month && gpx->day) { |
863 |
GPXLIST_COL_OPEN, !gpx->closed, |
GPXLIST_COL_OPEN, !gpx->closed, |
864 |
GPXLIST_COL_CACHES, gpx->closed?NULL:cnum, |
GPXLIST_COL_CACHES, gpx->closed?NULL:cnum, |
865 |
#ifdef USE_PANNABLE_AREA |
#ifdef USE_PANNABLE_AREA |
866 |
GPXLIST_COL_DELETE, icon_get(ICON_MISC, 7), |
GPXLIST_COL_DELETE, icon_get(ICON_MISC, 2), |
867 |
#endif |
#endif |
868 |
GPXLIST_COL_DATA, gpx, |
GPXLIST_COL_DATA, gpx, |
869 |
-1); |
-1); |
909 |
gconf_save_closed_name(appdata, gpx->filename, gpx->name); |
gconf_save_closed_name(appdata, gpx->filename, gpx->name); |
910 |
} |
} |
911 |
|
|
912 |
|
void gpxlist_goto_cachelist(appdata_t *appdata, gpx_t *gpx) { |
913 |
|
#if !defined(USE_BREAD_CRUMB_TRAIL) && !defined(BCT) |
914 |
|
#ifdef USE_STACKABLE_WINDOW |
915 |
|
if(!appdata->cur_gpx) |
916 |
|
#endif |
917 |
|
cachelist_dialog(appdata, gpx); |
918 |
|
#ifdef USE_STACKABLE_WINDOW |
919 |
|
else |
920 |
|
printf("selected gpx, but cachelist window already present\n"); |
921 |
|
#endif |
922 |
|
#else |
923 |
|
gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
924 |
|
appdata->cur_view = cachelist_create(appdata, gpx, NULL); |
925 |
|
gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view); |
926 |
|
gtk_widget_show_all(appdata->vbox); |
927 |
|
|
928 |
|
crumb_add(appdata, gpx->name, CRUMB_CACHELIST, gpx); |
929 |
|
#endif |
930 |
|
} |
931 |
|
|
932 |
static void gpxlist_view_onRowActivated(GtkTreeView *treeview, |
static void gpxlist_view_onRowActivated(GtkTreeView *treeview, |
933 |
GtkTreePath *path, |
GtkTreePath *path, |
934 |
GtkTreeViewColumn *col, |
GtkTreeViewColumn *col, |
937 |
GtkTreeIter iter; |
GtkTreeIter iter; |
938 |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
939 |
|
|
940 |
|
#ifdef USE_MAEMO |
941 |
|
/* check if a cache is already selected and ignore click if yes */ |
942 |
|
/* (was probably a double click) */ |
943 |
|
if(appdata->cur_gpx) return; |
944 |
|
#endif |
945 |
|
|
946 |
if (gtk_tree_model_get_iter(model, &iter, path)) { |
if (gtk_tree_model_get_iter(model, &iter, path)) { |
947 |
gpx_t *gpx; |
gpx_t *gpx; |
948 |
gtk_tree_model_get(model, &iter, GPXLIST_COL_DATA, &gpx, -1); |
gtk_tree_model_get(model, &iter, GPXLIST_COL_DATA, &gpx, -1); |
955 |
if(col_name && !strcmp(col_name, "Del")) { |
if(col_name && !strcmp(col_name, "Del")) { |
956 |
printf("clicked delete\n"); |
printf("clicked delete\n"); |
957 |
|
|
958 |
|
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
959 |
/* ask user what he wants */ |
/* ask user what he wants */ |
960 |
GtkWidget *dialog = gtk_message_dialog_new( |
GtkWidget *dialog = gtk_message_dialog_new( |
961 |
GTK_WINDOW(appdata->window), |
GTK_WINDOW(appdata->window), |
962 |
GTK_DIALOG_DESTROY_WITH_PARENT, |
GTK_DIALOG_DESTROY_WITH_PARENT, |
963 |
GTK_MESSAGE_QUESTION, GTK_BUTTONS_CANCEL, |
GTK_MESSAGE_QUESTION, |
964 |
|
GTK_BUTTONS_CANCEL, |
965 |
_("Do you want to close this entry only or do " |
_("Do you want to close this entry only or do " |
966 |
"you want to remove it completely from the list?")); |
"you want to remove it completely from the list?")); |
967 |
|
|
970 |
_("Close"), 2, |
_("Close"), 2, |
971 |
NULL); |
NULL); |
972 |
|
|
973 |
|
gtk_window_set_title(GTK_WINDOW(dialog), _("Close or remove entry?")); |
974 |
|
#else |
975 |
|
|
976 |
|
GtkWidget *dialog = |
977 |
|
gtk_dialog_new_with_buttons(_("Close or remove entry?"), |
978 |
|
GTK_WINDOW(appdata->window), |
979 |
|
GTK_DIALOG_DESTROY_WITH_PARENT, |
980 |
|
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, |
981 |
|
_("Remove"), 1, |
982 |
|
_("Close"), 2, |
983 |
|
NULL); |
984 |
|
|
985 |
|
GtkWidget *content_area = |
986 |
|
gtk_dialog_get_content_area (GTK_DIALOG (dialog)); |
987 |
|
|
988 |
|
GtkWidget *hbox = gtk_hbox_new(FALSE, 0); |
989 |
|
|
990 |
|
GtkWidget *label = gtk_label_new( |
991 |
|
_("Do you want to close this entry only or do " |
992 |
|
"you want to remove it completely from the list?")); |
993 |
|
|
994 |
|
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
995 |
|
gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_WORD); |
996 |
|
|
997 |
|
gtk_box_pack_start_defaults(GTK_BOX(hbox), label); |
998 |
|
gtk_container_add (GTK_CONTAINER (content_area), hbox); |
999 |
|
|
1000 |
|
gtk_widget_show_all (dialog); |
1001 |
|
#endif |
1002 |
|
|
1003 |
if(gpx->closed) |
if(gpx->closed) |
1004 |
gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), 2, FALSE); |
gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), 2, FALSE); |
1005 |
|
|
|
gtk_window_set_title(GTK_WINDOW(dialog), _("Remove entry?")); |
|
|
|
|
1006 |
/* set the active flag again if the user answered "no" */ |
/* set the active flag again if the user answered "no" */ |
1007 |
switch(gtk_dialog_run(GTK_DIALOG(dialog))) { |
switch(gtk_dialog_run(GTK_DIALOG(dialog))) { |
1008 |
|
|
1032 |
gpx_t *new = NULL; |
gpx_t *new = NULL; |
1033 |
|
|
1034 |
if(g_file_test(gpx->filename, G_FILE_TEST_IS_DIR)) |
if(g_file_test(gpx->filename, G_FILE_TEST_IS_DIR)) |
1035 |
new = gpx_parse_dir(dialog, gpx->filename); |
new = gpx_parse_dir(dialog, gpx->filename, appdata->username); |
1036 |
else |
else |
1037 |
new = gpx_parse(dialog, gpx->filename); |
new = gpx_parse(dialog, gpx->filename, appdata->username); |
1038 |
|
|
1039 |
if(new) { |
if(new) { |
1040 |
gpx_t **prev = &(appdata->gpx); |
gpx_t **prev = &(appdata->gpx); |
1070 |
|
|
1071 |
gpx_busy_dialog_destroy(dialog); |
gpx_busy_dialog_destroy(dialog); |
1072 |
} |
} |
1073 |
#ifndef USE_BREAD_CRUMB_TRAIL |
|
1074 |
#ifdef USE_STACKABLE_WINDOW |
gpxlist_goto_cachelist(appdata, gpx); |
|
if(!appdata->cur_gpx) |
|
|
#endif |
|
|
cachelist_dialog(appdata, gpx); |
|
|
#ifdef USE_STACKABLE_WINDOW |
|
|
else |
|
|
printf("selected gpx, but cachelist window already present\n"); |
|
|
#endif |
|
|
#else |
|
|
gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
|
|
appdata->cur_view = cachelist_create(appdata, gpx, NULL); |
|
|
gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view); |
|
|
gtk_widget_show_all(appdata->vbox); |
|
|
|
|
|
crumb_add(appdata, gpx->name, CRUMB_CACHELIST, gpx); |
|
|
#endif |
|
1075 |
} |
} |
1076 |
} |
} |
1077 |
} |
} |
1078 |
|
|
1079 |
|
/* search gpx file in gpx list */ |
1080 |
|
gboolean gpxlist_find(appdata_t *appdata, GtkTreeIter *iter, gpx_t *gpx) { |
1081 |
|
GtkTreeModel *model = |
1082 |
|
gtk_tree_view_get_model(GTK_TREE_VIEW(appdata->gpxview)); |
1083 |
|
|
1084 |
|
gboolean found = |
1085 |
|
gtk_tree_model_get_iter_first(model, iter); |
1086 |
|
|
1087 |
|
while(found) { |
1088 |
|
gpx_t *this_gpx; |
1089 |
|
gtk_tree_model_get(model, iter, GPXLIST_COL_DATA, &this_gpx, -1); |
1090 |
|
|
1091 |
|
if(gpx == this_gpx) |
1092 |
|
return TRUE; |
1093 |
|
|
1094 |
|
found = gtk_tree_model_iter_next(model, iter); |
1095 |
|
} |
1096 |
|
|
1097 |
|
return FALSE; |
1098 |
|
} |
1099 |
|
|
1100 |
|
|
1101 |
#ifndef USE_PANNABLE_AREA |
#ifndef USE_PANNABLE_AREA |
1102 |
static gboolean |
static gboolean |
1103 |
view_selection_func(GtkTreeSelection *selection, GtkTreeModel *model, |
view_selection_func(GtkTreeSelection *selection, GtkTreeModel *model, |
1136 |
|
|
1137 |
appdata->gpxview = gtk_tree_view_new (); |
appdata->gpxview = gtk_tree_view_new (); |
1138 |
|
|
1139 |
|
printf("building gpx list, items = %d\n", appdata->gpxlist_items); |
1140 |
|
|
1141 |
GtkTreeSelection *selection = |
GtkTreeSelection *selection = |
1142 |
gtk_tree_view_get_selection(GTK_TREE_VIEW(appdata->gpxview)); |
gtk_tree_view_get_selection(GTK_TREE_VIEW(appdata->gpxview)); |
1143 |
#ifndef USE_PANNABLE_AREA |
#ifndef USE_PANNABLE_AREA |
1150 |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview), |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview), |
1151 |
-1, "Icon", renderer, |
-1, "Icon", renderer, |
1152 |
"pixbuf", GPXLIST_COL_ICON, |
"pixbuf", GPXLIST_COL_ICON, |
1153 |
// "sensitive", GPXLIST_COL_OPEN, |
#ifdef USE_PANNABLE_AREA |
1154 |
|
/* at least one entry needs to be sensitive. */ |
1155 |
|
/* This is the delete icon if the PANNABLE_AREA is used */ |
1156 |
|
"sensitive", GPXLIST_COL_OPEN, |
1157 |
|
#endif |
1158 |
NULL); |
NULL); |
1159 |
|
|
1160 |
/* --- "FileName" column --- */ |
/* --- "FileName" column --- */ |
1210 |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview), |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview), |
1211 |
-1, "Del", renderer, |
-1, "Del", renderer, |
1212 |
"pixbuf", GPXLIST_COL_DELETE, |
"pixbuf", GPXLIST_COL_DELETE, |
1213 |
"sensitive", GPXLIST_COL_OPEN, |
// "sensitive", GPXLIST_COL_OPEN, |
1214 |
NULL); |
NULL); |
1215 |
#endif |
#endif |
1216 |
|
|
1230 |
GtkTreeIter iter; |
GtkTreeIter iter; |
1231 |
gtk_list_store_append(appdata->gpxstore, &iter); |
gtk_list_store_append(appdata->gpxstore, &iter); |
1232 |
gpxlist_set(appdata->gpxstore, &iter, gpx); |
gpxlist_set(appdata->gpxstore, &iter, gpx); |
1233 |
|
|
1234 |
if(gpx == sel_gpx) { |
if(gpx == sel_gpx) { |
1235 |
sel_iter = iter; |
sel_iter = iter; |
1236 |
sel_iter_valid = TRUE; |
sel_iter_valid = TRUE; |
1274 |
} |
} |
1275 |
|
|
1276 |
/* add last entry in gpx list to visual representation */ |
/* add last entry in gpx list to visual representation */ |
1277 |
static void gpxlist_add(appdata_t *appdata, gpx_t *new) { |
void gpxlist_add(appdata_t *appdata, gpx_t *new) { |
1278 |
GtkTreeIter iter; |
GtkTreeIter iter; |
1279 |
|
|
1280 |
gtk_list_store_append(appdata->gpxstore, &iter); |
gtk_list_store_append(appdata->gpxstore, &iter); |
1284 |
gpx_t **gpx = &appdata->gpx; |
gpx_t **gpx = &appdata->gpx; |
1285 |
while(*gpx) gpx = &((*gpx)->next); |
while(*gpx) gpx = &((*gpx)->next); |
1286 |
*gpx = new; |
*gpx = new; |
1287 |
|
|
1288 |
|
/* select new iter */ |
1289 |
|
GtkTreeSelection *selection = |
1290 |
|
gtk_tree_view_get_selection(GTK_TREE_VIEW(appdata->gpxview)); |
1291 |
|
gtk_tree_selection_select_iter(selection, &iter); |
1292 |
|
GtkTreePath *path = |
1293 |
|
gtk_tree_model_get_path(GTK_TREE_MODEL(appdata->gpxstore), &iter); |
1294 |
|
gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(appdata->gpxview), |
1295 |
|
path, NULL, TRUE, 0.0, 0.0); |
1296 |
|
gtk_tree_path_free(path); |
1297 |
} |
} |
1298 |
|
|
1299 |
/******************** end of gpxlist ********************/ |
/******************** end of gpxlist ********************/ |
1302 |
|
|
1303 |
static void |
static void |
1304 |
cb_menu_about(GtkWidget *window, gpointer data) { |
cb_menu_about(GtkWidget *window, gpointer data) { |
1305 |
GtkAboutDialog *about = GTK_ABOUT_DIALOG(gtk_about_dialog_new()); |
about_box((appdata_t*)data); |
|
|
|
|
gtk_about_dialog_set_name(about, "GPXView"); |
|
|
gtk_about_dialog_set_version(about, VERSION); |
|
|
|
|
|
#ifdef ENABLE_LIBLOCATION |
|
|
char *uses = "uses liblocation"; |
|
|
#elif defined(ENABLE_GPSBT) |
|
|
char *uses = "uses gpsbt and gpsd"; |
|
|
#else |
|
|
char *uses = "uses gpsd"; |
|
|
#endif |
|
|
|
|
|
char *str = g_strdup_printf("%s\n\n%s", |
|
|
_("GPXView (c) 2008 by\n" |
|
|
"Till Harbaum <till@harbaum.org>\n" |
|
|
"Geocaching.com: Tantil"), |
|
|
_(uses) |
|
|
); |
|
|
|
|
|
gtk_about_dialog_set_copyright(about, str); |
|
|
g_free(str); |
|
|
|
|
|
gtk_about_dialog_set_website(about, |
|
|
_("http://www.harbaum.org/till/maemo")); |
|
|
|
|
|
gtk_about_dialog_set_comments(about, |
|
|
_("Geocaching.com GPX file viewer")); |
|
|
|
|
|
gtk_widget_show_all(GTK_WIDGET(about)); |
|
|
gtk_dialog_run(GTK_DIALOG(about)); |
|
|
gtk_widget_destroy(GTK_WIDGET(about)); |
|
1306 |
} |
} |
1307 |
|
|
1308 |
#if defined(USE_MAEMO) && defined(HILDON_HELP) |
#if defined(USE_MAEMO) && defined(HILDON_HELP) |
1474 |
else if(cache->long_description && (what & SEARCH_DESC) && |
else if(cache->long_description && (what & SEARCH_DESC) && |
1475 |
strcasestr(cache->long_description, phrase)) |
strcasestr(cache->long_description, phrase)) |
1476 |
hit = 1; |
hit = 1; |
1477 |
else if(cache->owner && (what & SEARCH_OWNER) && |
else if(cache->owner && cache->owner->name && (what & SEARCH_OWNER) && |
1478 |
strcasestr(cache->owner, phrase)) |
strcasestr(cache->owner->name, phrase)) |
1479 |
hit = 1; |
hit = 1; |
1480 |
|
|
1481 |
if(hit) { |
if(hit) { |
1504 |
GtkWidget *in_id, *in_name, *in_desc, *in_owner, *in_finds; |
GtkWidget *in_id, *in_name, *in_desc, *in_owner, *in_finds; |
1505 |
} search_context_t; |
} search_context_t; |
1506 |
|
|
1507 |
|
|
1508 |
static void callback_finds_toggled(GtkWidget *widget, gpointer data ) { |
static void callback_finds_toggled(GtkWidget *widget, gpointer data ) { |
1509 |
search_context_t *context = (search_context_t*)data; |
search_context_t *context = (search_context_t*)data; |
1510 |
|
|
1511 |
gboolean in_finds = gtk_toggle_button_get_active( |
gboolean in_finds = check_button_get_active(context->in_finds); |
|
GTK_TOGGLE_BUTTON(context->in_finds)); |
|
1512 |
|
|
1513 |
gtk_widget_set_sensitive(context->entry, !in_finds); |
gtk_widget_set_sensitive(context->entry, !in_finds); |
1514 |
gtk_widget_set_sensitive(context->in_id, !in_finds); |
gtk_widget_set_sensitive(context->in_id, !in_finds); |
1538 |
GtkWidget *table = gtk_table_new(2, 2, TRUE); |
GtkWidget *table = gtk_table_new(2, 2, TRUE); |
1539 |
gtk_table_set_col_spacing(GTK_TABLE(table), 0, 8); |
gtk_table_set_col_spacing(GTK_TABLE(table), 0, 8); |
1540 |
|
|
1541 |
context.in_id = gtk_check_button_new_with_label(_("Waypoint IDs")); |
context.in_id = check_button_new_with_label(_("Waypoint IDs")); |
1542 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(context.in_id), |
check_button_set_active(context.in_id, appdata->search & SEARCH_ID); |
|
appdata->search & SEARCH_ID); |
|
1543 |
gtk_table_attach_defaults(GTK_TABLE(table), context.in_id, 0, 1, 0, 1); |
gtk_table_attach_defaults(GTK_TABLE(table), context.in_id, 0, 1, 0, 1); |
1544 |
|
|
1545 |
context.in_name = gtk_check_button_new_with_label(_("Names")); |
context.in_name = check_button_new_with_label(_("Names")); |
1546 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(context.in_name), |
check_button_set_active(context.in_name, appdata->search & SEARCH_NAME); |
|
appdata->search & SEARCH_NAME); |
|
1547 |
gtk_table_attach_defaults(GTK_TABLE(table), context.in_name, 1, 2, 0, 1); |
gtk_table_attach_defaults(GTK_TABLE(table), context.in_name, 1, 2, 0, 1); |
1548 |
|
|
1549 |
context.in_desc = gtk_check_button_new_with_label(_("Descriptions")); |
context.in_desc = check_button_new_with_label(_("Descriptions")); |
1550 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(context.in_desc), |
check_button_set_active(context.in_desc, appdata->search & SEARCH_DESC); |
|
appdata->search & SEARCH_DESC); |
|
1551 |
gtk_table_attach_defaults(GTK_TABLE(table), context.in_desc, 0, 1, 1, 2); |
gtk_table_attach_defaults(GTK_TABLE(table), context.in_desc, 0, 1, 1, 2); |
1552 |
|
|
1553 |
context.in_owner = gtk_check_button_new_with_label(_("Owner")); |
context.in_owner = check_button_new_with_label(_("Owner")); |
1554 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(context.in_owner), |
check_button_set_active(context.in_owner, appdata->search & SEARCH_OWNER); |
|
appdata->search & SEARCH_OWNER); |
|
1555 |
gtk_table_attach_defaults(GTK_TABLE(table), context.in_owner, 1, 2, 1, 2); |
gtk_table_attach_defaults(GTK_TABLE(table), context.in_owner, 1, 2, 1, 2); |
1556 |
|
|
1557 |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table); |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table); |
1560 |
|
|
1561 |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), |
1562 |
gtk_label_new(_("Search for:"))); |
gtk_label_new(_("Search for:"))); |
1563 |
|
context.entry = entry_new(); |
1564 |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), |
1565 |
context.entry = gtk_entry_new()); |
context.entry); |
1566 |
|
|
1567 |
if(appdata->search_str) |
if(appdata->search_str) |
1568 |
gtk_entry_set_text(GTK_ENTRY(context.entry), appdata->search_str); |
gtk_entry_set_text(GTK_ENTRY(context.entry), appdata->search_str); |
1569 |
|
|
1574 |
|
|
1575 |
GtkWidget *hbox = gtk_hbox_new(FALSE, 5); |
GtkWidget *hbox = gtk_hbox_new(FALSE, 5); |
1576 |
|
|
1577 |
context.in_finds = gtk_check_button_new_with_label(_("Search finds for")); |
context.in_finds = check_button_new_with_label(_("Search finds for")); |
1578 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(context.in_finds), |
check_button_set_active(context.in_finds, appdata->search & SEARCH_FINDS); |
|
appdata->search & SEARCH_FINDS); |
|
1579 |
gtk_box_pack_start_defaults(GTK_BOX(hbox), context.in_finds); |
gtk_box_pack_start_defaults(GTK_BOX(hbox), context.in_finds); |
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(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_finds))) |
if(check_button_get_active(context.in_finds)) |
1606 |
appdata->search |= SEARCH_FINDS; |
appdata->search |= SEARCH_FINDS; |
1607 |
else |
else |
1608 |
appdata->search &= ~SEARCH_FINDS; |
appdata->search &= ~SEARCH_FINDS; |
1609 |
|
|
1610 |
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_id))) |
if(check_button_get_active(context.in_id)) |
1611 |
appdata->search |= SEARCH_ID; |
appdata->search |= SEARCH_ID; |
1612 |
else |
else |
1613 |
appdata->search &= ~SEARCH_ID; |
appdata->search &= ~SEARCH_ID; |
1614 |
|
|
1615 |
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_name))) |
if(check_button_get_active(context.in_name)) |
1616 |
appdata->search |= SEARCH_NAME; |
appdata->search |= SEARCH_NAME; |
1617 |
else |
else |
1618 |
appdata->search &= ~SEARCH_NAME; |
appdata->search &= ~SEARCH_NAME; |
1619 |
|
|
1620 |
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_desc))) |
if(check_button_get_active(context.in_desc)) |
1621 |
appdata->search |= SEARCH_DESC; |
appdata->search |= SEARCH_DESC; |
1622 |
else |
else |
1623 |
appdata->search &= ~SEARCH_DESC; |
appdata->search &= ~SEARCH_DESC; |
1624 |
|
|
1625 |
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_owner))) |
if(check_button_get_active(context.in_owner)) |
1626 |
appdata->search |= SEARCH_OWNER; |
appdata->search |= SEARCH_OWNER; |
1627 |
else |
else |
1628 |
appdata->search &= ~SEARCH_OWNER; |
appdata->search &= ~SEARCH_OWNER; |
1635 |
|
|
1636 |
printf("Search for %s (flags = %x)...\n", p, appdata->search); |
printf("Search for %s (flags = %x)...\n", p, appdata->search); |
1637 |
|
|
1638 |
#ifndef USE_BREAD_CRUMB_TRAIL |
#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; |
1674 |
gtk_widget_destroy(dialog); |
gtk_widget_destroy(dialog); |
1675 |
} |
} |
1676 |
|
|
1677 |
void on_window_destroy (GtkWidget *widget, gpointer data); |
static void on_window_destroy (GtkWidget *widget, gpointer data); |
1678 |
|
|
1679 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
1680 |
static void |
static void |
1736 |
notes_log_export(appdata); |
notes_log_export(appdata); |
1737 |
} |
} |
1738 |
|
|
1739 |
#ifdef USE_MAEMO |
#ifdef ENABLE_MAEMO_MAPPER |
1740 |
static void |
static void |
1741 |
cb_menu_export_mmpoi(GtkWidget *widget, gpointer data) { |
cb_menu_export_mmpoi(GtkWidget *widget, gpointer data) { |
1742 |
appdata_t *appdata = (appdata_t*)data; |
appdata_t *appdata = (appdata_t*)data; |
1750 |
garmin_export(appdata); |
garmin_export(appdata); |
1751 |
} |
} |
1752 |
|
|
1753 |
|
#ifdef ENABLE_OSM_GPS_MAP |
1754 |
|
static void |
1755 |
|
cb_menu_map(GtkWidget *window, gpointer data) { |
1756 |
|
map((appdata_t *)data); |
1757 |
|
} |
1758 |
|
#endif |
1759 |
|
|
1760 |
static void |
static void |
1761 |
cb_menu_geomath(GtkWidget *window, gpointer data) { |
cb_menu_geomath(GtkWidget *window, gpointer data) { |
1762 |
geomath_dialog((appdata_t *)data); |
geomath_dialog((appdata_t *)data); |
1772 |
precise_position((appdata_t *)data); |
precise_position((appdata_t *)data); |
1773 |
} |
} |
1774 |
|
|
1775 |
#ifdef USE_STACKABLE_WINDOW |
static void |
1776 |
static void on_export_destroy(GtkWidget *widget, appdata_t *appdata) { |
cb_menu_geotoad(GtkWidget *window, gpointer data) { |
1777 |
appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view"); |
geotoad((appdata_t *)data); |
1778 |
} |
} |
1779 |
|
|
1780 |
void on_export_clicked(GtkButton *button, appdata_t *appdata) { |
#ifdef USE_STACKABLE_WINDOW |
1781 |
HildonStackableWindow *view_window; |
typedef struct { |
1782 |
GtkWidget *but; |
char *label, *desc; |
1783 |
|
GtkSignalFunc activate_cb; |
1784 |
|
} menu_entry_t; |
1785 |
|
|
1786 |
view_window = HILDON_STACKABLE_WINDOW (hildon_stackable_window_new ()); |
typedef struct { |
1787 |
gtk_window_set_title (GTK_WINDOW (view_window), "GPXView - Export"); |
const char *title; |
1788 |
|
const menu_entry_t *menu; |
1789 |
|
int len; |
1790 |
|
} submenu_t; |
1791 |
|
|
1792 |
/* store last "cur_view" in window */ |
#define COLUMNS 1 |
|
g_object_set_data(G_OBJECT(view_window), "cur_view", appdata->cur_view); |
|
|
appdata->cur_view = NULL; |
|
1793 |
|
|
1794 |
g_signal_connect(G_OBJECT(view_window), "destroy", |
void on_submenu_entry_clicked(GtkButton *button, GtkWidget *menu) { |
|
G_CALLBACK(on_export_destroy), appdata); |
|
1795 |
|
|
1796 |
GtkVBox *contents = GTK_VBOX(gtk_vbox_new (12, FALSE)); |
/* force closing of submenu dialog */ |
1797 |
|
gtk_dialog_response(GTK_DIALOG(menu), GTK_RESPONSE_NONE); |
1798 |
|
gtk_widget_hide(menu); |
1799 |
|
|
1800 |
|
/* let gtk clean up */ |
1801 |
|
while(gtk_events_pending()) |
1802 |
|
gtk_main_iteration(); |
1803 |
|
} |
1804 |
|
|
1805 |
but = hildon_button_new_with_text( |
static GtkWidget *app_submenu_create(appdata_t *appdata, |
1806 |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
const submenu_t *submenu) { |
|
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
|
|
_("Export to Maemo Mapper"), |
|
|
_("Save a Maemo Mapper POI file")); |
|
|
g_signal_connect(but, "clicked", |
|
|
G_CALLBACK(cb_menu_export_mmpoi), appdata); |
|
|
gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0); |
|
1807 |
|
|
1808 |
|
/* create a oridinary dialog box */ |
1809 |
|
GtkWidget *dialog = gtk_dialog_new(); |
1810 |
|
gtk_window_set_title(GTK_WINDOW(dialog), _(submenu->title)); |
1811 |
|
gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); |
1812 |
|
gtk_window_set_transient_for(GTK_WINDOW(dialog), |
1813 |
|
GTK_WINDOW(appdata->window)); |
1814 |
|
gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); |
1815 |
|
|
1816 |
|
GtkWidget *table = gtk_table_new(submenu->len/COLUMNS, COLUMNS, TRUE); |
1817 |
|
int x = 0, y = 0; |
1818 |
|
|
1819 |
|
const menu_entry_t *menu_entries = submenu->menu; |
1820 |
|
while(menu_entries->label) { |
1821 |
|
GtkWidget *button = NULL; |
1822 |
|
|
1823 |
but = hildon_button_new_with_text( |
button = hildon_button_new_with_text( |
1824 |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
1825 |
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
1826 |
_("Export Field Notes"), |
_(menu_entries->label), _(menu_entries->desc)); |
|
_("Save a Garmin Field Notes file")); |
|
|
g_signal_connect(but, "clicked", |
|
|
G_CALLBACK(cb_menu_export_log), appdata); |
|
|
gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0); |
|
|
|
|
1827 |
|
|
1828 |
but = hildon_button_new_with_text( |
/* try to center both texts */ |
1829 |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
hildon_button_set_title_alignment(HILDON_BUTTON(button), 0.5, 0.5); |
1830 |
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
hildon_button_set_value_alignment(HILDON_BUTTON(button), 0.5, 0.5); |
|
_("Export Garmin GPX"), |
|
|
_("Save a GPX file containing modified waypoints")); |
|
|
g_signal_connect(but, "clicked", |
|
|
G_CALLBACK(cb_menu_export_garmin), appdata); |
|
|
gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0); |
|
1831 |
|
|
1832 |
gtk_container_add (GTK_CONTAINER (view_window), GTK_WIDGET (contents)); |
g_signal_connect(button, "clicked", |
1833 |
gtk_widget_show_all (GTK_WIDGET (view_window)); |
G_CALLBACK(on_submenu_entry_clicked), dialog); |
1834 |
} |
|
1835 |
|
g_signal_connect(button, "clicked", |
1836 |
|
menu_entries->activate_cb, appdata); |
1837 |
|
|
1838 |
|
gtk_table_attach_defaults(GTK_TABLE(table), button, x, x+1, y, y+1); |
1839 |
|
|
1840 |
|
x++; |
1841 |
|
if(x == COLUMNS) { x = 0; y++; } |
1842 |
|
|
1843 |
static void on_tools_destroy(GtkWidget *widget, appdata_t *appdata) { |
menu_entries++; |
1844 |
appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view"); |
} |
1845 |
|
|
1846 |
|
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table); |
1847 |
|
|
1848 |
|
return dialog; |
1849 |
} |
} |
1850 |
|
|
1851 |
void on_tools_clicked(GtkButton *button, appdata_t *appdata) { |
/* popup the dialog shaped submenu */ |
1852 |
HildonStackableWindow *view_window; |
static void submenu_popup(GtkWidget *menu) { |
1853 |
GtkWidget *but; |
gtk_widget_show_all(menu); |
1854 |
|
gtk_dialog_run(GTK_DIALOG(menu)); |
1855 |
|
gtk_widget_hide(menu); |
1856 |
|
} |
1857 |
|
|
1858 |
view_window = HILDON_STACKABLE_WINDOW (hildon_stackable_window_new ()); |
static void submenu_cleanup(GtkWidget *menu) { |
1859 |
gtk_window_set_title (GTK_WINDOW (view_window), "GPXView - Tools"); |
gtk_widget_destroy(menu); |
1860 |
|
} |
1861 |
|
|
1862 |
/* store last "cur_view" in window */ |
static const menu_entry_t submenu_export_entries[] = { |
1863 |
g_object_set_data(G_OBJECT(view_window), "cur_view", appdata->cur_view); |
#ifdef ENABLE_MAEMO_MAPPER |
1864 |
appdata->cur_view = NULL; |
{ "Export to Maemo Mapper" , "Save a Maemo Mapper POI file", |
1865 |
|
G_CALLBACK(cb_menu_export_mmpoi) }, |
1866 |
|
#endif |
1867 |
|
{ "Export Field Notes", "Save a Garmin Field Notes file", |
1868 |
|
G_CALLBACK(cb_menu_export_log) }, |
1869 |
|
{ "Export Garmin GPX", "Save modified waypoints in GPX file", |
1870 |
|
G_CALLBACK(cb_menu_export_garmin) }, |
1871 |
|
{ NULL, NULL, NULL } |
1872 |
|
}; |
1873 |
|
|
1874 |
g_signal_connect(G_OBJECT(view_window), "destroy", |
static const submenu_t submenu_export = { |
1875 |
G_CALLBACK(on_tools_destroy), appdata); |
"Export", submenu_export_entries, |
1876 |
|
sizeof(submenu_export_entries)/sizeof(menu_entry_t)-1 |
1877 |
|
}; |
1878 |
|
|
1879 |
GtkVBox *contents = GTK_VBOX(gtk_vbox_new (12, FALSE)); |
/* the export submenu */ |
1880 |
|
void on_export_clicked(GtkButton *button, appdata_t *appdata) { |
1881 |
|
if(!appdata->export_menu) |
1882 |
|
appdata->export_menu = app_submenu_create(appdata, &submenu_export); |
1883 |
|
|
1884 |
but = hildon_button_new_with_text( |
submenu_popup(appdata->export_menu); |
1885 |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
} |
|
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
|
|
_("Geomath"), |
|
|
_("Geocoordinate calculation")); |
|
|
g_signal_connect(but, "clicked", |
|
|
G_CALLBACK(cb_menu_geomath), appdata); |
|
|
gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0); |
|
1886 |
|
|
1887 |
|
static const menu_entry_t submenu_tools_entries[] = { |
1888 |
|
{ "Geomath", "Geocoordinate calculation", |
1889 |
|
G_CALLBACK(cb_menu_geomath) }, |
1890 |
|
{ "Geotext", "Text analysis", |
1891 |
|
G_CALLBACK(cb_menu_geotext) }, |
1892 |
|
{ "Precise Position", "Calculate a precise GPS position", |
1893 |
|
G_CALLBACK(cb_menu_precpos) }, |
1894 |
|
{ "GeoToad", "Use GeoToad online downloader", |
1895 |
|
G_CALLBACK(cb_menu_geotoad) }, |
1896 |
|
{ NULL, NULL, NULL } |
1897 |
|
}; |
1898 |
|
|
1899 |
but = hildon_button_new_with_text( |
static const submenu_t submenu_tools = { |
1900 |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
"Tools", submenu_tools_entries, |
1901 |
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
sizeof(submenu_tools_entries)/sizeof(menu_entry_t)-1 |
1902 |
_("Geotext"), |
}; |
|
_("Text analysis, letter counting etc")); |
|
|
g_signal_connect(but, "clicked", |
|
|
G_CALLBACK(cb_menu_geotext), appdata); |
|
|
gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0); |
|
|
|
|
1903 |
|
|
1904 |
but = hildon_button_new_with_text( |
/* the tools submenu */ |
1905 |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
void on_tools_clicked(GtkButton *button, appdata_t *appdata) { |
1906 |
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
if(!appdata->tools_menu) |
1907 |
_("Precise Position"), |
appdata->tools_menu = app_submenu_create(appdata, &submenu_tools); |
|
_("Calculate a very precise GPS position")); |
|
|
g_signal_connect(but, "clicked", |
|
|
G_CALLBACK(cb_menu_precpos), appdata); |
|
|
gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0); |
|
1908 |
|
|
1909 |
gtk_container_add (GTK_CONTAINER (view_window), GTK_WIDGET (contents)); |
submenu_popup(appdata->tools_menu); |
|
gtk_widget_show_all (GTK_WIDGET (view_window)); |
|
1910 |
} |
} |
1911 |
|
|
1912 |
HildonAppMenu *menu_create(appdata_t *appdata, int mode) { |
HildonAppMenu *menu_create(appdata_t *appdata, int mode) { |
1934 |
g_signal_connect_after(button, "clicked", |
g_signal_connect_after(button, "clicked", |
1935 |
G_CALLBACK(cb_menu_adddir), appdata); |
G_CALLBACK(cb_menu_adddir), appdata); |
1936 |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
|
} |
|
1937 |
|
|
|
if(mode == MENU_GPXLIST) { |
|
1938 |
button = gtk_button_new_with_label(_("Export")); |
button = gtk_button_new_with_label(_("Export")); |
1939 |
g_signal_connect_after(button, "clicked", |
g_signal_connect_after(button, "clicked", |
1940 |
G_CALLBACK(on_export_clicked), appdata); |
G_CALLBACK(on_export_clicked), appdata); |
1941 |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1942 |
|
} |
1943 |
|
|
1944 |
|
/* if search results exist, don't allow another search */ |
1945 |
|
if(!appdata->search_results && |
1946 |
|
((mode == MENU_GPXLIST) || (mode == MENU_CACHELIST))) { |
1947 |
button = gtk_button_new_with_label(_("Search")); |
button = gtk_button_new_with_label(_("Search")); |
1948 |
g_signal_connect_after(button, "clicked", |
g_signal_connect_after(button, "clicked", |
1949 |
G_CALLBACK(cb_menu_search), appdata); |
G_CALLBACK(cb_menu_search), appdata); |
1955 |
G_CALLBACK(on_tools_clicked), appdata); |
G_CALLBACK(on_tools_clicked), appdata); |
1956 |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1957 |
|
|
1958 |
// gtk_widget_show(GTK_WIDGET(menu)); |
#ifdef ENABLE_OSM_GPS_MAP |
1959 |
|
button = gtk_button_new_with_label(_("Map")); |
1960 |
|
g_signal_connect_after(button, "clicked", |
1961 |
|
G_CALLBACK(cb_menu_map), appdata); |
1962 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1963 |
|
#endif |
1964 |
|
|
1965 |
|
#ifdef HILDON_HELP |
1966 |
|
button = gtk_button_new_with_label(_("Help")); |
1967 |
|
g_signal_connect_after(button, "clicked", |
1968 |
|
G_CALLBACK(cb_menu_help), appdata); |
1969 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1970 |
|
#endif |
1971 |
|
|
1972 |
|
gtk_widget_show_all(GTK_WIDGET(menu)); |
1973 |
|
|
1974 |
return menu; |
return menu; |
1975 |
} |
} |
1979 |
GtkWidget *menu, *item; |
GtkWidget *menu, *item; |
1980 |
menu = gtk_menu_new(); |
menu = gtk_menu_new(); |
1981 |
|
|
1982 |
#ifdef USE_BREAD_CRUMB_TRAIL |
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
1983 |
appdata->menu_import = |
appdata->menu_import = |
1984 |
#endif |
#endif |
1985 |
item = gtk_menu_item_new_with_label(_("Import")); |
item = gtk_menu_item_new_with_label(_("Import")); |
2009 |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_remove), appdata); |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_remove), appdata); |
2010 |
#endif |
#endif |
2011 |
|
|
2012 |
#ifdef USE_BREAD_CRUMB_TRAIL |
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
2013 |
appdata->menu_export = |
appdata->menu_export = |
2014 |
#endif |
#endif |
2015 |
item = gtk_menu_item_new_with_label(_("Export")); |
item = gtk_menu_item_new_with_label(_("Export")); |
2017 |
submenu = gtk_menu_new(); |
submenu = gtk_menu_new(); |
2018 |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
2019 |
|
|
2020 |
#ifdef USE_MAEMO |
#ifdef ENABLE_MAEMO_MAPPER |
2021 |
item = gtk_menu_item_new_with_label( _("Maemo Mapper POI") ); |
item = gtk_menu_item_new_with_label( _("Maemo Mapper POI") ); |
2022 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
2023 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
2034 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
2035 |
GTK_SIGNAL_FUNC(cb_menu_export_garmin), appdata); |
GTK_SIGNAL_FUNC(cb_menu_export_garmin), appdata); |
2036 |
|
|
2037 |
#ifdef USE_BREAD_CRUMB_TRAIL |
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
2038 |
appdata->menu_search = |
appdata->menu_search = |
2039 |
#endif |
#endif |
2040 |
item = gtk_menu_item_new_with_label( _("Search") ); |
item = gtk_menu_item_new_with_label( _("Search") ); |
2043 |
|
|
2044 |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
2045 |
|
|
|
#ifndef NO_COPY_N_PASTE |
|
2046 |
/* ----------- copy'n paste submenu ----------------- */ |
/* ----------- copy'n paste submenu ----------------- */ |
2047 |
appdata->clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); |
#ifndef NO_COPY_N_PASTE |
|
gtk_clipboard_set_can_store(appdata->clipboard, NULL, 0); |
|
|
|
|
2048 |
item = gtk_menu_item_new_with_label(_("Edit")); |
item = gtk_menu_item_new_with_label(_("Edit")); |
2049 |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
2050 |
submenu = gtk_menu_new(); |
submenu = gtk_menu_new(); |
2071 |
|
|
2072 |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
2073 |
|
|
2074 |
|
#ifdef ENABLE_OSM_GPS_MAP |
2075 |
|
item = gtk_menu_item_new_with_label( _("Map") ); |
2076 |
|
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
2077 |
|
g_signal_connect(item, "activate", |
2078 |
|
GTK_SIGNAL_FUNC(cb_menu_map), appdata); |
2079 |
|
#endif |
2080 |
|
|
2081 |
item = gtk_menu_item_new_with_label(_("Tools")); |
item = gtk_menu_item_new_with_label(_("Tools")); |
2082 |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
2083 |
submenu = gtk_menu_new(); |
submenu = gtk_menu_new(); |
2098 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
2099 |
GTK_SIGNAL_FUNC(cb_menu_precpos), appdata); |
GTK_SIGNAL_FUNC(cb_menu_precpos), appdata); |
2100 |
|
|
2101 |
|
item = gtk_menu_item_new_with_label( _("GeoToad") ); |
2102 |
|
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
2103 |
|
g_signal_connect(item, "activate", |
2104 |
|
GTK_SIGNAL_FUNC(cb_menu_geotoad), appdata); |
2105 |
|
|
2106 |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
2107 |
|
|
2108 |
#if defined(USE_MAEMO) && defined(HILDON_HELP) |
#if defined(USE_MAEMO) && defined(HILDON_HELP) |
2142 |
/********************* end of menu **********************/ |
/********************* end of menu **********************/ |
2143 |
|
|
2144 |
void cleanup(appdata_t *appdata) { |
void cleanup(appdata_t *appdata) { |
2145 |
|
gconf_save_state(appdata); |
2146 |
|
|
2147 |
gpx_free_all(appdata->gpx); |
gpx_free_all(appdata->gpx); |
2148 |
if(appdata->path) free(appdata->path); |
|
2149 |
if(appdata->image_path) free(appdata->image_path); |
#ifdef ESPEAK |
2150 |
if(appdata->search_str) free(appdata->search_str); |
espeak_Terminate(); |
2151 |
|
#endif |
2152 |
|
|
2153 |
|
#ifdef USE_STACKABLE_WINDOW |
2154 |
|
if(appdata->export_menu) submenu_cleanup(appdata->export_menu); |
2155 |
|
if(appdata->tools_menu) submenu_cleanup(appdata->tools_menu); |
2156 |
|
#endif |
2157 |
|
|
2158 |
gnome_vfs_shutdown(); |
gnome_vfs_shutdown(); |
2159 |
icons_free(); |
icons_free(); |
|
gps_release(appdata); |
|
2160 |
|
|
2161 |
#ifdef USE_MAEMO |
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"); |
2166 |
search_result_free(appdata->search_results); |
search_result_free(appdata->search_results); |
2167 |
} |
} |
2168 |
|
|
2169 |
|
#ifdef USE_MAEMO |
2170 |
if(appdata->osso_context) |
if(appdata->osso_context) |
2171 |
osso_deinitialize(appdata->osso_context); |
osso_deinitialize(appdata->osso_context); |
2172 |
|
|
2185 |
puts("everything is gone"); |
puts("everything is gone"); |
2186 |
} |
} |
2187 |
|
|
2188 |
void on_window_destroy (GtkWidget *widget, gpointer data) { |
static void on_window_destroy (GtkWidget *widget, gpointer data) { |
2189 |
appdata_t *appdata = (appdata_t*)data; |
appdata_t *appdata = (appdata_t*)data; |
2190 |
|
|
|
gconf_save_state(appdata); |
|
2191 |
gtk_main_quit(); |
gtk_main_quit(); |
2192 |
appdata->window = NULL; |
appdata->window = NULL; |
2193 |
} |
} |
2247 |
return handled; |
return handled; |
2248 |
} |
} |
2249 |
|
|
2250 |
#ifdef USE_BREAD_CRUMB_TRAIL |
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
2251 |
typedef struct { |
typedef struct { |
2252 |
int level; |
int level; |
2253 |
appdata_t *appdata; |
appdata_t *appdata; |
2339 |
|
|
2340 |
gtk_widget_show_all(crumb->appdata->vbox); |
gtk_widget_show_all(crumb->appdata->vbox); |
2341 |
g_free(data); |
g_free(data); |
2342 |
|
|
2343 |
|
#ifdef ENABLE_OSM_GPS_MAP |
2344 |
|
map_update(crumb->appdata); |
2345 |
|
#endif |
2346 |
} |
} |
2347 |
|
|
2348 |
static void crumb_add(appdata_t *appdata, char *name, int level, |
static void crumb_add(appdata_t *appdata, char *name, int level, |
2349 |
gpointer user_data) { |
gpointer user_data) { |
2350 |
crumb_t *crumb = malloc(sizeof(crumb_t)); |
crumb_t *crumb = g_new0(crumb_t, 1); |
2351 |
crumb->level = level; |
crumb->level = level; |
2352 |
crumb->appdata = appdata; |
crumb->appdata = appdata; |
2353 |
crumb->data = user_data; |
crumb->data = user_data; |
2383 |
#endif |
#endif |
2384 |
} |
} |
2385 |
|
|
2386 |
|
#ifdef USE_BREAD_CRUMB_TRAIL |
2387 |
hildon_bread_crumb_trail_push_text(HILDON_BREAD_CRUMB_TRAIL(appdata->bct), |
hildon_bread_crumb_trail_push_text(HILDON_BREAD_CRUMB_TRAIL(appdata->bct), |
2388 |
name, crumb, (GDestroyNotify)crumb_back); |
name, crumb, (GDestroyNotify)crumb_back); |
2389 |
|
#else |
2390 |
|
bct_push_text(appdata->bct, name, crumb, (GDestroyNotify)crumb_back); |
2391 |
|
#endif |
2392 |
|
|
2393 |
|
#ifdef ENABLE_OSM_GPS_MAP |
2394 |
|
map_update(appdata); |
2395 |
|
#endif |
2396 |
} |
} |
2397 |
#endif // USE_BREAD_CRUMB_TRAIL |
#endif // USE_BREAD_CRUMB_TRAIL |
2398 |
|
|
2404 |
return; |
return; |
2405 |
} |
} |
2406 |
|
|
|
#ifndef USE_MAEMO |
|
|
// in non-maemo setup this can only affect the main screen as |
|
|
// the menu is blocked while a dialog is open. also the main |
|
|
// screen is always present |
|
|
if(appdata->gpxlist_items != appdata->cur_items) { |
|
|
/* re-do the main screen */ |
|
|
gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
|
|
appdata->cur_view = gpxlist_create_view_and_model(appdata, NULL); |
|
|
gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view); |
|
|
gtk_widget_show_all(appdata->vbox); |
|
|
} |
|
|
#else |
|
2407 |
/* a cache screen cannot be changed from the settings and thus doesn't */ |
/* a cache screen cannot be changed from the settings and thus doesn't */ |
2408 |
/* need to be redrawn */ |
/* need to be redrawn */ |
2409 |
if(appdata->cur_cache) { |
if(appdata->cur_cache) { |
2427 |
} |
} |
2428 |
|
|
2429 |
if(redraw) { |
if(redraw) { |
|
GtkWidget *container = appdata->vbox; |
|
2430 |
|
|
2431 |
#ifdef USE_STACKABLE_WINDOW |
#ifdef USE_STACKABLE_WINDOW |
2432 |
HildonWindowStack *stack = hildon_window_stack_get_default(); |
HildonWindowStack *stack = hildon_window_stack_get_default(); |
2433 |
container = hildon_window_stack_peek(stack); |
GtkWidget *container = hildon_window_stack_peek(stack); |
2434 |
|
#else |
2435 |
|
GtkWidget *container = appdata->vbox; |
2436 |
#endif |
#endif |
2437 |
|
|
2438 |
gtk_container_remove(GTK_CONTAINER(container), appdata->cur_view); |
gtk_container_remove(GTK_CONTAINER(container), appdata->cur_view); |
2451 |
} |
} |
2452 |
|
|
2453 |
#ifdef USE_STACKABLE_WINDOW |
#ifdef USE_STACKABLE_WINDOW |
|
if(container != appdata->vbox) |
|
2454 |
gtk_container_add(GTK_CONTAINER(container), appdata->cur_view); |
gtk_container_add(GTK_CONTAINER(container), appdata->cur_view); |
2455 |
else |
#else |
|
#endif |
|
2456 |
gtk_box_pack_start_defaults(GTK_BOX(container), appdata->cur_view); |
gtk_box_pack_start_defaults(GTK_BOX(container), appdata->cur_view); |
2457 |
|
#endif |
2458 |
|
|
2459 |
gtk_widget_show_all(container); |
gtk_widget_show_all(container); |
2460 |
} |
} |
|
#endif // USE_MAEMO |
|
2461 |
} |
} |
2462 |
|
|
2463 |
|
#if (MAEMO_VERSION_MAJOR == 5) && !defined(__i386__) |
2464 |
|
/* get access to zoom buttons */ |
2465 |
|
static void |
2466 |
|
on_window_realize(GtkWidget *widget, gpointer data) { |
2467 |
|
if (widget->window) { |
2468 |
|
unsigned char value = 1; |
2469 |
|
Atom hildon_zoom_key_atom = |
2470 |
|
gdk_x11_get_xatom_by_name("_HILDON_ZOOM_KEY_ATOM"), |
2471 |
|
integer_atom = gdk_x11_get_xatom_by_name("INTEGER"); |
2472 |
|
Display *dpy = |
2473 |
|
GDK_DISPLAY_XDISPLAY(gdk_drawable_get_display(widget->window)); |
2474 |
|
Window w = GDK_WINDOW_XID(widget->window); |
2475 |
|
|
2476 |
|
XChangeProperty(dpy, w, hildon_zoom_key_atom, |
2477 |
|
integer_atom, 8, PropModeReplace, &value, 1); |
2478 |
|
} |
2479 |
|
} |
2480 |
|
#endif |
2481 |
|
|
2482 |
int main(int argc, char *argv[]) { |
int main(int argc, char *argv[]) { |
2483 |
appdata_t appdata; |
appdata_t appdata; |
2484 |
|
|
2497 |
|
|
2498 |
gtk_init (&argc, &argv); |
gtk_init (&argc, &argv); |
2499 |
|
|
2500 |
|
misc_init(); |
2501 |
|
|
2502 |
|
curl_global_init(CURL_GLOBAL_ALL); |
2503 |
|
|
2504 |
|
#ifdef ESPEAK |
2505 |
|
#if ESPEAK_API_REVISION == 1 |
2506 |
|
appdata.espeak.sample_rate = |
2507 |
|
espeak_Initialize(AUDIO_OUTPUT_PLAYBACK, 512, NULL); |
2508 |
|
#else |
2509 |
|
appdata.espeak.sample_rate = |
2510 |
|
espeak_Initialize(AUDIO_OUTPUT_PLAYBACK, 512, NULL, 0); |
2511 |
|
#endif |
2512 |
|
if(appdata.espeak.sample_rate < 0) |
2513 |
|
printf("espeak: init error\n"); |
2514 |
|
else |
2515 |
|
printf("espeak: running at %dhz\n", appdata.espeak.sample_rate); |
2516 |
|
|
2517 |
|
/* set language */ |
2518 |
|
espeak_VOICE voice_spec; |
2519 |
|
voice_spec.name = NULL; |
2520 |
|
voice_spec.languages = _("en"); |
2521 |
|
voice_spec.gender = 0; |
2522 |
|
voice_spec.age = 0; |
2523 |
|
voice_spec.variant = 0; |
2524 |
|
if(EE_OK != espeak_SetVoiceByProperties(&voice_spec)) { |
2525 |
|
printf("failed to set voice spec for %s\n", voice_spec.languages); |
2526 |
|
appdata.espeak.sample_rate = -1; |
2527 |
|
} |
2528 |
|
#endif |
2529 |
|
|
2530 |
#ifdef USE_MAEMO |
#ifdef USE_MAEMO |
2531 |
printf("Installing osso context for \"org.harbaum." APP "\"\n"); |
printf("Installing osso context for \"org.harbaum." APP "\"\n"); |
2532 |
appdata.osso_context = osso_initialize("org.harbaum."APP, |
appdata.osso_context = osso_initialize("org.harbaum."APP, |
2535 |
fprintf(stderr, "error initiating osso context\n"); |
fprintf(stderr, "error initiating osso context\n"); |
2536 |
} |
} |
2537 |
|
|
2538 |
|
#ifdef ENABLE_MAEMO_MAPPER |
2539 |
dbus_register(&appdata); |
dbus_register(&appdata); |
2540 |
#endif |
#endif |
2541 |
|
#endif |
2542 |
|
|
2543 |
icons_init(); |
icons_init(); |
2544 |
|
|
2562 |
/* Create a Window. */ |
/* Create a Window. */ |
2563 |
appdata.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
appdata.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
2564 |
/* Set a decent default size for the window. */ |
/* Set a decent default size for the window. */ |
2565 |
gtk_window_set_default_size(GTK_WINDOW(appdata.window), 500, 300); |
gtk_window_set_default_size(GTK_WINDOW(appdata.window), 640, 480); |
2566 |
#endif |
#endif |
2567 |
|
|
2568 |
#if MAEMO_VERSION_MAJOR == 5 |
#if MAEMO_VERSION_MAJOR == 5 |
2569 |
gtk_window_set_title(GTK_WINDOW(appdata.window), "GPXView"); |
gtk_window_set_title(GTK_WINDOW(appdata.window), "GPXView"); |
2570 |
|
#if !defined(__i386__) |
2571 |
|
g_signal_connect(G_OBJECT(appdata.window), "realize", |
2572 |
|
G_CALLBACK(on_window_realize), NULL); |
2573 |
|
#endif |
2574 |
#endif |
#endif |
2575 |
|
|
2576 |
g_signal_connect(G_OBJECT(appdata.window), "destroy", |
g_signal_connect(G_OBJECT(appdata.window), "destroy", |
2579 |
g_signal_connect(G_OBJECT(appdata.window), "key_press_event", |
g_signal_connect(G_OBJECT(appdata.window), "key_press_event", |
2580 |
G_CALLBACK(on_window_key_press), &appdata); |
G_CALLBACK(on_window_key_press), &appdata); |
2581 |
|
|
2582 |
appdata.vbox = gtk_vbox_new(FALSE, 2); |
/* prepare clipboard */ |
2583 |
gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox); |
appdata.clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); |
2584 |
|
gtk_clipboard_set_can_store(appdata.clipboard, NULL, 0); |
2585 |
|
|
2586 |
#ifndef USE_STACKABLE_WINDOW |
#ifndef USE_STACKABLE_WINDOW |
2587 |
|
appdata.vbox = gtk_vbox_new(FALSE, 2); |
2588 |
|
gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox); |
2589 |
menu_create(&appdata); |
menu_create(&appdata); |
2590 |
#else |
#else |
2591 |
hildon_window_set_app_menu(HILDON_WINDOW(appdata.window), |
hildon_window_set_app_menu(HILDON_WINDOW(appdata.window), |
2598 |
gtk_box_pack_start(GTK_BOX(appdata.vbox), appdata.bct, FALSE,FALSE,0); |
gtk_box_pack_start(GTK_BOX(appdata.vbox), appdata.bct, FALSE,FALSE,0); |
2599 |
|
|
2600 |
hildon_bread_crumb_trail_clear(HILDON_BREAD_CRUMB_TRAIL(appdata.bct)); |
hildon_bread_crumb_trail_clear(HILDON_BREAD_CRUMB_TRAIL(appdata.bct)); |
2601 |
|
#else |
2602 |
|
#ifdef BCT |
2603 |
|
/* on non-hildon machines we use some custom made breadcrumbtrail */ |
2604 |
|
/* replacement */ |
2605 |
|
appdata.bct = bct_new(); |
2606 |
|
gtk_box_pack_start(GTK_BOX(appdata.vbox), appdata.bct, FALSE,FALSE,0); |
2607 |
|
#endif |
2608 |
|
#endif |
2609 |
|
|
2610 |
|
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
2611 |
crumb_add(&appdata, "GPX", CRUMB_GPXLIST, NULL); |
crumb_add(&appdata, "GPX", CRUMB_GPXLIST, NULL); |
2612 |
#endif |
#endif |
2613 |
|
|
2618 |
|
|
2619 |
appdata.gconf_client = gconf_client_get_default(); |
appdata.gconf_client = gconf_client_get_default(); |
2620 |
gconf_load_state(&appdata); |
gconf_load_state(&appdata); |
2621 |
gps_init(&appdata); |
|
2622 |
|
appdata.gps_state = gps_init(); |
2623 |
|
gps_change_state(&appdata); |
2624 |
|
|
2625 |
|
gps_register_callback(appdata.gps_state, |
2626 |
|
LATLON_CHANGED | TRACK_CHANGED | HERR_CHANGED | SATELLITE_CHANGED, |
2627 |
|
main_gps_cb, &appdata); |
2628 |
|
|
2629 |
|
/* make sure window can control gps */ |
2630 |
|
g_signal_connect(G_OBJECT(appdata.window), "focus-in-event", |
2631 |
|
G_CALLBACK(on_main_focus_change), &appdata); |
2632 |
|
|
2633 |
|
g_signal_connect(G_OBJECT(appdata.window), "focus-out-event", |
2634 |
|
G_CALLBACK(on_main_focus_change), &appdata); |
2635 |
|
|
2636 |
|
|
2637 |
appdata.cur_view = gpxlist_create_view_and_model(&appdata, NULL); |
appdata.cur_view = gpxlist_create_view_and_model(&appdata, NULL); |
2638 |
|
#ifndef USE_STACKABLE_WINDOW |
2639 |
gtk_box_pack_start_defaults(GTK_BOX(appdata.vbox), appdata.cur_view); |
gtk_box_pack_start_defaults(GTK_BOX(appdata.vbox), appdata.cur_view); |
2640 |
|
#else |
2641 |
|
gtk_container_add(GTK_CONTAINER(appdata.window), appdata.cur_view); |
2642 |
|
#endif |
2643 |
|
|
2644 |
gtk_widget_show_all(GTK_WIDGET(appdata.window)); |
gtk_widget_show_all(GTK_WIDGET(appdata.window)); |
2645 |
gtk_main(); |
gtk_main(); |