Diff of /trunk/src/main.c

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

revision 74 by harbaum, Mon Aug 24 09:23:36 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      gpx_dialog_t *dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window));      if(filename) {
143          gpx_dialog_t *dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window));
144      if(!whole_dir)  
145        gpx = gpx_parse(dialog, filename);        if(!whole_dir)
146      else {          gpx = gpx_parse(dialog, filename);
147        /* cur trailing '/' if present */        else {
148        if(strlastchr(filename) == '/')          /* cur trailing '/' if present */
149          filename[strlen(filename)] = 0;          if(strlastchr(filename) == '/')
150              filename[strlen(filename)] = 0;
151        gpx = gpx_parse_dir(dialog, filename);  
152      }          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        if(whole_dir)        gpx_busy_dialog_destroy(dialog);
156          appdata->path = strdup(filename);  
157      } else        /* save path if gpx was successfully loaded */
158        errorf(_("Load error"));        if(gpx) {
159            char *r = strrchr(filename, '/');
160      g_free (filename);  
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          g_free (filename);
176        } 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        }
185    }    }
186    
187    gtk_widget_destroy (dialog);    gtk_widget_destroy (dialog);

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