/* UndoNodeAttach.c generated by valac 0.56.19, the Vala compiler
 * generated from UndoNodeAttach.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 <float.h>
#include <math.h>
#include <gdk/gdk.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_ATTACH (undo_node_attach_get_type ())
#define UNDO_NODE_ATTACH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_UNDO_NODE_ATTACH, UndoNodeAttach))
#define UNDO_NODE_ATTACH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_UNDO_NODE_ATTACH, UndoNodeAttachClass))
#define IS_UNDO_NODE_ATTACH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_UNDO_NODE_ATTACH))
#define IS_UNDO_NODE_ATTACH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_UNDO_NODE_ATTACH))
#define UNDO_NODE_ATTACH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_UNDO_NODE_ATTACH, UndoNodeAttachClass))

typedef struct _UndoNodeAttach UndoNodeAttach;
typedef struct _UndoNodeAttachClass UndoNodeAttachClass;
typedef struct _UndoNodeAttachPrivate UndoNodeAttachPrivate;

#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;
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_NODE_INFO (node_info_get_type ())
typedef struct _NodeInfo NodeInfo;

#define TYPE_SUMMARY_NODE (summary_node_get_type ())
#define SUMMARY_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SUMMARY_NODE, SummaryNode))
#define SUMMARY_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SUMMARY_NODE, SummaryNodeClass))
#define IS_SUMMARY_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SUMMARY_NODE))
#define IS_SUMMARY_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SUMMARY_NODE))
#define SUMMARY_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SUMMARY_NODE, SummaryNodeClass))

typedef struct _SummaryNode SummaryNode;
typedef struct _SummaryNodeClass SummaryNodeClass;

#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;
enum  {
	UNDO_NODE_ATTACH_0_PROPERTY,
	UNDO_NODE_ATTACH_NUM_PROPERTIES
};
static GParamSpec* undo_node_attach_properties[UNDO_NODE_ATTACH_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_array_unref0(var) ((var == NULL) ? NULL : (var = (g_array_unref (var), NULL)))
#define _style_unref0(var) ((var == NULL) ? NULL : (var = (style_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 TYPE_MAP_MODEL (map_model_get_type ())
#define MAP_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MAP_MODEL, MapModel))
#define MAP_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MAP_MODEL, MapModelClass))
#define IS_MAP_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MAP_MODEL))
#define IS_MAP_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MAP_MODEL))
#define MAP_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MAP_MODEL, MapModelClass))

typedef struct _MapModel MapModel;
typedef struct _MapModelClass MapModelClass;

#define TYPE_LAYOUT (layout_get_type ())
#define LAYOUT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_LAYOUT, Layout))
#define LAYOUT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_LAYOUT, LayoutClass))
#define IS_LAYOUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_LAYOUT))
#define IS_LAYOUT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_LAYOUT))
#define LAYOUT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_LAYOUT, LayoutClass))

typedef struct _Layout Layout;
typedef struct _LayoutClass LayoutClass;

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

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 _UndoNodeAttach {
	UndoItem parent_instance;
	UndoNodeAttachPrivate * priv;
};

struct _UndoNodeAttachClass {
	UndoItemClass parent_class;
};

struct _NodeInfo {
	gdouble posx;
	gdouble posy;
	NodeSide side;
	GdkRGBA color;
};

struct _UndoNodeAttachPrivate {
	Node* _n;
	Node* _old_parent;
	NodeSide _old_side;
	gint _old_index;
	GArray* _old_info;
	SummaryNode* _old_summary;
	Style* _old_style;
	Node* _new_parent;
	NodeSide _new_side;
	gint _new_index;
	GArray* _new_info;
	SummaryNode* _new_summary;
};

static gint UndoNodeAttach_private_offset;
static gpointer undo_node_attach_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_attach_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (UndoNodeAttach, g_object_unref)
VALA_EXTERN GType node_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Node, g_object_unref)
VALA_EXTERN GType node_side_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType node_info_get_type (void) G_GNUC_CONST ;
VALA_EXTERN NodeInfo* node_info_dup (const NodeInfo* self);
VALA_EXTERN void node_info_free (NodeInfo* self);
VALA_EXTERN GType summary_node_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SummaryNode, 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 void undo_item_undo (UndoItem* self,
                     MindMap* map);
VALA_EXTERN void undo_item_redo (UndoItem* self,
                     MindMap* map);
VALA_EXTERN UndoNodeAttach* undo_node_attach_new (Node* n,
                                      Node* old_parent,
                                      NodeSide old_side,
                                      gint old_index,
                                      GArray* old_info,
                                      SummaryNode* old_summary,
                                      gint old_summary_index,
                                      Style* old_style);
VALA_EXTERN UndoNodeAttach* undo_node_attach_construct (GType object_type,
                                            Node* n,
                                            Node* old_parent,
                                            NodeSide old_side,
                                            gint old_index,
                                            GArray* old_info,
                                            SummaryNode* old_summary,
                                            gint old_summary_index,
                                            Style* old_style);
VALA_EXTERN UndoItem* undo_item_new (const gchar* name);
VALA_EXTERN UndoItem* undo_item_construct (GType object_type,
                               const gchar* name);
VALA_EXTERN Node* node_get_parent (Node* self);
VALA_EXTERN NodeSide node_get_side (Node* self);
VALA_EXTERN gint node_index (Node* self);
static void _node_info_free0_ (gpointer var);
static void _vala_NodeInfo_free_function_content_of (gpointer data);
VALA_EXTERN void node_get_node_info (Node* self,
                         GArray** info);
VALA_EXTERN SummaryNode* node_summary_node (Node* self);
VALA_EXTERN UndoNodeAttach* undo_node_attach_new_for_root (Node* n,
                                               gint old_index,
                                               GArray* old_info,
                                               Style* old_style);
VALA_EXTERN UndoNodeAttach* undo_node_attach_construct_for_root (GType object_type,
                                                     Node* n,
                                                     gint old_index,
                                                     GArray* old_info,
                                                     Style* old_style);
static void undo_node_attach_real_undo (UndoItem* base,
                                 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 void summary_node_remove_node (SummaryNode* self,
                               Node* node);
VALA_EXTERN void node_detach (Node* self,
                  NodeSide side);
VALA_EXTERN gpointer map_model_ref (gpointer instance);
VALA_EXTERN void map_model_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_map_model (const gchar* name,
                                  const gchar* nick,
                                  const gchar* blurb,
                                  GType object_type,
                                  GParamFlags flags);
VALA_EXTERN void value_set_map_model (GValue* value,
                          gpointer v_object);
VALA_EXTERN void value_take_map_model (GValue* value,
                           gpointer v_object);
VALA_EXTERN gpointer value_get_map_model (const GValue* value);
VALA_EXTERN GType map_model_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MapModel, map_model_unref)
VALA_EXTERN MapModel* mind_map_get_model (MindMap* self);
VALA_EXTERN void map_model_add_root (MapModel* self,
                         Node* n,
                         gint index);
VALA_EXTERN void node_set_node_info (Node* self,
                         GArray* info,
                         gint* index);
VALA_EXTERN void node_set_side (Node* self,
                    NodeSide value);
VALA_EXTERN GType layout_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Layout, g_object_unref)
VALA_EXTERN Layout* node_get_layout (Node* self);
VALA_EXTERN void layout_propagate_side (Layout* self,
                            Node* parent,
                            NodeSide side);
VALA_EXTERN void node_attach_init (Node* self,
                       Node* parent,
                       gint index);
VALA_EXTERN void summary_node_add_node (SummaryNode* self,
                            Node* node);
VALA_EXTERN void node_set_style (Node* self,
                     Style* value);
VALA_EXTERN void mind_map_set_current_node (MindMap* self,
                                Node* n);
VALA_EXTERN void animator_animate (Animator* self);
VALA_EXTERN void mind_map_auto_save (MindMap* self);
static void undo_node_attach_real_redo (UndoItem* base,
                                 MindMap* map);
VALA_EXTERN void map_model_remove_root (MapModel* self,
                            gint index);
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);
VALA_EXTERN Theme* mind_map_get_theme (MindMap* self);
VALA_EXTERN void map_model_set_style_after_parent_attach (MapModel* self,
                                              Node* node);
static void undo_node_attach_finalize (GObject * obj);
static GType undo_node_attach_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
undo_node_attach_get_instance_private (UndoNodeAttach* self)
{
	return G_STRUCT_MEMBER_P (self, UndoNodeAttach_private_offset);
}

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

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

static gpointer
_style_ref0 (gpointer self)
{
	return self ? style_ref (self) : NULL;
}

static void
_node_info_free0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (node_info_free (var), NULL));
}

static void
_vala_NodeInfo_free_function_content_of (gpointer data)
{
	NodeInfo* self;
	self = *((NodeInfo**) data);
	_node_info_free0_ (self);
}

UndoNodeAttach*
undo_node_attach_construct (GType object_type,
                            Node* n,
                            Node* old_parent,
                            NodeSide old_side,
                            gint old_index,
                            GArray* old_info,
                            SummaryNode* old_summary,
                            gint old_summary_index,
                            Style* old_style)
{
	UndoNodeAttach * self = NULL;
	Node* _tmp0_;
	Node* _tmp1_;
	GArray* _tmp2_;
	SummaryNode* _tmp3_;
	Style* _tmp4_;
	Node* _tmp5_;
	Node* _tmp6_;
	Node* _tmp7_;
	NodeSide _tmp8_;
	NodeSide _tmp9_;
	GArray* _tmp10_;
	Node* _tmp11_;
	SummaryNode* _tmp12_;
	g_return_val_if_fail (n != NULL, NULL);
	g_return_val_if_fail (old_info != NULL, NULL);
	g_return_val_if_fail (old_style != NULL, NULL);
	self = (UndoNodeAttach*) undo_item_construct (object_type, _ ("attach node"));
	_tmp0_ = _g_object_ref0 (n);
	_g_object_unref0 (self->priv->_n);
	self->priv->_n = _tmp0_;
	_tmp1_ = _g_object_ref0 (old_parent);
	_g_object_unref0 (self->priv->_old_parent);
	self->priv->_old_parent = _tmp1_;
	self->priv->_old_side = old_side;
	self->priv->_old_index = old_index;
	_tmp2_ = _g_array_ref0 (old_info);
	_g_array_unref0 (self->priv->_old_info);
	self->priv->_old_info = _tmp2_;
	_tmp3_ = _g_object_ref0 (old_summary);
	_g_object_unref0 (self->priv->_old_summary);
	self->priv->_old_summary = _tmp3_;
	_tmp4_ = _style_ref0 (old_style);
	_style_unref0 (self->priv->_old_style);
	self->priv->_old_style = _tmp4_;
	_tmp5_ = node_get_parent (n);
	_tmp6_ = _tmp5_;
	_tmp7_ = _g_object_ref0 (_tmp6_);
	_g_object_unref0 (self->priv->_new_parent);
	self->priv->_new_parent = _tmp7_;
	_tmp8_ = node_get_side (n);
	_tmp9_ = _tmp8_;
	self->priv->_new_side = _tmp9_;
	self->priv->_new_index = node_index (n);
	_tmp10_ = g_array_new (TRUE, TRUE, sizeof (NodeInfo*));
	g_array_set_clear_func (_tmp10_, (GDestroyNotify) _vala_NodeInfo_free_function_content_of);
	_g_array_unref0 (self->priv->_new_info);
	self->priv->_new_info = _tmp10_;
	_tmp11_ = self->priv->_n;
	node_get_node_info (_tmp11_, &self->priv->_new_info);
	_tmp12_ = node_summary_node (n);
	_g_object_unref0 (self->priv->_new_summary);
	self->priv->_new_summary = _tmp12_;
	return self;
}

UndoNodeAttach*
undo_node_attach_new (Node* n,
                      Node* old_parent,
                      NodeSide old_side,
                      gint old_index,
                      GArray* old_info,
                      SummaryNode* old_summary,
                      gint old_summary_index,
                      Style* old_style)
{
	return undo_node_attach_construct (TYPE_UNDO_NODE_ATTACH, n, old_parent, old_side, old_index, old_info, old_summary, old_summary_index, old_style);
}

UndoNodeAttach*
undo_node_attach_construct_for_root (GType object_type,
                                     Node* n,
                                     gint old_index,
                                     GArray* old_info,
                                     Style* old_style)
{
	UndoNodeAttach * self = NULL;
	Node* _tmp0_;
	GArray* _tmp1_;
	Style* _tmp2_;
	Node* _tmp3_;
	Node* _tmp4_;
	Node* _tmp5_;
	NodeSide _tmp6_;
	NodeSide _tmp7_;
	GArray* _tmp8_;
	Node* _tmp9_;
	SummaryNode* _tmp10_;
	g_return_val_if_fail (n != NULL, NULL);
	g_return_val_if_fail (old_info != NULL, NULL);
	g_return_val_if_fail (old_style != NULL, NULL);
	self = (UndoNodeAttach*) undo_item_construct (object_type, _ ("attach node"));
	_tmp0_ = _g_object_ref0 (n);
	_g_object_unref0 (self->priv->_n);
	self->priv->_n = _tmp0_;
	_g_object_unref0 (self->priv->_old_parent);
	self->priv->_old_parent = NULL;
	self->priv->_old_index = old_index;
	_tmp1_ = _g_array_ref0 (old_info);
	_g_array_unref0 (self->priv->_old_info);
	self->priv->_old_info = _tmp1_;
	_g_object_unref0 (self->priv->_old_summary);
	self->priv->_old_summary = NULL;
	_tmp2_ = _style_ref0 (old_style);
	_style_unref0 (self->priv->_old_style);
	self->priv->_old_style = _tmp2_;
	_tmp3_ = node_get_parent (n);
	_tmp4_ = _tmp3_;
	_tmp5_ = _g_object_ref0 (_tmp4_);
	_g_object_unref0 (self->priv->_new_parent);
	self->priv->_new_parent = _tmp5_;
	_tmp6_ = node_get_side (n);
	_tmp7_ = _tmp6_;
	self->priv->_new_side = _tmp7_;
	self->priv->_new_index = node_index (n);
	_tmp8_ = g_array_new (TRUE, TRUE, sizeof (NodeInfo*));
	g_array_set_clear_func (_tmp8_, (GDestroyNotify) _vala_NodeInfo_free_function_content_of);
	_g_array_unref0 (self->priv->_new_info);
	self->priv->_new_info = _tmp8_;
	_tmp9_ = self->priv->_n;
	node_get_node_info (_tmp9_, &self->priv->_new_info);
	_tmp10_ = node_summary_node (n);
	_g_object_unref0 (self->priv->_new_summary);
	self->priv->_new_summary = _tmp10_;
	return self;
}

UndoNodeAttach*
undo_node_attach_new_for_root (Node* n,
                               gint old_index,
                               GArray* old_info,
                               Style* old_style)
{
	return undo_node_attach_construct_for_root (TYPE_UNDO_NODE_ATTACH, n, old_index, old_info, old_style);
}

static void
undo_node_attach_real_undo (UndoItem* base,
                            MindMap* map)
{
	UndoNodeAttach * self;
	gint index = 0;
	Animator* _tmp0_;
	Animator* _tmp1_;
	GArray* _tmp2_;
	GArray* _tmp3_;
	SummaryNode* _tmp4_;
	Node* _tmp7_;
	Node* _tmp8_;
	Node* _tmp26_;
	Style* _tmp27_;
	Node* _tmp28_;
	Animator* _tmp29_;
	Animator* _tmp30_;
	self = (UndoNodeAttach*) base;
	g_return_if_fail (map != NULL);
	index = 0;
	_tmp0_ = mind_map_get_animator (map);
	_tmp1_ = _tmp0_;
	_tmp2_ = mind_map_get_nodes (map);
	_tmp3_ = _tmp2_;
	animator_add_nodes (_tmp1_, _tmp3_, FALSE, "undo attach");
	_g_array_unref0 (_tmp3_);
	_tmp4_ = self->priv->_new_summary;
	if (_tmp4_ != NULL) {
		SummaryNode* _tmp5_;
		Node* _tmp6_;
		_tmp5_ = self->priv->_new_summary;
		_tmp6_ = self->priv->_n;
		summary_node_remove_node (_tmp5_, _tmp6_);
	}
	_tmp7_ = self->priv->_n;
	node_detach (_tmp7_, self->priv->_new_side);
	_tmp8_ = self->priv->_old_parent;
	if (_tmp8_ == NULL) {
		MapModel* _tmp9_;
		MapModel* _tmp10_;
		Node* _tmp11_;
		Node* _tmp12_;
		GArray* _tmp13_;
		_tmp9_ = mind_map_get_model (map);
		_tmp10_ = _tmp9_;
		_tmp11_ = self->priv->_n;
		map_model_add_root (_tmp10_, _tmp11_, self->priv->_old_index);
		_tmp12_ = self->priv->_n;
		_tmp13_ = self->priv->_old_info;
		node_set_node_info (_tmp12_, _tmp13_, &index);
	} else {
		Node* _tmp14_;
		GArray* _tmp15_;
		Node* _tmp16_;
		Node* _tmp17_;
		Layout* _tmp18_;
		Layout* _tmp19_;
		Node* _tmp20_;
		Node* _tmp21_;
		Node* _tmp22_;
		SummaryNode* _tmp23_;
		_tmp14_ = self->priv->_n;
		_tmp15_ = self->priv->_old_info;
		node_set_node_info (_tmp14_, _tmp15_, &index);
		_tmp16_ = self->priv->_n;
		node_set_side (_tmp16_, self->priv->_old_side);
		_tmp17_ = self->priv->_n;
		_tmp18_ = node_get_layout (_tmp17_);
		_tmp19_ = _tmp18_;
		_tmp20_ = self->priv->_n;
		layout_propagate_side (_tmp19_, _tmp20_, self->priv->_old_side);
		_tmp21_ = self->priv->_n;
		_tmp22_ = self->priv->_old_parent;
		node_attach_init (_tmp21_, _tmp22_, self->priv->_old_index);
		_tmp23_ = self->priv->_old_summary;
		if (_tmp23_ != NULL) {
			SummaryNode* _tmp24_;
			Node* _tmp25_;
			_tmp24_ = self->priv->_old_summary;
			_tmp25_ = self->priv->_n;
			summary_node_add_node (_tmp24_, _tmp25_);
		}
	}
	_tmp26_ = self->priv->_n;
	_tmp27_ = self->priv->_old_style;
	node_set_style (_tmp26_, _tmp27_);
	_tmp28_ = self->priv->_n;
	mind_map_set_current_node (map, _tmp28_);
	_tmp29_ = mind_map_get_animator (map);
	_tmp30_ = _tmp29_;
	animator_animate (_tmp30_);
	mind_map_auto_save (map);
}

static void
undo_node_attach_real_redo (UndoItem* base,
                            MindMap* map)
{
	UndoNodeAttach * self;
	gint index = 0;
	Animator* _tmp0_;
	Animator* _tmp1_;
	GArray* _tmp2_;
	GArray* _tmp3_;
	SummaryNode* _tmp4_;
	Node* _tmp7_;
	Node* _tmp11_;
	Node* _tmp12_;
	Layout* _tmp13_;
	Layout* _tmp14_;
	Node* _tmp15_;
	Node* _tmp16_;
	MapModel* _tmp30_;
	MapModel* _tmp31_;
	Node* _tmp32_;
	Node* _tmp33_;
	Animator* _tmp34_;
	Animator* _tmp35_;
	self = (UndoNodeAttach*) base;
	g_return_if_fail (map != NULL);
	index = 0;
	_tmp0_ = mind_map_get_animator (map);
	_tmp1_ = _tmp0_;
	_tmp2_ = mind_map_get_nodes (map);
	_tmp3_ = _tmp2_;
	animator_add_nodes (_tmp1_, _tmp3_, FALSE, "redo attach");
	_g_array_unref0 (_tmp3_);
	_tmp4_ = self->priv->_old_summary;
	if (_tmp4_ != NULL) {
		SummaryNode* _tmp5_;
		Node* _tmp6_;
		_tmp5_ = self->priv->_old_summary;
		_tmp6_ = self->priv->_n;
		summary_node_remove_node (_tmp5_, _tmp6_);
	}
	_tmp7_ = self->priv->_old_parent;
	if (_tmp7_ == NULL) {
		MapModel* _tmp8_;
		MapModel* _tmp9_;
		_tmp8_ = mind_map_get_model (map);
		_tmp9_ = _tmp8_;
		map_model_remove_root (_tmp9_, self->priv->_old_index);
	} else {
		Node* _tmp10_;
		_tmp10_ = self->priv->_n;
		node_detach (_tmp10_, self->priv->_old_side);
	}
	_tmp11_ = self->priv->_n;
	node_set_side (_tmp11_, self->priv->_new_side);
	_tmp12_ = self->priv->_n;
	_tmp13_ = node_get_layout (_tmp12_);
	_tmp14_ = _tmp13_;
	_tmp15_ = self->priv->_n;
	layout_propagate_side (_tmp14_, _tmp15_, self->priv->_new_side);
	_tmp16_ = self->priv->_old_parent;
	if (_tmp16_ == NULL) {
		Node* _tmp17_;
		Node* _tmp18_;
		Theme* _tmp19_;
		Theme* _tmp20_;
		Node* _tmp21_;
		GArray* _tmp22_;
		_tmp17_ = self->priv->_n;
		_tmp18_ = self->priv->_new_parent;
		_tmp19_ = mind_map_get_theme (map);
		_tmp20_ = _tmp19_;
		node_attach (_tmp17_, _tmp18_, -1, _tmp20_, TRUE);
		_g_object_unref0 (_tmp20_);
		_tmp21_ = self->priv->_n;
		_tmp22_ = self->priv->_new_info;
		node_set_node_info (_tmp21_, _tmp22_, &index);
	} else {
		Node* _tmp23_;
		GArray* _tmp24_;
		Node* _tmp25_;
		Node* _tmp26_;
		SummaryNode* _tmp27_;
		_tmp23_ = self->priv->_n;
		_tmp24_ = self->priv->_new_info;
		node_set_node_info (_tmp23_, _tmp24_, &index);
		_tmp25_ = self->priv->_n;
		_tmp26_ = self->priv->_new_parent;
		node_attach_init (_tmp25_, _tmp26_, self->priv->_new_index);
		_tmp27_ = self->priv->_new_summary;
		if (_tmp27_ != NULL) {
			SummaryNode* _tmp28_;
			Node* _tmp29_;
			_tmp28_ = self->priv->_new_summary;
			_tmp29_ = self->priv->_n;
			summary_node_add_node (_tmp28_, _tmp29_);
		}
	}
	_tmp30_ = mind_map_get_model (map);
	_tmp31_ = _tmp30_;
	_tmp32_ = self->priv->_n;
	map_model_set_style_after_parent_attach (_tmp31_, _tmp32_);
	_tmp33_ = self->priv->_n;
	mind_map_set_current_node (map, _tmp33_);
	_tmp34_ = mind_map_get_animator (map);
	_tmp35_ = _tmp34_;
	animator_animate (_tmp35_);
	mind_map_auto_save (map);
}

static void
undo_node_attach_class_init (UndoNodeAttachClass * klass,
                             gpointer klass_data)
{
	undo_node_attach_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &UndoNodeAttach_private_offset);
	((UndoItemClass *) klass)->undo = (void (*) (UndoItem*, MindMap*)) undo_node_attach_real_undo;
	((UndoItemClass *) klass)->redo = (void (*) (UndoItem*, MindMap*)) undo_node_attach_real_redo;
	G_OBJECT_CLASS (klass)->finalize = undo_node_attach_finalize;
}

static void
undo_node_attach_instance_init (UndoNodeAttach * self,
                                gpointer klass)
{
	self->priv = undo_node_attach_get_instance_private (self);
}

static void
undo_node_attach_finalize (GObject * obj)
{
	UndoNodeAttach * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_UNDO_NODE_ATTACH, UndoNodeAttach);
	_g_object_unref0 (self->priv->_n);
	_g_object_unref0 (self->priv->_old_parent);
	_g_array_unref0 (self->priv->_old_info);
	_g_object_unref0 (self->priv->_old_summary);
	_style_unref0 (self->priv->_old_style);
	_g_object_unref0 (self->priv->_new_parent);
	_g_array_unref0 (self->priv->_new_info);
	_g_object_unref0 (self->priv->_new_summary);
	G_OBJECT_CLASS (undo_node_attach_parent_class)->finalize (obj);
}

static GType
undo_node_attach_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (UndoNodeAttachClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) undo_node_attach_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UndoNodeAttach), 0, (GInstanceInitFunc) undo_node_attach_instance_init, NULL };
	GType undo_node_attach_type_id;
	undo_node_attach_type_id = g_type_register_static (TYPE_UNDO_ITEM, "UndoNodeAttach", &g_define_type_info, 0);
	UndoNodeAttach_private_offset = g_type_add_instance_private (undo_node_attach_type_id, sizeof (UndoNodeAttachPrivate));
	return undo_node_attach_type_id;
}

GType
undo_node_attach_get_type (void)
{
	static volatile gsize undo_node_attach_type_id__once = 0;
	if (g_once_init_enter (&undo_node_attach_type_id__once)) {
		GType undo_node_attach_type_id;
		undo_node_attach_type_id = undo_node_attach_get_type_once ();
		g_once_init_leave (&undo_node_attach_type_id__once, undo_node_attach_type_id);
	}
	return undo_node_attach_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;
}

