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_LATLON_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 |
free(user_data); |
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(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 |
static GtkWidget *cachelist_create(appdata_t *appdata, gpx_t *gpx, |
static GtkWidget *cachelist_create(appdata_t *appdata, gpx_t *gpx, |
508 |
cache_t *sel_cache) { |
cache_t *sel_cache) { |
509 |
GtkCellRenderer *renderer; |
GtkCellRenderer *renderer; |
601 |
if(tint > 8) tint = 8; |
if(tint > 8) tint = 8; |
602 |
|
|
603 |
/* cache type includes "solved" flag in lowest bit */ |
/* cache type includes "solved" flag in lowest bit */ |
604 |
int type = (cache->type<<8) + |
int type = cache->type<<8; |
605 |
(cache->notes?4:0) + |
if(cache->notes) type |= 4; |
606 |
((cache->notes && cache->notes->override)?1:0) + |
if(cache->notes && cache->notes->override) type |= 1; |
607 |
((cache->notes && cache->notes->found)?2:0); |
if(cache->notes && cache->notes->found) type |= 2; |
608 |
|
if(cache->found) type |= 2; |
609 |
|
if(cache->mine) type |= 8; |
610 |
|
|
611 |
if((!(type & 2)) || !appdata->cachelist_hide_found) { |
if((!(type & 2)) || !appdata->cachelist_hide_found) { |
612 |
|
|
649 |
g_signal_connect(view, "row-activated", |
g_signal_connect(view, "row-activated", |
650 |
(GCallback)cachelist_view_onRowActivated, appdata); |
(GCallback)cachelist_view_onRowActivated, appdata); |
651 |
|
|
652 |
cachelist_expose_t *ce = malloc(sizeof(cachelist_expose_t)); |
cachelist_context_t *ce = g_new0(cachelist_context_t, 1); |
653 |
ce->appdata = appdata; |
ce->appdata = appdata; |
654 |
ce->path = path; |
ce->path = path; |
655 |
ce->done = FALSE; |
ce->done = FALSE; |
656 |
|
|
657 |
g_signal_connect(view, "expose-event", |
g_signal_connect(view, "expose-event", |
658 |
(GCallback)cachelist_expose, ce); |
(GCallback)cachelist_expose, ce); |
|
g_signal_connect(view, "destroy", |
|
|
(GCallback)cachelist_destroy, ce); |
|
659 |
|
|
660 |
/* put this inside a scrolled view */ |
/* put this inside a scrolled view */ |
661 |
#ifndef USE_PANNABLE_AREA |
#ifndef USE_PANNABLE_AREA |
662 |
GtkWidget *scrolled_window = gtk_scrolled_window_new (NULL, NULL); |
GtkWidget *container = gtk_scrolled_window_new (NULL, NULL); |
663 |
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), |
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(container), |
664 |
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); |
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); |
665 |
gtk_container_add(GTK_CONTAINER(scrolled_window), view); |
gtk_container_add(GTK_CONTAINER(container), view); |
666 |
#else |
#else |
667 |
GtkWidget *pannable_area = hildon_pannable_area_new(); |
GtkWidget *container = hildon_pannable_area_new(); |
668 |
|
gtk_container_add(GTK_CONTAINER(container), view); |
|
gtk_container_add(GTK_CONTAINER(pannable_area), view); |
|
669 |
#endif |
#endif |
670 |
|
|
671 |
/* add a timer for automatic update */ |
g_signal_connect(view, "destroy", |
672 |
g_assert(!appdata->cachelist_handler_id); |
(GCallback)cachelist_destroy, container); |
|
appdata->cachelist_handler_id = |
|
|
gtk_timeout_add(CACHELIST_UPDATE_TIMEOUT, cachelist_update, appdata); |
|
673 |
|
|
674 |
/* update timer is being reset if the user scrolls or selects */ |
/* update timer is being reset if the user scrolls or selects */ |
675 |
g_signal_connect(view, "button-press-event", |
g_signal_connect(view, "button-press-event", |
676 |
(GCallback)cachelist_update_reset0, appdata); |
(GCallback)cachelist_update_reset0, container); |
677 |
|
|
678 |
|
/* add a timer for automatic update */ |
679 |
|
g_object_set_data(G_OBJECT(container), "handler_id", (gpointer) |
680 |
|
gtk_timeout_add(CACHELIST_UPDATE_TIMEOUT, cachelist_update, container)); |
681 |
|
|
682 |
|
printf("cachelist timer created\n"); |
683 |
|
|
684 |
|
g_object_set_data(G_OBJECT(container), "appdata", (gpointer)appdata); |
685 |
|
|
686 |
|
g_object_set_data(G_OBJECT(container), "ce", (gpointer)ce); |
687 |
|
|
688 |
|
/* the timer is removed and re-enabled on every focus change event */ |
689 |
|
/* for the main top window */ |
690 |
|
// GtkWidget *root = gtk_widget_get_toplevel(GTK_WIDGET(button))) |
691 |
|
|
692 |
|
g_signal_connect(G_OBJECT(view), "focus-in-event", |
693 |
|
G_CALLBACK(on_cachelist_focus_in), container); |
694 |
|
|
695 |
|
g_signal_connect(G_OBJECT(view), "focus-out-event", |
696 |
|
G_CALLBACK(on_cachelist_focus_out), container); |
697 |
|
|
698 |
#ifndef USE_PANNABLE_AREA |
#ifndef USE_PANNABLE_AREA |
699 |
g_signal_connect(gtk_scrolled_window_get_vadjustment( |
g_signal_connect(gtk_scrolled_window_get_vadjustment( |
700 |
GTK_SCROLLED_WINDOW(scrolled_window)), |
GTK_SCROLLED_WINDOW(container)), |
701 |
"value-changed", |
"value-changed", |
702 |
(GCallback)cachelist_update_reset1, appdata); |
(GCallback)cachelist_update_reset1, container); |
|
|
|
|
return scrolled_window; |
|
703 |
#else |
#else |
704 |
g_signal_connect(hildon_pannable_area_get_vadjustment( |
g_signal_connect(hildon_pannable_area_get_vadjustment( |
705 |
HILDON_PANNABLE_AREA(pannable_area)), |
HILDON_PANNABLE_AREA(container)), |
706 |
"value-changed", |
"value-changed", |
707 |
(GCallback)cachelist_update_reset1, appdata); |
(GCallback)cachelist_update_reset1, container); |
|
|
|
708 |
|
|
|
return pannable_area; |
|
709 |
#endif |
#endif |
710 |
|
return container; |
711 |
} |
} |
712 |
|
|
713 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
734 |
static void search_result_free(gpx_t *result); |
static void search_result_free(gpx_t *result); |
735 |
|
|
736 |
void on_cachelist_destroy(GtkWidget *widget, appdata_t *appdata) { |
void on_cachelist_destroy(GtkWidget *widget, appdata_t *appdata) { |
737 |
|
printf("cachelist destroy\n"); |
738 |
|
|
739 |
|
HildonWindowStack *stack = hildon_window_stack_get_default(); |
740 |
|
appdata->window = HILDON_WINDOW(hildon_window_stack_peek(stack)); |
741 |
|
|
742 |
if(appdata->search_results) { |
if(appdata->search_results) { |
743 |
search_result_free(appdata->search_results); |
search_result_free(appdata->search_results); |
744 |
appdata->search_results = NULL; |
appdata->search_results = NULL; |
745 |
} |
} |
746 |
appdata->cur_gpx = NULL; |
appdata->cur_gpx = NULL; |
747 |
|
|
748 |
|
#ifdef ENABLE_OSM_GPS_MAP |
749 |
|
map_update(appdata); |
750 |
|
#endif |
751 |
|
|
752 |
/* restore cur_view */ |
/* restore cur_view */ |
753 |
appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view"); |
appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view"); |
754 |
} |
} |
755 |
|
|
756 |
void cachelist_dialog(appdata_t *appdata, gpx_t *gpx) { |
void cachelist_dialog(appdata_t *appdata, gpx_t *gpx) { |
757 |
GtkWidget *window = hildon_stackable_window_new(); |
GtkWidget *window = hildon_stackable_window_new(); |
758 |
|
appdata->window = HILDON_WINDOW(window); |
759 |
|
|
760 |
/* store last "cur_view" in window */ |
/* store last "cur_view" in window */ |
761 |
g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view); |
g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view); |
762 |
|
|
763 |
appdata->cur_gpx = gpx; |
appdata->cur_gpx = gpx; |
764 |
char *title = g_strdup_printf("%s - GPXView", gpx->name); |
gtk_window_set_title(GTK_WINDOW(window), gpx->name); |
|
gtk_window_set_title(GTK_WINDOW(window), title); |
|
|
g_free(title); |
|
765 |
|
|
766 |
appdata->cur_view = cachelist_create(appdata, gpx, NULL); |
appdata->cur_view = cachelist_create(appdata, gpx, NULL); |
767 |
gtk_container_add(GTK_CONTAINER(window), appdata->cur_view); |
gtk_container_add(GTK_CONTAINER(window), appdata->cur_view); |
774 |
G_CALLBACK(on_cachelist_destroy), appdata); |
G_CALLBACK(on_cachelist_destroy), appdata); |
775 |
|
|
776 |
gtk_widget_show_all(window); |
gtk_widget_show_all(window); |
777 |
|
|
778 |
|
#ifdef ENABLE_OSM_GPS_MAP |
779 |
|
map_update(appdata); |
780 |
|
#endif |
781 |
} |
} |
782 |
#endif |
#endif |
783 |
#endif |
#endif |
810 |
return icon_get(ICON_FILE, 0); |
return icon_get(ICON_FILE, 0); |
811 |
} |
} |
812 |
|
|
813 |
static void gpxlist_set(GtkListStore *store, GtkTreeIter *iter, gpx_t *gpx) { |
void gpxlist_set(GtkListStore *store, GtkTreeIter *iter, gpx_t *gpx) { |
814 |
char date_str[32], cnum[32]; |
char date_str[32], cnum[32]; |
815 |
|
|
816 |
if(gpx->year && gpx->month && gpx->day) { |
if(gpx->year && gpx->month && gpx->day) { |
835 |
GPXLIST_COL_OPEN, !gpx->closed, |
GPXLIST_COL_OPEN, !gpx->closed, |
836 |
GPXLIST_COL_CACHES, gpx->closed?NULL:cnum, |
GPXLIST_COL_CACHES, gpx->closed?NULL:cnum, |
837 |
#ifdef USE_PANNABLE_AREA |
#ifdef USE_PANNABLE_AREA |
838 |
GPXLIST_COL_DELETE, icon_get(ICON_MISC, 7), |
GPXLIST_COL_DELETE, icon_get(ICON_MISC, 2), |
839 |
#endif |
#endif |
840 |
GPXLIST_COL_DATA, gpx, |
GPXLIST_COL_DATA, gpx, |
841 |
-1); |
-1); |
881 |
gconf_save_closed_name(appdata, gpx->filename, gpx->name); |
gconf_save_closed_name(appdata, gpx->filename, gpx->name); |
882 |
} |
} |
883 |
|
|
884 |
|
void gpxlist_goto_cachelist(appdata_t *appdata, gpx_t *gpx) { |
885 |
|
#if !defined(USE_BREAD_CRUMB_TRAIL) && !defined(BCT) |
886 |
|
#ifdef USE_STACKABLE_WINDOW |
887 |
|
if(!appdata->cur_gpx) |
888 |
|
#endif |
889 |
|
cachelist_dialog(appdata, gpx); |
890 |
|
#ifdef USE_STACKABLE_WINDOW |
891 |
|
else |
892 |
|
printf("selected gpx, but cachelist window already present\n"); |
893 |
|
#endif |
894 |
|
#else |
895 |
|
gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
896 |
|
appdata->cur_view = cachelist_create(appdata, gpx, NULL); |
897 |
|
gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view); |
898 |
|
gtk_widget_show_all(appdata->vbox); |
899 |
|
|
900 |
|
crumb_add(appdata, gpx->name, CRUMB_CACHELIST, gpx); |
901 |
|
#endif |
902 |
|
} |
903 |
|
|
904 |
static void gpxlist_view_onRowActivated(GtkTreeView *treeview, |
static void gpxlist_view_onRowActivated(GtkTreeView *treeview, |
905 |
GtkTreePath *path, |
GtkTreePath *path, |
906 |
GtkTreeViewColumn *col, |
GtkTreeViewColumn *col, |
909 |
GtkTreeIter iter; |
GtkTreeIter iter; |
910 |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
911 |
|
|
912 |
|
#ifdef USE_MAEMO |
913 |
|
/* check if a cache is already selected and ignore click if yes */ |
914 |
|
/* (was probably a double click) */ |
915 |
|
if(appdata->cur_gpx) return; |
916 |
|
#endif |
917 |
|
|
918 |
if (gtk_tree_model_get_iter(model, &iter, path)) { |
if (gtk_tree_model_get_iter(model, &iter, path)) { |
919 |
gpx_t *gpx; |
gpx_t *gpx; |
920 |
gtk_tree_model_get(model, &iter, GPXLIST_COL_DATA, &gpx, -1); |
gtk_tree_model_get(model, &iter, GPXLIST_COL_DATA, &gpx, -1); |
927 |
if(col_name && !strcmp(col_name, "Del")) { |
if(col_name && !strcmp(col_name, "Del")) { |
928 |
printf("clicked delete\n"); |
printf("clicked delete\n"); |
929 |
|
|
930 |
|
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
931 |
/* ask user what he wants */ |
/* ask user what he wants */ |
932 |
GtkWidget *dialog = gtk_message_dialog_new( |
GtkWidget *dialog = gtk_message_dialog_new( |
933 |
GTK_WINDOW(appdata->window), |
GTK_WINDOW(appdata->window), |
934 |
GTK_DIALOG_DESTROY_WITH_PARENT, |
GTK_DIALOG_DESTROY_WITH_PARENT, |
935 |
GTK_MESSAGE_QUESTION, GTK_BUTTONS_CANCEL, |
GTK_MESSAGE_QUESTION, |
936 |
|
GTK_BUTTONS_CANCEL, |
937 |
_("Do you want to close this entry only or do " |
_("Do you want to close this entry only or do " |
938 |
"you want to remove it completely from the list?")); |
"you want to remove it completely from the list?")); |
939 |
|
|
942 |
_("Close"), 2, |
_("Close"), 2, |
943 |
NULL); |
NULL); |
944 |
|
|
945 |
|
gtk_window_set_title(GTK_WINDOW(dialog), _("Close or remove entry?")); |
946 |
|
#else |
947 |
|
|
948 |
|
GtkWidget *dialog = |
949 |
|
gtk_dialog_new_with_buttons(_("Close or remove entry?"), |
950 |
|
GTK_WINDOW(appdata->window), |
951 |
|
GTK_DIALOG_DESTROY_WITH_PARENT, |
952 |
|
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, |
953 |
|
_("Remove"), 1, |
954 |
|
_("Close"), 2, |
955 |
|
NULL); |
956 |
|
|
957 |
|
GtkWidget *content_area = |
958 |
|
gtk_dialog_get_content_area (GTK_DIALOG (dialog)); |
959 |
|
|
960 |
|
GtkWidget *hbox = gtk_hbox_new(FALSE, 0); |
961 |
|
|
962 |
|
GtkWidget *label = gtk_label_new( |
963 |
|
_("Do you want to close this entry only or do " |
964 |
|
"you want to remove it completely from the list?")); |
965 |
|
|
966 |
|
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
967 |
|
gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_WORD); |
968 |
|
|
969 |
|
gtk_box_pack_start_defaults(GTK_BOX(hbox), label); |
970 |
|
gtk_container_add (GTK_CONTAINER (content_area), hbox); |
971 |
|
|
972 |
|
gtk_widget_show_all (dialog); |
973 |
|
#endif |
974 |
|
|
975 |
if(gpx->closed) |
if(gpx->closed) |
976 |
gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), 2, FALSE); |
gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), 2, FALSE); |
977 |
|
|
|
gtk_window_set_title(GTK_WINDOW(dialog), _("Remove entry?")); |
|
|
|
|
978 |
/* set the active flag again if the user answered "no" */ |
/* set the active flag again if the user answered "no" */ |
979 |
switch(gtk_dialog_run(GTK_DIALOG(dialog))) { |
switch(gtk_dialog_run(GTK_DIALOG(dialog))) { |
980 |
|
|
1004 |
gpx_t *new = NULL; |
gpx_t *new = NULL; |
1005 |
|
|
1006 |
if(g_file_test(gpx->filename, G_FILE_TEST_IS_DIR)) |
if(g_file_test(gpx->filename, G_FILE_TEST_IS_DIR)) |
1007 |
new = gpx_parse_dir(dialog, gpx->filename); |
new = gpx_parse_dir(dialog, gpx->filename, appdata->username); |
1008 |
else |
else |
1009 |
new = gpx_parse(dialog, gpx->filename); |
new = gpx_parse(dialog, gpx->filename, appdata->username); |
1010 |
|
|
1011 |
if(new) { |
if(new) { |
1012 |
gpx_t **prev = &(appdata->gpx); |
gpx_t **prev = &(appdata->gpx); |
1042 |
|
|
1043 |
gpx_busy_dialog_destroy(dialog); |
gpx_busy_dialog_destroy(dialog); |
1044 |
} |
} |
1045 |
#ifndef USE_BREAD_CRUMB_TRAIL |
|
1046 |
#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 |
|
1047 |
} |
} |
1048 |
} |
} |
1049 |
} |
} |
1050 |
|
|
1051 |
|
/* search gpx file in gpx list */ |
1052 |
|
gboolean gpxlist_find(appdata_t *appdata, GtkTreeIter *iter, gpx_t *gpx) { |
1053 |
|
GtkTreeModel *model = |
1054 |
|
gtk_tree_view_get_model(GTK_TREE_VIEW(appdata->gpxview)); |
1055 |
|
|
1056 |
|
gboolean found = |
1057 |
|
gtk_tree_model_get_iter_first(model, iter); |
1058 |
|
|
1059 |
|
while(found) { |
1060 |
|
gpx_t *this_gpx; |
1061 |
|
gtk_tree_model_get(model, iter, GPXLIST_COL_DATA, &this_gpx, -1); |
1062 |
|
|
1063 |
|
if(gpx == this_gpx) |
1064 |
|
return TRUE; |
1065 |
|
|
1066 |
|
found = gtk_tree_model_iter_next(model, iter); |
1067 |
|
} |
1068 |
|
|
1069 |
|
return FALSE; |
1070 |
|
} |
1071 |
|
|
1072 |
|
|
1073 |
#ifndef USE_PANNABLE_AREA |
#ifndef USE_PANNABLE_AREA |
1074 |
static gboolean |
static gboolean |
1075 |
view_selection_func(GtkTreeSelection *selection, GtkTreeModel *model, |
view_selection_func(GtkTreeSelection *selection, GtkTreeModel *model, |
1108 |
|
|
1109 |
appdata->gpxview = gtk_tree_view_new (); |
appdata->gpxview = gtk_tree_view_new (); |
1110 |
|
|
1111 |
|
printf("building gpx list, items = %d\n", appdata->gpxlist_items); |
1112 |
|
|
1113 |
GtkTreeSelection *selection = |
GtkTreeSelection *selection = |
1114 |
gtk_tree_view_get_selection(GTK_TREE_VIEW(appdata->gpxview)); |
gtk_tree_view_get_selection(GTK_TREE_VIEW(appdata->gpxview)); |
1115 |
#ifndef USE_PANNABLE_AREA |
#ifndef USE_PANNABLE_AREA |
1122 |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview), |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview), |
1123 |
-1, "Icon", renderer, |
-1, "Icon", renderer, |
1124 |
"pixbuf", GPXLIST_COL_ICON, |
"pixbuf", GPXLIST_COL_ICON, |
1125 |
// "sensitive", GPXLIST_COL_OPEN, |
#ifdef USE_PANNABLE_AREA |
1126 |
|
/* at least one entry needs to be sensitive. */ |
1127 |
|
/* This is the delete icon if the PANNABLE_AREA is used */ |
1128 |
|
"sensitive", GPXLIST_COL_OPEN, |
1129 |
|
#endif |
1130 |
NULL); |
NULL); |
1131 |
|
|
1132 |
/* --- "FileName" column --- */ |
/* --- "FileName" column --- */ |
1182 |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview), |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview), |
1183 |
-1, "Del", renderer, |
-1, "Del", renderer, |
1184 |
"pixbuf", GPXLIST_COL_DELETE, |
"pixbuf", GPXLIST_COL_DELETE, |
1185 |
"sensitive", GPXLIST_COL_OPEN, |
// "sensitive", GPXLIST_COL_OPEN, |
1186 |
NULL); |
NULL); |
1187 |
#endif |
#endif |
1188 |
|
|
1202 |
GtkTreeIter iter; |
GtkTreeIter iter; |
1203 |
gtk_list_store_append(appdata->gpxstore, &iter); |
gtk_list_store_append(appdata->gpxstore, &iter); |
1204 |
gpxlist_set(appdata->gpxstore, &iter, gpx); |
gpxlist_set(appdata->gpxstore, &iter, gpx); |
1205 |
|
|
1206 |
if(gpx == sel_gpx) { |
if(gpx == sel_gpx) { |
1207 |
sel_iter = iter; |
sel_iter = iter; |
1208 |
sel_iter_valid = TRUE; |
sel_iter_valid = TRUE; |
1246 |
} |
} |
1247 |
|
|
1248 |
/* add last entry in gpx list to visual representation */ |
/* add last entry in gpx list to visual representation */ |
1249 |
static void gpxlist_add(appdata_t *appdata, gpx_t *new) { |
void gpxlist_add(appdata_t *appdata, gpx_t *new) { |
1250 |
GtkTreeIter iter; |
GtkTreeIter iter; |
1251 |
|
|
1252 |
gtk_list_store_append(appdata->gpxstore, &iter); |
gtk_list_store_append(appdata->gpxstore, &iter); |
1256 |
gpx_t **gpx = &appdata->gpx; |
gpx_t **gpx = &appdata->gpx; |
1257 |
while(*gpx) gpx = &((*gpx)->next); |
while(*gpx) gpx = &((*gpx)->next); |
1258 |
*gpx = new; |
*gpx = new; |
1259 |
|
|
1260 |
|
/* select new iter */ |
1261 |
|
GtkTreeSelection *selection = |
1262 |
|
gtk_tree_view_get_selection(GTK_TREE_VIEW(appdata->gpxview)); |
1263 |
|
gtk_tree_selection_select_iter(selection, &iter); |
1264 |
|
GtkTreePath *path = |
1265 |
|
gtk_tree_model_get_path(GTK_TREE_MODEL(appdata->gpxstore), &iter); |
1266 |
|
gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(appdata->gpxview), |
1267 |
|
path, NULL, TRUE, 0.0, 0.0); |
1268 |
|
gtk_tree_path_free(path); |
1269 |
} |
} |
1270 |
|
|
1271 |
/******************** end of gpxlist ********************/ |
/******************** end of gpxlist ********************/ |
1274 |
|
|
1275 |
static void |
static void |
1276 |
cb_menu_about(GtkWidget *window, gpointer data) { |
cb_menu_about(GtkWidget *window, gpointer data) { |
1277 |
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-2009 by\n" |
|
|
"Till Harbaum <till@harbaum.org>\n" |
|
|
"Mailing list: gpxview-users@garage.maemo.org"), |
|
|
_(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)); |
|
1278 |
} |
} |
1279 |
|
|
1280 |
#if defined(USE_MAEMO) && defined(HILDON_HELP) |
#if defined(USE_MAEMO) && defined(HILDON_HELP) |
1446 |
else if(cache->long_description && (what & SEARCH_DESC) && |
else if(cache->long_description && (what & SEARCH_DESC) && |
1447 |
strcasestr(cache->long_description, phrase)) |
strcasestr(cache->long_description, phrase)) |
1448 |
hit = 1; |
hit = 1; |
1449 |
else if(cache->owner && (what & SEARCH_OWNER) && |
else if(cache->owner && cache->owner->name && (what & SEARCH_OWNER) && |
1450 |
strcasestr(cache->owner, phrase)) |
strcasestr(cache->owner->name, phrase)) |
1451 |
hit = 1; |
hit = 1; |
1452 |
|
|
1453 |
if(hit) { |
if(hit) { |
1476 |
GtkWidget *in_id, *in_name, *in_desc, *in_owner, *in_finds; |
GtkWidget *in_id, *in_name, *in_desc, *in_owner, *in_finds; |
1477 |
} search_context_t; |
} search_context_t; |
1478 |
|
|
1479 |
|
|
1480 |
static void callback_finds_toggled(GtkWidget *widget, gpointer data ) { |
static void callback_finds_toggled(GtkWidget *widget, gpointer data ) { |
1481 |
search_context_t *context = (search_context_t*)data; |
search_context_t *context = (search_context_t*)data; |
1482 |
|
|
1483 |
gboolean in_finds = gtk_toggle_button_get_active( |
gboolean in_finds = check_button_get_active(context->in_finds); |
|
GTK_TOGGLE_BUTTON(context->in_finds)); |
|
1484 |
|
|
1485 |
gtk_widget_set_sensitive(context->entry, !in_finds); |
gtk_widget_set_sensitive(context->entry, !in_finds); |
1486 |
gtk_widget_set_sensitive(context->in_id, !in_finds); |
gtk_widget_set_sensitive(context->in_id, !in_finds); |
1510 |
GtkWidget *table = gtk_table_new(2, 2, TRUE); |
GtkWidget *table = gtk_table_new(2, 2, TRUE); |
1511 |
gtk_table_set_col_spacing(GTK_TABLE(table), 0, 8); |
gtk_table_set_col_spacing(GTK_TABLE(table), 0, 8); |
1512 |
|
|
1513 |
context.in_id = gtk_check_button_new_with_label(_("Waypoint IDs")); |
context.in_id = check_button_new_with_label(_("Waypoint IDs")); |
1514 |
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); |
|
1515 |
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); |
1516 |
|
|
1517 |
context.in_name = gtk_check_button_new_with_label(_("Names")); |
context.in_name = check_button_new_with_label(_("Names")); |
1518 |
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); |
|
1519 |
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); |
1520 |
|
|
1521 |
context.in_desc = gtk_check_button_new_with_label(_("Descriptions")); |
context.in_desc = check_button_new_with_label(_("Descriptions")); |
1522 |
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); |
|
1523 |
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); |
1524 |
|
|
1525 |
context.in_owner = gtk_check_button_new_with_label(_("Owner")); |
context.in_owner = check_button_new_with_label(_("Owner")); |
1526 |
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); |
|
1527 |
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); |
1528 |
|
|
1529 |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table); |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table); |
1532 |
|
|
1533 |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), |
1534 |
gtk_label_new(_("Search for:"))); |
gtk_label_new(_("Search for:"))); |
1535 |
|
context.entry = entry_new(); |
1536 |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), |
1537 |
context.entry = gtk_entry_new()); |
context.entry); |
1538 |
|
|
1539 |
if(appdata->search_str) |
if(appdata->search_str) |
1540 |
gtk_entry_set_text(GTK_ENTRY(context.entry), appdata->search_str); |
gtk_entry_set_text(GTK_ENTRY(context.entry), appdata->search_str); |
1541 |
|
|
1546 |
|
|
1547 |
GtkWidget *hbox = gtk_hbox_new(FALSE, 5); |
GtkWidget *hbox = gtk_hbox_new(FALSE, 5); |
1548 |
|
|
1549 |
context.in_finds = gtk_check_button_new_with_label(_("Search finds for")); |
context.in_finds = check_button_new_with_label(_("Search finds for")); |
1550 |
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); |
|
1551 |
gtk_box_pack_start_defaults(GTK_BOX(hbox), context.in_finds); |
gtk_box_pack_start_defaults(GTK_BOX(hbox), context.in_finds); |
1552 |
g_signal_connect(G_OBJECT(context.in_finds), "toggled", |
g_signal_connect(G_OBJECT(context.in_finds), "toggled", |
1553 |
G_CALLBACK(callback_finds_toggled), &context); |
G_CALLBACK(callback_finds_toggled), &context); |
1554 |
|
|
1555 |
#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 |
|
1556 |
gtk_box_pack_start_defaults(GTK_BOX(hbox), context.spinner); |
gtk_box_pack_start_defaults(GTK_BOX(hbox), context.spinner); |
1557 |
|
|
1558 |
gtk_box_pack_start_defaults(GTK_BOX(hbox), gtk_label_new(_("days"))); |
gtk_box_pack_start_defaults(GTK_BOX(hbox), gtk_label_new(_("days"))); |
1559 |
|
|
1560 |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox); |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox); |
1572 |
if(strlen(p) > 0) |
if(strlen(p) > 0) |
1573 |
appdata->search_str = strdup(p); |
appdata->search_str = strdup(p); |
1574 |
|
|
1575 |
#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 |
|
1576 |
|
|
1577 |
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_finds))) |
if(check_button_get_active(context.in_finds)) |
1578 |
appdata->search |= SEARCH_FINDS; |
appdata->search |= SEARCH_FINDS; |
1579 |
else |
else |
1580 |
appdata->search &= ~SEARCH_FINDS; |
appdata->search &= ~SEARCH_FINDS; |
1581 |
|
|
1582 |
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_id))) |
if(check_button_get_active(context.in_id)) |
1583 |
appdata->search |= SEARCH_ID; |
appdata->search |= SEARCH_ID; |
1584 |
else |
else |
1585 |
appdata->search &= ~SEARCH_ID; |
appdata->search &= ~SEARCH_ID; |
1586 |
|
|
1587 |
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_name))) |
if(check_button_get_active(context.in_name)) |
1588 |
appdata->search |= SEARCH_NAME; |
appdata->search |= SEARCH_NAME; |
1589 |
else |
else |
1590 |
appdata->search &= ~SEARCH_NAME; |
appdata->search &= ~SEARCH_NAME; |
1591 |
|
|
1592 |
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_desc))) |
if(check_button_get_active(context.in_desc)) |
1593 |
appdata->search |= SEARCH_DESC; |
appdata->search |= SEARCH_DESC; |
1594 |
else |
else |
1595 |
appdata->search &= ~SEARCH_DESC; |
appdata->search &= ~SEARCH_DESC; |
1596 |
|
|
1597 |
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_owner))) |
if(check_button_get_active(context.in_owner)) |
1598 |
appdata->search |= SEARCH_OWNER; |
appdata->search |= SEARCH_OWNER; |
1599 |
else |
else |
1600 |
appdata->search &= ~SEARCH_OWNER; |
appdata->search &= ~SEARCH_OWNER; |
1607 |
|
|
1608 |
printf("Search for %s (flags = %x)...\n", p, appdata->search); |
printf("Search for %s (flags = %x)...\n", p, appdata->search); |
1609 |
|
|
1610 |
#ifndef USE_BREAD_CRUMB_TRAIL |
#if !defined(USE_BREAD_CRUMB_TRAIL) && !defined(BCT) |
1611 |
gpx_t *found = |
|
1612 |
search_do(appdata, appdata->gpx, p, appdata->search, FALSE); |
if(appdata->cur_gpx) |
1613 |
|
appdata->search_results = |
1614 |
|
search_do(appdata, appdata->cur_gpx, p, appdata->search, TRUE); |
1615 |
|
else |
1616 |
|
appdata->search_results = |
1617 |
|
search_do(appdata, appdata->gpx, p, appdata->search, FALSE); |
1618 |
|
|
1619 |
/* do search result dialog here ... */ |
/* do search result dialog here ... */ |
1620 |
cachelist_dialog(appdata, found); |
cachelist_dialog(appdata, appdata->search_results); |
1621 |
|
|
1622 |
#ifndef USE_STACKABLE_WINDOW |
#ifndef USE_STACKABLE_WINDOW |
1623 |
search_result_free(found); |
search_result_free(appdata->search_results); |
1624 |
#else |
appdata->search_results = NULL; |
|
appdata->search_results = found; |
|
1625 |
#endif |
#endif |
1626 |
#else |
#else |
1627 |
gpx_t *found = NULL; |
gpx_t *found = NULL; |
1646 |
gtk_widget_destroy(dialog); |
gtk_widget_destroy(dialog); |
1647 |
} |
} |
1648 |
|
|
1649 |
void on_window_destroy (GtkWidget *widget, gpointer data); |
static void on_window_destroy (GtkWidget *widget, gpointer data); |
1650 |
|
|
1651 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
1652 |
static void |
static void |
1708 |
notes_log_export(appdata); |
notes_log_export(appdata); |
1709 |
} |
} |
1710 |
|
|
1711 |
#ifdef USE_MAEMO |
#ifdef ENABLE_MAEMO_MAPPER |
1712 |
static void |
static void |
1713 |
cb_menu_export_mmpoi(GtkWidget *widget, gpointer data) { |
cb_menu_export_mmpoi(GtkWidget *widget, gpointer data) { |
1714 |
appdata_t *appdata = (appdata_t*)data; |
appdata_t *appdata = (appdata_t*)data; |
1744 |
precise_position((appdata_t *)data); |
precise_position((appdata_t *)data); |
1745 |
} |
} |
1746 |
|
|
1747 |
|
static void |
1748 |
|
cb_menu_geotoad(GtkWidget *window, gpointer data) { |
1749 |
|
geotoad((appdata_t *)data); |
1750 |
|
} |
1751 |
|
|
1752 |
#ifdef USE_STACKABLE_WINDOW |
#ifdef USE_STACKABLE_WINDOW |
1753 |
typedef struct { |
typedef struct { |
1754 |
char *label, *desc; |
char *label, *desc; |
1832 |
} |
} |
1833 |
|
|
1834 |
static const menu_entry_t submenu_export_entries[] = { |
static const menu_entry_t submenu_export_entries[] = { |
1835 |
|
#ifdef ENABLE_MAEMO_MAPPER |
1836 |
{ "Export to Maemo Mapper" , "Save a Maemo Mapper POI file", |
{ "Export to Maemo Mapper" , "Save a Maemo Mapper POI file", |
1837 |
G_CALLBACK(cb_menu_export_mmpoi) }, |
G_CALLBACK(cb_menu_export_mmpoi) }, |
1838 |
|
#endif |
1839 |
{ "Export Field Notes", "Save a Garmin Field Notes file", |
{ "Export Field Notes", "Save a Garmin Field Notes file", |
1840 |
G_CALLBACK(cb_menu_export_log) }, |
G_CALLBACK(cb_menu_export_log) }, |
1841 |
{ "Export Garmin GPX", "Save modified waypoints in GPX file", |
{ "Export Garmin GPX", "Save modified waypoints in GPX file", |
1857 |
} |
} |
1858 |
|
|
1859 |
static const menu_entry_t submenu_tools_entries[] = { |
static const menu_entry_t submenu_tools_entries[] = { |
|
#ifdef ENABLE_OSM_GPS_MAP |
|
|
{ "Map", "Display an interactive world map", |
|
|
G_CALLBACK(cb_menu_map) }, |
|
|
#endif |
|
1860 |
{ "Geomath", "Geocoordinate calculation", |
{ "Geomath", "Geocoordinate calculation", |
1861 |
G_CALLBACK(cb_menu_geomath) }, |
G_CALLBACK(cb_menu_geomath) }, |
1862 |
{ "Geotext", "Text analysis", |
{ "Geotext", "Text analysis", |
1863 |
G_CALLBACK(cb_menu_geotext) }, |
G_CALLBACK(cb_menu_geotext) }, |
1864 |
{ "Precise Position", "Calculate a precise GPS position", |
{ "Precise Position", "Calculate a precise GPS position", |
1865 |
G_CALLBACK(cb_menu_precpos) }, |
G_CALLBACK(cb_menu_precpos) }, |
1866 |
|
{ "GeoToad", "Use GeoToad online downloader", |
1867 |
|
G_CALLBACK(cb_menu_geotoad) }, |
1868 |
{ NULL, NULL, NULL } |
{ NULL, NULL, NULL } |
1869 |
}; |
}; |
1870 |
|
|
1906 |
g_signal_connect_after(button, "clicked", |
g_signal_connect_after(button, "clicked", |
1907 |
G_CALLBACK(cb_menu_adddir), appdata); |
G_CALLBACK(cb_menu_adddir), appdata); |
1908 |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
|
} |
|
1909 |
|
|
|
if(mode == MENU_GPXLIST) { |
|
1910 |
button = gtk_button_new_with_label(_("Export")); |
button = gtk_button_new_with_label(_("Export")); |
1911 |
g_signal_connect_after(button, "clicked", |
g_signal_connect_after(button, "clicked", |
1912 |
G_CALLBACK(on_export_clicked), appdata); |
G_CALLBACK(on_export_clicked), appdata); |
1913 |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1914 |
|
} |
1915 |
|
|
1916 |
|
/* if search results exist, don't allow another search */ |
1917 |
|
if(!appdata->search_results && |
1918 |
|
((mode == MENU_GPXLIST) || (mode == MENU_CACHELIST))) { |
1919 |
button = gtk_button_new_with_label(_("Search")); |
button = gtk_button_new_with_label(_("Search")); |
1920 |
g_signal_connect_after(button, "clicked", |
g_signal_connect_after(button, "clicked", |
1921 |
G_CALLBACK(cb_menu_search), appdata); |
G_CALLBACK(cb_menu_search), appdata); |
1927 |
G_CALLBACK(on_tools_clicked), appdata); |
G_CALLBACK(on_tools_clicked), appdata); |
1928 |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1929 |
|
|
1930 |
|
#ifdef ENABLE_OSM_GPS_MAP |
1931 |
|
button = gtk_button_new_with_label(_("Map")); |
1932 |
|
g_signal_connect_after(button, "clicked", |
1933 |
|
G_CALLBACK(cb_menu_map), appdata); |
1934 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1935 |
|
#endif |
1936 |
|
|
1937 |
#ifdef HILDON_HELP |
#ifdef HILDON_HELP |
1938 |
button = gtk_button_new_with_label(_("Help")); |
button = gtk_button_new_with_label(_("Help")); |
1939 |
g_signal_connect_after(button, "clicked", |
g_signal_connect_after(button, "clicked", |
1951 |
GtkWidget *menu, *item; |
GtkWidget *menu, *item; |
1952 |
menu = gtk_menu_new(); |
menu = gtk_menu_new(); |
1953 |
|
|
1954 |
#ifdef USE_BREAD_CRUMB_TRAIL |
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
1955 |
appdata->menu_import = |
appdata->menu_import = |
1956 |
#endif |
#endif |
1957 |
item = gtk_menu_item_new_with_label(_("Import")); |
item = gtk_menu_item_new_with_label(_("Import")); |
1981 |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_remove), appdata); |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_remove), appdata); |
1982 |
#endif |
#endif |
1983 |
|
|
1984 |
#ifdef USE_BREAD_CRUMB_TRAIL |
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
1985 |
appdata->menu_export = |
appdata->menu_export = |
1986 |
#endif |
#endif |
1987 |
item = gtk_menu_item_new_with_label(_("Export")); |
item = gtk_menu_item_new_with_label(_("Export")); |
1989 |
submenu = gtk_menu_new(); |
submenu = gtk_menu_new(); |
1990 |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
1991 |
|
|
1992 |
#ifdef USE_MAEMO |
#ifdef ENABLE_MAEMO_MAPPER |
1993 |
item = gtk_menu_item_new_with_label( _("Maemo Mapper POI") ); |
item = gtk_menu_item_new_with_label( _("Maemo Mapper POI") ); |
1994 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1995 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
2006 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
2007 |
GTK_SIGNAL_FUNC(cb_menu_export_garmin), appdata); |
GTK_SIGNAL_FUNC(cb_menu_export_garmin), appdata); |
2008 |
|
|
2009 |
#ifdef USE_BREAD_CRUMB_TRAIL |
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
2010 |
appdata->menu_search = |
appdata->menu_search = |
2011 |
#endif |
#endif |
2012 |
item = gtk_menu_item_new_with_label( _("Search") ); |
item = gtk_menu_item_new_with_label( _("Search") ); |
2015 |
|
|
2016 |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
2017 |
|
|
|
#ifndef NO_COPY_N_PASTE |
|
2018 |
/* ----------- copy'n paste submenu ----------------- */ |
/* ----------- copy'n paste submenu ----------------- */ |
2019 |
appdata->clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); |
#ifndef NO_COPY_N_PASTE |
|
gtk_clipboard_set_can_store(appdata->clipboard, NULL, 0); |
|
|
|
|
2020 |
item = gtk_menu_item_new_with_label(_("Edit")); |
item = gtk_menu_item_new_with_label(_("Edit")); |
2021 |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
2022 |
submenu = gtk_menu_new(); |
submenu = gtk_menu_new(); |
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 |
|
|
|
item = gtk_menu_item_new_with_label(_("Tools")); |
|
|
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
|
|
submenu = gtk_menu_new(); |
|
|
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
|
|
|
|
2046 |
#ifdef ENABLE_OSM_GPS_MAP |
#ifdef ENABLE_OSM_GPS_MAP |
2047 |
item = gtk_menu_item_new_with_label( _("Map") ); |
item = gtk_menu_item_new_with_label( _("Map") ); |
2048 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
2049 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
2050 |
GTK_SIGNAL_FUNC(cb_menu_map), appdata); |
GTK_SIGNAL_FUNC(cb_menu_map), appdata); |
2051 |
#endif |
#endif |
2052 |
|
|
2053 |
|
item = gtk_menu_item_new_with_label(_("Tools")); |
2054 |
|
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
2055 |
|
submenu = gtk_menu_new(); |
2056 |
|
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
2057 |
|
|
2058 |
item = gtk_menu_item_new_with_label( _("Geomath") ); |
item = gtk_menu_item_new_with_label( _("Geomath") ); |
2059 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
2060 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
2070 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
2071 |
GTK_SIGNAL_FUNC(cb_menu_precpos), appdata); |
GTK_SIGNAL_FUNC(cb_menu_precpos), appdata); |
2072 |
|
|
2073 |
|
item = gtk_menu_item_new_with_label( _("GeoToad") ); |
2074 |
|
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
2075 |
|
g_signal_connect(item, "activate", |
2076 |
|
GTK_SIGNAL_FUNC(cb_menu_geotoad), appdata); |
2077 |
|
|
2078 |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
2079 |
|
|
2080 |
#if defined(USE_MAEMO) && defined(HILDON_HELP) |
#if defined(USE_MAEMO) && defined(HILDON_HELP) |
2114 |
/********************* end of menu **********************/ |
/********************* end of menu **********************/ |
2115 |
|
|
2116 |
void cleanup(appdata_t *appdata) { |
void cleanup(appdata_t *appdata) { |
2117 |
|
gps_unregister_callback(appdata->gps_state, main_gps_cb); |
2118 |
|
|
2119 |
|
gconf_save_state(appdata); |
2120 |
|
|
2121 |
gpx_free_all(appdata->gpx); |
gpx_free_all(appdata->gpx); |
2122 |
if(appdata->path) free(appdata->path); |
|
2123 |
if(appdata->image_path) free(appdata->image_path); |
#ifdef ESPEAK |
2124 |
if(appdata->search_str) free(appdata->search_str); |
espeak_Terminate(); |
2125 |
|
#endif |
2126 |
|
|
2127 |
#ifdef USE_STACKABLE_WINDOW |
#ifdef USE_STACKABLE_WINDOW |
2128 |
if(appdata->export_menu) submenu_cleanup(appdata->export_menu); |
if(appdata->export_menu) submenu_cleanup(appdata->export_menu); |
2131 |
|
|
2132 |
gnome_vfs_shutdown(); |
gnome_vfs_shutdown(); |
2133 |
icons_free(); |
icons_free(); |
|
gps_release(appdata); |
|
2134 |
|
|
2135 |
#ifdef USE_MAEMO |
gps_release(appdata->gps_state); |
2136 |
|
appdata->gps_state = NULL; |
2137 |
|
|
2138 |
if(appdata->search_results) { |
if(appdata->search_results) { |
2139 |
printf("freeing pending search\n"); |
printf("freeing pending search\n"); |
2140 |
search_result_free(appdata->search_results); |
search_result_free(appdata->search_results); |
2141 |
} |
} |
2142 |
|
|
2143 |
|
#ifdef USE_MAEMO |
2144 |
if(appdata->osso_context) |
if(appdata->osso_context) |
2145 |
osso_deinitialize(appdata->osso_context); |
osso_deinitialize(appdata->osso_context); |
2146 |
|
|
2159 |
puts("everything is gone"); |
puts("everything is gone"); |
2160 |
} |
} |
2161 |
|
|
2162 |
void on_window_destroy (GtkWidget *widget, gpointer data) { |
static void on_window_destroy (GtkWidget *widget, gpointer data) { |
2163 |
appdata_t *appdata = (appdata_t*)data; |
appdata_t *appdata = (appdata_t*)data; |
2164 |
|
|
|
gconf_save_state(appdata); |
|
2165 |
gtk_main_quit(); |
gtk_main_quit(); |
2166 |
appdata->window = NULL; |
appdata->window = NULL; |
2167 |
} |
} |
2221 |
return handled; |
return handled; |
2222 |
} |
} |
2223 |
|
|
2224 |
#ifdef USE_BREAD_CRUMB_TRAIL |
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
2225 |
typedef struct { |
typedef struct { |
2226 |
int level; |
int level; |
2227 |
appdata_t *appdata; |
appdata_t *appdata; |
2313 |
|
|
2314 |
gtk_widget_show_all(crumb->appdata->vbox); |
gtk_widget_show_all(crumb->appdata->vbox); |
2315 |
g_free(data); |
g_free(data); |
2316 |
|
|
2317 |
|
#ifdef ENABLE_OSM_GPS_MAP |
2318 |
|
map_update(crumb->appdata); |
2319 |
|
#endif |
2320 |
} |
} |
2321 |
|
|
2322 |
static void crumb_add(appdata_t *appdata, char *name, int level, |
static void crumb_add(appdata_t *appdata, char *name, int level, |
2323 |
gpointer user_data) { |
gpointer user_data) { |
2324 |
crumb_t *crumb = malloc(sizeof(crumb_t)); |
crumb_t *crumb = g_new0(crumb_t, 1); |
2325 |
crumb->level = level; |
crumb->level = level; |
2326 |
crumb->appdata = appdata; |
crumb->appdata = appdata; |
2327 |
crumb->data = user_data; |
crumb->data = user_data; |
2357 |
#endif |
#endif |
2358 |
} |
} |
2359 |
|
|
2360 |
|
#ifdef USE_BREAD_CRUMB_TRAIL |
2361 |
hildon_bread_crumb_trail_push_text(HILDON_BREAD_CRUMB_TRAIL(appdata->bct), |
hildon_bread_crumb_trail_push_text(HILDON_BREAD_CRUMB_TRAIL(appdata->bct), |
2362 |
name, crumb, (GDestroyNotify)crumb_back); |
name, crumb, (GDestroyNotify)crumb_back); |
2363 |
|
#else |
2364 |
|
bct_push_text(appdata->bct, name, crumb, (GDestroyNotify)crumb_back); |
2365 |
|
#endif |
2366 |
|
|
2367 |
|
#ifdef ENABLE_OSM_GPS_MAP |
2368 |
|
map_update(appdata); |
2369 |
|
#endif |
2370 |
} |
} |
2371 |
#endif // USE_BREAD_CRUMB_TRAIL |
#endif // USE_BREAD_CRUMB_TRAIL |
2372 |
|
|
2378 |
return; |
return; |
2379 |
} |
} |
2380 |
|
|
|
#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 |
|
2381 |
/* 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 */ |
2382 |
/* need to be redrawn */ |
/* need to be redrawn */ |
2383 |
if(appdata->cur_cache) { |
if(appdata->cur_cache) { |
2401 |
} |
} |
2402 |
|
|
2403 |
if(redraw) { |
if(redraw) { |
|
GtkWidget *container = appdata->vbox; |
|
2404 |
|
|
2405 |
#ifdef USE_STACKABLE_WINDOW |
#ifdef USE_STACKABLE_WINDOW |
2406 |
HildonWindowStack *stack = hildon_window_stack_get_default(); |
HildonWindowStack *stack = hildon_window_stack_get_default(); |
2407 |
container = hildon_window_stack_peek(stack); |
GtkWidget *container = hildon_window_stack_peek(stack); |
2408 |
|
#else |
2409 |
|
GtkWidget *container = appdata->vbox; |
2410 |
#endif |
#endif |
2411 |
|
|
2412 |
gtk_container_remove(GTK_CONTAINER(container), appdata->cur_view); |
gtk_container_remove(GTK_CONTAINER(container), appdata->cur_view); |
2425 |
} |
} |
2426 |
|
|
2427 |
#ifdef USE_STACKABLE_WINDOW |
#ifdef USE_STACKABLE_WINDOW |
|
if(container != appdata->vbox) |
|
2428 |
gtk_container_add(GTK_CONTAINER(container), appdata->cur_view); |
gtk_container_add(GTK_CONTAINER(container), appdata->cur_view); |
2429 |
else |
#else |
|
#endif |
|
2430 |
gtk_box_pack_start_defaults(GTK_BOX(container), appdata->cur_view); |
gtk_box_pack_start_defaults(GTK_BOX(container), appdata->cur_view); |
2431 |
|
#endif |
2432 |
|
|
2433 |
gtk_widget_show_all(container); |
gtk_widget_show_all(container); |
2434 |
} |
} |
|
#endif // USE_MAEMO |
|
2435 |
} |
} |
2436 |
|
|
2437 |
int main(int argc, char *argv[]) { |
int main(int argc, char *argv[]) { |
2452 |
|
|
2453 |
gtk_init (&argc, &argv); |
gtk_init (&argc, &argv); |
2454 |
|
|
2455 |
|
misc_init(); |
2456 |
|
|
2457 |
|
curl_global_init(CURL_GLOBAL_ALL); |
2458 |
|
|
2459 |
|
#ifdef ESPEAK |
2460 |
|
#if ESPEAK_API_REVISION == 1 |
2461 |
|
appdata.espeak.sample_rate = |
2462 |
|
espeak_Initialize(AUDIO_OUTPUT_PLAYBACK, 512, NULL); |
2463 |
|
#else |
2464 |
|
appdata.espeak.sample_rate = |
2465 |
|
espeak_Initialize(AUDIO_OUTPUT_PLAYBACK, 512, NULL, 0); |
2466 |
|
#endif |
2467 |
|
if(appdata.espeak.sample_rate < 0) |
2468 |
|
printf("espeak: init error\n"); |
2469 |
|
else |
2470 |
|
printf("espeak: running at %dhz\n", appdata.espeak.sample_rate); |
2471 |
|
|
2472 |
|
/* set language */ |
2473 |
|
espeak_VOICE voice_spec; |
2474 |
|
voice_spec.name = NULL; |
2475 |
|
voice_spec.languages = _("en"); |
2476 |
|
voice_spec.gender = 0; |
2477 |
|
voice_spec.age = 0; |
2478 |
|
voice_spec.variant = 0; |
2479 |
|
if(EE_OK != espeak_SetVoiceByProperties(&voice_spec)) { |
2480 |
|
printf("failed to set voice spec for %s\n", voice_spec.languages); |
2481 |
|
appdata.espeak.sample_rate = -1; |
2482 |
|
} |
2483 |
|
#endif |
2484 |
|
|
2485 |
#ifdef USE_MAEMO |
#ifdef USE_MAEMO |
2486 |
printf("Installing osso context for \"org.harbaum." APP "\"\n"); |
printf("Installing osso context for \"org.harbaum." APP "\"\n"); |
2487 |
appdata.osso_context = osso_initialize("org.harbaum."APP, |
appdata.osso_context = osso_initialize("org.harbaum."APP, |
2490 |
fprintf(stderr, "error initiating osso context\n"); |
fprintf(stderr, "error initiating osso context\n"); |
2491 |
} |
} |
2492 |
|
|
2493 |
|
#ifdef ENABLE_MAEMO_MAPPER |
2494 |
dbus_register(&appdata); |
dbus_register(&appdata); |
2495 |
#endif |
#endif |
2496 |
|
#endif |
2497 |
|
|
2498 |
icons_init(); |
icons_init(); |
2499 |
|
|
2517 |
/* Create a Window. */ |
/* Create a Window. */ |
2518 |
appdata.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
appdata.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
2519 |
/* Set a decent default size for the window. */ |
/* Set a decent default size for the window. */ |
2520 |
gtk_window_set_default_size(GTK_WINDOW(appdata.window), 500, 300); |
gtk_window_set_default_size(GTK_WINDOW(appdata.window), 640, 480); |
2521 |
#endif |
#endif |
2522 |
|
|
2523 |
#if MAEMO_VERSION_MAJOR == 5 |
#if MAEMO_VERSION_MAJOR == 5 |
2530 |
g_signal_connect(G_OBJECT(appdata.window), "key_press_event", |
g_signal_connect(G_OBJECT(appdata.window), "key_press_event", |
2531 |
G_CALLBACK(on_window_key_press), &appdata); |
G_CALLBACK(on_window_key_press), &appdata); |
2532 |
|
|
2533 |
|
/* prepare clipboard */ |
2534 |
|
appdata.clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); |
2535 |
|
gtk_clipboard_set_can_store(appdata.clipboard, NULL, 0); |
2536 |
|
|
2537 |
|
#ifndef USE_STACKABLE_WINDOW |
2538 |
appdata.vbox = gtk_vbox_new(FALSE, 2); |
appdata.vbox = gtk_vbox_new(FALSE, 2); |
2539 |
gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox); |
gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox); |
|
#ifndef USE_STACKABLE_WINDOW |
|
2540 |
menu_create(&appdata); |
menu_create(&appdata); |
2541 |
#else |
#else |
2542 |
hildon_window_set_app_menu(HILDON_WINDOW(appdata.window), |
hildon_window_set_app_menu(HILDON_WINDOW(appdata.window), |
2549 |
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); |
2550 |
|
|
2551 |
hildon_bread_crumb_trail_clear(HILDON_BREAD_CRUMB_TRAIL(appdata.bct)); |
hildon_bread_crumb_trail_clear(HILDON_BREAD_CRUMB_TRAIL(appdata.bct)); |
2552 |
|
#else |
2553 |
|
#ifdef BCT |
2554 |
|
/* on non-hildon machines we use some custom made breadcrumbtrail */ |
2555 |
|
/* replacement */ |
2556 |
|
appdata.bct = bct_new(); |
2557 |
|
gtk_box_pack_start(GTK_BOX(appdata.vbox), appdata.bct, FALSE,FALSE,0); |
2558 |
|
#endif |
2559 |
|
#endif |
2560 |
|
|
2561 |
|
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
2562 |
crumb_add(&appdata, "GPX", CRUMB_GPXLIST, NULL); |
crumb_add(&appdata, "GPX", CRUMB_GPXLIST, NULL); |
2563 |
#endif |
#endif |
2564 |
|
|
2569 |
|
|
2570 |
appdata.gconf_client = gconf_client_get_default(); |
appdata.gconf_client = gconf_client_get_default(); |
2571 |
gconf_load_state(&appdata); |
gconf_load_state(&appdata); |
2572 |
gps_init(&appdata); |
|
2573 |
|
appdata.gps_state = gps_init(); |
2574 |
|
gps_change_state(&appdata); |
2575 |
|
|
2576 |
|
/* register the gps callback for the main screen (map has its own) */ |
2577 |
|
gps_register_callback(appdata.gps_state, |
2578 |
|
LATLON_CHANGED | TRACK_CHANGED | HERR_CHANGED | SATELLITE_CHANGED, |
2579 |
|
main_gps_cb, &appdata); |
2580 |
|
|
2581 |
appdata.cur_view = gpxlist_create_view_and_model(&appdata, NULL); |
appdata.cur_view = gpxlist_create_view_and_model(&appdata, NULL); |
2582 |
|
#ifndef USE_STACKABLE_WINDOW |
2583 |
gtk_box_pack_start_defaults(GTK_BOX(appdata.vbox), appdata.cur_view); |
gtk_box_pack_start_defaults(GTK_BOX(appdata.vbox), appdata.cur_view); |
2584 |
|
#else |
2585 |
|
gtk_container_add(GTK_CONTAINER(appdata.window), appdata.cur_view); |
2586 |
|
#endif |
2587 |
|
|
2588 |
gtk_widget_show_all(GTK_WIDGET(appdata.window)); |
gtk_widget_show_all(GTK_WIDGET(appdata.window)); |
2589 |
gtk_main(); |
gtk_main(); |