spek

Acoustic spectrum analyser
git clone http://git.hanabi.in/repos/spek.git
Log | Files | Refs | README

commit 4f8de5bdea721a0ae183fb00a28914c10d5f5afb
parent 7e5ca1765a057aee5d65bd9df83dd34fe4618fb3
Author: Alexander Kojevnikov <alexander@kojevnikov.com>
Date:   Fri, 10 Aug 2012 21:44:09 -0700

Open file dialogue

Diffstat:
Msrc/spek-window.cc | 20++++++++++++++++++++
Msrc/spek-window.hh | 5+++--
Msrc/spek-window.vala | 17-----------------
3 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/src/spek-window.cc b/src/spek-window.cc @@ -77,6 +77,22 @@ SpekWindow::SpekWindow(const wxString& title) : wxFrame(NULL, -1, title) void SpekWindow::OnOpen(wxCommandEvent& WXUNUSED(event)) { + static wxString cur_dir = wxGetHomeDir(); + wxFileDialog *dlg = new wxFileDialog( + this, + _("Open File"), + cur_dir, + wxEmptyString, + wxT("*.*"), + wxFD_OPEN + ); + + if (dlg->ShowModal() == wxID_OK) { + cur_dir = dlg->GetDirectory(); + Open(dlg->GetPath()); + } + + dlg->Destroy(); } void SpekWindow::OnSave(wxCommandEvent& WXUNUSED(event)) @@ -95,3 +111,7 @@ void SpekWindow::OnPreferences(wxCommandEvent& WXUNUSED(event)) void SpekWindow::OnAbout(wxCommandEvent& WXUNUSED(event)) { } + +void SpekWindow::Open(const wxString& path) +{ +} diff --git a/src/spek-window.hh b/src/spek-window.hh @@ -26,14 +26,15 @@ class SpekWindow : public wxFrame public: SpekWindow(const wxString& title); -protected: +private: void OnOpen(wxCommandEvent& event); void OnSave(wxCommandEvent& event); void OnExit(wxCommandEvent& event); void OnPreferences(wxCommandEvent& event); void OnAbout(wxCommandEvent& event); -private: + void Open(const wxString& path); + DECLARE_EVENT_TABLE() }; diff --git a/src/spek-window.vala b/src/spek-window.vala @@ -110,23 +110,6 @@ namespace Spek { title = _("Spek - %s").printf (Path.get_basename (file_name)); } - private void on_file_open () { - var chooser = new FileChooserDialog ( - _("Open File"), this, FileChooserAction.OPEN, - Stock.CANCEL, ResponseType.CANCEL, - Stock.OPEN, ResponseType.ACCEPT, null); - chooser.set_default_response (ResponseType.ACCEPT); - chooser.select_multiple = false; - chooser.set_current_folder (cur_dir); - chooser.add_filter (filter_all); - chooser.add_filter (filter_audio); - chooser.set_filter (filter_audio); - if (chooser.run () == ResponseType.ACCEPT) { - open_file (chooser.get_filename ()); - } - chooser.destroy (); - } - private void on_file_save () { var chooser = new FileChooserDialog ( _("Save Spectrogram"), this, FileChooserAction.SAVE,