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); |
155 |
gtk_widget_show_all (GTK_WIDGET(dialog)); |
gtk_widget_show_all (GTK_WIDGET(dialog)); |
156 |
if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_FM_OK) { |
if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_FM_OK) { |
157 |
char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); |
char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); |
158 |
|
|
159 |
|
if(filename) { |
160 |
|
gpx_dialog_t *dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window)); |
161 |
|
|
162 |
gpx_dialog_t *dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window)); |
if(!whole_dir) |
163 |
|
gpx = gpx_parse(dialog, filename, appdata->username); |
164 |
if(!whole_dir) |
else { |
165 |
gpx = gpx_parse(dialog, filename); |
/* cur trailing '/' if present */ |
166 |
else { |
if(strlastchr(filename) == '/') |
167 |
/* cur trailing '/' if present */ |
filename[strlen(filename)] = 0; |
168 |
if(strlastchr(filename) == '/') |
|
169 |
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 = '/'; |
|
170 |
} |
} |
171 |
|
|
172 |
if(whole_dir) |
gpx_busy_dialog_destroy(dialog); |
173 |
appdata->path = strdup(filename); |
|
174 |
} |
/* save path if gpx was successfully loaded */ |
175 |
|
if(gpx) { |
176 |
|
char *r = strrchr(filename, '/'); |
177 |
|
|
178 |
|
/* there is a delimiter, use everything left of it as path */ |
179 |
|
if(r && !whole_dir) { |
180 |
|
*r = 0; |
181 |
|
if(appdata->path) free(appdata->path); |
182 |
|
appdata->path = strdup(filename); |
183 |
|
/* restore path ... just in case ... */ |
184 |
|
*r = '/'; |
185 |
|
} |
186 |
|
|
187 |
|
if(whole_dir) |
188 |
|
appdata->path = strdup(filename); |
189 |
|
} else |
190 |
|
errorf(_("Load error")); |
191 |
|
|
192 |
g_free (filename); |
g_free (filename); |
193 |
|
} else { |
194 |
|
#ifndef USE_MAEMO |
195 |
|
errorf(_("Error accessing the file.")); |
196 |
|
#else |
197 |
|
errorf(_("Error accessing the file. This may happen if the file " |
198 |
|
"resides on a remote file system. Please copy the file onto " |
199 |
|
"the device (e.g. onto the memory card) and try again.")); |
200 |
|
#endif |
201 |
|
} |
202 |
} |
} |
203 |
|
|
204 |
gtk_widget_destroy (dialog); |
gtk_widget_destroy (dialog); |
222 |
CACHELIST_NUM_COLS |
CACHELIST_NUM_COLS |
223 |
} ; |
} ; |
224 |
|
|
225 |
void cachelist_view_onRowActivated(GtkTreeView *treeview, |
void cachelist_goto_cache(appdata_t *appdata, cache_t *cache) { |
226 |
|
#if !defined(USE_BREAD_CRUMB_TRAIL) && !defined(BCT) |
227 |
|
cache_dialog(appdata, cache); |
228 |
|
#else |
229 |
|
crumb_add(appdata, cache->name, CRUMB_CACHE, cache); |
230 |
|
|
231 |
|
gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
232 |
|
appdata->cur_view = cache_view(appdata, cache); |
233 |
|
gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view); |
234 |
|
gtk_widget_show_all(appdata->vbox); |
235 |
|
#endif |
236 |
|
} |
237 |
|
|
238 |
|
static void cachelist_view_onRowActivated(GtkTreeView *treeview, |
239 |
GtkTreePath *path, |
GtkTreePath *path, |
240 |
GtkTreeViewColumn *col, |
GtkTreeViewColumn *col, |
241 |
gpointer userdata) { |
gpointer userdata) { |
243 |
GtkTreeIter iter; |
GtkTreeIter iter; |
244 |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
245 |
|
|
246 |
|
#ifdef USE_MAEMO |
247 |
|
/* check if a cache is already selected and ignore click if yes */ |
248 |
|
/* (was probably a double click) */ |
249 |
|
if(appdata->cur_cache) return; |
250 |
|
#endif |
251 |
|
|
252 |
if(gtk_tree_model_get_iter(model, &iter, path)) { |
if(gtk_tree_model_get_iter(model, &iter, path)) { |
253 |
cache_t *cache; |
cache_t *cache; |
254 |
gtk_tree_model_get(model, &iter, CACHELIST_COL_DATA, &cache, -1); |
gtk_tree_model_get(model, &iter, CACHELIST_COL_DATA, &cache, -1); |
255 |
#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 |
|
256 |
} |
} |
257 |
} |
} |
258 |
|
|
260 |
appdata_t *appdata; |
appdata_t *appdata; |
261 |
GtkTreePath *path; |
GtkTreePath *path; |
262 |
gboolean done; |
gboolean done; |
263 |
} cachelist_expose_t; |
} cachelist_context_t; |
264 |
|
|
265 |
static gboolean cachelist_expose(GtkWidget *widget, GdkEventExpose *event, |
static gboolean cachelist_expose(GtkWidget *widget, GdkEventExpose *event, |
266 |
gpointer user_data) { |
gpointer user_data) { |
267 |
cachelist_expose_t *ce = (cachelist_expose_t*)user_data; |
cachelist_context_t *ce = (cachelist_context_t*)user_data; |
268 |
|
|
269 |
if(event->type == GDK_EXPOSE) { |
if(event->type == GDK_EXPOSE) { |
270 |
if(ce->path && !ce->done) { |
if(ce->path && !ce->done) { |
279 |
} |
} |
280 |
|
|
281 |
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; |
|
282 |
|
|
283 |
printf("cachelist timer removed\n"); |
guint handler_id = |
284 |
g_assert(ce->appdata->cachelist_handler_id); |
(guint)g_object_get_data(G_OBJECT(user_data), "handler_id"); |
|
gtk_timeout_remove(ce->appdata->cachelist_handler_id); |
|
|
ce->appdata->cachelist_handler_id = 0; |
|
285 |
|
|
286 |
free(user_data); |
if(handler_id) { |
287 |
|
gtk_timeout_remove(handler_id); |
288 |
|
g_object_set_data(G_OBJECT(user_data), "handler_id", NULL); |
289 |
|
|
290 |
|
printf("cachelist timer removed\n"); |
291 |
|
} |
292 |
|
|
293 |
|
gpointer *ce = |
294 |
|
g_object_get_data(G_OBJECT(user_data), "ce"); |
295 |
|
g_assert(ce); |
296 |
|
|
297 |
|
free(ce); |
298 |
} |
} |
299 |
|
|
300 |
#define CACHELIST_UPDATE_TIMEOUT (30000) |
#define CACHELIST_UPDATE_TIMEOUT (30000) |
303 |
cache_t *sel_cache); |
cache_t *sel_cache); |
304 |
|
|
305 |
void cachelist_redraw(appdata_t *appdata) { |
void cachelist_redraw(appdata_t *appdata) { |
306 |
#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 |
|
307 |
|
|
308 |
if(!appdata->cur_view) { |
if(!appdata->cur_view) { |
309 |
printf("cachelist redraw: no active view\n"); |
printf("cachelist redraw: no active view\n"); |
320 |
} |
} |
321 |
|
|
322 |
if(redraw) { |
if(redraw) { |
|
GtkWidget *container = appdata->vbox; |
|
|
|
|
|
printf("redraw %d\n", redraw); |
|
|
|
|
323 |
#ifdef USE_STACKABLE_WINDOW |
#ifdef USE_STACKABLE_WINDOW |
324 |
HildonWindowStack *stack = hildon_window_stack_get_default(); |
HildonWindowStack *stack = hildon_window_stack_get_default(); |
325 |
container = hildon_window_stack_peek(stack); |
GtkWidget *container = hildon_window_stack_peek(stack); |
326 |
|
#else |
327 |
|
GtkWidget *container = appdata->vbox; |
328 |
#endif |
#endif |
329 |
|
|
330 |
gtk_container_remove(GTK_CONTAINER(container), appdata->cur_view); |
gtk_container_remove(GTK_CONTAINER(container), appdata->cur_view); |
340 |
} |
} |
341 |
|
|
342 |
#ifdef USE_STACKABLE_WINDOW |
#ifdef USE_STACKABLE_WINDOW |
343 |
if(container != appdata->vbox) |
gtk_container_add(GTK_CONTAINER(container), appdata->cur_view); |
344 |
gtk_container_add(GTK_CONTAINER(container), appdata->cur_view); |
#else |
345 |
else |
gtk_box_pack_start_defaults(GTK_BOX(container), appdata->cur_view); |
346 |
#endif |
#endif |
|
gtk_box_pack_start_defaults(GTK_BOX(container), appdata->cur_view); |
|
347 |
|
|
348 |
gtk_widget_show_all(container); |
gtk_widget_show_all(container); |
349 |
} |
} |
|
#endif |
|
350 |
} |
} |
351 |
|
|
352 |
|
|
353 |
static gboolean cachelist_update(gpointer data) { |
static gboolean cachelist_update(gpointer data) { |
354 |
|
appdata_t *appdata = |
355 |
|
(appdata_t*)g_object_get_data(G_OBJECT(data), "appdata"); |
356 |
|
g_assert(appdata); |
357 |
|
|
358 |
printf("cachelist timer fired!\n"); |
printf("cachelist timer fired!\n"); |
359 |
|
|
360 |
#ifdef USE_MAEMO |
/* check if the widget the timer fired for is the currently */ |
361 |
appdata_t *appdata = (appdata_t*)data; |
/* visible one (if a search result is being shown, a cachlist */ |
362 |
|
/* may also be present below it) */ |
363 |
|
if(appdata->cur_view != data) { |
364 |
|
printf("-> widget is not the one currently on top, don't redraw\n"); |
365 |
|
return TRUE; |
366 |
|
} |
367 |
|
|
368 |
if(appdata->cur_cache) |
if(appdata->cur_cache) |
369 |
return TRUE; |
return TRUE; |
370 |
|
|
371 |
|
#ifdef USE_MAEMO |
372 |
if(appdata->cachelist_disable_screensaver) |
if(appdata->cachelist_disable_screensaver) |
373 |
if (osso_display_blanking_pause(appdata->osso_context) != OSSO_OK) |
if (osso_display_blanking_pause(appdata->osso_context) != OSSO_OK) |
374 |
fprintf(stderr, "error with display blank\n"); |
fprintf(stderr, "error with display blank\n"); |
375 |
|
#endif |
376 |
|
|
377 |
if(appdata->cachelist_update) |
if(appdata->cachelist_update) |
378 |
cachelist_redraw(appdata); |
cachelist_redraw(appdata); |
379 |
#endif |
else |
380 |
|
printf("update disabled\n"); |
381 |
|
|
382 |
return TRUE; |
return TRUE; |
383 |
} |
} |
384 |
|
|
385 |
static void cachelist_timer_reset(appdata_t *appdata) { |
static void cachelist_timer_reset(GtkWidget *widget) { |
386 |
|
guint handler_id = |
387 |
|
(guint)g_object_get_data(G_OBJECT(widget), "handler_id"); |
388 |
|
g_assert(handler_id); |
389 |
|
|
390 |
|
appdata_t *appdata = |
391 |
|
(appdata_t*)g_object_get_data(G_OBJECT(widget), "appdata"); |
392 |
|
g_assert(appdata); |
393 |
|
|
394 |
printf("cachelist timer reset\n"); |
printf("cachelist timer reset\n"); |
395 |
g_assert(appdata->cachelist_handler_id); |
gtk_timeout_remove(handler_id); |
396 |
gtk_timeout_remove(appdata->cachelist_handler_id); |
g_object_set_data(G_OBJECT(widget), "handler_id", (gpointer) |
397 |
appdata->cachelist_handler_id = |
gtk_timeout_add(CACHELIST_UPDATE_TIMEOUT, cachelist_update, widget)); |
|
gtk_timeout_add(CACHELIST_UPDATE_TIMEOUT, cachelist_update, appdata); |
|
398 |
} |
} |
399 |
|
|
400 |
static gboolean cachelist_update_reset0(GtkWidget *widget, |
static gboolean cachelist_update_reset0(GtkWidget *widget, |
401 |
GdkEventButton *event, |
GdkEventButton *event, |
402 |
gpointer user_data) { |
gpointer user_data) { |
403 |
cachelist_timer_reset((appdata_t*)user_data); |
cachelist_timer_reset(GTK_WIDGET(user_data)); |
404 |
return FALSE; |
return FALSE; |
405 |
} |
} |
406 |
|
|
407 |
static void cachelist_update_reset1(GtkAdjustment *adj, |
static void cachelist_update_reset1(GtkAdjustment *adj, |
408 |
gpointer user_data) { |
gpointer user_data) { |
409 |
cachelist_timer_reset((appdata_t*)user_data); |
cachelist_timer_reset(GTK_WIDGET(user_data)); |
410 |
} |
} |
411 |
|
|
412 |
|
static gboolean on_cachelist_focus_in(GtkWidget *widget, GdkEventFocus *event, |
413 |
|
gpointer data) { |
414 |
|
|
415 |
|
|
416 |
|
/* we don't want a runnign timer yet */ |
417 |
|
if(!g_object_get_data(G_OBJECT(data), "handler_id")) { |
418 |
|
printf("focus received: restarting cachelist timer\n"); |
419 |
|
|
420 |
|
appdata_t *appdata = |
421 |
|
(appdata_t*)g_object_get_data(G_OBJECT(data), "appdata"); |
422 |
|
g_assert(appdata); |
423 |
|
|
424 |
|
g_object_set_data(G_OBJECT(data), "handler_id", (gpointer) |
425 |
|
gtk_timeout_add(CACHELIST_UPDATE_TIMEOUT, cachelist_update, data)); |
426 |
|
} |
427 |
|
|
428 |
|
return FALSE; |
429 |
|
} |
430 |
|
|
431 |
|
static gboolean on_cachelist_focus_out(GtkWidget *widget, GdkEventFocus *event, |
432 |
|
gpointer data) { |
433 |
|
|
434 |
|
guint handler_id = |
435 |
|
(guint)g_object_get_data(G_OBJECT(data), "handler_id"); |
436 |
|
g_assert(handler_id); |
437 |
|
|
438 |
|
gtk_timeout_remove(handler_id); |
439 |
|
g_object_set_data(G_OBJECT(data), "handler_id", NULL); |
440 |
|
|
441 |
|
printf("focus lost: cachelist timer removed\n"); |
442 |
|
|
443 |
|
return FALSE; |
444 |
|
} |
445 |
|
|
446 |
static GtkWidget *cachelist_create(appdata_t *appdata, gpx_t *gpx, |
static GtkWidget *cachelist_create(appdata_t *appdata, gpx_t *gpx, |
447 |
cache_t *sel_cache) { |
cache_t *sel_cache) { |
448 |
GtkCellRenderer *renderer; |
GtkCellRenderer *renderer; |
540 |
if(tint > 8) tint = 8; |
if(tint > 8) tint = 8; |
541 |
|
|
542 |
/* cache type includes "solved" flag in lowest bit */ |
/* cache type includes "solved" flag in lowest bit */ |
543 |
int type = (cache->type<<8) + |
int type = cache->type<<8; |
544 |
(cache->notes?4:0) + |
if(cache->notes) type |= 4; |
545 |
((cache->notes && cache->notes->override)?1:0) + |
if(cache->notes && cache->notes->override) type |= 1; |
546 |
((cache->notes && cache->notes->found)?2:0); |
if(cache->notes && cache->notes->found) type |= 2; |
547 |
|
if(cache->found) type |= 2; |
548 |
|
if(cache->mine) type |= 8; |
549 |
|
|
550 |
if((!(type & 2)) || !appdata->cachelist_hide_found) { |
if((!(type & 2)) || !appdata->cachelist_hide_found) { |
551 |
|
|
588 |
g_signal_connect(view, "row-activated", |
g_signal_connect(view, "row-activated", |
589 |
(GCallback)cachelist_view_onRowActivated, appdata); |
(GCallback)cachelist_view_onRowActivated, appdata); |
590 |
|
|
591 |
cachelist_expose_t *ce = malloc(sizeof(cachelist_expose_t)); |
cachelist_context_t *ce = g_new0(cachelist_context_t, 1); |
592 |
ce->appdata = appdata; |
ce->appdata = appdata; |
593 |
ce->path = path; |
ce->path = path; |
594 |
ce->done = FALSE; |
ce->done = FALSE; |
595 |
|
|
596 |
g_signal_connect(view, "expose-event", |
g_signal_connect(view, "expose-event", |
597 |
(GCallback)cachelist_expose, ce); |
(GCallback)cachelist_expose, ce); |
|
g_signal_connect(view, "destroy", |
|
|
(GCallback)cachelist_destroy, ce); |
|
598 |
|
|
599 |
/* put this inside a scrolled view */ |
/* put this inside a scrolled view */ |
600 |
#ifndef USE_PANNABLE_AREA |
#ifndef USE_PANNABLE_AREA |
601 |
GtkWidget *scrolled_window = gtk_scrolled_window_new (NULL, NULL); |
GtkWidget *container = gtk_scrolled_window_new (NULL, NULL); |
602 |
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), |
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(container), |
603 |
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); |
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); |
604 |
gtk_container_add(GTK_CONTAINER(scrolled_window), view); |
gtk_container_add(GTK_CONTAINER(container), view); |
605 |
#else |
#else |
606 |
GtkWidget *pannable_area = hildon_pannable_area_new(); |
GtkWidget *container = hildon_pannable_area_new(); |
607 |
|
gtk_container_add(GTK_CONTAINER(container), view); |
|
gtk_container_add(GTK_CONTAINER(pannable_area), view); |
|
608 |
#endif |
#endif |
609 |
|
|
610 |
/* add a timer for automatic update */ |
g_signal_connect(view, "destroy", |
611 |
g_assert(!appdata->cachelist_handler_id); |
(GCallback)cachelist_destroy, container); |
|
appdata->cachelist_handler_id = |
|
|
gtk_timeout_add(CACHELIST_UPDATE_TIMEOUT, cachelist_update, appdata); |
|
612 |
|
|
613 |
/* update timer is being reset if the user scrolls or selects */ |
/* update timer is being reset if the user scrolls or selects */ |
614 |
g_signal_connect(view, "button-press-event", |
g_signal_connect(view, "button-press-event", |
615 |
(GCallback)cachelist_update_reset0, appdata); |
(GCallback)cachelist_update_reset0, container); |
616 |
|
|
617 |
|
/* add a timer for automatic update */ |
618 |
|
g_object_set_data(G_OBJECT(container), "handler_id", (gpointer) |
619 |
|
gtk_timeout_add(CACHELIST_UPDATE_TIMEOUT, cachelist_update, container)); |
620 |
|
|
621 |
|
printf("cachelist timer created\n"); |
622 |
|
|
623 |
|
g_object_set_data(G_OBJECT(container), "appdata", (gpointer)appdata); |
624 |
|
|
625 |
|
g_object_set_data(G_OBJECT(container), "ce", (gpointer)ce); |
626 |
|
|
627 |
|
/* the timer is removed and re-enabled on every focus change event */ |
628 |
|
/* for the main top window */ |
629 |
|
// GtkWidget *root = gtk_widget_get_toplevel(GTK_WIDGET(button))) |
630 |
|
|
631 |
|
g_signal_connect(G_OBJECT(view), "focus-in-event", |
632 |
|
G_CALLBACK(on_cachelist_focus_in), container); |
633 |
|
|
634 |
|
g_signal_connect(G_OBJECT(view), "focus-out-event", |
635 |
|
G_CALLBACK(on_cachelist_focus_out), container); |
636 |
|
|
637 |
#ifndef USE_PANNABLE_AREA |
#ifndef USE_PANNABLE_AREA |
638 |
g_signal_connect(gtk_scrolled_window_get_vadjustment( |
g_signal_connect(gtk_scrolled_window_get_vadjustment( |
639 |
GTK_SCROLLED_WINDOW(scrolled_window)), |
GTK_SCROLLED_WINDOW(container)), |
640 |
"value-changed", |
"value-changed", |
641 |
(GCallback)cachelist_update_reset1, appdata); |
(GCallback)cachelist_update_reset1, container); |
|
|
|
|
return scrolled_window; |
|
642 |
#else |
#else |
643 |
g_signal_connect(hildon_pannable_area_get_vadjustment( |
g_signal_connect(hildon_pannable_area_get_vadjustment( |
644 |
HILDON_PANNABLE_AREA(pannable_area)), |
HILDON_PANNABLE_AREA(container)), |
645 |
"value-changed", |
"value-changed", |
646 |
(GCallback)cachelist_update_reset1, appdata); |
(GCallback)cachelist_update_reset1, container); |
|
|
|
647 |
|
|
|
return pannable_area; |
|
648 |
#endif |
#endif |
649 |
|
return container; |
650 |
} |
} |
651 |
|
|
652 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
673 |
static void search_result_free(gpx_t *result); |
static void search_result_free(gpx_t *result); |
674 |
|
|
675 |
void on_cachelist_destroy(GtkWidget *widget, appdata_t *appdata) { |
void on_cachelist_destroy(GtkWidget *widget, appdata_t *appdata) { |
676 |
|
printf("cachelist destroy\n"); |
677 |
|
|
678 |
|
HildonWindowStack *stack = hildon_window_stack_get_default(); |
679 |
|
appdata->window = HILDON_WINDOW(hildon_window_stack_peek(stack)); |
680 |
|
|
681 |
if(appdata->search_results) { |
if(appdata->search_results) { |
682 |
search_result_free(appdata->search_results); |
search_result_free(appdata->search_results); |
683 |
appdata->search_results = NULL; |
appdata->search_results = NULL; |
684 |
} |
} |
685 |
appdata->cur_gpx = NULL; |
appdata->cur_gpx = NULL; |
686 |
|
|
687 |
|
#ifdef ENABLE_OSM_GPS_MAP |
688 |
|
map_update(appdata); |
689 |
|
#endif |
690 |
|
|
691 |
/* restore cur_view */ |
/* restore cur_view */ |
692 |
appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view"); |
appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view"); |
693 |
} |
} |
694 |
|
|
695 |
void cachelist_dialog(appdata_t *appdata, gpx_t *gpx) { |
void cachelist_dialog(appdata_t *appdata, gpx_t *gpx) { |
696 |
GtkWidget *window = hildon_stackable_window_new(); |
GtkWidget *window = hildon_stackable_window_new(); |
697 |
|
appdata->window = HILDON_WINDOW(window); |
698 |
|
|
699 |
/* store last "cur_view" in window */ |
/* store last "cur_view" in window */ |
700 |
g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view); |
g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view); |
701 |
|
|
702 |
appdata->cur_gpx = gpx; |
appdata->cur_gpx = gpx; |
703 |
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); |
|
704 |
|
|
705 |
appdata->cur_view = cachelist_create(appdata, gpx, NULL); |
appdata->cur_view = cachelist_create(appdata, gpx, NULL); |
706 |
gtk_container_add(GTK_CONTAINER(window), appdata->cur_view); |
gtk_container_add(GTK_CONTAINER(window), appdata->cur_view); |
713 |
G_CALLBACK(on_cachelist_destroy), appdata); |
G_CALLBACK(on_cachelist_destroy), appdata); |
714 |
|
|
715 |
gtk_widget_show_all(window); |
gtk_widget_show_all(window); |
716 |
|
|
717 |
|
#ifdef ENABLE_OSM_GPS_MAP |
718 |
|
map_update(appdata); |
719 |
|
#endif |
720 |
} |
} |
721 |
#endif |
#endif |
722 |
#endif |
#endif |
749 |
return icon_get(ICON_FILE, 0); |
return icon_get(ICON_FILE, 0); |
750 |
} |
} |
751 |
|
|
752 |
static void gpxlist_set(GtkListStore *store, GtkTreeIter *iter, gpx_t *gpx) { |
void gpxlist_set(GtkListStore *store, GtkTreeIter *iter, gpx_t *gpx) { |
753 |
char date_str[32], cnum[32]; |
char date_str[32], cnum[32]; |
754 |
|
|
755 |
if(gpx->year && gpx->month && gpx->day) { |
if(gpx->year && gpx->month && gpx->day) { |
774 |
GPXLIST_COL_OPEN, !gpx->closed, |
GPXLIST_COL_OPEN, !gpx->closed, |
775 |
GPXLIST_COL_CACHES, gpx->closed?NULL:cnum, |
GPXLIST_COL_CACHES, gpx->closed?NULL:cnum, |
776 |
#ifdef USE_PANNABLE_AREA |
#ifdef USE_PANNABLE_AREA |
777 |
GPXLIST_COL_DELETE, icon_get(ICON_MISC, 7), |
GPXLIST_COL_DELETE, icon_get(ICON_MISC, 2), |
778 |
#endif |
#endif |
779 |
GPXLIST_COL_DATA, gpx, |
GPXLIST_COL_DATA, gpx, |
780 |
-1); |
-1); |
820 |
gconf_save_closed_name(appdata, gpx->filename, gpx->name); |
gconf_save_closed_name(appdata, gpx->filename, gpx->name); |
821 |
} |
} |
822 |
|
|
823 |
|
void gpxlist_goto_cachelist(appdata_t *appdata, gpx_t *gpx) { |
824 |
|
#if !defined(USE_BREAD_CRUMB_TRAIL) && !defined(BCT) |
825 |
|
#ifdef USE_STACKABLE_WINDOW |
826 |
|
if(!appdata->cur_gpx) |
827 |
|
#endif |
828 |
|
cachelist_dialog(appdata, gpx); |
829 |
|
#ifdef USE_STACKABLE_WINDOW |
830 |
|
else |
831 |
|
printf("selected gpx, but cachelist window already present\n"); |
832 |
|
#endif |
833 |
|
#else |
834 |
|
gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
835 |
|
appdata->cur_view = cachelist_create(appdata, gpx, NULL); |
836 |
|
gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view); |
837 |
|
gtk_widget_show_all(appdata->vbox); |
838 |
|
|
839 |
|
crumb_add(appdata, gpx->name, CRUMB_CACHELIST, gpx); |
840 |
|
#endif |
841 |
|
} |
842 |
|
|
843 |
static void gpxlist_view_onRowActivated(GtkTreeView *treeview, |
static void gpxlist_view_onRowActivated(GtkTreeView *treeview, |
844 |
GtkTreePath *path, |
GtkTreePath *path, |
845 |
GtkTreeViewColumn *col, |
GtkTreeViewColumn *col, |
848 |
GtkTreeIter iter; |
GtkTreeIter iter; |
849 |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
850 |
|
|
851 |
|
#ifdef USE_MAEMO |
852 |
|
/* check if a cache is already selected and ignore click if yes */ |
853 |
|
/* (was probably a double click) */ |
854 |
|
if(appdata->cur_gpx) return; |
855 |
|
#endif |
856 |
|
|
857 |
if (gtk_tree_model_get_iter(model, &iter, path)) { |
if (gtk_tree_model_get_iter(model, &iter, path)) { |
858 |
gpx_t *gpx; |
gpx_t *gpx; |
859 |
gtk_tree_model_get(model, &iter, GPXLIST_COL_DATA, &gpx, -1); |
gtk_tree_model_get(model, &iter, GPXLIST_COL_DATA, &gpx, -1); |
866 |
if(col_name && !strcmp(col_name, "Del")) { |
if(col_name && !strcmp(col_name, "Del")) { |
867 |
printf("clicked delete\n"); |
printf("clicked delete\n"); |
868 |
|
|
869 |
|
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
870 |
/* ask user what he wants */ |
/* ask user what he wants */ |
871 |
GtkWidget *dialog = gtk_message_dialog_new( |
GtkWidget *dialog = gtk_message_dialog_new( |
872 |
GTK_WINDOW(appdata->window), |
GTK_WINDOW(appdata->window), |
873 |
GTK_DIALOG_DESTROY_WITH_PARENT, |
GTK_DIALOG_DESTROY_WITH_PARENT, |
874 |
GTK_MESSAGE_QUESTION, GTK_BUTTONS_CANCEL, |
GTK_MESSAGE_QUESTION, |
875 |
|
GTK_BUTTONS_CANCEL, |
876 |
_("Do you want to close this entry only or do " |
_("Do you want to close this entry only or do " |
877 |
"you want to remove it completely from the list?")); |
"you want to remove it completely from the list?")); |
878 |
|
|
881 |
_("Close"), 2, |
_("Close"), 2, |
882 |
NULL); |
NULL); |
883 |
|
|
884 |
|
gtk_window_set_title(GTK_WINDOW(dialog), _("Close or remove entry?")); |
885 |
|
#else |
886 |
|
|
887 |
|
GtkWidget *dialog = |
888 |
|
gtk_dialog_new_with_buttons(_("Close or remove entry?"), |
889 |
|
GTK_WINDOW(appdata->window), |
890 |
|
GTK_DIALOG_DESTROY_WITH_PARENT, |
891 |
|
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, |
892 |
|
_("Remove"), 1, |
893 |
|
_("Close"), 2, |
894 |
|
NULL); |
895 |
|
|
896 |
|
GtkWidget *content_area = |
897 |
|
gtk_dialog_get_content_area (GTK_DIALOG (dialog)); |
898 |
|
|
899 |
|
GtkWidget *hbox = gtk_hbox_new(FALSE, 0); |
900 |
|
|
901 |
|
GtkWidget *label = gtk_label_new( |
902 |
|
_("Do you want to close this entry only or do " |
903 |
|
"you want to remove it completely from the list?")); |
904 |
|
|
905 |
|
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
906 |
|
gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_WORD); |
907 |
|
|
908 |
|
gtk_box_pack_start_defaults(GTK_BOX(hbox), label); |
909 |
|
gtk_container_add (GTK_CONTAINER (content_area), hbox); |
910 |
|
|
911 |
|
gtk_widget_show_all (dialog); |
912 |
|
#endif |
913 |
|
|
914 |
if(gpx->closed) |
if(gpx->closed) |
915 |
gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), 2, FALSE); |
gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), 2, FALSE); |
916 |
|
|
|
gtk_window_set_title(GTK_WINDOW(dialog), _("Remove entry?")); |
|
|
|
|
917 |
/* set the active flag again if the user answered "no" */ |
/* set the active flag again if the user answered "no" */ |
918 |
switch(gtk_dialog_run(GTK_DIALOG(dialog))) { |
switch(gtk_dialog_run(GTK_DIALOG(dialog))) { |
919 |
|
|
943 |
gpx_t *new = NULL; |
gpx_t *new = NULL; |
944 |
|
|
945 |
if(g_file_test(gpx->filename, G_FILE_TEST_IS_DIR)) |
if(g_file_test(gpx->filename, G_FILE_TEST_IS_DIR)) |
946 |
new = gpx_parse_dir(dialog, gpx->filename); |
new = gpx_parse_dir(dialog, gpx->filename, appdata->username); |
947 |
else |
else |
948 |
new = gpx_parse(dialog, gpx->filename); |
new = gpx_parse(dialog, gpx->filename, appdata->username); |
949 |
|
|
950 |
if(new) { |
if(new) { |
951 |
gpx_t **prev = &(appdata->gpx); |
gpx_t **prev = &(appdata->gpx); |
981 |
|
|
982 |
gpx_busy_dialog_destroy(dialog); |
gpx_busy_dialog_destroy(dialog); |
983 |
} |
} |
984 |
#ifndef USE_BREAD_CRUMB_TRAIL |
|
985 |
#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 |
|
986 |
} |
} |
987 |
} |
} |
988 |
} |
} |
989 |
|
|
990 |
|
/* search gpx file in gpx list */ |
991 |
|
gboolean gpxlist_find(appdata_t *appdata, GtkTreeIter *iter, gpx_t *gpx) { |
992 |
|
GtkTreeModel *model = |
993 |
|
gtk_tree_view_get_model(GTK_TREE_VIEW(appdata->gpxview)); |
994 |
|
|
995 |
|
gboolean found = |
996 |
|
gtk_tree_model_get_iter_first(model, iter); |
997 |
|
|
998 |
|
while(found) { |
999 |
|
gpx_t *this_gpx; |
1000 |
|
gtk_tree_model_get(model, iter, GPXLIST_COL_DATA, &this_gpx, -1); |
1001 |
|
|
1002 |
|
if(gpx == this_gpx) |
1003 |
|
return TRUE; |
1004 |
|
|
1005 |
|
found = gtk_tree_model_iter_next(model, iter); |
1006 |
|
} |
1007 |
|
|
1008 |
|
return FALSE; |
1009 |
|
} |
1010 |
|
|
1011 |
|
|
1012 |
#ifndef USE_PANNABLE_AREA |
#ifndef USE_PANNABLE_AREA |
1013 |
static gboolean |
static gboolean |
1014 |
view_selection_func(GtkTreeSelection *selection, GtkTreeModel *model, |
view_selection_func(GtkTreeSelection *selection, GtkTreeModel *model, |
1047 |
|
|
1048 |
appdata->gpxview = gtk_tree_view_new (); |
appdata->gpxview = gtk_tree_view_new (); |
1049 |
|
|
1050 |
|
printf("building gpx list, items = %d\n", appdata->gpxlist_items); |
1051 |
|
|
1052 |
GtkTreeSelection *selection = |
GtkTreeSelection *selection = |
1053 |
gtk_tree_view_get_selection(GTK_TREE_VIEW(appdata->gpxview)); |
gtk_tree_view_get_selection(GTK_TREE_VIEW(appdata->gpxview)); |
1054 |
#ifndef USE_PANNABLE_AREA |
#ifndef USE_PANNABLE_AREA |
1061 |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview), |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview), |
1062 |
-1, "Icon", renderer, |
-1, "Icon", renderer, |
1063 |
"pixbuf", GPXLIST_COL_ICON, |
"pixbuf", GPXLIST_COL_ICON, |
1064 |
// "sensitive", GPXLIST_COL_OPEN, |
#ifdef USE_PANNABLE_AREA |
1065 |
|
/* at least one entry needs to be sensitive. */ |
1066 |
|
/* This is the delete icon if the PANNABLE_AREA is used */ |
1067 |
|
"sensitive", GPXLIST_COL_OPEN, |
1068 |
|
#endif |
1069 |
NULL); |
NULL); |
1070 |
|
|
1071 |
/* --- "FileName" column --- */ |
/* --- "FileName" column --- */ |
1121 |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview), |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview), |
1122 |
-1, "Del", renderer, |
-1, "Del", renderer, |
1123 |
"pixbuf", GPXLIST_COL_DELETE, |
"pixbuf", GPXLIST_COL_DELETE, |
1124 |
"sensitive", GPXLIST_COL_OPEN, |
// "sensitive", GPXLIST_COL_OPEN, |
1125 |
NULL); |
NULL); |
1126 |
#endif |
#endif |
1127 |
|
|
1141 |
GtkTreeIter iter; |
GtkTreeIter iter; |
1142 |
gtk_list_store_append(appdata->gpxstore, &iter); |
gtk_list_store_append(appdata->gpxstore, &iter); |
1143 |
gpxlist_set(appdata->gpxstore, &iter, gpx); |
gpxlist_set(appdata->gpxstore, &iter, gpx); |
1144 |
|
|
1145 |
if(gpx == sel_gpx) { |
if(gpx == sel_gpx) { |
1146 |
sel_iter = iter; |
sel_iter = iter; |
1147 |
sel_iter_valid = TRUE; |
sel_iter_valid = TRUE; |
1185 |
} |
} |
1186 |
|
|
1187 |
/* add last entry in gpx list to visual representation */ |
/* add last entry in gpx list to visual representation */ |
1188 |
static void gpxlist_add(appdata_t *appdata, gpx_t *new) { |
void gpxlist_add(appdata_t *appdata, gpx_t *new) { |
1189 |
GtkTreeIter iter; |
GtkTreeIter iter; |
1190 |
|
|
1191 |
gtk_list_store_append(appdata->gpxstore, &iter); |
gtk_list_store_append(appdata->gpxstore, &iter); |
1195 |
gpx_t **gpx = &appdata->gpx; |
gpx_t **gpx = &appdata->gpx; |
1196 |
while(*gpx) gpx = &((*gpx)->next); |
while(*gpx) gpx = &((*gpx)->next); |
1197 |
*gpx = new; |
*gpx = new; |
1198 |
|
|
1199 |
|
/* select new iter */ |
1200 |
|
GtkTreeSelection *selection = |
1201 |
|
gtk_tree_view_get_selection(GTK_TREE_VIEW(appdata->gpxview)); |
1202 |
|
gtk_tree_selection_select_iter(selection, &iter); |
1203 |
|
GtkTreePath *path = |
1204 |
|
gtk_tree_model_get_path(GTK_TREE_MODEL(appdata->gpxstore), &iter); |
1205 |
|
gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(appdata->gpxview), |
1206 |
|
path, NULL, TRUE, 0.0, 0.0); |
1207 |
|
gtk_tree_path_free(path); |
1208 |
} |
} |
1209 |
|
|
1210 |
/******************** end of gpxlist ********************/ |
/******************** end of gpxlist ********************/ |
1213 |
|
|
1214 |
static void |
static void |
1215 |
cb_menu_about(GtkWidget *window, gpointer data) { |
cb_menu_about(GtkWidget *window, gpointer data) { |
1216 |
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)); |
|
1217 |
} |
} |
1218 |
|
|
1219 |
#if defined(USE_MAEMO) && defined(HILDON_HELP) |
#if defined(USE_MAEMO) && defined(HILDON_HELP) |
1385 |
else if(cache->long_description && (what & SEARCH_DESC) && |
else if(cache->long_description && (what & SEARCH_DESC) && |
1386 |
strcasestr(cache->long_description, phrase)) |
strcasestr(cache->long_description, phrase)) |
1387 |
hit = 1; |
hit = 1; |
1388 |
else if(cache->owner && (what & SEARCH_OWNER) && |
else if(cache->owner && cache->owner->name && (what & SEARCH_OWNER) && |
1389 |
strcasestr(cache->owner, phrase)) |
strcasestr(cache->owner->name, phrase)) |
1390 |
hit = 1; |
hit = 1; |
1391 |
|
|
1392 |
if(hit) { |
if(hit) { |
1415 |
GtkWidget *in_id, *in_name, *in_desc, *in_owner, *in_finds; |
GtkWidget *in_id, *in_name, *in_desc, *in_owner, *in_finds; |
1416 |
} search_context_t; |
} search_context_t; |
1417 |
|
|
1418 |
|
|
1419 |
static void callback_finds_toggled(GtkWidget *widget, gpointer data ) { |
static void callback_finds_toggled(GtkWidget *widget, gpointer data ) { |
1420 |
search_context_t *context = (search_context_t*)data; |
search_context_t *context = (search_context_t*)data; |
1421 |
|
|
1422 |
gboolean in_finds = gtk_toggle_button_get_active( |
gboolean in_finds = check_button_get_active(context->in_finds); |
|
GTK_TOGGLE_BUTTON(context->in_finds)); |
|
1423 |
|
|
1424 |
gtk_widget_set_sensitive(context->entry, !in_finds); |
gtk_widget_set_sensitive(context->entry, !in_finds); |
1425 |
gtk_widget_set_sensitive(context->in_id, !in_finds); |
gtk_widget_set_sensitive(context->in_id, !in_finds); |
1449 |
GtkWidget *table = gtk_table_new(2, 2, TRUE); |
GtkWidget *table = gtk_table_new(2, 2, TRUE); |
1450 |
gtk_table_set_col_spacing(GTK_TABLE(table), 0, 8); |
gtk_table_set_col_spacing(GTK_TABLE(table), 0, 8); |
1451 |
|
|
1452 |
context.in_id = gtk_check_button_new_with_label(_("Waypoint IDs")); |
context.in_id = check_button_new_with_label(_("Waypoint IDs")); |
1453 |
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); |
|
1454 |
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); |
1455 |
|
|
1456 |
context.in_name = gtk_check_button_new_with_label(_("Names")); |
context.in_name = check_button_new_with_label(_("Names")); |
1457 |
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); |
|
1458 |
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); |
1459 |
|
|
1460 |
context.in_desc = gtk_check_button_new_with_label(_("Descriptions")); |
context.in_desc = check_button_new_with_label(_("Descriptions")); |
1461 |
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); |
|
1462 |
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); |
1463 |
|
|
1464 |
context.in_owner = gtk_check_button_new_with_label(_("Owner")); |
context.in_owner = check_button_new_with_label(_("Owner")); |
1465 |
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); |
|
1466 |
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); |
1467 |
|
|
1468 |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table); |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table); |
1471 |
|
|
1472 |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), |
1473 |
gtk_label_new(_("Search for:"))); |
gtk_label_new(_("Search for:"))); |
1474 |
|
context.entry = entry_new(); |
1475 |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), |
1476 |
context.entry = gtk_entry_new()); |
context.entry); |
1477 |
|
|
1478 |
if(appdata->search_str) |
if(appdata->search_str) |
1479 |
gtk_entry_set_text(GTK_ENTRY(context.entry), appdata->search_str); |
gtk_entry_set_text(GTK_ENTRY(context.entry), appdata->search_str); |
1480 |
|
|
1485 |
|
|
1486 |
GtkWidget *hbox = gtk_hbox_new(FALSE, 5); |
GtkWidget *hbox = gtk_hbox_new(FALSE, 5); |
1487 |
|
|
1488 |
context.in_finds = gtk_check_button_new_with_label(_("Search finds for")); |
context.in_finds = check_button_new_with_label(_("Search finds for")); |
1489 |
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); |
|
1490 |
gtk_box_pack_start_defaults(GTK_BOX(hbox), context.in_finds); |
gtk_box_pack_start_defaults(GTK_BOX(hbox), context.in_finds); |
1491 |
g_signal_connect(G_OBJECT(context.in_finds), "toggled", |
g_signal_connect(G_OBJECT(context.in_finds), "toggled", |
1492 |
G_CALLBACK(callback_finds_toggled), &context); |
G_CALLBACK(callback_finds_toggled), &context); |
1493 |
|
|
1494 |
#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 |
|
1495 |
gtk_box_pack_start_defaults(GTK_BOX(hbox), context.spinner); |
gtk_box_pack_start_defaults(GTK_BOX(hbox), context.spinner); |
1496 |
|
|
1497 |
gtk_box_pack_start_defaults(GTK_BOX(hbox), gtk_label_new(_("days"))); |
gtk_box_pack_start_defaults(GTK_BOX(hbox), gtk_label_new(_("days"))); |
1498 |
|
|
1499 |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox); |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox); |
1511 |
if(strlen(p) > 0) |
if(strlen(p) > 0) |
1512 |
appdata->search_str = strdup(p); |
appdata->search_str = strdup(p); |
1513 |
|
|
1514 |
#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 |
|
1515 |
|
|
1516 |
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_finds))) |
if(check_button_get_active(context.in_finds)) |
1517 |
appdata->search |= SEARCH_FINDS; |
appdata->search |= SEARCH_FINDS; |
1518 |
else |
else |
1519 |
appdata->search &= ~SEARCH_FINDS; |
appdata->search &= ~SEARCH_FINDS; |
1520 |
|
|
1521 |
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_id))) |
if(check_button_get_active(context.in_id)) |
1522 |
appdata->search |= SEARCH_ID; |
appdata->search |= SEARCH_ID; |
1523 |
else |
else |
1524 |
appdata->search &= ~SEARCH_ID; |
appdata->search &= ~SEARCH_ID; |
1525 |
|
|
1526 |
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_name))) |
if(check_button_get_active(context.in_name)) |
1527 |
appdata->search |= SEARCH_NAME; |
appdata->search |= SEARCH_NAME; |
1528 |
else |
else |
1529 |
appdata->search &= ~SEARCH_NAME; |
appdata->search &= ~SEARCH_NAME; |
1530 |
|
|
1531 |
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_desc))) |
if(check_button_get_active(context.in_desc)) |
1532 |
appdata->search |= SEARCH_DESC; |
appdata->search |= SEARCH_DESC; |
1533 |
else |
else |
1534 |
appdata->search &= ~SEARCH_DESC; |
appdata->search &= ~SEARCH_DESC; |
1535 |
|
|
1536 |
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_owner))) |
if(check_button_get_active(context.in_owner)) |
1537 |
appdata->search |= SEARCH_OWNER; |
appdata->search |= SEARCH_OWNER; |
1538 |
else |
else |
1539 |
appdata->search &= ~SEARCH_OWNER; |
appdata->search &= ~SEARCH_OWNER; |
1546 |
|
|
1547 |
printf("Search for %s (flags = %x)...\n", p, appdata->search); |
printf("Search for %s (flags = %x)...\n", p, appdata->search); |
1548 |
|
|
1549 |
#ifndef USE_BREAD_CRUMB_TRAIL |
#if !defined(USE_BREAD_CRUMB_TRAIL) && !defined(BCT) |
1550 |
gpx_t *found = |
|
1551 |
search_do(appdata, appdata->gpx, p, appdata->search, FALSE); |
if(appdata->cur_gpx) |
1552 |
|
appdata->search_results = |
1553 |
|
search_do(appdata, appdata->cur_gpx, p, appdata->search, TRUE); |
1554 |
|
else |
1555 |
|
appdata->search_results = |
1556 |
|
search_do(appdata, appdata->gpx, p, appdata->search, FALSE); |
1557 |
|
|
1558 |
/* do search result dialog here ... */ |
/* do search result dialog here ... */ |
1559 |
cachelist_dialog(appdata, found); |
cachelist_dialog(appdata, appdata->search_results); |
1560 |
|
|
1561 |
#ifndef USE_STACKABLE_WINDOW |
#ifndef USE_STACKABLE_WINDOW |
1562 |
search_result_free(found); |
search_result_free(appdata->search_results); |
1563 |
#else |
appdata->search_results = NULL; |
|
appdata->search_results = found; |
|
1564 |
#endif |
#endif |
1565 |
#else |
#else |
1566 |
gpx_t *found = NULL; |
gpx_t *found = NULL; |
1647 |
notes_log_export(appdata); |
notes_log_export(appdata); |
1648 |
} |
} |
1649 |
|
|
1650 |
#ifdef USE_MAEMO |
#ifdef ENABLE_MAEMO_MAPPER |
1651 |
static void |
static void |
1652 |
cb_menu_export_mmpoi(GtkWidget *widget, gpointer data) { |
cb_menu_export_mmpoi(GtkWidget *widget, gpointer data) { |
1653 |
appdata_t *appdata = (appdata_t*)data; |
appdata_t *appdata = (appdata_t*)data; |
1683 |
precise_position((appdata_t *)data); |
precise_position((appdata_t *)data); |
1684 |
} |
} |
1685 |
|
|
1686 |
|
static void |
1687 |
|
cb_menu_geotoad(GtkWidget *window, gpointer data) { |
1688 |
|
geotoad((appdata_t *)data); |
1689 |
|
} |
1690 |
|
|
1691 |
#ifdef USE_STACKABLE_WINDOW |
#ifdef USE_STACKABLE_WINDOW |
1692 |
typedef struct { |
typedef struct { |
1693 |
char *label, *desc; |
char *label, *desc; |
1771 |
} |
} |
1772 |
|
|
1773 |
static const menu_entry_t submenu_export_entries[] = { |
static const menu_entry_t submenu_export_entries[] = { |
1774 |
|
#ifdef ENABLE_MAEMO_MAPPER |
1775 |
{ "Export to Maemo Mapper" , "Save a Maemo Mapper POI file", |
{ "Export to Maemo Mapper" , "Save a Maemo Mapper POI file", |
1776 |
G_CALLBACK(cb_menu_export_mmpoi) }, |
G_CALLBACK(cb_menu_export_mmpoi) }, |
1777 |
|
#endif |
1778 |
{ "Export Field Notes", "Save a Garmin Field Notes file", |
{ "Export Field Notes", "Save a Garmin Field Notes file", |
1779 |
G_CALLBACK(cb_menu_export_log) }, |
G_CALLBACK(cb_menu_export_log) }, |
1780 |
{ "Export Garmin GPX", "Save modified waypoints in GPX file", |
{ "Export Garmin GPX", "Save modified waypoints in GPX file", |
1796 |
} |
} |
1797 |
|
|
1798 |
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 |
|
1799 |
{ "Geomath", "Geocoordinate calculation", |
{ "Geomath", "Geocoordinate calculation", |
1800 |
G_CALLBACK(cb_menu_geomath) }, |
G_CALLBACK(cb_menu_geomath) }, |
1801 |
{ "Geotext", "Text analysis", |
{ "Geotext", "Text analysis", |
1802 |
G_CALLBACK(cb_menu_geotext) }, |
G_CALLBACK(cb_menu_geotext) }, |
1803 |
{ "Precise Position", "Calculate a precise GPS position", |
{ "Precise Position", "Calculate a precise GPS position", |
1804 |
G_CALLBACK(cb_menu_precpos) }, |
G_CALLBACK(cb_menu_precpos) }, |
1805 |
|
{ "GeoToad", "Use GeoToad online downloader", |
1806 |
|
G_CALLBACK(cb_menu_geotoad) }, |
1807 |
{ NULL, NULL, NULL } |
{ NULL, NULL, NULL } |
1808 |
}; |
}; |
1809 |
|
|
1845 |
g_signal_connect_after(button, "clicked", |
g_signal_connect_after(button, "clicked", |
1846 |
G_CALLBACK(cb_menu_adddir), appdata); |
G_CALLBACK(cb_menu_adddir), appdata); |
1847 |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
|
} |
|
1848 |
|
|
|
if(mode == MENU_GPXLIST) { |
|
1849 |
button = gtk_button_new_with_label(_("Export")); |
button = gtk_button_new_with_label(_("Export")); |
1850 |
g_signal_connect_after(button, "clicked", |
g_signal_connect_after(button, "clicked", |
1851 |
G_CALLBACK(on_export_clicked), appdata); |
G_CALLBACK(on_export_clicked), appdata); |
1852 |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1853 |
|
} |
1854 |
|
|
1855 |
|
/* if search results exist, don't allow another search */ |
1856 |
|
if(!appdata->search_results && |
1857 |
|
((mode == MENU_GPXLIST) || (mode == MENU_CACHELIST))) { |
1858 |
button = gtk_button_new_with_label(_("Search")); |
button = gtk_button_new_with_label(_("Search")); |
1859 |
g_signal_connect_after(button, "clicked", |
g_signal_connect_after(button, "clicked", |
1860 |
G_CALLBACK(cb_menu_search), appdata); |
G_CALLBACK(cb_menu_search), appdata); |
1866 |
G_CALLBACK(on_tools_clicked), appdata); |
G_CALLBACK(on_tools_clicked), appdata); |
1867 |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1868 |
|
|
1869 |
|
#ifdef ENABLE_OSM_GPS_MAP |
1870 |
|
button = gtk_button_new_with_label(_("Map")); |
1871 |
|
g_signal_connect_after(button, "clicked", |
1872 |
|
G_CALLBACK(cb_menu_map), appdata); |
1873 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1874 |
|
#endif |
1875 |
|
|
1876 |
#ifdef HILDON_HELP |
#ifdef HILDON_HELP |
1877 |
button = gtk_button_new_with_label(_("Help")); |
button = gtk_button_new_with_label(_("Help")); |
1878 |
g_signal_connect_after(button, "clicked", |
g_signal_connect_after(button, "clicked", |
1890 |
GtkWidget *menu, *item; |
GtkWidget *menu, *item; |
1891 |
menu = gtk_menu_new(); |
menu = gtk_menu_new(); |
1892 |
|
|
1893 |
#ifdef USE_BREAD_CRUMB_TRAIL |
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
1894 |
appdata->menu_import = |
appdata->menu_import = |
1895 |
#endif |
#endif |
1896 |
item = gtk_menu_item_new_with_label(_("Import")); |
item = gtk_menu_item_new_with_label(_("Import")); |
1920 |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_remove), appdata); |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_remove), appdata); |
1921 |
#endif |
#endif |
1922 |
|
|
1923 |
#ifdef USE_BREAD_CRUMB_TRAIL |
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
1924 |
appdata->menu_export = |
appdata->menu_export = |
1925 |
#endif |
#endif |
1926 |
item = gtk_menu_item_new_with_label(_("Export")); |
item = gtk_menu_item_new_with_label(_("Export")); |
1928 |
submenu = gtk_menu_new(); |
submenu = gtk_menu_new(); |
1929 |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
1930 |
|
|
1931 |
#ifdef USE_MAEMO |
#ifdef ENABLE_MAEMO_MAPPER |
1932 |
item = gtk_menu_item_new_with_label( _("Maemo Mapper POI") ); |
item = gtk_menu_item_new_with_label( _("Maemo Mapper POI") ); |
1933 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1934 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
1945 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
1946 |
GTK_SIGNAL_FUNC(cb_menu_export_garmin), appdata); |
GTK_SIGNAL_FUNC(cb_menu_export_garmin), appdata); |
1947 |
|
|
1948 |
#ifdef USE_BREAD_CRUMB_TRAIL |
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
1949 |
appdata->menu_search = |
appdata->menu_search = |
1950 |
#endif |
#endif |
1951 |
item = gtk_menu_item_new_with_label( _("Search") ); |
item = gtk_menu_item_new_with_label( _("Search") ); |
1954 |
|
|
1955 |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
1956 |
|
|
|
#ifndef NO_COPY_N_PASTE |
|
1957 |
/* ----------- copy'n paste submenu ----------------- */ |
/* ----------- copy'n paste submenu ----------------- */ |
1958 |
appdata->clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); |
#ifndef NO_COPY_N_PASTE |
|
gtk_clipboard_set_can_store(appdata->clipboard, NULL, 0); |
|
|
|
|
1959 |
item = gtk_menu_item_new_with_label(_("Edit")); |
item = gtk_menu_item_new_with_label(_("Edit")); |
1960 |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
1961 |
submenu = gtk_menu_new(); |
submenu = gtk_menu_new(); |
1982 |
|
|
1983 |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
1984 |
|
|
|
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); |
|
|
|
|
1985 |
#ifdef ENABLE_OSM_GPS_MAP |
#ifdef ENABLE_OSM_GPS_MAP |
1986 |
item = gtk_menu_item_new_with_label( _("Map") ); |
item = gtk_menu_item_new_with_label( _("Map") ); |
1987 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
1988 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
1989 |
GTK_SIGNAL_FUNC(cb_menu_map), appdata); |
GTK_SIGNAL_FUNC(cb_menu_map), appdata); |
1990 |
#endif |
#endif |
1991 |
|
|
1992 |
|
item = gtk_menu_item_new_with_label(_("Tools")); |
1993 |
|
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
1994 |
|
submenu = gtk_menu_new(); |
1995 |
|
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
1996 |
|
|
1997 |
item = gtk_menu_item_new_with_label( _("Geomath") ); |
item = gtk_menu_item_new_with_label( _("Geomath") ); |
1998 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1999 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
2009 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
2010 |
GTK_SIGNAL_FUNC(cb_menu_precpos), appdata); |
GTK_SIGNAL_FUNC(cb_menu_precpos), appdata); |
2011 |
|
|
2012 |
|
item = gtk_menu_item_new_with_label( _("GeoToad") ); |
2013 |
|
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
2014 |
|
g_signal_connect(item, "activate", |
2015 |
|
GTK_SIGNAL_FUNC(cb_menu_geotoad), appdata); |
2016 |
|
|
2017 |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
2018 |
|
|
2019 |
#if defined(USE_MAEMO) && defined(HILDON_HELP) |
#if defined(USE_MAEMO) && defined(HILDON_HELP) |
2053 |
/********************* end of menu **********************/ |
/********************* end of menu **********************/ |
2054 |
|
|
2055 |
void cleanup(appdata_t *appdata) { |
void cleanup(appdata_t *appdata) { |
2056 |
|
gconf_save_state(appdata); |
2057 |
|
|
2058 |
gpx_free_all(appdata->gpx); |
gpx_free_all(appdata->gpx); |
2059 |
if(appdata->path) free(appdata->path); |
|
2060 |
if(appdata->image_path) free(appdata->image_path); |
#ifdef ESPEAK |
2061 |
if(appdata->search_str) free(appdata->search_str); |
espeak_Terminate(); |
2062 |
|
#endif |
2063 |
|
|
2064 |
#ifdef USE_STACKABLE_WINDOW |
#ifdef USE_STACKABLE_WINDOW |
2065 |
if(appdata->export_menu) submenu_cleanup(appdata->export_menu); |
if(appdata->export_menu) submenu_cleanup(appdata->export_menu); |
2070 |
icons_free(); |
icons_free(); |
2071 |
gps_release(appdata); |
gps_release(appdata); |
2072 |
|
|
|
#ifdef USE_MAEMO |
|
2073 |
if(appdata->search_results) { |
if(appdata->search_results) { |
2074 |
printf("freeing pending search\n"); |
printf("freeing pending search\n"); |
2075 |
search_result_free(appdata->search_results); |
search_result_free(appdata->search_results); |
2076 |
} |
} |
2077 |
|
|
2078 |
|
#ifdef USE_MAEMO |
2079 |
if(appdata->osso_context) |
if(appdata->osso_context) |
2080 |
osso_deinitialize(appdata->osso_context); |
osso_deinitialize(appdata->osso_context); |
2081 |
|
|
2097 |
static void on_window_destroy (GtkWidget *widget, gpointer data) { |
static void on_window_destroy (GtkWidget *widget, gpointer data) { |
2098 |
appdata_t *appdata = (appdata_t*)data; |
appdata_t *appdata = (appdata_t*)data; |
2099 |
|
|
|
gconf_save_state(appdata); |
|
2100 |
gtk_main_quit(); |
gtk_main_quit(); |
2101 |
appdata->window = NULL; |
appdata->window = NULL; |
2102 |
} |
} |
2156 |
return handled; |
return handled; |
2157 |
} |
} |
2158 |
|
|
2159 |
#ifdef USE_BREAD_CRUMB_TRAIL |
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
2160 |
typedef struct { |
typedef struct { |
2161 |
int level; |
int level; |
2162 |
appdata_t *appdata; |
appdata_t *appdata; |
2248 |
|
|
2249 |
gtk_widget_show_all(crumb->appdata->vbox); |
gtk_widget_show_all(crumb->appdata->vbox); |
2250 |
g_free(data); |
g_free(data); |
2251 |
|
|
2252 |
|
#ifdef ENABLE_OSM_GPS_MAP |
2253 |
|
map_update(crumb->appdata); |
2254 |
|
#endif |
2255 |
} |
} |
2256 |
|
|
2257 |
static void crumb_add(appdata_t *appdata, char *name, int level, |
static void crumb_add(appdata_t *appdata, char *name, int level, |
2258 |
gpointer user_data) { |
gpointer user_data) { |
2259 |
crumb_t *crumb = malloc(sizeof(crumb_t)); |
crumb_t *crumb = g_new0(crumb_t, 1); |
2260 |
crumb->level = level; |
crumb->level = level; |
2261 |
crumb->appdata = appdata; |
crumb->appdata = appdata; |
2262 |
crumb->data = user_data; |
crumb->data = user_data; |
2292 |
#endif |
#endif |
2293 |
} |
} |
2294 |
|
|
2295 |
|
#ifdef USE_BREAD_CRUMB_TRAIL |
2296 |
hildon_bread_crumb_trail_push_text(HILDON_BREAD_CRUMB_TRAIL(appdata->bct), |
hildon_bread_crumb_trail_push_text(HILDON_BREAD_CRUMB_TRAIL(appdata->bct), |
2297 |
name, crumb, (GDestroyNotify)crumb_back); |
name, crumb, (GDestroyNotify)crumb_back); |
2298 |
|
#else |
2299 |
|
bct_push_text(appdata->bct, name, crumb, (GDestroyNotify)crumb_back); |
2300 |
|
#endif |
2301 |
|
|
2302 |
|
#ifdef ENABLE_OSM_GPS_MAP |
2303 |
|
map_update(appdata); |
2304 |
|
#endif |
2305 |
} |
} |
2306 |
#endif // USE_BREAD_CRUMB_TRAIL |
#endif // USE_BREAD_CRUMB_TRAIL |
2307 |
|
|
2313 |
return; |
return; |
2314 |
} |
} |
2315 |
|
|
|
#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 |
|
2316 |
/* 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 */ |
2317 |
/* need to be redrawn */ |
/* need to be redrawn */ |
2318 |
if(appdata->cur_cache) { |
if(appdata->cur_cache) { |
2336 |
} |
} |
2337 |
|
|
2338 |
if(redraw) { |
if(redraw) { |
|
GtkWidget *container = appdata->vbox; |
|
2339 |
|
|
2340 |
#ifdef USE_STACKABLE_WINDOW |
#ifdef USE_STACKABLE_WINDOW |
2341 |
HildonWindowStack *stack = hildon_window_stack_get_default(); |
HildonWindowStack *stack = hildon_window_stack_get_default(); |
2342 |
container = hildon_window_stack_peek(stack); |
GtkWidget *container = hildon_window_stack_peek(stack); |
2343 |
|
#else |
2344 |
|
GtkWidget *container = appdata->vbox; |
2345 |
#endif |
#endif |
2346 |
|
|
2347 |
gtk_container_remove(GTK_CONTAINER(container), appdata->cur_view); |
gtk_container_remove(GTK_CONTAINER(container), appdata->cur_view); |
2360 |
} |
} |
2361 |
|
|
2362 |
#ifdef USE_STACKABLE_WINDOW |
#ifdef USE_STACKABLE_WINDOW |
|
if(container != appdata->vbox) |
|
2363 |
gtk_container_add(GTK_CONTAINER(container), appdata->cur_view); |
gtk_container_add(GTK_CONTAINER(container), appdata->cur_view); |
2364 |
else |
#else |
|
#endif |
|
2365 |
gtk_box_pack_start_defaults(GTK_BOX(container), appdata->cur_view); |
gtk_box_pack_start_defaults(GTK_BOX(container), appdata->cur_view); |
2366 |
|
#endif |
2367 |
|
|
2368 |
gtk_widget_show_all(container); |
gtk_widget_show_all(container); |
2369 |
} |
} |
|
#endif // USE_MAEMO |
|
2370 |
} |
} |
2371 |
|
|
2372 |
int main(int argc, char *argv[]) { |
int main(int argc, char *argv[]) { |
2387 |
|
|
2388 |
gtk_init (&argc, &argv); |
gtk_init (&argc, &argv); |
2389 |
|
|
2390 |
|
misc_init(); |
2391 |
|
|
2392 |
|
curl_global_init(CURL_GLOBAL_ALL); |
2393 |
|
|
2394 |
|
#ifdef ESPEAK |
2395 |
|
#if ESPEAK_API_REVISION == 1 |
2396 |
|
appdata.espeak.sample_rate = |
2397 |
|
espeak_Initialize(AUDIO_OUTPUT_PLAYBACK, 512, NULL); |
2398 |
|
#else |
2399 |
|
appdata.espeak.sample_rate = |
2400 |
|
espeak_Initialize(AUDIO_OUTPUT_PLAYBACK, 512, NULL, 0); |
2401 |
|
#endif |
2402 |
|
if(appdata.espeak.sample_rate < 0) |
2403 |
|
printf("espeak: init error\n"); |
2404 |
|
else |
2405 |
|
printf("espeak: running at %dhz\n", appdata.espeak.sample_rate); |
2406 |
|
|
2407 |
|
/* set language */ |
2408 |
|
espeak_VOICE voice_spec; |
2409 |
|
voice_spec.name = NULL; |
2410 |
|
voice_spec.languages = _("en"); |
2411 |
|
voice_spec.gender = 0; |
2412 |
|
voice_spec.age = 0; |
2413 |
|
voice_spec.variant = 0; |
2414 |
|
if(EE_OK != espeak_SetVoiceByProperties(&voice_spec)) { |
2415 |
|
printf("failed to set voice spec for %s\n", voice_spec.languages); |
2416 |
|
appdata.espeak.sample_rate = -1; |
2417 |
|
} |
2418 |
|
#endif |
2419 |
|
|
2420 |
#ifdef USE_MAEMO |
#ifdef USE_MAEMO |
2421 |
printf("Installing osso context for \"org.harbaum." APP "\"\n"); |
printf("Installing osso context for \"org.harbaum." APP "\"\n"); |
2422 |
appdata.osso_context = osso_initialize("org.harbaum."APP, |
appdata.osso_context = osso_initialize("org.harbaum."APP, |
2425 |
fprintf(stderr, "error initiating osso context\n"); |
fprintf(stderr, "error initiating osso context\n"); |
2426 |
} |
} |
2427 |
|
|
2428 |
|
#ifdef ENABLE_MAEMO_MAPPER |
2429 |
dbus_register(&appdata); |
dbus_register(&appdata); |
2430 |
#endif |
#endif |
2431 |
|
#endif |
2432 |
|
|
2433 |
icons_init(); |
icons_init(); |
2434 |
|
|
2452 |
/* Create a Window. */ |
/* Create a Window. */ |
2453 |
appdata.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
appdata.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
2454 |
/* Set a decent default size for the window. */ |
/* Set a decent default size for the window. */ |
2455 |
gtk_window_set_default_size(GTK_WINDOW(appdata.window), 500, 300); |
gtk_window_set_default_size(GTK_WINDOW(appdata.window), 640, 480); |
2456 |
#endif |
#endif |
2457 |
|
|
2458 |
#if MAEMO_VERSION_MAJOR == 5 |
#if MAEMO_VERSION_MAJOR == 5 |
2465 |
g_signal_connect(G_OBJECT(appdata.window), "key_press_event", |
g_signal_connect(G_OBJECT(appdata.window), "key_press_event", |
2466 |
G_CALLBACK(on_window_key_press), &appdata); |
G_CALLBACK(on_window_key_press), &appdata); |
2467 |
|
|
2468 |
|
/* prepare clipboard */ |
2469 |
|
appdata.clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); |
2470 |
|
gtk_clipboard_set_can_store(appdata.clipboard, NULL, 0); |
2471 |
|
|
2472 |
|
#ifndef USE_STACKABLE_WINDOW |
2473 |
appdata.vbox = gtk_vbox_new(FALSE, 2); |
appdata.vbox = gtk_vbox_new(FALSE, 2); |
2474 |
gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox); |
gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox); |
|
#ifndef USE_STACKABLE_WINDOW |
|
2475 |
menu_create(&appdata); |
menu_create(&appdata); |
2476 |
#else |
#else |
2477 |
hildon_window_set_app_menu(HILDON_WINDOW(appdata.window), |
hildon_window_set_app_menu(HILDON_WINDOW(appdata.window), |
2484 |
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); |
2485 |
|
|
2486 |
hildon_bread_crumb_trail_clear(HILDON_BREAD_CRUMB_TRAIL(appdata.bct)); |
hildon_bread_crumb_trail_clear(HILDON_BREAD_CRUMB_TRAIL(appdata.bct)); |
2487 |
|
#else |
2488 |
|
#ifdef BCT |
2489 |
|
/* on non-hildon machines we use some custom made breadcrumbtrail */ |
2490 |
|
/* replacement */ |
2491 |
|
appdata.bct = bct_new(); |
2492 |
|
gtk_box_pack_start(GTK_BOX(appdata.vbox), appdata.bct, FALSE,FALSE,0); |
2493 |
|
#endif |
2494 |
|
#endif |
2495 |
|
|
2496 |
|
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
2497 |
crumb_add(&appdata, "GPX", CRUMB_GPXLIST, NULL); |
crumb_add(&appdata, "GPX", CRUMB_GPXLIST, NULL); |
2498 |
#endif |
#endif |
2499 |
|
|
2504 |
|
|
2505 |
appdata.gconf_client = gconf_client_get_default(); |
appdata.gconf_client = gconf_client_get_default(); |
2506 |
gconf_load_state(&appdata); |
gconf_load_state(&appdata); |
2507 |
|
|
2508 |
gps_init(&appdata); |
gps_init(&appdata); |
2509 |
|
|
2510 |
appdata.cur_view = gpxlist_create_view_and_model(&appdata, NULL); |
appdata.cur_view = gpxlist_create_view_and_model(&appdata, NULL); |
2511 |
|
#ifndef USE_STACKABLE_WINDOW |
2512 |
gtk_box_pack_start_defaults(GTK_BOX(appdata.vbox), appdata.cur_view); |
gtk_box_pack_start_defaults(GTK_BOX(appdata.vbox), appdata.cur_view); |
2513 |
|
#else |
2514 |
|
gtk_container_add(GTK_CONTAINER(appdata.window), appdata.cur_view); |
2515 |
|
#endif |
2516 |
|
|
2517 |
gtk_widget_show_all(GTK_WIDGET(appdata.window)); |
gtk_widget_show_all(GTK_WIDGET(appdata.window)); |
2518 |
gtk_main(); |
gtk_main(); |