From 4f8de5bdea721a0ae183fb00a28914c10d5f5afb Mon Sep 17 00:00:00 2001 From: Alexander Kojevnikov Date: Fri, 10 Aug 2012 21:44:09 -0700 Subject: [PATCH] Open file dialogue --- src/spek-window.cc | 20 ++++++++++++++++++++ src/spek-window.hh | 5 +++-- src/spek-window.vala | 17 ----------------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/spek-window.cc b/src/spek-window.cc index e25d546..039e195 100644 --- 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 index f7163c0..6bc031c 100644 --- 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 index 8ea9b78..3ee26f0 100644 --- 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,