Пример #1
0
void DebuggerTreeListCtrlBase::DoRefreshItemRecursively(IDebugger *dbgr, const wxTreeItemId &item, wxArrayString &itemsToRefresh)
{
    if(itemsToRefresh.IsEmpty())
        return;

    wxTreeItemIdValue cookieOne;
    wxTreeItemId exprItem = m_listTable->GetFirstChild(item, cookieOne);
    while( exprItem.IsOk() ) {

        DbgTreeItemData* data = static_cast<DbgTreeItemData*>(m_listTable->GetItemData(exprItem));
        if(data) {
            int where = itemsToRefresh.Index(data->_gdbId);
            if(where != wxNOT_FOUND) {
                dbgr->EvaluateVariableObject(data->_gdbId, m_DBG_USERR);
                m_gdbIdToTreeId[data->_gdbId] = exprItem;
                itemsToRefresh.RemoveAt((size_t)where);
            }
        }

        if(m_listTable->HasChildren(exprItem)) {
            DoRefreshItemRecursively(dbgr, exprItem, itemsToRefresh);
        }
        exprItem = m_listTable->GetNextChild(item, cookieOne);
    }
}
Пример #2
0
void SubversionView::DoAddNode(const wxString& title, int imgId, SvnTreeData::SvnNodeType nodeType, const wxArrayString& files)
{
	wxTreeItemId root = m_treeCtrl->GetRootItem();
	wxString basePath = m_textCtrlRootDir->GetValue();

	// Add the basic four root items
	if (files.IsEmpty() == false) {

		wxTreeItemId parent = m_treeCtrl->AppendItem(root, title, imgId, imgId, new SvnTreeData(nodeType, wxT("")));

		// Set the parent node with bold font
		wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
		font.SetWeight(wxBOLD);
		m_treeCtrl->SetItemFont(parent, font);

		// Add all children items
		for (size_t i=0; i<files.GetCount(); i++) {
			wxString filename(files.Item(i));
			m_treeCtrl->AppendItem(parent, files.Item(i), DoGetIconIndex(filename), DoGetIconIndex(filename), new SvnTreeData(SvnTreeData::SvnNodeTypeFile, files.Item(i)));
		}

		if ( nodeType != SvnTreeData::SvnNodeTypeUnversionedRoot) {
			m_treeCtrl->Expand(parent);
		}
	}
}
Пример #3
0
void PHPWorkspaceView::DoAddFilesToFolder(const wxArrayString& paths, PHPProject::Ptr_t pProject, bool notify)
{
    if(paths.IsEmpty()) return;

    CHECK_PTR_RET(pProject);

    wxString folder_path = PHPFolder::GetFolderPathFromFileFullPath(paths.Item(0), pProject->GetFilename().GetPath());
    wxTreeItemId folderItem =
        EnsureFolderExists(DoGetProjectItem(pProject->GetName()), folder_path, pProject->GetName());
    PHPFolder::Ptr_t pFolder = pProject->AddFolder(folder_path);
    CHECK_PTR_RET(pFolder);

    wxArrayString newPaths;
    for(size_t i = 0; i < paths.GetCount(); i++) {
        if(pFolder->AddFile(paths.Item(i))) {
            newPaths.Add(paths.Item(i));
        }
    }
    if(newPaths.IsEmpty()) return;

    if(notify) {
        DoAddFilesToTreeView(folderItem, pProject, pFolder, newPaths);
        // Notify the plugins
        clCommandEvent evtFilesAdded(wxEVT_PROJ_FILE_ADDED);
        evtFilesAdded.SetStrings(newPaths);
        EventNotifier::Get()->AddPendingEvent(evtFilesAdded);
    }
}
Пример #4
0
void PHPWorkspace::DoNotifyFilesRemoved(const wxArrayString& files)
{
    if(!files.IsEmpty()) {

        wxBusyInfo info(_("Updating workspace..."));
        wxYieldIfNeeded();
        EventNotifier::Get()->PostFileRemovedEvent(files);
    }
}
Пример #5
0
clSingleChoiceDialog::clSingleChoiceDialog(wxWindow* parent, const wxArrayString& options, int initialSelection)
    : clSingleChoiceDialogBase(parent)
{
    if(!options.IsEmpty()) {
        m_listBox->Append(options);
        if(initialSelection >= 0 && initialSelection < (int)options.size()) {
            m_listBox->Select(initialSelection);
        }
    }
    CenterOnParent();
}
Пример #6
0
void myFindReplaceDlg::LoadDirHistory () {
    if (!m_finddirHist.IsEmpty()) return;
    wxConfig *cfg = new wxConfig (g_appname);
    wxString group = FINDREPLACEDLG + _T("/") + DIRECTORYHISTORY;
    wxString key;
    wxString value;
    int i;
    for (i = 0; i < MAXHISTORY; ++i) {
        key = group + wxString::Format (_T("%d"), i);
        if (cfg->Read (key, &value)) m_finddirHist.Add (value);
    }
    delete cfg;
}
Пример #7
0
SvnCommitDialog::SvnCommitDialog(wxWindow* parent, const wxArrayString &paths, const wxString &url, Subversion2 *plugin, const wxString &repoPath)
    : SvnCommitDialogBaseClass(parent)
    , m_plugin(plugin)
    , m_url(url)
    , m_repoPath(repoPath)
    , m_process(NULL)
{
    m_stcDiff->SetReadOnly(true);
    wxString title = GetTitle();
    title << wxT(" - ") << url;
    SetTitle(title);

    for (size_t i=0; i<paths.GetCount(); i++) {
        int index = m_checkListFiles->Append(paths.Item(i));
        m_checkListFiles->Check((unsigned int)index);
    }

    wxArrayString lastMessages, previews;
    m_plugin->GetCommitMessagesCache().GetMessages(lastMessages, previews);

    for(size_t i=0; i<previews.GetCount(); i++) {
        m_choiceMessages->Append(previews.Item(i), new CommitMessageStringData(lastMessages.Item(i)));
    }
    
    if ( !paths.IsEmpty() ) {
        m_checkListFiles->Select(0);
        DoShowDiff(0);
    }
    
    WindowAttrManager::Load(this, wxT("SvnCommitDialog"), m_plugin->GetManager()->GetConfigTool());
    int sashPos = m_plugin->GetSettings().GetCommitDlgSashPos();
    if ( sashPos != wxNOT_FOUND ) {
        m_splitterH->SetSashPosition(sashPos);
    }
    
    int sashHPos = m_plugin->GetSettings().GetCommitDlgHSashPos();
    if ( sashHPos != wxNOT_FOUND ) {
        m_splitterV->SetSashPosition(sashHPos);
    }
    
    LexerConfPtr diffLexer = EditorConfigST::Get()->GetLexer("Diff");
    if ( diffLexer ) {
        m_stcDiff->SetLexer(wxSTC_LEX_DIFF);
        diffLexer->Apply( m_stcDiff );
    }
    
    LexerConfPtr textLexer = EditorConfigST::Get()->GetLexer("text");
    if ( textLexer ) {
        textLexer->Apply( m_stcMessage );
    }
}
Пример #8
0
SvnCommitDialog::SvnCommitDialog(
    wxWindow* parent, const wxArrayString& paths, const wxString& url, Subversion2* plugin, const wxString& repoPath)
    : SvnCommitDialogBaseClass(parent)
    , m_plugin(plugin)
    , m_url(url)
    , m_repoPath(repoPath)
    , m_process(NULL)
{
    Bind(wxEVT_ASYNC_PROCESS_OUTPUT, &SvnCommitDialog::OnProcessOutput, this);
    Bind(wxEVT_ASYNC_PROCESS_TERMINATED, &SvnCommitDialog::OnProcessTerminatd, this);

    m_stcDiff->SetReadOnly(true);
    wxString title = GetTitle();
    title << wxT(" - ") << url;
    SetTitle(title);

    for(size_t i = 0; i < paths.GetCount(); i++) {
        int index = m_checkListFiles->Append(paths.Item(i));
        m_checkListFiles->Check((unsigned int)index);
    }

    if(!paths.IsEmpty()) {
        m_checkListFiles->Select(0);
        DoShowDiff(0);
    }

    SetName("SvnCommitDialog");
    WindowAttrManager::Load(this);
    int sashPos = m_plugin->GetSettings().GetCommitDlgSashPos();
    if(sashPos != wxNOT_FOUND) {
        m_splitterH->SetSashPosition(sashPos);
    }

    int sashHPos = m_plugin->GetSettings().GetCommitDlgHSashPos();
    if(sashHPos != wxNOT_FOUND) {
        m_splitterV->SetSashPosition(sashHPos);
    }

    LexerConf::Ptr_t diffLexer = EditorConfigST::Get()->GetLexer("Diff");
    if(diffLexer) {
        m_stcDiff->SetLexer(wxSTC_LEX_DIFF);
        diffLexer->Apply(m_stcDiff);
    }

    LexerConf::Ptr_t textLexer = EditorConfigST::Get()->GetLexer("text");
    if(textLexer) {
        textLexer->Apply(m_stcMessage);
    }
}
Пример #9
0
bool NetDebugReport::OnServerReply( const wxArrayString& reply )
{
	if ( reply.IsEmpty() ) {
		wxLogError( _T( "Didn't receive the expected server reply." ) );
		return false;
	}

	wxString s( _T( "Server replied:\n" ) );
	const size_t count = reply.GetCount();
	for ( size_t n = 0; n < count; n++ ) {
		s << _T( '\t' ) << reply[n] << _T( '\n' );
	}

	wxLogMessage( _T( "%s" ), s.c_str() );
	return true;
}
Пример #10
0
wxString
join(const wxString &pattern,
     wxArrayString const &strings) {
  wxString dst;
  uint32_t i;

  if (strings.IsEmpty())
    return wxEmptyString;
  dst = strings[0];
  for (i = 1; strings.Count() > i; ++i) {
    dst += pattern;
    dst += strings[i];
  }

  return dst;
}
Пример #11
0
bool GitCommitListDlg::IsMatchFilter(const wxArrayString& filters, const wxArrayString& columns)
{
    if(filters.IsEmpty()) return true;

    bool match = true;
    for(size_t i = 0; i < filters.GetCount() && match; ++i) {
        wxString filter = filters.Item(i).Lower();
        wxString col1, col2, col3, col4;
        col1 = columns.Item(0).Lower();
        col2 = columns.Item(1).Lower();
        col3 = columns.Item(2).Lower();
        col4 = columns.Item(3).Lower();
        match = (col1.Contains(filter) || col2.Contains(filter) || col3.Contains(filter) || col4.Contains(filter));
    }
    return match;
}
bool CslGameRedEclipse::GetMapImagePaths(wxArrayString& paths) const
{
    wxInt32 pos;
    wxString path;

    if (!m_clientSettings.GamePath.IsEmpty())
    {
        path<<m_clientSettings.GamePath<<wxT("data")<<PATHDIV<<wxT("maps")<<PATHDIV;
        paths.Add(path);
    }

    //TODO look for extra package directories
    if ((pos=m_clientSettings.Options.Find(wxT("-k")))!=wxNOT_FOUND)
    {
    }

    return !paths.IsEmpty();
}
Пример #13
0
void PHPProject::FilesDeleted(const wxArrayString& files, bool notify)
{
    if(files.IsEmpty()) return;

    // Normalize the folder name by using wxFileName
    for(size_t i=0; i<files.GetCount(); ++i) {
        int where = m_files.Index(files.Item(i));
        if(where != wxNOT_FOUND) {
            m_files.RemoveAt(where);
        }
    }
    
    if(notify) {
        clCommandEvent event(wxEVT_PROJ_FILE_REMOVED);
        event.SetStrings(files);
        EventNotifier::Get()->AddPendingEvent(event);
    }
}
Пример #14
0
bool FileUtils::WildMatch(const wxArrayString& masks, const wxString& filename)
{
    if(masks.IsEmpty()) { return false; }

    if(masks.Index("*") != wxNOT_FOUND) {
        // If one of the masks is plain "*" - we match everything
        return true;
    }

    for(size_t i = 0; i < masks.size(); ++i) {
        const wxString& pattern = masks.Item(i);
        if((!pattern.Contains("*") && filename == pattern) ||
           (pattern.Contains("*") && ::wxMatchWild(pattern, filename))) {
            // use exact match
            return true;
        }
    }
    return false;
}
Пример #15
0
static bool projectinfo_match(const wxString& path, const wxArrayString& includes, const wxArrayString& excludes) {
	if (!includes.IsEmpty()) {
		bool doInclude = false;
		for (unsigned int i = 0; i < includes.GetCount(); ++i) {
			if (wxMatchWild(includes[i], path, false)) {
				doInclude = true;
				break;
			}
		}

		if (!doInclude) return false;
	}

	for (unsigned int i = 0; i < excludes.GetCount(); ++i) {
		if (wxMatchWild(excludes[i], path, false)) {
			return false;
		}
	}

	return true;
}
Пример #16
0
void CodeCompletionManager::CompileCommandsFileProcessed(const wxArrayString& includePaths)
{
    if(m_compileCommandsThread) {
        m_compileCommandsThread->join();
        wxDELETE(m_compileCommandsThread);
    }
    if(includePaths.IsEmpty()) { return; }

    // Update the parser search paths
    wxArrayString inc, exc;
    ParseThreadST::Get()->GetSearchPaths(inc, exc);
    for(size_t i = 0; i < includePaths.size(); ++i) {
        if(inc.Index(includePaths.Item(i)) == wxNOT_FOUND) { inc.Add(includePaths.Item(i)); }
    }
    ParseThreadST::Get()->SetSearchPaths(inc, exc);
    clDEBUG() << "Parser thread search paths are now updated to:" << inc;

    // Trigger a quick parse
    wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, XRCID("retag_workspace"));
    clMainFrame::Get()->GetEventHandler()->AddPendingEvent(event);
}
Пример #17
0
void wxHandheldInstallCtrl::InsertDirectoryDestinations( wxArrayString& directories )
{
    if ( directories.IsEmpty() ) 
    {
        return;
    }
    // Insert by rows, starting at index zero. Achieve by getting number
    // of items in listctrl.
    int rowToInsert;
    
    // Insert them
    for ( size_t n = 0; n < directories.GetCount(); n++ ) 
    {
        rowToInsert =  m_directoriesListCtrl->GetItemCount();
        // Only insert it if the directoryname already exists in the list 
        // -1 starts from start, looks for string, and returns -1 if not found
        if ( m_directoriesListCtrl->FindItem(-1, directories[n]) == -1 )
        {
            m_directoriesListCtrl->InsertItem(rowToInsert, directories[n], m_directoriesListCtrlImageId);
        }
    }
}
Пример #18
0
bool wxHandheldInstallCtrl::InstallFilesToDestinations( wxArrayString& install_fullnames )
{
    if ( install_fullnames.IsEmpty() )
    {
        return false;
    }

    // We will clear this array later with WX_CLEAR_ARRAY macro
    handheld_dest_array_type handheld_dest_array;    
    wxArrayString directory_destinations;

    GetUserDestinations( handheld_dest_array );
    GetDirectoryDestinations( directory_destinations );    

    for ( int n=0; n < (int)handheld_dest_array.GetCount(); n++ )
    {
        wxLogDebug( wxT( "user_array index is %d" ), n );          
        m_palmInstaller->install_files_by_handheld_dest( *handheld_dest_array.Item( n ),
                                                         install_fullnames );
    }

    for ( int i=0; i < (int)directory_destinations.GetCount(); i++ ) 
    {
        wxLogDebug( wxT( "directory_array index is %d" ), i );
        m_palmInstaller->install_files_by_directory( directory_destinations.Item( i ),
                                                     install_fullnames );
    }

    // The WX_CLEAR_ARRAY(array) macro [see dynarray.h] is required to clear out all the 
    // elements from memory of an array of structs that was built with WX_DEFINE_ARRAY.
    // All that this macro does is just to loop through the array, "delete" each element
    // to free it from memory, then mark the array as Empty().
    WX_CLEAR_ARRAY( handheld_dest_array );
    directory_destinations.Clear();
  
    return true;
}
Пример #19
0
void ProcessingDlg::CheckFilter(
    const wxString& OldBasePath,
    const wxStringStringMap& OldVars,
    const wxArrayString& OldCompilers,
    const LibraryDetectionConfig* Config,
    const LibraryDetectionConfigSet* Set,
    int WhichFilter)
{
    if ( (int)Config->Filters.size() <= WhichFilter )
    {
        FoundLibrary(OldBasePath,OldVars,OldCompilers,Config,Set);
        return;
    }

    const LibraryDetectionFilter& Filter = Config->Filters[WhichFilter];

    switch ( Filter.Type )
    {
        case LibraryDetectionFilter::File:
        {
            // Split path
            wxArrayString Pattern;
            SplitPath(Filter.Value,Pattern);

            // Fetch list of files with filename matching last pattern's element
            const wxArrayString& PathArray = Map[Pattern[Pattern.Count()-1]];
            if ( PathArray.empty() ) return;

            // Process those files
            for ( size_t i=0; i<PathArray.Count(); i++ )
            {
                wxArrayString Path;
                wxStringStringMap Vars = OldVars;
                SplitPath(PathArray[i],Path);

                int path_index = (int)Path.Count() - 1;
                int pattern_index = (int)Pattern.Count() - 1;

                // Check if patterns do match
                while ( ( path_index >= 0 ) && ( pattern_index >= 0 ) )
                {
                    wxString& PatternPart = Pattern[pattern_index];
                    if ( IsVariable(PatternPart) )
                    {
                        wxString VarName = PatternPart.Mid(3,PatternPart.Len()-4);
                        if ( Vars[VarName].empty() )
                        {
                            Vars[VarName] = Path[path_index];
                        }
                        else
                        {
                            if ( Vars[VarName] != Path[path_index] ) break;
                        }
                    }
                    else
                    {
                        if ( PatternPart != Path[path_index] ) break;
                    }
                    path_index--;
                    pattern_index--;
                }

                // This is when patterns did not match
                if ( pattern_index >= 0 ) continue;

                // Construct base path from the rest of file's name
                wxString BasePath;
                for ( int j=0; j<=path_index; j++ )
                {
                    BasePath += Path[j] + wxFileName::GetPathSeparator();
                }

                // And check if base path match the previous one
                if ( !OldBasePath.IsEmpty() )
                {
                    if ( BasePath != OldBasePath ) continue;
                }

                // Ok, this filter matches, let's advance to next filet
                CheckFilter(BasePath,Vars,OldCompilers,Config,Set,WhichFilter+1);
            }
            break;
        }

        case LibraryDetectionFilter::Platform:
        {
            wxStringTokenizer Tokenizer(Filter.Value,_T("| \t"));
            bool IsPlatform = false;
            while ( Tokenizer.HasMoreTokens() )
            {
                wxString Platform = Tokenizer.GetNextToken();

                if ( platform::windows )
                {
                    if ( Platform==_T("win") || Platform==_T("windows") )
                    {
                        IsPlatform = true;
                        break;
                    }
                }

                if ( platform::macosx )
                {
                    if ( Platform==_T("mac") || Platform==_T("macosx") )
                    {
                        IsPlatform = true;
                        break;
                    }
                }

                if ( platform::linux )
                {
                    if ( Platform==_T("lin") || Platform==_T("linux") )
                    {
                        IsPlatform = true;
                        break;
                    }
                }

                if ( platform::freebsd )
                {
                    if ( Platform==_T("bsd") || Platform==_T("freebsd") )
                    {
                        IsPlatform = true;
                        break;
                    }
                }

                if ( platform::netbsd )
                {
                    if ( Platform==_T("bsd") || Platform==_T("netbsd") )
                    {
                        IsPlatform = true;
                        break;
                    }
                }

                if ( platform::openbsd )
                {
                    if ( Platform==_T("bsd") || Platform==_T("openbsd") )
                    {
                        IsPlatform = true;
                        break;
                    }
                }

                if ( platform::darwin )
                {
                    if ( Platform==_T("darwin") )
                    {
                        IsPlatform = true;
                        break;
                    }
                }

                if ( platform::solaris )
                {
                    if ( Platform==_T("solaris") )
                    {
                        IsPlatform = true;
                        break;
                    }
                }

                if ( platform::unix )
                {
                    if ( Platform==_T("unix") || Platform==_T("un*x") )
                    {
                        IsPlatform = true;
                        break;
                    }
                }
            }

            if ( IsPlatform )
            {
                CheckFilter(OldBasePath,OldVars,OldCompilers,Config,Set,WhichFilter+1);
            }
            break;
        }

        case LibraryDetectionFilter::Exec:
        {
            bool IsExec = false;
            if ( wxIsAbsolutePath(Filter.Value) )
            {
                // If this is absolute path, we don't search in PATH evironment var
                IsExec = wxFileName::IsFileExecutable(Filter.Value);
            }
            else
            {
                // Let's search for the name in search paths
                wxString Path;
                if ( wxGetEnv(_T("PATH"),&Path) )
                {
                    wxString Splitter = _T(":");
                    if ( platform::windows ) Splitter = _T(";");
                    wxStringTokenizer Tokenizer(Path,Splitter);
                    while ( Tokenizer.HasMoreTokens() )
                    {
                        wxString OnePath = Tokenizer.GetNextToken();

                        // Let's skip relative paths (f.ex. ".")
                        if ( !wxIsAbsolutePath(OnePath) ) continue;

                        OnePath += wxFileName::GetPathSeparator()+Filter.Value;
                        if ( wxFileName::IsFileExecutable(OnePath) )
                        {
                            IsExec = true;
                            break;
                        }
                    }
                }
            }

            if ( IsExec )
            {
                CheckFilter(OldBasePath,OldVars,OldCompilers,Config,Set,WhichFilter+1);
            }
            break;
        }

        case LibraryDetectionFilter::PkgConfig:
        {
            if ( m_KnownResults[rtPkgConfig].IsShortCode(Filter.Value) )
            {
                CheckFilter(OldBasePath,OldVars,OldCompilers,Config,Set,WhichFilter+1);
            }
            break;
        }

        case LibraryDetectionFilter::Compiler:
        {
            if ( OldCompilers.IsEmpty() )
            {
                // If this is the first compiler filter, let's build new list and continue
                CheckFilter(OldBasePath,OldVars,wxStringTokenize(Filter.Value,_T("| \t")),Config,Set,WhichFilter+1);
            }
            else
            {
                // We've set compiler list before, leave only the intersection
                // of previous and current list
                wxArrayString Compilers;
                wxStringTokenizer Tokenizer(Filter.Value,_T("| \t"));
                while ( Tokenizer.HasMoreTokens() )
                {
                    wxString Comp = Tokenizer.GetNextToken();
                    if ( OldCompilers.Index(Comp) != wxNOT_FOUND )
                    {
                        Compilers.Add(Comp);
                    }
                }

                if ( !Compilers.IsEmpty() )
                {
                    CheckFilter(OldBasePath,OldVars,Compilers,Config,Set,WhichFilter+1);
                }
            }
            break;
        }

        case LibraryDetectionFilter::None:
        {
            CheckFilter(OldBasePath,OldVars,OldCompilers,Config,Set,WhichFilter+1);
            break;
        }
    }
}
Пример #20
0
int WXDLLIMPEXP_BASE wxParseCommonDialogsFilter(const wxString& filterStr,
                                           wxArrayString& descriptions,
                                           wxArrayString& filters)
{
    descriptions.Clear();
    filters.Clear();

    wxString str(filterStr);

    wxString description, filter;
    int pos = 0;
    while( pos != wxNOT_FOUND )
    {
        pos = str.Find(wxT('|'));
        if ( pos == wxNOT_FOUND )
        {
            // if there are no '|'s at all in the string just take the entire
            // string as filter and make description empty for later autocompletion
            if ( filters.IsEmpty() )
            {
                descriptions.Add(wxEmptyString);
                filters.Add(filterStr);
            }
            else
            {
                wxFAIL_MSG( wxT("missing '|' in the wildcard string!") );
            }

            break;
        }

        description = str.Left(pos);
        str = str.Mid(pos + 1);
        pos = str.Find(wxT('|'));
        if ( pos == wxNOT_FOUND )
        {
            filter = str;
        }
        else
        {
            filter = str.Left(pos);
            str = str.Mid(pos + 1);
        }

        descriptions.Add(description);
        filters.Add(filter);
    }

#if defined(__WXMOTIF__)
    // split it so there is one wildcard per entry
    for( size_t i = 0 ; i < descriptions.GetCount() ; i++ )
    {
        pos = filters[i].Find(wxT(';'));
        if (pos != wxNOT_FOUND)
        {
            // first split only filters
            descriptions.Insert(descriptions[i],i+1);
            filters.Insert(filters[i].Mid(pos+1),i+1);
            filters[i]=filters[i].Left(pos);

            // autoreplace new filter in description with pattern:
            //     C/C++ Files(*.cpp;*.c;*.h)|*.cpp;*.c;*.h
            // cause split into:
            //     C/C++ Files(*.cpp)|*.cpp
            //     C/C++ Files(*.c;*.h)|*.c;*.h
            // and next iteration cause another split into:
            //     C/C++ Files(*.cpp)|*.cpp
            //     C/C++ Files(*.c)|*.c
            //     C/C++ Files(*.h)|*.h
            for ( size_t k=i;k<i+2;k++ )
            {
                pos = descriptions[k].Find(filters[k]);
                if (pos != wxNOT_FOUND)
                {
                    wxString before = descriptions[k].Left(pos);
                    wxString after = descriptions[k].Mid(pos+filters[k].Len());
                    pos = before.Find(wxT('('),true);
                    if (pos>before.Find(wxT(')'),true))
                    {
                        before = before.Left(pos+1);
                        before << filters[k];
                        pos = after.Find(wxT(')'));
                        int pos1 = after.Find(wxT('('));
                        if (pos != wxNOT_FOUND && (pos<pos1 || pos1==wxNOT_FOUND))
                        {
                            before << after.Mid(pos);
                            descriptions[k] = before;
                        }
                    }
                }
            }
        }
    }
#endif

    // autocompletion
    for( size_t j = 0 ; j < descriptions.GetCount() ; j++ )
    {
        if ( descriptions[j].empty() && !filters[j].empty() )
        {
            descriptions[j].Printf(_("Files (%s)"), filters[j].c_str());
        }
    }

    return filters.GetCount();
}
Пример #21
0
void PluginManager::Load()
{
    wxString ext;
#if defined(__WXGTK__)
    ext = wxT("so");

#elif defined(__WXMAC__)
    ext = wxT("dylib");

#else
    ext = wxT("dll");
#endif

    wxString fileSpec(wxT("*.") + ext);
    clConfig conf("plugins.conf");

    conf.ReadItem(&m_pluginsData);

    // set the managers
    // this code assures us that the shared objects will see the same instances as the application
    // does
    LanguageST::Get()->SetTagsManager(GetTagsManager());
    TagsManagerST::Get()->SetLanguage(LanguageST::Get());

    // Plugin loading policy
    CodeLiteApp* app = static_cast<CodeLiteApp*>(GetTheApp());
    CodeLiteApp::PluginPolicy pp = app->GetPluginLoadPolicy();
    wxArrayString allowedPlugins;
    if(pp == CodeLiteApp::PP_None) {
        return;
    }

    else if(pp == CodeLiteApp::PP_FromList)
        allowedPlugins = app->GetAllowedPlugins();

    wxString pluginsDir = clStandardPaths::Get().GetPluginsDirectory();
    if(wxDir::Exists(pluginsDir)) {
        // get list of dlls
        wxArrayString files;
        wxDir::GetAllFiles(pluginsDir, &files, fileSpec, wxDIR_FILES);

        // Sort the plugins by A-Z
        std::sort(files.begin(), files.end());
        for(size_t i = 0; i < files.GetCount(); i++) {

            wxString fileName(files.Item(i));
#if defined(__WXMSW__) && !defined(NDEBUG)

            // Under MSW loading a release plugin while in debug mode will cause a crash
            if(!fileName.EndsWith("-dbg.dll")) {
                continue;
            }
#elif defined(__WXMSW__)

            // filter debug plugins
            if(fileName.EndsWith("-dbg.dll")) {
                continue;
            }
#endif

#ifdef __WXGTK__
            wxFileName fnDLL(fileName);
            if(fnDLL.GetFullName().StartsWith("lib")) {
                // don't attempt to load a library
                continue;
            }
#endif

            clDynamicLibrary* dl = new clDynamicLibrary();
            if(!dl->Load(fileName)) {
                CL_ERROR(wxT("Failed to load plugin's dll: ") + fileName);
                if(!dl->GetError().IsEmpty()) {
                    CL_ERROR(dl->GetError());
                }
                continue;
            }

            bool success(false);
            GET_PLUGIN_INFO_FUNC pfnGetPluginInfo = (GET_PLUGIN_INFO_FUNC)dl->GetSymbol(wxT("GetPluginInfo"), &success);
            if(!success) {
                continue;
            }

            // load the plugin version method
            // if the methods does not exist, handle it as if it has value of 100 (lowest version API)
            int interface_version(100);
            GET_PLUGIN_INTERFACE_VERSION_FUNC pfnInterfaceVersion =
                (GET_PLUGIN_INTERFACE_VERSION_FUNC)dl->GetSymbol(wxT("GetPluginInterfaceVersion"), &success);
            if(success) {
                interface_version = pfnInterfaceVersion();
            } else {
                CL_WARNING(wxT("Failed to find GetPluginInterfaceVersion() in dll: ") + fileName);
                if(!dl->GetError().IsEmpty()) {
                    CL_WARNING(dl->GetError());
                }
            }

            if(interface_version != PLUGIN_INTERFACE_VERSION) {
                CL_WARNING(wxString::Format(wxT("Version interface mismatch error for plugin '%s'. Plugin's interface "
                                                "version is '%d', CodeLite interface version is '%d'"),
                                            fileName.c_str(),
                                            interface_version,
                                            PLUGIN_INTERFACE_VERSION));
                continue;
            }

            // Check if this dll can be loaded
            PluginInfo pluginInfo = pfnGetPluginInfo();

            wxString pname = pluginInfo.GetName();
            pname.MakeLower().Trim().Trim(false);

            // Check the policy
            if(pp == CodeLiteApp::PP_FromList && allowedPlugins.Index(pname) == wxNOT_FOUND) {
                // Policy is set to 'from list' and this plugin does not match any plugins from
                // the list, don't allow it to be loaded
                continue;
            }

            // Add the plugin information
            m_pluginsData.AddPlugin(pluginInfo);

            // Can we load it?
            if(!m_pluginsData.CanLoad(pluginInfo.GetName())) {
                CL_WARNING(wxT("Plugin ") + pluginInfo.GetName() + wxT(" is not enabled"));
                continue;
            }

            // try and load the plugin
            GET_PLUGIN_CREATE_FUNC pfn = (GET_PLUGIN_CREATE_FUNC)dl->GetSymbol(wxT("CreatePlugin"), &success);
            if(!success) {
                CL_WARNING(wxT("Failed to find CreatePlugin() in dll: ") + fileName);
                if(!dl->GetError().IsEmpty()) {
                    CL_WARNING(dl->GetError());
                }

                m_pluginsData.DisablePlugin(pluginInfo.GetName());
                continue;
            }

            // Construct the plugin
            IPlugin* plugin = pfn((IManager*)this);
            CL_DEBUG(wxT("Loaded plugin: ") + plugin->GetLongName());
            m_plugins[plugin->GetShortName()] = plugin;

            // Load the toolbar
            clToolBar* tb = plugin->CreateToolBar((wxWindow*)clMainFrame::Get());
            if(tb) {
#if USE_AUI_TOOLBAR
                // When using AUI toolbars, use our own custom art-provider
                tb->SetArtProvider(new CLMainAuiTBArt());
#endif
                clMainFrame::Get()->GetDockingManager().AddPane(tb,
                                                                wxAuiPaneInfo()
                                                                    .Name(plugin->GetShortName())
                                                                    .LeftDockable(true)
                                                                    .RightDockable(true)
                                                                    .Caption(plugin->GetShortName())
                                                                    .ToolbarPane()
                                                                    .Top()
                                                                    .Row(0));

                // Add menu entry at the 'View->Toolbars' menu for this toolbar
                wxMenuItem* item = clMainFrame::Get()->GetMenuBar()->FindItem(XRCID("toolbars_menu"));
                if(item) {
                    wxMenu* submenu = NULL;
                    submenu = item->GetSubMenu();
                    // add the new toolbar entry at the end of this menu

                    int id = wxNewId();
                    wxString text(plugin->GetShortName());
                    text << _(" ToolBar");
                    wxMenuItem* newItem = new wxMenuItem(submenu, id, text, wxEmptyString, wxITEM_CHECK);
                    submenu->Append(newItem);
                    clMainFrame::Get()->RegisterToolbar(id, plugin->GetShortName());
                }
            }

            // Keep the dynamic load library
            m_dl.push_back(dl);
        }
        clMainFrame::Get()->GetDockingManager().Update();

        // Let the plugins plug their menu in the 'Plugins' menu at the menu bar
        // the create menu will be placed as a sub menu of the 'Plugin' menu
        wxMenu* pluginsMenu = NULL;
        wxMenuItem* menuitem = clMainFrame::Get()->GetMenuBar()->FindItem(XRCID("manage_plugins"), &pluginsMenu);
        if(pluginsMenu && menuitem) {
            std::map<wxString, IPlugin*>::iterator iter = m_plugins.begin();
            for(; iter != m_plugins.end(); ++iter) {
                IPlugin* plugin = iter->second;
                plugin->CreatePluginMenu(pluginsMenu);
            }
        }

        // save the plugins data
        conf.WriteItem(&m_pluginsData);
    }

    // Now that all the plugins are loaded, load from the configuration file
    // list of visible tabs
    static wxArrayString DefaultArray;
    if(DefaultArray.IsEmpty()) {
        DefaultArray.Add("NOT-FOUND");
    }
    {
        const wxArrayString& tabs = GetWorkspaceTabs();
        wxArrayString visibleTabs = clConfig::Get().Read("VisibleWorkspaceTabs", DefaultArray);
        if(!((visibleTabs.size() == 1) && (visibleTabs.Item(0) == "NOT-FOUND"))) {
            for(size_t i = 0; i < tabs.size(); ++i) {
                if(visibleTabs.Index(tabs.Item(i)) == wxNOT_FOUND) {
                    // hidden tab - post an event
                    clCommandEvent eventHide(wxEVT_SHOW_WORKSPACE_TAB);
                    eventHide.SetSelected(false).SetString(tabs.Item(i));
                    EventNotifier::Get()->AddPendingEvent(eventHide);
                }
            }
        }
    }

    {
        const wxArrayString& tabs = GetOutputTabs();
        wxArrayString visibleTabs = clConfig::Get().Read("VisibleOutputTabs", DefaultArray);
        if(!((visibleTabs.size() == 1) && (visibleTabs.Item(0) == "NOT-FOUND"))) {
            for(size_t i = 0; i < tabs.size(); ++i) {
                if(visibleTabs.Index(tabs.Item(i)) == wxNOT_FOUND) {
                    // hidden tab - post an event
                    clCommandEvent eventHide(wxEVT_SHOW_OUTPUT_TAB);
                    eventHide.SetSelected(false).SetString(tabs.Item(i));
                    EventNotifier::Get()->AddPendingEvent(eventHide);
                }
            }
        }
    }
}
Пример #22
0
void BuildLineInfo::NormalizeFilename(const wxArrayString& directories, const wxString &cygwinPath)
{
    wxFileName fn(this->GetFilename());

    if(fn.IsAbsolute()) {
        SetFilename( fn.GetFullPath() );
        return;
        
    } else if ( fn.IsAbsolute(wxPATH_UNIX) && IS_WINDOWS && !cygwinPath.IsEmpty()) {
        
        wxFileName cygfile(fn);
        wxString path = cygwinPath + cygfile.GetFullPath();
        SetFilename(wxFileName(path).GetFullPath());
        return;
        
    }

    if(directories.IsEmpty()) {
        SetFilename(fn.GetFullName());
        return;
    }
    
    // we got a relative file name
    int dircount = directories.GetCount();
    for(int i=dircount-1; i>=0; --i) {
        wxFileName tmp = fn;
        if( tmp.Normalize(wxPATH_NORM_ALL & ~wxPATH_NORM_LONG) ) {
            // Windows sanity
            if ( IS_WINDOWS && tmp.GetVolume().length() > 1 ) {
                // Invalid file path
                SetFilename("");
                return;
            }
            
            if ( tmp.FileExists() && tmp.MakeAbsolute(directories.Item(i))) {
                SetFilename( tmp.GetFullPath() );
                return;
            }
        }
    }

    // One more try: the above will fail if the project isn't stored in the cwd that Normalize() assumes
    // So see if one of 'directories' is the correct path to use
    for(int i=dircount-1; i>=0; --i) {
        wxFileName tmp = fn;
        if( tmp.Normalize(wxPATH_NORM_ALL & ~wxPATH_NORM_LONG, directories.Item(i)) ) {
            // Windows sanity
            if ( IS_WINDOWS && tmp.GetVolume().length() > 1 ) {
                // Invalid file path
                SetFilename("");
                return;
            }

            if ( tmp.FileExists()) {
                SetFilename( tmp.GetFullPath() );
                return;
            }
        }
    }

    // failed.. keep it as fullname only
    SetFilename(fn.GetFullName());
}
Пример #23
0
void PHPFolder::DoNotifyFilesRemoved(const wxArrayString& files)
{
    if(!files.IsEmpty()) {
        EventNotifier::Get()->PostFileRemovedEvent(files);
    }
}
Пример #24
0
bool CFilterConditionsDialog::CreateListControl(int conditions /*=common*/)
{
	wxScrolledWindow* wnd = XRCCTRL(*this, "ID_CONDITIONS", wxScrolledWindow);
	if (!wnd)
		return false;

	m_pListCtrl = new wxCustomHeightListCtrl(this, wxID_ANY, wxDefaultPosition, wnd->GetSize(), wxVSCROLL|wxSUNKEN_BORDER|wxTAB_TRAVERSAL);
	if (!m_pListCtrl)
		return false;
	m_pListCtrl->AllowSelection(false);
	ReplaceControl(wnd, m_pListCtrl);
	CalcMinListWidth();

	if (stringConditionTypes.IsEmpty())
	{
		stringConditionTypes.Add(_("contains"));
		stringConditionTypes.Add(_("is equal to"));
		stringConditionTypes.Add(_("begins with"));
		stringConditionTypes.Add(_("ends with"));
		stringConditionTypes.Add(_("matches regex"));
		stringConditionTypes.Add(_("does not contain"));

		sizeConditionTypes.Add(_("greater than"));
		sizeConditionTypes.Add(_("equals"));
		sizeConditionTypes.Add(_("does not equal"));
		sizeConditionTypes.Add(_("less than"));

		attributeSetTypes.Add(_("is set"));
		attributeSetTypes.Add(_("is unset"));

		attributeConditionTypes.Add(_("Archive"));
		attributeConditionTypes.Add(_("Compressed"));
		attributeConditionTypes.Add(_("Encrypted"));
		attributeConditionTypes.Add(_("Hidden"));
		attributeConditionTypes.Add(_("Read-only"));
		attributeConditionTypes.Add(_("System"));

		permissionConditionTypes.Add(_("owner readable"));
		permissionConditionTypes.Add(_("owner writeable"));
		permissionConditionTypes.Add(_("owner executable"));
		permissionConditionTypes.Add(_("group readable"));
		permissionConditionTypes.Add(_("group writeable"));
		permissionConditionTypes.Add(_("group executable"));
		permissionConditionTypes.Add(_("world readable"));
		permissionConditionTypes.Add(_("world writeable"));
		permissionConditionTypes.Add(_("world executable"));

		dateConditionTypes.Add(_("before"));
		dateConditionTypes.Add(_("equals"));
		dateConditionTypes.Add(_("does not equal"));
		dateConditionTypes.Add(_("after"));
	}

	if (conditions & filter_name)
	{
		filterTypes.Add(_("Filename"));
		filter_type_map.push_back(filter_name);
	}
	if (conditions & filter_size)
	{
		filterTypes.Add(_("Filesize"));
		filter_type_map.push_back(filter_size);
	}
	if (conditions & filter_attributes)
	{
		filterTypes.Add(_("Attribute"));
		filter_type_map.push_back(filter_attributes);
	}
	if (conditions & filter_permissions)
	{
		filterTypes.Add(_("Permission"));
		filter_type_map.push_back(filter_permissions);
	}
	if (conditions & filter_path)
	{
		filterTypes.Add(_("Path"));
		filter_type_map.push_back(filter_path);
	}
	if (conditions & filter_date)
	{
		filterTypes.Add(_("Date"));
		filter_type_map.push_back(filter_date);
	}

	SetFilterCtrlState(true);

	m_pListCtrl->Connect(wxEVT_SIZE, wxSizeEventHandler(CFilterConditionsDialog::OnListSize), 0, this);

	m_pListCtrl->MoveAfterInTabOrder(XRCCTRL(*this, "ID_MATCHTYPE", wxChoice));

	return true;
}
Пример #25
0
void SearchThread::DoSearchLine(const wxString& line,
                                const int lineNum,
                                const int lineOffset,
                                const wxString& fileName,
                                const SearchData* data,
                                const wxString& findWhat,
                                const wxArrayString& filters,
                                TextStatesPtr statesPtr)
{
    wxString modLine = line;

    if(!data->IsMatchCase()) {
        modLine.MakeLower();
    }

    int pos = 0;
    int col = 0;
    int iCorrectedCol = 0;
    int iCorrectedLen = 0;
    while(pos != wxNOT_FOUND) {
        pos = modLine.Find(findWhat);
        if(pos != wxNOT_FOUND) {
            col += pos;
            
            // Pipe support
            bool allFiltersOK = true;
            if(!filters.IsEmpty()) {
                // Apply the filters
                for(size_t i = 0; i < filters.size() && allFiltersOK; ++i) {
                    allFiltersOK = (modLine.Find(filters.Item(i)) != wxNOT_FOUND);
                }
            }
            
            // Pipe filtes OK?
            if(!allFiltersOK) return;
            
            // we have a match
            if(data->IsMatchWholeWord()) {

                // make sure that the word before is not in the wordChars map
                if((pos > 0) && (m_wordCharsMap.find(modLine.GetChar(pos - 1)) != m_wordCharsMap.end())) {
                    if(!AdjustLine(modLine, pos, findWhat)) {

                        break;
                    } else {
                        col += (int)findWhat.Length();
                        continue;
                    }
                }
                // if we have more characters to the right, make sure that the first char does not match any
                // in the wordCharsMap
                if(pos + findWhat.Length() <= modLine.Length()) {
                    wxChar nextCh = modLine.GetChar(pos + findWhat.Length());
                    if(m_wordCharsMap.find(nextCh) != m_wordCharsMap.end()) {
                        if(!AdjustLine(modLine, pos, findWhat)) {

                            break;
                        } else {
                            col += (int)findWhat.Length();
                            continue;
                        }
                    }
                }
            }

            // Notify our match
            // correct search Pos and Length owing to non plain ASCII multibyte characters
            iCorrectedCol = clUTF8Length(line.c_str(), col);
            iCorrectedLen = clUTF8Length(findWhat.c_str(), findWhat.Length());
            SearchResult result;
            result.SetPosition(lineOffset + col);
            result.SetColumnInChars(col);
            result.SetColumn(iCorrectedCol);
            result.SetLineNumber(lineNum);
            result.SetPattern(line);
            result.SetFileName(fileName);
            result.SetLenInChars((int)findWhat.Length());
            result.SetLen(iCorrectedLen);
            result.SetFindWhat(data->GetFindString());
            result.SetFlags(data->m_flags);

            int position(wxNOT_FOUND);
            bool canAdd(true);

            if(statesPtr) {
                position = statesPtr->LineToPos(lineNum - 1);
                position += iCorrectedCol;
            }

            // Make sure our match is not on a comment
            if(statesPtr && position != wxNOT_FOUND && data->GetSkipComments()) {
                if(statesPtr->states.size() > (size_t)position) {
                    short state = statesPtr->states.at(position).state;
                    if(state == CppWordScanner::STATE_CPP_COMMENT || state == CppWordScanner::STATE_C_COMMENT) {
                        canAdd = false;
                    }
                }
            }

            if(statesPtr && position != wxNOT_FOUND && data->GetSkipStrings()) {
                if(statesPtr->states.size() > (size_t)position) {
                    short state = statesPtr->states.at(position).state;
                    if(state == CppWordScanner::STATE_DQ_STRING || state == CppWordScanner::STATE_SINGLE_STRING) {
                        canAdd = false;
                    }
                }
            }

            result.SetMatchState(CppWordScanner::STATE_NORMAL);
            if(canAdd && statesPtr && position != wxNOT_FOUND && data->GetColourComments()) {
                // set the match state
                if(statesPtr->states.size() > (size_t)position) {
                    short state = statesPtr->states.at(position).state;
                    if(state == CppWordScanner::STATE_C_COMMENT || state == CppWordScanner::STATE_CPP_COMMENT) {
                        result.SetMatchState(state);
                    }
                }
            }

            if(canAdd) {
                m_results.push_back(result);
                m_summary.SetNumMatchesFound(m_summary.GetNumMatchesFound() + 1);
            }

            if(!AdjustLine(modLine, pos, findWhat)) {
                break;
            }
            col += (int)findWhat.Length();
        }
    }
}
bool palm_installer::install_files_by_handheld_dest( handheld_dest_type& handheld_dest,
        wxArrayString& install_fullnames )
{
    wxString    destination_fullname;
    wxString    destination_path;
    wxString    destination_rootpath;
    wxString    destination_basename;
    wxString    destination_extension;
    int         user_index;
    wxString    install_fullname;
    bool        install_fullname_exists = false;
    bool        successful              = false;

    // This is a dummy to induce a translatable string, when we want the original to stay as untranslated.
    wxString 	dummy1 = _( "SecureDigital (SD) Card" );

    wxLogDebug( wxT( "Entering palm_installer::install_files_by_handheld_dest function" ) );

    // If wxArrayString is empty, then abort
    if ( install_fullnames.IsEmpty() )
    {
        wxLogDebug( "Error: no filenames sent to install_files_by_handheld_dest. Aborting..." );
        return false;
    }

    // Look up the user_index of this user_name
    user_index = get_user_index_from_user_name( handheld_dest.user_name );

    if ( get_number_of_users() > 0 )
    {
        destination_rootpath = get_palm_desktop_path() + "/"
                               + get_user_subdirectory( user_index );

        // If installing to card, use that path...
        switch (  handheld_dest.handheld_target_storage_mode )
        {
        case plkrHANDHELD_TARGET_STORAGE_MODE_SD_CARD:
            destination_path = get_translated_handheld_destination_path( destination_rootpath,
                               "SecureDigital (SD) Card",
                               "SecureDigital"
                                                                       );
            break;
        case plkrHANDHELD_TARGET_STORAGE_MODE_MEMORY_STICK:
            destination_path = destination_rootpath + "/Files to Install/Memory Stick";
            break;
        case plkrHANDHELD_TARGET_STORAGE_MODE_COMPACT_FLASH:
            destination_path = destination_rootpath + "/Files to Install/Compact Flash Card";
            break;
        // default is the normal RAM one.
        default:
            destination_path = destination_rootpath + "/Files to Install";
            break;
        }

        // Check the destination rootpath exists. It may not, if it was a newly created
        // user, it may not have its directory yet
        wxLogDebug( "destination_rootpath=" + destination_rootpath );

        // If this is a brand new user, won't have an "Install" subdirectory
        // in his/her directory yet, so create it, if not there yet.
        if ( ! wxDirExists( destination_path ) )
        {
            wxLogDebug( "destination_path not exist, so making..." );

            // If the "Files to Install" doesn't exist, then need to make that, before can
            // make a dir such as "Memory Stick" inside of that.
            if ( ! wxDirExists ( destination_rootpath + "/Files to Install" ) )
            {
                wxMkdir( destination_rootpath + "/Files to Install", 0777 );
            }

            // OK: can now make the SecureDigital (SD) Card or Memory Stick dir
            // if destination is a card (or the "Files to Install" dir if not card).
            wxMkdir( destination_path, 0777 );
        }

        for ( size_t n = 0; n < install_fullnames.GetCount(); n++ )
        {
            wxLogDebug( "Starting loop to install" );
            install_fullname = install_fullnames.Item( n );
            wxLogDebug( "install_fullname=" + install_fullname );
            install_fullname_exists = wxFileExists( install_fullname );

            if ( install_fullname_exists )
            {
                // Get the basename and extension, so it can have the same basename + extension
                // in the install directory.
                wxSplitPath( install_fullname.c_str(), NULL, &destination_basename,
                             &destination_extension );

                destination_fullname = destination_path + "/" + destination_basename
                                       + '.' + destination_extension;

                // Copy the file over.
                if ( wxCopyFile( install_fullname, destination_fullname, TRUE ) )
                {
                    successful = TRUE;
                }
                else
                {
                    wxLogError( "Error: couldn't copy " + install_fullname + " to " + destination_fullname );
                }

            }
            else
            {
                wxLogDebug( "Error: install_fullname " + install_fullname + " doesn't exist" );
            }
        }
    }

    return successful;
}
Пример #27
0
bool MainFrame::TransferNode(TiXmlNode** node, const wxArrayString& path)
{
  if (!path.IsEmpty())
  {
    int           level     = 0;
    TiXmlElement* element   = mCfgDst->FirstChildElement("CodeBlocksConfig");
    TiXmlNode*    node_copy = (*node)->Clone();

    if (!TiXmlSuccess(mCfgDst))
      return false;

    for (size_t i=0; i<path.Count(); ++i)
    {
      wxString section_path = path.Item(i);

      if (element->NoChildren())
      {
        // element has no children -> create new child named after section
        element = (TiXmlElement*) element->InsertEndChild(
          TiXmlElement(
#if wxUSE_UNICODE
            section_path.mb_str(wxConvUTF8)
#else
            (wxChar*)section_path.mb_str()
#endif
          ));
      }// if
      else
      {
        // element has children -> find child named after section
        TiXmlElement* new_element = element->FirstChildElement(
#if wxUSE_UNICODE
          section_path.mb_str(wxConvUTF8)
#else
          (wxChar*)section_path.mb_str()
#endif
        );

        if (!new_element)
        {
          // child could not be found -> create child named after section
          element = (TiXmlElement*) element->InsertEndChild(TiXmlElement(
#if wxUSE_UNICODE
            section_path.mb_str(wxConvUTF8)
#else
            (wxChar*)section_path.mb_str()
#endif
            ));
        }
        else
        {
          // child has been found -> switch to this child
          element = new_element;
        }
      }// else

      if (!element)
        return false;

      // ...continue with next section.
    }

    TiXmlNode* parent_node = element->Parent();
    parent_node->ReplaceChild(element, *node_copy);

    return true;
  }

  return false;
}// TransferNode