/* KeyboardModel.c generated by valac 0.56.19, the Vala compiler
 * generated from KeyboardModel.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 <gio/gio.h>
#include <glib.h>
#include <stdlib.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
#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_DAEMON_TYPE_KEYBOARD_MODEL (gala_daemon_keyboard_model_get_type ())
#define GALA_DAEMON_KEYBOARD_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_DAEMON_TYPE_KEYBOARD_MODEL, GalaDaemonKeyboardModel))
#define GALA_DAEMON_KEYBOARD_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_DAEMON_TYPE_KEYBOARD_MODEL, GalaDaemonKeyboardModelClass))
#define GALA_DAEMON_IS_KEYBOARD_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_DAEMON_TYPE_KEYBOARD_MODEL))
#define GALA_DAEMON_IS_KEYBOARD_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_DAEMON_TYPE_KEYBOARD_MODEL))
#define GALA_DAEMON_KEYBOARD_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_DAEMON_TYPE_KEYBOARD_MODEL, GalaDaemonKeyboardModelClass))

typedef struct _GalaDaemonKeyboardModel GalaDaemonKeyboardModel;
typedef struct _GalaDaemonKeyboardModelClass GalaDaemonKeyboardModelClass;
typedef struct _GalaDaemonKeyboardModelPrivate GalaDaemonKeyboardModelPrivate;
enum  {
	GALA_DAEMON_KEYBOARD_MODEL_0_PROPERTY,
	GALA_DAEMON_KEYBOARD_MODEL_VIEWS_PROPERTY,
	GALA_DAEMON_KEYBOARD_MODEL_NUM_PROPERTIES
};
static GParamSpec* gala_daemon_keyboard_model_properties[GALA_DAEMON_KEYBOARD_MODEL_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define GALA_DAEMON_TYPE_KEYBOARD_VIEW (gala_daemon_keyboard_view_get_type ())
#define GALA_DAEMON_KEYBOARD_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_DAEMON_TYPE_KEYBOARD_VIEW, GalaDaemonKeyboardView))
#define GALA_DAEMON_KEYBOARD_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_DAEMON_TYPE_KEYBOARD_VIEW, GalaDaemonKeyboardViewClass))
#define GALA_DAEMON_IS_KEYBOARD_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_DAEMON_TYPE_KEYBOARD_VIEW))
#define GALA_DAEMON_IS_KEYBOARD_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_DAEMON_TYPE_KEYBOARD_VIEW))
#define GALA_DAEMON_KEYBOARD_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_DAEMON_TYPE_KEYBOARD_VIEW, GalaDaemonKeyboardViewClass))

typedef struct _GalaDaemonKeyboardView GalaDaemonKeyboardView;
typedef struct _GalaDaemonKeyboardViewClass GalaDaemonKeyboardViewClass;

struct _GalaDaemonKeyboardModel {
	GObject parent_instance;
	GalaDaemonKeyboardModelPrivate * priv;
};

struct _GalaDaemonKeyboardModelClass {
	GObjectClass parent_class;
};

struct _GalaDaemonKeyboardModelPrivate {
	GListModel* _views;
};

static gint GalaDaemonKeyboardModel_private_offset;
static gpointer gala_daemon_keyboard_model_parent_class = NULL;

VALA_EXTERN GType gala_daemon_keyboard_model_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaDaemonKeyboardModel, g_object_unref)
VALA_EXTERN GalaDaemonKeyboardModel* gala_daemon_keyboard_model_new (GListModel* views);
VALA_EXTERN GalaDaemonKeyboardModel* gala_daemon_keyboard_model_construct (GType object_type,
                                                               GListModel* views);
VALA_EXTERN GType gala_daemon_keyboard_view_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaDaemonKeyboardView, g_object_unref)
VALA_EXTERN GalaDaemonKeyboardView* gala_daemon_keyboard_model_get_view_by_name (GalaDaemonKeyboardModel* self,
                                                                     const gchar* name);
VALA_EXTERN GListModel* gala_daemon_keyboard_model_get_views (GalaDaemonKeyboardModel* self);
VALA_EXTERN const gchar* gala_daemon_keyboard_view_get_name (GalaDaemonKeyboardView* self);
VALA_EXTERN GalaDaemonKeyboardView* gala_daemon_keyboard_model_find_default_view (GalaDaemonKeyboardModel* self);
VALA_EXTERN gboolean gala_daemon_keyboard_view_get_is_default (GalaDaemonKeyboardView* self);
static void gala_daemon_keyboard_model_set_views (GalaDaemonKeyboardModel* self,
                                           GListModel* value);
static void gala_daemon_keyboard_model_finalize (GObject * obj);
static GType gala_daemon_keyboard_model_get_type_once (void);
static void _vala_gala_daemon_keyboard_model_get_property (GObject * object,
                                                    guint property_id,
                                                    GValue * value,
                                                    GParamSpec * pspec);
static void _vala_gala_daemon_keyboard_model_set_property (GObject * object,
                                                    guint property_id,
                                                    const GValue * value,
                                                    GParamSpec * pspec);

static inline gpointer
gala_daemon_keyboard_model_get_instance_private (GalaDaemonKeyboardModel* self)
{
	return G_STRUCT_MEMBER_P (self, GalaDaemonKeyboardModel_private_offset);
}

GalaDaemonKeyboardModel*
gala_daemon_keyboard_model_construct (GType object_type,
                                      GListModel* views)
{
	GalaDaemonKeyboardModel * self = NULL;
	g_return_val_if_fail (views != NULL, NULL);
	self = (GalaDaemonKeyboardModel*) g_object_new (object_type, "views", views, NULL);
	return self;
}

GalaDaemonKeyboardModel*
gala_daemon_keyboard_model_new (GListModel* views)
{
	return gala_daemon_keyboard_model_construct (GALA_DAEMON_TYPE_KEYBOARD_MODEL, views);
}

GalaDaemonKeyboardView*
gala_daemon_keyboard_model_get_view_by_name (GalaDaemonKeyboardModel* self,
                                             const gchar* name)
{
	GalaDaemonKeyboardView* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	{
		guint i = 0U;
		i = (guint) 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GListModel* _tmp2_;
				GalaDaemonKeyboardView* view = NULL;
				GListModel* _tmp3_;
				GObject* _tmp4_;
				GalaDaemonKeyboardView* _tmp5_;
				const gchar* _tmp6_;
				const gchar* _tmp7_;
				if (!_tmp0_) {
					guint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = self->priv->_views;
				if (!(i < g_list_model_get_n_items (_tmp2_))) {
					break;
				}
				_tmp3_ = self->priv->_views;
				_tmp4_ = g_list_model_get_item (_tmp3_, i);
				view = G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, GALA_DAEMON_TYPE_KEYBOARD_VIEW, GalaDaemonKeyboardView);
				_tmp5_ = view;
				_tmp6_ = gala_daemon_keyboard_view_get_name (_tmp5_);
				_tmp7_ = _tmp6_;
				if (g_strcmp0 (_tmp7_, name) == 0) {
					result = view;
					return result;
				}
				_g_object_unref0 (view);
			}
		}
	}
	result = NULL;
	return result;
}

GalaDaemonKeyboardView*
gala_daemon_keyboard_model_find_default_view (GalaDaemonKeyboardModel* self)
{
	GListModel* _tmp8_;
	GObject* _tmp9_;
	GalaDaemonKeyboardView* result;
	g_return_val_if_fail (self != NULL, NULL);
	{
		guint i = 0U;
		i = (guint) 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GListModel* _tmp2_;
				GalaDaemonKeyboardView* view = NULL;
				GListModel* _tmp3_;
				GObject* _tmp4_;
				GalaDaemonKeyboardView* _tmp5_;
				gboolean _tmp6_;
				gboolean _tmp7_;
				if (!_tmp0_) {
					guint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = self->priv->_views;
				if (!(i < g_list_model_get_n_items (_tmp2_))) {
					break;
				}
				_tmp3_ = self->priv->_views;
				_tmp4_ = g_list_model_get_item (_tmp3_, i);
				view = G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, GALA_DAEMON_TYPE_KEYBOARD_VIEW, GalaDaemonKeyboardView);
				_tmp5_ = view;
				_tmp6_ = gala_daemon_keyboard_view_get_is_default (_tmp5_);
				_tmp7_ = _tmp6_;
				if (_tmp7_) {
					result = view;
					return result;
				}
				_g_object_unref0 (view);
			}
		}
	}
	_tmp8_ = self->priv->_views;
	_tmp9_ = g_list_model_get_item (_tmp8_, (guint) 0);
	result = G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, GALA_DAEMON_TYPE_KEYBOARD_VIEW, GalaDaemonKeyboardView);
	return result;
}

GListModel*
gala_daemon_keyboard_model_get_views (GalaDaemonKeyboardModel* self)
{
	GListModel* result;
	GListModel* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_views;
	result = _tmp0_;
	return result;
}

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

static void
gala_daemon_keyboard_model_set_views (GalaDaemonKeyboardModel* self,
                                      GListModel* value)
{
	GListModel* old_value;
	g_return_if_fail (self != NULL);
	old_value = gala_daemon_keyboard_model_get_views (self);
	if (old_value != value) {
		GListModel* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_views);
		self->priv->_views = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, gala_daemon_keyboard_model_properties[GALA_DAEMON_KEYBOARD_MODEL_VIEWS_PROPERTY]);
	}
}

static void
gala_daemon_keyboard_model_class_init (GalaDaemonKeyboardModelClass * klass,
                                       gpointer klass_data)
{
	gala_daemon_keyboard_model_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GalaDaemonKeyboardModel_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_gala_daemon_keyboard_model_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gala_daemon_keyboard_model_set_property;
	G_OBJECT_CLASS (klass)->finalize = gala_daemon_keyboard_model_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_DAEMON_KEYBOARD_MODEL_VIEWS_PROPERTY, gala_daemon_keyboard_model_properties[GALA_DAEMON_KEYBOARD_MODEL_VIEWS_PROPERTY] = g_param_spec_object ("views", "views", "views", g_list_model_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
gala_daemon_keyboard_model_instance_init (GalaDaemonKeyboardModel * self,
                                          gpointer klass)
{
	self->priv = gala_daemon_keyboard_model_get_instance_private (self);
}

static void
gala_daemon_keyboard_model_finalize (GObject * obj)
{
	GalaDaemonKeyboardModel * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_DAEMON_TYPE_KEYBOARD_MODEL, GalaDaemonKeyboardModel);
	_g_object_unref0 (self->priv->_views);
	G_OBJECT_CLASS (gala_daemon_keyboard_model_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
gala_daemon_keyboard_model_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GalaDaemonKeyboardModelClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gala_daemon_keyboard_model_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GalaDaemonKeyboardModel), 0, (GInstanceInitFunc) gala_daemon_keyboard_model_instance_init, NULL };
	GType gala_daemon_keyboard_model_type_id;
	gala_daemon_keyboard_model_type_id = g_type_register_static (G_TYPE_OBJECT, "GalaDaemonKeyboardModel", &g_define_type_info, G_TYPE_FLAG_NONE);
	GalaDaemonKeyboardModel_private_offset = g_type_add_instance_private (gala_daemon_keyboard_model_type_id, sizeof (GalaDaemonKeyboardModelPrivate));
	return gala_daemon_keyboard_model_type_id;
}

GType
gala_daemon_keyboard_model_get_type (void)
{
	static gsize gala_daemon_keyboard_model_type_id__once = 0;
	if (g_once_init_enter (&gala_daemon_keyboard_model_type_id__once)) {
		GType gala_daemon_keyboard_model_type_id;
		gala_daemon_keyboard_model_type_id = gala_daemon_keyboard_model_get_type_once ();
		g_once_init_leave (&gala_daemon_keyboard_model_type_id__once, gala_daemon_keyboard_model_type_id);
	}
	return gala_daemon_keyboard_model_type_id__once;
}

static void
_vala_gala_daemon_keyboard_model_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec)
{
	GalaDaemonKeyboardModel * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_DAEMON_TYPE_KEYBOARD_MODEL, GalaDaemonKeyboardModel);
	switch (property_id) {
		case GALA_DAEMON_KEYBOARD_MODEL_VIEWS_PROPERTY:
		g_value_set_object (value, gala_daemon_keyboard_model_get_views (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_gala_daemon_keyboard_model_set_property (GObject * object,
                                               guint property_id,
                                               const GValue * value,
                                               GParamSpec * pspec)
{
	GalaDaemonKeyboardModel * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_DAEMON_TYPE_KEYBOARD_MODEL, GalaDaemonKeyboardModel);
	switch (property_id) {
		case GALA_DAEMON_KEYBOARD_MODEL_VIEWS_PROPERTY:
		gala_daemon_keyboard_model_set_views (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

