KiCad PCB EDA Suite
pgm_base.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2004-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
6  * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
33 #include <wx/html/htmlwin.h>
34 #include <wx/fs_zip.h>
35 #include <wx/dir.h>
36 #include <wx/filename.h>
37 #include <wx/snglinst.h>
38 #include <wx/stdpaths.h>
39 #include <wx/sysopt.h>
40 #include <wx/filedlg.h>
41 #include <wx/tooltip.h>
42 
43 #include <common.h>
44 #include <config_params.h>
45 #include <confirm.h>
46 #include <core/arraydim.h>
47 #include <eda_base_frame.h>
48 #include <eda_draw_frame.h>
49 #include <gestfich.h>
50 #include <id.h>
51 #include <lockfile.h>
52 #include <menus_helpers.h>
53 #include <pgm_base.h>
54 #include <python_scripting.h>
57 #include <systemdirsappend.h>
58 #include <trace_helpers.h>
59 
60 
68 #undef _
69 #define _(s) s
71 {
72  { wxLANGUAGE_DEFAULT, ID_LANGUAGE_DEFAULT, _( "Default" ), false },
73  { wxLANGUAGE_INDONESIAN, ID_LANGUAGE_INDONESIAN, wxT( "Bahasa Indonesia" ), true },
74  { wxLANGUAGE_CATALAN, ID_LANGUAGE_CATALAN, wxT( "Català" ), true },
75  { wxLANGUAGE_CZECH, ID_LANGUAGE_CZECH, wxT( "Čeština" ), true },
76  { wxLANGUAGE_DANISH, ID_LANGUAGE_DANISH, wxT( "Dansk" ), true },
77  { wxLANGUAGE_GERMAN, ID_LANGUAGE_GERMAN, wxT( "Deutsch" ), true },
78  { wxLANGUAGE_GREEK, ID_LANGUAGE_GREEK, wxT( "Ελληνικά" ), true },
79  { wxLANGUAGE_ENGLISH, ID_LANGUAGE_ENGLISH, wxT( "English" ), true },
80  { wxLANGUAGE_SPANISH, ID_LANGUAGE_SPANISH, wxT( "Español" ), true },
81  { wxLANGUAGE_FRENCH, ID_LANGUAGE_FRENCH, wxT( "Français" ), true },
82  { wxLANGUAGE_ITALIAN, ID_LANGUAGE_ITALIAN, wxT( "Italiano" ), true },
83  { wxLANGUAGE_LITHUANIAN, ID_LANGUAGE_LITHUANIAN, wxT( "Lietuvių" ), true },
84  { wxLANGUAGE_HUNGARIAN, ID_LANGUAGE_HUNGARIAN, wxT( "Magyar" ), true },
85  { wxLANGUAGE_JAPANESE, ID_LANGUAGE_JAPANESE, wxT( "日本語" ), true },
86  { wxLANGUAGE_POLISH, ID_LANGUAGE_POLISH, wxT( "Polski" ), true },
87  { wxLANGUAGE_PORTUGUESE, ID_LANGUAGE_PORTUGUESE, wxT( "Português" ),true },
88  { wxLANGUAGE_RUSSIAN, ID_LANGUAGE_RUSSIAN, wxT( "Русский" ), true },
89  { wxLANGUAGE_SERBIAN, ID_LANGUAGE_SERBIAN, wxT( "Српски"), true },
90  { wxLANGUAGE_FINNISH, ID_LANGUAGE_FINNISH, wxT( "Suomi" ), true },
91  { wxLANGUAGE_VIETNAMESE, ID_LANGUAGE_VIETNAMESE, wxT( "Tiếng Việt" ), true },
92  { wxLANGUAGE_TURKISH, ID_LANGUAGE_TURKISH, wxT( "Türkçe" ), true },
93  { wxLANGUAGE_CHINESE_SIMPLIFIED, ID_LANGUAGE_CHINESE_SIMPLIFIED,
94  wxT( "简体中文" ), true },
95  { wxLANGUAGE_CHINESE_TRADITIONAL, ID_LANGUAGE_CHINESE_TRADITIONAL,
96  wxT( "繁體中文" ), false },
97  { 0, 0, "", false } // Sentinel
98 };
99 #undef _
100 #define _(s) wxGetTranslation((s))
101 
102 
104 {
105  m_locale = nullptr;
106  m_Printing = false;
107  m_ModalDialogCount = 0;
108 
109  m_show_env_var_dialog = true;
110 
111  setLanguageId( wxLANGUAGE_DEFAULT );
112 
113  ForceSystemPdfBrowser( false );
114 }
115 
116 
118 {
119  Destroy();
120 }
121 
122 
124 {
125  // unlike a normal destructor, this is designed to be called more than once safely:
126  delete m_locale;
127  m_locale = nullptr;
128 }
129 
130 
132 {
133  wxASSERT( wxTheApp );
134  return *wxTheApp;
135 }
136 
137 
138 void PGM_BASE::SetEditorName( const wxString& aFileName )
139 {
140  m_editor_name = aFileName;
141  wxASSERT( GetCommonSettings() );
142  GetCommonSettings()->m_System.editor_name = aFileName;
143 }
144 
145 
146 const wxString& PGM_BASE::GetEditorName( bool aCanShowFileChooser )
147 {
148  wxString editorname = m_editor_name;
149 
150  if( !editorname )
151  {
152  if( !wxGetEnv( "EDITOR", &editorname ) )
153  {
154  // If there is no EDITOR variable set, try the desktop default
155 #ifdef __WXMAC__
156  editorname = "/usr/bin/open";
157 #elif __WXX11__
158  editorname = "/usr/bin/xdg-open";
159 #endif
160  }
161  }
162 
163  // If we still don't have an editor name show a dialog asking the user to select one
164  if( !editorname && aCanShowFileChooser )
165  {
166  DisplayInfoMessage( NULL, _( "No default editor found, you must choose it" ) );
167 
168  editorname = AskUserForPreferredEditor();
169  }
170 
171  // If we finally have a new editor name request it to be copied to m_editor_name and
172  // saved to the preferences file.
173  if( !editorname.IsEmpty() )
174  SetEditorName( editorname );
175 
176  // m_editor_name already has the same value that editorname, or empty if no editor was
177  // found/chosen.
178  return m_editor_name;
179 }
180 
181 
182 const wxString PGM_BASE::AskUserForPreferredEditor( const wxString& aDefaultEditor )
183 {
184  // Create a mask representing the executable files in the current platform
185 #ifdef __WINDOWS__
186  wxString mask( _( "Executable file (*.exe)|*.exe" ) );
187 #else
188  wxString mask( _( "Executable file (*)|*" ) );
189 #endif
190 
191  // Extract the path, name and extension from the default editor (even if the editor's
192  // name was empty, this method will succeed and return empty strings).
193  wxString path, name, ext;
194  wxFileName::SplitPath( aDefaultEditor, &path, &name, &ext );
195 
196  // Show the modal editor and return the file chosen (may be empty if the user cancels
197  // the dialog).
198  return EDA_FILE_SELECTOR( _( "Select Preferred Editor" ), path, name, ext, mask, NULL,
199  wxFD_OPEN | wxFD_FILE_MUST_EXIST, true );
200 }
201 
202 
203 bool PGM_BASE::InitPgm( bool aHeadless )
204 {
205  wxString pgm_name = wxFileName( App().argv[0] ).GetName().Lower();
206 
207  wxInitAllImageHandlers();
208 
209 #ifndef __WINDOWS__
210  if( wxString( wxGetenv( "HOME" ) ).IsEmpty() )
211  {
212  DisplayErrorMessage( nullptr, _( "Environment variable HOME is empty. "
213  "Unable to continue." ) );
214  return false;
215  }
216 #endif
217 
218  // Init KiCad environment
219  // the environment variable KICAD (if exists) gives the kicad path:
220  // something like set KICAD=d:\kicad
221  bool isDefined = wxGetEnv( "KICAD", &m_kicad_env );
222 
223  if( isDefined ) // ensure m_kicad_env ends by "/"
224  {
226 
227  if( !m_kicad_env.IsEmpty() && m_kicad_env.Last() != '/' )
229  }
230 
231  // Init parameters for configuration
232  App().SetVendorName( "KiCad" );
233  App().SetAppName( pgm_name );
234 
235  // Install some image handlers, mainly for help
236  if( wxImage::FindHandler( wxBITMAP_TYPE_PNG ) == NULL )
237  wxImage::AddHandler( new wxPNGHandler );
238 
239  if( wxImage::FindHandler( wxBITMAP_TYPE_GIF ) == NULL )
240  wxImage::AddHandler( new wxGIFHandler );
241 
242  if( wxImage::FindHandler( wxBITMAP_TYPE_JPEG ) == NULL )
243  wxImage::AddHandler( new wxJPEGHandler );
244 
245  wxFileSystem::AddHandler( new wxZipFSHandler );
246 
247  // Analyze the command line & initialize the binary path
248  wxString tmp;
250  SetLanguagePath();
251  SetDefaultLanguage( tmp );
252 
253  m_settings_manager = std::make_unique<SETTINGS_MANAGER>( aHeadless );
254 
255  // Something got in the way of settings load: can't continue
256  if( !m_settings_manager->IsOK() )
257  return false;
258 
259  // Set up built-in environment variables (and override them from the system enviroment if set)
261 
262  // Load common settings from disk after setting up env vars
264 
265  // Init user language *before* calling loadCommonSettings, because
266  // env vars could be incorrectly initialized on Linux
267  // (if the value contains some non ASCII7 chars, the env var is not initialized)
268  SetLanguage( tmp, true );
269 
270  // Now that translations are available, inform the user if the OS is unsupported
272 
274 
275  ReadPdfBrowserInfos(); // needs GetCommonSettings()
276 
277  m_python_scripting = std::make_unique<SCRIPTING>();
278 
279 #ifdef __WXMAC__
280  // Always show filters on Open dialog to be able to choose plugin
281  wxSystemOptions::SetOption( wxOSX_FILEDIALOG_ALWAYS_SHOW_TYPES, 1 );
282 #endif
283 
284  // TODO(JE): Remove this if apps are refactored to not assume Prj() always works
285  // Need to create a project early for now (it can have an empty path for the moment)
287 
288  // TODO: Move tooltips into KIPLATFORM
289  // This sets the maximum tooltip display duration to 10s (up from 5) but only affects
290  // Windows as other platforms display tooltips while the mouse is not moving
291  wxToolTip::SetAutoPop( 10000 );
292 
293  return true;
294 }
295 
296 
298 {
299  m_bin_dir = wxStandardPaths::Get().GetExecutablePath();
300 
301 #ifdef __WXMAC__
302  // On OSX Pgm().GetExecutablePath() will always point to main
303  // bundle directory, e.g., /Applications/kicad.app/
304 
305  wxFileName fn( m_bin_dir );
306 
307  if( fn.GetName() == wxT( "kicad" ) )
308  {
309  // kicad launcher, so just remove the Contents/MacOS part
310  fn.RemoveLastDir();
311  fn.RemoveLastDir();
312  }
313  else
314  {
315  // standalone binaries live in Contents/Applications/<standalone>.app/Contents/MacOS
316  fn.RemoveLastDir();
317  fn.RemoveLastDir();
318  fn.RemoveLastDir();
319  fn.RemoveLastDir();
320  fn.RemoveLastDir();
321  }
322 
323  m_bin_dir = fn.GetPath() + wxT( "/" );
324 #else
325  // Use unix notation for paths. I am not sure this is a good idea,
326  // but it simplifies compatibility between Windows and Unices.
327  // However it is a potential problem in path handling under Windows.
329 
330  // Remove file name form command line:
331  while( m_bin_dir.Last() != '/' && !m_bin_dir.IsEmpty() )
332  m_bin_dir.RemoveLast();
333 #endif
334 
335  return true;
336 }
337 
338 
340 {
343 
344  for( const std::pair<wxString, ENV_VAR_ITEM> it : GetCommonSettings()->m_Env.vars )
345  {
346  wxLogTrace( traceEnvVars, "PGM_BASE::loadCommonSettings: Found entry %s = %s",
347  it.first, it.second.GetValue() );
348 
349  // Do not store the env var PROJECT_VAR_NAME ("KIPRJMOD") definition if for some reason
350  // it is found in config. (It is reserved and defined as project path)
351  if( it.first == PROJECT_VAR_NAME )
352  continue;
353 
354  // Don't set bogus empty entries in the environment
355  if( it.first.IsEmpty() )
356  continue;
357 
358  // Do not overwrite vars set by the system environment with values from the settings file
359  if( it.second.GetDefinedExternally() )
360  continue;
361 
362  SetLocalEnvVariable( it.first, it.second.GetValue() );
363  }
364 }
365 
366 
368 {
369  // GetCommonSettings() is not initialized until fairly late in the
370  // process startup: InitPgm(), so test before using:
371  if( GetCommonSettings() )
372  {
373  GetCommonSettings()->m_System.working_dir = wxGetCwd();
375  }
376 }
377 
378 
380 {
382 }
383 
384 
385 bool PGM_BASE::SetLanguage( wxString& aErrMsg, bool first_time )
386 {
387  if( first_time )
388  {
389  setLanguageId( wxLANGUAGE_DEFAULT );
390  // First time SetLanguage is called, the user selected language id is set
391  // from common user config settings
392  wxString languageSel = GetCommonSettings()->m_System.language;
393 
394  // Search for the current selection
395  for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
396  {
397  if( LanguagesList[ii].m_Lang_Label == languageSel )
398  {
399  setLanguageId( LanguagesList[ii].m_WX_Lang_Identifier );
400  break;
401  }
402  }
403  }
404 
405  // dictionary file name without extend (full name is kicad.mo)
406  wxString dictionaryName( "kicad" );
407 
408  delete m_locale;
409  m_locale = new wxLocale;
410 
411  if( !m_locale->Init( m_language_id ) )
412  {
413  wxLogTrace( traceLocale, "This language is not supported by the system." );
414 
415  setLanguageId( wxLANGUAGE_DEFAULT );
416  delete m_locale;
417 
418  m_locale = new wxLocale;
419  m_locale->Init();
420 
421  aErrMsg = _( "This language is not supported by the operating system." );
422  return false;
423  }
424  else if( !first_time )
425  {
426  wxLogTrace( traceLocale, "Search for dictionary %s.mo in %s",
427  dictionaryName, m_locale->GetName() );
428  }
429 
430  if( !first_time )
431  {
432  // If we are here, the user has selected another language.
433  // Therefore the new preferred language name is stored in common config.
434  // Do NOT store the wxWidgets language Id, it can change between wxWidgets
435  // versions, for a given language
436  wxString languageSel;
437 
438  // Search for the current selection language name
439  for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
440  {
441  if( LanguagesList[ii].m_WX_Lang_Identifier == m_language_id )
442  {
443  languageSel = LanguagesList[ii].m_Lang_Label;
444  break;
445  }
446  }
447 
449  cfg->m_System.language = languageSel;
450  cfg->SaveToFile( GetSettingsManager().GetPathForSettingsFile( cfg ) );
451  }
452 
453  // Try adding the dictionary if it is not currently loaded
454  if( !m_locale->IsLoaded( dictionaryName ) )
455  m_locale->AddCatalog( dictionaryName );
456 
457  // Verify the Kicad dictionary was loaded properly
458  // However, for the English language, the dictionary is not mandatory, as
459  // all messages are already in English, just restricted to ASCII7 chars,
460  // the verification is skipped.
461  if( !m_locale->IsLoaded( dictionaryName ) && m_language_id != wxLANGUAGE_ENGLISH )
462  {
463  wxLogTrace( traceLocale, "Unable to load dictionary %s.mo in %s",
464  dictionaryName, m_locale->GetName() );
465 
466  setLanguageId( wxLANGUAGE_DEFAULT );
467  delete m_locale;
468 
469  m_locale = new wxLocale;
470  m_locale->Init();
471 
472  aErrMsg = _( "The KiCad language file for this language is not installed." );
473  return false;
474  }
475 
476  return true;
477 }
478 
479 
480 bool PGM_BASE::SetDefaultLanguage( wxString& aErrMsg )
481 {
482  setLanguageId( wxLANGUAGE_DEFAULT );
483 
484  // dictionary file name without extend (full name is kicad.mo)
485  wxString dictionaryName( "kicad" );
486 
487  delete m_locale;
488  m_locale = new wxLocale;
489  m_locale->Init();
490 
491  // Try adding the dictionary if it is not currently loaded
492  if( !m_locale->IsLoaded( dictionaryName ) )
493  m_locale->AddCatalog( dictionaryName );
494 
495  // Verify the Kicad dictionary was loaded properly
496  // However, for the English language, the dictionary is not mandatory, as
497  // all messages are already in English, just restricted to ASCII7 chars,
498  // the verification is skipped.
499  if( !m_locale->IsLoaded( dictionaryName ) && m_language_id != wxLANGUAGE_ENGLISH )
500  {
501  wxLogTrace( traceLocale, "Unable to load dictionary %s.mo in %s",
502  dictionaryName, m_locale->GetName() );
503 
504  setLanguageId( wxLANGUAGE_DEFAULT );
505  delete m_locale;
506 
507  m_locale = new wxLocale;
508  m_locale->Init();
509 
510  aErrMsg = _( "The KiCad language file for this language is not installed." );
511  return false;
512  }
513 
514  return true;
515 }
516 
517 
519 {
520  wxLogTrace( traceLocale, "Select language ID %d from %d possible languages.",
521  menu_id, (int)arrayDim( LanguagesList )-1 );
522 
523  for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
524  {
525  if( menu_id == LanguagesList[ii].m_KI_Lang_Identifier )
526  {
527  setLanguageId( LanguagesList[ii].m_WX_Lang_Identifier );
528  break;
529  }
530  }
531 }
532 
533 
535 {
536  SEARCH_STACK guesses;
537 
538  SystemDirsAppend( &guesses );
539 
540  // Add our internat dir to the wxLocale catalog of paths
541  for( unsigned i = 0; i < guesses.GetCount(); i++ )
542  {
543  wxFileName fn( guesses[i], wxEmptyString );
544 
545  // Append path for Windows and unix KiCad package install
546  fn.AppendDir( "share" );
547  fn.AppendDir( "internat" );
548 
549  if( fn.IsDirReadable() )
550  {
551  wxLogTrace( traceLocale, "Adding locale lookup path: " + fn.GetPath() );
552  wxLocale::AddCatalogLookupPathPrefix( fn.GetPath() );
553  }
554 
555  // Append path for unix standard install
556  fn.RemoveLastDir();
557  fn.AppendDir( "kicad" );
558  fn.AppendDir( "internat" );
559 
560  if( fn.IsDirReadable() )
561  {
562  wxLogTrace( traceLocale, "Adding locale lookup path: " + fn.GetPath() );
563  wxLocale::AddCatalogLookupPathPrefix( fn.GetPath() );
564  }
565 
566  // Append path for macOS install
567  fn.RemoveLastDir();
568  fn.RemoveLastDir();
569  fn.RemoveLastDir();
570  fn.AppendDir( "internat" );
571 
572  if( fn.IsDirReadable() )
573  {
574  wxLogTrace( traceLocale, "Adding locale lookup path: " + fn.GetPath() );
575  wxLocale::AddCatalogLookupPathPrefix( fn.GetPath() );
576  }
577  }
578 
579  if( wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) )
580  {
581  wxFileName fn( Pgm().GetExecutablePath() );
582  fn.RemoveLastDir();
583  fn.AppendDir( "translation" );
584  wxLocale::AddCatalogLookupPathPrefix( fn.GetPath() );
585  }
586 }
587 
588 
589 bool PGM_BASE::SetLocalEnvVariable( const wxString& aName, const wxString& aValue )
590 {
591  wxString env;
592 
593  if( aName.IsEmpty() )
594  {
595  wxLogTrace( traceEnvVars,
596  "PGM_BASE::SetLocalEnvVariable: Attempt to set empty variable to value %s",
597  aValue );
598  return false;
599  }
600 
601  // Check to see if the environment variable is already set.
602  if( wxGetEnv( aName, &env ) )
603  {
604  wxLogTrace( traceEnvVars,
605  "PGM_BASE::SetLocalEnvVariable: Environment variable %s already set to %s",
606  aName, env );
607  return env == aValue;
608  }
609 
610  wxLogTrace( traceEnvVars,
611  "PGM_BASE::SetLocalEnvVariable: Setting local environment variable %s to %s",
612  aName, aValue );
613 
614  return wxSetEnv( aName, aValue );
615 }
616 
617 
619 {
620  // Overwrites externally defined environment variable until the next time the application
621  // is run.
622  for( const std::pair<wxString, ENV_VAR_ITEM> m_local_env_var : GetCommonSettings()->m_Env.vars )
623  {
624  wxLogTrace( traceEnvVars,
625  "PGM_BASE::SetLocalEnvVariables: Setting local environment variable %s to %s",
626  m_local_env_var.first,
627  m_local_env_var.second.GetValue() );
628  wxSetEnv( m_local_env_var.first, m_local_env_var.second.GetValue() );
629  }
630 }
631 
632 
634 {
635  return GetCommonSettings()->m_Env.vars;
636 }
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:379
std::unique_ptr< SCRIPTING > m_python_scripting
Definition: pgm_base.h:309
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:129
void loadCommonSettings()
Loads internal settings from COMMON_SETTINGS.
Definition: pgm_base.cpp:339
LANGUAGE_DESCR LanguagesList[]
An array containing all the languages that KiCad supports.
Definition: pgm_base.cpp:70
#define WIN_STRING_DIR_SEP
Definition: gestfich.h:44
virtual void SetEditorName(const wxString &aFileName)
Definition: pgm_base.cpp:138
virtual ~PGM_BASE()
Definition: pgm_base.cpp:117
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:265
This file is part of the common library TODO brief description.
This file is part of the common library.
void SaveCommonSettings()
Save the program (process) settings subset which are stored .kicad_common.
Definition: pgm_base.cpp:367
int m_ModalDialogCount
Definition: pgm_base.h:291
#define UNIX_STRING_DIR_SEP
Definition: gestfich.h:43
wxLocale * m_locale
The current locale.
Definition: pgm_base.h:318
int m_KI_Lang_Identifier
KiCad identifier used in menu selection (See id.h)
Definition: pgm_base.h:65
#define PROJECT_VAR_NAME
A variable name whose value holds the current project directory.
Definition: project.h:38
virtual wxApp & App()
Returns a bare naked wxApp which may come from wxPython, SINGLE_TOP, or kicad.exe.
Definition: pgm_base.cpp:131
bool m_show_env_var_dialog
Flag to indicate if the environment variable overwrite warning dialog should be shown.
Definition: pgm_base.h:331
void Destroy()
Definition: pgm_base.cpp:123
bool setExecutablePath()
Find the path to the executable and stores it in PGM_BASE::m_bin_dir.
Definition: pgm_base.cpp:297
System directories search utilities.
A small class to handle the list of existing translations.
Definition: pgm_base.h:59
Look for files in a number of paths.
Definition: search_stack.h:41
virtual void ForceSystemPdfBrowser(bool aFlg)
Force the use of system PDF browser, even if a preferred PDF browser is set.
Definition: pgm_base.h:181
virtual const wxString AskUserForPreferredEditor(const wxString &aDefaultEditor=wxEmptyString)
Shows a dialog that instructs the user to select a new preferred editor.
Definition: pgm_base.cpp:182
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
int m_language_id
The current language setting.
Definition: pgm_base.h:321
std::unique_ptr< SETTINGS_MANAGER > m_settings_manager
Definition: pgm_base.h:307
void InitializeEnvironment()
Creates the built-in environment variables and sets their default values.
wxString m_kicad_env
The KICAD system environment variable.
Definition: pgm_base.h:315
virtual bool SaveToFile(const wxString &aDirectory="", bool aForce=false)
virtual bool SetLocalEnvVariable(const wxString &aName, const wxString &aValue)
Sets the environment variable aName to aValue.
Definition: pgm_base.cpp:589
#define NULL
virtual void SetLanguageIdentifier(int menu_id)
Set in .m_language_id member the wxWidgets language identifier ID fromthe KiCad menu id (internal men...
Definition: pgm_base.cpp:518
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)
A helper function that wraps a call to wxFileSelector.
Definition: gestfich.cpp:52
COMMON_SETTINGS * GetCommonSettings() const
Retrieves the common settings shared by all applications.
Base window classes and related definitions.
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
Definition: arraydim.h:31
void SystemDirsAppend(SEARCH_STACK *aSearchStack)
Append system places to aSearchStack in a platform specific way and pertinent to KiCad programs.
wxLogTrace helper definitions.
void setLanguageId(int aId)
Trap all changes in here, simplifies debugging.
Definition: pgm_base.h:298
const wxChar *const traceLocale
Flag to enable locale debug output.
ENVIRONMENT m_Env
virtual bool SetLanguage(wxString &aErrMsg, bool first_time=false)
Set the dictionary file name for internationalization.
Definition: pgm_base.cpp:385
const wxChar *const traceEnvVars
Flag to enable debug output of environment variable operations.
wxString m_Lang_Label
Labels used in menus.
Definition: pgm_base.h:68
virtual void SetLanguagePath()
Definition: pgm_base.cpp:534
wxString m_bin_dir
full path to this program
Definition: pgm_base.h:312
bool InitPgm(bool aHeadless=false)
Initialize this program.
Definition: pgm_base.cpp:203
bool LoadProject(const wxString &aFullPath, bool aSetActive=true)
Loads a project or sets up a new project with a specified path.
virtual void ReadPdfBrowserInfos()
Read the PDF browser choice from the common configuration.
Definition: eda_doc.cpp:42
bool m_Printing
wxWidgets on MSW tends to crash if you spool up more than one print job at a time.
Definition: pgm_base.h:289
see class PGM_BASE
std::map< wxString, ENV_VAR_ITEM > ENV_VAR_MAP
virtual const wxString & GetExecutablePath() const
Definition: pgm_base.h:160
const char * name
Definition: DXF_plotter.cpp:59
bool WarnUserIfOperatingSystemUnsupported()
Checks if the operating system is explicitly unsupported and displays a disclaimer message box.
Definition: common.cpp:610
virtual void SetLocalEnvVariables()
Updates the local environment with the contents of the current ENV_VAR_MAP stored in the COMMON_SETTI...
Definition: pgm_base.cpp:618
#define _(s)
Current list of languages supported by KiCad.
Definition: pgm_base.cpp:100
The common library.
wxString m_editor_name
Definition: pgm_base.h:328
virtual const wxString & GetEditorName(bool aCanShowFileChooser=true)
Return the preferred editor name.
Definition: pgm_base.cpp:146
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:280
bool SetDefaultLanguage(wxString &aErrMsg)
Set the default language without reference to any preferences.
Definition: pgm_base.cpp:480
virtual ENV_VAR_MAP & GetLocalEnvVariables() const
Definition: pgm_base.cpp:633
File locking utilities.