Bug #2957125 Default browser choice ignored

This commit is contained in:
Zane U. Ji 2012-08-11 15:33:01 +08:00
parent a8ed8dc173
commit 5367c5dabb
6 changed files with 14 additions and 129 deletions

View File

@ -26,16 +26,12 @@ BEGIN_EVENT_TABLE ( MyPropertySheet, wxPropertySheetDialog )
EVT_BUTTON ( EVT_BUTTON (
APPLICATION_DIR_BROWSE, APPLICATION_DIR_BROWSE,
MyPropertySheet::OnApplicationDirBrowse ) MyPropertySheet::OnApplicationDirBrowse )
EVT_BUTTON (
BROWSER_COMMAND_BROWSE,
MyPropertySheet::OnBrowserCommandBrowse )
END_EVENT_TABLE() END_EVENT_TABLE()
MyPropertySheet::MyPropertySheet ( MyPropertySheet::MyPropertySheet (
wxWindow *parent, wxWindow *parent,
XmlCtrlProperties& propertiesParameter, XmlCtrlProperties& propertiesParameter,
wxString& applicationDirParameter, wxString& applicationDirParameter,
wxString& browserCommandParameter,
bool rememberOpenTabsParameter, bool rememberOpenTabsParameter,
bool libxmlNetAccessParameter, bool libxmlNetAccessParameter,
bool singleInstanceCheckParameter, bool singleInstanceCheckParameter,
@ -49,11 +45,11 @@ MyPropertySheet::MyPropertySheet (
wxString title, wxString title,
const wxPoint& position, const wxPoint& position,
const wxSize& size, const wxSize& size,
long style ) : wxPropertySheetDialog ( long style
parent, id, title, position, size, style ), )
properties ( propertiesParameter ), : wxPropertySheetDialog ( parent, id, title, position, size, style )
applicationDir ( applicationDirParameter ), , properties ( propertiesParameter )
browserCommand ( browserCommandParameter ) , applicationDir ( applicationDirParameter )
{ {
CreateButtons ( wxOK | wxCANCEL ); CreateButtons ( wxOK | wxCANCEL );
@ -140,7 +136,6 @@ MyPropertySheet::MyPropertySheet (
wxPanel *generalPanel = new wxPanel ( GetBookCtrl() ); wxPanel *generalPanel = new wxPanel ( GetBookCtrl() );
wxBoxSizer *vsizer = new wxBoxSizer ( wxVERTICAL ); wxBoxSizer *vsizer = new wxBoxSizer ( wxVERTICAL );
wxBoxSizer *hsizer = new wxBoxSizer ( wxHORIZONTAL ); wxBoxSizer *hsizer = new wxBoxSizer ( wxHORIZONTAL );
wxBoxSizer *hsizerBrowser = new wxBoxSizer ( wxHORIZONTAL );
wxBoxSizer *hsizerCheckboxes = new wxBoxSizer ( wxHORIZONTAL ); wxBoxSizer *hsizerCheckboxes = new wxBoxSizer ( wxHORIZONTAL );
wxBoxSizer *vsizerCheckbox1 = new wxBoxSizer ( wxVERTICAL ); wxBoxSizer *vsizerCheckbox1 = new wxBoxSizer ( wxVERTICAL );
wxBoxSizer *vsizerCheckbox2 = new wxBoxSizer ( wxVERTICAL ); wxBoxSizer *vsizerCheckbox2 = new wxBoxSizer ( wxVERTICAL );
@ -161,22 +156,6 @@ MyPropertySheet::MyPropertySheet (
_ ( "Browse" ), _ ( "Browse" ),
wxDefaultPosition, wxDefaultPosition,
wxSize ( -1, applicationDirEdit->GetSize().GetHeight() ) ); wxSize ( -1, applicationDirEdit->GetSize().GetHeight() ) );
wxStaticText *labelBrowser = new wxStaticText (
generalPanel,
wxID_ANY,
_ ( "Browser" ) );
browserCommandEdit = new wxTextCtrl (
generalPanel,
wxID_ANY,
browserCommand,
wxDefaultPosition,
wxSize ( 240, -1 ) );
wxButton *browseCommand = new wxButton (
generalPanel,
BROWSER_COMMAND_BROWSE,
_ ( "Browse" ),
wxDefaultPosition,
wxSize ( -1, browserCommandEdit->GetSize().GetHeight() ) );
wxStaticText *labelLanguage = new wxStaticText ( wxStaticText *labelLanguage = new wxStaticText (
generalPanel, generalPanel,
@ -233,12 +212,8 @@ MyPropertySheet::MyPropertySheet (
hsizer->Add ( applicationDirEdit, 0, wxALL | wxALIGN_LEFT, 0 ); hsizer->Add ( applicationDirEdit, 0, wxALL | wxALIGN_LEFT, 0 );
hsizer->Add ( browse, 0, wxLEFT | wxALIGN_LEFT, 5 ); hsizer->Add ( browse, 0, wxLEFT | wxALIGN_LEFT, 5 );
hsizerBrowser->Add ( browserCommandEdit, 0, wxALL | wxALIGN_LEFT, 0 );
hsizerBrowser->Add ( browseCommand, 0, wxLEFT | wxALIGN_LEFT, 5 );
vsizer->Add ( label, 0, wxLEFT | wxTOP | wxALIGN_LEFT, 5 ); vsizer->Add ( label, 0, wxLEFT | wxTOP | wxALIGN_LEFT, 5 );
vsizer->Add ( hsizer, 0, wxALL | wxALIGN_LEFT, 5 ); vsizer->Add ( hsizer, 0, wxALL | wxALIGN_LEFT, 5 );
vsizer->Add ( labelBrowser, 0, wxLEFT | wxTOP | wxALIGN_LEFT, 5 );
vsizer->Add ( hsizerBrowser, 0, wxALL | wxALIGN_LEFT, 5 );
vsizer->Add ( labelLanguage, 0, wxLEFT | wxTOP | wxALIGN_LEFT, 5 ); vsizer->Add ( labelLanguage, 0, wxLEFT | wxTOP | wxALIGN_LEFT, 5 );
vsizer->Add ( languageBox, 0, wxALL | wxALIGN_LEFT, 5 ); vsizer->Add ( languageBox, 0, wxALL | wxALIGN_LEFT, 5 );
@ -293,7 +268,6 @@ void MyPropertySheet::OnOk ( wxCommandEvent& e )
else else
applicationDir = testDir; applicationDir = testDir;
browserCommand = browserCommandEdit->GetValue(); // permit incorrect value
singleInstanceCheck = singleInstanceCheckBox->GetValue(); singleInstanceCheck = singleInstanceCheckBox->GetValue();
restoreLayout = restoreLayoutBox->GetValue(); restoreLayout = restoreLayoutBox->GetValue();
rememberOpenTabs = rememberOpenTabsBox->GetValue(); rememberOpenTabs = rememberOpenTabsBox->GetValue();
@ -319,13 +293,6 @@ void MyPropertySheet::OnApplicationDirBrowse ( wxCommandEvent& e )
applicationDirEdit->SetValue ( browseDialog->GetPath() ); applicationDirEdit->SetValue ( browseDialog->GetPath() );
} }
void MyPropertySheet::OnBrowserCommandBrowse ( wxCommandEvent& e )
{
wxFileDialog *browseDialog = new wxFileDialog ( this );
if ( browseDialog->ShowModal() == wxID_OK )
browserCommandEdit->SetValue ( browseDialog->GetPath() );
}
XmlCtrlProperties MyPropertySheet::getProperties() XmlCtrlProperties MyPropertySheet::getProperties()
{ {
return properties; return properties;
@ -336,11 +303,6 @@ wxString MyPropertySheet::getApplicationDir()
return applicationDir; return applicationDir;
} }
wxString MyPropertySheet::getBrowserCommand()
{
return browserCommand;
}
bool MyPropertySheet::getSingleInstanceCheck() bool MyPropertySheet::getSingleInstanceCheck()
{ {
return singleInstanceCheck; return singleInstanceCheck;

View File

@ -28,7 +28,6 @@
enum enum
{ {
APPLICATION_DIR_BROWSE, APPLICATION_DIR_BROWSE,
BROWSER_COMMAND_BROWSE,
FONT_BROWSE FONT_BROWSE
}; };
@ -39,7 +38,6 @@ class MyPropertySheet : public wxPropertySheetDialog
wxWindow *parent, wxWindow *parent,
XmlCtrlProperties& propertiesParameter, XmlCtrlProperties& propertiesParameter,
wxString& applicationDirParameter, wxString& applicationDirParameter,
wxString& browserCommandParameter,
bool rememberOpenTabsParameter, bool rememberOpenTabsParameter,
bool libxmlNetAccess, bool libxmlNetAccess,
bool singleInstanceCheck, bool singleInstanceCheck,
@ -56,11 +54,9 @@ class MyPropertySheet : public wxPropertySheetDialog
long style = wxDEFAULT_DIALOG_STYLE ); long style = wxDEFAULT_DIALOG_STYLE );
~MyPropertySheet(); ~MyPropertySheet();
void OnOk ( wxCommandEvent& e ); void OnOk ( wxCommandEvent& e );
void OnBrowserCommandBrowse ( wxCommandEvent& e );
void OnApplicationDirBrowse ( wxCommandEvent& e ); void OnApplicationDirBrowse ( wxCommandEvent& e );
XmlCtrlProperties getProperties(); XmlCtrlProperties getProperties();
wxString getApplicationDir(); wxString getApplicationDir();
wxString getBrowserCommand();
bool getSingleInstanceCheck(); bool getSingleInstanceCheck();
bool getRememberOpenTabs(); bool getRememberOpenTabs();
bool getLibxmlNetAccess(); bool getLibxmlNetAccess();
@ -93,9 +89,9 @@ class MyPropertySheet : public wxPropertySheetDialog
*expandInternalEntitiesBox, *expandInternalEntitiesBox,
*insertCloseTagBox; *insertCloseTagBox;
wxChoice *languageBox, *fontBox; wxChoice *languageBox, *fontBox;
wxTextCtrl *applicationDirEdit, *browserCommandEdit; wxTextCtrl *applicationDirEdit;
XmlCtrlProperties properties; XmlCtrlProperties properties;
wxString applicationDir, browserCommand; wxString applicationDir;
bool singleInstanceCheck, bool singleInstanceCheck,
rememberOpenTabs, rememberOpenTabs,
libxmlNetAccess, libxmlNetAccess,

View File

@ -89,7 +89,6 @@ StyleDialog::StyleDialog (
const wxString& fileNameParameter, const wxString& fileNameParameter,
const wxString& ruleSetDirectoryParameter, const wxString& ruleSetDirectoryParameter,
const wxString& filterDirectoryParameter, const wxString& filterDirectoryParameter,
const wxString& browserParameter,
const wxString& ruleSetPresetParameter, const wxString& ruleSetPresetParameter,
const wxString& filterPresetParameter, const wxString& filterPresetParameter,
#if !defined(USE_ENCHANT) && defined(__WXMSW__) #if !defined(USE_ENCHANT) && defined(__WXMSW__)
@ -115,7 +114,6 @@ StyleDialog::StyleDialog (
fileName ( fileNameParameter ), fileName ( fileNameParameter ),
ruleSetDirectory ( ruleSetDirectoryParameter ), ruleSetDirectory ( ruleSetDirectoryParameter ),
filterDirectory ( filterDirectoryParameter ), filterDirectory ( filterDirectoryParameter ),
browser ( browserParameter ),
ruleSetPreset ( ruleSetPresetParameter ), ruleSetPreset ( ruleSetPresetParameter ),
filterPreset ( filterPresetParameter ), filterPreset ( filterPresetParameter ),
type(typeParameter), type(typeParameter),
@ -678,8 +676,7 @@ void StyleDialog::OnStyleWebReport ( wxCommandEvent& event )
if ( !wxFileName::FileExists ( tempNameWide ) ) if ( !wxFileName::FileExists ( tempNameWide ) )
return; return;
wxString cmd = browser + _T ( " \"" ) + tempNameWide + _T ( "\"" ); wxLaunchDefaultBrowser ( tempNameWide );
wxExecute ( cmd, wxEXEC_SYNC );
} }
void StyleDialog::OnStyleWebSummary ( wxCommandEvent& event ) void StyleDialog::OnStyleWebSummary ( wxCommandEvent& event )
@ -745,8 +742,7 @@ void StyleDialog::OnStyleWebSummary ( wxCommandEvent& event )
if ( !wxFileName::FileExists ( tempNameWide ) ) if ( !wxFileName::FileExists ( tempNameWide ) )
return; return;
wxString cmd = browser + _T ( " \"" ) + tempNameWide + _T ( "\"" ); wxLaunchDefaultBrowser ( tempNameWide );
wxExecute ( cmd, wxEXEC_SYNC );
} }
void StyleDialog::styleSetIgnoreAll ( bool ignore ) void StyleDialog::styleSetIgnoreAll ( bool ignore )

View File

@ -70,7 +70,6 @@ class StyleDialog : public wxDialog
const wxString& fileNameParameter, const wxString& fileNameParameter,
const wxString& ruleSetDirectoryParameter, const wxString& ruleSetDirectoryParameter,
const wxString& filterDirectoryParameter, const wxString& filterDirectoryParameter,
const wxString& browserParameter,
const wxString& ruleSetPresetParameter, const wxString& ruleSetPresetParameter,
const wxString& filterPresetParameter, const wxString& filterPresetParameter,
#ifdef __WXMSW__ #ifdef __WXMSW__
@ -121,7 +120,7 @@ class StyleDialog : public wxDialog
wxStatusBar *status; wxStatusBar *status;
std::string bufferUtf8, aspellDataPath, aspellDictPath; std::string bufferUtf8, aspellDataPath, aspellDictPath;
std::set<wxString> tempFiles; std::set<wxString> tempFiles;
wxString fileName, ruleSetDirectory, filterDirectory, browser; wxString fileName, ruleSetDirectory, filterDirectory;
wxString ruleSetPreset, filterPreset; wxString ruleSetPreset, filterPreset;
vector<ContextMatch> matchVector; vector<ContextMatch> matchVector;
int type; int type;

View File

@ -656,8 +656,6 @@ MyFrame::MyFrame (
applicationDir = applicationDir =
config->Read ( _T ( "applicationDir" ), wxStandardPaths::Get().GetDataDir() ); config->Read ( _T ( "applicationDir" ), wxStandardPaths::Get().GetDataDir() );
browserCommand =
config->Read ( _T ( "browserCommand" ), wxEmptyString );
// if default value != true, type as long int // if default value != true, type as long int
long valZoom, longFalse; long valZoom, longFalse;
@ -751,7 +749,6 @@ MyFrame::MyFrame (
rememberOpenTabs = true; rememberOpenTabs = true;
libxmlNetAccess = false; libxmlNetAccess = false;
openTabsOnClose = wxEmptyString; openTabsOnClose = wxEmptyString;
browserCommand = wxEmptyString;
notebookStyle = ID_NOTEBOOK_STYLE_VC8_COLOR; notebookStyle = ID_NOTEBOOK_STYLE_VC8_COLOR;
saveBom = unlimitedUndo = true; saveBom = unlimitedUndo = true;
layout = wxEmptyString; layout = wxEmptyString;
@ -804,15 +801,6 @@ MyFrame::MyFrame (
findData.SetFlags ( findFlags ); findData.SetFlags ( findFlags );
if ( browserCommand.empty() )
{
#ifdef __WXMSW__
browserCommand = binDir + _T ( "navigate.exe" );
#else
browserCommand = getLinuxBrowser();
#endif
}
// initialise document count for tab labels // initialise document count for tab labels
documentCount = 1; documentCount = 1;
@ -1023,7 +1011,6 @@ MyFrame::~MyFrame()
config->Write ( _T ( "toolbarVisible" ), toolbarVisible ); config->Write ( _T ( "toolbarVisible" ), toolbarVisible );
config->Write ( _T ( "protectTags" ), protectTags ); config->Write ( _T ( "protectTags" ), protectTags );
config->Write ( _T ( "visibilityState" ), visibilityState ); config->Write ( _T ( "visibilityState" ), visibilityState );
config->Write ( _T ( "browserCommand" ), browserCommand );
config->Write ( _T ( "showLocationPane" ), manager.GetPane ( locationPanel ).IsShown() ); config->Write ( _T ( "showLocationPane" ), manager.GetPane ( locationPanel ).IsShown() );
config->Write ( _T ( "showInsertChildPane" ), manager.GetPane ( insertChildPanel ).IsShown() ); config->Write ( _T ( "showInsertChildPane" ), manager.GetPane ( insertChildPanel ).IsShown() );
config->Write ( _T ( "showInsertSiblingPane" ), manager.GetPane ( insertSiblingPanel ).IsShown() ); config->Write ( _T ( "showInsertSiblingPane" ), manager.GetPane ( insertSiblingPanel ).IsShown() );
@ -1071,30 +1058,6 @@ MyFrame::~MyFrame()
wxTheClipboard->Flush(); wxTheClipboard->Flush();
} }
wxString MyFrame::getLinuxBrowser()
{
wxString s;
const int stringArrayLen = 9;
wxString stringArray[stringArrayLen];
stringArray[0] = _T ( "/usr/bin/firefox" );
stringArray[1] = _T ( "/usr/bin/mozilla" );
stringArray[2] = _T ( "/usr/bin/opera" );
stringArray[3] = _T ( "/usr/bin/dillo" );
stringArray[4] = _T ( "/opt/gnome/bin/epiphany" );
stringArray[5] = _T ( "/opt/gnome/bin/galeon" );
stringArray[6] = _T ( "/opt/kde/bin/konqueror" );
stringArray[7] = _T ( "/opt/mozilla/bin/firefox" );
stringArray[8] = wxEmptyString; // empty option is safe
for ( int i = 0; i < stringArrayLen; i++ )
{
s = stringArray[i];
if ( wxFileName::FileExists ( s ) )
break;
}
return s;
}
void MyFrame::showTopBars ( bool b ) void MyFrame::showTopBars ( bool b )
{ {
if ( !menuBar ) if ( !menuBar )
@ -2381,7 +2344,7 @@ void MyFrame::OnBrowser ( wxCommandEvent& WXUNUSED ( event ) )
wtfn.setKeepFiles ( true ); wtfn.setKeepFiles ( true );
} }
navigate ( sourceFileName ); wxLaunchDefaultBrowser ( sourceFileName );
} }
void MyFrame::OnHelp ( wxCommandEvent& event ) void MyFrame::OnHelp ( wxCommandEvent& event )
@ -2533,7 +2496,6 @@ void MyFrame::OnOptions ( wxCommandEvent& WXUNUSED ( event ) )
this, this,
properties, properties,
applicationDir, applicationDir,
browserCommand,
rememberOpenTabs, rememberOpenTabs,
libxmlNetAccess, libxmlNetAccess,
singleInstanceCheck, singleInstanceCheck,
@ -2550,7 +2512,6 @@ void MyFrame::OnOptions ( wxCommandEvent& WXUNUSED ( event ) )
properties = mpsd->getProperties(); properties = mpsd->getProperties();
applyEditorProperties(); applyEditorProperties();
applicationDir = mpsd->getApplicationDir(); applicationDir = mpsd->getApplicationDir();
browserCommand = mpsd->getBrowserCommand();
rememberOpenTabs = mpsd->getRememberOpenTabs(); rememberOpenTabs = mpsd->getRememberOpenTabs();
libxmlNetAccess = mpsd->getLibxmlNetAccess(); libxmlNetAccess = mpsd->getLibxmlNetAccess();
singleInstanceCheck = mpsd->getSingleInstanceCheck(); singleInstanceCheck = mpsd->getSingleInstanceCheck();
@ -3413,7 +3374,6 @@ void MyFrame::OnSpelling ( wxCommandEvent& event )
doc->getShortFileName(), doc->getShortFileName(),
ruleSetDir, ruleSetDir,
filterDir, filterDir,
browserCommand,
( type == ID_TYPE_SPELL ) ? dictionaryPreset : ruleSetPreset, ( type == ID_TYPE_SPELL ) ? dictionaryPreset : ruleSetPreset,
filterPreset, filterPreset,
#ifdef __WXMSW__ #ifdef __WXMSW__
@ -4343,12 +4303,12 @@ void MyFrame::OnEncoding ( wxCommandEvent& event )
void MyFrame::OnHome ( wxCommandEvent& event ) void MyFrame::OnHome ( wxCommandEvent& event )
{ {
navigate ( _T ( "http://xml-copy-editor.sourceforge.net" ) ); wxLaunchDefaultBrowser ( _T ( "http://xml-copy-editor.sourceforge.net" ) );
} }
void MyFrame::OnDownloadSource ( wxCommandEvent& event ) void MyFrame::OnDownloadSource ( wxCommandEvent& event )
{ {
navigate ( _T ( "http://xml-copy-editor.svn.sourceforge.net/viewvc/xml-copy-editor/" ) ); wxLaunchDefaultBrowser ( _T ( "http://xml-copy-editor.svn.sourceforge.net/viewvc/xml-copy-editor/" ) );
} }
void MyFrame::OnToolbarVisible ( wxCommandEvent& event ) void MyFrame::OnToolbarVisible ( wxCommandEvent& event )
@ -4475,32 +4435,7 @@ void MyFrame::OnFeedback ( wxCommandEvent& event )
{ {
wxString forumUrl = wxString forumUrl =
_T ( "https://sourceforge.net/forum/forum.php?forum_id=475215" ); _T ( "https://sourceforge.net/forum/forum.php?forum_id=475215" );
navigate ( forumUrl ); wxLaunchDefaultBrowser ( forumUrl );
}
void MyFrame::navigate ( const wxString& url )
{
wxString testString = browserCommand;
testString.Replace ( _T ( " -remote" ), wxEmptyString, true );
if ( browserCommand.empty() )
{
messagePane (
_ ( "Cannot open in browser: no browser defined (see Tools, Options..., General)" ),
CONST_STOP );
return;
}
else if ( !wxFileName::FileExists ( testString ) )
{
wxString message;
message.Printf (
_ ( "Cannot open in browser: %s not found (see Tools, Options..., General)" ),
testString.c_str() );
messagePane ( message, CONST_STOP );
return;
}
wxString cmd;
cmd = browserCommand + _T ( " \"" ) + url + _T ( "\"" );
wxExecute ( cmd, wxEXEC_ASYNC ); // make ASYNC an option?
} }
void MyFrame::findAgain ( wxString s, int flags ) void MyFrame::findAgain ( wxString s, int flags )

View File

@ -309,7 +309,6 @@ class MyFrame : public wxFrame
XmlDoc *doc, XmlDoc *doc,
const wxString& schemaName, const wxString& schemaName,
wxString& fileName ); wxString& fileName );
void navigate ( const wxString& url );
void closePane(); void closePane();
void closeFindReplacePane(); void closeFindReplacePane();
void closeCommandPane(); void closeCommandPane();
@ -410,7 +409,6 @@ class MyFrame : public wxFrame
lastRelaxNGSchema, lastRelaxNGSchema,
lastDtdPublicAux, lastDtdPublicAux,
openTabsOnClose, openTabsOnClose,
browserCommand,
layout, layout,
defaultLayout, defaultLayout,
lastParent, lastParent,
@ -492,7 +490,6 @@ class MyFrame : public wxFrame
bool checkLastModified = true ); bool checkLastModified = true );
int getFileType ( const wxString& fileName ); int getFileType ( const wxString& fileName );
long getNotebookStyleMask(); long getNotebookStyleMask();
wxString getLinuxBrowser();
bool isSpecialFileType ( const wxString& fileName ); bool isSpecialFileType ( const wxString& fileName );
wxString getHtmlBuffer(); wxString getHtmlBuffer();
void encodingMessage(); void encodingMessage();