settingsdlg.cpp

00001 
00002 // Name:        settingsdlg.cpp
00003 // Purpose:     wxPackageManagerSettingsDlg
00004 // Author:      Francesco Montorsi
00005 // Modified by: 
00006 // Created:     25/07/2006 17:27:47
00007 // RCS-ID:      $Id: settingsdlg.cpp,v 1.6 2007/02/01 20:28:15 frm Exp $
00008 // Copyright:   (c) 2006 Francesco Montorsi
00009 // Licence:     wxWidgets license
00011 
00012 
00013 // For compilers that support precompilation, includes "wx/wx.h".
00014 #include "wx/wxprec.h"
00015 
00016 #ifdef __BORLANDC__
00017 #pragma hdrstop
00018 #endif
00019 
00020 #ifndef WX_PRECOMP
00021 #include "wx/wx.h"
00022 #endif
00023 
00024 #include "wx/config.h"
00025 #include "wx/bookctrl.h"
00026 #include "wx/filepicker.h"
00027 #include "wx/stdpaths.h"
00028 
00029 #include "guipm/settingsdlg.h"
00030 #include "guipm/presetspanel.h"
00031 #include "guipm/viewerpanel.h"
00032 #include "guipm/browsepanel.h"
00033 #include "guipm/compilerpanel.h"
00034 #include "guipm/wxbuildpropdlg.h"
00035 #include "guipm/smartmsgdlg.h"
00036 
00037 #include "wxp/wxp.h"
00038 #include "wxp/package.h"
00039 
00040 
00041 // ----------------------------------------------------------------------------
00042 // wxPackageManagerSettingsDlg
00043 // ----------------------------------------------------------------------------
00044 
00045 IMPLEMENT_DYNAMIC_CLASS( wxPackageManagerSettingsDlg, wxPropertySheetDialog )
00046 BEGIN_EVENT_TABLE( wxPackageManagerSettingsDlg, wxPropertySheetDialog )
00047 
00048     // wxwidgets build panel events
00049     EVT_BUTTON( ID_SETTINGS_WX_ADDNEW, 
00050                 wxPackageManagerSettingsDlg::OnWxBuildAddNew )
00051     EVT_BUTTON( ID_SETTINGS_WX_EDIT, 
00052                 wxPackageManagerSettingsDlg::OnWxBuildEdit )
00053     EVT_BUTTON( ID_SETTINGS_WX_DELETE, 
00054                 wxPackageManagerSettingsDlg::OnWxBuildDelete )
00055     EVT_BUTTON( ID_SETTINGS_WX_AUTODETECT,
00056                 wxPackageManagerSettingsDlg::OnWxBuildAutodetect ) 
00057     EVT_LISTBOX_DCLICK( ID_SETTINGS_LIST,
00058                 wxPackageManagerSettingsDlg::OnWxBuildEdit ) 
00059 
00060     // local repository panel events
00061     EVT_BUTTON( ID_SETTINGS_LOCALREPO_ADDPATH, 
00062                 wxPackageManagerSettingsDlg::OnLocalRepoAddPath )
00063     EVT_BUTTON( ID_SETTINGS_LOCALREPO_EDITPATH, 
00064                 wxPackageManagerSettingsDlg::OnLocalRepoEditPath )
00065     EVT_BUTTON( ID_SETTINGS_LOCALREPO_OPENPATH,
00066                 wxPackageManagerSettingsDlg::OnLocalRepoOpenPath )
00067     EVT_BUTTON( ID_SETTINGS_LOCALREPO_DELETEPATH, 
00068                 wxPackageManagerSettingsDlg::OnLocalRepoDeletePath )
00069     EVT_LISTBOX_DCLICK( ID_SETTINGS_LOCALREPO_PATHS,
00070                 wxPackageManagerSettingsDlg::OnLocalRepoEditPath ) 
00071 
00072     // misc
00073     EVT_BUTTON( wxID_OK, wxPackageManagerSettingsDlg::OnOK )
00074     EVT_UPDATE_UI( wxID_ANY, wxPackageManagerSettingsDlg::OnUpdateUI )
00075 
00076 END_EVENT_TABLE()
00077 
00078 wxPackageManagerSettingsDlg::wxPackageManagerSettingsDlg( )
00079 {
00080 }
00081 
00082 wxPackageManagerSettingsDlg::wxPackageManagerSettingsDlg( wxWindow* parent, wxWindowID id, wxConfigBase *cfg, const wxString &path, wxPackageViewerPanel *vp, wxPackageBrowserPanel *bp )
00083 {
00084     Create(parent, id, cfg, path, vp, bp);
00085 }
00086 
00087 bool wxPackageManagerSettingsDlg::Create( wxWindow* parent, wxWindowID id, wxConfigBase *cfg, const wxString &path, wxPackageViewerPanel *vp, wxPackageBrowserPanel *bp )
00088 {
00090     m_pViewMode = NULL;
00091     m_pLoadWxDocs = NULL;
00092     m_pAutoLoadWxPackages = NULL;
00093     m_pDownloadPicker = NULL;
00094     m_pDecompressionPicker = NULL;
00095     m_pInstallationPicker = NULL;
00096     m_pQuestionList = NULL;
00097     m_pPathList = NULL;
00098     m_pWxBuildList = NULL;
00100 
00101     // init objects whose settings will be updated through this dialog
00102     m_pCfg = cfg;
00103     m_strPath = path;
00104     m_pViewerPanel = vp;
00105     m_pBrowserPanel = bp;
00106 
00107     SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS);
00108     wxPropertySheetDialog::Create( parent, id, wxT("wxWidgets Package Manager Settings"),
00109                                     wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
00110     CreateButtons(wxOK|wxCANCEL|wxHELP);
00111     CreateControls();
00112     LayoutDialog();
00113     Centre();
00114     return true;
00115 }
00116 
00117 void wxPackageManagerSettingsDlg::CreateControls()
00118 {    
00120 
00121     wxPanel* itemPanel2 = new wxPanel( GetBookCtrl(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
00122     wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL);
00123     itemPanel2->SetSizer(itemBoxSizer3);
00124 
00125     wxStaticBox* itemStaticBoxSizer4Static = new wxStaticBox(itemPanel2, wxID_ANY, _("Miscellaneous"));
00126     wxStaticBoxSizer* itemStaticBoxSizer4 = new wxStaticBoxSizer(itemStaticBoxSizer4Static, wxVERTICAL);
00127     itemBoxSizer3->Add(itemStaticBoxSizer4, 0, wxGROW|wxALL, 5);
00128     wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxHORIZONTAL);
00129     itemStaticBoxSizer4->Add(itemBoxSizer5, 0, wxGROW, 5);
00130     wxStaticText* itemStaticText6 = new wxStaticText( itemPanel2, wxID_STATIC, _("View mode for package summary and details:"), wxDefaultPosition, wxDefaultSize, 0 );
00131     itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5);
00132 
00133     wxString* m_pViewModeStrings = NULL;
00134     m_pViewMode = new wxChoice( itemPanel2, ID_SETTINGS_VIEWMODE, wxDefaultPosition, wxDefaultSize, 0, m_pViewModeStrings, 0 );
00135     itemBoxSizer5->Add(m_pViewMode, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
00136 
00137     m_pLoadWxDocs = new wxCheckBox( itemPanel2, ID_SETTINGS_LOADWXDOC, _("Load wxWidgets manual in the 'Documentation' tab"), wxDefaultPosition, wxDefaultSize, 0 );
00138     m_pLoadWxDocs->SetValue(false);
00139     itemStaticBoxSizer4->Add(m_pLoadWxDocs, 0, wxGROW|wxALL, 5);
00140 
00141     m_pAutoLoadWxPackages = new wxCheckBox( itemPanel2, ID_SETTINGS_AUTOLOAD_WXPACKAGES, _("Load local packages at startup"), wxDefaultPosition, wxDefaultSize, 0 );
00142     m_pAutoLoadWxPackages->SetValue(true);
00143     itemStaticBoxSizer4->Add(m_pAutoLoadWxPackages, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);
00144 
00145     wxStaticBox* itemStaticBoxSizer10Static = new wxStaticBox(itemPanel2, wxID_ANY, _("Directories"));
00146     wxStaticBoxSizer* itemStaticBoxSizer10 = new wxStaticBoxSizer(itemStaticBoxSizer10Static, wxVERTICAL);
00147     itemBoxSizer3->Add(itemStaticBoxSizer10, 0, wxGROW|wxALL, 5);
00148     wxFlexGridSizer* itemFlexGridSizer11 = new wxFlexGridSizer(3, 2, 0, 0);
00149     itemFlexGridSizer11->AddGrowableRow(0);
00150     itemFlexGridSizer11->AddGrowableRow(1);
00151     itemFlexGridSizer11->AddGrowableRow(2);
00152     itemFlexGridSizer11->AddGrowableCol(1);
00153     itemStaticBoxSizer10->Add(itemFlexGridSizer11, 0, wxGROW, 5);
00154     wxStaticText* itemStaticText12 = new wxStaticText( itemPanel2, wxID_STATIC, _("Default download folder:"), wxDefaultPosition, wxDefaultSize, 0 );
00155     itemFlexGridSizer11->Add(itemStaticText12, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5);
00156 
00157     m_pDownloadPicker = new wxDirPickerCtrl( itemPanel2, ID_SETTINGS_DOWNLOAD_PICKER );
00158     itemFlexGridSizer11->Add(m_pDownloadPicker, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
00159 
00160     wxStaticText* itemStaticText14 = new wxStaticText( itemPanel2, wxID_STATIC, _("Default decompression folder:"), wxDefaultPosition, wxDefaultSize, 0 );
00161     itemFlexGridSizer11->Add(itemStaticText14, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5);
00162 
00163     m_pDecompressionPicker = new wxDirPickerCtrl( itemPanel2, ID_SETTINGS_DOWNLOAD_PICKER );
00164     itemFlexGridSizer11->Add(m_pDecompressionPicker, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
00165 
00166     wxStaticText* itemStaticText16 = new wxStaticText( itemPanel2, wxID_STATIC, _("Default installation folder:"), wxDefaultPosition, wxDefaultSize, 0 );
00167     itemFlexGridSizer11->Add(itemStaticText16, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5);
00168 
00169     m_pInstallationPicker = new wxDirPickerCtrl( itemPanel2, ID_SETTINGS_DOWNLOAD_PICKER );
00170     itemFlexGridSizer11->Add(m_pInstallationPicker, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
00171 
00172     wxStaticBox* itemStaticBoxSizer18Static = new wxStaticBox(itemPanel2, wxID_ANY, _("Questions"));
00173     wxStaticBoxSizer* itemStaticBoxSizer18 = new wxStaticBoxSizer(itemStaticBoxSizer18Static, wxVERTICAL);
00174     itemBoxSizer3->Add(itemStaticBoxSizer18, 1, wxGROW|wxALL, 5);
00175     wxString* m_pQuestionListStrings = NULL;
00176     m_pQuestionList = new wxCheckListBox( itemPanel2, ID_SETTINGS_QUESTIONS_LIST, wxDefaultPosition, wxDefaultSize, 0, m_pQuestionListStrings, wxLB_SINGLE|wxLB_NEEDED_SB );
00177     itemStaticBoxSizer18->Add(m_pQuestionList, 1, wxGROW|wxALL, 5);
00178 
00179     itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
00180 
00181     GetBookCtrl()->AddPage(itemPanel2, _("General"));
00182 
00183     wxPanel* itemPanel21 = new wxPanel( GetBookCtrl(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
00184     wxBoxSizer* itemBoxSizer22 = new wxBoxSizer(wxVERTICAL);
00185     itemPanel21->SetSizer(itemBoxSizer22);
00186 
00187     wxStaticText* itemStaticText23 = new wxStaticText( itemPanel21, wxID_STATIC, _("The following directories are scanned automatically for WXZ \npackages and the results are listed as 'local packages':"), wxDefaultPosition, wxDefaultSize, 0 );
00188     itemBoxSizer22->Add(itemStaticText23, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5);
00189 
00190     wxBoxSizer* itemBoxSizer24 = new wxBoxSizer(wxHORIZONTAL);
00191     itemBoxSizer22->Add(itemBoxSizer24, 1, wxGROW, 5);
00192     wxString* m_pPathListStrings = NULL;
00193     m_pPathList = new wxListBox( itemPanel21, ID_SETTINGS_LOCALREPO_PATHS, wxDefaultPosition, wxDefaultSize, 0, m_pPathListStrings, wxLB_SINGLE|wxLB_HSCROLL );
00194     itemBoxSizer24->Add(m_pPathList, 1, wxGROW|wxALL, 5);
00195 
00196     wxBoxSizer* itemBoxSizer26 = new wxBoxSizer(wxVERTICAL);
00197     itemBoxSizer24->Add(itemBoxSizer26, 0, wxALIGN_BOTTOM, 5);
00198     wxButton* itemButton27 = new wxButton( itemPanel21, ID_SETTINGS_LOCALREPO_ADDPATH, _("Add new..."), wxDefaultPosition, wxDefaultSize, 0 );
00199     itemBoxSizer26->Add(itemButton27, 0, wxGROW|wxALL, 5);
00200 
00201     wxButton* itemButton28 = new wxButton( itemPanel21, ID_SETTINGS_LOCALREPO_EDITPATH, _("Edit..."), wxDefaultPosition, wxDefaultSize, 0 );
00202     itemBoxSizer26->Add(itemButton28, 0, wxGROW|wxALL, 5);
00203 
00204     wxButton* itemButton29 = new wxButton( itemPanel21, ID_SETTINGS_LOCALREPO_OPENPATH, _("Open..."), wxDefaultPosition, wxDefaultSize, 0 );
00205     itemBoxSizer26->Add(itemButton29, 0, wxGROW|wxALL, 5);
00206 
00207     wxButton* itemButton30 = new wxButton( itemPanel21, ID_SETTINGS_LOCALREPO_DELETEPATH, _("Delete"), wxDefaultPosition, wxDefaultSize, 0 );
00208     itemBoxSizer26->Add(itemButton30, 0, wxGROW|wxALL, 5);
00209 
00210     GetBookCtrl()->AddPage(itemPanel21, _("Local repositories"));
00211 
00212     wxPanel* itemPanel31 = new wxPanel( GetBookCtrl(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
00213     wxBoxSizer* itemBoxSizer32 = new wxBoxSizer(wxVERTICAL);
00214     itemPanel31->SetSizer(itemBoxSizer32);
00215 
00216     wxStaticText* itemStaticText33 = new wxStaticText( itemPanel31, wxID_STATIC, _("Available wxWidgets builds:"), wxDefaultPosition, wxDefaultSize, 0 );
00217     itemBoxSizer32->Add(itemStaticText33, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
00218 
00219     wxBoxSizer* itemBoxSizer34 = new wxBoxSizer(wxHORIZONTAL);
00220     itemBoxSizer32->Add(itemBoxSizer34, 1, wxGROW, 5);
00221     wxString* m_pWxBuildListStrings = NULL;
00222     m_pWxBuildList = new wxListBox( itemPanel31, ID_SETTINGS_LIST, wxDefaultPosition, wxDefaultSize, 0, m_pWxBuildListStrings, wxLB_SINGLE|wxLB_HSCROLL );
00223     itemBoxSizer34->Add(m_pWxBuildList, 1, wxGROW|wxALL, 5);
00224 
00225     wxBoxSizer* itemBoxSizer36 = new wxBoxSizer(wxVERTICAL);
00226     itemBoxSizer34->Add(itemBoxSizer36, 0, wxALIGN_BOTTOM, 5);
00227     wxButton* itemButton37 = new wxButton( itemPanel31, ID_SETTINGS_WX_ADDNEW, _("Add new..."), wxDefaultPosition, wxDefaultSize, 0 );
00228     itemBoxSizer36->Add(itemButton37, 0, wxGROW|wxALL, 5);
00229 
00230     wxButton* itemButton38 = new wxButton( itemPanel31, ID_SETTINGS_WX_EDIT, _("Edit..."), wxDefaultPosition, wxDefaultSize, 0 );
00231     itemBoxSizer36->Add(itemButton38, 0, wxGROW|wxALL, 5);
00232 
00233     wxButton* itemButton39 = new wxButton( itemPanel31, ID_SETTINGS_WX_DELETE, _("Delete"), wxDefaultPosition, wxDefaultSize, 0 );
00234     itemBoxSizer36->Add(itemButton39, 0, wxGROW|wxALL, 5);
00235 
00236     wxButton* itemButton40 = new wxButton( itemPanel31, ID_SETTINGS_WX_AUTODETECT, _("Autodetect..."), wxDefaultPosition, wxDefaultSize, 0 );
00237     itemBoxSizer36->Add(itemButton40, 0, wxGROW|wxALL, 5);
00238 
00239     GetBookCtrl()->AddPage(itemPanel31, _("wxWidgets"));
00240 
00242 
00243     // init view mode list
00244     const wxPackageHTMLOutputFormatHashMap &h = wxPackageInfo::s_hashmapHTMLFormats;
00245     for (wxPackageHTMLOutputFormatHashMap::const_iterator it = h.begin();
00246          it != h.end(); it++)
00247     {
00248         const wxPackageHTMLOutputFormat &fmt = it->second;
00249 
00250         // show to the user only those viewformats coinceived to the used with wxHtmlWindow!
00251         if (fmt.GetContext() == wxPSIC_WXHTML)
00252             m_pViewMode->Append(fmt.GetName());
00253     }
00254 
00255     // init wxWidgets list property panel
00256     m_arrBuilds = wxWidgetsBuildArray::s_arrWxBuilds;
00257     for (size_t i=0; i < m_arrBuilds.GetCount(); i++)
00258         m_pWxBuildList->Append(m_arrBuilds[i].GetUserFriendlyName());
00259 
00260     // add a static text above the preset panel
00261     wxPanel *panel = new wxPanel(GetBookCtrl(), wxID_ANY);
00262     wxSizer *sz = new wxBoxSizer(wxVERTICAL);
00263     sz->Add(new wxStaticText(panel, wxID_ANY, 
00264                              wxT("Here you can edit the default values of the set of standard options.\nNote that are shown all options for all compilers and platforms.")), 0, wxGROW|wxALL, 5);
00265     m_pPresetsPanel = new wxPackagePresetsPanel(panel, wxID_ANY);
00266     sz->Add(m_pPresetsPanel, 1, wxGROW|wxALL, 5);
00267     panel->SetSizer(sz);
00268     sz->SetSizeHints(panel);
00269 
00270     // build subpanels
00271     m_pCompilerOptPanel = new wxCompilerSettingsPanel(GetBookCtrl(), wxID_ANY);
00272     m_pCompilerOptPanel->InitAsGlobal();
00273 
00274     GetBookCtrl()->AddPage(panel, _("Options"));
00275     GetBookCtrl()->AddPage(m_pCompilerOptPanel, _("Compiler"));
00276 }
00277 
00278 bool wxPackageManagerSettingsDlg::LoadSettings()
00279 {
00280     if (m_pViewerPanel)
00281         m_pLoadWxDocs->SetValue(
00282                 m_pViewerPanel->GetDocs().Index(wxT("wx.htb")) != wxNOT_FOUND);
00283     if (m_pViewerPanel)
00284     {
00285         wxString name = m_pViewerPanel->GetViewModeName();
00286 
00287         // see how m_pViewMode listbox is filled above...
00288         wxASSERT_MSG(m_pViewMode->FindString(name) != wxNOT_FOUND,
00289                      wxT("maybe the viewformat in use is not compatible with wxHtmlWindow??"));
00290 
00291         m_pViewMode->SetStringSelection(name);
00292     }
00293 
00294     m_pDownloadPicker->SetPath(m_pBrowserPanel->GetDefaultDownloadPath());
00295     m_pDecompressionPicker->SetPath(m_pBrowserPanel->GetDefaultDecompressionPath());
00296     m_pInstallationPicker->SetPath(m_pBrowserPanel->GetDefaultInstallationPath());
00297     m_pAutoLoadWxPackages->SetValue(m_pBrowserPanel->IsAutoLoadLocalPackagesEnabled());
00298 
00299     m_pPathList->Clear();
00300     m_pPathList->Append(wxPackage::s_arrLocalRepo);
00301 
00302     // load questions and their "do not ask again" status
00303     wxStringHashMap::iterator it;
00304     for( it = wxSmartMessageDialog::s_hashDesc.begin(); 
00305          it != wxSmartMessageDialog::s_hashDesc.end(); ++it )
00306     {
00307         wxString key = it->first, desc = it->second;
00308 
00309         // NB: we can't use client data with a wxCheckListBox so we rather
00310         //     use an internal array...
00311         m_questionListKeynames.Add(key);
00312 
00313         int last = m_pQuestionList->Append(desc);
00314         m_pQuestionList->Check(last, wxSmartMessageDialog::GetValueFor(key));
00315     }
00316 
00317     return true;
00318 }
00319 
00320 void wxPackageManagerSettingsDlg::ApplySettings()
00321 {
00322     m_pPresetsPanel->ApplySettings();
00323 
00324     // apply settings to the linked windows
00325 
00326     m_pViewerPanel->SetViewMode(m_pViewMode->GetStringSelection().MakeLower());
00327 
00328     bool wxdocs = m_pViewerPanel->GetDocs().Index(wxT("wx.htb")) != wxNOT_FOUND;
00329     if (m_pLoadWxDocs->GetValue())
00330         if (wxdocs)
00331             m_pViewerPanel->GetDocs().Remove(wxT("wx.htb"));
00332     else
00333         if (!wxdocs)
00334             m_pViewerPanel->GetDocs().Add(wxT("wx.htb"));
00335 
00336     m_pBrowserPanel->SetDefaultDownloadPath(m_pDownloadPicker->GetPath());
00337     m_pBrowserPanel->SetDefaultDecompressionPath(m_pDecompressionPicker->GetPath());
00338     m_pBrowserPanel->SetDefaultInstallationPath(m_pInstallationPicker->GetPath());
00339     m_pBrowserPanel->SetAutoLoadLocalPackages(m_pAutoLoadWxPackages->GetValue());
00340 
00341     wxPackage::s_arrLocalRepo = m_pPathList->GetStrings();
00342 
00343     // compiler paths could have changed - update all build-system options
00344     // in all loaded packages
00345     m_pBrowserPanel->GetLocalPackages().InvalidateCachedSubstHashMap();
00346     m_pBrowserPanel->GetNewPackages().InvalidateCachedSubstHashMap();
00347 
00348     // update also global list of wxwidgets builds
00349     wxWidgetsBuildArray::s_arrWxBuilds = m_arrBuilds;
00350 
00351     // save "do not ask again" status of questions
00352     for (size_t i=0; i<m_pQuestionList->GetCount(); i++)
00353         wxSmartMessageDialog::SetValueFor(m_questionListKeynames[i],
00354                                           m_pQuestionList->IsChecked(i));
00355 
00356     // update global selected compiler
00357     wxCompilerSettings::SetDefaultFormat(m_pCompilerOptPanel->GetSelCompilerFormat());
00358 }
00359 
00360 
00361 
00362 
00363 //----------------------------------------------------------------------------
00364 // wxPackageManagerSettingsDlg - event handlers
00365 //----------------------------------------------------------------------------
00366 
00367 void wxPackageManagerSettingsDlg::OnLocalRepoAddPath(wxCommandEvent &)
00368 {
00369     wxDirDialog dlg(this);
00370     if (dlg.ShowModal() == wxID_OK)
00371         m_pPathList->SetSelection(m_pPathList->Append(dlg.GetPath()));
00372 }
00373 
00374 void wxPackageManagerSettingsDlg::OnLocalRepoDeletePath(wxCommandEvent &)
00375 {
00376     m_pPathList->Delete(m_pPathList->GetSelection());
00377 }
00378 
00379 void wxPackageManagerSettingsDlg::OnLocalRepoEditPath(wxCommandEvent &)
00380 {
00381     wxDirDialog dlg(this);
00382 
00383     dlg.SetPath(m_pPathList->GetStringSelection());
00384     if (dlg.ShowModal() == wxID_OK)
00385         m_pPathList->SetString(m_pPathList->GetSelection(), dlg.GetPath());
00386 }
00387 
00388 void wxPackageManagerSettingsDlg::OnLocalRepoOpenPath(wxCommandEvent &)
00389 {
00390 #ifdef __WXGTK__
00391     wxFileName fn = wxFileName::DirName(m_pPathList->GetStringSelection());
00392     wxLaunchDefaultBrowser(wxFileSystem::FileNameToURL(fn));
00393 #elif defined(__WXMSW__)
00394     wxExecute(wxT("explorer ") + m_pPathList->GetStringSelection());
00395 #endif
00396 }
00397 
00398 void wxPackageManagerSettingsDlg::OnWxBuildAddNew(wxCommandEvent &)
00399 {
00400     wxPackageWXBuildPropDlg dlg(this);
00401     if (dlg.ShowModal() == wxID_OK)
00402     {
00403         wxWidgetsBuild b(dlg.GetBuild());
00404 
00405         m_pWxBuildList->SetSelection(
00406             m_pWxBuildList->Append(b.GetUserFriendlyName()));
00407         m_arrBuilds.Add(b);
00408     }
00409 }
00410 
00411 void wxPackageManagerSettingsDlg::OnWxBuildEdit(wxCommandEvent &)
00412 {
00413     size_t n = m_pWxBuildList->GetSelection();
00414 
00415     wxPackageWXBuildPropDlg dlg(this);
00416     dlg.SetBuild(m_arrBuilds[n]);
00417     if (dlg.ShowModal() == wxID_OK)
00418     {
00419         wxWidgetsBuild b(dlg.GetBuild());
00420         m_pWxBuildList->SetString(n, b.GetUserFriendlyName());
00421         m_arrBuilds[n] = b;
00422     }
00423 }
00424 
00425 void wxPackageManagerSettingsDlg::OnWxBuildDelete(wxCommandEvent &)
00426 {
00427     size_t n = m_pWxBuildList->GetSelection();
00428 
00429     m_arrBuilds.RemoveAt(n);
00430     m_pWxBuildList->Delete(n);
00431 }
00432 
00433 void wxPackageManagerSettingsDlg::OnWxBuildAutodetect(wxCommandEvent &)
00434 {
00435     // TODO
00436 }
00437 
00438 void wxPackageManagerSettingsDlg::OnOK(wxCommandEvent &event)
00439 {
00440     wxString downloadpath = m_pDownloadPicker->GetPath();
00441 
00442     // should this event be 'vetoed' ?
00443     if (m_pPathList->FindString(downloadpath) == wxNOT_FOUND)
00444     {
00445         int reply = wxMessageBox(wxString::Format(
00446             _("The directory currently chosen as destination for package downloads is not listed among the directories scanned for packages (see the 'Local repositories' tab). This means that when packages are downloaded, they won't show in the 'Local packages' tab panel.\n\nDo you want to add '%s' in the directories used as local repositories ?"),
00447             downloadpath.c_str()), wxT("Warning"), 
00448             wxICON_EXCLAMATION|wxYES_NO|wxCANCEL);
00449 
00450         switch (reply)
00451         {
00452         case wxYES:
00453             m_pPathList->Append(downloadpath);
00454             event.Skip();
00455             break;
00456 
00457         case wxNO:
00458             event.Skip();   // close this window and leave it as is
00459             break;
00460 
00461         case wxCANCEL:
00462 
00463             // do not close this window
00464             return;
00465         }
00466     }
00467 
00468     // do default processing
00469     event.Skip();
00470 }
00471 
00472 void wxPackageManagerSettingsDlg::OnUpdateUI(wxUpdateUIEvent &)
00473 {
00474     bool toenable;
00475     
00476     toenable = m_pPathList->GetSelection() != wxNOT_FOUND;
00477     FindWindowById(ID_SETTINGS_LOCALREPO_EDITPATH, this)->Enable(toenable);
00478     FindWindowById(ID_SETTINGS_LOCALREPO_OPENPATH, this)->Enable(toenable);
00479     FindWindowById(ID_SETTINGS_LOCALREPO_DELETEPATH, this)->Enable(toenable);
00480 
00481     toenable = m_pWxBuildList->GetSelection() != wxNOT_FOUND;
00482     FindWindowById(ID_SETTINGS_WX_EDIT, this)->Enable(toenable);
00483     FindWindowById(ID_SETTINGS_WX_DELETE, this)->Enable(toenable);
00484 }
00485 

Generated on Thu Feb 1 22:14:31 2007 for wxWidgets Package Manager by  doxygen 1.5.1-p1