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