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

/* This file is part of GNOME Games. License: GPL-3.0+.*/

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include "gnome-games.h"

#define GAMES_UNDO_NOTIFICATION_NOTIFICATION_TIMEOUT_SEC ((guint) 3)
#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 GAMES_TYPE_UNDO_NOTIFICATION (games_undo_notification_get_type ())
#define GAMES_UNDO_NOTIFICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_UNDO_NOTIFICATION, GamesUndoNotification))
#define GAMES_UNDO_NOTIFICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_UNDO_NOTIFICATION, GamesUndoNotificationClass))
#define GAMES_IS_UNDO_NOTIFICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_UNDO_NOTIFICATION))
#define GAMES_IS_UNDO_NOTIFICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_UNDO_NOTIFICATION))
#define GAMES_UNDO_NOTIFICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_UNDO_NOTIFICATION, GamesUndoNotificationClass))

typedef struct _GamesUndoNotification GamesUndoNotification;
typedef struct _GamesUndoNotificationClass GamesUndoNotificationClass;
typedef struct _GamesUndoNotificationPrivate GamesUndoNotificationPrivate;
enum  {
	GAMES_UNDO_NOTIFICATION_0_PROPERTY,
	GAMES_UNDO_NOTIFICATION_REVEAL_PROPERTY,
	GAMES_UNDO_NOTIFICATION_LABEL_PROPERTY,
	GAMES_UNDO_NOTIFICATION_NUM_PROPERTIES
};
static GParamSpec* games_undo_notification_properties[GAMES_UNDO_NOTIFICATION_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))
enum  {
	GAMES_UNDO_NOTIFICATION_UNDO_SIGNAL,
	GAMES_UNDO_NOTIFICATION_CLOSED_SIGNAL,
	GAMES_UNDO_NOTIFICATION_NUM_SIGNALS
};
static guint games_undo_notification_signals[GAMES_UNDO_NOTIFICATION_NUM_SIGNALS] = {0};

struct _GamesUndoNotification {
	GtkEventBox parent_instance;
	GamesUndoNotificationPrivate * priv;
};

struct _GamesUndoNotificationClass {
	GtkEventBoxClass parent_class;
};

struct _GamesUndoNotificationPrivate {
	guint timeout_id;
	GtkEventControllerMotion* motion_controller;
	gboolean _reveal;
	gchar* _label;
};

static gint GamesUndoNotification_private_offset;
static gpointer games_undo_notification_parent_class = NULL;

VALA_EXTERN GType games_undo_notification_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void games_undo_notification_show_notification (GamesUndoNotification* self);
VALA_EXTERN void games_undo_notification_set_reveal (GamesUndoNotification* self,
                                         gboolean value);
static void games_undo_notification_remove_current_timeout_if_exists (GamesUndoNotification* self);
static void games_undo_notification_set_new_timeout (GamesUndoNotification* self);
static gboolean __lambda49_ (GamesUndoNotification* self);
static gboolean ___lambda49__gsource_func (gpointer self);
static void games_undo_notification_on_undo_button_clicked (GamesUndoNotification* self);
static void _games_undo_notification_on_undo_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                         gpointer self);
static void games_undo_notification_on_notification_closed (GamesUndoNotification* self);
static void _games_undo_notification_on_notification_closed_gtk_button_clicked (GtkButton* _sender,
                                                                         gpointer self);
VALA_EXTERN GamesUndoNotification* games_undo_notification_new (void);
VALA_EXTERN GamesUndoNotification* games_undo_notification_construct (GType object_type);
VALA_EXTERN gboolean games_undo_notification_get_reveal (GamesUndoNotification* self);
VALA_EXTERN const gchar* games_undo_notification_get_label (GamesUndoNotification* self);
VALA_EXTERN void games_undo_notification_set_label (GamesUndoNotification* self,
                                        const gchar* value);
static GObject * games_undo_notification_constructor (GType type,
                                               guint n_construct_properties,
                                               GObjectConstructParam * construct_properties);
static void _games_undo_notification___lambda50_ (GamesUndoNotification* self);
static void __games_undo_notification___lambda50__gtk_event_controller_motion_enter (GtkEventControllerMotion* _sender,
                                                                              gdouble x,
                                                                              gdouble y,
                                                                              gpointer self);
static void _games_undo_notification___lambda51_ (GamesUndoNotification* self);
static void __games_undo_notification___lambda51__gtk_event_controller_motion_leave (GtkEventControllerMotion* _sender,
                                                                              gpointer self);
static void games_undo_notification_finalize (GObject * obj);
static GType games_undo_notification_get_type_once (void);
static void _vala_games_undo_notification_get_property (GObject * object,
                                                 guint property_id,
                                                 GValue * value,
                                                 GParamSpec * pspec);
static void _vala_games_undo_notification_set_property (GObject * object,
                                                 guint property_id,
                                                 const GValue * value,
                                                 GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
games_undo_notification_get_instance_private (GamesUndoNotification* self)
{
	return G_STRUCT_MEMBER_P (self, GamesUndoNotification_private_offset);
}

void
games_undo_notification_show_notification (GamesUndoNotification* self)
{
	g_return_if_fail (self != NULL);
	games_undo_notification_set_reveal (self, TRUE);
	games_undo_notification_remove_current_timeout_if_exists (self);
	games_undo_notification_set_new_timeout (self);
}

static gboolean
__lambda49_ (GamesUndoNotification* self)
{
	gboolean result;
	self->priv->timeout_id = (guint) 0;
	games_undo_notification_set_reveal (self, FALSE);
	g_signal_emit (self, games_undo_notification_signals[GAMES_UNDO_NOTIFICATION_CLOSED_SIGNAL], 0);
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
___lambda49__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda49_ ((GamesUndoNotification*) self);
	return result;
}

static void
games_undo_notification_set_new_timeout (GamesUndoNotification* self)
{
	g_return_if_fail (self != NULL);
	self->priv->timeout_id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, GAMES_UNDO_NOTIFICATION_NOTIFICATION_TIMEOUT_SEC, ___lambda49__gsource_func, g_object_ref (self), g_object_unref);
}

static void
games_undo_notification_remove_current_timeout_if_exists (GamesUndoNotification* self)
{
	g_return_if_fail (self != NULL);
	if (self->priv->timeout_id != ((guint) 0)) {
		g_source_remove (self->priv->timeout_id);
		self->priv->timeout_id = (guint) 0;
	}
}

static void
games_undo_notification_on_undo_button_clicked (GamesUndoNotification* self)
{
	g_return_if_fail (self != NULL);
	games_undo_notification_remove_current_timeout_if_exists (self);
	games_undo_notification_set_reveal (self, FALSE);
	g_signal_emit (self, games_undo_notification_signals[GAMES_UNDO_NOTIFICATION_UNDO_SIGNAL], 0);
}

static void
_games_undo_notification_on_undo_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                    gpointer self)
{
	games_undo_notification_on_undo_button_clicked ((GamesUndoNotification*) self);
}

static void
games_undo_notification_on_notification_closed (GamesUndoNotification* self)
{
	g_return_if_fail (self != NULL);
	games_undo_notification_remove_current_timeout_if_exists (self);
	games_undo_notification_set_reveal (self, FALSE);
	g_signal_emit (self, games_undo_notification_signals[GAMES_UNDO_NOTIFICATION_CLOSED_SIGNAL], 0);
}

static void
_games_undo_notification_on_notification_closed_gtk_button_clicked (GtkButton* _sender,
                                                                    gpointer self)
{
	games_undo_notification_on_notification_closed ((GamesUndoNotification*) self);
}

GamesUndoNotification*
games_undo_notification_construct (GType object_type)
{
	GamesUndoNotification * self = NULL;
	self = (GamesUndoNotification*) g_object_new (object_type, NULL);
	return self;
}

GamesUndoNotification*
games_undo_notification_new (void)
{
	return games_undo_notification_construct (GAMES_TYPE_UNDO_NOTIFICATION);
}

gboolean
games_undo_notification_get_reveal (GamesUndoNotification* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_reveal;
	return result;
}

void
games_undo_notification_set_reveal (GamesUndoNotification* self,
                                    gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = games_undo_notification_get_reveal (self);
	if (old_value != value) {
		self->priv->_reveal = value;
		g_object_notify_by_pspec ((GObject *) self, games_undo_notification_properties[GAMES_UNDO_NOTIFICATION_REVEAL_PROPERTY]);
	}
}

const gchar*
games_undo_notification_get_label (GamesUndoNotification* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_label;
	result = _tmp0_;
	return result;
}

void
games_undo_notification_set_label (GamesUndoNotification* self,
                                   const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = games_undo_notification_get_label (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_label);
		self->priv->_label = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, games_undo_notification_properties[GAMES_UNDO_NOTIFICATION_LABEL_PROPERTY]);
	}
}

static void
_games_undo_notification___lambda50_ (GamesUndoNotification* self)
{
	games_undo_notification_remove_current_timeout_if_exists (self);
}

static void
__games_undo_notification___lambda50__gtk_event_controller_motion_enter (GtkEventControllerMotion* _sender,
                                                                         gdouble x,
                                                                         gdouble y,
                                                                         gpointer self)
{
	_games_undo_notification___lambda50_ ((GamesUndoNotification*) self);
}

static void
_games_undo_notification___lambda51_ (GamesUndoNotification* self)
{
	games_undo_notification_set_new_timeout (self);
}

static void
__games_undo_notification___lambda51__gtk_event_controller_motion_leave (GtkEventControllerMotion* _sender,
                                                                         gpointer self)
{
	_games_undo_notification___lambda51_ ((GamesUndoNotification*) self);
}

static GObject *
games_undo_notification_constructor (GType type,
                                     guint n_construct_properties,
                                     GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GamesUndoNotification * self;
	GtkEventControllerMotion* _tmp0_;
	GtkEventControllerMotion* _tmp1_;
	GtkEventControllerMotion* _tmp2_;
	GtkEventControllerMotion* _tmp3_;
	parent_class = G_OBJECT_CLASS (games_undo_notification_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_UNDO_NOTIFICATION, GamesUndoNotification);
	_tmp0_ = (GtkEventControllerMotion*) gtk_event_controller_motion_new ((GtkWidget*) self);
	_g_object_unref0 (self->priv->motion_controller);
	self->priv->motion_controller = _tmp0_;
	_tmp1_ = self->priv->motion_controller;
	gtk_event_controller_set_propagation_phase ((GtkEventController*) _tmp1_, GTK_PHASE_TARGET);
	_tmp2_ = self->priv->motion_controller;
	g_signal_connect_object (_tmp2_, "enter", (GCallback) __games_undo_notification___lambda50__gtk_event_controller_motion_enter, self, 0);
	_tmp3_ = self->priv->motion_controller;
	g_signal_connect_object (_tmp3_, "leave", (GCallback) __games_undo_notification___lambda51__gtk_event_controller_motion_leave, self, 0);
	return obj;
}

static void
games_undo_notification_class_init (GamesUndoNotificationClass * klass,
                                    gpointer klass_data)
{
	games_undo_notification_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GamesUndoNotification_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_games_undo_notification_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_games_undo_notification_set_property;
	G_OBJECT_CLASS (klass)->constructor = games_undo_notification_constructor;
	G_OBJECT_CLASS (klass)->finalize = games_undo_notification_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_UNDO_NOTIFICATION_REVEAL_PROPERTY, games_undo_notification_properties[GAMES_UNDO_NOTIFICATION_REVEAL_PROPERTY] = g_param_spec_boolean ("reveal", "reveal", "reveal", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_UNDO_NOTIFICATION_LABEL_PROPERTY, games_undo_notification_properties[GAMES_UNDO_NOTIFICATION_LABEL_PROPERTY] = g_param_spec_string ("label", "label", "label", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Games/ui/undo-notification.ui");
	games_undo_notification_signals[GAMES_UNDO_NOTIFICATION_UNDO_SIGNAL] = g_signal_new ("undo", GAMES_TYPE_UNDO_NOTIFICATION, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	games_undo_notification_signals[GAMES_UNDO_NOTIFICATION_CLOSED_SIGNAL] = g_signal_new ("closed", GAMES_TYPE_UNDO_NOTIFICATION, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_undo_button_clicked", G_CALLBACK(_games_undo_notification_on_undo_button_clicked_gtk_button_clicked));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_notification_closed", G_CALLBACK(_games_undo_notification_on_notification_closed_gtk_button_clicked));
}

static void
games_undo_notification_instance_init (GamesUndoNotification * self,
                                       gpointer klass)
{
	self->priv = games_undo_notification_get_instance_private (self);
	self->priv->timeout_id = (guint) 0;
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
games_undo_notification_finalize (GObject * obj)
{
	GamesUndoNotification * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_UNDO_NOTIFICATION, GamesUndoNotification);
	_g_object_unref0 (self->priv->motion_controller);
	_g_free0 (self->priv->_label);
	G_OBJECT_CLASS (games_undo_notification_parent_class)->finalize (obj);
}

static GType
games_undo_notification_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GamesUndoNotificationClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_undo_notification_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesUndoNotification), 0, (GInstanceInitFunc) games_undo_notification_instance_init, NULL };
	GType games_undo_notification_type_id;
	games_undo_notification_type_id = g_type_register_static (gtk_event_box_get_type (), "GamesUndoNotification", &g_define_type_info, 0);
	GamesUndoNotification_private_offset = g_type_add_instance_private (games_undo_notification_type_id, sizeof (GamesUndoNotificationPrivate));
	return games_undo_notification_type_id;
}

GType
games_undo_notification_get_type (void)
{
	static volatile gsize games_undo_notification_type_id__once = 0;
	if (g_once_init_enter (&games_undo_notification_type_id__once)) {
		GType games_undo_notification_type_id;
		games_undo_notification_type_id = games_undo_notification_get_type_once ();
		g_once_init_leave (&games_undo_notification_type_id__once, games_undo_notification_type_id);
	}
	return games_undo_notification_type_id__once;
}

static void
_vala_games_undo_notification_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec)
{
	GamesUndoNotification * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_UNDO_NOTIFICATION, GamesUndoNotification);
	switch (property_id) {
		case GAMES_UNDO_NOTIFICATION_REVEAL_PROPERTY:
		g_value_set_boolean (value, games_undo_notification_get_reveal (self));
		break;
		case GAMES_UNDO_NOTIFICATION_LABEL_PROPERTY:
		g_value_set_string (value, games_undo_notification_get_label (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_games_undo_notification_set_property (GObject * object,
                                            guint property_id,
                                            const GValue * value,
                                            GParamSpec * pspec)
{
	GamesUndoNotification * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_UNDO_NOTIFICATION, GamesUndoNotification);
	switch (property_id) {
		case GAMES_UNDO_NOTIFICATION_REVEAL_PROPERTY:
		games_undo_notification_set_reveal (self, g_value_get_boolean (value));
		break;
		case GAMES_UNDO_NOTIFICATION_LABEL_PROPERTY:
		games_undo_notification_set_label (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

