Diff of /trunk/src/main.c

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

revision 12 by harbaum, Fri Jun 26 20:07:33 2009 UTC revision 129 by harbaum, Tue Sep 29 14:30:16 2009 UTC
# Line 35  Line 35 
35    
36  extern char *strcasestr (__const char *__haystack, __const char *__needle);  extern char *strcasestr (__const char *__haystack, __const char *__needle);
37    
38  #ifdef USE_BREAD_CRUMB_TRAIL  #if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT)
39  static void crumb_add(appdata_t *appdata, char *name, int level,  static void crumb_add(appdata_t *appdata, char *name, int level,
40                        gpointer user_data);                        gpointer user_data);
41    
# Line 95  void errorf(const char *fmt, ...) { Line 95  void errorf(const char *fmt, ...) {
95    GtkWidget *dialog = gtk_message_dialog_new(    GtkWidget *dialog = gtk_message_dialog_new(
96                             GTK_WINDOW(NULL),                             GTK_WINDOW(NULL),
97                             GTK_DIALOG_DESTROY_WITH_PARENT,                             GTK_DIALOG_DESTROY_WITH_PARENT,
98                             GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,  #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
99                             buf);                             GTK_MESSAGE_ERROR,
100    #else
101                               GTK_MESSAGE_OTHER,
102    #endif
103                               GTK_BUTTONS_CLOSE, buf);
104    
105    gtk_window_set_title(GTK_WINDOW(dialog), _("ERROR"));    gtk_window_set_title(GTK_WINDOW(dialog), _("ERROR"));
106    
# Line 138  gpx_t *choose_file(appdata_t *appdata, g Line 142  gpx_t *choose_file(appdata_t *appdata, g
142    gtk_widget_show_all (GTK_WIDGET(dialog));    gtk_widget_show_all (GTK_WIDGET(dialog));
143    if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_FM_OK) {    if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_FM_OK) {
144      char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));      char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
145    
146        if(filename) {
147          gpx_dialog_t *dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window));
148    
149      gpx_dialog_t *dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window));        if(!whole_dir)
150            gpx = gpx_parse(dialog, filename);
151      if(!whole_dir)        else {
152        gpx = gpx_parse(dialog, filename);          /* cur trailing '/' if present */
153      else {          if(strlastchr(filename) == '/')
154        /* cur trailing '/' if present */            filename[strlen(filename)] = 0;
155        if(strlastchr(filename) == '/')  
156          filename[strlen(filename)] = 0;          gpx = gpx_parse_dir(dialog, filename);
   
       gpx = gpx_parse_dir(dialog, filename);  
     }  
   
     gpx_busy_dialog_destroy(dialog);  
   
     /* save path if gpx was successfully loaded */  
     if(gpx) {  
       char *r = strrchr(filename, '/');  
   
       /* there is a delimiter, use everything left of it as path */  
       if(r && !whole_dir) {  
         *r = 0;  
         if(appdata->path) free(appdata->path);  
         appdata->path = strdup(filename);  
         /* restore path ... just in case ... */  
         *r = '/';  
157        }        }
158    
159          gpx_busy_dialog_destroy(dialog);
160    
161          /* save path if gpx was successfully loaded */
162          if(gpx) {
163            char *r = strrchr(filename, '/');
164    
165            /* there is a delimiter, use everything left of it as path */
166            if(r && !whole_dir) {
167              *r = 0;
168              if(appdata->path) free(appdata->path);
169              appdata->path = strdup(filename);
170              /* restore path ... just in case ... */
171              *r = '/';
172            }
173    
174            if(whole_dir)
175              appdata->path = strdup(filename);
176          } else
177            errorf(_("Load error"));
178    
179        if(whole_dir)        g_free (filename);
180          appdata->path = strdup(filename);      } else {
181    #ifndef USE_MAEMO
182          errorf(_("Error accessing the file."));
183    #else
184          errorf(_("Error accessing the file. This may happen if the file "
185                   "resides on a remote file system. Please copy the file onto "
186                   "the device (e.g. onto the memory card) and try again."));
187    #endif
188      }      }
   
     g_free (filename);  
189    }    }
190    
191    gtk_widget_destroy (dialog);    gtk_widget_destroy (dialog);
# Line 202  void cachelist_view_onRowActivated(GtkTr Line 217  void cachelist_view_onRowActivated(GtkTr
217    GtkTreeIter   iter;    GtkTreeIter   iter;
218    GtkTreeModel *model = gtk_tree_view_get_model(treeview);    GtkTreeModel *model = gtk_tree_view_get_model(treeview);
219    
220    #ifdef USE_MAEMO
221      /* check if a cache is already selected and ignore click if yes */
222      /* (was probably a double click) */
223      if(appdata->cur_cache) return;
224    #endif
225    
226    if(gtk_tree_model_get_iter(model, &iter, path)) {    if(gtk_tree_model_get_iter(model, &iter, path)) {
227      cache_t *cache;      cache_t *cache;
228      gtk_tree_model_get(model, &iter, CACHELIST_COL_DATA, &cache, -1);      gtk_tree_model_get(model, &iter, CACHELIST_COL_DATA, &cache, -1);
229  #ifndef USE_BREAD_CRUMB_TRAIL  #if !defined(USE_BREAD_CRUMB_TRAIL) && !defined(BCT)
230      cache_dialog(appdata, cache);      cache_dialog(appdata, cache);
231  #else  #else
232      gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view);      gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view);
# Line 257  static GtkWidget *cachelist_create(appda Line 278  static GtkWidget *cachelist_create(appda
278                                     cache_t *sel_cache);                                     cache_t *sel_cache);
279    
280  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  
   
281    if(!appdata->cur_view) {    if(!appdata->cur_view) {
282      printf("cachelist redraw: no active view\n");      printf("cachelist redraw: no active view\n");
283      return;      return;
# Line 281  void cachelist_redraw(appdata_t *appdata Line 295  void cachelist_redraw(appdata_t *appdata
295    if(redraw) {    if(redraw) {
296      GtkWidget *container = appdata->vbox;      GtkWidget *container = appdata->vbox;
297    
     printf("redraw %d\n", redraw);  
   
298  #ifdef USE_STACKABLE_WINDOW  #ifdef USE_STACKABLE_WINDOW
299      HildonWindowStack *stack = hildon_window_stack_get_default();      HildonWindowStack *stack = hildon_window_stack_get_default();
300      container = hildon_window_stack_peek(stack);      container = hildon_window_stack_peek(stack);
# Line 309  void cachelist_redraw(appdata_t *appdata Line 321  void cachelist_redraw(appdata_t *appdata
321    
322      gtk_widget_show_all(container);      gtk_widget_show_all(container);
323    }    }
 #endif  
324  }  }
325    
326    
# Line 317  static gboolean cachelist_update(gpointe Line 328  static gboolean cachelist_update(gpointe
328    
329    printf("cachelist timer fired!\n");    printf("cachelist timer fired!\n");
330    
 #ifdef USE_MAEMO  
331    appdata_t *appdata = (appdata_t*)data;    appdata_t *appdata = (appdata_t*)data;
332    
333    if(appdata->cur_cache)    if(appdata->cur_cache)
334      return TRUE;      return TRUE;
335    
336    #ifdef USE_MAEMO
337    if(appdata->cachelist_disable_screensaver)    if(appdata->cachelist_disable_screensaver)
338      if (osso_display_blanking_pause(appdata->osso_context) != OSSO_OK)      if (osso_display_blanking_pause(appdata->osso_context) != OSSO_OK)
339        fprintf(stderr, "error with display blank\n");        fprintf(stderr, "error with display blank\n");
340    #endif
341    
342    if(appdata->cachelist_update)    if(appdata->cachelist_update)
343      cachelist_redraw(appdata);      cachelist_redraw(appdata);
 #endif  
344    
345    return TRUE;    return TRUE;
346  }  }
# Line 524  static GtkWidget *cachelist_create(appda Line 535  static GtkWidget *cachelist_create(appda
535    appdata->cachelist_handler_id =    appdata->cachelist_handler_id =
536      gtk_timeout_add(CACHELIST_UPDATE_TIMEOUT, cachelist_update, appdata);      gtk_timeout_add(CACHELIST_UPDATE_TIMEOUT, cachelist_update, appdata);
537    
538    #ifdef ENABLE_OSM_GPS_MAP
539      map_update(appdata);
540    #endif
541    
542    /* update timer is being reset if the user scrolls or selects */    /* update timer is being reset if the user scrolls or selects */
543    g_signal_connect(view, "button-press-event",    g_signal_connect(view, "button-press-event",
544                     (GCallback)cachelist_update_reset0, appdata);                     (GCallback)cachelist_update_reset0, appdata);
# Line 587  void cachelist_dialog(appdata_t *appdata Line 602  void cachelist_dialog(appdata_t *appdata
602    g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view);    g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view);
603    
604    appdata->cur_gpx = gpx;    appdata->cur_gpx = gpx;
605    char *title = g_strdup_printf("GPXView - %s", gpx->name);    char *title = g_strdup_printf("%s - GPXView", gpx->name);
606    gtk_window_set_title(GTK_WINDOW(window), title);    gtk_window_set_title(GTK_WINDOW(window), title);
607    g_free(title);    g_free(title);
608    
# Line 713  static void gpxlist_view_onRowActivated( Line 728  static void gpxlist_view_onRowActivated(
728    GtkTreeIter   iter;    GtkTreeIter   iter;
729    GtkTreeModel *model = gtk_tree_view_get_model(treeview);    GtkTreeModel *model = gtk_tree_view_get_model(treeview);
730    
731    #ifdef USE_MAEMO
732      /* check if a cache is already selected and ignore click if yes */
733      /* (was probably a double click) */
734      if(appdata->cur_gpx) return;
735    #endif
736    
737    if (gtk_tree_model_get_iter(model, &iter, path)) {    if (gtk_tree_model_get_iter(model, &iter, path)) {
738      gpx_t *gpx;      gpx_t *gpx;
739      gtk_tree_model_get(model, &iter, GPXLIST_COL_DATA, &gpx, -1);      gtk_tree_model_get(model, &iter, GPXLIST_COL_DATA, &gpx, -1);
# Line 810  static void gpxlist_view_onRowActivated( Line 831  static void gpxlist_view_onRowActivated(
831    
832          gpx_busy_dialog_destroy(dialog);          gpx_busy_dialog_destroy(dialog);
833        }        }
834  #ifndef USE_BREAD_CRUMB_TRAIL  #if !defined(USE_BREAD_CRUMB_TRAIL) && !defined(BCT)
835  #ifdef USE_STACKABLE_WINDOW  #ifdef USE_STACKABLE_WINDOW
836        if(!appdata->cur_gpx)        if(!appdata->cur_gpx)
837  #endif  #endif
# Line 957  static GtkWidget *gpxlist_create_view_an Line 978  static GtkWidget *gpxlist_create_view_an
978      GtkTreeIter         iter;      GtkTreeIter         iter;
979      gtk_list_store_append(appdata->gpxstore, &iter);      gtk_list_store_append(appdata->gpxstore, &iter);
980      gpxlist_set(appdata->gpxstore, &iter, gpx);      gpxlist_set(appdata->gpxstore, &iter, gpx);
981    
982      if(gpx == sel_gpx) {      if(gpx == sel_gpx) {
983        sel_iter = iter;        sel_iter = iter;
984        sel_iter_valid = TRUE;        sel_iter_valid = TRUE;
# Line 1017  static void gpxlist_add(appdata_t *appda Line 1038  static void gpxlist_add(appdata_t *appda
1038    
1039  /******************** begin of menu *********************/  /******************** begin of menu *********************/
1040    
1041    typedef struct {
1042      appdata_t *appdata;
1043      GtkWidget *dialog;
1044    } about_context_t;
1045    
1046    #ifdef ENABLE_BROWSER_INTERFACE
1047    void on_paypal_button_clicked(GtkButton *button, about_context_t *context) {
1048      gtk_dialog_response(GTK_DIALOG(context->dialog), GTK_RESPONSE_ACCEPT);
1049      browser_url(context->appdata,
1050                  "https://www.paypal.com/cgi-bin/webscr"
1051                  "?cmd=_s-xclick&hosted_button_id=7400558");
1052    }
1053    #endif
1054    
1055  static void  static void
1056  cb_menu_about(GtkWidget *window, gpointer data) {  cb_menu_about(GtkWidget *window, gpointer data) {
1057    GtkAboutDialog *about = GTK_ABOUT_DIALOG(gtk_about_dialog_new());    about_context_t context;
1058    
1059      context.appdata = (appdata_t *)data;
1060    
1061    #ifdef ENABLE_LIBLOCATION
1062      char *uses = "uses liblocation";
1063    #elif defined(ENABLE_GPSBT)
1064      char *uses = "uses gpsbt and gpsd";
1065    #else
1066      char *uses = "uses gpsd";
1067    #endif
1068    
1069      const gchar *authors[] = {
1070        "Till Harbaum <till@harbaum.org>",
1071        "John Stowers <john.stowers@gmail.com>",
1072        NULL };
1073    
1074      context.dialog = g_object_new(GTK_TYPE_ABOUT_DIALOG,
1075                            "name", "GPXView",
1076                            "version", VERSION,
1077                            "copyright", _("Copyright 2008-2009"),
1078                            "authors", authors,
1079                            "website", _("http://www.harbaum.org/till/maemo"),
1080                            "comments", _(uses),
1081                            NULL);
1082    
1083    gtk_about_dialog_set_name(about, "GPXView");  #ifdef ENABLE_BROWSER_INTERFACE
1084    gtk_about_dialog_set_version(about, VERSION);    /* add a way to donate to the project */
1085    gtk_about_dialog_set_copyright(about,    GtkWidget *alignment = gtk_alignment_new(0.5, 0, 0, 0);
1086           _("GPXView (c) 2008 by\n"  
1087           "Till Harbaum <till@harbaum.org>\n"    GtkWidget *hbox = gtk_hbox_new(FALSE, 8);
1088           "Geocaching.com: Tantil"));    gtk_box_pack_start(GTK_BOX(hbox),
1089                         gtk_label_new(_("Do you like GPXView?")),
1090    gtk_about_dialog_set_website(about,                       FALSE, FALSE, 0);
1091         _("http://www.harbaum.org/till/maemo"));  
1092      GtkWidget *button = gtk_button_new();
1093    gtk_about_dialog_set_comments(about,    gtk_button_set_image(GTK_BUTTON(button),
1094         _("Geocaching.com GPX file viewer"));                         icon_get_widget(ICON_MISC, 8));
1095      gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
1096    gtk_widget_show_all(GTK_WIDGET(about));    g_signal_connect(button, "clicked",
1097    gtk_dialog_run(GTK_DIALOG(about));                     G_CALLBACK(on_paypal_button_clicked), &context);
1098    gtk_widget_destroy(GTK_WIDGET(about));    gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1099    
1100      gtk_container_add(GTK_CONTAINER(alignment), hbox);
1101      gtk_box_pack_start_defaults(GTK_BOX((GTK_DIALOG(context.dialog))->vbox),
1102                                  alignment);
1103    
1104      gtk_widget_show_all(alignment);
1105    #endif
1106    
1107      gtk_dialog_run(GTK_DIALOG(context.dialog));
1108      gtk_widget_destroy(context.dialog);
1109  }  }
1110    
1111  #if defined(USE_MAEMO) && defined(HILDON_HELP)  #if defined(USE_MAEMO) && defined(HILDON_HELP)
# Line 1385  cb_menu_search(GtkWidget *window, gpoint Line 1454  cb_menu_search(GtkWidget *window, gpoint
1454    
1455        printf("Search for %s (flags = %x)...\n", p, appdata->search);        printf("Search for %s (flags = %x)...\n", p, appdata->search);
1456    
1457  #ifndef USE_BREAD_CRUMB_TRAIL  #if !defined(USE_BREAD_CRUMB_TRAIL) && !defined(BCT)
1458        gpx_t *found =        gpx_t *found =
1459          search_do(appdata, appdata->gpx, p, appdata->search, FALSE);          search_do(appdata, appdata->gpx, p, appdata->search, FALSE);
1460    
# Line 1419  cb_menu_search(GtkWidget *window, gpoint Line 1488  cb_menu_search(GtkWidget *window, gpoint
1488      gtk_widget_destroy(dialog);      gtk_widget_destroy(dialog);
1489  }  }
1490    
1491  void on_window_destroy (GtkWidget *widget, gpointer data);  static void on_window_destroy (GtkWidget *widget, gpointer data);
1492    
1493  #ifndef USE_MAEMO  #ifndef USE_MAEMO
1494  static void  static void
# Line 1481  cb_menu_export_log(GtkWidget *widget, gp Line 1550  cb_menu_export_log(GtkWidget *widget, gp
1550    notes_log_export(appdata);    notes_log_export(appdata);
1551  }  }
1552    
1553  #ifdef USE_MAEMO  #ifdef ENABLE_MAEMO_MAPPER
1554  static void  static void
1555  cb_menu_export_mmpoi(GtkWidget *widget, gpointer data) {  cb_menu_export_mmpoi(GtkWidget *widget, gpointer data) {
1556    appdata_t *appdata = (appdata_t*)data;    appdata_t *appdata = (appdata_t*)data;
# Line 1495  cb_menu_export_garmin(GtkWidget *widget, Line 1564  cb_menu_export_garmin(GtkWidget *widget,
1564    garmin_export(appdata);    garmin_export(appdata);
1565  }  }
1566    
1567    #ifdef ENABLE_OSM_GPS_MAP
1568    static void
1569    cb_menu_map(GtkWidget *window, gpointer data) {
1570      map((appdata_t *)data);
1571    }
1572    #endif
1573    
1574  static void  static void
1575  cb_menu_geomath(GtkWidget *window, gpointer data) {  cb_menu_geomath(GtkWidget *window, gpointer data) {
1576    geomath_dialog((appdata_t *)data);    geomath_dialog((appdata_t *)data);
# Line 1511  cb_menu_precpos(GtkWidget *window, gpoin Line 1587  cb_menu_precpos(GtkWidget *window, gpoin
1587  }  }
1588    
1589  #ifdef USE_STACKABLE_WINDOW  #ifdef USE_STACKABLE_WINDOW
1590  static void on_export_destroy(GtkWidget *widget, appdata_t *appdata) {  typedef struct {
1591    appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view");    char *label, *desc;
1592  }    GtkSignalFunc activate_cb;
1593    } menu_entry_t;
1594    
1595  void on_export_clicked(GtkButton *button, appdata_t *appdata) {  typedef struct {
1596    HildonStackableWindow *view_window;    const char *title;
1597    GtkWidget *but;    const menu_entry_t *menu;
1598      int len;
1599    } submenu_t;
1600    
1601    view_window = HILDON_STACKABLE_WINDOW (hildon_stackable_window_new ());  #define COLUMNS  1
   gtk_window_set_title (GTK_WINDOW (view_window), "GPXView - Export");  
1602    
1603     /* 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;  
1604    
1605    g_signal_connect(G_OBJECT(view_window), "destroy",    /* force closing of submenu dialog */
1606                     G_CALLBACK(on_export_destroy), appdata);    gtk_dialog_response(GTK_DIALOG(menu), GTK_RESPONSE_NONE);
1607      gtk_widget_hide(menu);
1608    
1609      /* let gtk clean up */
1610      while(gtk_events_pending())
1611        gtk_main_iteration();
1612    }
1613    
1614    GtkVBox *contents = GTK_VBOX(gtk_vbox_new (12, FALSE));  static GtkWidget *app_submenu_create(appdata_t *appdata,
1615                                         const submenu_t *submenu) {
1616    
1617    but = hildon_button_new_with_text(    /* create a oridinary dialog box */
1618              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,    GtkWidget *dialog = gtk_dialog_new();
1619              HILDON_BUTTON_ARRANGEMENT_VERTICAL,    gtk_window_set_title(GTK_WINDOW(dialog), _(submenu->title));
1620              _("Export to Maemo Mapper"),    gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
1621              _("Save a Maemo Mapper POI file"));    gtk_window_set_transient_for(GTK_WINDOW(dialog),
1622    g_signal_connect(but, "clicked",                                 GTK_WINDOW(appdata->window));
1623                     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);  
1624    
1625      GtkWidget *table = gtk_table_new(submenu->len/COLUMNS, COLUMNS, TRUE);
1626      int x = 0, y = 0;
1627    
1628    but = hildon_button_new_with_text(    const menu_entry_t *menu_entries = submenu->menu;
1629              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,    while(menu_entries->label) {
1630              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);  
   
1631    
1632    but = hildon_button_new_with_text(      button = hildon_button_new_with_text(
1633              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,
1634              HILDON_BUTTON_ARRANGEMENT_VERTICAL,              HILDON_BUTTON_ARRANGEMENT_VERTICAL,
1635              _("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);  
1636    
1637    gtk_container_add (GTK_CONTAINER (view_window), GTK_WIDGET (contents));      /* try to center both texts */
1638    gtk_widget_show_all (GTK_WIDGET (view_window));      hildon_button_set_title_alignment(HILDON_BUTTON(button), 0.5, 0.5);
1639  }      hildon_button_set_value_alignment(HILDON_BUTTON(button), 0.5, 0.5);
1640    
1641  static void on_tools_destroy(GtkWidget *widget, appdata_t *appdata) {      g_signal_connect(button, "clicked",
1642    appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view");                       G_CALLBACK(on_submenu_entry_clicked), dialog);
1643    
1644        g_signal_connect(button, "clicked",
1645                         menu_entries->activate_cb, appdata);
1646    
1647        gtk_table_attach_defaults(GTK_TABLE(table),  button, x, x+1, y, y+1);
1648    
1649        x++;
1650        if(x == COLUMNS) { x = 0; y++; }
1651    
1652        menu_entries++;
1653      }
1654    
1655      gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table);
1656    
1657      return dialog;
1658  }  }
1659    
1660  void on_tools_clicked(GtkButton *button, appdata_t *appdata) {  /* popup the dialog shaped submenu */
1661    HildonStackableWindow *view_window;  static void submenu_popup(GtkWidget *menu) {
1662    GtkWidget *but;    gtk_widget_show_all(menu);
1663      gtk_dialog_run(GTK_DIALOG(menu));
1664      gtk_widget_hide(menu);
1665    }
1666    
1667    view_window = HILDON_STACKABLE_WINDOW (hildon_stackable_window_new ());  static void submenu_cleanup(GtkWidget *menu) {
1668    gtk_window_set_title (GTK_WINDOW (view_window), "GPXView - Tools");    gtk_widget_destroy(menu);
1669    }
1670    
1671     /* store last "cur_view" in window */  static const menu_entry_t submenu_export_entries[] = {
1672    g_object_set_data(G_OBJECT(view_window), "cur_view", appdata->cur_view);  #ifdef ENABLE_MAEMO_MAPPER
1673    appdata->cur_view = NULL;    { "Export to Maemo Mapper" , "Save a Maemo Mapper POI file",
1674        G_CALLBACK(cb_menu_export_mmpoi)  },
1675    #endif
1676      { "Export Field Notes",      "Save a Garmin Field Notes file",
1677        G_CALLBACK(cb_menu_export_log)    },
1678      { "Export Garmin GPX",       "Save modified waypoints in GPX file",
1679        G_CALLBACK(cb_menu_export_garmin) },
1680      { NULL, NULL, NULL }
1681    };
1682    
1683    g_signal_connect(G_OBJECT(view_window), "destroy",  static const submenu_t submenu_export = {
1684                     G_CALLBACK(on_tools_destroy), appdata);    "Export", submenu_export_entries,
1685      sizeof(submenu_export_entries)/sizeof(menu_entry_t)-1
1686    };
1687    
1688    GtkVBox *contents = GTK_VBOX(gtk_vbox_new (12, FALSE));  /* the export submenu */
1689    void on_export_clicked(GtkButton *button, appdata_t *appdata) {
1690      if(!appdata->export_menu)
1691        appdata->export_menu = app_submenu_create(appdata, &submenu_export);
1692    
1693    but = hildon_button_new_with_text(    submenu_popup(appdata->export_menu);
1694              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);  
1695    
1696    static const menu_entry_t submenu_tools_entries[] = {
1697      { "Geomath",          "Geocoordinate calculation",
1698        G_CALLBACK(cb_menu_geomath) },
1699      { "Geotext",          "Text analysis",
1700        G_CALLBACK(cb_menu_geotext) },
1701      { "Precise Position", "Calculate a precise GPS position",
1702        G_CALLBACK(cb_menu_precpos) },
1703      { NULL, NULL, NULL }
1704    };
1705    
1706    but = hildon_button_new_with_text(  static const submenu_t submenu_tools = {
1707              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,    "Tools", submenu_tools_entries,
1708              HILDON_BUTTON_ARRANGEMENT_VERTICAL,    sizeof(submenu_tools_entries)/sizeof(menu_entry_t)-1
1709              _("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);  
   
1710    
1711    but = hildon_button_new_with_text(  /* the tools submenu */
1712              HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH,  void on_tools_clicked(GtkButton *button, appdata_t *appdata) {
1713              HILDON_BUTTON_ARRANGEMENT_VERTICAL,    if(!appdata->tools_menu)
1714              _("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);  
1715    
1716    gtk_container_add (GTK_CONTAINER (view_window), GTK_WIDGET (contents));    submenu_popup(appdata->tools_menu);
   gtk_widget_show_all (GTK_WIDGET (view_window));  
1717  }  }
1718    
1719  HildonAppMenu *menu_create(appdata_t *appdata, int mode) {  HildonAppMenu *menu_create(appdata_t *appdata, int mode) {
# Line 1642  HildonAppMenu *menu_create(appdata_t *ap Line 1741  HildonAppMenu *menu_create(appdata_t *ap
1741      g_signal_connect_after(button, "clicked",      g_signal_connect_after(button, "clicked",
1742                             G_CALLBACK(cb_menu_adddir), appdata);                             G_CALLBACK(cb_menu_adddir), appdata);
1743      hildon_app_menu_append(menu, GTK_BUTTON(button));      hildon_app_menu_append(menu, GTK_BUTTON(button));
   }  
1744    
   if(mode == MENU_GPXLIST) {  
1745      button = gtk_button_new_with_label(_("Export"));      button = gtk_button_new_with_label(_("Export"));
1746      g_signal_connect_after(button, "clicked",      g_signal_connect_after(button, "clicked",
1747                             G_CALLBACK(on_export_clicked), appdata);                             G_CALLBACK(on_export_clicked), appdata);
# Line 1661  HildonAppMenu *menu_create(appdata_t *ap Line 1758  HildonAppMenu *menu_create(appdata_t *ap
1758                           G_CALLBACK(on_tools_clicked), appdata);                           G_CALLBACK(on_tools_clicked), appdata);
1759    hildon_app_menu_append(menu, GTK_BUTTON(button));    hildon_app_menu_append(menu, GTK_BUTTON(button));
1760    
1761    //  gtk_widget_show(GTK_WIDGET(menu));  #ifdef ENABLE_OSM_GPS_MAP
1762        button = gtk_button_new_with_label(_("Map"));
1763        g_signal_connect_after(button, "clicked",
1764                               G_CALLBACK(cb_menu_map), appdata);
1765        hildon_app_menu_append(menu, GTK_BUTTON(button));
1766    #endif
1767    
1768    #ifdef HILDON_HELP
1769      button = gtk_button_new_with_label(_("Help"));
1770      g_signal_connect_after(button, "clicked",
1771                             G_CALLBACK(cb_menu_help), appdata);
1772      hildon_app_menu_append(menu, GTK_BUTTON(button));
1773    #endif
1774    
1775      gtk_widget_show_all(GTK_WIDGET(menu));
1776    
1777    return menu;    return menu;
1778  }  }
# Line 1671  void menu_create(appdata_t *appdata) { Line 1782  void menu_create(appdata_t *appdata) {
1782    GtkWidget *menu, *item;    GtkWidget *menu, *item;
1783    menu = gtk_menu_new();    menu = gtk_menu_new();
1784    
1785  #ifdef USE_BREAD_CRUMB_TRAIL  #if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT)
1786    appdata->menu_import =    appdata->menu_import =
1787  #endif  #endif
1788    item = gtk_menu_item_new_with_label(_("Import"));    item = gtk_menu_item_new_with_label(_("Import"));
# Line 1701  void menu_create(appdata_t *appdata) { Line 1812  void menu_create(appdata_t *appdata) {
1812    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_remove), appdata);    g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_remove), appdata);
1813  #endif  #endif
1814    
1815  #ifdef USE_BREAD_CRUMB_TRAIL  #if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT)
1816    appdata->menu_export =    appdata->menu_export =
1817  #endif  #endif
1818      item = gtk_menu_item_new_with_label(_("Export"));      item = gtk_menu_item_new_with_label(_("Export"));
# Line 1709  void menu_create(appdata_t *appdata) { Line 1820  void menu_create(appdata_t *appdata) {
1820    submenu = gtk_menu_new();    submenu = gtk_menu_new();
1821    gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);    gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
1822    
1823  #ifdef USE_MAEMO  #ifdef ENABLE_MAEMO_MAPPER
1824    item = gtk_menu_item_new_with_label( _("Maemo Mapper POI") );    item = gtk_menu_item_new_with_label( _("Maemo Mapper POI") );
1825    gtk_menu_append(GTK_MENU_SHELL(submenu), item);    gtk_menu_append(GTK_MENU_SHELL(submenu), item);
1826    g_signal_connect(item, "activate",    g_signal_connect(item, "activate",
# Line 1726  void menu_create(appdata_t *appdata) { Line 1837  void menu_create(appdata_t *appdata) {
1837    g_signal_connect(item, "activate",    g_signal_connect(item, "activate",
1838                     GTK_SIGNAL_FUNC(cb_menu_export_garmin), appdata);                     GTK_SIGNAL_FUNC(cb_menu_export_garmin), appdata);
1839    
1840  #ifdef USE_BREAD_CRUMB_TRAIL  #if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT)
1841    appdata->menu_search =    appdata->menu_search =
1842  #endif  #endif
1843    item = gtk_menu_item_new_with_label( _("Search") );    item = gtk_menu_item_new_with_label( _("Search") );
# Line 1766  void menu_create(appdata_t *appdata) { Line 1877  void menu_create(appdata_t *appdata) {
1877    
1878    gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new());    gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new());
1879    
1880    #ifdef ENABLE_OSM_GPS_MAP
1881      item = gtk_menu_item_new_with_label( _("Map") );
1882      gtk_menu_append(GTK_MENU_SHELL(menu), item);
1883      g_signal_connect(item, "activate",
1884                       GTK_SIGNAL_FUNC(cb_menu_map), appdata);
1885    #endif
1886    
1887    item = gtk_menu_item_new_with_label(_("Tools"));    item = gtk_menu_item_new_with_label(_("Tools"));
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();
# Line 1830  void cleanup(appdata_t *appdata) { Line 1948  void cleanup(appdata_t *appdata) {
1948    if(appdata->image_path) free(appdata->image_path);    if(appdata->image_path) free(appdata->image_path);
1949    if(appdata->search_str) free(appdata->search_str);    if(appdata->search_str) free(appdata->search_str);
1950    
1951    #ifdef USE_STACKABLE_WINDOW
1952      if(appdata->export_menu) submenu_cleanup(appdata->export_menu);
1953      if(appdata->tools_menu)  submenu_cleanup(appdata->tools_menu);
1954    #endif
1955    
1956    gnome_vfs_shutdown();    gnome_vfs_shutdown();
1957    icons_free();    icons_free();
1958    gps_release(appdata);    gps_release(appdata);
# Line 1858  void cleanup(appdata_t *appdata) { Line 1981  void cleanup(appdata_t *appdata) {
1981    puts("everything is gone");    puts("everything is gone");
1982  }  }
1983    
1984  void on_window_destroy (GtkWidget *widget, gpointer data) {  static void on_window_destroy (GtkWidget *widget, gpointer data) {
1985    appdata_t *appdata = (appdata_t*)data;    appdata_t *appdata = (appdata_t*)data;
1986    
1987    gconf_save_state(appdata);    gconf_save_state(appdata);
# Line 1921  gboolean on_window_key_press(GtkWidget * Line 2044  gboolean on_window_key_press(GtkWidget *
2044    return handled;    return handled;
2045  }  }
2046    
2047  #ifdef USE_BREAD_CRUMB_TRAIL  #if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT)
2048  typedef struct {  typedef struct {
2049    int level;    int level;
2050    appdata_t *appdata;    appdata_t *appdata;
# Line 2053  static void crumb_add(appdata_t *appdata Line 2176  static void crumb_add(appdata_t *appdata
2176  #endif  #endif
2177    }    }
2178    
2179    #ifdef USE_BREAD_CRUMB_TRAIL
2180    hildon_bread_crumb_trail_push_text(HILDON_BREAD_CRUMB_TRAIL(appdata->bct),    hildon_bread_crumb_trail_push_text(HILDON_BREAD_CRUMB_TRAIL(appdata->bct),
2181                                       name, crumb, (GDestroyNotify)crumb_back);                                       name, crumb, (GDestroyNotify)crumb_back);
2182    #else
2183      bct_push_text(appdata->bct, name, crumb, (GDestroyNotify)crumb_back);
2184    #endif
2185  }  }
2186  #endif // USE_BREAD_CRUMB_TRAIL  #endif // USE_BREAD_CRUMB_TRAIL
2187    
# Line 2066  void main_after_settings_redraw(appdata_ Line 2193  void main_after_settings_redraw(appdata_
2193      return;      return;
2194    }    }
2195    
 #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  
2196    /* 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 */
2197    /* need to be redrawn */    /* need to be redrawn */
2198    if(appdata->cur_cache) {    if(appdata->cur_cache) {
# Line 2132  void main_after_settings_redraw(appdata_ Line 2247  void main_after_settings_redraw(appdata_
2247    
2248      gtk_widget_show_all(container);      gtk_widget_show_all(container);
2249    }    }
 #endif // USE_MAEMO  
2250  }  }
2251    
2252  int main(int argc, char *argv[]) {  int main(int argc, char *argv[]) {
# Line 2161  int main(int argc, char *argv[]) { Line 2275  int main(int argc, char *argv[]) {
2275      fprintf(stderr, "error initiating osso context\n");      fprintf(stderr, "error initiating osso context\n");
2276    }    }
2277    
2278    #ifdef ENABLE_MAEMO_MAPPER
2279    dbus_register(&appdata);    dbus_register(&appdata);
2280  #endif  #endif
2281    #endif
2282    
2283    icons_init();    icons_init();
2284    
# Line 2186  int main(int argc, char *argv[]) { Line 2302  int main(int argc, char *argv[]) {
2302    /* Create a Window. */    /* Create a Window. */
2303    appdata.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);    appdata.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2304    /* Set a decent default size for the window. */    /* Set a decent default size for the window. */
2305    gtk_window_set_default_size(GTK_WINDOW(appdata.window), 500, 300);    gtk_window_set_default_size(GTK_WINDOW(appdata.window), 640, 480);
2306  #endif  #endif
2307    
2308  #if MAEMO_VERSION_MAJOR == 5  #if MAEMO_VERSION_MAJOR == 5
# Line 2201  int main(int argc, char *argv[]) { Line 2317  int main(int argc, char *argv[]) {
2317    
2318    appdata.vbox = gtk_vbox_new(FALSE, 2);    appdata.vbox = gtk_vbox_new(FALSE, 2);
2319    gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox);    gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox);
   
2320  #ifndef USE_STACKABLE_WINDOW  #ifndef USE_STACKABLE_WINDOW
2321    menu_create(&appdata);    menu_create(&appdata);
2322  #else  #else
# Line 2215  int main(int argc, char *argv[]) { Line 2330  int main(int argc, char *argv[]) {
2330    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);
2331    
2332    hildon_bread_crumb_trail_clear(HILDON_BREAD_CRUMB_TRAIL(appdata.bct));    hildon_bread_crumb_trail_clear(HILDON_BREAD_CRUMB_TRAIL(appdata.bct));
2333    #else
2334    #ifdef BCT
2335      /* on non-hildon machines we use some custom made breadcrumbtrail */
2336      /* replacement */
2337      appdata.bct = bct_new();
2338      gtk_box_pack_start(GTK_BOX(appdata.vbox), appdata.bct, FALSE,FALSE,0);
2339    #endif
2340    #endif
2341    
2342    #if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT)
2343    crumb_add(&appdata, "GPX", CRUMB_GPXLIST, NULL);    crumb_add(&appdata, "GPX", CRUMB_GPXLIST, NULL);
2344  #endif  #endif
2345    

Legend:
Removed from v.12  
changed lines
  Added in v.129