Audacity  3.0.3
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ModulePrefs Class Referencefinal

A PrefsPanel to enable/disable certain modules. 'Modules' are dynamically linked libraries that modify Audacity. They are plug-ins with names like mod-script-pipe that add NEW features. More...

#include <ModulePrefs.h>

Inheritance diagram for ModulePrefs:
[legend]
Collaboration diagram for ModulePrefs:
[legend]

Public Member Functions

 ModulePrefs (wxWindow *parent, wxWindowID winid)
 
 ~ModulePrefs ()
 
ComponentInterfaceSymbol GetSymbol () override
 
TranslatableString GetDescription () override
 
bool Commit () override
 
ManualPageID HelpPageName () override
 If not empty string, the Help button is added below the panel. More...
 
void PopulateOrExchange (ShuttleGui &S) override
 
- Public Member Functions inherited from PrefsPanel
 PrefsPanel (wxWindow *parent, wxWindowID winid, const TranslatableString &title)
 
virtual ~PrefsPanel ()
 
virtual void Preview ()
 
virtual PluginPath GetPath ()
 
virtual VendorSymbol GetVendor ()
 
virtual wxString GetVersion ()
 
virtual bool ShowsPreviewButton ()
 
virtual void PopulateOrExchange (ShuttleGui &WXUNUSED(S))
 
virtual void Cancel ()
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
void SetLabel (const TranslatableString &label)
 
void SetName (const TranslatableString &name)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Private Member Functions

void GetAllModuleStatuses ()
 
void Populate ()
 

Private Attributes

wxArrayString mModules
 
std::vector< int > mStatuses
 
FilePaths mPaths
 

Additional Inherited Members

- Public Types inherited from PrefsPanel
using Factories = std::vector< PrefsPanel::PrefsNode >
 
using Factory = std::function< PrefsPanel *(wxWindow *parent, wxWindowID winid, AudacityProject *) >
 
- Static Public Member Functions inherited from PrefsPanel
static FactoriesDefaultFactories ()
 

Detailed Description

A PrefsPanel to enable/disable certain modules. 'Modules' are dynamically linked libraries that modify Audacity. They are plug-ins with names like mod-script-pipe that add NEW features.

Definition at line 26 of file ModulePrefs.h.

Constructor & Destructor Documentation

◆ ModulePrefs()

ModulePrefs::ModulePrefs ( wxWindow *  parent,
wxWindowID  winid 
)

Definition at line 33 of file ModulePrefs.cpp.

35 : PrefsPanel(parent, winid, XO("Modules"))
36 {
37  Populate();
38 }

References Populate().

Here is the call graph for this function:

◆ ~ModulePrefs()

ModulePrefs::~ModulePrefs ( )

Definition at line 40 of file ModulePrefs.cpp.

41 {
42 }

Member Function Documentation

◆ Commit()

bool ModulePrefs::Commit ( )
overridevirtual

Implements PrefsPanel.

Definition at line 157 of file ModulePrefs.cpp.

158 {
159  ShuttleGui S(this, eIsSavingToPrefs);
161  int i;
162  for(i=0;i<(int)mPaths.size();i++)
164  return true;
165 }

References eIsSavingToPrefs, mPaths, mStatuses, PopulateOrExchange(), and ModuleSettings::SetModuleStatus().

Here is the call graph for this function:

◆ GetAllModuleStatuses()

void ModulePrefs::GetAllModuleStatuses ( )
private

Definition at line 59 of file ModulePrefs.cpp.

59  {
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 }

References FileConfig::GetFirstEntry(), FileConfig::GetNextEntry(), gPrefs, kModuleDisabled, kModuleNew, mModules, mPaths, mStatuses, and FileConfig::SetPath().

Referenced by Populate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDescription()

TranslatableString ModulePrefs::GetDescription ( )
overridevirtual

Implements ComponentInterface.

Definition at line 49 of file ModulePrefs.cpp.

50 {
51  return XO("Preferences for Module");
52 }

References XO.

◆ GetSymbol()

ComponentInterfaceSymbol ModulePrefs::GetSymbol ( )
overridevirtual

Implements ComponentInterface.

Definition at line 44 of file ModulePrefs.cpp.

45 {
47 }

References MODULE_PREFS_PLUGIN_SYMBOL.

◆ HelpPageName()

ManualPageID ModulePrefs::HelpPageName ( )
overridevirtual

If not empty string, the Help button is added below the panel.

Default returns empty string.

Reimplemented from PrefsPanel.

Definition at line 54 of file ModulePrefs.cpp.

55 {
56  return "Modules_Preferences";
57 }

◆ Populate()

void ModulePrefs::Populate ( )
private

Definition at line 100 of file ModulePrefs.cpp.

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 }

References eIsCreatingFromPrefs, GetAllModuleStatuses(), and PopulateOrExchange().

Referenced by ModulePrefs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PopulateOrExchange()

void ModulePrefs::PopulateOrExchange ( ShuttleGui S)
override

Definition at line 112 of file ModulePrefs.cpp.

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 }

References ShuttleGuiBase::AddFixedText(), ShuttleGuiBase::EndMultiColumn(), ShuttleGuiBase::EndScroller(), ShuttleGuiBase::EndStatic(), mModules, mStatuses, ShuttleGuiBase::SetBorder(), ShuttleGuiBase::StartMultiColumn(), ShuttleGuiBase::StartScroller(), ShuttleGuiBase::StartStatic(), ShuttleGuiBase::TieChoice(), Verbatim(), and XO.

Referenced by Commit(), and Populate().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mModules

wxArrayString ModulePrefs::mModules
private

Definition at line 41 of file ModulePrefs.h.

Referenced by GetAllModuleStatuses(), and PopulateOrExchange().

◆ mPaths

FilePaths ModulePrefs::mPaths
private

Definition at line 43 of file ModulePrefs.h.

Referenced by Commit(), and GetAllModuleStatuses().

◆ mStatuses

std::vector<int> ModulePrefs::mStatuses
private

Definition at line 42 of file ModulePrefs.h.

Referenced by Commit(), GetAllModuleStatuses(), and PopulateOrExchange().


The documentation for this class was generated from the following files:
FileConfig::SetPath
virtual void SetPath(const wxString &strPath) wxOVERRIDE
Definition: FileConfig.cpp:93
MODULE_PREFS_PLUGIN_SYMBOL
#define MODULE_PREFS_PLUGIN_SYMBOL
Definition: ModulePrefs.h:24
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:70
ModulePrefs::mStatuses
std::vector< int > mStatuses
Definition: ModulePrefs.h:42
XO
#define XO(s)
Definition: Internat.h:31
ShuttleGuiBase::EndMultiColumn
void EndMultiColumn()
Definition: ShuttleGui.cpp:1238
FileConfig::GetFirstEntry
virtual bool GetFirstEntry(wxString &str, long &lIndex) const wxOVERRIDE
Definition: FileConfig.cpp:113
FileConfig::GetNextEntry
virtual bool GetNextEntry(wxString &str, long &lIndex) const wxOVERRIDE
Definition: FileConfig.cpp:118
ShuttleGuiBase::EndScroller
void EndScroller()
Definition: ShuttleGui.cpp:971
ShuttleGuiBase::StartScroller
wxScrolledWindow * StartScroller(int iStyle=0)
Definition: ShuttleGui.cpp:938
ShuttleGuiBase::StartMultiColumn
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:1229
ShuttleGuiBase::AddFixedText
void AddFixedText(const TranslatableString &Str, bool bCenter=false, int wrapWidth=0)
Definition: ShuttleGui.cpp:440
ModulePrefs::mModules
wxArrayString mModules
Definition: ModulePrefs.h:41
kModuleNew
@ kModuleNew
Definition: ModuleSettings.h:21
ModulePrefs::Populate
void Populate()
Definition: ModulePrefs.cpp:100
ShuttleGuiBase::StartStatic
wxStaticBox * StartStatic(const TranslatableString &Str, int iProp=0)
Definition: ShuttleGui.cpp:893
eIsSavingToPrefs
@ eIsSavingToPrefs
Definition: ShuttleGui.h:48
ModulePrefs::mPaths
FilePaths mPaths
Definition: ModulePrefs.h:43
ModuleSettings::SetModuleStatus
void SetModuleStatus(const FilePath &fname, int iStatus)
Definition: ModuleSettings.cpp:75
ModulePrefs::GetAllModuleStatuses
void GetAllModuleStatuses()
Definition: ModulePrefs.cpp:59
Verbatim
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
Definition: TranslatableString.h:321
kModuleDisabled
@ kModuleDisabled
Definition: ModuleSettings.h:17
ModulePrefs::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S) override
Definition: ModulePrefs.cpp:112
ShuttleGuiBase::SetBorder
void SetBorder(int Border)
Definition: ShuttleGui.h:489
eIsCreatingFromPrefs
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:47
ShuttleGuiBase::EndStatic
void EndStatic()
Definition: ShuttleGui.cpp:922
ShuttleGuiBase::TieChoice
wxChoice * TieChoice(const TranslatableString &Prompt, TranslatableString &Selected, const TranslatableStrings &choices)
Definition: ShuttleGui.cpp:1727
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631
PrefsPanel::PrefsPanel
PrefsPanel(wxWindow *parent, wxWindowID winid, const TranslatableString &title)
Definition: PrefsPanel.h:90