/* NewUserDialog.c generated by valac 0.56.19, the Vala compiler
 * generated from NewUserDialog.vala, do not modify */

/*
 * SPDX-License-Identifier: GPL-3.0-or-later
 * SPDX-FileCopyrightText: 2014-2023 elementary, Inc. (https://elementary.io)
 */

#include "useraccounts.h"
#include <gtk/gtk.h>
#include <glib-object.h>
#include <granite-7.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <act/act.h>
#include <polkit/polkit.h>
#include <gio/gio.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

#define SWITCHBOARD_PLUG_USER_ACCOUNTS_TYPE_ERROR_REVEALER (switchboard_plug_user_accounts_error_revealer_get_type ())
#define SWITCHBOARD_PLUG_USER_ACCOUNTS_ERROR_REVEALER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWITCHBOARD_PLUG_USER_ACCOUNTS_TYPE_ERROR_REVEALER, SwitchboardPlugUserAccountsErrorRevealer))
#define SWITCHBOARD_PLUG_USER_ACCOUNTS_ERROR_REVEALER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWITCHBOARD_PLUG_USER_ACCOUNTS_TYPE_ERROR_REVEALER, SwitchboardPlugUserAccountsErrorRevealerClass))
#define SWITCHBOARD_PLUG_USER_ACCOUNTS_IS_ERROR_REVEALER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWITCHBOARD_PLUG_USER_ACCOUNTS_TYPE_ERROR_REVEALER))
#define SWITCHBOARD_PLUG_USER_ACCOUNTS_IS_ERROR_REVEALER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWITCHBOARD_PLUG_USER_ACCOUNTS_TYPE_ERROR_REVEALER))
#define SWITCHBOARD_PLUG_USER_ACCOUNTS_ERROR_REVEALER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWITCHBOARD_PLUG_USER_ACCOUNTS_TYPE_ERROR_REVEALER, SwitchboardPlugUserAccountsErrorRevealerClass))

typedef struct _SwitchboardPlugUserAccountsErrorRevealer SwitchboardPlugUserAccountsErrorRevealer;
typedef struct _SwitchboardPlugUserAccountsErrorRevealerClass SwitchboardPlugUserAccountsErrorRevealerClass;
enum  {
	SWITCHBOARD_PLUG_USER_ACCOUNTS_NEW_USER_DIALOG_0_PROPERTY,
	SWITCHBOARD_PLUG_USER_ACCOUNTS_NEW_USER_DIALOG_NUM_PROPERTIES
};
static GParamSpec* switchboard_plug_user_accounts_new_user_dialog_properties[SWITCHBOARD_PLUG_USER_ACCOUNTS_NEW_USER_DIALOG_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block2Data Block2Data;

struct _SwitchboardPlugUserAccountsNewUserDialogPrivate {
	SwitchboardPlugUserAccountsErrorRevealer* username_error_revealer;
	GtkButton* create_button;
	SwitchboardPlugUserAccountsWidgetsPasswordEditor* pw_editor;
	GraniteValidatedEntry* username_entry;
};

struct _Block2Data {
	int _ref_count_;
	SwitchboardPlugUserAccountsNewUserDialog* self;
	GtkComboBoxText* accounttype_combobox;
	GtkEntry* realname_entry;
};

static gint SwitchboardPlugUserAccountsNewUserDialog_private_offset;
static gpointer switchboard_plug_user_accounts_new_user_dialog_parent_class = NULL;

VALA_EXTERN GType switchboard_plug_user_accounts_error_revealer_get_type (void) G_GNUC_CONST ;
static gboolean switchboard_plug_user_accounts_new_user_dialog_check_username (SwitchboardPlugUserAccountsNewUserDialog* self);
VALA_EXTERN void switchboard_plug_user_accounts_error_revealer_set_reveal_child (SwitchboardPlugUserAccountsErrorRevealer* self,
                                                                     gboolean value);
VALA_EXTERN void switchboard_plug_user_accounts_error_revealer_set_label (SwitchboardPlugUserAccountsErrorRevealer* self,
                                                              const gchar* value);
static void switchboard_plug_user_accounts_new_user_dialog_update_create_button (SwitchboardPlugUserAccountsNewUserDialog* self);
static GObject * switchboard_plug_user_accounts_new_user_dialog_constructor (GType type,
                                                                      guint n_construct_properties,
                                                                      GObjectConstructParam * construct_properties);
static Block2Data* block2_data_ref (Block2Data* _data2_);
static void block2_data_unref (void * _userdata_);
VALA_EXTERN SwitchboardPlugUserAccountsErrorRevealer* switchboard_plug_user_accounts_error_revealer_new (const gchar* label);
VALA_EXTERN SwitchboardPlugUserAccountsErrorRevealer* switchboard_plug_user_accounts_error_revealer_construct (GType object_type,
                                                                                                   const gchar* label);
VALA_EXTERN GtkLabel* switchboard_plug_user_accounts_error_revealer_get_label_widget (SwitchboardPlugUserAccountsErrorRevealer* self);
static void _switchboard_plug_user_accounts_new_user_dialog___lambda25_ (Block2Data* _data2_);
static void __switchboard_plug_user_accounts_new_user_dialog___lambda25__gtk_editable_changed (GtkEditable* _sender,
                                                                                        gpointer self);
static void _switchboard_plug_user_accounts_new_user_dialog___lambda26_ (SwitchboardPlugUserAccountsNewUserDialog* self);
static void __switchboard_plug_user_accounts_new_user_dialog___lambda26__gtk_editable_changed (GtkEditable* _sender,
                                                                                        gpointer self);
static void _switchboard_plug_user_accounts_new_user_dialog___lambda27_ (SwitchboardPlugUserAccountsNewUserDialog* self);
static void __switchboard_plug_user_accounts_new_user_dialog___lambda27__switchboard_plug_user_accounts_widgets_password_editor_validation_changed (SwitchboardPlugUserAccountsWidgetsPasswordEditor* _sender,
                                                                                                                                             gpointer self);
static void _switchboard_plug_user_accounts_new_user_dialog___lambda28_ (Block2Data* _data2_,
                                                                  gint response_id);
static void __switchboard_plug_user_accounts_new_user_dialog___lambda28__gtk_dialog_response (GtkDialog* _sender,
                                                                                       gint response_id,
                                                                                       gpointer self);
static void switchboard_plug_user_accounts_new_user_dialog_finalize (GObject * obj);
static GType switchboard_plug_user_accounts_new_user_dialog_get_type_once (void);

static inline gpointer
switchboard_plug_user_accounts_new_user_dialog_get_instance_private (SwitchboardPlugUserAccountsNewUserDialog* self)
{
	return G_STRUCT_MEMBER_P (self, SwitchboardPlugUserAccountsNewUserDialog_private_offset);
}

SwitchboardPlugUserAccountsNewUserDialog*
switchboard_plug_user_accounts_new_user_dialog_construct (GType object_type,
                                                          GtkWindow* parent)
{
	SwitchboardPlugUserAccountsNewUserDialog * self = NULL;
	g_return_val_if_fail (parent != NULL, NULL);
	self = (SwitchboardPlugUserAccountsNewUserDialog*) g_object_new (object_type, "transient-for", parent, NULL);
	return self;
}

SwitchboardPlugUserAccountsNewUserDialog*
switchboard_plug_user_accounts_new_user_dialog_new (GtkWindow* parent)
{
	return switchboard_plug_user_accounts_new_user_dialog_construct (SWITCHBOARD_PLUG_USER_ACCOUNTS_TYPE_NEW_USER_DIALOG, parent);
}

static gboolean
switchboard_plug_user_accounts_new_user_dialog_check_username (SwitchboardPlugUserAccountsNewUserDialog* self)
{
	gchar* username_entry_text = NULL;
	GraniteValidatedEntry* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gboolean username_is_valid = FALSE;
	const gchar* _tmp4_;
	gboolean username_is_taken = FALSE;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->username_entry;
	_tmp1_ = gtk_editable_get_text ((GtkEditable*) _tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strdup (_tmp2_);
	username_entry_text = _tmp3_;
	_tmp4_ = username_entry_text;
	username_is_valid = switchboard_plug_user_accounts_is_valid_username (_tmp4_);
	_tmp5_ = username_entry_text;
	username_is_taken = switchboard_plug_user_accounts_is_taken_username (_tmp5_);
	_tmp6_ = username_entry_text;
	if (g_strcmp0 (_tmp6_, "") == 0) {
		SwitchboardPlugUserAccountsErrorRevealer* _tmp7_;
		_tmp7_ = self->priv->username_error_revealer;
		switchboard_plug_user_accounts_error_revealer_set_reveal_child (_tmp7_, FALSE);
	} else {
		gboolean _tmp8_ = FALSE;
		if (username_is_valid) {
			_tmp8_ = !username_is_taken;
		} else {
			_tmp8_ = FALSE;
		}
		if (_tmp8_) {
			SwitchboardPlugUserAccountsErrorRevealer* _tmp9_;
			_tmp9_ = self->priv->username_error_revealer;
			switchboard_plug_user_accounts_error_revealer_set_reveal_child (_tmp9_, FALSE);
			result = TRUE;
			_g_free0 (username_entry_text);
			return result;
		} else {
			SwitchboardPlugUserAccountsErrorRevealer* _tmp12_;
			if (username_is_taken) {
				SwitchboardPlugUserAccountsErrorRevealer* _tmp10_;
				_tmp10_ = self->priv->username_error_revealer;
				switchboard_plug_user_accounts_error_revealer_set_label (_tmp10_, _ ("Username is already taken"));
			} else {
				if (!username_is_valid) {
					SwitchboardPlugUserAccountsErrorRevealer* _tmp11_;
					_tmp11_ = self->priv->username_error_revealer;
					switchboard_plug_user_accounts_error_revealer_set_label (_tmp11_, _ ("Username can only contain lowercase letters and numbers, without space" \
"s"));
				}
			}
			_tmp12_ = self->priv->username_error_revealer;
			switchboard_plug_user_accounts_error_revealer_set_reveal_child (_tmp12_, TRUE);
		}
	}
	result = FALSE;
	_g_free0 (username_entry_text);
	return result;
}

static void
switchboard_plug_user_accounts_new_user_dialog_update_create_button (SwitchboardPlugUserAccountsNewUserDialog* self)
{
	gboolean _tmp0_ = FALSE;
	GraniteValidatedEntry* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->username_entry;
	_tmp2_ = granite_validated_entry_get_is_valid (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_) {
		SwitchboardPlugUserAccountsWidgetsPasswordEditor* _tmp4_;
		gboolean _tmp5_;
		gboolean _tmp6_;
		_tmp4_ = self->priv->pw_editor;
		_tmp5_ = switchboard_plug_user_accounts_widgets_password_editor_get_is_valid (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp0_ = _tmp6_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		GtkButton* _tmp7_;
		GtkButton* _tmp8_;
		_tmp7_ = self->priv->create_button;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp7_, TRUE);
		_tmp8_ = self->priv->create_button;
		gtk_window_set_default_widget ((GtkWindow*) self, (GtkWidget*) _tmp8_);
	} else {
		GtkButton* _tmp9_;
		_tmp9_ = self->priv->create_button;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp9_, FALSE);
	}
}

static Block2Data*
block2_data_ref (Block2Data* _data2_)
{
	g_atomic_int_inc (&_data2_->_ref_count_);
	return _data2_;
}

static void
block2_data_unref (void * _userdata_)
{
	Block2Data* _data2_;
	_data2_ = (Block2Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data2_->_ref_count_)) {
		SwitchboardPlugUserAccountsNewUserDialog* self;
		self = _data2_->self;
		_g_object_unref0 (_data2_->realname_entry);
		_g_object_unref0 (_data2_->accounttype_combobox);
		_g_object_unref0 (self);
		g_slice_free (Block2Data, _data2_);
	}
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static void
_switchboard_plug_user_accounts_new_user_dialog___lambda25_ (Block2Data* _data2_)
{
	SwitchboardPlugUserAccountsNewUserDialog* self;
	gchar* username = NULL;
	GtkEntry* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	GraniteValidatedEntry* _tmp4_;
	const gchar* _tmp5_;
	self = _data2_->self;
	_tmp0_ = _data2_->realname_entry;
	_tmp1_ = gtk_editable_get_text ((GtkEditable*) _tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = switchboard_plug_user_accounts_gen_username (_tmp2_);
	username = _tmp3_;
	_tmp4_ = self->priv->username_entry;
	_tmp5_ = username;
	gtk_editable_set_text ((GtkEditable*) _tmp4_, _tmp5_);
	_g_free0 (username);
}

static void
__switchboard_plug_user_accounts_new_user_dialog___lambda25__gtk_editable_changed (GtkEditable* _sender,
                                                                                   gpointer self)
{
	_switchboard_plug_user_accounts_new_user_dialog___lambda25_ (self);
}

static void
_switchboard_plug_user_accounts_new_user_dialog___lambda26_ (SwitchboardPlugUserAccountsNewUserDialog* self)
{
	GraniteValidatedEntry* _tmp0_;
	_tmp0_ = self->priv->username_entry;
	granite_validated_entry_set_is_valid (_tmp0_, switchboard_plug_user_accounts_new_user_dialog_check_username (self));
	switchboard_plug_user_accounts_new_user_dialog_update_create_button (self);
}

static void
__switchboard_plug_user_accounts_new_user_dialog___lambda26__gtk_editable_changed (GtkEditable* _sender,
                                                                                   gpointer self)
{
	_switchboard_plug_user_accounts_new_user_dialog___lambda26_ ((SwitchboardPlugUserAccountsNewUserDialog*) self);
}

static void
_switchboard_plug_user_accounts_new_user_dialog___lambda27_ (SwitchboardPlugUserAccountsNewUserDialog* self)
{
	switchboard_plug_user_accounts_new_user_dialog_update_create_button (self);
}

static void
__switchboard_plug_user_accounts_new_user_dialog___lambda27__switchboard_plug_user_accounts_widgets_password_editor_validation_changed (SwitchboardPlugUserAccountsWidgetsPasswordEditor* _sender,
                                                                                                                                        gpointer self)
{
	_switchboard_plug_user_accounts_new_user_dialog___lambda27_ ((SwitchboardPlugUserAccountsNewUserDialog*) self);
}

static void
_switchboard_plug_user_accounts_new_user_dialog___lambda28_ (Block2Data* _data2_,
                                                             gint response_id)
{
	SwitchboardPlugUserAccountsNewUserDialog* self;
	GError* _inner_error0_ = NULL;
	self = _data2_->self;
	if (response_id == ((gint) GTK_RESPONSE_OK)) {
		gchar* fullname = NULL;
		GtkEntry* _tmp0_;
		const gchar* _tmp1_;
		const gchar* _tmp2_;
		gchar* _tmp3_;
		gchar* username = NULL;
		GraniteValidatedEntry* _tmp4_;
		const gchar* _tmp5_;
		const gchar* _tmp6_;
		gchar* _tmp7_;
		gchar* password = NULL;
		SwitchboardPlugUserAccountsWidgetsPasswordEditor* _tmp8_;
		gchar* _tmp9_;
		ActUserAccountType accounttype = 0;
		GtkComboBoxText* _tmp10_;
		PolkitPermission* _tmp11_;
		PolkitPermission* _tmp12_;
		gboolean _tmp13_;
		gboolean _tmp14_;
		gboolean _tmp15_;
		_tmp0_ = _data2_->realname_entry;
		_tmp1_ = gtk_editable_get_text ((GtkEditable*) _tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = g_strdup (_tmp2_);
		fullname = _tmp3_;
		_tmp4_ = self->priv->username_entry;
		_tmp5_ = gtk_editable_get_text ((GtkEditable*) _tmp4_);
		_tmp6_ = _tmp5_;
		_tmp7_ = g_strdup (_tmp6_);
		username = _tmp7_;
		_tmp8_ = self->priv->pw_editor;
		_tmp9_ = switchboard_plug_user_accounts_widgets_password_editor_get_password (_tmp8_);
		password = _tmp9_;
		accounttype = ACT_USER_ACCOUNT_TYPE_STANDARD;
		_tmp10_ = _data2_->accounttype_combobox;
		if (gtk_combo_box_get_active ((GtkComboBox*) _tmp10_) == 1) {
			accounttype = ACT_USER_ACCOUNT_TYPE_ADMINISTRATOR;
		}
		_tmp11_ = switchboard_plug_user_accounts_get_permission ();
		_tmp12_ = _tmp11_;
		_tmp13_ = g_permission_get_allowed ((GPermission*) _tmp12_);
		_tmp14_ = _tmp13_;
		_tmp15_ = _tmp14_;
		_g_object_unref0 (_tmp12_);
		if (_tmp15_) {
			{
				ActUser* created_user = NULL;
				ActUserManager* _tmp16_;
				const gchar* _tmp17_;
				const gchar* _tmp18_;
				ActUser* _tmp19_;
				const gchar* _tmp20_;
				ActUser* _tmp23_;
				_tmp16_ = switchboard_plug_user_accounts_get_usermanager ();
				_tmp17_ = username;
				_tmp18_ = fullname;
				_tmp19_ = act_user_manager_create_user (_tmp16_, _tmp17_, _tmp18_, accounttype, &_inner_error0_);
				created_user = _tmp19_;
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					goto __catch0_g_error;
				}
				_tmp20_ = password;
				if (_tmp20_ != NULL) {
					ActUser* _tmp21_;
					const gchar* _tmp22_;
					_tmp21_ = created_user;
					_tmp22_ = password;
					act_user_set_password (_tmp21_, _tmp22_, "");
				}
				_tmp23_ = created_user;
				act_user_set_locked (_tmp23_, FALSE);
				_g_object_unref0 (created_user);
			}
			goto __finally0;
			__catch0_g_error:
			{
				const gchar* _tmp24_;
				g_clear_error (&_inner_error0_);
				_tmp24_ = username;
				g_critical ("NewUserDialog.vala:106: Creation of user '%s' failed", _tmp24_);
			}
			__finally0:
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_free0 (password);
				_g_free0 (username);
				_g_free0 (fullname);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
				g_clear_error (&_inner_error0_);
				return;
			}
		}
		_g_free0 (password);
		_g_free0 (username);
		_g_free0 (fullname);
	}
	gtk_window_destroy ((GtkWindow*) self);
}

static void
__switchboard_plug_user_accounts_new_user_dialog___lambda28__gtk_dialog_response (GtkDialog* _sender,
                                                                                  gint response_id,
                                                                                  gpointer self)
{
	_switchboard_plug_user_accounts_new_user_dialog___lambda28_ (self, response_id);
}

static GObject *
switchboard_plug_user_accounts_new_user_dialog_constructor (GType type,
                                                            guint n_construct_properties,
                                                            GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	SwitchboardPlugUserAccountsNewUserDialog * self;
	Block2Data* _data2_;
	GtkComboBoxText* _tmp0_;
	GtkComboBoxText* _tmp1_;
	GtkComboBoxText* _tmp2_;
	GtkComboBoxText* _tmp3_;
	GraniteHeaderLabel* accounttype_label = NULL;
	GtkComboBoxText* _tmp4_;
	GtkWidget* _tmp5_;
	GraniteHeaderLabel* _tmp6_ = NULL;
	GtkEntry* _tmp7_ = NULL;
	GraniteHeaderLabel* realname_label = NULL;
	GtkEntry* _tmp8_;
	GtkWidget* _tmp9_;
	GraniteHeaderLabel* _tmp10_ = NULL;
	GraniteValidatedEntry* _tmp11_;
	GraniteHeaderLabel* username_label = NULL;
	GraniteValidatedEntry* _tmp12_;
	GtkWidget* _tmp13_;
	GraniteHeaderLabel* _tmp14_ = NULL;
	SwitchboardPlugUserAccountsErrorRevealer* _tmp15_;
	SwitchboardPlugUserAccountsErrorRevealer* _tmp16_;
	GtkLabel* _tmp17_;
	GtkLabel* _tmp18_;
	SwitchboardPlugUserAccountsWidgetsPasswordEditor* _tmp19_;
	GtkBox* form_box = NULL;
	GtkBox* _tmp20_ = NULL;
	GtkBox* _tmp21_;
	GraniteHeaderLabel* _tmp22_;
	GtkBox* _tmp23_;
	GtkComboBoxText* _tmp24_;
	GtkBox* _tmp25_;
	SwitchboardPlugUserAccountsErrorRevealer* _tmp26_;
	SwitchboardPlugUserAccountsErrorRevealer* _tmp27_;
	GtkBox* _tmp28_;
	GraniteHeaderLabel* _tmp29_;
	GtkBox* _tmp30_;
	GtkEntry* _tmp31_;
	GtkBox* _tmp32_;
	SwitchboardPlugUserAccountsErrorRevealer* _tmp33_;
	SwitchboardPlugUserAccountsErrorRevealer* _tmp34_;
	GtkBox* _tmp35_;
	GraniteHeaderLabel* _tmp36_;
	GtkBox* _tmp37_;
	GraniteValidatedEntry* _tmp38_;
	GtkBox* _tmp39_;
	SwitchboardPlugUserAccountsErrorRevealer* _tmp40_;
	GtkBox* _tmp41_;
	SwitchboardPlugUserAccountsWidgetsPasswordEditor* _tmp42_;
	GtkBox* _tmp43_;
	GtkBox* _tmp44_;
	GtkWidget* cancel_button = NULL;
	GtkWidget* _tmp45_;
	GtkWidget* _tmp46_;
	GtkWidget* _tmp47_;
	GtkButton* _tmp48_;
	GtkButton* _tmp49_;
	GtkButton* _tmp50_;
	GtkButton* _tmp51_;
	GtkEntry* _tmp52_;
	GraniteValidatedEntry* _tmp53_;
	SwitchboardPlugUserAccountsWidgetsPasswordEditor* _tmp54_;
	parent_class = G_OBJECT_CLASS (switchboard_plug_user_accounts_new_user_dialog_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SWITCHBOARD_PLUG_USER_ACCOUNTS_TYPE_NEW_USER_DIALOG, SwitchboardPlugUserAccountsNewUserDialog);
	_data2_ = g_slice_new0 (Block2Data);
	_data2_->_ref_count_ = 1;
	_data2_->self = g_object_ref (self);
	_tmp0_ = (GtkComboBoxText*) gtk_combo_box_text_new ();
	g_object_ref_sink (_tmp0_);
	_data2_->accounttype_combobox = _tmp0_;
	_tmp1_ = _data2_->accounttype_combobox;
	gtk_combo_box_text_append_text (_tmp1_, _ ("Standard User"));
	_tmp2_ = _data2_->accounttype_combobox;
	gtk_combo_box_text_append_text (_tmp2_, _ ("Administrator"));
	_tmp3_ = _data2_->accounttype_combobox;
	gtk_combo_box_set_active ((GtkComboBox*) _tmp3_, 0);
	_tmp4_ = _data2_->accounttype_combobox;
	_tmp5_ = _g_object_ref0 ((GtkWidget*) _tmp4_);
	_tmp6_ = granite_header_label_new (_ ("Account Type"));
	granite_header_label_set_mnemonic_widget (_tmp6_, _tmp5_);
	_g_object_unref0 (_tmp5_);
	g_object_ref_sink (_tmp6_);
	accounttype_label = _tmp6_;
	_tmp7_ = (GtkEntry*) gtk_entry_new ();
	gtk_widget_set_hexpand ((GtkWidget*) _tmp7_, TRUE);
	gtk_entry_set_input_purpose (_tmp7_, GTK_INPUT_PURPOSE_NAME);
	g_object_ref_sink (_tmp7_);
	_data2_->realname_entry = _tmp7_;
	_tmp8_ = _data2_->realname_entry;
	_tmp9_ = _g_object_ref0 ((GtkWidget*) _tmp8_);
	_tmp10_ = granite_header_label_new (_ ("Full Name"));
	granite_header_label_set_mnemonic_widget (_tmp10_, _tmp9_);
	_g_object_unref0 (_tmp9_);
	g_object_ref_sink (_tmp10_);
	realname_label = _tmp10_;
	_tmp11_ = granite_validated_entry_new ();
	g_object_ref_sink (_tmp11_);
	_g_object_unref0 (self->priv->username_entry);
	self->priv->username_entry = _tmp11_;
	_tmp12_ = self->priv->username_entry;
	_tmp13_ = _g_object_ref0 ((GtkWidget*) _tmp12_);
	_tmp14_ = granite_header_label_new (_ ("Username"));
	granite_header_label_set_mnemonic_widget (_tmp14_, _tmp13_);
	_g_object_unref0 (_tmp13_);
	g_object_ref_sink (_tmp14_);
	username_label = _tmp14_;
	_tmp15_ = switchboard_plug_user_accounts_error_revealer_new (".");
	g_object_ref_sink (_tmp15_);
	_g_object_unref0 (self->priv->username_error_revealer);
	self->priv->username_error_revealer = _tmp15_;
	_tmp16_ = self->priv->username_error_revealer;
	_tmp17_ = switchboard_plug_user_accounts_error_revealer_get_label_widget (_tmp16_);
	_tmp18_ = _tmp17_;
	gtk_widget_add_css_class ((GtkWidget*) _tmp18_, GRANITE_STYLE_CLASS_ERROR);
	_tmp19_ = switchboard_plug_user_accounts_widgets_password_editor_new (NULL);
	g_object_ref_sink (_tmp19_);
	_g_object_unref0 (self->priv->pw_editor);
	self->priv->pw_editor = _tmp19_;
	_tmp20_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
	gtk_widget_set_valign ((GtkWidget*) _tmp20_, GTK_ALIGN_START);
	gtk_widget_set_vexpand ((GtkWidget*) _tmp20_, TRUE);
	g_object_ref_sink (_tmp20_);
	form_box = _tmp20_;
	_tmp21_ = form_box;
	_tmp22_ = accounttype_label;
	gtk_box_append (_tmp21_, (GtkWidget*) _tmp22_);
	_tmp23_ = form_box;
	_tmp24_ = _data2_->accounttype_combobox;
	gtk_box_append (_tmp23_, (GtkWidget*) _tmp24_);
	_tmp25_ = form_box;
	_tmp26_ = switchboard_plug_user_accounts_error_revealer_new (".");
	g_object_ref_sink (_tmp26_);
	_tmp27_ = _tmp26_;
	gtk_box_append (_tmp25_, (GtkWidget*) _tmp27_);
	_g_object_unref0 (_tmp27_);
	_tmp28_ = form_box;
	_tmp29_ = realname_label;
	gtk_box_append (_tmp28_, (GtkWidget*) _tmp29_);
	_tmp30_ = form_box;
	_tmp31_ = _data2_->realname_entry;
	gtk_box_append (_tmp30_, (GtkWidget*) _tmp31_);
	_tmp32_ = form_box;
	_tmp33_ = switchboard_plug_user_accounts_error_revealer_new (".");
	g_object_ref_sink (_tmp33_);
	_tmp34_ = _tmp33_;
	gtk_box_append (_tmp32_, (GtkWidget*) _tmp34_);
	_g_object_unref0 (_tmp34_);
	_tmp35_ = form_box;
	_tmp36_ = username_label;
	gtk_box_append (_tmp35_, (GtkWidget*) _tmp36_);
	_tmp37_ = form_box;
	_tmp38_ = self->priv->username_entry;
	gtk_box_append (_tmp37_, (GtkWidget*) _tmp38_);
	_tmp39_ = form_box;
	_tmp40_ = self->priv->username_error_revealer;
	gtk_box_append (_tmp39_, (GtkWidget*) _tmp40_);
	_tmp41_ = form_box;
	_tmp42_ = self->priv->pw_editor;
	gtk_box_append (_tmp41_, (GtkWidget*) _tmp42_);
	gtk_window_set_modal ((GtkWindow*) self, TRUE);
	g_object_set ((GtkWindow*) self, "default-width", 350, NULL);
	_tmp43_ = gtk_dialog_get_content_area ((GtkDialog*) self);
	_tmp44_ = form_box;
	gtk_box_append (_tmp43_, (GtkWidget*) _tmp44_);
	_tmp45_ = granite_dialog_add_button ((GraniteDialog*) self, _ ("Cancel"), (gint) GTK_RESPONSE_CANCEL);
	_tmp46_ = _g_object_ref0 (_tmp45_);
	cancel_button = _tmp46_;
	_tmp47_ = granite_dialog_add_button ((GraniteDialog*) self, _ ("Create User"), (gint) GTK_RESPONSE_OK);
	_tmp48_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp47_, gtk_button_get_type (), GtkButton));
	_g_object_unref0 (self->priv->create_button);
	self->priv->create_button = _tmp48_;
	_tmp49_ = self->priv->create_button;
	gtk_widget_set_receives_default ((GtkWidget*) _tmp49_, TRUE);
	_tmp50_ = self->priv->create_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp50_, FALSE);
	_tmp51_ = self->priv->create_button;
	gtk_widget_add_css_class ((GtkWidget*) _tmp51_, GRANITE_STYLE_CLASS_SUGGESTED_ACTION);
	_tmp52_ = _data2_->realname_entry;
	g_signal_connect_data ((GtkEditable*) _tmp52_, "changed", (GCallback) __switchboard_plug_user_accounts_new_user_dialog___lambda25__gtk_editable_changed, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	_tmp53_ = self->priv->username_entry;
	g_signal_connect_object ((GtkEditable*) _tmp53_, "changed", (GCallback) __switchboard_plug_user_accounts_new_user_dialog___lambda26__gtk_editable_changed, self, 0);
	_tmp54_ = self->priv->pw_editor;
	g_signal_connect_object (_tmp54_, "validation-changed", (GCallback) __switchboard_plug_user_accounts_new_user_dialog___lambda27__switchboard_plug_user_accounts_widgets_password_editor_validation_changed, self, 0);
	g_signal_connect_data ((GtkDialog*) self, "response", (GCallback) __switchboard_plug_user_accounts_new_user_dialog___lambda28__gtk_dialog_response, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	_g_object_unref0 (cancel_button);
	_g_object_unref0 (form_box);
	_g_object_unref0 (username_label);
	_g_object_unref0 (realname_label);
	_g_object_unref0 (accounttype_label);
	block2_data_unref (_data2_);
	_data2_ = NULL;
	return obj;
}

static void
switchboard_plug_user_accounts_new_user_dialog_class_init (SwitchboardPlugUserAccountsNewUserDialogClass * klass,
                                                           gpointer klass_data)
{
	switchboard_plug_user_accounts_new_user_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &SwitchboardPlugUserAccountsNewUserDialog_private_offset);
	G_OBJECT_CLASS (klass)->constructor = switchboard_plug_user_accounts_new_user_dialog_constructor;
	G_OBJECT_CLASS (klass)->finalize = switchboard_plug_user_accounts_new_user_dialog_finalize;
}

static void
switchboard_plug_user_accounts_new_user_dialog_instance_init (SwitchboardPlugUserAccountsNewUserDialog * self,
                                                              gpointer klass)
{
	self->priv = switchboard_plug_user_accounts_new_user_dialog_get_instance_private (self);
}

static void
switchboard_plug_user_accounts_new_user_dialog_finalize (GObject * obj)
{
	SwitchboardPlugUserAccountsNewUserDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SWITCHBOARD_PLUG_USER_ACCOUNTS_TYPE_NEW_USER_DIALOG, SwitchboardPlugUserAccountsNewUserDialog);
	_g_object_unref0 (self->priv->username_error_revealer);
	_g_object_unref0 (self->priv->create_button);
	_g_object_unref0 (self->priv->pw_editor);
	_g_object_unref0 (self->priv->username_entry);
	G_OBJECT_CLASS (switchboard_plug_user_accounts_new_user_dialog_parent_class)->finalize (obj);
}

static GType
switchboard_plug_user_accounts_new_user_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SwitchboardPlugUserAccountsNewUserDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) switchboard_plug_user_accounts_new_user_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SwitchboardPlugUserAccountsNewUserDialog), 0, (GInstanceInitFunc) switchboard_plug_user_accounts_new_user_dialog_instance_init, NULL };
	GType switchboard_plug_user_accounts_new_user_dialog_type_id;
	switchboard_plug_user_accounts_new_user_dialog_type_id = g_type_register_static (GRANITE_TYPE_DIALOG, "SwitchboardPlugUserAccountsNewUserDialog", &g_define_type_info, 0);
	SwitchboardPlugUserAccountsNewUserDialog_private_offset = g_type_add_instance_private (switchboard_plug_user_accounts_new_user_dialog_type_id, sizeof (SwitchboardPlugUserAccountsNewUserDialogPrivate));
	return switchboard_plug_user_accounts_new_user_dialog_type_id;
}

GType
switchboard_plug_user_accounts_new_user_dialog_get_type (void)
{
	static volatile gsize switchboard_plug_user_accounts_new_user_dialog_type_id__once = 0;
	if (g_once_init_enter (&switchboard_plug_user_accounts_new_user_dialog_type_id__once)) {
		GType switchboard_plug_user_accounts_new_user_dialog_type_id;
		switchboard_plug_user_accounts_new_user_dialog_type_id = switchboard_plug_user_accounts_new_user_dialog_get_type_once ();
		g_once_init_leave (&switchboard_plug_user_accounts_new_user_dialog_type_id__once, switchboard_plug_user_accounts_new_user_dialog_type_id);
	}
	return switchboard_plug_user_accounts_new_user_dialog_type_id__once;
}

