Debian Codegraph @

components/output/winamp/config.cpp

raw symbols SCIP
1 /* BoCA - BonkEnc Component Architecture
2 * Copyright (C) 2007-2019 Robert Kausch <[email protected]>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation, either version 2 of
7 * the License, or (at your option) any later version.
8 *
9 * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
10 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
11 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
12
13 #include "config.h"
14 #include "dllinterface.h"
15
16 const String BoCA::ConfigureWinamp::ConfigID = "WinampOut";
17
18 BoCA::ConfigureWinamp::ConfigureWinamp()
19 {
20 const Config *config = Config::Get();
21 I18n *i18n = I18n::Get();
22
23 i18n->SetContext("Extensions::Winamp Adapter");
24
25 list_output = new ListBox(Point(7, 7), Size(425, 170));
26 list_output->SetFlags(LF_MULTICHECKBOX);
27 list_output->onSelectEntry.Connect(&ConfigureWinamp::SelectOutputPlugin, this);
28 list_output->onMarkEntry.Connect(&ConfigureWinamp::SelectOutputPlugin, this);
29
30 button_output = new Button(i18n->TranslateString("Configure"), Point(440, 7), Size());
31 button_output->onAction.Connect(&ConfigureWinamp::ConfigureOutputPlugin, this);
32 button_output->Deactivate();
33
34 button_output_about = new Button(i18n->TranslateString("About"), Point(440, 37), Size());
35 button_output_about->onAction.Connect(&ConfigureWinamp::AboutOutputPlugin, this);
36 button_output_about->Deactivate();
37
38 for (Int i = 0; i < winamp_out_modules.Length(); i++)
39 {
40 if (winamp_out_modules.GetNth(i)->version == OUT_VER) list_output->AddEntry(winamp_out_modules.GetNth(i)->description, config->GetIntValue(ConfigID, "OutputPlugin", 0) == i);
41 else list_output->AddEntry((wchar_t *) winamp_out_modules.GetNth(i)->description, config->GetIntValue(ConfigID, "OutputPlugin", 0) == i);
42 }
43
44 Add(list_output);
45 Add(button_output);
46 Add(button_output_about);
47
48 SetSize(Size(527, 184));
49 }
50
51 BoCA::ConfigureWinamp::~ConfigureWinamp()
52 {
53 DeleteObject(list_output);
54 DeleteObject(button_output);
55 DeleteObject(button_output_about);
56 }
57
58 Int BoCA::ConfigureWinamp::SaveSettings()
59 {
60 Config *config = Config::Get();
61 Int plugin = -1;
62
63 for (Int i = 0; i < list_output->Length(); i++) if (list_output->GetNthEntry(i)->IsMarked()) plugin = i;
64
65 config->SetIntValue(ConfigID, "OutputPlugin", plugin);
66
67 return Success();
68 }
69
70 Void BoCA::ConfigureWinamp::SelectOutputPlugin()
71 {
72 ListEntry *selectedEntry = list_output->GetSelectedEntry();
73
74 if (selectedEntry == NIL) return;
75
76 button_output->Activate();
77 button_output_about->Activate();
78
79 /* Make sure only one entry is marked at any time.
80 */
81 if (selectedEntry->IsMarked())
82 {
83 /* Unmark any other plugins.
84 */
85 for (Int i = 0; i < list_output->Length(); i++) if (list_output->GetNthEntry(i) != selectedEntry) list_output->GetNthEntry(i)->SetMark(False);
86 }
87 else
88 {
89 /* Mark this plugin if no other plugin is marked.
90 */
91 Bool selected = False;
92
93 for (Int i = 0; i < list_output->Length(); i++) if (list_output->GetNthEntry(i)->IsMarked()) selected = True;
94
95 if (!selected) selectedEntry->SetMark(True);
96 }
97 }
98
99 Void BoCA::ConfigureWinamp::ConfigureOutputPlugin()
100 {
101 if (list_output->GetSelectedEntry() == NIL) return;
102
103 winamp_out_modules.GetNth(list_output->GetSelectedEntryNumber())->Config((HWND) GetContainerWindow()->GetSystemWindow());
104 }
105
106 Void BoCA::ConfigureWinamp::AboutOutputPlugin()
107 {
108 if (list_output->GetSelectedEntry() == NIL) return;
109
110 winamp_out_modules.GetNth(list_output->GetSelectedEntryNumber())->About((HWND) GetContainerWindow()->GetSystemWindow());
111 }