comparison gtk/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
11594 gtk_file_chooser_add_filter( GTK_FILE_CHOOSER( filew ), filter2 ); 11594 gtk_file_chooser_add_filter( GTK_FILE_CHOOSER( filew ), filter2 );
11595 } 11595 }
11596 11596
11597 if ( defpath ) 11597 if ( defpath )
11598 { 11598 {
11599 struct stat buf;
11600
11599 if ( g_path_is_absolute( defpath ) || !realpath(defpath, mypath)) 11601 if ( g_path_is_absolute( defpath ) || !realpath(defpath, mypath))
11600 { 11602 {
11601 strcpy( mypath, defpath ); 11603 strcpy( mypath, defpath );
11602 } 11604 }
11603 gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER( filew ), mypath ); 11605
11606 /* See if the path exists */
11607 if(stat(mypath, &buf) == 0)
11608 {
11609 /* If the path is a directory... set the current folder */
11610 if(buf.st_mode & S_IFDIR)
11611 gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER( filew ), mypath );
11612 else if(flags == DW_FILE_SAVE) /* Otherwise set the filename */
11613 gtk_file_chooser_set_filename( GTK_FILE_CHOOSER( filew ), mypath );
11614 else if(flags == DW_FILE_OPEN)
11615 gtk_file_chooser_select_filename( GTK_FILE_CHOOSER( filew), mypath );
11616 }
11617 else if(flags == DW_FILE_SAVE)
11618 {
11619 /* If it doesn't exist... Try it as a file for now...
11620 * May need to separate it into folder and file.
11621 */
11622 gtk_file_chooser_set_filename( GTK_FILE_CHOOSER( filew ), mypath );
11623 }
11604 } 11624 }
11605 11625
11606 if ( gtk_dialog_run( GTK_DIALOG( filew ) ) == GTK_RESPONSE_ACCEPT ) 11626 if ( gtk_dialog_run( GTK_DIALOG( filew ) ) == GTK_RESPONSE_ACCEPT )
11607 { 11627 {
11608 filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( filew ) ); 11628 filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( filew ) );