35 |
|
|
36 |
extern char *strcasestr (__const char *__haystack, __const char *__needle); |
extern char *strcasestr (__const char *__haystack, __const char *__needle); |
37 |
|
|
38 |
#ifdef USE_BREAD_CRUMB_TRAIL |
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
39 |
static void crumb_add(appdata_t *appdata, char *name, int level, |
static void crumb_add(appdata_t *appdata, char *name, int level, |
40 |
gpointer user_data); |
gpointer user_data); |
41 |
|
|
95 |
GtkWidget *dialog = gtk_message_dialog_new( |
GtkWidget *dialog = gtk_message_dialog_new( |
96 |
GTK_WINDOW(NULL), |
GTK_WINDOW(NULL), |
97 |
GTK_DIALOG_DESTROY_WITH_PARENT, |
GTK_DIALOG_DESTROY_WITH_PARENT, |
98 |
GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, |
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
99 |
buf); |
GTK_MESSAGE_ERROR, |
100 |
|
#else |
101 |
|
GTK_MESSAGE_OTHER, |
102 |
|
#endif |
103 |
|
GTK_BUTTONS_CLOSE, buf); |
104 |
|
|
105 |
gtk_window_set_title(GTK_WINDOW(dialog), _("ERROR")); |
gtk_window_set_title(GTK_WINDOW(dialog), _("ERROR")); |
106 |
|
|
124 |
HELP_ID_IMPORT, appdata->osso_context); |
HELP_ID_IMPORT, appdata->osso_context); |
125 |
#endif |
#endif |
126 |
#else |
#else |
127 |
dialog = gtk_file_chooser_dialog_new (whole_dir?_("Open Directory"): |
dialog = gtk_file_chooser_dialog_new (whole_dir?_("Import directory"): |
128 |
_("Open File"), |
_("Import file"), |
129 |
GTK_WINDOW(appdata->window), |
GTK_WINDOW(appdata->window), |
130 |
whole_dir?GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER : |
whole_dir?GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER : |
131 |
GTK_FILE_CHOOSER_ACTION_OPEN, |
GTK_FILE_CHOOSER_ACTION_OPEN, |
142 |
gtk_widget_show_all (GTK_WIDGET(dialog)); |
gtk_widget_show_all (GTK_WIDGET(dialog)); |
143 |
if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_FM_OK) { |
if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_FM_OK) { |
144 |
char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); |
char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); |
145 |
|
|
146 |
|
if(filename) { |
147 |
|
gpx_dialog_t *dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window)); |
148 |
|
|
149 |
gpx_dialog_t *dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window)); |
if(!whole_dir) |
150 |
|
gpx = gpx_parse(dialog, filename); |
151 |
if(!whole_dir) |
else { |
152 |
gpx = gpx_parse(dialog, filename); |
/* cur trailing '/' if present */ |
153 |
else { |
if(strlastchr(filename) == '/') |
154 |
/* cur trailing '/' if present */ |
filename[strlen(filename)] = 0; |
155 |
if(strlastchr(filename) == '/') |
|
156 |
filename[strlen(filename)] = 0; |
gpx = gpx_parse_dir(dialog, filename); |
|
|
|
|
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 = '/'; |
|
157 |
} |
} |
158 |
|
|
159 |
|
gpx_busy_dialog_destroy(dialog); |
160 |
|
|
161 |
|
/* save path if gpx was successfully loaded */ |
162 |
|
if(gpx) { |
163 |
|
char *r = strrchr(filename, '/'); |
164 |
|
|
165 |
|
/* there is a delimiter, use everything left of it as path */ |
166 |
|
if(r && !whole_dir) { |
167 |
|
*r = 0; |
168 |
|
if(appdata->path) free(appdata->path); |
169 |
|
appdata->path = strdup(filename); |
170 |
|
/* restore path ... just in case ... */ |
171 |
|
*r = '/'; |
172 |
|
} |
173 |
|
|
174 |
|
if(whole_dir) |
175 |
|
appdata->path = strdup(filename); |
176 |
|
} else |
177 |
|
errorf(_("Load error")); |
178 |
|
|
179 |
if(whole_dir) |
g_free (filename); |
180 |
appdata->path = strdup(filename); |
} else { |
181 |
|
#ifndef USE_MAEMO |
182 |
|
errorf(_("Error accessing the file.")); |
183 |
|
#else |
184 |
|
errorf(_("Error accessing the file. This may happen if the file " |
185 |
|
"resides on a remote file system. Please copy the file onto " |
186 |
|
"the device (e.g. onto the memory card) and try again.")); |
187 |
|
#endif |
188 |
} |
} |
|
|
|
|
g_free (filename); |
|
189 |
} |
} |
190 |
|
|
191 |
gtk_widget_destroy (dialog); |
gtk_widget_destroy (dialog); |
209 |
CACHELIST_NUM_COLS |
CACHELIST_NUM_COLS |
210 |
} ; |
} ; |
211 |
|
|
212 |
void cachelist_view_onRowActivated(GtkTreeView *treeview, |
void cachelist_goto_cache(appdata_t *appdata, cache_t *cache) { |
213 |
|
#if !defined(USE_BREAD_CRUMB_TRAIL) && !defined(BCT) |
214 |
|
cache_dialog(appdata, cache); |
215 |
|
#else |
216 |
|
gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
217 |
|
appdata->cur_view = cache_view(appdata, cache); |
218 |
|
gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view); |
219 |
|
gtk_widget_show_all(appdata->vbox); |
220 |
|
|
221 |
|
crumb_add(appdata, cache->name, CRUMB_CACHE, cache); |
222 |
|
#endif |
223 |
|
} |
224 |
|
|
225 |
|
static void cachelist_view_onRowActivated(GtkTreeView *treeview, |
226 |
GtkTreePath *path, |
GtkTreePath *path, |
227 |
GtkTreeViewColumn *col, |
GtkTreeViewColumn *col, |
228 |
gpointer userdata) { |
gpointer userdata) { |
230 |
GtkTreeIter iter; |
GtkTreeIter iter; |
231 |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
232 |
|
|
233 |
|
#ifdef USE_MAEMO |
234 |
|
/* check if a cache is already selected and ignore click if yes */ |
235 |
|
/* (was probably a double click) */ |
236 |
|
if(appdata->cur_cache) return; |
237 |
|
#endif |
238 |
|
|
239 |
if(gtk_tree_model_get_iter(model, &iter, path)) { |
if(gtk_tree_model_get_iter(model, &iter, path)) { |
240 |
cache_t *cache; |
cache_t *cache; |
241 |
gtk_tree_model_get(model, &iter, CACHELIST_COL_DATA, &cache, -1); |
gtk_tree_model_get(model, &iter, CACHELIST_COL_DATA, &cache, -1); |
242 |
#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 |
|
243 |
} |
} |
244 |
} |
} |
245 |
|
|
282 |
cache_t *sel_cache); |
cache_t *sel_cache); |
283 |
|
|
284 |
void cachelist_redraw(appdata_t *appdata) { |
void cachelist_redraw(appdata_t *appdata) { |
285 |
#ifndef USE_MAEMO |
if(!appdata->cur_view) { |
286 |
// gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
printf("cachelist redraw: no active view\n"); |
287 |
// appdata->cur_view = gpxlist_create_view_and_model(appdata, NULL); |
return; |
288 |
// gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view); |
} |
|
// gtk_widget_show_all(appdata->vbox); |
|
|
#else |
|
289 |
|
|
290 |
g_assert(!appdata->cur_cache); |
g_assert(!appdata->cur_cache); |
291 |
int redraw = 0; |
int redraw = 0; |
297 |
} |
} |
298 |
|
|
299 |
if(redraw) { |
if(redraw) { |
300 |
gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
GtkWidget *container = appdata->vbox; |
301 |
|
|
302 |
|
#ifdef USE_STACKABLE_WINDOW |
303 |
|
HildonWindowStack *stack = hildon_window_stack_get_default(); |
304 |
|
container = hildon_window_stack_peek(stack); |
305 |
|
#endif |
306 |
|
|
307 |
|
gtk_container_remove(GTK_CONTAINER(container), appdata->cur_view); |
308 |
switch(redraw) { |
switch(redraw) { |
309 |
case 1: |
case 1: |
310 |
appdata->cur_view = cachelist_create(appdata, |
appdata->cur_view = cachelist_create(appdata, |
316 |
break; |
break; |
317 |
} |
} |
318 |
|
|
319 |
gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view); |
#ifdef USE_STACKABLE_WINDOW |
320 |
gtk_widget_show_all(appdata->vbox); |
if(container != appdata->vbox) |
321 |
} |
gtk_container_add(GTK_CONTAINER(container), appdata->cur_view); |
322 |
|
else |
323 |
#endif |
#endif |
324 |
|
gtk_box_pack_start_defaults(GTK_BOX(container), appdata->cur_view); |
325 |
|
|
326 |
|
gtk_widget_show_all(container); |
327 |
|
} |
328 |
} |
} |
329 |
|
|
330 |
|
|
332 |
|
|
333 |
printf("cachelist timer fired!\n"); |
printf("cachelist timer fired!\n"); |
334 |
|
|
|
#ifdef USE_MAEMO |
|
335 |
appdata_t *appdata = (appdata_t*)data; |
appdata_t *appdata = (appdata_t*)data; |
336 |
|
|
337 |
|
if(appdata->cur_cache) |
338 |
|
return TRUE; |
339 |
|
|
340 |
|
#ifdef USE_MAEMO |
341 |
if(appdata->cachelist_disable_screensaver) |
if(appdata->cachelist_disable_screensaver) |
342 |
if (osso_display_blanking_pause(appdata->osso_context) != OSSO_OK) |
if (osso_display_blanking_pause(appdata->osso_context) != OSSO_OK) |
343 |
fprintf(stderr, "error with display blank\n"); |
fprintf(stderr, "error with display blank\n"); |
344 |
|
#endif |
345 |
|
|
346 |
if(appdata->cachelist_update) |
if(appdata->cachelist_update) |
347 |
cachelist_redraw(appdata); |
cachelist_redraw(appdata); |
|
#endif |
|
348 |
|
|
349 |
return TRUE; |
return TRUE; |
350 |
} |
} |
351 |
|
|
352 |
static void cachelist_timer_reset(appdata_t *appdata) { |
static void cachelist_timer_reset(appdata_t *appdata) { |
353 |
|
printf("cachelist timer reset\n"); |
354 |
g_assert(appdata->cachelist_handler_id); |
g_assert(appdata->cachelist_handler_id); |
355 |
gtk_timeout_remove(appdata->cachelist_handler_id); |
gtk_timeout_remove(appdata->cachelist_handler_id); |
356 |
appdata->cachelist_handler_id = |
appdata->cachelist_handler_id = |
582 |
} |
} |
583 |
#else |
#else |
584 |
#ifdef USE_STACKABLE_WINDOW |
#ifdef USE_STACKABLE_WINDOW |
585 |
|
static void search_result_free(gpx_t *result); |
586 |
|
|
587 |
|
void on_cachelist_destroy(GtkWidget *widget, appdata_t *appdata) { |
588 |
|
if(appdata->search_results) { |
589 |
|
search_result_free(appdata->search_results); |
590 |
|
appdata->search_results = NULL; |
591 |
|
} |
592 |
|
appdata->cur_gpx = NULL; |
593 |
|
|
594 |
|
#ifdef ENABLE_OSM_GPS_MAP |
595 |
|
map_update(appdata); |
596 |
|
#endif |
597 |
|
|
598 |
|
/* restore cur_view */ |
599 |
|
appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view"); |
600 |
|
} |
601 |
|
|
602 |
void cachelist_dialog(appdata_t *appdata, gpx_t *gpx) { |
void cachelist_dialog(appdata_t *appdata, gpx_t *gpx) { |
603 |
GtkWidget *window = hildon_stackable_window_new(); |
GtkWidget *window = hildon_stackable_window_new(); |
604 |
|
|
605 |
gtk_window_set_title(GTK_WINDOW(window), gpx->name); |
/* store last "cur_view" in window */ |
606 |
|
g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view); |
607 |
|
|
608 |
gtk_container_add(GTK_CONTAINER(window), |
appdata->cur_gpx = gpx; |
609 |
cachelist_create(appdata, gpx, NULL)); |
char *title = g_strdup_printf("%s - GPXView", gpx->name); |
610 |
|
gtk_window_set_title(GTK_WINDOW(window), title); |
611 |
|
g_free(title); |
612 |
|
|
613 |
|
appdata->cur_view = cachelist_create(appdata, gpx, NULL); |
614 |
|
gtk_container_add(GTK_CONTAINER(window), appdata->cur_view); |
615 |
|
|
616 |
|
|
617 |
|
hildon_window_set_app_menu(HILDON_WINDOW(window), |
618 |
|
menu_create(appdata, MENU_CACHELIST)); |
619 |
|
|
620 |
|
g_signal_connect(G_OBJECT(window), "destroy", |
621 |
|
G_CALLBACK(on_cachelist_destroy), appdata); |
622 |
|
|
623 |
gtk_widget_show_all(window); |
gtk_widget_show_all(window); |
624 |
|
|
625 |
|
#ifdef ENABLE_OSM_GPS_MAP |
626 |
|
map_update(appdata); |
627 |
|
#endif |
628 |
} |
} |
629 |
#endif |
#endif |
630 |
#endif |
#endif |
728 |
gconf_save_closed_name(appdata, gpx->filename, gpx->name); |
gconf_save_closed_name(appdata, gpx->filename, gpx->name); |
729 |
} |
} |
730 |
|
|
731 |
|
void gpxlist_goto_cachelist(appdata_t *appdata, gpx_t *gpx) { |
732 |
|
#if !defined(USE_BREAD_CRUMB_TRAIL) && !defined(BCT) |
733 |
|
#ifdef USE_STACKABLE_WINDOW |
734 |
|
if(!appdata->cur_gpx) |
735 |
|
#endif |
736 |
|
cachelist_dialog(appdata, gpx); |
737 |
|
#ifdef USE_STACKABLE_WINDOW |
738 |
|
else |
739 |
|
printf("selected gpx, but cachelist window already present\n"); |
740 |
|
#endif |
741 |
|
#else |
742 |
|
gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
743 |
|
appdata->cur_view = cachelist_create(appdata, gpx, NULL); |
744 |
|
gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view); |
745 |
|
gtk_widget_show_all(appdata->vbox); |
746 |
|
|
747 |
|
crumb_add(appdata, gpx->name, CRUMB_CACHELIST, gpx); |
748 |
|
#endif |
749 |
|
} |
750 |
|
|
751 |
static void gpxlist_view_onRowActivated(GtkTreeView *treeview, |
static void gpxlist_view_onRowActivated(GtkTreeView *treeview, |
752 |
GtkTreePath *path, |
GtkTreePath *path, |
753 |
GtkTreeViewColumn *col, |
GtkTreeViewColumn *col, |
756 |
GtkTreeIter iter; |
GtkTreeIter iter; |
757 |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
758 |
|
|
759 |
|
#ifdef USE_MAEMO |
760 |
|
/* check if a cache is already selected and ignore click if yes */ |
761 |
|
/* (was probably a double click) */ |
762 |
|
if(appdata->cur_gpx) return; |
763 |
|
#endif |
764 |
|
|
765 |
if (gtk_tree_model_get_iter(model, &iter, path)) { |
if (gtk_tree_model_get_iter(model, &iter, path)) { |
766 |
gpx_t *gpx; |
gpx_t *gpx; |
767 |
gtk_tree_model_get(model, &iter, GPXLIST_COL_DATA, &gpx, -1); |
gtk_tree_model_get(model, &iter, GPXLIST_COL_DATA, &gpx, -1); |
778 |
GtkWidget *dialog = gtk_message_dialog_new( |
GtkWidget *dialog = gtk_message_dialog_new( |
779 |
GTK_WINDOW(appdata->window), |
GTK_WINDOW(appdata->window), |
780 |
GTK_DIALOG_DESTROY_WITH_PARENT, |
GTK_DIALOG_DESTROY_WITH_PARENT, |
781 |
GTK_MESSAGE_QUESTION, GTK_BUTTONS_CANCEL, |
/* this doesn't fix the text selection issues ... */ |
782 |
|
#if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >=5) |
783 |
|
GTK_MESSAGE_OTHER, |
784 |
|
#else |
785 |
|
GTK_MESSAGE_QUESTION, |
786 |
|
#endif |
787 |
|
GTK_BUTTONS_CANCEL, |
788 |
_("Do you want to close this entry only or do " |
_("Do you want to close this entry only or do " |
789 |
"you want to remove it completely from the list?")); |
"you want to remove it completely from the list?")); |
790 |
|
|
796 |
if(gpx->closed) |
if(gpx->closed) |
797 |
gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), 2, FALSE); |
gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), 2, FALSE); |
798 |
|
|
799 |
gtk_window_set_title(GTK_WINDOW(dialog), _("Remove entry?")); |
gtk_window_set_title(GTK_WINDOW(dialog), _("Close or remove entry?")); |
800 |
|
|
801 |
/* set the active flag again if the user answered "no" */ |
/* set the active flag again if the user answered "no" */ |
802 |
switch(gtk_dialog_run(GTK_DIALOG(dialog))) { |
switch(gtk_dialog_run(GTK_DIALOG(dialog))) { |
865 |
|
|
866 |
gpx_busy_dialog_destroy(dialog); |
gpx_busy_dialog_destroy(dialog); |
867 |
} |
} |
868 |
#ifndef USE_BREAD_CRUMB_TRAIL |
|
869 |
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 |
|
870 |
} |
} |
871 |
} |
} |
872 |
} |
} |
921 |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview), |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview), |
922 |
-1, "Icon", renderer, |
-1, "Icon", renderer, |
923 |
"pixbuf", GPXLIST_COL_ICON, |
"pixbuf", GPXLIST_COL_ICON, |
924 |
// "sensitive", GPXLIST_COL_OPEN, |
#ifdef USE_PANNABLE_AREA |
925 |
|
/* at least one entry needs to be sensitive. */ |
926 |
|
/* This is the delete icon if the PANNABLE_AREA is used */ |
927 |
|
"sensitive", GPXLIST_COL_OPEN, |
928 |
|
#endif |
929 |
NULL); |
NULL); |
930 |
|
|
931 |
/* --- "FileName" column --- */ |
/* --- "FileName" column --- */ |
981 |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview), |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview), |
982 |
-1, "Del", renderer, |
-1, "Del", renderer, |
983 |
"pixbuf", GPXLIST_COL_DELETE, |
"pixbuf", GPXLIST_COL_DELETE, |
984 |
"sensitive", GPXLIST_COL_OPEN, |
// "sensitive", GPXLIST_COL_OPEN, |
985 |
NULL); |
NULL); |
986 |
#endif |
#endif |
987 |
|
|
1001 |
GtkTreeIter iter; |
GtkTreeIter iter; |
1002 |
gtk_list_store_append(appdata->gpxstore, &iter); |
gtk_list_store_append(appdata->gpxstore, &iter); |
1003 |
gpxlist_set(appdata->gpxstore, &iter, gpx); |
gpxlist_set(appdata->gpxstore, &iter, gpx); |
1004 |
|
|
1005 |
if(gpx == sel_gpx) { |
if(gpx == sel_gpx) { |
1006 |
sel_iter = iter; |
sel_iter = iter; |
1007 |
sel_iter_valid = TRUE; |
sel_iter_valid = TRUE; |
1061 |
|
|
1062 |
/******************** begin of menu *********************/ |
/******************** begin of menu *********************/ |
1063 |
|
|
1064 |
|
typedef struct { |
1065 |
|
appdata_t *appdata; |
1066 |
|
GtkWidget *dialog; |
1067 |
|
} about_context_t; |
1068 |
|
|
1069 |
|
#ifdef ENABLE_BROWSER_INTERFACE |
1070 |
|
void on_paypal_button_clicked(GtkButton *button, about_context_t *context) { |
1071 |
|
gtk_dialog_response(GTK_DIALOG(context->dialog), GTK_RESPONSE_ACCEPT); |
1072 |
|
browser_url(context->appdata, |
1073 |
|
"https://www.paypal.com/cgi-bin/webscr" |
1074 |
|
"?cmd=_s-xclick&hosted_button_id=7400558"); |
1075 |
|
} |
1076 |
|
#endif |
1077 |
|
|
1078 |
static void |
static void |
1079 |
cb_menu_about(GtkWidget *window, gpointer data) { |
cb_menu_about(GtkWidget *window, gpointer data) { |
1080 |
GtkAboutDialog *about = GTK_ABOUT_DIALOG(gtk_about_dialog_new()); |
about_context_t context; |
1081 |
|
|
1082 |
|
context.appdata = (appdata_t *)data; |
1083 |
|
|
1084 |
|
#ifdef ENABLE_LIBLOCATION |
1085 |
|
char *uses = "uses liblocation"; |
1086 |
|
#elif defined(ENABLE_GPSBT) |
1087 |
|
char *uses = "uses gpsbt and gpsd"; |
1088 |
|
#else |
1089 |
|
char *uses = "uses gpsd"; |
1090 |
|
#endif |
1091 |
|
|
1092 |
|
const gchar *authors[] = { |
1093 |
|
"Till Harbaum <till@harbaum.org>", |
1094 |
|
"John Stowers <john.stowers@gmail.com>", |
1095 |
|
NULL }; |
1096 |
|
|
1097 |
|
context.dialog = g_object_new(GTK_TYPE_ABOUT_DIALOG, |
1098 |
|
"name", "GPXView", |
1099 |
|
"version", VERSION, |
1100 |
|
"copyright", _("Copyright 2008-2009"), |
1101 |
|
"authors", authors, |
1102 |
|
"website", _("http://www.harbaum.org/till/maemo"), |
1103 |
|
"comments", _(uses), |
1104 |
|
NULL); |
1105 |
|
|
1106 |
gtk_about_dialog_set_name(about, "GPXView"); |
#ifdef ENABLE_BROWSER_INTERFACE |
1107 |
gtk_about_dialog_set_version(about, VERSION); |
/* add a way to donate to the project */ |
1108 |
gtk_about_dialog_set_copyright(about, |
GtkWidget *alignment = gtk_alignment_new(0.5, 0, 0, 0); |
1109 |
_("GPXView (c) 2008 by\n" |
|
1110 |
"Till Harbaum <till@harbaum.org>\n" |
GtkWidget *hbox = gtk_hbox_new(FALSE, 8); |
1111 |
"Geocaching.com: Tantil")); |
gtk_box_pack_start(GTK_BOX(hbox), |
1112 |
|
gtk_label_new(_("Do you like GPXView?")), |
1113 |
gtk_about_dialog_set_website(about, |
FALSE, FALSE, 0); |
1114 |
_("http://www.harbaum.org/till/maemo")); |
|
1115 |
|
GtkWidget *button = gtk_button_new(); |
1116 |
gtk_about_dialog_set_comments(about, |
gtk_button_set_image(GTK_BUTTON(button), |
1117 |
_("Geocaching.com GPX file viewer")); |
icon_get_widget(ICON_MISC, 8)); |
1118 |
|
gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
1119 |
gtk_widget_show_all(GTK_WIDGET(about)); |
g_signal_connect(button, "clicked", |
1120 |
gtk_dialog_run(GTK_DIALOG(about)); |
G_CALLBACK(on_paypal_button_clicked), &context); |
1121 |
gtk_widget_destroy(GTK_WIDGET(about)); |
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
1122 |
|
|
1123 |
|
gtk_container_add(GTK_CONTAINER(alignment), hbox); |
1124 |
|
gtk_box_pack_start_defaults(GTK_BOX((GTK_DIALOG(context.dialog))->vbox), |
1125 |
|
alignment); |
1126 |
|
|
1127 |
|
gtk_widget_show_all(alignment); |
1128 |
|
#endif |
1129 |
|
|
1130 |
|
gtk_dialog_run(GTK_DIALOG(context.dialog)); |
1131 |
|
gtk_widget_destroy(context.dialog); |
1132 |
} |
} |
1133 |
|
|
1134 |
#if defined(USE_MAEMO) && defined(HILDON_HELP) |
#if defined(USE_MAEMO) && defined(HILDON_HELP) |
1156 |
if(new) gpxlist_add(appdata, new); |
if(new) gpxlist_add(appdata, new); |
1157 |
} |
} |
1158 |
|
|
|
static void |
|
|
cb_menu_geomath(GtkWidget *window, gpointer data) { |
|
|
geomath_dialog((appdata_t *)data); |
|
|
} |
|
|
|
|
|
static void |
|
|
cb_menu_geotext(GtkWidget *window, gpointer data) { |
|
|
geotext_dialog((appdata_t *)data); |
|
|
} |
|
|
|
|
|
static void |
|
|
cb_menu_precpos(GtkWidget *window, gpointer data) { |
|
|
precise_position((appdata_t *)data); |
|
|
} |
|
|
|
|
1159 |
#ifndef USE_PANNABLE_AREA |
#ifndef USE_PANNABLE_AREA |
1160 |
static void |
static void |
1161 |
cb_menu_close(GtkWidget *window, gpointer data) { |
cb_menu_close(GtkWidget *window, gpointer data) { |
1474 |
/* don't search if we are asked to search for nothing */ |
/* don't search if we are asked to search for nothing */ |
1475 |
if(((appdata->search & (SEARCH_ID|SEARCH_NAME|SEARCH_DESC|SEARCH_OWNER)) && |
if(((appdata->search & (SEARCH_ID|SEARCH_NAME|SEARCH_DESC|SEARCH_OWNER)) && |
1476 |
strlen(p) > 0) || (appdata->search & SEARCH_FINDS)) { |
strlen(p) > 0) || (appdata->search & SEARCH_FINDS)) { |
|
gpx_t *found = NULL; |
|
1477 |
|
|
1478 |
printf("Search for %s (flags = %x)...\n", p, appdata->search); |
printf("Search for %s (flags = %x)...\n", p, appdata->search); |
1479 |
|
|
1480 |
#ifndef USE_BREAD_CRUMB_TRAIL |
#if !defined(USE_BREAD_CRUMB_TRAIL) && !defined(BCT) |
1481 |
found = search_do(appdata, appdata->gpx, p, appdata->search, FALSE); |
gpx_t *found = |
1482 |
|
search_do(appdata, appdata->gpx, p, appdata->search, FALSE); |
1483 |
|
|
1484 |
/* do search result dialog here ... */ |
/* do search result dialog here ... */ |
1485 |
cachelist_dialog(appdata, found); |
cachelist_dialog(appdata, found); |
1486 |
|
#ifndef USE_STACKABLE_WINDOW |
1487 |
search_result_free(found); |
search_result_free(found); |
1488 |
#else |
#else |
1489 |
|
appdata->search_results = found; |
1490 |
|
#endif |
1491 |
|
#else |
1492 |
|
gpx_t *found = NULL; |
1493 |
|
|
1494 |
if(appdata->cur_gpx) |
if(appdata->cur_gpx) |
1495 |
found = search_do(appdata, appdata->cur_gpx, p, appdata->search, TRUE); |
found = search_do(appdata, appdata->cur_gpx, p, appdata->search, TRUE); |
1496 |
else |
else |
1511 |
gtk_widget_destroy(dialog); |
gtk_widget_destroy(dialog); |
1512 |
} |
} |
1513 |
|
|
1514 |
void on_window_destroy (GtkWidget *widget, gpointer data); |
static void on_window_destroy (GtkWidget *widget, gpointer data); |
1515 |
|
|
1516 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
1517 |
static void |
static void |
1573 |
notes_log_export(appdata); |
notes_log_export(appdata); |
1574 |
} |
} |
1575 |
|
|
1576 |
#ifdef USE_MAEMO |
#ifdef ENABLE_MAEMO_MAPPER |
1577 |
static void |
static void |
1578 |
cb_menu_export_mmpoi(GtkWidget *widget, gpointer data) { |
cb_menu_export_mmpoi(GtkWidget *widget, gpointer data) { |
1579 |
appdata_t *appdata = (appdata_t*)data; |
appdata_t *appdata = (appdata_t*)data; |
1587 |
garmin_export(appdata); |
garmin_export(appdata); |
1588 |
} |
} |
1589 |
|
|
1590 |
|
#ifdef ENABLE_OSM_GPS_MAP |
1591 |
|
static void |
1592 |
|
cb_menu_map(GtkWidget *window, gpointer data) { |
1593 |
|
map((appdata_t *)data); |
1594 |
|
} |
1595 |
|
#endif |
1596 |
|
|
1597 |
|
static void |
1598 |
|
cb_menu_geomath(GtkWidget *window, gpointer data) { |
1599 |
|
geomath_dialog((appdata_t *)data); |
1600 |
|
} |
1601 |
|
|
1602 |
|
static void |
1603 |
|
cb_menu_geotext(GtkWidget *window, gpointer data) { |
1604 |
|
geotext_dialog((appdata_t *)data); |
1605 |
|
} |
1606 |
|
|
1607 |
|
static void |
1608 |
|
cb_menu_precpos(GtkWidget *window, gpointer data) { |
1609 |
|
precise_position((appdata_t *)data); |
1610 |
|
} |
1611 |
|
|
1612 |
|
#ifdef USE_STACKABLE_WINDOW |
1613 |
|
typedef struct { |
1614 |
|
char *label, *desc; |
1615 |
|
GtkSignalFunc activate_cb; |
1616 |
|
} menu_entry_t; |
1617 |
|
|
1618 |
|
typedef struct { |
1619 |
|
const char *title; |
1620 |
|
const menu_entry_t *menu; |
1621 |
|
int len; |
1622 |
|
} submenu_t; |
1623 |
|
|
1624 |
|
#define COLUMNS 1 |
1625 |
|
|
1626 |
|
void on_submenu_entry_clicked(GtkButton *button, GtkWidget *menu) { |
1627 |
|
|
1628 |
|
/* force closing of submenu dialog */ |
1629 |
|
gtk_dialog_response(GTK_DIALOG(menu), GTK_RESPONSE_NONE); |
1630 |
|
gtk_widget_hide(menu); |
1631 |
|
|
1632 |
|
/* let gtk clean up */ |
1633 |
|
while(gtk_events_pending()) |
1634 |
|
gtk_main_iteration(); |
1635 |
|
} |
1636 |
|
|
1637 |
|
static GtkWidget *app_submenu_create(appdata_t *appdata, |
1638 |
|
const submenu_t *submenu) { |
1639 |
|
|
1640 |
|
/* create a oridinary dialog box */ |
1641 |
|
GtkWidget *dialog = gtk_dialog_new(); |
1642 |
|
gtk_window_set_title(GTK_WINDOW(dialog), _(submenu->title)); |
1643 |
|
gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); |
1644 |
|
gtk_window_set_transient_for(GTK_WINDOW(dialog), |
1645 |
|
GTK_WINDOW(appdata->window)); |
1646 |
|
gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); |
1647 |
|
|
1648 |
|
GtkWidget *table = gtk_table_new(submenu->len/COLUMNS, COLUMNS, TRUE); |
1649 |
|
int x = 0, y = 0; |
1650 |
|
|
1651 |
|
const menu_entry_t *menu_entries = submenu->menu; |
1652 |
|
while(menu_entries->label) { |
1653 |
|
GtkWidget *button = NULL; |
1654 |
|
|
1655 |
|
button = hildon_button_new_with_text( |
1656 |
|
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
1657 |
|
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
1658 |
|
_(menu_entries->label), _(menu_entries->desc)); |
1659 |
|
|
1660 |
|
/* try to center both texts */ |
1661 |
|
hildon_button_set_title_alignment(HILDON_BUTTON(button), 0.5, 0.5); |
1662 |
|
hildon_button_set_value_alignment(HILDON_BUTTON(button), 0.5, 0.5); |
1663 |
|
|
1664 |
|
g_signal_connect(button, "clicked", |
1665 |
|
G_CALLBACK(on_submenu_entry_clicked), dialog); |
1666 |
|
|
1667 |
|
g_signal_connect(button, "clicked", |
1668 |
|
menu_entries->activate_cb, appdata); |
1669 |
|
|
1670 |
|
gtk_table_attach_defaults(GTK_TABLE(table), button, x, x+1, y, y+1); |
1671 |
|
|
1672 |
|
x++; |
1673 |
|
if(x == COLUMNS) { x = 0; y++; } |
1674 |
|
|
1675 |
|
menu_entries++; |
1676 |
|
} |
1677 |
|
|
1678 |
|
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table); |
1679 |
|
|
1680 |
|
return dialog; |
1681 |
|
} |
1682 |
|
|
1683 |
|
/* popup the dialog shaped submenu */ |
1684 |
|
static void submenu_popup(GtkWidget *menu) { |
1685 |
|
gtk_widget_show_all(menu); |
1686 |
|
gtk_dialog_run(GTK_DIALOG(menu)); |
1687 |
|
gtk_widget_hide(menu); |
1688 |
|
} |
1689 |
|
|
1690 |
|
static void submenu_cleanup(GtkWidget *menu) { |
1691 |
|
gtk_widget_destroy(menu); |
1692 |
|
} |
1693 |
|
|
1694 |
|
static const menu_entry_t submenu_export_entries[] = { |
1695 |
|
#ifdef ENABLE_MAEMO_MAPPER |
1696 |
|
{ "Export to Maemo Mapper" , "Save a Maemo Mapper POI file", |
1697 |
|
G_CALLBACK(cb_menu_export_mmpoi) }, |
1698 |
|
#endif |
1699 |
|
{ "Export Field Notes", "Save a Garmin Field Notes file", |
1700 |
|
G_CALLBACK(cb_menu_export_log) }, |
1701 |
|
{ "Export Garmin GPX", "Save modified waypoints in GPX file", |
1702 |
|
G_CALLBACK(cb_menu_export_garmin) }, |
1703 |
|
{ NULL, NULL, NULL } |
1704 |
|
}; |
1705 |
|
|
1706 |
|
static const submenu_t submenu_export = { |
1707 |
|
"Export", submenu_export_entries, |
1708 |
|
sizeof(submenu_export_entries)/sizeof(menu_entry_t)-1 |
1709 |
|
}; |
1710 |
|
|
1711 |
|
/* the export submenu */ |
1712 |
|
void on_export_clicked(GtkButton *button, appdata_t *appdata) { |
1713 |
|
if(!appdata->export_menu) |
1714 |
|
appdata->export_menu = app_submenu_create(appdata, &submenu_export); |
1715 |
|
|
1716 |
|
submenu_popup(appdata->export_menu); |
1717 |
|
} |
1718 |
|
|
1719 |
|
static const menu_entry_t submenu_tools_entries[] = { |
1720 |
|
{ "Geomath", "Geocoordinate calculation", |
1721 |
|
G_CALLBACK(cb_menu_geomath) }, |
1722 |
|
{ "Geotext", "Text analysis", |
1723 |
|
G_CALLBACK(cb_menu_geotext) }, |
1724 |
|
{ "Precise Position", "Calculate a precise GPS position", |
1725 |
|
G_CALLBACK(cb_menu_precpos) }, |
1726 |
|
{ NULL, NULL, NULL } |
1727 |
|
}; |
1728 |
|
|
1729 |
|
static const submenu_t submenu_tools = { |
1730 |
|
"Tools", submenu_tools_entries, |
1731 |
|
sizeof(submenu_tools_entries)/sizeof(menu_entry_t)-1 |
1732 |
|
}; |
1733 |
|
|
1734 |
|
/* the tools submenu */ |
1735 |
|
void on_tools_clicked(GtkButton *button, appdata_t *appdata) { |
1736 |
|
if(!appdata->tools_menu) |
1737 |
|
appdata->tools_menu = app_submenu_create(appdata, &submenu_tools); |
1738 |
|
|
1739 |
|
submenu_popup(appdata->tools_menu); |
1740 |
|
} |
1741 |
|
|
1742 |
|
HildonAppMenu *menu_create(appdata_t *appdata, int mode) { |
1743 |
|
GtkWidget *button; |
1744 |
|
HildonAppMenu *menu = HILDON_APP_MENU(hildon_app_menu_new()); |
1745 |
|
|
1746 |
|
/* ------- */ |
1747 |
|
button = gtk_button_new_with_label(_("About")); |
1748 |
|
g_signal_connect_after(button, "clicked", |
1749 |
|
G_CALLBACK(cb_menu_about), appdata); |
1750 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1751 |
|
|
1752 |
|
button = gtk_button_new_with_label(_("Settings")); |
1753 |
|
g_signal_connect_after(button, "clicked", G_CALLBACK(cb_menu_settings), |
1754 |
|
appdata); |
1755 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1756 |
|
|
1757 |
|
if(mode == MENU_GPXLIST) { |
1758 |
|
button = gtk_button_new_with_label(_("Import file")); |
1759 |
|
g_signal_connect_after(button, "clicked", |
1760 |
|
G_CALLBACK(cb_menu_add), appdata); |
1761 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1762 |
|
|
1763 |
|
button = gtk_button_new_with_label(_("Import directory")); |
1764 |
|
g_signal_connect_after(button, "clicked", |
1765 |
|
G_CALLBACK(cb_menu_adddir), appdata); |
1766 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1767 |
|
|
1768 |
|
button = gtk_button_new_with_label(_("Export")); |
1769 |
|
g_signal_connect_after(button, "clicked", |
1770 |
|
G_CALLBACK(on_export_clicked), appdata); |
1771 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1772 |
|
|
1773 |
|
button = gtk_button_new_with_label(_("Search")); |
1774 |
|
g_signal_connect_after(button, "clicked", |
1775 |
|
G_CALLBACK(cb_menu_search), appdata); |
1776 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1777 |
|
} |
1778 |
|
|
1779 |
|
button = gtk_button_new_with_label(_("Tools")); |
1780 |
|
g_signal_connect_after(button, "clicked", |
1781 |
|
G_CALLBACK(on_tools_clicked), appdata); |
1782 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1783 |
|
|
1784 |
|
#ifdef ENABLE_OSM_GPS_MAP |
1785 |
|
button = gtk_button_new_with_label(_("Map")); |
1786 |
|
g_signal_connect_after(button, "clicked", |
1787 |
|
G_CALLBACK(cb_menu_map), appdata); |
1788 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1789 |
|
#endif |
1790 |
|
|
1791 |
|
#ifdef HILDON_HELP |
1792 |
|
button = gtk_button_new_with_label(_("Help")); |
1793 |
|
g_signal_connect_after(button, "clicked", |
1794 |
|
G_CALLBACK(cb_menu_help), appdata); |
1795 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1796 |
|
#endif |
1797 |
|
|
1798 |
|
gtk_widget_show_all(GTK_WIDGET(menu)); |
1799 |
|
|
1800 |
|
return menu; |
1801 |
|
} |
1802 |
|
#else |
1803 |
|
|
1804 |
void menu_create(appdata_t *appdata) { |
void menu_create(appdata_t *appdata) { |
1805 |
GtkWidget *menu, *item; |
GtkWidget *menu, *item; |
1806 |
menu = gtk_menu_new(); |
menu = gtk_menu_new(); |
1807 |
|
|
1808 |
#ifdef USE_MAEMO |
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
1809 |
appdata->menu_import = |
appdata->menu_import = |
1810 |
#endif |
#endif |
1811 |
item = gtk_menu_item_new_with_label(_("Import")); |
item = gtk_menu_item_new_with_label(_("Import")); |
1813 |
GtkWidget *submenu = gtk_menu_new(); |
GtkWidget *submenu = gtk_menu_new(); |
1814 |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
1815 |
|
|
1816 |
item = gtk_menu_item_new_with_label( _("File...") ); |
item = gtk_menu_item_new_with_label( _("File") ); |
1817 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1818 |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_add), appdata); |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_add), appdata); |
1819 |
|
|
1820 |
item = gtk_menu_item_new_with_label( _("Directory...") ); |
item = gtk_menu_item_new_with_label( _("Directory") ); |
1821 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1822 |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_adddir), appdata); |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_adddir), appdata); |
1823 |
|
|
1835 |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_remove), appdata); |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_remove), appdata); |
1836 |
#endif |
#endif |
1837 |
|
|
1838 |
#ifdef USE_MAEMO |
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
1839 |
appdata->menu_export = |
appdata->menu_export = |
1840 |
#endif |
#endif |
1841 |
item = gtk_menu_item_new_with_label(_("Export")); |
item = gtk_menu_item_new_with_label(_("Export")); |
1843 |
submenu = gtk_menu_new(); |
submenu = gtk_menu_new(); |
1844 |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
1845 |
|
|
1846 |
#ifdef USE_MAEMO |
#ifdef ENABLE_MAEMO_MAPPER |
1847 |
item = gtk_menu_item_new_with_label( _("Maemo Mapper POI...") ); |
item = gtk_menu_item_new_with_label( _("Maemo Mapper POI") ); |
1848 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1849 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
1850 |
GTK_SIGNAL_FUNC(cb_menu_export_mmpoi), appdata); |
GTK_SIGNAL_FUNC(cb_menu_export_mmpoi), appdata); |
1851 |
#endif |
#endif |
1852 |
|
|
1853 |
item = gtk_menu_item_new_with_label( _("Garmin Field Notes...") ); |
item = gtk_menu_item_new_with_label( _("Garmin Field Notes") ); |
1854 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1855 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
1856 |
GTK_SIGNAL_FUNC(cb_menu_export_log), appdata); |
GTK_SIGNAL_FUNC(cb_menu_export_log), appdata); |
1857 |
|
|
1858 |
item = gtk_menu_item_new_with_label( _("Garmin GPX...") ); |
item = gtk_menu_item_new_with_label( _("Garmin GPX") ); |
1859 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1860 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
1861 |
GTK_SIGNAL_FUNC(cb_menu_export_garmin), appdata); |
GTK_SIGNAL_FUNC(cb_menu_export_garmin), appdata); |
1862 |
|
|
1863 |
#ifdef USE_MAEMO |
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
1864 |
appdata->menu_search = |
appdata->menu_search = |
1865 |
#endif |
#endif |
1866 |
item = gtk_menu_item_new_with_label( _("Search...") ); |
item = gtk_menu_item_new_with_label( _("Search") ); |
1867 |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
1868 |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_search), appdata); |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_search), appdata); |
1869 |
|
|
1870 |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
1871 |
|
|
|
#ifndef NO_COPY_N_PASTE |
|
1872 |
/* ----------- copy'n paste submenu ----------------- */ |
/* ----------- copy'n paste submenu ----------------- */ |
1873 |
appdata->clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); |
#ifndef NO_COPY_N_PASTE |
|
gtk_clipboard_set_can_store(appdata->clipboard, NULL, 0); |
|
|
|
|
1874 |
item = gtk_menu_item_new_with_label(_("Edit")); |
item = gtk_menu_item_new_with_label(_("Edit")); |
1875 |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
1876 |
submenu = gtk_menu_new(); |
submenu = gtk_menu_new(); |
1890 |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_paste), appdata); |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_paste), appdata); |
1891 |
#endif |
#endif |
1892 |
|
|
1893 |
item = gtk_menu_item_new_with_label( _("Settings...") ); |
item = gtk_menu_item_new_with_label( _("Settings") ); |
1894 |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
1895 |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_settings), |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_settings), |
1896 |
appdata); |
appdata); |
1897 |
|
|
1898 |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
1899 |
|
|
1900 |
|
#ifdef ENABLE_OSM_GPS_MAP |
1901 |
|
item = gtk_menu_item_new_with_label( _("Map") ); |
1902 |
|
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
1903 |
|
g_signal_connect(item, "activate", |
1904 |
|
GTK_SIGNAL_FUNC(cb_menu_map), appdata); |
1905 |
|
#endif |
1906 |
|
|
1907 |
item = gtk_menu_item_new_with_label(_("Tools")); |
item = gtk_menu_item_new_with_label(_("Tools")); |
1908 |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
1909 |
submenu = gtk_menu_new(); |
submenu = gtk_menu_new(); |
1910 |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
1911 |
|
|
1912 |
item = gtk_menu_item_new_with_label( _("Geomath...") ); |
item = gtk_menu_item_new_with_label( _("Geomath") ); |
1913 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1914 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
1915 |
GTK_SIGNAL_FUNC(cb_menu_geomath), appdata); |
GTK_SIGNAL_FUNC(cb_menu_geomath), appdata); |
1916 |
|
|
1917 |
item = gtk_menu_item_new_with_label( _("Geotext...") ); |
item = gtk_menu_item_new_with_label( _("Geotext") ); |
1918 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1919 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
1920 |
GTK_SIGNAL_FUNC(cb_menu_geotext), appdata); |
GTK_SIGNAL_FUNC(cb_menu_geotext), appdata); |
1921 |
|
|
1922 |
item = gtk_menu_item_new_with_label( _("Precise Position...") ); |
item = gtk_menu_item_new_with_label( _("Precise Position") ); |
1923 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1924 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
1925 |
GTK_SIGNAL_FUNC(cb_menu_precpos), appdata); |
GTK_SIGNAL_FUNC(cb_menu_precpos), appdata); |
1927 |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
1928 |
|
|
1929 |
#if defined(USE_MAEMO) && defined(HILDON_HELP) |
#if defined(USE_MAEMO) && defined(HILDON_HELP) |
1930 |
item = gtk_menu_item_new_with_label( _("Help...") ); |
item = gtk_menu_item_new_with_label( _("Help") ); |
1931 |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
1932 |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_help), appdata); |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_help), appdata); |
1933 |
#endif |
#endif |
1934 |
|
|
1935 |
item = gtk_menu_item_new_with_label( _("About...") ); |
item = gtk_menu_item_new_with_label( _("About") ); |
1936 |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
1937 |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_about), appdata); |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_about), appdata); |
1938 |
|
|
1958 |
gtk_box_pack_start(GTK_BOX(appdata->vbox), menu_bar, 0, 0, 0); |
gtk_box_pack_start(GTK_BOX(appdata->vbox), menu_bar, 0, 0, 0); |
1959 |
#endif |
#endif |
1960 |
} |
} |
1961 |
|
#endif |
1962 |
|
|
1963 |
/********************* end of menu **********************/ |
/********************* end of menu **********************/ |
1964 |
|
|
1968 |
if(appdata->image_path) free(appdata->image_path); |
if(appdata->image_path) free(appdata->image_path); |
1969 |
if(appdata->search_str) free(appdata->search_str); |
if(appdata->search_str) free(appdata->search_str); |
1970 |
|
|
1971 |
|
#ifdef USE_STACKABLE_WINDOW |
1972 |
|
if(appdata->export_menu) submenu_cleanup(appdata->export_menu); |
1973 |
|
if(appdata->tools_menu) submenu_cleanup(appdata->tools_menu); |
1974 |
|
#endif |
1975 |
|
|
1976 |
gnome_vfs_shutdown(); |
gnome_vfs_shutdown(); |
1977 |
icons_free(); |
icons_free(); |
1978 |
gps_release(appdata); |
gps_release(appdata); |
2001 |
puts("everything is gone"); |
puts("everything is gone"); |
2002 |
} |
} |
2003 |
|
|
2004 |
void on_window_destroy (GtkWidget *widget, gpointer data) { |
static void on_window_destroy (GtkWidget *widget, gpointer data) { |
2005 |
appdata_t *appdata = (appdata_t*)data; |
appdata_t *appdata = (appdata_t*)data; |
2006 |
|
|
2007 |
gconf_save_state(appdata); |
gconf_save_state(appdata); |
2010 |
} |
} |
2011 |
|
|
2012 |
gboolean on_window_key_press(GtkWidget *widget, |
gboolean on_window_key_press(GtkWidget *widget, |
2013 |
GdkEventKey *event, gpointer data) { |
GdkEventKey *event, appdata_t *appdata) { |
|
appdata_t *appdata = (appdata_t*)data; |
|
2014 |
int handled = FALSE; |
int handled = FALSE; |
2015 |
|
|
2016 |
// printf("key event %d\n", event->keyval); |
// printf("key event %d\n", event->keyval); |
2018 |
switch(event->keyval) { |
switch(event->keyval) { |
2019 |
#ifdef USE_MAEMO |
#ifdef USE_MAEMO |
2020 |
|
|
|
#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 |
|
|
|
|
2021 |
#ifdef HILDON_HARDKEY_INCREASE |
#ifdef HILDON_HARDKEY_INCREASE |
2022 |
case HILDON_HARDKEY_INCREASE: |
case HILDON_HARDKEY_INCREASE: |
2023 |
html_zoom(appdata, TRUE); |
html_zoom(appdata, TRUE); |
2064 |
return handled; |
return handled; |
2065 |
} |
} |
2066 |
|
|
2067 |
#ifdef USE_BREAD_CRUMB_TRAIL |
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
2068 |
typedef struct { |
typedef struct { |
2069 |
int level; |
int level; |
2070 |
appdata_t *appdata; |
appdata_t *appdata; |
2156 |
|
|
2157 |
gtk_widget_show_all(crumb->appdata->vbox); |
gtk_widget_show_all(crumb->appdata->vbox); |
2158 |
g_free(data); |
g_free(data); |
2159 |
|
|
2160 |
|
#ifdef ENABLE_OSM_GPS_MAP |
2161 |
|
map_update(crumb->appdata); |
2162 |
|
#endif |
2163 |
} |
} |
2164 |
|
|
2165 |
static void crumb_add(appdata_t *appdata, char *name, int level, |
static void crumb_add(appdata_t *appdata, char *name, int level, |
2200 |
#endif |
#endif |
2201 |
} |
} |
2202 |
|
|
2203 |
|
#ifdef USE_BREAD_CRUMB_TRAIL |
2204 |
hildon_bread_crumb_trail_push_text(HILDON_BREAD_CRUMB_TRAIL(appdata->bct), |
hildon_bread_crumb_trail_push_text(HILDON_BREAD_CRUMB_TRAIL(appdata->bct), |
2205 |
name, crumb, (GDestroyNotify)crumb_back); |
name, crumb, (GDestroyNotify)crumb_back); |
2206 |
|
#else |
2207 |
|
bct_push_text(appdata->bct, name, crumb, (GDestroyNotify)crumb_back); |
2208 |
|
#endif |
2209 |
|
|
2210 |
|
#ifdef ENABLE_OSM_GPS_MAP |
2211 |
|
map_update(appdata); |
2212 |
|
#endif |
2213 |
} |
} |
2214 |
#endif // USE_BREAD_CRUMB_TRAIL |
#endif // USE_BREAD_CRUMB_TRAIL |
2215 |
|
|
2216 |
void main_after_settings_redraw(appdata_t *appdata, int flags) { |
void main_after_settings_redraw(appdata_t *appdata, int flags) { |
2217 |
#ifndef USE_MAEMO |
printf("main after settings redraw\n"); |
2218 |
// in non-maemo setup this can only affect the main screen as |
|
2219 |
// the menu is blocked while a dialog is open. also the main |
if(!appdata->cur_view) { |
2220 |
// screen is always present |
printf("no active view\n"); |
2221 |
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); |
|
2222 |
} |
} |
2223 |
#else |
|
2224 |
/* 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 */ |
2225 |
/* need to be redrawn */ |
/* need to be redrawn */ |
2226 |
if(appdata->cur_cache) { |
if(appdata->cur_cache) { |
2244 |
} |
} |
2245 |
|
|
2246 |
if(redraw) { |
if(redraw) { |
2247 |
gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
GtkWidget *container = appdata->vbox; |
2248 |
|
|
2249 |
|
#ifdef USE_STACKABLE_WINDOW |
2250 |
|
HildonWindowStack *stack = hildon_window_stack_get_default(); |
2251 |
|
container = hildon_window_stack_peek(stack); |
2252 |
|
#endif |
2253 |
|
|
2254 |
|
gtk_container_remove(GTK_CONTAINER(container), appdata->cur_view); |
2255 |
switch(redraw) { |
switch(redraw) { |
2256 |
case 1: |
case 1: |
2257 |
appdata->cur_view = cachelist_create(appdata, |
appdata->cur_view = cachelist_create(appdata, |
2266 |
break; |
break; |
2267 |
} |
} |
2268 |
|
|
2269 |
gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view); |
#ifdef USE_STACKABLE_WINDOW |
2270 |
gtk_widget_show_all(appdata->vbox); |
if(container != appdata->vbox) |
2271 |
} |
gtk_container_add(GTK_CONTAINER(container), appdata->cur_view); |
2272 |
|
else |
2273 |
#endif |
#endif |
2274 |
|
gtk_box_pack_start_defaults(GTK_BOX(container), appdata->cur_view); |
2275 |
|
|
2276 |
|
gtk_widget_show_all(container); |
2277 |
|
} |
2278 |
} |
} |
2279 |
|
|
2280 |
int main(int argc, char *argv[]) { |
int main(int argc, char *argv[]) { |
2303 |
fprintf(stderr, "error initiating osso context\n"); |
fprintf(stderr, "error initiating osso context\n"); |
2304 |
} |
} |
2305 |
|
|
2306 |
|
#ifdef ENABLE_MAEMO_MAPPER |
2307 |
dbus_register(&appdata); |
dbus_register(&appdata); |
2308 |
#endif |
#endif |
2309 |
|
#endif |
2310 |
|
|
2311 |
icons_init(); |
icons_init(); |
2312 |
|
|
2330 |
/* Create a Window. */ |
/* Create a Window. */ |
2331 |
appdata.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
appdata.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
2332 |
/* Set a decent default size for the window. */ |
/* Set a decent default size for the window. */ |
2333 |
gtk_window_set_default_size(GTK_WINDOW(appdata.window), 500, 300); |
gtk_window_set_default_size(GTK_WINDOW(appdata.window), 640, 480); |
2334 |
#endif |
#endif |
2335 |
|
|
2336 |
|
#if MAEMO_VERSION_MAJOR == 5 |
2337 |
gtk_window_set_title(GTK_WINDOW(appdata.window), "GPXView"); |
gtk_window_set_title(GTK_WINDOW(appdata.window), "GPXView"); |
2338 |
|
#endif |
2339 |
|
|
2340 |
g_signal_connect(G_OBJECT(appdata.window), "destroy", |
g_signal_connect(G_OBJECT(appdata.window), "destroy", |
2341 |
G_CALLBACK(on_window_destroy), &appdata); |
G_CALLBACK(on_window_destroy), &appdata); |
2342 |
|
|
2343 |
g_signal_connect(G_OBJECT(appdata.window), "key_press_event", |
g_signal_connect(G_OBJECT(appdata.window), "key_press_event", |
2344 |
G_CALLBACK(on_window_key_press), &appdata); |
G_CALLBACK(on_window_key_press), &appdata); |
2345 |
|
|
2346 |
|
/* prepare clipboard */ |
2347 |
|
appdata.clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); |
2348 |
|
gtk_clipboard_set_can_store(appdata.clipboard, NULL, 0); |
2349 |
|
|
2350 |
appdata.vbox = gtk_vbox_new(FALSE, 2); |
appdata.vbox = gtk_vbox_new(FALSE, 2); |
2351 |
gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox); |
gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox); |
2352 |
|
#ifndef USE_STACKABLE_WINDOW |
2353 |
menu_create(&appdata); |
menu_create(&appdata); |
2354 |
|
#else |
2355 |
|
hildon_window_set_app_menu(HILDON_WINDOW(appdata.window), |
2356 |
|
menu_create(&appdata, MENU_GPXLIST)); |
2357 |
|
#endif |
2358 |
|
|
2359 |
#ifdef USE_BREAD_CRUMB_TRAIL |
#ifdef USE_BREAD_CRUMB_TRAIL |
2360 |
appdata.bct = hildon_bread_crumb_trail_new(); |
appdata.bct = hildon_bread_crumb_trail_new(); |
2362 |
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); |
2363 |
|
|
2364 |
hildon_bread_crumb_trail_clear(HILDON_BREAD_CRUMB_TRAIL(appdata.bct)); |
hildon_bread_crumb_trail_clear(HILDON_BREAD_CRUMB_TRAIL(appdata.bct)); |
2365 |
|
#else |
2366 |
|
#ifdef BCT |
2367 |
|
/* on non-hildon machines we use some custom made breadcrumbtrail */ |
2368 |
|
/* replacement */ |
2369 |
|
appdata.bct = bct_new(); |
2370 |
|
gtk_box_pack_start(GTK_BOX(appdata.vbox), appdata.bct, FALSE,FALSE,0); |
2371 |
|
#endif |
2372 |
|
#endif |
2373 |
|
|
2374 |
|
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
2375 |
crumb_add(&appdata, "GPX", CRUMB_GPXLIST, NULL); |
crumb_add(&appdata, "GPX", CRUMB_GPXLIST, NULL); |
2376 |
#endif |
#endif |
2377 |
|
|