[gnome-initial-setup] Split the accounts page out



commit bdc536f3f2c4e99a1639393f03c4f4dc88eb5d79
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Wed Jun 27 16:24:14 2012 -0400

    Split the accounts page out
    
    This is very ugly and sketchy. But a lot of this code will have to be
    rewritten for enterprise support *anyway*.

 gnome-initial-setup/Makefile.am           |    1 +
 gnome-initial-setup/gis-account-page.c    |   78 +++++++++++++++++++---------
 gnome-initial-setup/gis-account-page.h    |   14 +++++
 gnome-initial-setup/gis-account-page.ui   |    2 +-
 gnome-initial-setup/gis-summary-page.c    |   30 +++--------
 gnome-initial-setup/gnome-initial-setup.c |   48 ++----------------
 gnome-initial-setup/gnome-initial-setup.h |    3 -
 gnome-initial-setup/welcome-tour.desktop  |    4 +-
 8 files changed, 84 insertions(+), 96 deletions(-)
---
diff --git a/gnome-initial-setup/Makefile.am b/gnome-initial-setup/Makefile.am
index 231c057..f78ddc3 100644
--- a/gnome-initial-setup/Makefile.am
+++ b/gnome-initial-setup/Makefile.am
@@ -51,6 +51,7 @@ gnome_initial_setup_SOURCES =	\
 	gis-welcome-page.c gis-welcome-page.h \
 	gis-eula-pages.c gis-eula-pages.h \
 	gis-location-page.c gis-location-page.h \
+	gis-account-page.c gis-account-page.h \
 	gis-network-page.c gis-network-page.h \
 	gis-summary-page.c gis-summary-page.h \
 	gis-goa-page.c gis-goa-page.h \
diff --git a/gnome-initial-setup/gis-account-page.c b/gnome-initial-setup/gis-account-page.c
index 1cfbd7b..28c215a 100644
--- a/gnome-initial-setup/gis-account-page.c
+++ b/gnome-initial-setup/gis-account-page.c
@@ -1,17 +1,35 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
 
 /* Account page {{{1 */
 
+#include "config.h"
+#include "gis-account-page.h"
+
+#include <glib/gi18n.h>
+#include <gio/gio.h>
+
+#include <act/act-user-manager.h>
+
+#include <gnome-keyring.h>
+
+#include "um-utils.h"
+#include "um-photo-dialog.h"
+#include "pw-utils.h"
+
+#ifdef HAVE_CHEESE
+#include <cheese-gtk.h>
+#endif
+
 #define OBJ(type,name) ((type)gtk_builder_get_object(data->builder,(name)))
 #define WID(name) OBJ(GtkWidget*,name)
 
-static gboolean skip_account = FALSE;
-
 typedef struct _AccountData AccountData;
 
 struct _AccountData {
   SetupData *setup;
   GtkBuilder *builder;
 
+  ActUser *act_user;
   ActUserManager *act_client;
 
   gboolean valid_name;
@@ -29,6 +47,22 @@ struct _AccountData {
 };
 
 static void
+copy_account_data (SetupData *setup, AccountData *data)
+{
+  ActUser *user = data->act_user;
+  /* here is where we copy all the things we just
+   * configured, from the current users home dir to the
+   * account that was created in the first step
+   */
+  g_debug ("Copying account data");
+  g_settings_sync ();
+
+  gis_copy_account_file (user, ".config/dconf/user");
+  gis_copy_account_file (user, ".config/goa-1.0/accounts.conf");
+  gis_copy_account_file (user, ".gnome2/keyrings/Default.keyring");
+}
+
+static void
 update_account_page_status (AccountData *data)
 {
   gboolean complete;
@@ -233,10 +267,9 @@ set_user_avatar (AccountData *data)
   GFileIOStream *io_stream = NULL;
   GOutputStream *stream = NULL;
   GError *error = NULL;
-  SetupData *setup = data->setup;
 
   if (data->avatar_filename != NULL) {
-    act_user_set_icon_file (setup->act_user, data->avatar_filename);
+    act_user_set_icon_file (data->act_user, data->avatar_filename);
     return;
   }
 
@@ -252,7 +285,7 @@ set_user_avatar (AccountData *data)
   if (!gdk_pixbuf_save_to_stream (data->avatar_pixbuf, stream, "png", NULL, &error, NULL))
     goto out;
 
-  act_user_set_icon_file (setup->act_user, g_file_get_path (file)); 
+  act_user_set_icon_file (data->act_user, g_file_get_path (file)); 
 
  out:
   if (error != NULL) {
@@ -270,13 +303,13 @@ create_user (AccountData *data)
   const gchar *username;
   const gchar *fullname;
   GError *error;
-  SetupData *setup = data->setup;
 
   username = gtk_combo_box_text_get_active_text (OBJ(GtkComboBoxText*, "account-username-combo"));
   fullname = gtk_entry_get_text (OBJ(GtkEntry*, "account-fullname-entry"));
 
   error = NULL;
-  setup->act_user = act_user_manager_create_user (data->act_client, username, fullname, data->account_type, &error);
+
+  data->act_user = act_user_manager_create_user (data->act_client, username, fullname, data->account_type, &error);
   if (error != NULL) {
     g_warning ("Failed to create user: %s", error->message);
     g_error_free (error);
@@ -342,7 +375,6 @@ save_account_data (AccountData *data)
   const gchar *realname;
   const gchar *username;
   const gchar *password;
-  SetupData *setup = data->setup;
 
   if (!data->user_data_unsaved) {
     return;
@@ -355,19 +387,19 @@ save_account_data (AccountData *data)
     return;
   }
 
-  if (setup->act_user == NULL) {
+  if (data->act_user == NULL) {
     create_user (data);
   }
 
-  if (setup->act_user == NULL) {
+  if (data->act_user == NULL) {
     g_warning ("User creation failed");
     clear_account_page (data);
     return;
   }
 
-  if (!act_user_is_loaded (setup->act_user)) {
+  if (!act_user_is_loaded (data->act_user)) {
     if (when_loaded == 0)
-      when_loaded = g_signal_connect (setup->act_user, "notify::is-loaded",
+      when_loaded = g_signal_connect (data->act_user, "notify::is-loaded",
                                       G_CALLBACK (save_when_loaded), data);
     return;
   }
@@ -376,14 +408,14 @@ save_account_data (AccountData *data)
   username = gtk_combo_box_text_get_active_text (OBJ (GtkComboBoxText*, "account-username-combo"));
   password = gtk_entry_get_text (OBJ (GtkEntry*, "account-password-entry"));
 
-  act_user_set_real_name (setup->act_user, realname);
-  act_user_set_user_name (setup->act_user, username);
-  act_user_set_account_type (setup->act_user, data->account_type);
+  act_user_set_real_name (data->act_user, realname);
+  act_user_set_user_name (data->act_user, username);
+  act_user_set_account_type (data->act_user, data->account_type);
   if (data->password_mode == ACT_USER_PASSWORD_MODE_REGULAR) {
-    act_user_set_password (setup->act_user, password, NULL);
+    act_user_set_password (data->act_user, password, NULL);
   }
   else {
-    act_user_set_password_mode (setup->act_user, data->password_mode);
+    act_user_set_password_mode (data->act_user, data->password_mode);
   }
 
   gnome_keyring_create_sync ("Default", password ? password : "");
@@ -455,8 +487,8 @@ avatar_callback (GdkPixbuf   *pixbuf,
   }
 }
 
-static void
-prepare_account_page (SetupData *setup)
+void
+gis_prepare_account_page (SetupData *setup)
 {
   GtkWidget *fullname_entry;
   GtkWidget *username_combo;
@@ -472,8 +504,7 @@ prepare_account_page (SetupData *setup)
   data->builder = gis_builder ("gis-account-page");
   data->setup = setup;
 
-  if (!skip_account)
-    gtk_widget_show (WID("account-page"));
+  gtk_widget_show (WID("account-page"));
 
   g_signal_connect (WID("account-new-local"), "clicked",
                     G_CALLBACK (show_local_account_dialog), data);
@@ -520,8 +551,5 @@ prepare_account_page (SetupData *setup)
 
   g_object_set_data (OBJ (GObject *, "account-page"), "gis-page-title", _("Login"));
   gis_assistant_add_page (assistant, WID ("account-page"));
-  gis_assistant_set_page_complete (assistant, WID ("account-page"), TRUE);
+  gis_add_summary_callback (setup, (GFunc)copy_account_data, data);
 }
-
-#undef OBJ
-#undef WID
diff --git a/gnome-initial-setup/gis-account-page.h b/gnome-initial-setup/gis-account-page.h
new file mode 100644
index 0000000..26a320f
--- /dev/null
+++ b/gnome-initial-setup/gis-account-page.h
@@ -0,0 +1,14 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+#ifndef __GIS_ACCOUNT_PAGE_H__
+#define __GIS_ACCOUNT_PAGE_H__
+
+#include "gnome-initial-setup.h"
+
+G_BEGIN_DECLS
+
+void gis_prepare_account_page (SetupData *setup);
+
+G_END_DECLS
+
+#endif /* __GIS_ACCOUNT_PAGE_H__ */
diff --git a/gnome-initial-setup/gis-account-page.ui b/gnome-initial-setup/gis-account-page.ui
index 3f96bc9..0582514 100644
--- a/gnome-initial-setup/gis-account-page.ui
+++ b/gnome-initial-setup/gis-account-page.ui
@@ -223,7 +223,7 @@
   </object>
   <object class="GtkGrid" id="account-page">
     <property name="name">account-page</property>
-    <property name="visible">False</property>
+    <property name="visible">True</property>
     <property name="halign">center</property>
     <child>
       <object class="GtkLabel" id="account-title">
diff --git a/gnome-initial-setup/gis-summary-page.c b/gnome-initial-setup/gis-summary-page.c
index 08b94b6..34ca7ac 100644
--- a/gnome-initial-setup/gis-summary-page.c
+++ b/gnome-initial-setup/gis-summary-page.c
@@ -37,33 +37,27 @@ on_ready_for_auto_login (GdmGreeterClient *client,
                          const char       *service_name,
                          SetupData        *setup)
 {
-  const gchar *username;
+  /* const gchar *username; */
 
-  username = act_user_get_user_name (gis_get_act_user (setup));
+  /* username = act_user_get_user_name (gis_get_act_user (setup)); */
 
-  g_debug ("Initiating autologin for %s", username);
-  gdm_greeter_client_call_begin_auto_login (client, username);
-  gdm_greeter_client_call_start_session_when_ready (client,
-                                                    service_name,
-                                                    TRUE);
+  /* g_debug ("Initiating autologin for %s", username); */
+  /* gdm_greeter_client_call_begin_auto_login (client, username); */
+  /* gdm_greeter_client_call_start_session_when_ready (client, */
+  /*                                                   service_name, */
+  /*                                                   TRUE); */
 }
 
 static void
 begin_autologin (SetupData *setup)
 {
   GdmGreeterClient *greeter_client = connect_to_slave ();
-  ActUser *act_user = gis_get_act_user (setup);
 
   if (greeter_client == NULL) {
     g_warning ("No slave connection; not initiating autologin");
     return;
   }
 
-  if (act_user == NULL) {
-    g_warning ("No username; not initiating autologin");
-    return;
-  }
-
   g_debug ("Preparing to autologin");
 
   g_signal_connect (greeter_client,
@@ -82,14 +76,8 @@ byebye_cb (GtkButton *button, SetupData *setup)
 static void
 tour_cb (GtkButton *button, SetupData *setup)
 {
-  gchar *filename;
-
-  /* the tour is triggered by ~/.config/run-welcome-tour */
-  filename = g_build_filename (g_get_home_dir (), ".config", "run-welcome-tour", NULL);
-  g_file_set_contents (filename, "yes", -1, NULL);
-  gis_copy_account_file (gis_get_act_user (setup), ".config/run-welcome-tour");
-  g_free (filename);
-
+  /* the tour is triggered by /tmp/run-welcome-tour */
+  g_file_set_contents ("/tmp/run-welcome-tour", "yes", -1, NULL);
   begin_autologin (setup);
 }
 
diff --git a/gnome-initial-setup/gnome-initial-setup.c b/gnome-initial-setup/gnome-initial-setup.c
index 2966fb8..83f8758 100644
--- a/gnome-initial-setup/gnome-initial-setup.c
+++ b/gnome-initial-setup/gnome-initial-setup.c
@@ -12,21 +12,12 @@
 #include <gtk/gtk.h>
 #include <clutter-gtk/clutter-gtk.h>
 
-#include "um-utils.h"
-#include "um-photo-dialog.h"
-#include "pw-utils.h"
-
-#ifdef HAVE_CHEESE
-#include <cheese-gtk.h>
-#endif
-
-#include <gnome-keyring.h>
-
 #include "gis-assistant.h"
 
 #include "gis-welcome-page.h"
 #include "gis-eula-pages.h"
 #include "gis-location-page.h"
+#include "gis-account-page.h"
 #include "gis-network-page.h"
 #include "gis-goa-page.h"
 #include "gis-summary-page.h"
@@ -40,7 +31,6 @@ struct _SetupData {
   GtkBuilder *builder;
   GisAssistant *assistant;
 
-  ActUser *act_user;
   GSList *finals;
 };
 
@@ -51,28 +41,10 @@ struct _AsyncClosure {
   gpointer user_data;
 };
 
-#include "gis-account-page.c"
-
 #define OBJ(type,name) ((type)gtk_builder_get_object(setup->builder,(name)))
 #define WID(name) OBJ(GtkWidget*,name)
 
 static void
-copy_account_data (SetupData *setup)
-{
-  ActUser *user = setup->act_user;
-  /* here is where we copy all the things we just
-   * configured, from the current users home dir to the
-   * account that was created in the first step
-   */
-  g_debug ("Copying account data");
-  g_settings_sync ();
-
-  gis_copy_account_file (user, ".config/dconf/user");
-  gis_copy_account_file (user, ".config/goa-1.0/accounts.conf");
-  gis_copy_account_file (user, ".gnome2/keyrings/Default.keyring");
-}
-
-static void
 run_finals (SetupData *setup)
 {
   GSList *l;
@@ -93,10 +65,8 @@ prepare_cb (GisAssistant *assi, GtkWidget *page, SetupData *setup)
   page_title = g_object_get_data (G_OBJECT (page), "gis-page-title");
   gtk_window_set_title (setup->main_window, page_title);
 
-  if (g_object_get_data (G_OBJECT (page), "gis-summary")) {
-    copy_account_data (setup);
+  if (g_object_get_data (G_OBJECT (page), "gis-summary"))
     run_finals (setup);
-  }
 }
 
 static void
@@ -120,7 +90,7 @@ prepare_main_window (SetupData *setup)
   gis_prepare_welcome_page (setup);
   gis_prepare_eula_pages (setup);
   gis_prepare_network_page (setup);
-  prepare_account_page (setup);
+  gis_prepare_account_page (setup);
   gis_prepare_location_page (setup);
   gis_prepare_online_page (setup);
   gis_prepare_summary_page (setup);
@@ -144,12 +114,6 @@ gis_get_assistant (SetupData *setup)
   return setup->assistant;
 }
 
-ActUser *
-gis_get_act_user (SetupData *setup)
-{
-  return setup->act_user;
-}
-
 void
 gis_add_summary_callback (SetupData *setup,
                           GFunc      callback,
@@ -171,10 +135,6 @@ main (int argc, char *argv[])
   SetupData *setup;
   gchar *filename;
   GError *error;
-  GOptionEntry entries[] = {
-    { "skip-account", 0, 0, G_OPTION_ARG_NONE, &skip_account, "Skip account creation", NULL },
-    { NULL, 0 }
-  };
 
   bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
   bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
@@ -185,7 +145,7 @@ main (int argc, char *argv[])
 
   setup = g_new0 (SetupData, 1);
 
-  gtk_init_with_args (&argc, &argv, "", entries, GETTEXT_PACKAGE, NULL);
+  gtk_init (&argc, &argv);
 
   if (gtk_clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS) {
     g_critical ("Clutter-GTK init failed");
diff --git a/gnome-initial-setup/gnome-initial-setup.h b/gnome-initial-setup/gnome-initial-setup.h
index 133b346..bdcf4b0 100644
--- a/gnome-initial-setup/gnome-initial-setup.h
+++ b/gnome-initial-setup/gnome-initial-setup.h
@@ -8,8 +8,6 @@
 #include "gis-assistant.h"
 #include "gis-utils.h"
 
-#include <act/act-user-manager.h>
-
 G_BEGIN_DECLS
 
 typedef struct _SetupData SetupData;
@@ -17,7 +15,6 @@ typedef struct _SetupData SetupData;
 GtkWindow *gis_get_main_window (SetupData *setup);
 GKeyFile *gis_get_overrides (SetupData *setup);
 GisAssistant * gis_get_assistant (SetupData *setup);
-ActUser * gis_get_act_user (SetupData *setup);
 void gis_add_summary_callback (SetupData *setup, GFunc callback, gpointer user_data);
 
 G_END_DECLS
diff --git a/gnome-initial-setup/welcome-tour.desktop b/gnome-initial-setup/welcome-tour.desktop
index b9a92b4..211984c 100644
--- a/gnome-initial-setup/welcome-tour.desktop
+++ b/gnome-initial-setup/welcome-tour.desktop
@@ -1,6 +1,6 @@
 [Desktop Entry]
 Type=Application
 Name=Welcome
-Exec=bash -c "epiphany --private-instance http://www.gnome3.org ; rm -f \\$HOME/.config/run-welcome-tour"
-AutostartCondition=if-exists run-welcome-tour
+Exec=bash -c "epiphany --private-instance http://www.gnome3.org ; rm -f /tmp/run-welcome-tour"
+AutostartCondition=if-exists /tmp/run-welcome-tour
 OnlyShowIn=GNOME;



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