Use pkg-config to find ncursesw
[centerim5.git] / src / PluginWindow.h
blob4ad8e9f9b66bd27717d878eacc816af33811fd6f
1 // Copyright (C) 2012-2015 Petr Pavlu <setup@dagobah.cz>
2 //
3 // This file is part of CenterIM.
4 //
5 // CenterIM is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // CenterIM is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with CenterIM. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef PLUGINWINDOW_H
19 #define PLUGINWINDOW_H
21 #include <cppconsui/Button.h>
22 #include <cppconsui/CheckBox.h>
23 #include <cppconsui/ComboBox.h>
24 #include <cppconsui/InputDialog.h>
25 #include <cppconsui/MessageDialog.h>
26 #include <cppconsui/SplitDialog.h>
27 #include <cppconsui/TreeView.h>
28 #include <libpurple/purple.h>
30 class PluginWindow : public CppConsUI::SplitDialog {
31 public:
32 PluginWindow();
33 virtual ~PluginWindow() override;
35 // FreeWindow
36 virtual void onScreenResized() override;
38 private:
39 class AddPluginWindow : public CppConsUI::Window {
40 public:
41 AddPluginWindow();
42 virtual ~AddPluginWindow() override {}
44 // FreeWindow
45 virtual void onScreenResized() override;
47 // Signal that the user has selected a plugin that he wants to add.
48 sigc::signal<void, AddPluginWindow &, PurplePlugin *> signal_selection;
50 protected:
51 void onPluginButtonActivate(
52 CppConsUI::Button &activator, PurplePlugin *plugin);
54 private:
55 CONSUI_DISABLE_COPY(AddPluginWindow);
58 class BoolOption : public CppConsUI::CheckBox {
59 public:
60 BoolOption(const char *name, const char *pref);
61 virtual ~BoolOption() override;
63 protected:
64 char *pref_;
66 void onToggle(CppConsUI::CheckBox &activator, bool new_state);
68 private:
69 CONSUI_DISABLE_COPY(BoolOption);
72 class StringOption : public CppConsUI::Button {
73 public:
74 StringOption(const char *name, const char *pref);
75 virtual ~StringOption() override;
77 protected:
78 char *pref_;
80 void updateValue();
81 void onActivate(CppConsUI::Button &activator);
82 void responseHandler(CppConsUI::InputDialog &activator,
83 CppConsUI::AbstractDialog::ResponseType response);
85 private:
86 CONSUI_DISABLE_COPY(StringOption);
89 class IntegerOption : public CppConsUI::Button {
90 public:
91 IntegerOption(const char *name, const char *pref);
92 virtual ~IntegerOption() override;
94 protected:
95 char *pref_;
97 void updateValue();
98 void onActivate(CppConsUI::Button &activator);
99 void responseHandler(CppConsUI::InputDialog &activator,
100 CppConsUI::AbstractDialog::ResponseType response);
102 private:
103 CONSUI_DISABLE_COPY(IntegerOption);
106 class PathOption : public CppConsUI::Button {
107 public:
108 PathOption(const char *name, const char *pref);
109 virtual ~PathOption() override;
111 protected:
112 char *pref_;
114 void updateValue();
115 void onActivate(CppConsUI::Button &activator);
116 void responseHandler(CppConsUI::InputDialog &activator,
117 CppConsUI::AbstractDialog::ResponseType response);
119 private:
120 CONSUI_DISABLE_COPY(PathOption);
123 struct PluginEntry {
124 CppConsUI::Button *parent;
125 CppConsUI::TreeView::NodeReference parent_reference;
126 PurplePluginPrefFrame *frame;
128 typedef std::map<PurplePlugin *, PluginEntry> PluginEntries;
130 CppConsUI::TreeView *treeview_;
131 PluginEntries plugin_entries_;
133 CONSUI_DISABLE_COPY(PluginWindow);
135 void clearPlugin(PurplePlugin *plugin);
136 void populatePlugin(PurplePlugin *plugin);
138 void addPlugin(CppConsUI::Button &activator);
139 void onAddPluginSelection(AddPluginWindow &activator, PurplePlugin *plugin);
141 void disablePlugin(CppConsUI::Button &activator, PurplePlugin *plugin);
142 void disablePluginResponseHandler(CppConsUI::MessageDialog &activator,
143 CppConsUI::AbstractDialog::ResponseType response, PurplePlugin *plugin);
146 #endif // PLUGINWINDOW_H
148 // vim: set tabstop=2 shiftwidth=2 textwidth=80 expandtab: