/* UndoNodeTasks.c generated by valac 0.56.19, the Vala compiler
 * generated from UndoNodeTasks.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>
#include <glib/gi18n-lib.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_NODE_TASKS (undo_node_tasks_get_type ())
#define UNDO_NODE_TASKS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_UNDO_NODE_TASKS, UndoNodeTasks))
#define UNDO_NODE_TASKS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_UNDO_NODE_TASKS, UndoNodeTasksClass))
#define IS_UNDO_NODE_TASKS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_UNDO_NODE_TASKS))
#define IS_UNDO_NODE_TASKS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_UNDO_NODE_TASKS))
#define UNDO_NODE_TASKS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_UNDO_NODE_TASKS, UndoNodeTasksClass))

typedef struct _UndoNodeTasks UndoNodeTasks;
typedef struct _UndoNodeTasksClass UndoNodeTasksClass;
typedef struct _UndoNodeTasksPrivate UndoNodeTasksPrivate;

#define TYPE_NODE_TASK_INFO (node_task_info_get_type ())
typedef struct _NodeTaskInfo NodeTaskInfo;

#define TYPE_NODE (node_get_type ())
#define NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_NODE, Node))
#define NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_NODE, NodeClass))
#define IS_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_NODE))
#define IS_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_NODE))
#define NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_NODE, NodeClass))

typedef struct _Node Node;
typedef struct _NodeClass NodeClass;
enum  {
	UNDO_NODE_TASKS_0_PROPERTY,
	UNDO_NODE_TASKS_NUM_PROPERTIES
};
static GParamSpec* undo_node_tasks_properties[UNDO_NODE_TASKS_NUM_PROPERTIES];
#define _g_array_unref0(var) ((var == NULL) ? NULL : (var = (g_array_unref (var), NULL)))

#define TYPE_ANIMATOR (animator_get_type ())
#define ANIMATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ANIMATOR, Animator))
#define ANIMATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ANIMATOR, AnimatorClass))
#define IS_ANIMATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ANIMATOR))
#define IS_ANIMATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ANIMATOR))
#define ANIMATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ANIMATOR, AnimatorClass))

typedef struct _Animator Animator;
typedef struct _AnimatorClass AnimatorClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

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 _UndoNodeTasks {
	UndoItem parent_instance;
	UndoNodeTasksPrivate * priv;
};

struct _UndoNodeTasksClass {
	UndoItemClass parent_class;
};

struct _NodeTaskInfo {
	gboolean enabled;
	gboolean done;
	Node* node;
};

struct _UndoNodeTasksPrivate {
	GArray* _task_info;
};

static gint UndoNodeTasks_private_offset;
static gpointer undo_node_tasks_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_node_tasks_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (UndoNodeTasks, g_object_unref)
VALA_EXTERN GType node_task_info_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType node_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Node, g_object_unref)
VALA_EXTERN NodeTaskInfo* node_task_info_dup (const NodeTaskInfo* self);
VALA_EXTERN void node_task_info_free (NodeTaskInfo* self);
VALA_EXTERN void node_task_info_copy (const NodeTaskInfo* self,
                          NodeTaskInfo* dest);
VALA_EXTERN void node_task_info_destroy (NodeTaskInfo* self);
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (NodeTaskInfo, node_task_info_destroy)
VALA_EXTERN void undo_item_undo (UndoItem* self,
                     MindMap* map);
VALA_EXTERN void undo_item_redo (UndoItem* self,
                     MindMap* map);
VALA_EXTERN UndoNodeTasks* undo_node_tasks_new (GArray* task_info);
VALA_EXTERN UndoNodeTasks* undo_node_tasks_construct (GType object_type,
                                          GArray* task_info);
VALA_EXTERN UndoItem* undo_item_new (const gchar* name);
VALA_EXTERN UndoItem* undo_item_construct (GType object_type,
                               const gchar* name);
static void undo_node_tasks_update (UndoNodeTasks* self,
                             MindMap* map);
VALA_EXTERN GType animator_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Animator, g_object_unref)
VALA_EXTERN Animator* mind_map_get_animator (MindMap* self);
VALA_EXTERN void animator_add_nodes (Animator* self,
                         GArray* n,
                         gboolean exclude_selected,
                         const gchar* name);
VALA_EXTERN GArray* mind_map_get_nodes (MindMap* self);
VALA_EXTERN gboolean node_task_enabled (Node* self);
VALA_EXTERN gboolean node_task_done (Node* self);
VALA_EXTERN void node_enable_task (Node* self,
                       gboolean task);
VALA_EXTERN void node_set_task_done (Node* self,
                         gboolean done);
VALA_EXTERN void animator_animate (Animator* self);
VALA_EXTERN void mind_map_auto_save (MindMap* self);
static void undo_node_tasks_real_undo (UndoItem* base,
                                MindMap* map);
static void undo_node_tasks_real_redo (UndoItem* base,
                                MindMap* map);
static void undo_node_tasks_finalize (GObject * obj);
static GType undo_node_tasks_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
undo_node_tasks_get_instance_private (UndoNodeTasks* self)
{
	return G_STRUCT_MEMBER_P (self, UndoNodeTasks_private_offset);
}

static gpointer
_g_array_ref0 (gpointer self)
{
	return self ? g_array_ref (self) : NULL;
}

UndoNodeTasks*
undo_node_tasks_construct (GType object_type,
                           GArray* task_info)
{
	UndoNodeTasks * self = NULL;
	GArray* _tmp0_;
	g_return_val_if_fail (task_info != NULL, NULL);
	self = (UndoNodeTasks*) undo_item_construct (object_type, _ ("node task changes"));
	_tmp0_ = _g_array_ref0 (task_info);
	_g_array_unref0 (self->priv->_task_info);
	self->priv->_task_info = _tmp0_;
	return self;
}

UndoNodeTasks*
undo_node_tasks_new (GArray* task_info)
{
	return undo_node_tasks_construct (TYPE_UNDO_NODE_TASKS, task_info);
}

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

static void
undo_node_tasks_update (UndoNodeTasks* self,
                        MindMap* map)
{
	Animator* _tmp0_;
	Animator* _tmp1_;
	GArray* _tmp2_;
	GArray* _tmp3_;
	Animator* _tmp20_;
	Animator* _tmp21_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (map != NULL);
	_tmp0_ = mind_map_get_animator (map);
	_tmp1_ = _tmp0_;
	_tmp2_ = mind_map_get_nodes (map);
	_tmp3_ = _tmp2_;
	animator_add_nodes (_tmp1_, _tmp3_, FALSE, "UndoNodeTasks update");
	_g_array_unref0 (_tmp3_);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp4_ = FALSE;
			_tmp4_ = TRUE;
			while (TRUE) {
				GArray* _tmp6_;
				GArray* _tmp7_;
				Node* node = NULL;
				GArray* _tmp8_;
				Node* _tmp9_;
				Node* _tmp10_;
				Node* _tmp11_;
				gboolean enabled = FALSE;
				Node* _tmp12_;
				gboolean done = FALSE;
				Node* _tmp13_;
				Node* _tmp14_;
				GArray* _tmp15_;
				Node* _tmp16_;
				GArray* _tmp17_;
				GArray* _tmp18_;
				GArray* _tmp19_;
				if (!_tmp4_) {
					gint _tmp5_;
					_tmp5_ = i;
					i = _tmp5_ + 1;
				}
				_tmp4_ = FALSE;
				_tmp6_ = self->priv->_task_info;
				if (!(((guint) i) < _tmp6_->len)) {
					break;
				}
				_tmp7_ = self->priv->_task_info;
				_vala_assert (g_array_index (_tmp7_, NodeTaskInfo*, (guint) i) != NULL, "_task_info.index( i ) != null");
				_tmp8_ = self->priv->_task_info;
				_tmp9_ = (*g_array_index (_tmp8_, NodeTaskInfo*, (guint) i)).node;
				_tmp10_ = _g_object_ref0 (_tmp9_);
				node = _tmp10_;
				_tmp11_ = node;
				_vala_assert (_tmp11_ != NULL, "node != null");
				_tmp12_ = node;
				enabled = node_task_enabled (_tmp12_);
				_tmp13_ = node;
				done = node_task_done (_tmp13_);
				_tmp14_ = node;
				_tmp15_ = self->priv->_task_info;
				node_enable_task (_tmp14_, (*g_array_index (_tmp15_, NodeTaskInfo*, (guint) i)).enabled);
				_tmp16_ = node;
				_tmp17_ = self->priv->_task_info;
				node_set_task_done (_tmp16_, (*g_array_index (_tmp17_, NodeTaskInfo*, (guint) i)).done);
				_tmp18_ = self->priv->_task_info;
				(*g_array_index (_tmp18_, NodeTaskInfo*, (guint) i)).enabled = enabled;
				_tmp19_ = self->priv->_task_info;
				(*g_array_index (_tmp19_, NodeTaskInfo*, (guint) i)).done = done;
				_g_object_unref0 (node);
			}
		}
	}
	g_signal_emit_by_name (map, "current-changed", map);
	_tmp20_ = mind_map_get_animator (map);
	_tmp21_ = _tmp20_;
	animator_animate (_tmp21_);
	mind_map_auto_save (map);
}

static void
undo_node_tasks_real_undo (UndoItem* base,
                           MindMap* map)
{
	UndoNodeTasks * self;
	self = (UndoNodeTasks*) base;
	g_return_if_fail (map != NULL);
	undo_node_tasks_update (self, map);
}

static void
undo_node_tasks_real_redo (UndoItem* base,
                           MindMap* map)
{
	UndoNodeTasks * self;
	self = (UndoNodeTasks*) base;
	g_return_if_fail (map != NULL);
	undo_node_tasks_update (self, map);
}

static void
undo_node_tasks_class_init (UndoNodeTasksClass * klass,
                            gpointer klass_data)
{
	undo_node_tasks_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &UndoNodeTasks_private_offset);
	((UndoItemClass *) klass)->undo = (void (*) (UndoItem*, MindMap*)) undo_node_tasks_real_undo;
	((UndoItemClass *) klass)->redo = (void (*) (UndoItem*, MindMap*)) undo_node_tasks_real_redo;
	G_OBJECT_CLASS (klass)->finalize = undo_node_tasks_finalize;
}

static void
undo_node_tasks_instance_init (UndoNodeTasks * self,
                               gpointer klass)
{
	self->priv = undo_node_tasks_get_instance_private (self);
}

static void
undo_node_tasks_finalize (GObject * obj)
{
	UndoNodeTasks * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_UNDO_NODE_TASKS, UndoNodeTasks);
	_g_array_unref0 (self->priv->_task_info);
	G_OBJECT_CLASS (undo_node_tasks_parent_class)->finalize (obj);
}

static GType
undo_node_tasks_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (UndoNodeTasksClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) undo_node_tasks_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UndoNodeTasks), 0, (GInstanceInitFunc) undo_node_tasks_instance_init, NULL };
	GType undo_node_tasks_type_id;
	undo_node_tasks_type_id = g_type_register_static (TYPE_UNDO_ITEM, "UndoNodeTasks", &g_define_type_info, 0);
	UndoNodeTasks_private_offset = g_type_add_instance_private (undo_node_tasks_type_id, sizeof (UndoNodeTasksPrivate));
	return undo_node_tasks_type_id;
}

GType
undo_node_tasks_get_type (void)
{
	static volatile gsize undo_node_tasks_type_id__once = 0;
	if (g_once_init_enter (&undo_node_tasks_type_id__once)) {
		GType undo_node_tasks_type_id;
		undo_node_tasks_type_id = undo_node_tasks_get_type_once ();
		g_once_init_leave (&undo_node_tasks_type_id__once, undo_node_tasks_type_id);
	}
	return undo_node_tasks_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;
}

