* open/save dialogs: use current file path, name, focus it, if present

brushexport plugin: case insensitive extension check
This commit is contained in:
Garux
2020-03-01 19:38:27 +03:00
parent 04bf329bf2
commit 4b2f9d6080
10 changed files with 67 additions and 30 deletions

View File

@@ -176,14 +176,15 @@ const char* file_dialog_show( GtkWidget* parent, bool open, const char* title, c
{
*w++ = ( *r == '/' ) ? G_DIR_SEPARATOR : *r;
}
// remove separator from end of path if required
if ( *( w - 1 ) == G_DIR_SEPARATOR ) {
--w;
}
// terminate string
*w = '\0';
gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER( dialog ), new_path.data() );
if( file_is_directory( new_path.data() ) ){ // folder path
gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER( dialog ), new_path.data() );
}
else{ // file path
gtk_file_chooser_set_filename( GTK_FILE_CHOOSER( dialog ), new_path.data() );
}
}
// we should add all important paths as shortcut folder...

View File

@@ -26,7 +26,7 @@
/// GTK+ file-chooser dialogs.
typedef struct _GtkWidget GtkWidget;
const char* file_dialog( GtkWidget *parent, bool open, const char* title, const char* path = 0, const char* pattern = 0, bool want_load = false, bool want_import = false, bool want_save = false );
const char* file_dialog( GtkWidget *parent, bool open, const char* title, const char* path = nullptr, const char* pattern = nullptr, bool want_load = false, bool want_import = false, bool want_save = false );
/// \brief Prompts the user to browse for a directory.