Menu

[r1967]: / trunk / src / sdk / pluginsconfigurationdlg.cpp  Maximize  Restore  History

Download this file

100 lines (85 with data), 3.2 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
* This file is part of Code::Blocks Studio, an open-source cross-platform IDE
* Copyright (C) 2003 Yiannis An. Mandravellos
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Contact e-mail: Yiannis An. Mandravellos <mandrav@codeblocks.org>
* Program URL : http://www.codeblocks.org
*
* $Revision$
* $Id$
* $HeadURL$
*/
#include "sdk_precomp.h"
#ifndef CB_PRECOMP
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include <wx/button.h>
#include "manager.h"
#include "configmanager.h"
#include "pluginmanager.h"
#include "personalitymanager.h"
#include <wx/checklst.h>
#endif
#include "pluginsconfigurationdlg.h" // class's header file
BEGIN_EVENT_TABLE(PluginsConfigurationDlg, wxDialog)
EVT_BUTTON(XRCID("btnOK"), PluginsConfigurationDlg::OnOK)
END_EVENT_TABLE()
// class constructor
PluginsConfigurationDlg::PluginsConfigurationDlg(wxWindow* parent)
{
wxXmlResource::Get()->LoadDialog(this, parent, _T("dlgConfigurePlugins"));
wxCheckListBox* list = XRCCTRL(*this, "lstPlugins", wxCheckListBox);
PluginManager* man = Manager::Get()->GetPluginManager();
PluginElementsArray& plugins = man->GetPlugins();
// populate Plugins and Help/Plugins menu
for (unsigned int i = 0; i < plugins.GetCount(); ++i)
{
PluginElement* elem = plugins[i];
if (!elem->plugin)
{
// this plugin is not loaded
// display its name
list->Append(elem->name);
list->Check(list->GetCount()-1, false);
continue;
}
list->Append(elem->plugin->GetInfo()->title + _(", v") + elem->plugin->GetInfo()->version);
wxString baseKey;
baseKey << _T("/") << elem->name;
list->Check(list->GetCount()-1, Manager::Get()->GetConfigManager(_T("plugins"))->ReadBool(baseKey, true));
}
}
// class destructor
PluginsConfigurationDlg::~PluginsConfigurationDlg()
{
// insert your code here
}
void PluginsConfigurationDlg::OnOK(wxCommandEvent& event)
{
wxCheckListBox* list = XRCCTRL(*this, "lstPlugins", wxCheckListBox);
PluginManager* man = Manager::Get()->GetPluginManager();
PluginElementsArray& plugins = man->GetPlugins();
for (int i = 0; i < list->GetCount(); ++i)
{
PluginElement* elem = plugins[i];
wxString baseKey;
baseKey << _T("/") << elem->name;
bool checked = list->IsChecked(i);
Manager::Get()->GetConfigManager(_T("plugins"))->Write(baseKey, checked);
}
EndModal(wxID_OK);
}