Add a helper function FileExtListToFilter() to build the wildcard filter used in File Dialog.
It avoid including these extensions in a translatable string, thus avoid breaking filter if the translation is incorrect (It happens sometimes). See wildcards_and_files_ext.cpp for use.
This commit is contained in:
parent
dffa399eab
commit
14ede151cc
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2012 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2018 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
|
||||
|
@ -25,6 +25,7 @@
|
|||
|
||||
/**
|
||||
* @file wildcards_and_files_ext.cpp
|
||||
* Definition of file extensions used in Kicad.
|
||||
*/
|
||||
#include <wildcards_and_files_ext.h>
|
||||
|
||||
|
@ -46,7 +47,7 @@
|
|||
*
|
||||
* @return the build appropriate file dialog wildcard filter.
|
||||
*/
|
||||
static wxString FormatWildcardExt( const wxString& aWildcard )
|
||||
static wxString formatWildcardExt( const wxString& aWildcard )
|
||||
{
|
||||
wxString wc;
|
||||
#if defined( __WXGTK__ )
|
||||
|
@ -68,6 +69,45 @@ static wxString FormatWildcardExt( const wxString& aWildcard )
|
|||
}
|
||||
|
||||
|
||||
wxString AddFileExtListToFilter( int aArgCnt, ... )
|
||||
{
|
||||
wxString files_filter = " (*.";
|
||||
|
||||
va_list args;
|
||||
va_start( args, aArgCnt );
|
||||
|
||||
// Add extensions to the info message:
|
||||
for( int ii = 0; ii < aArgCnt; ii++)
|
||||
{
|
||||
const char* ext = va_arg(args, char*);
|
||||
|
||||
if( ii > 0 )
|
||||
files_filter << " *.";
|
||||
|
||||
files_filter << formatWildcardExt( ext );
|
||||
}
|
||||
|
||||
files_filter << ")|*.";
|
||||
|
||||
va_start( args, aArgCnt );
|
||||
|
||||
// Add extensions to the filter list:
|
||||
for( int ii = 0; ii < aArgCnt; ii++)
|
||||
{
|
||||
const char* ext = va_arg( args, const char* );
|
||||
|
||||
if( ii > 0 )
|
||||
files_filter << ";*.";
|
||||
|
||||
files_filter << formatWildcardExt( ext );
|
||||
}
|
||||
|
||||
va_end( args );
|
||||
|
||||
return files_filter;
|
||||
}
|
||||
|
||||
|
||||
const std::string SchematicSymbolFileExtension( "sym" );
|
||||
const std::string SchematicLibraryFileExtension( "lib" );
|
||||
const std::string SchematicBackupFileExtension( "bak" );
|
||||
|
@ -112,280 +152,271 @@ const wxString AllFilesWildcard( _( "All files (*)|*" ) );
|
|||
|
||||
wxString SchematicSymbolFileWildcard()
|
||||
{
|
||||
return _( "KiCad drawing symbol files (*.sym)|*." ) + FormatWildcardExt( "sym" );
|
||||
return _( "KiCad drawing symbol files" ) + AddFileExtListToFilter( 1, "sym" );
|
||||
}
|
||||
|
||||
|
||||
wxString SchematicLibraryFileWildcard()
|
||||
{
|
||||
return _( "KiCad symbol library files (*.lib)|*." ) + FormatWildcardExt( "lib" );
|
||||
return _( "KiCad symbol library files" ) + AddFileExtListToFilter( 1, "lib" );
|
||||
}
|
||||
|
||||
|
||||
wxString ProjectFileWildcard()
|
||||
{
|
||||
return _( "KiCad project files (*.pro)|*." ) + FormatWildcardExt( "pro" );
|
||||
return _( "KiCad project files" ) + AddFileExtListToFilter( 1, "pro" );
|
||||
}
|
||||
|
||||
|
||||
wxString SchematicFileWildcard()
|
||||
{
|
||||
return _( "KiCad schematic files (*.sch)|*." ) + FormatWildcardExt( "sch" );
|
||||
return _( "KiCad schematic files" ) + AddFileExtListToFilter( 1, "sch" );
|
||||
}
|
||||
|
||||
|
||||
wxString EagleSchematicFileWildcard()
|
||||
{
|
||||
return _( "Eagle XML schematic files (*.sch)|*." ) + FormatWildcardExt( "sch" );
|
||||
return _( "Eagle XML schematic files" ) + AddFileExtListToFilter( 1, "sch" );
|
||||
}
|
||||
|
||||
|
||||
wxString EagleFilesWildcard()
|
||||
{
|
||||
return _( "Eagle XML files (*.sch *.brd)|*." ) +
|
||||
FormatWildcardExt( "sch" ) + ";*." + FormatWildcardExt( "brd" );
|
||||
return _( "Eagle XML files" ) + AddFileExtListToFilter( 2, "sch", "brd" );
|
||||
}
|
||||
|
||||
|
||||
wxString NetlistFileWildcard()
|
||||
{
|
||||
return _( "KiCad netlist files (*.net)|*." ) + FormatWildcardExt( "net" );
|
||||
return _( "KiCad netlist files" ) + AddFileExtListToFilter( 1, "net" );
|
||||
}
|
||||
|
||||
|
||||
wxString GerberFileWildcard()
|
||||
{
|
||||
return _( "Gerber files (*.pho)|*." ) + FormatWildcardExt( "pho" );
|
||||
return _( "Gerber files" ) + AddFileExtListToFilter( 1, "pho" );
|
||||
}
|
||||
|
||||
|
||||
wxString LegacyPcbFileWildcard()
|
||||
{
|
||||
return _( "KiCad printed circuit board files (*.brd)|*." ) + FormatWildcardExt( "brd" );
|
||||
return _( "KiCad printed circuit board files" ) + AddFileExtListToFilter( 1, "brd" );
|
||||
}
|
||||
|
||||
|
||||
wxString EaglePcbFileWildcard()
|
||||
{
|
||||
return _( "Eagle ver. 6.x XML PCB files (*.brd)|*." ) + FormatWildcardExt( "brd" );
|
||||
return _( "Eagle ver. 6.x XML PCB files" ) + AddFileExtListToFilter( 1, "brd" );
|
||||
}
|
||||
|
||||
|
||||
wxString PCadPcbFileWildcard()
|
||||
{
|
||||
return _( "P-Cad 200x ASCII PCB files (*.pcb)|*." ) + FormatWildcardExt( "pcb" );
|
||||
return _( "P-Cad 200x ASCII PCB files" ) + AddFileExtListToFilter( 1, "pcb" );
|
||||
}
|
||||
|
||||
|
||||
wxString PcbFileWildcard()
|
||||
{
|
||||
return _( "KiCad printed circuit board files (*.kicad_pcb)|*." ) +
|
||||
FormatWildcardExt( "kicad_pcb" );
|
||||
return _( "KiCad printed circuit board files" ) + AddFileExtListToFilter( 1, "kicad_pcb" );
|
||||
}
|
||||
|
||||
|
||||
wxString KiCadFootprintLibFileWildcard()
|
||||
{
|
||||
return _( "KiCad footprint files (*.kicad_mod)|*." ) + FormatWildcardExt( "kicad_mod" );
|
||||
return _( "KiCad footprint files" ) + AddFileExtListToFilter( 1, "kicad_mod" );
|
||||
}
|
||||
|
||||
|
||||
wxString KiCadFootprintLibPathWildcard()
|
||||
{
|
||||
return _( "KiCad footprint library paths (*.pretty)|*." ) + FormatWildcardExt( "pretty" );
|
||||
return _( "KiCad footprint library paths" ) + AddFileExtListToFilter( 1, "pretty" );
|
||||
}
|
||||
|
||||
|
||||
wxString LegacyFootprintLibPathWildcard()
|
||||
{
|
||||
return _( "Legacy footprint library files (*.mod)|*." ) + FormatWildcardExt( "mod" );
|
||||
return _( "Legacy footprint library files" ) + AddFileExtListToFilter( 1, "mod" );
|
||||
}
|
||||
|
||||
|
||||
wxString EagleFootprintLibPathWildcard()
|
||||
{
|
||||
return _( "Eagle ver. 6.x XML library files (*.lbr)|*." ) + FormatWildcardExt( "lbr" );
|
||||
return _( "Eagle ver. 6.x XML library files" ) + AddFileExtListToFilter( 1, "lbr" );
|
||||
}
|
||||
|
||||
|
||||
wxString GedaPcbFootprintLibFileWildcard()
|
||||
{
|
||||
return _( "Geda PCB footprint library files (*.fp)|*." ) + FormatWildcardExt( "fp" );
|
||||
return _( "Geda PCB footprint library files" ) + AddFileExtListToFilter( 1, "fp" );
|
||||
}
|
||||
|
||||
|
||||
wxString PageLayoutDescrFileWildcard()
|
||||
{
|
||||
return _( "Page layout design files (*.kicad_wks)|*." ) + FormatWildcardExt( "kicad_wks" );
|
||||
return _( "Page layout design files" ) + AddFileExtListToFilter( 1, "kicad_wks" );
|
||||
}
|
||||
|
||||
|
||||
// Wildcard for cvpcb component to footprint link file
|
||||
wxString ComponentFileWildcard()
|
||||
{
|
||||
return _( "KiCad symbol footprint link files (*.cmp)|*." ) + FormatWildcardExt( "cmp" );
|
||||
return _( "KiCad symbol footprint link files" ) + AddFileExtListToFilter( 1, "cmp" );
|
||||
}
|
||||
|
||||
|
||||
// Wildcard for reports and fabrication documents
|
||||
wxString DrillFileWildcard()
|
||||
{
|
||||
//return _( "Drill files (*.drl)|*." ) + FormatWildcardExt( "drl" );
|
||||
return _( "Drill files (*.drl *.nc *.xnc)|*." ) + FormatWildcardExt( "drl" )
|
||||
+ ";*." + FormatWildcardExt( "nc" )
|
||||
+ ";*." + FormatWildcardExt( "xnc" );
|
||||
return _( "Drill files" ) + AddFileExtListToFilter( 3, "drl", "nc", "xnc" );
|
||||
}
|
||||
|
||||
|
||||
wxString SVGFileWildcard()
|
||||
{
|
||||
return _( "SVG files (*.svg)|*." ) + FormatWildcardExt( "svg" );
|
||||
return _( "SVG files" ) + AddFileExtListToFilter( 1, "svg" );
|
||||
}
|
||||
|
||||
|
||||
wxString HtmlFileWildcard()
|
||||
{
|
||||
return _( "HTML files (*.html)|*." ) + FormatWildcardExt( "htm" ) + ";*.," +
|
||||
FormatWildcardExt( "html" );
|
||||
return _( "HTML files" ) + AddFileExtListToFilter( 2, "htm" , "html" );
|
||||
}
|
||||
|
||||
|
||||
wxString CsvFileWildcard()
|
||||
{
|
||||
return _( "CSV Files (*.csv)|*." ) + FormatWildcardExt( "csv" );
|
||||
return _( "CSV Files" ) + AddFileExtListToFilter( 1, "csv" );
|
||||
}
|
||||
|
||||
|
||||
wxString PdfFileWildcard()
|
||||
{
|
||||
return _( "Portable document format files (*.pdf)|*." ) + FormatWildcardExt( "pdf" );
|
||||
return _( "Portable document format files" ) + AddFileExtListToFilter( 1, "pdf" );
|
||||
}
|
||||
|
||||
|
||||
wxString PSFileWildcard()
|
||||
{
|
||||
return _( "PostScript files (.ps)|*." ) + FormatWildcardExt( "ps" );
|
||||
return _( "PostScript files" ) + AddFileExtListToFilter( 1, "ps" );
|
||||
}
|
||||
|
||||
|
||||
wxString ReportFileWildcard()
|
||||
{
|
||||
return _( "Report files (*.rpt)|*." ) + FormatWildcardExt( "rpt" );
|
||||
return _( "Report files" ) + AddFileExtListToFilter( 1, "rpt" );
|
||||
}
|
||||
|
||||
|
||||
wxString FootprintPlaceFileWildcard()
|
||||
{
|
||||
return _( "Footprint place files (*.pos)|*." ) + FormatWildcardExt( "pos" );
|
||||
return _( "Footprint place files" ) + AddFileExtListToFilter( 1, "pos" );
|
||||
}
|
||||
|
||||
|
||||
wxString Shapes3DFileWildcard()
|
||||
{
|
||||
return _( "VRML and X3D files (*.wrl *.x3d)|*." ) + FormatWildcardExt( "wrl" ) +
|
||||
";*." + FormatWildcardExt( "x3d" );
|
||||
return _( "VRML and X3D files" ) + AddFileExtListToFilter( 2, "wrl", "x3d" );
|
||||
}
|
||||
|
||||
|
||||
wxString IDF3DFileWildcard()
|
||||
{
|
||||
return _( "IDFv3 footprint files (*.idf)|*." ) + FormatWildcardExt( "idf" );
|
||||
return _( "IDFv3 footprint files" ) + AddFileExtListToFilter( 1, "idf" );
|
||||
}
|
||||
|
||||
|
||||
wxString TextFileWildcard()
|
||||
{
|
||||
return _( "Text files (*.txt)|*." ) + FormatWildcardExt( "txt" );
|
||||
return _( "Text files" ) + AddFileExtListToFilter( 1, "txt" );
|
||||
}
|
||||
|
||||
|
||||
wxString ModLegacyExportFileWildcard()
|
||||
{
|
||||
return _( "Legacy footprint export files (*.emp)|*." ) + FormatWildcardExt( "emp" );
|
||||
return _( "Legacy footprint export files" ) + AddFileExtListToFilter( 1, "emp" );
|
||||
}
|
||||
|
||||
|
||||
wxString ErcFileWildcard()
|
||||
{
|
||||
return _( "Electronic rule check file (.erc)|*." ) + FormatWildcardExt( "erc" );
|
||||
return _( "Electronic rule check file" ) + AddFileExtListToFilter( 1, "erc" );
|
||||
}
|
||||
|
||||
|
||||
wxString SpiceLibraryFileWildcard()
|
||||
{
|
||||
return _( "Spice library file (*.lib)|*." ) + FormatWildcardExt( "lib" );
|
||||
return _( "Spice library file" ) + AddFileExtListToFilter( 1, "lib" );
|
||||
}
|
||||
|
||||
|
||||
wxString SpiceNetlistFileWildcard()
|
||||
{
|
||||
return _( "SPICE netlist file (.cir)|*." ) + FormatWildcardExt( "cir" );
|
||||
return _( "SPICE netlist file" ) + AddFileExtListToFilter( 1, "cir" );
|
||||
}
|
||||
|
||||
|
||||
wxString CadstarNetlistFileWildcard()
|
||||
{
|
||||
return _( "CadStar netlist file (.frp)|*." ) + FormatWildcardExt( "frp" );
|
||||
return _( "CadStar netlist file" ) + AddFileExtListToFilter( 1, "frp" );
|
||||
}
|
||||
|
||||
|
||||
wxString EquFileWildcard()
|
||||
{
|
||||
return _( "Symbol footprint association files (*.equ)|*." ) + FormatWildcardExt( "equ" );
|
||||
return _( "Symbol footprint association files" ) + AddFileExtListToFilter( 1, "equ" );
|
||||
}
|
||||
|
||||
|
||||
wxString ZipFileWildcard()
|
||||
{
|
||||
return _( "Zip file (*.zip)|*." ) + FormatWildcardExt( "zip" );
|
||||
return _( "Zip file" ) + AddFileExtListToFilter( 1, "zip" );
|
||||
}
|
||||
|
||||
|
||||
wxString GencadFileWildcard()
|
||||
{
|
||||
return _( "GenCAD 1.4 board files (.cad)|*." ) + FormatWildcardExt( "cad" );
|
||||
return _( "GenCAD 1.4 board files" ) + AddFileExtListToFilter( 1, "cad" );
|
||||
}
|
||||
|
||||
|
||||
wxString DxfFileWildcard()
|
||||
{
|
||||
return _( "DXF Files (*.dxf)|*." ) + FormatWildcardExt( "dxf" );
|
||||
return _( "DXF Files" ) + AddFileExtListToFilter( 1, "dxf" );
|
||||
}
|
||||
|
||||
|
||||
wxString GerberJobFileWildcard()
|
||||
{
|
||||
return _( "Gerber job file (*.gbrjob)|*." ) + FormatWildcardExt( "gbrjob" ) +
|
||||
";.gbrjob";
|
||||
return _( "Gerber job file" ) + AddFileExtListToFilter( 1, "gbrjob" );
|
||||
}
|
||||
|
||||
|
||||
wxString SpecctraDsnFileWildcard()
|
||||
{
|
||||
return _( "Specctra DSN file (*.dsn)|*." ) + FormatWildcardExt( "dsn" );
|
||||
return _( "Specctra DSN file" ) + AddFileExtListToFilter( 1, "dsn" );
|
||||
}
|
||||
|
||||
|
||||
wxString IpcD356FileWildcard()
|
||||
{
|
||||
return _( "IPC-D-356 Test Files (.d356)|*." ) + FormatWildcardExt( "d356" );
|
||||
return _( "IPC-D-356 Test Files" ) + AddFileExtListToFilter( 1, "d356" );
|
||||
}
|
||||
|
||||
|
||||
wxString WorkbookFileWildcard()
|
||||
{
|
||||
return _( "Workbook file (*.wbk)|*." ) + FormatWildcardExt( "wbk" );
|
||||
return _( "Workbook file" ) + AddFileExtListToFilter( 1, "wbk" );
|
||||
}
|
||||
|
||||
|
||||
wxString PngFileWildcard()
|
||||
{
|
||||
return _( "PNG file (*.png)|*." ) + FormatWildcardExt( "png" );
|
||||
return _( "PNG file" ) + AddFileExtListToFilter( 1, "png" );
|
||||
}
|
||||
|
||||
|
||||
wxString JpegFileWildcard()
|
||||
{
|
||||
return _( "Jpeg file (*.jpg *.jpeg)|*." ) + FormatWildcardExt( "jpg" ) + ";*." +
|
||||
FormatWildcardExt( "jpeg" );
|
||||
return _( "Jpeg file" ) + AddFileExtListToFilter( 2, "jpg", "jpeg" );
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2007-2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2018 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
|
||||
|
@ -25,8 +25,8 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* The common library
|
||||
* @file wildcards_and_files_ext.h
|
||||
* Definition of file extensions used in Kicad.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_WILDCARDS_AND_FILES_EXT_H_
|
||||
|
@ -46,6 +46,23 @@
|
|||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* build the wildcard extension file dialog wildcard filter to add to the base message dialog.
|
||||
* for instance, to open .txt files in a file dialog:
|
||||
* the base message is for instance "Text files"
|
||||
* the ext list is " (*.txt)|*.txt"
|
||||
* and the returned string to add to the base message is " (*.txt)|*.txt"
|
||||
* the message to display in the dialog is "Text files (*.txt)|*.txt"
|
||||
*
|
||||
* @param aArgCnt is the count of file ext to add to the filter
|
||||
* other params are the const char* file ext to add to the filter
|
||||
*
|
||||
* @return the appropriate file dialog wildcard filter list.
|
||||
*/
|
||||
|
||||
wxString AddFileExtListToFilter( int aArgCnt, ... );
|
||||
|
||||
|
||||
// Do NOT use wxString for these. wxStrings are not thread-safe, even when const. (For the
|
||||
// curious the UTF8 cacheing strategy puts iterators in a linked list. Insertion and removal
|
||||
// from the linked list is not thread-safe.)
|
||||
|
|
Loading…
Reference in New Issue