Expunge EDA_FILE_SELECTOR.

EDA_FILE_SELECTOR was just an obfuscation of wxFileSelector().
This commit is contained in:
Wayne Stambaugh 2021-07-28 13:25:40 -04:00
parent c006a4f26e
commit f233f4a0a9
15 changed files with 125 additions and 189 deletions

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 1992-2020 Kicad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 Kicad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -27,6 +27,7 @@
#include <kiway_player.h>
#include <locale_io.h>
#include <panel_hotkeys_editor.h>
#include <wildcards_and_files_ext.h>
#include <tool/tool_manager.h>
#include <widgets/button_row_panel.h>
#include <widgets/ui_common.h>
@ -188,10 +189,9 @@ void PANEL_HOTKEYS_EDITOR::OnFilterSearch( wxCommandEvent& aEvent )
void PANEL_HOTKEYS_EDITOR::ImportHotKeys()
{
wxString ext = DEFAULT_HOTKEY_FILENAME_EXT;
wxString mask = wxT( "*." ) + ext;
wxString filename = EDA_FILE_SELECTOR( _( "Import Hotkeys File:" ), m_frame->GetMruPath(),
wxEmptyString, ext, mask, this, wxFD_OPEN, true );
wxString filename = wxFileSelector( _( "Import Hotkeys File:" ), m_frame->GetMruPath(),
wxEmptyString, HotkeyFileExtension,
HotkeyFileWildcard(), wxFD_OPEN, this );
if( filename.IsEmpty() )
return;
@ -216,9 +216,9 @@ void PANEL_HOTKEYS_EDITOR::ImportHotKeys()
void PANEL_HOTKEYS_EDITOR::dumpHotkeys()
{
wxString filename = EDA_FILE_SELECTOR( wxT( "Dump Hotkeys File:" ), m_frame->GetMruPath(),
wxEmptyString, wxT( "txt" ), wxT( "*.txt" ), this,
wxFD_SAVE, true );
wxString filename = wxFileSelector( wxT( "Hotkeys File" ), m_frame->GetMruPath(),
wxEmptyString, TextFileExtension, TextFileWildcard(),
wxFD_SAVE, this );
if( filename.IsEmpty() )
return;

View File

@ -121,40 +121,33 @@ bool GetAssociatedDocument( wxWindow* aParent, const wxString& aDocName, PROJECT
/* Compute the full file name */
if( wxIsAbsolutePath( docname ) || aPaths == nullptr )
fullfilename = docname;
/* If the file exists, this is a trivial case: return the filename
* "as this". the name can be an absolute path, or a relative path
* like ./filename or ../<filename>
/* If the file exists, this is a trivial case: return the filename "as this". the name can
* be an absolute path, or a relative path like ./filename or ../<filename>.
*/
else if( wxFileName::FileExists( docname ) )
fullfilename = docname;
else
fullfilename = aPaths->FindValidPath( docname );
wxString mask( wxT( "*" ) ), extension;
wxString extension;
#ifdef __WINDOWS__
mask += wxT( ".*" );
extension = wxT( ".*" );
#endif
if( wxIsWild( fullfilename ) )
{
fullfilename = EDA_FILE_SELECTOR( _( "Doc Files" ),
wxPathOnly( fullfilename ),
fullfilename,
extension,
mask,
aParent,
wxFD_OPEN,
true,
wxPoint( -1, -1 ) );
fullfilename = wxFileSelector( _( "Documentation File" ), wxPathOnly( fullfilename ),
fullfilename, extension, wxFileSelectorDefaultWildcardStr,
wxFD_OPEN, aParent );
if( fullfilename.IsEmpty() )
return false;
}
if( !wxFileExists( fullfilename ) )
{
msg.Printf( _( "Doc File '%s' not found" ), docname );
msg.Printf( _( "Documentation file '%s' not found." ), docname );
DisplayError( aParent, msg );
return false;
}
@ -197,7 +190,7 @@ bool GetAssociatedDocument( wxWindow* aParent, const wxString& aDocName, PROJECT
if( !success )
{
msg.Printf( _( "Unknown MIME type for doc file '%s'" ), fullfilename );
msg.Printf( _( "Unknown MIME type for documentation file '%s'" ), fullfilename );
DisplayError( aParent, msg );
}

View File

@ -49,56 +49,6 @@ void AddDelimiterString( wxString& string )
}
wxString EDA_FILE_SELECTOR( const wxString& aTitle,
const wxString& aPath,
const wxString& aFileName,
const wxString& aExtension,
const wxString& aWildcard,
wxWindow* aParent,
int aStyle,
const bool aKeepWorkingDirectory,
const wxPoint& aPosition,
wxString* aMruPath )
{
wxString fullfilename;
wxString curr_cwd = wxGetCwd();
wxString defaultname = aFileName;
wxString defaultpath = aPath;
wxString dotted_Ext = wxT(".") + aExtension;
#ifdef __WINDOWS__
defaultname.Replace( wxT( "/" ), wxT( "\\" ) );
defaultpath.Replace( wxT( "/" ), wxT( "\\" ) );
#endif
if( defaultpath.IsEmpty() )
{
if( aMruPath == nullptr )
defaultpath = wxGetCwd();
else
defaultpath = *aMruPath;
}
wxSetWorkingDirectory( defaultpath );
fullfilename = wxFileSelector( aTitle, defaultpath, defaultname,
dotted_Ext, aWildcard,
aStyle, // open mode wxFD_OPEN, wxFD_SAVE ..
aParent, aPosition.x, aPosition.y );
if( aKeepWorkingDirectory )
wxSetWorkingDirectory( curr_cwd );
if( !fullfilename.IsEmpty() && aMruPath )
{
wxFileName fn = fullfilename;
*aMruPath = fn.GetPath();
}
return fullfilename;
}
wxString FindKicadFile( const wxString& shortname )
{
// Test the presence of the file in the directory shortname of

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2010 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -29,6 +29,7 @@
#include <kicad_string.h>
#include <eda_base_frame.h>
#include <eda_draw_frame.h>
#include <wildcards_and_files_ext.h>
#include <settings/settings_manager.h>
#include <tool/tool_manager.h>
@ -50,6 +51,7 @@ struct hotkey_name_descr
int m_KeyCode;
};
/* table giving the hotkey name from the hotkey code, for special keys
* Note : when modifiers (ATL, SHIFT, CTRL) do not modify
* the code of the key, do need to enter the modified key code
@ -120,6 +122,7 @@ static struct hotkey_name_descr hotkeyNameList[] =
{ wxT( "" ), KEY_NON_FOUND }
};
// name of modifier keys.
// Note: the Ctrl key is Cmd key on Mac OS X.
// However, in wxWidgets defs, the key WXK_CONTROL is the Cmd key,
@ -326,7 +329,7 @@ void ReadHotKeyConfig( const wxString& aFileName, std::map<std::string, int>& aH
if( fileName.IsEmpty() )
{
wxFileName fn( "user" );
fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
fn.SetExt( HotkeyFileExtension );
fn.SetPath( SETTINGS_MANAGER::GetUserSettingsPath() );
fileName = fn.GetFullPath();
}
@ -362,7 +365,7 @@ int WriteHotKeyConfig( const std::map<std::string, TOOL_ACTION*>& aActionMap )
std::map<std::string, int> hotkeys;
wxFileName fn( "user" );
fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
fn.SetExt( HotkeyFileExtension );
fn.SetPath( SETTINGS_MANAGER::GetUserSettingsPath() );
// Read the existing config (all hotkeys)
@ -408,7 +411,7 @@ int ReadLegacyHotkeyConfigFile( const wxString& aFilename, std::map<std::string,
{
wxFileName fn( aFilename );
fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
fn.SetExt( HotkeyFileExtension );
fn.SetPath( SETTINGS_MANAGER::GetUserSettingsPath() );
if( !wxFile::Exists( fn.GetFullPath() ) )

View File

@ -193,8 +193,8 @@ const wxString PGM_BASE::AskUserForPreferredEditor( const wxString& aDefaultEdit
// Show the modal editor and return the file chosen (may be empty if the user cancels
// the dialog).
return EDA_FILE_SELECTOR( _( "Select Preferred Editor" ), path, name, ext, mask, nullptr,
wxFD_OPEN | wxFD_FILE_MUST_EXIST, true );
return wxFileSelector( _( "Select Preferred Editor" ), path, name, wxT( "." ) + ext,
mask, wxFD_OPEN | wxFD_FILE_MUST_EXIST, nullptr );
}

View File

@ -138,6 +138,7 @@ const std::string GerberFileExtension( "gbr" );
const std::string GerberJobFileExtension( "gbrjob" );
const std::string HtmlFileExtension( "html" );
const std::string EquFileExtension( "equ" );
const std::string HotkeyFileExtension( "hotkeys" );
const std::string ArchiveFileExtension( "zip" );
@ -160,11 +161,13 @@ const std::string GedaPcbFootprintLibFileExtension( "fp" ); // this is a fil
const std::string KiCadFootprintFileExtension( "kicad_mod" );
const std::string SpecctraDsnFileExtension( "dsn" );
const std::string SpecctraSessionFileExtension( "ses" );
const std::string IpcD356FileExtension( "d356" );
const std::string WorkbookFileExtension( "wbk" );
const std::string PngFileExtension( "png" );
const std::string JpegFileExtension( "jpg" );
const std::string TextFileExtension( "txt" );
bool IsProtelExtension( const wxString& ext )
@ -500,6 +503,12 @@ wxString SpecctraDsnFileWildcard()
}
wxString SpecctraSessionFileWildcard()
{
return _( "Specctra Session file" ) + AddFileExtListToFilter( { "ses" } );
}
wxString IpcD356FileWildcard()
{
return _( "IPC-D-356 Test Files" ) + AddFileExtListToFilter( { "d356" } );
@ -522,3 +531,9 @@ wxString JpegFileWildcard()
{
return _( "Jpeg file" ) + AddFileExtListToFilter( { "jpg", "jpeg" } );
}
wxString HotkeyFileWildcard()
{
return _( "Hotkey file" ) + AddFileExtListToFilter( { "hotkey" } );
}

View File

@ -417,9 +417,9 @@ wxString DIALOG_BOM::chooseGenerator()
if( lastPath.IsEmpty() )
lastPath = PATHS::GetUserPluginsPath();
wxString fullFileName = EDA_FILE_SELECTOR( _( "Generator files:" ), lastPath, wxEmptyString,
wxString fullFileName = wxFileSelector( _( "Generator File" ), lastPath, wxEmptyString,
wxEmptyString, wxFileSelectorDefaultWildcardStr,
this, wxFD_OPEN, true );
wxFD_OPEN, this );
return fullFileName;
}

View File

@ -376,8 +376,8 @@ void NETLIST_DIALOG::InstallCustomPages()
}
NETLIST_PAGE_DIALOG* NETLIST_DIALOG::AddOneCustomPage( const wxString & aTitle,
const wxString & aCommandString,
NETLIST_PAGE_DIALOG* NETLIST_DIALOG::AddOneCustomPage( const wxString& aTitle,
const wxString& aCommandString,
NETLIST_TYPE_ID aNetTypeId )
{
NETLIST_PAGE_DIALOG* currPage = new NETLIST_PAGE_DIALOG( m_NoteBook, aTitle, aNetTypeId );
@ -686,9 +686,11 @@ void NETLIST_DIALOG_ADD_GENERATOR::OnBrowseGenerators( wxCommandEvent& event )
#else
Path = PATHS::GetOSXKicadDataDir() + wxT( "/plugins" );
#endif
FullFileName = EDA_FILE_SELECTOR( _( "Generator files:" ), Path, FullFileName,
FullFileName = wxFileSelector( _( "Generator File" ), Path, FullFileName,
wxEmptyString, wxFileSelectorDefaultWildcardStr,
this, wxFD_OPEN, true );
wxFD_OPEN, this );
if( FullFileName.IsEmpty() )
return;

View File

@ -32,7 +32,7 @@
#include <symbol_viewer_frame.h>
#include <symbol_tree_model_adapter.h>
#include <wildcards_and_files_ext.h>
#include <gestfich.h>
#include <wildcards_and_files_ext.h>
#include <bitmaps/bitmap_types.h>
#include <confirm.h>
#include <wx/filedlg.h>
@ -427,15 +427,15 @@ int SYMBOL_EDITOR_CONTROL::ExportSymbolAsSVG( const TOOL_EVENT& aEvent )
return 0;
}
wxString file_ext = wxT( "svg" );
wxString mask = wxT( "*." ) + file_ext;
wxString file_ext = SVGFileExtension;
wxFileName fn( symbol->GetName() );
fn.SetExt( file_ext );
fn.SetExt( SVGFileExtension );
wxString pro_dir = wxPathOnly( m_frame->Prj().GetProjectFullName() );
wxString fullFileName = EDA_FILE_SELECTOR( _( "Filename:" ), pro_dir, fn.GetFullName(),
file_ext, mask, m_frame, wxFD_SAVE, true );
wxString fullFileName = wxFileSelector( _( "SVG File Name" ), pro_dir, fn.GetFullName(),
SVGFileExtension, SVGFileWildcard(), wxFD_SAVE,
m_frame );
if( !fullFileName.IsEmpty() )
{

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009-2014 Jerry Jacobs
* Copyright (C) 1992-2020 KiCad Developers, see CHANGELOG.TXT for contributors.
* Copyright (C) 1992-2021 KiCad Developers, see CHANGELOG.TXT for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -66,36 +66,6 @@ bool CanPrintFile( const wxString& file );
*/
void KiCopyFile( const wxString& aSrcPath, const wxString& aDestPath, wxString& aErrors );
/**
* A helper function that wraps a call to wxFileSelector.
*
* @param aTitle is a string to display in the dialog title bar.
* @param aPath is a string contain the default path for the path dialog.
* @param aFileName is a string containing the default file name.
* @param aExtension is a string containing the default file extension.
* @param aWildcard is a string containing the default wildcard.
* @param aParent is the parent window of the dialog.
* @param aStyle is the style of the path dialog, wxFD_???.
* @param aKeepWorkingDirectory determines if current working directory should be set to the
* user selected path.
* @param aPosition is the position of the dialog.
* @param aMruPath is a pointer to a string to copy the path selected by the user when
* the OK button is pressed to dismiss the dialog. This can be NULL.
* @return the full path and file name of the selected file or wxEmptyString if the user
* pressed the cancel button to dismiss the dialog.
*/
wxString EDA_FILE_SELECTOR( const wxString& aTitle,
const wxString& aPath,
const wxString& aFileName,
const wxString& aExtension,
const wxString& aWildcard,
wxWindow* aParent,
int aStyle,
const bool aKeepWorkingDirectory,
const wxPoint& aPosition = wxDefaultPosition,
wxString* aMruPath = nullptr );
/**
* Call the executable file \a ExecFile with the command line parameters \a param.
*/

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -27,7 +27,6 @@
#include <wx/string.h>
#include <map>
#define DEFAULT_HOTKEY_FILENAME_EXT wxT( "hotkeys" )
#define EESCHEMA_HOTKEY_NAME wxT( "Eeschema" )
#define PCBNEW_HOTKEY_NAME wxT( "PcbNew" )

View File

@ -126,6 +126,7 @@ extern const std::string GerberFileExtension;
extern const std::string GerberJobFileExtension;
extern const std::string HtmlFileExtension;
extern const std::string EquFileExtension;
extern const std::string HotkeyFileExtension;
extern const std::string ArchiveFileExtension;
@ -150,11 +151,13 @@ extern const std::string GedaPcbFootprintLibFileExtension;
extern const std::string EagleFootprintLibPathExtension;
extern const std::string DrawingSheetFileExtension;
extern const std::string SpecctraDsnFileExtension;
extern const std::string SpecctraSessionFileExtension;
extern const std::string IpcD356FileExtension;
extern const std::string WorkbookFileExtension;
extern const std::string PngFileExtension;
extern const std::string JpegFileExtension;
extern const std::string TextFileExtension;
bool IsProtelExtension( const wxString& ext );
@ -233,10 +236,12 @@ extern wxString GencadFileWildcard();
extern wxString DxfFileWildcard();
extern wxString GerberJobFileWildcard();
extern wxString SpecctraDsnFileWildcard();
extern wxString SpecctraSessionFileWildcard();
extern wxString IpcD356FileWildcard();
extern wxString WorkbookFileWildcard();
extern wxString PngFileWildcard();
extern wxString JpegFileWildcard();
extern wxString HotkeyFileWildcard();
/**
* @}

View File

@ -106,9 +106,6 @@ static const wxChar* s_allowedExtensionsToList[] = {
* library as required.
*/
// File extension definitions.
const wxChar TextFileExtension[] = wxT( "txt" );
// Gerber file extension wildcard.
const wxString GerberFileExtensionWildCard( ".((gbr|gbrjob|(gb|gt)[alops])|pho)" );
@ -505,6 +502,7 @@ wxTreeItemId PROJECT_TREE_PANE::addItemToProjectTree( const wxString& aName,
bool haveFile = dir.GetFirst( &dir_filename );
data->SetPopulated( true );
#ifndef __WINDOWS__
subdir_populated = aRecurse;
#endif
@ -799,6 +797,7 @@ void PROJECT_TREE_PANE::onRight( wxTreeEvent& Event )
{
popup_menu.AppendSeparator();
AddMenuItem( &popup_menu, ID_PROJECT_PRINT,
#ifdef __APPLE__
_( "Print..." ),
#else
@ -969,6 +968,7 @@ void PROJECT_TREE_PANE::onExpand( wxTreeEvent& Event )
}
itemData->SetPopulated( true ); // set state to populated
#ifndef __WINDOWS__
subdir_populated = true;
#endif
@ -1098,8 +1098,8 @@ void PROJECT_TREE_PANE::onFileSystemEvent( wxFileSystemWatcherEvent& event )
{
case wxFSW_EVENT_CREATE:
{
wxTreeItemId newitem = addItemToProjectTree( pathModified.GetFullPath(), root_id,
nullptr, true );
wxTreeItemId newitem =
addItemToProjectTree( pathModified.GetFullPath(), root_id, nullptr, true );
// If we are in the process of renaming a file, select the new one
// This is needed for MSW and OSX, since we don't get RENAME events from them, just a

View File

@ -27,7 +27,6 @@
#include <confirm.h>
#include <trigo.h>
#include <kicad_string.h>
#include <gestfich.h>
#include <pcb_edit_frame.h>
#include <dialog_helpers.h>
#include <dialog_shim.h>
@ -172,9 +171,8 @@ void MWAVE_POLYGONAL_SHAPE_DLG::ReadDataShapeDescr( wxCommandEvent& event )
wxString fullFileName;
wxString mask = wxFileSelectorDefaultWildcardStr;
fullFileName = EDA_FILE_SELECTOR( _( "Read Shape Description File" ), lastpath,
fullFileName, wxEmptyString, mask, this,
wxFD_OPEN, true );
fullFileName = wxFileSelector( _( "Shape Description File" ), lastpath,
fullFileName, wxEmptyString, mask, wxFD_OPEN, this );
if( fullFileName.IsEmpty() )
return;

View File

@ -47,7 +47,6 @@
#include <dialogs/dialog_page_settings.h>
#include <dialogs/dialog_update_pcb.h>
#include <functional>
#include <gestfich.h>
#include <kiface_i.h>
#include <kiway.h>
#include <memory>
@ -375,10 +374,12 @@ int BOARD_EDITOR_CONTROL::ImportSpecctraSession( const TOOL_EVENT& aEvent )
wxString ext;
wxFileName::SplitPath( fullFileName, &path, &name, &ext );
name += wxT( ".ses" );
name += wxT( "." ) + SpecctraSessionFileExtension;
fullFileName = EDA_FILE_SELECTOR( _( "Merge Specctra Session file:" ), path, name,
wxT( ".ses" ), wxT( "*.ses" ), frame(), wxFD_OPEN, false );
fullFileName = wxFileSelector( _( "Specctra Session File" ), path, name,
wxT( "." ) + SpecctraSessionFileExtension,
SpecctraSessionFileWildcard(), wxFD_OPEN | wxFD_CHANGE_DIR,
frame() );
if( !fullFileName.IsEmpty() )
getEditFrame<PCB_EDIT_FRAME>()->ImportSpecctraSession( fullFileName );
@ -400,9 +401,9 @@ int BOARD_EDITOR_CONTROL::ExportSpecctraDSN( const TOOL_EVENT& aEvent )
else
fn = fullFileName;
fullFileName = EDA_FILE_SELECTOR( _( "Specctra DSN File" ), fn.GetPath(), fn.GetFullName(),
fullFileName = wxFileSelector( _( "Specctra DSN File" ), fn.GetPath(), fn.GetFullName(),
SpecctraDsnFileExtension, SpecctraDsnFileWildcard(),
frame(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT, false );
wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxFD_CHANGE_DIR, frame() );
if( !fullFileName.IsEmpty() )
{