[gnome-initial-setup/wip/port-to-gtk4: 14/16] Make GNOME Online Accounts optional




commit 496d512e090029293f6276da1e8787dbb55dff93
Author: Will Thompson <will willthompson co uk>
Date:   Thu Dec 16 12:54:05 2021 +0000

    Make GNOME Online Accounts optional
    
    This is not intended to be used for real, but to simplify an incremental
    GTK4 port.

 gnome-initial-setup/gnome-initial-setup.c                  |  2 ++
 gnome-initial-setup/meson.build                            |  4 ++--
 gnome-initial-setup/pages/account/gis-account-page-local.c | 10 ++++++++++
 gnome-initial-setup/pages/meson.build                      |  5 ++++-
 meson.build                                                |  6 ++++++
 meson_options.txt                                          |  6 ++++++
 6 files changed, 30 insertions(+), 3 deletions(-)
---
diff --git a/gnome-initial-setup/gnome-initial-setup.c b/gnome-initial-setup/gnome-initial-setup.c
index a4c67110..c7ac54e6 100644
--- a/gnome-initial-setup/gnome-initial-setup.c
+++ b/gnome-initial-setup/gnome-initial-setup.c
@@ -72,7 +72,9 @@ static PageData page_table[] = {
   PAGE (privacy,  FALSE),
   PAGE (timezone, TRUE),
   PAGE (software, TRUE),
+#ifdef HAVE_ONLINE_ACCOUNTS
   PAGE (goa,      FALSE),
+#endif
   PAGE (account,  TRUE),
   PAGE (password, TRUE),
 #ifdef HAVE_PARENTAL_CONTROLS
diff --git a/gnome-initial-setup/meson.build b/gnome-initial-setup/meson.build
index 210864a5..28ae5ea6 100644
--- a/gnome-initial-setup/meson.build
+++ b/gnome-initial-setup/meson.build
@@ -36,8 +36,8 @@ dependencies = [
     dependency ('gsettings-desktop-schemas', version: '>= 3.37.1'),
     dependency ('fontconfig'),
     dependency ('gweather4', fallback: ['libgweather', 'libgweather_dep']),
-    dependency ('goa-1.0'),
-    dependency ('goa-backend-1.0'),
+    goa_dep,
+    goa_backend_dep,
     dependency ('gtk+-3.0', version: '>= 3.11.3'),
     dependency ('glib-2.0', version: '>= 2.63.1'),
     dependency ('gio-unix-2.0', version: '>= 2.53.0'),
diff --git a/gnome-initial-setup/pages/account/gis-account-page-local.c 
b/gnome-initial-setup/pages/account/gis-account-page-local.c
index c858c608..b9aae005 100644
--- a/gnome-initial-setup/pages/account/gis-account-page-local.c
+++ b/gnome-initial-setup/pages/account/gis-account-page-local.c
@@ -35,8 +35,10 @@
 
 #include "gis-page-header.h"
 
+#ifdef HAVE_ONLINE_ACCOUNTS
 #define GOA_API_IS_SUBJECT_TO_CHANGE
 #include <goa/goa.h>
+#endif
 
 #include <rest/oauth-proxy.h>
 #include <json-glib/json-glib.h>
@@ -63,7 +65,9 @@ struct _GisAccountPageLocalPrivate
 
   ActUserManager *act_client;
 
+#ifdef HAVE_ONLINE_ACCOUNTS
   GoaClient *goa_client;
+#endif
 
   gboolean valid_name;
   gboolean valid_username;
@@ -89,6 +93,7 @@ validation_changed (GisAccountPageLocal *page)
   g_signal_emit (page, signals[VALIDATION_CHANGED], 0);
 }
 
+#ifdef HAVE_ONLINE_ACCOUNTS
 static gboolean
 get_profile_sync (const gchar        *access_token,
                   gchar             **out_name,
@@ -246,6 +251,7 @@ accounts_changed (GoaClient *client, GoaObject *object, gpointer data)
 
   prepopulate_account_page (page);
 }
+#endif
 
 static gboolean
 validate (GisAccountPageLocal *page)
@@ -458,6 +464,7 @@ gis_account_page_local_constructed (GObject *object)
   gtk_image_set_pixel_size (GTK_IMAGE (priv->avatar_image), 96);
   gtk_image_set_from_icon_name (GTK_IMAGE (priv->avatar_image), "avatar-default-symbolic", 1);
 
+#ifdef HAVE_ONLINE_ACCOUNTS
   priv->goa_client = goa_client_new_sync (NULL, NULL);
   if (priv->goa_client) {
     g_signal_connect (priv->goa_client, "account-added",
@@ -466,6 +473,7 @@ gis_account_page_local_constructed (GObject *object)
                       G_CALLBACK (accounts_changed), page);
     prepopulate_account_page (page);
   }
+#endif
 
   priv->photo_dialog = um_photo_dialog_new (priv->avatar_button,
                                             avatar_callback,
@@ -488,7 +496,9 @@ gis_account_page_local_dispose (GObject *object)
   GisAccountPageLocal *page = GIS_ACCOUNT_PAGE_LOCAL (object);
   GisAccountPageLocalPrivate *priv = gis_account_page_local_get_instance_private (page);
 
+#ifdef HAVE_ONLINE_ACCOUNTS
   g_clear_object (&priv->goa_client);
+#endif
   g_clear_object (&priv->avatar_pixbuf);
   g_clear_pointer (&priv->avatar_filename, g_free);
   g_clear_handle_id (&priv->timeout_id, g_source_remove);
diff --git a/gnome-initial-setup/pages/meson.build b/gnome-initial-setup/pages/meson.build
index 32305018..e82c5574 100644
--- a/gnome-initial-setup/pages/meson.build
+++ b/gnome-initial-setup/pages/meson.build
@@ -5,7 +5,6 @@ pages = [
    'network',
    'timezone',
    'privacy',
-   'goa',
    'password',
    'software',
    'summary',
@@ -16,6 +15,10 @@ if libmalcontent_dep.found() and libmalcontent_ui_dep.found()
   pages += 'parental-controls'
 endif
 
+if have_goa
+  pages += 'goa'
+endif
+
 foreach page: pages
     subdir (page)
 endforeach
diff --git a/meson.build b/meson.build
index 1f1da0a8..0e62c858 100644
--- a/meson.build
+++ b/meson.build
@@ -73,6 +73,12 @@ 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 for the online accounts page
+goa_dep = dependency('goa-1.0', required: get_option('online_accounts'))
+goa_backend_dep = dependency('goa-backend-1.0', required: get_option('online_accounts'))
+have_goa = goa_dep.found() and goa_backend_dep.found()
+conf.set('HAVE_ONLINE_ACCOUNTS', have_goa)
+
 # 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())
diff --git a/meson_options.txt b/meson_options.txt
index a4fea5be..68c060cf 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -27,6 +27,12 @@ option('parental_controls',
   description: 'Enable parental controls pages',
 )
 
+option('online_accounts',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable online accounts page',
+)
+
 option('privacy_policy',
   type: 'feature',
   value: 'auto',


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