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

/*
* Copyright (c) 2018-2026 (https://github.com/phase1geo/Minder)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* Authored by: Trevor Williams <phase1geo@gmail.com>
*/

#include <glib-object.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 TYPE_UNDO_ITEM (undo_item_get_type ())
#define UNDO_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_UNDO_ITEM, UndoItem))
#define UNDO_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_UNDO_ITEM, UndoItemClass))
#define IS_UNDO_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_UNDO_ITEM))
#define IS_UNDO_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_UNDO_ITEM))
#define UNDO_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_UNDO_ITEM, UndoItemClass))

typedef struct _UndoItem UndoItem;
typedef struct _UndoItemClass UndoItemClass;
typedef struct _UndoItemPrivate UndoItemPrivate;

#define TYPE_MIND_MAP (mind_map_get_type ())
#define MIND_MAP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MIND_MAP, MindMap))
#define MIND_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MIND_MAP, MindMapClass))
#define IS_MIND_MAP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MIND_MAP))
#define IS_MIND_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MIND_MAP))
#define MIND_MAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MIND_MAP, MindMapClass))

typedef struct _MindMap MindMap;
typedef struct _MindMapClass MindMapClass;
enum  {
	UNDO_ITEM_0_PROPERTY,
	UNDO_ITEM_NAME_PROPERTY,
	UNDO_ITEM_ID_PROPERTY,
	UNDO_ITEM_NUM_PROPERTIES
};
static GParamSpec* undo_item_properties[UNDO_ITEM_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

struct _UndoItem {
	GObject parent_instance;
	UndoItemPrivate * priv;
};

struct _UndoItemClass {
	GObjectClass parent_class;
	void (*undo) (UndoItem* self, MindMap* map);
	void (*redo) (UndoItem* self, MindMap* map);
	gboolean (*matches) (UndoItem* self, UndoItem* item);
	void (*replace_with_item) (UndoItem* self, UndoItem* item);
	gchar* (*to_string) (UndoItem* self);
};

struct _UndoItemPrivate {
	gchar* _name;
	gint _id;
};

static gint UndoItem_private_offset;
static gpointer undo_item_parent_class = NULL;

VALA_EXTERN GType undo_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (UndoItem, g_object_unref)
VALA_EXTERN gpointer mind_map_ref (gpointer instance);
VALA_EXTERN void mind_map_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_mind_map (const gchar* name,
                                 const gchar* nick,
                                 const gchar* blurb,
                                 GType object_type,
                                 GParamFlags flags);
VALA_EXTERN void value_set_mind_map (GValue* value,
                         gpointer v_object);
VALA_EXTERN void value_take_mind_map (GValue* value,
                          gpointer v_object);
VALA_EXTERN gpointer value_get_mind_map (const GValue* value);
VALA_EXTERN GType mind_map_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MindMap, mind_map_unref)
VALA_EXTERN void undo_item_undo (UndoItem* self,
                     MindMap* map);
VALA_EXTERN void undo_item_redo (UndoItem* self,
                     MindMap* map);
VALA_EXTERN gboolean undo_item_matches (UndoItem* self,
                            UndoItem* item);
VALA_EXTERN void undo_item_replace_with_item (UndoItem* self,
                                  UndoItem* item);
VALA_EXTERN gchar* undo_item_to_string (UndoItem* self);
VALA_EXTERN UndoItem* undo_item_new (const gchar* name);
VALA_EXTERN UndoItem* undo_item_construct (GType object_type,
                               const gchar* name);
VALA_EXTERN void undo_item_set_name (UndoItem* self,
                         const gchar* value);
static void undo_item_real_undo (UndoItem* self,
                          MindMap* map);
static void undo_item_real_redo (UndoItem* self,
                          MindMap* map);
static gboolean undo_item_real_matches (UndoItem* self,
                                 UndoItem* item);
static void undo_item_real_replace_with_item (UndoItem* self,
                                       UndoItem* item);
static gchar* undo_item_real_to_string (UndoItem* self);
VALA_EXTERN const gchar* undo_item_get_name (UndoItem* self);
VALA_EXTERN gint undo_item_get_id (UndoItem* self);
VALA_EXTERN void undo_item_set_id (UndoItem* self,
                       gint value);
static void undo_item_finalize (GObject * obj);
static GType undo_item_get_type_once (void);
static void _vala_undo_item_get_property (GObject * object,
                                   guint property_id,
                                   GValue * value,
                                   GParamSpec * pspec);
static void _vala_undo_item_set_property (GObject * object,
                                   guint property_id,
                                   const GValue * value,
                                   GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
undo_item_get_instance_private (UndoItem* self)
{
	return G_STRUCT_MEMBER_P (self, UndoItem_private_offset);
}

UndoItem*
undo_item_construct (GType object_type,
                     const gchar* name)
{
	UndoItem * self = NULL;
	g_return_val_if_fail (name != NULL, NULL);
	self = (UndoItem*) g_object_new (object_type, NULL);
	undo_item_set_name (self, name);
	return self;
}

UndoItem*
undo_item_new (const gchar* name)
{
	return undo_item_construct (TYPE_UNDO_ITEM, name);
}

static void
undo_item_real_undo (UndoItem* self,
                     MindMap* map)
{
	g_return_if_fail (map != NULL);
}

void
undo_item_undo (UndoItem* self,
                MindMap* map)
{
	UndoItemClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = UNDO_ITEM_GET_CLASS (self);
	if (_klass_->undo) {
		_klass_->undo (self, map);
	}
}

static void
undo_item_real_redo (UndoItem* self,
                     MindMap* map)
{
	g_return_if_fail (map != NULL);
}

void
undo_item_redo (UndoItem* self,
                MindMap* map)
{
	UndoItemClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = UNDO_ITEM_GET_CLASS (self);
	if (_klass_->redo) {
		_klass_->redo (self, map);
	}
}

static gboolean
undo_item_real_matches (UndoItem* self,
                        UndoItem* item)
{
	gboolean result;
	g_return_val_if_fail (item != NULL, FALSE);
	result = FALSE;
	return result;
}

gboolean
undo_item_matches (UndoItem* self,
                   UndoItem* item)
{
	UndoItemClass* _klass_;
	g_return_val_if_fail (self != NULL, FALSE);
	_klass_ = UNDO_ITEM_GET_CLASS (self);
	if (_klass_->matches) {
		return _klass_->matches (self, item);
	}
	return FALSE;
}

static void
undo_item_real_replace_with_item (UndoItem* self,
                                  UndoItem* item)
{
	g_return_if_fail (item != NULL);
}

void
undo_item_replace_with_item (UndoItem* self,
                             UndoItem* item)
{
	UndoItemClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = UNDO_ITEM_GET_CLASS (self);
	if (_klass_->replace_with_item) {
		_klass_->replace_with_item (self, item);
	}
}

static gchar*
undo_item_real_to_string (UndoItem* self)
{
	const gchar* _tmp0_;
	gint _tmp1_;
	gchar* _tmp2_;
	gchar* result;
	_tmp0_ = self->priv->_name;
	_tmp1_ = self->priv->_id;
	_tmp2_ = g_strdup_printf ("%s [%d]", _tmp0_, _tmp1_);
	result = _tmp2_;
	return result;
}

gchar*
undo_item_to_string (UndoItem* self)
{
	UndoItemClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = UNDO_ITEM_GET_CLASS (self);
	if (_klass_->to_string) {
		return _klass_->to_string (self);
	}
	return NULL;
}

const gchar*
undo_item_get_name (UndoItem* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_name;
	result = _tmp0_;
	return result;
}

void
undo_item_set_name (UndoItem* self,
                    const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = undo_item_get_name (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_name);
		self->priv->_name = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, undo_item_properties[UNDO_ITEM_NAME_PROPERTY]);
	}
}

gint
undo_item_get_id (UndoItem* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_id;
	return result;
}

void
undo_item_set_id (UndoItem* self,
                  gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = undo_item_get_id (self);
	if (old_value != value) {
		self->priv->_id = value;
		g_object_notify_by_pspec ((GObject *) self, undo_item_properties[UNDO_ITEM_ID_PROPERTY]);
	}
}

static void
undo_item_class_init (UndoItemClass * klass,
                      gpointer klass_data)
{
	undo_item_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &UndoItem_private_offset);
	((UndoItemClass *) klass)->undo = (void (*) (UndoItem*, MindMap*)) undo_item_real_undo;
	((UndoItemClass *) klass)->redo = (void (*) (UndoItem*, MindMap*)) undo_item_real_redo;
	((UndoItemClass *) klass)->matches = (gboolean (*) (UndoItem*, UndoItem*)) undo_item_real_matches;
	((UndoItemClass *) klass)->replace_with_item = (void (*) (UndoItem*, UndoItem*)) undo_item_real_replace_with_item;
	((UndoItemClass *) klass)->to_string = (gchar* (*) (UndoItem*)) undo_item_real_to_string;
	G_OBJECT_CLASS (klass)->get_property = _vala_undo_item_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_undo_item_set_property;
	G_OBJECT_CLASS (klass)->finalize = undo_item_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), UNDO_ITEM_NAME_PROPERTY, undo_item_properties[UNDO_ITEM_NAME_PROPERTY] = g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), UNDO_ITEM_ID_PROPERTY, undo_item_properties[UNDO_ITEM_ID_PROPERTY] = g_param_spec_int ("id", "id", "id", G_MININT, G_MAXINT, -1, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
undo_item_instance_init (UndoItem * self,
                         gpointer klass)
{
	gchar* _tmp0_;
	self->priv = undo_item_get_instance_private (self);
	_tmp0_ = g_strdup ("");
	self->priv->_name = _tmp0_;
	self->priv->_id = -1;
}

static void
undo_item_finalize (GObject * obj)
{
	UndoItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_UNDO_ITEM, UndoItem);
	_g_free0 (self->priv->_name);
	G_OBJECT_CLASS (undo_item_parent_class)->finalize (obj);
}

static GType
undo_item_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (UndoItemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) undo_item_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UndoItem), 0, (GInstanceInitFunc) undo_item_instance_init, NULL };
	GType undo_item_type_id;
	undo_item_type_id = g_type_register_static (G_TYPE_OBJECT, "UndoItem", &g_define_type_info, 0);
	UndoItem_private_offset = g_type_add_instance_private (undo_item_type_id, sizeof (UndoItemPrivate));
	return undo_item_type_id;
}

GType
undo_item_get_type (void)
{
	static volatile gsize undo_item_type_id__once = 0;
	if (g_once_init_enter (&undo_item_type_id__once)) {
		GType undo_item_type_id;
		undo_item_type_id = undo_item_get_type_once ();
		g_once_init_leave (&undo_item_type_id__once, undo_item_type_id);
	}
	return undo_item_type_id__once;
}

static void
_vala_undo_item_get_property (GObject * object,
                              guint property_id,
                              GValue * value,
                              GParamSpec * pspec)
{
	UndoItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_UNDO_ITEM, UndoItem);
	switch (property_id) {
		case UNDO_ITEM_NAME_PROPERTY:
		g_value_set_string (value, undo_item_get_name (self));
		break;
		case UNDO_ITEM_ID_PROPERTY:
		g_value_set_int (value, undo_item_get_id (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_undo_item_set_property (GObject * object,
                              guint property_id,
                              const GValue * value,
                              GParamSpec * pspec)
{
	UndoItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_UNDO_ITEM, UndoItem);
	switch (property_id) {
		case UNDO_ITEM_NAME_PROPERTY:
		undo_item_set_name (self, g_value_get_string (value));
		break;
		case UNDO_ITEM_ID_PROPERTY:
		undo_item_set_id (self, g_value_get_int (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

