/* LabelButton.c generated by valac 0.56.19, the Vala compiler
 * generated from LabelButton.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 <glib.h>
#include <gtk/gtk.h>
#include <gee.h>
#include <glib-object.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include <pango/pango.h>
#include <adwaita.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_LABEL_PICKER_LABEL_BUTTON_0_PROPERTY,
	WIDGETS_LABEL_PICKER_LABEL_BUTTON_IS_BOARD_PROPERTY,
	WIDGETS_LABEL_PICKER_LABEL_BUTTON_LABELS_PROPERTY,
	WIDGETS_LABEL_PICKER_LABEL_BUTTON_SOURCE_PROPERTY,
	WIDGETS_LABEL_PICKER_LABEL_BUTTON_NUM_PROPERTIES
};
static GParamSpec* widgets_label_picker_label_button_properties[WIDGETS_LABEL_PICKER_LABEL_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))
enum  {
	WIDGETS_LABEL_PICKER_LABEL_BUTTON_LABELS_CHANGED_SIGNAL,
	WIDGETS_LABEL_PICKER_LABEL_BUTTON_PICKER_OPENED_SIGNAL,
	WIDGETS_LABEL_PICKER_LABEL_BUTTON_NUM_SIGNALS
};
static guint widgets_label_picker_label_button_signals[WIDGETS_LABEL_PICKER_LABEL_BUTTON_NUM_SIGNALS] = {0};

struct _WidgetsLabelPickerLabelButtonPrivate {
	gboolean _is_board;
	GtkMenuButton* button;
	WidgetsLabelPickerLabelPicker* labels_picker;
	GtkLabel* labels_label;
	ObjectsSource* _source;
	GeeHashMap* signal_map;
};

static gint WidgetsLabelPickerLabelButton_private_offset;
static gpointer widgets_label_picker_label_button_parent_class = NULL;

static GObject * widgets_label_picker_label_button_constructor (GType type,
                                                         guint n_construct_properties,
                                                         GObjectConstructParam * construct_properties);
static void _widgets_label_picker_label_button___lambda271_ (WidgetsLabelPickerLabelButton* self);
static void __widgets_label_picker_label_button___lambda271__gtk_popover_closed (GtkPopover* _sender,
                                                                          gpointer self);
static void _widgets_label_picker_label_button___lambda272_ (WidgetsLabelPickerLabelButton* self);
static void __widgets_label_picker_label_button___lambda272__gtk_widget_show (GtkWidget* _sender,
                                                                       gpointer self);
static void widgets_label_picker_label_button_finalize (GObject * obj);
static GType widgets_label_picker_label_button_get_type_once (void);
static void _vala_widgets_label_picker_label_button_get_property (GObject * object,
                                                           guint property_id,
                                                           GValue * value,
                                                           GParamSpec * pspec);
static void _vala_widgets_label_picker_label_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_label_picker_label_button_get_instance_private (WidgetsLabelPickerLabelButton* self)
{
	return G_STRUCT_MEMBER_P (self, WidgetsLabelPickerLabelButton_private_offset);
}

WidgetsLabelPickerLabelButton*
widgets_label_picker_label_button_construct (GType object_type)
{
	WidgetsLabelPickerLabelButton * self = NULL;
	self = (WidgetsLabelPickerLabelButton*) g_object_new (object_type, "is-board", FALSE, "valign", GTK_ALIGN_CENTER, "halign", GTK_ALIGN_CENTER, "tooltip-text", _ ("Add Labels"), NULL);
	return self;
}

WidgetsLabelPickerLabelButton*
widgets_label_picker_label_button_new (void)
{
	return widgets_label_picker_label_button_construct (WIDGETS_LABEL_PICKER_TYPE_LABEL_BUTTON);
}

WidgetsLabelPickerLabelButton*
widgets_label_picker_label_button_construct_for_board (GType object_type)
{
	WidgetsLabelPickerLabelButton * self = NULL;
	self = (WidgetsLabelPickerLabelButton*) g_object_new (object_type, "is-board", TRUE, "tooltip-text", _ ("Add Labels"), NULL);
	return self;
}

WidgetsLabelPickerLabelButton*
widgets_label_picker_label_button_new_for_board (void)
{
	return widgets_label_picker_label_button_construct_for_board (WIDGETS_LABEL_PICKER_TYPE_LABEL_BUTTON);
}

void
widgets_label_picker_label_button_reset (WidgetsLabelPickerLabelButton* self)
{
	WidgetsLabelPickerLabelPicker* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->labels_picker;
	widgets_label_picker_label_picker_reset (_tmp0_);
}

void
widgets_label_picker_label_button_update_tooltip_from_item (WidgetsLabelPickerLabelButton* self,
                                                            ObjectsItem* item)
{
	GtkLabel* _tmp0_;
	GtkLabel* _tmp1_;
	GeeArrayList* _tmp2_;
	GeeArrayList* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (item != NULL);
	_tmp0_ = self->priv->labels_label;
	gtk_label_set_label (_tmp0_, _ ("Select Labels"));
	_tmp1_ = self->priv->labels_label;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp1_, NULL);
	_tmp2_ = objects_item_get_labels (item);
	_tmp3_ = _tmp2_;
	_tmp4_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp3_);
	_tmp5_ = _tmp4_;
	if (_tmp5_ > 0) {
		GtkLabel* _tmp6_;
		GtkLabel* _tmp43_;
		GtkLabel* _tmp44_;
		const gchar* _tmp45_;
		const gchar* _tmp46_;
		_tmp6_ = self->priv->labels_label;
		gtk_label_set_label (_tmp6_, "");
		{
			gint index = 0;
			index = 0;
			{
				gboolean _tmp7_ = FALSE;
				_tmp7_ = TRUE;
				while (TRUE) {
					GeeArrayList* _tmp9_;
					GeeArrayList* _tmp10_;
					gint _tmp11_;
					gint _tmp12_;
					GeeArrayList* _tmp13_;
					GeeArrayList* _tmp14_;
					gint _tmp15_;
					gint _tmp16_;
					if (!_tmp7_) {
						gint _tmp8_;
						_tmp8_ = index;
						index = _tmp8_ + 1;
					}
					_tmp7_ = FALSE;
					_tmp9_ = objects_item_get_labels (item);
					_tmp10_ = _tmp9_;
					_tmp11_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp10_);
					_tmp12_ = _tmp11_;
					if (!(index < _tmp12_)) {
						break;
					}
					_tmp13_ = objects_item_get_labels (item);
					_tmp14_ = _tmp13_;
					_tmp15_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp14_);
					_tmp16_ = _tmp15_;
					if (index < (_tmp16_ - 1)) {
						GtkLabel* _tmp17_;
						GtkLabel* _tmp18_;
						const gchar* _tmp19_;
						const gchar* _tmp20_;
						GeeArrayList* _tmp21_;
						GeeArrayList* _tmp22_;
						gpointer _tmp23_;
						ObjectsLabel* _tmp24_;
						const gchar* _tmp25_;
						const gchar* _tmp26_;
						gchar* _tmp27_;
						gchar* _tmp28_;
						gchar* _tmp29_;
						gchar* _tmp30_;
						_tmp17_ = self->priv->labels_label;
						_tmp18_ = self->priv->labels_label;
						_tmp19_ = gtk_label_get_label (_tmp18_);
						_tmp20_ = _tmp19_;
						_tmp21_ = objects_item_get_labels (item);
						_tmp22_ = _tmp21_;
						_tmp23_ = gee_abstract_list_get ((GeeAbstractList*) _tmp22_, index);
						_tmp24_ = (ObjectsLabel*) _tmp23_;
						_tmp25_ = objects_base_object_get_name ((ObjectsBaseObject*) _tmp24_);
						_tmp26_ = _tmp25_;
						_tmp27_ = g_strconcat (_tmp26_, ", ", NULL);
						_tmp28_ = _tmp27_;
						_tmp29_ = g_strconcat (_tmp20_, _tmp28_, NULL);
						_tmp30_ = _tmp29_;
						gtk_label_set_label (_tmp18_, _tmp30_);
						_g_free0 (_tmp30_);
						_g_free0 (_tmp28_);
						_g_object_unref0 (_tmp24_);
					} else {
						GtkLabel* _tmp31_;
						GtkLabel* _tmp32_;
						const gchar* _tmp33_;
						const gchar* _tmp34_;
						GeeArrayList* _tmp35_;
						GeeArrayList* _tmp36_;
						gpointer _tmp37_;
						ObjectsLabel* _tmp38_;
						const gchar* _tmp39_;
						const gchar* _tmp40_;
						gchar* _tmp41_;
						gchar* _tmp42_;
						_tmp31_ = self->priv->labels_label;
						_tmp32_ = self->priv->labels_label;
						_tmp33_ = gtk_label_get_label (_tmp32_);
						_tmp34_ = _tmp33_;
						_tmp35_ = objects_item_get_labels (item);
						_tmp36_ = _tmp35_;
						_tmp37_ = gee_abstract_list_get ((GeeAbstractList*) _tmp36_, index);
						_tmp38_ = (ObjectsLabel*) _tmp37_;
						_tmp39_ = objects_base_object_get_name ((ObjectsBaseObject*) _tmp38_);
						_tmp40_ = _tmp39_;
						_tmp41_ = g_strconcat (_tmp34_, _tmp40_, NULL);
						_tmp42_ = _tmp41_;
						gtk_label_set_label (_tmp32_, _tmp42_);
						_g_free0 (_tmp42_);
						_g_object_unref0 (_tmp38_);
					}
				}
			}
		}
		_tmp43_ = self->priv->labels_label;
		_tmp44_ = self->priv->labels_label;
		_tmp45_ = gtk_label_get_label (_tmp44_);
		_tmp46_ = _tmp45_;
		gtk_widget_set_tooltip_text ((GtkWidget*) _tmp43_, _tmp46_);
	}
}

void
widgets_label_picker_label_button_open_picker (WidgetsLabelPickerLabelButton* self)
{
	GtkMenuButton* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->button;
	gtk_menu_button_set_active (_tmp0_, TRUE);
}

void
widgets_label_picker_label_button_clean_up (WidgetsLabelPickerLabelButton* self)
{
	GeeHashMap* _tmp15_;
	WidgetsLabelPickerLabelPicker* _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->labels_picker;
	widgets_label_picker_label_picker_clean_up (_tmp16_);
}

gboolean
widgets_label_picker_label_button_get_is_board (WidgetsLabelPickerLabelButton* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_is_board;
	return result;
}

static void
widgets_label_picker_label_button_set_is_board (WidgetsLabelPickerLabelButton* self,
                                                gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = widgets_label_picker_label_button_get_is_board (self);
	if (old_value != value) {
		self->priv->_is_board = value;
		g_object_notify_by_pspec ((GObject *) self, widgets_label_picker_label_button_properties[WIDGETS_LABEL_PICKER_LABEL_BUTTON_IS_BOARD_PROPERTY]);
	}
}

void
widgets_label_picker_label_button_set_labels (WidgetsLabelPickerLabelButton* self,
                                              GeeArrayList* value)
{
	WidgetsLabelPickerLabelPicker* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->labels_picker;
	widgets_label_picker_label_picker_set_labels (_tmp0_, value);
	g_object_notify_by_pspec ((GObject *) self, widgets_label_picker_label_button_properties[WIDGETS_LABEL_PICKER_LABEL_BUTTON_LABELS_PROPERTY]);
}

ObjectsSource*
widgets_label_picker_label_button_get_source (WidgetsLabelPickerLabelButton* self)
{
	ObjectsSource* result;
	ObjectsSource* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_source;
	result = _tmp0_;
	return result;
}

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

void
widgets_label_picker_label_button_set_source (WidgetsLabelPickerLabelButton* self,
                                              ObjectsSource* value)
{
	ObjectsSource* _tmp0_;
	WidgetsLabelPickerLabelPicker* _tmp1_;
	ObjectsSource* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_source);
	self->priv->_source = _tmp0_;
	_tmp1_ = self->priv->labels_picker;
	_tmp2_ = self->priv->_source;
	widgets_label_picker_label_picker_set_source (_tmp1_, _tmp2_);
	g_object_notify_by_pspec ((GObject *) self, widgets_label_picker_label_button_properties[WIDGETS_LABEL_PICKER_LABEL_BUTTON_SOURCE_PROPERTY]);
}

static void
_widgets_label_picker_label_button___lambda271_ (WidgetsLabelPickerLabelButton* self)
{
	WidgetsLabelPickerLabelPicker* _tmp0_;
	GeeHashMap* _tmp1_;
	GeeHashMap* _tmp2_;
	_tmp0_ = self->priv->labels_picker;
	_tmp1_ = widgets_label_picker_label_picker_get_picked (_tmp0_);
	_tmp2_ = _tmp1_;
	g_signal_emit (self, widgets_label_picker_label_button_signals[WIDGETS_LABEL_PICKER_LABEL_BUTTON_LABELS_CHANGED_SIGNAL], 0, _tmp2_);
	g_signal_emit (self, widgets_label_picker_label_button_signals[WIDGETS_LABEL_PICKER_LABEL_BUTTON_PICKER_OPENED_SIGNAL], 0, FALSE);
}

static void
__widgets_label_picker_label_button___lambda271__gtk_popover_closed (GtkPopover* _sender,
                                                                     gpointer self)
{
	_widgets_label_picker_label_button___lambda271_ ((WidgetsLabelPickerLabelButton*) self);
}

static void
_widgets_label_picker_label_button___lambda272_ (WidgetsLabelPickerLabelButton* self)
{
	g_signal_emit (self, widgets_label_picker_label_button_signals[WIDGETS_LABEL_PICKER_LABEL_BUTTON_PICKER_OPENED_SIGNAL], 0, TRUE);
}

static void
__widgets_label_picker_label_button___lambda272__gtk_widget_show (GtkWidget* _sender,
                                                                  gpointer self)
{
	_widgets_label_picker_label_button___lambda272_ ((WidgetsLabelPickerLabelButton*) self);
}

static GObject *
widgets_label_picker_label_button_constructor (GType type,
                                               guint n_construct_properties,
                                               GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	WidgetsLabelPickerLabelButton * self;
	WidgetsLabelPickerLabelPicker* _tmp0_;
	gboolean _tmp1_;
	GeeHashMap* _tmp36_;
	WidgetsLabelPickerLabelPicker* _tmp37_;
	gulong _tmp38_;
	WidgetsLabelPickerLabelPicker* _tmp39_;
	GeeHashMap* _tmp40_;
	WidgetsLabelPickerLabelPicker* _tmp41_;
	gulong _tmp42_;
	WidgetsLabelPickerLabelPicker* _tmp43_;
	parent_class = G_OBJECT_CLASS (widgets_label_picker_label_button_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIDGETS_LABEL_PICKER_TYPE_LABEL_BUTTON, WidgetsLabelPickerLabelButton);
	_tmp0_ = widgets_label_picker_label_picker_new ();
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->labels_picker);
	self->priv->labels_picker = _tmp0_;
	_tmp1_ = self->priv->_is_board;
	if (_tmp1_) {
		GtkLabel* title_label = NULL;
		gchar* _tmp2_;
		gchar* _tmp3_;
		gchar* _tmp4_;
		gchar** _tmp5_;
		GtkLabel* _tmp6_ = NULL;
		gchar* _tmp7_;
		gchar** _tmp8_;
		GtkLabel* _tmp9_ = NULL;
		GtkGrid* card_grid = NULL;
		GtkGrid* _tmp10_ = NULL;
		GtkGrid* _tmp11_;
		GtkImage* _tmp12_;
		GtkImage* _tmp13_;
		GtkGrid* _tmp14_;
		GtkLabel* _tmp15_;
		GtkGrid* _tmp16_;
		GtkLabel* _tmp17_;
		WidgetsLabelPickerLabelPicker* _tmp18_;
		GtkPopover* _tmp19_;
		GtkGrid* _tmp20_;
		GtkWidget* _tmp21_;
		gchar* _tmp22_;
		gchar* _tmp23_;
		gchar* _tmp24_;
		gchar* _tmp25_;
		gchar** _tmp26_;
		GtkMenuButton* _tmp27_ = NULL;
		GtkMenuButton* _tmp28_;
		_tmp2_ = g_strdup ("title-4");
		_tmp3_ = g_strdup ("caption");
		_tmp4_ = g_strdup ("font-bold");
		_tmp5_ = g_new0 (gchar*, 3 + 1);
		_tmp5_[0] = _tmp2_;
		_tmp5_[1] = _tmp3_;
		_tmp5_[2] = _tmp4_;
		_tmp6_ = (GtkLabel*) gtk_label_new (_ ("Labels"));
		gtk_widget_set_halign ((GtkWidget*) _tmp6_, GTK_ALIGN_START);
		gtk_widget_set_css_classes ((GtkWidget*) _tmp6_, _tmp5_);
		_tmp5_ = (_vala_array_free (_tmp5_, 3, (GDestroyNotify) g_free), NULL);
		g_object_ref_sink (_tmp6_);
		title_label = _tmp6_;
		_tmp7_ = g_strdup ("caption");
		_tmp8_ = g_new0 (gchar*, 1 + 1);
		_tmp8_[0] = _tmp7_;
		_tmp9_ = (GtkLabel*) gtk_label_new (_ ("Select Labels"));
		gtk_label_set_xalign (_tmp9_, (gfloat) 0);
		gtk_label_set_use_markup (_tmp9_, TRUE);
		gtk_widget_set_halign ((GtkWidget*) _tmp9_, GTK_ALIGN_START);
		gtk_label_set_ellipsize (_tmp9_, PANGO_ELLIPSIZE_END);
		gtk_widget_set_css_classes ((GtkWidget*) _tmp9_, _tmp8_);
		_tmp8_ = (_vala_array_free (_tmp8_, 1, (GDestroyNotify) g_free), NULL);
		g_object_ref_sink (_tmp9_);
		_g_object_unref0 (self->priv->labels_label);
		self->priv->labels_label = _tmp9_;
		_tmp10_ = (GtkGrid*) gtk_grid_new ();
		gtk_grid_set_column_spacing (_tmp10_, 12);
		gtk_widget_set_margin_start ((GtkWidget*) _tmp10_, 12);
		gtk_widget_set_margin_end ((GtkWidget*) _tmp10_, 6);
		gtk_widget_set_margin_top ((GtkWidget*) _tmp10_, 6);
		gtk_widget_set_margin_bottom ((GtkWidget*) _tmp10_, 6);
		gtk_widget_set_vexpand ((GtkWidget*) _tmp10_, TRUE);
		gtk_widget_set_hexpand ((GtkWidget*) _tmp10_, TRUE);
		g_object_ref_sink (_tmp10_);
		card_grid = _tmp10_;
		_tmp11_ = card_grid;
		_tmp12_ = (GtkImage*) gtk_image_new_from_icon_name ("tag-outline-symbolic");
		g_object_ref_sink (_tmp12_);
		_tmp13_ = _tmp12_;
		gtk_grid_attach (_tmp11_, (GtkWidget*) _tmp13_, 0, 0, 1, 2);
		_g_object_unref0 (_tmp13_);
		_tmp14_ = card_grid;
		_tmp15_ = title_label;
		gtk_grid_attach (_tmp14_, (GtkWidget*) _tmp15_, 1, 0, 1, 1);
		_tmp16_ = card_grid;
		_tmp17_ = self->priv->labels_label;
		gtk_grid_attach (_tmp16_, (GtkWidget*) _tmp17_, 1, 1, 1, 1);
		_tmp18_ = self->priv->labels_picker;
		_tmp19_ = _g_object_ref0 ((GtkPopover*) _tmp18_);
		_tmp20_ = card_grid;
		_tmp21_ = _g_object_ref0 ((GtkWidget*) _tmp20_);
		_tmp22_ = g_strdup ("flat");
		_tmp23_ = g_strdup ("card");
		_tmp24_ = g_strdup ("activatable");
		_tmp25_ = g_strdup ("menu-button-no-padding");
		_tmp26_ = g_new0 (gchar*, 4 + 1);
		_tmp26_[0] = _tmp22_;
		_tmp26_[1] = _tmp23_;
		_tmp26_[2] = _tmp24_;
		_tmp26_[3] = _tmp25_;
		_tmp27_ = (GtkMenuButton*) gtk_menu_button_new ();
		gtk_menu_button_set_popover (_tmp27_, _tmp19_);
		_g_object_unref0 (_tmp19_);
		gtk_menu_button_set_child (_tmp27_, _tmp21_);
		_g_object_unref0 (_tmp21_);
		gtk_widget_set_css_classes ((GtkWidget*) _tmp27_, _tmp26_);
		_tmp26_ = (_vala_array_free (_tmp26_, 4, (GDestroyNotify) g_free), NULL);
		gtk_widget_set_hexpand ((GtkWidget*) _tmp27_, TRUE);
		g_object_ref_sink (_tmp27_);
		_g_object_unref0 (self->priv->button);
		self->priv->button = _tmp27_;
		_tmp28_ = self->priv->button;
		adw_bin_set_child ((AdwBin*) self, (GtkWidget*) _tmp28_);
		_g_object_unref0 (card_grid);
		_g_object_unref0 (title_label);
	} else {
		gchar* _tmp29_;
		WidgetsLabelPickerLabelPicker* _tmp30_;
		GtkPopover* _tmp31_;
		gchar* _tmp32_;
		gchar** _tmp33_;
		GtkMenuButton* _tmp34_ = NULL;
		GtkMenuButton* _tmp35_;
		_tmp29_ = g_strdup ("tag-outline-symbolic");
		_tmp30_ = self->priv->labels_picker;
		_tmp31_ = _g_object_ref0 ((GtkPopover*) _tmp30_);
		_tmp32_ = g_strdup ("flat");
		_tmp33_ = g_new0 (gchar*, 1 + 1);
		_tmp33_[0] = _tmp32_;
		_tmp34_ = (GtkMenuButton*) gtk_menu_button_new ();
		gtk_menu_button_set_icon_name (_tmp34_, _tmp29_);
		_g_free0 (_tmp29_);
		gtk_menu_button_set_popover (_tmp34_, _tmp31_);
		_g_object_unref0 (_tmp31_);
		gtk_widget_set_css_classes ((GtkWidget*) _tmp34_, _tmp33_);
		_tmp33_ = (_vala_array_free (_tmp33_, 1, (GDestroyNotify) g_free), NULL);
		g_object_ref_sink (_tmp34_);
		_g_object_unref0 (self->priv->button);
		self->priv->button = _tmp34_;
		_tmp35_ = self->priv->button;
		adw_bin_set_child ((AdwBin*) self, (GtkWidget*) _tmp35_);
	}
	_tmp36_ = self->priv->signal_map;
	_tmp37_ = self->priv->labels_picker;
	_tmp38_ = g_signal_connect_object ((GtkPopover*) _tmp37_, "closed", (GCallback) __widgets_label_picker_label_button___lambda271__gtk_popover_closed, self, 0);
	_tmp39_ = self->priv->labels_picker;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp36_, (gpointer) ((guintptr) _tmp38_), (GObject*) _tmp39_);
	_tmp40_ = self->priv->signal_map;
	_tmp41_ = self->priv->labels_picker;
	_tmp42_ = g_signal_connect_object ((GtkWidget*) _tmp41_, "show", (GCallback) __widgets_label_picker_label_button___lambda272__gtk_widget_show, self, 0);
	_tmp43_ = self->priv->labels_picker;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp40_, (gpointer) ((guintptr) _tmp42_), (GObject*) _tmp43_);
	return obj;
}

static void
widgets_label_picker_label_button_class_init (WidgetsLabelPickerLabelButtonClass * klass,
                                              gpointer klass_data)
{
	widgets_label_picker_label_button_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &WidgetsLabelPickerLabelButton_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_widgets_label_picker_label_button_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_widgets_label_picker_label_button_set_property;
	G_OBJECT_CLASS (klass)->constructor = widgets_label_picker_label_button_constructor;
	G_OBJECT_CLASS (klass)->finalize = widgets_label_picker_label_button_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), WIDGETS_LABEL_PICKER_LABEL_BUTTON_IS_BOARD_PROPERTY, widgets_label_picker_label_button_properties[WIDGETS_LABEL_PICKER_LABEL_BUTTON_IS_BOARD_PROPERTY] = g_param_spec_boolean ("is-board", "is-board", "is-board", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), WIDGETS_LABEL_PICKER_LABEL_BUTTON_LABELS_PROPERTY, widgets_label_picker_label_button_properties[WIDGETS_LABEL_PICKER_LABEL_BUTTON_LABELS_PROPERTY] = g_param_spec_object ("labels", "labels", "labels", GEE_TYPE_ARRAY_LIST, G_PARAM_STATIC_STRINGS | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), WIDGETS_LABEL_PICKER_LABEL_BUTTON_SOURCE_PROPERTY, widgets_label_picker_label_button_properties[WIDGETS_LABEL_PICKER_LABEL_BUTTON_SOURCE_PROPERTY] = g_param_spec_object ("source", "source", "source", OBJECTS_TYPE_SOURCE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	widgets_label_picker_label_button_signals[WIDGETS_LABEL_PICKER_LABEL_BUTTON_LABELS_CHANGED_SIGNAL] = g_signal_new ("labels-changed", WIDGETS_LABEL_PICKER_TYPE_LABEL_BUTTON, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GEE_TYPE_HASH_MAP);
	widgets_label_picker_label_button_signals[WIDGETS_LABEL_PICKER_LABEL_BUTTON_PICKER_OPENED_SIGNAL] = g_signal_new ("picker-opened", WIDGETS_LABEL_PICKER_TYPE_LABEL_BUTTON, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
}

static void
widgets_label_picker_label_button_instance_init (WidgetsLabelPickerLabelButton * self,
                                                 gpointer klass)
{
	GeeHashMap* _tmp0_;
	self->priv = widgets_label_picker_label_button_get_instance_private (self);
	_tmp0_ = 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 = _tmp0_;
}

static void
widgets_label_picker_label_button_finalize (GObject * obj)
{
	WidgetsLabelPickerLabelButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIDGETS_LABEL_PICKER_TYPE_LABEL_BUTTON, WidgetsLabelPickerLabelButton);
	g_debug ("LabelButton.vala:69: Destroying - Widgets.LabelPicker.LabelButton\n");
	_g_object_unref0 (self->priv->button);
	_g_object_unref0 (self->priv->labels_picker);
	_g_object_unref0 (self->priv->labels_label);
	_g_object_unref0 (self->priv->_source);
	_g_object_unref0 (self->priv->signal_map);
	G_OBJECT_CLASS (widgets_label_picker_label_button_parent_class)->finalize (obj);
}

static GType
widgets_label_picker_label_button_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (WidgetsLabelPickerLabelButtonClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) widgets_label_picker_label_button_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WidgetsLabelPickerLabelButton), 0, (GInstanceInitFunc) widgets_label_picker_label_button_instance_init, NULL };
	GType widgets_label_picker_label_button_type_id;
	widgets_label_picker_label_button_type_id = g_type_register_static (adw_bin_get_type (), "WidgetsLabelPickerLabelButton", &g_define_type_info, 0);
	WidgetsLabelPickerLabelButton_private_offset = g_type_add_instance_private (widgets_label_picker_label_button_type_id, sizeof (WidgetsLabelPickerLabelButtonPrivate));
	return widgets_label_picker_label_button_type_id;
}

GType
widgets_label_picker_label_button_get_type (void)
{
	static volatile gsize widgets_label_picker_label_button_type_id__once = 0;
	if (g_once_init_enter (&widgets_label_picker_label_button_type_id__once)) {
		GType widgets_label_picker_label_button_type_id;
		widgets_label_picker_label_button_type_id = widgets_label_picker_label_button_get_type_once ();
		g_once_init_leave (&widgets_label_picker_label_button_type_id__once, widgets_label_picker_label_button_type_id);
	}
	return widgets_label_picker_label_button_type_id__once;
}

static void
_vala_widgets_label_picker_label_button_get_property (GObject * object,
                                                      guint property_id,
                                                      GValue * value,
                                                      GParamSpec * pspec)
{
	WidgetsLabelPickerLabelButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, WIDGETS_LABEL_PICKER_TYPE_LABEL_BUTTON, WidgetsLabelPickerLabelButton);
	switch (property_id) {
		case WIDGETS_LABEL_PICKER_LABEL_BUTTON_IS_BOARD_PROPERTY:
		g_value_set_boolean (value, widgets_label_picker_label_button_get_is_board (self));
		break;
		case WIDGETS_LABEL_PICKER_LABEL_BUTTON_SOURCE_PROPERTY:
		g_value_set_object (value, widgets_label_picker_label_button_get_source (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_widgets_label_picker_label_button_set_property (GObject * object,
                                                      guint property_id,
                                                      const GValue * value,
                                                      GParamSpec * pspec)
{
	WidgetsLabelPickerLabelButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, WIDGETS_LABEL_PICKER_TYPE_LABEL_BUTTON, WidgetsLabelPickerLabelButton);
	switch (property_id) {
		case WIDGETS_LABEL_PICKER_LABEL_BUTTON_IS_BOARD_PROPERTY:
		widgets_label_picker_label_button_set_is_board (self, g_value_get_boolean (value));
		break;
		case WIDGETS_LABEL_PICKER_LABEL_BUTTON_LABELS_PROPERTY:
		widgets_label_picker_label_button_set_labels (self, g_value_get_object (value));
		break;
		case WIDGETS_LABEL_PICKER_LABEL_BUTTON_SOURCE_PROPERTY:
		widgets_label_picker_label_button_set_source (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;
}

