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

/*
 * Copyright (c) 2023-2025 focus-timer contributors
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#include "ft_ui.h"
#include <gtk/gtk.h>
#include "ft_core.h"
#include <glib-object.h>
#include <glib.h>
#include <string.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

enum  {
	FT_SCREEN_OVERLAY_0_PROPERTY,
	FT_SCREEN_OVERLAY_NUM_PROPERTIES
};
static GParamSpec* ft_screen_overlay_properties[FT_SCREEN_OVERLAY_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _FtScreenOverlayPrivate {
	GtkButton* lock_screen_button;
	FtLockScreen* lock_screen;
};

static gint FtScreenOverlay_private_offset;
static gpointer ft_screen_overlay_parent_class = NULL;

static void ft_screen_overlay_on_lock_screen_button_clicked (FtScreenOverlay* self,
                                                      GtkButton* button);
static void _ft_screen_overlay_on_lock_screen_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                          gpointer self);
static void ft_screen_overlay_on_close_button_clicked (FtScreenOverlay* self,
                                                GtkButton* button);
static void _ft_screen_overlay_on_close_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                    gpointer self);
static void ft_screen_overlay_real_dispose (GObject* base);
static GObject * ft_screen_overlay_constructor (GType type,
                                         guint n_construct_properties,
                                         GObjectConstructParam * construct_properties);
static void ft_screen_overlay_finalize (GObject * obj);
static GType ft_screen_overlay_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
ft_screen_overlay_get_instance_private (FtScreenOverlay* self)
{
	return G_STRUCT_MEMBER_P (self, FtScreenOverlay_private_offset);
}

static void
ft_screen_overlay_on_lock_screen_button_clicked (FtScreenOverlay* self,
                                                 GtkButton* button)
{
	FtLockScreen* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (button != NULL);
	_tmp0_ = self->priv->lock_screen;
	ft_lock_screen_activate (_tmp0_);
}

static void
_ft_screen_overlay_on_lock_screen_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                     gpointer self)
{
	ft_screen_overlay_on_lock_screen_button_clicked ((FtScreenOverlay*) self, _sender);
}

static void
ft_screen_overlay_on_close_button_clicked (FtScreenOverlay* self,
                                           GtkButton* button)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (button != NULL);
	gtk_window_close ((GtkWindow*) self);
}

static void
_ft_screen_overlay_on_close_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                               gpointer self)
{
	ft_screen_overlay_on_close_button_clicked ((FtScreenOverlay*) self, _sender);
}

static void
ft_screen_overlay_real_dispose (GObject* base)
{
	FtScreenOverlay * self;
	self = (FtScreenOverlay*) base;
	_g_object_unref0 (self->priv->lock_screen);
	self->priv->lock_screen = NULL;
	G_OBJECT_CLASS (ft_screen_overlay_parent_class)->dispose ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, FT_TYPE_LIGHTBOX, FtLightbox));
}

FtScreenOverlay*
ft_screen_overlay_construct (GType object_type)
{
	FtScreenOverlay * self = NULL;
	self = (FtScreenOverlay*) ft_lightbox_construct (object_type);
	return self;
}

FtScreenOverlay*
ft_screen_overlay_new (void)
{
	return ft_screen_overlay_construct (FT_TYPE_SCREEN_OVERLAY);
}

static GObject *
ft_screen_overlay_constructor (GType type,
                               guint n_construct_properties,
                               GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	FtScreenOverlay * self;
	FtLockScreen* _tmp0_;
	FtLockScreen* _tmp1_;
	GtkButton* _tmp2_;
	parent_class = G_OBJECT_CLASS (ft_screen_overlay_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_SCREEN_OVERLAY, FtScreenOverlay);
	_tmp0_ = ft_lock_screen_new ();
	_g_object_unref0 (self->priv->lock_screen);
	self->priv->lock_screen = _tmp0_;
	_tmp1_ = self->priv->lock_screen;
	_tmp2_ = self->priv->lock_screen_button;
	g_object_bind_property_with_closures ((GObject*) _tmp1_, "enabled", (GObject*) _tmp2_, "visible", 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)));
	return obj;
}

static void
ft_screen_overlay_class_init (FtScreenOverlayClass * klass,
                              gpointer klass_data)
{
	ft_screen_overlay_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FtScreenOverlay_private_offset);
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) ft_screen_overlay_real_dispose;
	G_OBJECT_CLASS (klass)->constructor = ft_screen_overlay_constructor;
	G_OBJECT_CLASS (klass)->finalize = ft_screen_overlay_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/io/github/focustimerhq/FocusTimer/ui/overlays/screen-overlay.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "lock_screen_button", FALSE, FtScreenOverlay_private_offset + G_STRUCT_OFFSET (FtScreenOverlayPrivate, lock_screen_button));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_lock_screen_button_clicked", G_CALLBACK(_ft_screen_overlay_on_lock_screen_button_clicked_gtk_button_clicked));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_close_button_clicked", G_CALLBACK(_ft_screen_overlay_on_close_button_clicked_gtk_button_clicked));
}

static void
ft_screen_overlay_instance_init (FtScreenOverlay * self,
                                 gpointer klass)
{
	self->priv = ft_screen_overlay_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
ft_screen_overlay_finalize (GObject * obj)
{
	FtScreenOverlay * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_SCREEN_OVERLAY, FtScreenOverlay);
	_g_object_unref0 (self->priv->lock_screen);
	G_OBJECT_CLASS (ft_screen_overlay_parent_class)->finalize (obj);
}

static GType
ft_screen_overlay_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtScreenOverlayClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_screen_overlay_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtScreenOverlay), 0, (GInstanceInitFunc) ft_screen_overlay_instance_init, NULL };
	GType ft_screen_overlay_type_id;
	ft_screen_overlay_type_id = g_type_register_static (FT_TYPE_LIGHTBOX, "FtScreenOverlay", &g_define_type_info, 0);
	FtScreenOverlay_private_offset = g_type_add_instance_private (ft_screen_overlay_type_id, sizeof (FtScreenOverlayPrivate));
	return ft_screen_overlay_type_id;
}

GType
ft_screen_overlay_get_type (void)
{
	static volatile gsize ft_screen_overlay_type_id__once = 0;
	if (g_once_init_enter (&ft_screen_overlay_type_id__once)) {
		GType ft_screen_overlay_type_id;
		ft_screen_overlay_type_id = ft_screen_overlay_get_type_once ();
		g_once_init_leave (&ft_screen_overlay_type_id__once, ft_screen_overlay_type_id);
	}
	return ft_screen_overlay_type_id__once;
}

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;
}

