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 // Modules could for example be:
61 // mod-script-pipe
62 // mod-nyq-bench
63 // mod-menu-munger
64 // mod-theming
65
66 // TODO: On an Audacity upgrade we should (?) actually untick modules.
67 // The old modules might be still around, and we do not want to use them.
68 mModules.clear();
69 mStatuses.clear();
70 mPaths.clear();
71
72
73 // Iterate through all Modules listed in prefs.
74 // Get their names and values.
75 auto moduleGroup = gPrefs->BeginGroup("Module");
76 for(const auto& key : gPrefs->GetChildKeys())
77 {
78 int iStatus;
79 gPrefs->Read( key, &iStatus, static_cast<decltype(iStatus)>(kModuleDisabled) );
80 wxString fname;
81 gPrefs->Read(wxT("/ModulePath/") + key, &fname, {} );
82 if( !fname.empty() && wxFileExists( fname ) ){
83 if( iStatus > kModuleNew ){
84 iStatus = kModuleNew;
85 gPrefs->Write( key, iStatus );
86 }
87 //wxLogDebug( wxT("Entry: %s Value: %i"), str, iStatus );
88 mModules.push_back( key );
89 mStatuses.push_back( iStatus );
90 mPaths.push_back( fname );
91 }
92 }
93}
94
96{
98 //------------------------- Main section --------------------
99 // Now construct the GUI itself.
100 // Use 'eIsCreatingFromPrefs' so that the GUI is
101 // initialised with values from gPrefs.
104 // ----------------------- End of main section --------------
105}
106
108{
109 S.SetBorder(2);
110 S.StartScroller();
111
112 S.StartStatic( {} );
113 {
114 S.AddFixedText(XO(
115"Modules are optional components of Audacity that enable some functionality, such as importing and exporting. \nIt is generally not necessary to change these settings.") );
116 S.AddFixedText(XO(
117"Changes to these settings only take effect when restarting Audacity.\n") );
118 {
119 S.StartMultiColumn( 2 );
120 int i;
121 for(i=0;i<(int)mModules.size();i++)
122 S.TieChoice( Verbatim( mModules[i] ),
123 mStatuses[i],
124 {
125 XO("Disabled" ) ,
126 XO("Enabled" ) ,
127 XO("Always ask" ) ,
128 XO("Failed" ) ,
129 XO("No choice made" ) ,
130 }
131 );
132 S.EndMultiColumn();
133 }
134 if( mModules.size() < 1 )
135 {
136 S.AddFixedText( XO("Error: No modules were found. This may indicate a faulty installation.") );
137 }
138 }
139 S.EndStatic();
140 S.EndScroller();
141}
142
144{
147 int i;
148 for(i=0;i<(int)mPaths.size();i++)
150 return true;
151}
152
153namespace{
155 [](wxWindow *parent, wxWindowID winid, AudacityProject *)
156 {
157 wxASSERT(parent); // to justify safenew
158 return safenew ModulePrefs(parent, winid);
159 },
160 false,
161 // Register with an explicit ordering hint because this one is
162 // only conditionally compiled
163 { "", { Registry::OrderingHint::After, "Mouse" } }
164};
165}
wxT("CloseDown"))
XO("Cut/Copy/Paste")
#define safenew
Definition: MemoryX.h:10
#define MODULE_PREFS_PLUGIN_SYMBOL
Definition: ModulePrefs.h:24
@ kModuleDisabled
@ kModuleNew
static const AudacityProject::AttachedObjects::RegisteredFactory key
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
@ 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,...
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()
Definition: ModulePrefs.cpp:95
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:640
Holds a msgid for the translation catalog; may also bind format arguments.
GroupScope BeginGroup(const wxString &prefix)
Appends a prefix to the current group or sets a new absolute path. Group that was set as current befo...
virtual wxArrayString GetChildKeys() const =0
Returns all child keys within the current group.
virtual bool Write(const wxString &key, bool value)=0
virtual bool Read(const wxString &key, bool *value) const =0
MODULE_MANAGER_API void SetModuleStatus(const FilePath &fname, int iStatus)
PrefsPanel::Registration sAttachment