[gnome-initial-setup] account: don't cast GisAccountPageLocal to GisPage



commit b7f55eacfdc9b6c456ec8bf8f73bd43c9a15e3ee
Author: Will Thompson <will willthompson co uk>
Date:   Sat Feb 15 21:22:42 2020 +0000

    account: don't cast GisAccountPageLocal to GisPage
    
    GisAccountPage is a subclass of GisPage, but (despite what its name
    might suggest), GisAccountPageLocal is not a subclass of GisAccountPage.
    Since d8d1af4, local_create_user() tried to cast its
    'GisAccountPageLocal *page' parameter to GisPage.
    
    Like several similar functions which need access to the GisPage, rename
    the existing parameter to 'local' and add a new 'GisPage *page'
    parameter.

 .../pages/account/gis-account-page-local.c             | 18 ++++++++++--------
 .../pages/account/gis-account-page-local.h             |  3 ++-
 gnome-initial-setup/pages/account/gis-account-page.c   |  2 +-
 3 files changed, 13 insertions(+), 10 deletions(-)
---
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 a4346fa..fb12c05 100644
--- a/gnome-initial-setup/pages/account/gis-account-page-local.c
+++ b/gnome-initial-setup/pages/account/gis-account-page-local.c
@@ -542,9 +542,10 @@ set_user_avatar (GisAccountPageLocal *page,
 }
 
 static void
-local_create_user (GisAccountPageLocal *page)
+local_create_user (GisAccountPageLocal *local,
+                   GisPage             *page)
 {
-  GisAccountPageLocalPrivate *priv = gis_account_page_local_get_instance_private (page);
+  GisAccountPageLocalPrivate *priv = gis_account_page_local_get_instance_private (local);
   const gchar *username;
   const gchar *fullname;
   g_autoptr(GError) local_error = NULL;
@@ -554,7 +555,7 @@ local_create_user (GisAccountPageLocal *page)
 
   username = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (priv->username_combo));
   fullname = gtk_entry_get_text (GTK_ENTRY (priv->fullname_entry));
-  parental_controls_enabled = gis_driver_get_parental_controls_enabled (GIS_PAGE (page)->driver);
+  parental_controls_enabled = gis_driver_get_parental_controls_enabled (page->driver);
 
   /* 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. */
@@ -568,7 +569,7 @@ local_create_user (GisAccountPageLocal *page)
       return;
     }
 
-    g_signal_emit (page, signals[PARENT_USER_CREATED], 0, parent_user, "");
+    g_signal_emit (local, signals[PARENT_USER_CREATED], 0, parent_user, "");
   }
 
   /* Now create the main user. */
@@ -578,9 +579,9 @@ local_create_user (GisAccountPageLocal *page)
     return;
   }
 
-  set_user_avatar (page, main_user);
+  set_user_avatar (local, main_user);
 
-  g_signal_emit (page, signals[MAIN_USER_CREATED], 0, main_user, "");
+  g_signal_emit (local, signals[MAIN_USER_CREATED], 0, main_user, "");
 }
 
 static void
@@ -635,9 +636,10 @@ gis_account_page_local_validate (GisAccountPageLocal *page)
 }
 
 void
-gis_account_page_local_create_user (GisAccountPageLocal *page)
+gis_account_page_local_create_user (GisAccountPageLocal *local,
+                                    GisPage             *page)
 {
-  local_create_user (page);
+  local_create_user (local, page);
 }
 
 gboolean
diff --git a/gnome-initial-setup/pages/account/gis-account-page-local.h 
b/gnome-initial-setup/pages/account/gis-account-page-local.h
index bb70fd3..7e7fea1 100644
--- a/gnome-initial-setup/pages/account/gis-account-page-local.h
+++ b/gnome-initial-setup/pages/account/gis-account-page-local.h
@@ -50,7 +50,8 @@ GType gis_account_page_local_get_type (void);
 
 gboolean gis_account_page_local_validate (GisAccountPageLocal *local);
 gboolean gis_account_page_local_apply (GisAccountPageLocal *local, GisPage *page);
-void gis_account_page_local_create_user (GisAccountPageLocal *local);
+void gis_account_page_local_create_user (GisAccountPageLocal *local,
+                                         GisPage             *page);
 void gis_account_page_local_shown (GisAccountPageLocal *local);
 
 G_END_DECLS
diff --git a/gnome-initial-setup/pages/account/gis-account-page.c 
b/gnome-initial-setup/pages/account/gis-account-page.c
index 1ba7107..ebccf96 100644
--- a/gnome-initial-setup/pages/account/gis-account-page.c
+++ b/gnome-initial-setup/pages/account/gis-account-page.c
@@ -150,7 +150,7 @@ gis_account_page_save_data (GisPage *gis_page)
 
   switch (priv->mode) {
   case UM_LOCAL:
-    gis_account_page_local_create_user (GIS_ACCOUNT_PAGE_LOCAL (priv->page_local));
+    gis_account_page_local_create_user (GIS_ACCOUNT_PAGE_LOCAL (priv->page_local), gis_page);
     break;
   case UM_ENTERPRISE:
     break;


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