Commit 6f72aaec authored by jean-pierre charras's avatar jean-pierre charras
Browse files

Kicad: files watcher: fix Linux specific issues

parent 45b01a5c
Loading
Loading
Loading
Loading
+2 −45
Original line number Original line Diff line number Diff line
@@ -31,12 +31,6 @@
#include <fctsys.h>
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <appl_wxstruct.h>


#ifdef USE_SPLASH_IMAGE
  #define SPLASH_IMAGE logo_kicad.png
  #include "wx/splash.h"
  #include "wx/mediactrl.h"
#endif

#include <kicad.h>
#include <kicad.h>
#include <tree_project_frame.h>
#include <tree_project_frame.h>
#include <wildcards_and_files_ext.h>
#include <wildcards_and_files_ext.h>
@@ -45,12 +39,6 @@


const wxString g_KicadPrjFilenameExtension( wxT( ".pro" ) );
const wxString g_KicadPrjFilenameExtension( wxT( ".pro" ) );


/* Import functions */
char* GetFileName( char* FullPathName );
void  ShowLogo( char* FonteFileName );

/* Local functions */

/************************************/
/************************************/
/* Called to initialize the program */
/* Called to initialize the program */
/************************************/
/************************************/
@@ -113,7 +101,8 @@ bool EDA_APP::OnInit()
    wxFileName namelessProject( wxGetCwd(), NAMELESS_PROJECT, ProjectFileExtension );
    wxFileName namelessProject( wxGetCwd(), NAMELESS_PROJECT, ProjectFileExtension );


    frame = new KICAD_MANAGER_FRAME( NULL, wxT( "KiCad" ),
    frame = new KICAD_MANAGER_FRAME( NULL, wxT( "KiCad" ),
                                     wxPoint( 30, 20 ), wxSize( 600, 400 ) );
                                     wxDefaultPosition, wxDefaultSize );
    SetTopWindow( frame );


    if( argc > 1 )
    if( argc > 1 )
    {
    {
@@ -141,38 +130,6 @@ bool EDA_APP::OnInit()
        frame->OnLoadProject( cmd );
        frame->OnLoadProject( cmd );
    }
    }


    wxString title = GetTitle() + wxT( " " ) + GetBuildVersion() +
                     wxT( " " ) + frame->m_ProjectFileName.GetFullPath();

    if( !namelessProject.IsDirWritable() )
        title += _( " [Read Only]" );

    frame->SetTitle( title );
    frame->ReCreateMenuBar();
    frame->RecreateBaseHToolbar();

    frame->m_LeftWin->ReCreateTreePrj();
    SetTopWindow( frame );

    /* Splash screen logo */
#ifdef USE_SPLASH_IMAGE
    wxBitmap bmp;
    wxString binDir = GetTraits()->GetStandardPaths().GetExecutablePath() +
                      wxFileName::GetPathSeparator();

    if( bmp.LoadFile( binDir + _T( "logokicad.png" ), wxBITMAP_TYPE_PNG ) )
    {
        wxSplashScreen* splash = new wxSplashScreen( splash_screen,
                                                     wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_TIMEOUT,
                                                     3000,
                                                     frame,
                                                     wxID_ANY,
                                                     wxDefaultPosition,
                                                     wxDefaultSize,
                                                     wxSIMPLE_BORDER | wxSTAY_ON_TOP );
    }
#endif /* USE_SPLASH_IMAGE */

    frame->Show( true );
    frame->Show( true );
    frame->Raise();
    frame->Raise();


+17 −1
Original line number Original line Diff line number Diff line
@@ -15,6 +15,12 @@
#include <wxstruct.h>
#include <wxstruct.h>
#include <appl_wxstruct.h>
#include <appl_wxstruct.h>


// With a recent wxWidget, we can use the wxFileSystemWatcherEvent
// to monitor files add/remove/rename in tree project
#if wxCHECK_VERSION( 2, 9, 4  )
#define KICAD_USE_FILES_WATCHER
#endif

extern const wxString g_KicadPrjFilenameExtension;
extern const wxString g_KicadPrjFilenameExtension;


class RIGHT_KM_FRAME;
class RIGHT_KM_FRAME;
@@ -77,7 +83,8 @@ enum id_kicad_frm {
    ID_SELECT_PREFERED_PDF_BROWSER,
    ID_SELECT_PREFERED_PDF_BROWSER,
    ID_SELECT_DEFAULT_PDF_BROWSER,
    ID_SELECT_DEFAULT_PDF_BROWSER,
    ID_SAVE_AND_ZIP_FILES,
    ID_SAVE_AND_ZIP_FILES,
    ID_READ_ZIP_ARCHIVE
    ID_READ_ZIP_ARCHIVE,
    ID_INIT_WATCHED_PATHS
};
};




@@ -175,6 +182,15 @@ public: KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title,
     */
     */
    void SaveSettings();
    void SaveSettings();


#ifdef KICAD_USE_FILES_WATCHER
    void                            FileWatcherReset();
    /**
     * Called by sending a event with id = ID_INIT_WATCHED_PATHS
     * rebuild the list of wahtched paths
     */
    void OnChangeWatchedPaths(wxCommandEvent& aEvent );
#endif

    DECLARE_EVENT_TABLE()
    DECLARE_EVENT_TABLE()
};
};


+1 −0
Original line number Original line Diff line number Diff line
@@ -89,6 +89,7 @@ KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent,
    PrintMsg( line );
    PrintMsg( line );


    RecreateBaseHToolbar();
    RecreateBaseHToolbar();
    ReCreateMenuBar();


    m_auimgr.SetManagedWindow( this );
    m_auimgr.SetManagedWindow( this );


+6 −1
Original line number Original line Diff line number Diff line
@@ -31,6 +31,7 @@
#include <appl_wxstruct.h>
#include <appl_wxstruct.h>
#include <kicad.h>
#include <kicad.h>
#include <menus_helpers.h>
#include <menus_helpers.h>
#include <tree_project_frame.h>


/* Menubar and toolbar event table */
/* Menubar and toolbar event table */
BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME )
BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME )
@@ -67,9 +68,13 @@ BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME )


    /* Range menu events */
    /* Range menu events */
    EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, KICAD_MANAGER_FRAME::SetLanguage )
    EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, KICAD_MANAGER_FRAME::SetLanguage )

    EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, KICAD_MANAGER_FRAME::OnFileHistory )
    EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, KICAD_MANAGER_FRAME::OnFileHistory )


    // Special functions
    #ifdef KICAD_USE_FILES_WATCHER
    EVT_MENU( ID_INIT_WATCHED_PATHS, KICAD_MANAGER_FRAME::OnChangeWatchedPaths )
    #endif

    /* Button events */
    /* Button events */
    EVT_BUTTON( ID_TO_PCB, KICAD_MANAGER_FRAME::OnRunPcbNew )
    EVT_BUTTON( ID_TO_PCB, KICAD_MANAGER_FRAME::OnRunPcbNew )
    EVT_BUTTON( ID_TO_CVPCB, KICAD_MANAGER_FRAME::OnRunCvpcb )
    EVT_BUTTON( ID_TO_CVPCB, KICAD_MANAGER_FRAME::OnRunCvpcb )
+7 −3
Original line number Original line Diff line number Diff line
@@ -222,10 +222,14 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event )


    SetTitle( title );
    SetTitle( title );
    UpdateFileHistory( m_ProjectFileName.GetFullPath() );
    UpdateFileHistory( m_ProjectFileName.GetFullPath() );
#if wxCHECK_VERSION( 2, 9, 2  )
    m_LeftWin->FileWatcherReset();
#endif
    m_LeftWin->ReCreateTreePrj();
    m_LeftWin->ReCreateTreePrj();
#ifdef KICAD_USE_FILES_WATCHER
    // Rebuild the list of watched paths.
    // however this is possible only when the main loop event handler is running,
    // so we use it to rub the rebuild function.
    wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_INIT_WATCHED_PATHS );
    wxPostEvent( this, cmd);
#endif


    PrintMsg( _( "Working dir: " ) + m_ProjectFileName.GetPath() +
    PrintMsg( _( "Working dir: " ) + m_ProjectFileName.GetPath() +
              _( "\nProject: " ) + m_ProjectFileName.GetFullName() +
              _( "\nProject: " ) + m_ProjectFileName.GetFullName() +
Loading