minor (and old) bugs fixed.

minor changes in search paths for help and translation files.
This commit is contained in:
charras 2009-02-07 20:11:09 +00:00
parent 3a618567bb
commit 2075ac8476
4 changed files with 67 additions and 30 deletions

View File

@ -735,13 +735,9 @@ void WinEDA_App::SetLanguagePath( void )
for( i = 0; i < m_searchPaths.GetCount(); i++ )
{
wxFileName fn( m_searchPaths[i], wxEmptyString );
// Append path for Windows and unix kicad pack install
fn.AppendDir( wxT( "share" ) );
#ifndef __WXMSW__
/* Up on level relative to binary path with "share/kicad" appended
* for all other platforms. */
fn.AppendDir( wxT( "kicad" ) );
#endif
fn.AppendDir( wxT( "internat" ) );
if( fn.DirExists() )
{
@ -749,6 +745,18 @@ void WinEDA_App::SetLanguagePath( void )
fn.GetPath() );
wxLocale::AddCatalogLookupPathPrefix( fn.GetPath() );
}
fn.RemoveLastDir();
// Append path for unix standard install
fn.AppendDir( wxT( "kicad" ) );
fn.AppendDir( wxT( "internat" ) );
if( fn.DirExists() )
{
wxLogDebug( wxT( "Adding locale lookup path: " ) +
fn.GetPath() );
wxLocale::AddCatalogLookupPathPrefix( fn.GetPath() );
}
}
}
}
@ -854,20 +862,32 @@ wxString WinEDA_App::FindFileInSearchPaths( const wxString& filename,
wxString WinEDA_App::GetHelpFile( void )
{
wxString fn;
wxArrayString subdirs;
wxArrayString subdirs, altsubdirs;
/* FIXME: This is not the ideal way to handle this. Unfortunely, the
* CMake install paths seem to be a moving target so this crude
* hack solve the problem of install path differences between
* Windows and non-Windows platforms. */
#ifndef __WXMSW__
// Partially fixed, but must be enhanced
// Create subdir tree for "standard" linux distributions, when kicad comes from a distribution
// files are in /usr/share/doc/kicad/help
// and binaries in /usr/bin or /usr/local/bin
subdirs.Add( wxT( "share" ) );
#endif
subdirs.Add( _T( "doc" ) );
#ifndef __WXMSW__
subdirs.Add( wxT( "kicad" ) );
#endif
subdirs.Add( _T( "help" ) );
// Create subdir tree for linux and Windows kicad pack
// Note the pack form under linux is also useful if an user want to install kicad to a server.
// because there is only one path to mount or export (something like /usr/local/kicad).
// files are in <install dir>/kicad/doc/help
// (often /usr/local/kicad/kicad/doc/help)
// <install dir>/kicad/ is retrievered from m_BinDir
altsubdirs.Add( _T( "doc" ) );
altsubdirs.Add( _T( "help" ) );
/* Search for a help file.
* we *must* find a help file.
@ -879,22 +899,33 @@ wxString WinEDA_App::GetHelpFile( void )
// Step 1 : Try to find help file in help/<canonical name>
subdirs.Add( m_Locale->GetCanonicalName() );
fn = FindFileInSearchPaths( m_HelpFileName, &subdirs );
altsubdirs.Add( m_Locale->GetCanonicalName() );
fn = FindFileInSearchPaths( m_HelpFileName, &altsubdirs );
if( !fn )
fn = FindFileInSearchPaths( m_HelpFileName, &subdirs );
// Step 2 : if not found Try to find help file in help/<short name>
if( !fn )
{
subdirs.RemoveAt( subdirs.GetCount() - 1 );
altsubdirs.RemoveAt( altsubdirs.GetCount() - 1 );
subdirs.Add( m_Locale->GetName().BeforeLast( '_' ) ); // GetName( ) does not return always the short name
fn = FindFileInSearchPaths( m_HelpFileName, &subdirs );
altsubdirs.Add( m_Locale->GetName().BeforeLast( '_' ) ); // GetName( ) does not return always the short name
fn = FindFileInSearchPaths( m_HelpFileName, &altsubdirs );
if ( ! fn )
fn = FindFileInSearchPaths( m_HelpFileName, &subdirs );
}
// Step 3 : if not found Try to find help file in help/en
if( !fn )
{
subdirs.RemoveAt( subdirs.GetCount() - 1 );
altsubdirs.RemoveAt( altsubdirs.GetCount() - 1 );
subdirs.Add( _T( "en" ) );
fn = FindFileInSearchPaths( m_HelpFileName, &subdirs );
altsubdirs.Add( _T( "en" ) );
fn = FindFileInSearchPaths( m_HelpFileName, &altsubdirs );
if ( ! fn )
fn = FindFileInSearchPaths( m_HelpFileName, &subdirs );
}
return fn;
@ -918,7 +949,7 @@ wxString WinEDA_App::GetLibraryFile( const wxString& filename )
/**
* Run init scripts
* @return the defualt OnRun() value (exit codes not used in kicad, so value has no special mening)
* @return the default OnRun() value (exit codes not used in kicad, so value has no special mening)
*/
/**********************/
int WinEDA_App::OnRun()

View File

@ -361,7 +361,10 @@ wxString FullLibName,ShortLibName, Mask;
wxEmptyString, Mask,
wxFD_DEFAULT_STYLE | wxFD_MULTIPLE);
FilesDialog.ShowModal();
int diag = FilesDialog.ShowModal();
if ( diag != wxID_OK )
return;
wxArrayString Filenames;
FilesDialog.GetPaths(Filenames);
@ -372,7 +375,7 @@ wxString FullLibName,ShortLibName, Mask;
if ( ShortLibName.IsEmpty() ) //Just in case...
continue;
//Add or insert new library name
if (FindLibrary(ShortLibName) == NULL)
if ( g_LibName_List.Index(ShortLibName) == wxNOT_FOUND)
{
m_LibListChanged = TRUE;
g_LibName_List.Insert(ShortLibName, ii);

View File

@ -1,12 +1,12 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dialog_pcbnew_config.cpp
// Purpose:
// Purpose:
// Author: jean-pierre Charras
// Modified by:
// Modified by:
// Created: 18/02/2006 16:41:57
// RCS-ID:
// RCS-ID:
// Copyright: License GNU
// Licence:
// Licence:
/////////////////////////////////////////////////////////////////////////////
/* Handle the pcbnew libary config (library list, and default lib path)
@ -125,9 +125,9 @@ bool KiConfigPcbnewFrame::Create( wxWindow* parent, wxWindowID id, const wxStrin
*/
void KiConfigPcbnewFrame::CreateControls()
{
{
SetFont(*g_DialogFont);
////@begin KiConfigPcbnewFrame content construction
// Generated by DialogBlocks, 18/02/2006 17:19:54 (unregistered)
@ -208,15 +208,15 @@ void KiConfigPcbnewFrame::CreateControls()
wxString msg = _("Board ext: ") + PcbExtBuffer;
wxStaticText * text = new wxStaticText( itemDialog1, -1, msg, wxDefaultPosition, wxDefaultSize, 0 );
m_FileExtList->Add(text, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5);
msg = _("Cmp ext: ") + NetCmpExtBuffer;
text = new wxStaticText( itemDialog1, -1, msg, wxDefaultPosition, wxDefaultSize, 0 );
m_FileExtList->Add(text, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5);
msg = _("Lib ext: ") + LibExtBuffer;
text = new wxStaticText( itemDialog1, -1, msg, wxDefaultPosition, wxDefaultSize, 0 );
m_FileExtList->Add(text, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5);
msg = _("Net ext: ") + NetExtBuffer;
text = new wxStaticText( itemDialog1, -1, msg, wxDefaultPosition, wxDefaultSize, 0 );
m_FileExtList->Add(text, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5);
@ -360,10 +360,13 @@ wxString mask = wxT("*");
wxEmptyString, mask,
wxFD_DEFAULT_STYLE | wxFD_MULTIPLE);
FilesDialog.ShowModal();
int diag = FilesDialog.ShowModal();
if ( diag != wxID_OK )
return;
wxArrayString Filenames;
FilesDialog.GetPaths(Filenames);
for ( unsigned jj = 0; jj < Filenames.GetCount(); jj ++ )
{
fullfilename = Filenames[jj];

View File

@ -34,10 +34,10 @@ void WinEDA_PcbGridFrame::AcceptPcbOptions(wxCommandEvent& event)
m_Parent->GetScreen()->AddGrid( g_UserGrid, g_UserGrid_Unit, ID_POPUP_GRID_USER );
EndModal(1);
// If the user grid is the current selection , ensure grid size value = new user grid value
int ii = m_Parent->m_SelGridBox->GetSelection();
if ( ii == m_Parent->m_SelGridBox->GetCount() - 1 )
if ( ii == (int)(m_Parent->m_SelGridBox->GetCount() - 1) )
m_Parent->GetScreen()->SetGrid( ID_POPUP_GRID_USER );
m_Parent->DrawPanel->Refresh( TRUE );