X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f6bcfd974ef26faf6f91a62cac09827e09463fd1..ee33aa3f2b022caea8e583bd4f47d87f751bf7d7:/src/unix/mimetype.cpp diff --git a/src/unix/mimetype.cpp b/src/unix/mimetype.cpp index 1b8cf25097..c6f51fb542 100644 --- a/src/unix/mimetype.cpp +++ b/src/unix/mimetype.cpp @@ -322,6 +322,9 @@ ArrayIconHandlers wxMimeTypesManagerImpl::ms_iconHandlers; // with blank lines separating the entries and indented lines starting with // TABs. We're interested in the field icon-filename whose value is the path // containing the icon. +// +// Update (Chris Elliott): apparently there may be an optional "[lang]" prefix +// just before the field name. void wxGNOMEIconHandler::LoadIconsFromKeyFile(const wxString& filename) { @@ -389,6 +392,16 @@ void wxGNOMEIconHandler::LoadIconsFromKeyFile(const wxString& filename) // this is a field=value ling pc++; // skip leading TAB + // skip optional "[lang]" + if ( *pc == _T('[') ) + { + while ( *pc ) + { + if ( *pc++ == _T(']') ) + break; + } + } + static const int lenField = 13; // strlen("icon-filename") if ( wxStrncmp(pc, _T("icon-filename"), lenField) == 0 ) { @@ -897,24 +910,27 @@ wxFileTypeImpl::GetEntry(const wxFileType::MessageParameters& params) const wxString command; MailCapEntry *entry = m_manager->m_aEntries[m_index[0]]; while ( entry != NULL ) { - // notice that an empty command would always succeed (it's ok) + // get the command to run as the test for this entry command = wxFileType::ExpandCommand(entry->GetTestCmd(), params); - // suppress the command output - if ( !command.IsEmpty() ) + // don't trace the test result if there is no test at all + if ( command.IsEmpty() ) { - if ( wxSystem(command) == 0 ) { - // ok, passed - wxLogTrace(TRACE_MIME, - wxT("Test '%s' for mime type '%s' succeeded."), - command.c_str(), params.GetMimeType().c_str()); - break; - } - else { - wxLogTrace(TRACE_MIME, - wxT("Test '%s' for mime type '%s' failed."), - command.c_str(), params.GetMimeType().c_str()); - } + // no test at all, ok + break; + } + + if ( wxSystem(command) == 0 ) { + // ok, test passed + wxLogTrace(TRACE_MIME, + wxT("Test '%s' for mime type '%s' succeeded."), + command.c_str(), params.GetMimeType().c_str()); + break; + } + else { + wxLogTrace(TRACE_MIME, + wxT("Test '%s' for mime type '%s' failed."), + command.c_str(), params.GetMimeType().c_str()); } entry = entry->GetNext(); @@ -1512,17 +1528,18 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName, } else { // no, it's a simple flag - // TODO support the flags: - // 1. create an xterm for 'needsterminal' - // 2. append "| $PAGER" for 'copiousoutput' if ( curField == wxT("needsterminal") ) needsterminal = TRUE; - else if ( curField == wxT("copiousoutput") ) + else if ( curField == wxT("copiousoutput")) { + // copiousoutput impies that the + // viewer is a console program + needsterminal = copiousoutput = TRUE; - else if ( curField == wxT("textualnewlines") ) - ; // ignore - else + } + else { + // unknown flag ok = FALSE; + } } if ( !ok ) @@ -1572,6 +1589,19 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName, strFileName.c_str(), nLine + 1); } else { + // support for flags: + // 1. create an xterm for 'needsterminal' + // 2. append "| $PAGER" for 'copiousoutput' + if ( copiousoutput ) { + const wxChar *p = wxGetenv(_T("PAGER")); + strOpenCmd << _T(" | ") << (p ? p : _T("more")); + } + + if ( needsterminal ) { + strOpenCmd.Printf(_T("xterm -e sh -c '%s'"), + strOpenCmd.c_str()); + } + MailCapEntry *entry = new MailCapEntry(strOpenCmd, strPrintCmd, strTest);