* 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

@@ -312,7 +312,7 @@ void update(){
}
typedef MemberCaller<ModelAttribute, &ModelAttribute::update> UpdateCaller;
void browse( const BrowsedPathEntry::SetPathCallback& setPath ){
const char *filename = misc_model_dialog( gtk_widget_get_toplevel( GTK_WIDGET( m_entry.m_entry.m_frame ) ) );
const char *filename = misc_model_dialog( gtk_widget_get_toplevel( GTK_WIDGET( m_entry.m_entry.m_frame ) ), gtk_entry_get_text( GTK_ENTRY( m_entry.m_entry.m_entry ) ) );
if ( filename != 0 ) {
setPath( filename );
@@ -322,18 +322,25 @@ void browse( const BrowsedPathEntry::SetPathCallback& setPath ){
typedef MemberCaller1<ModelAttribute, const BrowsedPathEntry::SetPathCallback&, &ModelAttribute::browse> BrowseCaller;
};
const char* browse_sound( GtkWidget* parent ){
const char* browse_sound( GtkWidget* parent, const char* filepath ){
StringOutputStream buffer( 1024 );
buffer << g_qeglobals.m_userGamePath.c_str() << "sound/";
if( !string_empty( filepath ) ){
const char* root = GlobalFileSystem().findFile( filepath );
if( !string_empty( root ) && file_is_directory( root ) )
buffer << root << filepath;
}
if( buffer.empty() ){
buffer << g_qeglobals.m_userGamePath.c_str() << "sound/";
if ( !file_readable( buffer.c_str() ) ) {
// just go to fsmain
buffer.clear();
buffer << g_qeglobals.m_userGamePath.c_str();
if ( !file_readable( buffer.c_str() ) ) {
// just go to fsmain
buffer.clear();
buffer << g_qeglobals.m_userGamePath.c_str();
}
}
const char* filename = file_dialog( parent, TRUE, "Open Wav File", buffer.c_str(), "sound" );
const char* filename = file_dialog( parent, true, "Open Wav File", buffer.c_str(), "sound" );
if ( filename != 0 ) {
const char* relative = path_make_relative( filename, GlobalFileSystem().findRoot( filename ) );
if ( relative == filename ) {
@@ -375,7 +382,7 @@ void update(){
}
typedef MemberCaller<SoundAttribute, &SoundAttribute::update> UpdateCaller;
void browse( const BrowsedPathEntry::SetPathCallback& setPath ){
const char *filename = browse_sound( gtk_widget_get_toplevel( GTK_WIDGET( m_entry.m_entry.m_frame ) ) );
const char *filename = browse_sound( gtk_widget_get_toplevel( GTK_WIDGET( m_entry.m_entry.m_frame ) ), gtk_entry_get_text( GTK_ENTRY( m_entry.m_entry.m_entry ) ) );
if ( filename != 0 ) {
setPath( filename );