Show opened file name in the window title

This commit is contained in:
Alexander Kojevnikov 2012-08-12 18:34:24 -07:00
parent 4009648397
commit 063d0433c0
4 changed files with 13 additions and 7 deletions

View File

@ -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);
}
}

View File

@ -24,7 +24,7 @@
class SpekWindow : public wxFrame
{
public:
SpekWindow(const wxString& title);
SpekWindow();
private:
void OnOpen(wxCommandEvent& event);

View File

@ -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 () {

View File

@ -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;