File 0001-MGR-support-wxWidgets-without-webview.patch of Package boinc-client

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.8-7.8.3/clientgui/NoticeListCtrl.cpp
===================================================================
--- boinc-client_release-7.8-7.8.3.orig/clientgui/NoticeListCtrl.cpp
+++ boinc-client_release-7.8-7.8.3/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;
@@ -238,7 +246,11 @@ void CNoticeListCtrl::SetItemCount(int n
     m_noticesBody += wxT("</font></body></html>");
     // baseURL is not needed here (see comments above) and it
     // must be an empty string for this to work under OS 10.12.4
+#if wxUSE_WEBVIEW
     m_browser->SetPage(m_noticesBody, wxEmptyString);
+#else
+    m_browser->SetPage(m_noticesBody);
+#endif
 }
 
 
@@ -248,6 +260,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
@@ -264,6 +277,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.8-7.8.3/clientgui/NoticeListCtrl.h
===================================================================
--- boinc-client_release-7.8-7.8.3.orig/clientgui/NoticeListCtrl.h
+++ boinc-client_release-7.8-7.8.3/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;
openSUSE Build Service is sponsored by