[gnome-control-center/wip/add-account: 2/7] user-accounts: Refactor the user add dialog



commit 04c0aaf51acb71685f8b491c98bc75e52c23328e
Author: Stef Walter <stefw gnome org>
Date:   Wed May 30 17:45:58 2012 +0200

    user-accounts: Refactor the user add dialog
    
     * Make room for the 'Enterprise Login' option
     * Not yet implemented, stubbed out

 panels/user-accounts/data/account-dialog.ui |  555 ++++++++++++++---------
 panels/user-accounts/um-account-dialog.c    |  649 +++++++++++++++++++--------
 panels/user-accounts/um-account-dialog.h    |   24 +-
 panels/user-accounts/um-user-panel.c        |   18 +-
 4 files changed, 845 insertions(+), 401 deletions(-)
---
diff --git a/panels/user-accounts/data/account-dialog.ui b/panels/user-accounts/data/account-dialog.ui
index 3ae2fc3..217ad81 100644
--- a/panels/user-accounts/data/account-dialog.ui
+++ b/panels/user-accounts/data/account-dialog.ui
@@ -1,265 +1,396 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <!-- interface-requires gtk+ 2.12 -->
-  <!-- interface-naming-policy toplevel-contextual -->
-  <object class="GtkListStore" id="username-model">
-    <columns>
-      <!-- column-name gchararray -->
-      <column type="gchararray"/>
-    </columns>
-  </object>
-  <object class="GtkListStore" id="account-type-model">
-    <columns>
-      <!-- column-name gchararray -->
-      <column type="gchararray"/>
-      <!-- column-name gint -->
-      <column type="gint"/>
-    </columns>
-    <data>
-      <row>
-        <col id="0" translatable="yes" context="Account type">Standard</col>
-        <col id="1">0</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes" context="Account type">Administrator</col>
-        <col id="1">1</col>
-      </row>
-    </data>
-  </object>
-  <object class="GtkDialog" id="dialog">
-    <property name="border_width">5</property>
-    <property name="title"> </property>
-    <property name="resizable">False</property>
-    <property name="modal">True</property>
-    <property name="window_position">center-on-parent</property>
-    <property name="icon_name">system-users</property>
-    <property name="type_hint">dialog</property>
-    <child internal-child="vbox">
-      <object class="GtkVBox" id="content-area">
+  <!-- interface-requires gtk+ 3.0 -->
+  <object class="GtkBox" id="account-dialog">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="orientation">vertical</property>
+    <property name="spacing">10</property>
+    <child>
+      <object class="GtkLabel" id="label11">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Add Account</property>
+        <attributes>
+          <attribute name="weight" value="bold"/>
+          <attribute name="scale" value="1.2"/>
+        </attributes>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="position">0</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkAlignment" id="alignment1">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="xscale">0</property>
+        <property name="yscale">0</property>
+        <child>
+          <object class="GtkBox" id="account-buttons">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkToggleButton" id="local-button">
+                <property name="label" translatable="yes">Local Account</property>
+                <property name="use_action_appearance">False</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="focus_on_click">False</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkToggleButton" id="enterprise-button">
+                <property name="label" translatable="yes">Enterprise Login</property>
+                <property name="use_action_appearance">False</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="focus_on_click">False</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+        </child>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="position">1</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkNotebook" id="account-pages">
         <property name="visible">True</property>
-        <property name="orientation">vertical</property>
-        <property name="spacing">2</property>
+        <property name="can_focus">True</property>
+        <property name="show_tabs">False</property>
+        <property name="show_border">False</property>
         <child>
-          <object class="GtkVBox" id="vbox1">
+          <object class="GtkGrid" id="local-account">
             <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="hexpand">True</property>
             <property name="border_width">10</property>
-            <property name="spacing">6</property>
+            <property name="row_spacing">10</property>
+            <property name="column_spacing">10</property>
+            <child>
+              <object class="GtkLabel" id="label1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">1</property>
+                <property name="label" translatable="yes">_Account Type</property>
+                <property name="use_underline">True</property>
+                <property name="mnemonic_widget">local-account-type</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">0</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
             <child>
-              <object class="GtkTable" id="table1">
+              <object class="GtkComboBox" id="local-account-type">
                 <property name="visible">True</property>
-                <property name="n_rows">5</property>
-                <property name="n_columns">2</property>
-                <property name="column_spacing">10</property>
-                <property name="row_spacing">10</property>
+                <property name="can_focus">False</property>
+                <property name="hexpand">True</property>
+                <property name="model">account-type-model</property>
                 <child>
-                  <object class="GtkComboBoxText" id="username-combo">
-                    <property name="visible">True</property>
-                    <property name="has_entry">True</property>
-                    <property name="entry_text_column">0</property>
-                    <property name="model">username-model</property>
-                    <child internal-child="entry">
-                      <object class="GtkEntry" id="username-entry">
-                        <property name="activates_default">True</property>
-                      </object>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="top_attach">4</property>
-                    <property name="bottom_attach">5</property>
-                  </packing>
+                  <object class="GtkCellRendererText" id="account-type-cell1"/>
+                  <attributes>
+                    <attribute name="text">0</attribute>
+                  </attributes>
                 </child>
-                <child>
-                  <object class="GtkLabel" id="label6">
-                    <property name="visible">True</property>
-                    <property name="xalign">1</property>
-                    <property name="label" translatable="yes">_Username</property>
-                    <property name="use_underline">True</property>
-                    <property name="mnemonic_widget">username-combo</property>
-                    <style>
-                      <class name="dim-label"/>
-                    </style>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">0</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label2">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">1</property>
+                <property name="label" translatable="yes">_Full Name</property>
+                <property name="use_underline">True</property>
+                <property name="mnemonic_widget">local-name</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">1</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkEntry" id="local-name">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="hexpand">True</property>
+                <property name="invisible_char">â</property>
+                <property name="activates_default">True</property>
+                <property name="invisible_char_set">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">1</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label3">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">1</property>
+                <property name="label" translatable="yes">_Login Name</property>
+                <property name="use_underline">True</property>
+                <property name="mnemonic_widget">local-login</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">2</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkComboBoxText" id="local-login">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="hexpand">True</property>
+                <property name="has_entry">True</property>
+                <property name="entry_text_column">0</property>
+                <child internal-child="entry">
+                  <object class="GtkEntry" id="local-login-entry">
+                    <property name="can_focus">True</property>
                   </object>
-                  <packing>
-                    <property name="top_attach">4</property>
-                    <property name="bottom_attach">5</property>
-                    <property name="x_options">GTK_FILL</property>
-                  </packing>
                 </child>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">2</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="tab_fill">False</property>
+          </packing>
+        </child>
+        <child type="tab">
+          <object class="GtkLabel" id="label5">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">page 1</property>
+          </object>
+          <packing>
+            <property name="tab_fill">False</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkGrid" id="enterprise-account">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="hexpand">True</property>
+            <property name="border_width">10</property>
+            <property name="row_spacing">10</property>
+            <property name="column_spacing">10</property>
+            <child>
+              <object class="GtkLabel" id="label4">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="margin_top">5</property>
+                <property name="xalign">1</property>
+                <property name="yalign">0</property>
+                <property name="label" translatable="yes">_Domain</property>
+                <property name="use_underline">True</property>
+                <property name="mnemonic_widget">enterprise-domain</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">0</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label8">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">1</property>
+                <property name="label" translatable="yes">_Login Name</property>
+                <property name="use_underline">True</property>
+                <property name="mnemonic_widget">enterprise-login</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">1</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label9">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">1</property>
+                <property name="label" translatable="yes">_Password</property>
+                <property name="use_underline">True</property>
+                <property name="mnemonic_widget">enterprise-password</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">2</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkBox" id="box1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="orientation">vertical</property>
+                <property name="spacing">3</property>
                 <child>
-                  <object class="GtkHBox" id="hbox1">
+                  <object class="GtkComboBoxText" id="enterprise-domain">
                     <property name="visible">True</property>
-                    <child>
-                      <object class="GtkLabel" id="label1">
-                        <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="hexpand">True</property>
+                    <property name="has_entry">True</property>
+                    <property name="entry_text_column">0</property>
+                    <property name="id_column">1</property>
+                    <child internal-child="entry">
+                      <object class="GtkEntry" id="enterprise-domain-entry">
+                        <property name="can_focus">True</property>
                       </object>
-                      <packing>
-                        <property name="position">0</property>
-                      </packing>
                     </child>
                   </object>
                   <packing>
-                    <property name="x_options">GTK_FILL</property>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkLabel" id="label2">
+                  <object class="GtkLabel" id="label10">
                     <property name="visible">True</property>
-                    <property name="label" translatable="yes">Create new account</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">Tip: Enterprise domain or realm name</property>
                     <attributes>
-                      <attribute name="weight" value="bold"/>
-                      <attribute name="scale" value="1.200000"/>
+                      <attribute name="scale" value="0.80000000000000004"/>
                     </attributes>
                   </object>
                   <packing>
-                    <property name="right_attach">2</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="label3">
-                    <property name="visible">True</property>
-                  </object>
-                  <packing>
-                    <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
-                    <property name="x_options">GTK_FILL</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="label4">
-                    <property name="visible">True</property>
-                  </object>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkEntry" id="name-entry">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="activates_default">True</property>
-                  </object>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="top_attach">3</property>
-                    <property name="bottom_attach">4</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="label5">
-                    <property name="visible">True</property>
-                    <property name="xalign">1</property>
-                    <property name="label" translatable="yes">_Full name</property>
-                    <property name="use_underline">True</property>
-                    <property name="mnemonic_widget">name-entry</property>
-                    <style>
-                      <class name="dim-label"/>
-                    </style>
-                  </object>
-                  <packing>
-                    <property name="top_attach">3</property>
-                    <property name="bottom_attach">4</property>
-                    <property name="x_options">GTK_FILL</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="label7">
-                    <property name="visible">True</property>
-                    <property name="xalign">1</property>
-                    <property name="label" translatable="yes">_Account Type</property>
-                    <property name="use_underline">True</property>
-                    <property name="mnemonic_widget">account-type-combo</property>
-                    <style>
-                      <class name="dim-label"/>
-                    </style>
-                  </object>
-                  <packing>
-                    <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkComboBox" id="account-type-combo">
-                    <property name="visible">True</property>
-                    <property name="model">account-type-model</property>
-                    <child>
-                      <object class="GtkCellRendererText" id="account-type-cell"/>
-                      <attributes>
-                        <attribute name="text">0</attribute>
-                      </attributes>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
                   </packing>
                 </child>
               </object>
               <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
+                <property name="left_attach">1</property>
+                <property name="top_attach">0</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
               </packing>
             </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child internal-child="action_area">
-          <object class="GtkHButtonBox" id="dialog-action_area9">
-            <property name="visible">True</property>
-            <property name="layout_style">end</property>
             <child>
-              <object class="GtkButton" id="cancel-button">
-                <property name="label">gtk-cancel</property>
+              <object class="GtkEntry" id="enterprise-login">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="use_stock">True</property>
+                <property name="hexpand">True</property>
+                <property name="invisible_char">â</property>
+                <property name="invisible_char_set">True</property>
               </object>
               <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
+                <property name="left_attach">1</property>
+                <property name="top_attach">1</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
               </packing>
             </child>
             <child>
-              <object class="GtkButton" id="ok-button">
-                <property name="label" translatable="yes">Cr_eate</property>
+              <object class="GtkEntry" id="enterprise-password">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_underline">True</property>
+                <property name="hexpand">True</property>
+                <property name="invisible_char">â</property>
+                <property name="invisible_char_set">True</property>
               </object>
               <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
+                <property name="left_attach">1</property>
+                <property name="top_attach">2</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
               </packing>
             </child>
           </object>
           <packing>
-            <property name="expand">False</property>
-            <property name="pack_type">end</property>
-            <property name="position">0</property>
+            <property name="position">1</property>
+            <property name="tab_fill">False</property>
           </packing>
         </child>
+        <child type="tab">
+          <object class="GtkLabel" id="label6">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">page 2</property>
+          </object>
+          <packing>
+            <property name="position">1</property>
+            <property name="tab_fill">False</property>
+          </packing>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child type="tab">
+          <placeholder/>
+        </child>
       </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="position">2</property>
+      </packing>
     </child>
-    <action-widgets>
-      <action-widget response="0">cancel-button</action-widget>
-      <action-widget response="0">ok-button</action-widget>
-    </action-widgets>
+  </object>
+  <object class="GtkListStore" id="account-type-model">
+    <columns>
+      <!-- column-name gchararray -->
+      <column type="gchararray"/>
+      <!-- column-name gint -->
+      <column type="gint"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes" context="Account type">Standard</col>
+        <col id="1">0</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes" context="Account type">Administrator</col>
+        <col id="1">1</col>
+      </row>
+    </data>
   </object>
 </interface>
diff --git a/panels/user-accounts/um-account-dialog.c b/panels/user-accounts/um-account-dialog.c
index e5caf49..db39638 100644
--- a/panels/user-accounts/um-account-dialog.c
+++ b/panels/user-accounts/um-account-dialog.c
@@ -1,6 +1,6 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
  *
- * Copyright 2009-2010  Red Hat, Inc,
+ * Copyright 2009-2012  Red Hat, Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -17,6 +17,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  *
  * Written by: Matthias Clasen <mclasen redhat com>
+ *             Stef Walter <stefw gnome org>
  */
 
 #include "config.h"
@@ -29,229 +30,525 @@
 #include "um-user-manager.h"
 #include "um-utils.h"
 
-#define MAXNAMELEN  (UT_NAMESIZE - 1)
+#define UM_ACCOUNT_DIALOG_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), UM_TYPE_ACCOUNT_DIALOG, \
+                                                                    UmAccountDialogClass))
+#define UM_IS_ACCOUNT_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UM_TYPE_ACCOUNT_DIALOG))
+#define UM_ACCOUNT_DIALOG_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), UM_TYPE_ACCOUNT_DIALOG, \
+                                                                      UmAccountDialogClass))
+
+typedef enum {
+	UM_LOCAL,
+	UM_ENTERPRISE,
+} UmAccountMode;
 
 struct _UmAccountDialog {
-        GtkWidget *dialog;
-        GtkWidget *username_combo;
-        GtkWidget *name_entry;
-        GtkWidget *account_type_combo;
-        GtkWidget *ok_button;
+	GtkDialog parent;
+	GtkNotebook *notebook;
+	GSimpleAsyncResult *async;
+	GtkWidget *buttons;
+	gboolean buttons_updating;
+
+	/* Local users */
+	GtkWidget *local_login;
+	GtkWidget *local_name;
+	GtkWidget *local_account_type;
+
+	/* Enterprise users */
+	GtkWidget *enterprise_domain;
+	GtkWidget *enterprise_login;
+	GtkWidget *enterprise_password;
+};
 
-        gboolean valid_name;
-        gboolean valid_username;
+typedef struct {
+	GtkDialogClass parent_class;
+} UmAccountDialogClass;
 
-        UserCreatedCallback user_created_callback;
-        gpointer            user_created_data;
-};
+G_DEFINE_TYPE (UmAccountDialog, um_account_dialog, GTK_TYPE_DIALOG);
+
+static UmAccountType
+get_account_mode (UmAccountDialog *self)
+{
+	return gtk_notebook_get_current_page (self->notebook);
+}
+
+static gboolean
+local_validate (UmAccountDialog *self)
+{
+	gboolean valid_login;
+	gboolean valid_name;
+	GtkWidget *entry;
+	const gchar *name;
+	gchar *tip;
+
+	name = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (self->local_login));
+	valid_login = is_valid_username (name, &tip);
+
+	entry = gtk_bin_get_child (GTK_BIN (self->local_login));
+	if (tip) {
+		set_entry_validation_error (GTK_ENTRY (entry), tip);
+		g_free (tip);
+	} else {
+		clear_entry_validation_error (GTK_ENTRY (entry));
+	}
+
+	name = gtk_entry_get_text (GTK_ENTRY (self->local_name));
+	valid_name = is_valid_name (name);
+
+	return valid_name && valid_login;
+}
+
+static gboolean
+enterprise_validate (UmAccountDialog *self)
+{
+	const gchar *name;
+	gboolean valid_name;
+	gboolean valid_domain;
+
+	name = gtk_entry_get_text (GTK_ENTRY (self->enterprise_login));
+	valid_name = is_valid_name (name);
+
+	name = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (self->enterprise_domain));
+	valid_domain = is_valid_name (name);
+
+	/* TODO: More validation here, and also checking of the domain */
+
+	return valid_name && valid_domain;
+}
 
 static void
-cancel_account_dialog (GtkButton       *button,
-                       UmAccountDialog *um)
+dialog_validate (UmAccountDialog *self)
 {
-        gtk_widget_hide (um->dialog);
+	gboolean valid = FALSE;
+
+	switch (get_account_mode (self)) {
+	case UM_LOCAL:
+		valid = local_validate (self);
+		break;
+	case UM_ENTERPRISE:
+		valid = enterprise_validate (self);
+		break;
+	}
+
+	gtk_dialog_set_response_sensitive (GTK_DIALOG (self), GTK_RESPONSE_OK, valid);
 }
 
 static void
-create_user_done (UmUserManager   *manager,
-                  GAsyncResult    *res,
-                  UmAccountDialog *um)
+on_local_login_changed (GtkComboBoxText *combo,
+                        gpointer user_data)
 {
-        UmUser *user;
-        GError *error;
-
-        error = NULL;
-        if (!um_user_manager_create_user_finish (manager, res, &user, &error)) {
-
-                if (!g_error_matches (error, UM_USER_MANAGER_ERROR, UM_USER_MANAGER_ERROR_PERMISSION_DENIED)) {
-                        GtkWidget *dialog;
-
-                        dialog = gtk_message_dialog_new (gtk_window_get_transient_for (GTK_WINDOW (um->dialog)),
-                                                         GTK_DIALOG_DESTROY_WITH_PARENT,
-                                                         GTK_MESSAGE_ERROR,
-                                                         GTK_BUTTONS_CLOSE,
-                                                         _("Failed to create user"));
-
-                        gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-                                                                  "%s", error->message);
-
-                        g_signal_connect (G_OBJECT (dialog), "response",
-                                          G_CALLBACK (gtk_widget_destroy), NULL);
-                        gtk_window_present (GTK_WINDOW (dialog));
-                }
-                g_error_free (error);
-        }
-        else {
-                um->user_created_callback (user, um->user_created_data);
-        }
+	dialog_validate (UM_ACCOUNT_DIALOG (user_data));
 }
 
 static void
-accept_account_dialog (GtkButton       *button,
-                       UmAccountDialog *um)
+on_name_changed (GtkEditable *editable,
+                 gpointer user_data)
 {
-        UmUserManager *manager;
-        const gchar *username;
-        const gchar *name;
-        gint account_type;
-        GtkTreeModel *model;
-        GtkTreeIter iter;
-
-        name = gtk_entry_get_text (GTK_ENTRY (um->name_entry));
-        username = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (um->username_combo));
-        model = gtk_combo_box_get_model (GTK_COMBO_BOX (um->account_type_combo));
-        gtk_combo_box_get_active_iter (GTK_COMBO_BOX (um->account_type_combo), &iter);
-        gtk_tree_model_get (model, &iter, 1, &account_type, -1);
-
-        manager = um_user_manager_ref_default ();
-        um_user_manager_create_user (manager,
-                                     username,
-                                     name,
-                                     account_type,
-                                     (GAsyncReadyCallback)create_user_done,
-                                     um,
-                                     NULL);
-        g_object_unref (manager);
-
-        gtk_widget_hide (um->dialog);
+	UmAccountDialog *self = UM_ACCOUNT_DIALOG (user_data);
+	GtkTreeModel *model;
+	const char *name;
+
+	model = gtk_combo_box_get_model (GTK_COMBO_BOX (self->local_login));
+	gtk_list_store_clear (GTK_LIST_STORE (model));
+
+	name = gtk_entry_get_text (GTK_ENTRY (editable));
+	generate_username_choices (name, GTK_LIST_STORE (model));
+	gtk_combo_box_set_active (GTK_COMBO_BOX (self->local_login), 0);
+
+	dialog_validate (self);
 }
 
 static void
-username_changed (GtkComboBoxText *combo,
-                  UmAccountDialog *um)
+on_text_changed (GObject *object,
+                 GParamSpec *spec,
+                 gpointer user_data)
 {
-        const gchar *username;
-        gchar *tip;
-        GtkWidget *entry;
+	dialog_validate (UM_ACCOUNT_DIALOG (user_data));
+}
 
-        username = gtk_combo_box_text_get_active_text (combo);
+static void
+local_construct (UmAccountDialog *self,
+                 GtkBuilder *builder)
+{
+	GtkWidget *widget;
 
-        um->valid_username = is_valid_username (username, &tip);
+	widget = (GtkWidget *) gtk_builder_get_object (builder, "local-login");
+	g_signal_connect (widget, "changed", G_CALLBACK (on_local_login_changed), self);
+	self->local_login = widget;
 
-        gtk_widget_set_sensitive (um->ok_button, um->valid_name && um->valid_username);
-        entry = gtk_bin_get_child (GTK_BIN (combo));
+	widget = (GtkWidget *) gtk_builder_get_object (builder, "local-name");
+	g_signal_connect (widget, "changed", G_CALLBACK (on_name_changed), self);
+	self->local_name = widget;
 
-        if (tip) {
-                set_entry_validation_error (GTK_ENTRY (entry), tip);
-                g_free (tip);
-        }
-        else {
-                clear_entry_validation_error (GTK_ENTRY (entry));
-        }
+	widget = (GtkWidget *) gtk_builder_get_object (builder, "local-account-type");
+	self->local_account_type = widget;
 }
 
 static void
-name_changed (GtkEntry        *name_entry,
-              GParamSpec      *pspec,
-              UmAccountDialog *um)
+local_clear (UmAccountDialog *self)
 {
-        GtkWidget *entry;
-        GtkTreeModel *model;
-        const char *name;
+	GtkTreeModel *model;
 
-        entry = gtk_bin_get_child (GTK_BIN (um->username_combo));
+	gtk_entry_set_text (GTK_ENTRY (self->local_name), "");
+	gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (self->local_login))), "");
+	model = gtk_combo_box_get_model (GTK_COMBO_BOX (self->local_login));
+	gtk_list_store_clear (GTK_LIST_STORE (model));
+	gtk_combo_box_set_active (GTK_COMBO_BOX (self->local_account_type), 0);
+}
 
-        model = gtk_combo_box_get_model (GTK_COMBO_BOX (um->username_combo));
-        gtk_list_store_clear (GTK_LIST_STORE (model));
+static void
+on_create_local_user (GObject         *object,
+                      GAsyncResult    *res,
+                      gpointer         user_data)
+{
+	UmAccountDialog *self = UM_ACCOUNT_DIALOG (user_data);
+	GError *error = NULL;
+	UmUser *user;
+
+	if (!um_user_manager_create_user_finish (UM_USER_MANAGER (object), res, &user, &error)) {
+		if (!g_error_matches (error, UM_USER_MANAGER_ERROR, UM_USER_MANAGER_ERROR_PERMISSION_DENIED)) {
+			GtkWidget *dialog;
+
+			dialog = gtk_message_dialog_new (gtk_window_get_transient_for (GTK_WINDOW (self)),
+			                                 GTK_DIALOG_DESTROY_WITH_PARENT,
+			                                 GTK_MESSAGE_ERROR,
+			                                 GTK_BUTTONS_CLOSE,
+			                                 _("Failed to create user"));
+
+			gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+			                                          "%s", error->message);
+
+			g_signal_connect (G_OBJECT (dialog), "response",
+			                  G_CALLBACK (gtk_widget_destroy), NULL);
+			gtk_window_present (GTK_WINDOW (dialog));
+		}
+		g_error_free (error);
+	}
+
+	g_simple_async_result_complete_in_idle (self->async);
+}
 
-        name = gtk_entry_get_text (GTK_ENTRY (name_entry));
+static void
+local_add (UmAccountDialog *self)
+{
+	UmUserManager *manager;
+	const gchar *username;
+	const gchar *name;
+	gint account_type;
+	GtkTreeModel *model;
+	GtkTreeIter iter;
+
+	name = gtk_entry_get_text (GTK_ENTRY (self->local_name));
+	username = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (self->local_login));
+	model = gtk_combo_box_get_model (GTK_COMBO_BOX (self->local_account_type));
+	gtk_combo_box_get_active_iter (GTK_COMBO_BOX (self->local_account_type), &iter);
+	gtk_tree_model_get (model, &iter, 1, &account_type, -1);
+
+	manager = um_user_manager_ref_default ();
+	um_user_manager_create_user (manager,
+	                             username,
+	                             name,
+	                             account_type,
+	                             on_create_local_user,
+	                             g_object_ref (self),
+	                             g_object_unref);
+	g_object_unref (manager);
+
+	gtk_widget_hide (GTK_WIDGET (self));
+}
+
+static void
+enterprise_add (UmAccountDialog *self)
+{
+	/* TODO: Implement adding of users */
+
+	g_simple_async_result_complete_in_idle (self->async);
+	gtk_widget_hide (GTK_WIDGET (self));
+}
+
+static void
+enterprise_construct (UmAccountDialog *self,
+                      GtkBuilder *builder)
+{
+	GtkWidget *widget;
 
-        um->valid_name = is_valid_name (name);
-        gtk_widget_set_sensitive (um->ok_button, um->valid_name && um->valid_username);
+	widget = (GtkWidget *) gtk_builder_get_object (builder, "enterprise-domain");
+	g_signal_connect (widget, "notify::text", G_CALLBACK (on_text_changed), self);
+	self->enterprise_domain = widget;
 
-        if (!um->valid_name) {
-                gtk_entry_set_text (GTK_ENTRY (entry), "");
-                return;
-        }
+	widget = (GtkWidget *) gtk_builder_get_object (builder, "enterprise-login");
+	g_signal_connect (widget, "notify::text", G_CALLBACK (on_text_changed), self);
+	self->enterprise_login = widget;
 
-        generate_username_choices (name, GTK_LIST_STORE (model));
+	widget = (GtkWidget *) gtk_builder_get_object (builder, "enterprise-password");
+	self->enterprise_password = widget;
 
-        gtk_combo_box_set_active (GTK_COMBO_BOX (um->username_combo), 0);
+	/* TODO: Populate the drop down for enrolled domains */
+	/* TODO: Choose first domain if so */
+	/* TODO: If another domain not selected, then validate and enter current domain name */
 }
 
-UmAccountDialog *
-um_account_dialog_new (void)
+static void
+enterprise_clear (UmAccountDialog *self)
 {
-        GtkBuilder *builder;
-        GtkWidget *widget;
-        UmAccountDialog *um;
-        const gchar *filename;
-        GError *error = NULL;
-
-        builder = gtk_builder_new ();
-
-        filename = UIDIR "/account-dialog.ui";
-        if (!g_file_test (filename, G_FILE_TEST_EXISTS))
-                filename = "data/account-dialog.ui";
-        if (!gtk_builder_add_from_file (builder, filename, &error)) {
-                g_error ("%s", error->message);
-                g_error_free (error);
-                return NULL;
-        }
-
-        um = g_new0 (UmAccountDialog, 1);
-
-        widget = (GtkWidget *) gtk_builder_get_object (builder, "dialog");
-        g_signal_connect (widget, "delete-event",
-                          G_CALLBACK (gtk_widget_hide_on_delete), NULL);
-        um->dialog = widget;
-
-        widget = (GtkWidget *) gtk_builder_get_object (builder, "cancel-button");
-        g_signal_connect (widget, "clicked",
-                          G_CALLBACK (cancel_account_dialog), um);
-
-        widget = (GtkWidget *) gtk_builder_get_object (builder, "ok-button");
-        g_signal_connect (widget, "clicked",
-                          G_CALLBACK (accept_account_dialog), um);
-        gtk_widget_grab_default (widget);
-
-        widget = (GtkWidget *) gtk_builder_get_object (builder, "username-combo");
-        g_signal_connect (widget, "changed",
-                          G_CALLBACK (username_changed), um);
-        um->username_combo = widget;
-
-        widget = (GtkWidget *) gtk_builder_get_object (builder, "name-entry");
-        g_signal_connect (widget, "notify::text",
-                          G_CALLBACK (name_changed), um);
-        um->name_entry = widget;
-
-        um->ok_button = (GtkWidget *) gtk_builder_get_object (builder, "ok-button");
-
-        widget = (GtkWidget *) gtk_builder_get_object (builder, "account-type-combo");
-        um->account_type_combo = widget;
-
-        return um;
+	gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (self->enterprise_domain))), "");
+	gtk_entry_set_text (GTK_ENTRY (self->enterprise_login), "");
+	gtk_entry_set_text (GTK_ENTRY (self->enterprise_password), "");
 }
 
-void
-um_account_dialog_free (UmAccountDialog *um)
+static void
+um_account_dialog_init (UmAccountDialog *self)
 {
-        gtk_widget_destroy (um->dialog);
-        g_free (um);
+
+}
+
+static void
+label_set_bold (GtkLabel *label,
+                gboolean bold)
+{
+	PangoAttrList *attrs;
+	PangoAttribute *attr;
+
+	attrs = pango_attr_list_new ();
+	attr = pango_attr_weight_new (bold ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL);
+	pango_attr_list_insert (attrs, attr);
+	gtk_label_set_attributes (label, attrs);
+	pango_attr_list_unref (attrs);
+}
+
+static void
+buttons_update (UmAccountDialog *self,
+                GtkToggleButton *active)
+{
+	gboolean any_visible = FALSE;
+	gboolean set_active;
+	GList *children, *l;
+	gint current = -1;
+	gint idx = 0;
+
+	g_assert (!self->buttons_updating);
+	self->buttons_updating = TRUE;
+
+	children = gtk_container_get_children (GTK_CONTAINER (self->buttons));
+	for (l = children; l != NULL; l = g_list_next (l)) {
+		if (!GTK_IS_TOGGLE_BUTTON (l->data))
+			continue;
+
+		if (active != NULL) {
+			set_active = (l->data == active);
+			if (gtk_toggle_button_get_active (l->data) != set_active)
+				gtk_toggle_button_set_active (l->data, set_active);
+			label_set_bold (GTK_LABEL (gtk_bin_get_child (l->data)), set_active);
+			if (set_active)
+				current = idx;
+		}
+
+		if (gtk_widget_get_visible (l->data))
+			any_visible = TRUE;
+
+		idx++;
+	}
+
+	g_list_free (children);
+
+	if (current != -1) {
+		gtk_notebook_set_current_page (self->notebook, current);
+		dialog_validate (self);
+	}
+
+	gtk_widget_set_visible (GTK_WIDGET (self->buttons), any_visible);
+
+	self->buttons_updating = FALSE;
+}
+
+static void
+on_button_toggled (GtkToggleButton *toggle,
+                   gpointer user_data)
+{
+	UmAccountDialog *self = UM_ACCOUNT_DIALOG (user_data);
+
+	if (self->buttons_updating)
+		return;
+
+	/* Undo the toggle if already pressed */
+	if (!gtk_toggle_button_get_active (toggle))
+		gtk_toggle_button_set_active (toggle, TRUE);
+
+	/* Otherwise update everything */
+	else
+		buttons_update (self, toggle);
+}
+
+static void
+buttons_construct (UmAccountDialog *self,
+                   GtkBuilder *builder)
+{
+	GtkToggleButton *first = NULL;
+	GtkStyleContext *context;
+	GList *children, *l;
+
+	self->buttons = (GtkWidget *) gtk_builder_get_object (builder, "account-buttons");
+
+	context = gtk_widget_get_style_context (self->buttons);
+	gtk_style_context_add_class (context, GTK_STYLE_CLASS_LINKED);
+
+	children = gtk_container_get_children (GTK_CONTAINER (self->buttons));
+	for (l = children; l != NULL; l = g_list_next (l)) {
+		if (!GTK_IS_TOGGLE_BUTTON (l->data))
+			continue;
+		if (first == NULL)
+			first = l->data;
+		g_signal_connect (l->data, "toggled",
+		                  G_CALLBACK (on_button_toggled), self);
+	}
+
+	g_list_free (children);
+
+	/* Update and select the first button */
+	if (first != NULL)
+		gtk_toggle_button_set_active (first, TRUE);
+}
+
+static void
+um_account_dialog_constructed (GObject *obj)
+{
+	GtkBuilder *builder;
+	GtkWidget *widget;
+	UmAccountDialog *self;
+	const gchar *filename;
+	GError *error = NULL;
+	GtkWidget *content;
+
+	G_OBJECT_CLASS (um_account_dialog_parent_class)->constructed (obj);
+
+	self = UM_ACCOUNT_DIALOG (obj);
+	builder = gtk_builder_new ();
+
+	filename = UIDIR "/account-dialog.ui";
+	if (!g_file_test (filename, G_FILE_TEST_EXISTS))
+		filename = "data/account-dialog.ui";
+	if (!gtk_builder_add_from_file (builder, filename, &error)) {
+		g_error ("%s", error->message);
+		g_error_free (error);
+		return;
+	}
+
+	widget = gtk_dialog_add_button (GTK_DIALOG (self),
+	                                _("Add"), GTK_RESPONSE_OK);
+	gtk_widget_grab_default (widget);
+
+	gtk_dialog_add_button (GTK_DIALOG (self),
+	                       _("Cancel"), GTK_RESPONSE_CANCEL);
+
+	content = gtk_dialog_get_content_area (GTK_DIALOG (self));
+
+	widget = (GtkWidget *) gtk_builder_get_object (builder, "account-dialog");
+	gtk_container_add (GTK_CONTAINER (content), widget);
+
+	widget = (GtkWidget *) gtk_builder_get_object (builder, "account-pages");
+	self->notebook = GTK_NOTEBOOK (widget);
+
+	local_construct (self, builder);
+	enterprise_construct (self, builder);
+
+	buttons_construct (self, builder);
+	g_object_unref (builder);
+}
+
+static void
+um_account_dialog_response (GtkDialog *dialog,
+                            gint response_id)
+{
+	UmAccountDialog *self = UM_ACCOUNT_DIALOG (dialog);
+
+	switch (response_id) {
+	case GTK_RESPONSE_OK:
+		switch (get_account_mode (self)) {
+		case UM_LOCAL:
+			local_add (self);
+			break;
+		case UM_ENTERPRISE:
+			enterprise_add (self);
+			break;
+		default:
+			g_return_if_reached ();
+			break;
+		}
+		break;
+	case GTK_RESPONSE_CANCEL:
+	case GTK_RESPONSE_DELETE_EVENT:
+		g_simple_async_result_set_op_res_gpointer (self->async, NULL, NULL);
+		g_simple_async_result_complete_in_idle (self->async);
+		gtk_widget_hide (GTK_WIDGET (self));
+		break;
+	default:
+		g_warn_if_reached ();
+		break;
+	}
+}
+
+static void
+um_account_dialog_finalize (GObject *obj)
+{
+	G_OBJECT_CLASS (um_account_dialog_parent_class)->finalize (obj);
+}
+
+static void
+um_account_dialog_class_init (UmAccountDialogClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (klass);
+
+	object_class->constructed = um_account_dialog_constructed;
+	object_class->finalize = um_account_dialog_finalize;
+
+	dialog_class->response = um_account_dialog_response;
+}
+
+UmAccountDialog *
+um_account_dialog_new (void)
+{
+	return g_object_new (UM_TYPE_ACCOUNT_DIALOG, NULL);
 }
 
 void
-um_account_dialog_show (UmAccountDialog     *um,
-                        GtkWindow           *parent,
-                        UserCreatedCallback  user_created_callback,
-                        gpointer             user_created_data)
+um_account_dialog_perform (UmAccountDialog     *self,
+                           GtkWindow           *parent,
+                           GAsyncReadyCallback  callback,
+                           gpointer             user_data)
 {
-        GtkTreeModel *model;
+	g_return_if_fail (UM_IS_ACCOUNT_DIALOG (self));
+
+	/* Make sure not already doing an operation */
+	g_return_if_fail (self->async == NULL);
 
-        gtk_entry_set_text (GTK_ENTRY (um->name_entry), "");
-        gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (um->username_combo))), "");
-        model = gtk_combo_box_get_model (GTK_COMBO_BOX (um->username_combo));
-        gtk_list_store_clear (GTK_LIST_STORE (model));
-        gtk_combo_box_set_active (GTK_COMBO_BOX (um->account_type_combo), 0);
+	self->async = g_simple_async_result_new (G_OBJECT (self), callback, user_data,
+	                                         um_account_dialog_perform);
 
-        gtk_window_set_transient_for (GTK_WINDOW (um->dialog), parent);
-        gtk_window_present (GTK_WINDOW (um->dialog));
-        gtk_widget_grab_focus (um->name_entry);
+	local_clear (self);
+	enterprise_clear (self);
 
-        um->valid_name = um->valid_username = TRUE;
+	gtk_window_set_modal (GTK_WINDOW (self), parent != NULL);
+	gtk_window_set_transient_for (GTK_WINDOW (self), parent);
+	gtk_window_present (GTK_WINDOW (self));
 
-        um->user_created_callback = user_created_callback;
-        um->user_created_data = user_created_data;
+	gtk_widget_grab_focus (self->local_name);
 }
 
+UmUser *
+um_account_dialog_finish (UmAccountDialog     *self,
+                          GAsyncResult        *result)
+{
+	UmUser *user;
+
+	g_return_val_if_fail (UM_IS_ACCOUNT_DIALOG (self), NULL);
+	g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (self),
+	                      um_account_dialog_perform), NULL);
+	g_return_val_if_fail (result == G_ASYNC_RESULT (self->async), NULL);
+
+	user = g_simple_async_result_get_op_res_gpointer (self->async);
+	if (user != NULL)
+		g_object_ref (user);
 
+	g_clear_object (&self->async);
+	return user;
+}
diff --git a/panels/user-accounts/um-account-dialog.h b/panels/user-accounts/um-account-dialog.h
index e3b2ebc..12b9a41 100644
--- a/panels/user-accounts/um-account-dialog.h
+++ b/panels/user-accounts/um-account-dialog.h
@@ -1,6 +1,6 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
  *
- * Copyright 2009-2010  Red Hat, Inc,
+ * Copyright 2009-2012  Red Hat, Inc,
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -17,6 +17,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  *
  * Written by: Matthias Clasen <mclasen redhat com>
+ *             Stef Walter <stefw gnome org>
  */
 
 #ifndef __UM_ACCOUNT_DIALOG_H__
@@ -27,16 +28,23 @@
 
 G_BEGIN_DECLS
 
+#define UM_TYPE_ACCOUNT_DIALOG      (um_account_dialog_get_type ())
+#define UM_ACCOUNT_DIALOG(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), UM_TYPE_ACCOUNT_DIALOG, UmAccountDialog))
+#define UM_IS_ACCOUNT_DIALOG(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UM_TYPE_ACCOUNT_DIALOG))
+
 typedef struct _UmAccountDialog UmAccountDialog;
 
-typedef void (*UserCreatedCallback) (UmUser *user, gpointer data);
+GType             um_account_dialog_get_type (void) G_GNUC_CONST;
+
+UmAccountDialog * um_account_dialog_new      (void);
+
+void              um_account_dialog_perform  (UmAccountDialog     *self,
+                                              GtkWindow           *parent,
+                                              GAsyncReadyCallback  callback,
+                                              gpointer             user_data);
 
-UmAccountDialog *um_account_dialog_new      (void);
-void             um_account_dialog_free     (UmAccountDialog     *dialog);
-void             um_account_dialog_show     (UmAccountDialog     *dialog,
-                                             GtkWindow           *parent,
-                                             UserCreatedCallback  user_created,
-                                             gpointer             data);
+UmUser *          um_account_dialog_finish   (UmAccountDialog     *self,
+                                              GAsyncResult        *result);
 
 G_END_DECLS
 
diff --git a/panels/user-accounts/um-user-panel.c b/panels/user-accounts/um-user-panel.c
index b4b3809..d4bd90a 100644
--- a/panels/user-accounts/um-user-panel.c
+++ b/panels/user-accounts/um-user-panel.c
@@ -299,14 +299,22 @@ user_changed (UmUserManager *um, UmUser *user, UmUserPanelPrivate *d)
 }
 
 static void
-select_created_user (UmUser *user, UmUserPanelPrivate *d)
+select_created_user (GObject *object,
+                     GAsyncResult *result,
+                     gpointer user_data)
 {
+        UmUserPanelPrivate *d = user_data;
         GtkTreeView *tv;
         GtkTreeModel *model;
         GtkTreeSelection *selection;
         GtkTreeIter iter;
         UmUser *current;
         GtkTreePath *path;
+        UmUser *user;
+
+        user = um_account_dialog_finish (UM_ACCOUNT_DIALOG (object), result);
+        if (user == NULL)
+                return;
 
         tv = (GtkTreeView *)get_widget (d, "list-treeview");
         model = gtk_tree_view_get_model (tv);
@@ -331,9 +339,9 @@ select_created_user (UmUser *user, UmUserPanelPrivate *d)
 static void
 add_user (GtkButton *button, UmUserPanelPrivate *d)
 {
-        um_account_dialog_show (d->account_dialog,
-                                GTK_WINDOW (gtk_widget_get_toplevel (d->main_box)),
-                                (UserCreatedCallback)select_created_user, d);
+        um_account_dialog_perform (d->account_dialog,
+                                   GTK_WINDOW (gtk_widget_get_toplevel (d->main_box)),
+                                   select_created_user, d);
 }
 
 static void
@@ -1297,7 +1305,7 @@ um_user_panel_dispose (GObject *object)
                 priv->builder = NULL;
         }
         if (priv->account_dialog) {
-                um_account_dialog_free (priv->account_dialog);
+                g_object_unref (priv->account_dialog);
                 priv->account_dialog = NULL;
         }
         if (priv->password_dialog) {



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