Mercurial > dwindows
comparison gtk/dw.c @ 1300:9c8de9cccc07
Fix for file and folder not being selected on GTK if file does not exist.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 01 Nov 2011 21:57:19 +0000 |
parents | d0c9d4d0ff3b |
children | dbd507f42947 |
comparison
equal
deleted
inserted
replaced
1299:66d4e16349e0 | 1300:9c8de9cccc07 |
---|---|
11614 else if(flags == DW_FILE_OPEN) | 11614 else if(flags == DW_FILE_OPEN) |
11615 gtk_file_chooser_select_filename( GTK_FILE_CHOOSER( filew), mypath ); | 11615 gtk_file_chooser_select_filename( GTK_FILE_CHOOSER( filew), mypath ); |
11616 } | 11616 } |
11617 else if(flags == DW_FILE_SAVE) | 11617 else if(flags == DW_FILE_SAVE) |
11618 { | 11618 { |
11619 /* If it doesn't exist... Try it as a file for now... | 11619 if(strchr(mypath, '/')) |
11620 * May need to separate it into folder and file. | 11620 { |
11621 */ | 11621 unsigned long x = strlen(mypath) - 1; |
11622 gtk_file_chooser_set_filename( GTK_FILE_CHOOSER( filew ), mypath ); | 11622 |
11623 /* Trim off the filename */ | |
11624 while(x > 0 && mypath[x] != '/') | |
11625 { | |
11626 x--; | |
11627 } | |
11628 if(mypath[x] == '/') | |
11629 { | |
11630 char *file = NULL; | |
11631 char temp[PATH_MAX+1]; | |
11632 | |
11633 /* Save the original path in temp */ | |
11634 strcpy(temp, mypath); | |
11635 mypath[x] = 0; | |
11636 | |
11637 /* Check to make sure the trimmed piece is a directory */ | |
11638 if(realpath(mypath, temp) && stat(temp, &buf) == 0) | |
11639 { | |
11640 if(buf.st_mode & S_IFDIR) | |
11641 { | |
11642 /* We now have it split */ | |
11643 file = &mypath[x+1]; | |
11644 } | |
11645 } | |
11646 | |
11647 /* Select folder... */ | |
11648 gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(filew), temp ); | |
11649 /* ... and file separately */ | |
11650 if(file) | |
11651 gtk_file_chooser_set_current_name( GTK_FILE_CHOOSER(filew), file ); | |
11652 } | |
11653 } | |
11623 } | 11654 } |
11624 } | 11655 } |
11625 | 11656 |
11626 if ( gtk_dialog_run( GTK_DIALOG( filew ) ) == GTK_RESPONSE_ACCEPT ) | 11657 if ( gtk_dialog_run( GTK_DIALOG( filew ) ) == GTK_RESPONSE_ACCEPT ) |
11627 { | 11658 { |