Update list of wide characters
[centerim5.git] / src / AccountWindow.h
blobf2ffcc757ff26e471baec01891a98dfd7d5e5ec0
1 // Copyright (C) 2007 Mark Pustjens <pustjens@dds.nl>
2 // Copyright (C) 2010-2015 Petr Pavlu <setup@dagobah.cz>
3 //
4 // This file is part of CenterIM.
5 //
6 // CenterIM is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // CenterIM is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with CenterIM. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef ACCOUNTWINDOW_H
20 #define ACCOUNTWINDOW_H
22 #include <cppconsui/Button.h>
23 #include <cppconsui/CheckBox.h>
24 #include <cppconsui/ColorPicker.h>
25 #include <cppconsui/ComboBox.h>
26 #include <cppconsui/InputDialog.h>
27 #include <cppconsui/MessageDialog.h>
28 #include <cppconsui/SplitDialog.h>
29 #include <cppconsui/TreeView.h>
30 #include <libpurple/purple.h>
32 class AccountWindow : public CppConsUI::SplitDialog {
33 public:
34 AccountWindow();
35 virtual ~AccountWindow() override {}
37 // FreeWindow
38 virtual void onScreenResized() override;
40 private:
41 class SplitOption;
42 typedef std::list<SplitOption *> SplitWidgets;
43 typedef std::vector<CppConsUI::Widget *> Widgets;
45 struct AccountEntry {
46 CppConsUI::Button *parent;
47 CppConsUI::TreeView::NodeReference parent_reference;
48 SplitWidgets split_widgets;
50 typedef std::map<PurpleAccount *, AccountEntry> AccountEntries;
52 class BoolOption : public CppConsUI::CheckBox {
53 public:
54 enum Type {
55 TYPE_PURPLE,
56 TYPE_REMEMBER_PASSWORD,
57 TYPE_ENABLE_ACCOUNT,
60 BoolOption(PurpleAccount *account, PurpleAccountOption *option);
61 BoolOption(PurpleAccount *account, Type type);
62 virtual ~BoolOption() override {}
64 protected:
65 PurpleAccount *account_;
66 PurpleAccountOption *option_;
67 Type type_;
69 void onToggle(CppConsUI::CheckBox &activator, bool new_state);
71 private:
72 CONSUI_DISABLE_COPY(BoolOption);
75 class StringOption : public CppConsUI::Button {
76 public:
77 enum Type {
78 TYPE_PURPLE,
79 TYPE_PASSWORD,
80 TYPE_ALIAS,
83 StringOption(PurpleAccount *account, PurpleAccountOption *option);
84 StringOption(PurpleAccount *account, Type type);
85 virtual ~StringOption() override {}
87 protected:
88 PurpleAccount *account_;
89 PurpleAccountOption *option_;
90 Type type_;
92 void initialize();
93 void updateValue();
94 void onActivate(CppConsUI::Button &activator);
95 void responseHandler(CppConsUI::InputDialog &activator,
96 CppConsUI::AbstractDialog::ResponseType response);
98 private:
99 CONSUI_DISABLE_COPY(StringOption);
102 class IntegerOption : public CppConsUI::Button {
103 public:
104 IntegerOption(PurpleAccount *account, PurpleAccountOption *option);
105 virtual ~IntegerOption() override {}
107 protected:
108 PurpleAccount *account_;
109 PurpleAccountOption *option_;
111 void updateValue();
112 void onActivate(CppConsUI::Button &activator);
113 void responseHandler(CppConsUI::InputDialog &activator,
114 CppConsUI::AbstractDialog::ResponseType response);
116 private:
117 CONSUI_DISABLE_COPY(IntegerOption);
120 class StringListOption : public CppConsUI::ComboBox {
121 public:
122 StringListOption(PurpleAccount *account, PurpleAccountOption *option);
123 virtual ~StringListOption() override {}
125 protected:
126 PurpleAccount *account_;
127 PurpleAccountOption *option_;
129 void onSelectionChanged(CppConsUI::ComboBox &activator, int new_entry,
130 const char *title, intptr_t data);
132 private:
133 CONSUI_DISABLE_COPY(StringListOption);
136 class SplitOption : public CppConsUI::Button {
137 public:
138 SplitOption(PurpleAccount *account, PurpleAccountUserSplit *split,
139 AccountEntry *account_entry);
140 virtual ~SplitOption() override {}
142 protected:
143 PurpleAccount *account_;
144 PurpleAccountUserSplit *split_;
145 AccountEntry *account_entry_;
147 void updateSplits();
148 void onActivate(CppConsUI::Button &activator);
149 void responseHandler(CppConsUI::InputDialog &activator,
150 CppConsUI::AbstractDialog::ResponseType response);
152 private:
153 CONSUI_DISABLE_COPY(SplitOption);
156 class ProtocolOption : public CppConsUI::ComboBox {
157 public:
158 ProtocolOption(PurpleAccount *account, AccountWindow &account_window);
159 virtual ~ProtocolOption() override {}
161 protected:
162 AccountWindow *account_window_;
163 PurpleAccount *account_;
165 void onProtocolChanged(CppConsUI::ComboBox &activator,
166 std::size_t new_entry, const char *title, intptr_t data);
168 private:
169 CONSUI_DISABLE_COPY(ProtocolOption);
172 class ColorOption : public CppConsUI::ColorPicker {
173 public:
174 ColorOption(PurpleAccount *account);
175 virtual ~ColorOption() override {}
177 protected:
178 PurpleAccount *account_;
180 void onColorChanged(
181 CppConsUI::ColorPicker &activator, int new_fg, int new_bg);
183 private:
184 CONSUI_DISABLE_COPY(ColorOption);
187 CppConsUI::TreeView *treeview_;
188 AccountEntries account_entries_;
190 CONSUI_DISABLE_COPY(AccountWindow);
192 void clearAccount(PurpleAccount *account, bool full);
193 void populateAccount(PurpleAccount *account);
195 void addAccount(CppConsUI::Button &activator);
196 void dropAccount(CppConsUI::Button &activator, PurpleAccount *account);
197 void dropAccountResponseHandler(CppConsUI::MessageDialog &activator,
198 CppConsUI::AbstractDialog::ResponseType response, PurpleAccount *account);
201 #endif // ACCOUNTWINDOW_H
203 // vim: set tabstop=2 shiftwidth=2 textwidth=80 expandtab: