Audacity 3.2.0
ModulePrefs.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 ModulePrefs.cpp
6
7 James Crook
8
9*******************************************************************//*******************************************************************/
17
18
19#include "ModulePrefs.h"
20
21
22
23#include <wx/defs.h>
24#include <wx/filename.h>
25
26#include "ShuttleGui.h"
27
28#include "Prefs.h"
29#include "ModuleSettings.h"
30
32
33ModulePrefs::ModulePrefs(wxWindow * parent, wxWindowID winid)
34/* i18n-hint: Modules are optional extensions to Audacity that add NEW features.*/
35: PrefsPanel(parent, winid, XO("Modules"))
36{
37 Populate();
38}
39
41{
42}
43
45{
47}
48
50{
51 return XO("Preferences for Module");
52}
53
55{
56 return "Modules_Preferences";
57}
58
60 wxString str;
61 long dummy;
62
63 // Modules could for example be:
64 // mod-script-pipe
65 // mod-nyq-bench
66 // mod-menu-munger
67 // mod-theming
68
69 // TODO: On an Audacity upgrade we should (?) actually untick modules.
70 // The old modules might be still around, and we do not want to use them.
71 mModules.clear();
72 mStatuses.clear();
73 mPaths.clear();
74
75
76 // Iterate through all Modules listed in prefs.
77 // Get their names and values.
78 gPrefs->SetPath( wxT("Module/") );
79 bool bCont = gPrefs->GetFirstEntry(str, dummy);
80 while ( bCont ) {
81 int iStatus;
82 gPrefs->Read( str, &iStatus, kModuleDisabled );
83 wxString fname;
84 gPrefs->Read( wxString( wxT("/ModulePath/") ) + str, &fname, wxEmptyString );
85 if( !fname.empty() && wxFileExists( fname ) ){
86 if( iStatus > kModuleNew ){
87 iStatus = kModuleNew;
88 gPrefs->Write( str, iStatus );
89 }
90 //wxLogDebug( wxT("Entry: %s Value: %i"), str, iStatus );
91 mModules.push_back( str );
92 mStatuses.push_back( iStatus );
93 mPaths.push_back( fname );
94 }
95 bCont = gPrefs->GetNextEntry(str, dummy);
96 }
97 gPrefs->SetPath( wxT("") );
98}
99
101{
103 //------------------------- Main section --------------------
104 // Now construct the GUI itself.
105 // Use 'eIsCreatingFromPrefs' so that the GUI is
106 // initialised with values from gPrefs.
109 // ----------------------- End of main section --------------
110}
111
113{
114 S.SetBorder(2);
115 S.StartScroller();
116
117 S.StartStatic( {} );
118 {
119 S.AddFixedText(XO(
120"These are experimental modules. Enable them only if you've read the Audacity Manual\nand know what you are doing.") );
121 S.AddFixedText(XO(
122/* i18n-hint preserve the leading spaces */
123" 'Ask' means Audacity will ask if you want to load the module each time it starts.") );
124 S.AddFixedText(XO(
125/* i18n-hint preserve the leading spaces */
126" 'Failed' means Audacity thinks the module is broken and won't run it.") );
127 S.AddFixedText(XO(
128/* i18n-hint preserve the leading spaces */
129" 'New' means no choice has been made yet.") );
130 S.AddFixedText(XO(
131"Changes to these settings only take effect when Audacity starts up."));
132 {
133 S.StartMultiColumn( 2 );
134 int i;
135 for(i=0;i<(int)mModules.size();i++)
136 S.TieChoice( Verbatim( mModules[i] ),
137 mStatuses[i],
138 {
139 XO("Disabled" ) ,
140 XO("Enabled" ) ,
141 XO("Ask" ) ,
142 XO("Failed" ) ,
143 XO("New" ) ,
144 }
145 );
146 S.EndMultiColumn();
147 }
148 if( mModules.size() < 1 )
149 {
150 S.AddFixedText( XO("No modules were found") );
151 }
152 }
153 S.EndStatic();
154 S.EndScroller();
155}
156
158{
161 int i;
162 for(i=0;i<(int)mPaths.size();i++)
164 return true;
165}
166
167#ifdef EXPERIMENTAL_MODULE_PREFS
168namespace{
170 [](wxWindow *parent, wxWindowID winid, AudacityProject *)
171 {
172 wxASSERT(parent); // to justify safenew
173 return safenew ModulePrefs(parent, winid);
174 },
175 false,
176 // Register with an explicit ordering hint because this one is
177 // only conditionally compiled
178 { "", { Registry::OrderingHint::After, "Mouse" } }
179};
180}
181#endif
wxT("CloseDown"))
#define str(a)
XO("Cut/Copy/Paste")
#define safenew
Definition: MemoryX.h:10
#define MODULE_PREFS_PLUGIN_SYMBOL
Definition: ModulePrefs.h:24
@ kModuleDisabled
@ kModuleNew
FileConfig * gPrefs
Definition: Prefs.cpp:70
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:46
@ eIsSavingToPrefs
Definition: ShuttleGui.h:47
#define S(N)
Definition: ToChars.cpp:64
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
virtual bool GetNextEntry(wxString &str, long &lIndex) const wxOVERRIDE
Definition: FileConfig.cpp:118
virtual void SetPath(const wxString &strPath) wxOVERRIDE
Definition: FileConfig.cpp:93
virtual bool GetFirstEntry(wxString &str, long &lIndex) const wxOVERRIDE
Definition: FileConfig.cpp:113
A PrefsPanel to enable/disable certain modules. 'Modules' are dynamically linked libraries that modif...
Definition: ModulePrefs.h:27
wxArrayString mModules
Definition: ModulePrefs.h:41
void PopulateOrExchange(ShuttleGui &S) override
ModulePrefs(wxWindow *parent, wxWindowID winid)
Definition: ModulePrefs.cpp:33
bool Commit() override
FilePaths mPaths
Definition: ModulePrefs.h:43
ComponentInterfaceSymbol GetSymbol() const override
Definition: ModulePrefs.cpp:44
TranslatableString GetDescription() const override
Definition: ModulePrefs.cpp:49
void Populate()
void GetAllModuleStatuses()
Definition: ModulePrefs.cpp:59
std::vector< int > mStatuses
Definition: ModulePrefs.h:42
ManualPageID HelpPageName() override
If not empty string, the Help button is added below the panel.
Definition: ModulePrefs.cpp:54
Base class for a panel in the PrefsDialog. Classes derived from this class include BatchPrefs,...
Definition: PrefsPanel.h:51
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:625
Holds a msgid for the translation catalog; may also bind format arguments.
MODULE_MANAGER_API void SetModuleStatus(const FilePath &fname, int iStatus)