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

/*  
 * SPDX-License-Identifier: GPL-3.0-or-later  
 * SPDX-FileCopyrightText: 2023 elementary, Inc. <https://elementary.io>  
 *
 * Authored by: Colin Kiama <colinkiama@gmail.com>
 */

#include "codecore.h"
#include <gio/gio.h>
#include <glib-object.h>
#include <glib.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  {
	RESTORE_OVERRIDE_0_PROPERTY,
	RESTORE_OVERRIDE_FILE_PROPERTY,
	RESTORE_OVERRIDE_RANGE_PROPERTY,
	RESTORE_OVERRIDE_NUM_PROPERTIES
};
static GParamSpec* restore_override_properties[RESTORE_OVERRIDE_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _RestoreOverridePrivate {
	GFile* _file;
	SelectionRange _range;
};

static gint RestoreOverride_private_offset;
static gpointer restore_override_parent_class = NULL;

static gboolean _selection_range_equal (const SelectionRange * s1,
                                 const SelectionRange * s2);
static void restore_override_finalize (GObject * obj);
static GType restore_override_get_type_once (void);
static void _vala_restore_override_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec);
static void _vala_restore_override_set_property (GObject * object,
                                          guint property_id,
                                          const GValue * value,
                                          GParamSpec * pspec);

static inline gpointer
restore_override_get_instance_private (RestoreOverride* self)
{
	return G_STRUCT_MEMBER_P (self, RestoreOverride_private_offset);
}

RestoreOverride*
restore_override_construct (GType object_type,
                            GFile* file,
                            SelectionRange* range)
{
	RestoreOverride * self = NULL;
	SelectionRange _tmp0_;
	g_return_val_if_fail (file != NULL, NULL);
	g_return_val_if_fail (range != NULL, NULL);
	_tmp0_ = *range;
	self = (RestoreOverride*) g_object_new (object_type, "file", file, "range", &_tmp0_, NULL);
	return self;
}

RestoreOverride*
restore_override_new (GFile* file,
                      SelectionRange* range)
{
	return restore_override_construct (TYPE_RESTORE_OVERRIDE, file, range);
}

GFile*
restore_override_get_file (RestoreOverride* self)
{
	GFile* result;
	GFile* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_file;
	result = _tmp0_;
	return result;
}

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

static void
restore_override_set_file (RestoreOverride* self,
                           GFile* value)
{
	GFile* old_value;
	g_return_if_fail (self != NULL);
	old_value = restore_override_get_file (self);
	if (old_value != value) {
		GFile* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_file);
		self->priv->_file = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, restore_override_properties[RESTORE_OVERRIDE_FILE_PROPERTY]);
	}
}

void
restore_override_get_range (RestoreOverride* self,
                            SelectionRange * result)
{
	SelectionRange _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_range;
	*result = _tmp0_;
	return;
}

static gboolean
_selection_range_equal (const SelectionRange * s1,
                        const SelectionRange * s2)
{
	if (s1 == s2) {
		return TRUE;
	}
	if (s1 == NULL) {
		return FALSE;
	}
	if (s2 == NULL) {
		return FALSE;
	}
	if (s1->start_line != s2->start_line) {
		return FALSE;
	}
	if (s1->start_column != s2->start_column) {
		return FALSE;
	}
	if (s1->end_line != s2->end_line) {
		return FALSE;
	}
	if (s1->end_column != s2->end_column) {
		return FALSE;
	}
	return TRUE;
}

static void
restore_override_set_range (RestoreOverride* self,
                            SelectionRange * value)
{
	SelectionRange old_value;
	g_return_if_fail (self != NULL);
	restore_override_get_range (self, &old_value);
	if (_selection_range_equal (value, &old_value) != TRUE) {
		SelectionRange _tmp0_;
		_tmp0_ = *value;
		self->priv->_range = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, restore_override_properties[RESTORE_OVERRIDE_RANGE_PROPERTY]);
	}
}

static void
restore_override_class_init (RestoreOverrideClass * klass,
                             gpointer klass_data)
{
	restore_override_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &RestoreOverride_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_restore_override_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_restore_override_set_property;
	G_OBJECT_CLASS (klass)->finalize = restore_override_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), RESTORE_OVERRIDE_FILE_PROPERTY, restore_override_properties[RESTORE_OVERRIDE_FILE_PROPERTY] = g_param_spec_object ("file", "file", "file", g_file_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), RESTORE_OVERRIDE_RANGE_PROPERTY, restore_override_properties[RESTORE_OVERRIDE_RANGE_PROPERTY] = g_param_spec_boxed ("range", "range", "range", TYPE_SELECTION_RANGE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
restore_override_instance_init (RestoreOverride * self,
                                gpointer klass)
{
	self->priv = restore_override_get_instance_private (self);
}

static void
restore_override_finalize (GObject * obj)
{
	RestoreOverride * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_RESTORE_OVERRIDE, RestoreOverride);
	_g_object_unref0 (self->priv->_file);
	G_OBJECT_CLASS (restore_override_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
restore_override_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (RestoreOverrideClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) restore_override_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RestoreOverride), 0, (GInstanceInitFunc) restore_override_instance_init, NULL };
	GType restore_override_type_id;
	restore_override_type_id = g_type_register_static (G_TYPE_OBJECT, "RestoreOverride", &g_define_type_info, G_TYPE_FLAG_NONE);
	RestoreOverride_private_offset = g_type_add_instance_private (restore_override_type_id, sizeof (RestoreOverridePrivate));
	return restore_override_type_id;
}

GType
restore_override_get_type (void)
{
	static gsize restore_override_type_id__once = 0;
	if (g_once_init_enter (&restore_override_type_id__once)) {
		GType restore_override_type_id;
		restore_override_type_id = restore_override_get_type_once ();
		g_once_init_leave (&restore_override_type_id__once, restore_override_type_id);
	}
	return restore_override_type_id__once;
}

static void
_vala_restore_override_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec)
{
	RestoreOverride * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_RESTORE_OVERRIDE, RestoreOverride);
	switch (property_id) {
		case RESTORE_OVERRIDE_FILE_PROPERTY:
		g_value_set_object (value, restore_override_get_file (self));
		break;
		case RESTORE_OVERRIDE_RANGE_PROPERTY:
		{
			SelectionRange boxed;
			restore_override_get_range (self, &boxed);
			g_value_set_boxed (value, &boxed);
		}
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_restore_override_set_property (GObject * object,
                                     guint property_id,
                                     const GValue * value,
                                     GParamSpec * pspec)
{
	RestoreOverride * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_RESTORE_OVERRIDE, RestoreOverride);
	switch (property_id) {
		case RESTORE_OVERRIDE_FILE_PROPERTY:
		restore_override_set_file (self, g_value_get_object (value));
		break;
		case RESTORE_OVERRIDE_RANGE_PROPERTY:
		restore_override_set_range (self, g_value_get_boxed (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

