From cab393815f32e2925ea5766ec9d71e14cf029804 Mon Sep 17 00:00:00 2001 From: Gerald Schmidt Date: Thu, 30 Aug 2007 23:43:34 +0000 Subject: [PATCH] Fixed 'Open with...' behaviour in Gnome. --- src/myipc.cpp | 2 +- src/xmlcopyeditor.cpp | 14 ++++++++++++-- src/xmlcopyeditor.h | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/myipc.cpp b/src/myipc.cpp index cc304fd..f04d13c 100755 --- a/src/myipc.cpp +++ b/src/myipc.cpp @@ -41,7 +41,7 @@ bool MyServerConnection::OnPoke( return false; if (item == (wxString)IPC_NO_FILE) { ; } else if (frame->isOpen(item)) { frame->activateTab(item); } - else { frame->openFile(item); } + else { frame->openFile((wxString&)item); } frame->Raise(); return true; } diff --git a/src/xmlcopyeditor.cpp b/src/xmlcopyeditor.cpp index f4ae76b..35e5829 100755 --- a/src/xmlcopyeditor.cpp +++ b/src/xmlcopyeditor.cpp @@ -1085,7 +1085,7 @@ void MyFrame::handleCommandLine() } else { - std::cout << "Usage: xmlcopyeditor [-ws --version --help] [] []" << std::endl; + std::cout << "Usage: xmlcopyeditor [--version --help -ws] [] []" << std::endl << "Options -w (import Microsoft Word document) and -s (open Spelling and style check) are provided for integration with Microsoft Office and only available on Windows" << std::endl; } exit(0); default: @@ -2717,8 +2717,18 @@ void MyFrame::OnOpen(wxCommandEvent& event) break; } -bool MyFrame::openFile(const wxString& fileName, bool largeFile) +bool MyFrame::openFile(wxString& fileName, bool largeFile) { +#ifndef __WXMSW__ + // truncate string up to file:/ portion added by GNOME + wxString filePrefix = _T("file:"); + int index = fileName.Find(filePrefix.c_str()); + if (index != -1) + { + fileName = fileName.Mid((size_t)index + filePrefix.Length()); + } +#endif + if (!wxFileName::FileExists(fileName)) { wxString message; diff --git a/src/xmlcopyeditor.h b/src/xmlcopyeditor.h index c3ed0fe..2f28a8b 100755 --- a/src/xmlcopyeditor.h +++ b/src/xmlcopyeditor.h @@ -305,7 +305,7 @@ class MyFrame : public wxFrame void messagePane(const wxString& s, int iconType = CONST_INFO); // public to allow IPC access - bool openFile(const wxString& fileName, bool largeFile = false); + bool openFile(wxString& fileName, bool largeFile = false); bool isOpen(const wxString& fileName); void activateTab(const wxString& fileName); private: