[gnome-initial-setup] gnome-initial-setup: Don't autologin in session setup mode



commit 9594ac16f83f7d64314d7849fa27f9481b93e348
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Thu Jan 17 19:48:19 2013 -0500

    gnome-initial-setup: Don't autologin in session setup mode
    
    Don't remove the trigger file either; simply exit the app directly
    when asked to stop working in session mode.

 gnome-initial-setup/gis-driver.c                   |   86 +++++++++++++++++++-
 gnome-initial-setup/gis-driver.h                   |   11 +++-
 gnome-initial-setup/gnome-initial-setup.c          |   11 +++-
 .../pages/summary/gis-summary-page.c               |   13 +++-
 4 files changed, 116 insertions(+), 5 deletions(-)
---
diff --git a/gnome-initial-setup/gis-driver.c b/gnome-initial-setup/gis-driver.c
index 2314f6a..7a1a1ca 100644
--- a/gnome-initial-setup/gis-driver.c
+++ b/gnome-initial-setup/gis-driver.c
@@ -33,6 +33,25 @@
 #include "gis-assistant-clutter.h"
 #endif
 
+#define GIS_TYPE_DRIVER_MODE (gis_driver_mode_get_type ())
+
+/* Statically include this for now. Maybe later
+ * we'll generate this from glib-mkenums. */
+GType
+gis_driver_mode_get_type (void) {
+  static GType enum_type_id = 0;
+  if (G_UNLIKELY (!enum_type_id))
+    {
+      static const GEnumValue values[] = {
+        { GIS_DRIVER_MODE_NEW_USER, "GIS_DRIVER_MODE_NEW_USER", "new_user" },
+        { GIS_DRIVER_MODE_EXISTING_USER, "GIS_DRIVER_MODE_EXISTING_USER", "existing_user" },
+        { 0, NULL, NULL }
+      };
+      enum_type_id = g_enum_register_static("GisDriverMode", values);
+    }
+  return enum_type_id;
+}
+
 G_DEFINE_TYPE(GisDriver, gis_driver, GTK_TYPE_APPLICATION)
 
 #define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GIS_TYPE_DRIVER, GisDriverPrivate))
@@ -44,12 +63,22 @@ enum {
 
 static guint signals[LAST_SIGNAL];
 
+enum {
+  PROP_0,
+  PROP_MODE,
+  PROP_LAST,
+};
+
+static GParamSpec *obj_props[PROP_LAST];
+
 struct _GisDriverPrivate {
   GtkWindow *main_window;
   GisAssistant *assistant;
 
   ActUser *user_account;
   const gchar *user_password;
+
+  GisDriverMode mode;
 };
 
 static void
@@ -130,6 +159,13 @@ gis_driver_locale_changed (GisDriver *driver)
   gis_assistant_locale_changed (priv->assistant);
 }
 
+GisDriverMode
+gis_driver_get_mode (GisDriver *driver)
+{
+  GisDriverPrivate *priv = driver->priv;
+  return priv->mode;
+}
+
 static GType
 get_assistant_type (void)
 {
@@ -147,6 +183,42 @@ get_assistant_type (void)
 }
 
 static void
+gis_driver_get_property (GObject      *object,
+                         guint         prop_id,
+                         GValue       *value,
+                         GParamSpec   *pspec)
+{
+  GisDriver *driver = GIS_DRIVER (object);
+  switch (prop_id)
+    {
+    case PROP_MODE:
+      g_value_set_enum (value, driver->priv->mode);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+gis_driver_set_property (GObject      *object,
+                         guint         prop_id,
+                         const GValue *value,
+                         GParamSpec   *pspec)
+{
+  GisDriver *driver = GIS_DRIVER (object);
+  switch (prop_id)
+    {
+    case PROP_MODE:
+      driver->priv->mode = g_value_get_enum (value);
+      break;
+   default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
 gis_driver_activate (GApplication *app)
 {
   GisDriver *driver = GIS_DRIVER (app);
@@ -194,9 +266,12 @@ static void
 gis_driver_class_init (GisDriverClass *klass)
 {
   GApplicationClass *application_class = G_APPLICATION_CLASS (klass);
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
 
   g_type_class_add_private (klass, sizeof (GisDriverPrivate));
 
+  gobject_class->get_property = gis_driver_get_property;
+  gobject_class->set_property = gis_driver_set_property;
   application_class->startup = gis_driver_startup;
   application_class->activate = gis_driver_activate;
 
@@ -207,12 +282,21 @@ gis_driver_class_init (GisDriverClass *klass)
                   G_STRUCT_OFFSET (GisDriverClass, rebuild_pages),
                   NULL, NULL, NULL,
                   G_TYPE_NONE, 0);
+
+  obj_props[PROP_MODE] =
+    g_param_spec_enum ("mode", "", "",
+                       GIS_TYPE_DRIVER_MODE,
+                       GIS_DRIVER_MODE_EXISTING_USER,
+                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+
+  g_object_class_install_properties (gobject_class, PROP_LAST, obj_props);
 }
 
 GisDriver *
-gis_driver_new (void)
+gis_driver_new (GisDriverMode mode)
 {
   return g_object_new (GIS_TYPE_DRIVER,
                        "application-id", "org.gnome.InitialSetup",
+                       "mode", mode,
                        NULL);
 }
diff --git a/gnome-initial-setup/gis-driver.h b/gnome-initial-setup/gis-driver.h
index f0bbae2..2e74f73 100644
--- a/gnome-initial-setup/gis-driver.h
+++ b/gnome-initial-setup/gis-driver.h
@@ -55,6 +55,11 @@ struct _GisDriverClass
   void (* rebuild_pages) (GisDriver *driver);
 };
 
+typedef enum {
+  GIS_DRIVER_MODE_NEW_USER,
+  GIS_DRIVER_MODE_EXISTING_USER,
+} GisDriverMode;
+
 GType gis_driver_get_type (void);
 
 GisAssistant *gis_driver_get_assistant (GisDriver *driver);
@@ -67,9 +72,13 @@ void gis_driver_set_user_permissions (GisDriver   *driver,
 void gis_driver_get_user_permissions (GisDriver    *driver,
                                       ActUser     **user,
                                       const gchar **password);
+
+GisDriverMode gis_driver_get_mode (GisDriver *driver);
+
 void gis_driver_add_page (GisDriver *driver,
                           GisPage   *page);
-GisDriver *gis_driver_new (void);
+
+GisDriver *gis_driver_new (GisDriverMode mode);
 
 G_END_DECLS
 
diff --git a/gnome-initial-setup/gnome-initial-setup.c b/gnome-initial-setup/gnome-initial-setup.c
index ea92bb4..efe8809 100644
--- a/gnome-initial-setup/gnome-initial-setup.c
+++ b/gnome-initial-setup/gnome-initial-setup.c
@@ -153,6 +153,15 @@ rebuild_pages_cb (GisDriver *driver, GList *pages)
   g_strfreev (skip_pages);
 }
 
+static GisDriverMode
+get_mode (void)
+{
+  if (session_setup_mode)
+    return GIS_DRIVER_MODE_EXISTING_USER;
+  else
+    return GIS_DRIVER_MODE_NEW_USER;
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -193,7 +202,7 @@ main (int argc, char *argv[])
 
   g_type_ensure (EGG_TYPE_LIST_BOX);
 
-  driver = gis_driver_new ();
+  driver = gis_driver_new (get_mode ());
   g_signal_connect (driver, "rebuild-pages", G_CALLBACK (rebuild_pages_cb), pages);
   status = g_application_run (G_APPLICATION (driver), argc, argv);
 
diff --git a/gnome-initial-setup/pages/summary/gis-summary-page.c b/gnome-initial-setup/pages/summary/gis-summary-page.c
index 04b4c7e..acbb507 100644
--- a/gnome-initial-setup/pages/summary/gis-summary-page.c
+++ b/gnome-initial-setup/pages/summary/gis-summary-page.c
@@ -216,8 +216,17 @@ done_cb (GtkButton *button, GisSummaryPage *page)
   g_file_set_contents (file, "yes", -1, NULL);
   g_free (file);
 
-  remove_trigger_file (page);
-  log_user_in (page);
+  switch (gis_driver_get_mode (GIS_PAGE (page)->driver))
+    {
+    case GIS_DRIVER_MODE_NEW_USER:
+      log_user_in (page);
+      remove_trigger_file (page);
+      break;
+    case GIS_DRIVER_MODE_EXISTING_USER:
+      g_application_quit (GIS_DRIVER (GIS_PAGE (page)->driver));
+    default:
+      break;
+    }
 }
 
 static void



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