/* sidebar-branch.c generated by valac 0.56.3, the Vala compiler
 * generated from sidebar-branch.vala, do not modify */

/* Copyright 2016 Software Freedom Conservancy Inc.
 *
 * This software is licensed under the GNU Lesser General Public License
 * (version 2.1 or later).  See the COPYING file in this distribution.
 */

#include "geary-client-43.0.h"
#include <glib-object.h>
#include <glib.h>
#include <gee.h>
#include "geary-engine.h"
#include <gobject/gvaluecollector.h>

#define SIDEBAR_BRANCH_TYPE_NODE (sidebar_branch_node_get_type ())
#define SIDEBAR_BRANCH_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SIDEBAR_BRANCH_TYPE_NODE, SidebarBranchNode))
#define SIDEBAR_BRANCH_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SIDEBAR_BRANCH_TYPE_NODE, SidebarBranchNodeClass))
#define SIDEBAR_BRANCH_IS_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SIDEBAR_BRANCH_TYPE_NODE))
#define SIDEBAR_BRANCH_IS_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SIDEBAR_BRANCH_TYPE_NODE))
#define SIDEBAR_BRANCH_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SIDEBAR_BRANCH_TYPE_NODE, SidebarBranchNodeClass))

typedef struct _SidebarBranchNode SidebarBranchNode;
typedef struct _SidebarBranchNodeClass SidebarBranchNodeClass;
enum  {
	SIDEBAR_BRANCH_0_PROPERTY,
	SIDEBAR_BRANCH_NUM_PROPERTIES
};
static GParamSpec* sidebar_branch_properties[SIDEBAR_BRANCH_NUM_PROPERTIES];
#define _sidebar_branch_node_unref0(var) ((var == NULL) ? NULL : (var = (sidebar_branch_node_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _SidebarBranchNodePrivate SidebarBranchNodePrivate;
typedef void (*SidebarBranchNodePruneCallback) (SidebarBranchNode* node, gpointer user_data);
typedef void (*SidebarBranchNodeChildrenReorderedCallback) (SidebarBranchNode* node, gpointer user_data);
typedef struct _SidebarBranchParamSpecNode SidebarBranchParamSpecNode;
enum  {
	SIDEBAR_BRANCH_ENTRY_ADDED_SIGNAL,
	SIDEBAR_BRANCH_ENTRY_REMOVED_SIGNAL,
	SIDEBAR_BRANCH_ENTRY_MOVED_SIGNAL,
	SIDEBAR_BRANCH_ENTRY_REPARENTED_SIGNAL,
	SIDEBAR_BRANCH_CHILDREN_REORDERED_SIGNAL,
	SIDEBAR_BRANCH_SHOW_BRANCH_SIGNAL,
	SIDEBAR_BRANCH_NUM_SIGNALS
};
static guint sidebar_branch_signals[SIDEBAR_BRANCH_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 _SidebarBranchPrivate {
	SidebarBranchNode* root;
	SidebarBranchOptions options;
	gboolean shown;
	GCompareFunc default_comparator;
	GeeHashMap* map;
};

struct _SidebarBranchNode {
	GTypeInstance parent_instance;
	volatile int ref_count;
	SidebarEntry* entry;
	SidebarBranchNode* parent;
	GCompareFunc comparator;
	GeeSortedSet* children;
	SidebarBranchNodePrivate * priv;
};

struct _SidebarBranchNodeClass {
	GTypeClass parent_class;
	void (*finalize) (SidebarBranchNode *self);
};

struct _SidebarBranchParamSpecNode {
	GParamSpec parent_instance;
};

static gint SidebarBranch_private_offset;
static gpointer sidebar_branch_parent_class = NULL;
static gpointer sidebar_branch_node_parent_class = NULL;

static gpointer sidebar_branch_node_ref (gpointer instance);
static void sidebar_branch_node_unref (gpointer instance);
static GParamSpec* sidebar_branch_param_spec_node (const gchar* name,
                                            const gchar* nick,
                                            const gchar* blurb,
                                            GType object_type,
                                            GParamFlags flags) G_GNUC_UNUSED ;
static void sidebar_branch_value_set_node (GValue* value,
                                    gpointer v_object) G_GNUC_UNUSED ;
static void sidebar_branch_value_take_node (GValue* value,
                                     gpointer v_object) G_GNUC_UNUSED ;
static gpointer sidebar_branch_value_get_node (const GValue* value) G_GNUC_UNUSED ;
static GType sidebar_branch_node_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static void g_cclosure_user_marshal_VOID__OBJECT_OBJECT (GClosure * closure,
                                                  GValue * return_value,
                                                  guint n_param_values,
                                                  const GValue * param_values,
                                                  gpointer invocation_hint,
                                                  gpointer marshal_data);
static SidebarBranchNode* sidebar_branch_node_new (SidebarEntry* entry,
                                            SidebarBranchNode* parent,
                                            GCompareFunc comparator);
static SidebarBranchNode* sidebar_branch_node_construct (GType object_type,
                                                  SidebarEntry* entry,
                                                  SidebarBranchNode* parent,
                                                  GCompareFunc comparator);
static void sidebar_branch_node_add_child (SidebarBranchNode* self,
                                    SidebarBranchNode* child);
static void sidebar_branch_node_prune_children (SidebarBranchNode* self,
                                         SidebarBranchNodePruneCallback cb,
                                         gpointer cb_target);
static void sidebar_branch_prune_callback (SidebarBranch* self,
                                    SidebarBranchNode* node);
static void _sidebar_branch_prune_callback_sidebar_branch_node_prune_callback (SidebarBranchNode* node,
                                                                        gpointer self);
static void sidebar_branch_node_remove_child (SidebarBranchNode* self,
                                       SidebarBranchNode* child);
static gboolean sidebar_branch_node_has_children (SidebarBranchNode* self);
static gboolean sidebar_branch_node_reorder_child (SidebarBranchNode* self,
                                            SidebarBranchNode* child);
static void sidebar_branch_node_reorder_children (SidebarBranchNode* self,
                                           gboolean recursive,
                                           SidebarBranchNodeChildrenReorderedCallback cb,
                                           gpointer cb_target);
static void sidebar_branch_children_reordered_callback (SidebarBranch* self,
                                                 SidebarBranchNode* node);
static void _sidebar_branch_children_reordered_callback_sidebar_branch_node_children_reordered_callback (SidebarBranchNode* node,
                                                                                                  gpointer self);
static void sidebar_branch_node_change_comparator (SidebarBranchNode* self,
                                            GCompareFunc comparator,
                                            gboolean recursive,
                                            SidebarBranchNodeChildrenReorderedCallback cb,
                                            gpointer cb_target);
static gint sidebar_branch_node_comparator_wrapper (SidebarBranchNode* anode,
                                             SidebarBranchNode* bnode);
static gint _sidebar_branch_node_comparator_wrapper_gcompare_data_func (gconstpointer a,
                                                                 gconstpointer b,
                                                                 gpointer self);
static gint sidebar_branch_node_index_of_by_reference (SidebarBranchNode* self,
                                                SidebarBranchNode* child);
static void sidebar_branch_node_finalize (SidebarBranchNode * obj);
static GType sidebar_branch_node_get_type_once (void);
static void sidebar_branch_finalize (GObject * obj);
static GType sidebar_branch_get_type_once (void);

static inline gpointer
sidebar_branch_get_instance_private (SidebarBranch* self)
{
	return G_STRUCT_MEMBER_P (self, SidebarBranch_private_offset);
}

gboolean
sidebar_branch_options_is_hide_if_empty (SidebarBranchOptions self)
{
	gboolean result;
	result = (self & SIDEBAR_BRANCH_OPTIONS_HIDE_IF_EMPTY) != 0;
	return result;
}

gboolean
sidebar_branch_options_is_auto_open_on_new_child (SidebarBranchOptions self)
{
	gboolean result;
	result = (self & SIDEBAR_BRANCH_OPTIONS_AUTO_OPEN_ON_NEW_CHILD) != 0;
	return result;
}

gboolean
sidebar_branch_options_is_startup_expand_to_first_child (SidebarBranchOptions self)
{
	gboolean result;
	result = (self & SIDEBAR_BRANCH_OPTIONS_STARTUP_EXPAND_TO_FIRST_CHILD) != 0;
	return result;
}

gboolean
sidebar_branch_options_is_startup_open_grouping (SidebarBranchOptions self)
{
	gboolean result;
	result = (self & SIDEBAR_BRANCH_OPTIONS_STARTUP_OPEN_GROUPING) != 0;
	return result;
}

static GType
sidebar_branch_options_get_type_once (void)
{
	static const GFlagsValue values[] = {{SIDEBAR_BRANCH_OPTIONS_NONE, "SIDEBAR_BRANCH_OPTIONS_NONE", "none"}, {SIDEBAR_BRANCH_OPTIONS_HIDE_IF_EMPTY, "SIDEBAR_BRANCH_OPTIONS_HIDE_IF_EMPTY", "hide-if-empty"}, {SIDEBAR_BRANCH_OPTIONS_AUTO_OPEN_ON_NEW_CHILD, "SIDEBAR_BRANCH_OPTIONS_AUTO_OPEN_ON_NEW_CHILD", "auto-open-on-new-child"}, {SIDEBAR_BRANCH_OPTIONS_STARTUP_EXPAND_TO_FIRST_CHILD, "SIDEBAR_BRANCH_OPTIONS_STARTUP_EXPAND_TO_FIRST_CHILD", "startup-expand-to-first-child"}, {SIDEBAR_BRANCH_OPTIONS_STARTUP_OPEN_GROUPING, "SIDEBAR_BRANCH_OPTIONS_STARTUP_OPEN_GROUPING", "startup-open-grouping"}, {0, NULL, NULL}};
	GType sidebar_branch_options_type_id;
	sidebar_branch_options_type_id = g_flags_register_static ("SidebarBranchOptions", values);
	return sidebar_branch_options_type_id;
}

GType
sidebar_branch_options_get_type (void)
{
	static volatile gsize sidebar_branch_options_type_id__once = 0;
	if (g_once_init_enter (&sidebar_branch_options_type_id__once)) {
		GType sidebar_branch_options_type_id;
		sidebar_branch_options_type_id = sidebar_branch_options_get_type_once ();
		g_once_init_leave (&sidebar_branch_options_type_id__once, sidebar_branch_options_type_id);
	}
	return sidebar_branch_options_type_id__once;
}

static void
g_cclosure_user_marshal_VOID__OBJECT_OBJECT (GClosure * closure,
                                             GValue * return_value,
                                             guint n_param_values,
                                             const GValue * param_values,
                                             gpointer invocation_hint,
                                             gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__OBJECT_OBJECT) (gpointer data1, gpointer arg_1, gpointer arg_2, gpointer data2);
	register GMarshalFunc_VOID__OBJECT_OBJECT callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__OBJECT_OBJECT) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_object (param_values + 1), g_value_get_object (param_values + 2), data2);
}

SidebarBranch*
sidebar_branch_construct (GType object_type,
                          SidebarEntry* root,
                          SidebarBranchOptions options,
                          GCompareFunc default_comparator,
                          GCompareFunc root_comparator)
{
	SidebarBranch * self = NULL;
	GCompareFunc _tmp0_ = NULL;
	SidebarBranchNode* _tmp1_;
	GeeHashMap* _tmp2_;
	SidebarBranchNode* _tmp3_;
	g_return_val_if_fail (SIDEBAR_IS_ENTRY (root), NULL);
	self = (SidebarBranch*) geary_base_object_construct (object_type);
	self->priv->default_comparator = default_comparator;
	if (root_comparator != NULL) {
		_tmp0_ = root_comparator;
	} else {
		_tmp0_ = default_comparator;
	}
	_tmp1_ = sidebar_branch_node_new (root, NULL, _tmp0_);
	_sidebar_branch_node_unref0 (self->priv->root);
	self->priv->root = _tmp1_;
	self->priv->options = options;
	_tmp2_ = self->priv->map;
	_tmp3_ = self->priv->root;
	gee_abstract_map_set (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), root, _tmp3_);
	if (sidebar_branch_options_is_hide_if_empty (options)) {
		sidebar_branch_set_show_branch (self, FALSE);
	}
	return self;
}

SidebarBranch*
sidebar_branch_new (SidebarEntry* root,
                    SidebarBranchOptions options,
                    GCompareFunc default_comparator,
                    GCompareFunc root_comparator)
{
	return sidebar_branch_construct (SIDEBAR_TYPE_BRANCH, root, options, default_comparator, root_comparator);
}

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

SidebarEntry*
sidebar_branch_get_root (SidebarBranch* self)
{
	SidebarBranchNode* _tmp0_;
	SidebarEntry* _tmp1_;
	SidebarEntry* _tmp2_;
	SidebarEntry* result;
	g_return_val_if_fail (SIDEBAR_IS_BRANCH (self), NULL);
	_tmp0_ = self->priv->root;
	_tmp1_ = _tmp0_->entry;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	result = _tmp2_;
	return result;
}

void
sidebar_branch_set_show_branch (SidebarBranch* self,
                                gboolean shown)
{
	g_return_if_fail (SIDEBAR_IS_BRANCH (self));
	if (self->priv->shown == shown) {
		return;
	}
	self->priv->shown = shown;
	g_signal_emit (self, sidebar_branch_signals[SIDEBAR_BRANCH_SHOW_BRANCH_SIGNAL], 0, shown);
}

gboolean
sidebar_branch_get_show_branch (SidebarBranch* self)
{
	gboolean result;
	g_return_val_if_fail (SIDEBAR_IS_BRANCH (self), FALSE);
	result = self->priv->shown;
	return result;
}

gboolean
sidebar_branch_is_auto_open_on_new_child (SidebarBranch* self)
{
	gboolean result;
	g_return_val_if_fail (SIDEBAR_IS_BRANCH (self), FALSE);
	result = sidebar_branch_options_is_auto_open_on_new_child (self->priv->options);
	return result;
}

gboolean
sidebar_branch_is_startup_expand_to_first_child (SidebarBranch* self)
{
	gboolean result;
	g_return_val_if_fail (SIDEBAR_IS_BRANCH (self), FALSE);
	result = sidebar_branch_options_is_startup_expand_to_first_child (self->priv->options);
	return result;
}

gboolean
sidebar_branch_is_startup_open_grouping (SidebarBranch* self)
{
	gboolean result;
	g_return_val_if_fail (SIDEBAR_IS_BRANCH (self), FALSE);
	result = sidebar_branch_options_is_startup_open_grouping (self->priv->options);
	return result;
}

void
sidebar_branch_graft (SidebarBranch* self,
                      SidebarEntry* parent,
                      SidebarEntry* entry,
                      GCompareFunc comparator)
{
	GeeHashMap* _tmp0_;
	GeeHashMap* _tmp1_;
	SidebarBranchNode* parent_node = NULL;
	GeeHashMap* _tmp2_;
	gpointer _tmp3_;
	GCompareFunc _tmp4_ = NULL;
	SidebarBranchNode* entry_node = NULL;
	SidebarBranchNode* _tmp6_;
	SidebarBranchNode* _tmp7_;
	SidebarBranchNode* _tmp8_;
	GeeHashMap* _tmp9_;
	g_return_if_fail (SIDEBAR_IS_BRANCH (self));
	g_return_if_fail (SIDEBAR_IS_ENTRY (parent));
	g_return_if_fail (SIDEBAR_IS_ENTRY (entry));
	_tmp0_ = self->priv->map;
	_vala_assert (gee_abstract_map_has_key (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), parent), "map.has_key(parent)");
	_tmp1_ = self->priv->map;
	_vala_assert (!gee_abstract_map_has_key (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), entry), "!map.has_key(entry)");
	if (sidebar_branch_options_is_hide_if_empty (self->priv->options)) {
		sidebar_branch_set_show_branch (self, TRUE);
	}
	_tmp2_ = self->priv->map;
	_tmp3_ = gee_abstract_map_get (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), parent);
	parent_node = (SidebarBranchNode*) _tmp3_;
	if (comparator != NULL) {
		_tmp4_ = comparator;
	} else {
		GCompareFunc _tmp5_;
		_tmp5_ = self->priv->default_comparator;
		_tmp4_ = _tmp5_;
	}
	_tmp6_ = parent_node;
	_tmp7_ = sidebar_branch_node_new (entry, _tmp6_, _tmp4_);
	entry_node = _tmp7_;
	_tmp8_ = parent_node;
	sidebar_branch_node_add_child (_tmp8_, entry_node);
	_tmp9_ = self->priv->map;
	gee_abstract_map_set (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), entry, entry_node);
	g_signal_emit (self, sidebar_branch_signals[SIDEBAR_BRANCH_ENTRY_ADDED_SIGNAL], 0, entry);
	_sidebar_branch_node_unref0 (entry_node);
	_sidebar_branch_node_unref0 (parent_node);
}

static void
_sidebar_branch_prune_callback_sidebar_branch_node_prune_callback (SidebarBranchNode* node,
                                                                   gpointer self)
{
	sidebar_branch_prune_callback ((SidebarBranch*) self, node);
}

void
sidebar_branch_prune (SidebarBranch* self,
                      SidebarEntry* entry)
{
	SidebarBranchNode* _tmp0_;
	SidebarEntry* _tmp1_;
	GeeHashMap* _tmp2_;
	SidebarBranchNode* entry_node = NULL;
	GeeHashMap* _tmp3_;
	gpointer _tmp4_;
	SidebarBranchNode* _tmp5_;
	SidebarBranchNode* _tmp6_;
	SidebarBranchNode* _tmp7_;
	SidebarBranchNode* _tmp8_;
	SidebarBranchNode* _tmp9_;
	SidebarBranchNode* _tmp10_;
	gboolean removed = FALSE;
	GeeHashMap* _tmp11_;
	gboolean _tmp12_ = FALSE;
	g_return_if_fail (SIDEBAR_IS_BRANCH (self));
	g_return_if_fail (SIDEBAR_IS_ENTRY (entry));
	_tmp0_ = self->priv->root;
	_tmp1_ = _tmp0_->entry;
	_vala_assert (entry != _tmp1_, "entry != root.entry");
	_tmp2_ = self->priv->map;
	_vala_assert (gee_abstract_map_has_key (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), entry), "map.has_key(entry)");
	_tmp3_ = self->priv->map;
	_tmp4_ = gee_abstract_map_get (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), entry);
	entry_node = (SidebarBranchNode*) _tmp4_;
	_tmp5_ = entry_node;
	sidebar_branch_node_prune_children (_tmp5_, _sidebar_branch_prune_callback_sidebar_branch_node_prune_callback, self);
	_tmp6_ = entry_node;
	_tmp7_ = _tmp6_->parent;
	_vala_assert (_tmp7_ != NULL, "entry_node.parent != null");
	_tmp8_ = entry_node;
	_tmp9_ = _tmp8_->parent;
	_tmp10_ = entry_node;
	sidebar_branch_node_remove_child (_tmp9_, _tmp10_);
	_tmp11_ = self->priv->map;
	removed = gee_abstract_map_unset (G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), entry, NULL);
	_vala_assert (removed, "removed");
	g_signal_emit (self, sidebar_branch_signals[SIDEBAR_BRANCH_ENTRY_REMOVED_SIGNAL], 0, entry);
	if (sidebar_branch_options_is_hide_if_empty (self->priv->options)) {
		SidebarBranchNode* _tmp13_;
		_tmp13_ = self->priv->root;
		_tmp12_ = !sidebar_branch_node_has_children (_tmp13_);
	} else {
		_tmp12_ = FALSE;
	}
	if (_tmp12_) {
		sidebar_branch_set_show_branch (self, FALSE);
	}
	_sidebar_branch_node_unref0 (entry_node);
}

void
sidebar_branch_reparent (SidebarBranch* self,
                         SidebarEntry* new_parent,
                         SidebarEntry* entry)
{
	SidebarBranchNode* _tmp0_;
	SidebarEntry* _tmp1_;
	GeeHashMap* _tmp2_;
	GeeHashMap* _tmp3_;
	SidebarBranchNode* entry_node = NULL;
	GeeHashMap* _tmp4_;
	gpointer _tmp5_;
	SidebarBranchNode* new_parent_node = NULL;
	GeeHashMap* _tmp6_;
	gpointer _tmp7_;
	SidebarBranchNode* _tmp8_;
	SidebarEntry* old_parent = NULL;
	SidebarBranchNode* _tmp9_;
	SidebarEntry* _tmp10_;
	SidebarEntry* _tmp11_;
	SidebarBranchNode* _tmp12_;
	g_return_if_fail (SIDEBAR_IS_BRANCH (self));
	g_return_if_fail (SIDEBAR_IS_ENTRY (new_parent));
	g_return_if_fail (SIDEBAR_IS_ENTRY (entry));
	_tmp0_ = self->priv->root;
	_tmp1_ = _tmp0_->entry;
	_vala_assert (entry != _tmp1_, "entry != root.entry");
	_tmp2_ = self->priv->map;
	_vala_assert (gee_abstract_map_has_key (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), entry), "map.has_key(entry)");
	_tmp3_ = self->priv->map;
	_vala_assert (gee_abstract_map_has_key (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), new_parent), "map.has_key(new_parent)");
	_tmp4_ = self->priv->map;
	_tmp5_ = gee_abstract_map_get (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), entry);
	entry_node = (SidebarBranchNode*) _tmp5_;
	_tmp6_ = self->priv->map;
	_tmp7_ = gee_abstract_map_get (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), new_parent);
	new_parent_node = (SidebarBranchNode*) _tmp7_;
	_tmp8_ = entry_node->parent;
	_vala_assert (_tmp8_ != NULL, "entry_node.parent != null");
	_tmp9_ = entry_node->parent;
	_tmp10_ = _tmp9_->entry;
	_tmp11_ = _g_object_ref0 (_tmp10_);
	old_parent = _tmp11_;
	_tmp12_ = entry_node->parent;
	sidebar_branch_node_remove_child (_tmp12_, entry_node);
	sidebar_branch_node_add_child (new_parent_node, entry_node);
	g_signal_emit (self, sidebar_branch_signals[SIDEBAR_BRANCH_ENTRY_REPARENTED_SIGNAL], 0, entry, old_parent);
	_g_object_unref0 (old_parent);
	_sidebar_branch_node_unref0 (new_parent_node);
	_sidebar_branch_node_unref0 (entry_node);
}

gboolean
sidebar_branch_has_entry (SidebarBranch* self,
                          SidebarEntry* entry)
{
	gboolean _tmp0_ = FALSE;
	SidebarBranchNode* _tmp1_;
	SidebarEntry* _tmp2_;
	gboolean result;
	g_return_val_if_fail (SIDEBAR_IS_BRANCH (self), FALSE);
	g_return_val_if_fail (SIDEBAR_IS_ENTRY (entry), FALSE);
	_tmp1_ = self->priv->root;
	_tmp2_ = _tmp1_->entry;
	if (_tmp2_ == entry) {
		_tmp0_ = TRUE;
	} else {
		GeeHashMap* _tmp3_;
		_tmp3_ = self->priv->map;
		_tmp0_ = gee_abstract_map_has_key (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), entry);
	}
	result = _tmp0_;
	return result;
}

void
sidebar_branch_reorder (SidebarBranch* self,
                        SidebarEntry* entry)
{
	SidebarBranchNode* _tmp0_;
	SidebarEntry* _tmp1_;
	SidebarBranchNode* entry_node = NULL;
	GeeHashMap* _tmp2_;
	gpointer _tmp3_;
	SidebarBranchNode* _tmp4_;
	SidebarBranchNode* _tmp5_;
	SidebarBranchNode* _tmp6_;
	SidebarBranchNode* _tmp7_;
	SidebarBranchNode* _tmp8_;
	SidebarBranchNode* _tmp9_;
	g_return_if_fail (SIDEBAR_IS_BRANCH (self));
	g_return_if_fail (SIDEBAR_IS_ENTRY (entry));
	_tmp0_ = self->priv->root;
	_tmp1_ = _tmp0_->entry;
	_vala_assert (entry != _tmp1_, "entry != root.entry");
	_tmp2_ = self->priv->map;
	_tmp3_ = gee_abstract_map_get (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), entry);
	entry_node = (SidebarBranchNode*) _tmp3_;
	_tmp4_ = entry_node;
	_vala_assert (_tmp4_ != NULL, "entry_node != null");
	_tmp5_ = entry_node;
	_tmp6_ = _tmp5_->parent;
	_vala_assert (_tmp6_ != NULL, "entry_node.parent != null");
	_tmp7_ = entry_node;
	_tmp8_ = _tmp7_->parent;
	_tmp9_ = entry_node;
	if (sidebar_branch_node_reorder_child (_tmp8_, _tmp9_)) {
		g_signal_emit (self, sidebar_branch_signals[SIDEBAR_BRANCH_ENTRY_MOVED_SIGNAL], 0, entry);
	}
	_sidebar_branch_node_unref0 (entry_node);
}

static void
_sidebar_branch_children_reordered_callback_sidebar_branch_node_children_reordered_callback (SidebarBranchNode* node,
                                                                                             gpointer self)
{
	sidebar_branch_children_reordered_callback ((SidebarBranch*) self, node);
}

void
sidebar_branch_reorder_all (SidebarBranch* self)
{
	SidebarBranchNode* _tmp0_;
	g_return_if_fail (SIDEBAR_IS_BRANCH (self));
	_tmp0_ = self->priv->root;
	sidebar_branch_node_reorder_children (_tmp0_, TRUE, _sidebar_branch_children_reordered_callback_sidebar_branch_node_children_reordered_callback, self);
}

void
sidebar_branch_reorder_children (SidebarBranch* self,
                                 SidebarEntry* entry,
                                 gboolean recursive)
{
	SidebarBranchNode* entry_node = NULL;
	GeeHashMap* _tmp0_;
	gpointer _tmp1_;
	g_return_if_fail (SIDEBAR_IS_BRANCH (self));
	g_return_if_fail (SIDEBAR_IS_ENTRY (entry));
	_tmp0_ = self->priv->map;
	_tmp1_ = gee_abstract_map_get (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), entry);
	entry_node = (SidebarBranchNode*) _tmp1_;
	_vala_assert (entry_node != NULL, "entry_node != null");
	sidebar_branch_node_reorder_children (entry_node, recursive, _sidebar_branch_children_reordered_callback_sidebar_branch_node_children_reordered_callback, self);
	_sidebar_branch_node_unref0 (entry_node);
}

void
sidebar_branch_change_all_comparators (SidebarBranch* self,
                                       GCompareFunc comparator)
{
	SidebarBranchNode* _tmp0_;
	g_return_if_fail (SIDEBAR_IS_BRANCH (self));
	_tmp0_ = self->priv->root;
	sidebar_branch_node_change_comparator (_tmp0_, comparator, TRUE, _sidebar_branch_children_reordered_callback_sidebar_branch_node_children_reordered_callback, self);
}

void
sidebar_branch_change_comparator (SidebarBranch* self,
                                  SidebarEntry* entry,
                                  gboolean recursive,
                                  GCompareFunc comparator)
{
	SidebarBranchNode* entry_node = NULL;
	GeeHashMap* _tmp0_;
	gpointer _tmp1_;
	g_return_if_fail (SIDEBAR_IS_BRANCH (self));
	g_return_if_fail (SIDEBAR_IS_ENTRY (entry));
	_tmp0_ = self->priv->map;
	_tmp1_ = gee_abstract_map_get (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), entry);
	entry_node = (SidebarBranchNode*) _tmp1_;
	_vala_assert (entry_node != NULL, "entry_node != null");
	sidebar_branch_node_change_comparator (entry_node, comparator, recursive, _sidebar_branch_children_reordered_callback_sidebar_branch_node_children_reordered_callback, self);
	_sidebar_branch_node_unref0 (entry_node);
}

gint
sidebar_branch_get_child_count (SidebarBranch* self,
                                SidebarEntry* parent)
{
	SidebarBranchNode* parent_node = NULL;
	GeeHashMap* _tmp0_;
	gpointer _tmp1_;
	SidebarBranchNode* _tmp2_;
	gint _tmp3_ = 0;
	SidebarBranchNode* _tmp4_;
	GeeSortedSet* _tmp5_;
	gint result;
	g_return_val_if_fail (SIDEBAR_IS_BRANCH (self), 0);
	g_return_val_if_fail (SIDEBAR_IS_ENTRY (parent), 0);
	_tmp0_ = self->priv->map;
	_tmp1_ = gee_abstract_map_get (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), parent);
	parent_node = (SidebarBranchNode*) _tmp1_;
	_tmp2_ = parent_node;
	_vala_assert (_tmp2_ != NULL, "parent_node != null");
	_tmp4_ = parent_node;
	_tmp5_ = _tmp4_->children;
	if (_tmp5_ != NULL) {
		SidebarBranchNode* _tmp6_;
		GeeSortedSet* _tmp7_;
		gint _tmp8_;
		gint _tmp9_;
		_tmp6_ = parent_node;
		_tmp7_ = _tmp6_->children;
		_tmp8_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, GEE_TYPE_COLLECTION, GeeCollection));
		_tmp9_ = _tmp8_;
		_tmp3_ = _tmp9_;
	} else {
		_tmp3_ = 0;
	}
	result = _tmp3_;
	_sidebar_branch_node_unref0 (parent_node);
	return result;
}

GeeList*
sidebar_branch_get_children (SidebarBranch* self,
                             SidebarEntry* parent)
{
	GeeHashMap* _tmp0_;
	SidebarBranchNode* parent_node = NULL;
	GeeHashMap* _tmp1_;
	gpointer _tmp2_;
	SidebarBranchNode* _tmp3_;
	GeeSortedSet* _tmp4_;
	GeeList* child_entries = NULL;
	GeeArrayList* _tmp5_;
	GeeList* result;
	g_return_val_if_fail (SIDEBAR_IS_BRANCH (self), NULL);
	g_return_val_if_fail (SIDEBAR_IS_ENTRY (parent), NULL);
	_tmp0_ = self->priv->map;
	_vala_assert (gee_abstract_map_has_key (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), parent), "map.has_key(parent)");
	_tmp1_ = self->priv->map;
	_tmp2_ = gee_abstract_map_get (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), parent);
	parent_node = (SidebarBranchNode*) _tmp2_;
	_tmp3_ = parent_node;
	_tmp4_ = _tmp3_->children;
	if (_tmp4_ == NULL) {
		result = NULL;
		_sidebar_branch_node_unref0 (parent_node);
		return result;
	}
	_tmp5_ = gee_array_list_new (SIDEBAR_TYPE_ENTRY, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	child_entries = G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, GEE_TYPE_LIST, GeeList);
	{
		GeeIterator* _child_it = NULL;
		SidebarBranchNode* _tmp6_;
		GeeSortedSet* _tmp7_;
		GeeIterator* _tmp8_;
		_tmp6_ = parent_node;
		_tmp7_ = _tmp6_->children;
		_tmp8_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, GEE_TYPE_ITERABLE, GeeIterable));
		_child_it = _tmp8_;
		while (TRUE) {
			GeeIterator* _tmp9_;
			SidebarBranchNode* child = NULL;
			GeeIterator* _tmp10_;
			gpointer _tmp11_;
			GeeList* _tmp12_;
			SidebarBranchNode* _tmp13_;
			SidebarEntry* _tmp14_;
			_tmp9_ = _child_it;
			if (!gee_iterator_next (_tmp9_)) {
				break;
			}
			_tmp10_ = _child_it;
			_tmp11_ = gee_iterator_get (_tmp10_);
			child = (SidebarBranchNode*) _tmp11_;
			_tmp12_ = child_entries;
			_tmp13_ = child;
			_tmp14_ = _tmp13_->entry;
			gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, GEE_TYPE_COLLECTION, GeeCollection), _tmp14_);
			_sidebar_branch_node_unref0 (child);
		}
		_g_object_unref0 (_child_it);
	}
	result = child_entries;
	_sidebar_branch_node_unref0 (parent_node);
	return result;
}

SidebarEntry*
sidebar_branch_find_first_child (SidebarBranch* self,
                                 SidebarEntry* parent,
                                 Locator locator,
                                 gpointer locator_target)
{
	SidebarBranchNode* parent_node = NULL;
	GeeHashMap* _tmp0_;
	gpointer _tmp1_;
	SidebarBranchNode* _tmp2_;
	SidebarBranchNode* _tmp3_;
	GeeSortedSet* _tmp4_;
	SidebarEntry* result;
	g_return_val_if_fail (SIDEBAR_IS_BRANCH (self), NULL);
	g_return_val_if_fail (SIDEBAR_IS_ENTRY (parent), NULL);
	_tmp0_ = self->priv->map;
	_tmp1_ = gee_abstract_map_get (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), parent);
	parent_node = (SidebarBranchNode*) _tmp1_;
	_tmp2_ = parent_node;
	_vala_assert (_tmp2_ != NULL, "parent_node != null");
	_tmp3_ = parent_node;
	_tmp4_ = _tmp3_->children;
	if (_tmp4_ == NULL) {
		result = NULL;
		_sidebar_branch_node_unref0 (parent_node);
		return result;
	}
	{
		GeeIterator* _child_it = NULL;
		SidebarBranchNode* _tmp5_;
		GeeSortedSet* _tmp6_;
		GeeIterator* _tmp7_;
		_tmp5_ = parent_node;
		_tmp6_ = _tmp5_->children;
		_tmp7_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, GEE_TYPE_ITERABLE, GeeIterable));
		_child_it = _tmp7_;
		while (TRUE) {
			GeeIterator* _tmp8_;
			SidebarBranchNode* child = NULL;
			GeeIterator* _tmp9_;
			gpointer _tmp10_;
			SidebarBranchNode* _tmp11_;
			SidebarEntry* _tmp12_;
			_tmp8_ = _child_it;
			if (!gee_iterator_next (_tmp8_)) {
				break;
			}
			_tmp9_ = _child_it;
			_tmp10_ = gee_iterator_get (_tmp9_);
			child = (SidebarBranchNode*) _tmp10_;
			_tmp11_ = child;
			_tmp12_ = _tmp11_->entry;
			if (locator (_tmp12_, locator_target)) {
				SidebarBranchNode* _tmp13_;
				SidebarEntry* _tmp14_;
				SidebarEntry* _tmp15_;
				_tmp13_ = child;
				_tmp14_ = _tmp13_->entry;
				_tmp15_ = _g_object_ref0 (_tmp14_);
				result = _tmp15_;
				_sidebar_branch_node_unref0 (child);
				_g_object_unref0 (_child_it);
				_sidebar_branch_node_unref0 (parent_node);
				return result;
			}
			_sidebar_branch_node_unref0 (child);
		}
		_g_object_unref0 (_child_it);
	}
	result = NULL;
	_sidebar_branch_node_unref0 (parent_node);
	return result;
}

SidebarEntry*
sidebar_branch_get_parent (SidebarBranch* self,
                           SidebarEntry* entry)
{
	SidebarBranchNode* _tmp0_;
	SidebarEntry* _tmp1_;
	SidebarBranchNode* entry_node = NULL;
	GeeHashMap* _tmp2_;
	gpointer _tmp3_;
	SidebarBranchNode* _tmp4_;
	SidebarBranchNode* _tmp5_;
	SidebarBranchNode* _tmp6_;
	SidebarBranchNode* _tmp7_;
	SidebarBranchNode* _tmp8_;
	SidebarEntry* _tmp9_;
	SidebarEntry* _tmp10_;
	SidebarEntry* result;
	g_return_val_if_fail (SIDEBAR_IS_BRANCH (self), NULL);
	g_return_val_if_fail (SIDEBAR_IS_ENTRY (entry), NULL);
	_tmp0_ = self->priv->root;
	_tmp1_ = _tmp0_->entry;
	if (entry == _tmp1_) {
		result = NULL;
		return result;
	}
	_tmp2_ = self->priv->map;
	_tmp3_ = gee_abstract_map_get (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), entry);
	entry_node = (SidebarBranchNode*) _tmp3_;
	_tmp4_ = entry_node;
	_vala_assert (_tmp4_ != NULL, "entry_node != null");
	_tmp5_ = entry_node;
	_tmp6_ = _tmp5_->parent;
	_vala_assert (_tmp6_ != NULL, "entry_node.parent != null");
	_tmp7_ = entry_node;
	_tmp8_ = _tmp7_->parent;
	_tmp9_ = _tmp8_->entry;
	_tmp10_ = _g_object_ref0 (_tmp9_);
	result = _tmp10_;
	_sidebar_branch_node_unref0 (entry_node);
	return result;
}

SidebarEntry*
sidebar_branch_get_previous_sibling (SidebarBranch* self,
                                     SidebarEntry* entry)
{
	SidebarBranchNode* _tmp0_;
	SidebarEntry* _tmp1_;
	SidebarBranchNode* entry_node = NULL;
	GeeHashMap* _tmp2_;
	gpointer _tmp3_;
	SidebarBranchNode* _tmp4_;
	SidebarBranchNode* _tmp5_;
	SidebarBranchNode* _tmp6_;
	SidebarBranchNode* _tmp7_;
	SidebarBranchNode* _tmp8_;
	GeeSortedSet* _tmp9_;
	SidebarBranchNode* sibling = NULL;
	SidebarBranchNode* _tmp10_;
	SidebarBranchNode* _tmp11_;
	GeeSortedSet* _tmp12_;
	SidebarBranchNode* _tmp13_;
	gpointer _tmp14_;
	SidebarEntry* _tmp15_ = NULL;
	SidebarBranchNode* _tmp16_;
	SidebarEntry* _tmp19_;
	SidebarEntry* result;
	g_return_val_if_fail (SIDEBAR_IS_BRANCH (self), NULL);
	g_return_val_if_fail (SIDEBAR_IS_ENTRY (entry), NULL);
	_tmp0_ = self->priv->root;
	_tmp1_ = _tmp0_->entry;
	if (entry == _tmp1_) {
		result = NULL;
		return result;
	}
	_tmp2_ = self->priv->map;
	_tmp3_ = gee_abstract_map_get (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), entry);
	entry_node = (SidebarBranchNode*) _tmp3_;
	_tmp4_ = entry_node;
	_vala_assert (_tmp4_ != NULL, "entry_node != null");
	_tmp5_ = entry_node;
	_tmp6_ = _tmp5_->parent;
	_vala_assert (_tmp6_ != NULL, "entry_node.parent != null");
	_tmp7_ = entry_node;
	_tmp8_ = _tmp7_->parent;
	_tmp9_ = _tmp8_->children;
	_vala_assert (_tmp9_ != NULL, "entry_node.parent.children != null");
	_tmp10_ = entry_node;
	_tmp11_ = _tmp10_->parent;
	_tmp12_ = _tmp11_->children;
	_tmp13_ = entry_node;
	_tmp14_ = gee_sorted_set_lower (_tmp12_, _tmp13_);
	sibling = (SidebarBranchNode*) _tmp14_;
	_tmp16_ = sibling;
	if (_tmp16_ != NULL) {
		SidebarBranchNode* _tmp17_;
		SidebarEntry* _tmp18_;
		_tmp17_ = sibling;
		_tmp18_ = _tmp17_->entry;
		_tmp15_ = _tmp18_;
	} else {
		_tmp15_ = NULL;
	}
	_tmp19_ = _g_object_ref0 (_tmp15_);
	result = _tmp19_;
	_sidebar_branch_node_unref0 (sibling);
	_sidebar_branch_node_unref0 (entry_node);
	return result;
}

SidebarEntry*
sidebar_branch_get_next_sibling (SidebarBranch* self,
                                 SidebarEntry* entry)
{
	SidebarBranchNode* _tmp0_;
	SidebarEntry* _tmp1_;
	SidebarBranchNode* entry_node = NULL;
	GeeHashMap* _tmp2_;
	gpointer _tmp3_;
	SidebarBranchNode* _tmp4_;
	SidebarBranchNode* _tmp5_;
	SidebarBranchNode* _tmp6_;
	SidebarBranchNode* _tmp7_;
	SidebarBranchNode* _tmp8_;
	GeeSortedSet* _tmp9_;
	SidebarBranchNode* sibling = NULL;
	SidebarBranchNode* _tmp10_;
	SidebarBranchNode* _tmp11_;
	GeeSortedSet* _tmp12_;
	SidebarBranchNode* _tmp13_;
	gpointer _tmp14_;
	SidebarEntry* _tmp15_ = NULL;
	SidebarBranchNode* _tmp16_;
	SidebarEntry* _tmp19_;
	SidebarEntry* result;
	g_return_val_if_fail (SIDEBAR_IS_BRANCH (self), NULL);
	g_return_val_if_fail (SIDEBAR_IS_ENTRY (entry), NULL);
	_tmp0_ = self->priv->root;
	_tmp1_ = _tmp0_->entry;
	if (entry == _tmp1_) {
		result = NULL;
		return result;
	}
	_tmp2_ = self->priv->map;
	_tmp3_ = gee_abstract_map_get (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), entry);
	entry_node = (SidebarBranchNode*) _tmp3_;
	_tmp4_ = entry_node;
	_vala_assert (_tmp4_ != NULL, "entry_node != null");
	_tmp5_ = entry_node;
	_tmp6_ = _tmp5_->parent;
	_vala_assert (_tmp6_ != NULL, "entry_node.parent != null");
	_tmp7_ = entry_node;
	_tmp8_ = _tmp7_->parent;
	_tmp9_ = _tmp8_->children;
	_vala_assert (_tmp9_ != NULL, "entry_node.parent.children != null");
	_tmp10_ = entry_node;
	_tmp11_ = _tmp10_->parent;
	_tmp12_ = _tmp11_->children;
	_tmp13_ = entry_node;
	_tmp14_ = gee_sorted_set_higher (_tmp12_, _tmp13_);
	sibling = (SidebarBranchNode*) _tmp14_;
	_tmp16_ = sibling;
	if (_tmp16_ != NULL) {
		SidebarBranchNode* _tmp17_;
		SidebarEntry* _tmp18_;
		_tmp17_ = sibling;
		_tmp18_ = _tmp17_->entry;
		_tmp15_ = _tmp18_;
	} else {
		_tmp15_ = NULL;
	}
	_tmp19_ = _g_object_ref0 (_tmp15_);
	result = _tmp19_;
	_sidebar_branch_node_unref0 (sibling);
	_sidebar_branch_node_unref0 (entry_node);
	return result;
}

static void
sidebar_branch_prune_callback (SidebarBranch* self,
                               SidebarBranchNode* node)
{
	SidebarEntry* _tmp0_;
	g_return_if_fail (SIDEBAR_IS_BRANCH (self));
	g_return_if_fail (SIDEBAR_BRANCH_IS_NODE (node));
	_tmp0_ = node->entry;
	g_signal_emit (self, sidebar_branch_signals[SIDEBAR_BRANCH_ENTRY_REMOVED_SIGNAL], 0, _tmp0_);
}

static void
sidebar_branch_children_reordered_callback (SidebarBranch* self,
                                            SidebarBranchNode* node)
{
	SidebarEntry* _tmp0_;
	g_return_if_fail (SIDEBAR_IS_BRANCH (self));
	g_return_if_fail (SIDEBAR_BRANCH_IS_NODE (node));
	_tmp0_ = node->entry;
	g_signal_emit (self, sidebar_branch_signals[SIDEBAR_BRANCH_CHILDREN_REORDERED_SIGNAL], 0, _tmp0_);
}

static SidebarBranchNode*
sidebar_branch_node_construct (GType object_type,
                               SidebarEntry* entry,
                               SidebarBranchNode* parent,
                               GCompareFunc comparator)
{
	SidebarBranchNode* self = NULL;
	SidebarEntry* _tmp0_;
	g_return_val_if_fail (SIDEBAR_IS_ENTRY (entry), NULL);
	g_return_val_if_fail ((parent == NULL) || SIDEBAR_BRANCH_IS_NODE (parent), NULL);
	self = (SidebarBranchNode*) g_type_create_instance (object_type);
	_tmp0_ = _g_object_ref0 (entry);
	_g_object_unref0 (self->entry);
	self->entry = _tmp0_;
	self->parent = parent;
	self->comparator = comparator;
	return self;
}

static SidebarBranchNode*
sidebar_branch_node_new (SidebarEntry* entry,
                         SidebarBranchNode* parent,
                         GCompareFunc comparator)
{
	return sidebar_branch_node_construct (SIDEBAR_BRANCH_TYPE_NODE, entry, parent, comparator);
}

static gint
sidebar_branch_node_comparator_wrapper (SidebarBranchNode* anode,
                                        SidebarBranchNode* bnode)
{
	SidebarBranchNode* _tmp0_;
	SidebarBranchNode* _tmp1_;
	SidebarBranchNode* _tmp2_;
	GCompareFunc _tmp3_;
	SidebarEntry* _tmp4_;
	SidebarEntry* _tmp5_;
	gint result;
	g_return_val_if_fail (SIDEBAR_BRANCH_IS_NODE (anode), 0);
	g_return_val_if_fail (SIDEBAR_BRANCH_IS_NODE (bnode), 0);
	if (anode == bnode) {
		result = 0;
		return result;
	}
	_tmp0_ = anode->parent;
	_tmp1_ = bnode->parent;
	_vala_assert (_tmp0_ == _tmp1_, "anode.parent == bnode.parent");
	_tmp2_ = anode->parent;
	_tmp3_ = _tmp2_->comparator;
	_tmp4_ = anode->entry;
	_tmp5_ = bnode->entry;
	result = _tmp3_ (_tmp4_, _tmp5_);
	return result;
}

static gboolean
sidebar_branch_node_has_children (SidebarBranchNode* self)
{
	gboolean _tmp0_ = FALSE;
	GeeSortedSet* _tmp1_;
	gboolean result;
	g_return_val_if_fail (SIDEBAR_BRANCH_IS_NODE (self), FALSE);
	_tmp1_ = self->children;
	if (_tmp1_ != NULL) {
		GeeSortedSet* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		_tmp2_ = self->children;
		_tmp3_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEE_TYPE_COLLECTION, GeeCollection));
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_ > 0;
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

static gint
_sidebar_branch_node_comparator_wrapper_gcompare_data_func (gconstpointer a,
                                                            gconstpointer b,
                                                            gpointer self)
{
	gint result;
	result = sidebar_branch_node_comparator_wrapper ((SidebarBranchNode*) a, (SidebarBranchNode*) b);
	return result;
}

static void
sidebar_branch_node_add_child (SidebarBranchNode* self,
                               SidebarBranchNode* child)
{
	GeeSortedSet* _tmp0_;
	GeeSortedSet* _tmp2_;
	g_return_if_fail (SIDEBAR_BRANCH_IS_NODE (self));
	g_return_if_fail (SIDEBAR_BRANCH_IS_NODE (child));
	child->parent = self;
	_tmp0_ = self->children;
	if (_tmp0_ == NULL) {
		GeeTreeSet* _tmp1_;
		_tmp1_ = gee_tree_set_new (SIDEBAR_BRANCH_TYPE_NODE, (GBoxedCopyFunc) sidebar_branch_node_ref, (GDestroyNotify) sidebar_branch_node_unref, _sidebar_branch_node_comparator_wrapper_gcompare_data_func, NULL, NULL);
		_g_object_unref0 (self->children);
		self->children = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_SORTED_SET, GeeSortedSet);
	}
	_tmp2_ = self->children;
	gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEE_TYPE_COLLECTION, GeeCollection), child);
}

static void
sidebar_branch_node_remove_child (SidebarBranchNode* self,
                                  SidebarBranchNode* child)
{
	GeeSortedSet* new_children = NULL;
	GeeTreeSet* _tmp0_;
	GeeSortedSet* _tmp9_;
	gint _tmp10_;
	gint _tmp11_;
	g_return_if_fail (SIDEBAR_BRANCH_IS_NODE (self));
	g_return_if_fail (SIDEBAR_BRANCH_IS_NODE (child));
	_tmp0_ = gee_tree_set_new (SIDEBAR_BRANCH_TYPE_NODE, (GBoxedCopyFunc) sidebar_branch_node_ref, (GDestroyNotify) sidebar_branch_node_unref, _sidebar_branch_node_comparator_wrapper_gcompare_data_func, NULL, NULL);
	new_children = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_SORTED_SET, GeeSortedSet);
	{
		GeeIterator* _c_it = NULL;
		GeeSortedSet* _tmp1_;
		GeeIterator* _tmp2_;
		_tmp1_ = self->children;
		_tmp2_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_ITERABLE, GeeIterable));
		_c_it = _tmp2_;
		while (TRUE) {
			GeeIterator* _tmp3_;
			SidebarBranchNode* c = NULL;
			GeeIterator* _tmp4_;
			gpointer _tmp5_;
			SidebarBranchNode* _tmp6_;
			_tmp3_ = _c_it;
			if (!gee_iterator_next (_tmp3_)) {
				break;
			}
			_tmp4_ = _c_it;
			_tmp5_ = gee_iterator_get (_tmp4_);
			c = (SidebarBranchNode*) _tmp5_;
			_tmp6_ = c;
			if (_tmp6_ != child) {
				GeeSortedSet* _tmp7_;
				SidebarBranchNode* _tmp8_;
				_tmp7_ = new_children;
				_tmp8_ = c;
				gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, GEE_TYPE_COLLECTION, GeeCollection), _tmp8_);
			}
			_sidebar_branch_node_unref0 (c);
		}
		_g_object_unref0 (_c_it);
	}
	_tmp9_ = new_children;
	_tmp10_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, GEE_TYPE_COLLECTION, GeeCollection));
	_tmp11_ = _tmp10_;
	if (_tmp11_ != 0) {
		GeeSortedSet* _tmp12_;
		GeeSortedSet* _tmp13_;
		_tmp12_ = new_children;
		_tmp13_ = _g_object_ref0 (_tmp12_);
		_g_object_unref0 (self->children);
		self->children = _tmp13_;
	} else {
		_g_object_unref0 (self->children);
		self->children = NULL;
	}
	child->parent = NULL;
	_g_object_unref0 (new_children);
}

static void
sidebar_branch_node_prune_children (SidebarBranchNode* self,
                                    SidebarBranchNodePruneCallback cb,
                                    gpointer cb_target)
{
	GeeSortedSet* _tmp0_;
	GeeSortedSet* old_children = NULL;
	GeeSortedSet* _tmp7_;
	GeeSortedSet* _tmp8_;
	g_return_if_fail (SIDEBAR_BRANCH_IS_NODE (self));
	_tmp0_ = self->children;
	if (_tmp0_ == NULL) {
		return;
	}
	{
		GeeIterator* _child_it = NULL;
		GeeSortedSet* _tmp1_;
		GeeIterator* _tmp2_;
		_tmp1_ = self->children;
		_tmp2_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_ITERABLE, GeeIterable));
		_child_it = _tmp2_;
		while (TRUE) {
			GeeIterator* _tmp3_;
			SidebarBranchNode* child = NULL;
			GeeIterator* _tmp4_;
			gpointer _tmp5_;
			SidebarBranchNode* _tmp6_;
			_tmp3_ = _child_it;
			if (!gee_iterator_next (_tmp3_)) {
				break;
			}
			_tmp4_ = _child_it;
			_tmp5_ = gee_iterator_get (_tmp4_);
			child = (SidebarBranchNode*) _tmp5_;
			_tmp6_ = child;
			sidebar_branch_node_prune_children (_tmp6_, cb, cb_target);
			_sidebar_branch_node_unref0 (child);
		}
		_g_object_unref0 (_child_it);
	}
	_tmp7_ = self->children;
	_tmp8_ = _g_object_ref0 (_tmp7_);
	old_children = _tmp8_;
	_g_object_unref0 (self->children);
	self->children = NULL;
	{
		GeeIterator* _child_it = NULL;
		GeeSortedSet* _tmp9_;
		GeeIterator* _tmp10_;
		_tmp9_ = old_children;
		_tmp10_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, GEE_TYPE_ITERABLE, GeeIterable));
		_child_it = _tmp10_;
		while (TRUE) {
			GeeIterator* _tmp11_;
			SidebarBranchNode* child = NULL;
			GeeIterator* _tmp12_;
			gpointer _tmp13_;
			SidebarBranchNode* _tmp14_;
			_tmp11_ = _child_it;
			if (!gee_iterator_next (_tmp11_)) {
				break;
			}
			_tmp12_ = _child_it;
			_tmp13_ = gee_iterator_get (_tmp12_);
			child = (SidebarBranchNode*) _tmp13_;
			_tmp14_ = child;
			cb (_tmp14_, cb_target);
			_sidebar_branch_node_unref0 (child);
		}
		_g_object_unref0 (_child_it);
	}
	_g_object_unref0 (old_children);
}

static gint
sidebar_branch_node_index_of_by_reference (SidebarBranchNode* self,
                                           SidebarBranchNode* child)
{
	GeeSortedSet* _tmp0_;
	gint index = 0;
	gint result;
	g_return_val_if_fail (SIDEBAR_BRANCH_IS_NODE (self), 0);
	g_return_val_if_fail (SIDEBAR_BRANCH_IS_NODE (child), 0);
	_tmp0_ = self->children;
	if (_tmp0_ == NULL) {
		result = -1;
		return result;
	}
	index = 0;
	{
		GeeIterator* _c_it = NULL;
		GeeSortedSet* _tmp1_;
		GeeIterator* _tmp2_;
		_tmp1_ = self->children;
		_tmp2_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_ITERABLE, GeeIterable));
		_c_it = _tmp2_;
		while (TRUE) {
			GeeIterator* _tmp3_;
			SidebarBranchNode* c = NULL;
			GeeIterator* _tmp4_;
			gpointer _tmp5_;
			SidebarBranchNode* _tmp6_;
			gint _tmp7_;
			_tmp3_ = _c_it;
			if (!gee_iterator_next (_tmp3_)) {
				break;
			}
			_tmp4_ = _c_it;
			_tmp5_ = gee_iterator_get (_tmp4_);
			c = (SidebarBranchNode*) _tmp5_;
			_tmp6_ = c;
			if (child == _tmp6_) {
				result = index;
				_sidebar_branch_node_unref0 (c);
				_g_object_unref0 (_c_it);
				return result;
			}
			_tmp7_ = index;
			index = _tmp7_ + 1;
			_sidebar_branch_node_unref0 (c);
		}
		_g_object_unref0 (_c_it);
	}
	result = -1;
	return result;
}

static gboolean
sidebar_branch_node_reorder_child (SidebarBranchNode* self,
                                   SidebarBranchNode* child)
{
	GeeSortedSet* _tmp0_;
	gint old_index = 0;
	GeeSortedSet* new_children = NULL;
	GeeTreeSet* _tmp1_;
	gboolean added = FALSE;
	GeeSortedSet* _tmp2_;
	GeeSortedSet* _tmp3_;
	gint new_index = 0;
	gboolean result;
	g_return_val_if_fail (SIDEBAR_BRANCH_IS_NODE (self), FALSE);
	g_return_val_if_fail (SIDEBAR_BRANCH_IS_NODE (child), FALSE);
	_tmp0_ = self->children;
	_vala_assert (_tmp0_ != NULL, "children != null");
	old_index = sidebar_branch_node_index_of_by_reference (self, child);
	_vala_assert (old_index >= 0, "old_index >= 0");
	_tmp1_ = gee_tree_set_new (SIDEBAR_BRANCH_TYPE_NODE, (GBoxedCopyFunc) sidebar_branch_node_ref, (GDestroyNotify) sidebar_branch_node_unref, _sidebar_branch_node_comparator_wrapper_gcompare_data_func, NULL, NULL);
	new_children = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_SORTED_SET, GeeSortedSet);
	_tmp2_ = self->children;
	added = gee_collection_add_all (G_TYPE_CHECK_INSTANCE_CAST (new_children, GEE_TYPE_COLLECTION, GeeCollection), G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEE_TYPE_COLLECTION, GeeCollection));
	_vala_assert (added, "added");
	_tmp3_ = _g_object_ref0 (new_children);
	_g_object_unref0 (self->children);
	self->children = _tmp3_;
	new_index = sidebar_branch_node_index_of_by_reference (self, child);
	_vala_assert (new_index >= 0, "new_index >= 0");
	result = old_index != new_index;
	_g_object_unref0 (new_children);
	return result;
}

static void
sidebar_branch_node_reorder_children (SidebarBranchNode* self,
                                      gboolean recursive,
                                      SidebarBranchNodeChildrenReorderedCallback cb,
                                      gpointer cb_target)
{
	GeeSortedSet* _tmp0_;
	GeeSortedSet* reordered = NULL;
	GeeTreeSet* _tmp1_;
	GeeSortedSet* _tmp2_;
	GeeSortedSet* _tmp3_;
	GeeSortedSet* _tmp4_;
	GeeSortedSet* _tmp5_;
	g_return_if_fail (SIDEBAR_BRANCH_IS_NODE (self));
	_tmp0_ = self->children;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = gee_tree_set_new (SIDEBAR_BRANCH_TYPE_NODE, (GBoxedCopyFunc) sidebar_branch_node_ref, (GDestroyNotify) sidebar_branch_node_unref, _sidebar_branch_node_comparator_wrapper_gcompare_data_func, NULL, NULL);
	reordered = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_SORTED_SET, GeeSortedSet);
	_tmp2_ = reordered;
	_tmp3_ = self->children;
	gee_collection_add_all (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEE_TYPE_COLLECTION, GeeCollection), G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEE_TYPE_COLLECTION, GeeCollection));
	_tmp4_ = reordered;
	_tmp5_ = _g_object_ref0 (_tmp4_);
	_g_object_unref0 (self->children);
	self->children = _tmp5_;
	if (recursive) {
		{
			GeeIterator* _child_it = NULL;
			GeeSortedSet* _tmp6_;
			GeeIterator* _tmp7_;
			_tmp6_ = self->children;
			_tmp7_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, GEE_TYPE_ITERABLE, GeeIterable));
			_child_it = _tmp7_;
			while (TRUE) {
				GeeIterator* _tmp8_;
				SidebarBranchNode* child = NULL;
				GeeIterator* _tmp9_;
				gpointer _tmp10_;
				SidebarBranchNode* _tmp11_;
				_tmp8_ = _child_it;
				if (!gee_iterator_next (_tmp8_)) {
					break;
				}
				_tmp9_ = _child_it;
				_tmp10_ = gee_iterator_get (_tmp9_);
				child = (SidebarBranchNode*) _tmp10_;
				_tmp11_ = child;
				sidebar_branch_node_reorder_children (_tmp11_, TRUE, cb, cb_target);
				_sidebar_branch_node_unref0 (child);
			}
			_g_object_unref0 (_child_it);
		}
	}
	cb (self, cb_target);
	_g_object_unref0 (reordered);
}

static void
sidebar_branch_node_change_comparator (SidebarBranchNode* self,
                                       GCompareFunc comparator,
                                       gboolean recursive,
                                       SidebarBranchNodeChildrenReorderedCallback cb,
                                       gpointer cb_target)
{
	g_return_if_fail (SIDEBAR_BRANCH_IS_NODE (self));
	self->comparator = comparator;
	sidebar_branch_node_reorder_children (self, FALSE, cb, cb_target);
	if (recursive) {
		{
			GeeIterator* _child_it = NULL;
			GeeSortedSet* _tmp0_;
			GeeIterator* _tmp1_;
			_tmp0_ = self->children;
			_tmp1_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_ITERABLE, GeeIterable));
			_child_it = _tmp1_;
			while (TRUE) {
				GeeIterator* _tmp2_;
				SidebarBranchNode* child = NULL;
				GeeIterator* _tmp3_;
				gpointer _tmp4_;
				SidebarBranchNode* _tmp5_;
				_tmp2_ = _child_it;
				if (!gee_iterator_next (_tmp2_)) {
					break;
				}
				_tmp3_ = _child_it;
				_tmp4_ = gee_iterator_get (_tmp3_);
				child = (SidebarBranchNode*) _tmp4_;
				_tmp5_ = child;
				sidebar_branch_node_change_comparator (_tmp5_, comparator, TRUE, cb, cb_target);
				_sidebar_branch_node_unref0 (child);
			}
			_g_object_unref0 (_child_it);
		}
	}
}

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

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

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

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

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

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

static GParamSpec*
sidebar_branch_param_spec_node (const gchar* name,
                                const gchar* nick,
                                const gchar* blurb,
                                GType object_type,
                                GParamFlags flags)
{
	SidebarBranchParamSpecNode* spec;
	g_return_val_if_fail (g_type_is_a (object_type, SIDEBAR_BRANCH_TYPE_NODE), 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
sidebar_branch_value_get_node (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, SIDEBAR_BRANCH_TYPE_NODE), NULL);
	return value->data[0].v_pointer;
}

static void
sidebar_branch_value_set_node (GValue* value,
                               gpointer v_object)
{
	SidebarBranchNode * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, SIDEBAR_BRANCH_TYPE_NODE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, SIDEBAR_BRANCH_TYPE_NODE));
		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;
		sidebar_branch_node_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		sidebar_branch_node_unref (old);
	}
}

static void
sidebar_branch_value_take_node (GValue* value,
                                gpointer v_object)
{
	SidebarBranchNode * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, SIDEBAR_BRANCH_TYPE_NODE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, SIDEBAR_BRANCH_TYPE_NODE));
		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) {
		sidebar_branch_node_unref (old);
	}
}

static void
sidebar_branch_node_class_init (SidebarBranchNodeClass * klass,
                                gpointer klass_data)
{
	sidebar_branch_node_parent_class = g_type_class_peek_parent (klass);
	((SidebarBranchNodeClass *) klass)->finalize = sidebar_branch_node_finalize;
}

static void
sidebar_branch_node_instance_init (SidebarBranchNode * self,
                                   gpointer klass)
{
	self->children = NULL;
	self->ref_count = 1;
}

static void
sidebar_branch_node_finalize (SidebarBranchNode * obj)
{
	SidebarBranchNode * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SIDEBAR_BRANCH_TYPE_NODE, SidebarBranchNode);
	g_signal_handlers_destroy (self);
	_g_object_unref0 (self->entry);
	_g_object_unref0 (self->children);
}

static GType
sidebar_branch_node_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { sidebar_branch_value_node_init, sidebar_branch_value_node_free_value, sidebar_branch_value_node_copy_value, sidebar_branch_value_node_peek_pointer, "p", sidebar_branch_value_node_collect_value, "p", sidebar_branch_value_node_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (SidebarBranchNodeClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) sidebar_branch_node_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SidebarBranchNode), 0, (GInstanceInitFunc) sidebar_branch_node_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 sidebar_branch_node_type_id;
	sidebar_branch_node_type_id = g_type_register_fundamental (g_type_fundamental_next (), "SidebarBranchNode", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return sidebar_branch_node_type_id;
}

static GType
sidebar_branch_node_get_type (void)
{
	static volatile gsize sidebar_branch_node_type_id__once = 0;
	if (g_once_init_enter (&sidebar_branch_node_type_id__once)) {
		GType sidebar_branch_node_type_id;
		sidebar_branch_node_type_id = sidebar_branch_node_get_type_once ();
		g_once_init_leave (&sidebar_branch_node_type_id__once, sidebar_branch_node_type_id);
	}
	return sidebar_branch_node_type_id__once;
}

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

static void
sidebar_branch_node_unref (gpointer instance)
{
	SidebarBranchNode * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		SIDEBAR_BRANCH_NODE_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static void
sidebar_branch_class_init (SidebarBranchClass * klass,
                           gpointer klass_data)
{
	sidebar_branch_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &SidebarBranch_private_offset);
	G_OBJECT_CLASS (klass)->finalize = sidebar_branch_finalize;
	sidebar_branch_signals[SIDEBAR_BRANCH_ENTRY_ADDED_SIGNAL] = g_signal_new ("entry-added", SIDEBAR_TYPE_BRANCH, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, SIDEBAR_TYPE_ENTRY);
	sidebar_branch_signals[SIDEBAR_BRANCH_ENTRY_REMOVED_SIGNAL] = g_signal_new ("entry-removed", SIDEBAR_TYPE_BRANCH, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, SIDEBAR_TYPE_ENTRY);
	sidebar_branch_signals[SIDEBAR_BRANCH_ENTRY_MOVED_SIGNAL] = g_signal_new ("entry-moved", SIDEBAR_TYPE_BRANCH, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, SIDEBAR_TYPE_ENTRY);
	sidebar_branch_signals[SIDEBAR_BRANCH_ENTRY_REPARENTED_SIGNAL] = g_signal_new ("entry-reparented", SIDEBAR_TYPE_BRANCH, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_OBJECT, G_TYPE_NONE, 2, SIDEBAR_TYPE_ENTRY, SIDEBAR_TYPE_ENTRY);
	sidebar_branch_signals[SIDEBAR_BRANCH_CHILDREN_REORDERED_SIGNAL] = g_signal_new ("children-reordered", SIDEBAR_TYPE_BRANCH, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, SIDEBAR_TYPE_ENTRY);
	sidebar_branch_signals[SIDEBAR_BRANCH_SHOW_BRANCH_SIGNAL] = g_signal_new ("show-branch", SIDEBAR_TYPE_BRANCH, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
}

static void
sidebar_branch_instance_init (SidebarBranch * self,
                              gpointer klass)
{
	GeeHashMap* _tmp0_;
	self->priv = sidebar_branch_get_instance_private (self);
	self->priv->shown = TRUE;
	_tmp0_ = gee_hash_map_new (SIDEBAR_TYPE_ENTRY, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, SIDEBAR_BRANCH_TYPE_NODE, (GBoxedCopyFunc) sidebar_branch_node_ref, (GDestroyNotify) sidebar_branch_node_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	self->priv->map = _tmp0_;
}

static void
sidebar_branch_finalize (GObject * obj)
{
	SidebarBranch * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SIDEBAR_TYPE_BRANCH, SidebarBranch);
	_sidebar_branch_node_unref0 (self->priv->root);
	_g_object_unref0 (self->priv->map);
	G_OBJECT_CLASS (sidebar_branch_parent_class)->finalize (obj);
}

static GType
sidebar_branch_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SidebarBranchClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) sidebar_branch_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SidebarBranch), 0, (GInstanceInitFunc) sidebar_branch_instance_init, NULL };
	GType sidebar_branch_type_id;
	sidebar_branch_type_id = g_type_register_static (GEARY_TYPE_BASE_OBJECT, "SidebarBranch", &g_define_type_info, 0);
	SidebarBranch_private_offset = g_type_add_instance_private (sidebar_branch_type_id, sizeof (SidebarBranchPrivate));
	return sidebar_branch_type_id;
}

GType
sidebar_branch_get_type (void)
{
	static volatile gsize sidebar_branch_type_id__once = 0;
	if (g_once_init_enter (&sidebar_branch_type_id__once)) {
		GType sidebar_branch_type_id;
		sidebar_branch_type_id = sidebar_branch_get_type_once ();
		g_once_init_leave (&sidebar_branch_type_id__once, sidebar_branch_type_id);
	}
	return sidebar_branch_type_id__once;
}

