Library Editor: notify is library is read-only

This commit is contained in:
Maciej Suminski 2017-11-14 14:19:11 +01:00
parent d2d3680774
commit 86f71a9eb4
3 changed files with 19 additions and 7 deletions

View File

@ -240,7 +240,7 @@ bool LIB_MANAGER::IsLibraryReadOnly( const wxString& aLibrary ) const
{
wxCHECK( LibraryExists( aLibrary ), true );
wxFileName fn( m_symbolTable->GetFullURI( aLibrary ) );
return !fn.IsFileWritable();
return ( fn.FileExists() && !fn.IsFileWritable() ) || !fn.IsDirWritable();
}

View File

@ -67,7 +67,7 @@ void LIB_EDIT_FRAME::DisplayLibInfos()
title += lib + " (" + fileName + ")";
if( !wxFileName::IsFileWritable( fileName ) )
if( wxFileName::FileExists( fileName ) && !wxFileName::IsFileWritable( fileName ) )
title += " " + _( "[Read Only]" );
}
else

View File

@ -519,9 +519,20 @@ void LIB_EDIT_FRAME::OnUpdatePartModified( wxUpdateUIEvent& aEvent )
const wxString& partName = libId.GetLibItemName();
const wxString& libName = libId.GetLibNickname();
aEvent.Enable( !partName.IsEmpty() && !libName.IsEmpty()
&& m_libMgr->IsPartModified( partName, libName )
&& ( aEvent.GetId() == ID_LIBEDIT_REVERT_PART || !m_libMgr->IsLibraryReadOnly( libName ) ) );
if( aEvent.GetId() == ID_LIBEDIT_SAVE_PART )
{
bool readOnly = libName.IsEmpty() || m_libMgr->IsLibraryReadOnly( libName );
aEvent.SetText( readOnly ? _( "Save part [Read Only]" ) : _( "Save part" ) );
aEvent.Enable( !readOnly && !partName.IsEmpty()
&& m_libMgr->IsPartModified( partName, libName ) );
}
else if( aEvent.GetId() == ID_LIBEDIT_REVERT_PART )
{
aEvent.Enable( !partName.IsEmpty() && !libName.IsEmpty()
&& m_libMgr->IsPartModified( partName, libName ) );
}
else wxFAIL;
}
@ -554,9 +565,10 @@ void LIB_EDIT_FRAME::OnUpdateRedo( wxUpdateUIEvent& event )
void LIB_EDIT_FRAME::OnUpdateSaveLib( wxUpdateUIEvent& event )
{
wxString lib = getTargetLib();
bool readOnly = lib.IsEmpty() || m_libMgr->IsLibraryReadOnly( lib );
event.Enable( m_libMgr->LibraryExists( lib ) && !m_libMgr->IsLibraryReadOnly( lib ) &&
m_libMgr->IsLibraryModified( lib ) );
event.SetText( readOnly ? _( "Save library [Read Only]" ) : _( "Save library" ) );
event.Enable( !readOnly && m_libMgr->IsLibraryModified( lib ) );
}