1
0
forked from pool/boinc-client
boinc-client/0001-MGR-support-wxWidgets-without-webview.patch
2017-09-13 20:26:14 +00:00

112 lines
3.5 KiB
Diff

From 84c17bc232a7721ab0687228af5b3acfba12ad75 Mon Sep 17 00:00:00 2001
From: Jan Engelhardt <jengelh@inai.de>
Date: Fri, 8 Sep 2017 01:55:57 +0200
Subject: [PATCH] MGR: support wxWidgets without webview
If wxWidgets is built without support for the webview widget, make do
with a wxHtmlWindow instead.
---
clientgui/NoticeListCtrl.cpp | 25 +++++++++++++++++++++++++
clientgui/NoticeListCtrl.h | 8 ++++++++
2 files changed, 33 insertions(+)
Index: boinc-client_release-7.6-7.6.33/clientgui/NoticeListCtrl.cpp
===================================================================
--- boinc-client_release-7.6-7.6.33.orig/clientgui/NoticeListCtrl.cpp
+++ boinc-client_release-7.6-7.6.33/clientgui/NoticeListCtrl.cpp
@@ -49,10 +49,14 @@ IMPLEMENT_DYNAMIC_CLASS( CNoticeListCtrl
BEGIN_EVENT_TABLE( CNoticeListCtrl, wxWindow )
+#if wxUSE_WEBVIEW
////@begin CNoticeListCtrl event table entries
EVT_WEBVIEW_NAVIGATING(ID_LIST_NOTIFICATIONSVIEW, CNoticeListCtrl::OnLinkClicked)
EVT_WEBVIEW_ERROR(ID_LIST_NOTIFICATIONSVIEW, CNoticeListCtrl::OnWebViewError)
////@end CNoticeListCtrl event table entries
+#else
+ EVT_HTML_LINK_CLICKED(ID_LIST_NOTIFICATIONSVIEW, CNoticeListCtrl::OnLinkClicked)
+#endif
END_EVENT_TABLE()
@@ -84,7 +88,11 @@ bool CNoticeListCtrl::Create( wxWindow*
wxWindow::Create( parent, ID_LIST_NOTIFICATIONSVIEW, wxDefaultPosition, wxDefaultSize,
wxSUNKEN_BORDER | wxTAB_TRAVERSAL );
+#if wxUSE_WEBVIEW
m_browser = wxWebView::New( this, ID_LIST_NOTIFICATIONSVIEW );
+#else
+ m_browser = new wxHtmlWindow(this, ID_LIST_NOTIFICATIONSVIEW);
+#endif
////@end CNoticeListCtrl creation
wxBoxSizer *topsizer;
@@ -236,7 +244,11 @@ void CNoticeListCtrl::SetItemCount(int n
m_noticesBody += strBuffer;
}
m_noticesBody += wxT("</font></body></html>");
+#if wxUSE_WEBVIEW
m_browser->SetPage(m_noticesBody, wxT("http://"));
+#else
+ m_browser->SetPage(m_noticesBody);
+#endif
}
@@ -246,6 +258,7 @@ void CNoticeListCtrl::Clear() {
}
+#if wxUSE_WEBVIEW
void CNoticeListCtrl::OnLinkClicked( wxWebViewEvent& event ) {
if (event.GetURL().StartsWith(wxT("http://")) || event.GetURL().StartsWith(wxT("https://"))) {
event.Veto(); // Tell wxWebView not to follow link
@@ -262,6 +275,18 @@ void CNoticeListCtrl::OnWebViewError( wx
event.Skip();
}
+#else
+void CNoticeListCtrl::OnLinkClicked(wxHtmlLinkEvent &event)
+{
+ wxString url = event.GetLinkInfo().GetHref();
+ if (!url.StartsWith(wxT("http://")) && !url.StartsWith(wxT("https://"))) {
+ event.Skip();
+ return;
+ }
+ event.Skip(); // Tell element not to follow link
+ wxLaunchDefaultBrowser(url);
+}
+#endif
/*!
Index: boinc-client_release-7.6-7.6.33/clientgui/NoticeListCtrl.h
===================================================================
--- boinc-client_release-7.6-7.6.33.orig/clientgui/NoticeListCtrl.h
+++ boinc-client_release-7.6-7.6.33/clientgui/NoticeListCtrl.h
@@ -45,8 +45,12 @@ public:
////@begin CNoticeListCtrl event handler declarations
+#if defined(wxUSE_WEBVIEW) && wxUSE_WEBVIEW
void OnLinkClicked( wxWebViewEvent& event );
void OnWebViewError( wxWebViewEvent& event );
+#else
+ void OnLinkClicked(wxHtmlLinkEvent &);
+#endif
////@end CNoticeListCtrl event handler declarations
@@ -56,7 +60,11 @@ public:
bool m_bDisplayFetchingNotices;
bool m_bDisplayEmptyNotice;
private:
+#if wxUSE_WEBVIEW
wxWebView* m_browser;
+#else
+ wxHtmlWindow *m_browser;
+#endif
bool m_bNeedsReloading;
int m_itemCount;
wxString m_noticesBody;