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

/*
* Copyright (c) 2025-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 <gtk/gtk.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <libxml/tree.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_TEMPLATE_GROUP (template_group_get_type ())
#define TEMPLATE_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TEMPLATE_GROUP, TemplateGroup))
#define TEMPLATE_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TEMPLATE_GROUP, TemplateGroupClass))
#define IS_TEMPLATE_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TEMPLATE_GROUP))
#define IS_TEMPLATE_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TEMPLATE_GROUP))
#define TEMPLATE_GROUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TEMPLATE_GROUP, TemplateGroupClass))

typedef struct _TemplateGroup TemplateGroup;
typedef struct _TemplateGroupClass TemplateGroupClass;
typedef struct _TemplateGroupPrivate TemplateGroupPrivate;
typedef enum  {
	TEMPLATE_TYPE_STYLE_GENERAL,
	TEMPLATE_TYPE_STYLE_NODE,
	TEMPLATE_TYPE_STYLE_CONNECTION,
	TEMPLATE_TYPE_STYLE_CALLOUT,
	TEMPLATE_TYPE_STYLE_OPTION_BRANCH,
	TEMPLATE_TYPE_STYLE_OPTION_LINK,
	TEMPLATE_TYPE_STYLE_OPTION_NODE,
	TEMPLATE_TYPE_STYLE_OPTION_CONNECTION,
	TEMPLATE_TYPE_STYLE_OPTION_CALLOUT,
	TEMPLATE_TYPE_NUM
} TemplateType;

#define TYPE_TEMPLATE_TYPE (template_type_get_type ())

#define TYPE_TEMPLATE (template_get_type ())
#define TEMPLATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TEMPLATE, Template))
#define TEMPLATE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TEMPLATE, TemplateClass))
#define IS_TEMPLATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TEMPLATE))
#define IS_TEMPLATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TEMPLATE))
#define TEMPLATE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TEMPLATE, TemplateClass))

typedef struct _Template Template;
typedef struct _TemplateClass TemplateClass;
#define _g_array_unref0(var) ((var == NULL) ? NULL : (var = (g_array_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define TYPE_MAIN_WINDOW (main_window_get_type ())
#define MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MAIN_WINDOW, MainWindow))
#define MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MAIN_WINDOW, MainWindowClass))
#define IS_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MAIN_WINDOW))
#define IS_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MAIN_WINDOW))
#define MAIN_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MAIN_WINDOW, MainWindowClass))

typedef struct _MainWindow MainWindow;
typedef struct _MainWindowClass MainWindowClass;
typedef void (*TemplateAddLoadFunc) (Template* template, gpointer user_data);
typedef struct _Block78Data Block78Data;
#define _template_group_unref0(var) ((var == NULL) ? NULL : (var = (template_group_unref (var), NULL)))
#define _template_unref0(var) ((var == NULL) ? NULL : (var = (template_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef void (*TemplateDeleteFunc) (gpointer user_data);

#define TYPE_TEMPLATE_EDITOR (template_editor_get_type ())
#define TEMPLATE_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TEMPLATE_EDITOR, TemplateEditor))
#define TEMPLATE_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TEMPLATE_EDITOR, TemplateEditorClass))
#define IS_TEMPLATE_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TEMPLATE_EDITOR))
#define IS_TEMPLATE_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TEMPLATE_EDITOR))
#define TEMPLATE_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TEMPLATE_EDITOR, TemplateEditorClass))

typedef struct _TemplateEditor TemplateEditor;
typedef struct _TemplateEditorClass TemplateEditorClass;
typedef struct _Block79Data Block79Data;
typedef struct _ParamSpecTemplateGroup ParamSpecTemplateGroup;
enum  {
	TEMPLATE_GROUP_LOCAL_CHANGED_SIGNAL,
	TEMPLATE_GROUP_CHANGED_SIGNAL,
	TEMPLATE_GROUP_NUM_SIGNALS
};
static guint template_group_signals[TEMPLATE_GROUP_NUM_SIGNALS] = {0};
#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 _TemplateGroup {
	GTypeInstance parent_instance;
	volatile int ref_count;
	TemplateGroupPrivate * priv;
};

struct _TemplateGroupClass {
	GTypeClass parent_class;
	void (*finalize) (TemplateGroup *self);
};

struct _TemplateGroupPrivate {
	TemplateType _type;
	GArray* _templates;
	GtkPopoverMenu* _menu;
};

struct _Block78Data {
	int _ref_count_;
	TemplateGroup* self;
	TemplateAddLoadFunc func;
	gpointer func_target;
};

struct _Block79Data {
	int _ref_count_;
	TemplateGroup* self;
	GMenu* load_submenu;
	TemplateEditor* editor;
};

struct _ParamSpecTemplateGroup {
	GParamSpec parent_instance;
};

static gint TemplateGroup_private_offset;
static gpointer template_group_parent_class = NULL;

VALA_EXTERN gpointer template_group_ref (gpointer instance);
VALA_EXTERN void template_group_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_template_group (const gchar* name,
                                       const gchar* nick,
                                       const gchar* blurb,
                                       GType object_type,
                                       GParamFlags flags);
VALA_EXTERN void value_set_template_group (GValue* value,
                               gpointer v_object);
VALA_EXTERN void value_take_template_group (GValue* value,
                                gpointer v_object);
VALA_EXTERN gpointer value_get_template_group (const GValue* value);
VALA_EXTERN GType template_group_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TemplateGroup, template_group_unref)
VALA_EXTERN GType template_type_get_type (void) G_GNUC_CONST ;
VALA_EXTERN gpointer template_ref (gpointer instance);
VALA_EXTERN void template_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_template (const gchar* name,
                                 const gchar* nick,
                                 const gchar* blurb,
                                 GType object_type,
                                 GParamFlags flags);
VALA_EXTERN void value_set_template (GValue* value,
                         gpointer v_object);
VALA_EXTERN void value_take_template (GValue* value,
                          gpointer v_object);
VALA_EXTERN gpointer value_get_template (const GValue* value);
VALA_EXTERN GType template_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Template, template_unref)
VALA_EXTERN TemplateGroup* template_group_new (TemplateType ttype);
VALA_EXTERN TemplateGroup* template_group_construct (GType object_type,
                                         TemplateType ttype);
static void _template_unref0_ (gpointer var);
static void _vala_Template_free_function_content_of (gpointer data);
VALA_EXTERN GType main_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MainWindow, g_object_unref)
static void template_group_add_save_as_menu_command (TemplateGroup* self,
                                              GSimpleActionGroup* group,
                                              MainWindow* win,
                                              TemplateAddLoadFunc func,
                                              gpointer func_target);
static void __lambda14_ (TemplateGroup* self,
                  GVariant* v);
static void ___lambda14__g_simple_action_activate (GSimpleAction* _sender,
                                            GVariant* parameter,
                                            gpointer self);
static void template_group_add_load_menu_command (TemplateGroup* self,
                                           GSimpleActionGroup* group,
                                           TemplateAddLoadFunc func,
                                           gpointer func_target);
static Block78Data* block78_data_ref (Block78Data* _data78_);
static void block78_data_unref (void * _userdata_);
static void __lambda15_ (Block78Data* _data78_,
                  GVariant* v);
VALA_EXTERN Template* template_group_get_template (TemplateGroup* self,
                                       const gchar* name);
static void ___lambda15__g_simple_action_activate (GSimpleAction* _sender,
                                            GVariant* parameter,
                                            gpointer self);
static void template_group_add_delete_menu_command (TemplateGroup* self,
                                             GSimpleActionGroup* group);
static void __lambda16_ (TemplateGroup* self,
                  GVariant* v);
VALA_EXTERN gboolean template_group_delete_template (TemplateGroup* self,
                                         const gchar* name);
static void ___lambda16__g_simple_action_activate (GSimpleAction* _sender,
                                            GVariant* parameter,
                                            gpointer self);
VALA_EXTERN gboolean template_group_save_as_template (TemplateGroup* self,
                                          const gchar* name,
                                          TemplateAddLoadFunc func,
                                          gpointer func_target);
VALA_EXTERN Template* template_type_create_template (TemplateType self,
                                         const gchar* name);
VALA_EXTERN gboolean template_group_add_template (TemplateGroup* self,
                                      Template* template);
static void template_group_create_menus (TemplateGroup* self,
                                  MainWindow* win,
                                  TemplateAddLoadFunc add_func,
                                  gpointer add_func_target,
                                  TemplateAddLoadFunc load_func,
                                  gpointer load_func_target,
                                  TemplateDeleteFunc del_func,
                                  gpointer del_func_target);
VALA_EXTERN GType template_editor_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TemplateEditor, g_object_unref)
static Block79Data* block79_data_ref (Block79Data* _data79_);
static void block79_data_unref (void * _userdata_);
VALA_EXTERN gchar* template_type_to_string (TemplateType self);
VALA_EXTERN TemplateEditor* template_editor_new (MainWindow* win,
                                     TemplateGroup* templates,
                                     TemplateAddLoadFunc add_func,
                                     gpointer add_func_target,
                                     TemplateAddLoadFunc load_func,
                                     gpointer load_func_target,
                                     TemplateDeleteFunc del_func,
                                     gpointer del_func_target);
VALA_EXTERN TemplateEditor* template_editor_construct (GType object_type,
                                           MainWindow* win,
                                           TemplateGroup* templates,
                                           TemplateAddLoadFunc add_func,
                                           gpointer add_func_target,
                                           TemplateAddLoadFunc load_func,
                                           gpointer load_func_target,
                                           TemplateDeleteFunc del_func,
                                           gpointer del_func_target);
static void __lambda28_ (TemplateGroup* self);
static void ___lambda28__template_editor_close (TemplateEditor* _sender,
                                         gpointer self);
static void __lambda29_ (Block79Data* _data79_);
static void template_group_update_menu (TemplateGroup* self,
                                 GMenu* ld_menu,
                                 TemplateEditor* editor);
static void ___lambda29__template_group_local_changed (TemplateGroup* _sender,
                                                gpointer self);
VALA_EXTERN void template_group_add_menus (TemplateGroup* self,
                               GtkWidget* w,
                               MainWindow* win,
                               TemplateAddLoadFunc add_func,
                               gpointer add_func_target,
                               TemplateAddLoadFunc load_func,
                               gpointer load_func_target,
                               TemplateDeleteFunc del_func,
                               gpointer del_func_target);
VALA_EXTERN void template_editor_update_list (TemplateEditor* self);
VALA_EXTERN const gchar* template_get_name (Template* self);
static gint template_group_get_template_index (TemplateGroup* self,
                                        const gchar* name);
VALA_EXTERN GArray* template_group_get_names (TemplateGroup* self);
static void _g_free0_ (gpointer var);
static void _vala_gchar_free_function_content_of (gpointer data);
VALA_EXTERN xmlNode* template_group_save (TemplateGroup* self);
VALA_EXTERN xmlNode* template_save (Template* self,
                        const gchar* node_name);
VALA_EXTERN void template_group_load (TemplateGroup* self,
                          xmlNode* node);
VALA_EXTERN void template_load (Template* self,
                    xmlNode* node);
VALA_EXTERN GtkPopoverMenu* template_group_get_menu (TemplateGroup* self);
static void template_group_finalize (TemplateGroup * obj);
static GType template_group_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
template_group_get_instance_private (TemplateGroup* self)
{
	return G_STRUCT_MEMBER_P (self, TemplateGroup_private_offset);
}

static void
_template_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (template_unref (var), NULL));
}

static void
_vala_Template_free_function_content_of (gpointer data)
{
	Template* self;
	self = *((Template**) data);
	_template_unref0_ (self);
}

TemplateGroup*
template_group_construct (GType object_type,
                          TemplateType ttype)
{
	TemplateGroup* self = NULL;
	GArray* _tmp0_;
	self = (TemplateGroup*) g_type_create_instance (object_type);
	self->priv->_type = ttype;
	_tmp0_ = g_array_new (TRUE, TRUE, sizeof (Template*));
	g_array_set_clear_func (_tmp0_, (GDestroyNotify) _vala_Template_free_function_content_of);
	_g_array_unref0 (self->priv->_templates);
	self->priv->_templates = _tmp0_;
	return self;
}

TemplateGroup*
template_group_new (TemplateType ttype)
{
	return template_group_construct (TYPE_TEMPLATE_GROUP, ttype);
}

static void
__lambda14_ (TemplateGroup* self,
             GVariant* v)
{
}

static void
___lambda14__g_simple_action_activate (GSimpleAction* _sender,
                                       GVariant* parameter,
                                       gpointer self)
{
	__lambda14_ ((TemplateGroup*) self, parameter);
}

static void
template_group_add_save_as_menu_command (TemplateGroup* self,
                                         GSimpleActionGroup* group,
                                         MainWindow* win,
                                         TemplateAddLoadFunc func,
                                         gpointer func_target)
{
	GSimpleAction* action = NULL;
	GSimpleAction* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (group != NULL);
	g_return_if_fail (win != NULL);
	_tmp0_ = g_simple_action_new ("action_save_as_template", NULL);
	action = _tmp0_;
	g_signal_connect (action, "activate", (GCallback) ___lambda14__g_simple_action_activate, self);
	g_action_map_add_action ((GActionMap*) group, (GAction*) action);
	_g_object_unref0 (action);
}

static Block78Data*
block78_data_ref (Block78Data* _data78_)
{
	g_atomic_int_inc (&_data78_->_ref_count_);
	return _data78_;
}

static void
block78_data_unref (void * _userdata_)
{
	Block78Data* _data78_;
	_data78_ = (Block78Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data78_->_ref_count_)) {
		TemplateGroup* self;
		self = _data78_->self;
		_template_group_unref0 (self);
		g_slice_free (Block78Data, _data78_);
	}
}

static void
__lambda15_ (Block78Data* _data78_,
             GVariant* v)
{
	TemplateGroup* self;
	gchar* name = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	Template* template = NULL;
	const gchar* _tmp2_;
	Template* _tmp3_;
	Template* _tmp4_;
	self = _data78_->self;
	_tmp0_ = g_variant_get_string (v, NULL);
	_tmp1_ = g_strdup (_tmp0_);
	name = _tmp1_;
	_tmp2_ = name;
	_tmp3_ = template_group_get_template (self, _tmp2_);
	template = _tmp3_;
	_tmp4_ = template;
	if (_tmp4_ != NULL) {
		Template* _tmp5_;
		_tmp5_ = template;
		_data78_->func (_tmp5_, _data78_->func_target);
	}
	_template_unref0 (template);
	_g_free0 (name);
}

static void
___lambda15__g_simple_action_activate (GSimpleAction* _sender,
                                       GVariant* parameter,
                                       gpointer self)
{
	__lambda15_ (self, parameter);
}

static void
template_group_add_load_menu_command (TemplateGroup* self,
                                      GSimpleActionGroup* group,
                                      TemplateAddLoadFunc func,
                                      gpointer func_target)
{
	Block78Data* _data78_;
	GSimpleAction* action = NULL;
	const GVariantType* _tmp0_;
	GSimpleAction* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (group != NULL);
	_data78_ = g_slice_new0 (Block78Data);
	_data78_->_ref_count_ = 1;
	_data78_->self = template_group_ref (self);
	_data78_->func = func;
	_data78_->func_target = func_target;
	_tmp0_ = G_VARIANT_TYPE_STRING;
	_tmp1_ = g_simple_action_new ("action_load_saved_template", _tmp0_);
	action = _tmp1_;
	g_signal_connect_data (action, "activate", (GCallback) ___lambda15__g_simple_action_activate, block78_data_ref (_data78_), (GClosureNotify) block78_data_unref, 0);
	g_action_map_add_action ((GActionMap*) group, (GAction*) action);
	_g_object_unref0 (action);
	block78_data_unref (_data78_);
	_data78_ = NULL;
}

static void
__lambda16_ (TemplateGroup* self,
             GVariant* v)
{
	gchar* name = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	_tmp0_ = g_variant_get_string (v, NULL);
	_tmp1_ = g_strdup (_tmp0_);
	name = _tmp1_;
	template_group_delete_template (self, name);
	_g_free0 (name);
}

static void
___lambda16__g_simple_action_activate (GSimpleAction* _sender,
                                       GVariant* parameter,
                                       gpointer self)
{
	__lambda16_ ((TemplateGroup*) self, parameter);
}

static void
template_group_add_delete_menu_command (TemplateGroup* self,
                                        GSimpleActionGroup* group)
{
	GSimpleAction* action = NULL;
	const GVariantType* _tmp0_;
	GSimpleAction* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (group != NULL);
	_tmp0_ = G_VARIANT_TYPE_STRING;
	_tmp1_ = g_simple_action_new ("action_delete_saved_template", _tmp0_);
	action = _tmp1_;
	g_signal_connect (action, "activate", (GCallback) ___lambda16__g_simple_action_activate, self);
	g_action_map_add_action ((GActionMap*) group, (GAction*) action);
	_g_object_unref0 (action);
}

gboolean
template_group_save_as_template (TemplateGroup* self,
                                 const gchar* name,
                                 TemplateAddLoadFunc func,
                                 gpointer func_target)
{
	Template* template = NULL;
	Template* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (name != NULL, FALSE);
	_tmp0_ = template_type_create_template (self->priv->_type, name);
	template = _tmp0_;
	func (template, func_target);
	result = template_group_add_template (self, template);
	_template_unref0 (template);
	return result;
}

static Block79Data*
block79_data_ref (Block79Data* _data79_)
{
	g_atomic_int_inc (&_data79_->_ref_count_);
	return _data79_;
}

static void
block79_data_unref (void * _userdata_)
{
	Block79Data* _data79_;
	_data79_ = (Block79Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data79_->_ref_count_)) {
		TemplateGroup* self;
		self = _data79_->self;
		_g_object_unref0 (_data79_->editor);
		_g_object_unref0 (_data79_->load_submenu);
		_template_group_unref0 (self);
		g_slice_free (Block79Data, _data79_);
	}
}

static void
__lambda28_ (TemplateGroup* self)
{
	GtkPopoverMenu* _tmp0_;
	_tmp0_ = self->priv->_menu;
	gtk_popover_popdown ((GtkPopover*) _tmp0_);
}

static void
___lambda28__template_editor_close (TemplateEditor* _sender,
                                    gpointer self)
{
	__lambda28_ ((TemplateGroup*) self);
}

static void
__lambda29_ (Block79Data* _data79_)
{
	TemplateGroup* self;
	self = _data79_->self;
	template_group_update_menu (self, _data79_->load_submenu, _data79_->editor);
}

static void
___lambda29__template_group_local_changed (TemplateGroup* _sender,
                                           gpointer self)
{
	__lambda29_ (self);
}

static void
template_group_create_menus (TemplateGroup* self,
                             MainWindow* win,
                             TemplateAddLoadFunc add_func,
                             gpointer add_func_target,
                             TemplateAddLoadFunc load_func,
                             gpointer load_func_target,
                             TemplateDeleteFunc del_func,
                             gpointer del_func_target)
{
	Block79Data* _data79_;
	GMenu* saved_menu = NULL;
	GMenu* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	GMenu* _tmp5_;
	GMenu* load_menu = NULL;
	GMenu* _tmp6_;
	GMenuItem* menu_item = NULL;
	GMenuItem* _tmp7_;
	GMenu* menu = NULL;
	GMenu* _tmp8_;
	TemplateEditor* _tmp9_;
	GtkPopoverMenu* _tmp10_ = NULL;
	GtkPopoverMenu* _tmp11_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (win != NULL);
	_data79_ = g_slice_new0 (Block79Data);
	_data79_->_ref_count_ = 1;
	_data79_->self = template_group_ref (self);
	_tmp0_ = g_menu_new ();
	saved_menu = _tmp0_;
	_tmp1_ = template_type_to_string (self->priv->_type);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strdup_printf ("%s.action_save_as_template", _tmp2_);
	_tmp4_ = _tmp3_;
	g_menu_append (saved_menu, _ ("Save Style As Template"), _tmp4_);
	_g_free0 (_tmp4_);
	_g_free0 (_tmp2_);
	_tmp5_ = g_menu_new ();
	_data79_->load_submenu = _tmp5_;
	_tmp6_ = g_menu_new ();
	load_menu = _tmp6_;
	g_menu_append_submenu (load_menu, _ ("Load Saved Style"), (GMenuModel*) _data79_->load_submenu);
	_tmp7_ = g_menu_item_new (NULL, NULL);
	menu_item = _tmp7_;
	g_menu_item_set_attribute (menu_item, "custom", "s", "editor", NULL);
	_tmp8_ = g_menu_new ();
	menu = _tmp8_;
	g_menu_append_item (menu, menu_item);
	_tmp9_ = template_editor_new (win, self, add_func, add_func_target, load_func, load_func_target, del_func, del_func_target);
	g_object_ref_sink (_tmp9_);
	_data79_->editor = _tmp9_;
	_tmp10_ = (GtkPopoverMenu*) gtk_popover_menu_new_from_model ((GMenuModel*) menu);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp10_, 5);
	g_object_ref_sink (_tmp10_);
	_g_object_unref0 (self->priv->_menu);
	self->priv->_menu = _tmp10_;
	_tmp11_ = self->priv->_menu;
	gtk_popover_menu_add_child (_tmp11_, (GtkWidget*) _data79_->editor, "editor");
	g_signal_connect (_data79_->editor, "close", (GCallback) ___lambda28__template_editor_close, self);
	g_signal_connect_data (self, "local-changed", (GCallback) ___lambda29__template_group_local_changed, block79_data_ref (_data79_), (GClosureNotify) block79_data_unref, 0);
	_g_object_unref0 (menu);
	_g_object_unref0 (menu_item);
	_g_object_unref0 (load_menu);
	_g_object_unref0 (saved_menu);
	block79_data_unref (_data79_);
	_data79_ = NULL;
}

void
template_group_add_menus (TemplateGroup* self,
                          GtkWidget* w,
                          MainWindow* win,
                          TemplateAddLoadFunc add_func,
                          gpointer add_func_target,
                          TemplateAddLoadFunc load_func,
                          gpointer load_func_target,
                          TemplateDeleteFunc del_func,
                          gpointer del_func_target)
{
	GSimpleActionGroup* group = NULL;
	GSimpleActionGroup* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (w != NULL);
	g_return_if_fail (win != NULL);
	_tmp0_ = g_simple_action_group_new ();
	group = _tmp0_;
	_tmp1_ = template_type_to_string (self->priv->_type);
	_tmp2_ = _tmp1_;
	gtk_widget_insert_action_group (w, _tmp2_, (GActionGroup*) group);
	_g_free0 (_tmp2_);
	template_group_add_save_as_menu_command (self, group, win, add_func, add_func_target);
	template_group_add_load_menu_command (self, group, load_func, load_func_target);
	template_group_add_delete_menu_command (self, group);
	template_group_create_menus (self, win, add_func, add_func_target, load_func, load_func_target, del_func, del_func_target);
	_g_object_unref0 (group);
}

static void
template_group_update_menu (TemplateGroup* self,
                            GMenu* ld_menu,
                            TemplateEditor* editor)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (ld_menu != NULL);
	g_return_if_fail (editor != NULL);
	g_menu_remove_all (ld_menu);
	template_editor_update_list (editor);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GArray* _tmp2_;
				gchar* name = NULL;
				GArray* _tmp3_;
				Template* _tmp4_;
				const gchar* _tmp5_;
				const gchar* _tmp6_;
				gchar* _tmp7_;
				const gchar* _tmp8_;
				gchar* _tmp9_;
				gchar* _tmp10_;
				const gchar* _tmp11_;
				gchar* _tmp12_;
				gchar* _tmp13_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = self->priv->_templates;
				if (!(((guint) i) < _tmp2_->len)) {
					break;
				}
				_tmp3_ = self->priv->_templates;
				_tmp4_ = g_array_index (_tmp3_, Template*, (guint) i);
				_tmp5_ = template_get_name (_tmp4_);
				_tmp6_ = _tmp5_;
				_tmp7_ = g_strdup (_tmp6_);
				name = _tmp7_;
				_tmp8_ = name;
				_tmp9_ = template_type_to_string (self->priv->_type);
				_tmp10_ = _tmp9_;
				_tmp11_ = name;
				_tmp12_ = g_strdup_printf ("%s.action_load_saved_template('%s')", _tmp10_, _tmp11_);
				_tmp13_ = _tmp12_;
				g_menu_append (ld_menu, _tmp8_, _tmp13_);
				_g_free0 (_tmp13_);
				_g_free0 (_tmp10_);
				_g_free0 (name);
			}
		}
	}
}

static gint
template_group_get_template_index (TemplateGroup* self,
                                   const gchar* name)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (name != NULL, -1);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GArray* _tmp2_;
				GArray* _tmp3_;
				Template* _tmp4_;
				const gchar* _tmp5_;
				const gchar* _tmp6_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = self->priv->_templates;
				if (!(((guint) i) < _tmp2_->len)) {
					break;
				}
				_tmp3_ = self->priv->_templates;
				_tmp4_ = g_array_index (_tmp3_, Template*, (guint) i);
				_tmp5_ = template_get_name (_tmp4_);
				_tmp6_ = _tmp5_;
				if (g_strcmp0 (_tmp6_, name) == 0) {
					result = i;
					return result;
				}
			}
		}
	}
	result = -1;
	return result;
}

static gpointer
_template_ref0 (gpointer self)
{
	return self ? template_ref (self) : NULL;
}

Template*
template_group_get_template (TemplateGroup* self,
                             const gchar* name)
{
	gint index = 0;
	Template* _tmp0_ = NULL;
	Template* _tmp3_;
	Template* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	index = template_group_get_template_index (self, name);
	if (index == -1) {
		_tmp0_ = NULL;
	} else {
		GArray* _tmp1_;
		Template* _tmp2_;
		_tmp1_ = self->priv->_templates;
		_tmp2_ = g_array_index (_tmp1_, Template*, (guint) index);
		_tmp0_ = _tmp2_;
	}
	_tmp3_ = _template_ref0 (_tmp0_);
	result = _tmp3_;
	return result;
}

static void
_g_free0_ (gpointer var)
{
	var = (g_free (var), NULL);
}

static void
_vala_gchar_free_function_content_of (gpointer data)
{
	gchar* self;
	self = *((gchar**) data);
	_g_free0_ (self);
}

GArray*
template_group_get_names (TemplateGroup* self)
{
	GArray* names = NULL;
	GArray* _tmp0_;
	GArray* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_array_new (TRUE, TRUE, sizeof (gchar*));
	g_array_set_clear_func (_tmp0_, (GDestroyNotify) _vala_gchar_free_function_content_of);
	names = _tmp0_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				GArray* _tmp3_;
				GArray* _tmp4_;
				GArray* _tmp5_;
				Template* _tmp6_;
				const gchar* _tmp7_;
				const gchar* _tmp8_;
				gchar* _tmp9_;
				if (!_tmp1_) {
					gint _tmp2_;
					_tmp2_ = i;
					i = _tmp2_ + 1;
				}
				_tmp1_ = FALSE;
				_tmp3_ = self->priv->_templates;
				if (!(((guint) i) < _tmp3_->len)) {
					break;
				}
				_tmp4_ = names;
				_tmp5_ = self->priv->_templates;
				_tmp6_ = g_array_index (_tmp5_, Template*, (guint) i);
				_tmp7_ = template_get_name (_tmp6_);
				_tmp8_ = _tmp7_;
				_tmp9_ = g_strdup (_tmp8_);
				g_array_append_val (_tmp4_, _tmp9_);
			}
		}
	}
	result = names;
	return result;
}

gboolean
template_group_add_template (TemplateGroup* self,
                             Template* template)
{
	gint index = 0;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (template != NULL, FALSE);
	_tmp0_ = template_get_name (template);
	_tmp1_ = _tmp0_;
	index = template_group_get_template_index (self, _tmp1_);
	if (index == -1) {
		GArray* _tmp2_;
		Template* _tmp3_;
		_tmp2_ = self->priv->_templates;
		_tmp3_ = _template_ref0 (template);
		g_array_append_val (_tmp2_, _tmp3_);
		g_signal_emit (self, template_group_signals[TEMPLATE_GROUP_LOCAL_CHANGED_SIGNAL], 0);
		g_signal_emit (self, template_group_signals[TEMPLATE_GROUP_CHANGED_SIGNAL], 0);
		result = TRUE;
		return result;
	}
	result = FALSE;
	return result;
}

static gpointer
vala_g_array_remove_index (GArray* self,
                           guint index)
{
	gpointer g = NULL;
	gpointer* _tmp0_;
	gint _tmp0__length1;
	gpointer _tmp1_;
	gpointer result;
	g_return_val_if_fail (self != NULL, NULL);
	_vala_assert (self->len > index, "length > index");
	_tmp0_ = self->data;
	_tmp0__length1 = self->len;
	_tmp1_ = _tmp0_[index];
	_tmp0_[index] = NULL;
	g = _tmp1_;
	g_array_remove_index (self, index);
	result = g;
	return result;
}

gboolean
template_group_delete_template (TemplateGroup* self,
                                const gchar* name)
{
	gint index = 0;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (name != NULL, FALSE);
	index = template_group_get_template_index (self, name);
	if (index != -1) {
		GArray* _tmp0_;
		Template* _tmp1_;
		Template* _tmp2_;
		_tmp0_ = self->priv->_templates;
		_tmp1_ = vala_g_array_remove_index (_tmp0_, (guint) index);
		_tmp2_ = _tmp1_;
		_template_unref0 (_tmp2_);
		g_signal_emit (self, template_group_signals[TEMPLATE_GROUP_LOCAL_CHANGED_SIGNAL], 0);
		g_signal_emit (self, template_group_signals[TEMPLATE_GROUP_CHANGED_SIGNAL], 0);
		result = TRUE;
		return result;
	}
	result = FALSE;
	return result;
}

xmlNode*
template_group_save (TemplateGroup* self)
{
	xmlNode* node = NULL;
	xmlNode* _tmp0_;
	xmlNode* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	xmlNode* _tmp11_;
	xmlNode* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = xmlNewNode (NULL, (xmlChar*) "template-group");
	node = _tmp0_;
	_tmp1_ = node;
	_tmp2_ = template_type_to_string (self->priv->_type);
	_tmp3_ = _tmp2_;
	xmlSetProp (_tmp1_, (xmlChar*) "name", (xmlChar*) _tmp3_);
	_g_free0 (_tmp3_);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp4_ = FALSE;
			_tmp4_ = TRUE;
			while (TRUE) {
				GArray* _tmp6_;
				xmlNode* _tmp7_;
				GArray* _tmp8_;
				Template* _tmp9_;
				xmlNode* _tmp10_;
				if (!_tmp4_) {
					gint _tmp5_;
					_tmp5_ = i;
					i = _tmp5_ + 1;
				}
				_tmp4_ = FALSE;
				_tmp6_ = self->priv->_templates;
				if (!(((guint) i) < _tmp6_->len)) {
					break;
				}
				_tmp7_ = node;
				_tmp8_ = self->priv->_templates;
				_tmp9_ = g_array_index (_tmp8_, Template*, (guint) i);
				_tmp10_ = template_save (_tmp9_, "template");
				xmlAddChild (_tmp7_, _tmp10_);
			}
		}
	}
	_tmp11_ = node;
	result = _tmp11_;
	return result;
}

void
template_group_load (TemplateGroup* self,
                     xmlNode* node)
{
	g_return_if_fail (self != NULL);
	{
		xmlNode* it = NULL;
		xmlNode* _tmp0_;
		_tmp0_ = node->children;
		it = _tmp0_;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				xmlNode* _tmp4_;
				gboolean _tmp5_ = FALSE;
				xmlNode* _tmp6_;
				if (!_tmp1_) {
					xmlNode* _tmp2_;
					xmlNode* _tmp3_;
					_tmp2_ = it;
					_tmp3_ = _tmp2_->next;
					it = _tmp3_;
				}
				_tmp1_ = FALSE;
				_tmp4_ = it;
				if (!(_tmp4_ != NULL)) {
					break;
				}
				_tmp6_ = it;
				if (_tmp6_->type == XML_ELEMENT_NODE) {
					xmlNode* _tmp7_;
					const gchar* _tmp8_;
					_tmp7_ = it;
					_tmp8_ = _tmp7_->name;
					_tmp5_ = g_strcmp0 (_tmp8_, "template") == 0;
				} else {
					_tmp5_ = FALSE;
				}
				if (_tmp5_) {
					Template* template = NULL;
					Template* _tmp9_;
					Template* _tmp10_;
					xmlNode* _tmp11_;
					GArray* _tmp12_;
					Template* _tmp13_;
					Template* _tmp14_;
					_tmp9_ = template_type_create_template (self->priv->_type, "");
					template = _tmp9_;
					_tmp10_ = template;
					_tmp11_ = it;
					template_load (_tmp10_, _tmp11_);
					_tmp12_ = self->priv->_templates;
					_tmp13_ = template;
					_tmp14_ = _template_ref0 (_tmp13_);
					g_array_append_val (_tmp12_, _tmp14_);
					_template_unref0 (template);
				}
			}
		}
	}
	g_signal_emit (self, template_group_signals[TEMPLATE_GROUP_LOCAL_CHANGED_SIGNAL], 0);
}

GtkPopoverMenu*
template_group_get_menu (TemplateGroup* self)
{
	GtkPopoverMenu* result;
	GtkPopoverMenu* _tmp0_;
	GtkPopoverMenu* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_menu;
	_vala_assert (_tmp0_ != NULL, "_menu != null");
	_tmp1_ = self->priv->_menu;
	result = _tmp1_;
	return result;
}

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

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

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

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

static gchar*
value_template_group_collect_value (GValue* value,
                                    guint n_collect_values,
                                    GTypeCValue* collect_values,
                                    guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		TemplateGroup * 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 = template_group_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
value_template_group_lcopy_value (const GValue* value,
                                  guint n_collect_values,
                                  GTypeCValue* collect_values,
                                  guint collect_flags)
{
	TemplateGroup ** 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 = template_group_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
param_spec_template_group (const gchar* name,
                           const gchar* nick,
                           const gchar* blurb,
                           GType object_type,
                           GParamFlags flags)
{
	ParamSpecTemplateGroup* spec;
	g_return_val_if_fail (g_type_is_a (object_type, TYPE_TEMPLATE_GROUP), 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);
}

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

void
value_set_template_group (GValue* value,
                          gpointer v_object)
{
	TemplateGroup * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_TEMPLATE_GROUP));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_TEMPLATE_GROUP));
		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;
		template_group_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		template_group_unref (old);
	}
}

void
value_take_template_group (GValue* value,
                           gpointer v_object)
{
	TemplateGroup * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_TEMPLATE_GROUP));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_TEMPLATE_GROUP));
		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) {
		template_group_unref (old);
	}
}

static void
template_group_class_init (TemplateGroupClass * klass,
                           gpointer klass_data)
{
	template_group_parent_class = g_type_class_peek_parent (klass);
	((TemplateGroupClass *) klass)->finalize = template_group_finalize;
	g_type_class_adjust_private_offset (klass, &TemplateGroup_private_offset);
	template_group_signals[TEMPLATE_GROUP_LOCAL_CHANGED_SIGNAL] = g_signal_new ("local-changed", TYPE_TEMPLATE_GROUP, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	template_group_signals[TEMPLATE_GROUP_CHANGED_SIGNAL] = g_signal_new ("changed", TYPE_TEMPLATE_GROUP, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
template_group_instance_init (TemplateGroup * self,
                              gpointer klass)
{
	self->priv = template_group_get_instance_private (self);
	self->priv->_menu = NULL;
	self->ref_count = 1;
}

static void
template_group_finalize (TemplateGroup * obj)
{
	TemplateGroup * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_TEMPLATE_GROUP, TemplateGroup);
	g_signal_handlers_destroy (self);
	_g_array_unref0 (self->priv->_templates);
	_g_object_unref0 (self->priv->_menu);
}

static GType
template_group_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { value_template_group_init, value_template_group_free_value, value_template_group_copy_value, value_template_group_peek_pointer, "p", value_template_group_collect_value, "p", value_template_group_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (TemplateGroupClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) template_group_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TemplateGroup), 0, (GInstanceInitFunc) template_group_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 template_group_type_id;
	template_group_type_id = g_type_register_fundamental (g_type_fundamental_next (), "TemplateGroup", &g_define_type_info, &g_define_type_fundamental_info, 0);
	TemplateGroup_private_offset = g_type_add_instance_private (template_group_type_id, sizeof (TemplateGroupPrivate));
	return template_group_type_id;
}

GType
template_group_get_type (void)
{
	static volatile gsize template_group_type_id__once = 0;
	if (g_once_init_enter (&template_group_type_id__once)) {
		GType template_group_type_id;
		template_group_type_id = template_group_get_type_once ();
		g_once_init_leave (&template_group_type_id__once, template_group_type_id);
	}
	return template_group_type_id__once;
}

gpointer
template_group_ref (gpointer instance)
{
	TemplateGroup * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
template_group_unref (gpointer instance)
{
	TemplateGroup * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		TEMPLATE_GROUP_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

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

