19 |
#include <string.h> |
#include <string.h> |
20 |
#include <math.h> |
#include <math.h> |
21 |
|
|
22 |
|
#include <curl/curl.h> |
23 |
|
|
24 |
#include <time.h> |
#include <time.h> |
25 |
#include <sys/time.h> |
#include <sys/time.h> |
26 |
|
|
31 |
|
|
32 |
#ifdef USE_MAEMO |
#ifdef USE_MAEMO |
33 |
#include <hildon/hildon-banner.h> |
#include <hildon/hildon-banner.h> |
34 |
|
#if MAEMO_VERSION_MAJOR >= 5 |
35 |
|
#include <hildon/hildon-note.h> |
36 |
|
#endif |
37 |
#endif |
#endif |
38 |
|
|
39 |
#include <locale.h> |
#include <locale.h> |
40 |
|
|
41 |
extern char *strcasestr (__const char *__haystack, __const char *__needle); |
extern char *strcasestr (__const char *__haystack, __const char *__needle); |
42 |
|
|
43 |
#ifdef USE_BREAD_CRUMB_TRAIL |
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
44 |
static void crumb_add(appdata_t *appdata, char *name, int level, |
static void crumb_add(appdata_t *appdata, char *name, int level, |
45 |
gpointer user_data); |
gpointer user_data); |
46 |
|
|
97 |
} |
} |
98 |
} |
} |
99 |
|
|
100 |
|
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
101 |
GtkWidget *dialog = gtk_message_dialog_new( |
GtkWidget *dialog = gtk_message_dialog_new( |
102 |
GTK_WINDOW(NULL), |
GTK_WINDOW(NULL), |
103 |
GTK_DIALOG_DESTROY_WITH_PARENT, |
GTK_DIALOG_DESTROY_WITH_PARENT, |
104 |
GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, |
GTK_MESSAGE_ERROR, |
105 |
buf); |
GTK_BUTTONS_CLOSE, buf); |
106 |
|
|
107 |
gtk_window_set_title(GTK_WINDOW(dialog), _("ERROR")); |
gtk_window_set_title(GTK_WINDOW(dialog), _("ERROR")); |
108 |
|
#else |
109 |
|
GtkWidget *dialog = |
110 |
|
hildon_note_new_information(GTK_WINDOW(NULL), buf); |
111 |
|
#endif |
112 |
|
|
113 |
gtk_dialog_run(GTK_DIALOG(dialog)); |
gtk_dialog_run(GTK_DIALOG(dialog)); |
114 |
gtk_widget_destroy(dialog); |
gtk_widget_destroy(dialog); |
148 |
gtk_widget_show_all (GTK_WIDGET(dialog)); |
gtk_widget_show_all (GTK_WIDGET(dialog)); |
149 |
if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_FM_OK) { |
if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_FM_OK) { |
150 |
char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); |
char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); |
151 |
|
|
152 |
|
if(filename) { |
153 |
|
gpx_dialog_t *dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window)); |
154 |
|
|
155 |
gpx_dialog_t *dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window)); |
if(!whole_dir) |
156 |
|
gpx = gpx_parse(dialog, filename); |
157 |
if(!whole_dir) |
else { |
158 |
gpx = gpx_parse(dialog, filename); |
/* cur trailing '/' if present */ |
159 |
else { |
if(strlastchr(filename) == '/') |
160 |
/* cur trailing '/' if present */ |
filename[strlen(filename)] = 0; |
161 |
if(strlastchr(filename) == '/') |
|
162 |
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 = '/'; |
|
163 |
} |
} |
164 |
|
|
165 |
|
gpx_busy_dialog_destroy(dialog); |
166 |
|
|
167 |
|
/* save path if gpx was successfully loaded */ |
168 |
|
if(gpx) { |
169 |
|
char *r = strrchr(filename, '/'); |
170 |
|
|
171 |
|
/* there is a delimiter, use everything left of it as path */ |
172 |
|
if(r && !whole_dir) { |
173 |
|
*r = 0; |
174 |
|
if(appdata->path) free(appdata->path); |
175 |
|
appdata->path = strdup(filename); |
176 |
|
/* restore path ... just in case ... */ |
177 |
|
*r = '/'; |
178 |
|
} |
179 |
|
|
180 |
|
if(whole_dir) |
181 |
|
appdata->path = strdup(filename); |
182 |
|
} else |
183 |
|
errorf(_("Load error")); |
184 |
|
|
185 |
if(whole_dir) |
g_free (filename); |
186 |
appdata->path = strdup(filename); |
} else { |
187 |
|
#ifndef USE_MAEMO |
188 |
|
errorf(_("Error accessing the file.")); |
189 |
|
#else |
190 |
|
errorf(_("Error accessing the file. This may happen if the file " |
191 |
|
"resides on a remote file system. Please copy the file onto " |
192 |
|
"the device (e.g. onto the memory card) and try again.")); |
193 |
|
#endif |
194 |
} |
} |
|
|
|
|
g_free (filename); |
|
195 |
} |
} |
196 |
|
|
197 |
gtk_widget_destroy (dialog); |
gtk_widget_destroy (dialog); |
215 |
CACHELIST_NUM_COLS |
CACHELIST_NUM_COLS |
216 |
} ; |
} ; |
217 |
|
|
218 |
void cachelist_view_onRowActivated(GtkTreeView *treeview, |
void cachelist_goto_cache(appdata_t *appdata, cache_t *cache) { |
219 |
|
#if !defined(USE_BREAD_CRUMB_TRAIL) && !defined(BCT) |
220 |
|
cache_dialog(appdata, cache); |
221 |
|
#else |
222 |
|
gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
223 |
|
appdata->cur_view = cache_view(appdata, cache); |
224 |
|
gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view); |
225 |
|
gtk_widget_show_all(appdata->vbox); |
226 |
|
|
227 |
|
crumb_add(appdata, cache->name, CRUMB_CACHE, cache); |
228 |
|
#endif |
229 |
|
} |
230 |
|
|
231 |
|
static void cachelist_view_onRowActivated(GtkTreeView *treeview, |
232 |
GtkTreePath *path, |
GtkTreePath *path, |
233 |
GtkTreeViewColumn *col, |
GtkTreeViewColumn *col, |
234 |
gpointer userdata) { |
gpointer userdata) { |
236 |
GtkTreeIter iter; |
GtkTreeIter iter; |
237 |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
238 |
|
|
239 |
|
#ifdef USE_MAEMO |
240 |
|
/* check if a cache is already selected and ignore click if yes */ |
241 |
|
/* (was probably a double click) */ |
242 |
|
if(appdata->cur_cache) return; |
243 |
|
#endif |
244 |
|
|
245 |
if(gtk_tree_model_get_iter(model, &iter, path)) { |
if(gtk_tree_model_get_iter(model, &iter, path)) { |
246 |
cache_t *cache; |
cache_t *cache; |
247 |
gtk_tree_model_get(model, &iter, CACHELIST_COL_DATA, &cache, -1); |
gtk_tree_model_get(model, &iter, CACHELIST_COL_DATA, &cache, -1); |
248 |
#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 |
|
249 |
} |
} |
250 |
} |
} |
251 |
|
|
288 |
cache_t *sel_cache); |
cache_t *sel_cache); |
289 |
|
|
290 |
void cachelist_redraw(appdata_t *appdata) { |
void cachelist_redraw(appdata_t *appdata) { |
|
#ifndef USE_MAEMO |
|
|
// gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
|
|
// appdata->cur_view = gpxlist_create_view_and_model(appdata, NULL); |
|
|
// gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view); |
|
|
// gtk_widget_show_all(appdata->vbox); |
|
|
#else |
|
|
|
|
291 |
if(!appdata->cur_view) { |
if(!appdata->cur_view) { |
292 |
printf("cachelist redraw: no active view\n"); |
printf("cachelist redraw: no active view\n"); |
293 |
return; |
return; |
305 |
if(redraw) { |
if(redraw) { |
306 |
GtkWidget *container = appdata->vbox; |
GtkWidget *container = appdata->vbox; |
307 |
|
|
|
printf("redraw %d\n", redraw); |
|
|
|
|
308 |
#ifdef USE_STACKABLE_WINDOW |
#ifdef USE_STACKABLE_WINDOW |
309 |
HildonWindowStack *stack = hildon_window_stack_get_default(); |
HildonWindowStack *stack = hildon_window_stack_get_default(); |
310 |
container = hildon_window_stack_peek(stack); |
container = hildon_window_stack_peek(stack); |
331 |
|
|
332 |
gtk_widget_show_all(container); |
gtk_widget_show_all(container); |
333 |
} |
} |
|
#endif |
|
334 |
} |
} |
335 |
|
|
336 |
|
|
338 |
|
|
339 |
printf("cachelist timer fired!\n"); |
printf("cachelist timer fired!\n"); |
340 |
|
|
|
#ifdef USE_MAEMO |
|
341 |
appdata_t *appdata = (appdata_t*)data; |
appdata_t *appdata = (appdata_t*)data; |
342 |
|
|
343 |
if(appdata->cur_cache) |
if(appdata->cur_cache) |
344 |
return TRUE; |
return TRUE; |
345 |
|
|
346 |
|
#ifdef USE_MAEMO |
347 |
if(appdata->cachelist_disable_screensaver) |
if(appdata->cachelist_disable_screensaver) |
348 |
if (osso_display_blanking_pause(appdata->osso_context) != OSSO_OK) |
if (osso_display_blanking_pause(appdata->osso_context) != OSSO_OK) |
349 |
fprintf(stderr, "error with display blank\n"); |
fprintf(stderr, "error with display blank\n"); |
350 |
|
#endif |
351 |
|
|
352 |
if(appdata->cachelist_update) |
if(appdata->cachelist_update) |
353 |
cachelist_redraw(appdata); |
cachelist_redraw(appdata); |
|
#endif |
|
354 |
|
|
355 |
return TRUE; |
return TRUE; |
356 |
} |
} |
597 |
} |
} |
598 |
appdata->cur_gpx = NULL; |
appdata->cur_gpx = NULL; |
599 |
|
|
600 |
|
#ifdef ENABLE_OSM_GPS_MAP |
601 |
|
map_update(appdata); |
602 |
|
#endif |
603 |
|
|
604 |
/* restore cur_view */ |
/* restore cur_view */ |
605 |
appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view"); |
appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view"); |
606 |
} |
} |
612 |
g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view); |
g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view); |
613 |
|
|
614 |
appdata->cur_gpx = gpx; |
appdata->cur_gpx = gpx; |
615 |
char *title = g_strdup_printf("GPXView - %s", gpx->name); |
char *title = g_strdup_printf("%s - GPXView", gpx->name); |
616 |
gtk_window_set_title(GTK_WINDOW(window), title); |
gtk_window_set_title(GTK_WINDOW(window), title); |
617 |
g_free(title); |
g_free(title); |
618 |
|
|
627 |
G_CALLBACK(on_cachelist_destroy), appdata); |
G_CALLBACK(on_cachelist_destroy), appdata); |
628 |
|
|
629 |
gtk_widget_show_all(window); |
gtk_widget_show_all(window); |
630 |
|
|
631 |
|
#ifdef ENABLE_OSM_GPS_MAP |
632 |
|
map_update(appdata); |
633 |
|
#endif |
634 |
} |
} |
635 |
#endif |
#endif |
636 |
#endif |
#endif |
734 |
gconf_save_closed_name(appdata, gpx->filename, gpx->name); |
gconf_save_closed_name(appdata, gpx->filename, gpx->name); |
735 |
} |
} |
736 |
|
|
737 |
|
void gpxlist_goto_cachelist(appdata_t *appdata, gpx_t *gpx) { |
738 |
|
#if !defined(USE_BREAD_CRUMB_TRAIL) && !defined(BCT) |
739 |
|
#ifdef USE_STACKABLE_WINDOW |
740 |
|
if(!appdata->cur_gpx) |
741 |
|
#endif |
742 |
|
cachelist_dialog(appdata, gpx); |
743 |
|
#ifdef USE_STACKABLE_WINDOW |
744 |
|
else |
745 |
|
printf("selected gpx, but cachelist window already present\n"); |
746 |
|
#endif |
747 |
|
#else |
748 |
|
gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
749 |
|
appdata->cur_view = cachelist_create(appdata, gpx, NULL); |
750 |
|
gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view); |
751 |
|
gtk_widget_show_all(appdata->vbox); |
752 |
|
|
753 |
|
crumb_add(appdata, gpx->name, CRUMB_CACHELIST, gpx); |
754 |
|
#endif |
755 |
|
} |
756 |
|
|
757 |
static void gpxlist_view_onRowActivated(GtkTreeView *treeview, |
static void gpxlist_view_onRowActivated(GtkTreeView *treeview, |
758 |
GtkTreePath *path, |
GtkTreePath *path, |
759 |
GtkTreeViewColumn *col, |
GtkTreeViewColumn *col, |
762 |
GtkTreeIter iter; |
GtkTreeIter iter; |
763 |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
764 |
|
|
765 |
|
#ifdef USE_MAEMO |
766 |
|
/* check if a cache is already selected and ignore click if yes */ |
767 |
|
/* (was probably a double click) */ |
768 |
|
if(appdata->cur_gpx) return; |
769 |
|
#endif |
770 |
|
|
771 |
if (gtk_tree_model_get_iter(model, &iter, path)) { |
if (gtk_tree_model_get_iter(model, &iter, path)) { |
772 |
gpx_t *gpx; |
gpx_t *gpx; |
773 |
gtk_tree_model_get(model, &iter, GPXLIST_COL_DATA, &gpx, -1); |
gtk_tree_model_get(model, &iter, GPXLIST_COL_DATA, &gpx, -1); |
780 |
if(col_name && !strcmp(col_name, "Del")) { |
if(col_name && !strcmp(col_name, "Del")) { |
781 |
printf("clicked delete\n"); |
printf("clicked delete\n"); |
782 |
|
|
783 |
|
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
784 |
/* ask user what he wants */ |
/* ask user what he wants */ |
785 |
GtkWidget *dialog = gtk_message_dialog_new( |
GtkWidget *dialog = gtk_message_dialog_new( |
786 |
GTK_WINDOW(appdata->window), |
GTK_WINDOW(appdata->window), |
787 |
GTK_DIALOG_DESTROY_WITH_PARENT, |
GTK_DIALOG_DESTROY_WITH_PARENT, |
788 |
GTK_MESSAGE_QUESTION, GTK_BUTTONS_CANCEL, |
GTK_MESSAGE_QUESTION, |
789 |
|
GTK_BUTTONS_CANCEL, |
790 |
_("Do you want to close this entry only or do " |
_("Do you want to close this entry only or do " |
791 |
"you want to remove it completely from the list?")); |
"you want to remove it completely from the list?")); |
792 |
|
|
795 |
_("Close"), 2, |
_("Close"), 2, |
796 |
NULL); |
NULL); |
797 |
|
|
798 |
|
gtk_window_set_title(GTK_WINDOW(dialog), _("Close or remove entry?")); |
799 |
|
#else |
800 |
|
GtkWidget *dialog = |
801 |
|
hildon_note_new_confirmation_add_buttons(GTK_WINDOW(appdata->window), |
802 |
|
_("Do you want to close this entry only or do " |
803 |
|
"you want to remove it completely from the list?"), |
804 |
|
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, |
805 |
|
_("Remove"), 1, |
806 |
|
_("Close"), 2, |
807 |
|
NULL); |
808 |
|
#endif |
809 |
|
|
810 |
if(gpx->closed) |
if(gpx->closed) |
811 |
gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), 2, FALSE); |
gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), 2, FALSE); |
812 |
|
|
|
gtk_window_set_title(GTK_WINDOW(dialog), _("Remove entry?")); |
|
|
|
|
813 |
/* set the active flag again if the user answered "no" */ |
/* set the active flag again if the user answered "no" */ |
814 |
switch(gtk_dialog_run(GTK_DIALOG(dialog))) { |
switch(gtk_dialog_run(GTK_DIALOG(dialog))) { |
815 |
|
|
877 |
|
|
878 |
gpx_busy_dialog_destroy(dialog); |
gpx_busy_dialog_destroy(dialog); |
879 |
} |
} |
880 |
#ifndef USE_BREAD_CRUMB_TRAIL |
|
881 |
#ifdef USE_STACKABLE_WINDOW |
gpxlist_goto_cachelist(appdata, gpx); |
|
if(!appdata->cur_gpx) |
|
|
#endif |
|
|
cachelist_dialog(appdata, gpx); |
|
|
#ifdef USE_STACKABLE_WINDOW |
|
|
else |
|
|
printf("selected gpx, but cachelist window already present\n"); |
|
|
#endif |
|
|
#else |
|
|
gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
|
|
appdata->cur_view = cachelist_create(appdata, gpx, NULL); |
|
|
gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view); |
|
|
gtk_widget_show_all(appdata->vbox); |
|
|
|
|
|
crumb_add(appdata, gpx->name, CRUMB_CACHELIST, gpx); |
|
|
#endif |
|
882 |
} |
} |
883 |
} |
} |
884 |
} |
} |
933 |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview), |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview), |
934 |
-1, "Icon", renderer, |
-1, "Icon", renderer, |
935 |
"pixbuf", GPXLIST_COL_ICON, |
"pixbuf", GPXLIST_COL_ICON, |
936 |
// "sensitive", GPXLIST_COL_OPEN, |
#ifdef USE_PANNABLE_AREA |
937 |
|
/* at least one entry needs to be sensitive. */ |
938 |
|
/* This is the delete icon if the PANNABLE_AREA is used */ |
939 |
|
"sensitive", GPXLIST_COL_OPEN, |
940 |
|
#endif |
941 |
NULL); |
NULL); |
942 |
|
|
943 |
/* --- "FileName" column --- */ |
/* --- "FileName" column --- */ |
993 |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview), |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview), |
994 |
-1, "Del", renderer, |
-1, "Del", renderer, |
995 |
"pixbuf", GPXLIST_COL_DELETE, |
"pixbuf", GPXLIST_COL_DELETE, |
996 |
"sensitive", GPXLIST_COL_OPEN, |
// "sensitive", GPXLIST_COL_OPEN, |
997 |
NULL); |
NULL); |
998 |
#endif |
#endif |
999 |
|
|
1013 |
GtkTreeIter iter; |
GtkTreeIter iter; |
1014 |
gtk_list_store_append(appdata->gpxstore, &iter); |
gtk_list_store_append(appdata->gpxstore, &iter); |
1015 |
gpxlist_set(appdata->gpxstore, &iter, gpx); |
gpxlist_set(appdata->gpxstore, &iter, gpx); |
1016 |
|
|
1017 |
if(gpx == sel_gpx) { |
if(gpx == sel_gpx) { |
1018 |
sel_iter = iter; |
sel_iter = iter; |
1019 |
sel_iter_valid = TRUE; |
sel_iter_valid = TRUE; |
1073 |
|
|
1074 |
/******************** begin of menu *********************/ |
/******************** begin of menu *********************/ |
1075 |
|
|
1076 |
|
typedef struct { |
1077 |
|
appdata_t *appdata; |
1078 |
|
GtkWidget *dialog; |
1079 |
|
} about_context_t; |
1080 |
|
|
1081 |
|
#ifdef ENABLE_BROWSER_INTERFACE |
1082 |
|
void on_paypal_button_clicked(GtkButton *button, about_context_t *context) { |
1083 |
|
gtk_dialog_response(GTK_DIALOG(context->dialog), GTK_RESPONSE_ACCEPT); |
1084 |
|
browser_url(context->appdata, |
1085 |
|
"https://www.paypal.com/cgi-bin/webscr" |
1086 |
|
"?cmd=_s-xclick&hosted_button_id=7400558"); |
1087 |
|
} |
1088 |
|
#endif |
1089 |
|
|
1090 |
static void |
static void |
1091 |
cb_menu_about(GtkWidget *window, gpointer data) { |
cb_menu_about(GtkWidget *window, gpointer data) { |
1092 |
GtkAboutDialog *about = GTK_ABOUT_DIALOG(gtk_about_dialog_new()); |
about_context_t context; |
1093 |
|
|
1094 |
gtk_about_dialog_set_name(about, "GPXView"); |
context.appdata = (appdata_t *)data; |
1095 |
gtk_about_dialog_set_version(about, VERSION); |
|
1096 |
gtk_about_dialog_set_copyright(about, |
#ifdef ENABLE_LIBLOCATION |
1097 |
_("GPXView (c) 2008 by\n" |
char *uses = "uses liblocation"; |
1098 |
"Till Harbaum <till@harbaum.org>\n" |
#elif defined(ENABLE_GPSBT) |
1099 |
"Geocaching.com: Tantil")); |
char *uses = "uses gpsbt and gpsd"; |
1100 |
|
#else |
1101 |
gtk_about_dialog_set_website(about, |
char *uses = "uses gpsd"; |
1102 |
_("http://www.harbaum.org/till/maemo")); |
#endif |
1103 |
|
|
1104 |
gtk_about_dialog_set_comments(about, |
const gchar *authors[] = { |
1105 |
_("Geocaching.com GPX file viewer")); |
"Till Harbaum <till@harbaum.org>", |
1106 |
|
"John Stowers <john.stowers@gmail.com>", |
1107 |
gtk_widget_show_all(GTK_WIDGET(about)); |
"GCVote: Guido Wegener <guido.wegener@gmx.de>", |
1108 |
gtk_dialog_run(GTK_DIALOG(about)); |
NULL }; |
1109 |
gtk_widget_destroy(GTK_WIDGET(about)); |
|
1110 |
|
context.dialog = g_object_new(GTK_TYPE_ABOUT_DIALOG, |
1111 |
|
"name", "GPXView", |
1112 |
|
"version", VERSION, |
1113 |
|
"copyright", _("Copyright 2008-2009"), |
1114 |
|
"authors", authors, |
1115 |
|
"website", _("http://www.harbaum.org/till/maemo"), |
1116 |
|
"comments", _(uses), |
1117 |
|
NULL); |
1118 |
|
|
1119 |
|
#ifdef ENABLE_BROWSER_INTERFACE |
1120 |
|
/* add a way to donate to the project */ |
1121 |
|
GtkWidget *alignment = gtk_alignment_new(0.5, 0, 0, 0); |
1122 |
|
|
1123 |
|
GtkWidget *hbox = gtk_hbox_new(FALSE, 8); |
1124 |
|
gtk_box_pack_start(GTK_BOX(hbox), |
1125 |
|
gtk_label_new(_("Do you like GPXView?")), |
1126 |
|
FALSE, FALSE, 0); |
1127 |
|
|
1128 |
|
GtkWidget *button = gtk_button_new(); |
1129 |
|
gtk_button_set_image(GTK_BUTTON(button), |
1130 |
|
icon_get_widget(ICON_MISC, 8)); |
1131 |
|
gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
1132 |
|
g_signal_connect(button, "clicked", |
1133 |
|
G_CALLBACK(on_paypal_button_clicked), &context); |
1134 |
|
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
1135 |
|
|
1136 |
|
gtk_container_add(GTK_CONTAINER(alignment), hbox); |
1137 |
|
gtk_box_pack_start_defaults(GTK_BOX((GTK_DIALOG(context.dialog))->vbox), |
1138 |
|
alignment); |
1139 |
|
|
1140 |
|
gtk_widget_show_all(alignment); |
1141 |
|
#endif |
1142 |
|
|
1143 |
|
gtk_dialog_run(GTK_DIALOG(context.dialog)); |
1144 |
|
gtk_widget_destroy(context.dialog); |
1145 |
} |
} |
1146 |
|
|
1147 |
#if defined(USE_MAEMO) && defined(HILDON_HELP) |
#if defined(USE_MAEMO) && defined(HILDON_HELP) |
1313 |
else if(cache->long_description && (what & SEARCH_DESC) && |
else if(cache->long_description && (what & SEARCH_DESC) && |
1314 |
strcasestr(cache->long_description, phrase)) |
strcasestr(cache->long_description, phrase)) |
1315 |
hit = 1; |
hit = 1; |
1316 |
else if(cache->owner && (what & SEARCH_OWNER) && |
else if(cache->owner && cache->owner->name && (what & SEARCH_OWNER) && |
1317 |
strcasestr(cache->owner, phrase)) |
strcasestr(cache->owner->name, phrase)) |
1318 |
hit = 1; |
hit = 1; |
1319 |
|
|
1320 |
if(hit) { |
if(hit) { |
1490 |
|
|
1491 |
printf("Search for %s (flags = %x)...\n", p, appdata->search); |
printf("Search for %s (flags = %x)...\n", p, appdata->search); |
1492 |
|
|
1493 |
#ifndef USE_BREAD_CRUMB_TRAIL |
#if !defined(USE_BREAD_CRUMB_TRAIL) && !defined(BCT) |
1494 |
gpx_t *found = |
gpx_t *found = |
1495 |
search_do(appdata, appdata->gpx, p, appdata->search, FALSE); |
search_do(appdata, appdata->gpx, p, appdata->search, FALSE); |
1496 |
|
|
1524 |
gtk_widget_destroy(dialog); |
gtk_widget_destroy(dialog); |
1525 |
} |
} |
1526 |
|
|
1527 |
void on_window_destroy (GtkWidget *widget, gpointer data); |
static void on_window_destroy (GtkWidget *widget, gpointer data); |
1528 |
|
|
1529 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
1530 |
static void |
static void |
1586 |
notes_log_export(appdata); |
notes_log_export(appdata); |
1587 |
} |
} |
1588 |
|
|
1589 |
#ifdef USE_MAEMO |
#ifdef ENABLE_MAEMO_MAPPER |
1590 |
static void |
static void |
1591 |
cb_menu_export_mmpoi(GtkWidget *widget, gpointer data) { |
cb_menu_export_mmpoi(GtkWidget *widget, gpointer data) { |
1592 |
appdata_t *appdata = (appdata_t*)data; |
appdata_t *appdata = (appdata_t*)data; |
1600 |
garmin_export(appdata); |
garmin_export(appdata); |
1601 |
} |
} |
1602 |
|
|
1603 |
|
#ifdef ENABLE_OSM_GPS_MAP |
1604 |
|
static void |
1605 |
|
cb_menu_map(GtkWidget *window, gpointer data) { |
1606 |
|
map((appdata_t *)data); |
1607 |
|
} |
1608 |
|
#endif |
1609 |
|
|
1610 |
static void |
static void |
1611 |
cb_menu_geomath(GtkWidget *window, gpointer data) { |
cb_menu_geomath(GtkWidget *window, gpointer data) { |
1612 |
geomath_dialog((appdata_t *)data); |
geomath_dialog((appdata_t *)data); |
1623 |
} |
} |
1624 |
|
|
1625 |
#ifdef USE_STACKABLE_WINDOW |
#ifdef USE_STACKABLE_WINDOW |
1626 |
static void on_export_destroy(GtkWidget *widget, appdata_t *appdata) { |
typedef struct { |
1627 |
appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view"); |
char *label, *desc; |
1628 |
} |
GtkSignalFunc activate_cb; |
1629 |
|
} menu_entry_t; |
1630 |
|
|
1631 |
void on_export_clicked(GtkButton *button, appdata_t *appdata) { |
typedef struct { |
1632 |
HildonStackableWindow *view_window; |
const char *title; |
1633 |
GtkWidget *but; |
const menu_entry_t *menu; |
1634 |
|
int len; |
1635 |
|
} submenu_t; |
1636 |
|
|
1637 |
view_window = HILDON_STACKABLE_WINDOW (hildon_stackable_window_new ()); |
#define COLUMNS 1 |
|
gtk_window_set_title (GTK_WINDOW (view_window), "GPXView - Export"); |
|
1638 |
|
|
1639 |
/* store last "cur_view" in window */ |
void on_submenu_entry_clicked(GtkButton *button, GtkWidget *menu) { |
|
g_object_set_data(G_OBJECT(view_window), "cur_view", appdata->cur_view); |
|
|
appdata->cur_view = NULL; |
|
1640 |
|
|
1641 |
g_signal_connect(G_OBJECT(view_window), "destroy", |
/* force closing of submenu dialog */ |
1642 |
G_CALLBACK(on_export_destroy), appdata); |
gtk_dialog_response(GTK_DIALOG(menu), GTK_RESPONSE_NONE); |
1643 |
|
gtk_widget_hide(menu); |
1644 |
|
|
1645 |
|
/* let gtk clean up */ |
1646 |
|
while(gtk_events_pending()) |
1647 |
|
gtk_main_iteration(); |
1648 |
|
} |
1649 |
|
|
1650 |
GtkVBox *contents = GTK_VBOX(gtk_vbox_new (12, FALSE)); |
static GtkWidget *app_submenu_create(appdata_t *appdata, |
1651 |
|
const submenu_t *submenu) { |
1652 |
|
|
1653 |
but = hildon_button_new_with_text( |
/* create a oridinary dialog box */ |
1654 |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
GtkWidget *dialog = gtk_dialog_new(); |
1655 |
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
gtk_window_set_title(GTK_WINDOW(dialog), _(submenu->title)); |
1656 |
_("Export to Maemo Mapper"), |
gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); |
1657 |
_("Save a Maemo Mapper POI file")); |
gtk_window_set_transient_for(GTK_WINDOW(dialog), |
1658 |
g_signal_connect(but, "clicked", |
GTK_WINDOW(appdata->window)); |
1659 |
G_CALLBACK(cb_menu_export_mmpoi), appdata); |
gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); |
|
gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0); |
|
1660 |
|
|
1661 |
|
GtkWidget *table = gtk_table_new(submenu->len/COLUMNS, COLUMNS, TRUE); |
1662 |
|
int x = 0, y = 0; |
1663 |
|
|
1664 |
but = hildon_button_new_with_text( |
const menu_entry_t *menu_entries = submenu->menu; |
1665 |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
while(menu_entries->label) { |
1666 |
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
GtkWidget *button = NULL; |
|
_("Export Field Notes"), |
|
|
_("Save a Garmin Field Notes file")); |
|
|
g_signal_connect(but, "clicked", |
|
|
G_CALLBACK(cb_menu_export_log), appdata); |
|
|
gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0); |
|
|
|
|
1667 |
|
|
1668 |
but = hildon_button_new_with_text( |
button = hildon_button_new_with_text( |
1669 |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
1670 |
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
1671 |
_("Export Garmin GPX"), |
_(menu_entries->label), _(menu_entries->desc)); |
|
_("Save a GPX file containing modified waypoints")); |
|
|
g_signal_connect(but, "clicked", |
|
|
G_CALLBACK(cb_menu_export_garmin), appdata); |
|
|
gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0); |
|
1672 |
|
|
1673 |
gtk_container_add (GTK_CONTAINER (view_window), GTK_WIDGET (contents)); |
/* try to center both texts */ |
1674 |
gtk_widget_show_all (GTK_WIDGET (view_window)); |
hildon_button_set_title_alignment(HILDON_BUTTON(button), 0.5, 0.5); |
1675 |
} |
hildon_button_set_value_alignment(HILDON_BUTTON(button), 0.5, 0.5); |
1676 |
|
|
1677 |
static void on_tools_destroy(GtkWidget *widget, appdata_t *appdata) { |
g_signal_connect(button, "clicked", |
1678 |
appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view"); |
G_CALLBACK(on_submenu_entry_clicked), dialog); |
1679 |
|
|
1680 |
|
g_signal_connect(button, "clicked", |
1681 |
|
menu_entries->activate_cb, appdata); |
1682 |
|
|
1683 |
|
gtk_table_attach_defaults(GTK_TABLE(table), button, x, x+1, y, y+1); |
1684 |
|
|
1685 |
|
x++; |
1686 |
|
if(x == COLUMNS) { x = 0; y++; } |
1687 |
|
|
1688 |
|
menu_entries++; |
1689 |
|
} |
1690 |
|
|
1691 |
|
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table); |
1692 |
|
|
1693 |
|
return dialog; |
1694 |
} |
} |
1695 |
|
|
1696 |
void on_tools_clicked(GtkButton *button, appdata_t *appdata) { |
/* popup the dialog shaped submenu */ |
1697 |
HildonStackableWindow *view_window; |
static void submenu_popup(GtkWidget *menu) { |
1698 |
GtkWidget *but; |
gtk_widget_show_all(menu); |
1699 |
|
gtk_dialog_run(GTK_DIALOG(menu)); |
1700 |
|
gtk_widget_hide(menu); |
1701 |
|
} |
1702 |
|
|
1703 |
view_window = HILDON_STACKABLE_WINDOW (hildon_stackable_window_new ()); |
static void submenu_cleanup(GtkWidget *menu) { |
1704 |
gtk_window_set_title (GTK_WINDOW (view_window), "GPXView - Tools"); |
gtk_widget_destroy(menu); |
1705 |
|
} |
1706 |
|
|
1707 |
/* store last "cur_view" in window */ |
static const menu_entry_t submenu_export_entries[] = { |
1708 |
g_object_set_data(G_OBJECT(view_window), "cur_view", appdata->cur_view); |
#ifdef ENABLE_MAEMO_MAPPER |
1709 |
appdata->cur_view = NULL; |
{ "Export to Maemo Mapper" , "Save a Maemo Mapper POI file", |
1710 |
|
G_CALLBACK(cb_menu_export_mmpoi) }, |
1711 |
|
#endif |
1712 |
|
{ "Export Field Notes", "Save a Garmin Field Notes file", |
1713 |
|
G_CALLBACK(cb_menu_export_log) }, |
1714 |
|
{ "Export Garmin GPX", "Save modified waypoints in GPX file", |
1715 |
|
G_CALLBACK(cb_menu_export_garmin) }, |
1716 |
|
{ NULL, NULL, NULL } |
1717 |
|
}; |
1718 |
|
|
1719 |
g_signal_connect(G_OBJECT(view_window), "destroy", |
static const submenu_t submenu_export = { |
1720 |
G_CALLBACK(on_tools_destroy), appdata); |
"Export", submenu_export_entries, |
1721 |
|
sizeof(submenu_export_entries)/sizeof(menu_entry_t)-1 |
1722 |
|
}; |
1723 |
|
|
1724 |
GtkVBox *contents = GTK_VBOX(gtk_vbox_new (12, FALSE)); |
/* the export submenu */ |
1725 |
|
void on_export_clicked(GtkButton *button, appdata_t *appdata) { |
1726 |
|
if(!appdata->export_menu) |
1727 |
|
appdata->export_menu = app_submenu_create(appdata, &submenu_export); |
1728 |
|
|
1729 |
but = hildon_button_new_with_text( |
submenu_popup(appdata->export_menu); |
1730 |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
} |
|
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
|
|
_("Geomath"), |
|
|
_("Geocoordinate calculation")); |
|
|
g_signal_connect(but, "clicked", |
|
|
G_CALLBACK(cb_menu_geomath), appdata); |
|
|
gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0); |
|
1731 |
|
|
1732 |
|
static const menu_entry_t submenu_tools_entries[] = { |
1733 |
|
{ "Geomath", "Geocoordinate calculation", |
1734 |
|
G_CALLBACK(cb_menu_geomath) }, |
1735 |
|
{ "Geotext", "Text analysis", |
1736 |
|
G_CALLBACK(cb_menu_geotext) }, |
1737 |
|
{ "Precise Position", "Calculate a precise GPS position", |
1738 |
|
G_CALLBACK(cb_menu_precpos) }, |
1739 |
|
{ NULL, NULL, NULL } |
1740 |
|
}; |
1741 |
|
|
1742 |
but = hildon_button_new_with_text( |
static const submenu_t submenu_tools = { |
1743 |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
"Tools", submenu_tools_entries, |
1744 |
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
sizeof(submenu_tools_entries)/sizeof(menu_entry_t)-1 |
1745 |
_("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); |
|
|
|
|
1746 |
|
|
1747 |
but = hildon_button_new_with_text( |
/* the tools submenu */ |
1748 |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
void on_tools_clicked(GtkButton *button, appdata_t *appdata) { |
1749 |
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
if(!appdata->tools_menu) |
1750 |
_("Precise Position"), |
appdata->tools_menu = app_submenu_create(appdata, &submenu_tools); |
|
_("Calculate a very precise GPS position")); |
|
|
g_signal_connect(but, "clicked", |
|
|
G_CALLBACK(cb_menu_precpos), appdata); |
|
|
gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0); |
|
1751 |
|
|
1752 |
gtk_container_add (GTK_CONTAINER (view_window), GTK_WIDGET (contents)); |
submenu_popup(appdata->tools_menu); |
|
gtk_widget_show_all (GTK_WIDGET (view_window)); |
|
1753 |
} |
} |
1754 |
|
|
1755 |
HildonAppMenu *menu_create(appdata_t *appdata, int mode) { |
HildonAppMenu *menu_create(appdata_t *appdata, int mode) { |
1777 |
g_signal_connect_after(button, "clicked", |
g_signal_connect_after(button, "clicked", |
1778 |
G_CALLBACK(cb_menu_adddir), appdata); |
G_CALLBACK(cb_menu_adddir), appdata); |
1779 |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
|
} |
|
1780 |
|
|
|
if(mode == MENU_GPXLIST) { |
|
1781 |
button = gtk_button_new_with_label(_("Export")); |
button = gtk_button_new_with_label(_("Export")); |
1782 |
g_signal_connect_after(button, "clicked", |
g_signal_connect_after(button, "clicked", |
1783 |
G_CALLBACK(on_export_clicked), appdata); |
G_CALLBACK(on_export_clicked), appdata); |
1794 |
G_CALLBACK(on_tools_clicked), appdata); |
G_CALLBACK(on_tools_clicked), appdata); |
1795 |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1796 |
|
|
1797 |
// gtk_widget_show(GTK_WIDGET(menu)); |
#ifdef ENABLE_OSM_GPS_MAP |
1798 |
|
button = gtk_button_new_with_label(_("Map")); |
1799 |
|
g_signal_connect_after(button, "clicked", |
1800 |
|
G_CALLBACK(cb_menu_map), appdata); |
1801 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1802 |
|
#endif |
1803 |
|
|
1804 |
|
#ifdef HILDON_HELP |
1805 |
|
button = gtk_button_new_with_label(_("Help")); |
1806 |
|
g_signal_connect_after(button, "clicked", |
1807 |
|
G_CALLBACK(cb_menu_help), appdata); |
1808 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1809 |
|
#endif |
1810 |
|
|
1811 |
|
gtk_widget_show_all(GTK_WIDGET(menu)); |
1812 |
|
|
1813 |
return menu; |
return menu; |
1814 |
} |
} |
1818 |
GtkWidget *menu, *item; |
GtkWidget *menu, *item; |
1819 |
menu = gtk_menu_new(); |
menu = gtk_menu_new(); |
1820 |
|
|
1821 |
#ifdef USE_BREAD_CRUMB_TRAIL |
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
1822 |
appdata->menu_import = |
appdata->menu_import = |
1823 |
#endif |
#endif |
1824 |
item = gtk_menu_item_new_with_label(_("Import")); |
item = gtk_menu_item_new_with_label(_("Import")); |
1848 |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_remove), appdata); |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_remove), appdata); |
1849 |
#endif |
#endif |
1850 |
|
|
1851 |
#ifdef USE_BREAD_CRUMB_TRAIL |
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
1852 |
appdata->menu_export = |
appdata->menu_export = |
1853 |
#endif |
#endif |
1854 |
item = gtk_menu_item_new_with_label(_("Export")); |
item = gtk_menu_item_new_with_label(_("Export")); |
1856 |
submenu = gtk_menu_new(); |
submenu = gtk_menu_new(); |
1857 |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
1858 |
|
|
1859 |
#ifdef USE_MAEMO |
#ifdef ENABLE_MAEMO_MAPPER |
1860 |
item = gtk_menu_item_new_with_label( _("Maemo Mapper POI") ); |
item = gtk_menu_item_new_with_label( _("Maemo Mapper POI") ); |
1861 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1862 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
1873 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
1874 |
GTK_SIGNAL_FUNC(cb_menu_export_garmin), appdata); |
GTK_SIGNAL_FUNC(cb_menu_export_garmin), appdata); |
1875 |
|
|
1876 |
#ifdef USE_BREAD_CRUMB_TRAIL |
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
1877 |
appdata->menu_search = |
appdata->menu_search = |
1878 |
#endif |
#endif |
1879 |
item = gtk_menu_item_new_with_label( _("Search") ); |
item = gtk_menu_item_new_with_label( _("Search") ); |
1882 |
|
|
1883 |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
1884 |
|
|
|
#ifndef NO_COPY_N_PASTE |
|
1885 |
/* ----------- copy'n paste submenu ----------------- */ |
/* ----------- copy'n paste submenu ----------------- */ |
1886 |
appdata->clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); |
#ifndef NO_COPY_N_PASTE |
|
gtk_clipboard_set_can_store(appdata->clipboard, NULL, 0); |
|
|
|
|
1887 |
item = gtk_menu_item_new_with_label(_("Edit")); |
item = gtk_menu_item_new_with_label(_("Edit")); |
1888 |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
1889 |
submenu = gtk_menu_new(); |
submenu = gtk_menu_new(); |
1910 |
|
|
1911 |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
1912 |
|
|
1913 |
|
#ifdef ENABLE_OSM_GPS_MAP |
1914 |
|
item = gtk_menu_item_new_with_label( _("Map") ); |
1915 |
|
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
1916 |
|
g_signal_connect(item, "activate", |
1917 |
|
GTK_SIGNAL_FUNC(cb_menu_map), appdata); |
1918 |
|
#endif |
1919 |
|
|
1920 |
item = gtk_menu_item_new_with_label(_("Tools")); |
item = gtk_menu_item_new_with_label(_("Tools")); |
1921 |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
1922 |
submenu = gtk_menu_new(); |
submenu = gtk_menu_new(); |
1981 |
if(appdata->image_path) free(appdata->image_path); |
if(appdata->image_path) free(appdata->image_path); |
1982 |
if(appdata->search_str) free(appdata->search_str); |
if(appdata->search_str) free(appdata->search_str); |
1983 |
|
|
1984 |
|
#ifdef USE_STACKABLE_WINDOW |
1985 |
|
if(appdata->export_menu) submenu_cleanup(appdata->export_menu); |
1986 |
|
if(appdata->tools_menu) submenu_cleanup(appdata->tools_menu); |
1987 |
|
#endif |
1988 |
|
|
1989 |
gnome_vfs_shutdown(); |
gnome_vfs_shutdown(); |
1990 |
icons_free(); |
icons_free(); |
1991 |
gps_release(appdata); |
gps_release(appdata); |
2014 |
puts("everything is gone"); |
puts("everything is gone"); |
2015 |
} |
} |
2016 |
|
|
2017 |
void on_window_destroy (GtkWidget *widget, gpointer data) { |
static void on_window_destroy (GtkWidget *widget, gpointer data) { |
2018 |
appdata_t *appdata = (appdata_t*)data; |
appdata_t *appdata = (appdata_t*)data; |
2019 |
|
|
2020 |
gconf_save_state(appdata); |
gconf_save_state(appdata); |
2077 |
return handled; |
return handled; |
2078 |
} |
} |
2079 |
|
|
2080 |
#ifdef USE_BREAD_CRUMB_TRAIL |
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
2081 |
typedef struct { |
typedef struct { |
2082 |
int level; |
int level; |
2083 |
appdata_t *appdata; |
appdata_t *appdata; |
2169 |
|
|
2170 |
gtk_widget_show_all(crumb->appdata->vbox); |
gtk_widget_show_all(crumb->appdata->vbox); |
2171 |
g_free(data); |
g_free(data); |
2172 |
|
|
2173 |
|
#ifdef ENABLE_OSM_GPS_MAP |
2174 |
|
map_update(crumb->appdata); |
2175 |
|
#endif |
2176 |
} |
} |
2177 |
|
|
2178 |
static void crumb_add(appdata_t *appdata, char *name, int level, |
static void crumb_add(appdata_t *appdata, char *name, int level, |
2213 |
#endif |
#endif |
2214 |
} |
} |
2215 |
|
|
2216 |
|
#ifdef USE_BREAD_CRUMB_TRAIL |
2217 |
hildon_bread_crumb_trail_push_text(HILDON_BREAD_CRUMB_TRAIL(appdata->bct), |
hildon_bread_crumb_trail_push_text(HILDON_BREAD_CRUMB_TRAIL(appdata->bct), |
2218 |
name, crumb, (GDestroyNotify)crumb_back); |
name, crumb, (GDestroyNotify)crumb_back); |
2219 |
|
#else |
2220 |
|
bct_push_text(appdata->bct, name, crumb, (GDestroyNotify)crumb_back); |
2221 |
|
#endif |
2222 |
|
|
2223 |
|
#ifdef ENABLE_OSM_GPS_MAP |
2224 |
|
map_update(appdata); |
2225 |
|
#endif |
2226 |
} |
} |
2227 |
#endif // USE_BREAD_CRUMB_TRAIL |
#endif // USE_BREAD_CRUMB_TRAIL |
2228 |
|
|
2234 |
return; |
return; |
2235 |
} |
} |
2236 |
|
|
|
#ifndef USE_MAEMO |
|
|
// in non-maemo setup this can only affect the main screen as |
|
|
// the menu is blocked while a dialog is open. also the main |
|
|
// screen is always present |
|
|
if(appdata->gpxlist_items != appdata->cur_items) { |
|
|
/* re-do the main screen */ |
|
|
gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
|
|
appdata->cur_view = gpxlist_create_view_and_model(appdata, NULL); |
|
|
gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view); |
|
|
gtk_widget_show_all(appdata->vbox); |
|
|
} |
|
|
#else |
|
2237 |
/* 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 */ |
2238 |
/* need to be redrawn */ |
/* need to be redrawn */ |
2239 |
if(appdata->cur_cache) { |
if(appdata->cur_cache) { |
2288 |
|
|
2289 |
gtk_widget_show_all(container); |
gtk_widget_show_all(container); |
2290 |
} |
} |
|
#endif // USE_MAEMO |
|
2291 |
} |
} |
2292 |
|
|
2293 |
int main(int argc, char *argv[]) { |
int main(int argc, char *argv[]) { |
2308 |
|
|
2309 |
gtk_init (&argc, &argv); |
gtk_init (&argc, &argv); |
2310 |
|
|
2311 |
|
curl_global_init(CURL_GLOBAL_ALL); |
2312 |
|
|
2313 |
#ifdef USE_MAEMO |
#ifdef USE_MAEMO |
2314 |
printf("Installing osso context for \"org.harbaum." APP "\"\n"); |
printf("Installing osso context for \"org.harbaum." APP "\"\n"); |
2315 |
appdata.osso_context = osso_initialize("org.harbaum."APP, |
appdata.osso_context = osso_initialize("org.harbaum."APP, |
2318 |
fprintf(stderr, "error initiating osso context\n"); |
fprintf(stderr, "error initiating osso context\n"); |
2319 |
} |
} |
2320 |
|
|
2321 |
|
#ifdef ENABLE_MAEMO_MAPPER |
2322 |
dbus_register(&appdata); |
dbus_register(&appdata); |
2323 |
#endif |
#endif |
2324 |
|
#endif |
2325 |
|
|
2326 |
icons_init(); |
icons_init(); |
2327 |
|
|
2345 |
/* Create a Window. */ |
/* Create a Window. */ |
2346 |
appdata.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
appdata.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
2347 |
/* Set a decent default size for the window. */ |
/* Set a decent default size for the window. */ |
2348 |
gtk_window_set_default_size(GTK_WINDOW(appdata.window), 500, 300); |
gtk_window_set_default_size(GTK_WINDOW(appdata.window), 640, 480); |
2349 |
#endif |
#endif |
2350 |
|
|
2351 |
#if MAEMO_VERSION_MAJOR == 5 |
#if MAEMO_VERSION_MAJOR == 5 |
2358 |
g_signal_connect(G_OBJECT(appdata.window), "key_press_event", |
g_signal_connect(G_OBJECT(appdata.window), "key_press_event", |
2359 |
G_CALLBACK(on_window_key_press), &appdata); |
G_CALLBACK(on_window_key_press), &appdata); |
2360 |
|
|
2361 |
|
/* prepare clipboard */ |
2362 |
|
appdata.clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); |
2363 |
|
gtk_clipboard_set_can_store(appdata.clipboard, NULL, 0); |
2364 |
|
|
2365 |
appdata.vbox = gtk_vbox_new(FALSE, 2); |
appdata.vbox = gtk_vbox_new(FALSE, 2); |
2366 |
gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox); |
gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox); |
|
|
|
2367 |
#ifndef USE_STACKABLE_WINDOW |
#ifndef USE_STACKABLE_WINDOW |
2368 |
menu_create(&appdata); |
menu_create(&appdata); |
2369 |
#else |
#else |
2377 |
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); |
2378 |
|
|
2379 |
hildon_bread_crumb_trail_clear(HILDON_BREAD_CRUMB_TRAIL(appdata.bct)); |
hildon_bread_crumb_trail_clear(HILDON_BREAD_CRUMB_TRAIL(appdata.bct)); |
2380 |
|
#else |
2381 |
|
#ifdef BCT |
2382 |
|
/* on non-hildon machines we use some custom made breadcrumbtrail */ |
2383 |
|
/* replacement */ |
2384 |
|
appdata.bct = bct_new(); |
2385 |
|
gtk_box_pack_start(GTK_BOX(appdata.vbox), appdata.bct, FALSE,FALSE,0); |
2386 |
|
#endif |
2387 |
|
#endif |
2388 |
|
|
2389 |
|
#if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT) |
2390 |
crumb_add(&appdata, "GPX", CRUMB_GPXLIST, NULL); |
crumb_add(&appdata, "GPX", CRUMB_GPXLIST, NULL); |
2391 |
#endif |
#endif |
2392 |
|
|