Audacity  2.2.2
Public Member Functions | Static 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 mnod-script-pipe that add NEW features. More...

#include <ModulePrefs.h>

Inheritance diagram for ModulePrefs:
PrefsPanel wxPanelWrapper wxTabTraversalWrapper< wxPanel >

Public Member Functions

 ModulePrefs (wxWindow *parent, wxWindowID winid)
 
 ~ModulePrefs ()
 
bool Commit () override
 
wxString HelpPageName () override
 
void PopulateOrExchange (ShuttleGui &S) override
 
- Public Member Functions inherited from PrefsPanel
 PrefsPanel (wxWindow *parent, wxWindowID winid, const wxString &title)
 
virtual ~PrefsPanel ()
 
virtual void Preview ()
 
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 wxString &name=_("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const wxString &name=_("Panel"))
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&...args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Static Public Member Functions

static int GetModuleStatus (const wxString &fname)
 
static void SetModuleStatus (const wxString &fname, int iStatus)
 

Private Member Functions

void GetAllModuleStatuses ()
 
void Populate ()
 

Private Attributes

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

Detailed Description

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

Definition at line 34 of file ModulePrefs.h.

Constructor & Destructor Documentation

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

Definition at line 32 of file ModulePrefs.cpp.

References Populate().

33 : PrefsPanel(parent, winid, _("Modules"))
34 {
35  Populate();
36 }
PrefsPanel(wxWindow *parent, wxWindowID winid, const wxString &title)
Definition: PrefsPanel.h:48
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
void Populate()
Definition: ModulePrefs.cpp:84
ModulePrefs::~ModulePrefs ( )

Definition at line 38 of file ModulePrefs.cpp.

39 {
40 }

Member Function Documentation

bool ModulePrefs::Commit ( )
overridevirtual

Implements PrefsPanel.

Definition at line 131 of file ModulePrefs.cpp.

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

132 {
133  ShuttleGui S(this, eIsSavingToPrefs);
135  int i;
136  for(i=0;i<(int)mPaths.GetCount();i++)
137  SetModuleStatus( mPaths[i], mStatuses[i] );
138  return true;
139 }
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
std::vector< int > mStatuses
Definition: ModulePrefs.h:50
static void SetModuleStatus(const wxString &fname, int iStatus)
void PopulateOrExchange(ShuttleGui &S) override
Definition: ModulePrefs.cpp:96
wxArrayString mPaths
Definition: ModulePrefs.h:51
void ModulePrefs::GetAllModuleStatuses ( )
private

Definition at line 42 of file ModulePrefs.cpp.

References gPrefs, kModuleDisabled, kModuleNew, mModules, mPaths, and mStatuses.

Referenced by Populate().

42  {
43  wxString str;
44  long dummy;
45 
46  // Modules could for example be:
47  // mod-script-pipe
48  // mod-nyq-bench
49  // mod-track-panel
50  // mod-menu-munger
51  // mod-theming
52 
53  // TODO: On an Audacity upgrade we should (?) actually untick modules.
54  // The old modules might be still around, and we do not want to use them.
55  mModules.Clear();
56  mStatuses.clear();
57  mPaths.Clear();
58 
59 
60  // Iterate through all Modules listed in prefs.
61  // Get their names and values.
62  gPrefs->SetPath( wxT("Module/") );
63  bool bCont = gPrefs->GetFirstEntry(str, dummy);
64  while ( bCont ) {
65  int iStatus;
66  gPrefs->Read( str, &iStatus, kModuleDisabled );
67  wxString fname;
68  gPrefs->Read( wxString( wxT("/ModulePath/") ) + str, &fname, wxEmptyString );
69  if( fname != wxEmptyString && wxFileExists( fname ) ){
70  if( iStatus > kModuleNew ){
71  iStatus = kModuleNew;
72  gPrefs->Write( str, iStatus );
73  }
74  //wxLogDebug( wxT("Entry: %s Value: %i"), str, iStatus );
75  mModules.Add( str );
76  mStatuses.push_back( iStatus );
77  mPaths.Add( fname );
78  }
79  bCont = gPrefs->GetNextEntry(str, dummy);
80  }
81  gPrefs->SetPath( wxT("") );
82 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
std::vector< int > mStatuses
Definition: ModulePrefs.h:50
wxArrayString mModules
Definition: ModulePrefs.h:49
wxArrayString mPaths
Definition: ModulePrefs.h:51
int ModulePrefs::GetModuleStatus ( const wxString &  fname)
static

Definition at line 143 of file ModulePrefs.cpp.

References gPrefs, and kModuleNew.

Referenced by ModuleManager::Initialize().

143  {
144  // Default status is NEW module, and we will ask once.
145  int iStatus = kModuleNew;
146 
147  wxString ShortName = wxFileName( fname ).GetName();
148  wxString PrefName = wxString( wxT("/Module/") ) + ShortName.Lower();
149 
150  gPrefs->Read( PrefName, &iStatus, kModuleNew );
151  // fix up a bad status.
152  if( iStatus > kModuleNew )
153  iStatus=kModuleNew;
154  return iStatus;
155 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
wxString ModulePrefs::HelpPageName ( )
overridevirtual

Reimplemented from PrefsPanel.

Definition at line 166 of file ModulePrefs.cpp.

167 {
168  return "Modules_Preferences";
169 }
void ModulePrefs::Populate ( )
private

Definition at line 84 of file ModulePrefs.cpp.

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

Referenced by ModulePrefs().

85 {
87  //------------------------- Main section --------------------
88  // Now construct the GUI itself.
89  // Use 'eIsCreatingFromPrefs' so that the GUI is
90  // initialised with values from gPrefs.
93  // ----------------------- End of main section --------------
94 }
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
void GetAllModuleStatuses()
Definition: ModulePrefs.cpp:42
void PopulateOrExchange(ShuttleGui &S) override
Definition: ModulePrefs.cpp:96
void ModulePrefs::PopulateOrExchange ( ShuttleGui S)
override

Definition at line 96 of file ModulePrefs.cpp.

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

Referenced by Commit(), and Populate().

97 {
98  wxArrayString StatusChoices;
99  StatusChoices.Add( _("Disabled" ) );
100  StatusChoices.Add( _("Enabled" ) );
101  StatusChoices.Add( _("Ask" ) );
102  StatusChoices.Add( _("Failed" ) );
103  StatusChoices.Add( _("New" ) );
104 
105  S.SetBorder(2);
106  S.StartScroller();
107 
108  S.StartStatic( {} );
109  {
110  S.AddFixedText(_("These are experimental modules. Enable them only if you've read the Audacity Manual\nand know what you are doing.") );
111  S.AddFixedText(wxString(wxT(" ")) + _("'Ask' means Audacity will ask if you want to load the module each time it starts.") );
112  S.AddFixedText(wxString(wxT(" ")) + _("'Failed' means Audacity thinks the module is broken and won't run it.") );
113  S.AddFixedText(wxString(wxT(" ")) + _("'New' means no choice has been made yet.") );
114  S.AddFixedText(_("Changes to these settings only take effect when Audacity starts up."));
115  {
116  S.StartMultiColumn( 2 );
117  int i;
118  for(i=0;i<(int)mModules.GetCount();i++)
119  S.TieChoice( mModules[i], mStatuses[i], &StatusChoices );
120  S.EndMultiColumn();
121  }
122  if( mModules.GetCount() < 1 )
123  {
124  S.AddFixedText( _("No modules were found") );
125  }
126  }
127  S.EndStatic();
128  S.EndScroller();
129 }
wxChoice * TieChoice(const wxString &Prompt, WrappedType &WrappedRef, const wxArrayString *pChoices)
std::vector< int > mStatuses
Definition: ModulePrefs.h:50
void EndMultiColumn()
void EndScroller()
Definition: ShuttleGui.cpp:828
wxArrayString mModules
Definition: ModulePrefs.h:49
wxScrolledWindow * StartScroller(int iStyle=0)
Definition: ShuttleGui.cpp:795
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
void AddFixedText(const wxString &Str, bool bCenter=false)
Definition: ShuttleGui.cpp:397
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
wxStaticBox * StartStatic(const wxString &Str, int iProp=0)
Definition: ShuttleGui.cpp:763
void SetBorder(int Border)
Definition: ShuttleGui.h:286
void ModulePrefs::SetModuleStatus ( const wxString &  fname,
int  iStatus 
)
static

Definition at line 157 of file ModulePrefs.cpp.

References gPrefs.

Referenced by Commit(), and ModuleManager::Initialize().

157  {
158  wxString ShortName = wxFileName( fname ).GetName();
159  wxString PrefName = wxString( wxT("/Module/") ) + ShortName.Lower();
160  gPrefs->Write( PrefName, iStatus );
161  PrefName = wxString( wxT("/ModulePath/") ) + ShortName.Lower();
162  gPrefs->Write( PrefName, fname );
163  gPrefs->Flush();
164 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73

Member Data Documentation

wxArrayString ModulePrefs::mModules
private

Definition at line 49 of file ModulePrefs.h.

Referenced by GetAllModuleStatuses(), and PopulateOrExchange().

wxArrayString ModulePrefs::mPaths
private

Definition at line 51 of file ModulePrefs.h.

Referenced by Commit(), and GetAllModuleStatuses().

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

Definition at line 50 of file ModulePrefs.h.

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


The documentation for this class was generated from the following files: