/* UndoNodeSort.c generated by valac 0.56.19, the Vala compiler
 * generated from UndoNodeSort.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>
#include <gobject/gvaluecollector.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_SORT (undo_node_sort_get_type ())
#define UNDO_NODE_SORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_UNDO_NODE_SORT, UndoNodeSort))
#define UNDO_NODE_SORT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_UNDO_NODE_SORT, UndoNodeSortClass))
#define IS_UNDO_NODE_SORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_UNDO_NODE_SORT))
#define IS_UNDO_NODE_SORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_UNDO_NODE_SORT))
#define UNDO_NODE_SORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_UNDO_NODE_SORT, UndoNodeSortClass))

typedef struct _UndoNodeSort UndoNodeSort;
typedef struct _UndoNodeSortClass UndoNodeSortClass;
typedef struct _UndoNodeSortPrivate UndoNodeSortPrivate;

#define UNDO_NODE_SORT_TYPE_SORT_NODES (undo_node_sort_sort_nodes_get_type ())
#define UNDO_NODE_SORT_SORT_NODES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNDO_NODE_SORT_TYPE_SORT_NODES, UndoNodeSortSortNodes))
#define UNDO_NODE_SORT_SORT_NODES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNDO_NODE_SORT_TYPE_SORT_NODES, UndoNodeSortSortNodesClass))
#define UNDO_NODE_SORT_IS_SORT_NODES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNDO_NODE_SORT_TYPE_SORT_NODES))
#define UNDO_NODE_SORT_IS_SORT_NODES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNDO_NODE_SORT_TYPE_SORT_NODES))
#define UNDO_NODE_SORT_SORT_NODES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNDO_NODE_SORT_TYPE_SORT_NODES, UndoNodeSortSortNodesClass))

typedef struct _UndoNodeSortSortNodes UndoNodeSortSortNodes;
typedef struct _UndoNodeSortSortNodesClass UndoNodeSortSortNodesClass;

#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_SORT_0_PROPERTY,
	UNDO_NODE_SORT_NUM_PROPERTIES
};
static GParamSpec* undo_node_sort_properties[UNDO_NODE_SORT_NUM_PROPERTIES];
#define _undo_node_sort_sort_nodes_unref0(var) ((var == NULL) ? NULL : (var = (undo_node_sort_sort_nodes_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_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_array_unref0(var) ((var == NULL) ? NULL : (var = (g_array_unref (var), NULL)))
typedef struct _UndoNodeSortSortNodesPrivate UndoNodeSortSortNodesPrivate;
typedef enum  {
	NODE_SIDE_LEFT = 1,
	NODE_SIDE_TOP = 2,
	NODE_SIDE_RIGHT = 4,
	NODE_SIDE_BOTTOM = 8
} NodeSide;

#define TYPE_NODE_SIDE (node_side_get_type ())

#define TYPE_THEME (theme_get_type ())
#define THEME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_THEME, Theme))
#define THEME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_THEME, ThemeClass))
#define IS_THEME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_THEME))
#define IS_THEME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_THEME))
#define THEME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_THEME, ThemeClass))

typedef struct _Theme Theme;
typedef struct _ThemeClass ThemeClass;
typedef struct _UndoNodeSortParamSpecSortNodes UndoNodeSortParamSpecSortNodes;

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 _UndoNodeSort {
	UndoItem parent_instance;
	UndoNodeSortPrivate * priv;
};

struct _UndoNodeSortClass {
	UndoItemClass parent_class;
};

struct _UndoNodeSortPrivate {
	UndoNodeSortSortNodes* _old;
	UndoNodeSortSortNodes* _new;
	Node* _parent;
};

struct _UndoNodeSortSortNodes {
	GTypeInstance parent_instance;
	volatile int ref_count;
	UndoNodeSortSortNodesPrivate * priv;
};

struct _UndoNodeSortSortNodesClass {
	GTypeClass parent_class;
	void (*finalize) (UndoNodeSortSortNodes *self);
};

struct _UndoNodeSortSortNodesPrivate {
	GArray* _nodes;
};

struct _UndoNodeSortParamSpecSortNodes {
	GParamSpec parent_instance;
};

static gint UndoNodeSort_private_offset;
static gpointer undo_node_sort_parent_class = NULL;
static gint UndoNodeSortSortNodes_private_offset;
static gpointer undo_node_sort_sort_nodes_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_sort_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (UndoNodeSort, g_object_unref)
static gpointer undo_node_sort_sort_nodes_ref (gpointer instance);
static void undo_node_sort_sort_nodes_unref (gpointer instance);
static GParamSpec* undo_node_sort_param_spec_sort_nodes (const gchar* name,
                                                  const gchar* nick,
                                                  const gchar* blurb,
                                                  GType object_type,
                                                  GParamFlags flags) G_GNUC_UNUSED ;
static void undo_node_sort_value_set_sort_nodes (GValue* value,
                                          gpointer v_object) G_GNUC_UNUSED ;
static void undo_node_sort_value_take_sort_nodes (GValue* value,
                                           gpointer v_object) G_GNUC_UNUSED ;
static gpointer undo_node_sort_value_get_sort_nodes (const GValue* value) G_GNUC_UNUSED ;
static GType undo_node_sort_sort_nodes_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (UndoNodeSortSortNodes, undo_node_sort_sort_nodes_unref)
VALA_EXTERN GType node_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Node, g_object_unref)
VALA_EXTERN void undo_item_undo (UndoItem* self,
                     MindMap* map);
VALA_EXTERN void undo_item_redo (UndoItem* self,
                     MindMap* map);
VALA_EXTERN UndoNodeSort* undo_node_sort_new (Node* parent);
VALA_EXTERN UndoNodeSort* undo_node_sort_construct (GType object_type,
                                        Node* parent);
VALA_EXTERN UndoItem* undo_item_new (const gchar* name);
VALA_EXTERN UndoItem* undo_item_construct (GType object_type,
                               const gchar* name);
static UndoNodeSortSortNodes* undo_node_sort_sort_nodes_new (Node* n);
static UndoNodeSortSortNodes* undo_node_sort_sort_nodes_construct (GType object_type,
                                                            Node* n);
static void undo_node_sort_change (UndoNodeSort* self,
                            MindMap* map,
                            UndoNodeSortSortNodes* nodes);
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);
static void undo_node_sort_sort_nodes_change (UndoNodeSortSortNodes* self,
                                       Node* parent);
VALA_EXTERN void animator_animate (Animator* self);
static void undo_node_sort_real_undo (UndoItem* base,
                               MindMap* map);
static void undo_node_sort_real_redo (UndoItem* base,
                               MindMap* map);
static void _g_object_unref0_ (gpointer var);
static void _vala_Node_free_function_content_of (gpointer data);
VALA_EXTERN GArray* node_children (Node* self);
VALA_EXTERN GType node_side_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void node_detach (Node* self,
                  NodeSide side);
VALA_EXTERN NodeSide node_get_side (Node* self);
VALA_EXTERN GType theme_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Theme, g_object_unref)
VALA_EXTERN void node_attach (Node* self,
                  Node* parent,
                  gint idx,
                  Theme* theme,
                  gboolean set_side);
static void undo_node_sort_sort_nodes_finalize (UndoNodeSortSortNodes * obj);
static GType undo_node_sort_sort_nodes_get_type_once (void);
static void undo_node_sort_finalize (GObject * obj);
static GType undo_node_sort_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
undo_node_sort_get_instance_private (UndoNodeSort* self)
{
	return G_STRUCT_MEMBER_P (self, UndoNodeSort_private_offset);
}

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

UndoNodeSort*
undo_node_sort_construct (GType object_type,
                          Node* parent)
{
	UndoNodeSort * self = NULL;
	Node* _tmp0_;
	UndoNodeSortSortNodes* _tmp1_;
	g_return_val_if_fail (parent != NULL, NULL);
	self = (UndoNodeSort*) undo_item_construct (object_type, _ ("sort nodes"));
	_tmp0_ = _g_object_ref0 (parent);
	_g_object_unref0 (self->priv->_parent);
	self->priv->_parent = _tmp0_;
	_tmp1_ = undo_node_sort_sort_nodes_new (parent);
	_undo_node_sort_sort_nodes_unref0 (self->priv->_old);
	self->priv->_old = _tmp1_;
	return self;
}

UndoNodeSort*
undo_node_sort_new (Node* parent)
{
	return undo_node_sort_construct (TYPE_UNDO_NODE_SORT, parent);
}

static void
undo_node_sort_change (UndoNodeSort* self,
                       MindMap* map,
                       UndoNodeSortSortNodes* nodes)
{
	Animator* _tmp0_;
	Animator* _tmp1_;
	GArray* _tmp2_;
	GArray* _tmp3_;
	Node* _tmp4_;
	Animator* _tmp5_;
	Animator* _tmp6_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (map != NULL);
	g_return_if_fail (nodes != NULL);
	_tmp0_ = mind_map_get_animator (map);
	_tmp1_ = _tmp0_;
	_tmp2_ = mind_map_get_nodes (map);
	_tmp3_ = _tmp2_;
	animator_add_nodes (_tmp1_, _tmp3_, FALSE, "undo sorted nodes");
	_g_array_unref0 (_tmp3_);
	_tmp4_ = self->priv->_parent;
	undo_node_sort_sort_nodes_change (nodes, _tmp4_);
	_tmp5_ = mind_map_get_animator (map);
	_tmp6_ = _tmp5_;
	animator_animate (_tmp6_);
}

static void
undo_node_sort_real_undo (UndoItem* base,
                          MindMap* map)
{
	UndoNodeSort * self;
	UndoNodeSortSortNodes* _tmp0_;
	UndoNodeSortSortNodes* _tmp3_;
	self = (UndoNodeSort*) base;
	g_return_if_fail (map != NULL);
	_tmp0_ = self->priv->_new;
	if (_tmp0_ == NULL) {
		Node* _tmp1_;
		UndoNodeSortSortNodes* _tmp2_;
		_tmp1_ = self->priv->_parent;
		_tmp2_ = undo_node_sort_sort_nodes_new (_tmp1_);
		_undo_node_sort_sort_nodes_unref0 (self->priv->_new);
		self->priv->_new = _tmp2_;
	}
	_tmp3_ = self->priv->_old;
	undo_node_sort_change (self, map, _tmp3_);
}

static void
undo_node_sort_real_redo (UndoItem* base,
                          MindMap* map)
{
	UndoNodeSort * self;
	UndoNodeSortSortNodes* _tmp0_;
	self = (UndoNodeSort*) base;
	g_return_if_fail (map != NULL);
	_tmp0_ = self->priv->_new;
	undo_node_sort_change (self, map, _tmp0_);
}

static inline gpointer
undo_node_sort_sort_nodes_get_instance_private (UndoNodeSortSortNodes* self)
{
	return G_STRUCT_MEMBER_P (self, UndoNodeSortSortNodes_private_offset);
}

static void
_g_object_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}

static void
_vala_Node_free_function_content_of (gpointer data)
{
	Node* self;
	self = *((Node**) data);
	_g_object_unref0_ (self);
}

static UndoNodeSortSortNodes*
undo_node_sort_sort_nodes_construct (GType object_type,
                                     Node* n)
{
	UndoNodeSortSortNodes* self = NULL;
	GArray* _tmp0_;
	g_return_val_if_fail (n != NULL, NULL);
	self = (UndoNodeSortSortNodes*) g_type_create_instance (object_type);
	_tmp0_ = g_array_new (TRUE, TRUE, sizeof (Node*));
	g_array_set_clear_func (_tmp0_, (GDestroyNotify) _vala_Node_free_function_content_of);
	_g_array_unref0 (self->priv->_nodes);
	self->priv->_nodes = _tmp0_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				GArray* _tmp3_;
				GArray* _tmp4_;
				gboolean _tmp5_;
				GArray* _tmp6_;
				GArray* _tmp7_;
				GArray* _tmp8_;
				Node* _tmp9_;
				Node* _tmp10_;
				if (!_tmp1_) {
					gint _tmp2_;
					_tmp2_ = i;
					i = _tmp2_ + 1;
				}
				_tmp1_ = FALSE;
				_tmp3_ = node_children (n);
				_tmp4_ = _tmp3_;
				_tmp5_ = !(((guint) i) < _tmp4_->len);
				_g_array_unref0 (_tmp4_);
				if (_tmp5_) {
					break;
				}
				_tmp6_ = self->priv->_nodes;
				_tmp7_ = node_children (n);
				_tmp8_ = _tmp7_;
				_tmp9_ = g_array_index (_tmp8_, Node*, (guint) i);
				_tmp10_ = _g_object_ref0 (_tmp9_);
				g_array_append_val (_tmp6_, _tmp10_);
				_g_array_unref0 (_tmp8_);
			}
		}
	}
	return self;
}

static UndoNodeSortSortNodes*
undo_node_sort_sort_nodes_new (Node* n)
{
	return undo_node_sort_sort_nodes_construct (UNDO_NODE_SORT_TYPE_SORT_NODES, n);
}

static void
undo_node_sort_sort_nodes_change (UndoNodeSortSortNodes* self,
                                  Node* parent)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (parent != NULL);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GArray* _tmp2_;
				Node* n = NULL;
				GArray* _tmp3_;
				Node* _tmp4_;
				Node* _tmp5_;
				Node* _tmp6_;
				Node* _tmp7_;
				NodeSide _tmp8_;
				NodeSide _tmp9_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = self->priv->_nodes;
				if (!(((guint) i) < _tmp2_->len)) {
					break;
				}
				_tmp3_ = self->priv->_nodes;
				_tmp4_ = g_array_index (_tmp3_, Node*, (guint) i);
				_tmp5_ = _g_object_ref0 (_tmp4_);
				n = _tmp5_;
				_tmp6_ = n;
				_tmp7_ = n;
				_tmp8_ = node_get_side (_tmp7_);
				_tmp9_ = _tmp8_;
				node_detach (_tmp6_, _tmp9_);
				_g_object_unref0 (n);
			}
		}
	}
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp10_ = FALSE;
			_tmp10_ = TRUE;
			while (TRUE) {
				GArray* _tmp12_;
				Node* n = NULL;
				GArray* _tmp13_;
				Node* _tmp14_;
				Node* _tmp15_;
				Node* _tmp16_;
				if (!_tmp10_) {
					gint _tmp11_;
					_tmp11_ = i;
					i = _tmp11_ + 1;
				}
				_tmp10_ = FALSE;
				_tmp12_ = self->priv->_nodes;
				if (!(((guint) i) < _tmp12_->len)) {
					break;
				}
				_tmp13_ = self->priv->_nodes;
				_tmp14_ = g_array_index (_tmp13_, Node*, (guint) i);
				_tmp15_ = _g_object_ref0 (_tmp14_);
				n = _tmp15_;
				_tmp16_ = n;
				node_attach (_tmp16_, parent, -1, NULL, TRUE);
				_g_object_unref0 (n);
			}
		}
	}
}

static void
undo_node_sort_value_sort_nodes_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
undo_node_sort_value_sort_nodes_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		undo_node_sort_sort_nodes_unref (value->data[0].v_pointer);
	}
}

static void
undo_node_sort_value_sort_nodes_copy_value (const GValue* src_value,
                                            GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = undo_node_sort_sort_nodes_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
undo_node_sort_value_sort_nodes_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
undo_node_sort_value_sort_nodes_collect_value (GValue* value,
                                               guint n_collect_values,
                                               GTypeCValue* collect_values,
                                               guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		UndoNodeSortSortNodes * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = undo_node_sort_sort_nodes_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
undo_node_sort_value_sort_nodes_lcopy_value (const GValue* value,
                                             guint n_collect_values,
                                             GTypeCValue* collect_values,
                                             guint collect_flags)
{
	UndoNodeSortSortNodes ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = undo_node_sort_sort_nodes_ref (value->data[0].v_pointer);
	}
	return NULL;
}

static GParamSpec*
undo_node_sort_param_spec_sort_nodes (const gchar* name,
                                      const gchar* nick,
                                      const gchar* blurb,
                                      GType object_type,
                                      GParamFlags flags)
{
	UndoNodeSortParamSpecSortNodes* spec;
	g_return_val_if_fail (g_type_is_a (object_type, UNDO_NODE_SORT_TYPE_SORT_NODES), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

static gpointer
undo_node_sort_value_get_sort_nodes (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, UNDO_NODE_SORT_TYPE_SORT_NODES), NULL);
	return value->data[0].v_pointer;
}

static void
undo_node_sort_value_set_sort_nodes (GValue* value,
                                     gpointer v_object)
{
	UndoNodeSortSortNodes * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, UNDO_NODE_SORT_TYPE_SORT_NODES));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, UNDO_NODE_SORT_TYPE_SORT_NODES));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		undo_node_sort_sort_nodes_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		undo_node_sort_sort_nodes_unref (old);
	}
}

static void
undo_node_sort_value_take_sort_nodes (GValue* value,
                                      gpointer v_object)
{
	UndoNodeSortSortNodes * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, UNDO_NODE_SORT_TYPE_SORT_NODES));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, UNDO_NODE_SORT_TYPE_SORT_NODES));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		undo_node_sort_sort_nodes_unref (old);
	}
}

static void
undo_node_sort_sort_nodes_class_init (UndoNodeSortSortNodesClass * klass,
                                      gpointer klass_data)
{
	undo_node_sort_sort_nodes_parent_class = g_type_class_peek_parent (klass);
	((UndoNodeSortSortNodesClass *) klass)->finalize = undo_node_sort_sort_nodes_finalize;
	g_type_class_adjust_private_offset (klass, &UndoNodeSortSortNodes_private_offset);
}

static void
undo_node_sort_sort_nodes_instance_init (UndoNodeSortSortNodes * self,
                                         gpointer klass)
{
	self->priv = undo_node_sort_sort_nodes_get_instance_private (self);
	self->ref_count = 1;
}

static void
undo_node_sort_sort_nodes_finalize (UndoNodeSortSortNodes * obj)
{
	UndoNodeSortSortNodes * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, UNDO_NODE_SORT_TYPE_SORT_NODES, UndoNodeSortSortNodes);
	g_signal_handlers_destroy (self);
	_g_array_unref0 (self->priv->_nodes);
}

static GType
undo_node_sort_sort_nodes_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { undo_node_sort_value_sort_nodes_init, undo_node_sort_value_sort_nodes_free_value, undo_node_sort_value_sort_nodes_copy_value, undo_node_sort_value_sort_nodes_peek_pointer, "p", undo_node_sort_value_sort_nodes_collect_value, "p", undo_node_sort_value_sort_nodes_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (UndoNodeSortSortNodesClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) undo_node_sort_sort_nodes_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UndoNodeSortSortNodes), 0, (GInstanceInitFunc) undo_node_sort_sort_nodes_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType undo_node_sort_sort_nodes_type_id;
	undo_node_sort_sort_nodes_type_id = g_type_register_fundamental (g_type_fundamental_next (), "UndoNodeSortSortNodes", &g_define_type_info, &g_define_type_fundamental_info, 0);
	UndoNodeSortSortNodes_private_offset = g_type_add_instance_private (undo_node_sort_sort_nodes_type_id, sizeof (UndoNodeSortSortNodesPrivate));
	return undo_node_sort_sort_nodes_type_id;
}

static GType
undo_node_sort_sort_nodes_get_type (void)
{
	static volatile gsize undo_node_sort_sort_nodes_type_id__once = 0;
	if (g_once_init_enter (&undo_node_sort_sort_nodes_type_id__once)) {
		GType undo_node_sort_sort_nodes_type_id;
		undo_node_sort_sort_nodes_type_id = undo_node_sort_sort_nodes_get_type_once ();
		g_once_init_leave (&undo_node_sort_sort_nodes_type_id__once, undo_node_sort_sort_nodes_type_id);
	}
	return undo_node_sort_sort_nodes_type_id__once;
}

static gpointer
undo_node_sort_sort_nodes_ref (gpointer instance)
{
	UndoNodeSortSortNodes * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

static void
undo_node_sort_sort_nodes_unref (gpointer instance)
{
	UndoNodeSortSortNodes * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		UNDO_NODE_SORT_SORT_NODES_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static void
undo_node_sort_class_init (UndoNodeSortClass * klass,
                           gpointer klass_data)
{
	undo_node_sort_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &UndoNodeSort_private_offset);
	((UndoItemClass *) klass)->undo = (void (*) (UndoItem*, MindMap*)) undo_node_sort_real_undo;
	((UndoItemClass *) klass)->redo = (void (*) (UndoItem*, MindMap*)) undo_node_sort_real_redo;
	G_OBJECT_CLASS (klass)->finalize = undo_node_sort_finalize;
}

static void
undo_node_sort_instance_init (UndoNodeSort * self,
                              gpointer klass)
{
	self->priv = undo_node_sort_get_instance_private (self);
	self->priv->_new = NULL;
}

static void
undo_node_sort_finalize (GObject * obj)
{
	UndoNodeSort * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_UNDO_NODE_SORT, UndoNodeSort);
	_undo_node_sort_sort_nodes_unref0 (self->priv->_old);
	_undo_node_sort_sort_nodes_unref0 (self->priv->_new);
	_g_object_unref0 (self->priv->_parent);
	G_OBJECT_CLASS (undo_node_sort_parent_class)->finalize (obj);
}

static GType
undo_node_sort_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (UndoNodeSortClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) undo_node_sort_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UndoNodeSort), 0, (GInstanceInitFunc) undo_node_sort_instance_init, NULL };
	GType undo_node_sort_type_id;
	undo_node_sort_type_id = g_type_register_static (TYPE_UNDO_ITEM, "UndoNodeSort", &g_define_type_info, 0);
	UndoNodeSort_private_offset = g_type_add_instance_private (undo_node_sort_type_id, sizeof (UndoNodeSortPrivate));
	return undo_node_sort_type_id;
}

GType
undo_node_sort_get_type (void)
{
	static volatile gsize undo_node_sort_type_id__once = 0;
	if (g_once_init_enter (&undo_node_sort_type_id__once)) {
		GType undo_node_sort_type_id;
		undo_node_sort_type_id = undo_node_sort_get_type_once ();
		g_once_init_leave (&undo_node_sort_type_id__once, undo_node_sort_type_id);
	}
	return undo_node_sort_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;
}

