[gdm/wip/initial-setup: 14/17] initial-setup: Misc cleanups



commit f81294cc7c23c8a7dec83825fab3c5ed73dbaea3
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Oct 21 02:28:40 2011 -0400

    initial-setup: Misc cleanups

 gui/initial-setup/gdm-initial-setup.c |  126 +++++++++++++++++----------------
 1 files changed, 64 insertions(+), 62 deletions(-)
---
diff --git a/gui/initial-setup/gdm-initial-setup.c b/gui/initial-setup/gdm-initial-setup.c
index 9d5b91e..511993c 100644
--- a/gui/initial-setup/gdm-initial-setup.c
+++ b/gui/initial-setup/gdm-initial-setup.c
@@ -62,10 +62,6 @@ typedef struct {
 #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);
-static void begin_autologin (SetupData *setup);
-static void connect_to_slave (SetupData *setup);
-
 /* --- Welcome page --- */
 
 static void
@@ -1052,7 +1048,7 @@ save_account_data (SetupData *setup)
         act_user_set_real_name (setup->act_user,
                                 gtk_entry_get_text (OBJ (GtkEntry*, "account-fullname-entry")));
         act_user_set_user_name (setup->act_user,
-                                gtk_entry_get_text (OBJ (GtkEntry*, "account-username-entry")));
+                                gtk_combo_box_text_get_active_text (OBJ (GtkComboBoxText*, "account-username-combo")));
         act_user_set_account_type (setup->act_user, setup->account_type);
         if (setup->password_mode == ACT_USER_PASSWORD_MODE_REGULAR) {
                 act_user_set_password (setup->act_user,
@@ -1324,52 +1320,45 @@ prepare_location_page (SetupData *setup)
 /* --- Other setup --- */
 
 static void
-close_cb (GtkAssistant *assi, gpointer data)
+copy_account_data (SetupData *setup)
 {
-        SetupData *setup = data;
-
+        /* FIXME: 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 ();
-
-        copy_account_data (setup);
-
-        begin_autologin (setup);
 }
 
 static void
-prepare_cb (GtkAssistant *assi, GtkWidget *page, SetupData *setup)
+connect_to_slave (SetupData *setup)
 {
-        if (page != WID("account-page"))
-                gtk_assistant_set_page_complete (assi, page, TRUE);
-        save_account_data (setup);
-}
+        GDBusConnection *connection;
+        const gchar *address;
+        GError *error;
 
-static void
-prepare_assistant (SetupData *setup)
-{
-        setup->assistant = OBJ(GtkAssistant*, "gnome-setup-assistant");
+        address = g_getenv ("GDM_GREETER_DBUS_ADDRESS");
 
-        /* small hack to get rid of cancel button */
-        gtk_assistant_commit (setup->assistant);
+        if (address == NULL) {
+                g_warning ("GDM_GREETER_DBUS_ADDRESS not set; not initiating autologin");
+                return;
+        }
 
-        g_signal_connect (G_OBJECT (setup->assistant), "prepare",
-                          G_CALLBACK (prepare_cb), setup);
-        g_signal_connect (G_OBJECT (setup->assistant), "close",
-                          G_CALLBACK (close_cb), setup);
+        error = NULL;
+        connection = g_dbus_connection_new_for_address_sync (address,
+                                                             G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
+                                                             NULL,
+                                                             NULL,
+                                                             &error);
+        if (connection == NULL) {
+                g_warning ("Failed to create D-Bus connection for address '%s' (%s); not initiating autologin", address, error->message);
+                g_error_free (error);
+                return;
+        }
 
-        connect_to_slave (setup);
-        prepare_welcome_page (setup);
-        prepare_network_page (setup);
-        prepare_account_page (setup);
-        prepare_location_page (setup);
-}
+        g_dbus_connection_set_exit_on_close (connection, TRUE);
 
-static void
-copy_account_data (SetupData *setup)
-{
-        /* FIXME: 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
-         */
+        setup->slave_connection = connection;
 }
 
 static void
@@ -1381,6 +1370,8 @@ begin_autologin (SetupData *setup)
 
         username = act_user_get_user_name (setup->act_user);
 
+        g_debug ("Initiating autologin for %s", username);
+
         ret = g_dbus_connection_call_sync (setup->slave_connection,
                                            NULL,
                                            "/org/gnome/DisplayManager/GreeterServer",
@@ -1402,34 +1393,45 @@ begin_autologin (SetupData *setup)
 }
 
 static void
-connect_to_slave (SetupData *setup)
+close_cb (GtkAssistant *assi, SetupData *setup)
 {
-        GDBusConnection *connection;
-        const gchar *address;
-        GError *error;
+        begin_autologin (setup);
+}
 
-        address = g_getenv ("GDM_GREETER_DBUS_ADDRESS");
+static void
+prepare_cb (GtkAssistant *assi, GtkWidget *page, SetupData *setup)
+{
+        g_debug ("Preparing page %s", gtk_widget_get_name (page));
 
-        if (address == NULL) {
-                g_warning ("GDM_GREETER_DBUS_ADDRESS not set; not initiating autologin");
-                return;
-        }
+        if (page != WID("account-page"))
+                gtk_assistant_set_page_complete (assi, page, TRUE);
 
-        error = NULL;
-        connection = g_dbus_connection_new_for_address_sync (address,
-                                                             G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
-                                                             NULL,
-                                                             NULL,
-                                                             &error);
-        if (connection == NULL) {
-                g_warning ("Failed to create D-Bus connection for address '%s' (%s); not initiating autologin", address, error->message);
-                g_error_free (error);
-                return;
-        }
+        save_account_data (setup);
 
-        g_dbus_connection_set_exit_on_close (connection, TRUE);
+        if (page == WID("summary_page"))
+                copy_account_data (setup);
+}
 
-        setup->slave_connection = connection;
+static void
+prepare_assistant (SetupData *setup)
+{
+        setup->assistant = OBJ(GtkAssistant*, "gnome-setup-assistant");
+
+        /* small hack to get rid of cancel button */
+        gtk_assistant_commit (setup->assistant);
+
+        g_signal_connect (G_OBJECT (setup->assistant), "prepare",
+                          G_CALLBACK (prepare_cb), setup);
+        g_signal_connect (G_OBJECT (setup->assistant), "close",
+                          G_CALLBACK (close_cb), setup);
+
+        /* connect to gdm slave */
+        connect_to_slave (setup);
+
+        prepare_welcome_page (setup);
+        prepare_network_page (setup);
+        prepare_account_page (setup);
+        prepare_location_page (setup);
 }
 
 int



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