Workaround a few more OSX printf problems.

Also regularizes the frame title processing.

Also fixes a type where the library name wasn't processed for
variable expansion.

Fixes https://gitlab.com/kicad/code/kicad/issues/7742
This commit is contained in:
Jeff Young 2021-06-20 22:46:41 +01:00
parent 99da3d1336
commit 685ee31c35
10 changed files with 118 additions and 65 deletions

View File

@ -1249,11 +1249,7 @@ void SCH_EDIT_FRAME::UpdateTitle()
{
wxString title;
if( GetScreen()->GetFileName().IsEmpty() )
{
title = _( "[no file]" ) + wxT( " \u2014 " ) + _( "Schematic Editor" );
}
else
if( !GetScreen()->GetFileName().IsEmpty() )
{
wxFileName fn( Prj().AbsolutePath( GetScreen()->GetFileName() ) );
bool readOnly = false;
@ -1264,12 +1260,24 @@ void SCH_EDIT_FRAME::UpdateTitle()
else
unsaved = true;
title = ( IsContentModified() ? "*" : "" )
+ fn.GetName() + " [" + GetCurrentSheet().PathHumanReadable( false ) + "] "
+ ( readOnly ? _( "[Read Only]" ) + wxS( " " ) : wxS( "" ) )
+ ( unsaved ? _( "[Unsaved]" ) + wxS( " " ) : wxS( "" ) )
+ wxT( "\u2014 " ) + _( "Schematic Editor" );
if( IsContentModified() )
title = wxT( "*" );
title += fn.GetName();
title += wxString::Format( wxT( " [%s]" ), GetCurrentSheet().PathHumanReadable( false ) );
if( readOnly )
title += wxS( " " ) + _( "[Read Only]" );
if( unsaved )
title += wxS( " " ) + _( "[Unsaved]" );
}
else
{
title = _( "[no schematic loaded]" );
}
title += wxT( " \u2014 " ) + _( "Schematic Editor" );
SetTitle( title );
}

View File

@ -333,11 +333,22 @@ void SIM_PLOT_FRAME::updateTitle()
else
unsaved = true;
SetTitle( wxString::Format( wxT( "%s%s %s%s\u2014 " ) + _( "Spice Simulator" ),
m_workbook->IsModified() ? "*" : "",
filename.GetName(),
readOnly ? _( "[Read Only]" ) + wxS( " " ) : "",
unsaved ? _( "[Unsaved]" ) + wxS( " " ) : "" ) );
wxString title;
if( m_workbook->IsModified() )
title = wxT( "*" ) + filename.GetName();
else
title = filename.GetName();
if( readOnly )
title += wxS( " " ) + _( "[Read Only]" );
if( unsaved )
title += wxS( " " ) + _( "[Unsaved]" );
title += wxT( " \u2014 " ) + _( "Spice Simulator" );
SetTitle( title );
}

View File

@ -139,26 +139,28 @@ void SYMBOL_EDIT_FRAME::updateTitle()
if( IsSymbolFromSchematic() )
{
title = ( GetScreen() && GetScreen()->IsContentModified() ? "*" : "" )
+ m_reference + " "
+ _( "[from schematic]" )
+ wxT( " \u2014 " );
if( GetScreen() && GetScreen()->IsContentModified() )
title = wxT( "*" );
title += m_reference;
title += wxS( " " ) + _( "[from schematic]" );
}
else if( GetCurSymbol() )
{
if( GetScreen() && GetScreen()->IsContentModified() )
title = wxT( "*" );
title += FROM_UTF8( GetCurSymbol()->GetLibId().Format().c_str() );
if( m_libMgr && m_libMgr->IsLibraryReadOnly( GetCurLib() ) )
title += wxS( " " ) + _( "[Read Only Library]" );
}
else
{
if( GetCurSymbol() )
{
bool readOnly = m_libMgr && m_libMgr->IsLibraryReadOnly( GetCurLib() );
title = ( GetScreen() && GetScreen()->IsContentModified() ? "*" : "" )
+ FROM_UTF8( GetCurSymbol()->GetLibId().Format().c_str() )
+ " "
+ ( readOnly ? _( "[Read Only Library]" ) + wxT( " " ) : "" )
+ wxT( " \u2014 " );
}
title = _( "[no symbol loaded]" );
}
title += _( "Symbol Editor" );
title += wxT( " \u2014 " ) + _( "Symbol Editor" );
SetTitle( title );
}

View File

@ -901,8 +901,9 @@ void SYMBOL_VIEWER_FRAME::DisplayLibInfos()
{
const SYMBOL_LIB_TABLE_ROW* row = Prj().SchSymbolLibTable()->FindRow( m_libraryName, true );
wxString title = wxString::Format( wxT( "%s \u2014 " ) + _( "Symbol Library Browser" ),
row ? row->GetFullURI() : _( "no library selected" ) );
wxString title = row ? row->GetFullURI( true ) : _( "[no library selected]" );
title += wxT( " \u2014 " ) + _( "Symbol Library Browser" );
SetTitle( title );
}
}

View File

@ -621,13 +621,15 @@ void GERBVIEW_FRAME::UpdateTitleAndInfo()
}
else
{
wxString title;
wxString title;
wxFileName filename( gerber->m_FileName );
title.Printf( wxT( "%s%s \u2014 " ) + _( "Gerber Viewer" ),
filename.GetFullName(),
gerber->m_IsX2_file ? wxS( " " ) + _( "(with X2 attributes)" )
: wxString( wxEmptyString ) );
title = filename.GetFullName();
if( gerber->m_IsX2_file )
title += wxS( " " ) + _( "(with X2 attributes)" );
title += wxT( " \u2014 " ) + _( "Gerber Viewer" );
SetTitle( title );
gerber->DisplayImageInfo( this );

View File

@ -605,7 +605,6 @@ void KICAD_MANAGER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTex
void KICAD_MANAGER_FRAME::ProjectChanged()
{
wxString app = wxS( "KiCad " ) + GetMajorMinorVersion();
wxString file = GetProjectFileName();
wxString title;
@ -613,15 +612,17 @@ void KICAD_MANAGER_FRAME::ProjectChanged()
{
wxFileName fn( file );
title += fn.GetName();
title = fn.GetName();
if( !fn.IsDirWritable() )
title += wxS( " " ) + _( "[Read Only]" );
title += wxS(" \u2014 ");
}
else
{
title = _( "[no project loaded]" );
}
title += app;
title += wxT( " \u2014 " ) + _( "KiCad " ) + GetMajorMinorVersion();
SetTitle( title );
}

View File

@ -547,8 +547,13 @@ void PL_EDITOR_FRAME::UpdateTitleAndInfo()
wxString title;
wxFileName file( GetCurrentFileName() );
title.Printf( wxT( "%s \u2014 " ) + _( "Drawing Sheet Editor" ),
file.IsOk() ? file.GetName() : _( "no file selected" ) );
if( file.IsOk() )
title = file.GetName();
else
title = _( "[no drawing sheet loaded]" );
title += wxT( " \u2014 " ) + _( "Drawing Sheet Editor" ),
SetTitle( title );
}

View File

@ -756,9 +756,12 @@ void FOOTPRINT_EDIT_FRAME::UpdateTitle()
if( IsCurrentFPFromBoard() )
{
title = ( IsContentModified() ? "*" : "" )
+ footprint->GetReference() + wxS( " [" ) + _( "from" ) + " "
+ Prj().GetProjectName() + "." + PcbFileExtension + wxS( "] \u2014 " );
if( IsContentModified() )
title = wxT( "*" );
title += footprint->GetReference();
title += wxS( " " ) + wxString::Format( _( "[from %s]" ),
Prj().GetProjectName() + "." + PcbFileExtension );
}
else if( fpid.IsValid() )
{
@ -772,19 +775,29 @@ void FOOTPRINT_EDIT_FRAME::UpdateTitle()
}
// Note: don't used GetLoadedFPID(); footprint name may have been edited
title = ( IsContentModified() ? "*" : "" )
+ FROM_UTF8( footprint->GetFPID().Format().c_str() ) + " "
+ ( writable ? wxS( "" ) : _( "[Read Only]" ) + wxS( " " ) ) + wxS( "\u2014 " );
if( IsContentModified() )
title = wxT( "*" );
title += FROM_UTF8( footprint->GetFPID().Format().c_str() );
if( !writable )
title += wxS( " " ) + _( "[Read Only]" );
}
else if( !fpid.GetLibItemName().empty() )
{
// Note: don't used GetLoadedFPID(); footprint name may have been edited
title = ( IsContentModified() ? "*" : "" )
+ FROM_UTF8( footprint->GetFPID().GetLibItemName().c_str() ) + " "
+ _( "[Unsaved]" ) + wxS( " \u2014 " );
if( IsContentModified() )
title = wxT( "*" );
title += FROM_UTF8( footprint->GetFPID().GetLibItemName().c_str() );
title += wxS( " " ) + _( "[Unsaved]" );
}
else
{
title = _( "[no footprint loaded]" );
}
title += _( "Footprint Editor" );
title += wxT( " \u2014 " ) + _( "Footprint Editor" );
SetTitle( title );
}

View File

@ -977,8 +977,7 @@ bool FOOTPRINT_VIEWER_FRAME::ShowModal( wxString* aFootprint, wxWindow* aParent
void FOOTPRINT_VIEWER_FRAME::Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle )
{
wxString title = wxString::Format( _( "3D Viewer" ) + wxT( " \u2014 %s" ),
getCurFootprintName() );
wxString title = _( "3D Viewer" ) + wxT( " \u2014 " ) + getCurFootprintName();
PCB_BASE_FRAME::Update3DView( aMarkDirty, aRefresh, &title );
}
@ -1013,16 +1012,19 @@ void FOOTPRINT_VIEWER_FRAME::UpdateTitle()
wxString title;
wxString path;
title.Printf( getCurNickname().IsEmpty() ? _( "no library selected" ) : getCurNickname() );
// Now, add the full path, for info
if( !getCurNickname().IsEmpty() )
{
title = getCurNickname();
FP_LIB_TABLE* libtable = Prj().PcbFootprintLibs();
const LIB_TABLE_ROW* row = libtable->FindRow( getCurNickname() );
if( row )
title << L" \u2014 " << row->GetFullURI( true );
title += wxT( " \u2014 " ) + row->GetFullURI( true );
}
else
{
title = _( "[no library selected]" );
}
title += wxT( " \u2014 " ) + _( "Footprint Library Browser" );

View File

@ -1245,11 +1245,19 @@ void PCB_EDIT_FRAME::UpdateTitle()
wxString title;
title = ( IsContentModified() ? "*" : "" )
+ fn.GetName() + " "
+ ( readOnly ? _( "[Read Only]" ) + wxS( " " ) : wxS( "" ) )
+ ( unsaved ? _( "[Unsaved]" ) + wxS( " " ) : wxS( "" ) )
+ wxT( "\u2014 " ) + _( "PCB Editor" );
if( IsContentModified() )
title = wxT( "*" );
title += fn.GetName();
if( readOnly )
title += wxS( " " ) + _( "[Read Only]" );
if( unsaved )
title += wxS( " " ) + _( "[Unsaved]" );
title += wxT( " \u2014 " ) + _( "PCB Editor" );
SetTitle( title );
}