Esempio n. 1
0
void KICAD_MANAGER_FRAME::OnCloseWindow( wxCloseEvent& Event )
{
    if( Kiway().PlayersClose( false ) )
    {
        int px, py;

        if( !GetProjectFileName().empty() )
            UpdateFileHistory( GetProjectFileName(), &PgmTop().GetFileHistory() );

        if( !IsIconized() )   // save main frame position and size
        {
            GetPosition( &px, &py );
            m_FramePos.x = px;
            m_FramePos.y = py;

            GetSize( &px, &py );
            m_FrameSize.x = px;
            m_FrameSize.y = py;
        }

        Event.SetCanVeto( true );

        m_LeftWin->Show( false );

        Destroy();
    }
}
Esempio n. 2
0
void KICAD_MANAGER_FRAME::OnSaveProject( wxCommandEvent& event )
{
    if( !wxIsWritable( GetProjectFileName() ) )
        return;

    Prj().ConfigSave( PgmTop().SysSearch(), GeneralGroupName, s_KicadManagerParams );
}
Esempio n. 3
0
void KICAD_MANAGER_FRAME::OnRunEeschema( wxCommandEvent& event )
{
    wxFileName fn( GetProjectFileName() );

    fn.SetExt( SchematicFileExtension );

    RunEeschema( fn.GetFullPath() );
}
Esempio n. 4
0
const wxString KICAD_MANAGER_FRAME::PcbLegacyFileName()
{
   wxFileName   fn( GetProjectFileName() );

   fn.SetExt( LegacyPcbFileExtension );

   return fn.GetFullPath();
}
Esempio n. 5
0
const wxString KICAD_MANAGER_FRAME::SchFileName()
{
   wxFileName   fn( GetProjectFileName() );

   fn.SetExt( SchematicFileExtension );

   return fn.GetFullPath();
}
Esempio n. 6
0
/**
 * a minor helper function:
 * Prints the Current Working Dir name and the projet name on the text panel.
 */
void KICAD_MANAGER_FRAME::PrintPrjInfo()
{
    wxString msg = wxString::Format( _(
            "Working dir: %s\nProject: %s\n" ),
            GetChars( wxGetCwd() ),
            GetChars( GetProjectFileName() )
            );
    PrintMsg( msg );
}
Esempio n. 7
0
void KICAD_MANAGER_FRAME::OnSaveProject( wxCommandEvent& event )
{
    if( !wxIsWritable( GetProjectFileName() ) )
        return;

    // was: wxGetApp().WriteProjectConfig( m_ProjectFileName.GetFullPath(),
    //          GeneralGroupName, s_KicadManagerParams );
    Prj().ConfigSave( Pgm().SysSearch(), GeneralGroupName, s_KicadManagerParams );
}
Esempio n. 8
0
// arg is a table with the following elements
// project  - string name of the project
// callback - function(filename, linenumber, linestring)
// regex    - regex to search for
// caseSensitive  - optional
// regexIsLiteral - optional
int C_executeSearch(lua_State* L)
{
    const int arg_table = 1;
    lua_getfield(L, arg_table, "project");            /* idx:2 */
    test_error(lua_isstring(L, -1), "execute_search needs a key of 'project' which must be a string");
    const char* project = luaL_checkstring(L, 2);

    char projectFile[1024];
    GetProjectFileName(projectFile, project);
    if (FileExists(projectFile))
    {
        // unpack the rest of the table
        lua_getfield(L, arg_table, "regex");          /* idx:3 */
        test_error(lua_isstring(L, -1), "execute_search needs a key of 'regex' which must be a string");
        lua_getfield(L, arg_table, "caseSensitive");  /* idx:4 */
        lua_getfield(L, arg_table, "regexIsLiteral"); /* idx:5 */
        lua_getfield(L, arg_table, "ignoreTrigrams"); /* idx:6 */
        // MUST leave the callback on the top of the stack
        lua_getfield(L, arg_table, "callback");       /* idx:7 */
        test_error(lua_isfunction(L, -1), "execute_search needs a key of 'callback' which must be a lua function");
    
        // marshal into C data
        const char* regex   = luaL_checkstring(L, 3);
        bool caseSensitive  = lua_isnil(L, 4) || lua_toboolean(L, 4);
        bool regexIsLiteral = lua_toboolean(L, 5);
        bool ignoreTrigrams = lua_toboolean(L, 6);
    
        GrepParams params;
        memset(&params, 0, sizeof(params));
        // standard parms
        params.streamBlockSize = 1 * 1024 * 1024;
        params.streamBlockCount = 10;
        params.searchFilenames = false;
        // custom parms
        params.sourceArchiveName = projectFile;
        params.callbackFunction = luaHitCallback;
        params.caseSensitive = caseSensitive;
        params.regexIsLiteral = regexIsLiteral;
        params.ignoreTrigrams = ignoreTrigrams;
        params.searchPattern = regex;
        params.callbackContext = (void*)L;
        ExecuteSearch(&params);
    }
    else
    {
        lua_ProjectExistsOrDie(project);
        printf("Project is registered, but archive does not exist.\n");
        printf("Run 'qgrep build %s' to generate archive\n", project);
    }
    return 0;
}
Esempio n. 9
0
void KICAD_MANAGER_FRAME::OnRunCvpcb( wxCommandEvent& event )
{
    wxFileName fn( GetProjectFileName() );

    fn.SetExt( NetlistFileExtension );

    KIWAY_PLAYER* frame = Kiway.Player( FRAME_CVPCB, false );
    if( !frame )
    {
        frame = Kiway.Player( FRAME_CVPCB, true );
        frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
        frame->Show( true );
    }
    frame->Raise();
}
Esempio n. 10
0
void FastPathSearch(int argc, const char** argv)
{
    char projectNames[1024];
    strcpy(projectNames, argv[2]);
    const char* options = "";
    const char* regex = "";
    const char* secondPhaseRegex = NULL;
    char projectFile[1024];
    switch (argc)
    {
    case 6: // options regex secondPhaseRegex
        options = argv[3];
        regex = argv[4];
        secondPhaseRegex = argv[5];
        break;
    case 5: // Options must now start with '-'
        if (argv[3][0] == '-')
        {
            options = argv[3];
            regex = argv[4];
        }
        else
        {
            regex = argv[3];
            secondPhaseRegex = argv[4];
        }
        break;
    case 4: // regex only
        regex = argv[3];
        break;
    default:
        printf("Insufficient arguments for command '%s'\n", argv[1]);
        usage();
    }
    
    char* projects[20];
    int projectCount = 0;
    for (char* project = strtok(projectNames, ",");
         project && projectCount < 20;
         project = strtok(NULL, ","), projectCount++)
    {
        projects[projectCount] = project;
    }
    
    for (int i = 0; i < projectCount; i++)
    {
        const char* project = projects[i];
    
        GetProjectFileName(projectFile, project);
        if (FileExists(projectFile))
        {
            ExecuteSimpleColouredSearch(projectFile, options, regex, secondPhaseRegex, GetQgrepColouring());
        }
        else
        {
            lua_NoCacheSearch(project, options, regex, secondPhaseRegex);
            fprintf(stderr, "Project is registered, but archive does not exist.\n");
            fprintf(stderr, "Run 'qgrep build %s' to generate archive\n", project);
        }
    }
}
Esempio n. 11
0
void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event )
{
    // Any open KIFACE's must be closed if they are not part of the new project.
    // (We never want a KIWAY_PLAYER open on a KIWAY that isn't in the same project.)
    // User is prompted here to close those KIWAY_PLAYERs:
    if( !Kiway.PlayersClose( false ) )
        return;

    // evt_id can be one of:
    //   ID_NEW_PROJECT, ID_NEW_PROJECT_FROM_TEMPLATE, ID_LOAD_PROJECT, and
    //   wxID_ANY from 3 different places.
    int evt_id = event.GetId();

    wxString    title;

    ClearMsg();

    bool newProject = ( evt_id == ID_NEW_PROJECT ) ||
                      ( evt_id == ID_NEW_PROJECT_FROM_TEMPLATE );

    if( evt_id != wxID_ANY )
    {
        int  style;

        if( newProject )
        {
            title = _( "Create New Project" );
            style = wxFD_SAVE | wxFD_OVERWRITE_PROMPT;
        }
        else
        {
            title = _( "Open Existing Project" );
            style = wxFD_OPEN | wxFD_FILE_MUST_EXIST;
        }

        wxString        default_dir = GetMruPath();
        wxFileDialog    dlg( this, title, default_dir, wxEmptyString,
                             ProjectFileWildcard, style );

        if( dlg.ShowModal() == wxID_CANCEL )
            return;

        //DBG( printf( "%s: wxFileDialog::GetPath=%s\n", __func__, TO_UTF8( dlg.GetPath() ) );)

        wxFileName pro( dlg.GetPath() );
        pro.SetExt( ProjectFileExtension );     // enforce extension

        if( !pro.IsAbsolute() )
            pro.MakeAbsolute();

        if( newProject )
        {
            // Check if the project directory is empty
            wxDir directory( pro.GetPath() );

            if( directory.HasFiles() )
            {
                wxString msg = _( "The selected directory is not empty.  We recommend you "
                                  "create projects in their own clean directory.\n\nDo you "
                                  "want to create a new empty directory for the project?" );

                if( IsOK( this, msg ) )
                {
                    // Append a new directory with the same name of the project file
                    // and try to create it
                    pro.AppendDir( pro.GetName() );

                    if( !wxMkdir( pro.GetPath() ) )
                        // There was a problem, undo
                        pro.RemoveLastDir();
                }
            }

            if( evt_id == ID_NEW_PROJECT )
            {
                CreateNewProject( pro.GetFullPath() );
            }
            else if( evt_id == ID_NEW_PROJECT_FROM_TEMPLATE )
            {
                // Launch the template selector dialog
                CreateNewProject( pro.GetFullPath(), true );
            }
        }

        SetProjectFileName( pro.GetFullPath() );
    }

    wxString prj_filename = GetProjectFileName();

    wxString nameless_prj = NAMELESS_PROJECT  wxT( ".pro" );

    wxLogDebug( wxT( "%s: %s" ),
                GetChars( wxFileName( prj_filename ).GetFullName() ),
                GetChars( nameless_prj ) );

    // Check if project file exists and if it is not noname.pro
    if( !wxFileExists( prj_filename )
            && !wxFileName( prj_filename ).GetFullName().IsSameAs( nameless_prj ) )
    {
        wxString msg = wxString::Format( _(
                                             "KiCad project file '%s' not found" ),
                                         GetChars( prj_filename ) );

        DisplayError( this, msg );
        return;
    }

    // Either this is the first time kicad has been run or one of the projects in the
    // history list is no longer valid.  This prevents kicad from automatically creating
    // a noname.pro file in the same folder as the kicad binary.
    if( wxFileName( prj_filename ).GetFullName().IsSameAs( nameless_prj ) && !newProject )
    {
        m_active_project = false;
        m_MessagesBox->SetValue( _( "To proceed, you can use the File menu to start a new project." ) );
        return;
    }
    else
    {
        m_active_project = true;
        m_MessagesBox->Clear();
    }

    Prj().ConfigLoad( Pgm().SysSearch(), GeneralGroupName, s_KicadManagerParams );

    title = wxT( "KiCad " ) + GetBuildVersion() +  wxT( ' ' ) + prj_filename;

    if( !wxFileName( prj_filename ).IsDirWritable() )
        title += _( " [Read Only]" );
    else
        SetMruPath( Prj().GetProjectPath() );    // Only set MRU path if we have write access.

    SetTitle( title );

    if( !prj_filename.IsSameAs( nameless_prj ) )
        UpdateFileHistory( prj_filename, &Pgm().GetFileHistory() );

    m_LeftWin->ReCreateTreePrj();

    // Rebuild the list of watched paths.
    // however this is possible only when the main loop event handler is running,
    // so we use it to run the rebuild function.
    wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_INIT_WATCHED_PATHS );

    wxPostEvent( this, cmd );

    PrintPrjInfo();
}
Esempio n. 12
0
void KICAD_MANAGER_FRAME::OnUnarchiveFiles( wxCommandEvent& event )
{
    wxFileName fn = GetProjectFileName();

    fn.SetExt( ZipFileExtension );

    wxFileDialog zipfiledlg( this, _( "Unzip Project" ), fn.GetPath(),
                             fn.GetFullName(), ZipFileWildcard(),
                             wxFD_OPEN | wxFD_FILE_MUST_EXIST );

    if( zipfiledlg.ShowModal() == wxID_CANCEL )
        return;

    wxString msg = wxString::Format( _( "\nOpen \"%s\"\n" ), GetChars( zipfiledlg.GetPath() ) );
    PrintMsg( msg );

    wxDirDialog dirDlg( this, _( "Target Directory" ), fn.GetPath(),
                        wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );

    if( dirDlg.ShowModal() == wxID_CANCEL )
        return;

    wxString unzipDir = dirDlg.GetPath() + wxT( "/" );
    msg.Printf( _( "Unzipping project in \"%s\"\n" ), GetChars( unzipDir ) );
    PrintMsg( msg );

    wxFileSystem zipfilesys;

    zipfilesys.AddHandler( new wxZipFSHandler );
    auto path = wxURI( zipfiledlg.GetPath() + wxT( "#zip:" ) ).BuildURI();
    zipfilesys.ChangePathTo( path, true );

    wxFSFile* zipfile = NULL;
    wxString  localfilename = zipfilesys.FindFirst( wxFileSelectorDefaultWildcardStr, wxFILE );

    while( !localfilename.IsEmpty() )
    {
        zipfile = zipfilesys.OpenFile( localfilename );
        if( !zipfile )
        {
            DisplayError( this, wxT( "Zip file read error" ) );
            break;
        }

        wxFileName uzfn = localfilename.AfterLast( ':' );
        uzfn.MakeAbsolute( unzipDir );
        wxString unzipfilename = uzfn.GetFullPath();

        msg.Printf( _( "Extract file \"%s\"" ), GetChars( unzipfilename ) );
        PrintMsg( msg );

        wxInputStream* stream = zipfile->GetStream();
        wxFFileOutputStream* ofile = new wxFFileOutputStream( unzipfilename );

        if( ofile->Ok() )
        {
            ofile->Write( *stream );
            PrintMsg( _( " OK\n" ) );
        }
        else
            PrintMsg( _( " *ERROR*\n" ) );

        delete ofile;
        delete zipfile;

        localfilename = zipfilesys.FindNext();
    }

    PrintMsg( wxT( "** end **\n" ) );

    if( unzipDir == Prj().GetProjectPath() )
    {
        wxCommandEvent dummy;
        OnRefresh( dummy );
    }
}
Esempio n. 13
0
void KICAD_MANAGER_FRAME::OnArchiveFiles( wxCommandEvent& event )
{
    // List of file extensions to save.
    static const wxChar* extentionList[] = {
        wxT( "*.pro" ),
        wxT( "*.sch" ), wxT( "*.lib" ), wxT( "*.dcm" ), // Schematic related files
        wxT( "*.cmp" ),
        wxT( "*.brd" ), wxT( "*.kicad_pcb" ),   // Brd files
        wxT( "*.mod" ), wxT( "*.kicad_mod" ),   // fp files
        wxT( "*.gb?" ), wxT( "*.gbrjob" ),      // Gerber files
        wxT( "*.gko" ), wxT( "*.gm1" ),
        wxT( "*.gm2" ), wxT( "*.g?" ),
        wxT( "*.gp1" ), wxT( "*.gp2" ),
        wxT( "*.gpb" ), wxT( "*.gpt" ),
        wxT( "*.gt?" ),
        wxT( "*.pos" ), wxT( "*.drl" ),         // Fab files
        wxT( "*.d356" ), wxT( "*.rpt" ),
        wxT( "*.stp" ), wxT( "*.step" ),        // 3d files
        wxT( "*.wrl" ),
        wxT( "*.net" ), wxT( "*.py" ),
        wxT( "*.pdf" ), wxT( "*.txt" ), wxT( "*.kicad_wks" ),
        wxT( "fp-lib-table" ), wxT( "sym-lib-table" )
    };

    wxString    msg;
    wxFileName  fileName = GetProjectFileName();
    wxString    oldCwd = wxGetCwd();

    fileName.SetExt( wxT( "zip" ) );

    wxFileDialog dlg( this, _( "Archive Project Files" ),
                      fileName.GetPath(), fileName.GetFullName(),
                      ZipFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );

    if( dlg.ShowModal() == wxID_CANCEL )
        return;

    wxFileName zip = dlg.GetPath();

    wxString currdirname = fileName.GetPathWithSep();
    wxDir dir( currdirname );

    if( !dir.IsOpened() )   // wxWidgets display a error message on issue.
        return;

    wxSetWorkingDirectory( currdirname );

    // Prepare the zip file
    wxString zipfilename = zip.GetFullPath();

    wxFFileOutputStream ostream( zipfilename );

    if( !ostream.IsOk() )   // issue to create the file. Perhaps not writable dir
    {
        wxMessageBox( wxString::Format( _( "Unable to create zip archive file \"%s\"" ),
                                        zipfilename ) );
        return;
    }

    wxZipOutputStream zipstream( ostream );

    // Build list of filenames to put in zip archive
    wxString currFilename;

	wxArrayString files;

    for( unsigned ii = 0; ii < arrayDim( extentionList ); ii++ )
        wxDir::GetAllFiles( currdirname, &files, extentionList[ii] );

    files.Sort();

    int zipBytesCnt = 0;

    for( unsigned ii = 0; ii < files.GetCount(); ii++ )
    {
        wxFileSystem fsfile;

        wxFileName curr_fn( files[ii] );
        curr_fn.MakeRelativeTo( currdirname );
        currFilename = curr_fn.GetFullPath();

        msg.Printf( _( "Archive file \"%s\"" ), GetChars( currFilename ) );
        PrintMsg( msg );

        // Read input file and add it to the zip file:
        wxFSFile* infile = fsfile.OpenFile( currFilename );

        if( infile )
        {
            zipstream.PutNextEntry( currFilename, infile->GetModificationTime() );
            infile->GetStream()->Read( zipstream );
            zipstream.CloseEntry();
            int zippedsize = zipstream.GetSize() - zipBytesCnt;
            zipBytesCnt = zipstream.GetSize();
            PrintMsg( wxT("  ") );
            msg.Printf( _( "(%lu bytes, compressed %d bytes)\n" ),
                        (unsigned long)infile->GetStream()->GetSize(), zippedsize );
            PrintMsg( msg );
            delete infile;
        }
        else
            PrintMsg( _( " >>Error\n" ) );
    }

    zipBytesCnt = ostream.GetSize();

    if( zipstream.Close() )
    {
        msg.Printf( _( "\nZip archive \"%s\" created (%d bytes)" ),
                    GetChars( zipfilename ), zipBytesCnt );
        PrintMsg( msg );
        PrintMsg( wxT( "\n** end **\n" ) );
    }
    else
    {
        msg.Printf( wxT( "Unable to create archive \"%s\", abort\n" ),
                    GetChars( zipfilename ) );
        PrintMsg( msg );
    }

    wxSetWorkingDirectory( oldCwd );
}
Esempio n. 14
0
void KICAD_MANAGER_FRAME::OnArchiveFiles( wxCommandEvent& event )
{
    // List of file extensions to save.
    static const wxChar* extentionList[] = {
        wxT( "*.sch" ), wxT( "*.lib" ), wxT( "*.mod" ), wxT( "*.cmp" ),
        wxT( "*.brd" ), wxT( "*.kicad_pcb" ), wxT( "*.gbr" ), wxT( "*.pos" ),
        wxT( "*.net" ), wxT( "*.pro" ), wxT( "*.drl" ), wxT( "*.py" ),
        wxT( "*.pdf" ), wxT( "*.txt" ), wxT( "*.dcm" ), wxT( "*.kicad_wks" ),
    };

    wxString    msg;
    wxFileName  fileName = GetProjectFileName();
    wxString    oldCwd = wxGetCwd();

    fileName.SetExt( wxT( "zip" ) );

    wxFileDialog dlg( this, _( "Archive Project Files" ),
                      fileName.GetPath(), fileName.GetFullName(),
                      ZipFileWildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT );

    if( dlg.ShowModal() == wxID_CANCEL )
        return;

    wxFileName zip = dlg.GetPath();

    wxString currdirname = fileName.GetPathWithSep();
    wxDir dir( currdirname );

    if( !dir.IsOpened() )
        return;

    wxSetWorkingDirectory( currdirname );

    // Prepare the zip file
    wxString zipfilename = zip.GetFullPath();

    wxFFileOutputStream ostream(zipfilename);
    wxZipOutputStream zipstream( ostream );

    // Build list of filenames to put in zip archive
    wxString currFilename;

	wxArrayString files;

    for( unsigned ii = 0; ii < DIM( extentionList ); ii++ )
        wxDir::GetAllFiles( currdirname, &files, extentionList[ii] );

    files.Sort();

    int zipBytesCnt = 0;

    for( unsigned ii = 0; ii < files.GetCount(); ii++ )
    {
        wxFileSystem fsfile;

        wxFileName curr_fn( files[ii] );
        curr_fn.MakeRelativeTo( currdirname );
        currFilename = curr_fn.GetFullPath();

        msg.Printf(_( "Archive file <%s>" ), GetChars( currFilename ) );
        PrintMsg( msg );

        // Read input file and add it to the zip file:
        wxFSFile* infile = fsfile.OpenFile(currFilename);

        if( infile )
        {
            zipstream.PutNextEntry( currFilename, infile->GetModificationTime() );
            infile->GetStream()->Read( zipstream );
            zipstream.CloseEntry();
            int zippedsize = zipstream.GetSize() - zipBytesCnt;
            zipBytesCnt = zipstream.GetSize();
            PrintMsg( wxT("  ") );
            msg.Printf( _( "(%d bytes, compressed %d bytes)\n"),
                        infile->GetStream()->GetSize(), zippedsize );
            PrintMsg( msg );
            delete infile;
        }
        else
            PrintMsg( _(" >>Error\n") );
    }

    zipBytesCnt = ostream.GetSize();

    if( zipstream.Close() )
    {
        msg.Printf( _("\nZip archive <%s> created (%d bytes)" ),
                    GetChars( zipfilename ), zipBytesCnt );
        PrintMsg( msg );
        PrintMsg( wxT( "\n** end **\n" ) );
    }
    else
    {
        msg.Printf( wxT( "Unable to create archive <%s>, abort\n" ),
                  GetChars( zipfilename ) );
        PrintMsg( msg );
    }

    wxSetWorkingDirectory( oldCwd );
}
Esempio n. 15
0
/**
 * a minor helper function:
 * Prints the Current Project full name on the text panel.
 */
void KICAD_MANAGER_FRAME::PrintPrjInfo()
{
    wxString msg = wxString::Format( _( "Project name:\n%s\n" ),
                        GetChars( GetProjectFileName() ) );
    PrintMsg( msg );
}
Esempio n. 16
0
void KICAD_MANAGER_FRAME::OnImportEagleFiles( wxCommandEvent& event )
{
    // Close other windows.
    if( !Kiway().PlayersClose( false ) )
        return;


    wxString title = _( "Import Eagle Project Files" );
    int style = wxFD_OPEN | wxFD_FILE_MUST_EXIST;
    wxString default_dir = GetMruPath();

    ClearMsg();

    wxFileDialog schdlg( this, title, default_dir, wxEmptyString,
                         EagleFilesWildcard(), style );

    if( schdlg.ShowModal() == wxID_CANCEL )
        return;


    wxFileName sch( schdlg.GetPath() );

    sch.SetExt( SchematicFileExtension );

    wxFileName pro = sch;

    pro.SetExt( ProjectFileExtension );

    wxString protitle = _( "KiCad Project Destination" );

    // Don't use wxFileDialog here.  On GTK builds, the default path is returned unless a
    // file is actually selected.
    wxDirDialog prodlg( this, protitle, pro.GetPath(), wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );

    if( prodlg.ShowModal() == wxID_CANCEL )
        return;

    pro.SetPath( prodlg.GetPath() );

    // Check if the project directory is empty
    wxDir directory( pro.GetPath() );

    if( directory.HasFiles() )
    {
        wxString msg = _( "The selected directory is not empty.  We recommend you "
                          "create projects in their own clean directory.\n\nDo you "
                          "want to create a new empty directory for the project?" );

        KIDIALOG dlg( this, msg, _( "Confirmation" ), wxYES_NO | wxICON_WARNING );
        dlg.DoNotShowCheckbox( __FILE__, __LINE__ );

        if( dlg.ShowModal() == wxID_YES )
        {
            // Append a new directory with the same name of the project file
            // and try to create it
            pro.AppendDir( pro.GetName() );

            if( !wxMkdir( pro.GetPath() ) )
                // There was a problem, undo
                pro.RemoveLastDir();
        }
    }

    wxFileName pcb( sch );
    pro.SetExt( ProjectFileExtension );         // enforce extension
    pcb.SetExt( LegacyPcbFileExtension );       // enforce extension

    if( !pro.IsAbsolute() )
        pro.MakeAbsolute();

    SetProjectFileName( pro.GetFullPath() );
    wxString prj_filename = GetProjectFileName();

    if( sch.FileExists() )
    {
        KIWAY_PLAYER* schframe = Kiway().Player( FRAME_SCH, false );

        if( !schframe )
        {
            try     // SCH frame was not available, try to start it
            {
                schframe = Kiway().Player( FRAME_SCH, true );
            }
            catch( const IO_ERROR& err )
            {
                wxMessageBox( _( "Eeschema failed to load:\n" ) + err.What(),
                        _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
                return;
            }
        }

        std::string packet = StrPrintf( "%d\n%s", SCH_IO_MGR::SCH_EAGLE,
                                                  TO_UTF8( sch.GetFullPath() ) );
        schframe->Kiway().ExpressMail( FRAME_SCH, MAIL_IMPORT_FILE, packet, this );

        if( !schframe->IsShown() )      // the frame exists, (created by the dialog field editor)
                                        // but no project loaded.
        {
            schframe->Show( true );
        }

        if( schframe->IsIconized() )
            schframe->Iconize( false );

        schframe->Raise();
    }


    if( pcb.FileExists() )
    {
        KIWAY_PLAYER* pcbframe = Kiway().Player( FRAME_PCB, false );

        if( !pcbframe )
        {
            try     // PCB frame was not available, try to start it
            {
                pcbframe = Kiway().Player( FRAME_PCB, true );
            }
            catch( const IO_ERROR& err )
            {
                wxMessageBox( _( "Pcbnew failed to load:\n" ) + err.What(), _( "KiCad Error" ),
                        wxOK | wxICON_ERROR, this );
                return;
            }
        }

        // a pcb frame can be already existing, but not yet used.
        // this is the case when running the footprint editor, or the footprint viewer first
        // if the frame is not visible, the board is not yet loaded
        if( !pcbframe->IsVisible() )
        {
            pcbframe->Show( true );
        }

        std::string packet = StrPrintf( "%d\n%s", IO_MGR::EAGLE,
                                                  TO_UTF8( pcb.GetFullPath() ) );
        pcbframe->Kiway().ExpressMail( FRAME_PCB, MAIL_IMPORT_FILE, packet, this );

        // On Windows, Raise() does not bring the window on screen, when iconized
        if( pcbframe->IsIconized() )
            pcbframe->Iconize( false );

        pcbframe->Raise();
    }

    ReCreateTreePrj();
    m_active_project = true;
}