/* gitg-commit-sidebar.c generated by valac 0.56.19, the Vala compiler
 * generated from gitg-commit-sidebar.vala, do not modify */

/*
 * This file is part of gitg
 *
 * Copyright (C) 2014 - Jesse van den Kieboom
 *
 * gitg 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.
 *
 * gitg 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 gitg. If not, see <http://www.gnu.org/licenses/>.
 */

#include "libgitg.h"
#include <glib-object.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gdk/gdk.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 GITG_COMMIT_TYPE_SIDEBAR (gitg_commit_sidebar_get_type ())
#define GITG_COMMIT_SIDEBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GITG_COMMIT_TYPE_SIDEBAR, GitgCommitSidebar))
#define GITG_COMMIT_SIDEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GITG_COMMIT_TYPE_SIDEBAR, GitgCommitSidebarClass))
#define GITG_COMMIT_IS_SIDEBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GITG_COMMIT_TYPE_SIDEBAR))
#define GITG_COMMIT_IS_SIDEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GITG_COMMIT_TYPE_SIDEBAR))
#define GITG_COMMIT_SIDEBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GITG_COMMIT_TYPE_SIDEBAR, GitgCommitSidebarClass))

typedef struct _GitgCommitSidebar GitgCommitSidebar;
typedef struct _GitgCommitSidebarClass GitgCommitSidebarClass;
typedef struct _GitgCommitSidebarPrivate GitgCommitSidebarPrivate;
enum  {
	GITG_COMMIT_SIDEBAR_0_PROPERTY,
	GITG_COMMIT_SIDEBAR_NUM_PROPERTIES
};
static GParamSpec* gitg_commit_sidebar_properties[GITG_COMMIT_SIDEBAR_NUM_PROPERTIES];
typedef enum  {
	GITG_COMMIT_SIDEBAR_ITEM_TYPE_NONE,
	GITG_COMMIT_SIDEBAR_ITEM_TYPE_STAGED,
	GITG_COMMIT_SIDEBAR_ITEM_TYPE_UNSTAGED,
	GITG_COMMIT_SIDEBAR_ITEM_TYPE_UNTRACKED,
	GITG_COMMIT_SIDEBAR_ITEM_TYPE_SUBMODULE
} GitgCommitSidebarItemType;

#define GITG_COMMIT_SIDEBAR_ITEM_TYPE_TYPE (gitg_commit_sidebar_item_type_get_type ())
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define GITG_COMMIT_SIDEBAR_TYPE_ITEM (gitg_commit_sidebar_item_get_type ())
#define GITG_COMMIT_SIDEBAR_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GITG_COMMIT_SIDEBAR_TYPE_ITEM, GitgCommitSidebarItem))
#define GITG_COMMIT_SIDEBAR_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GITG_COMMIT_SIDEBAR_TYPE_ITEM, GitgCommitSidebarItemClass))
#define GITG_COMMIT_SIDEBAR_IS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GITG_COMMIT_SIDEBAR_TYPE_ITEM))
#define GITG_COMMIT_SIDEBAR_IS_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GITG_COMMIT_SIDEBAR_TYPE_ITEM))
#define GITG_COMMIT_SIDEBAR_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GITG_COMMIT_SIDEBAR_TYPE_ITEM, GitgCommitSidebarItemClass))

typedef struct _GitgCommitSidebarItem GitgCommitSidebarItem;
typedef struct _GitgCommitSidebarItemClass GitgCommitSidebarItemClass;
typedef struct _Block16Data Block16Data;
typedef struct _GitgCommitSidebarItemPrivate GitgCommitSidebarItemPrivate;
enum  {
	GITG_COMMIT_SIDEBAR_ITEM_0_PROPERTY,
	GITG_COMMIT_SIDEBAR_ITEM_ITEM_PROPERTY,
	GITG_COMMIT_SIDEBAR_ITEM_TEXT_PROPERTY,
	GITG_COMMIT_SIDEBAR_ITEM_STAGE_TYPE_PROPERTY,
	GITG_COMMIT_SIDEBAR_ITEM_ICON_NAME_PROPERTY,
	GITG_COMMIT_SIDEBAR_ITEM_NUM_PROPERTIES
};
static GParamSpec* gitg_commit_sidebar_item_properties[GITG_COMMIT_SIDEBAR_ITEM_NUM_PROPERTIES];
enum  {
	GITG_COMMIT_SIDEBAR_STAGE_SELECTION_SIGNAL,
	GITG_COMMIT_SIDEBAR_UNSTAGE_SELECTION_SIGNAL,
	GITG_COMMIT_SIDEBAR_DISCARD_SELECTION_SIGNAL,
	GITG_COMMIT_SIDEBAR_EDIT_SELECTION_SIGNAL,
	GITG_COMMIT_SIDEBAR_SELECTED_ITEMS_CHANGED_SIGNAL,
	GITG_COMMIT_SIDEBAR_NUM_SIGNALS
};
static guint gitg_commit_sidebar_signals[GITG_COMMIT_SIDEBAR_NUM_SIGNALS] = {0};

struct _GitgCommitSidebar {
	GitgSidebar parent_instance;
	GitgCommitSidebarPrivate * priv;
};

struct _GitgCommitSidebarClass {
	GitgSidebarClass parent_class;
};

struct _Block16Data {
	int _ref_count_;
	GitgCommitSidebar* self;
	GitgCommitSidebarItem** ret;
	gint ret_length1;
	gint _ret_size_;
	GitgCommitSidebarItemType type;
};

struct _GitgCommitSidebarItem {
	GObject parent_instance;
	GitgCommitSidebarItemPrivate * priv;
};

struct _GitgCommitSidebarItemClass {
	GObjectClass parent_class;
};

struct _GitgCommitSidebarItemPrivate {
	GitgStageStatusItem* d_item;
	GitgCommitSidebarItemType d_type;
};

static gpointer gitg_commit_sidebar_parent_class = NULL;
static gint GitgCommitSidebarItem_private_offset;
static gpointer gitg_commit_sidebar_item_parent_class = NULL;
static GitgSidebarItemIface * gitg_commit_sidebar_item_gitg_sidebar_item_parent_iface = NULL;

VALA_EXTERN GType gitg_commit_sidebar_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GitgCommitSidebar, g_object_unref)
VALA_EXTERN GType gitg_commit_sidebar_item_type_get_type (void) G_GNUC_CONST ;
static GitgCommitSidebarItemType gitg_commit_sidebar_get_item_type (GitgCommitSidebar* self,
                                                             GitgSidebarItem* item);
VALA_EXTERN GType gitg_commit_sidebar_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GitgCommitSidebarItem, g_object_unref)
VALA_EXTERN GitgCommitSidebarItemType gitg_commit_sidebar_item_get_stage_type (GitgCommitSidebarItem* self);
static GitgCommitSidebarItemType gitg_commit_sidebar_selected_type (GitgCommitSidebar* self);
static gboolean gitg_commit_sidebar_real_select_function (GitgSidebar* base,
                                                   GtkTreeSelection* sel,
                                                   GtkTreeModel* model,
                                                   GtkTreePath* path,
                                                   gboolean cursel);
static void gitg_commit_sidebar_real_selection_changed (GitgSidebar* base,
                                                 GtkTreeSelection* sel);
VALA_EXTERN GitgCommitSidebarItem** gitg_commit_sidebar_items_of_type (GitgCommitSidebar* self,
                                                           GitgCommitSidebarItemType type,
                                                           gint* result_length1);
static Block16Data* block16_data_ref (Block16Data* _data16_);
static void block16_data_unref (void * _userdata_);
static gboolean __lambda36_ (Block16Data* _data16_,
                      GtkTreeModel* m,
                      GtkTreePath* path,
                      GtkTreeIter* iter);
static void _vala_array_add6 (GitgCommitSidebarItem** * array,
                       gint* length,
                       gint* size,
                       GitgCommitSidebarItem* value);
static gboolean ___lambda36__gtk_tree_model_foreach_func (GtkTreeModel* model,
                                                   GtkTreePath* path,
                                                   GtkTreeIter* iter,
                                                   gpointer self);
static GitgCommitSidebarItem** _vala_array_dup2 (GitgCommitSidebarItem** self,
                                          gssize length);
VALA_EXTERN GitgCommitSidebar* gitg_commit_sidebar_new (void);
VALA_EXTERN GitgCommitSidebar* gitg_commit_sidebar_construct (GType object_type);
static void g_cclosure_user_marshal_VOID__POINTER_INT (GClosure * closure,
                                                GValue * return_value,
                                                guint n_param_values,
                                                const GValue * param_values,
                                                gpointer invocation_hint,
                                                gpointer marshal_data);
VALA_EXTERN GitgCommitSidebarItem* gitg_commit_sidebar_item_new (GitgStageStatusItem* item,
                                                     GitgCommitSidebarItemType type);
VALA_EXTERN GitgCommitSidebarItem* gitg_commit_sidebar_item_construct (GType object_type,
                                                           GitgStageStatusItem* item,
                                                           GitgCommitSidebarItemType type);
VALA_EXTERN GitgStageStatusItem* gitg_commit_sidebar_item_get_item (GitgCommitSidebarItem* self);
static void gitg_commit_sidebar_item_finalize (GObject * obj);
static GType gitg_commit_sidebar_item_get_type_once (void);
static void _vala_gitg_commit_sidebar_item_get_property (GObject * object,
                                                  guint property_id,
                                                  GValue * value,
                                                  GParamSpec * pspec);
static GObject * gitg_commit_sidebar_constructor (GType type,
                                           guint n_construct_properties,
                                           GObjectConstructParam * construct_properties);
static GType gitg_commit_sidebar_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

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

static GitgCommitSidebarItemType
gitg_commit_sidebar_get_item_type (GitgCommitSidebar* self,
                                   GitgSidebarItem* item)
{
	GitgSidebarStoreSidebarHeader* header = NULL;
	GitgSidebarStoreSidebarHeader* _tmp0_;
	GitgSidebarStoreSidebarHeader* _tmp1_;
	GitgCommitSidebarItem* sitem = NULL;
	GitgCommitSidebarItem* _tmp5_;
	GitgCommitSidebarItem* _tmp6_;
	GitgCommitSidebarItemType result;
	g_return_val_if_fail (self != NULL, 0);
	g_return_val_if_fail (item != NULL, 0);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (item, GITG_SIDEBAR_STORE_TYPE_SIDEBAR_HEADER) ? ((GitgSidebarStoreSidebarHeader*) item) : NULL);
	header = _tmp0_;
	_tmp1_ = header;
	if (_tmp1_ != NULL) {
		GitgSidebarStoreSidebarHeader* _tmp2_;
		guint _tmp3_;
		guint _tmp4_;
		_tmp2_ = header;
		_tmp3_ = gitg_sidebar_store_sidebar_header_get_id (_tmp2_);
		_tmp4_ = _tmp3_;
		result = (GitgCommitSidebarItemType) _tmp4_;
		_g_object_unref0 (header);
		return result;
	}
	_tmp5_ = _g_object_ref0 (GITG_COMMIT_SIDEBAR_IS_ITEM (item) ? ((GitgCommitSidebarItem*) item) : NULL);
	sitem = _tmp5_;
	_tmp6_ = sitem;
	if (_tmp6_ != NULL) {
		GitgCommitSidebarItem* _tmp7_;
		GitgCommitSidebarItemType _tmp8_;
		GitgCommitSidebarItemType _tmp9_;
		_tmp7_ = sitem;
		_tmp8_ = gitg_commit_sidebar_item_get_stage_type (_tmp7_);
		_tmp9_ = _tmp8_;
		result = _tmp9_;
		_g_object_unref0 (sitem);
		_g_object_unref0 (header);
		return result;
	}
	result = GITG_COMMIT_SIDEBAR_ITEM_TYPE_NONE;
	_g_object_unref0 (sitem);
	_g_object_unref0 (header);
	return result;
}

static GitgCommitSidebarItemType
gitg_commit_sidebar_selected_type (GitgCommitSidebar* self)
{
	gint _tmp0_ = 0;
	gpointer* _tmp1_;
	GitgCommitSidebarItemType result;
	g_return_val_if_fail (self != NULL, 0);
	_tmp1_ = gitg_sidebar_get_selected_items ((GitgSidebar*) self, GITG_TYPE_SIDEBAR_ITEM, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, &_tmp0_);
	{
		GitgSidebarItem** item_collection = NULL;
		gint item_collection_length1 = 0;
		gint _item_collection_size_ = 0;
		gint item_it = 0;
		item_collection = _tmp1_;
		item_collection_length1 = _tmp0_;
		for (item_it = 0; item_it < item_collection_length1; item_it = item_it + 1) {
			GitgSidebarItem* _tmp2_;
			GitgSidebarItem* item = NULL;
			_tmp2_ = _g_object_ref0 (item_collection[item_it]);
			item = _tmp2_;
			{
				GitgCommitSidebarItemType tp = 0;
				GitgSidebarItem* _tmp3_;
				_tmp3_ = item;
				tp = gitg_commit_sidebar_get_item_type (self, _tmp3_);
				if (tp != GITG_COMMIT_SIDEBAR_ITEM_TYPE_NONE) {
					result = tp;
					_g_object_unref0 (item);
					item_collection = (_vala_array_free (item_collection, item_collection_length1, (GDestroyNotify) g_object_unref), NULL);
					return result;
				}
				_g_object_unref0 (item);
			}
		}
		item_collection = (_vala_array_free (item_collection, item_collection_length1, (GDestroyNotify) g_object_unref), NULL);
	}
	result = GITG_COMMIT_SIDEBAR_ITEM_TYPE_NONE;
	return result;
}

static gboolean
gitg_commit_sidebar_real_select_function (GitgSidebar* base,
                                          GtkTreeSelection* sel,
                                          GtkTreeModel* model,
                                          GtkTreePath* path,
                                          gboolean cursel)
{
	GitgCommitSidebar * self;
	GtkTreeIter iter = {0};
	GtkTreeIter _tmp0_ = {0};
	GitgSidebarHint hint = 0;
	GitgSidebarStore* m = NULL;
	GitgSidebarStore* _tmp1_;
	GitgSidebarStore* _tmp2_;
	GtkTreeIter _tmp3_;
	GitgSidebarHint _tmp4_ = 0;
	GitgSidebarItem* item = NULL;
	GitgSidebarStore* _tmp5_;
	GtkTreeIter _tmp6_;
	GitgSidebarItem* _tmp7_;
	GitgSidebarStoreSidebarHeader* header = NULL;
	GitgSidebarItem* _tmp8_;
	GitgSidebarStoreSidebarHeader* _tmp9_;
	GitgSidebarStoreSidebarHeader* _tmp10_;
	GitgCommitSidebarItemType seltp = 0;
	GitgCommitSidebarItemType tp = 0;
	GitgSidebarItem* _tmp15_;
	gboolean result;
	self = (GitgCommitSidebar*) base;
	g_return_val_if_fail (sel != NULL, FALSE);
	g_return_val_if_fail (model != NULL, FALSE);
	g_return_val_if_fail (path != NULL, FALSE);
	if (cursel) {
		result = TRUE;
		return result;
	}
	gtk_tree_model_get_iter (model, &_tmp0_, path);
	iter = _tmp0_;
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (model, GITG_TYPE_SIDEBAR_STORE) ? ((GitgSidebarStore*) model) : NULL);
	m = _tmp1_;
	_tmp2_ = m;
	_tmp3_ = iter;
	gtk_tree_model_get ((GtkTreeModel*) _tmp2_, &_tmp3_, GITG_SIDEBAR_COLUMN_HINT, &_tmp4_, -1);
	hint = _tmp4_;
	if (hint == GITG_SIDEBAR_HINT_DUMMY) {
		result = FALSE;
		_g_object_unref0 (m);
		return result;
	}
	_tmp5_ = m;
	_tmp6_ = iter;
	_tmp7_ = gitg_sidebar_store_item_for_iter (_tmp5_, &_tmp6_);
	item = _tmp7_;
	_tmp8_ = item;
	_tmp9_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp8_, GITG_SIDEBAR_STORE_TYPE_SIDEBAR_HEADER) ? ((GitgSidebarStoreSidebarHeader*) _tmp8_) : NULL);
	header = _tmp9_;
	_tmp10_ = header;
	if (_tmp10_ != NULL) {
		GitgCommitSidebarItemType id = 0;
		GitgSidebarStoreSidebarHeader* _tmp11_;
		guint _tmp12_;
		guint _tmp13_;
		gboolean _tmp14_ = FALSE;
		_tmp11_ = header;
		_tmp12_ = gitg_sidebar_store_sidebar_header_get_id (_tmp11_);
		_tmp13_ = _tmp12_;
		id = (GitgCommitSidebarItemType) _tmp13_;
		if (id == GITG_COMMIT_SIDEBAR_ITEM_TYPE_UNTRACKED) {
			_tmp14_ = TRUE;
		} else {
			_tmp14_ = id == GITG_COMMIT_SIDEBAR_ITEM_TYPE_SUBMODULE;
		}
		if (_tmp14_) {
			result = FALSE;
			_g_object_unref0 (header);
			_g_object_unref0 (item);
			_g_object_unref0 (m);
			return result;
		}
	}
	seltp = gitg_commit_sidebar_selected_type (self);
	if (seltp == GITG_COMMIT_SIDEBAR_ITEM_TYPE_NONE) {
		result = TRUE;
		_g_object_unref0 (header);
		_g_object_unref0 (item);
		_g_object_unref0 (m);
		return result;
	}
	if (seltp == GITG_COMMIT_SIDEBAR_ITEM_TYPE_SUBMODULE) {
		result = FALSE;
		_g_object_unref0 (header);
		_g_object_unref0 (item);
		_g_object_unref0 (m);
		return result;
	}
	_tmp15_ = item;
	tp = gitg_commit_sidebar_get_item_type (self, _tmp15_);
	result = tp == seltp;
	_g_object_unref0 (header);
	_g_object_unref0 (item);
	_g_object_unref0 (m);
	return result;
}

static void
gitg_commit_sidebar_real_selection_changed (GitgSidebar* base,
                                            GtkTreeSelection* sel)
{
	GitgCommitSidebar * self;
	GitgSidebarStore* _tmp0_;
	GitgSidebarStore* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	GitgSidebarItem** items = NULL;
	gint _tmp4_ = 0;
	gpointer* _tmp5_;
	gint items_length1;
	gint _items_size_;
	GitgSidebarItem** _tmp6_;
	gint _tmp6__length1;
	self = (GitgCommitSidebar*) base;
	g_return_if_fail (sel != NULL);
	_tmp0_ = gitg_sidebar_get_model ((GitgSidebar*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = gitg_sidebar_store_get_clearing (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_) {
		return;
	}
	_tmp5_ = gitg_sidebar_get_selected_items ((GitgSidebar*) self, GITG_TYPE_SIDEBAR_ITEM, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, &_tmp4_);
	items = _tmp5_;
	items_length1 = _tmp4_;
	_items_size_ = items_length1;
	_tmp6_ = items;
	_tmp6__length1 = items_length1;
	if (_tmp6__length1 == 0) {
		g_signal_emit_by_name ((GitgSidebar*) self, "deselected");
	} else {
		GitgSidebarItem** _tmp7_;
		gint _tmp7__length1;
		_tmp7_ = items;
		_tmp7__length1 = items_length1;
		g_signal_emit (self, gitg_commit_sidebar_signals[GITG_COMMIT_SIDEBAR_SELECTED_ITEMS_CHANGED_SIGNAL], 0, _tmp7_, (gint) _tmp7__length1);
	}
	items = (_vala_array_free (items, items_length1, (GDestroyNotify) g_object_unref), NULL);
}

static Block16Data*
block16_data_ref (Block16Data* _data16_)
{
	g_atomic_int_inc (&_data16_->_ref_count_);
	return _data16_;
}

static void
block16_data_unref (void * _userdata_)
{
	Block16Data* _data16_;
	_data16_ = (Block16Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data16_->_ref_count_)) {
		GitgCommitSidebar* self;
		self = _data16_->self;
		_data16_->ret = (_vala_array_free (_data16_->ret, _data16_->ret_length1, (GDestroyNotify) g_object_unref), NULL);
		_g_object_unref0 (self);
		g_slice_free (Block16Data, _data16_);
	}
}

static void
_vala_array_add6 (GitgCommitSidebarItem** * array,
                  gint* length,
                  gint* size,
                  GitgCommitSidebarItem* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (GitgCommitSidebarItem*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static gboolean
__lambda36_ (Block16Data* _data16_,
             GtkTreeModel* m,
             GtkTreePath* path,
             GtkTreeIter* iter)
{
	GitgCommitSidebar* self;
	GitgSidebarItem* item = NULL;
	GitgSidebarStore* _tmp0_;
	GitgSidebarStore* _tmp1_;
	GtkTreeIter _tmp2_;
	GitgSidebarItem* _tmp3_;
	GitgSidebarItem* _tmp4_;
	GitgCommitSidebarItem* sitem = NULL;
	GitgSidebarItem* _tmp5_;
	GitgCommitSidebarItem* _tmp6_;
	gboolean _tmp7_ = FALSE;
	GitgCommitSidebarItem* _tmp8_;
	gboolean result;
	self = _data16_->self;
	g_return_val_if_fail (m != NULL, FALSE);
	g_return_val_if_fail (path != NULL, FALSE);
	g_return_val_if_fail (iter != NULL, FALSE);
	_tmp0_ = gitg_sidebar_get_model ((GitgSidebar*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = *iter;
	_tmp3_ = gitg_sidebar_store_item_for_iter (_tmp1_, &_tmp2_);
	item = _tmp3_;
	_tmp4_ = item;
	if (_tmp4_ == NULL) {
		result = FALSE;
		_g_object_unref0 (item);
		return result;
	}
	_tmp5_ = item;
	_tmp6_ = _g_object_ref0 (GITG_COMMIT_SIDEBAR_IS_ITEM (_tmp5_) ? ((GitgCommitSidebarItem*) _tmp5_) : NULL);
	sitem = _tmp6_;
	_tmp8_ = sitem;
	if (_tmp8_ != NULL) {
		GitgCommitSidebarItem* _tmp9_;
		GitgCommitSidebarItemType _tmp10_;
		GitgCommitSidebarItemType _tmp11_;
		_tmp9_ = sitem;
		_tmp10_ = gitg_commit_sidebar_item_get_stage_type (_tmp9_);
		_tmp11_ = _tmp10_;
		_tmp7_ = _tmp11_ == _data16_->type;
	} else {
		_tmp7_ = FALSE;
	}
	if (_tmp7_) {
		GitgCommitSidebarItem* _tmp12_;
		GitgCommitSidebarItem* _tmp13_;
		_tmp12_ = sitem;
		_tmp13_ = _g_object_ref0 (_tmp12_);
		_vala_array_add6 (&_data16_->ret, &_data16_->ret_length1, &_data16_->_ret_size_, _tmp13_);
	}
	result = FALSE;
	_g_object_unref0 (sitem);
	_g_object_unref0 (item);
	return result;
}

static gboolean
___lambda36__gtk_tree_model_foreach_func (GtkTreeModel* model,
                                          GtkTreePath* path,
                                          GtkTreeIter* iter,
                                          gpointer self)
{
	gboolean result;
	result = __lambda36_ (self, model, path, iter);
	return result;
}

static GitgCommitSidebarItem**
_vala_array_dup2 (GitgCommitSidebarItem** self,
                  gssize length)
{
	if (length >= 0) {
		GitgCommitSidebarItem** result;
		gssize i;
		result = g_new0 (GitgCommitSidebarItem*, length + 1);
		for (i = 0; i < length; i++) {
			GitgCommitSidebarItem* _tmp0_;
			_tmp0_ = _g_object_ref0 (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

GitgCommitSidebarItem**
gitg_commit_sidebar_items_of_type (GitgCommitSidebar* self,
                                   GitgCommitSidebarItemType type,
                                   gint* result_length1)
{
	Block16Data* _data16_;
	GitgCommitSidebarItem** _tmp0_;
	GitgSidebarStore* _tmp1_;
	GitgSidebarStore* _tmp2_;
	GitgCommitSidebarItem** _tmp3_;
	gint _tmp3__length1;
	GitgCommitSidebarItem** _tmp4_;
	gint _tmp4__length1;
	GitgCommitSidebarItem** result;
	g_return_val_if_fail (self != NULL, NULL);
	_data16_ = g_slice_new0 (Block16Data);
	_data16_->_ref_count_ = 1;
	_data16_->self = g_object_ref (self);
	_data16_->type = type;
	_tmp0_ = g_new0 (GitgCommitSidebarItem*, 0 + 1);
	_data16_->ret = _tmp0_;
	_data16_->ret_length1 = 0;
	_data16_->_ret_size_ = _data16_->ret_length1;
	_tmp1_ = gitg_sidebar_get_model ((GitgSidebar*) self);
	_tmp2_ = _tmp1_;
	gtk_tree_model_foreach ((GtkTreeModel*) _tmp2_, ___lambda36__gtk_tree_model_foreach_func, _data16_);
	_tmp3_ = (_data16_->ret != NULL) ? _vala_array_dup2 (_data16_->ret, _data16_->ret_length1) : _data16_->ret;
	_tmp3__length1 = _data16_->ret_length1;
	_tmp4_ = _tmp3_;
	_tmp4__length1 = _tmp3__length1;
	if (result_length1) {
		*result_length1 = _tmp4__length1;
	}
	result = _tmp4_;
	block16_data_unref (_data16_);
	_data16_ = NULL;
	return result;
}

GitgCommitSidebar*
gitg_commit_sidebar_construct (GType object_type)
{
	GitgCommitSidebar * self = NULL;
	self = (GitgCommitSidebar*) gitg_sidebar_construct (object_type);
	return self;
}

GitgCommitSidebar*
gitg_commit_sidebar_new (void)
{
	return gitg_commit_sidebar_construct (GITG_COMMIT_TYPE_SIDEBAR);
}

static void
g_cclosure_user_marshal_VOID__POINTER_INT (GClosure * closure,
                                           GValue * return_value,
                                           guint n_param_values,
                                           const GValue * param_values,
                                           gpointer invocation_hint,
                                           gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__POINTER_INT) (gpointer data1, gpointer arg_1, gint arg_2, gpointer data2);
	register GMarshalFunc_VOID__POINTER_INT 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__POINTER_INT) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_pointer (param_values + 1), g_value_get_int (param_values + 2), data2);
}

static inline gpointer
gitg_commit_sidebar_item_get_instance_private (GitgCommitSidebarItem* self)
{
	return G_STRUCT_MEMBER_P (self, GitgCommitSidebarItem_private_offset);
}

 G_GNUC_NO_INLINE static GType
gitg_commit_sidebar_item_type_get_type_once (void)
{
	static const GEnumValue values[] = {{GITG_COMMIT_SIDEBAR_ITEM_TYPE_NONE, "GITG_COMMIT_SIDEBAR_ITEM_TYPE_NONE", "none"}, {GITG_COMMIT_SIDEBAR_ITEM_TYPE_STAGED, "GITG_COMMIT_SIDEBAR_ITEM_TYPE_STAGED", "staged"}, {GITG_COMMIT_SIDEBAR_ITEM_TYPE_UNSTAGED, "GITG_COMMIT_SIDEBAR_ITEM_TYPE_UNSTAGED", "unstaged"}, {GITG_COMMIT_SIDEBAR_ITEM_TYPE_UNTRACKED, "GITG_COMMIT_SIDEBAR_ITEM_TYPE_UNTRACKED", "untracked"}, {GITG_COMMIT_SIDEBAR_ITEM_TYPE_SUBMODULE, "GITG_COMMIT_SIDEBAR_ITEM_TYPE_SUBMODULE", "submodule"}, {0, NULL, NULL}};
	GType gitg_commit_sidebar_item_type_type_id;
	gitg_commit_sidebar_item_type_type_id = g_enum_register_static ("GitgCommitSidebarItemType", values);
	return gitg_commit_sidebar_item_type_type_id;
}

GType
gitg_commit_sidebar_item_type_get_type (void)
{
	static gsize gitg_commit_sidebar_item_type_type_id__once = 0;
	if (g_once_init_enter (&gitg_commit_sidebar_item_type_type_id__once)) {
		GType gitg_commit_sidebar_item_type_type_id;
		gitg_commit_sidebar_item_type_type_id = gitg_commit_sidebar_item_type_get_type_once ();
		g_once_init_leave (&gitg_commit_sidebar_item_type_type_id__once, gitg_commit_sidebar_item_type_type_id);
	}
	return gitg_commit_sidebar_item_type_type_id__once;
}

GitgCommitSidebarItem*
gitg_commit_sidebar_item_construct (GType object_type,
                                    GitgStageStatusItem* item,
                                    GitgCommitSidebarItemType type)
{
	GitgCommitSidebarItem * self = NULL;
	GitgStageStatusItem* _tmp0_;
	g_return_val_if_fail (item != NULL, NULL);
	self = (GitgCommitSidebarItem*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (item);
	_g_object_unref0 (self->priv->d_item);
	self->priv->d_item = _tmp0_;
	self->priv->d_type = type;
	return self;
}

GitgCommitSidebarItem*
gitg_commit_sidebar_item_new (GitgStageStatusItem* item,
                              GitgCommitSidebarItemType type)
{
	return gitg_commit_sidebar_item_construct (GITG_COMMIT_SIDEBAR_TYPE_ITEM, item, type);
}

GitgStageStatusItem*
gitg_commit_sidebar_item_get_item (GitgCommitSidebarItem* self)
{
	GitgStageStatusItem* result;
	GitgStageStatusItem* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->d_item;
	result = _tmp0_;
	return result;
}

static gchar*
gitg_commit_sidebar_item_real_get_text (GitgSidebarItem* base)
{
	gchar* result;
	GitgCommitSidebarItem* self;
	GitgStageStatusItem* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	self = (GitgCommitSidebarItem*) base;
	_tmp0_ = self->priv->d_item;
	_tmp1_ = gitg_stage_status_item_get_path (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

GitgCommitSidebarItemType
gitg_commit_sidebar_item_get_stage_type (GitgCommitSidebarItem* self)
{
	GitgCommitSidebarItemType result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->d_type;
	return result;
}

static gchar*
gitg_commit_sidebar_item_real_get_icon_name (GitgSidebarItem* base)
{
	gchar* result;
	GitgCommitSidebarItem* self;
	GitgStageStatusItem* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	self = (GitgCommitSidebarItem*) base;
	_tmp0_ = self->priv->d_item;
	_tmp1_ = gitg_stage_status_item_get_icon_name (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

static void
gitg_commit_sidebar_item_class_init (GitgCommitSidebarItemClass * klass,
                                     gpointer klass_data)
{
	gitg_commit_sidebar_item_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GitgCommitSidebarItem_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_gitg_commit_sidebar_item_get_property;
	G_OBJECT_CLASS (klass)->finalize = gitg_commit_sidebar_item_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GITG_COMMIT_SIDEBAR_ITEM_ITEM_PROPERTY, gitg_commit_sidebar_item_properties[GITG_COMMIT_SIDEBAR_ITEM_ITEM_PROPERTY] = g_param_spec_object ("item", "item", "item", GITG_TYPE_STAGE_STATUS_ITEM, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GITG_COMMIT_SIDEBAR_ITEM_TEXT_PROPERTY, gitg_commit_sidebar_item_properties[GITG_COMMIT_SIDEBAR_ITEM_TEXT_PROPERTY] = g_param_spec_string ("text", "text", "text", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GITG_COMMIT_SIDEBAR_ITEM_STAGE_TYPE_PROPERTY, gitg_commit_sidebar_item_properties[GITG_COMMIT_SIDEBAR_ITEM_STAGE_TYPE_PROPERTY] = g_param_spec_enum ("stage-type", "stage-type", "stage-type", GITG_COMMIT_SIDEBAR_ITEM_TYPE_TYPE, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GITG_COMMIT_SIDEBAR_ITEM_ICON_NAME_PROPERTY, gitg_commit_sidebar_item_properties[GITG_COMMIT_SIDEBAR_ITEM_ICON_NAME_PROPERTY] = g_param_spec_string ("icon-name", "icon-name", "icon-name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
gitg_commit_sidebar_item_gitg_sidebar_item_interface_init (GitgSidebarItemIface * iface,
                                                           gpointer iface_data)
{
	gitg_commit_sidebar_item_gitg_sidebar_item_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_text = gitg_commit_sidebar_item_real_get_text;
	iface->get_icon_name = gitg_commit_sidebar_item_real_get_icon_name;
}

static void
gitg_commit_sidebar_item_instance_init (GitgCommitSidebarItem * self,
                                        gpointer klass)
{
	self->priv = gitg_commit_sidebar_item_get_instance_private (self);
}

static void
gitg_commit_sidebar_item_finalize (GObject * obj)
{
	GitgCommitSidebarItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GITG_COMMIT_SIDEBAR_TYPE_ITEM, GitgCommitSidebarItem);
	_g_object_unref0 (self->priv->d_item);
	G_OBJECT_CLASS (gitg_commit_sidebar_item_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
gitg_commit_sidebar_item_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GitgCommitSidebarItemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gitg_commit_sidebar_item_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GitgCommitSidebarItem), 0, (GInstanceInitFunc) gitg_commit_sidebar_item_instance_init, NULL };
	static const GInterfaceInfo gitg_sidebar_item_info = { (GInterfaceInitFunc) gitg_commit_sidebar_item_gitg_sidebar_item_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType gitg_commit_sidebar_item_type_id;
	gitg_commit_sidebar_item_type_id = g_type_register_static (G_TYPE_OBJECT, "GitgCommitSidebarItem", &g_define_type_info, 0);
	g_type_add_interface_static (gitg_commit_sidebar_item_type_id, GITG_TYPE_SIDEBAR_ITEM, &gitg_sidebar_item_info);
	GitgCommitSidebarItem_private_offset = g_type_add_instance_private (gitg_commit_sidebar_item_type_id, sizeof (GitgCommitSidebarItemPrivate));
	return gitg_commit_sidebar_item_type_id;
}

GType
gitg_commit_sidebar_item_get_type (void)
{
	static gsize gitg_commit_sidebar_item_type_id__once = 0;
	if (g_once_init_enter (&gitg_commit_sidebar_item_type_id__once)) {
		GType gitg_commit_sidebar_item_type_id;
		gitg_commit_sidebar_item_type_id = gitg_commit_sidebar_item_get_type_once ();
		g_once_init_leave (&gitg_commit_sidebar_item_type_id__once, gitg_commit_sidebar_item_type_id);
	}
	return gitg_commit_sidebar_item_type_id__once;
}

static void
_vala_gitg_commit_sidebar_item_get_property (GObject * object,
                                             guint property_id,
                                             GValue * value,
                                             GParamSpec * pspec)
{
	GitgCommitSidebarItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GITG_COMMIT_SIDEBAR_TYPE_ITEM, GitgCommitSidebarItem);
	switch (property_id) {
		case GITG_COMMIT_SIDEBAR_ITEM_ITEM_PROPERTY:
		g_value_set_object (value, gitg_commit_sidebar_item_get_item (self));
		break;
		case GITG_COMMIT_SIDEBAR_ITEM_TEXT_PROPERTY:
		g_value_take_string (value, gitg_sidebar_item_get_text ((GitgSidebarItem*) self));
		break;
		case GITG_COMMIT_SIDEBAR_ITEM_STAGE_TYPE_PROPERTY:
		g_value_set_enum (value, gitg_commit_sidebar_item_get_stage_type (self));
		break;
		case GITG_COMMIT_SIDEBAR_ITEM_ICON_NAME_PROPERTY:
		g_value_take_string (value, gitg_sidebar_item_get_icon_name ((GitgSidebarItem*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static GObject *
gitg_commit_sidebar_constructor (GType type,
                                 guint n_construct_properties,
                                 GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GitgCommitSidebar * self;
	GtkBindingSet* binding_set = NULL;
	GObjectClass* _tmp0_;
	GtkBindingSet* _tmp1_;
	GtkBindingSet* _tmp2_;
	GtkBindingSet* _tmp3_;
	GtkBindingSet* _tmp4_;
	GtkBindingSet* _tmp5_;
	GtkTreeSelection* sel = NULL;
	GtkTreeSelection* _tmp6_;
	GtkTreeSelection* _tmp7_;
	GtkTreeSelection* _tmp8_;
	parent_class = G_OBJECT_CLASS (gitg_commit_sidebar_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GITG_COMMIT_TYPE_SIDEBAR, GitgCommitSidebar);
	_tmp0_ = G_OBJECT_GET_CLASS ((GObject*) self);
	_tmp1_ = gtk_binding_set_by_class ((gpointer) _tmp0_);
	binding_set = _tmp1_;
	_tmp2_ = binding_set;
	gtk_binding_entry_add_signal (_tmp2_, GDK_KEY_s, GDK_CONTROL_MASK, "stage-selection", (guint) 0, NULL);
	_tmp3_ = binding_set;
	gtk_binding_entry_add_signal (_tmp3_, GDK_KEY_u, GDK_CONTROL_MASK, "unstage-selection", (guint) 0, NULL);
	_tmp4_ = binding_set;
	gtk_binding_entry_add_signal (_tmp4_, GDK_KEY_d, GDK_CONTROL_MASK, "discard-selection", (guint) 0, NULL);
	_tmp5_ = binding_set;
	gtk_binding_entry_add_signal (_tmp5_, GDK_KEY_e, GDK_CONTROL_MASK, "edit-selection", (guint) 0, NULL);
	_tmp6_ = gtk_tree_view_get_selection ((GtkTreeView*) self);
	_tmp7_ = _g_object_ref0 (_tmp6_);
	sel = _tmp7_;
	_tmp8_ = sel;
	gtk_tree_selection_set_mode (_tmp8_, GTK_SELECTION_MULTIPLE);
	_g_object_unref0 (sel);
	return obj;
}

static void
gitg_commit_sidebar_class_init (GitgCommitSidebarClass * klass,
                                gpointer klass_data)
{
	gitg_commit_sidebar_parent_class = g_type_class_peek_parent (klass);
	((GitgSidebarClass *) klass)->select_function = (gboolean (*) (GitgSidebar*, GtkTreeSelection*, GtkTreeModel*, GtkTreePath*, gboolean)) gitg_commit_sidebar_real_select_function;
	((GitgSidebarClass *) klass)->selection_changed = (void (*) (GitgSidebar*, GtkTreeSelection*)) gitg_commit_sidebar_real_selection_changed;
	G_OBJECT_CLASS (klass)->constructor = gitg_commit_sidebar_constructor;
	gitg_commit_sidebar_signals[GITG_COMMIT_SIDEBAR_STAGE_SELECTION_SIGNAL] = g_signal_new ("stage-selection", GITG_COMMIT_TYPE_SIDEBAR, G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	gitg_commit_sidebar_signals[GITG_COMMIT_SIDEBAR_UNSTAGE_SELECTION_SIGNAL] = g_signal_new ("unstage-selection", GITG_COMMIT_TYPE_SIDEBAR, G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	gitg_commit_sidebar_signals[GITG_COMMIT_SIDEBAR_DISCARD_SELECTION_SIGNAL] = g_signal_new ("discard-selection", GITG_COMMIT_TYPE_SIDEBAR, G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	gitg_commit_sidebar_signals[GITG_COMMIT_SIDEBAR_EDIT_SELECTION_SIGNAL] = g_signal_new ("edit-selection", GITG_COMMIT_TYPE_SIDEBAR, G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	gitg_commit_sidebar_signals[GITG_COMMIT_SIDEBAR_SELECTED_ITEMS_CHANGED_SIGNAL] = g_signal_new ("selected-items-changed", GITG_COMMIT_TYPE_SIDEBAR, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__POINTER_INT, G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_INT);
}

static void
gitg_commit_sidebar_instance_init (GitgCommitSidebar * self,
                                   gpointer klass)
{
}

 G_GNUC_NO_INLINE static GType
gitg_commit_sidebar_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GitgCommitSidebarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gitg_commit_sidebar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GitgCommitSidebar), 0, (GInstanceInitFunc) gitg_commit_sidebar_instance_init, NULL };
	GType gitg_commit_sidebar_type_id;
	gitg_commit_sidebar_type_id = g_type_register_static (GITG_TYPE_SIDEBAR, "GitgCommitSidebar", &g_define_type_info, 0);
	return gitg_commit_sidebar_type_id;
}

GType
gitg_commit_sidebar_get_type (void)
{
	static gsize gitg_commit_sidebar_type_id__once = 0;
	if (g_once_init_enter (&gitg_commit_sidebar_type_id__once)) {
		GType gitg_commit_sidebar_type_id;
		gitg_commit_sidebar_type_id = gitg_commit_sidebar_get_type_once ();
		g_once_init_leave (&gitg_commit_sidebar_type_id__once, gitg_commit_sidebar_type_id);
	}
	return gitg_commit_sidebar_type_id__once;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

