/* FormView.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from FormView.vala, do not modify */

/*
 * Copyright 2020-2021 elementary, Inc. (https://elementary.io)
 * SPDX-License-Identifier: LGPL-3.0-or-later
 */

#include "granite-7.h"
#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define TYPE_DEMO_PAGE (demo_page_get_type ())
#define DEMO_PAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DEMO_PAGE, DemoPage))
#define DEMO_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DEMO_PAGE, DemoPageClass))
#define IS_DEMO_PAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DEMO_PAGE))
#define IS_DEMO_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DEMO_PAGE))
#define DEMO_PAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DEMO_PAGE, DemoPageClass))

typedef struct _DemoPage DemoPage;
typedef struct _DemoPageClass DemoPageClass;
typedef struct _DemoPagePrivate DemoPagePrivate;

#define TYPE_FORM_VIEW (form_view_get_type ())
#define FORM_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FORM_VIEW, FormView))
#define FORM_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FORM_VIEW, FormViewClass))
#define IS_FORM_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FORM_VIEW))
#define IS_FORM_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FORM_VIEW))
#define FORM_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FORM_VIEW, FormViewClass))

typedef struct _FormView FormView;
typedef struct _FormViewClass FormViewClass;
typedef struct _FormViewPrivate FormViewPrivate;
enum  {
	FORM_VIEW_0_PROPERTY,
	FORM_VIEW_NUM_PROPERTIES
};
static GParamSpec* form_view_properties[FORM_VIEW_NUM_PROPERTIES];
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _DemoPage {
	GraniteToolBox parent_instance;
	DemoPagePrivate * priv;
};

struct _DemoPageClass {
	GraniteToolBoxClass parent_class;
};

struct _FormView {
	DemoPage parent_instance;
	FormViewPrivate * priv;
};

struct _FormViewClass {
	DemoPageClass parent_class;
};

static gpointer form_view_parent_class = NULL;

VALA_EXTERN GType demo_page_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DemoPage, g_object_unref)
VALA_EXTERN GType form_view_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FormView, g_object_unref)
VALA_EXTERN FormView* form_view_new (void);
VALA_EXTERN FormView* form_view_construct (GType object_type);
VALA_EXTERN DemoPage* demo_page_new (void);
VALA_EXTERN DemoPage* demo_page_construct (GType object_type);
static GObject * form_view_constructor (GType type,
                                 guint n_construct_properties,
                                 GObjectConstructParam * construct_properties);
VALA_EXTERN void demo_page_set_child (DemoPage* self,
                          GtkWidget* value);
static GType form_view_get_type_once (void);

FormView*
form_view_construct (GType object_type)
{
	FormView * self = NULL;
	self = (FormView*) demo_page_construct (object_type);
	return self;
}

FormView*
form_view_new (void)
{
	return form_view_construct (TYPE_FORM_VIEW);
}

static gpointer
_g_regex_ref0 (gpointer self)
{
	return self ? g_regex_ref (self) : NULL;
}

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

static GObject *
form_view_constructor (GType type,
                       guint n_construct_properties,
                       GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	FormView * self;
	GRegex* username_regex = NULL;
	GraniteValidatedEntry* username_entry = NULL;
	GRegex* _tmp5_;
	GRegex* _tmp6_;
	GraniteValidatedEntry* _tmp7_ = NULL;
	GraniteHeaderLabel* username_label = NULL;
	GraniteValidatedEntry* _tmp8_;
	GtkWidget* _tmp9_;
	gchar* _tmp10_;
	GraniteHeaderLabel* _tmp11_ = NULL;
	GtkButton* button = NULL;
	GtkButton* _tmp12_;
	gint _tmp13_ = 0;
	GraniteBox* box = NULL;
	GraniteBox* _tmp14_ = NULL;
	GraniteBox* _tmp15_;
	GraniteHeaderLabel* _tmp16_;
	GraniteBox* _tmp17_;
	GraniteValidatedEntry* _tmp18_;
	GraniteBox* _tmp19_;
	GtkButton* _tmp20_;
	GraniteBox* _tmp21_;
	GraniteValidatedEntry* _tmp22_;
	GtkButton* _tmp23_;
	GError* _inner_error0_ = NULL;
	parent_class = G_OBJECT_CLASS (form_view_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_FORM_VIEW, FormView);
	username_regex = NULL;
	{
		GRegex* _tmp0_ = NULL;
		GRegex* _tmp1_;
		GRegex* _tmp2_;
		_tmp1_ = g_regex_new ("^[a-z]+[a-z0-9]*$", 0, 0, &_inner_error0_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp2_ = _tmp0_;
		_tmp0_ = NULL;
		_g_regex_unref0 (username_regex);
		username_regex = _tmp2_;
		_g_regex_unref0 (_tmp0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp3_;
		const gchar* _tmp4_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp3_ = e;
		_tmp4_ = _tmp3_->message;
		g_critical ("FormView.vala:12: %s", _tmp4_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_regex_unref0 (username_regex);
		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_);
	}
	_tmp5_ = username_regex;
	_tmp6_ = _g_regex_ref0 (_tmp5_);
	_tmp7_ = granite_validated_entry_new ();
	granite_validated_entry_set_min_length (_tmp7_, 8);
	granite_validated_entry_set_regex (_tmp7_, _tmp6_);
	_g_regex_unref0 (_tmp6_);
	g_object_ref_sink (_tmp7_);
	username_entry = _tmp7_;
	_tmp8_ = username_entry;
	_tmp9_ = _g_object_ref0 ((GtkWidget*) _tmp8_);
	_tmp10_ = g_strdup ("Must be at least 8 characters long");
	_tmp11_ = granite_header_label_new ("Username");
	granite_header_label_set_mnemonic_widget (_tmp11_, _tmp9_);
	_g_object_unref0 (_tmp9_);
	granite_header_label_set_secondary_text (_tmp11_, _tmp10_);
	_g_free0 (_tmp10_);
	g_object_ref_sink (_tmp11_);
	username_label = _tmp11_;
	_tmp12_ = (GtkButton*) gtk_button_new_with_label ("Submit");
	g_object_ref_sink (_tmp12_);
	button = _tmp12_;
	_tmp13_ = 12;
	_tmp14_ = granite_box_new (GTK_ORIENTATION_VERTICAL, GRANITE_BOX_SPACING_SINGLE);
	gtk_widget_set_halign ((GtkWidget*) _tmp14_, GTK_ALIGN_CENTER);
	gtk_widget_set_valign ((GtkWidget*) _tmp14_, GTK_ALIGN_CENTER);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp14_, _tmp13_);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp14_, _tmp13_);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp14_, _tmp13_);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp14_, _tmp13_);
	g_object_ref_sink (_tmp14_);
	box = _tmp14_;
	_tmp15_ = box;
	_tmp16_ = username_label;
	gtk_box_append ((GtkBox*) _tmp15_, (GtkWidget*) _tmp16_);
	_tmp17_ = box;
	_tmp18_ = username_entry;
	gtk_box_append ((GtkBox*) _tmp17_, (GtkWidget*) _tmp18_);
	_tmp19_ = box;
	_tmp20_ = button;
	gtk_box_append ((GtkBox*) _tmp19_, (GtkWidget*) _tmp20_);
	_tmp21_ = box;
	demo_page_set_child ((DemoPage*) self, (GtkWidget*) _tmp21_);
	_tmp22_ = username_entry;
	_tmp23_ = button;
	g_object_bind_property_with_closures ((GObject*) _tmp22_, "is-valid", (GObject*) _tmp23_, "sensitive", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_g_object_unref0 (box);
	_g_object_unref0 (button);
	_g_object_unref0 (username_label);
	_g_object_unref0 (username_entry);
	_g_regex_unref0 (username_regex);
	return obj;
}

static void
form_view_class_init (FormViewClass * klass,
                      gpointer klass_data)
{
	form_view_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->constructor = form_view_constructor;
}

static void
form_view_instance_init (FormView * self,
                         gpointer klass)
{
}

static GType
form_view_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FormViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) form_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FormView), 0, (GInstanceInitFunc) form_view_instance_init, NULL };
	GType form_view_type_id;
	form_view_type_id = g_type_register_static (TYPE_DEMO_PAGE, "FormView", &g_define_type_info, 0);
	return form_view_type_id;
}

GType
form_view_get_type (void)
{
	static volatile gsize form_view_type_id__once = 0;
	if (g_once_init_enter (&form_view_type_id__once)) {
		GType form_view_type_id;
		form_view_type_id = form_view_get_type_once ();
		g_once_init_leave (&form_view_type_id__once, form_view_type_id);
	}
	return form_view_type_id__once;
}

