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

/*
 * Copyright 2018–2021 elementary, Inc. (https://elementary.io)
 *
 * 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 the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA.
 *
 * Authors: Corentin Noël <corentin@elementary.io>
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gdk/gdk.h>

#define GREETER_BASE_CARD_ERROR_SHAKE_DURATION 450
#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 GREETER_TYPE_BASE_CARD (greeter_base_card_get_type ())
#define GREETER_BASE_CARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GREETER_TYPE_BASE_CARD, GreeterBaseCard))
#define GREETER_BASE_CARD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GREETER_TYPE_BASE_CARD, GreeterBaseCardClass))
#define GREETER_IS_BASE_CARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GREETER_TYPE_BASE_CARD))
#define GREETER_IS_BASE_CARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GREETER_TYPE_BASE_CARD))
#define GREETER_BASE_CARD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GREETER_TYPE_BASE_CARD, GreeterBaseCardClass))

typedef struct _GreeterBaseCard GreeterBaseCard;
typedef struct _GreeterBaseCardClass GreeterBaseCardClass;
typedef struct _GreeterBaseCardPrivate GreeterBaseCardPrivate;
enum  {
	GREETER_BASE_CARD_0_PROPERTY,
	GREETER_BASE_CARD_CONNECTING_PROPERTY,
	GREETER_BASE_CARD_NEED_PASSWORD_PROPERTY,
	GREETER_BASE_CARD_USE_FINGERPRINT_PROPERTY,
	GREETER_BASE_CARD_NUM_PROPERTIES
};
static GParamSpec* greeter_base_card_properties[GREETER_BASE_CARD_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	GREETER_BASE_CARD_DO_CONNECT_SIGNAL,
	GREETER_BASE_CARD_NUM_SIGNALS
};
static guint greeter_base_card_signals[GREETER_BASE_CARD_NUM_SIGNALS] = {0};

struct _GreeterBaseCard {
	GtkRevealer parent_instance;
	GreeterBaseCardPrivate * priv;
};

struct _GreeterBaseCardClass {
	GtkRevealerClass parent_class;
	void (*wrong_credentials) (GreeterBaseCard* self);
};

struct _GreeterBaseCardPrivate {
	gboolean _connecting;
	gboolean _need_password;
	gboolean _use_fingerprint;
};

static gint GreeterBaseCard_private_offset;
static gpointer greeter_base_card_parent_class = NULL;
VALA_EXTERN GtkCssProvider* greeter_base_card_css_provider;
GtkCssProvider* greeter_base_card_css_provider = NULL;

VALA_EXTERN GType greeter_base_card_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GreeterBaseCard, g_object_unref)
VALA_EXTERN void greeter_base_card_wrong_credentials (GreeterBaseCard* self);
static void greeter_base_card_real_wrong_credentials (GreeterBaseCard* self);
VALA_EXTERN GreeterBaseCard* greeter_base_card_construct (GType object_type);
VALA_EXTERN gboolean greeter_base_card_get_connecting (GreeterBaseCard* self);
VALA_EXTERN void greeter_base_card_set_connecting (GreeterBaseCard* self,
                                       gboolean value);
VALA_EXTERN gboolean greeter_base_card_get_need_password (GreeterBaseCard* self);
VALA_EXTERN void greeter_base_card_set_need_password (GreeterBaseCard* self,
                                          gboolean value);
VALA_EXTERN gboolean greeter_base_card_get_use_fingerprint (GreeterBaseCard* self);
VALA_EXTERN void greeter_base_card_set_use_fingerprint (GreeterBaseCard* self,
                                            gboolean value);
static GObject * greeter_base_card_constructor (GType type,
                                         guint n_construct_properties,
                                         GObjectConstructParam * construct_properties);
static void _greeter_base_card___lambda7_ (GreeterBaseCard* self);
static void __greeter_base_card___lambda7__g_object_notify (GObject* _sender,
                                                     GParamSpec* pspec,
                                                     gpointer self);
static void _greeter_base_card___lambda8_ (GreeterBaseCard* self);
static void __greeter_base_card___lambda8__g_object_notify (GObject* _sender,
                                                     GParamSpec* pspec,
                                                     gpointer self);
static void greeter_base_card_finalize (GObject * obj);
static GType greeter_base_card_get_type_once (void);
static void _vala_greeter_base_card_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec);
static void _vala_greeter_base_card_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec);

static inline gpointer
greeter_base_card_get_instance_private (GreeterBaseCard* self)
{
	return G_STRUCT_MEMBER_P (self, GreeterBaseCard_private_offset);
}

static void
greeter_base_card_real_wrong_credentials (GreeterBaseCard* self)
{
}

void
greeter_base_card_wrong_credentials (GreeterBaseCard* self)
{
	GreeterBaseCardClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = GREETER_BASE_CARD_GET_CLASS (self);
	if (_klass_->wrong_credentials) {
		_klass_->wrong_credentials (self);
	}
}

GreeterBaseCard*
greeter_base_card_construct (GType object_type)
{
	GreeterBaseCard * self = NULL;
	self = (GreeterBaseCard*) g_object_new (object_type, NULL);
	return self;
}

gboolean
greeter_base_card_get_connecting (GreeterBaseCard* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_connecting;
	return result;
}

void
greeter_base_card_set_connecting (GreeterBaseCard* self,
                                  gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = greeter_base_card_get_connecting (self);
	if (old_value != value) {
		self->priv->_connecting = value;
		g_object_notify_by_pspec ((GObject *) self, greeter_base_card_properties[GREETER_BASE_CARD_CONNECTING_PROPERTY]);
	}
}

gboolean
greeter_base_card_get_need_password (GreeterBaseCard* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_need_password;
	return result;
}

void
greeter_base_card_set_need_password (GreeterBaseCard* self,
                                     gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = greeter_base_card_get_need_password (self);
	if (old_value != value) {
		self->priv->_need_password = value;
		g_object_notify_by_pspec ((GObject *) self, greeter_base_card_properties[GREETER_BASE_CARD_NEED_PASSWORD_PROPERTY]);
	}
}

gboolean
greeter_base_card_get_use_fingerprint (GreeterBaseCard* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_use_fingerprint;
	return result;
}

void
greeter_base_card_set_use_fingerprint (GreeterBaseCard* self,
                                       gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = greeter_base_card_get_use_fingerprint (self);
	if (old_value != value) {
		self->priv->_use_fingerprint = value;
		g_object_notify_by_pspec ((GObject *) self, greeter_base_card_properties[GREETER_BASE_CARD_USE_FINGERPRINT_PROPERTY]);
	}
}

static void
_greeter_base_card___lambda7_ (GreeterBaseCard* self)
{
	gboolean _tmp0_;
	gboolean _tmp1_;
	_tmp0_ = gtk_revealer_get_child_revealed ((GtkRevealer*) self);
	_tmp1_ = _tmp0_;
	if (!_tmp1_) {
		gtk_widget_set_visible ((GtkWidget*) self, FALSE);
	}
}

static void
__greeter_base_card___lambda7__g_object_notify (GObject* _sender,
                                                GParamSpec* pspec,
                                                gpointer self)
{
	_greeter_base_card___lambda7_ ((GreeterBaseCard*) self);
}

static void
_greeter_base_card___lambda8_ (GreeterBaseCard* self)
{
	gboolean _tmp0_;
	gboolean _tmp1_;
	_tmp0_ = gtk_revealer_get_reveal_child ((GtkRevealer*) self);
	_tmp1_ = _tmp0_;
	if (_tmp1_) {
		gtk_widget_set_visible ((GtkWidget*) self, TRUE);
	}
}

static void
__greeter_base_card___lambda8__g_object_notify (GObject* _sender,
                                                GParamSpec* pspec,
                                                gpointer self)
{
	_greeter_base_card___lambda8_ ((GreeterBaseCard*) self);
}

static GObject *
greeter_base_card_constructor (GType type,
                               guint n_construct_properties,
                               GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GreeterBaseCard * self;
	GdkEventMask _tmp0_;
	GdkEventMask _tmp1_;
	parent_class = G_OBJECT_CLASS (greeter_base_card_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GREETER_TYPE_BASE_CARD, GreeterBaseCard);
	g_object_set ((GtkWidget*) self, "width-request", 350, NULL);
	gtk_revealer_set_reveal_child ((GtkRevealer*) self, TRUE);
	gtk_revealer_set_transition_type ((GtkRevealer*) self, GTK_REVEALER_TRANSITION_TYPE_CROSSFADE);
	gtk_widget_set_halign ((GtkWidget*) self, GTK_ALIGN_CENTER);
	gtk_widget_set_valign ((GtkWidget*) self, GTK_ALIGN_CENTER);
	_tmp0_ = gtk_widget_get_events ((GtkWidget*) self);
	_tmp1_ = _tmp0_;
	gtk_widget_set_events ((GtkWidget*) self, _tmp1_ | GDK_BUTTON_RELEASE_MASK);
	g_signal_connect_object ((GObject*) self, "notify::child-revealed", (GCallback) __greeter_base_card___lambda7__g_object_notify, self, 0);
	g_signal_connect_object ((GObject*) self, "notify::reveal-child", (GCallback) __greeter_base_card___lambda8__g_object_notify, self, 0);
	return obj;
}

static void
greeter_base_card_class_init (GreeterBaseCardClass * klass,
                              gpointer klass_data)
{
	GtkCssProvider* _tmp0_;
	GtkCssProvider* _tmp1_;
	greeter_base_card_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GreeterBaseCard_private_offset);
	((GreeterBaseCardClass *) klass)->wrong_credentials = (void (*) (GreeterBaseCard*)) greeter_base_card_real_wrong_credentials;
	G_OBJECT_CLASS (klass)->get_property = _vala_greeter_base_card_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_greeter_base_card_set_property;
	G_OBJECT_CLASS (klass)->constructor = greeter_base_card_constructor;
	G_OBJECT_CLASS (klass)->finalize = greeter_base_card_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GREETER_BASE_CARD_CONNECTING_PROPERTY, greeter_base_card_properties[GREETER_BASE_CARD_CONNECTING_PROPERTY] = g_param_spec_boolean ("connecting", "connecting", "connecting", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GREETER_BASE_CARD_NEED_PASSWORD_PROPERTY, greeter_base_card_properties[GREETER_BASE_CARD_NEED_PASSWORD_PROPERTY] = g_param_spec_boolean ("need-password", "need-password", "need-password", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GREETER_BASE_CARD_USE_FINGERPRINT_PROPERTY, greeter_base_card_properties[GREETER_BASE_CARD_USE_FINGERPRINT_PROPERTY] = g_param_spec_boolean ("use-fingerprint", "use-fingerprint", "use-fingerprint", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	greeter_base_card_signals[GREETER_BASE_CARD_DO_CONNECT_SIGNAL] = g_signal_new ("do-connect", GREETER_TYPE_BASE_CARD, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
	_tmp0_ = gtk_css_provider_new ();
	_g_object_unref0 (greeter_base_card_css_provider);
	greeter_base_card_css_provider = _tmp0_;
	_tmp1_ = greeter_base_card_css_provider;
	gtk_css_provider_load_from_resource (_tmp1_, "/io/elementary/greeter/Card.css");
}

static void
greeter_base_card_instance_init (GreeterBaseCard * self,
                                 gpointer klass)
{
	self->priv = greeter_base_card_get_instance_private (self);
	self->priv->_connecting = FALSE;
	self->priv->_need_password = FALSE;
	self->priv->_use_fingerprint = FALSE;
}

static void
greeter_base_card_finalize (GObject * obj)
{
	GreeterBaseCard * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GREETER_TYPE_BASE_CARD, GreeterBaseCard);
	G_OBJECT_CLASS (greeter_base_card_parent_class)->finalize (obj);
}

static GType
greeter_base_card_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GreeterBaseCardClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) greeter_base_card_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GreeterBaseCard), 0, (GInstanceInitFunc) greeter_base_card_instance_init, NULL };
	GType greeter_base_card_type_id;
	greeter_base_card_type_id = g_type_register_static (gtk_revealer_get_type (), "GreeterBaseCard", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	GreeterBaseCard_private_offset = g_type_add_instance_private (greeter_base_card_type_id, sizeof (GreeterBaseCardPrivate));
	return greeter_base_card_type_id;
}

GType
greeter_base_card_get_type (void)
{
	static volatile gsize greeter_base_card_type_id__once = 0;
	if (g_once_init_enter (&greeter_base_card_type_id__once)) {
		GType greeter_base_card_type_id;
		greeter_base_card_type_id = greeter_base_card_get_type_once ();
		g_once_init_leave (&greeter_base_card_type_id__once, greeter_base_card_type_id);
	}
	return greeter_base_card_type_id__once;
}

static void
_vala_greeter_base_card_get_property (GObject * object,
                                      guint property_id,
                                      GValue * value,
                                      GParamSpec * pspec)
{
	GreeterBaseCard * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GREETER_TYPE_BASE_CARD, GreeterBaseCard);
	switch (property_id) {
		case GREETER_BASE_CARD_CONNECTING_PROPERTY:
		g_value_set_boolean (value, greeter_base_card_get_connecting (self));
		break;
		case GREETER_BASE_CARD_NEED_PASSWORD_PROPERTY:
		g_value_set_boolean (value, greeter_base_card_get_need_password (self));
		break;
		case GREETER_BASE_CARD_USE_FINGERPRINT_PROPERTY:
		g_value_set_boolean (value, greeter_base_card_get_use_fingerprint (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_greeter_base_card_set_property (GObject * object,
                                      guint property_id,
                                      const GValue * value,
                                      GParamSpec * pspec)
{
	GreeterBaseCard * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GREETER_TYPE_BASE_CARD, GreeterBaseCard);
	switch (property_id) {
		case GREETER_BASE_CARD_CONNECTING_PROPERTY:
		greeter_base_card_set_connecting (self, g_value_get_boolean (value));
		break;
		case GREETER_BASE_CARD_NEED_PASSWORD_PROPERTY:
		greeter_base_card_set_need_password (self, g_value_get_boolean (value));
		break;
		case GREETER_BASE_CARD_USE_FINGERPRINT_PROPERTY:
		greeter_base_card_set_use_fingerprint (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

