spek

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

commit 063d0433c0dd2e92cd9e1f84b3006a29a105fe1e
parent 40096483971a5678372729adce322778216cb1f4
Author: Alexander Kojevnikov <alexander@kojevnikov.com>
Date:   Sun, 12 Aug 2012 18:34:24 -0700

Show opened file name in the window title

Diffstat:
Msrc/spek-window.cc | 12+++++++++++-
Msrc/spek-window.hh | 2+-
Msrc/spek-window.vala | 4----
Msrc/spek.cc | 2+-
4 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/spek-window.cc b/src/spek-window.cc @@ -17,6 +17,7 @@ */ #include <wx/artprov.h> +#include <wx/filename.h> #include "spek-window.hh" @@ -28,8 +29,9 @@ BEGIN_EVENT_TABLE(SpekWindow, wxFrame) EVT_MENU(wxID_ABOUT, SpekWindow::OnAbout) END_EVENT_TABLE() -SpekWindow::SpekWindow(const wxString& title) : wxFrame(NULL, -1, title) +SpekWindow::SpekWindow() : wxFrame(NULL, -1, wxEmptyString) { + SetTitle(_("Spek - Acoustic Spectrum Analyser")); // TODO: test on all platforms SetIcon(wxIcon(wxT("spek"))); @@ -167,4 +169,12 @@ void SpekWindow::OnAbout(wxCommandEvent& WXUNUSED(event)) void SpekWindow::Open(const wxString& path) { + wxFileName file_name(path); + if (file_name.FileExists()) { + wxString full_name = file_name.GetFullName(); + // TRANSLATORS: window title, %s is replaced with the file name + wxString title = wxString::Format(_("Spek - %s"), full_name.c_str()); + // TODO: make sure the above works on all platforms, both in x32 and x64. + SetTitle(title); + } } diff --git a/src/spek-window.hh b/src/spek-window.hh @@ -24,7 +24,7 @@ class SpekWindow : public wxFrame { public: - SpekWindow(const wxString& title); + SpekWindow(); private: void OnOpen(wxCommandEvent& event); diff --git a/src/spek-window.vala b/src/spek-window.vala @@ -94,11 +94,7 @@ namespace Spek { } private void open_file (string file_name) { - cur_dir = Path.get_dirname (file_name); spectrogram.open (file_name); - - // TRANSLATORS: window title, %s is replaced with the file name - title = _("Spek - %s").printf (Path.get_basename (file_name)); } private void on_file_save () { diff --git a/src/spek.cc b/src/spek.cc @@ -43,7 +43,7 @@ bool Spek::OnInit() return false; } - SpekWindow *window = new SpekWindow(_("Spek - Acoustic Spectrum Analyser")); + SpekWindow *window = new SpekWindow(); window->Show(true); SetTopWindow(window); return true;