[gnome-initial-setup/wip/port-to-gtk4: 10/13] Make WebKitGTK optional




commit 6b885e5dd76a489f75f99ae20b5dbd4df3adbed2
Author: Will Thompson <will willthompson co uk>
Date:   Thu Dec 16 12:52:13 2021 +0000

    Make WebKitGTK optional
    
    This is not intended to be used for real, but will simplify an
    incremental GTK4 port.

 gnome-initial-setup/gis-driver.c                     |  6 ++++++
 gnome-initial-setup/meson.build                      |  2 +-
 gnome-initial-setup/pages/privacy/gis-privacy-page.c | 13 +++++++++++++
 meson.build                                          |  4 ++++
 meson_options.txt                                    |  6 ++++++
 5 files changed, 30 insertions(+), 1 deletion(-)
---
diff --git a/gnome-initial-setup/gis-driver.c b/gnome-initial-setup/gis-driver.c
index daf3a430..ea04cf57 100644
--- a/gnome-initial-setup/gis-driver.c
+++ b/gnome-initial-setup/gis-driver.c
@@ -26,7 +26,9 @@
 #include <errno.h>
 #include <locale.h>
 #include <stdlib.h>
+#ifdef HAVE_WEBKIT
 #include <webkit2/webkit2.h>
+#endif
 
 #include "cc-common-language.h"
 #include "gis-assistant.h"
@@ -813,11 +815,15 @@ static void
 gis_driver_startup (GApplication *app)
 {
   GisDriver *driver = GIS_DRIVER (app);
+#ifdef HAVE_WEBKIT
   WebKitWebContext *context = webkit_web_context_get_default ();
+#endif
 
   G_APPLICATION_CLASS (gis_driver_parent_class)->startup (app);
 
+#ifdef HAVE_WEBKIT
   webkit_web_context_set_sandbox_enabled (context, TRUE);
+#endif
 
   if (driver->mode == GIS_DRIVER_MODE_NEW_USER)
     connect_to_gdm (driver);
diff --git a/gnome-initial-setup/meson.build b/gnome-initial-setup/meson.build
index f171e7db..c3462a9c 100644
--- a/gnome-initial-setup/meson.build
+++ b/gnome-initial-setup/meson.build
@@ -51,7 +51,7 @@ dependencies = [
     dependency ('krb5'),
     dependency ('libsecret-1', version: '>= 0.18.8'),
     dependency ('pwquality'),
-    dependency ('webkit2gtk-4.0', version: '>= 2.26.0'),
+    webkit_dep,
     cheese_dep,
     cheese_gtk_dep,
     ibus_dep,
diff --git a/gnome-initial-setup/pages/privacy/gis-privacy-page.c 
b/gnome-initial-setup/pages/privacy/gis-privacy-page.c
index 80c40c36..305700a3 100644
--- a/gnome-initial-setup/pages/privacy/gis-privacy-page.c
+++ b/gnome-initial-setup/pages/privacy/gis-privacy-page.c
@@ -27,7 +27,9 @@
 #include "privacy-resources.h"
 #include "gis-privacy-page.h"
 
+#ifdef HAVE_WEBKIT
 #include <webkit2/webkit2.h>
+#endif
 
 #include <locale.h>
 #include <gtk/gtk.h>
@@ -180,6 +182,7 @@ gis_privacy_page_apply (GisPage *gis_page,
   return FALSE;
 }
 
+#ifdef HAVE_WEBKIT
 static void
 notify_progress_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
 {
@@ -239,6 +242,16 @@ activate_link (GtkLabel       *label,
 
   return TRUE;
 }
+#else
+static gboolean
+activate_link (GtkLabel       *label,
+               const gchar    *uri,
+               GisPrivacyPage *page)
+{
+  g_warning ("Built without WebKit, cannot show %s", uri);
+  return FALSE;
+}
+#endif
 
 static void
 gis_privacy_page_locale_changed (GisPage *page)
diff --git a/meson.build b/meson.build
index da1b6a82..9cf76a60 100644
--- a/meson.build
+++ b/meson.build
@@ -73,6 +73,10 @@ libmalcontent_ui_dep = dependency ('malcontent-ui-0',
 have_parental_controls = libmalcontent_dep.found() and libmalcontent_ui_dep.found()
 conf.set('HAVE_PARENTAL_CONTROLS', have_parental_controls)
 
+# Needed to show privacy policies
+webkit_dep = dependency('webkit2gtk-4.0', version: '>= 2.26.0', required: get_option('privacy_policy'))
+conf.set('HAVE_WEBKIT', webkit_dep.found())
+
 configure_file(output: 'config.h',
                configuration: conf)
 config_h_dir = include_directories('.')
diff --git a/meson_options.txt b/meson_options.txt
index be386b59..a4fea5be 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -26,3 +26,9 @@ option('parental_controls',
   value: 'auto',
   description: 'Enable parental controls pages',
 )
+
+option('privacy_policy',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable showing privacy policies (using WebKitGTK)',
+)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]