Add possibility to retrieve compile-time wxWebView version

This is currently only implemented for GTK WebKit2 and CEF backends.

Show both the compile- and run-time versions in the sample.
This commit is contained in:
Vadim Zeitlin
2024-08-23 00:19:53 +02:00
parent 41e8148ef2
commit 435fa14076
15 changed files with 210 additions and 74 deletions
+24 -7
View File
@@ -551,15 +551,32 @@ WebFrame::WebFrame(const wxString& url, int flags, wxWebViewWindowFeatures* wind
wxLog::SetActiveTarget(new wxLogTextCtrl(m_log_textCtrl));
// Log backend information
const auto& version = wxWebView::GetBackendVersionInfo(backend);
wxString description;
if ( version.HasDescription() )
description.Printf(" (%s)", version.GetDescription());
wxLogMessage("Backend: %s version=%s%s",
const auto formatVersion = [](const char* context,
const wxVersionInfo& version) {
wxString str;
if ( version.IsOk() )
{
str.Printf(", %s version=%s",
context, version.GetNumericVersionString());
if ( version.HasDescription() )
str += wxString::Format(" (%s)", version.GetDescription());
}
return str;
};
const auto versionRunTime = formatVersion("run-time", wxWebView::GetBackendVersionInfo(backend));
const auto versionBuildTime = formatVersion("build-time", wxWebView::GetBackendVersionInfo(
backend, wxVersionContext::BuildTime
));
wxLogMessage("Backend: %s%s%s",
m_browser->GetClassInfo()->GetClassName(),
version.GetNumericVersionString(),
description);
versionRunTime,
versionBuildTime);
// Chromium backend can't be used immediately after creation, so wait
// until the browser is created before calling GetUserAgent(), but we