[gnome-control-center/wip/feborges/new-users-panel: 13/15] user-accounts: port Add User dialog to gtk+ composite widget templates



commit 2758110d416c12063a309c16ff66f219f3f2a30d
Author: Felipe Borges <felipeborges gnome org>
Date:   Fri Jun 10 11:34:05 2016 +0200

    user-accounts: port Add User dialog to gtk+ composite widget templates
    
    https://bugzilla.gnome.org/show_bug.cgi?id=767065

 panels/user-accounts/data/account-dialog.ui |   78 +++++++------
 panels/user-accounts/data/join-dialog.ui    |    1 -
 panels/user-accounts/um-account-dialog.c    |  172 +++++++++-----------------
 3 files changed, 101 insertions(+), 150 deletions(-)
---
diff --git a/panels/user-accounts/data/account-dialog.ui b/panels/user-accounts/data/account-dialog.ui
index 71783a3..647040b 100644
--- a/panels/user-accounts/data/account-dialog.ui
+++ b/panels/user-accounts/data/account-dialog.ui
@@ -8,7 +8,9 @@
       <column type="gchararray"/>
     </columns>
   </object>
-
+  <template class="UmAccountDialog" parent="GtkDialog">
+    <property name="can_focus">False</property>
+    <child internal-child="vbox">
       <object class="GtkBox" id="account-dialog">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
@@ -21,21 +23,21 @@
             <property name="border_width">6</property>
             <property name="margin_bottom">6</property>
             <child>
-              <object class="GtkGrid" id="local-area">
+              <object class="GtkGrid" id="local_area">
                 <property name="visible">True</property>
                 <property name="hexpand">True</property>
                 <property name="column_spacing">6</property>
                 <property name="row_spacing">6</property>
                 <property name="halign">center</property>
                 <child>
-                  <object class="GtkComboBoxText" id="local-username">
+                  <object class="GtkComboBoxText" id="local_username">
                     <property name="visible">True</property>
                     <property name="has_entry">True</property>
                     <property name="entry_text_column">0</property>
                     <property name="model">username-model</property>
                     <property name="hexpand">True</property>
                     <child internal-child="entry">
-                      <object class="GtkEntry" id="local-username-entry">
+                      <object class="GtkEntry" id="local_username_entry">
                         <property name="activates_default">True</property>
                       </object>
                     </child>
@@ -46,7 +48,7 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkLabel" id="local-username-hint">
+                  <object class="GtkLabel" id="local_username_hint">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="yalign">0</property>
@@ -75,7 +77,7 @@
                     <property name="xalign">1</property>
                     <property name="label" translatable="yes">_Username</property>
                     <property name="use_underline">True</property>
-                    <property name="mnemonic_widget">local-username</property>
+                    <property name="mnemonic_widget">local_username</property>
                     <property name="margin_start">12</property>
                     <style>
                       <class name="dim-label"/>
@@ -87,7 +89,7 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkEntry" id="local-name">
+                  <object class="GtkEntry" id="local_name">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="activates_default">True</property>
@@ -104,7 +106,7 @@
                     <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>
+                    <property name="mnemonic_widget">local_name</property>
                     <property name="margin_start">12</property>
                     <style>
                       <class name="dim-label"/>
@@ -123,7 +125,7 @@
                       <class name="linked"/>
                     </style>
                     <child>
-                      <object class="GtkRadioButton" id="account-type-standard">
+                      <object class="GtkRadioButton" id="account_type_standard">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="hexpand">True</property>
@@ -140,7 +142,7 @@
                         <property name="label" translatable="yes">Administrator</property>
                         <property name="draw_indicator">False</property>
                         <property name="height_request">35</property>
-                        <property name="group">account-type-standard</property>
+                        <property name="group">account_type_standard</property>
                       </object>
                     </child>
                   </object>
@@ -186,7 +188,7 @@
                     <property name="visible">True</property>
                     <property name="orientation">vertical</property>
                     <child>
-                      <object class="GtkRadioButton" id="local-password-login-radio">
+                      <object class="GtkRadioButton" id="local_password_login_radio">
                         <property name="label" translatable="yes">Allow user to set a password when they 
next _login</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
@@ -201,14 +203,14 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkRadioButton" id="local-password-now-radio">
+                      <object class="GtkRadioButton" id="local_password_radio">
                         <property name="label" translatable="yes">Set a password _now</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
                         <property name="active">True</property>
                         <property name="draw_indicator">True</property>
-                        <property name="group">local-password-login-radio</property>
+                        <property name="group">local_password_login_radio</property>
                         <property name="use_underline">True</property>
                         <property name="margin_start">12</property>
                       </object>
@@ -231,7 +233,7 @@
                     <property name="xalign">1</property>
                     <property name="label" translatable="yes">_Password</property>
                     <property name="use_underline">True</property>
-                    <property name="mnemonic_widget">local-password</property>
+                    <property name="mnemonic_widget">local_password</property>
                     <property name="margin_start">12</property>
                     <style>
                       <class name="dim-label"/>
@@ -245,7 +247,7 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkEntry" id="local-password">
+                  <object class="GtkEntry" id="local_password">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="has_tooltip">True</property>
@@ -264,7 +266,7 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkLevelBar" id="local-strength-indicator">
+                  <object class="GtkLevelBar" id="local_strength_indicator">
                     <property name="visible">True</property>
                     <property name="mode">discrete</property>
                     <property name="max-value">4</property>
@@ -281,7 +283,7 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkLabel" id="local-hint">
+                  <object class="GtkLabel" id="local_hint">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="yalign">0</property>
@@ -313,7 +315,7 @@
                     <property name="xalign">1</property>
                     <property name="label" translatable="yes">_Confirm</property>
                     <property name="use_underline">True</property>
-                    <property name="mnemonic_widget">local-verify</property>
+                    <property name="mnemonic_widget">local_verify</property>
                     <property name="margin_start">12</property>
                     <style>
                       <class name="dim-label"/>
@@ -327,7 +329,7 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkEntry" id="local-verify">
+                  <object class="GtkEntry" id="local_verify">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="visibility">False</property>
@@ -344,7 +346,7 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkLabel" id="local-verify-hint">
+                  <object class="GtkLabel" id="local_verify_hint">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="yalign">0</property>
@@ -407,7 +409,7 @@
                     <property name="xalign">1</property>
                     <property name="label" translatable="yes">_Domain</property>
                     <property name="use_underline">True</property>
-                    <property name="mnemonic_widget">enterprise-domain</property>
+                    <property name="mnemonic_widget">enterprise_domain</property>
                     <property name="margin_start">12</property>
                     <style>
                       <class name="dim-label"/>
@@ -427,7 +429,7 @@
                     <property name="xalign">1</property>
                     <property name="label" translatable="yes">_Username</property>
                     <property name="use_underline">True</property>
-                    <property name="mnemonic_widget">enterprise-login</property>
+                    <property name="mnemonic_widget">enterprise_login</property>
                     <property name="margin_start">12</property>
                     <style>
                       <class name="dim-label"/>
@@ -447,7 +449,7 @@
                     <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>
+                    <property name="mnemonic_widget">enterprise_password</property>
                     <property name="margin_start">12</property>
                     <style>
                       <class name="dim-label"/>
@@ -487,14 +489,14 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkComboBox" id="enterprise-domain">
+                  <object class="GtkComboBox" id="enterprise_domain">
                     <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="combobox-entry">
+                      <object class="GtkEntry" id="enterprise_domain_entry">
                         <property name="can_focus">True</property>
                       </object>
                     </child>
@@ -507,7 +509,7 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkLabel" id="enterprise-domain-hint">
+                  <object class="GtkLabel" id="enterprise_domain_hint">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="yalign">0</property>
@@ -534,7 +536,7 @@
                 </child>
 
                 <child>
-                  <object class="GtkEntry" id="enterprise-login">
+                  <object class="GtkEntry" id="enterprise_login">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="hexpand">True</property>
@@ -551,7 +553,7 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkEntry" id="enterprise-password">
+                  <object class="GtkEntry" id="enterprise_password">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="hexpand">True</property>
@@ -674,7 +676,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <child>
-              <object class="GtkToggleButton" id="enterprise-button">
+              <object class="GtkToggleButton" id="enterprise_button">
                 <property name="label" translatable="yes">_Enterprise Login</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
@@ -707,6 +709,8 @@
           </packing>
         </child>
       </object>
+    </child>
+  </template>
   <object class="GtkSizeGroup" id="labels_sizegroup">
     <widgets>
       <widget name="label6"/>
@@ -721,20 +725,20 @@
   </object>
   <object class="GtkSizeGroup" id="controls_sizegroup">
     <widgets>
-      <widget name="local-username"/>
-      <widget name="local-name"/>
+      <widget name="local_username"/>
+      <widget name="local_name"/>
       <widget name="local-account-type"/>
-      <widget name="local-password"/>
-      <widget name="local-verify"/>
-      <widget name="enterprise-domain"/>
-      <widget name="enterprise-login"/>
-      <widget name="enterprise-password"/>
+      <widget name="local_password"/>
+      <widget name="local_verify"/>
+      <widget name="enterprise_domain"/>
+      <widget name="enterprise_login"/>
+      <widget name="enterprise_password"/>
     </widgets>
   </object>
   <object class="GtkSizeGroup">
     <property name="mode">horizontal</property>
     <widgets>
-      <widget name="account-type-standard"/>
+      <widget name="account_type_standard"/>
       <widget name="account-type-admin"/>
     </widgets>
   </object>
diff --git a/panels/user-accounts/data/join-dialog.ui b/panels/user-accounts/data/join-dialog.ui
index 45b9a4b..0fda6f7 100644
--- a/panels/user-accounts/data/join-dialog.ui
+++ b/panels/user-accounts/data/join-dialog.ui
@@ -236,4 +236,3 @@ type their domain password here.</property>
     </action-widgets>
   </object>
 </interface>
-
diff --git a/panels/user-accounts/um-account-dialog.c b/panels/user-accounts/um-account-dialog.c
index 1b83b3e..8053595 100644
--- a/panels/user-accounts/um-account-dialog.c
+++ b/panels/user-accounts/um-account-dialog.c
@@ -70,7 +70,6 @@ static void   um_account_dialog_response  (GtkDialog *dialog,
 struct _UmAccountDialog {
         GtkDialog parent;
         GtkWidget *stack;
-        GtkWidget *container_widget;
         GSimpleAsyncResult *async;
         GCancellable *cancellable;
         GPermission *permission;
@@ -79,11 +78,12 @@ struct _UmAccountDialog {
 
         /* Local user account widgets */
         GtkWidget *local_username;
+        GtkWidget *local_username_entry;
         GtkWidget *local_name;
         gint       local_name_timeout_id;
         GtkWidget *local_username_hint;
         gint       local_username_timeout_id;
-        GtkWidget *local_account_type;
+        GtkWidget *account_type_standard;
         ActUserPasswordMode local_password_mode;
         GtkWidget *local_password_radio;
         GtkWidget *local_password;
@@ -251,7 +251,7 @@ local_create_user (UmAccountDialog *self)
 
         name = gtk_entry_get_text (GTK_ENTRY (self->local_name));
         username = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (self->local_username));
-        account_type = (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->local_account_type)) ? 
ACT_USER_ACCOUNT_TYPE_STANDARD : ACT_USER_ACCOUNT_TYPE_ADMINISTRATOR);
+        account_type = (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->account_type_standard)) ? 
ACT_USER_ACCOUNT_TYPE_STANDARD : ACT_USER_ACCOUNT_TYPE_ADMINISTRATOR);
 
         g_debug ("Creating local user: %s", username);
 
@@ -542,63 +542,36 @@ on_password_radio_changed (GtkRadioButton *radio,
 }
 
 static void
-local_init (UmAccountDialog *self,
-            GtkBuilder *builder)
+local_init (UmAccountDialog *self)
 {
-        GtkWidget *widget;
-
-        widget = (GtkWidget *) gtk_builder_get_object (builder, "local-username");
-        g_signal_connect (widget, "changed",
+        g_signal_connect (self->local_username, "changed",
                           G_CALLBACK (on_username_changed), self);
-        g_signal_connect_after (widget, "focus-out-event", G_CALLBACK (on_username_focus_out), self);
-        self->local_username = widget;
-
-        widget = (GtkWidget *) gtk_builder_get_object (builder, "local-username-entry");
-        g_signal_connect_swapped (widget, "activate", G_CALLBACK (dialog_validate), self);
-
-        widget = (GtkWidget *) gtk_builder_get_object (builder, "local-name");
-        g_signal_connect (widget, "changed", G_CALLBACK (on_name_changed), self);
-        g_signal_connect_after (widget, "focus-out-event", G_CALLBACK (on_name_focus_out), self);
-        g_signal_connect_swapped (widget, "activate", G_CALLBACK (dialog_validate), self);
-        self->local_name = widget;
+        g_signal_connect_after (self->local_username, "focus-out-event", G_CALLBACK (on_username_focus_out), 
self);
 
-        widget = (GtkWidget *) gtk_builder_get_object (builder, "local-username-hint");
-        self->local_username_hint = widget;
+        g_signal_connect_swapped (self->local_username_entry, "activate", G_CALLBACK (dialog_validate), 
self);
 
-        widget = (GtkWidget *) gtk_builder_get_object (builder, "account-type-standard");
-        self->local_account_type = widget;
+        g_signal_connect (self->local_name, "changed", G_CALLBACK (on_name_changed), self);
+        g_signal_connect_after (self->local_name, "focus-out-event", G_CALLBACK (on_name_focus_out), self);
+        g_signal_connect_swapped (self->local_name, "activate", G_CALLBACK (dialog_validate), self);
 
-        widget = (GtkWidget *) gtk_builder_get_object (builder, "local-password-now-radio");
-        g_signal_connect (widget, "toggled", G_CALLBACK (on_password_radio_changed), self);
-        self->local_password_radio = widget;
+        g_signal_connect (self->local_password_radio, "toggled", G_CALLBACK (on_password_radio_changed), 
self);
 
         self->local_password_mode = ACT_USER_PASSWORD_MODE_SET_AT_LOGIN;
 
-        widget = (GtkWidget *) gtk_builder_get_object (builder, "local-password");
-        gtk_widget_set_sensitive (widget, FALSE);
-        g_signal_connect (widget, "notify::text", G_CALLBACK (on_password_changed), self);
-        g_signal_connect_after (widget, "focus-out-event", G_CALLBACK (on_password_focus_out), self);
-        g_signal_connect_swapped (widget, "activate", G_CALLBACK (dialog_validate), self);
-        self->local_password = widget;
-        g_signal_connect (widget, "icon-press", G_CALLBACK (on_generate), self);
+        gtk_widget_set_sensitive (self->local_password, FALSE);
+        g_signal_connect (self->local_password, "notify::text", G_CALLBACK (on_password_changed), self);
+        g_signal_connect_after (self->local_password, "focus-out-event", G_CALLBACK (on_password_focus_out), 
self);
+        g_signal_connect_swapped (self->local_password, "activate", G_CALLBACK (dialog_validate), self);
+        g_signal_connect (self->local_password, "icon-press", G_CALLBACK (on_generate), self);
 
-        widget = (GtkWidget *) gtk_builder_get_object (builder, "local-verify");
-        gtk_widget_set_sensitive (widget, FALSE);
-        g_signal_connect (widget, "notify::text", G_CALLBACK (on_password_changed), self);
-        g_signal_connect_after (widget, "focus-out-event", G_CALLBACK (on_password_focus_out), self);
-        g_signal_connect_swapped (widget, "activate", G_CALLBACK (dialog_validate), self);
-        self->local_verify = widget;
+        gtk_widget_set_sensitive (self->local_verify, FALSE);
+        g_signal_connect (self->local_verify, "notify::text", G_CALLBACK (on_password_changed), self);
+        g_signal_connect_after (self->local_verify, "focus-out-event", G_CALLBACK (on_password_focus_out), 
self);
+        g_signal_connect_swapped (self->local_verify, "activate", G_CALLBACK (dialog_validate), self);
 
-        widget = (GtkWidget *) gtk_builder_get_object (builder, "local-strength-indicator");
-        gtk_widget_set_sensitive (widget, FALSE);
-        self->local_strength_indicator = widget;
+        gtk_widget_set_sensitive (self->local_strength_indicator, FALSE);
 
-        widget = (GtkWidget *) gtk_builder_get_object (builder, "local-hint");
-        gtk_widget_set_sensitive (widget, FALSE);
-        self->local_hint = widget;
-
-        widget = (GtkWidget *) gtk_builder_get_object (builder, "local-verify-hint");
-        self->local_verify_hint = widget;
+        gtk_widget_set_sensitive (self->local_hint, FALSE);
 
         dialog_validate (self);
         update_password_strength (self);
@@ -613,7 +586,7 @@ local_prepare (UmAccountDialog *self)
         gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (self->local_username))), "");
         model = gtk_combo_box_get_model (GTK_COMBO_BOX (self->local_username));
         gtk_list_store_clear (GTK_LIST_STORE (model));
-        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->local_account_type), TRUE);
+        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->account_type_standard), TRUE);
 }
 
 static gboolean
@@ -1334,38 +1307,26 @@ on_entry_changed (GtkEditable *editable,
 }
 
 static void
-enterprise_init (UmAccountDialog *self,
-                 GtkBuilder *builder)
+enterprise_init (UmAccountDialog *self)
 {
-        GtkWidget *widget;
         GNetworkMonitor *monitor;
 
         self->enterprise_realms = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_OBJECT);
         self->enterprise_check_credentials = FALSE;
 
-        self->enterprise_hint = (GtkWidget *) gtk_builder_get_object (builder, "enterprise-hint");
-        self->enterprise_domain_hint = (GtkWidget *) gtk_builder_get_object (builder, 
"enterprise-domain-hint");
-
-        widget = (GtkWidget *) gtk_builder_get_object (builder, "enterprise-domain");
-        g_signal_connect (widget, "changed", G_CALLBACK (on_domain_changed), self);
-        g_signal_connect_after (widget, "focus-out-event", G_CALLBACK (on_enterprise_domain_focus_out), 
self);
-        self->enterprise_domain = GTK_COMBO_BOX (widget);
-        gtk_combo_box_set_model (self->enterprise_domain,
+        g_signal_connect (self->enterprise_domain, "changed", G_CALLBACK (on_domain_changed), self);
+        g_signal_connect_after (self->enterprise_domain, "focus-out-event", G_CALLBACK 
(on_enterprise_domain_focus_out), self);
+        gtk_combo_box_set_model (GTK_COMBO_BOX (self->enterprise_domain),
                                  GTK_TREE_MODEL (self->enterprise_realms));
-        self->enterprise_domain_entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (widget)));
+        self->enterprise_domain_entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (self->enterprise_domain)));
         enterprise_check_domain (self);
 
-        widget = (GtkWidget *) gtk_builder_get_object (builder, "enterprise-login");
-        g_signal_connect (widget, "changed", G_CALLBACK (on_entry_changed), self);
-        self->enterprise_login = GTK_ENTRY (widget);
+        g_signal_connect (self->enterprise_login, "changed", G_CALLBACK (on_entry_changed), self);
 
-        widget = (GtkWidget *) gtk_builder_get_object (builder, "enterprise-password");
-        g_signal_connect (widget, "changed", G_CALLBACK (on_entry_changed), self);
-        self->enterprise_password = GTK_ENTRY (widget);
+        g_signal_connect (self->enterprise_password, "changed", G_CALLBACK (on_entry_changed), self);
 
         /* Initially we hide the 'Enterprise Login' stuff */
-        widget = self->enterprise_button;
-        gtk_widget_hide (widget);
+        gtk_widget_hide (self->enterprise_button);
 
         self->realmd_watch = g_bus_watch_name (G_BUS_TYPE_SYSTEM, "org.freedesktop.realmd",
                                                G_BUS_NAME_WATCHER_FLAGS_AUTO_START,
@@ -1439,66 +1400,30 @@ on_enterprise_toggle (GtkToggleButton *toggle,
 }
 
 static void
-mode_init (UmAccountDialog *self,
-           GtkBuilder *builder)
+mode_init (UmAccountDialog *self)
 {
-        GtkWidget *widget;
-
-        widget = self->enterprise_button;
-        g_signal_connect (widget, "toggled", G_CALLBACK (on_enterprise_toggle), self);
+        g_signal_connect (self->enterprise_button, "toggled", G_CALLBACK (on_enterprise_toggle), self);
 }
 
 static void
 um_account_dialog_init (UmAccountDialog *self)
 {
-        GtkBuilder *builder;
         GtkWidget *widget;
-        GError *error = NULL;
         GtkDialog *dialog;
-        GtkWidget *content;
-
-        builder = gtk_builder_new ();
 
-        if (!gtk_builder_add_from_resource (builder,
-                                            "/org/gnome/control-center/user-accounts/account-dialog.ui",
-                                            &error)) {
-                g_error ("%s", error->message);
-                g_error_free (error);
-                return;
-        }
+        gtk_widget_init_template (GTK_WIDGET (self));
 
         dialog = GTK_DIALOG (self);
-        content = gtk_dialog_get_content_area (dialog);
-        gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
-        gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
-        gtk_window_set_title (GTK_WINDOW (dialog), _("Add User"));
-        gtk_window_set_icon_name (GTK_WINDOW (dialog), "system-users");
-
-        widget = GTK_WIDGET (gtk_builder_get_object (builder, "enterprise-button"));
-        self->enterprise_button = widget;
-
-        widget = GTK_WIDGET (gtk_builder_get_object (builder, "spinner"));
-        gtk_widget_hide (widget);
-        self->spinner = GTK_SPINNER (widget);
 
         gtk_dialog_add_button (dialog, _("_Cancel"), GTK_RESPONSE_CANCEL);
         widget = gtk_dialog_add_button (dialog, _("_Add"), GTK_RESPONSE_OK);
         gtk_dialog_set_default_response (dialog, GTK_RESPONSE_OK);
         gtk_widget_grab_default (widget);
 
-        widget = (GtkWidget *) gtk_builder_get_object (builder, "account-dialog");
-        gtk_container_add (GTK_CONTAINER (content), widget);
-        self->container_widget = widget;
-
-        widget = GTK_WIDGET (gtk_builder_get_object (builder, "stack"));
-        self->stack = widget;
-
-        local_init (self, builder);
-        enterprise_init (self, builder);
+        local_init (self);
+        enterprise_init (self);
         join_init (self);
-        mode_init (self, builder);
-
-        g_object_unref (builder);
+        mode_init (self);
 }
 
 static void
@@ -1621,11 +1546,34 @@ um_account_dialog_class_init (UmAccountDialogClass *klass)
 {
         GObjectClass *object_class = G_OBJECT_CLASS (klass);
         GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (klass);
+        GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
         object_class->dispose = um_account_dialog_dispose;
         object_class->finalize = um_account_dialog_finalize;
 
         dialog_class->response = um_account_dialog_response;
+
+        gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (dialog_class),
+                                                     
"/org/gnome/control-center/user-accounts/account-dialog.ui");
+
+        gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, stack);
+        gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, local_username);
+        gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, local_username_entry);
+        gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, local_name);
+        gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, local_username_hint);
+        gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, account_type_standard);
+        gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, local_password_radio);
+        gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, local_password);
+        gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, local_verify);
+        gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, local_strength_indicator);
+        gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, local_hint);
+        gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, local_verify_hint);
+        gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, enterprise_button);
+        gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, spinner);
+        gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, enterprise_domain);
+        gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, enterprise_login);
+        gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, enterprise_password);
+        gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, enterprise_domain_hint);
 }
 
 UmAccountDialog *


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