Diff of /trunk/src/main.c

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

revision 50 by harbaum, Wed Aug 12 09:31:09 2009 UTC revision 107 by harbaum, Fri Sep 11 12:16:50 2009 UTC
# Line 138  gpx_t *choose_file(appdata_t *appdata, g Line 138  gpx_t *choose_file(appdata_t *appdata, g
138    gtk_widget_show_all (GTK_WIDGET(dialog));    gtk_widget_show_all (GTK_WIDGET(dialog));
139    if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_FM_OK) {    if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_FM_OK) {
140      char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));      char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
141    
142        if(filename) {
143          gpx_dialog_t *dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window));
144    
145      gpx_dialog_t *dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window));        if(!whole_dir)
146            gpx = gpx_parse(dialog, filename);
147      if(!whole_dir)        else {
148        gpx = gpx_parse(dialog, filename);          /* cur trailing '/' if present */
149      else {          if(strlastchr(filename) == '/')
150        /* cur trailing '/' if present */            filename[strlen(filename)] = 0;
151        if(strlastchr(filename) == '/')  
152          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 = '/';  
153        }        }
154    
155          gpx_busy_dialog_destroy(dialog);
156    
157          /* save path if gpx was successfully loaded */
158          if(gpx) {
159            char *r = strrchr(filename, '/');
160    
161            /* there is a delimiter, use everything left of it as path */
162            if(r && !whole_dir) {
163              *r = 0;
164              if(appdata->path) free(appdata->path);
165              appdata->path = strdup(filename);
166              /* restore path ... just in case ... */
167              *r = '/';
168            }
169    
170            if(whole_dir)
171              appdata->path = strdup(filename);
172          } else
173            errorf(_("Load error"));
174    
175        if(whole_dir)        g_free (filename);
176          appdata->path = strdup(filename);      } else {
177    #ifndef USE_MAEMO
178          errorf(_("Error accessing the file."));
179    #else
180          errorf(_("Error accessing the file. This may happen if the file "
181                   "resides on a remote file system. Please copy the file onto "
182                   "the device (e.g. onto the memory card) and try again."));
183    #endif
184      }      }
   
     g_free (filename);  
185    }    }
186    
187    gtk_widget_destroy (dialog);    gtk_widget_destroy (dialog);
# Line 966  static GtkWidget *gpxlist_create_view_an Line 977  static GtkWidget *gpxlist_create_view_an
977    GtkTreeIter sel_iter;    GtkTreeIter sel_iter;
978    gboolean sel_iter_valid = FALSE;    gboolean sel_iter_valid = FALSE;
979    while(gpx) {    while(gpx) {
980      GtkTreeIter         iter;      /* don't display entries that failed at load */
981      gtk_list_store_append(appdata->gpxstore, &iter);      if(!gpx->failed) {
982      gpxlist_set(appdata->gpxstore, &iter, gpx);        GtkTreeIter         iter;
983          gtk_list_store_append(appdata->gpxstore, &iter);
984      if(gpx == sel_gpx) {        gpxlist_set(appdata->gpxstore, &iter, gpx);
985        sel_iter = iter;  
986        sel_iter_valid = TRUE;        if(gpx == sel_gpx) {
987            sel_iter = iter;
988            sel_iter_valid = TRUE;
989          }
990      }      }
991    
992      gpx = gpx->next;      gpx = gpx->next;
# Line 1868  void menu_create(appdata_t *appdata) { Line 1882  void menu_create(appdata_t *appdata) {
1882    
1883    gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new());    gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new());
1884    
   item = gtk_menu_item_new_with_label(_("Tools"));  
   gtk_menu_append(GTK_MENU_SHELL(menu), item);  
   submenu = gtk_menu_new();  
   gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);  
   
1885  #ifdef ENABLE_OSM_GPS_MAP  #ifdef ENABLE_OSM_GPS_MAP
1886    item = gtk_menu_item_new_with_label( _("Map") );    item = gtk_menu_item_new_with_label( _("Map") );
1887    gtk_menu_append(GTK_MENU_SHELL(submenu), item);    gtk_menu_append(GTK_MENU_SHELL(menu), item);
1888    g_signal_connect(item, "activate",    g_signal_connect(item, "activate",
1889                     GTK_SIGNAL_FUNC(cb_menu_map), appdata);                     GTK_SIGNAL_FUNC(cb_menu_map), appdata);
1890  #endif  #endif
1891    
1892      item = gtk_menu_item_new_with_label(_("Tools"));
1893      gtk_menu_append(GTK_MENU_SHELL(menu), item);
1894      submenu = gtk_menu_new();
1895      gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
1896    
1897    item = gtk_menu_item_new_with_label( _("Geomath") );    item = gtk_menu_item_new_with_label( _("Geomath") );
1898    gtk_menu_append(GTK_MENU_SHELL(submenu), item);    gtk_menu_append(GTK_MENU_SHELL(submenu), item);
1899    g_signal_connect(item, "activate",    g_signal_connect(item, "activate",

Legend:
Removed from v.50  
changed lines
  Added in v.107