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

/*
 * Copyright 2026 elementary, Inc. (https://elementary.io)
 * SPDX-License-Identifier: GPL-3.0-or-later
 *
 * Authored by: Leonhard Kargl <leo.kargl@proton.me>
 */

#include <glib-object.h>
#include <clutter/clutter.h>
#include <glib.h>
#include "gala.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
#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 GALA_TYPE_LOCK_SCREEN_MANAGER (gala_lock_screen_manager_get_type ())
#define GALA_LOCK_SCREEN_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_LOCK_SCREEN_MANAGER, GalaLockScreenManager))
#define GALA_LOCK_SCREEN_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_TYPE_LOCK_SCREEN_MANAGER, GalaLockScreenManagerClass))
#define GALA_IS_LOCK_SCREEN_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_LOCK_SCREEN_MANAGER))
#define GALA_IS_LOCK_SCREEN_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_TYPE_LOCK_SCREEN_MANAGER))
#define GALA_LOCK_SCREEN_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_TYPE_LOCK_SCREEN_MANAGER, GalaLockScreenManagerClass))

typedef struct _GalaLockScreenManager GalaLockScreenManager;
typedef struct _GalaLockScreenManagerClass GalaLockScreenManagerClass;
typedef struct _GalaLockScreenManagerPrivate GalaLockScreenManagerPrivate;

#define GALA_TYPE_LOCK_SCREEN (gala_lock_screen_get_type ())
#define GALA_LOCK_SCREEN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_LOCK_SCREEN, GalaLockScreen))
#define GALA_LOCK_SCREEN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_TYPE_LOCK_SCREEN, GalaLockScreenClass))
#define GALA_IS_LOCK_SCREEN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_LOCK_SCREEN))
#define GALA_IS_LOCK_SCREEN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_TYPE_LOCK_SCREEN))
#define GALA_LOCK_SCREEN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_TYPE_LOCK_SCREEN, GalaLockScreenClass))

typedef struct _GalaLockScreen GalaLockScreen;
typedef struct _GalaLockScreenClass GalaLockScreenClass;
enum  {
	GALA_LOCK_SCREEN_MANAGER_0_PROPERTY,
	GALA_LOCK_SCREEN_MANAGER_LOCK_SCREEN_PROPERTY,
	GALA_LOCK_SCREEN_MANAGER_MANUALLY_LOCKED_PROPERTY,
	GALA_LOCK_SCREEN_MANAGER_NUM_PROPERTIES
};
static GParamSpec* gala_lock_screen_manager_properties[GALA_LOCK_SCREEN_MANAGER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _GalaLockScreenManager {
	GObject parent_instance;
	GalaLockScreenManagerPrivate * priv;
};

struct _GalaLockScreenManagerClass {
	GObjectClass parent_class;
};

struct _GalaLockScreenManagerPrivate {
	GalaLockScreen* _lock_screen;
	gboolean _manually_locked;
};

static gint GalaLockScreenManager_private_offset;
static gpointer gala_lock_screen_manager_parent_class = NULL;

VALA_EXTERN GType gala_lock_screen_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaLockScreenManager, g_object_unref)
VALA_EXTERN GType gala_lock_screen_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaLockScreen, g_object_unref)
VALA_EXTERN GalaLockScreenManager* gala_lock_screen_manager_new (GalaLockScreen* lock_screen);
VALA_EXTERN GalaLockScreenManager* gala_lock_screen_manager_construct (GType object_type,
                                                           GalaLockScreen* lock_screen);
static void gala_lock_screen_manager_update_active (GalaLockScreenManager* self);
VALA_EXTERN gboolean gala_lock_screen_manager_get_manually_locked (GalaLockScreenManager* self);
static GalaLockScreen* gala_lock_screen_manager_get_lock_screen (GalaLockScreenManager* self);
VALA_EXTERN void gala_lock_screen_set_active (GalaLockScreen* self,
                                  gboolean active,
                                  GAsyncReadyCallback _callback_,
                                  gpointer _user_data_);
VALA_EXTERN void gala_lock_screen_set_active_finish (GalaLockScreen* self,
                                         GAsyncResult* _res_);
static void gala_lock_screen_manager_set_lock_screen (GalaLockScreenManager* self,
                                               GalaLockScreen* value);
VALA_EXTERN void gala_lock_screen_manager_set_manually_locked (GalaLockScreenManager* self,
                                                   gboolean value);
static GObject * gala_lock_screen_manager_constructor (GType type,
                                                guint n_construct_properties,
                                                GObjectConstructParam * construct_properties);
static void _gala_lock_screen_manager_update_active_g_object_notify (GObject* _sender,
                                                              GParamSpec* pspec,
                                                              gpointer self);
static void gala_lock_screen_manager_finalize (GObject * obj);
static GType gala_lock_screen_manager_get_type_once (void);
static void _vala_gala_lock_screen_manager_get_property (GObject * object,
                                                  guint property_id,
                                                  GValue * value,
                                                  GParamSpec * pspec);
static void _vala_gala_lock_screen_manager_set_property (GObject * object,
                                                  guint property_id,
                                                  const GValue * value,
                                                  GParamSpec * pspec);

static inline gpointer
gala_lock_screen_manager_get_instance_private (GalaLockScreenManager* self)
{
	return G_STRUCT_MEMBER_P (self, GalaLockScreenManager_private_offset);
}

GalaLockScreenManager*
gala_lock_screen_manager_construct (GType object_type,
                                    GalaLockScreen* lock_screen)
{
	GalaLockScreenManager * self = NULL;
	g_return_val_if_fail (lock_screen != NULL, NULL);
	self = (GalaLockScreenManager*) g_object_new (object_type, "lock-screen", lock_screen, NULL);
	return self;
}

GalaLockScreenManager*
gala_lock_screen_manager_new (GalaLockScreen* lock_screen)
{
	return gala_lock_screen_manager_construct (GALA_TYPE_LOCK_SCREEN_MANAGER, lock_screen);
}

static void
gala_lock_screen_manager_update_active (GalaLockScreenManager* self)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_;
	gboolean active = FALSE;
	GalaLockScreen* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->_manually_locked;
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = gala_session_settings_is_greeter ();
	}
	active = _tmp0_;
	_tmp2_ = self->priv->_lock_screen;
	gala_lock_screen_set_active (_tmp2_, active, NULL, NULL);
}

static GalaLockScreen*
gala_lock_screen_manager_get_lock_screen (GalaLockScreenManager* self)
{
	GalaLockScreen* result;
	GalaLockScreen* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_lock_screen;
	result = _tmp0_;
	return result;
}

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

static void
gala_lock_screen_manager_set_lock_screen (GalaLockScreenManager* self,
                                          GalaLockScreen* value)
{
	GalaLockScreen* old_value;
	g_return_if_fail (self != NULL);
	old_value = gala_lock_screen_manager_get_lock_screen (self);
	if (old_value != value) {
		GalaLockScreen* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_lock_screen);
		self->priv->_lock_screen = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, gala_lock_screen_manager_properties[GALA_LOCK_SCREEN_MANAGER_LOCK_SCREEN_PROPERTY]);
	}
}

gboolean
gala_lock_screen_manager_get_manually_locked (GalaLockScreenManager* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_manually_locked;
	return result;
}

void
gala_lock_screen_manager_set_manually_locked (GalaLockScreenManager* self,
                                              gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = gala_lock_screen_manager_get_manually_locked (self);
	if (old_value != value) {
		self->priv->_manually_locked = value;
		g_object_notify_by_pspec ((GObject *) self, gala_lock_screen_manager_properties[GALA_LOCK_SCREEN_MANAGER_MANUALLY_LOCKED_PROPERTY]);
	}
}

static void
_gala_lock_screen_manager_update_active_g_object_notify (GObject* _sender,
                                                         GParamSpec* pspec,
                                                         gpointer self)
{
	gala_lock_screen_manager_update_active ((GalaLockScreenManager*) self);
}

static GObject *
gala_lock_screen_manager_constructor (GType type,
                                      guint n_construct_properties,
                                      GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GalaLockScreenManager * self;
	parent_class = G_OBJECT_CLASS (gala_lock_screen_manager_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_LOCK_SCREEN_MANAGER, GalaLockScreenManager);
	g_signal_connect_object ((GObject*) self, "notify::manually-locked", (GCallback) _gala_lock_screen_manager_update_active_g_object_notify, self, 0);
	gala_lock_screen_manager_update_active (self);
	return obj;
}

static void
gala_lock_screen_manager_class_init (GalaLockScreenManagerClass * klass,
                                     gpointer klass_data)
{
	gala_lock_screen_manager_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GalaLockScreenManager_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_gala_lock_screen_manager_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gala_lock_screen_manager_set_property;
	G_OBJECT_CLASS (klass)->constructor = gala_lock_screen_manager_constructor;
	G_OBJECT_CLASS (klass)->finalize = gala_lock_screen_manager_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_LOCK_SCREEN_MANAGER_LOCK_SCREEN_PROPERTY, gala_lock_screen_manager_properties[GALA_LOCK_SCREEN_MANAGER_LOCK_SCREEN_PROPERTY] = g_param_spec_object ("lock-screen", "lock-screen", "lock-screen", GALA_TYPE_LOCK_SCREEN, G_PARAM_STATIC_STRINGS | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	/**
	     * To be set by the session locker in the future when we have an in session lock screen
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_LOCK_SCREEN_MANAGER_MANUALLY_LOCKED_PROPERTY, gala_lock_screen_manager_properties[GALA_LOCK_SCREEN_MANAGER_MANUALLY_LOCKED_PROPERTY] = g_param_spec_boolean ("manually-locked", "manually-locked", "manually-locked", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
gala_lock_screen_manager_instance_init (GalaLockScreenManager * self,
                                        gpointer klass)
{
	self->priv = gala_lock_screen_manager_get_instance_private (self);
	self->priv->_manually_locked = FALSE;
}

static void
gala_lock_screen_manager_finalize (GObject * obj)
{
	GalaLockScreenManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_LOCK_SCREEN_MANAGER, GalaLockScreenManager);
	_g_object_unref0 (self->priv->_lock_screen);
	G_OBJECT_CLASS (gala_lock_screen_manager_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
gala_lock_screen_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GalaLockScreenManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gala_lock_screen_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GalaLockScreenManager), 0, (GInstanceInitFunc) gala_lock_screen_manager_instance_init, NULL };
	GType gala_lock_screen_manager_type_id;
	gala_lock_screen_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "GalaLockScreenManager", &g_define_type_info, G_TYPE_FLAG_NONE);
	GalaLockScreenManager_private_offset = g_type_add_instance_private (gala_lock_screen_manager_type_id, sizeof (GalaLockScreenManagerPrivate));
	return gala_lock_screen_manager_type_id;
}

GType
gala_lock_screen_manager_get_type (void)
{
	static gsize gala_lock_screen_manager_type_id__once = 0;
	if (g_once_init_enter (&gala_lock_screen_manager_type_id__once)) {
		GType gala_lock_screen_manager_type_id;
		gala_lock_screen_manager_type_id = gala_lock_screen_manager_get_type_once ();
		g_once_init_leave (&gala_lock_screen_manager_type_id__once, gala_lock_screen_manager_type_id);
	}
	return gala_lock_screen_manager_type_id__once;
}

static void
_vala_gala_lock_screen_manager_get_property (GObject * object,
                                             guint property_id,
                                             GValue * value,
                                             GParamSpec * pspec)
{
	GalaLockScreenManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_LOCK_SCREEN_MANAGER, GalaLockScreenManager);
	switch (property_id) {
		case GALA_LOCK_SCREEN_MANAGER_LOCK_SCREEN_PROPERTY:
		g_value_set_object (value, gala_lock_screen_manager_get_lock_screen (self));
		break;
		case GALA_LOCK_SCREEN_MANAGER_MANUALLY_LOCKED_PROPERTY:
		g_value_set_boolean (value, gala_lock_screen_manager_get_manually_locked (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_gala_lock_screen_manager_set_property (GObject * object,
                                             guint property_id,
                                             const GValue * value,
                                             GParamSpec * pspec)
{
	GalaLockScreenManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_LOCK_SCREEN_MANAGER, GalaLockScreenManager);
	switch (property_id) {
		case GALA_LOCK_SCREEN_MANAGER_LOCK_SCREEN_PROPERTY:
		gala_lock_screen_manager_set_lock_screen (self, g_value_get_object (value));
		break;
		case GALA_LOCK_SCREEN_MANAGER_MANUALLY_LOCKED_PROPERTY:
		gala_lock_screen_manager_set_manually_locked (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

