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 |
|
|
33 |
|
|
34 |
#ifdef USE_MAEMO |
#ifdef USE_MAEMO |
35 |
#include <hildon/hildon-banner.h> |
#include <hildon/hildon-banner.h> |
36 |
|
#if MAEMO_VERSION_MAJOR >= 5 |
37 |
|
#include <hildon/hildon-note.h> |
38 |
|
#include <hildon/hildon-entry.h> |
39 |
|
#endif |
40 |
#endif |
#endif |
41 |
|
|
42 |
#include <locale.h> |
#include <locale.h> |
43 |
|
|
44 |
extern char *strcasestr (__const char *__haystack, __const char *__needle); |
extern char *strcasestr (__const char *__haystack, __const char *__needle); |
45 |
|
|
46 |
#ifdef USE_BREAD_CRUMB_TRAIL |
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
47 |
static void crumb_add(appdata_t *appdata, char *name, int level, |
static void crumb_add(appdata_t *appdata, char *name, int level, |
48 |
gpointer user_data); |
gpointer user_data); |
49 |
|
|
100 |
} |
} |
101 |
} |
} |
102 |
|
|
103 |
|
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
104 |
GtkWidget *dialog = gtk_message_dialog_new( |
GtkWidget *dialog = gtk_message_dialog_new( |
105 |
GTK_WINDOW(NULL), |
GTK_WINDOW(NULL), |
106 |
GTK_DIALOG_DESTROY_WITH_PARENT, |
GTK_DIALOG_DESTROY_WITH_PARENT, |
107 |
GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, |
GTK_MESSAGE_ERROR, |
108 |
buf); |
GTK_BUTTONS_CLOSE, buf); |
109 |
|
|
110 |
gtk_window_set_title(GTK_WINDOW(dialog), _("ERROR")); |
gtk_window_set_title(GTK_WINDOW(dialog), _("ERROR")); |
111 |
|
#else |
112 |
|
GtkWidget *dialog = |
113 |
|
hildon_note_new_information(GTK_WINDOW(NULL), buf); |
114 |
|
#endif |
115 |
|
|
116 |
gtk_dialog_run(GTK_DIALOG(dialog)); |
gtk_dialog_run(GTK_DIALOG(dialog)); |
117 |
gtk_widget_destroy(dialog); |
gtk_widget_destroy(dialog); |
133 |
HELP_ID_IMPORT, appdata->osso_context); |
HELP_ID_IMPORT, appdata->osso_context); |
134 |
#endif |
#endif |
135 |
#else |
#else |
136 |
dialog = gtk_file_chooser_dialog_new (whole_dir?_("Open Directory"): |
dialog = gtk_file_chooser_dialog_new (whole_dir?_("Import directory"): |
137 |
_("Open File"), |
_("Import file"), |
138 |
GTK_WINDOW(appdata->window), |
GTK_WINDOW(appdata->window), |
139 |
whole_dir?GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER : |
whole_dir?GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER : |
140 |
GTK_FILE_CHOOSER_ACTION_OPEN, |
GTK_FILE_CHOOSER_ACTION_OPEN, |
151 |
gtk_widget_show_all (GTK_WIDGET(dialog)); |
gtk_widget_show_all (GTK_WIDGET(dialog)); |
152 |
if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_FM_OK) { |
if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_FM_OK) { |
153 |
char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); |
char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); |
154 |
|
|
155 |
|
if(filename) { |
156 |
|
gpx_dialog_t *dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window)); |
157 |
|
|
158 |
gpx_dialog_t *dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window)); |
if(!whole_dir) |
159 |
|
gpx = gpx_parse(dialog, filename, appdata->username); |
160 |
if(!whole_dir) |
else { |
161 |
gpx = gpx_parse(dialog, filename); |
/* cur trailing '/' if present */ |
162 |
else { |
if(strlastchr(filename) == '/') |
163 |
/* cur trailing '/' if present */ |
filename[strlen(filename)] = 0; |
164 |
if(strlastchr(filename) == '/') |
|
165 |
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 = '/'; |
|
166 |
} |
} |
167 |
|
|
168 |
if(whole_dir) |
gpx_busy_dialog_destroy(dialog); |
169 |
appdata->path = strdup(filename); |
|
170 |
} |
/* save path if gpx was successfully loaded */ |
171 |
|
if(gpx) { |
172 |
|
char *r = strrchr(filename, '/'); |
173 |
|
|
174 |
|
/* there is a delimiter, use everything left of it as path */ |
175 |
|
if(r && !whole_dir) { |
176 |
|
*r = 0; |
177 |
|
if(appdata->path) free(appdata->path); |
178 |
|
appdata->path = strdup(filename); |
179 |
|
/* restore path ... just in case ... */ |
180 |
|
*r = '/'; |
181 |
|
} |
182 |
|
|
183 |
|
if(whole_dir) |
184 |
|
appdata->path = strdup(filename); |
185 |
|
} else |
186 |
|
errorf(_("Load error")); |
187 |
|
|
188 |
g_free (filename); |
g_free (filename); |
189 |
|
} else { |
190 |
|
#ifndef USE_MAEMO |
191 |
|
errorf(_("Error accessing the file.")); |
192 |
|
#else |
193 |
|
errorf(_("Error accessing the file. This may happen if the file " |
194 |
|
"resides on a remote file system. Please copy the file onto " |
195 |
|
"the device (e.g. onto the memory card) and try again.")); |
196 |
|
#endif |
197 |
|
} |
198 |
} |
} |
199 |
|
|
200 |
gtk_widget_destroy (dialog); |
gtk_widget_destroy (dialog); |
218 |
CACHELIST_NUM_COLS |
CACHELIST_NUM_COLS |
219 |
} ; |
} ; |
220 |
|
|
221 |
void cachelist_view_onRowActivated(GtkTreeView *treeview, |
void cachelist_goto_cache(appdata_t *appdata, cache_t *cache) { |
222 |
|
#if !defined(USE_BREAD_CRUMB_TRAIL) && !defined(BCT) |
223 |
|
cache_dialog(appdata, cache); |
224 |
|
#else |
225 |
|
crumb_add(appdata, cache->name, CRUMB_CACHE, cache); |
226 |
|
|
227 |
|
gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
228 |
|
appdata->cur_view = cache_view(appdata, cache); |
229 |
|
gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view); |
230 |
|
gtk_widget_show_all(appdata->vbox); |
231 |
|
#endif |
232 |
|
} |
233 |
|
|
234 |
|
static void cachelist_view_onRowActivated(GtkTreeView *treeview, |
235 |
GtkTreePath *path, |
GtkTreePath *path, |
236 |
GtkTreeViewColumn *col, |
GtkTreeViewColumn *col, |
237 |
gpointer userdata) { |
gpointer userdata) { |
239 |
GtkTreeIter iter; |
GtkTreeIter iter; |
240 |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
241 |
|
|
242 |
|
#ifdef USE_MAEMO |
243 |
|
/* check if a cache is already selected and ignore click if yes */ |
244 |
|
/* (was probably a double click) */ |
245 |
|
if(appdata->cur_cache) return; |
246 |
|
#endif |
247 |
|
|
248 |
if(gtk_tree_model_get_iter(model, &iter, path)) { |
if(gtk_tree_model_get_iter(model, &iter, path)) { |
249 |
cache_t *cache; |
cache_t *cache; |
250 |
gtk_tree_model_get(model, &iter, CACHELIST_COL_DATA, &cache, -1); |
gtk_tree_model_get(model, &iter, CACHELIST_COL_DATA, &cache, -1); |
251 |
#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 |
|
252 |
} |
} |
253 |
} |
} |
254 |
|
|
256 |
appdata_t *appdata; |
appdata_t *appdata; |
257 |
GtkTreePath *path; |
GtkTreePath *path; |
258 |
gboolean done; |
gboolean done; |
259 |
} cachelist_expose_t; |
} cachelist_context_t; |
260 |
|
|
261 |
static gboolean cachelist_expose(GtkWidget *widget, GdkEventExpose *event, |
static gboolean cachelist_expose(GtkWidget *widget, GdkEventExpose *event, |
262 |
gpointer user_data) { |
gpointer user_data) { |
263 |
cachelist_expose_t *ce = (cachelist_expose_t*)user_data; |
cachelist_context_t *ce = (cachelist_context_t*)user_data; |
264 |
|
|
265 |
if(event->type == GDK_EXPOSE) { |
if(event->type == GDK_EXPOSE) { |
266 |
if(ce->path && !ce->done) { |
if(ce->path && !ce->done) { |
275 |
} |
} |
276 |
|
|
277 |
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; |
|
278 |
|
|
279 |
printf("cachelist timer removed\n"); |
guint handler_id = |
280 |
g_assert(ce->appdata->cachelist_handler_id); |
(guint)g_object_get_data(G_OBJECT(user_data), "handler_id"); |
281 |
gtk_timeout_remove(ce->appdata->cachelist_handler_id); |
|
282 |
ce->appdata->cachelist_handler_id = 0; |
if(handler_id) { |
283 |
|
gtk_timeout_remove(handler_id); |
284 |
|
g_object_set_data(G_OBJECT(user_data), "handler_id", NULL); |
285 |
|
|
286 |
free(user_data); |
printf("cachelist timer removed\n"); |
287 |
|
} |
288 |
|
|
289 |
|
gpointer *ce = |
290 |
|
g_object_get_data(G_OBJECT(user_data), "ce"); |
291 |
|
g_assert(ce); |
292 |
|
|
293 |
|
free(ce); |
294 |
} |
} |
295 |
|
|
296 |
#define CACHELIST_UPDATE_TIMEOUT (30000) |
#define CACHELIST_UPDATE_TIMEOUT (30000) |
299 |
cache_t *sel_cache); |
cache_t *sel_cache); |
300 |
|
|
301 |
void cachelist_redraw(appdata_t *appdata) { |
void cachelist_redraw(appdata_t *appdata) { |
302 |
#ifndef USE_MAEMO |
printf("redrawing cachelist\n"); |
303 |
// gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
|
304 |
// appdata->cur_view = gpxlist_create_view_and_model(appdata, NULL); |
if(!appdata->cur_view) { |
305 |
// gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view); |
printf("cachelist redraw: no active view\n"); |
306 |
// gtk_widget_show_all(appdata->vbox); |
return; |
307 |
#else |
} |
308 |
|
|
309 |
g_assert(!appdata->cur_cache); |
g_assert(!appdata->cur_cache); |
310 |
int redraw = 0; |
int redraw = 0; |
316 |
} |
} |
317 |
|
|
318 |
if(redraw) { |
if(redraw) { |
319 |
gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
#ifdef USE_STACKABLE_WINDOW |
320 |
|
HildonWindowStack *stack = hildon_window_stack_get_default(); |
321 |
|
GtkWidget *container = hildon_window_stack_peek(stack); |
322 |
|
#else |
323 |
|
GtkWidget *container = appdata->vbox; |
324 |
|
#endif |
325 |
|
|
326 |
|
gtk_container_remove(GTK_CONTAINER(container), appdata->cur_view); |
327 |
switch(redraw) { |
switch(redraw) { |
328 |
case 1: |
case 1: |
329 |
appdata->cur_view = cachelist_create(appdata, |
appdata->cur_view = cachelist_create(appdata, |
335 |
break; |
break; |
336 |
} |
} |
337 |
|
|
338 |
gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view); |
#ifdef USE_STACKABLE_WINDOW |
339 |
gtk_widget_show_all(appdata->vbox); |
gtk_container_add(GTK_CONTAINER(container), appdata->cur_view); |
340 |
} |
#else |
341 |
|
gtk_box_pack_start_defaults(GTK_BOX(container), appdata->cur_view); |
342 |
#endif |
#endif |
343 |
|
|
344 |
|
gtk_widget_show_all(container); |
345 |
|
} |
346 |
} |
} |
347 |
|
|
348 |
|
|
349 |
static gboolean cachelist_update(gpointer data) { |
static gboolean cachelist_update(gpointer data) { |
350 |
|
appdata_t *appdata = |
351 |
|
(appdata_t*)g_object_get_data(G_OBJECT(data), "appdata"); |
352 |
|
g_assert(appdata); |
353 |
|
|
354 |
printf("cachelist timer fired!\n"); |
printf("cachelist timer fired!\n"); |
355 |
|
|
356 |
#ifdef USE_MAEMO |
/* check if the widget the timer fired for is the currently */ |
357 |
appdata_t *appdata = (appdata_t*)data; |
/* visible one (if a search result is being shown, a cachlist */ |
358 |
|
/* may also be present below it) */ |
359 |
|
if(appdata->cur_view != data) { |
360 |
|
printf("-> widget is not the one currently on top, don't redraw\n"); |
361 |
|
return TRUE; |
362 |
|
} |
363 |
|
|
364 |
|
if(appdata->cur_cache) |
365 |
|
return TRUE; |
366 |
|
|
367 |
|
#ifdef USE_MAEMO |
368 |
if(appdata->cachelist_disable_screensaver) |
if(appdata->cachelist_disable_screensaver) |
369 |
if (osso_display_blanking_pause(appdata->osso_context) != OSSO_OK) |
if (osso_display_blanking_pause(appdata->osso_context) != OSSO_OK) |
370 |
fprintf(stderr, "error with display blank\n"); |
fprintf(stderr, "error with display blank\n"); |
371 |
|
#endif |
372 |
|
|
373 |
if(appdata->cachelist_update) |
if(appdata->cachelist_update) |
374 |
cachelist_redraw(appdata); |
cachelist_redraw(appdata); |
375 |
#endif |
else |
376 |
|
printf("update disabled\n"); |
377 |
|
|
378 |
return TRUE; |
return TRUE; |
379 |
} |
} |
380 |
|
|
381 |
static void cachelist_timer_reset(appdata_t *appdata) { |
static void cachelist_timer_reset(GtkWidget *widget) { |
382 |
g_assert(appdata->cachelist_handler_id); |
guint handler_id = |
383 |
gtk_timeout_remove(appdata->cachelist_handler_id); |
(guint)g_object_get_data(G_OBJECT(widget), "handler_id"); |
384 |
appdata->cachelist_handler_id = |
g_assert(handler_id); |
385 |
gtk_timeout_add(CACHELIST_UPDATE_TIMEOUT, cachelist_update, appdata); |
|
386 |
|
appdata_t *appdata = |
387 |
|
(appdata_t*)g_object_get_data(G_OBJECT(widget), "appdata"); |
388 |
|
g_assert(appdata); |
389 |
|
|
390 |
|
printf("cachelist timer reset\n"); |
391 |
|
gtk_timeout_remove(handler_id); |
392 |
|
g_object_set_data(G_OBJECT(widget), "handler_id", (gpointer) |
393 |
|
gtk_timeout_add(CACHELIST_UPDATE_TIMEOUT, cachelist_update, widget)); |
394 |
} |
} |
395 |
|
|
396 |
static gboolean cachelist_update_reset0(GtkWidget *widget, |
static gboolean cachelist_update_reset0(GtkWidget *widget, |
397 |
GdkEventButton *event, |
GdkEventButton *event, |
398 |
gpointer user_data) { |
gpointer user_data) { |
399 |
cachelist_timer_reset((appdata_t*)user_data); |
cachelist_timer_reset(GTK_WIDGET(user_data)); |
400 |
return FALSE; |
return FALSE; |
401 |
} |
} |
402 |
|
|
403 |
static void cachelist_update_reset1(GtkAdjustment *adj, |
static void cachelist_update_reset1(GtkAdjustment *adj, |
404 |
gpointer user_data) { |
gpointer user_data) { |
405 |
cachelist_timer_reset((appdata_t*)user_data); |
cachelist_timer_reset(GTK_WIDGET(user_data)); |
406 |
} |
} |
407 |
|
|
408 |
|
static gboolean on_cachelist_focus_in(GtkWidget *widget, GdkEventFocus *event, |
409 |
|
gpointer data) { |
410 |
|
|
411 |
|
|
412 |
|
/* we don't want a runnign timer yet */ |
413 |
|
if(!g_object_get_data(G_OBJECT(data), "handler_id")) { |
414 |
|
printf("focus received: restarting cachelist timer\n"); |
415 |
|
|
416 |
|
appdata_t *appdata = |
417 |
|
(appdata_t*)g_object_get_data(G_OBJECT(data), "appdata"); |
418 |
|
g_assert(appdata); |
419 |
|
|
420 |
|
g_object_set_data(G_OBJECT(data), "handler_id", (gpointer) |
421 |
|
gtk_timeout_add(CACHELIST_UPDATE_TIMEOUT, cachelist_update, data)); |
422 |
|
} |
423 |
|
|
424 |
|
return FALSE; |
425 |
|
} |
426 |
|
|
427 |
|
static gboolean on_cachelist_focus_out(GtkWidget *widget, GdkEventFocus *event, |
428 |
|
gpointer data) { |
429 |
|
|
430 |
|
guint handler_id = |
431 |
|
(guint)g_object_get_data(G_OBJECT(data), "handler_id"); |
432 |
|
g_assert(handler_id); |
433 |
|
|
434 |
|
gtk_timeout_remove(handler_id); |
435 |
|
g_object_set_data(G_OBJECT(data), "handler_id", NULL); |
436 |
|
|
437 |
|
printf("focus lost: cachelist timer removed\n"); |
438 |
|
|
439 |
|
return FALSE; |
440 |
|
} |
441 |
|
|
442 |
static GtkWidget *cachelist_create(appdata_t *appdata, gpx_t *gpx, |
static GtkWidget *cachelist_create(appdata_t *appdata, gpx_t *gpx, |
443 |
cache_t *sel_cache) { |
cache_t *sel_cache) { |
444 |
GtkCellRenderer *renderer; |
GtkCellRenderer *renderer; |
536 |
if(tint > 8) tint = 8; |
if(tint > 8) tint = 8; |
537 |
|
|
538 |
/* cache type includes "solved" flag in lowest bit */ |
/* cache type includes "solved" flag in lowest bit */ |
539 |
int type = (cache->type<<8) + |
int type = cache->type<<8; |
540 |
(cache->notes?4:0) + |
if(cache->notes) type |= 4; |
541 |
((cache->notes && cache->notes->override)?1:0) + |
if(cache->notes && cache->notes->override) type |= 1; |
542 |
((cache->notes && cache->notes->found)?2:0); |
if(cache->notes && cache->notes->found) type |= 2; |
543 |
|
if(cache->found) type |= 2; |
544 |
|
if(cache->mine) type |= 8; |
545 |
|
|
546 |
if((!(type & 2)) || !appdata->cachelist_hide_found) { |
if((!(type & 2)) || !appdata->cachelist_hide_found) { |
547 |
|
|
584 |
g_signal_connect(view, "row-activated", |
g_signal_connect(view, "row-activated", |
585 |
(GCallback)cachelist_view_onRowActivated, appdata); |
(GCallback)cachelist_view_onRowActivated, appdata); |
586 |
|
|
587 |
cachelist_expose_t *ce = malloc(sizeof(cachelist_expose_t)); |
cachelist_context_t *ce = g_new0(cachelist_context_t, 1); |
588 |
ce->appdata = appdata; |
ce->appdata = appdata; |
589 |
ce->path = path; |
ce->path = path; |
590 |
ce->done = FALSE; |
ce->done = FALSE; |
591 |
|
|
592 |
g_signal_connect(view, "expose-event", |
g_signal_connect(view, "expose-event", |
593 |
(GCallback)cachelist_expose, ce); |
(GCallback)cachelist_expose, ce); |
|
g_signal_connect(view, "destroy", |
|
|
(GCallback)cachelist_destroy, ce); |
|
594 |
|
|
595 |
/* put this inside a scrolled view */ |
/* put this inside a scrolled view */ |
596 |
#ifndef USE_PANNABLE_AREA |
#ifndef USE_PANNABLE_AREA |
597 |
GtkWidget *scrolled_window = gtk_scrolled_window_new (NULL, NULL); |
GtkWidget *container = gtk_scrolled_window_new (NULL, NULL); |
598 |
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), |
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(container), |
599 |
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); |
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); |
600 |
gtk_container_add(GTK_CONTAINER(scrolled_window), view); |
gtk_container_add(GTK_CONTAINER(container), view); |
601 |
#else |
#else |
602 |
GtkWidget *pannable_area = hildon_pannable_area_new(); |
GtkWidget *container = hildon_pannable_area_new(); |
603 |
|
gtk_container_add(GTK_CONTAINER(container), view); |
|
gtk_container_add(GTK_CONTAINER(pannable_area), view); |
|
604 |
#endif |
#endif |
605 |
|
|
606 |
/* add a timer for automatic update */ |
g_signal_connect(view, "destroy", |
607 |
g_assert(!appdata->cachelist_handler_id); |
(GCallback)cachelist_destroy, container); |
|
appdata->cachelist_handler_id = |
|
|
gtk_timeout_add(CACHELIST_UPDATE_TIMEOUT, cachelist_update, appdata); |
|
608 |
|
|
609 |
/* update timer is being reset if the user scrolls or selects */ |
/* update timer is being reset if the user scrolls or selects */ |
610 |
g_signal_connect(view, "button-press-event", |
g_signal_connect(view, "button-press-event", |
611 |
(GCallback)cachelist_update_reset0, appdata); |
(GCallback)cachelist_update_reset0, container); |
612 |
|
|
613 |
|
/* add a timer for automatic update */ |
614 |
|
g_object_set_data(G_OBJECT(container), "handler_id", (gpointer) |
615 |
|
gtk_timeout_add(CACHELIST_UPDATE_TIMEOUT, cachelist_update, container)); |
616 |
|
|
617 |
|
printf("cachelist timer created\n"); |
618 |
|
|
619 |
|
g_object_set_data(G_OBJECT(container), "appdata", (gpointer)appdata); |
620 |
|
|
621 |
|
g_object_set_data(G_OBJECT(container), "ce", (gpointer)ce); |
622 |
|
|
623 |
|
/* the timer is removed and re-enabled on every focus change event */ |
624 |
|
/* for the main top window */ |
625 |
|
// GtkWidget *root = gtk_widget_get_toplevel(GTK_WIDGET(button))) |
626 |
|
|
627 |
|
g_signal_connect(G_OBJECT(view), "focus-in-event", |
628 |
|
G_CALLBACK(on_cachelist_focus_in), container); |
629 |
|
|
630 |
|
g_signal_connect(G_OBJECT(view), "focus-out-event", |
631 |
|
G_CALLBACK(on_cachelist_focus_out), container); |
632 |
|
|
633 |
#ifndef USE_PANNABLE_AREA |
#ifndef USE_PANNABLE_AREA |
634 |
g_signal_connect(gtk_scrolled_window_get_vadjustment( |
g_signal_connect(gtk_scrolled_window_get_vadjustment( |
635 |
GTK_SCROLLED_WINDOW(scrolled_window)), |
GTK_SCROLLED_WINDOW(container)), |
636 |
"value-changed", |
"value-changed", |
637 |
(GCallback)cachelist_update_reset1, appdata); |
(GCallback)cachelist_update_reset1, container); |
|
|
|
|
return scrolled_window; |
|
638 |
#else |
#else |
639 |
g_signal_connect(hildon_pannable_area_get_vadjustment( |
g_signal_connect(hildon_pannable_area_get_vadjustment( |
640 |
HILDON_PANNABLE_AREA(pannable_area)), |
HILDON_PANNABLE_AREA(container)), |
641 |
"value-changed", |
"value-changed", |
642 |
(GCallback)cachelist_update_reset1, appdata); |
(GCallback)cachelist_update_reset1, container); |
|
|
|
643 |
|
|
|
return pannable_area; |
|
644 |
#endif |
#endif |
645 |
|
return container; |
646 |
} |
} |
647 |
|
|
648 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
666 |
} |
} |
667 |
#else |
#else |
668 |
#ifdef USE_STACKABLE_WINDOW |
#ifdef USE_STACKABLE_WINDOW |
669 |
|
static void search_result_free(gpx_t *result); |
670 |
|
|
671 |
|
void on_cachelist_destroy(GtkWidget *widget, appdata_t *appdata) { |
672 |
|
printf("cachelist destroy\n"); |
673 |
|
|
674 |
|
HildonWindowStack *stack = hildon_window_stack_get_default(); |
675 |
|
appdata->window = HILDON_WINDOW(hildon_window_stack_peek(stack)); |
676 |
|
|
677 |
|
if(appdata->search_results) { |
678 |
|
search_result_free(appdata->search_results); |
679 |
|
appdata->search_results = NULL; |
680 |
|
} |
681 |
|
appdata->cur_gpx = NULL; |
682 |
|
|
683 |
|
#ifdef ENABLE_OSM_GPS_MAP |
684 |
|
map_update(appdata); |
685 |
|
#endif |
686 |
|
|
687 |
|
/* restore cur_view */ |
688 |
|
appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view"); |
689 |
|
} |
690 |
|
|
691 |
void cachelist_dialog(appdata_t *appdata, gpx_t *gpx) { |
void cachelist_dialog(appdata_t *appdata, gpx_t *gpx) { |
692 |
GtkWidget *window = hildon_stackable_window_new(); |
GtkWidget *window = hildon_stackable_window_new(); |
693 |
|
appdata->window = HILDON_WINDOW(window); |
694 |
|
|
695 |
|
/* store last "cur_view" in window */ |
696 |
|
g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view); |
697 |
|
|
698 |
|
appdata->cur_gpx = gpx; |
699 |
gtk_window_set_title(GTK_WINDOW(window), gpx->name); |
gtk_window_set_title(GTK_WINDOW(window), gpx->name); |
700 |
|
|
701 |
gtk_container_add(GTK_CONTAINER(window), |
appdata->cur_view = cachelist_create(appdata, gpx, NULL); |
702 |
cachelist_create(appdata, gpx, NULL)); |
gtk_container_add(GTK_CONTAINER(window), appdata->cur_view); |
703 |
|
|
704 |
|
|
705 |
hildon_window_set_app_menu(HILDON_WINDOW(window), |
hildon_window_set_app_menu(HILDON_WINDOW(window), |
706 |
menu_create(appdata, MENU_CACHELIST)); |
menu_create(appdata, MENU_CACHELIST)); |
707 |
|
|
708 |
|
g_signal_connect(G_OBJECT(window), "destroy", |
709 |
|
G_CALLBACK(on_cachelist_destroy), appdata); |
710 |
|
|
711 |
gtk_widget_show_all(window); |
gtk_widget_show_all(window); |
712 |
|
|
713 |
|
#ifdef ENABLE_OSM_GPS_MAP |
714 |
|
map_update(appdata); |
715 |
|
#endif |
716 |
} |
} |
717 |
#endif |
#endif |
718 |
#endif |
#endif |
745 |
return icon_get(ICON_FILE, 0); |
return icon_get(ICON_FILE, 0); |
746 |
} |
} |
747 |
|
|
748 |
static void gpxlist_set(GtkListStore *store, GtkTreeIter *iter, gpx_t *gpx) { |
void gpxlist_set(GtkListStore *store, GtkTreeIter *iter, gpx_t *gpx) { |
749 |
char date_str[32], cnum[32]; |
char date_str[32], cnum[32]; |
750 |
|
|
751 |
if(gpx->year && gpx->month && gpx->day) { |
if(gpx->year && gpx->month && gpx->day) { |
770 |
GPXLIST_COL_OPEN, !gpx->closed, |
GPXLIST_COL_OPEN, !gpx->closed, |
771 |
GPXLIST_COL_CACHES, gpx->closed?NULL:cnum, |
GPXLIST_COL_CACHES, gpx->closed?NULL:cnum, |
772 |
#ifdef USE_PANNABLE_AREA |
#ifdef USE_PANNABLE_AREA |
773 |
GPXLIST_COL_DELETE, icon_get(ICON_MISC, 7), |
GPXLIST_COL_DELETE, icon_get(ICON_MISC, 2), |
774 |
#endif |
#endif |
775 |
GPXLIST_COL_DATA, gpx, |
GPXLIST_COL_DATA, gpx, |
776 |
-1); |
-1); |
816 |
gconf_save_closed_name(appdata, gpx->filename, gpx->name); |
gconf_save_closed_name(appdata, gpx->filename, gpx->name); |
817 |
} |
} |
818 |
|
|
819 |
|
void gpxlist_goto_cachelist(appdata_t *appdata, gpx_t *gpx) { |
820 |
|
#if !defined(USE_BREAD_CRUMB_TRAIL) && !defined(BCT) |
821 |
|
#ifdef USE_STACKABLE_WINDOW |
822 |
|
if(!appdata->cur_gpx) |
823 |
|
#endif |
824 |
|
cachelist_dialog(appdata, gpx); |
825 |
|
#ifdef USE_STACKABLE_WINDOW |
826 |
|
else |
827 |
|
printf("selected gpx, but cachelist window already present\n"); |
828 |
|
#endif |
829 |
|
#else |
830 |
|
gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
831 |
|
appdata->cur_view = cachelist_create(appdata, gpx, NULL); |
832 |
|
gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view); |
833 |
|
gtk_widget_show_all(appdata->vbox); |
834 |
|
|
835 |
|
crumb_add(appdata, gpx->name, CRUMB_CACHELIST, gpx); |
836 |
|
#endif |
837 |
|
} |
838 |
|
|
839 |
static void gpxlist_view_onRowActivated(GtkTreeView *treeview, |
static void gpxlist_view_onRowActivated(GtkTreeView *treeview, |
840 |
GtkTreePath *path, |
GtkTreePath *path, |
841 |
GtkTreeViewColumn *col, |
GtkTreeViewColumn *col, |
844 |
GtkTreeIter iter; |
GtkTreeIter iter; |
845 |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
846 |
|
|
847 |
|
#ifdef USE_MAEMO |
848 |
|
/* check if a cache is already selected and ignore click if yes */ |
849 |
|
/* (was probably a double click) */ |
850 |
|
if(appdata->cur_gpx) return; |
851 |
|
#endif |
852 |
|
|
853 |
if (gtk_tree_model_get_iter(model, &iter, path)) { |
if (gtk_tree_model_get_iter(model, &iter, path)) { |
854 |
gpx_t *gpx; |
gpx_t *gpx; |
855 |
gtk_tree_model_get(model, &iter, GPXLIST_COL_DATA, &gpx, -1); |
gtk_tree_model_get(model, &iter, GPXLIST_COL_DATA, &gpx, -1); |
862 |
if(col_name && !strcmp(col_name, "Del")) { |
if(col_name && !strcmp(col_name, "Del")) { |
863 |
printf("clicked delete\n"); |
printf("clicked delete\n"); |
864 |
|
|
865 |
|
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
866 |
/* ask user what he wants */ |
/* ask user what he wants */ |
867 |
GtkWidget *dialog = gtk_message_dialog_new( |
GtkWidget *dialog = gtk_message_dialog_new( |
868 |
GTK_WINDOW(appdata->window), |
GTK_WINDOW(appdata->window), |
869 |
GTK_DIALOG_DESTROY_WITH_PARENT, |
GTK_DIALOG_DESTROY_WITH_PARENT, |
870 |
GTK_MESSAGE_QUESTION, GTK_BUTTONS_CANCEL, |
GTK_MESSAGE_QUESTION, |
871 |
|
GTK_BUTTONS_CANCEL, |
872 |
_("Do you want to close this entry only or do " |
_("Do you want to close this entry only or do " |
873 |
"you want to remove it completely from the list?")); |
"you want to remove it completely from the list?")); |
874 |
|
|
877 |
_("Close"), 2, |
_("Close"), 2, |
878 |
NULL); |
NULL); |
879 |
|
|
880 |
|
gtk_window_set_title(GTK_WINDOW(dialog), _("Close or remove entry?")); |
881 |
|
#else |
882 |
|
|
883 |
|
GtkWidget *dialog = |
884 |
|
gtk_dialog_new_with_buttons(_("Close or remove entry?"), |
885 |
|
GTK_WINDOW(appdata->window), |
886 |
|
GTK_DIALOG_DESTROY_WITH_PARENT, |
887 |
|
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, |
888 |
|
_("Remove"), 1, |
889 |
|
_("Close"), 2, |
890 |
|
NULL); |
891 |
|
|
892 |
|
GtkWidget *content_area = |
893 |
|
gtk_dialog_get_content_area (GTK_DIALOG (dialog)); |
894 |
|
|
895 |
|
GtkWidget *hbox = gtk_hbox_new(FALSE, 0); |
896 |
|
|
897 |
|
GtkWidget *label = gtk_label_new( |
898 |
|
_("Do you want to close this entry only or do " |
899 |
|
"you want to remove it completely from the list?")); |
900 |
|
|
901 |
|
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
902 |
|
gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_WORD); |
903 |
|
|
904 |
|
gtk_box_pack_start_defaults(GTK_BOX(hbox), label); |
905 |
|
gtk_container_add (GTK_CONTAINER (content_area), hbox); |
906 |
|
|
907 |
|
gtk_widget_show_all (dialog); |
908 |
|
#endif |
909 |
|
|
910 |
if(gpx->closed) |
if(gpx->closed) |
911 |
gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), 2, FALSE); |
gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), 2, FALSE); |
912 |
|
|
|
gtk_window_set_title(GTK_WINDOW(dialog), _("Remove entry?")); |
|
|
|
|
913 |
/* set the active flag again if the user answered "no" */ |
/* set the active flag again if the user answered "no" */ |
914 |
switch(gtk_dialog_run(GTK_DIALOG(dialog))) { |
switch(gtk_dialog_run(GTK_DIALOG(dialog))) { |
915 |
|
|
939 |
gpx_t *new = NULL; |
gpx_t *new = NULL; |
940 |
|
|
941 |
if(g_file_test(gpx->filename, G_FILE_TEST_IS_DIR)) |
if(g_file_test(gpx->filename, G_FILE_TEST_IS_DIR)) |
942 |
new = gpx_parse_dir(dialog, gpx->filename); |
new = gpx_parse_dir(dialog, gpx->filename, appdata->username); |
943 |
else |
else |
944 |
new = gpx_parse(dialog, gpx->filename); |
new = gpx_parse(dialog, gpx->filename, appdata->username); |
945 |
|
|
946 |
if(new) { |
if(new) { |
947 |
gpx_t **prev = &(appdata->gpx); |
gpx_t **prev = &(appdata->gpx); |
977 |
|
|
978 |
gpx_busy_dialog_destroy(dialog); |
gpx_busy_dialog_destroy(dialog); |
979 |
} |
} |
980 |
#ifndef USE_BREAD_CRUMB_TRAIL |
|
981 |
cachelist_dialog(appdata, gpx); |
gpxlist_goto_cachelist(appdata, gpx); |
|
#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 |
|
982 |
} |
} |
983 |
} |
} |
984 |
} |
} |
985 |
|
|
986 |
|
/* search gpx file in gpx list */ |
987 |
|
gboolean gpxlist_find(appdata_t *appdata, GtkTreeIter *iter, gpx_t *gpx) { |
988 |
|
GtkTreeModel *model = |
989 |
|
gtk_tree_view_get_model(GTK_TREE_VIEW(appdata->gpxview)); |
990 |
|
|
991 |
|
gboolean found = |
992 |
|
gtk_tree_model_get_iter_first(model, iter); |
993 |
|
|
994 |
|
while(found) { |
995 |
|
gpx_t *this_gpx; |
996 |
|
gtk_tree_model_get(model, iter, GPXLIST_COL_DATA, &this_gpx, -1); |
997 |
|
|
998 |
|
if(gpx == this_gpx) |
999 |
|
return TRUE; |
1000 |
|
|
1001 |
|
found = gtk_tree_model_iter_next(model, iter); |
1002 |
|
} |
1003 |
|
|
1004 |
|
return FALSE; |
1005 |
|
} |
1006 |
|
|
1007 |
|
|
1008 |
#ifndef USE_PANNABLE_AREA |
#ifndef USE_PANNABLE_AREA |
1009 |
static gboolean |
static gboolean |
1010 |
view_selection_func(GtkTreeSelection *selection, GtkTreeModel *model, |
view_selection_func(GtkTreeSelection *selection, GtkTreeModel *model, |
1043 |
|
|
1044 |
appdata->gpxview = gtk_tree_view_new (); |
appdata->gpxview = gtk_tree_view_new (); |
1045 |
|
|
1046 |
|
printf("building gpx list, items = %d\n", appdata->gpxlist_items); |
1047 |
|
|
1048 |
GtkTreeSelection *selection = |
GtkTreeSelection *selection = |
1049 |
gtk_tree_view_get_selection(GTK_TREE_VIEW(appdata->gpxview)); |
gtk_tree_view_get_selection(GTK_TREE_VIEW(appdata->gpxview)); |
1050 |
#ifndef USE_PANNABLE_AREA |
#ifndef USE_PANNABLE_AREA |
1057 |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview), |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview), |
1058 |
-1, "Icon", renderer, |
-1, "Icon", renderer, |
1059 |
"pixbuf", GPXLIST_COL_ICON, |
"pixbuf", GPXLIST_COL_ICON, |
1060 |
// "sensitive", GPXLIST_COL_OPEN, |
#ifdef USE_PANNABLE_AREA |
1061 |
|
/* at least one entry needs to be sensitive. */ |
1062 |
|
/* This is the delete icon if the PANNABLE_AREA is used */ |
1063 |
|
"sensitive", GPXLIST_COL_OPEN, |
1064 |
|
#endif |
1065 |
NULL); |
NULL); |
1066 |
|
|
1067 |
/* --- "FileName" column --- */ |
/* --- "FileName" column --- */ |
1117 |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview), |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview), |
1118 |
-1, "Del", renderer, |
-1, "Del", renderer, |
1119 |
"pixbuf", GPXLIST_COL_DELETE, |
"pixbuf", GPXLIST_COL_DELETE, |
1120 |
"sensitive", GPXLIST_COL_OPEN, |
// "sensitive", GPXLIST_COL_OPEN, |
1121 |
NULL); |
NULL); |
1122 |
#endif |
#endif |
1123 |
|
|
1137 |
GtkTreeIter iter; |
GtkTreeIter iter; |
1138 |
gtk_list_store_append(appdata->gpxstore, &iter); |
gtk_list_store_append(appdata->gpxstore, &iter); |
1139 |
gpxlist_set(appdata->gpxstore, &iter, gpx); |
gpxlist_set(appdata->gpxstore, &iter, gpx); |
1140 |
|
|
1141 |
if(gpx == sel_gpx) { |
if(gpx == sel_gpx) { |
1142 |
sel_iter = iter; |
sel_iter = iter; |
1143 |
sel_iter_valid = TRUE; |
sel_iter_valid = TRUE; |
1181 |
} |
} |
1182 |
|
|
1183 |
/* add last entry in gpx list to visual representation */ |
/* add last entry in gpx list to visual representation */ |
1184 |
static void gpxlist_add(appdata_t *appdata, gpx_t *new) { |
void gpxlist_add(appdata_t *appdata, gpx_t *new) { |
1185 |
GtkTreeIter iter; |
GtkTreeIter iter; |
1186 |
|
|
1187 |
gtk_list_store_append(appdata->gpxstore, &iter); |
gtk_list_store_append(appdata->gpxstore, &iter); |
1191 |
gpx_t **gpx = &appdata->gpx; |
gpx_t **gpx = &appdata->gpx; |
1192 |
while(*gpx) gpx = &((*gpx)->next); |
while(*gpx) gpx = &((*gpx)->next); |
1193 |
*gpx = new; |
*gpx = new; |
1194 |
|
|
1195 |
|
/* select new iter */ |
1196 |
|
GtkTreeSelection *selection = |
1197 |
|
gtk_tree_view_get_selection(GTK_TREE_VIEW(appdata->gpxview)); |
1198 |
|
gtk_tree_selection_select_iter(selection, &iter); |
1199 |
|
GtkTreePath *path = |
1200 |
|
gtk_tree_model_get_path(GTK_TREE_MODEL(appdata->gpxstore), &iter); |
1201 |
|
gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(appdata->gpxview), |
1202 |
|
path, NULL, TRUE, 0.0, 0.0); |
1203 |
|
gtk_tree_path_free(path); |
1204 |
} |
} |
1205 |
|
|
1206 |
/******************** end of gpxlist ********************/ |
/******************** end of gpxlist ********************/ |
1209 |
|
|
1210 |
static void |
static void |
1211 |
cb_menu_about(GtkWidget *window, gpointer data) { |
cb_menu_about(GtkWidget *window, gpointer data) { |
1212 |
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); |
|
|
gtk_about_dialog_set_copyright(about, |
|
|
_("GPXView (c) 2008 by\n" |
|
|
"Till Harbaum <till@harbaum.org>\n" |
|
|
"Geocaching.com: Tantil")); |
|
|
|
|
|
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)); |
|
1213 |
} |
} |
1214 |
|
|
1215 |
#if defined(USE_MAEMO) && defined(HILDON_HELP) |
#if defined(USE_MAEMO) && defined(HILDON_HELP) |
1381 |
else if(cache->long_description && (what & SEARCH_DESC) && |
else if(cache->long_description && (what & SEARCH_DESC) && |
1382 |
strcasestr(cache->long_description, phrase)) |
strcasestr(cache->long_description, phrase)) |
1383 |
hit = 1; |
hit = 1; |
1384 |
else if(cache->owner && (what & SEARCH_OWNER) && |
else if(cache->owner && cache->owner->name && (what & SEARCH_OWNER) && |
1385 |
strcasestr(cache->owner, phrase)) |
strcasestr(cache->owner->name, phrase)) |
1386 |
hit = 1; |
hit = 1; |
1387 |
|
|
1388 |
if(hit) { |
if(hit) { |
1411 |
GtkWidget *in_id, *in_name, *in_desc, *in_owner, *in_finds; |
GtkWidget *in_id, *in_name, *in_desc, *in_owner, *in_finds; |
1412 |
} search_context_t; |
} search_context_t; |
1413 |
|
|
1414 |
|
|
1415 |
static void callback_finds_toggled(GtkWidget *widget, gpointer data ) { |
static void callback_finds_toggled(GtkWidget *widget, gpointer data ) { |
1416 |
search_context_t *context = (search_context_t*)data; |
search_context_t *context = (search_context_t*)data; |
1417 |
|
|
1418 |
gboolean in_finds = gtk_toggle_button_get_active( |
gboolean in_finds = check_button_get_active(context->in_finds); |
|
GTK_TOGGLE_BUTTON(context->in_finds)); |
|
1419 |
|
|
1420 |
gtk_widget_set_sensitive(context->entry, !in_finds); |
gtk_widget_set_sensitive(context->entry, !in_finds); |
1421 |
gtk_widget_set_sensitive(context->in_id, !in_finds); |
gtk_widget_set_sensitive(context->in_id, !in_finds); |
1445 |
GtkWidget *table = gtk_table_new(2, 2, TRUE); |
GtkWidget *table = gtk_table_new(2, 2, TRUE); |
1446 |
gtk_table_set_col_spacing(GTK_TABLE(table), 0, 8); |
gtk_table_set_col_spacing(GTK_TABLE(table), 0, 8); |
1447 |
|
|
1448 |
context.in_id = gtk_check_button_new_with_label(_("Waypoint IDs")); |
context.in_id = check_button_new_with_label(_("Waypoint IDs")); |
1449 |
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); |
|
1450 |
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); |
1451 |
|
|
1452 |
context.in_name = gtk_check_button_new_with_label(_("Names")); |
context.in_name = check_button_new_with_label(_("Names")); |
1453 |
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); |
|
1454 |
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); |
1455 |
|
|
1456 |
context.in_desc = gtk_check_button_new_with_label(_("Descriptions")); |
context.in_desc = check_button_new_with_label(_("Descriptions")); |
1457 |
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); |
|
1458 |
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); |
1459 |
|
|
1460 |
context.in_owner = gtk_check_button_new_with_label(_("Owner")); |
context.in_owner = check_button_new_with_label(_("Owner")); |
1461 |
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); |
|
1462 |
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); |
1463 |
|
|
1464 |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table); |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table); |
1467 |
|
|
1468 |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), |
1469 |
gtk_label_new(_("Search for:"))); |
gtk_label_new(_("Search for:"))); |
1470 |
|
context.entry = entry_new(); |
1471 |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), |
1472 |
context.entry = gtk_entry_new()); |
context.entry); |
1473 |
|
|
1474 |
if(appdata->search_str) |
if(appdata->search_str) |
1475 |
gtk_entry_set_text(GTK_ENTRY(context.entry), appdata->search_str); |
gtk_entry_set_text(GTK_ENTRY(context.entry), appdata->search_str); |
1476 |
|
|
1481 |
|
|
1482 |
GtkWidget *hbox = gtk_hbox_new(FALSE, 5); |
GtkWidget *hbox = gtk_hbox_new(FALSE, 5); |
1483 |
|
|
1484 |
context.in_finds = gtk_check_button_new_with_label(_("Search finds for")); |
context.in_finds = check_button_new_with_label(_("Search finds for")); |
1485 |
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); |
|
1486 |
gtk_box_pack_start_defaults(GTK_BOX(hbox), context.in_finds); |
gtk_box_pack_start_defaults(GTK_BOX(hbox), context.in_finds); |
1487 |
g_signal_connect(G_OBJECT(context.in_finds), "toggled", |
g_signal_connect(G_OBJECT(context.in_finds), "toggled", |
1488 |
G_CALLBACK(callback_finds_toggled), &context); |
G_CALLBACK(callback_finds_toggled), &context); |
1522 |
HILDON_NUMBER_EDITOR(context.spinner)); |
HILDON_NUMBER_EDITOR(context.spinner)); |
1523 |
#endif |
#endif |
1524 |
|
|
1525 |
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_finds))) |
if(check_button_get_active(context.in_finds)) |
1526 |
appdata->search |= SEARCH_FINDS; |
appdata->search |= SEARCH_FINDS; |
1527 |
else |
else |
1528 |
appdata->search &= ~SEARCH_FINDS; |
appdata->search &= ~SEARCH_FINDS; |
1529 |
|
|
1530 |
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_id))) |
if(check_button_get_active(context.in_id)) |
1531 |
appdata->search |= SEARCH_ID; |
appdata->search |= SEARCH_ID; |
1532 |
else |
else |
1533 |
appdata->search &= ~SEARCH_ID; |
appdata->search &= ~SEARCH_ID; |
1534 |
|
|
1535 |
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_name))) |
if(check_button_get_active(context.in_name)) |
1536 |
appdata->search |= SEARCH_NAME; |
appdata->search |= SEARCH_NAME; |
1537 |
else |
else |
1538 |
appdata->search &= ~SEARCH_NAME; |
appdata->search &= ~SEARCH_NAME; |
1539 |
|
|
1540 |
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_desc))) |
if(check_button_get_active(context.in_desc)) |
1541 |
appdata->search |= SEARCH_DESC; |
appdata->search |= SEARCH_DESC; |
1542 |
else |
else |
1543 |
appdata->search &= ~SEARCH_DESC; |
appdata->search &= ~SEARCH_DESC; |
1544 |
|
|
1545 |
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_owner))) |
if(check_button_get_active(context.in_owner)) |
1546 |
appdata->search |= SEARCH_OWNER; |
appdata->search |= SEARCH_OWNER; |
1547 |
else |
else |
1548 |
appdata->search &= ~SEARCH_OWNER; |
appdata->search &= ~SEARCH_OWNER; |
1552 |
/* don't search if we are asked to search for nothing */ |
/* don't search if we are asked to search for nothing */ |
1553 |
if(((appdata->search & (SEARCH_ID|SEARCH_NAME|SEARCH_DESC|SEARCH_OWNER)) && |
if(((appdata->search & (SEARCH_ID|SEARCH_NAME|SEARCH_DESC|SEARCH_OWNER)) && |
1554 |
strlen(p) > 0) || (appdata->search & SEARCH_FINDS)) { |
strlen(p) > 0) || (appdata->search & SEARCH_FINDS)) { |
|
gpx_t *found = NULL; |
|
1555 |
|
|
1556 |
printf("Search for %s (flags = %x)...\n", p, appdata->search); |
printf("Search for %s (flags = %x)...\n", p, appdata->search); |
1557 |
|
|
1558 |
#ifndef USE_BREAD_CRUMB_TRAIL |
#if !defined(USE_BREAD_CRUMB_TRAIL) && !defined(BCT) |
1559 |
found = search_do(appdata, appdata->gpx, p, appdata->search, FALSE); |
gpx_t *found = |
1560 |
|
search_do(appdata, appdata->gpx, p, appdata->search, FALSE); |
1561 |
|
|
1562 |
/* do search result dialog here ... */ |
/* do search result dialog here ... */ |
1563 |
cachelist_dialog(appdata, found); |
cachelist_dialog(appdata, found); |
1564 |
|
#ifndef USE_STACKABLE_WINDOW |
1565 |
search_result_free(found); |
search_result_free(found); |
1566 |
#else |
#else |
1567 |
|
appdata->search_results = found; |
1568 |
|
#endif |
1569 |
|
#else |
1570 |
|
gpx_t *found = NULL; |
1571 |
|
|
1572 |
if(appdata->cur_gpx) |
if(appdata->cur_gpx) |
1573 |
found = search_do(appdata, appdata->cur_gpx, p, appdata->search, TRUE); |
found = search_do(appdata, appdata->cur_gpx, p, appdata->search, TRUE); |
1574 |
else |
else |
1589 |
gtk_widget_destroy(dialog); |
gtk_widget_destroy(dialog); |
1590 |
} |
} |
1591 |
|
|
1592 |
void on_window_destroy (GtkWidget *widget, gpointer data); |
static void on_window_destroy (GtkWidget *widget, gpointer data); |
1593 |
|
|
1594 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
1595 |
static void |
static void |
1651 |
notes_log_export(appdata); |
notes_log_export(appdata); |
1652 |
} |
} |
1653 |
|
|
1654 |
#ifdef USE_MAEMO |
#ifdef ENABLE_MAEMO_MAPPER |
1655 |
static void |
static void |
1656 |
cb_menu_export_mmpoi(GtkWidget *widget, gpointer data) { |
cb_menu_export_mmpoi(GtkWidget *widget, gpointer data) { |
1657 |
appdata_t *appdata = (appdata_t*)data; |
appdata_t *appdata = (appdata_t*)data; |
1665 |
garmin_export(appdata); |
garmin_export(appdata); |
1666 |
} |
} |
1667 |
|
|
1668 |
|
#ifdef ENABLE_OSM_GPS_MAP |
1669 |
|
static void |
1670 |
|
cb_menu_map(GtkWidget *window, gpointer data) { |
1671 |
|
map((appdata_t *)data); |
1672 |
|
} |
1673 |
|
#endif |
1674 |
|
|
1675 |
static void |
static void |
1676 |
cb_menu_geomath(GtkWidget *window, gpointer data) { |
cb_menu_geomath(GtkWidget *window, gpointer data) { |
1677 |
geomath_dialog((appdata_t *)data); |
geomath_dialog((appdata_t *)data); |
1687 |
precise_position((appdata_t *)data); |
precise_position((appdata_t *)data); |
1688 |
} |
} |
1689 |
|
|
1690 |
|
static void |
1691 |
|
cb_menu_geotoad(GtkWidget *window, gpointer data) { |
1692 |
|
geotoad((appdata_t *)data); |
1693 |
|
} |
1694 |
|
|
1695 |
#ifdef USE_STACKABLE_WINDOW |
#ifdef USE_STACKABLE_WINDOW |
1696 |
|
typedef struct { |
1697 |
|
char *label, *desc; |
1698 |
|
GtkSignalFunc activate_cb; |
1699 |
|
} menu_entry_t; |
1700 |
|
|
1701 |
void on_export_clicked(GtkButton *button, appdata_t *appdata) { |
typedef struct { |
1702 |
HildonStackableWindow *view_window; |
const char *title; |
1703 |
GtkWidget *but; |
const menu_entry_t *menu; |
1704 |
|
int len; |
1705 |
|
} submenu_t; |
1706 |
|
|
1707 |
view_window = HILDON_STACKABLE_WINDOW (hildon_stackable_window_new ()); |
#define COLUMNS 1 |
|
gtk_window_set_title (GTK_WINDOW (view_window), "Export"); |
|
1708 |
|
|
1709 |
GtkVBox *contents = GTK_VBOX(gtk_vbox_new (12, FALSE)); |
void on_submenu_entry_clicked(GtkButton *button, GtkWidget *menu) { |
1710 |
|
|
1711 |
but = hildon_button_new_with_text( |
/* force closing of submenu dialog */ |
1712 |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
gtk_dialog_response(GTK_DIALOG(menu), GTK_RESPONSE_NONE); |
1713 |
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
gtk_widget_hide(menu); |
1714 |
_("Export to Maemo Mapper"), |
|
1715 |
_("Save a Maemo Mapper POI file")); |
/* let gtk clean up */ |
1716 |
g_signal_connect(but, "clicked", |
while(gtk_events_pending()) |
1717 |
G_CALLBACK(cb_menu_export_mmpoi), appdata); |
gtk_main_iteration(); |
1718 |
gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0); |
} |
1719 |
|
|
1720 |
|
static GtkWidget *app_submenu_create(appdata_t *appdata, |
1721 |
|
const submenu_t *submenu) { |
1722 |
|
|
1723 |
but = hildon_button_new_with_text( |
/* create a oridinary dialog box */ |
1724 |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
GtkWidget *dialog = gtk_dialog_new(); |
1725 |
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
gtk_window_set_title(GTK_WINDOW(dialog), _(submenu->title)); |
1726 |
_("Export Field Notes"), |
gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); |
1727 |
_("Save a Garmin Field Notes file")); |
gtk_window_set_transient_for(GTK_WINDOW(dialog), |
1728 |
g_signal_connect(but, "clicked", |
GTK_WINDOW(appdata->window)); |
1729 |
G_CALLBACK(cb_menu_export_log), appdata); |
gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); |
1730 |
gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0); |
|
1731 |
|
GtkWidget *table = gtk_table_new(submenu->len/COLUMNS, COLUMNS, TRUE); |
1732 |
|
int x = 0, y = 0; |
1733 |
|
|
1734 |
|
const menu_entry_t *menu_entries = submenu->menu; |
1735 |
|
while(menu_entries->label) { |
1736 |
|
GtkWidget *button = NULL; |
1737 |
|
|
1738 |
but = hildon_button_new_with_text( |
button = hildon_button_new_with_text( |
1739 |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
1740 |
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
1741 |
_("Export Garmin GPX"), |
_(menu_entries->label), _(menu_entries->desc)); |
1742 |
_("Save a GPX file containing modified waypoints")); |
|
1743 |
g_signal_connect(but, "clicked", |
/* try to center both texts */ |
1744 |
G_CALLBACK(cb_menu_export_garmin), appdata); |
hildon_button_set_title_alignment(HILDON_BUTTON(button), 0.5, 0.5); |
1745 |
gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0); |
hildon_button_set_value_alignment(HILDON_BUTTON(button), 0.5, 0.5); |
1746 |
|
|
1747 |
|
g_signal_connect(button, "clicked", |
1748 |
|
G_CALLBACK(on_submenu_entry_clicked), dialog); |
1749 |
|
|
1750 |
|
g_signal_connect(button, "clicked", |
1751 |
|
menu_entries->activate_cb, appdata); |
1752 |
|
|
1753 |
|
gtk_table_attach_defaults(GTK_TABLE(table), button, x, x+1, y, y+1); |
1754 |
|
|
1755 |
|
x++; |
1756 |
|
if(x == COLUMNS) { x = 0; y++; } |
1757 |
|
|
1758 |
|
menu_entries++; |
1759 |
|
} |
1760 |
|
|
1761 |
|
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table); |
1762 |
|
|
1763 |
gtk_container_add (GTK_CONTAINER (view_window), GTK_WIDGET (contents)); |
return dialog; |
|
gtk_widget_show_all (GTK_WIDGET (view_window)); |
|
1764 |
} |
} |
1765 |
|
|
1766 |
void on_tools_clicked(GtkButton *button, appdata_t *appdata) { |
/* popup the dialog shaped submenu */ |
1767 |
HildonStackableWindow *view_window; |
static void submenu_popup(GtkWidget *menu) { |
1768 |
GtkWidget *but; |
gtk_widget_show_all(menu); |
1769 |
|
gtk_dialog_run(GTK_DIALOG(menu)); |
1770 |
|
gtk_widget_hide(menu); |
1771 |
|
} |
1772 |
|
|
1773 |
view_window = HILDON_STACKABLE_WINDOW (hildon_stackable_window_new ()); |
static void submenu_cleanup(GtkWidget *menu) { |
1774 |
gtk_window_set_title (GTK_WINDOW (view_window), "Export"); |
gtk_widget_destroy(menu); |
1775 |
|
} |
1776 |
|
|
1777 |
GtkVBox *contents = GTK_VBOX(gtk_vbox_new (12, FALSE)); |
static const menu_entry_t submenu_export_entries[] = { |
1778 |
|
#ifdef ENABLE_MAEMO_MAPPER |
1779 |
|
{ "Export to Maemo Mapper" , "Save a Maemo Mapper POI file", |
1780 |
|
G_CALLBACK(cb_menu_export_mmpoi) }, |
1781 |
|
#endif |
1782 |
|
{ "Export Field Notes", "Save a Garmin Field Notes file", |
1783 |
|
G_CALLBACK(cb_menu_export_log) }, |
1784 |
|
{ "Export Garmin GPX", "Save modified waypoints in GPX file", |
1785 |
|
G_CALLBACK(cb_menu_export_garmin) }, |
1786 |
|
{ NULL, NULL, NULL } |
1787 |
|
}; |
1788 |
|
|
1789 |
but = hildon_button_new_with_text( |
static const submenu_t submenu_export = { |
1790 |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
"Export", submenu_export_entries, |
1791 |
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
sizeof(submenu_export_entries)/sizeof(menu_entry_t)-1 |
1792 |
_("Geomath"), |
}; |
|
_("Geocoordinate calculation")); |
|
|
g_signal_connect(but, "clicked", |
|
|
G_CALLBACK(cb_menu_geomath), appdata); |
|
|
gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0); |
|
1793 |
|
|
1794 |
|
/* the export submenu */ |
1795 |
|
void on_export_clicked(GtkButton *button, appdata_t *appdata) { |
1796 |
|
if(!appdata->export_menu) |
1797 |
|
appdata->export_menu = app_submenu_create(appdata, &submenu_export); |
1798 |
|
|
1799 |
but = hildon_button_new_with_text( |
submenu_popup(appdata->export_menu); |
1800 |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
} |
|
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
|
|
_("Geotext"), |
|
|
_("Text analysis, letter counting etc")); |
|
|
g_signal_connect(but, "clicked", |
|
|
G_CALLBACK(cb_menu_geotext), appdata); |
|
|
gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0); |
|
|
|
|
1801 |
|
|
1802 |
but = hildon_button_new_with_text( |
static const menu_entry_t submenu_tools_entries[] = { |
1803 |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
{ "Geomath", "Geocoordinate calculation", |
1804 |
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
G_CALLBACK(cb_menu_geomath) }, |
1805 |
_("Precise Position"), |
{ "Geotext", "Text analysis", |
1806 |
_("Calculate a very precise GPS position")); |
G_CALLBACK(cb_menu_geotext) }, |
1807 |
g_signal_connect(but, "clicked", |
{ "Precise Position", "Calculate a precise GPS position", |
1808 |
G_CALLBACK(cb_menu_precpos), appdata); |
G_CALLBACK(cb_menu_precpos) }, |
1809 |
gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0); |
{ "GeoToad", "Use GeoToad online downloader", |
1810 |
|
G_CALLBACK(cb_menu_geotoad) }, |
1811 |
|
{ NULL, NULL, NULL } |
1812 |
|
}; |
1813 |
|
|
1814 |
gtk_container_add (GTK_CONTAINER (view_window), GTK_WIDGET (contents)); |
static const submenu_t submenu_tools = { |
1815 |
gtk_widget_show_all (GTK_WIDGET (view_window)); |
"Tools", submenu_tools_entries, |
1816 |
|
sizeof(submenu_tools_entries)/sizeof(menu_entry_t)-1 |
1817 |
|
}; |
1818 |
|
|
1819 |
|
/* the tools submenu */ |
1820 |
|
void on_tools_clicked(GtkButton *button, appdata_t *appdata) { |
1821 |
|
if(!appdata->tools_menu) |
1822 |
|
appdata->tools_menu = app_submenu_create(appdata, &submenu_tools); |
1823 |
|
|
1824 |
|
submenu_popup(appdata->tools_menu); |
1825 |
} |
} |
1826 |
|
|
1827 |
HildonAppMenu *menu_create(appdata_t *appdata, int mode) { |
HildonAppMenu *menu_create(appdata_t *appdata, int mode) { |
1849 |
g_signal_connect_after(button, "clicked", |
g_signal_connect_after(button, "clicked", |
1850 |
G_CALLBACK(cb_menu_adddir), appdata); |
G_CALLBACK(cb_menu_adddir), appdata); |
1851 |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
|
} |
|
1852 |
|
|
|
if(mode == MENU_GPXLIST) { |
|
1853 |
button = gtk_button_new_with_label(_("Export")); |
button = gtk_button_new_with_label(_("Export")); |
1854 |
g_signal_connect_after(button, "clicked", |
g_signal_connect_after(button, "clicked", |
1855 |
G_CALLBACK(on_export_clicked), appdata); |
G_CALLBACK(on_export_clicked), appdata); |
1856 |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1857 |
|
} |
1858 |
|
|
1859 |
|
/* if search results exist, don't allow another search */ |
1860 |
|
if(!appdata->search_results && |
1861 |
|
((mode == MENU_GPXLIST) || (mode == MENU_CACHELIST))) { |
1862 |
button = gtk_button_new_with_label(_("Search")); |
button = gtk_button_new_with_label(_("Search")); |
1863 |
g_signal_connect_after(button, "clicked", |
g_signal_connect_after(button, "clicked", |
1864 |
G_CALLBACK(cb_menu_search), appdata); |
G_CALLBACK(cb_menu_search), appdata); |
1870 |
G_CALLBACK(on_tools_clicked), appdata); |
G_CALLBACK(on_tools_clicked), appdata); |
1871 |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1872 |
|
|
1873 |
gtk_widget_show(GTK_WIDGET(menu)); |
#ifdef ENABLE_OSM_GPS_MAP |
1874 |
|
button = gtk_button_new_with_label(_("Map")); |
1875 |
|
g_signal_connect_after(button, "clicked", |
1876 |
|
G_CALLBACK(cb_menu_map), appdata); |
1877 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1878 |
|
#endif |
1879 |
|
|
1880 |
|
#ifdef HILDON_HELP |
1881 |
|
button = gtk_button_new_with_label(_("Help")); |
1882 |
|
g_signal_connect_after(button, "clicked", |
1883 |
|
G_CALLBACK(cb_menu_help), appdata); |
1884 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1885 |
|
#endif |
1886 |
|
|
1887 |
|
gtk_widget_show_all(GTK_WIDGET(menu)); |
1888 |
|
|
1889 |
return menu; |
return menu; |
1890 |
} |
} |
1894 |
GtkWidget *menu, *item; |
GtkWidget *menu, *item; |
1895 |
menu = gtk_menu_new(); |
menu = gtk_menu_new(); |
1896 |
|
|
1897 |
#ifdef USE_BREAD_CRUMB_TRAIL |
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
1898 |
appdata->menu_import = |
appdata->menu_import = |
1899 |
#endif |
#endif |
1900 |
item = gtk_menu_item_new_with_label(_("Import")); |
item = gtk_menu_item_new_with_label(_("Import")); |
1924 |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_remove), appdata); |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_remove), appdata); |
1925 |
#endif |
#endif |
1926 |
|
|
1927 |
#ifdef USE_BREAD_CRUMB_TRAIL |
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
1928 |
appdata->menu_export = |
appdata->menu_export = |
1929 |
#endif |
#endif |
1930 |
item = gtk_menu_item_new_with_label(_("Export")); |
item = gtk_menu_item_new_with_label(_("Export")); |
1932 |
submenu = gtk_menu_new(); |
submenu = gtk_menu_new(); |
1933 |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
1934 |
|
|
1935 |
#ifdef USE_MAEMO |
#ifdef ENABLE_MAEMO_MAPPER |
1936 |
item = gtk_menu_item_new_with_label( _("Maemo Mapper POI") ); |
item = gtk_menu_item_new_with_label( _("Maemo Mapper POI") ); |
1937 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1938 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
1949 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
1950 |
GTK_SIGNAL_FUNC(cb_menu_export_garmin), appdata); |
GTK_SIGNAL_FUNC(cb_menu_export_garmin), appdata); |
1951 |
|
|
1952 |
#ifdef USE_BREAD_CRUMB_TRAIL |
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
1953 |
appdata->menu_search = |
appdata->menu_search = |
1954 |
#endif |
#endif |
1955 |
item = gtk_menu_item_new_with_label( _("Search") ); |
item = gtk_menu_item_new_with_label( _("Search") ); |
1958 |
|
|
1959 |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
1960 |
|
|
|
#ifndef NO_COPY_N_PASTE |
|
1961 |
/* ----------- copy'n paste submenu ----------------- */ |
/* ----------- copy'n paste submenu ----------------- */ |
1962 |
appdata->clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); |
#ifndef NO_COPY_N_PASTE |
|
gtk_clipboard_set_can_store(appdata->clipboard, NULL, 0); |
|
|
|
|
1963 |
item = gtk_menu_item_new_with_label(_("Edit")); |
item = gtk_menu_item_new_with_label(_("Edit")); |
1964 |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
1965 |
submenu = gtk_menu_new(); |
submenu = gtk_menu_new(); |
1986 |
|
|
1987 |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
1988 |
|
|
1989 |
|
#ifdef ENABLE_OSM_GPS_MAP |
1990 |
|
item = gtk_menu_item_new_with_label( _("Map") ); |
1991 |
|
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
1992 |
|
g_signal_connect(item, "activate", |
1993 |
|
GTK_SIGNAL_FUNC(cb_menu_map), appdata); |
1994 |
|
#endif |
1995 |
|
|
1996 |
item = gtk_menu_item_new_with_label(_("Tools")); |
item = gtk_menu_item_new_with_label(_("Tools")); |
1997 |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
1998 |
submenu = gtk_menu_new(); |
submenu = gtk_menu_new(); |
2013 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
2014 |
GTK_SIGNAL_FUNC(cb_menu_precpos), appdata); |
GTK_SIGNAL_FUNC(cb_menu_precpos), appdata); |
2015 |
|
|
2016 |
|
item = gtk_menu_item_new_with_label( _("GeoToad") ); |
2017 |
|
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
2018 |
|
g_signal_connect(item, "activate", |
2019 |
|
GTK_SIGNAL_FUNC(cb_menu_geotoad), appdata); |
2020 |
|
|
2021 |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
2022 |
|
|
2023 |
#if defined(USE_MAEMO) && defined(HILDON_HELP) |
#if defined(USE_MAEMO) && defined(HILDON_HELP) |
2057 |
/********************* end of menu **********************/ |
/********************* end of menu **********************/ |
2058 |
|
|
2059 |
void cleanup(appdata_t *appdata) { |
void cleanup(appdata_t *appdata) { |
2060 |
|
gconf_save_state(appdata); |
2061 |
|
|
2062 |
gpx_free_all(appdata->gpx); |
gpx_free_all(appdata->gpx); |
2063 |
if(appdata->path) free(appdata->path); |
|
2064 |
if(appdata->image_path) free(appdata->image_path); |
#ifdef USE_STACKABLE_WINDOW |
2065 |
if(appdata->search_str) free(appdata->search_str); |
if(appdata->export_menu) submenu_cleanup(appdata->export_menu); |
2066 |
|
if(appdata->tools_menu) submenu_cleanup(appdata->tools_menu); |
2067 |
|
#endif |
2068 |
|
|
2069 |
gnome_vfs_shutdown(); |
gnome_vfs_shutdown(); |
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 |
|
|
2094 |
puts("everything is gone"); |
puts("everything is gone"); |
2095 |
} |
} |
2096 |
|
|
2097 |
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 |
} |
} |
2103 |
|
|
2104 |
gboolean on_window_key_press(GtkWidget *widget, |
gboolean on_window_key_press(GtkWidget *widget, |
2105 |
GdkEventKey *event, gpointer data) { |
GdkEventKey *event, appdata_t *appdata) { |
|
appdata_t *appdata = (appdata_t*)data; |
|
2106 |
int handled = FALSE; |
int handled = FALSE; |
2107 |
|
|
2108 |
// printf("key event %d\n", event->keyval); |
// printf("key event %d\n", event->keyval); |
2110 |
switch(event->keyval) { |
switch(event->keyval) { |
2111 |
#ifdef USE_MAEMO |
#ifdef USE_MAEMO |
2112 |
|
|
|
#if 0 /* don't do this as it interferes with gtkentry fields */ |
|
|
case HILDON_HARDKEY_SELECT: |
|
|
/* remove as long as we haven't reached the main gpx list */ |
|
|
if(appdata->cur_gpx) |
|
|
hildon_bread_crumb_trail_pop(HILDON_BREAD_CRUMB_TRAIL(appdata->bct)); |
|
|
handled = TRUE; |
|
|
break; |
|
|
#endif |
|
|
|
|
2113 |
#ifdef HILDON_HARDKEY_INCREASE |
#ifdef HILDON_HARDKEY_INCREASE |
2114 |
case HILDON_HARDKEY_INCREASE: |
case HILDON_HARDKEY_INCREASE: |
2115 |
html_zoom(appdata, TRUE); |
html_zoom(appdata, TRUE); |
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 |
|
|
2308 |
void main_after_settings_redraw(appdata_t *appdata, int flags) { |
void main_after_settings_redraw(appdata_t *appdata, int flags) { |
2309 |
#ifndef USE_MAEMO |
printf("main after settings redraw\n"); |
2310 |
// in non-maemo setup this can only affect the main screen as |
|
2311 |
// the menu is blocked while a dialog is open. also the main |
if(!appdata->cur_view) { |
2312 |
// screen is always present |
printf("no active view\n"); |
2313 |
if(appdata->gpxlist_items != appdata->cur_items) { |
return; |
|
/* 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); |
|
2314 |
} |
} |
2315 |
#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) { |
2339 |
gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
|
2340 |
|
#ifdef USE_STACKABLE_WINDOW |
2341 |
|
HildonWindowStack *stack = hildon_window_stack_get_default(); |
2342 |
|
GtkWidget *container = hildon_window_stack_peek(stack); |
2343 |
|
#else |
2344 |
|
GtkWidget *container = appdata->vbox; |
2345 |
|
#endif |
2346 |
|
|
2347 |
|
gtk_container_remove(GTK_CONTAINER(container), appdata->cur_view); |
2348 |
switch(redraw) { |
switch(redraw) { |
2349 |
case 1: |
case 1: |
2350 |
appdata->cur_view = cachelist_create(appdata, |
appdata->cur_view = cachelist_create(appdata, |
2359 |
break; |
break; |
2360 |
} |
} |
2361 |
|
|
2362 |
gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view); |
#ifdef USE_STACKABLE_WINDOW |
2363 |
gtk_widget_show_all(appdata->vbox); |
gtk_container_add(GTK_CONTAINER(container), appdata->cur_view); |
2364 |
} |
#else |
2365 |
|
gtk_box_pack_start_defaults(GTK_BOX(container), appdata->cur_view); |
2366 |
#endif |
#endif |
2367 |
|
|
2368 |
|
gtk_widget_show_all(container); |
2369 |
|
} |
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 USE_MAEMO |
#ifdef USE_MAEMO |
2395 |
printf("Installing osso context for \"org.harbaum." APP "\"\n"); |
printf("Installing osso context for \"org.harbaum." APP "\"\n"); |
2396 |
appdata.osso_context = osso_initialize("org.harbaum."APP, |
appdata.osso_context = osso_initialize("org.harbaum."APP, |
2399 |
fprintf(stderr, "error initiating osso context\n"); |
fprintf(stderr, "error initiating osso context\n"); |
2400 |
} |
} |
2401 |
|
|
2402 |
|
#ifdef ENABLE_MAEMO_MAPPER |
2403 |
dbus_register(&appdata); |
dbus_register(&appdata); |
2404 |
#endif |
#endif |
2405 |
|
#endif |
2406 |
|
|
2407 |
icons_init(); |
icons_init(); |
2408 |
|
|
2426 |
/* Create a Window. */ |
/* Create a Window. */ |
2427 |
appdata.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
appdata.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
2428 |
/* Set a decent default size for the window. */ |
/* Set a decent default size for the window. */ |
2429 |
gtk_window_set_default_size(GTK_WINDOW(appdata.window), 500, 300); |
gtk_window_set_default_size(GTK_WINDOW(appdata.window), 640, 480); |
2430 |
#endif |
#endif |
2431 |
|
|
2432 |
|
#if MAEMO_VERSION_MAJOR == 5 |
2433 |
gtk_window_set_title(GTK_WINDOW(appdata.window), "GPXView"); |
gtk_window_set_title(GTK_WINDOW(appdata.window), "GPXView"); |
2434 |
|
#endif |
2435 |
|
|
2436 |
g_signal_connect(G_OBJECT(appdata.window), "destroy", |
g_signal_connect(G_OBJECT(appdata.window), "destroy", |
2437 |
G_CALLBACK(on_window_destroy), &appdata); |
G_CALLBACK(on_window_destroy), &appdata); |
2438 |
|
|
2439 |
g_signal_connect(G_OBJECT(appdata.window), "key_press_event", |
g_signal_connect(G_OBJECT(appdata.window), "key_press_event", |
2440 |
G_CALLBACK(on_window_key_press), &appdata); |
G_CALLBACK(on_window_key_press), &appdata); |
2441 |
|
|
2442 |
appdata.vbox = gtk_vbox_new(FALSE, 2); |
/* prepare clipboard */ |
2443 |
gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox); |
appdata.clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); |
2444 |
|
gtk_clipboard_set_can_store(appdata.clipboard, NULL, 0); |
2445 |
|
|
2446 |
#ifndef USE_STACKABLE_WINDOW |
#ifndef USE_STACKABLE_WINDOW |
2447 |
|
appdata.vbox = gtk_vbox_new(FALSE, 2); |
2448 |
|
gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox); |
2449 |
menu_create(&appdata); |
menu_create(&appdata); |
2450 |
#else |
#else |
2451 |
hildon_window_set_app_menu(HILDON_WINDOW(appdata.window), |
hildon_window_set_app_menu(HILDON_WINDOW(appdata.window), |
2458 |
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); |
2459 |
|
|
2460 |
hildon_bread_crumb_trail_clear(HILDON_BREAD_CRUMB_TRAIL(appdata.bct)); |
hildon_bread_crumb_trail_clear(HILDON_BREAD_CRUMB_TRAIL(appdata.bct)); |
2461 |
|
#else |
2462 |
|
#ifdef BCT |
2463 |
|
/* on non-hildon machines we use some custom made breadcrumbtrail */ |
2464 |
|
/* replacement */ |
2465 |
|
appdata.bct = bct_new(); |
2466 |
|
gtk_box_pack_start(GTK_BOX(appdata.vbox), appdata.bct, FALSE,FALSE,0); |
2467 |
|
#endif |
2468 |
|
#endif |
2469 |
|
|
2470 |
|
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
2471 |
crumb_add(&appdata, "GPX", CRUMB_GPXLIST, NULL); |
crumb_add(&appdata, "GPX", CRUMB_GPXLIST, NULL); |
2472 |
#endif |
#endif |
2473 |
|
|
2481 |
gps_init(&appdata); |
gps_init(&appdata); |
2482 |
|
|
2483 |
appdata.cur_view = gpxlist_create_view_and_model(&appdata, NULL); |
appdata.cur_view = gpxlist_create_view_and_model(&appdata, NULL); |
2484 |
|
#ifndef USE_STACKABLE_WINDOW |
2485 |
gtk_box_pack_start_defaults(GTK_BOX(appdata.vbox), appdata.cur_view); |
gtk_box_pack_start_defaults(GTK_BOX(appdata.vbox), appdata.cur_view); |
2486 |
|
#else |
2487 |
|
gtk_container_add(GTK_CONTAINER(appdata.window), appdata.cur_view); |
2488 |
|
#endif |
2489 |
|
|
2490 |
gtk_widget_show_all(GTK_WIDGET(appdata.window)); |
gtk_widget_show_all(GTK_WIDGET(appdata.window)); |
2491 |
gtk_main(); |
gtk_main(); |