From 063d0433c0dd2e92cd9e1f84b3006a29a105fe1e Mon Sep 17 00:00:00 2001 From: Alexander Kojevnikov Date: Sun, 12 Aug 2012 18:34:24 -0700 Subject: [PATCH] Show opened file name in the window title --- src/spek-window.cc | 12 +++++++++++- src/spek-window.hh | 2 +- src/spek-window.vala | 4 ---- src/spek.cc | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/spek-window.cc b/src/spek-window.cc index 3cab0e1..07d1969 100644 --- a/src/spek-window.cc +++ b/src/spek-window.cc @@ -17,6 +17,7 @@ */ #include +#include #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 index 6bc031c..a89fd5d 100644 --- 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 index 1747223..ee4fffe 100644 --- 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 index fc2a8c4..567c24a 100644 --- 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;