Diff of /trunk/src/main.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 20 by harbaum, Sat Jul 4 19:42:28 2009 UTC revision 189 by harbaum, Tue Nov 17 09:07:17 2009 UTC
# Line 19  Line 19 
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    
# Line 29  Line 31 
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    #include <hildon/hildon-check-button.h>
37    #endif
38  #endif  #endif
39    
40  #include <locale.h>  #include <locale.h>
41    
42  extern char *strcasestr (__const char *__haystack, __const char *__needle);  extern char *strcasestr (__const char *__haystack, __const char *__needle);
43    
44  #ifdef USE_BREAD_CRUMB_TRAIL  #if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT)
45  static void crumb_add(appdata_t *appdata, char *name, int level,  static void crumb_add(appdata_t *appdata, char *name, int level,
46                        gpointer user_data);                        gpointer user_data);
47    
# Line 92  void errorf(const char *fmt, ...) { Line 98  void errorf(const char *fmt, ...) {
98      }      }
99    }    }
100    
101    #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
102    GtkWidget *dialog = gtk_message_dialog_new(    GtkWidget *dialog = gtk_message_dialog_new(
103                             GTK_WINDOW(NULL),                             GTK_WINDOW(NULL),
104                             GTK_DIALOG_DESTROY_WITH_PARENT,                             GTK_DIALOG_DESTROY_WITH_PARENT,
105                             GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,                             GTK_MESSAGE_ERROR,
106                             buf);                             GTK_BUTTONS_CLOSE, buf);
107    
108    gtk_window_set_title(GTK_WINDOW(dialog), _("ERROR"));    gtk_window_set_title(GTK_WINDOW(dialog), _("ERROR"));
109    #else
110      GtkWidget *dialog =
111        hildon_note_new_information(GTK_WINDOW(NULL), buf);
112    #endif
113    
114    gtk_dialog_run(GTK_DIALOG(dialog));    gtk_dialog_run(GTK_DIALOG(dialog));
115    gtk_widget_destroy(dialog);    gtk_widget_destroy(dialog);
# Line 138  gpx_t *choose_file(appdata_t *appdata, g Line 149  gpx_t *choose_file(appdata_t *appdata, g
149    gtk_widget_show_all (GTK_WIDGET(dialog));    gtk_widget_show_all (GTK_WIDGET(dialog));
150    if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_FM_OK) {    if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_FM_OK) {
151      char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));      char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
152    
153        if(filename) {
154          gpx_dialog_t *dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window));
155    
156      gpx_dialog_t *dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window));        if(!whole_dir)
157            gpx = gpx_parse(dialog, filename);
158      if(!whole_dir)        else {
159        gpx = gpx_parse(dialog, filename);          /* cur trailing '/' if present */
160      else {          if(strlastchr(filename) == '/')
161        /* cur trailing '/' if present */            filename[strlen(filename)] = 0;
162        if(strlastchr(filename) == '/')  
163          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 = '/';  
164        }        }
165    
166          gpx_busy_dialog_destroy(dialog);
167    
168          /* save path if gpx was successfully loaded */
169          if(gpx) {
170            char *r = strrchr(filename, '/');
171    
172            /* there is a delimiter, use everything left of it as path */
173            if(r && !whole_dir) {
174              *r = 0;
175              if(appdata->path) free(appdata->path);
176              appdata->path = strdup(filename);
177              /* restore path ... just in case ... */
178              *r = '/';
179            }
180    
181            if(whole_dir)
182              appdata->path = strdup(filename);
183          } else
184            errorf(_("Load error"));
185    
186        if(whole_dir)        g_free (filename);
187          appdata->path = strdup(filename);      } else {
188    #ifndef USE_MAEMO
189          errorf(_("Error accessing the file."));
190    #else
191          errorf(_("Error accessing the file. This may happen if the file "
192                   "resides on a remote file system. Please copy the file onto "
193                   "the device (e.g. onto the memory card) and try again."));
194    #endif
195      }      }
   
     g_free (filename);  
196    }    }
197    
198    gtk_widget_destroy (dialog);    gtk_widget_destroy (dialog);
# Line 194  enum { Line 216  enum {
216    CACHELIST_NUM_COLS    CACHELIST_NUM_COLS
217  } ;  } ;
218    
219  void cachelist_view_onRowActivated(GtkTreeView        *treeview,  void cachelist_goto_cache(appdata_t *appdata, cache_t *cache) {
220    #if !defined(USE_BREAD_CRUMB_TRAIL) && !defined(BCT)
221        cache_dialog(appdata, cache);
222    #else
223        gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view);
224        appdata->cur_view = cache_view(appdata, cache);
225        gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view);
226        gtk_widget_show_all(appdata->vbox);
227    
228        crumb_add(appdata, cache->name, CRUMB_CACHE, cache);
229    #endif
230    }
231    
232    static void cachelist_view_onRowActivated(GtkTreeView        *treeview,
233                                     GtkTreePath        *path,                                     GtkTreePath        *path,
234                                     GtkTreeViewColumn  *col,                                     GtkTreeViewColumn  *col,
235                                     gpointer            userdata) {                                     gpointer            userdata) {
# Line 202  void cachelist_view_onRowActivated(GtkTr Line 237  void cachelist_view_onRowActivated(GtkTr
237    GtkTreeIter   iter;    GtkTreeIter   iter;
238    GtkTreeModel *model = gtk_tree_view_get_model(treeview);    GtkTreeModel *model = gtk_tree_view_get_model(treeview);
239    
240    #ifdef USE_MAEMO
241      /* check if a cache is already selected and ignore click if yes */
242      /* (was probably a double click) */
243      if(appdata->cur_cache) return;
244    #endif
245    
246    if(gtk_tree_model_get_iter(model, &iter, path)) {    if(gtk_tree_model_get_iter(model, &iter, path)) {
247      cache_t *cache;      cache_t *cache;
248      gtk_tree_model_get(model, &iter, CACHELIST_COL_DATA, &cache, -1);      gtk_tree_model_get(model, &iter, CACHELIST_COL_DATA, &cache, -1);
249  #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  
250    }    }
251  }  }
252    
# Line 257  static GtkWidget *cachelist_create(appda Line 289  static GtkWidget *cachelist_create(appda
289                                     cache_t *sel_cache);                                     cache_t *sel_cache);
290    
291  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  
   
292    if(!appdata->cur_view) {    if(!appdata->cur_view) {
293      printf("cachelist redraw: no active view\n");      printf("cachelist redraw: no active view\n");
294      return;      return;
# Line 281  void cachelist_redraw(appdata_t *appdata Line 306  void cachelist_redraw(appdata_t *appdata
306    if(redraw) {    if(redraw) {
307      GtkWidget *container = appdata->vbox;      GtkWidget *container = appdata->vbox;
308    
     printf("redraw %d\n", redraw);  
   
309  #ifdef USE_STACKABLE_WINDOW  #ifdef USE_STACKABLE_WINDOW
310      HildonWindowStack *stack = hildon_window_stack_get_default();      HildonWindowStack *stack = hildon_window_stack_get_default();
311      container = hildon_window_stack_peek(stack);      container = hildon_window_stack_peek(stack);
# Line 309  void cachelist_redraw(appdata_t *appdata Line 332  void cachelist_redraw(appdata_t *appdata
332    
333      gtk_widget_show_all(container);      gtk_widget_show_all(container);
334    }    }
 #endif  
335  }  }
336    
337    
# Line 317  static gboolean cachelist_update(gpointe Line 339  static gboolean cachelist_update(gpointe
339    
340    printf("cachelist timer fired!\n");    printf("cachelist timer fired!\n");
341    
 #ifdef USE_MAEMO  
342    appdata_t *appdata = (appdata_t*)data;    appdata_t *appdata = (appdata_t*)data;
343    
344    if(appdata->cur_cache)    if(appdata->cur_cache)
345      return TRUE;      return TRUE;
346    
347    #ifdef USE_MAEMO
348    if(appdata->cachelist_disable_screensaver)    if(appdata->cachelist_disable_screensaver)
349      if (osso_display_blanking_pause(appdata->osso_context) != OSSO_OK)      if (osso_display_blanking_pause(appdata->osso_context) != OSSO_OK)
350        fprintf(stderr, "error with display blank\n");        fprintf(stderr, "error with display blank\n");
351    #endif
352    
353    if(appdata->cachelist_update)    if(appdata->cachelist_update)
354      cachelist_redraw(appdata);      cachelist_redraw(appdata);
 #endif  
355    
356    return TRUE;    return TRUE;
357  }  }
# Line 576  void on_cachelist_destroy(GtkWidget *wid Line 598  void on_cachelist_destroy(GtkWidget *wid
598    }    }
599    appdata->cur_gpx = NULL;    appdata->cur_gpx = NULL;
600    
601    #ifdef ENABLE_OSM_GPS_MAP
602      map_update(appdata);
603    #endif
604    
605    /* restore cur_view */    /* restore cur_view */
606    appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view");    appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view");
607  }  }
# Line 587  void cachelist_dialog(appdata_t *appdata Line 613  void cachelist_dialog(appdata_t *appdata
613    g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view);    g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view);
614    
615    appdata->cur_gpx = gpx;    appdata->cur_gpx = gpx;
616    char *title = g_strdup_printf("GPXView - %s", gpx->name);    char *title = g_strdup_printf("%s - GPXView", gpx->name);
617    gtk_window_set_title(GTK_WINDOW(window), title);    gtk_window_set_title(GTK_WINDOW(window), title);
618    g_free(title);    g_free(title);
619    
# Line 602  void cachelist_dialog(appdata_t *appdata Line 628  void cachelist_dialog(appdata_t *appdata
628                     G_CALLBACK(on_cachelist_destroy), appdata);                     G_CALLBACK(on_cachelist_destroy), appdata);
629    
630    gtk_widget_show_all(window);    gtk_widget_show_all(window);
631    
632    #ifdef ENABLE_OSM_GPS_MAP
633      map_update(appdata);
634    #endif
635  }  }
636  #endif  #endif
637  #endif  #endif
# Line 659  static void gpxlist_set(GtkListStore *st Line 689  static void gpxlist_set(GtkListStore *st
689                       GPXLIST_COL_OPEN, !gpx->closed,                       GPXLIST_COL_OPEN, !gpx->closed,
690                       GPXLIST_COL_CACHES, gpx->closed?NULL:cnum,                       GPXLIST_COL_CACHES, gpx->closed?NULL:cnum,
691  #ifdef USE_PANNABLE_AREA  #ifdef USE_PANNABLE_AREA
692                       GPXLIST_COL_DELETE, icon_get(ICON_MISC, 7),                       GPXLIST_COL_DELETE, icon_get(ICON_MISC, 4),
693  #endif  #endif
694                       GPXLIST_COL_DATA, gpx,                       GPXLIST_COL_DATA, gpx,
695                       -1);                       -1);
# Line 705  static void gpxlist_close(appdata_t *app Line 735  static void gpxlist_close(appdata_t *app
735    gconf_save_closed_name(appdata, gpx->filename, gpx->name);    gconf_save_closed_name(appdata, gpx->filename, gpx->name);
736  }  }
737    
738    void gpxlist_goto_cachelist(appdata_t *appdata, gpx_t *gpx) {
739    #if !defined(USE_BREAD_CRUMB_TRAIL) && !defined(BCT)
740    #ifdef USE_STACKABLE_WINDOW
741      if(!appdata->cur_gpx)
742    #endif
743        cachelist_dialog(appdata, gpx);
744    #ifdef USE_STACKABLE_WINDOW
745      else
746        printf("selected gpx, but cachelist window already present\n");
747    #endif
748    #else
749      gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view);
750      appdata->cur_view = cachelist_create(appdata, gpx, NULL);
751      gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view);
752      gtk_widget_show_all(appdata->vbox);
753    
754      crumb_add(appdata, gpx->name, CRUMB_CACHELIST, gpx);
755    #endif
756    }
757    
758  static void gpxlist_view_onRowActivated(GtkTreeView *treeview,  static void gpxlist_view_onRowActivated(GtkTreeView *treeview,
759                            GtkTreePath        *path,                            GtkTreePath        *path,
760                            GtkTreeViewColumn  *col,                            GtkTreeViewColumn  *col,
# Line 713  static void gpxlist_view_onRowActivated( Line 763  static void gpxlist_view_onRowActivated(
763    GtkTreeIter   iter;    GtkTreeIter   iter;
764    GtkTreeModel *model = gtk_tree_view_get_model(treeview);    GtkTreeModel *model = gtk_tree_view_get_model(treeview);
765    
766    #ifdef USE_MAEMO
767      /* check if a cache is already selected and ignore click if yes */
768      /* (was probably a double click) */
769      if(appdata->cur_gpx) return;
770    #endif
771    
772    if (gtk_tree_model_get_iter(model, &iter, path)) {    if (gtk_tree_model_get_iter(model, &iter, path)) {
773      gpx_t *gpx;      gpx_t *gpx;
774      gtk_tree_model_get(model, &iter, GPXLIST_COL_DATA, &gpx, -1);      gtk_tree_model_get(model, &iter, GPXLIST_COL_DATA, &gpx, -1);
# Line 725  static void gpxlist_view_onRowActivated( Line 781  static void gpxlist_view_onRowActivated(
781      if(col_name && !strcmp(col_name, "Del")) {      if(col_name && !strcmp(col_name, "Del")) {
782        printf("clicked delete\n");        printf("clicked delete\n");
783    
784    #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
785        /* ask user what he wants */        /* ask user what he wants */
786        GtkWidget *dialog = gtk_message_dialog_new(        GtkWidget *dialog = gtk_message_dialog_new(
787                   GTK_WINDOW(appdata->window),                   GTK_WINDOW(appdata->window),
788                   GTK_DIALOG_DESTROY_WITH_PARENT,                   GTK_DIALOG_DESTROY_WITH_PARENT,
789                   GTK_MESSAGE_QUESTION, GTK_BUTTONS_CANCEL,                   GTK_MESSAGE_QUESTION,
790                     GTK_BUTTONS_CANCEL,
791                   _("Do you want to close this entry only or do "                   _("Do you want to close this entry only or do "
792                     "you want to remove it completely from the list?"));                     "you want to remove it completely from the list?"));
793    
# Line 738  static void gpxlist_view_onRowActivated( Line 796  static void gpxlist_view_onRowActivated(
796                               _("Close"), 2,                               _("Close"), 2,
797                               NULL);                               NULL);
798    
799          gtk_window_set_title(GTK_WINDOW(dialog), _("Close or remove entry?"));
800    #else
801    
802          GtkWidget *dialog =
803            gtk_dialog_new_with_buttons(_("Close or remove entry?"),
804                                GTK_WINDOW(appdata->window),
805                                GTK_DIALOG_DESTROY_WITH_PARENT,
806                                GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
807                                _("Remove"), 1,
808                                _("Close"), 2,
809                                NULL);
810    
811          GtkWidget *content_area =
812            gtk_dialog_get_content_area (GTK_DIALOG (dialog));
813    
814          GtkWidget *hbox = gtk_hbox_new(FALSE, 0);
815    
816          gtk_box_pack_start(GTK_BOX(hbox),
817             gtk_image_new_from_stock( GTK_STOCK_DIALOG_QUESTION,
818                                       GTK_ICON_SIZE_DIALOG),
819                             FALSE, FALSE, 0);
820    
821          GtkWidget *label = gtk_label_new(
822                      _("Do you want to close this entry only or do "
823                        "you want to remove it completely from the list?"));
824    
825          gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
826          gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_WORD);
827    
828          gtk_box_pack_start_defaults(GTK_BOX(hbox), label);
829          gtk_container_add (GTK_CONTAINER (content_area), hbox);
830    
831          gtk_widget_show_all (dialog);
832    #endif
833    
834        if(gpx->closed)        if(gpx->closed)
835          gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), 2, FALSE);          gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), 2, FALSE);
836    
       gtk_window_set_title(GTK_WINDOW(dialog), _("Remove entry?"));  
   
837        /* set the active flag again if the user answered "no" */        /* set the active flag again if the user answered "no" */
838        switch(gtk_dialog_run(GTK_DIALOG(dialog))) {        switch(gtk_dialog_run(GTK_DIALOG(dialog))) {
839    
# Line 810  static void gpxlist_view_onRowActivated( Line 901  static void gpxlist_view_onRowActivated(
901    
902          gpx_busy_dialog_destroy(dialog);          gpx_busy_dialog_destroy(dialog);
903        }        }
904  #ifndef USE_BREAD_CRUMB_TRAIL  
905  #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  
906      }      }
907    }    }
908  }  }
# Line 881  static GtkWidget *gpxlist_create_view_an Line 957  static GtkWidget *gpxlist_create_view_an
957    gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview),    gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview),
958                    -1, "Icon", renderer,                    -1, "Icon", renderer,
959                    "pixbuf", GPXLIST_COL_ICON,                    "pixbuf", GPXLIST_COL_ICON,
960                //                  "sensitive", GPXLIST_COL_OPEN,  #ifdef USE_PANNABLE_AREA
961            /* at least one entry needs to be sensitive. */
962            /* This is the delete icon if the PANNABLE_AREA is used */
963                      "sensitive", GPXLIST_COL_OPEN,
964    #endif
965                    NULL);                    NULL);
966    
967    /* --- "FileName" column --- */    /* --- "FileName" column --- */
# Line 937  static GtkWidget *gpxlist_create_view_an Line 1017  static GtkWidget *gpxlist_create_view_an
1017    gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview),    gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview),
1018                    -1, "Del", renderer,                    -1, "Del", renderer,
1019                    "pixbuf", GPXLIST_COL_DELETE,                    "pixbuf", GPXLIST_COL_DELETE,
1020                    "sensitive", GPXLIST_COL_OPEN,                //                  "sensitive", GPXLIST_COL_OPEN,
1021                    NULL);                    NULL);
1022  #endif  #endif
1023    
# Line 957  static GtkWidget *gpxlist_create_view_an Line 1037  static GtkWidget *gpxlist_create_view_an
1037      GtkTreeIter         iter;      GtkTreeIter         iter;
1038      gtk_list_store_append(appdata->gpxstore, &iter);      gtk_list_store_append(appdata->gpxstore, &iter);
1039      gpxlist_set(appdata->gpxstore, &iter, gpx);      gpxlist_set(appdata->gpxstore, &iter, gpx);
1040    
1041      if(gpx == sel_gpx) {      if(gpx == sel_gpx) {
1042        sel_iter = iter;        sel_iter = iter;
1043        sel_iter_valid = TRUE;        sel_iter_valid = TRUE;
# Line 1017  static void gpxlist_add(appdata_t *appda Line 1097  static void gpxlist_add(appdata_t *appda
1097    
1098  /******************** begin of menu *********************/  /******************** begin of menu *********************/
1099    
1100    typedef struct {
1101      appdata_t *appdata;
1102      GtkWidget *dialog;
1103    } about_context_t;
1104    
1105    #ifdef ENABLE_BROWSER_INTERFACE
1106    void on_paypal_button_clicked(GtkButton *button, about_context_t *context) {
1107      gtk_dialog_response(GTK_DIALOG(context->dialog), GTK_RESPONSE_ACCEPT);
1108      browser_url(context->appdata,
1109                  "https://www.paypal.com/cgi-bin/webscr"
1110                  "?cmd=_s-xclick&hosted_button_id=7400558");
1111    }
1112    #endif
1113    
1114  static void  static void
1115  cb_menu_about(GtkWidget *window, gpointer data) {  cb_menu_about(GtkWidget *window, gpointer data) {
1116    GtkAboutDialog *about = GTK_ABOUT_DIALOG(gtk_about_dialog_new());    about_context_t context;
1117    
1118    gtk_about_dialog_set_name(about, "GPXView");    context.appdata = (appdata_t *)data;
   gtk_about_dialog_set_version(about, VERSION);  
1119    
1120  #ifdef ENABLE_LIBLOCATION  #ifdef ENABLE_LIBLOCATION
1121    char *uses = "uses liblocation";    char *uses = "uses liblocation";
# Line 1032  cb_menu_about(GtkWidget *window, gpointe Line 1125  cb_menu_about(GtkWidget *window, gpointe
1125    char *uses = "uses gpsd";    char *uses = "uses gpsd";
1126  #endif  #endif
1127    
1128    char *str = g_strdup_printf("%s\n\n(%s)",    const gchar *authors[] = {
1129                        _("GPXView (c) 2008-2009 by\n"      "Till Harbaum <till@harbaum.org>",
1130                          "Till Harbaum <till@harbaum.org>\n"      "John Stowers <john.stowers@gmail.com>",
1131                          "Mailing list: gpxview-users@garage.maemo.org"),      "GCVote: Guido Wegener <guido.wegener@gmx.de>",
1132                        _(uses)      NULL };
1133                        );  
1134      context.dialog = g_object_new(GTK_TYPE_ABOUT_DIALOG,
1135    gtk_about_dialog_set_copyright(about, str);                          "name", "GPXView",
1136    g_free(str);                          "version", VERSION,
1137                            "copyright", _("Copyright 2008-2009"),
1138    gtk_about_dialog_set_website(about,                          "authors", authors,
1139         _("http://www.harbaum.org/till/maemo"));                          "website", _("http://www.harbaum.org/till/maemo"),
1140                            "comments", _(uses),
1141    gtk_about_dialog_set_comments(about,                          NULL);
1142         _("Geocaching.com GPX file viewer"));  
1143    #ifdef ENABLE_BROWSER_INTERFACE
1144    gtk_widget_show_all(GTK_WIDGET(about));    /* add a way to donate to the project */
1145    gtk_dialog_run(GTK_DIALOG(about));    GtkWidget *alignment = gtk_alignment_new(0.5, 0, 0, 0);
1146    gtk_widget_destroy(GTK_WIDGET(about));  
1147      GtkWidget *hbox = gtk_hbox_new(FALSE, 8);
1148      gtk_box_pack_start(GTK_BOX(hbox),
1149                         gtk_label_new(_("Do you like GPXView?")),
1150                         FALSE, FALSE, 0);
1151    
1152      GtkWidget *button = gtk_button_new();
1153      gtk_button_set_image(GTK_BUTTON(button),
1154                           icon_get_widget(ICON_MISC, 5));
1155      gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
1156      g_signal_connect(button, "clicked",
1157                       G_CALLBACK(on_paypal_button_clicked), &context);
1158      gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1159    
1160      gtk_container_add(GTK_CONTAINER(alignment), hbox);
1161      gtk_box_pack_start_defaults(GTK_BOX((GTK_DIALOG(context.dialog))->vbox),
1162                                  alignment);
1163    
1164      gtk_widget_show_all(alignment);
1165    #endif
1166    
1167      gtk_dialog_run(GTK_DIALOG(context.dialog));
1168      gtk_widget_destroy(context.dialog);
1169  }  }
1170    
1171  #if defined(USE_MAEMO) && defined(HILDON_HELP)  #if defined(USE_MAEMO) && defined(HILDON_HELP)
# Line 1222  gpx_t *search_do(appdata_t *appdata, gpx Line 1337  gpx_t *search_do(appdata_t *appdata, gpx
1337        else if(cache->long_description && (what & SEARCH_DESC) &&        else if(cache->long_description && (what & SEARCH_DESC) &&
1338                strcasestr(cache->long_description, phrase))                strcasestr(cache->long_description, phrase))
1339          hit = 1;          hit = 1;
1340        else if(cache->owner && (what & SEARCH_OWNER) &&        else if(cache->owner && cache->owner->name && (what & SEARCH_OWNER) &&
1341                strcasestr(cache->owner, phrase))                strcasestr(cache->owner->name, phrase))
1342          hit = 1;          hit = 1;
1343    
1344        if(hit) {        if(hit) {
# Line 1252  typedef struct { Line 1367  typedef struct {
1367    GtkWidget *in_id, *in_name, *in_desc, *in_owner, *in_finds;    GtkWidget *in_id, *in_name, *in_desc, *in_owner, *in_finds;
1368  } search_context_t;  } search_context_t;
1369    
1370    
1371    static GtkWidget *check_button_new_with_label(char *label) {
1372    #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
1373      return gtk_check_button_new_with_label(label);
1374    #else
1375      GtkWidget *cbut =
1376        hildon_check_button_new(HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH);
1377      gtk_button_set_label(GTK_BUTTON(cbut), label);
1378      return cbut;
1379    #endif
1380    }
1381    
1382    static void check_button_set_active(GtkWidget *button, gboolean active) {
1383    #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
1384      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), active);
1385    #else
1386      hildon_check_button_set_active(HILDON_CHECK_BUTTON(button), active);
1387    #endif
1388    }
1389    
1390    static gboolean check_button_get_active(GtkWidget *button) {
1391    #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
1392      return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
1393    #else
1394      return hildon_check_button_get_active(HILDON_CHECK_BUTTON(button));
1395    #endif
1396    }
1397    
1398  static void callback_finds_toggled(GtkWidget *widget, gpointer data ) {  static void callback_finds_toggled(GtkWidget *widget, gpointer data ) {
1399    search_context_t *context = (search_context_t*)data;    search_context_t *context = (search_context_t*)data;
1400    
1401    gboolean in_finds = gtk_toggle_button_get_active(    gboolean in_finds = check_button_get_active(context->in_finds);
           GTK_TOGGLE_BUTTON(context->in_finds));  
1402    
1403    gtk_widget_set_sensitive(context->entry,    !in_finds);    gtk_widget_set_sensitive(context->entry,    !in_finds);
1404    gtk_widget_set_sensitive(context->in_id,    !in_finds);    gtk_widget_set_sensitive(context->in_id,    !in_finds);
# Line 1286  cb_menu_search(GtkWidget *window, gpoint Line 1428  cb_menu_search(GtkWidget *window, gpoint
1428    GtkWidget *table = gtk_table_new(2, 2, TRUE);    GtkWidget *table = gtk_table_new(2, 2, TRUE);
1429    gtk_table_set_col_spacing(GTK_TABLE(table), 0, 8);    gtk_table_set_col_spacing(GTK_TABLE(table), 0, 8);
1430    
1431    context.in_id = gtk_check_button_new_with_label(_("Waypoint IDs"));    context.in_id = check_button_new_with_label(_("Waypoint IDs"));
1432    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);  
1433    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);
1434    
1435    context.in_name = gtk_check_button_new_with_label(_("Names"));    context.in_name = check_button_new_with_label(_("Names"));
1436    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);  
1437    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);
1438    
1439    context.in_desc = gtk_check_button_new_with_label(_("Descriptions"));    context.in_desc = check_button_new_with_label(_("Descriptions"));
1440    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);  
1441    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);
1442    
1443    context.in_owner = gtk_check_button_new_with_label(_("Owner"));    context.in_owner = check_button_new_with_label(_("Owner"));
1444    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);  
1445    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);
1446    
1447    gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table);    gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table);
# Line 1324  cb_menu_search(GtkWidget *window, gpoint Line 1462  cb_menu_search(GtkWidget *window, gpoint
1462    
1463    GtkWidget *hbox = gtk_hbox_new(FALSE, 5);    GtkWidget *hbox = gtk_hbox_new(FALSE, 5);
1464    
1465    context.in_finds = gtk_check_button_new_with_label(_("Search finds for"));    context.in_finds = check_button_new_with_label(_("Search finds for"));
1466    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);  
1467    gtk_box_pack_start_defaults(GTK_BOX(hbox), context.in_finds);    gtk_box_pack_start_defaults(GTK_BOX(hbox), context.in_finds);
1468    g_signal_connect(G_OBJECT(context.in_finds), "toggled",    g_signal_connect(G_OBJECT(context.in_finds), "toggled",
1469                     G_CALLBACK(callback_finds_toggled), &context);                     G_CALLBACK(callback_finds_toggled), &context);
# Line 1366  cb_menu_search(GtkWidget *window, gpoint Line 1503  cb_menu_search(GtkWidget *window, gpoint
1503                      HILDON_NUMBER_EDITOR(context.spinner));                      HILDON_NUMBER_EDITOR(context.spinner));
1504  #endif  #endif
1505    
1506      if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_finds)))      if(check_button_get_active(context.in_finds))
1507        appdata->search |=  SEARCH_FINDS;        appdata->search |=  SEARCH_FINDS;
1508      else      else
1509        appdata->search &= ~SEARCH_FINDS;        appdata->search &= ~SEARCH_FINDS;
1510    
1511      if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_id)))      if(check_button_get_active(context.in_id))
1512        appdata->search |=  SEARCH_ID;        appdata->search |=  SEARCH_ID;
1513      else      else
1514        appdata->search &= ~SEARCH_ID;        appdata->search &= ~SEARCH_ID;
1515    
1516      if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_name)))      if(check_button_get_active(context.in_name))
1517        appdata->search |=  SEARCH_NAME;        appdata->search |=  SEARCH_NAME;
1518      else      else
1519        appdata->search &= ~SEARCH_NAME;        appdata->search &= ~SEARCH_NAME;
1520    
1521      if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_desc)))      if(check_button_get_active(context.in_desc))
1522        appdata->search |=  SEARCH_DESC;        appdata->search |=  SEARCH_DESC;
1523      else      else
1524        appdata->search &= ~SEARCH_DESC;        appdata->search &= ~SEARCH_DESC;
1525    
1526      if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_owner)))      if(check_button_get_active(context.in_owner))
1527        appdata->search |=  SEARCH_OWNER;        appdata->search |=  SEARCH_OWNER;
1528      else      else
1529        appdata->search &= ~SEARCH_OWNER;        appdata->search &= ~SEARCH_OWNER;
# Line 1399  cb_menu_search(GtkWidget *window, gpoint Line 1536  cb_menu_search(GtkWidget *window, gpoint
1536    
1537        printf("Search for %s (flags = %x)...\n", p, appdata->search);        printf("Search for %s (flags = %x)...\n", p, appdata->search);
1538    
1539  #ifndef USE_BREAD_CRUMB_TRAIL  #if !defined(USE_BREAD_CRUMB_TRAIL) && !defined(BCT)
1540        gpx_t *found =        gpx_t *found =
1541          search_do(appdata, appdata->gpx, p, appdata->search, FALSE);          search_do(appdata, appdata->gpx, p, appdata->search, FALSE);
1542    
# Line 1433  cb_menu_search(GtkWidget *window, gpoint Line 1570  cb_menu_search(GtkWidget *window, gpoint
1570      gtk_widget_destroy(dialog);      gtk_widget_destroy(dialog);
1571  }  }
1572    
1573  void on_window_destroy (GtkWidget *widget, gpointer data);  static void on_window_destroy (GtkWidget *widget, gpointer data);
1574    
1575  #ifndef USE_MAEMO  #ifndef USE_MAEMO
1576  static void  static void
# Line 1493  static void Line 1630  static void
1630  cb_menu_export_log(GtkWidget *widget, gpointer data) {  cb_menu_export_log(GtkWidget *widget, gpointer data) {
1631    appdata_t *appdata = (appdata_t*)data;    appdata_t *appdata = (appdata_t*)data;
1632    notes_log_export(appdata);    notes_log_export(appdata);
 #ifdef USE_STACKABLE_WINDOW  
   hildon_window_stack_pop_1 (hildon_window_stack_get_default());  
 #endif  
1633  }  }
1634    
1635  #ifdef USE_MAEMO  #ifdef ENABLE_MAEMO_MAPPER
1636  static void  static void
1637  cb_menu_export_mmpoi(GtkWidget *widget, gpointer data) {  cb_menu_export_mmpoi(GtkWidget *widget, gpointer data) {
1638    appdata_t *appdata = (appdata_t*)data;    appdata_t *appdata = (appdata_t*)data;
1639    mmpoi_export(appdata);    mmpoi_export(appdata);
 #ifdef USE_STACKABLE_WINDOW  
   hildon_window_stack_pop_1 (hildon_window_stack_get_default());  
 #endif  
1640  }  }
1641  #endif  #endif
1642    
# Line 1513  static void Line 1644  static void
1644  cb_menu_export_garmin(GtkWidget *widget, gpointer data) {  cb_menu_export_garmin(GtkWidget *widget, gpointer data) {
1645    appdata_t *appdata = (appdata_t*)data;    appdata_t *appdata = (appdata_t*)data;
1646    garmin_export(appdata);    garmin_export(appdata);
 #ifdef USE_STACKABLE_WINDOW  
   hildon_window_stack_pop_1 (hildon_window_stack_get_default());  
 #endif  
1647  }  }
1648    
1649    #ifdef ENABLE_OSM_GPS_MAP
1650    static void
1651    cb_menu_map(GtkWidget *window, gpointer data) {
1652      map((appdata_t *)data);
1653    }
1654    #endif
1655    
1656  static void  static void
1657  cb_menu_geomath(GtkWidget *window, gpointer data) {  cb_menu_geomath(GtkWidget *window, gpointer data) {
1658    geomath_dialog((appdata_t *)data);    geomath_dialog((appdata_t *)data);
 #ifdef USE_STACKABLE_WINDOW  
   hildon_window_stack_pop_1 (hildon_window_stack_get_default());  
 #endif  
1659  }  }
1660    
1661  static void  static void
1662  cb_menu_geotext(GtkWidget *window, gpointer data) {  cb_menu_geotext(GtkWidget *window, gpointer data) {
1663    geotext_dialog((appdata_t *)data);    geotext_dialog((appdata_t *)data);
 #ifdef USE_STACKABLE_WINDOW  
   hildon_window_stack_pop_1 (hildon_window_stack_get_default());  
 #endif  
1664  }  }
1665    
1666  static void  static void
1667  cb_menu_precpos(GtkWidget *window, gpointer data) {  cb_menu_precpos(GtkWidget *window, gpointer data) {
1668    precise_position((appdata_t *)data);    precise_position((appdata_t *)data);
 #ifdef USE_STACKABLE_WINDOW  
   hildon_window_stack_pop_1 (hildon_window_stack_get_default());  
 #endif  
1669  }  }
1670    
1671  #ifdef USE_STACKABLE_WINDOW  #ifdef USE_STACKABLE_WINDOW
1672  static GtkWidget *export_menu_create(appdata_t *appdata) {  typedef struct {
1673    GtkWidget *button;    char *label, *desc;
1674    HildonAppMenu *menu = HILDON_APP_MENU(hildon_app_menu_new());    GtkSignalFunc activate_cb;
1675    } menu_entry_t;
   button = hildon_button_new_with_text(  
             HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,  
             HILDON_BUTTON_ARRANGEMENT_VERTICAL,  
             _("Export to Maemo Mapper"),  
             _("Save a Maemo Mapper POI file"));  
   g_signal_connect(button, "clicked",  
                    G_CALLBACK(cb_menu_export_mmpoi), appdata);  
   hildon_app_menu_append(menu, GTK_BUTTON(button));  
1676    
1677    button = hildon_button_new_with_text(  typedef struct {
1678              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,    const char *title;
1679              HILDON_BUTTON_ARRANGEMENT_VERTICAL,    const menu_entry_t *menu;
1680              _("Export Field Notes"),    int len;
1681              _("Save a Garmin Field Notes file"));  } submenu_t;
   g_signal_connect(button, "clicked",  
                    G_CALLBACK(cb_menu_export_log), appdata);  
   hildon_app_menu_append(menu, GTK_BUTTON(button));  
1682    
1683    button = hildon_button_new_with_text(  #define COLUMNS  1
             HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,  
             HILDON_BUTTON_ARRANGEMENT_VERTICAL,  
             _("Export Garmin GPX"),  
             _("Save modified waypoints in GPX file"));  
   g_signal_connect(button, "clicked",  
                    G_CALLBACK(cb_menu_export_garmin), appdata);  
   hildon_app_menu_append(menu, GTK_BUTTON(button));  
1684    
1685    gtk_widget_show_all(GTK_WIDGET(menu));  void on_submenu_entry_clicked(GtkButton *button, GtkWidget *menu) {
1686    
1687    return GTK_WIDGET(menu);    /* force closing of submenu dialog */
1688      gtk_dialog_response(GTK_DIALOG(menu), GTK_RESPONSE_NONE);
1689      gtk_widget_hide(menu);
1690    
1691      /* let gtk clean up */
1692      while(gtk_events_pending())
1693        gtk_main_iteration();
1694  }  }
1695    
1696  /* the export submenu */  static GtkWidget *app_submenu_create(appdata_t *appdata,
1697  void on_export_clicked(GtkButton *button, appdata_t *appdata) {                                       const submenu_t *submenu) {
   if(!appdata->export_menu)  
     appdata->export_menu = export_menu_create(appdata);  
1698    
1699    /* draw a popup menu */    /* create a oridinary dialog box */
1700    hildon_app_menu_popup(HILDON_APP_MENU(appdata->export_menu),    GtkWidget *dialog = gtk_dialog_new();
1701                          GTK_WINDOW(hildon_window_stack_peek(    gtk_window_set_title(GTK_WINDOW(dialog), _(submenu->title));
1702                      hildon_window_stack_get_default())));    gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
1703  }    gtk_window_set_transient_for(GTK_WINDOW(dialog),
1704                                   GTK_WINDOW(appdata->window));
1705      gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
1706    
1707  static GtkWidget *tools_menu_create(appdata_t *appdata) {    GtkWidget *table = gtk_table_new(submenu->len/COLUMNS, COLUMNS, TRUE);
1708    GtkWidget *button;    int x = 0, y = 0;
1709    HildonAppMenu *menu = HILDON_APP_MENU(hildon_app_menu_new());  
1710      const menu_entry_t *menu_entries = submenu->menu;
1711      while(menu_entries->label) {
1712        GtkWidget *button = NULL;
1713    
1714    button = hildon_button_new_with_text(      button = hildon_button_new_with_text(
1715              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,
1716              HILDON_BUTTON_ARRANGEMENT_VERTICAL,              HILDON_BUTTON_ARRANGEMENT_VERTICAL,
1717              _("Geomath"),              _(menu_entries->label), _(menu_entries->desc));
             _("Geocoordinate calculation"));  
   g_signal_connect(button, "clicked",  
                    G_CALLBACK(cb_menu_geomath), appdata);  
   hildon_app_menu_append(menu, GTK_BUTTON(button));  
1718    
1719        /* try to center both texts */
1720        hildon_button_set_title_alignment(HILDON_BUTTON(button), 0.5, 0.5);
1721        hildon_button_set_value_alignment(HILDON_BUTTON(button), 0.5, 0.5);
1722    
1723    button = hildon_button_new_with_text(      g_signal_connect(button, "clicked",
1724              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,                       G_CALLBACK(on_submenu_entry_clicked), dialog);
1725              HILDON_BUTTON_ARRANGEMENT_VERTICAL,  
1726              _("Geotext"),      g_signal_connect(button, "clicked",
1727              _("Text analysis"));                       menu_entries->activate_cb, appdata);
1728    g_signal_connect(button, "clicked",  
1729                     G_CALLBACK(cb_menu_geotext), appdata);      gtk_table_attach_defaults(GTK_TABLE(table),  button, x, x+1, y, y+1);
1730    hildon_app_menu_append(menu, GTK_BUTTON(button));  
1731        x++;
1732        if(x == COLUMNS) { x = 0; y++; }
1733    
1734    button = hildon_button_new_with_text(      menu_entries++;
1735              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,    }
             HILDON_BUTTON_ARRANGEMENT_VERTICAL,  
             _("Precise Position"),  
             _("Calculate a precise GPS position"));  
   g_signal_connect(button, "clicked",  
                    G_CALLBACK(cb_menu_precpos), appdata);  
   hildon_app_menu_append(menu, GTK_BUTTON(button));  
1736    
1737    gtk_widget_show_all(GTK_WIDGET(menu));    gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table);
1738    
1739    return GTK_WIDGET(menu);    return dialog;
1740  }  }
1741    
1742    /* popup the dialog shaped submenu */
1743    static void submenu_popup(GtkWidget *menu) {
1744      gtk_widget_show_all(menu);
1745      gtk_dialog_run(GTK_DIALOG(menu));
1746      gtk_widget_hide(menu);
1747    }
1748    
1749    static void submenu_cleanup(GtkWidget *menu) {
1750      gtk_widget_destroy(menu);
1751    }
1752    
1753    static const menu_entry_t submenu_export_entries[] = {
1754    #ifdef ENABLE_MAEMO_MAPPER
1755      { "Export to Maemo Mapper" , "Save a Maemo Mapper POI file",
1756        G_CALLBACK(cb_menu_export_mmpoi)  },
1757    #endif
1758      { "Export Field Notes",      "Save a Garmin Field Notes file",
1759        G_CALLBACK(cb_menu_export_log)    },
1760      { "Export Garmin GPX",       "Save modified waypoints in GPX file",
1761        G_CALLBACK(cb_menu_export_garmin) },
1762      { NULL, NULL, NULL }
1763    };
1764    
1765    static const submenu_t submenu_export = {
1766      "Export", submenu_export_entries,
1767      sizeof(submenu_export_entries)/sizeof(menu_entry_t)-1
1768    };
1769    
1770    /* the export submenu */
1771    void on_export_clicked(GtkButton *button, appdata_t *appdata) {
1772      if(!appdata->export_menu)
1773        appdata->export_menu = app_submenu_create(appdata, &submenu_export);
1774    
1775      submenu_popup(appdata->export_menu);
1776    }
1777    
1778    static const menu_entry_t submenu_tools_entries[] = {
1779      { "Geomath",          "Geocoordinate calculation",
1780        G_CALLBACK(cb_menu_geomath) },
1781      { "Geotext",          "Text analysis",
1782        G_CALLBACK(cb_menu_geotext) },
1783      { "Precise Position", "Calculate a precise GPS position",
1784        G_CALLBACK(cb_menu_precpos) },
1785      { NULL, NULL, NULL }
1786    };
1787    
1788    static const submenu_t submenu_tools = {
1789      "Tools", submenu_tools_entries,
1790      sizeof(submenu_tools_entries)/sizeof(menu_entry_t)-1
1791    };
1792    
1793  /* the tools submenu */  /* the tools submenu */
1794  void on_tools_clicked(GtkButton *button, appdata_t *appdata) {  void on_tools_clicked(GtkButton *button, appdata_t *appdata) {
1795    if(!appdata->tools_menu)    if(!appdata->tools_menu)
1796      appdata->tools_menu = tools_menu_create(appdata);      appdata->tools_menu = app_submenu_create(appdata, &submenu_tools);
1797    
1798    /* draw a popup menu */    submenu_popup(appdata->tools_menu);
   hildon_app_menu_popup(HILDON_APP_MENU(appdata->tools_menu),  
                         GTK_WINDOW(hildon_window_stack_peek(  
                     hildon_window_stack_get_default())));  
1799  }  }
1800    
   
1801  HildonAppMenu *menu_create(appdata_t *appdata, int mode) {  HildonAppMenu *menu_create(appdata_t *appdata, int mode) {
1802    GtkWidget *button;    GtkWidget *button;
1803    HildonAppMenu *menu = HILDON_APP_MENU(hildon_app_menu_new());    HildonAppMenu *menu = HILDON_APP_MENU(hildon_app_menu_new());
# Line 1665  HildonAppMenu *menu_create(appdata_t *ap Line 1823  HildonAppMenu *menu_create(appdata_t *ap
1823      g_signal_connect_after(button, "clicked",      g_signal_connect_after(button, "clicked",
1824                             G_CALLBACK(cb_menu_adddir), appdata);                             G_CALLBACK(cb_menu_adddir), appdata);
1825      hildon_app_menu_append(menu, GTK_BUTTON(button));      hildon_app_menu_append(menu, GTK_BUTTON(button));
   }  
1826    
   if(mode == MENU_GPXLIST) {  
1827      button = gtk_button_new_with_label(_("Export"));      button = gtk_button_new_with_label(_("Export"));
1828      g_signal_connect_after(button, "clicked",      g_signal_connect_after(button, "clicked",
1829                             G_CALLBACK(on_export_clicked), appdata);                             G_CALLBACK(on_export_clicked), appdata);
# Line 1684  HildonAppMenu *menu_create(appdata_t *ap Line 1840  HildonAppMenu *menu_create(appdata_t *ap
1840                           G_CALLBACK(on_tools_clicked), appdata);                           G_CALLBACK(on_tools_clicked), appdata);
1841    hildon_app_menu_append(menu, GTK_BUTTON(button));    hildon_app_menu_append(menu, GTK_BUTTON(button));
1842    
1843    #ifdef ENABLE_OSM_GPS_MAP
1844        button = gtk_button_new_with_label(_("Map"));
1845        g_signal_connect_after(button, "clicked",
1846                               G_CALLBACK(cb_menu_map), appdata);
1847        hildon_app_menu_append(menu, GTK_BUTTON(button));
1848    #endif
1849    
1850  #ifdef HILDON_HELP  #ifdef HILDON_HELP
1851    button = gtk_button_new_with_label(_("Help"));    button = gtk_button_new_with_label(_("Help"));
1852    g_signal_connect_after(button, "clicked",    g_signal_connect_after(button, "clicked",
# Line 1701  void menu_create(appdata_t *appdata) { Line 1864  void menu_create(appdata_t *appdata) {
1864    GtkWidget *menu, *item;    GtkWidget *menu, *item;
1865    menu = gtk_menu_new();    menu = gtk_menu_new();
1866    
1867  #ifdef USE_BREAD_CRUMB_TRAIL  #if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT)
1868    appdata->menu_import =    appdata->menu_import =
1869  #endif  #endif
1870    item = gtk_menu_item_new_with_label(_("Import"));    item = gtk_menu_item_new_with_label(_("Import"));
# Line 1731  void menu_create(appdata_t *appdata) { Line 1894  void menu_create(appdata_t *appdata) {
1894    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_remove), appdata);    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_remove), appdata);
1895  #endif  #endif
1896    
1897  #ifdef USE_BREAD_CRUMB_TRAIL  #if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT)
1898    appdata->menu_export =    appdata->menu_export =
1899  #endif  #endif
1900      item = gtk_menu_item_new_with_label(_("Export"));      item = gtk_menu_item_new_with_label(_("Export"));
# Line 1739  void menu_create(appdata_t *appdata) { Line 1902  void menu_create(appdata_t *appdata) {
1902    submenu = gtk_menu_new();    submenu = gtk_menu_new();
1903    gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);    gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
1904    
1905  #ifdef USE_MAEMO  #ifdef ENABLE_MAEMO_MAPPER
1906    item = gtk_menu_item_new_with_label( _("Maemo Mapper POI") );    item = gtk_menu_item_new_with_label( _("Maemo Mapper POI") );
1907    gtk_menu_append(GTK_MENU_SHELL(submenu), item);    gtk_menu_append(GTK_MENU_SHELL(submenu), item);
1908    g_signal_connect(item, "activate",    g_signal_connect(item, "activate",
# Line 1756  void menu_create(appdata_t *appdata) { Line 1919  void menu_create(appdata_t *appdata) {
1919    g_signal_connect(item, "activate",    g_signal_connect(item, "activate",
1920                     GTK_SIGNAL_FUNC(cb_menu_export_garmin), appdata);                     GTK_SIGNAL_FUNC(cb_menu_export_garmin), appdata);
1921    
1922  #ifdef USE_BREAD_CRUMB_TRAIL  #if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT)
1923    appdata->menu_search =    appdata->menu_search =
1924  #endif  #endif
1925    item = gtk_menu_item_new_with_label( _("Search") );    item = gtk_menu_item_new_with_label( _("Search") );
# Line 1765  void menu_create(appdata_t *appdata) { Line 1928  void menu_create(appdata_t *appdata) {
1928    
1929    gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new());    gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new());
1930    
 #ifndef NO_COPY_N_PASTE  
1931    /* ----------- copy'n paste submenu ----------------- */    /* ----------- copy'n paste submenu ----------------- */
1932    appdata->clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);  #ifndef NO_COPY_N_PASTE
   gtk_clipboard_set_can_store(appdata->clipboard, NULL, 0);  
   
1933    item = gtk_menu_item_new_with_label(_("Edit"));    item = gtk_menu_item_new_with_label(_("Edit"));
1934    gtk_menu_append(GTK_MENU_SHELL(menu), item);    gtk_menu_append(GTK_MENU_SHELL(menu), item);
1935    submenu = gtk_menu_new();    submenu = gtk_menu_new();
# Line 1796  void menu_create(appdata_t *appdata) { Line 1956  void menu_create(appdata_t *appdata) {
1956    
1957    gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new());    gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new());
1958    
1959    #ifdef ENABLE_OSM_GPS_MAP
1960      item = gtk_menu_item_new_with_label( _("Map") );
1961      gtk_menu_append(GTK_MENU_SHELL(menu), item);
1962      g_signal_connect(item, "activate",
1963                       GTK_SIGNAL_FUNC(cb_menu_map), appdata);
1964    #endif
1965    
1966    item = gtk_menu_item_new_with_label(_("Tools"));    item = gtk_menu_item_new_with_label(_("Tools"));
1967    gtk_menu_append(GTK_MENU_SHELL(menu), item);    gtk_menu_append(GTK_MENU_SHELL(menu), item);
1968    submenu = gtk_menu_new();    submenu = gtk_menu_new();
# Line 1860  void cleanup(appdata_t *appdata) { Line 2027  void cleanup(appdata_t *appdata) {
2027    if(appdata->image_path) free(appdata->image_path);    if(appdata->image_path) free(appdata->image_path);
2028    if(appdata->search_str) free(appdata->search_str);    if(appdata->search_str) free(appdata->search_str);
2029    
2030    #ifdef USE_STACKABLE_WINDOW
2031      if(appdata->export_menu) submenu_cleanup(appdata->export_menu);
2032      if(appdata->tools_menu)  submenu_cleanup(appdata->tools_menu);
2033    #endif
2034    
2035    gnome_vfs_shutdown();    gnome_vfs_shutdown();
2036    icons_free();    icons_free();
2037    gps_release(appdata);    gps_release(appdata);
# Line 1888  void cleanup(appdata_t *appdata) { Line 2060  void cleanup(appdata_t *appdata) {
2060    puts("everything is gone");    puts("everything is gone");
2061  }  }
2062    
2063  void on_window_destroy (GtkWidget *widget, gpointer data) {  static void on_window_destroy (GtkWidget *widget, gpointer data) {
2064    appdata_t *appdata = (appdata_t*)data;    appdata_t *appdata = (appdata_t*)data;
2065    
2066    gconf_save_state(appdata);    gconf_save_state(appdata);
# Line 1951  gboolean on_window_key_press(GtkWidget * Line 2123  gboolean on_window_key_press(GtkWidget *
2123    return handled;    return handled;
2124  }  }
2125    
2126  #ifdef USE_BREAD_CRUMB_TRAIL  #if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT)
2127  typedef struct {  typedef struct {
2128    int level;    int level;
2129    appdata_t *appdata;    appdata_t *appdata;
# Line 2043  crumb_back(gpointer data) { Line 2215  crumb_back(gpointer data) {
2215    
2216    gtk_widget_show_all(crumb->appdata->vbox);    gtk_widget_show_all(crumb->appdata->vbox);
2217    g_free(data);    g_free(data);
2218    
2219    #ifdef ENABLE_OSM_GPS_MAP
2220      map_update(crumb->appdata);
2221    #endif
2222  }  }
2223    
2224  static void crumb_add(appdata_t *appdata, char *name, int level,  static void crumb_add(appdata_t *appdata, char *name, int level,
# Line 2083  static void crumb_add(appdata_t *appdata Line 2259  static void crumb_add(appdata_t *appdata
2259  #endif  #endif
2260    }    }
2261    
2262    #ifdef USE_BREAD_CRUMB_TRAIL
2263    hildon_bread_crumb_trail_push_text(HILDON_BREAD_CRUMB_TRAIL(appdata->bct),    hildon_bread_crumb_trail_push_text(HILDON_BREAD_CRUMB_TRAIL(appdata->bct),
2264                                       name, crumb, (GDestroyNotify)crumb_back);                                       name, crumb, (GDestroyNotify)crumb_back);
2265    #else
2266      bct_push_text(appdata->bct, name, crumb, (GDestroyNotify)crumb_back);
2267    #endif
2268    
2269    #ifdef ENABLE_OSM_GPS_MAP
2270      map_update(appdata);
2271    #endif
2272  }  }
2273  #endif // USE_BREAD_CRUMB_TRAIL  #endif // USE_BREAD_CRUMB_TRAIL
2274    
# Line 2096  void main_after_settings_redraw(appdata_ Line 2280  void main_after_settings_redraw(appdata_
2280      return;      return;
2281    }    }
2282    
 #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  
2283    /* 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 */
2284    /* need to be redrawn */    /* need to be redrawn */
2285    if(appdata->cur_cache) {    if(appdata->cur_cache) {
# Line 2162  void main_after_settings_redraw(appdata_ Line 2334  void main_after_settings_redraw(appdata_
2334    
2335      gtk_widget_show_all(container);      gtk_widget_show_all(container);
2336    }    }
 #endif // USE_MAEMO  
2337  }  }
2338    
2339  int main(int argc, char *argv[]) {  int main(int argc, char *argv[]) {
# Line 2183  int main(int argc, char *argv[]) { Line 2354  int main(int argc, char *argv[]) {
2354    
2355    gtk_init (&argc, &argv);    gtk_init (&argc, &argv);
2356    
2357      curl_global_init(CURL_GLOBAL_ALL);
2358    
2359  #ifdef USE_MAEMO  #ifdef USE_MAEMO
2360    printf("Installing osso context for \"org.harbaum." APP "\"\n");    printf("Installing osso context for \"org.harbaum." APP "\"\n");
2361    appdata.osso_context = osso_initialize("org.harbaum."APP,    appdata.osso_context = osso_initialize("org.harbaum."APP,
# Line 2191  int main(int argc, char *argv[]) { Line 2364  int main(int argc, char *argv[]) {
2364      fprintf(stderr, "error initiating osso context\n");      fprintf(stderr, "error initiating osso context\n");
2365    }    }
2366    
2367    #ifdef ENABLE_MAEMO_MAPPER
2368    dbus_register(&appdata);    dbus_register(&appdata);
2369  #endif  #endif
2370    #endif
2371    
2372    icons_init();    icons_init();
2373    
# Line 2216  int main(int argc, char *argv[]) { Line 2391  int main(int argc, char *argv[]) {
2391    /* Create a Window. */    /* Create a Window. */
2392    appdata.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);    appdata.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2393    /* Set a decent default size for the window. */    /* Set a decent default size for the window. */
2394    gtk_window_set_default_size(GTK_WINDOW(appdata.window), 500, 300);    gtk_window_set_default_size(GTK_WINDOW(appdata.window), 640, 480);
2395  #endif  #endif
2396    
2397  #if MAEMO_VERSION_MAJOR == 5  #if MAEMO_VERSION_MAJOR == 5
# Line 2229  int main(int argc, char *argv[]) { Line 2404  int main(int argc, char *argv[]) {
2404    g_signal_connect(G_OBJECT(appdata.window), "key_press_event",    g_signal_connect(G_OBJECT(appdata.window), "key_press_event",
2405                     G_CALLBACK(on_window_key_press), &appdata);                     G_CALLBACK(on_window_key_press), &appdata);
2406    
2407      /* prepare clipboard */
2408      appdata.clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
2409      gtk_clipboard_set_can_store(appdata.clipboard, NULL, 0);
2410    
2411    appdata.vbox = gtk_vbox_new(FALSE, 2);    appdata.vbox = gtk_vbox_new(FALSE, 2);
2412    gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox);    gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox);
   
2413  #ifndef USE_STACKABLE_WINDOW  #ifndef USE_STACKABLE_WINDOW
2414    menu_create(&appdata);    menu_create(&appdata);
2415  #else  #else
# Line 2245  int main(int argc, char *argv[]) { Line 2423  int main(int argc, char *argv[]) {
2423    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);
2424    
2425    hildon_bread_crumb_trail_clear(HILDON_BREAD_CRUMB_TRAIL(appdata.bct));    hildon_bread_crumb_trail_clear(HILDON_BREAD_CRUMB_TRAIL(appdata.bct));
2426    #else
2427    #ifdef BCT
2428      /* on non-hildon machines we use some custom made breadcrumbtrail */
2429      /* replacement */
2430      appdata.bct = bct_new();
2431      gtk_box_pack_start(GTK_BOX(appdata.vbox), appdata.bct, FALSE,FALSE,0);
2432    #endif
2433    #endif
2434    
2435    #if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT)
2436    crumb_add(&appdata, "GPX", CRUMB_GPXLIST, NULL);    crumb_add(&appdata, "GPX", CRUMB_GPXLIST, NULL);
2437  #endif  #endif
2438    

Legend:
Removed from v.20  
changed lines
  Added in v.189