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 <[email protected]>
6  * Copyright (C) 1992-2021 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 #include <paths.h>
60 
61 
69 #undef _
70 #define _(s) s
72 {
73  { wxLANGUAGE_DEFAULT, ID_LANGUAGE_DEFAULT, _( "Default" ), false },
74  { wxLANGUAGE_INDONESIAN, ID_LANGUAGE_INDONESIAN, wxT( "Bahasa Indonesia" ), 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_SPANISH_MEXICAN, ID_LANGUAGE_SPANISH_MEXICAN, wxT( "Español (Latinoamericano)" ), true },
82  { wxLANGUAGE_FRENCH, ID_LANGUAGE_FRENCH, wxT( "Français" ), true },
83  { wxLANGUAGE_KOREAN, ID_LANGUAGE_KOREAN, wxT( "한국어"), true },
84  { wxLANGUAGE_ITALIAN, ID_LANGUAGE_ITALIAN, wxT( "Italiano" ), true },
85  { wxLANGUAGE_LITHUANIAN, ID_LANGUAGE_LITHUANIAN, wxT( "Lietuvių" ), true },
86  { wxLANGUAGE_HUNGARIAN, ID_LANGUAGE_HUNGARIAN, wxT( "Magyar" ), true },
87  { wxLANGUAGE_JAPANESE, ID_LANGUAGE_JAPANESE, wxT( "日本語" ), true },
88  { wxLANGUAGE_THAI, ID_LANGUAGE_THAI, wxT( "ภาษาไทย" ), true },
89  { wxLANGUAGE_POLISH, ID_LANGUAGE_POLISH, wxT( "Polski" ), true },
90  { wxLANGUAGE_PORTUGUESE, ID_LANGUAGE_PORTUGUESE, wxT( "Português" ),true },
91  { wxLANGUAGE_PORTUGUESE_BRAZILIAN, ID_LANGUAGE_PORTUGUESE_BRAZILIAN, wxT( "Português (Brasil)" ), true },
92  { wxLANGUAGE_RUSSIAN, ID_LANGUAGE_RUSSIAN, wxT( "Русский" ), true },
93  { wxLANGUAGE_SERBIAN, ID_LANGUAGE_SERBIAN, wxT( "Српски" ), true },
94  { wxLANGUAGE_FINNISH, ID_LANGUAGE_FINNISH, wxT( "Suomi" ), true },
95  { wxLANGUAGE_SWEDISH, ID_LANGUAGE_SWEDISH, wxT( "Svenska" ), true },
96  { wxLANGUAGE_VIETNAMESE, ID_LANGUAGE_VIETNAMESE, wxT( "Tiếng Việt" ), true },
97  { wxLANGUAGE_TURKISH, ID_LANGUAGE_TURKISH, wxT( "Türkçe" ), true },
98  { wxLANGUAGE_CHINESE_SIMPLIFIED, ID_LANGUAGE_CHINESE_SIMPLIFIED,
99  wxT( "简体中文" ), true },
100  { wxLANGUAGE_CHINESE_TRADITIONAL, ID_LANGUAGE_CHINESE_TRADITIONAL,
101  wxT( "繁體中文" ), false },
102  { 0, 0, wxEmptyString, false } // Sentinel
103 };
104 #undef _
105 #define _(s) wxGetTranslation((s))
106 
107 
109 {
110  m_locale = nullptr;
111  m_Printing = false;
112  m_Quitting = false;
113  m_ModalDialogCount = 0;
114 
115  setLanguageId( wxLANGUAGE_DEFAULT );
116 
117  ForceSystemPdfBrowser( false );
118 }
119 
120 
122 {
123  Destroy();
124 }
125 
126 
128 {
129  // unlike a normal destructor, this is designed to be called more than once safely:
130  delete m_locale;
131  m_locale = nullptr;
132 }
133 
134 
136 {
137  wxASSERT( wxTheApp );
138  return *wxTheApp;
139 }
140 
141 
142 void PGM_BASE::SetTextEditor( const wxString& aFileName )
143 {
144  m_text_editor = aFileName;
145  GetCommonSettings()->m_System.text_editor = aFileName;
146 }
147 
148 
149 const wxString& PGM_BASE::GetTextEditor( bool aCanShowFileChooser )
150 {
151  wxString editorname = m_text_editor;
152 
153  if( !editorname )
154  {
155  if( !wxGetEnv( wxT( "EDITOR" ), &editorname ) )
156  {
157  // If there is no EDITOR variable set, try the desktop default
158 #ifdef __WXMAC__
159  editorname = wxT( "/usr/bin/open -e" );
160 #elif __WXX11__
161  editorname = wxT( "/usr/bin/xdg-open" );
162 #endif
163  }
164  }
165 
166  // If we still don't have an editor name show a dialog asking the user to select one
167  if( !editorname && aCanShowFileChooser )
168  {
169  DisplayInfoMessage( nullptr, _( "No default editor found, you must choose one." ) );
170 
171  editorname = AskUserForPreferredEditor();
172  }
173 
174  // If we finally have a new editor name request it to be copied to m_text_editor and
175  // saved to the preferences file.
176  if( !editorname.IsEmpty() )
177  SetTextEditor( editorname );
178 
179  // m_text_editor already has the same value that editorname, or empty if no editor was
180  // found/chosen.
181  return m_text_editor;
182 }
183 
184 
185 const wxString PGM_BASE::AskUserForPreferredEditor( const wxString& aDefaultEditor )
186 {
187  // Create a mask representing the executable files in the current platform
188 #ifdef __WINDOWS__
189  wxString mask( _( "Executable file" ) + wxT( " (*.exe)|*.exe" ) );
190 #else
191  wxString mask( _( "Executable file" ) + wxT( " (*)|*" ) );
192 #endif
193 
194  // Extract the path, name and extension from the default editor (even if the editor's
195  // name was empty, this method will succeed and return empty strings).
196  wxString path, name, ext;
197  wxFileName::SplitPath( aDefaultEditor, &path, &name, &ext );
198 
199  // Show the modal editor and return the file chosen (may be empty if the user cancels
200  // the dialog).
201  return wxFileSelector( _( "Select Preferred Editor" ), path, name, wxT( "." ) + ext,
202  mask, wxFD_OPEN | wxFD_FILE_MUST_EXIST, nullptr );
203 }
204 
205 
206 bool PGM_BASE::InitPgm( bool aHeadless, bool aSkipPyInit )
207 {
208  wxString pgm_name;
209 
211  if( App().argc == 0 )
212  pgm_name = wxT( "kicad" );
213  else
214  pgm_name = wxFileName( App().argv[0] ).GetName().Lower();
215 
216  wxInitAllImageHandlers();
217 
218 #ifndef __WINDOWS__
219  if( wxString( wxGetenv( wxT( "HOME" ) ) ).IsEmpty() )
220  {
221  DisplayErrorMessage( nullptr, _( "Environment variable HOME is empty. "
222  "Unable to continue." ) );
223  return false;
224  }
225 #endif
226 
227  // Init KiCad environment
228  // the environment variable KICAD (if exists) gives the kicad path:
229  // something like set KICAD=d:\kicad
230  bool isDefined = wxGetEnv( wxT( "KICAD" ), &m_kicad_env );
231 
232  if( isDefined ) // ensure m_kicad_env ends by "/"
233  {
235 
236  if( !m_kicad_env.IsEmpty() && m_kicad_env.Last() != '/' )
238  }
239 
240  // Init parameters for configuration
241  App().SetVendorName( wxT( "KiCad" ) );
242  App().SetAppName( pgm_name );
243 
244  // Install some image handlers, mainly for help
245  if( wxImage::FindHandler( wxBITMAP_TYPE_PNG ) == nullptr )
246  wxImage::AddHandler( new wxPNGHandler );
247 
248  if( wxImage::FindHandler( wxBITMAP_TYPE_GIF ) == nullptr )
249  wxImage::AddHandler( new wxGIFHandler );
250 
251  if( wxImage::FindHandler( wxBITMAP_TYPE_JPEG ) == nullptr )
252  wxImage::AddHandler( new wxJPEGHandler );
253 
254  wxFileSystem::AddHandler( new wxZipFSHandler );
255 
256  // Analyze the command line & initialize the binary path
257  wxString tmp;
259  SetLanguagePath();
260  SetDefaultLanguage( tmp );
261 
262  m_settings_manager = std::make_unique<SETTINGS_MANAGER>( aHeadless );
263 
264  // Something got in the way of settings load: can't continue
265  if( !m_settings_manager->IsOK() )
266  return false;
267 
268  // Set up built-in environment variables (and override them from the system environment if set)
270 
271  // Load color settings after env is initialized
272  m_settings_manager->ReloadColorSettings();
273 
274  // Load common settings from disk after setting up env vars
276 
277  // Init user language *before* calling loadSettings, because
278  // env vars could be incorrectly initialized on Linux
279  // (if the value contains some non ASCII7 chars, the env var is not initialized)
280  SetLanguage( tmp, true );
281 
282  // Now that translations are available, inform the user if the OS is unsupported
284 
286 
287  ReadPdfBrowserInfos(); // needs GetCommonSettings()
288 
289  // Create the python scripting stuff
290  // Skip it fot applications that do not use it
291  if( !aSkipPyInit )
292  m_python_scripting = std::make_unique<SCRIPTING>();
293 
294  // TODO(JE): Remove this if apps are refactored to not assume Prj() always works
295  // Need to create a project early for now (it can have an empty path for the moment)
297 
298  // TODO: Move tooltips into KIPLATFORM
299  // This sets the maximum tooltip display duration to 10s (up from 5) but only affects
300  // Windows as other platforms display tooltips while the mouse is not moving
301  wxToolTip::SetAutoPop( 10000 );
302 
303  return true;
304 }
305 
306 
308 {
309  m_bin_dir = wxStandardPaths::Get().GetExecutablePath();
310 
311 #ifdef __WXMAC__
312  // On OSX Pgm().GetExecutablePath() will always point to main
313  // bundle directory, e.g., /Applications/kicad.app/
314 
315  wxFileName fn( m_bin_dir );
316 
317  if( fn.GetName() == wxT( "kicad" ) )
318  {
319  // kicad launcher, so just remove the Contents/MacOS part
320  fn.RemoveLastDir();
321  fn.RemoveLastDir();
322  }
323  else
324  {
325  // standalone binaries live in Contents/Applications/<standalone>.app/Contents/MacOS
326  fn.RemoveLastDir();
327  fn.RemoveLastDir();
328  fn.RemoveLastDir();
329  fn.RemoveLastDir();
330  fn.RemoveLastDir();
331  }
332 
333  m_bin_dir = fn.GetPath() + wxT( "/" );
334 #else
335  // Use unix notation for paths. I am not sure this is a good idea,
336  // but it simplifies compatibility between Windows and Unices.
337  // However it is a potential problem in path handling under Windows.
339 
340  // Remove file name form command line:
341  while( m_bin_dir.Last() != '/' && !m_bin_dir.IsEmpty() )
342  m_bin_dir.RemoveLast();
343 #endif
344 
345  return true;
346 }
347 
348 
350 {
352 
353  for( const std::pair<wxString, ENV_VAR_ITEM> it : GetCommonSettings()->m_Env.vars )
354  {
355  wxLogTrace( traceEnvVars, wxT( "PGM_BASE::loadSettings: Found entry %s = %s" ),
356  it.first, it.second.GetValue() );
357 
358  // Do not store the env var PROJECT_VAR_NAME ("KIPRJMOD") definition if for some reason
359  // it is found in config. (It is reserved and defined as project path)
360  if( it.first == PROJECT_VAR_NAME )
361  continue;
362 
363  // Don't set bogus empty entries in the environment
364  if( it.first.IsEmpty() )
365  continue;
366 
367  // Do not overwrite vars set by the system environment with values from the settings file
368  if( it.second.GetDefinedExternally() )
369  continue;
370 
371  SetLocalEnvVariable( it.first, it.second.GetValue() );
372  }
373 }
374 
375 
377 {
378  // GetCommonSettings() is not initialized until fairly late in the
379  // process startup: InitPgm(), so test before using:
380  if( GetCommonSettings() )
381  GetCommonSettings()->m_System.working_dir = wxGetCwd();
382 }
383 
384 
386 {
388 }
389 
390 
391 bool PGM_BASE::SetLanguage( wxString& aErrMsg, bool first_time )
392 {
393  if( first_time )
394  {
395  setLanguageId( wxLANGUAGE_DEFAULT );
396  // First time SetLanguage is called, the user selected language id is set
397  // from common user config settings
398  wxString languageSel = GetCommonSettings()->m_System.language;
399 
400  // Search for the current selection
401  for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
402  {
403  if( LanguagesList[ii].m_Lang_Label == languageSel )
404  {
405  setLanguageId( LanguagesList[ii].m_WX_Lang_Identifier );
406  break;
407  }
408  }
409  }
410 
411  // dictionary file name without extend (full name is kicad.mo)
412  wxString dictionaryName( wxT( "kicad" ) );
413 
414  delete m_locale;
415  m_locale = new wxLocale;
416 
417  // don't use wxLOCALE_LOAD_DEFAULT flag so that Init() doesn't return
418  // false just because it failed to load wxstd catalog
419  if( !m_locale->Init( m_language_id, wxLOCALE_DONT_LOAD_DEFAULT ) )
420  {
421  wxLogTrace( traceLocale, wxT( "This language is not supported by the system." ) );
422 
423  setLanguageId( wxLANGUAGE_DEFAULT );
424  delete m_locale;
425 
426  m_locale = new wxLocale;
427  m_locale->Init( wxLANGUAGE_DEFAULT, wxLOCALE_DONT_LOAD_DEFAULT);
428 
429  aErrMsg = _( "This language is not supported by the operating system." );
430  return false;
431  }
432  else if( !first_time )
433  {
434  wxLogTrace( traceLocale, wxT( "Search for dictionary %s.mo in %s" ),
435  dictionaryName, m_locale->GetName() );
436  }
437 
438  if( !first_time )
439  {
440  // If we are here, the user has selected another language.
441  // Therefore the new preferred language name is stored in common config.
442  // Do NOT store the wxWidgets language Id, it can change between wxWidgets
443  // versions, for a given language
444  wxString languageSel;
445 
446  // Search for the current selection language name
447  for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
448  {
449  if( LanguagesList[ii].m_WX_Lang_Identifier == m_language_id )
450  {
451  languageSel = LanguagesList[ii].m_Lang_Label;
452  break;
453  }
454  }
455 
457  cfg->m_System.language = languageSel;
458  cfg->SaveToFile( GetSettingsManager().GetPathForSettingsFile( cfg ) );
459  }
460 
461  // Try adding the dictionary if it is not currently loaded
462  if( !m_locale->IsLoaded( dictionaryName ) )
463  m_locale->AddCatalog( dictionaryName );
464 
465  // Verify the Kicad dictionary was loaded properly
466  // However, for the English language, the dictionary is not mandatory, as
467  // all messages are already in English, just restricted to ASCII7 chars,
468  // the verification is skipped.
469  if( !m_locale->IsLoaded( dictionaryName ) && m_language_id != wxLANGUAGE_ENGLISH )
470  {
471  wxLogTrace( traceLocale, wxT( "Unable to load dictionary %s.mo in %s" ),
472  dictionaryName, m_locale->GetName() );
473 
474  setLanguageId( wxLANGUAGE_DEFAULT );
475  delete m_locale;
476 
477  m_locale = new wxLocale;
478  m_locale->Init( wxLANGUAGE_DEFAULT, wxLOCALE_DONT_LOAD_DEFAULT);
479 
480  aErrMsg = _( "The KiCad language file for this language is not installed." );
481  return false;
482  }
483 
484  return true;
485 }
486 
487 
488 bool PGM_BASE::SetDefaultLanguage( wxString& aErrMsg )
489 {
490  setLanguageId( wxLANGUAGE_DEFAULT );
491 
492  // dictionary file name without extend (full name is kicad.mo)
493  wxString dictionaryName( wxT( "kicad" ) );
494 
495  delete m_locale;
496  m_locale = new wxLocale;
497  m_locale->Init();
498 
499  // Try adding the dictionary if it is not currently loaded
500  if( !m_locale->IsLoaded( dictionaryName ) )
501  m_locale->AddCatalog( dictionaryName );
502 
503  // Verify the Kicad dictionary was loaded properly
504  // However, for the English language, the dictionary is not mandatory, as
505  // all messages are already in English, just restricted to ASCII7 chars,
506  // the verification is skipped.
507  if( !m_locale->IsLoaded( dictionaryName ) && m_language_id != wxLANGUAGE_ENGLISH )
508  {
509  wxLogTrace( traceLocale, wxT( "Unable to load dictionary %s.mo in %s" ),
510  dictionaryName, m_locale->GetName() );
511 
512  setLanguageId( wxLANGUAGE_DEFAULT );
513  delete m_locale;
514 
515  m_locale = new wxLocale;
516  m_locale->Init();
517 
518  aErrMsg = _( "The KiCad language file for this language is not installed." );
519  return false;
520  }
521 
522  return true;
523 }
524 
525 
527 {
528  wxLogTrace( traceLocale, wxT( "Select language ID %d from %d possible languages." ),
529  menu_id, (int)arrayDim( LanguagesList )-1 );
530 
531  for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
532  {
533  if( menu_id == LanguagesList[ii].m_KI_Lang_Identifier )
534  {
535  setLanguageId( LanguagesList[ii].m_WX_Lang_Identifier );
536  break;
537  }
538  }
539 }
540 
541 
543 {
544  wxLocale::AddCatalogLookupPathPrefix( PATHS::GetLocaleDataPath() );
545 
546  if( wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) )
547  {
548  wxFileName fn( Pgm().GetExecutablePath() );
549  fn.RemoveLastDir();
550  fn.AppendDir( wxT( "translation" ) );
551  wxLocale::AddCatalogLookupPathPrefix( fn.GetPath() );
552  }
553 }
554 
555 
556 bool PGM_BASE::SetLocalEnvVariable( const wxString& aName, const wxString& aValue )
557 {
558  wxString env;
559 
560  if( aName.IsEmpty() )
561  {
562  wxLogTrace( traceEnvVars,
563  wxT( "PGM_BASE::SetLocalEnvVariable: Attempt to set empty variable to value %s" ),
564  aValue );
565  return false;
566  }
567 
568  // Check to see if the environment variable is already set.
569  if( wxGetEnv( aName, &env ) )
570  {
571  wxLogTrace( traceEnvVars,
572  wxT( "PGM_BASE::SetLocalEnvVariable: Environment variable %s already set to %s" ),
573  aName, env );
574  return env == aValue;
575  }
576 
577  wxLogTrace( traceEnvVars,
578  wxT( "PGM_BASE::SetLocalEnvVariable: Setting local environment variable %s to %s" ),
579  aName, aValue );
580 
581  return wxSetEnv( aName, aValue );
582 }
583 
584 
586 {
587  // Overwrites externally defined environment variable until the next time the application
588  // is run.
589  for( const std::pair<wxString, ENV_VAR_ITEM> m_local_env_var : GetCommonSettings()->m_Env.vars )
590  {
591  wxLogTrace( traceEnvVars,
592  wxT( "PGM_BASE::SetLocalEnvVariables: Setting local environment variable %s to %s" ),
593  m_local_env_var.first,
594  m_local_env_var.second.GetValue() );
595  wxSetEnv( m_local_env_var.first, m_local_env_var.second.GetValue() );
596  }
597 }
598 
599 
601 {
602  return GetCommonSettings()->m_Env.vars;
603 }
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:385
std::unique_ptr< SCRIPTING > m_python_scripting
Definition: pgm_base.h:314
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:129
void loadCommonSettings()
Loads internal settings from COMMON_SETTINGS.
Definition: pgm_base.cpp:349
LANGUAGE_DESCR LanguagesList[]
An array containing all the languages that KiCad supports.
Definition: pgm_base.cpp:71
#define WIN_STRING_DIR_SEP
Definition: gestfich.h:36
virtual ~PGM_BASE()
Definition: pgm_base.cpp:121
bool InitPgm(bool aHeadless=false, bool aSkipPyInit=false)
Initialize this program.
Definition: pgm_base.cpp:206
virtual const wxString & GetTextEditor(bool aCanShowFileChooser=true)
Return the path to the preferred text editor application.
Definition: pgm_base.cpp:149
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:292
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:376
int m_ModalDialogCount
Definition: pgm_base.h:293
#define UNIX_STRING_DIR_SEP
Definition: gestfich.h:35
wxLocale * m_locale
The KICAD system environment variable.
Definition: pgm_base.h:319
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:135
void Destroy()
Definition: pgm_base.cpp:127
bool setExecutablePath()
Find the path to the executable and stores it in PGM_BASE::m_bin_dir.
Definition: pgm_base.cpp:307
System directories search utilities.
A small class to handle the list of existing translations.
Definition: pgm_base.h:59
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:185
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
int m_language_id
Definition: pgm_base.h:320
std::unique_ptr< SETTINGS_MANAGER > m_settings_manager
Definition: pgm_base.h:312
void InitializeEnvironment()
Creates the built-in environment variables and sets their default values.
wxString m_kicad_env
full path to this program
Definition: pgm_base.h:317
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:556
virtual void SetLanguageIdentifier(int menu_id)
Set in .m_language_id member the wxWidgets language identifier ID from the KiCad menu id (internal me...
Definition: pgm_base.cpp:526
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
wxLogTrace helper definitions.
void setLanguageId(int aId)
Trap all changes in here, simplifies debugging.
Definition: pgm_base.h:302
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:391
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:542
wxString m_bin_dir
Definition: pgm_base.h:316
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:37
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:291
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:56
bool WarnUserIfOperatingSystemUnsupported()
Checks if the operating system is explicitly unsupported and displays a disclaimer message box.
Definition: common.cpp:603
wxString m_text_editor
Filename of the app selected for browsing PDFs.
Definition: pgm_base.h:325
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:585
#define _(s)
Current list of languages supported by KiCad.
Definition: pgm_base.cpp:105
bool m_Quitting
Definition: pgm_base.h:295
The common library.
virtual void SetTextEditor(const wxString &aFileName)
Definition: pgm_base.cpp:142
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:307
bool SetDefaultLanguage(wxString &aErrMsg)
Set the default language without reference to any preferences.
Definition: pgm_base.cpp:488
virtual ENV_VAR_MAP & GetLocalEnvVariables() const
Definition: pgm_base.cpp:600
static wxString GetLocaleDataPath()
Gets the locales translation data path.
Definition: paths.cpp:252
File locking utilities.