Mercurial > dwindows
comparison gtk3/dw.c @ 1295:d0c9d4d0ff3b
Implement default filename support for GTK.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 01 Nov 2011 10:48:19 +0000 |
parents | b99b0b2c2826 |
children | 9c8de9cccc07 |
comparison
equal
deleted
inserted
replaced
1294:4bc8b6ffbe1e | 1295:d0c9d4d0ff3b |
---|---|
9875 gtk_file_chooser_add_filter( GTK_FILE_CHOOSER( filew ), filter2 ); | 9875 gtk_file_chooser_add_filter( GTK_FILE_CHOOSER( filew ), filter2 ); |
9876 } | 9876 } |
9877 | 9877 |
9878 if ( defpath ) | 9878 if ( defpath ) |
9879 { | 9879 { |
9880 struct stat buf; | |
9881 | |
9880 if ( g_path_is_absolute( defpath ) || !realpath(defpath, mypath)) | 9882 if ( g_path_is_absolute( defpath ) || !realpath(defpath, mypath)) |
9881 { | 9883 { |
9882 strcpy( mypath, defpath ); | 9884 strcpy( mypath, defpath ); |
9883 } | 9885 } |
9884 gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER( filew ), mypath ); | 9886 |
9887 /* See if the path exists */ | |
9888 if(stat(mypath, &buf) == 0) | |
9889 { | |
9890 /* If the path is a directory... set the current folder */ | |
9891 if(buf.st_mode & S_IFDIR) | |
9892 gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER( filew ), mypath ); | |
9893 else if(flags == DW_FILE_SAVE) /* Otherwise set the filename */ | |
9894 gtk_file_chooser_set_filename( GTK_FILE_CHOOSER( filew ), mypath ); | |
9895 else if(flags == DW_FILE_OPEN) | |
9896 gtk_file_chooser_select_filename( GTK_FILE_CHOOSER( filew), mypath ); | |
9897 } | |
9898 else if(flags == DW_FILE_SAVE) | |
9899 { | |
9900 /* If it doesn't exist... Try it as a file for now... | |
9901 * May need to separate it into folder and file. | |
9902 */ | |
9903 gtk_file_chooser_set_filename( GTK_FILE_CHOOSER( filew ), mypath ); | |
9904 } | |
9885 } | 9905 } |
9886 | 9906 |
9887 if ( gtk_dialog_run( GTK_DIALOG( filew ) ) == GTK_RESPONSE_ACCEPT ) | 9907 if ( gtk_dialog_run( GTK_DIALOG( filew ) ) == GTK_RESPONSE_ACCEPT ) |
9888 { | 9908 { |
9889 filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( filew ) ); | 9909 filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( filew ) ); |