[gnome-initial-setup/parental-controls: 2/4] WIP
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup/parental-controls: 2/4] WIP
- Date: Tue, 4 Feb 2020 13:18:35 +0000 (UTC)
commit 15a9e0e1848854acbd0919bde6d26a31d1b8df50
Author: Philip Withnall <withnall endlessm com>
Date: Thu Jan 30 18:14:18 2020 +0000
WIP
Signed-off-by: Philip Withnall <withnall endlessm com>
gnome-initial-setup/gis-page.h | 2 +
gnome-initial-setup/gnome-initial-setup.c | 2 +
.../parental-controls/gis-parental-controls-page.c | 202 +++------------------
.../parental-controls/gis-parental-controls-page.h | 2 +
.../pages/parental-controls/meson.build | 2 +-
meson.build | 2 +-
6 files changed, 36 insertions(+), 176 deletions(-)
---
diff --git a/gnome-initial-setup/gis-page.h b/gnome-initial-setup/gis-page.h
index b9a3e9a..9bc9af4 100644
--- a/gnome-initial-setup/gis-page.h
+++ b/gnome-initial-setup/gis-page.h
@@ -37,6 +37,8 @@ typedef struct _GisPage GisPage;
typedef struct _GisPageClass GisPageClass;
typedef struct _GisAssistantPagePrivate GisAssistantPagePrivate;
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (GisPage, g_object_unref)
+
typedef void (* GisPageApplyCallback) (GisPage *page,
gboolean valid,
gpointer user_data);
diff --git a/gnome-initial-setup/gnome-initial-setup.c b/gnome-initial-setup/gnome-initial-setup.c
index 2c3836c..673b17e 100644
--- a/gnome-initial-setup/gnome-initial-setup.c
+++ b/gnome-initial-setup/gnome-initial-setup.c
@@ -39,6 +39,7 @@
#include "pages/privacy/gis-privacy-page.h"
#include "pages/goa/gis-goa-page.h"
#include "pages/account/gis-account-pages.h"
+#include "pages/parental-controls/gis-parental-controls-page.h"
#include "pages/password/gis-password-page.h"
#include "pages/summary/gis-summary-page.h"
@@ -70,6 +71,7 @@ static PageData page_table[] = {
PAGE (goa, FALSE),
PAGE (account, TRUE),
PAGE (password, TRUE),
+ PAGE (parental_controls, TRUE), /* TODO: new_user_only? */
PAGE (summary, FALSE),
{ NULL },
};
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 9ec1d45..c7b876f 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
@@ -30,6 +30,7 @@
#include <glib/gi18n.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
+#include <libmalcontent-ui/malcontent-ui.h>
#include "parental-controls-resources.h"
#include "gis-parental-controls-page.h"
@@ -43,29 +44,10 @@ struct _GisParentalControlsPage
G_DEFINE_TYPE (GisParentalControlsPage, gis_parental_controls_page, GIS_TYPE_PAGE)
-static void
-enterprise_apply_complete (GisPage *dummy,
- gboolean valid,
- gpointer user_data)
-{
- GisParentalControlsPage *page = GIS_PARENTAL_CONTROLS_PAGE (user_data);
- gis_driver_set_username (GIS_PAGE (page)->driver, NULL);
- gis_page_apply_complete (GIS_PAGE (page), valid);
-}
-
static gboolean
page_validate (GisParentalControlsPage *page)
{
- GisParentalControlsPagePrivate *priv = gis_parental_controls_page_get_instance_private (page);
-
- switch (priv->mode) {
- case UM_LOCAL:
- return gis_parental_controls_page_local_validate (GIS_PARENTAL_CONTROLS_PAGE_LOCAL (priv->page_local));
- case UM_ENTERPRISE:
- return gis_parental_controls_page_enterprise_validate (GIS_PARENTAL_CONTROLS_PAGE_ENTERPRISE
(priv->page_enterprise));
- default:
- g_assert_not_reached ();
- }
+ /* TODO */
}
static void
@@ -74,216 +56,88 @@ update_page_validation (GisParentalControlsPage *page)
gis_page_set_complete (GIS_PAGE (page), page_validate (page));
}
-static void
-on_validation_changed (gpointer page_area,
- GisParentalControlsPage *page)
-{
- update_page_validation (page);
-}
-
-static void
-set_mode (GisParentalControlsPage *page,
- UmParentalControlsMode mode)
-{
- GisParentalControlsPagePrivate *priv = gis_parental_controls_page_get_instance_private (page);
-
- if (priv->mode == mode)
- return;
-
- priv->mode = mode;
- gis_driver_set_parental_controls_mode (GIS_PAGE (page)->driver, mode);
-
- switch (mode)
- {
- case UM_LOCAL:
- gtk_stack_set_visible_child (GTK_STACK (priv->stack), priv->page_local);
- gis_parental_controls_page_local_shown (GIS_PARENTAL_CONTROLS_PAGE_LOCAL (priv->page_local));
- break;
- case UM_ENTERPRISE:
- gtk_stack_set_visible_child (GTK_STACK (priv->stack), priv->page_enterprise);
- gis_parental_controls_page_enterprise_shown (GIS_PARENTAL_CONTROLS_PAGE_ENTERPRISE
(priv->page_enterprise));
- break;
- default:
- g_assert_not_reached ();
- }
-
- update_page_validation (page);
-}
-
-static void
-toggle_mode (GtkToggleButton *button,
- gpointer user_data)
-{
- set_mode (GIS_PARENTAL_CONTROLS_PAGE (user_data),
- gtk_toggle_button_get_active (button) ? UM_ENTERPRISE : UM_LOCAL);
-}
-
static gboolean
-gis_parental_controls_page_apply (GisPage *gis_page,
- GCancellable *cancellable)
+gis_parental_controls_page_apply (GisPage *gis_page,
+ GCancellable *cancellable)
{
GisParentalControlsPage *page = GIS_PARENTAL_CONTROLS_PAGE (gis_page);
- GisParentalControlsPagePrivate *priv = gis_parental_controls_page_get_instance_private (page);
- switch (priv->mode) {
- case UM_LOCAL:
- return gis_parental_controls_page_local_apply (GIS_PARENTAL_CONTROLS_PAGE_LOCAL (priv->page_local),
gis_page);
- case UM_ENTERPRISE:
- return gis_parental_controls_page_enterprise_apply (GIS_PARENTAL_CONTROLS_PAGE_ENTERPRISE
(priv->page_enterprise), cancellable,
- enterprise_apply_complete, page);
- default:
- g_assert_not_reached ();
- break;
- }
+ /* TODO */
}
static void
gis_parental_controls_page_save_data (GisPage *gis_page)
{
GisParentalControlsPage *page = GIS_PARENTAL_CONTROLS_PAGE (gis_page);
- GisParentalControlsPagePrivate *priv = gis_parental_controls_page_get_instance_private (page);
- switch (priv->mode) {
- case UM_LOCAL:
- gis_parental_controls_page_local_create_user (GIS_PARENTAL_CONTROLS_PAGE_LOCAL (priv->page_local));
- break;
- case UM_ENTERPRISE:
- break;
- default:
- g_assert_not_reached ();
- }
+ /* TODO: create the user and set the parental controls */
}
static void
gis_parental_controls_page_shown (GisPage *gis_page)
{
GisParentalControlsPage *page = GIS_PARENTAL_CONTROLS_PAGE (gis_page);
- GisParentalControlsPagePrivate *priv = gis_parental_controls_page_get_instance_private (page);
-
- gis_parental_controls_page_local_shown (GIS_PARENTAL_CONTROLS_PAGE_LOCAL (priv->page_local));
-}
-static void
-on_local_user_created (GtkWidget *page_local,
- ActUser *user,
- char *password,
- GisParentalControlsPage *page)
-{
- const gchar *language;
-
- language = gis_driver_get_user_language (GIS_PAGE (page)->driver);
- if (language)
- act_user_set_language (user, language);
-
- gis_driver_set_user_permissions (GIS_PAGE (page)->driver, user, password);
-}
-
-static void
-on_local_page_confirmed (GisParentalControlsPageLocal *local,
- GisParentalControlsPage *page)
-{
- gis_assistant_next_page (gis_driver_get_assistant (GIS_PAGE (page)->driver));
-}
-
-static void
-on_local_user_cached (GtkWidget *page_local,
- ActUser *user,
- char *password,
- GisParentalControlsPage *page)
-{
- const gchar *language;
-
- language = gis_driver_get_user_language (GIS_PAGE (page)->driver);
- if (language)
- act_user_set_language (user, language);
-
- gis_driver_set_user_permissions (GIS_PAGE (page)->driver, user, password);
-}
-
-static void
-on_network_changed (GNetworkMonitor *monitor,
- gboolean available,
- GisParentalControlsPage *page)
-{
- GisParentalControlsPagePrivate *priv = gis_parental_controls_page_get_instance_private (page);
-
- if (!available && priv->mode != UM_ENTERPRISE)
- gtk_stack_set_visible_child (GTK_STACK (priv->offline_stack), priv->offline_label);
- else
- gtk_stack_set_visible_child (GTK_STACK (priv->offline_stack), priv->page_toggle);
+ /* TODO */
}
static void
gis_parental_controls_page_constructed (GObject *object)
{
GisParentalControlsPage *page = GIS_PARENTAL_CONTROLS_PAGE (object);
- GisParentalControlsPagePrivate *priv = gis_parental_controls_page_get_instance_private (page);
- GNetworkMonitor *monitor;
- gboolean available;
G_OBJECT_CLASS (gis_parental_controls_page_parent_class)->constructed (object);
+ /* TODO connect to signals from the user controls
g_signal_connect (priv->page_local, "validation-changed",
- G_CALLBACK (on_validation_changed), page);
- g_signal_connect (priv->page_local, "user-created",
- G_CALLBACK (on_local_user_created), page);
- g_signal_connect (priv->page_local, "confirm",
- G_CALLBACK (on_local_page_confirmed), page);
-
- g_signal_connect (priv->page_enterprise, "validation-changed",
- G_CALLBACK (on_validation_changed), page);
- g_signal_connect (priv->page_enterprise, "user-cached",
- G_CALLBACK (on_local_user_cached), page);
+ G_CALLBACK (on_validation_changed), page); */
update_page_validation (page);
- g_signal_connect (priv->page_toggle, "toggled", G_CALLBACK (toggle_mode), page);
- g_object_bind_property (page, "applying", priv->page_toggle, "sensitive", G_BINDING_INVERT_BOOLEAN);
- g_object_bind_property (priv->page_enterprise, "visible", priv->offline_stack, "visible",
G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
-
- /* force a refresh by setting to an invalid value */
- priv->mode = NUM_MODES;
- set_mode (page, UM_LOCAL);
-
- monitor = g_network_monitor_get_default ();
- available = g_network_monitor_get_network_available (monitor);
- on_network_changed (monitor, available, page);
- g_signal_connect_object (monitor, "network-changed", G_CALLBACK (on_network_changed), page, 0);
-
+ /* TODO is this necessary? */
gtk_widget_show (GTK_WIDGET (page));
}
static void
gis_parental_controls_page_locale_changed (GisPage *page)
{
- gis_page_set_title (GIS_PAGE (page), _("About You"));
+ gis_page_set_title (GIS_PAGE (page), _("Parental Controls"));
}
static void
gis_parental_controls_page_class_init (GisParentalControlsPageClass *klass)
{
- GisPageClass *page_class = GIS_PAGE_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GisPageClass *page_class = GIS_PAGE_CLASS (klass);
- gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/initial-setup/gis-parental_controls-page.ui");
-
- gtk_widget_class_bind_template_child (widget_class, GisParentalControlsPage, user_controls);
+ object_class->constructed = gis_parental_controls_page_constructed;
page_class->page_id = PAGE_ID;
page_class->locale_changed = gis_parental_controls_page_locale_changed;
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;
- object_class->constructed = gis_parental_controls_page_constructed;
+
+ gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/initial-setup/gis-parental_controls-page.ui");
+
+ gtk_widget_class_bind_template_child (widget_class, GisParentalControlsPage, user_controls);
}
static void
gis_parental_controls_page_init (GisParentalControlsPage *page)
{
g_resources_register (parental_controls_get_resource ());
- g_type_ensure (GIS_TYPE_PARENTAL_CONTROLS_PAGE_LOCAL);
- g_type_ensure (GIS_TYPE_PARENTAL_CONTROLS_PAGE_ENTERPRISE);
+
+ g_type_ensure (MCT_TYPE_USER_CONTROLS);
gtk_widget_init_template (GTK_WIDGET (page));
}
+
+GisPage *
+gis_prepare_parental_controls_page (GisDriver *driver)
+{
+ return g_object_new (GIS_TYPE_PARENTAL_CONTROLS_PAGE,
+ "driver", driver,
+ NULL);
+}
diff --git a/gnome-initial-setup/pages/parental-controls/gis-parental-controls-page.h
b/gnome-initial-setup/pages/parental-controls/gis-parental-controls-page.h
index 3cd9c20..3b32341 100644
--- a/gnome-initial-setup/pages/parental-controls/gis-parental-controls-page.h
+++ b/gnome-initial-setup/pages/parental-controls/gis-parental-controls-page.h
@@ -33,4 +33,6 @@ G_DECLARE_FINAL_TYPE (GisParentalControlsPage, gis_parental_controls_page, GIS,
GType gis_parental_controls_page_get_type (void);
+GisPage *gis_prepare_parental_controls_page (GisDriver *driver);
+
G_END_DECLS
diff --git a/gnome-initial-setup/pages/parental-controls/meson.build
b/gnome-initial-setup/pages/parental-controls/meson.build
index ddf5b72..539460c 100644
--- a/gnome-initial-setup/pages/parental-controls/meson.build
+++ b/gnome-initial-setup/pages/parental-controls/meson.build
@@ -1,7 +1,7 @@
sources += gnome.compile_resources(
'parental-controls-resources',
files('parental-controls.gresource.xml'),
- c_name: 'parental-controls',
+ c_name: 'parental_controls',
)
sources += files(
diff --git a/meson.build b/meson.build
index 567893a..3bbb05d 100644
--- a/meson.build
+++ b/meson.build
@@ -60,7 +60,7 @@ ibus_dep = dependency ('ibus-1.0',
conf.set('HAVE_IBUS', ibus_dep.found())
# Needed for the parental controls pages
-libmalcontent_ui_dep = dependency ('libmalcontent-ui',
+libmalcontent_ui_dep = dependency ('malcontent-ui-0',
version: '>= 0.5.0',
required: get_option('parental_controls'))
conf.set('HAVE_PARENTAL_CONTROLS', libmalcontent_ui_dep.found())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]