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

/*
 * Copyright © 2023 Alain M. (https://github.com/alainm23/planify)
 *
 * 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, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA
 *
 * Authored by: Alain M. <alainmh23@gmail.com>
 */

#include "planify.h"
#include <gtk/gtk.h>
#include <gee.h>
#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <adwaita.h>
#include <gdk/gdk.h>
#include <gio/gio.h>
#include <pango/pango.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  {
	WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_0_PROPERTY,
	WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_PROJECT_PROPERTY,
	WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_SECTION_PROPERTY,
	WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_NUM_PROPERTIES
};
static GParamSpec* widgets_project_picker_project_picker_button_properties[WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block40Data Block40Data;
typedef struct _Block41Data Block41Data;
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
typedef struct _Block42Data Block42Data;
#define _http_response_unref0(var) ((var == NULL) ? NULL : (var = (http_response_unref (var), NULL)))
enum  {
	WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_PROJECT_CHANGE_SIGNAL,
	WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_SECTION_CHANGE_SIGNAL,
	WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_PICKER_OPENED_SIGNAL,
	WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_NUM_SIGNALS
};
static guint widgets_project_picker_project_picker_button_signals[WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_NUM_SIGNALS] = {0};

struct _WidgetsProjectPickerProjectPickerButtonPrivate {
	ObjectsProject* _project;
	ObjectsSection* _section;
	WidgetsIconColorProject* icon_project;
	GtkLabel* name_label;
	GtkLabel* section_label;
	GtkPopover* sections_popover;
	GtkRevealer* section_box_revealer;
	GtkMenuButton* project_button;
	WidgetsProjectPickerProjectPickerPopover* project_picker_popover;
	GtkListBox* sections_listbox;
	GtkRevealer* add_section_revealer;
	GtkLabel* placeholder_message_label;
	GtkRevealer* spinner_revealer;
	GeeHashMap* signal_map;
	gchar* PLACEHOLDER_MESSAGE;
	gchar* PLACEHOLDER_CREATE_MESSAGE;
};

struct _Block40Data {
	int _ref_count_;
	WidgetsProjectPickerProjectPickerButton* self;
	GtkSearchEntry* search_entry;
	GtkPopover* popover;
};

struct _Block41Data {
	int _ref_count_;
	Block40Data * _data40_;
	gint size;
};

struct _Block42Data {
	int _ref_count_;
	WidgetsProjectPickerProjectPickerButton* self;
	ObjectsSection* section;
};

static gint WidgetsProjectPickerProjectPickerButton_private_offset;
static gpointer widgets_project_picker_project_picker_button_parent_class = NULL;

static GtkPopover* widgets_project_picker_project_picker_button_build_sections_popover (WidgetsProjectPickerProjectPickerButton* self);
static Block40Data* block40_data_ref (Block40Data* _data40_);
static void block40_data_unref (void * _userdata_);
static GtkWidget* widgets_project_picker_project_picker_button_get_section_placeholder (WidgetsProjectPickerProjectPickerButton* self);
static void __lambda123_ (WidgetsProjectPickerProjectPickerButton* self,
                   GtkListBoxRow* row);
static void ___lambda123__gtk_list_box_row_activated (GtkListBox* _sender,
                                               GtkListBoxRow* row,
                                               gpointer self);
static void __lambda124_ (Block40Data* _data40_);
static Block41Data* block41_data_ref (Block41Data* _data41_);
static void block41_data_unref (void * _userdata_);
static gboolean __lambda125_ (Block41Data* _data41_,
                       GtkListBoxRow* row);
static gboolean ___lambda125__gtk_list_box_filter_func (GtkListBoxRow* row,
                                                 gpointer self);
static void ___lambda124__gtk_search_entry_search_changed (GtkSearchEntry* _sender,
                                                    gpointer self);
static gboolean __lambda126_ (Block40Data* _data40_,
                       guint keyval,
                       guint keycode,
                       GdkModifierType state);
static gboolean ___lambda126__gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                             guint keyval,
                                                             guint keycode,
                                                             GdkModifierType state,
                                                             gpointer self);
static void __lambda127_ (Block40Data* _data40_);
static void widgets_project_picker_project_picker_button_add_assign_section (WidgetsProjectPickerProjectPickerButton* self,
                                                                      const gchar* name);
static void ___lambda127__gtk_search_entry_activate (GtkSearchEntry* _sender,
                                              gpointer self);
static gboolean __lambda129_ (Block40Data* _data40_,
                       guint keyval,
                       guint keycode,
                       GdkModifierType state);
static gboolean ___lambda129__gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                             guint keyval,
                                                             guint keycode,
                                                             GdkModifierType state,
                                                             gpointer self);
static Block42Data* block42_data_ref (Block42Data* _data42_);
static void block42_data_unref (void * _userdata_);
static void _widgets_project_picker_project_picker_button_add_assign_section (WidgetsProjectPickerProjectPickerButton* self,
                                                                       ObjectsSection* section);
static void ___lambda128_ (Block42Data* _data42_,
                    GObject* obj,
                    GAsyncResult* res);
static void ____lambda128__gasync_ready_callback (GObject* source_object,
                                           GAsyncResult* res,
                                           gpointer self);
static void widgets_project_picker_project_picker_button_add_sections (WidgetsProjectPickerProjectPickerButton* self,
                                                                ObjectsProject* project);
static GObject * widgets_project_picker_project_picker_button_constructor (GType type,
                                                                    guint n_construct_properties,
                                                                    GObjectConstructParam * construct_properties);
static void _widgets_project_picker_project_picker_button___lambda130_ (WidgetsProjectPickerProjectPickerButton* self,
                                                                 ObjectsProject* _project);
static void __widgets_project_picker_project_picker_button___lambda130__widgets_project_picker_project_picker_popover_selected (WidgetsProjectPickerProjectPickerPopover* _sender,
                                                                                                                         ObjectsProject* project,
                                                                                                                         gpointer self);
static void _widgets_project_picker_project_picker_button___lambda131_ (WidgetsProjectPickerProjectPickerButton* self);
static void __widgets_project_picker_project_picker_button___lambda131__gtk_popover_closed (GtkPopover* _sender,
                                                                                     gpointer self);
static void _widgets_project_picker_project_picker_button___lambda132_ (WidgetsProjectPickerProjectPickerButton* self);
static void __widgets_project_picker_project_picker_button___lambda132__gtk_widget_show (GtkWidget* _sender,
                                                                                  gpointer self);
static void _widgets_project_picker_project_picker_button___lambda133_ (WidgetsProjectPickerProjectPickerButton* self);
static void __widgets_project_picker_project_picker_button___lambda133__gtk_popover_closed (GtkPopover* _sender,
                                                                                     gpointer self);
static void _widgets_project_picker_project_picker_button___lambda134_ (WidgetsProjectPickerProjectPickerButton* self);
static void __widgets_project_picker_project_picker_button___lambda134__gtk_widget_show (GtkWidget* _sender,
                                                                                  gpointer self);
static void widgets_project_picker_project_picker_button_finalize (GObject * obj);
static GType widgets_project_picker_project_picker_button_get_type_once (void);
static void _vala_widgets_project_picker_project_picker_button_get_property (GObject * object,
                                                                      guint property_id,
                                                                      GValue * value,
                                                                      GParamSpec * pspec);
static void _vala_widgets_project_picker_project_picker_button_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 inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
widgets_project_picker_project_picker_button_get_instance_private (WidgetsProjectPickerProjectPickerButton* self)
{
	return G_STRUCT_MEMBER_P (self, WidgetsProjectPickerProjectPickerButton_private_offset);
}

void
widgets_project_picker_project_picker_button_update_project_request (WidgetsProjectPickerProjectPickerButton* self)
{
	const gchar* _tmp0_ = NULL;
	ObjectsProject* _tmp1_;
	ObjectsProject* _tmp2_;
	gboolean _tmp3_;
	gboolean _tmp4_;
	GtkLabel* _tmp9_;
	WidgetsIconColorProject* _tmp10_;
	ObjectsProject* _tmp11_;
	ObjectsProject* _tmp12_;
	WidgetsIconColorProject* _tmp13_;
	gboolean _tmp14_ = FALSE;
	ObjectsProject* _tmp15_;
	ObjectsProject* _tmp16_;
	GeeArrayList* _tmp17_;
	GeeArrayList* _tmp18_;
	gint _tmp19_;
	gint _tmp20_;
	GtkRevealer* _tmp25_;
	g_return_if_fail (self != NULL);
	_tmp1_ = widgets_project_picker_project_picker_button_get_project (self);
	_tmp2_ = _tmp1_;
	_tmp3_ = objects_project_get_is_inbox_project (_tmp2_);
	_tmp4_ = _tmp3_;
	if (_tmp4_) {
		_tmp0_ = _ ("Inbox");
	} else {
		ObjectsProject* _tmp5_;
		ObjectsProject* _tmp6_;
		const gchar* _tmp7_;
		const gchar* _tmp8_;
		_tmp5_ = widgets_project_picker_project_picker_button_get_project (self);
		_tmp6_ = _tmp5_;
		_tmp7_ = objects_base_object_get_name ((ObjectsBaseObject*) _tmp6_);
		_tmp8_ = _tmp7_;
		_tmp0_ = _tmp8_;
	}
	_tmp9_ = self->priv->name_label;
	gtk_label_set_label (_tmp9_, _tmp0_);
	_tmp10_ = self->priv->icon_project;
	_tmp11_ = widgets_project_picker_project_picker_button_get_project (self);
	_tmp12_ = _tmp11_;
	widgets_icon_color_project_set_project (_tmp10_, _tmp12_);
	_tmp13_ = self->priv->icon_project;
	widgets_icon_color_project_update_request (_tmp13_);
	_tmp15_ = widgets_project_picker_project_picker_button_get_project (self);
	_tmp16_ = _tmp15_;
	_tmp17_ = objects_project_get_sections (_tmp16_);
	_tmp18_ = _tmp17_;
	_tmp19_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp18_);
	_tmp20_ = _tmp19_;
	if (_tmp20_ > 0) {
		ObjectsProject* _tmp21_;
		ObjectsProject* _tmp22_;
		SourceType _tmp23_;
		SourceType _tmp24_;
		_tmp21_ = widgets_project_picker_project_picker_button_get_project (self);
		_tmp22_ = _tmp21_;
		_tmp23_ = objects_project_get_source_type (_tmp22_);
		_tmp24_ = _tmp23_;
		_tmp14_ = _tmp24_ != SOURCE_TYPE_CALDAV;
	} else {
		_tmp14_ = FALSE;
	}
	_tmp25_ = self->priv->section_box_revealer;
	gtk_revealer_set_reveal_child (_tmp25_, _tmp14_);
}

static Block40Data*
block40_data_ref (Block40Data* _data40_)
{
	g_atomic_int_inc (&_data40_->_ref_count_);
	return _data40_;
}

static void
block40_data_unref (void * _userdata_)
{
	Block40Data* _data40_;
	_data40_ = (Block40Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data40_->_ref_count_)) {
		WidgetsProjectPickerProjectPickerButton* self;
		self = _data40_->self;
		_g_object_unref0 (_data40_->popover);
		_g_object_unref0 (_data40_->search_entry);
		_g_object_unref0 (self);
		g_slice_free (Block40Data, _data40_);
	}
}

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

static void
__lambda123_ (WidgetsProjectPickerProjectPickerButton* self,
              GtkListBoxRow* row)
{
	GtkPopover* _tmp0_;
	ObjectsSection* section = NULL;
	ObjectsSection* _tmp1_;
	ObjectsSection* _tmp2_;
	ObjectsSection* _tmp3_;
	GtkLabel* _tmp4_;
	ObjectsSection* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	ObjectsSection* _tmp8_ = NULL;
	ObjectsSection* _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	g_return_if_fail (row != NULL);
	_tmp0_ = self->priv->sections_popover;
	gtk_popover_popdown (_tmp0_);
	_tmp1_ = widgets_section_picker_section_picker_row_get_section (G_TYPE_CHECK_INSTANCE_CAST (row, WIDGETS_SECTION_PICKER_TYPE_SECTION_PICKER_ROW, WidgetsSectionPickerSectionPickerRow));
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	section = _tmp3_;
	_tmp4_ = self->priv->section_label;
	_tmp5_ = section;
	_tmp6_ = objects_base_object_get_name ((ObjectsBaseObject*) _tmp5_);
	_tmp7_ = _tmp6_;
	gtk_label_set_label (_tmp4_, _tmp7_);
	_tmp9_ = section;
	_tmp10_ = objects_base_object_get_id ((ObjectsBaseObject*) _tmp9_);
	_tmp11_ = _tmp10_;
	if (g_strcmp0 (_tmp11_, "") == 0) {
		_tmp8_ = NULL;
	} else {
		ObjectsSection* _tmp12_;
		_tmp12_ = section;
		_tmp8_ = _tmp12_;
	}
	g_signal_emit (self, widgets_project_picker_project_picker_button_signals[WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_SECTION_CHANGE_SIGNAL], 0, _tmp8_);
	_g_object_unref0 (section);
}

static void
___lambda123__gtk_list_box_row_activated (GtkListBox* _sender,
                                          GtkListBoxRow* row,
                                          gpointer self)
{
	__lambda123_ ((WidgetsProjectPickerProjectPickerButton*) self, row);
}

static Block41Data*
block41_data_ref (Block41Data* _data41_)
{
	g_atomic_int_inc (&_data41_->_ref_count_);
	return _data41_;
}

static void
block41_data_unref (void * _userdata_)
{
	Block41Data* _data41_;
	_data41_ = (Block41Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data41_->_ref_count_)) {
		WidgetsProjectPickerProjectPickerButton* self;
		self = _data41_->_data40_->self;
		block40_data_unref (_data41_->_data40_);
		_data41_->_data40_ = NULL;
		g_slice_free (Block41Data, _data41_);
	}
}

static gboolean
string_contains (const gchar* self,
                 const gchar* needle)
{
	gchar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (needle != NULL, FALSE);
	_tmp0_ = strstr ((gchar*) self, (gchar*) needle);
	result = _tmp0_ != NULL;
	return result;
}

static gboolean
__lambda125_ (Block41Data* _data41_,
              GtkListBoxRow* row)
{
	Block40Data* _data40_;
	WidgetsProjectPickerProjectPickerButton* self;
	ObjectsSection* section = NULL;
	ObjectsSection* _tmp0_;
	ObjectsSection* _tmp1_;
	ObjectsSection* _tmp2_;
	gboolean return_value = FALSE;
	ObjectsSection* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gboolean _tmp12_;
	gboolean result;
	_data40_ = _data41_->_data40_;
	self = _data40_->self;
	g_return_val_if_fail (row != NULL, FALSE);
	_tmp0_ = widgets_section_picker_section_picker_row_get_section (G_TYPE_CHECK_INSTANCE_CAST (row, WIDGETS_SECTION_PICKER_TYPE_SECTION_PICKER_ROW, WidgetsSectionPickerSectionPickerRow));
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	section = _tmp2_;
	_tmp3_ = section;
	_tmp4_ = objects_base_object_get_name ((ObjectsBaseObject*) _tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = g_utf8_strdown (_tmp5_, (gssize) -1);
	_tmp7_ = _tmp6_;
	_tmp8_ = gtk_editable_get_text ((GtkEditable*) _data40_->search_entry);
	_tmp9_ = _tmp8_;
	_tmp10_ = g_utf8_strdown (_tmp9_, (gssize) -1);
	_tmp11_ = _tmp10_;
	_tmp12_ = string_contains (_tmp7_, _tmp11_);
	_g_free0 (_tmp11_);
	_g_free0 (_tmp7_);
	return_value = _tmp12_;
	if (return_value) {
		gint _tmp13_;
		_tmp13_ = _data41_->size;
		_data41_->size = _tmp13_ + 1;
	}
	result = return_value;
	_g_object_unref0 (section);
	return result;
}

static gboolean
___lambda125__gtk_list_box_filter_func (GtkListBoxRow* row,
                                        gpointer self)
{
	gboolean result;
	result = __lambda125_ (self, row);
	return result;
}

static void
__lambda124_ (Block40Data* _data40_)
{
	WidgetsProjectPickerProjectPickerButton* self;
	Block41Data* _data41_;
	GtkListBox* _tmp0_;
	GtkRevealer* _tmp1_;
	gchar* _tmp2_ = NULL;
	GtkLabel* _tmp9_;
	self = _data40_->self;
	_data41_ = g_slice_new0 (Block41Data);
	_data41_->_ref_count_ = 1;
	_data41_->_data40_ = block40_data_ref (_data40_);
	_data41_->size = 0;
	_tmp0_ = self->priv->sections_listbox;
	gtk_list_box_set_filter_func (_tmp0_, ___lambda125__gtk_list_box_filter_func, block41_data_ref (_data41_), block41_data_unref);
	_tmp1_ = self->priv->add_section_revealer;
	gtk_revealer_set_reveal_child (_tmp1_, _data41_->size <= 0);
	if (_data41_->size <= 0) {
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		const gchar* _tmp5_;
		gchar* _tmp6_;
		_tmp3_ = self->priv->PLACEHOLDER_CREATE_MESSAGE;
		_tmp4_ = gtk_editable_get_text ((GtkEditable*) _data40_->search_entry);
		_tmp5_ = _tmp4_;
		_tmp6_ = g_strdup_printf (_tmp3_, _tmp5_);
		_g_free0 (_tmp2_);
		_tmp2_ = _tmp6_;
	} else {
		const gchar* _tmp7_;
		gchar* _tmp8_;
		_tmp7_ = self->priv->PLACEHOLDER_MESSAGE;
		_tmp8_ = g_strdup (_tmp7_);
		_g_free0 (_tmp2_);
		_tmp2_ = _tmp8_;
	}
	_tmp9_ = self->priv->placeholder_message_label;
	gtk_label_set_label (_tmp9_, _tmp2_);
	_g_free0 (_tmp2_);
	block41_data_unref (_data41_);
	_data41_ = NULL;
}

static void
___lambda124__gtk_search_entry_search_changed (GtkSearchEntry* _sender,
                                               gpointer self)
{
	__lambda124_ (self);
}

static gboolean
__lambda126_ (Block40Data* _data40_,
              guint keyval,
              guint keycode,
              GdkModifierType state)
{
	WidgetsProjectPickerProjectPickerButton* self;
	gboolean result;
	self = _data40_->self;
	if (keyval == GDK_KEY_Escape) {
		gtk_popover_popdown (_data40_->popover);
	}
	result = FALSE;
	return result;
}

static gboolean
___lambda126__gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                    guint keyval,
                                                    guint keycode,
                                                    GdkModifierType state,
                                                    gpointer self)
{
	gboolean result;
	result = __lambda126_ (self, keyval, keycode, state);
	return result;
}

static void
__lambda127_ (Block40Data* _data40_)
{
	WidgetsProjectPickerProjectPickerButton* self;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	self = _data40_->self;
	_tmp0_ = gtk_editable_get_text ((GtkEditable*) _data40_->search_entry);
	_tmp1_ = _tmp0_;
	_tmp2_ = strlen (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_ <= 0) {
		return;
	}
	_tmp4_ = gtk_editable_get_text ((GtkEditable*) _data40_->search_entry);
	_tmp5_ = _tmp4_;
	widgets_project_picker_project_picker_button_add_assign_section (self, _tmp5_);
}

static void
___lambda127__gtk_search_entry_activate (GtkSearchEntry* _sender,
                                         gpointer self)
{
	__lambda127_ (self);
}

static gchar*
string_replace (const gchar* self,
                const gchar* old,
                const gchar* replacement)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	if ((*((gchar*) self)) == '\0') {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = (*((gchar*) old)) == '\0';
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = g_strcmp0 (old, replacement) == 0;
	}
	if (_tmp0_) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup (self);
		result = _tmp2_;
		return result;
	}
	{
		GRegex* regex = NULL;
		gchar* _tmp3_;
		gchar* _tmp4_;
		GRegex* _tmp5_;
		GRegex* _tmp6_;
		gchar* _tmp7_ = NULL;
		GRegex* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp3_ = g_regex_escape_string (old, -1);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_regex_new (_tmp4_, 0, 0, &_inner_error0_);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		regex = _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp8_ = regex;
		_tmp9_ = g_regex_replace_literal (_tmp8_, self, (gssize) -1, 0, replacement, 0, &_inner_error0_);
		_tmp7_ = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_regex_unref0 (regex);
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp10_ = _tmp7_;
		_tmp7_ = NULL;
		result = _tmp10_;
		_g_free0 (_tmp7_);
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return NULL;
}

static gboolean
__lambda129_ (Block40Data* _data40_,
              guint keyval,
              guint keycode,
              GdkModifierType state)
{
	WidgetsProjectPickerProjectPickerButton* self;
	gchar* key = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gboolean _tmp2_ = FALSE;
	const gchar* _tmp3_;
	gboolean result;
	self = _data40_->self;
	_tmp0_ = gdk_keyval_name (keyval);
	_tmp1_ = string_replace (_tmp0_, "KP_", "");
	key = _tmp1_;
	_tmp3_ = key;
	if (g_strcmp0 (_tmp3_, "Up") == 0) {
		_tmp2_ = TRUE;
	} else {
		const gchar* _tmp4_;
		_tmp4_ = key;
		_tmp2_ = g_strcmp0 (_tmp4_, "Down") == 0;
	}
	if (_tmp2_) {
	} else {
		gboolean _tmp5_ = FALSE;
		gboolean _tmp6_ = FALSE;
		const gchar* _tmp7_;
		_tmp7_ = key;
		if (g_strcmp0 (_tmp7_, "Enter") == 0) {
			_tmp6_ = TRUE;
		} else {
			const gchar* _tmp8_;
			_tmp8_ = key;
			_tmp6_ = g_strcmp0 (_tmp8_, "Return") == 0;
		}
		if (_tmp6_) {
			_tmp5_ = TRUE;
		} else {
			const gchar* _tmp9_;
			_tmp9_ = key;
			_tmp5_ = g_strcmp0 (_tmp9_, "KP_Enter") == 0;
		}
		if (_tmp5_) {
		} else {
			gboolean _tmp10_;
			gboolean _tmp11_;
			g_object_get ((GtkWidget*) _data40_->search_entry, "has-focus", &_tmp10_, NULL);
			_tmp11_ = _tmp10_;
			if (!_tmp11_) {
				gint _tmp12_;
				gint _tmp13_;
				const gchar* _tmp14_;
				const gchar* _tmp15_;
				gint _tmp16_;
				gint _tmp17_;
				gtk_widget_grab_focus ((GtkWidget*) _data40_->search_entry);
				g_object_get ((GtkEditable*) _data40_->search_entry, "cursor-position", &_tmp12_, NULL);
				_tmp13_ = _tmp12_;
				_tmp14_ = gtk_editable_get_text ((GtkEditable*) _data40_->search_entry);
				_tmp15_ = _tmp14_;
				_tmp16_ = strlen (_tmp15_);
				_tmp17_ = _tmp16_;
				if (_tmp13_ < _tmp17_) {
					const gchar* _tmp18_;
					const gchar* _tmp19_;
					gint _tmp20_;
					gint _tmp21_;
					_tmp18_ = gtk_editable_get_text ((GtkEditable*) _data40_->search_entry);
					_tmp19_ = _tmp18_;
					_tmp20_ = strlen (_tmp19_);
					_tmp21_ = _tmp20_;
					gtk_editable_set_position ((GtkEditable*) _data40_->search_entry, _tmp21_);
				}
			}
		}
	}
	result = FALSE;
	_g_free0 (key);
	return result;
}

static gboolean
___lambda129__gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                    guint keyval,
                                                    guint keycode,
                                                    GdkModifierType state,
                                                    gpointer self)
{
	gboolean result;
	result = __lambda129_ (self, keyval, keycode, state);
	return result;
}

static GtkPopover*
widgets_project_picker_project_picker_button_build_sections_popover (WidgetsProjectPickerProjectPickerButton* self)
{
	Block40Data* _data40_;
	GtkSearchEntry* _tmp0_ = NULL;
	gchar* _tmp1_;
	gchar** _tmp2_;
	GtkListBox* _tmp3_ = NULL;
	GtkListBox* _tmp4_;
	GtkWidget* _tmp5_;
	GtkWidget* _tmp6_;
	GtkScrolledWindow* scrolled_window = NULL;
	GtkListBox* _tmp7_;
	GtkWidget* _tmp8_;
	GtkScrolledWindow* _tmp9_ = NULL;
	AdwToolbarView* toolbar_view = NULL;
	AdwToolbarView* _tmp10_;
	GtkWidget* _tmp11_;
	gchar* _tmp12_;
	gchar** _tmp13_;
	GtkPopover* _tmp14_ = NULL;
	GeeHashMap* _tmp15_;
	GtkListBox* _tmp16_;
	gulong _tmp17_;
	GtkListBox* _tmp18_;
	GeeHashMap* _tmp19_;
	gulong _tmp20_;
	GtkSearchEntry* _tmp21_;
	GtkEventControllerKey* search_entry_ctrl_key = NULL;
	GtkEventControllerKey* _tmp22_;
	GtkEventController* _tmp23_;
	GeeHashMap* _tmp24_;
	gulong _tmp25_;
	GeeHashMap* _tmp26_;
	gulong _tmp27_;
	GtkEventControllerKey* listbox_controller_key = NULL;
	GtkEventControllerKey* _tmp28_;
	GtkListBox* _tmp29_;
	GtkEventController* _tmp30_;
	GeeHashMap* _tmp31_;
	gulong _tmp32_;
	GtkPopover* _tmp33_;
	GtkPopover* result;
	g_return_val_if_fail (self != NULL, NULL);
	_data40_ = g_slice_new0 (Block40Data);
	_data40_->_ref_count_ = 1;
	_data40_->self = g_object_ref (self);
	_tmp0_ = (GtkSearchEntry*) gtk_search_entry_new ();
	gtk_widget_set_margin_top ((GtkWidget*) _tmp0_, 9);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp0_, 9);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp0_, 9);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp0_, 9);
	g_object_ref_sink (_tmp0_);
	_data40_->search_entry = _tmp0_;
	_tmp1_ = g_strdup ("listbox-background");
	_tmp2_ = g_new0 (gchar*, 1 + 1);
	_tmp2_[0] = _tmp1_;
	_tmp3_ = (GtkListBox*) gtk_list_box_new ();
	gtk_widget_set_hexpand ((GtkWidget*) _tmp3_, TRUE);
	gtk_widget_set_vexpand ((GtkWidget*) _tmp3_, TRUE);
	gtk_widget_set_css_classes ((GtkWidget*) _tmp3_, _tmp2_);
	_tmp2_ = (_vala_array_free (_tmp2_, 1, (GDestroyNotify) g_free), NULL);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp3_, 9);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp3_, 9);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp3_, 9);
	g_object_ref_sink (_tmp3_);
	_g_object_unref0 (self->priv->sections_listbox);
	self->priv->sections_listbox = _tmp3_;
	_tmp4_ = self->priv->sections_listbox;
	_tmp5_ = widgets_project_picker_project_picker_button_get_section_placeholder (self);
	_tmp6_ = _tmp5_;
	gtk_list_box_set_placeholder (_tmp4_, _tmp6_);
	_g_object_unref0 (_tmp6_);
	_tmp7_ = self->priv->sections_listbox;
	_tmp8_ = _g_object_ref0 ((GtkWidget*) _tmp7_);
	_tmp9_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	g_object_set (_tmp9_, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp9_, TRUE);
	gtk_widget_set_vexpand ((GtkWidget*) _tmp9_, TRUE);
	gtk_scrolled_window_set_child (_tmp9_, _tmp8_);
	_g_object_unref0 (_tmp8_);
	g_object_ref_sink (_tmp9_);
	scrolled_window = _tmp9_;
	_tmp10_ = (AdwToolbarView*) adw_toolbar_view_new ();
	g_object_ref_sink (_tmp10_);
	toolbar_view = _tmp10_;
	adw_toolbar_view_add_top_bar (toolbar_view, (GtkWidget*) _data40_->search_entry);
	adw_toolbar_view_set_content (toolbar_view, (GtkWidget*) scrolled_window);
	_tmp11_ = _g_object_ref0 ((GtkWidget*) toolbar_view);
	_tmp12_ = g_strdup ("popover-contents");
	_tmp13_ = g_new0 (gchar*, 1 + 1);
	_tmp13_[0] = _tmp12_;
	_tmp14_ = (GtkPopover*) gtk_popover_new ();
	gtk_popover_set_has_arrow (_tmp14_, FALSE);
	gtk_popover_set_position (_tmp14_, GTK_POS_BOTTOM);
	gtk_popover_set_child (_tmp14_, _tmp11_);
	_g_object_unref0 (_tmp11_);
	g_object_set ((GtkWidget*) _tmp14_, "height-request", 225, NULL);
	g_object_set ((GtkWidget*) _tmp14_, "width-request", 255, NULL);
	gtk_widget_set_css_classes ((GtkWidget*) _tmp14_, _tmp13_);
	_tmp13_ = (_vala_array_free (_tmp13_, 1, (GDestroyNotify) g_free), NULL);
	g_object_ref_sink (_tmp14_);
	_data40_->popover = _tmp14_;
	_tmp15_ = self->priv->signal_map;
	_tmp16_ = self->priv->sections_listbox;
	_tmp17_ = g_signal_connect_object (_tmp16_, "row-activated", (GCallback) ___lambda123__gtk_list_box_row_activated, self, 0);
	_tmp18_ = self->priv->sections_listbox;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp15_, (gpointer) ((guintptr) _tmp17_), (GObject*) _tmp18_);
	_tmp19_ = self->priv->signal_map;
	_tmp20_ = g_signal_connect_data (_data40_->search_entry, "search-changed", (GCallback) ___lambda124__gtk_search_entry_search_changed, block40_data_ref (_data40_), (GClosureNotify) block40_data_unref, 0);
	_tmp21_ = _data40_->search_entry;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp19_, (gpointer) ((guintptr) _tmp20_), (GObject*) _tmp21_);
	_tmp22_ = (GtkEventControllerKey*) gtk_event_controller_key_new ();
	search_entry_ctrl_key = _tmp22_;
	_tmp23_ = _g_object_ref0 ((GtkEventController*) search_entry_ctrl_key);
	gtk_widget_add_controller ((GtkWidget*) _data40_->search_entry, _tmp23_);
	_tmp24_ = self->priv->signal_map;
	_tmp25_ = g_signal_connect_data (search_entry_ctrl_key, "key-pressed", (GCallback) ___lambda126__gtk_event_controller_key_key_pressed, block40_data_ref (_data40_), (GClosureNotify) block40_data_unref, 0);
	gee_abstract_map_set ((GeeAbstractMap*) _tmp24_, (gpointer) ((guintptr) _tmp25_), (GObject*) search_entry_ctrl_key);
	_tmp26_ = self->priv->signal_map;
	_tmp27_ = g_signal_connect_data (_data40_->search_entry, "activate", (GCallback) ___lambda127__gtk_search_entry_activate, block40_data_ref (_data40_), (GClosureNotify) block40_data_unref, 0);
	gee_abstract_map_set ((GeeAbstractMap*) _tmp26_, (gpointer) ((guintptr) _tmp27_), (GObject*) _data40_->search_entry);
	_tmp28_ = (GtkEventControllerKey*) gtk_event_controller_key_new ();
	listbox_controller_key = _tmp28_;
	_tmp29_ = self->priv->sections_listbox;
	_tmp30_ = _g_object_ref0 ((GtkEventController*) listbox_controller_key);
	gtk_widget_add_controller ((GtkWidget*) _tmp29_, _tmp30_);
	_tmp31_ = self->priv->signal_map;
	_tmp32_ = g_signal_connect_data (listbox_controller_key, "key-pressed", (GCallback) ___lambda129__gtk_event_controller_key_key_pressed, block40_data_ref (_data40_), (GClosureNotify) block40_data_unref, 0);
	gee_abstract_map_set ((GeeAbstractMap*) _tmp31_, (gpointer) ((guintptr) _tmp32_), (GObject*) listbox_controller_key);
	_tmp33_ = _g_object_ref0 (_data40_->popover);
	result = _tmp33_;
	_g_object_unref0 (listbox_controller_key);
	_g_object_unref0 (search_entry_ctrl_key);
	_g_object_unref0 (toolbar_view);
	_g_object_unref0 (scrolled_window);
	block40_data_unref (_data40_);
	_data40_ = NULL;
	return result;
}

static Block42Data*
block42_data_ref (Block42Data* _data42_)
{
	g_atomic_int_inc (&_data42_->_ref_count_);
	return _data42_;
}

static void
block42_data_unref (void * _userdata_)
{
	Block42Data* _data42_;
	_data42_ = (Block42Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data42_->_ref_count_)) {
		WidgetsProjectPickerProjectPickerButton* self;
		self = _data42_->self;
		_g_object_unref0 (_data42_->section);
		_g_object_unref0 (self);
		g_slice_free (Block42Data, _data42_);
	}
}

static void
___lambda128_ (Block42Data* _data42_,
               GObject* obj,
               GAsyncResult* res)
{
	WidgetsProjectPickerProjectPickerButton* self;
	GtkRevealer* _tmp0_;
	HttpResponse* response = NULL;
	ServicesTodoist* _tmp1_;
	ServicesTodoist* _tmp2_;
	HttpResponse* _tmp3_;
	HttpResponse* _tmp4_;
	HttpResponse* _tmp5_;
	gboolean _tmp6_;
	gboolean _tmp7_;
	self = _data42_->self;
	g_return_if_fail (res != NULL);
	_tmp0_ = self->priv->spinner_revealer;
	gtk_revealer_set_reveal_child (_tmp0_, FALSE);
	_tmp1_ = services_todoist_get_default ();
	_tmp2_ = _tmp1_;
	_tmp3_ = services_todoist_add_finish (_tmp2_, res);
	_tmp4_ = _tmp3_;
	_g_object_unref0 (_tmp2_);
	response = _tmp4_;
	_tmp5_ = response;
	_tmp6_ = http_response_get_status (_tmp5_);
	_tmp7_ = _tmp6_;
	if (_tmp7_) {
		ObjectsSection* _tmp8_;
		HttpResponse* _tmp9_;
		const gchar* _tmp10_;
		const gchar* _tmp11_;
		ObjectsSection* _tmp12_;
		ObjectsProject* _tmp13_;
		ObjectsProject* _tmp14_;
		ObjectsSection* _tmp15_;
		ObjectsSection* _tmp16_;
		ObjectsSection* _tmp17_;
		ObjectsSection* _tmp18_;
		_tmp8_ = _data42_->section;
		_tmp9_ = response;
		_tmp10_ = http_response_get_data (_tmp9_);
		_tmp11_ = _tmp10_;
		objects_base_object_set_id ((ObjectsBaseObject*) _tmp8_, _tmp11_);
		_tmp12_ = _data42_->section;
		_tmp13_ = objects_section_get_project (_tmp12_);
		_tmp14_ = _tmp13_;
		_tmp15_ = _data42_->section;
		_tmp16_ = objects_project_add_section_if_not_exists (_tmp14_, _tmp15_);
		_tmp17_ = _tmp16_;
		_g_object_unref0 (_tmp17_);
		_tmp18_ = _data42_->section;
		_widgets_project_picker_project_picker_button_add_assign_section (self, _tmp18_);
	} else {
		ServicesEventBus* _tmp19_;
		ServicesEventBus* _tmp20_;
		HttpResponse* _tmp21_;
		gint _tmp22_;
		gint _tmp23_;
		HttpResponse* _tmp24_;
		const gchar* _tmp25_;
		const gchar* _tmp26_;
		_tmp19_ = services_event_bus_get_default ();
		_tmp20_ = _tmp19_;
		_tmp21_ = response;
		_tmp22_ = http_response_get_error_code (_tmp21_);
		_tmp23_ = _tmp22_;
		_tmp24_ = response;
		_tmp25_ = http_response_get_error (_tmp24_);
		_tmp26_ = _tmp25_;
		g_signal_emit_by_name (_tmp20_, "send-error-toast", _tmp23_, _tmp26_);
		_g_object_unref0 (_tmp20_);
	}
	_http_response_unref0 (response);
}

static void
____lambda128__gasync_ready_callback (GObject* source_object,
                                      GAsyncResult* res,
                                      gpointer self)
{
	___lambda128_ (self, source_object, res);
	block42_data_unref (self);
}

static void
widgets_project_picker_project_picker_button_add_assign_section (WidgetsProjectPickerProjectPickerButton* self,
                                                                 const gchar* name)
{
	Block42Data* _data42_;
	ObjectsSection* _tmp0_;
	ObjectsSection* _tmp1_;
	ObjectsSection* _tmp2_;
	ObjectsProject* _tmp3_;
	ObjectsProject* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	ObjectsSection* _tmp7_;
	ObjectsProject* _tmp8_;
	ObjectsProject* _tmp9_;
	SourceType _tmp10_;
	SourceType _tmp11_;
	ObjectsSection* _tmp25_;
	ObjectsProject* _tmp26_;
	ObjectsProject* _tmp27_;
	SourceType _tmp28_;
	SourceType _tmp29_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (name != NULL);
	_data42_ = g_slice_new0 (Block42Data);
	_data42_->_ref_count_ = 1;
	_data42_->self = g_object_ref (self);
	_tmp0_ = objects_section_new ();
	_data42_->section = _tmp0_;
	_tmp1_ = _data42_->section;
	objects_base_object_set_name ((ObjectsBaseObject*) _tmp1_, name);
	_tmp2_ = _data42_->section;
	_tmp3_ = widgets_project_picker_project_picker_button_get_project (self);
	_tmp4_ = _tmp3_;
	_tmp5_ = objects_base_object_get_id ((ObjectsBaseObject*) _tmp4_);
	_tmp6_ = _tmp5_;
	objects_section_set_project_id (_tmp2_, _tmp6_);
	_tmp7_ = _data42_->section;
	_tmp8_ = objects_section_get_project (_tmp7_);
	_tmp9_ = _tmp8_;
	_tmp10_ = objects_project_get_source_type (_tmp9_);
	_tmp11_ = _tmp10_;
	if (_tmp11_ == SOURCE_TYPE_LOCAL) {
		ObjectsSection* _tmp12_;
		Util* _tmp13_;
		Util* _tmp14_;
		ObjectsSection* _tmp15_;
		gchar* _tmp16_;
		gchar* _tmp17_;
		ObjectsSection* _tmp18_;
		ObjectsProject* _tmp19_;
		ObjectsProject* _tmp20_;
		ObjectsSection* _tmp21_;
		ObjectsSection* _tmp22_;
		ObjectsSection* _tmp23_;
		ObjectsSection* _tmp24_;
		_tmp12_ = _data42_->section;
		_tmp13_ = util_get_default ();
		_tmp14_ = _tmp13_;
		_tmp15_ = _data42_->section;
		_tmp16_ = util_generate_id (_tmp14_, (ObjectsBaseObject*) _tmp15_);
		_tmp17_ = _tmp16_;
		objects_base_object_set_id ((ObjectsBaseObject*) _tmp12_, _tmp17_);
		_g_free0 (_tmp17_);
		_g_object_unref0 (_tmp14_);
		_tmp18_ = _data42_->section;
		_tmp19_ = objects_section_get_project (_tmp18_);
		_tmp20_ = _tmp19_;
		_tmp21_ = _data42_->section;
		_tmp22_ = objects_project_add_section_if_not_exists (_tmp20_, _tmp21_);
		_tmp23_ = _tmp22_;
		_g_object_unref0 (_tmp23_);
		_tmp24_ = _data42_->section;
		_widgets_project_picker_project_picker_button_add_assign_section (self, _tmp24_);
		block42_data_unref (_data42_);
		_data42_ = NULL;
		return;
	}
	_tmp25_ = _data42_->section;
	_tmp26_ = objects_section_get_project (_tmp25_);
	_tmp27_ = _tmp26_;
	_tmp28_ = objects_project_get_source_type (_tmp27_);
	_tmp29_ = _tmp28_;
	if (_tmp29_ == SOURCE_TYPE_TODOIST) {
		GtkRevealer* _tmp30_;
		ServicesTodoist* _tmp31_;
		ServicesTodoist* _tmp32_;
		ObjectsSection* _tmp33_;
		_tmp30_ = self->priv->spinner_revealer;
		gtk_revealer_set_reveal_child (_tmp30_, TRUE);
		_tmp31_ = services_todoist_get_default ();
		_tmp32_ = _tmp31_;
		_tmp33_ = _data42_->section;
		services_todoist_add (_tmp32_, (ObjectsBaseObject*) _tmp33_, ____lambda128__gasync_ready_callback, block42_data_ref (_data42_));
		_g_object_unref0 (_tmp32_);
	}
	block42_data_unref (_data42_);
	_data42_ = NULL;
}

static void
_widgets_project_picker_project_picker_button_add_assign_section (WidgetsProjectPickerProjectPickerButton* self,
                                                                  ObjectsSection* section)
{
	GtkLabel* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	GeeHashMap* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	WidgetsSectionPickerSectionPickerRow* _tmp6_;
	WidgetsSectionPickerSectionPickerRow* _tmp7_;
	GtkListBox* _tmp8_;
	GeeHashMap* _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	gpointer _tmp12_;
	WidgetsSectionPickerSectionPickerRow* _tmp13_;
	GtkPopover* _tmp14_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (section != NULL);
	_tmp0_ = self->priv->section_label;
	_tmp1_ = objects_base_object_get_name ((ObjectsBaseObject*) section);
	_tmp2_ = _tmp1_;
	gtk_label_set_label (_tmp0_, _tmp2_);
	g_signal_emit (self, widgets_project_picker_project_picker_button_signals[WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_SECTION_CHANGE_SIGNAL], 0, section);
	_tmp3_ = self->sections_map;
	_tmp4_ = objects_base_object_get_id ((ObjectsBaseObject*) section);
	_tmp5_ = _tmp4_;
	_tmp6_ = widgets_section_picker_section_picker_row_new (section);
	g_object_ref_sink (_tmp6_);
	_tmp7_ = _tmp6_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp3_, _tmp5_, _tmp7_);
	_g_object_unref0 (_tmp7_);
	_tmp8_ = self->priv->sections_listbox;
	_tmp9_ = self->sections_map;
	_tmp10_ = objects_base_object_get_id ((ObjectsBaseObject*) section);
	_tmp11_ = _tmp10_;
	_tmp12_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp9_, _tmp11_);
	_tmp13_ = (WidgetsSectionPickerSectionPickerRow*) _tmp12_;
	gtk_list_box_append (_tmp8_, (GtkWidget*) _tmp13_);
	_g_object_unref0 (_tmp13_);
	_tmp14_ = self->priv->sections_popover;
	gtk_popover_popdown (_tmp14_);
}

static void
widgets_project_picker_project_picker_button_add_sections (WidgetsProjectPickerProjectPickerButton* self,
                                                           ObjectsProject* project)
{
	GeeHashMap* _tmp11_;
	GeeHashMap* _tmp12_;
	WidgetsSectionPickerSectionPickerRow* _tmp13_;
	WidgetsSectionPickerSectionPickerRow* _tmp14_;
	GeeArrayList* _tmp15_;
	GeeArrayList* _tmp16_;
	gint _tmp17_;
	gint _tmp18_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (project != NULL);
	{
		GeeIterator* _row_it = NULL;
		GeeHashMap* _tmp0_;
		GeeCollection* _tmp1_;
		GeeCollection* _tmp2_;
		GeeCollection* _tmp3_;
		GeeIterator* _tmp4_;
		GeeIterator* _tmp5_;
		_tmp0_ = self->sections_map;
		_tmp1_ = gee_abstract_map_get_values ((GeeAbstractMap*) _tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = _tmp2_;
		_tmp4_ = gee_iterable_iterator ((GeeIterable*) _tmp3_);
		_tmp5_ = _tmp4_;
		_g_object_unref0 (_tmp3_);
		_row_it = _tmp5_;
		while (TRUE) {
			GeeIterator* _tmp6_;
			WidgetsSectionPickerSectionPickerRow* row = NULL;
			GeeIterator* _tmp7_;
			gpointer _tmp8_;
			GtkListBox* _tmp9_;
			WidgetsSectionPickerSectionPickerRow* _tmp10_;
			_tmp6_ = _row_it;
			if (!gee_iterator_next (_tmp6_)) {
				break;
			}
			_tmp7_ = _row_it;
			_tmp8_ = gee_iterator_get (_tmp7_);
			row = (WidgetsSectionPickerSectionPickerRow*) _tmp8_;
			_tmp9_ = self->priv->sections_listbox;
			_tmp10_ = row;
			gtk_list_box_remove (_tmp9_, (GtkWidget*) _tmp10_);
			_g_object_unref0 (row);
		}
		_g_object_unref0 (_row_it);
	}
	_tmp11_ = self->sections_map;
	gee_abstract_map_clear ((GeeAbstractMap*) _tmp11_);
	_tmp12_ = self->sections_map;
	_tmp13_ = widgets_section_picker_section_picker_row_new_for_no_section ();
	g_object_ref_sink (_tmp13_);
	_tmp14_ = _tmp13_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp12_, "no-section", _tmp14_);
	_g_object_unref0 (_tmp14_);
	_tmp15_ = objects_project_get_sections (project);
	_tmp16_ = _tmp15_;
	_tmp17_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp16_);
	_tmp18_ = _tmp17_;
	if (_tmp18_ == 0) {
		GtkListBox* _tmp19_;
		GeeHashMap* _tmp20_;
		gpointer _tmp21_;
		WidgetsSectionPickerSectionPickerRow* _tmp22_;
		_tmp19_ = self->priv->sections_listbox;
		_tmp20_ = self->sections_map;
		_tmp21_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp20_, "no-section");
		_tmp22_ = (WidgetsSectionPickerSectionPickerRow*) _tmp21_;
		gtk_list_box_append (_tmp19_, (GtkWidget*) _tmp22_);
		_g_object_unref0 (_tmp22_);
	}
	{
		GeeArrayList* _section_list = NULL;
		GeeArrayList* _tmp23_;
		GeeArrayList* _tmp24_;
		gint _section_size = 0;
		GeeArrayList* _tmp25_;
		gint _tmp26_;
		gint _tmp27_;
		gint _section_index = 0;
		_tmp23_ = objects_project_get_sections (project);
		_tmp24_ = _tmp23_;
		_section_list = _tmp24_;
		_tmp25_ = _section_list;
		_tmp26_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp25_);
		_tmp27_ = _tmp26_;
		_section_size = _tmp27_;
		_section_index = -1;
		while (TRUE) {
			gint _tmp28_;
			gint _tmp29_;
			ObjectsSection* section = NULL;
			GeeArrayList* _tmp30_;
			gpointer _tmp31_;
			ObjectsSection* _tmp32_;
			_section_index = _section_index + 1;
			_tmp28_ = _section_index;
			_tmp29_ = _section_size;
			if (!(_tmp28_ < _tmp29_)) {
				break;
			}
			_tmp30_ = _section_list;
			_tmp31_ = gee_abstract_list_get ((GeeAbstractList*) _tmp30_, _section_index);
			section = (ObjectsSection*) _tmp31_;
			_tmp32_ = section;
			if (!objects_section_was_archived (_tmp32_)) {
				GeeHashMap* _tmp33_;
				ObjectsSection* _tmp34_;
				const gchar* _tmp35_;
				const gchar* _tmp36_;
				ObjectsSection* _tmp37_;
				WidgetsSectionPickerSectionPickerRow* _tmp38_;
				WidgetsSectionPickerSectionPickerRow* _tmp39_;
				GtkListBox* _tmp40_;
				GeeHashMap* _tmp41_;
				ObjectsSection* _tmp42_;
				const gchar* _tmp43_;
				const gchar* _tmp44_;
				gpointer _tmp45_;
				WidgetsSectionPickerSectionPickerRow* _tmp46_;
				_tmp33_ = self->sections_map;
				_tmp34_ = section;
				_tmp35_ = objects_base_object_get_id ((ObjectsBaseObject*) _tmp34_);
				_tmp36_ = _tmp35_;
				_tmp37_ = section;
				_tmp38_ = widgets_section_picker_section_picker_row_new (_tmp37_);
				g_object_ref_sink (_tmp38_);
				_tmp39_ = _tmp38_;
				gee_abstract_map_set ((GeeAbstractMap*) _tmp33_, _tmp36_, _tmp39_);
				_g_object_unref0 (_tmp39_);
				_tmp40_ = self->priv->sections_listbox;
				_tmp41_ = self->sections_map;
				_tmp42_ = section;
				_tmp43_ = objects_base_object_get_id ((ObjectsBaseObject*) _tmp42_);
				_tmp44_ = _tmp43_;
				_tmp45_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp41_, _tmp44_);
				_tmp46_ = (WidgetsSectionPickerSectionPickerRow*) _tmp45_;
				gtk_list_box_append (_tmp40_, (GtkWidget*) _tmp46_);
				_g_object_unref0 (_tmp46_);
			}
			_g_object_unref0 (section);
		}
	}
}

static GtkWidget*
widgets_project_picker_project_picker_button_get_section_placeholder (WidgetsProjectPickerProjectPickerButton* self)
{
	GtkImage* add_icon = NULL;
	GtkImage* _tmp0_ = NULL;
	GtkWidget* _tmp1_;
	GtkRevealer* _tmp2_ = NULL;
	gchar* _tmp3_;
	gchar** _tmp4_;
	GtkLabel* _tmp5_ = NULL;
	AdwSpinner* spinner = NULL;
	gchar* _tmp6_;
	gchar** _tmp7_;
	AdwSpinner* _tmp8_ = NULL;
	GtkWidget* _tmp9_;
	GtkRevealer* _tmp10_ = NULL;
	GtkBox* box = NULL;
	GtkBox* _tmp11_ = NULL;
	GtkRevealer* _tmp12_;
	GtkLabel* _tmp13_;
	GtkRevealer* _tmp14_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = (GtkImage*) gtk_image_new_from_icon_name ("tab-new-symbolic");
	gtk_image_set_pixel_size (_tmp0_, 24);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp0_, 12);
	g_object_ref_sink (_tmp0_);
	add_icon = _tmp0_;
	_tmp1_ = _g_object_ref0 ((GtkWidget*) add_icon);
	_tmp2_ = (GtkRevealer*) gtk_revealer_new ();
	gtk_revealer_set_transition_type (_tmp2_, GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP);
	gtk_revealer_set_child (_tmp2_, _tmp1_);
	_g_object_unref0 (_tmp1_);
	g_object_ref_sink (_tmp2_);
	_g_object_unref0 (self->priv->add_section_revealer);
	self->priv->add_section_revealer = _tmp2_;
	_tmp3_ = g_strdup ("dimmed");
	_tmp4_ = g_new0 (gchar*, 1 + 1);
	_tmp4_[0] = _tmp3_;
	_tmp5_ = (GtkLabel*) gtk_label_new (NULL);
	gtk_label_set_wrap (_tmp5_, TRUE);
	gtk_label_set_justify (_tmp5_, GTK_JUSTIFY_CENTER);
	gtk_widget_set_css_classes ((GtkWidget*) _tmp5_, _tmp4_);
	_tmp4_ = (_vala_array_free (_tmp4_, 1, (GDestroyNotify) g_free), NULL);
	g_object_ref_sink (_tmp5_);
	_g_object_unref0 (self->priv->placeholder_message_label);
	self->priv->placeholder_message_label = _tmp5_;
	_tmp6_ = g_strdup ("text-color");
	_tmp7_ = g_new0 (gchar*, 1 + 1);
	_tmp7_[0] = _tmp6_;
	_tmp8_ = (AdwSpinner*) adw_spinner_new ();
	gtk_widget_set_valign ((GtkWidget*) _tmp8_, GTK_ALIGN_CENTER);
	gtk_widget_set_halign ((GtkWidget*) _tmp8_, GTK_ALIGN_CENTER);
	g_object_set ((GtkWidget*) _tmp8_, "height-request", 24, NULL);
	g_object_set ((GtkWidget*) _tmp8_, "width-request", 24, NULL);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp8_, 12);
	gtk_widget_set_css_classes ((GtkWidget*) _tmp8_, _tmp7_);
	_tmp7_ = (_vala_array_free (_tmp7_, 1, (GDestroyNotify) g_free), NULL);
	g_object_ref_sink (_tmp8_);
	spinner = _tmp8_;
	_tmp9_ = _g_object_ref0 ((GtkWidget*) spinner);
	_tmp10_ = (GtkRevealer*) gtk_revealer_new ();
	gtk_revealer_set_transition_type (_tmp10_, GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP);
	gtk_revealer_set_child (_tmp10_, _tmp9_);
	_g_object_unref0 (_tmp9_);
	g_object_ref_sink (_tmp10_);
	_g_object_unref0 (self->priv->spinner_revealer);
	self->priv->spinner_revealer = _tmp10_;
	_tmp11_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_widget_set_valign ((GtkWidget*) _tmp11_, GTK_ALIGN_CENTER);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp11_, 24);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp11_, 24);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp11_, 24);
	g_object_ref_sink (_tmp11_);
	box = _tmp11_;
	_tmp12_ = self->priv->add_section_revealer;
	gtk_box_append (box, (GtkWidget*) _tmp12_);
	_tmp13_ = self->priv->placeholder_message_label;
	gtk_box_append (box, (GtkWidget*) _tmp13_);
	_tmp14_ = self->priv->spinner_revealer;
	gtk_box_append (box, (GtkWidget*) _tmp14_);
	result = (GtkWidget*) box;
	_g_object_unref0 (spinner);
	_g_object_unref0 (add_icon);
	return result;
}

void
widgets_project_picker_project_picker_button_open_picker (WidgetsProjectPickerProjectPickerButton* self)
{
	GtkMenuButton* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->project_button;
	gtk_menu_button_set_active (_tmp0_, TRUE);
}

void
widgets_project_picker_project_picker_button_clean_up (WidgetsProjectPickerProjectPickerButton* self)
{
	GeeHashMap* _tmp15_;
	WidgetsProjectPickerProjectPickerPopover* _tmp16_;
	g_return_if_fail (self != NULL);
	{
		GeeIterator* _entry_it = NULL;
		GeeHashMap* _tmp0_;
		GeeSet* _tmp1_;
		GeeSet* _tmp2_;
		GeeSet* _tmp3_;
		GeeIterator* _tmp4_;
		GeeIterator* _tmp5_;
		_tmp0_ = self->priv->signal_map;
		_tmp1_ = gee_abstract_map_get_entries ((GeeAbstractMap*) _tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = _tmp2_;
		_tmp4_ = gee_iterable_iterator ((GeeIterable*) _tmp3_);
		_tmp5_ = _tmp4_;
		_g_object_unref0 (_tmp3_);
		_entry_it = _tmp5_;
		while (TRUE) {
			GeeIterator* _tmp6_;
			GeeMapEntry* entry = NULL;
			GeeIterator* _tmp7_;
			gpointer _tmp8_;
			GeeMapEntry* _tmp9_;
			gconstpointer _tmp10_;
			gconstpointer _tmp11_;
			GeeMapEntry* _tmp12_;
			gconstpointer _tmp13_;
			gconstpointer _tmp14_;
			_tmp6_ = _entry_it;
			if (!gee_iterator_next (_tmp6_)) {
				break;
			}
			_tmp7_ = _entry_it;
			_tmp8_ = gee_iterator_get (_tmp7_);
			entry = (GeeMapEntry*) _tmp8_;
			_tmp9_ = entry;
			_tmp10_ = gee_map_entry_get_value (_tmp9_);
			_tmp11_ = _tmp10_;
			_tmp12_ = entry;
			_tmp13_ = gee_map_entry_get_key (_tmp12_);
			_tmp14_ = _tmp13_;
			g_signal_handler_disconnect ((GObject*) _tmp11_, (gulong) ((guintptr) _tmp14_));
			_g_object_unref0 (entry);
		}
		_g_object_unref0 (_entry_it);
	}
	_tmp15_ = self->priv->signal_map;
	gee_abstract_map_clear ((GeeAbstractMap*) _tmp15_);
	_tmp16_ = self->priv->project_picker_popover;
	if (_tmp16_ != NULL) {
		WidgetsProjectPickerProjectPickerPopover* _tmp17_;
		_tmp17_ = self->priv->project_picker_popover;
		widgets_project_picker_project_picker_popover_clean_up (_tmp17_);
	}
}

WidgetsProjectPickerProjectPickerButton*
widgets_project_picker_project_picker_button_construct (GType object_type)
{
	WidgetsProjectPickerProjectPickerButton * self = NULL;
	self = (WidgetsProjectPickerProjectPickerButton*) g_object_new (object_type, NULL);
	return self;
}

WidgetsProjectPickerProjectPickerButton*
widgets_project_picker_project_picker_button_new (void)
{
	return widgets_project_picker_project_picker_button_construct (WIDGETS_PROJECT_PICKER_TYPE_PROJECT_PICKER_BUTTON);
}

ObjectsProject*
widgets_project_picker_project_picker_button_get_project (WidgetsProjectPickerProjectPickerButton* self)
{
	ObjectsProject* result;
	ObjectsProject* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_project;
	result = _tmp0_;
	return result;
}

void
widgets_project_picker_project_picker_button_set_project (WidgetsProjectPickerProjectPickerButton* self,
                                                          ObjectsProject* value)
{
	ObjectsProject* _tmp0_;
	ObjectsProject* _tmp1_;
	ObjectsProject* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_project);
	self->priv->_project = _tmp0_;
	widgets_project_picker_project_picker_button_update_project_request (self);
	_tmp1_ = widgets_project_picker_project_picker_button_get_project (self);
	_tmp2_ = _tmp1_;
	widgets_project_picker_project_picker_button_add_sections (self, _tmp2_);
	g_object_notify_by_pspec ((GObject *) self, widgets_project_picker_project_picker_button_properties[WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_PROJECT_PROPERTY]);
}

void
widgets_project_picker_project_picker_button_set_section (WidgetsProjectPickerProjectPickerButton* self,
                                                          ObjectsSection* value)
{
	ObjectsSection* _tmp0_;
	GtkLabel* _tmp1_;
	ObjectsSection* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_section);
	self->priv->_section = _tmp0_;
	_tmp1_ = self->priv->section_label;
	_tmp2_ = self->priv->_section;
	_tmp3_ = objects_base_object_get_name ((ObjectsBaseObject*) _tmp2_);
	_tmp4_ = _tmp3_;
	gtk_label_set_label (_tmp1_, _tmp4_);
	g_object_notify_by_pspec ((GObject *) self, widgets_project_picker_project_picker_button_properties[WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_SECTION_PROPERTY]);
}

static void
_widgets_project_picker_project_picker_button___lambda130_ (WidgetsProjectPickerProjectPickerButton* self,
                                                            ObjectsProject* _project)
{
	GtkLabel* _tmp0_;
	g_return_if_fail (_project != NULL);
	widgets_project_picker_project_picker_button_set_project (self, _project);
	widgets_project_picker_project_picker_button_update_project_request (self);
	widgets_project_picker_project_picker_button_add_sections (self, _project);
	g_signal_emit (self, widgets_project_picker_project_picker_button_signals[WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_PROJECT_CHANGE_SIGNAL], 0, _project);
	_tmp0_ = self->priv->section_label;
	gtk_label_set_label (_tmp0_, _ ("No Section"));
	g_signal_emit (self, widgets_project_picker_project_picker_button_signals[WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_SECTION_CHANGE_SIGNAL], 0, NULL);
}

static void
__widgets_project_picker_project_picker_button___lambda130__widgets_project_picker_project_picker_popover_selected (WidgetsProjectPickerProjectPickerPopover* _sender,
                                                                                                                    ObjectsProject* project,
                                                                                                                    gpointer self)
{
	_widgets_project_picker_project_picker_button___lambda130_ ((WidgetsProjectPickerProjectPickerButton*) self, project);
}

static void
_widgets_project_picker_project_picker_button___lambda131_ (WidgetsProjectPickerProjectPickerButton* self)
{
	g_signal_emit (self, widgets_project_picker_project_picker_button_signals[WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_PICKER_OPENED_SIGNAL], 0, FALSE);
}

static void
__widgets_project_picker_project_picker_button___lambda131__gtk_popover_closed (GtkPopover* _sender,
                                                                                gpointer self)
{
	_widgets_project_picker_project_picker_button___lambda131_ ((WidgetsProjectPickerProjectPickerButton*) self);
}

static void
_widgets_project_picker_project_picker_button___lambda132_ (WidgetsProjectPickerProjectPickerButton* self)
{
	ObjectsProject* _tmp0_;
	g_signal_emit (self, widgets_project_picker_project_picker_button_signals[WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_PICKER_OPENED_SIGNAL], 0, TRUE);
	_tmp0_ = self->priv->_project;
	if (_tmp0_ != NULL) {
		WidgetsProjectPickerProjectPickerPopover* _tmp1_;
		ObjectsProject* _tmp2_;
		_tmp1_ = self->priv->project_picker_popover;
		_tmp2_ = self->priv->_project;
		widgets_project_picker_project_picker_popover_set_selected_project (_tmp1_, _tmp2_);
	}
}

static void
__widgets_project_picker_project_picker_button___lambda132__gtk_widget_show (GtkWidget* _sender,
                                                                             gpointer self)
{
	_widgets_project_picker_project_picker_button___lambda132_ ((WidgetsProjectPickerProjectPickerButton*) self);
}

static void
_widgets_project_picker_project_picker_button___lambda133_ (WidgetsProjectPickerProjectPickerButton* self)
{
	g_signal_emit (self, widgets_project_picker_project_picker_button_signals[WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_PICKER_OPENED_SIGNAL], 0, FALSE);
}

static void
__widgets_project_picker_project_picker_button___lambda133__gtk_popover_closed (GtkPopover* _sender,
                                                                                gpointer self)
{
	_widgets_project_picker_project_picker_button___lambda133_ ((WidgetsProjectPickerProjectPickerButton*) self);
}

static void
_widgets_project_picker_project_picker_button___lambda134_ (WidgetsProjectPickerProjectPickerButton* self)
{
	g_signal_emit (self, widgets_project_picker_project_picker_button_signals[WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_PICKER_OPENED_SIGNAL], 0, TRUE);
}

static void
__widgets_project_picker_project_picker_button___lambda134__gtk_widget_show (GtkWidget* _sender,
                                                                             gpointer self)
{
	_widgets_project_picker_project_picker_button___lambda134_ ((WidgetsProjectPickerProjectPickerButton*) self);
}

static GObject *
widgets_project_picker_project_picker_button_constructor (GType type,
                                                          guint n_construct_properties,
                                                          GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	WidgetsProjectPickerProjectPickerButton * self;
	WidgetsIconColorProject* _tmp0_;
	GtkLabel* _tmp1_ = NULL;
	GtkBox* project_box = NULL;
	GtkBox* _tmp2_ = NULL;
	GtkBox* _tmp3_;
	WidgetsIconColorProject* _tmp4_;
	GtkBox* _tmp5_;
	GtkLabel* _tmp6_;
	WidgetsProjectPickerProjectPickerPopover* _tmp7_;
	WidgetsProjectPickerProjectPickerPopover* _tmp8_;
	GtkPopover* _tmp9_;
	GtkBox* _tmp10_;
	GtkWidget* _tmp11_;
	gchar* _tmp12_;
	gchar** _tmp13_;
	GtkMenuButton* _tmp14_ = NULL;
	GtkLabel* _tmp15_ = NULL;
	GtkPopover* _tmp16_;
	GtkLabel* arrow_label = NULL;
	GtkLabel* _tmp17_;
	GtkMenuButton* section_button = NULL;
	GtkPopover* _tmp18_;
	GtkPopover* _tmp19_;
	GtkLabel* _tmp20_;
	GtkWidget* _tmp21_;
	gchar* _tmp22_;
	gchar** _tmp23_;
	GtkMenuButton* _tmp24_ = NULL;
	GtkBox* section_box = NULL;
	GtkBox* _tmp25_;
	GtkBox* _tmp26_;
	GtkLabel* _tmp27_;
	GtkBox* _tmp28_;
	GtkMenuButton* _tmp29_;
	GtkBox* _tmp30_;
	GtkWidget* _tmp31_;
	GtkRevealer* _tmp32_ = NULL;
	GtkBox* box = NULL;
	GtkBox* _tmp33_;
	GtkBox* _tmp34_;
	GtkMenuButton* _tmp35_;
	GtkBox* _tmp36_;
	GtkRevealer* _tmp37_;
	GtkBox* _tmp38_;
	GeeHashMap* _tmp39_;
	WidgetsProjectPickerProjectPickerPopover* _tmp40_;
	gulong _tmp41_;
	WidgetsProjectPickerProjectPickerPopover* _tmp42_;
	GeeHashMap* _tmp43_;
	WidgetsProjectPickerProjectPickerPopover* _tmp44_;
	gulong _tmp45_;
	WidgetsProjectPickerProjectPickerPopover* _tmp46_;
	GeeHashMap* _tmp47_;
	WidgetsProjectPickerProjectPickerPopover* _tmp48_;
	gulong _tmp49_;
	WidgetsProjectPickerProjectPickerPopover* _tmp50_;
	GeeHashMap* _tmp51_;
	GtkPopover* _tmp52_;
	gulong _tmp53_;
	GtkPopover* _tmp54_;
	GeeHashMap* _tmp55_;
	GtkPopover* _tmp56_;
	gulong _tmp57_;
	GtkPopover* _tmp58_;
	parent_class = G_OBJECT_CLASS (widgets_project_picker_project_picker_button_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIDGETS_PROJECT_PICKER_TYPE_PROJECT_PICKER_BUTTON, WidgetsProjectPickerProjectPickerButton);
	_tmp0_ = widgets_icon_color_project_new (18);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->icon_project);
	self->priv->icon_project = _tmp0_;
	_tmp1_ = (GtkLabel*) gtk_label_new (NULL);
	gtk_widget_set_valign ((GtkWidget*) _tmp1_, GTK_ALIGN_CENTER);
	gtk_label_set_ellipsize (_tmp1_, PANGO_ELLIPSIZE_END);
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->priv->name_label);
	self->priv->name_label = _tmp1_;
	_tmp2_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	gtk_widget_set_valign ((GtkWidget*) _tmp2_, GTK_ALIGN_CENTER);
	g_object_ref_sink (_tmp2_);
	project_box = _tmp2_;
	_tmp3_ = project_box;
	_tmp4_ = self->priv->icon_project;
	gtk_box_append (_tmp3_, (GtkWidget*) _tmp4_);
	_tmp5_ = project_box;
	_tmp6_ = self->priv->name_label;
	gtk_box_append (_tmp5_, (GtkWidget*) _tmp6_);
	_tmp7_ = widgets_project_picker_project_picker_popover_new ();
	g_object_ref_sink (_tmp7_);
	_g_object_unref0 (self->priv->project_picker_popover);
	self->priv->project_picker_popover = _tmp7_;
	_tmp8_ = self->priv->project_picker_popover;
	_tmp9_ = _g_object_ref0 ((GtkPopover*) _tmp8_);
	_tmp10_ = project_box;
	_tmp11_ = _g_object_ref0 ((GtkWidget*) _tmp10_);
	_tmp12_ = g_strdup ("flat");
	_tmp13_ = g_new0 (gchar*, 1 + 1);
	_tmp13_[0] = _tmp12_;
	_tmp14_ = (GtkMenuButton*) gtk_menu_button_new ();
	gtk_menu_button_set_popover (_tmp14_, _tmp9_);
	_g_object_unref0 (_tmp9_);
	gtk_menu_button_set_child (_tmp14_, _tmp11_);
	_g_object_unref0 (_tmp11_);
	gtk_widget_set_css_classes ((GtkWidget*) _tmp14_, _tmp13_);
	_tmp13_ = (_vala_array_free (_tmp13_, 1, (GDestroyNotify) g_free), NULL);
	g_object_ref_sink (_tmp14_);
	_g_object_unref0 (self->priv->project_button);
	self->priv->project_button = _tmp14_;
	_tmp15_ = (GtkLabel*) gtk_label_new (_ ("No Section"));
	gtk_widget_set_valign ((GtkWidget*) _tmp15_, GTK_ALIGN_CENTER);
	gtk_label_set_ellipsize (_tmp15_, PANGO_ELLIPSIZE_END);
	gtk_label_set_max_width_chars (_tmp15_, 16);
	g_object_ref_sink (_tmp15_);
	_g_object_unref0 (self->priv->section_label);
	self->priv->section_label = _tmp15_;
	_tmp16_ = widgets_project_picker_project_picker_button_build_sections_popover (self);
	_g_object_unref0 (self->priv->sections_popover);
	self->priv->sections_popover = _tmp16_;
	_tmp17_ = (GtkLabel*) gtk_label_new ("→");
	g_object_ref_sink (_tmp17_);
	arrow_label = _tmp17_;
	_tmp18_ = self->priv->sections_popover;
	_tmp19_ = _g_object_ref0 (_tmp18_);
	_tmp20_ = self->priv->section_label;
	_tmp21_ = _g_object_ref0 ((GtkWidget*) _tmp20_);
	_tmp22_ = g_strdup ("flat");
	_tmp23_ = g_new0 (gchar*, 1 + 1);
	_tmp23_[0] = _tmp22_;
	_tmp24_ = (GtkMenuButton*) gtk_menu_button_new ();
	gtk_menu_button_set_popover (_tmp24_, _tmp19_);
	_g_object_unref0 (_tmp19_);
	gtk_menu_button_set_child (_tmp24_, _tmp21_);
	_g_object_unref0 (_tmp21_);
	gtk_widget_set_css_classes ((GtkWidget*) _tmp24_, _tmp23_);
	_tmp23_ = (_vala_array_free (_tmp23_, 1, (GDestroyNotify) g_free), NULL);
	g_object_ref_sink (_tmp24_);
	section_button = _tmp24_;
	_tmp25_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	g_object_ref_sink (_tmp25_);
	section_box = _tmp25_;
	_tmp26_ = section_box;
	_tmp27_ = arrow_label;
	gtk_box_append (_tmp26_, (GtkWidget*) _tmp27_);
	_tmp28_ = section_box;
	_tmp29_ = section_button;
	gtk_box_append (_tmp28_, (GtkWidget*) _tmp29_);
	_tmp30_ = section_box;
	_tmp31_ = _g_object_ref0 ((GtkWidget*) _tmp30_);
	_tmp32_ = (GtkRevealer*) gtk_revealer_new ();
	gtk_revealer_set_transition_type (_tmp32_, GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT);
	gtk_revealer_set_reveal_child (_tmp32_, TRUE);
	gtk_revealer_set_child (_tmp32_, _tmp31_);
	_g_object_unref0 (_tmp31_);
	g_object_ref_sink (_tmp32_);
	_g_object_unref0 (self->priv->section_box_revealer);
	self->priv->section_box_revealer = _tmp32_;
	_tmp33_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	g_object_ref_sink (_tmp33_);
	box = _tmp33_;
	_tmp34_ = box;
	_tmp35_ = self->priv->project_button;
	gtk_box_append (_tmp34_, (GtkWidget*) _tmp35_);
	_tmp36_ = box;
	_tmp37_ = self->priv->section_box_revealer;
	gtk_box_append (_tmp36_, (GtkWidget*) _tmp37_);
	_tmp38_ = box;
	adw_bin_set_child ((AdwBin*) self, (GtkWidget*) _tmp38_);
	_tmp39_ = self->priv->signal_map;
	_tmp40_ = self->priv->project_picker_popover;
	_tmp41_ = g_signal_connect_object (_tmp40_, "selected", (GCallback) __widgets_project_picker_project_picker_button___lambda130__widgets_project_picker_project_picker_popover_selected, self, 0);
	_tmp42_ = self->priv->project_picker_popover;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp39_, (gpointer) ((guintptr) _tmp41_), (GObject*) _tmp42_);
	_tmp43_ = self->priv->signal_map;
	_tmp44_ = self->priv->project_picker_popover;
	_tmp45_ = g_signal_connect_object ((GtkPopover*) _tmp44_, "closed", (GCallback) __widgets_project_picker_project_picker_button___lambda131__gtk_popover_closed, self, 0);
	_tmp46_ = self->priv->project_picker_popover;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp43_, (gpointer) ((guintptr) _tmp45_), (GObject*) _tmp46_);
	_tmp47_ = self->priv->signal_map;
	_tmp48_ = self->priv->project_picker_popover;
	_tmp49_ = g_signal_connect_object ((GtkWidget*) _tmp48_, "show", (GCallback) __widgets_project_picker_project_picker_button___lambda132__gtk_widget_show, self, 0);
	_tmp50_ = self->priv->project_picker_popover;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp47_, (gpointer) ((guintptr) _tmp49_), (GObject*) _tmp50_);
	_tmp51_ = self->priv->signal_map;
	_tmp52_ = self->priv->sections_popover;
	_tmp53_ = g_signal_connect_object (_tmp52_, "closed", (GCallback) __widgets_project_picker_project_picker_button___lambda133__gtk_popover_closed, self, 0);
	_tmp54_ = self->priv->sections_popover;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp51_, (gpointer) ((guintptr) _tmp53_), (GObject*) _tmp54_);
	_tmp55_ = self->priv->signal_map;
	_tmp56_ = self->priv->sections_popover;
	_tmp57_ = g_signal_connect_object ((GtkWidget*) _tmp56_, "show", (GCallback) __widgets_project_picker_project_picker_button___lambda134__gtk_widget_show, self, 0);
	_tmp58_ = self->priv->sections_popover;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp55_, (gpointer) ((guintptr) _tmp57_), (GObject*) _tmp58_);
	_g_object_unref0 (box);
	_g_object_unref0 (section_box);
	_g_object_unref0 (section_button);
	_g_object_unref0 (arrow_label);
	_g_object_unref0 (project_box);
	return obj;
}

static void
widgets_project_picker_project_picker_button_class_init (WidgetsProjectPickerProjectPickerButtonClass * klass,
                                                         gpointer klass_data)
{
	widgets_project_picker_project_picker_button_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &WidgetsProjectPickerProjectPickerButton_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_widgets_project_picker_project_picker_button_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_widgets_project_picker_project_picker_button_set_property;
	G_OBJECT_CLASS (klass)->constructor = widgets_project_picker_project_picker_button_constructor;
	G_OBJECT_CLASS (klass)->finalize = widgets_project_picker_project_picker_button_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_PROJECT_PROPERTY, widgets_project_picker_project_picker_button_properties[WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_PROJECT_PROPERTY] = g_param_spec_object ("project", "project", "project", OBJECTS_TYPE_PROJECT, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_SECTION_PROPERTY, widgets_project_picker_project_picker_button_properties[WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_SECTION_PROPERTY] = g_param_spec_object ("section", "section", "section", OBJECTS_TYPE_SECTION, G_PARAM_STATIC_STRINGS | G_PARAM_WRITABLE));
	widgets_project_picker_project_picker_button_signals[WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_PROJECT_CHANGE_SIGNAL] = g_signal_new ("project-change", WIDGETS_PROJECT_PICKER_TYPE_PROJECT_PICKER_BUTTON, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, OBJECTS_TYPE_PROJECT);
	widgets_project_picker_project_picker_button_signals[WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_SECTION_CHANGE_SIGNAL] = g_signal_new ("section-change", WIDGETS_PROJECT_PICKER_TYPE_PROJECT_PICKER_BUTTON, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, OBJECTS_TYPE_SECTION);
	widgets_project_picker_project_picker_button_signals[WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_PICKER_OPENED_SIGNAL] = g_signal_new ("picker-opened", WIDGETS_PROJECT_PICKER_TYPE_PROJECT_PICKER_BUTTON, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
}

static void
widgets_project_picker_project_picker_button_instance_init (WidgetsProjectPickerProjectPickerButton * self,
                                                            gpointer klass)
{
	GeeHashMap* _tmp0_;
	GeeHashMap* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	self->priv = widgets_project_picker_project_picker_button_get_instance_private (self);
	_tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, WIDGETS_SECTION_PICKER_TYPE_SECTION_PICKER_ROW, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	self->sections_map = _tmp0_;
	_tmp1_ = gee_hash_map_new (G_TYPE_ULONG, NULL, NULL, G_TYPE_OBJECT, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	self->priv->signal_map = _tmp1_;
	_tmp2_ = g_strdup (_ ("Your list of section will show up here."));
	self->priv->PLACEHOLDER_MESSAGE = _tmp2_;
	_tmp3_ = g_strdup (_ ("Create '%s'"));
	self->priv->PLACEHOLDER_CREATE_MESSAGE = _tmp3_;
}

static void
widgets_project_picker_project_picker_button_finalize (GObject * obj)
{
	WidgetsProjectPickerProjectPickerButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIDGETS_PROJECT_PICKER_TYPE_PROJECT_PICKER_BUTTON, WidgetsProjectPickerProjectPickerButton);
	g_debug ("ProjectPickerButton.vala:67: Destroying - Widgets.ProjectPicker.Projec" \
"tPickerButton\n");
	_g_object_unref0 (self->priv->_project);
	_g_object_unref0 (self->priv->_section);
	_g_object_unref0 (self->priv->icon_project);
	_g_object_unref0 (self->priv->name_label);
	_g_object_unref0 (self->priv->section_label);
	_g_object_unref0 (self->priv->sections_popover);
	_g_object_unref0 (self->priv->section_box_revealer);
	_g_object_unref0 (self->priv->project_button);
	_g_object_unref0 (self->priv->project_picker_popover);
	_g_object_unref0 (self->priv->sections_listbox);
	_g_object_unref0 (self->priv->add_section_revealer);
	_g_object_unref0 (self->priv->placeholder_message_label);
	_g_object_unref0 (self->priv->spinner_revealer);
	_g_object_unref0 (self->sections_map);
	_g_object_unref0 (self->priv->signal_map);
	_g_free0 (self->priv->PLACEHOLDER_MESSAGE);
	_g_free0 (self->priv->PLACEHOLDER_CREATE_MESSAGE);
	G_OBJECT_CLASS (widgets_project_picker_project_picker_button_parent_class)->finalize (obj);
}

static GType
widgets_project_picker_project_picker_button_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (WidgetsProjectPickerProjectPickerButtonClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) widgets_project_picker_project_picker_button_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WidgetsProjectPickerProjectPickerButton), 0, (GInstanceInitFunc) widgets_project_picker_project_picker_button_instance_init, NULL };
	GType widgets_project_picker_project_picker_button_type_id;
	widgets_project_picker_project_picker_button_type_id = g_type_register_static (adw_bin_get_type (), "WidgetsProjectPickerProjectPickerButton", &g_define_type_info, 0);
	WidgetsProjectPickerProjectPickerButton_private_offset = g_type_add_instance_private (widgets_project_picker_project_picker_button_type_id, sizeof (WidgetsProjectPickerProjectPickerButtonPrivate));
	return widgets_project_picker_project_picker_button_type_id;
}

GType
widgets_project_picker_project_picker_button_get_type (void)
{
	static volatile gsize widgets_project_picker_project_picker_button_type_id__once = 0;
	if (g_once_init_enter (&widgets_project_picker_project_picker_button_type_id__once)) {
		GType widgets_project_picker_project_picker_button_type_id;
		widgets_project_picker_project_picker_button_type_id = widgets_project_picker_project_picker_button_get_type_once ();
		g_once_init_leave (&widgets_project_picker_project_picker_button_type_id__once, widgets_project_picker_project_picker_button_type_id);
	}
	return widgets_project_picker_project_picker_button_type_id__once;
}

static void
_vala_widgets_project_picker_project_picker_button_get_property (GObject * object,
                                                                 guint property_id,
                                                                 GValue * value,
                                                                 GParamSpec * pspec)
{
	WidgetsProjectPickerProjectPickerButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, WIDGETS_PROJECT_PICKER_TYPE_PROJECT_PICKER_BUTTON, WidgetsProjectPickerProjectPickerButton);
	switch (property_id) {
		case WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_PROJECT_PROPERTY:
		g_value_set_object (value, widgets_project_picker_project_picker_button_get_project (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_widgets_project_picker_project_picker_button_set_property (GObject * object,
                                                                 guint property_id,
                                                                 const GValue * value,
                                                                 GParamSpec * pspec)
{
	WidgetsProjectPickerProjectPickerButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, WIDGETS_PROJECT_PICKER_TYPE_PROJECT_PICKER_BUTTON, WidgetsProjectPickerProjectPickerButton);
	switch (property_id) {
		case WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_PROJECT_PROPERTY:
		widgets_project_picker_project_picker_button_set_project (self, g_value_get_object (value));
		break;
		case WIDGETS_PROJECT_PICKER_PROJECT_PICKER_BUTTON_SECTION_PROPERTY:
		widgets_project_picker_project_picker_button_set_section (self, g_value_get_object (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 inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

