[gnome-initial-setup/parental-controls: 6/8] WIP



commit 7843513b28b21ace406240e1e24f6704619bd157
Author: Philip Withnall <withnall endlessm com>
Date:   Tue Feb 4 17:46:20 2020 +0000

    WIP
    
    Signed-off-by: Philip Withnall <withnall endlessm com>

 gnome-initial-setup/gis-driver.c                   |  4 ++++
 .../pages/account/gis-account-page-local.c         |  3 +++
 .../parental-controls/gis-parental-controls-page.c | 27 +++++++++-------------
 .../pages/password/gis-password-page.c             | 19 ++++-----------
 4 files changed, 22 insertions(+), 31 deletions(-)
---
diff --git a/gnome-initial-setup/gis-driver.c b/gnome-initial-setup/gis-driver.c
index 3027a12..762cc24 100644
--- a/gnome-initial-setup/gis-driver.c
+++ b/gnome-initial-setup/gis-driver.c
@@ -317,7 +317,11 @@ gis_driver_set_parental_controls_enabled (GisDriver *driver,
 {
   GisDriverPrivate *priv = gis_driver_get_instance_private (driver);
 
+  if (priv->parental_controls_enabled == parental_controls_enabled)
+    return;
+
   priv->parental_controls_enabled = parental_controls_enabled;
+  rebuild_pages (driver);
 }
 
 /* TODO docs */
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 0e05b23..e792a62 100644
--- a/gnome-initial-setup/pages/account/gis-account-page-local.c
+++ b/gnome-initial-setup/pages/account/gis-account-page-local.c
@@ -541,6 +541,9 @@ local_create_user (GisAccountPageLocal *page)
   /* Always create the admin user first, in case of failure part-way through
    * this function, which would leave us with no admin user at all. */
   if (parental_controls_enabled) {
+    const gchar *parent_username = "administrator";
+    const gchar *parent_fullname = _("Administrator");
+
     parent_user = act_user_manager_create_user (priv->act_client, parent_username, parent_fullname, 
ACT_USER_ACCOUNT_TYPE_ADMINISTRATOR, &local_error);
     if (local_error != NULL) {
       g_warning ("Failed to create parent user: %s", local_error->message);
diff --git a/gnome-initial-setup/pages/parental-controls/gis-parental-controls-page.c 
b/gnome-initial-setup/pages/parental-controls/gis-parental-controls-page.c
index 5d12b4c..2e4c3f8 100644
--- a/gnome-initial-setup/pages/parental-controls/gis-parental-controls-page.c
+++ b/gnome-initial-setup/pages/parental-controls/gis-parental-controls-page.c
@@ -82,23 +82,11 @@ gis_parental_controls_page_shown (GisPage *gis_page)
   /* TODO */
 }
 
-/* TODO: I don’t think this does what I think it does */
-static gboolean
-gis_parental_controls_page_skip (GisPage *gis_page)
-{
-  GisParentalControlsPage *page = GIS_PARENTAL_CONTROLS_PAGE (gis_page);
-
-  /* Skip showing the parental controls if they’re not enabled. */
-  if (!gis_driver_get_parental_controls_enabled (GIS_PAGE (page)->driver))
-    return TRUE;
-
-  return FALSE;
-}
-
 static void
 gis_parental_controls_page_constructed (GObject *object)
 {
   GisParentalControlsPage *page = GIS_PARENTAL_CONTROLS_PAGE (object);
+  g_autoptr(GPermission) permission = NULL;
 
   G_OBJECT_CLASS (gis_parental_controls_page_parent_class)->constructed (object);
 
@@ -108,8 +96,12 @@ gis_parental_controls_page_constructed (GObject *object)
 
   update_page_validation (page);
 
-  mct_user_controls_set_user (page->user_controls, selected_user);
-  mct_user_controls_set_permission (self->user_controls, self->permission);
+  //mct_user_controls_set_user (MCT_USER_CONTROLS (page->user_controls), selected_user);
+
+  /* The gnome-initial-setup user should always be allowed to set parental
+   * controls. */
+  permission = g_simple_permission_new (TRUE);
+  // TODO makes controls disappear mct_user_controls_set_permission (MCT_USER_CONTROLS 
(page->user_controls), permission);
 
   /* TODO is this necessary? */
   gtk_widget_show (GTK_WIDGET (page));
@@ -135,7 +127,6 @@ gis_parental_controls_page_class_init (GisParentalControlsPageClass *klass)
   page_class->apply = gis_parental_controls_page_apply;
   page_class->save_data = gis_parental_controls_page_save_data;
   page_class->shown = gis_parental_controls_page_shown;
-  page_class->skip = gis_parental_controls_page_skip;
 
   gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/initial-setup/gis-parental-controls-page.ui");
 
@@ -157,6 +148,10 @@ gis_parental_controls_page_init (GisParentalControlsPage *page)
 GisPage *
 gis_prepare_parental_controls_page (GisDriver *driver)
 {
+  /* Skip parental controls if they’re not enabled. */
+  if (!gis_driver_get_parental_controls_enabled (driver))
+    return NULL;
+
   return g_object_new (GIS_TYPE_PARENTAL_CONTROLS_PAGE,
                        "driver", driver,
                        NULL);
diff --git a/gnome-initial-setup/pages/password/gis-password-page.c 
b/gnome-initial-setup/pages/password/gis-password-page.c
index 743f48a..7bd4b7c 100644
--- a/gnome-initial-setup/pages/password/gis-password-page.c
+++ b/gnome-initial-setup/pages/password/gis-password-page.c
@@ -171,20 +171,6 @@ gis_password_page_shown (GisPage *gis_page)
   gtk_widget_grab_focus (priv->password_entry);
 }
 
-static gboolean
-gis_password_page_skip (GisPage *gis_page)
-{
-  GisPasswordPage *page = GIS_PASSWORD_PAGE (gis_page);
-  GisPasswordPagePrivate *priv = gis_password_page_get_instance_private (page);
-
-  /* Skip prompting for the parent password (`priv->parent_mode`) if parental
-   * controls aren’t enabled (`gis_driver_get_parental_controls_enabled()`). */
-  if (priv->parent_mode && !gis_driver_get_parental_controls_enabled (GIS_PAGE (page)->driver))
-    return TRUE;
-
-  return FALSE;
-}
-
 static gboolean
 validate (GisPasswordPage *page)
 {
@@ -411,7 +397,6 @@ gis_password_page_class_init (GisPasswordPageClass *klass)
   page_class->locale_changed = gis_password_page_locale_changed;
   page_class->save_data = gis_password_page_save_data;
   page_class->shown = gis_password_page_shown;
-  page_class->skip = gis_password_page_skip;
 
   object_class->constructed = gis_password_page_constructed;
   object_class->get_property = gis_password_page_get_property;
@@ -466,6 +451,10 @@ gis_prepare_password_page (GisDriver *driver)
 GisPage *
 gis_prepare_parent_password_page (GisDriver *driver)
 {
+  /* Skip prompting for the parent password if parental controls aren’t enabled. */
+  if (!gis_driver_get_parental_controls_enabled (driver))
+    return NULL;
+
   return g_object_new (GIS_TYPE_PASSWORD_PAGE,
                        "driver", driver,
                        "parent-mode", TRUE,


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