/* UndoStyleNodeMargin.c generated by valac 0.56.19, the Vala compiler
 * generated from UndoStyleNodeMargin.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;

#define TYPE_UNDO_STYLE_CHANGE (undo_style_change_get_type ())
#define UNDO_STYLE_CHANGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_UNDO_STYLE_CHANGE, UndoStyleChange))
#define UNDO_STYLE_CHANGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_UNDO_STYLE_CHANGE, UndoStyleChangeClass))
#define IS_UNDO_STYLE_CHANGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_UNDO_STYLE_CHANGE))
#define IS_UNDO_STYLE_CHANGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_UNDO_STYLE_CHANGE))
#define UNDO_STYLE_CHANGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_UNDO_STYLE_CHANGE, UndoStyleChangeClass))

typedef struct _UndoStyleChange UndoStyleChange;
typedef struct _UndoStyleChangeClass UndoStyleChangeClass;
typedef struct _UndoStyleChangePrivate UndoStyleChangePrivate;

#define TYPE_STYLE (style_get_type ())
#define STYLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_STYLE, Style))
#define STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_STYLE, StyleClass))
#define IS_STYLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_STYLE))
#define IS_STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_STYLE))
#define STYLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_STYLE, StyleClass))

typedef struct _Style Style;
typedef struct _StyleClass StyleClass;

#define TYPE_UNDO_STYLE_NODE_MARGIN (undo_style_node_margin_get_type ())
#define UNDO_STYLE_NODE_MARGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_UNDO_STYLE_NODE_MARGIN, UndoStyleNodeMargin))
#define UNDO_STYLE_NODE_MARGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_UNDO_STYLE_NODE_MARGIN, UndoStyleNodeMarginClass))
#define IS_UNDO_STYLE_NODE_MARGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_UNDO_STYLE_NODE_MARGIN))
#define IS_UNDO_STYLE_NODE_MARGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_UNDO_STYLE_NODE_MARGIN))
#define UNDO_STYLE_NODE_MARGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_UNDO_STYLE_NODE_MARGIN, UndoStyleNodeMarginClass))

typedef struct _UndoStyleNodeMargin UndoStyleNodeMargin;
typedef struct _UndoStyleNodeMarginClass UndoStyleNodeMarginClass;
typedef struct _UndoStyleNodeMarginPrivate UndoStyleNodeMarginPrivate;
enum  {
	UNDO_STYLE_NODE_MARGIN_0_PROPERTY,
	UNDO_STYLE_NODE_MARGIN_NUM_PROPERTIES
};
static GParamSpec* undo_style_node_margin_properties[UNDO_STYLE_NODE_MARGIN_NUM_PROPERTIES];
#define _g_ptr_array_unref0(var) ((var == NULL) ? NULL : (var = (g_ptr_array_unref (var), NULL)))
typedef enum  {
	STYLE_AFFECTS_ALL = 0,
	STYLE_AFFECTS_SELECTED_NODES,
	STYLE_AFFECTS_SELECTED_CONNECTIONS,
	STYLE_AFFECTS_SELECTED_CALLOUTS,
	STYLE_AFFECTS_NUM
} StyleAffects;

#define TYPE_STYLE_AFFECTS (style_affects_get_type ())

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 _UndoStyleChange {
	UndoItem parent_instance;
	UndoStyleChangePrivate * priv;
};

struct _UndoStyleChangeClass {
	UndoItemClass parent_class;
	void (*load_style_value) (UndoStyleChange* self, Style* style);
	void (*store_style_value) (UndoStyleChange* self, Style* style, gint index);
};

struct _UndoStyleNodeMargin {
	UndoStyleChange parent_instance;
	UndoStyleNodeMarginPrivate * priv;
};

struct _UndoStyleNodeMarginClass {
	UndoStyleChangeClass parent_class;
};

struct _UndoStyleNodeMarginPrivate {
	GPtrArray* _values;
};

static gint UndoStyleNodeMargin_private_offset;
static gpointer undo_style_node_margin_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 GType undo_style_change_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (UndoStyleChange, g_object_unref)
VALA_EXTERN gpointer style_ref (gpointer instance);
VALA_EXTERN void style_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_style (const gchar* name,
                              const gchar* nick,
                              const gchar* blurb,
                              GType object_type,
                              GParamFlags flags);
VALA_EXTERN void value_set_style (GValue* value,
                      gpointer v_object);
VALA_EXTERN void value_take_style (GValue* value,
                       gpointer v_object);
VALA_EXTERN gpointer value_get_style (const GValue* value);
VALA_EXTERN GType style_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Style, style_unref)
VALA_EXTERN GType undo_style_node_margin_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (UndoStyleNodeMargin, g_object_unref)
VALA_EXTERN void undo_style_change_load_style_value (UndoStyleChange* self,
                                         Style* style);
VALA_EXTERN void undo_style_change_store_style_value (UndoStyleChange* self,
                                          Style* style,
                                          gint index);
VALA_EXTERN void undo_item_replace_with_item (UndoItem* self,
                                  UndoItem* item);
VALA_EXTERN GType style_affects_get_type (void) G_GNUC_CONST ;
VALA_EXTERN UndoStyleNodeMargin* undo_style_node_margin_new (StyleAffects affects,
                                                 gint node_margin,
                                                 MindMap* map);
VALA_EXTERN UndoStyleNodeMargin* undo_style_node_margin_construct (GType object_type,
                                                       StyleAffects affects,
                                                       gint node_margin,
                                                       MindMap* map);
VALA_EXTERN UndoStyleChange* undo_style_change_new (StyleAffects affects,
                                        MindMap* map);
VALA_EXTERN UndoStyleChange* undo_style_change_construct (GType object_type,
                                              StyleAffects affects,
                                              MindMap* map);
VALA_EXTERN void undo_style_change_load_styles (UndoStyleChange* self,
                                    MindMap* map);
static void undo_style_node_margin_real_load_style_value (UndoStyleChange* base,
                                                   Style* style);
VALA_EXTERN gint style_get_node_margin (Style* self);
static void undo_style_node_margin_real_store_style_value (UndoStyleChange* base,
                                                    Style* style,
                                                    gint index);
VALA_EXTERN void style_set_node_margin (Style* self,
                            gint value);
static void undo_style_node_margin_real_replace_with_item (UndoItem* base,
                                                    UndoItem* item);
static void undo_style_node_margin_finalize (GObject * obj);
static GType undo_style_node_margin_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
undo_style_node_margin_get_instance_private (UndoStyleNodeMargin* self)
{
	return G_STRUCT_MEMBER_P (self, UndoStyleNodeMargin_private_offset);
}

UndoStyleNodeMargin*
undo_style_node_margin_construct (GType object_type,
                                  StyleAffects affects,
                                  gint node_margin,
                                  MindMap* map)
{
	UndoStyleNodeMargin * self = NULL;
	GPtrArray* _tmp0_;
	GPtrArray* _tmp1_;
	g_return_val_if_fail (map != NULL, NULL);
	self = (UndoStyleNodeMargin*) undo_style_change_construct (object_type, affects, map);
	_tmp0_ = g_ptr_array_new_full ((guint) 0, NULL);
	_g_ptr_array_unref0 (self->priv->_values);
	self->priv->_values = _tmp0_;
	_tmp1_ = self->priv->_values;
	g_ptr_array_add (_tmp1_, (gpointer) ((gintptr) node_margin));
	undo_style_change_load_styles ((UndoStyleChange*) self, map);
	return self;
}

UndoStyleNodeMargin*
undo_style_node_margin_new (StyleAffects affects,
                            gint node_margin,
                            MindMap* map)
{
	return undo_style_node_margin_construct (TYPE_UNDO_STYLE_NODE_MARGIN, affects, node_margin, map);
}

static void
undo_style_node_margin_real_load_style_value (UndoStyleChange* base,
                                              Style* style)
{
	UndoStyleNodeMargin * self;
	GPtrArray* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	self = (UndoStyleNodeMargin*) base;
	g_return_if_fail (style != NULL);
	_tmp0_ = self->priv->_values;
	_tmp1_ = style_get_node_margin (style);
	_tmp2_ = _tmp1_;
	g_ptr_array_add (_tmp0_, (gpointer) ((gintptr) _tmp2_));
}

static void
undo_style_node_margin_real_store_style_value (UndoStyleChange* base,
                                               Style* style,
                                               gint index)
{
	UndoStyleNodeMargin * self;
	GPtrArray* _tmp0_;
	gconstpointer _tmp1_;
	self = (UndoStyleNodeMargin*) base;
	g_return_if_fail (style != NULL);
	_tmp0_ = self->priv->_values;
	_tmp1_ = g_ptr_array_index (_tmp0_, (guint) index);
	style_set_node_margin (style, (gint) ((gintptr) _tmp1_));
}

static void
g_ptr_array_set (GPtrArray* self,
                 guint index,
                 gpointer data)
{
	gpointer _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = data;
	data = NULL;
	g_ptr_array_add (self, _tmp0_);
	g_ptr_array_remove_index_fast (self, index);
}

static void
undo_style_node_margin_real_replace_with_item (UndoItem* base,
                                               UndoItem* item)
{
	UndoStyleNodeMargin * self;
	GPtrArray* _tmp0_;
	GPtrArray* _tmp1_;
	gconstpointer _tmp2_;
	self = (UndoStyleNodeMargin*) base;
	g_return_if_fail (item != NULL);
	_tmp0_ = self->priv->_values;
	_tmp1_ = G_TYPE_CHECK_INSTANCE_CAST (item, TYPE_UNDO_STYLE_NODE_MARGIN, UndoStyleNodeMargin)->priv->_values;
	_tmp2_ = g_ptr_array_index (_tmp1_, (guint) 0);
	g_ptr_array_set (_tmp0_, (guint) 0, (gpointer) ((gintptr) _tmp2_));
}

static void
undo_style_node_margin_class_init (UndoStyleNodeMarginClass * klass,
                                   gpointer klass_data)
{
	undo_style_node_margin_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &UndoStyleNodeMargin_private_offset);
	((UndoStyleChangeClass *) klass)->load_style_value = (void (*) (UndoStyleChange*, Style*)) undo_style_node_margin_real_load_style_value;
	((UndoStyleChangeClass *) klass)->store_style_value = (void (*) (UndoStyleChange*, Style*, gint)) undo_style_node_margin_real_store_style_value;
	((UndoItemClass *) klass)->replace_with_item = (void (*) (UndoItem*, UndoItem*)) undo_style_node_margin_real_replace_with_item;
	G_OBJECT_CLASS (klass)->finalize = undo_style_node_margin_finalize;
}

static void
undo_style_node_margin_instance_init (UndoStyleNodeMargin * self,
                                      gpointer klass)
{
	self->priv = undo_style_node_margin_get_instance_private (self);
}

static void
undo_style_node_margin_finalize (GObject * obj)
{
	UndoStyleNodeMargin * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_UNDO_STYLE_NODE_MARGIN, UndoStyleNodeMargin);
	_g_ptr_array_unref0 (self->priv->_values);
	G_OBJECT_CLASS (undo_style_node_margin_parent_class)->finalize (obj);
}

static GType
undo_style_node_margin_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (UndoStyleNodeMarginClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) undo_style_node_margin_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UndoStyleNodeMargin), 0, (GInstanceInitFunc) undo_style_node_margin_instance_init, NULL };
	GType undo_style_node_margin_type_id;
	undo_style_node_margin_type_id = g_type_register_static (TYPE_UNDO_STYLE_CHANGE, "UndoStyleNodeMargin", &g_define_type_info, 0);
	UndoStyleNodeMargin_private_offset = g_type_add_instance_private (undo_style_node_margin_type_id, sizeof (UndoStyleNodeMarginPrivate));
	return undo_style_node_margin_type_id;
}

GType
undo_style_node_margin_get_type (void)
{
	static volatile gsize undo_style_node_margin_type_id__once = 0;
	if (g_once_init_enter (&undo_style_node_margin_type_id__once)) {
		GType undo_style_node_margin_type_id;
		undo_style_node_margin_type_id = undo_style_node_margin_get_type_once ();
		g_once_init_leave (&undo_style_node_margin_type_id__once, undo_style_node_margin_type_id);
	}
	return undo_style_node_margin_type_id__once;
}

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

