コード例 #1
0
bool PGM_BASE::initPgm()
{
    wxFileName pgm_name( App().argv[0] );

    wxInitAllImageHandlers();

    m_pgm_checker = new wxSingleInstanceChecker( pgm_name.GetName().Lower() + wxT( "-" ) + wxGetUserId() );

    if( m_pgm_checker->IsAnotherRunning() )
    {
        wxString quiz = wxString::Format(
            _( "%s is already running, Continue?" ),
            GetChars( pgm_name.GetName() )
            );
        if( !IsOK( NULL, quiz ) )
            return false;
    }

    // Init KiCad environment
    // the environment variable KICAD (if exists) gives the kicad path:
    // something like set KICAD=d:\kicad
    bool isDefined = wxGetEnv( wxT( "KICAD" ), &m_kicad_env );

    if( isDefined )    // ensure m_kicad_env ends by "/"
    {
        m_kicad_env.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );

        if( !m_kicad_env.IsEmpty() && m_kicad_env.Last() != '/' )
            m_kicad_env += UNIX_STRING_DIR_SEP;
    }

    // Init parameters for configuration
    App().SetVendorName( wxT( "KiCad" ) );
    App().SetAppName( pgm_name.GetName().Lower() );

    // Install some image handlers, mainly for help
    wxImage::AddHandler( new wxPNGHandler );
    wxImage::AddHandler( new wxGIFHandler );
    wxImage::AddHandler( new wxJPEGHandler );
    wxFileSystem::AddHandler( new wxZipFSHandler );

    // Analyze the command line & initialize the binary path
    setExecutablePath();

    SetLanguagePath();

    // OS specific instantiation of wxConfigBase derivative:
    m_common_settings = new wxConfig( KICAD_COMMON );

    ReadPdfBrowserInfos();      // needs m_common_settings

    loadCommonSettings();


    bool succes = SetLanguage( true );

    if( !succes )
    {
    }

    // Set locale option for separator used in float numbers
    SetLocaleTo_Default();

    return true;
}
コード例 #2
0
void EDA_APP::InitEDA_Appl( const wxString& aName, EDA_APP_T aId )
{
    wxString EnvLang;

    m_Id = aId;
    m_Checker = new wxSingleInstanceChecker( aName.Lower() + wxT( "-" ) + wxGetUserId() );

    // Init KiCad environment
    // the environment variable KICAD (if exists) gives the kicad path:
    // something like set KICAD=d:\kicad
    bool isDefined = wxGetEnv( wxT( "KICAD" ), &m_KicadEnv );

    if( isDefined )    // ensure m_KicadEnv ends by "/"
    {
        m_KicadEnv.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );

        if( !m_KicadEnv.IsEmpty() && m_KicadEnv.Last() != '/' )
            m_KicadEnv += UNIX_STRING_DIR_SEP;
    }

    // Prepare On Line Help. Use only lower case for help file names, in order to
    // avoid problems with upper/lower case file names under windows and unix.
#if defined ONLINE_HELP_FILES_FORMAT_IS_HTML
    m_HelpFileName = aName.Lower() + wxT( ".html" );
#elif defined ONLINE_HELP_FILES_FORMAT_IS_PDF
    m_HelpFileName = aName.Lower() + wxT( ".pdf" );
#else
    #error Help files format not defined
#endif

    // Init parameters for configuration
    SetVendorName( wxT( "KiCad" ) );
    SetAppName( aName.Lower() );
    SetTitle( aName );
    m_settings = new wxConfig();
    wxASSERT( m_settings != NULL );
    m_commonSettings = new wxConfig( CommonConfigPath );
    wxASSERT( m_commonSettings != NULL );

    // Install some image handlers, mainly for help
    wxImage::AddHandler( new wxPNGHandler );
    wxImage::AddHandler( new wxGIFHandler );
    wxImage::AddHandler( new wxJPEGHandler );
    wxFileSystem::AddHandler( new wxZipFSHandler );

    // Analyze the command line & init binary path
    SetBinDir();
    SetDefaultSearchPaths();
    SetLanguagePath();
    ReadPdfBrowserInfos();

    // Internationalization: loading the kicad suitable Dictionary
    wxString languageSel;
    m_commonSettings->Read( languageCfgKey, &languageSel);
    m_LanguageId = wxLANGUAGE_DEFAULT;

    // Search for the current selection
    for( unsigned int ii = 0; ii < LANGUAGE_DESCR_COUNT; ii++ )
    {
        if( s_Language_List[ii].m_Lang_Label == languageSel )
        {
            m_LanguageId = s_Language_List[ii].m_WX_Lang_Identifier;
            break;
        }
    }

    bool succes = SetLanguage( true );

    if( !succes )
    {
    }

    // Set locale option for separator used in float numbers
    SetLocaleTo_Default();
}
コード例 #3
0
ファイル: pgm_base.cpp プロジェクト: chgans/kicad
bool PGM_BASE::initPgm()
{
    wxFileName pgm_name( App().argv[0] );

    wxConfigBase::DontCreateOnDemand();

    wxInitAllImageHandlers();

    m_pgm_checker = new wxSingleInstanceChecker( pgm_name.GetName().Lower() + wxT( "-" ) +
                                                 wxGetUserId(), GetKicadLockFilePath() );

    if( m_pgm_checker->IsAnotherRunning() )
    {
        wxString quiz = wxString::Format(
            _( "%s is already running, Continue?" ),
            GetChars( pgm_name.GetName() )
            );

        if( !IsOK( NULL, quiz ) )
            return false;
    }

    // Init KiCad environment
    // the environment variable KICAD (if exists) gives the kicad path:
    // something like set KICAD=d:\kicad
    bool isDefined = wxGetEnv( wxT( "KICAD" ), &m_kicad_env );

    if( isDefined )    // ensure m_kicad_env ends by "/"
    {
        m_kicad_env.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );

        if( !m_kicad_env.IsEmpty() && m_kicad_env.Last() != '/' )
            m_kicad_env += UNIX_STRING_DIR_SEP;
    }

    // Init parameters for configuration
    App().SetVendorName( wxT( "KiCad" ) );
    App().SetAppName( pgm_name.GetName().Lower() );

    // Install some image handlers, mainly for help
    if( wxImage::FindHandler( wxBITMAP_TYPE_PNG ) == NULL )
        wxImage::AddHandler( new wxPNGHandler );

    if( wxImage::FindHandler( wxBITMAP_TYPE_GIF ) == NULL )
        wxImage::AddHandler( new wxGIFHandler );

    if( wxImage::FindHandler( wxBITMAP_TYPE_JPEG ) == NULL )
        wxImage::AddHandler( new wxJPEGHandler );

    wxFileSystem::AddHandler( new wxZipFSHandler );

    // Analyze the command line & initialize the binary path
    setExecutablePath();

    SetLanguagePath();

    // OS specific instantiation of wxConfigBase derivative:
    m_common_settings = GetNewConfig( KICAD_COMMON );

    // Only define the default environment variable if they haven't been set in the
    // .kicad_common configuration file.
    if( m_common_settings && !m_common_settings->HasGroup( pathEnvVariables ) )
    {
        wxString envVarName = wxT( "KIGITHUB" );
        ENV_VAR_ITEM envVarItem;
        wxString envValue;
        wxFileName tmpFileName;

        envVarItem.SetValue( wxString( wxT( "https://github.com/KiCad" ) ) );
        envVarItem.SetDefinedExternally( wxGetEnv( envVarName, NULL ) );
        m_local_env_vars[ envVarName ] = envVarItem;

        wxFileName baseSharePath;
        baseSharePath.AssignDir( wxString( wxT( DEFAULT_INSTALL_PATH ) ) );

#if !defined( __WXMAC__ )
        baseSharePath.AppendDir( wxT( "share" ) );
        baseSharePath.AppendDir( wxT( "kicad" ) );
#endif

        // KISYSMOD
        envVarName = wxT( "KISYSMOD" );
        if( wxGetEnv( envVarName, &envValue ) == true && !envValue.IsEmpty() )
        {
            tmpFileName.AssignDir( envValue );
            envVarItem.SetDefinedExternally( true );
        }
        else
        {
            tmpFileName = baseSharePath;
            tmpFileName.AppendDir( wxT( "modules" ) );
            envVarItem.SetDefinedExternally( false );
        }
        envVarItem.SetValue( tmpFileName.GetFullPath() );
        m_local_env_vars[ envVarName ] = envVarItem;

        // KISYS3DMOD
        envVarName = wxT( "KISYS3DMOD" );
        if( wxGetEnv( envVarName, &envValue ) == true && !envValue.IsEmpty() )
        {
            tmpFileName.AssignDir( envValue );
            envVarItem.SetDefinedExternally( true );
        }
        else
        {
            tmpFileName.AppendDir( wxT( "packages3d" ) );
            envVarItem.SetDefinedExternally( false );
        }
        envVarItem.SetValue( tmpFileName.GetFullPath() );
        m_local_env_vars[ envVarName ] = envVarItem;

        // KICAD_PTEMPLATES
        envVarName = wxT( "KICAD_PTEMPLATES" );
        if( wxGetEnv( envVarName, &envValue ) == true && !envValue.IsEmpty() )
        {
            tmpFileName.AssignDir( envValue );
            envVarItem.SetDefinedExternally( true );
        }
        else
        {
            tmpFileName = baseSharePath;
            tmpFileName.AppendDir( wxT( "template" ) );
            envVarItem.SetDefinedExternally( false );
        }
        envVarItem.SetValue( tmpFileName.GetFullPath() );
        m_local_env_vars[ envVarName ] = envVarItem;
    }

    ReadPdfBrowserInfos();      // needs m_common_settings

    // Init user language *before* calling loadCommonSettings, because
    // env vars could be incorrectly initialized on Linux
    // (if the value contains some non ASCII7 chars, the env var is not initialized)
    SetLanguage( true );

    loadCommonSettings();

    // Set locale option for separator used in float numbers
    SetLocaleTo_Default();

#ifdef __WXMAC__
    // Always show filters on Open dialog to be able to choose plugin
    wxSystemOptions::SetOption( wxOSX_FILEDIALOG_ALWAYS_SHOW_TYPES, 1 );
#endif

    return true;
}