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

/*
 * SPDX-License-Identifier: GPL-2.0-or-later
 * SPDX-FileCopyrightText: 2018-2025 elementary, Inc. (https://elementary.io)
 *
 * Authors: Corentin Noël <corentin@elementary.io>
 */

#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>

#define CONSTANTS_CONF_DIR "/etc/lightdm"
#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 GREETER_TYPE_SETTINGS (greeter_settings_get_type ())
#define GREETER_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GREETER_TYPE_SETTINGS, GreeterSettings))
#define GREETER_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GREETER_TYPE_SETTINGS, GreeterSettingsClass))
#define GREETER_IS_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GREETER_TYPE_SETTINGS))
#define GREETER_IS_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GREETER_TYPE_SETTINGS))
#define GREETER_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GREETER_TYPE_SETTINGS, GreeterSettingsClass))

typedef struct _GreeterSettings GreeterSettings;
typedef struct _GreeterSettingsClass GreeterSettingsClass;
typedef struct _GreeterSettingsPrivate GreeterSettingsPrivate;
enum  {
	GREETER_SETTINGS_0_PROPERTY,
	GREETER_SETTINGS_ACTIVATE_NUMLOCK_PROPERTY,
	GREETER_SETTINGS_NUM_PROPERTIES
};
static GParamSpec* greeter_settings_properties[GREETER_SETTINGS_NUM_PROPERTIES];
#define _g_key_file_unref0(var) ((var == NULL) ? NULL : (var = (g_key_file_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _GreeterSettings {
	GObject parent_instance;
	GreeterSettingsPrivate * priv;
};

struct _GreeterSettingsClass {
	GObjectClass parent_class;
};

struct _GreeterSettingsPrivate {
	GKeyFile* settings;
};

static gint GreeterSettings_private_offset;
static gpointer greeter_settings_parent_class = NULL;

VALA_EXTERN GType greeter_settings_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GreeterSettings, g_object_unref)
VALA_EXTERN GreeterSettings* greeter_settings_new (void);
VALA_EXTERN GreeterSettings* greeter_settings_construct (GType object_type);
VALA_EXTERN gboolean greeter_settings_get_activate_numlock (GreeterSettings* self);
static GObject * greeter_settings_constructor (GType type,
                                        guint n_construct_properties,
                                        GObjectConstructParam * construct_properties);
static void greeter_settings_finalize (GObject * obj);
static GType greeter_settings_get_type_once (void);
static void _vala_greeter_settings_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec);

static inline gpointer
greeter_settings_get_instance_private (GreeterSettings* self)
{
	return G_STRUCT_MEMBER_P (self, GreeterSettings_private_offset);
}

GreeterSettings*
greeter_settings_construct (GType object_type)
{
	GreeterSettings * self = NULL;
	self = (GreeterSettings*) g_object_new (object_type, NULL);
	return self;
}

GreeterSettings*
greeter_settings_new (void)
{
	return greeter_settings_construct (GREETER_TYPE_SETTINGS);
}

gboolean
greeter_settings_get_activate_numlock (GreeterSettings* self)
{
	gboolean result;
	gboolean _tmp4_ = FALSE;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (self != NULL, FALSE);
	{
		gboolean _tmp0_ = FALSE;
		GKeyFile* _tmp1_;
		_tmp1_ = self->priv->settings;
		_tmp0_ = g_key_file_get_boolean (_tmp1_, "greeter", "activate-numlock", &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		result = _tmp0_;
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp2_;
		const gchar* _tmp3_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp2_ = e;
		_tmp3_ = _tmp2_->message;
		g_debug ("Settings.vala:16: %s", _tmp3_);
		result = FALSE;
		_g_error_free0 (e);
		return result;
	}
	__finally0:
	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_);
	return _tmp4_;
}

static GObject *
greeter_settings_constructor (GType type,
                              guint n_construct_properties,
                              GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GreeterSettings * self;
	GKeyFile* _tmp0_;
	GError* _inner_error0_ = NULL;
	parent_class = G_OBJECT_CLASS (greeter_settings_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GREETER_TYPE_SETTINGS, GreeterSettings);
	_tmp0_ = g_key_file_new ();
	_g_key_file_unref0 (self->priv->settings);
	self->priv->settings = _tmp0_;
	{
		gchar* greeter_conf_file = NULL;
		gchar* _tmp1_;
		GKeyFile* _tmp2_;
		const gchar* _tmp3_;
		_tmp1_ = g_build_filename (CONSTANTS_CONF_DIR, "io.elementary.greeter.conf", NULL);
		greeter_conf_file = _tmp1_;
		_tmp2_ = self->priv->settings;
		_tmp3_ = greeter_conf_file;
		g_key_file_load_from_file (_tmp2_, _tmp3_, G_KEY_FILE_NONE, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_free0 (greeter_conf_file);
			goto __catch0_g_error;
		}
		_g_free0 (greeter_conf_file);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp4_;
		const gchar* _tmp5_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp4_ = e;
		_tmp5_ = _tmp4_->message;
		g_critical ("Settings.vala:28: %s", _tmp5_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		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_);
	}
	return obj;
}

static void
greeter_settings_class_init (GreeterSettingsClass * klass,
                             gpointer klass_data)
{
	greeter_settings_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GreeterSettings_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_greeter_settings_get_property;
	G_OBJECT_CLASS (klass)->constructor = greeter_settings_constructor;
	G_OBJECT_CLASS (klass)->finalize = greeter_settings_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GREETER_SETTINGS_ACTIVATE_NUMLOCK_PROPERTY, greeter_settings_properties[GREETER_SETTINGS_ACTIVATE_NUMLOCK_PROPERTY] = g_param_spec_boolean ("activate-numlock", "activate-numlock", "activate-numlock", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
greeter_settings_instance_init (GreeterSettings * self,
                                gpointer klass)
{
	self->priv = greeter_settings_get_instance_private (self);
}

static void
greeter_settings_finalize (GObject * obj)
{
	GreeterSettings * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GREETER_TYPE_SETTINGS, GreeterSettings);
	_g_key_file_unref0 (self->priv->settings);
	G_OBJECT_CLASS (greeter_settings_parent_class)->finalize (obj);
}

static GType
greeter_settings_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GreeterSettingsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) greeter_settings_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GreeterSettings), 0, (GInstanceInitFunc) greeter_settings_instance_init, NULL };
	GType greeter_settings_type_id;
	greeter_settings_type_id = g_type_register_static (G_TYPE_OBJECT, "GreeterSettings", &g_define_type_info, 0);
	GreeterSettings_private_offset = g_type_add_instance_private (greeter_settings_type_id, sizeof (GreeterSettingsPrivate));
	return greeter_settings_type_id;
}

GType
greeter_settings_get_type (void)
{
	static volatile gsize greeter_settings_type_id__once = 0;
	if (g_once_init_enter (&greeter_settings_type_id__once)) {
		GType greeter_settings_type_id;
		greeter_settings_type_id = greeter_settings_get_type_once ();
		g_once_init_leave (&greeter_settings_type_id__once, greeter_settings_type_id);
	}
	return greeter_settings_type_id__once;
}

static void
_vala_greeter_settings_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec)
{
	GreeterSettings * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GREETER_TYPE_SETTINGS, GreeterSettings);
	switch (property_id) {
		case GREETER_SETTINGS_ACTIVATE_NUMLOCK_PROPERTY:
		g_value_set_boolean (value, greeter_settings_get_activate_numlock (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

