~efargaspro/+junk/codeblocks-16.01-release

« back to all changes in this revision

Viewing changes to src/plugins/contrib/FileManager/FileManager.cpp

  • Committer: damienlmoore at gmail
  • Date: 2016-02-02 02:43:22 UTC
  • Revision ID: damienlmoore@gmail.com-20160202024322-yql5qmtbwdyamdwd
Code::BlocksĀ 16.01

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <wx/aui/aui.h>
 
2
#include <sdk.h> // Code::Blocks SDK
 
3
#ifndef CB_PRECOMP
 
4
    #include <cbauibook.h>
 
5
    #include <cbproject.h>
 
6
    #include <projectmanager.h>
 
7
#endif
 
8
//#include <configurationpanel.h>
 
9
 
 
10
#include "FileManager.h"
 
11
 
 
12
// Register the plugin with Code::Blocks.
 
13
// We are using an anonymous namespace so we don't litter the global one.
 
14
namespace
 
15
{
 
16
    PluginRegistrant<FileManagerPlugin> reg(_T("FileManager"));
 
17
}
 
18
 
 
19
int ID_ProjectOpenInFileBrowser=wxNewId();
 
20
 
 
21
BEGIN_EVENT_TABLE(FileManagerPlugin, cbPlugin)
 
22
    EVT_MENU(ID_ProjectOpenInFileBrowser, FileManagerPlugin::OnOpenProjectInFileBrowser)
 
23
END_EVENT_TABLE()
 
24
 
 
25
 
 
26
// constructor
 
27
FileManagerPlugin::FileManagerPlugin()
 
28
{
 
29
    if(!Manager::LoadResource(_T("FileManager.zip")))
 
30
    {
 
31
        NotifyMissingFile(_T("FileManager.zip"));
 
32
    }
 
33
    m_fe=0;
 
34
}
 
35
 
 
36
// destructor
 
37
FileManagerPlugin::~FileManagerPlugin()
 
38
{
 
39
}
 
40
 
 
41
void FileManagerPlugin::OnAttach()
 
42
{
 
43
    //Create a new instance of the FileExplorer and attach it to the Project Manager notebook
 
44
    m_fe=new FileExplorer(Manager::Get()->GetAppWindow());
 
45
    Manager::Get()->GetProjectManager()->GetUI().GetNotebook()->AddPage(m_fe,_("Files"));
 
46
}
 
47
 
 
48
void FileManagerPlugin::OnRelease(bool /*appShutDown*/)
 
49
{
 
50
    if (m_fe) //remove the File Explorer from the managment pane and destroy it.
 
51
    {
 
52
        cbAuiNotebook *notebook = Manager::Get()->GetProjectManager()->GetUI().GetNotebook();
 
53
        int idx = notebook->GetPageIndex(m_fe);
 
54
        if (idx != -1)
 
55
            notebook->RemovePage(idx);
 
56
        delete m_fe;
 
57
    }
 
58
    m_fe = 0;
 
59
}
 
60
 
 
61
void FileManagerPlugin::BuildModuleMenu(const ModuleType type, wxMenu* menu, const FileTreeData* data)
 
62
{
 
63
        if(type==mtProjectManager && data && data->GetKind()==FileTreeData::ftdkProject)
 
64
        {
 
65
            m_project_selected=wxFileName(data->GetProject()->GetFilename()).GetPath();
 
66
        menu->Append(ID_ProjectOpenInFileBrowser, _("Open Project Folder in File Browser"), _("Opens the folder containing the project file in the file browser"));
 
67
        }
 
68
}
 
69
 
 
70
void FileManagerPlugin::OnOpenProjectInFileBrowser(wxCommandEvent& /*event*/)
 
71
{
 
72
    cbAuiNotebook *m_nb=Manager::Get()->GetProjectManager()->GetUI().GetNotebook();
 
73
    m_nb->SetSelection(m_nb->GetPageIndex(m_fe));
 
74
    m_fe->SetRootFolder(m_project_selected);
 
75
}