Commit c64a6937 authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

Add user write permission tests to EESchama and other minor fixes.

* Add general purpose user write permission test function to base
  window class.
* Check user write permissions before saving project, schematic and
  library files.
* Remove displaying file dialog every time the project file is saved.
* Display absolute paths for non-root sheet file in title bar.
* Remove redundant command table entry from schematic editor.
* Remove unused variables to fix GCC 4.6 warnings.
* The usual Doxygen comment and coding style policy fixes.
parent 2b453357
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -851,7 +851,7 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas )
        dx, dx0, dy, dy0,
        delta_cx, delta_cy,
        xc, yc;
    int     angle, delta_angle;
    int     angle;
    double  scale;
    double  zpos;
    wxPoint shape_pos;
@@ -933,14 +933,12 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas )
            delta_cx = dx - dy;
            delta_cy = 0;
            w = m_Size.y * scale;
            delta_angle = angle + 900;
        }
        else /* Vertical ellipse */
        {
            delta_cx = 0;
            delta_cy = dy - dx;
            w = m_Size.x * scale;
            delta_angle = angle;
        }
        RotatePoint( &delta_cx, &delta_cy, angle );
        {
+0 −2
Original line number Diff line number Diff line
@@ -291,7 +291,6 @@ double* ReadCoordsList( FILE* file, char* text_buffer, int* bufsize,
    char*        text;
    bool         HasData   = FALSE;
    bool         StartData = FALSE;
    bool         EndData   = FALSE;
    bool         EndNode   = FALSE;
    char         string_num[512];

@@ -338,7 +337,6 @@ double* ReadCoordsList( FILE* file, char* text_buffer, int* bufsize,
                if( *text == ']' )
                {
                    StartData = FALSE;
                    EndData   = TRUE;
                }
                break;

+32 −0
Original line number Diff line number Diff line
@@ -445,3 +445,35 @@ void EDA_BASE_FRAME::CopyVersionInfoToClipboard( wxCommandEvent& event )
    wxTheClipboard->SetData( new wxTextDataObject( tmp ) );
    wxTheClipboard->Close();
}


bool EDA_BASE_FRAME::IsWritable( const wxFileName& aFileName )
{
    wxString msg;

    wxCHECK_MSG( aFileName.IsOk(), false, wxT( "Invalid file name object.  Bad programmer!" ) );

    if( aFileName.IsDir() && !aFileName.IsDirWritable() )
    {
        msg.Printf( _( "You do not have write permissions to folder <%s>." ),
                    GetChars( aFileName.GetPath() ) );
    }
    else if( !aFileName.FileExists() && !aFileName.IsDirWritable() )
    {
        msg.Printf( _( "You do not have write permissions to save file <%s> to folder <%s>." ),
                    GetChars( aFileName.GetFullName() ), GetChars( aFileName.GetPath() ) );
    }
    else if( aFileName.FileExists() && !aFileName.IsFileWritable() )
    {
        msg.Printf( _( "You do not have write permissions to save file <%s>." ),
                    GetChars( aFileName.GetFullPath() ) );
    }

    if( !msg.IsEmpty() )
    {
        DisplayError( this, msg );
        return false;
    }

    return true;
}
+1 −1
Original line number Diff line number Diff line
@@ -197,7 +197,7 @@ void DIALOG_EESCHEMA_CONFIG::OnOkClick( wxCommandEvent& event )
        LIB_EDIT_FRAME::EnsureActiveLibExists();
    }

    m_Parent->SaveProjectFile( this, false );
    m_Parent->SaveProjectFile();
    EndModal( wxID_OK );
}

+7 −2
Original line number Diff line number Diff line
@@ -79,16 +79,21 @@ void SCH_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
        // Window title format:
        // [filename sheetpath] (/path/to/filedir)

        // Often the /path/to/filedir is blank because of the FullFileName argument
        // passed to LoadOneEEFile() which currently omits the path on non-root schematics.
        wxFileName t( GetScreen()->GetFileName() );

        // Often the /path/to/filedir is blank because of the FullFileName argument
        // passed to LoadOneEEFile() which omits the path on non-root schematics.
        // Making the path absolute solves this problem.
        t.MakeAbsolute();
        title = wxChar( '[' );
        title << t.GetName() << wxChar( ' ' );
        title << m_CurrentSheet->PathHumanReadable() << wxChar( ']' );

        title << wxChar( ' ' );
        title << wxChar( '(' ) << t.GetPath() << wxChar( ')' );

        if( !t.IsFileWritable() )
            title << _( " [Read Only]" );
#endif

        SetTitle( title );
Loading