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

/*-
 * Copyright 2017-2020 elementary, Inc. (https://elementary.io)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Authored by: Corentin Noël <corentin@elementary.io>
 */

#include "codecore.h"
#include <gtk/gtk.h>
#include <handy.h>
#include <gio/gio.h>
#include <granite.h>
#include <gdk/gdk.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib-object.h>
#include <glib/gi18n-lib.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	CODE_SIDEBAR_0_PROPERTY,
	CODE_SIDEBAR_STACK_PROPERTY,
	CODE_SIDEBAR_CHOOSE_PROJECT_BUTTON_PROPERTY,
	CODE_SIDEBAR_HEADERBAR_PROPERTY,
	CODE_SIDEBAR_PROJECT_MENU_MODEL_PROPERTY,
	CODE_SIDEBAR_CLONING_IN_PROGRESS_PROPERTY,
	CODE_SIDEBAR_NUM_PROPERTIES
};
static GParamSpec* code_sidebar_properties[CODE_SIDEBAR_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block56Data Block56Data;

struct _CodeSidebarPrivate {
	GtkStack* _stack;
	CodeChooseProjectButton* _choose_project_button;
	HdyHeaderBar* _headerbar;
	GMenuModel* _project_menu_model;
	GtkStackSwitcher* stack_switcher;
	GraniteWidgetsToast* cloning_success_toast;
};

struct _Block56Data {
	int _ref_count_;
	CodeSidebar* self;
	CodePaneSwitcher* tab;
};

static gint CodeSidebar_private_offset;
static gpointer code_sidebar_parent_class = NULL;

static void code_sidebar_drag_received (CodeSidebar* self,
                                 GtkWidget* w,
                                 GdkDragContext* ctx,
                                 gint x,
                                 gint y,
                                 GtkSelectionData* sel,
                                 guint info,
                                 guint time);
static void _g_object_unref0_ (gpointer var);
static inline void _g_list_free__g_object_unref0_ (GList* self);
static Block56Data* block56_data_ref (Block56Data* _data56_);
static void block56_data_unref (void * _userdata_);
static void __lambda168_ (Block56Data* _data56_);
static void ___lambda168__g_object_notify (GObject* _sender,
                                    GParamSpec* pspec,
                                    gpointer self);
static void __lambda169_ (Block56Data* _data56_);
static void ___lambda169__g_object_notify (GObject* _sender,
                                    GParamSpec* pspec,
                                    gpointer self);
static void code_sidebar_set_stack (CodeSidebar* self,
                             GtkStack* value);
static void code_sidebar_set_choose_project_button (CodeSidebar* self,
                                             CodeChooseProjectButton* value);
static void code_sidebar_set_headerbar (CodeSidebar* self,
                                 HdyHeaderBar* value);
static GObject * code_sidebar_constructor (GType type,
                                    guint n_construct_properties,
                                    GObjectConstructParam * construct_properties);
static void _code_sidebar___lambda170_ (CodeSidebar* self);
static void __code_sidebar___lambda170__gtk_container_add (GtkContainer* _sender,
                                                    GtkWidget* widget,
                                                    gpointer self);
static void _code_sidebar___lambda171_ (CodeSidebar* self);
static void __code_sidebar___lambda171__gtk_container_remove (GtkContainer* _sender,
                                                       GtkWidget* widget,
                                                       gpointer self);
static void _code_sidebar_drag_received_gtk_widget_drag_data_received (GtkWidget* _sender,
                                                                GdkDragContext* context,
                                                                gint x,
                                                                gint y,
                                                                GtkSelectionData* selection_data,
                                                                guint info,
                                                                guint time_,
                                                                gpointer self);
static void code_sidebar_finalize (GObject * obj);
static GType code_sidebar_get_type_once (void);
static void _vala_code_sidebar_get_property (GObject * object,
                                      guint property_id,
                                      GValue * value,
                                      GParamSpec * pspec);
static void _vala_code_sidebar_set_property (GObject * object,
                                      guint property_id,
                                      const GValue * value,
                                      GParamSpec * pspec);
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 gssize _vala_array_length (gpointer array);

static inline gpointer
code_sidebar_get_instance_private (CodeSidebar* self)
{
	return G_STRUCT_MEMBER_P (self, CodeSidebar_private_offset);
}

 G_GNUC_NO_INLINE static GType
code_sidebar_target_type_get_type_once (void)
{
	static const GEnumValue values[] = {{CODE_SIDEBAR_TARGET_TYPE_URI_LIST, "CODE_SIDEBAR_TARGET_TYPE_URI_LIST", "uri-list"}, {0, NULL, NULL}};
	GType code_sidebar_target_type_type_id;
	code_sidebar_target_type_type_id = g_enum_register_static ("CodeSidebarTargetType", values);
	return code_sidebar_target_type_type_id;
}

GType
code_sidebar_target_type_get_type (void)
{
	static gsize code_sidebar_target_type_type_id__once = 0;
	if (g_once_init_enter (&code_sidebar_target_type_type_id__once)) {
		GType code_sidebar_target_type_type_id;
		code_sidebar_target_type_type_id = code_sidebar_target_type_get_type_once ();
		g_once_init_leave (&code_sidebar_target_type_type_id__once, code_sidebar_target_type_type_id);
	}
	return code_sidebar_target_type_type_id__once;
}

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

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

static inline void
_g_list_free__g_object_unref0_ (GList* self)
{
	g_list_free_full (self, (GDestroyNotify) _g_object_unref0_);
}

static void
code_sidebar_drag_received (CodeSidebar* self,
                            GtkWidget* w,
                            GdkDragContext* ctx,
                            gint x,
                            gint y,
                            GtkSelectionData* sel,
                            guint info,
                            guint time)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (w != NULL);
	g_return_if_fail (ctx != NULL);
	g_return_if_fail (sel != NULL);
	if (info == ((guint) CODE_SIDEBAR_TARGET_TYPE_URI_LIST)) {
		gchar** uri_list = NULL;
		gchar** _tmp0_;
		gchar** _tmp1_;
		gint uri_list_length1;
		gint _uri_list_size_;
		GList* folder_list = NULL;
		gchar** _tmp2_;
		gint _tmp2__length1;
		GList* _tmp8_;
		GList* _tmp18_;
		_tmp1_ = _tmp0_ = gtk_selection_data_get_uris (sel);
		uri_list = _tmp1_;
		uri_list_length1 = _vala_array_length (_tmp0_);
		_uri_list_size_ = uri_list_length1;
		folder_list = NULL;
		_tmp2_ = uri_list;
		_tmp2__length1 = uri_list_length1;
		{
			gchar** uri_collection = NULL;
			gint uri_collection_length1 = 0;
			gint _uri_collection_size_ = 0;
			gint uri_it = 0;
			uri_collection = _tmp2_;
			uri_collection_length1 = _tmp2__length1;
			for (uri_it = 0; uri_it < uri_collection_length1; uri_it = uri_it + 1) {
				const gchar* uri = NULL;
				uri = uri_collection[uri_it];
				{
					GFile* file = NULL;
					const gchar* _tmp3_;
					GFile* _tmp4_;
					GFileType ftype = 0;
					GFile* _tmp5_;
					_tmp3_ = uri;
					_tmp4_ = g_file_new_for_uri (_tmp3_);
					file = _tmp4_;
					_tmp5_ = file;
					ftype = g_file_query_file_type (_tmp5_, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL);
					if (ftype == G_FILE_TYPE_DIRECTORY) {
						GFile* _tmp6_;
						GFile* _tmp7_;
						_tmp6_ = file;
						_tmp7_ = _g_object_ref0 (_tmp6_);
						folder_list = g_list_prepend (folder_list, _tmp7_);
					}
					_g_object_unref0 (file);
				}
			}
		}
		_tmp8_ = folder_list;
		{
			GList* folder_collection = NULL;
			GList* folder_it = NULL;
			folder_collection = _tmp8_;
			for (folder_it = folder_collection; folder_it != NULL; folder_it = folder_it->next) {
				GFile* _tmp9_;
				GFile* folder = NULL;
				_tmp9_ = _g_object_ref0 ((GFile*) folder_it->data);
				folder = _tmp9_;
				{
					GActionGroup* win_group = NULL;
					GActionGroup* _tmp10_;
					GActionGroup* _tmp11_;
					GActionGroup* _tmp12_;
					GFile* _tmp13_;
					gchar* _tmp14_;
					gchar* _tmp15_;
					GVariant* _tmp16_;
					GVariant* _tmp17_;
					_tmp10_ = gtk_widget_get_action_group ((GtkWidget*) self, SCRATCH_MAIN_WINDOW_ACTION_GROUP);
					_tmp11_ = _g_object_ref0 (_tmp10_);
					win_group = _tmp11_;
					_tmp12_ = win_group;
					_tmp13_ = folder;
					_tmp14_ = g_file_get_path (_tmp13_);
					_tmp15_ = _tmp14_;
					_tmp16_ = g_variant_new_string (_tmp15_);
					g_variant_ref_sink (_tmp16_);
					_tmp17_ = _tmp16_;
					g_action_group_activate_action (_tmp12_, SCRATCH_MAIN_WINDOW_ACTION_OPEN_FOLDER, _tmp17_);
					_g_variant_unref0 (_tmp17_);
					_g_free0 (_tmp15_);
					_g_object_unref0 (win_group);
					_g_object_unref0 (folder);
				}
			}
		}
		_tmp18_ = folder_list;
		gtk_drag_finish (ctx, g_list_length (_tmp18_) > ((guint) 0), FALSE, (guint32) time);
		(folder_list == NULL) ? NULL : (folder_list = (_g_list_free__g_object_unref0_ (folder_list), NULL));
		uri_list = (_vala_array_free (uri_list, uri_list_length1, (GDestroyNotify) g_free), NULL);
	}
}

static Block56Data*
block56_data_ref (Block56Data* _data56_)
{
	g_atomic_int_inc (&_data56_->_ref_count_);
	return _data56_;
}

static void
block56_data_unref (void * _userdata_)
{
	Block56Data* _data56_;
	_data56_ = (Block56Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data56_->_ref_count_)) {
		CodeSidebar* self;
		self = _data56_->self;
		_g_object_unref0 (_data56_->tab);
		_g_object_unref0 (self);
		g_slice_free (Block56Data, _data56_);
	}
}

static void
__lambda168_ (Block56Data* _data56_)
{
	CodeSidebar* self;
	GtkStack* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	GValue _tmp3_ = {0};
	self = _data56_->self;
	_tmp0_ = self->priv->_stack;
	_tmp1_ = code_pane_switcher_get_title (_data56_->tab);
	_tmp2_ = _tmp1_;
	g_value_init (&_tmp3_, G_TYPE_STRING);
	g_value_set_string (&_tmp3_, _tmp2_);
	gtk_container_child_set_property ((GtkContainer*) _tmp0_, (GtkWidget*) _data56_->tab, "title", &_tmp3_);
	G_IS_VALUE (&_tmp3_) ? (g_value_unset (&_tmp3_), NULL) : NULL;
}

static void
___lambda168__g_object_notify (GObject* _sender,
                               GParamSpec* pspec,
                               gpointer self)
{
	__lambda168_ (self);
}

static void
__lambda169_ (Block56Data* _data56_)
{
	CodeSidebar* self;
	GtkStack* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	GValue _tmp3_ = {0};
	self = _data56_->self;
	_tmp0_ = self->priv->_stack;
	_tmp1_ = code_pane_switcher_get_icon_name (_data56_->tab);
	_tmp2_ = _tmp1_;
	g_value_init (&_tmp3_, G_TYPE_STRING);
	g_value_set_string (&_tmp3_, _tmp2_);
	gtk_container_child_set_property ((GtkContainer*) _tmp0_, (GtkWidget*) _data56_->tab, "icon-name", &_tmp3_);
	G_IS_VALUE (&_tmp3_) ? (g_value_unset (&_tmp3_), NULL) : NULL;
}

static void
___lambda169__g_object_notify (GObject* _sender,
                               GParamSpec* pspec,
                               gpointer self)
{
	__lambda169_ (self);
}

void
code_sidebar_add_tab (CodeSidebar* self,
                      CodePaneSwitcher* tab)
{
	Block56Data* _data56_;
	CodePaneSwitcher* _tmp0_;
	GtkStack* _tmp1_;
	GtkStack* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	GValue _tmp5_ = {0};
	GtkStack* _tmp6_;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	GValue _tmp9_ = {0};
	g_return_if_fail (self != NULL);
	g_return_if_fail (tab != NULL);
	_data56_ = g_slice_new0 (Block56Data);
	_data56_->_ref_count_ = 1;
	_data56_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (tab);
	_g_object_unref0 (_data56_->tab);
	_data56_->tab = _tmp0_;
	_tmp1_ = self->priv->_stack;
	gtk_container_add ((GtkContainer*) _tmp1_, (GtkWidget*) _data56_->tab);
	_tmp2_ = self->priv->_stack;
	_tmp3_ = code_pane_switcher_get_title (_data56_->tab);
	_tmp4_ = _tmp3_;
	g_value_init (&_tmp5_, G_TYPE_STRING);
	g_value_set_string (&_tmp5_, _tmp4_);
	gtk_container_child_set_property ((GtkContainer*) _tmp2_, (GtkWidget*) _data56_->tab, "title", &_tmp5_);
	G_IS_VALUE (&_tmp5_) ? (g_value_unset (&_tmp5_), NULL) : NULL;
	_tmp6_ = self->priv->_stack;
	_tmp7_ = code_pane_switcher_get_icon_name (_data56_->tab);
	_tmp8_ = _tmp7_;
	g_value_init (&_tmp9_, G_TYPE_STRING);
	g_value_set_string (&_tmp9_, _tmp8_);
	gtk_container_child_set_property ((GtkContainer*) _tmp6_, (GtkWidget*) _data56_->tab, "icon-name", &_tmp9_);
	G_IS_VALUE (&_tmp9_) ? (g_value_unset (&_tmp9_), NULL) : NULL;
	g_signal_connect_data ((GObject*) _data56_->tab, "notify::title", (GCallback) ___lambda168__g_object_notify, block56_data_ref (_data56_), (GClosureNotify) block56_data_unref, 0);
	g_signal_connect_data ((GObject*) _data56_->tab, "notify::icon-name", (GCallback) ___lambda169__g_object_notify, block56_data_ref (_data56_), (GClosureNotify) block56_data_unref, 0);
	block56_data_unref (_data56_);
	_data56_ = NULL;
}

void
code_sidebar_remove_tab (CodeSidebar* self,
                         CodePaneSwitcher* tab)
{
	GtkStack* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (tab != NULL);
	_tmp0_ = self->priv->_stack;
	gtk_container_remove ((GtkContainer*) _tmp0_, (GtkWidget*) tab);
}

void
code_sidebar_notify_cloning_success (CodeSidebar* self)
{
	GraniteWidgetsToast* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->cloning_success_toast;
	granite_widgets_toast_send_notification (_tmp0_);
}

void
code_sidebar_focus_sidebar (CodeSidebar* self)
{
	GtkStack* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_stack;
	_tmp1_ = gtk_stack_get_visible_child (_tmp0_);
	_tmp2_ = _tmp1_;
	if (CODE_WIDGETS_IS_SOURCE_LIST (_tmp2_)) {
		GtkStack* _tmp3_;
		GtkWidget* _tmp4_;
		GtkWidget* _tmp5_;
		_tmp3_ = self->priv->_stack;
		_tmp4_ = gtk_stack_get_visible_child (_tmp3_);
		_tmp5_ = _tmp4_;
		code_widgets_source_list_grab_focus (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, CODE_WIDGETS_TYPE_SOURCE_LIST, CodeWidgetsSourceList));
	}
}

CodeSidebar*
code_sidebar_construct (GType object_type)
{
	CodeSidebar * self = NULL;
	self = (CodeSidebar*) g_object_new (object_type, NULL);
	return self;
}

CodeSidebar*
code_sidebar_new (void)
{
	return code_sidebar_construct (CODE_TYPE_SIDEBAR);
}

GtkStack*
code_sidebar_get_stack (CodeSidebar* self)
{
	GtkStack* result;
	GtkStack* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_stack;
	result = _tmp0_;
	return result;
}

static void
code_sidebar_set_stack (CodeSidebar* self,
                        GtkStack* value)
{
	GtkStack* old_value;
	g_return_if_fail (self != NULL);
	old_value = code_sidebar_get_stack (self);
	if (old_value != value) {
		GtkStack* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_stack);
		self->priv->_stack = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, code_sidebar_properties[CODE_SIDEBAR_STACK_PROPERTY]);
	}
}

CodeChooseProjectButton*
code_sidebar_get_choose_project_button (CodeSidebar* self)
{
	CodeChooseProjectButton* result;
	CodeChooseProjectButton* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_choose_project_button;
	result = _tmp0_;
	return result;
}

static void
code_sidebar_set_choose_project_button (CodeSidebar* self,
                                        CodeChooseProjectButton* value)
{
	CodeChooseProjectButton* old_value;
	g_return_if_fail (self != NULL);
	old_value = code_sidebar_get_choose_project_button (self);
	if (old_value != value) {
		CodeChooseProjectButton* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_choose_project_button);
		self->priv->_choose_project_button = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, code_sidebar_properties[CODE_SIDEBAR_CHOOSE_PROJECT_BUTTON_PROPERTY]);
	}
}

HdyHeaderBar*
code_sidebar_get_headerbar (CodeSidebar* self)
{
	HdyHeaderBar* result;
	HdyHeaderBar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_headerbar;
	result = _tmp0_;
	return result;
}

static void
code_sidebar_set_headerbar (CodeSidebar* self,
                            HdyHeaderBar* value)
{
	HdyHeaderBar* old_value;
	g_return_if_fail (self != NULL);
	old_value = code_sidebar_get_headerbar (self);
	if (old_value != value) {
		HdyHeaderBar* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_headerbar);
		self->priv->_headerbar = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, code_sidebar_properties[CODE_SIDEBAR_HEADERBAR_PROPERTY]);
	}
}

GMenuModel*
code_sidebar_get_project_menu_model (CodeSidebar* self)
{
	GMenuModel* result;
	GMenuModel* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_project_menu_model;
	result = _tmp0_;
	return result;
}

static void
code_sidebar_set_project_menu_model (CodeSidebar* self,
                                     GMenuModel* value)
{
	GMenuModel* old_value;
	g_return_if_fail (self != NULL);
	old_value = code_sidebar_get_project_menu_model (self);
	if (old_value != value) {
		GMenuModel* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_project_menu_model);
		self->priv->_project_menu_model = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, code_sidebar_properties[CODE_SIDEBAR_PROJECT_MENU_MODEL_PROPERTY]);
	}
}

gboolean
code_sidebar_get_cloning_in_progress (CodeSidebar* self)
{
	gboolean result;
	CodeChooseProjectButton* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->_choose_project_button;
	_tmp1_ = code_choose_project_button_get_cloning_in_progress (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

void
code_sidebar_set_cloning_in_progress (CodeSidebar* self,
                                      gboolean value)
{
	CodeChooseProjectButton* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_choose_project_button;
	code_choose_project_button_set_cloning_in_progress (_tmp0_, value);
	g_object_notify_by_pspec ((GObject *) self, code_sidebar_properties[CODE_SIDEBAR_CLONING_IN_PROGRESS_PROPERTY]);
}

static void
_code_sidebar___lambda170_ (CodeSidebar* self)
{
	GtkStack* _tmp0_;
	GList* _tmp1_;
	GList* _tmp2_;
	gboolean _tmp3_;
	GtkStack* _tmp6_;
	GtkStack* _tmp7_;
	_tmp0_ = self->priv->_stack;
	_tmp1_ = gtk_container_get_children ((GtkContainer*) _tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_list_length (_tmp2_) > ((guint) 1);
	(_tmp2_ == NULL) ? NULL : (_tmp2_ = (g_list_free (_tmp2_), NULL));
	if (_tmp3_) {
		GtkStackSwitcher* _tmp4_;
		GtkStackSwitcher* _tmp5_;
		_tmp4_ = self->priv->stack_switcher;
		gtk_widget_set_no_show_all ((GtkWidget*) _tmp4_, FALSE);
		_tmp5_ = self->priv->stack_switcher;
		gtk_widget_show_all ((GtkWidget*) _tmp5_);
	}
	_tmp6_ = self->priv->_stack;
	gtk_widget_set_no_show_all ((GtkWidget*) _tmp6_, FALSE);
	_tmp7_ = self->priv->_stack;
	gtk_widget_show_all ((GtkWidget*) _tmp7_);
}

static void
__code_sidebar___lambda170__gtk_container_add (GtkContainer* _sender,
                                               GtkWidget* widget,
                                               gpointer self)
{
	_code_sidebar___lambda170_ ((CodeSidebar*) self);
}

static void
_code_sidebar___lambda171_ (CodeSidebar* self)
{
	GtkStack* _tmp0_;
	GList* _tmp1_;
	GList* _tmp2_;
	guint _tmp3_;
	_tmp0_ = self->priv->_stack;
	_tmp1_ = gtk_container_get_children ((GtkContainer*) _tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_list_length (_tmp2_);
	(_tmp2_ == NULL) ? NULL : (_tmp2_ = (g_list_free (_tmp2_), NULL));
	switch (_tmp3_) {
		case 0:
		{
			GtkStack* _tmp4_;
			GtkStack* _tmp5_;
			_tmp4_ = self->priv->_stack;
			gtk_widget_set_no_show_all ((GtkWidget*) _tmp4_, TRUE);
			_tmp5_ = self->priv->_stack;
			gtk_widget_hide ((GtkWidget*) _tmp5_);
			break;
		}
		case 1:
		{
			GtkStackSwitcher* _tmp6_;
			GtkStackSwitcher* _tmp7_;
			_tmp6_ = self->priv->stack_switcher;
			gtk_widget_set_no_show_all ((GtkWidget*) _tmp6_, TRUE);
			_tmp7_ = self->priv->stack_switcher;
			gtk_widget_hide ((GtkWidget*) _tmp7_);
			break;
		}
		default:
		break;
	}
}

static void
__code_sidebar___lambda171__gtk_container_remove (GtkContainer* _sender,
                                                  GtkWidget* widget,
                                                  gpointer self)
{
	_code_sidebar___lambda171_ ((CodeSidebar*) self);
}

static void
_code_sidebar_drag_received_gtk_widget_drag_data_received (GtkWidget* _sender,
                                                           GdkDragContext* context,
                                                           gint x,
                                                           gint y,
                                                           GtkSelectionData* selection_data,
                                                           guint info,
                                                           guint time_,
                                                           gpointer self)
{
	code_sidebar_drag_received ((CodeSidebar*) self, _sender, context, x, y, selection_data, info, time_);
}

static GObject *
code_sidebar_constructor (GType type,
                          guint n_construct_properties,
                          GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	CodeSidebar * self;
	GtkStyleContext* _tmp0_;
	CodeChooseProjectButton* _tmp1_ = NULL;
	CodeChooseProjectButton* _tmp2_;
	GraniteWidgetsToast* _tmp3_ = NULL;
	CodeChooseProjectButton* _tmp4_;
	GtkWidget* _tmp5_;
	HdyHeaderBar* _tmp6_ = NULL;
	HdyHeaderBar* _tmp7_;
	HdyHeaderBar* _tmp8_;
	GtkStyleContext* _tmp9_;
	GtkStack* _tmp10_;
	GtkStack* _tmp11_;
	GtkStack* _tmp12_;
	GtkOverlay* overlay = NULL;
	GtkStack* _tmp13_;
	GtkWidget* _tmp14_;
	GtkOverlay* _tmp15_ = NULL;
	GtkOverlay* _tmp16_;
	GraniteWidgetsToast* _tmp17_;
	GtkStackSwitcher* _tmp18_;
	GtkStackSwitcher* _tmp19_;
	GtkStackSwitcher* _tmp20_;
	GtkStackSwitcher* _tmp21_;
	GtkStack* _tmp22_;
	GtkStackSwitcher* _tmp23_;
	GtkActionBar* actionbar = NULL;
	GtkActionBar* _tmp24_;
	GtkActionBar* _tmp25_;
	GtkStyleContext* _tmp26_;
	GMenuItem* collapse_all_menu_item = NULL;
	GMenuItem* _tmp27_;
	GSimpleActionGroup* action_group = NULL;
	GSimpleActionGroup* _tmp28_;
	GAction* sort_action = NULL;
	GSettings* _tmp29_;
	GAction* _tmp30_;
	GSimpleActionGroup* _tmp31_;
	GAction* _tmp32_;
	GSimpleActionGroup* _tmp33_;
	GMenuItem* order_projects_menu_item = NULL;
	GAction* _tmp34_;
	const gchar* _tmp35_;
	const gchar* _tmp36_;
	gchar* _tmp37_;
	gchar* _tmp38_;
	GMenuItem* _tmp39_;
	GMenuItem* _tmp40_;
	GMenu* project_menu = NULL;
	GMenu* _tmp41_;
	GMenu* _tmp42_;
	GMenuItem* _tmp43_;
	GMenu* _tmp44_;
	GMenuItem* _tmp45_;
	GMenu* _tmp46_;
	GtkLabel* label = NULL;
	GtkLabel* _tmp47_ = NULL;
	GtkMenuButton* project_menu_button = NULL;
	GMenuModel* _tmp48_;
	GMenuModel* _tmp49_;
	GtkLabel* _tmp50_;
	GtkWidget* _tmp51_;
	GtkMenuButton* _tmp52_ = NULL;
	GtkActionBar* _tmp53_;
	GtkMenuButton* _tmp54_;
	HdyHeaderBar* _tmp55_;
	GtkStackSwitcher* _tmp56_;
	GtkOverlay* _tmp57_;
	GtkActionBar* _tmp58_;
	GtkStack* _tmp59_;
	GtkStack* _tmp60_;
	GtkTargetEntry uris = {0};
	GtkTargetEntry _tmp61_ = {0};
	GtkTargetEntry _tmp62_;
	GtkTargetEntry* _tmp63_;
	GtkTargetEntry* _tmp64_;
	gint _tmp64__length1;
	parent_class = G_OBJECT_CLASS (code_sidebar_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CODE_TYPE_SIDEBAR, CodeSidebar);
	gtk_orientable_set_orientation ((GtkOrientable*) self, GTK_ORIENTATION_VERTICAL);
	_tmp0_ = gtk_widget_get_style_context ((GtkWidget*) self);
	gtk_style_context_add_class (_tmp0_, GTK_STYLE_CLASS_SIDEBAR);
	_tmp1_ = code_choose_project_button_new ();
	gtk_widget_set_hexpand ((GtkWidget*) _tmp1_, TRUE);
	gtk_widget_set_valign ((GtkWidget*) _tmp1_, GTK_ALIGN_CENTER);
	g_object_ref_sink (_tmp1_);
	_tmp2_ = _tmp1_;
	code_sidebar_set_choose_project_button (self, _tmp2_);
	_g_object_unref0 (_tmp2_);
	_tmp3_ = granite_widgets_toast_new (_ ("Cloning complete"));
	gtk_widget_set_halign ((GtkWidget*) _tmp3_, GTK_ALIGN_CENTER);
	gtk_widget_set_valign ((GtkWidget*) _tmp3_, GTK_ALIGN_START);
	g_object_ref_sink (_tmp3_);
	_g_object_unref0 (self->priv->cloning_success_toast);
	self->priv->cloning_success_toast = _tmp3_;
	_tmp4_ = self->priv->_choose_project_button;
	_tmp5_ = _g_object_ref0 ((GtkWidget*) _tmp4_);
	_tmp6_ = (HdyHeaderBar*) hdy_header_bar_new ();
	hdy_header_bar_set_custom_title (_tmp6_, _tmp5_);
	_g_object_unref0 (_tmp5_);
	hdy_header_bar_set_show_close_button (_tmp6_, TRUE);
	g_object_ref_sink (_tmp6_);
	_tmp7_ = _tmp6_;
	code_sidebar_set_headerbar (self, _tmp7_);
	_g_object_unref0 (_tmp7_);
	_tmp8_ = self->priv->_headerbar;
	_tmp9_ = gtk_widget_get_style_context ((GtkWidget*) _tmp8_);
	gtk_style_context_add_class (_tmp9_, GTK_STYLE_CLASS_FLAT);
	_tmp10_ = (GtkStack*) gtk_stack_new ();
	g_object_ref_sink (_tmp10_);
	_tmp11_ = _tmp10_;
	code_sidebar_set_stack (self, _tmp11_);
	_g_object_unref0 (_tmp11_);
	_tmp12_ = self->priv->_stack;
	gtk_stack_set_transition_type (_tmp12_, GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT);
	_tmp13_ = self->priv->_stack;
	_tmp14_ = _g_object_ref0 ((GtkWidget*) _tmp13_);
	_tmp15_ = (GtkOverlay*) gtk_overlay_new ();
	g_object_set ((GtkContainer*) _tmp15_, "child", _tmp14_, NULL);
	_g_object_unref0 (_tmp14_);
	g_object_ref_sink (_tmp15_);
	overlay = _tmp15_;
	_tmp16_ = overlay;
	_tmp17_ = self->priv->cloning_success_toast;
	gtk_overlay_add_overlay (_tmp16_, (GtkWidget*) _tmp17_);
	_tmp18_ = (GtkStackSwitcher*) gtk_stack_switcher_new ();
	g_object_ref_sink (_tmp18_);
	_g_object_unref0 (self->priv->stack_switcher);
	self->priv->stack_switcher = _tmp18_;
	_tmp19_ = self->priv->stack_switcher;
	gtk_widget_set_no_show_all ((GtkWidget*) _tmp19_, TRUE);
	_tmp20_ = self->priv->stack_switcher;
	gtk_widget_set_visible ((GtkWidget*) _tmp20_, FALSE);
	_tmp21_ = self->priv->stack_switcher;
	_tmp22_ = self->priv->_stack;
	gtk_stack_switcher_set_stack (_tmp21_, _tmp22_);
	_tmp23_ = self->priv->stack_switcher;
	gtk_box_set_homogeneous ((GtkBox*) _tmp23_, TRUE);
	_tmp24_ = (GtkActionBar*) gtk_action_bar_new ();
	g_object_ref_sink (_tmp24_);
	actionbar = _tmp24_;
	_tmp25_ = actionbar;
	_tmp26_ = gtk_widget_get_style_context ((GtkWidget*) _tmp25_);
	gtk_style_context_add_class (_tmp26_, GTK_STYLE_CLASS_INLINE_TOOLBAR);
	_tmp27_ = g_menu_item_new (_ ("Collapse All"), SCRATCH_MAIN_WINDOW_ACTION_PREFIX SCRATCH_MAIN_WINDOW_ACTION_COLLAPSE_ALL_FOLDERS);
	collapse_all_menu_item = _tmp27_;
	_tmp28_ = g_simple_action_group_new ();
	action_group = _tmp28_;
	_tmp29_ = scratch_saved_state;
	_tmp30_ = g_settings_create_action (_tmp29_, "order-folders");
	sort_action = _tmp30_;
	_tmp31_ = action_group;
	_tmp32_ = sort_action;
	g_action_map_add_action ((GActionMap*) _tmp31_, _tmp32_);
	_tmp33_ = action_group;
	gtk_widget_insert_action_group ((GtkWidget*) self, CODE_SIDEBAR_SIDEBAR_ACTION_GROUP, (GActionGroup*) _tmp33_);
	_tmp34_ = sort_action;
	_tmp35_ = g_action_get_name (_tmp34_);
	_tmp36_ = _tmp35_;
	_tmp37_ = g_strconcat (CODE_SIDEBAR_SIDEBAR_ACTION_PREFIX, _tmp36_, NULL);
	_tmp38_ = _tmp37_;
	_tmp39_ = g_menu_item_new (_ ("Keep Sorted"), _tmp38_);
	_tmp40_ = _tmp39_;
	_g_free0 (_tmp38_);
	order_projects_menu_item = _tmp40_;
	_tmp41_ = g_menu_new ();
	project_menu = _tmp41_;
	_tmp42_ = project_menu;
	_tmp43_ = collapse_all_menu_item;
	g_menu_append_item (_tmp42_, _tmp43_);
	_tmp44_ = project_menu;
	_tmp45_ = order_projects_menu_item;
	g_menu_append_item (_tmp44_, _tmp45_);
	_tmp46_ = project_menu;
	code_sidebar_set_project_menu_model (self, (GMenuModel*) _tmp46_);
	_tmp47_ = (GtkLabel*) gtk_label_new (_ ("Manage project folders…"));
	gtk_widget_set_halign ((GtkWidget*) _tmp47_, GTK_ALIGN_START);
	g_object_ref_sink (_tmp47_);
	label = _tmp47_;
	_tmp48_ = self->priv->_project_menu_model;
	_tmp49_ = _g_object_ref0 (_tmp48_);
	_tmp50_ = label;
	_tmp51_ = _g_object_ref0 ((GtkWidget*) _tmp50_);
	_tmp52_ = (GtkMenuButton*) gtk_menu_button_new ();
	gtk_widget_set_hexpand ((GtkWidget*) _tmp52_, TRUE);
	gtk_menu_button_set_use_popover (_tmp52_, FALSE);
	gtk_menu_button_set_menu_model (_tmp52_, _tmp49_);
	_g_object_unref0 (_tmp49_);
	g_object_set ((GtkContainer*) _tmp52_, "child", _tmp51_, NULL);
	_g_object_unref0 (_tmp51_);
	g_object_ref_sink (_tmp52_);
	project_menu_button = _tmp52_;
	_tmp53_ = actionbar;
	_tmp54_ = project_menu_button;
	gtk_action_bar_pack_start (_tmp53_, (GtkWidget*) _tmp54_);
	_tmp55_ = self->priv->_headerbar;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp55_);
	_tmp56_ = self->priv->stack_switcher;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp56_);
	_tmp57_ = overlay;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp57_);
	_tmp58_ = actionbar;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp58_);
	_tmp59_ = self->priv->_stack;
	g_signal_connect_object ((GtkContainer*) _tmp59_, "add", (GCallback) __code_sidebar___lambda170__gtk_container_add, self, 0);
	_tmp60_ = self->priv->_stack;
	g_signal_connect_object ((GtkContainer*) _tmp60_, "remove", (GCallback) __code_sidebar___lambda171__gtk_container_remove, self, 0);
	_tmp61_.target = "text/uri-list";
	_tmp61_.flags = (guint) 0;
	_tmp61_.info = (guint) CODE_SIDEBAR_TARGET_TYPE_URI_LIST;
	uris = _tmp61_;
	_tmp62_ = uris;
	_tmp63_ = g_new0 (GtkTargetEntry, 1);
	_tmp63_[0] = _tmp62_;
	_tmp64_ = _tmp63_;
	_tmp64__length1 = 1;
	gtk_drag_dest_set ((GtkWidget*) self, GTK_DEST_DEFAULT_ALL, _tmp64_, (gint) 1, GDK_ACTION_COPY);
	_tmp64_ = (g_free (_tmp64_), NULL);
	g_signal_connect_object ((GtkWidget*) self, "drag-data-received", (GCallback) _code_sidebar_drag_received_gtk_widget_drag_data_received, self, 0);
	_g_object_unref0 (project_menu_button);
	_g_object_unref0 (label);
	_g_object_unref0 (project_menu);
	_g_object_unref0 (order_projects_menu_item);
	_g_object_unref0 (sort_action);
	_g_object_unref0 (action_group);
	_g_object_unref0 (collapse_all_menu_item);
	_g_object_unref0 (actionbar);
	_g_object_unref0 (overlay);
	return obj;
}

static void
code_sidebar_class_init (CodeSidebarClass * klass,
                         gpointer klass_data)
{
	code_sidebar_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &CodeSidebar_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_code_sidebar_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_code_sidebar_set_property;
	G_OBJECT_CLASS (klass)->constructor = code_sidebar_constructor;
	G_OBJECT_CLASS (klass)->finalize = code_sidebar_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), CODE_SIDEBAR_STACK_PROPERTY, code_sidebar_properties[CODE_SIDEBAR_STACK_PROPERTY] = g_param_spec_object ("stack", "stack", "stack", gtk_stack_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CODE_SIDEBAR_CHOOSE_PROJECT_BUTTON_PROPERTY, code_sidebar_properties[CODE_SIDEBAR_CHOOSE_PROJECT_BUTTON_PROPERTY] = g_param_spec_object ("choose-project-button", "choose-project-button", "choose-project-button", CODE_TYPE_CHOOSE_PROJECT_BUTTON, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CODE_SIDEBAR_HEADERBAR_PROPERTY, code_sidebar_properties[CODE_SIDEBAR_HEADERBAR_PROPERTY] = g_param_spec_object ("headerbar", "headerbar", "headerbar", hdy_header_bar_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CODE_SIDEBAR_PROJECT_MENU_MODEL_PROPERTY, code_sidebar_properties[CODE_SIDEBAR_PROJECT_MENU_MODEL_PROPERTY] = g_param_spec_object ("project-menu-model", "project-menu-model", "project-menu-model", g_menu_model_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CODE_SIDEBAR_CLONING_IN_PROGRESS_PROPERTY, code_sidebar_properties[CODE_SIDEBAR_CLONING_IN_PROGRESS_PROPERTY] = g_param_spec_boolean ("cloning-in-progress", "cloning-in-progress", "cloning-in-progress", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
code_sidebar_instance_init (CodeSidebar * self,
                            gpointer klass)
{
	self->priv = code_sidebar_get_instance_private (self);
}

static void
code_sidebar_finalize (GObject * obj)
{
	CodeSidebar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CODE_TYPE_SIDEBAR, CodeSidebar);
	_g_object_unref0 (self->priv->_stack);
	_g_object_unref0 (self->priv->_choose_project_button);
	_g_object_unref0 (self->priv->_headerbar);
	_g_object_unref0 (self->priv->_project_menu_model);
	_g_object_unref0 (self->priv->stack_switcher);
	_g_object_unref0 (self->priv->cloning_success_toast);
	G_OBJECT_CLASS (code_sidebar_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
code_sidebar_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (CodeSidebarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) code_sidebar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CodeSidebar), 0, (GInstanceInitFunc) code_sidebar_instance_init, NULL };
	GType code_sidebar_type_id;
	code_sidebar_type_id = g_type_register_static (gtk_grid_get_type (), "CodeSidebar", &g_define_type_info, G_TYPE_FLAG_NONE);
	CodeSidebar_private_offset = g_type_add_instance_private (code_sidebar_type_id, sizeof (CodeSidebarPrivate));
	return code_sidebar_type_id;
}

GType
code_sidebar_get_type (void)
{
	static gsize code_sidebar_type_id__once = 0;
	if (g_once_init_enter (&code_sidebar_type_id__once)) {
		GType code_sidebar_type_id;
		code_sidebar_type_id = code_sidebar_get_type_once ();
		g_once_init_leave (&code_sidebar_type_id__once, code_sidebar_type_id);
	}
	return code_sidebar_type_id__once;
}

static void
_vala_code_sidebar_get_property (GObject * object,
                                 guint property_id,
                                 GValue * value,
                                 GParamSpec * pspec)
{
	CodeSidebar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, CODE_TYPE_SIDEBAR, CodeSidebar);
	switch (property_id) {
		case CODE_SIDEBAR_STACK_PROPERTY:
		g_value_set_object (value, code_sidebar_get_stack (self));
		break;
		case CODE_SIDEBAR_CHOOSE_PROJECT_BUTTON_PROPERTY:
		g_value_set_object (value, code_sidebar_get_choose_project_button (self));
		break;
		case CODE_SIDEBAR_HEADERBAR_PROPERTY:
		g_value_set_object (value, code_sidebar_get_headerbar (self));
		break;
		case CODE_SIDEBAR_PROJECT_MENU_MODEL_PROPERTY:
		g_value_set_object (value, code_sidebar_get_project_menu_model (self));
		break;
		case CODE_SIDEBAR_CLONING_IN_PROGRESS_PROPERTY:
		g_value_set_boolean (value, code_sidebar_get_cloning_in_progress (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_code_sidebar_set_property (GObject * object,
                                 guint property_id,
                                 const GValue * value,
                                 GParamSpec * pspec)
{
	CodeSidebar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, CODE_TYPE_SIDEBAR, CodeSidebar);
	switch (property_id) {
		case CODE_SIDEBAR_STACK_PROPERTY:
		code_sidebar_set_stack (self, g_value_get_object (value));
		break;
		case CODE_SIDEBAR_CHOOSE_PROJECT_BUTTON_PROPERTY:
		code_sidebar_set_choose_project_button (self, g_value_get_object (value));
		break;
		case CODE_SIDEBAR_HEADERBAR_PROPERTY:
		code_sidebar_set_headerbar (self, g_value_get_object (value));
		break;
		case CODE_SIDEBAR_PROJECT_MENU_MODEL_PROPERTY:
		code_sidebar_set_project_menu_model (self, g_value_get_object (value));
		break;
		case CODE_SIDEBAR_CLONING_IN_PROGRESS_PROPERTY:
		code_sidebar_set_cloning_in_progress (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

