/* LabelsSummary.c generated by valac 0.56.19, the Vala compiler
 * generated from LabelsSummary.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 <adwaita.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include "planify.h"
#include <glib.h>
#include <gee.h>
#include <stdlib.h>
#include <string.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define WIDGETS_TYPE_LABELS_SUMMARY (widgets_labels_summary_get_type ())
#define WIDGETS_LABELS_SUMMARY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIDGETS_TYPE_LABELS_SUMMARY, WidgetsLabelsSummary))
#define WIDGETS_LABELS_SUMMARY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIDGETS_TYPE_LABELS_SUMMARY, WidgetsLabelsSummaryClass))
#define WIDGETS_IS_LABELS_SUMMARY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIDGETS_TYPE_LABELS_SUMMARY))
#define WIDGETS_IS_LABELS_SUMMARY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIDGETS_TYPE_LABELS_SUMMARY))
#define WIDGETS_LABELS_SUMMARY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIDGETS_TYPE_LABELS_SUMMARY, WidgetsLabelsSummaryClass))

typedef struct _WidgetsLabelsSummary WidgetsLabelsSummary;
typedef struct _WidgetsLabelsSummaryClass WidgetsLabelsSummaryClass;
typedef struct _WidgetsLabelsSummaryPrivate WidgetsLabelsSummaryPrivate;
enum  {
	WIDGETS_LABELS_SUMMARY_0_PROPERTY,
	WIDGETS_LABELS_SUMMARY_ITEM_PROPERTY,
	WIDGETS_LABELS_SUMMARY_MAX_ITEMS_PROPERTY,
	WIDGETS_LABELS_SUMMARY_IS_BOARD_PROPERTY,
	WIDGETS_LABELS_SUMMARY_REVEAL_CHILD_PROPERTY,
	WIDGETS_LABELS_SUMMARY_START_MARGIN_PROPERTY,
	WIDGETS_LABELS_SUMMARY_END_MARGIN_PROPERTY,
	WIDGETS_LABELS_SUMMARY_NUM_PROPERTIES
};
static GParamSpec* widgets_labels_summary_properties[WIDGETS_LABELS_SUMMARY_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))

struct _WidgetsLabelsSummary {
	AdwBin parent_instance;
	WidgetsLabelsSummaryPrivate * priv;
	GtkBox* content_box;
};

struct _WidgetsLabelsSummaryClass {
	AdwBinClass parent_class;
};

struct _WidgetsLabelsSummaryPrivate {
	ObjectsItem* _item;
	gint _max_items;
	gboolean _is_board;
	GtkBox* box_layout;
	GtkRevealer* revealer;
	GtkLabel* more_label;
	AdwBin* more_label_grid;
	GtkRevealer* more_label_revealer;
	GeeHashMap* labels;
};

static gint WidgetsLabelsSummary_private_offset;
static gpointer widgets_labels_summary_parent_class = NULL;

VALA_EXTERN GType widgets_labels_summary_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WidgetsLabelsSummary, g_object_unref)
VALA_EXTERN WidgetsLabelsSummary* widgets_labels_summary_new (ObjectsItem* item,
                                                  gint max_items,
                                                  gboolean is_board);
VALA_EXTERN WidgetsLabelsSummary* widgets_labels_summary_construct (GType object_type,
                                                        ObjectsItem* item,
                                                        gint max_items,
                                                        gboolean is_board);
VALA_EXTERN void widgets_labels_summary_update_request (WidgetsLabelsSummary* self);
VALA_EXTERN ObjectsItem* widgets_labels_summary_get_item (WidgetsLabelsSummary* self);
VALA_EXTERN gint widgets_labels_summary_get_max_items (WidgetsLabelsSummary* self);
static gchar* widgets_labels_summary_create_overflow_tooltip (WidgetsLabelsSummary* self,
                                                       GeeArrayList* overflow_labels);
VALA_EXTERN void widgets_labels_summary_remove_item_label (WidgetsLabelsSummary* self,
                                               ObjectsLabel* label);
VALA_EXTERN void widgets_labels_summary_check_revealer (WidgetsLabelsSummary* self);
static void widgets_labels_summary_set_item (WidgetsLabelsSummary* self,
                                      ObjectsItem* value);
static void widgets_labels_summary_set_max_items (WidgetsLabelsSummary* self,
                                           gint value);
VALA_EXTERN gboolean widgets_labels_summary_get_is_board (WidgetsLabelsSummary* self);
static void widgets_labels_summary_set_is_board (WidgetsLabelsSummary* self,
                                          gboolean value);
VALA_EXTERN gboolean widgets_labels_summary_get_reveal_child (WidgetsLabelsSummary* self);
VALA_EXTERN void widgets_labels_summary_set_reveal_child (WidgetsLabelsSummary* self,
                                              gboolean value);
VALA_EXTERN void widgets_labels_summary_set_start_margin (WidgetsLabelsSummary* self,
                                              gint value);
VALA_EXTERN void widgets_labels_summary_set_end_margin (WidgetsLabelsSummary* self,
                                            gint value);
static GObject * widgets_labels_summary_constructor (GType type,
                                              guint n_construct_properties,
                                              GObjectConstructParam * construct_properties);
static void _widgets_labels_summary___lambda40_ (WidgetsLabelsSummary* self,
                                          ObjectsLabel* label);
static void __widgets_labels_summary___lambda40__objects_item_item_label_deleted (ObjectsItem* _sender,
                                                                           ObjectsLabel* label,
                                                                           gpointer self);
static void widgets_labels_summary_finalize (GObject * obj);
static GType widgets_labels_summary_get_type_once (void);
static void _vala_widgets_labels_summary_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec);
static void _vala_widgets_labels_summary_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
widgets_labels_summary_get_instance_private (WidgetsLabelsSummary* self)
{
	return G_STRUCT_MEMBER_P (self, WidgetsLabelsSummary_private_offset);
}

WidgetsLabelsSummary*
widgets_labels_summary_construct (GType object_type,
                                  ObjectsItem* item,
                                  gint max_items,
                                  gboolean is_board)
{
	WidgetsLabelsSummary * self = NULL;
	g_return_val_if_fail (item != NULL, NULL);
	self = (WidgetsLabelsSummary*) g_object_new (object_type, "item", item, "max-items", max_items, "is-board", is_board, NULL);
	return self;
}

WidgetsLabelsSummary*
widgets_labels_summary_new (ObjectsItem* item,
                            gint max_items,
                            gboolean is_board)
{
	return widgets_labels_summary_construct (WIDGETS_TYPE_LABELS_SUMMARY, item, max_items, is_board);
}

void
widgets_labels_summary_update_request (WidgetsLabelsSummary* self)
{
	GtkRevealer* _tmp0_;
	GeeArrayList* item_labels = NULL;
	ObjectsItem* _tmp1_;
	GeeArrayList* _tmp2_;
	GeeArrayList* overflow_labels = NULL;
	GeeArrayList* _tmp3_;
	gint current_visible = 0;
	GeeHashMap* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	GeeArrayList* _tmp37_;
	gint _tmp38_;
	gint _tmp39_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->more_label_revealer;
	gtk_revealer_set_reveal_child (_tmp0_, FALSE);
	_tmp1_ = self->priv->_item;
	_tmp2_ = objects_item_get_labels_list (_tmp1_);
	item_labels = _tmp2_;
	_tmp3_ = gee_array_list_new (OBJECTS_TYPE_LABEL, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	overflow_labels = _tmp3_;
	_tmp4_ = self->priv->labels;
	_tmp5_ = gee_abstract_map_get_size ((GeeAbstractMap*) _tmp4_);
	_tmp6_ = _tmp5_;
	current_visible = _tmp6_;
	{
		GeeArrayList* _label_list = NULL;
		GeeArrayList* _tmp7_;
		gint _label_size = 0;
		GeeArrayList* _tmp8_;
		gint _tmp9_;
		gint _tmp10_;
		gint _label_index = 0;
		_tmp7_ = item_labels;
		_label_list = _tmp7_;
		_tmp8_ = _label_list;
		_tmp9_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp8_);
		_tmp10_ = _tmp9_;
		_label_size = _tmp10_;
		_label_index = -1;
		while (TRUE) {
			gint _tmp11_;
			gint _tmp12_;
			ObjectsLabel* label = NULL;
			GeeArrayList* _tmp13_;
			gpointer _tmp14_;
			GeeHashMap* _tmp15_;
			ObjectsLabel* _tmp16_;
			const gchar* _tmp17_;
			const gchar* _tmp18_;
			_label_index = _label_index + 1;
			_tmp11_ = _label_index;
			_tmp12_ = _label_size;
			if (!(_tmp11_ < _tmp12_)) {
				break;
			}
			_tmp13_ = _label_list;
			_tmp14_ = gee_abstract_list_get ((GeeAbstractList*) _tmp13_, _label_index);
			label = (ObjectsLabel*) _tmp14_;
			_tmp15_ = self->priv->labels;
			_tmp16_ = label;
			_tmp17_ = objects_base_object_get_id ((ObjectsBaseObject*) _tmp16_);
			_tmp18_ = _tmp17_;
			if (!gee_abstract_map_has_key ((GeeAbstractMap*) _tmp15_, _tmp18_)) {
				gint _tmp19_;
				_tmp19_ = self->priv->_max_items;
				if (current_visible >= _tmp19_) {
					GeeArrayList* _tmp20_;
					ObjectsLabel* _tmp21_;
					_tmp20_ = overflow_labels;
					_tmp21_ = label;
					gee_abstract_collection_add ((GeeAbstractCollection*) _tmp20_, _tmp21_);
				} else {
					GeeHashMap* _tmp22_;
					ObjectsLabel* _tmp23_;
					const gchar* _tmp24_;
					const gchar* _tmp25_;
					ObjectsLabel* _tmp26_;
					WidgetsItemLabelChild* _tmp27_ = NULL;
					WidgetsItemLabelChild* _tmp28_;
					GtkBox* _tmp29_;
					GeeHashMap* _tmp30_;
					ObjectsLabel* _tmp31_;
					const gchar* _tmp32_;
					const gchar* _tmp33_;
					gpointer _tmp34_;
					WidgetsItemLabelChild* _tmp35_;
					gint _tmp36_;
					_tmp22_ = self->priv->labels;
					_tmp23_ = label;
					_tmp24_ = objects_base_object_get_id ((ObjectsBaseObject*) _tmp23_);
					_tmp25_ = _tmp24_;
					_tmp26_ = label;
					_tmp27_ = widgets_item_label_child_new (_tmp26_);
					widgets_item_label_child_set_clickable (_tmp27_, FALSE);
					g_object_ref_sink (_tmp27_);
					_tmp28_ = _tmp27_;
					gee_abstract_map_set ((GeeAbstractMap*) _tmp22_, _tmp25_, _tmp28_);
					_g_object_unref0 (_tmp28_);
					_tmp29_ = self->priv->box_layout;
					_tmp30_ = self->priv->labels;
					_tmp31_ = label;
					_tmp32_ = objects_base_object_get_id ((ObjectsBaseObject*) _tmp31_);
					_tmp33_ = _tmp32_;
					_tmp34_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp30_, _tmp33_);
					_tmp35_ = (WidgetsItemLabelChild*) _tmp34_;
					gtk_box_append (_tmp29_, (GtkWidget*) _tmp35_);
					_g_object_unref0 (_tmp35_);
					_tmp36_ = current_visible;
					current_visible = _tmp36_ + 1;
				}
			}
			_g_object_unref0 (label);
		}
	}
	_tmp37_ = overflow_labels;
	_tmp38_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp37_);
	_tmp39_ = _tmp38_;
	if (_tmp39_ > 0) {
		GtkLabel* _tmp40_;
		GeeArrayList* _tmp41_;
		gint _tmp42_;
		gint _tmp43_;
		gchar* _tmp44_;
		gchar* _tmp45_;
		AdwBin* _tmp46_;
		GeeArrayList* _tmp47_;
		gchar* _tmp48_;
		gchar* _tmp49_;
		Util* _tmp50_;
		Util* _tmp51_;
		Util* _tmp52_;
		Util* _tmp53_;
		GeeArrayList* _tmp54_;
		gpointer _tmp55_;
		ObjectsLabel* _tmp56_;
		const gchar* _tmp57_;
		const gchar* _tmp58_;
		gchar* _tmp59_;
		gchar* _tmp60_;
		AdwBin* _tmp61_;
		GtkRevealer* _tmp62_;
		_tmp40_ = self->priv->more_label;
		_tmp41_ = overflow_labels;
		_tmp42_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp41_);
		_tmp43_ = _tmp42_;
		_tmp44_ = g_strdup_printf ("+%d", _tmp43_);
		_tmp45_ = _tmp44_;
		gtk_label_set_label (_tmp40_, _tmp45_);
		_g_free0 (_tmp45_);
		_tmp46_ = self->priv->more_label_grid;
		_tmp47_ = overflow_labels;
		_tmp48_ = widgets_labels_summary_create_overflow_tooltip (self, _tmp47_);
		_tmp49_ = _tmp48_;
		gtk_widget_set_tooltip_text ((GtkWidget*) _tmp46_, _tmp49_);
		_g_free0 (_tmp49_);
		_tmp50_ = util_get_default ();
		_tmp51_ = _tmp50_;
		_tmp52_ = util_get_default ();
		_tmp53_ = _tmp52_;
		_tmp54_ = overflow_labels;
		_tmp55_ = gee_abstract_list_get ((GeeAbstractList*) _tmp54_, 0);
		_tmp56_ = (ObjectsLabel*) _tmp55_;
		_tmp57_ = objects_base_object_get_color ((ObjectsBaseObject*) _tmp56_);
		_tmp58_ = _tmp57_;
		_tmp59_ = util_get_color (_tmp53_, _tmp58_);
		_tmp60_ = _tmp59_;
		_tmp61_ = self->priv->more_label_grid;
		util_set_widget_color (_tmp51_, _tmp60_, (GtkWidget*) _tmp61_);
		_g_free0 (_tmp60_);
		_g_object_unref0 (_tmp56_);
		_g_object_unref0 (_tmp53_);
		_g_object_unref0 (_tmp51_);
		_tmp62_ = self->priv->more_label_revealer;
		gtk_revealer_set_reveal_child (_tmp62_, TRUE);
	}
	_g_object_unref0 (overflow_labels);
	_g_object_unref0 (item_labels);
}

static gchar*
_vala_g_strjoinv (const gchar* separator,
                  gchar** str_array,
                  gint str_array_length1)
{
	gboolean _tmp0_ = FALSE;
	gchar* result;
	if (separator == NULL) {
		separator = "";
	}
	if (str_array != NULL) {
		gboolean _tmp1_ = FALSE;
		if (str_array_length1 > 0) {
			_tmp1_ = TRUE;
		} else {
			gboolean _tmp2_ = FALSE;
			if (str_array_length1 == -1) {
				const gchar* _tmp3_;
				_tmp3_ = str_array[0];
				_tmp2_ = _tmp3_ != NULL;
			} else {
				_tmp2_ = FALSE;
			}
			_tmp1_ = _tmp2_;
		}
		_tmp0_ = _tmp1_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gint i = 0;
		gsize len = 0UL;
		gint _tmp16_;
		gint _tmp17_;
		const gchar* res = NULL;
		void* _tmp18_;
		const gchar* _tmp19_ = NULL;
		const gchar* _tmp20_;
		void* ptr = NULL;
		const gchar* _tmp22_;
		void* _tmp23_;
		const gchar* _tmp33_;
		len = (gsize) 1;
		{
			gboolean _tmp4_ = FALSE;
			i = 0;
			_tmp4_ = TRUE;
			while (TRUE) {
				gboolean _tmp6_ = FALSE;
				gboolean _tmp7_ = FALSE;
				gint _tmp10_ = 0;
				const gchar* _tmp11_;
				if (!_tmp4_) {
					gint _tmp5_;
					_tmp5_ = i;
					i = _tmp5_ + 1;
				}
				_tmp4_ = FALSE;
				if (str_array_length1 != -1) {
					_tmp7_ = i < str_array_length1;
				} else {
					_tmp7_ = FALSE;
				}
				if (_tmp7_) {
					_tmp6_ = TRUE;
				} else {
					gboolean _tmp8_ = FALSE;
					if (str_array_length1 == -1) {
						const gchar* _tmp9_;
						_tmp9_ = str_array[i];
						_tmp8_ = _tmp9_ != NULL;
					} else {
						_tmp8_ = FALSE;
					}
					_tmp6_ = _tmp8_;
				}
				if (!_tmp6_) {
					break;
				}
				_tmp11_ = str_array[i];
				if (_tmp11_ != NULL) {
					const gchar* _tmp12_;
					gint _tmp13_;
					gint _tmp14_;
					_tmp12_ = str_array[i];
					_tmp13_ = strlen ((const gchar*) _tmp12_);
					_tmp14_ = _tmp13_;
					_tmp10_ = _tmp14_;
				} else {
					_tmp10_ = 0;
				}
				len += (gsize) _tmp10_;
			}
		}
		if (i == 0) {
			gchar* _tmp15_;
			_tmp15_ = g_strdup ("");
			result = _tmp15_;
			return result;
		}
		str_array_length1 = i;
		_tmp16_ = strlen ((const gchar*) separator);
		_tmp17_ = _tmp16_;
		len += (gsize) (_tmp17_ * (i - 1));
		_tmp18_ = g_malloc (len);
		res = _tmp18_;
		_tmp20_ = str_array[0];
		if (_tmp20_ != NULL) {
			const gchar* _tmp21_;
			_tmp21_ = str_array[0];
			_tmp19_ = (const gchar*) _tmp21_;
		} else {
			_tmp19_ = "";
		}
		_tmp22_ = res;
		_tmp23_ = g_stpcpy ((void*) _tmp22_, _tmp19_);
		ptr = _tmp23_;
		{
			gboolean _tmp24_ = FALSE;
			i = 1;
			_tmp24_ = TRUE;
			while (TRUE) {
				void* _tmp26_;
				void* _tmp27_;
				const gchar* _tmp28_ = NULL;
				const gchar* _tmp29_;
				void* _tmp31_;
				void* _tmp32_;
				if (!_tmp24_) {
					gint _tmp25_;
					_tmp25_ = i;
					i = _tmp25_ + 1;
				}
				_tmp24_ = FALSE;
				if (!(i < str_array_length1)) {
					break;
				}
				_tmp26_ = ptr;
				_tmp27_ = g_stpcpy (_tmp26_, (const gchar*) separator);
				ptr = _tmp27_;
				_tmp29_ = str_array[i];
				if (_tmp29_ != NULL) {
					const gchar* _tmp30_;
					_tmp30_ = str_array[i];
					_tmp28_ = (const gchar*) _tmp30_;
				} else {
					_tmp28_ = "";
				}
				_tmp31_ = ptr;
				_tmp32_ = g_stpcpy (_tmp31_, _tmp28_);
				ptr = _tmp32_;
			}
		}
		_tmp33_ = res;
		res = NULL;
		result = (gchar*) _tmp33_;
		return result;
	} else {
		gchar* _tmp34_;
		_tmp34_ = g_strdup ("");
		result = _tmp34_;
		return result;
	}
}

static gchar*
widgets_labels_summary_create_overflow_tooltip (WidgetsLabelsSummary* self,
                                                GeeArrayList* overflow_labels)
{
	GeeArrayList* tooltip_parts = NULL;
	GeeArrayList* _tmp0_;
	GeeArrayList* _tmp14_;
	gint _tmp15_ = 0;
	gpointer* _tmp16_;
	gchar** _tmp17_;
	gint _tmp17__length1;
	gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (overflow_labels != NULL, NULL);
	_tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	tooltip_parts = _tmp0_;
	{
		GeeArrayList* _label_list = NULL;
		gint _label_size = 0;
		GeeArrayList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _label_index = 0;
		_label_list = overflow_labels;
		_tmp1_ = _label_list;
		_tmp2_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_label_size = _tmp3_;
		_label_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			ObjectsLabel* label = NULL;
			GeeArrayList* _tmp6_;
			gpointer _tmp7_;
			GeeArrayList* _tmp8_;
			ObjectsLabel* _tmp9_;
			const gchar* _tmp10_;
			const gchar* _tmp11_;
			gchar* _tmp12_;
			gchar* _tmp13_;
			_label_index = _label_index + 1;
			_tmp4_ = _label_index;
			_tmp5_ = _label_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _label_list;
			_tmp7_ = gee_abstract_list_get ((GeeAbstractList*) _tmp6_, _label_index);
			label = (ObjectsLabel*) _tmp7_;
			_tmp8_ = tooltip_parts;
			_tmp9_ = label;
			_tmp10_ = objects_base_object_get_name ((ObjectsBaseObject*) _tmp9_);
			_tmp11_ = _tmp10_;
			_tmp12_ = g_strdup_printf ("- %s", _tmp11_);
			_tmp13_ = _tmp12_;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp8_, _tmp13_);
			_g_free0 (_tmp13_);
			_g_object_unref0 (label);
		}
	}
	_tmp14_ = tooltip_parts;
	_tmp16_ = gee_collection_to_array ((GeeCollection*) _tmp14_, &_tmp15_);
	_tmp17_ = _tmp16_;
	_tmp17__length1 = _tmp15_;
	_tmp18_ = _vala_g_strjoinv ("\n", _tmp17_, (gint) _tmp15_);
	_tmp19_ = _tmp18_;
	_tmp17_ = (_vala_array_free (_tmp17_, _tmp17__length1, (GDestroyNotify) g_free), NULL);
	result = _tmp19_;
	_g_object_unref0 (tooltip_parts);
	return result;
}

void
widgets_labels_summary_remove_item_label (WidgetsLabelsSummary* self,
                                          ObjectsLabel* label)
{
	GeeHashMap* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (label != NULL);
	_tmp0_ = self->priv->labels;
	_tmp1_ = objects_base_object_get_id ((ObjectsBaseObject*) label);
	_tmp2_ = _tmp1_;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, _tmp2_)) {
		GeeHashMap* _tmp3_;
		const gchar* _tmp4_;
		const gchar* _tmp5_;
		gpointer _tmp6_;
		WidgetsItemLabelChild* _tmp7_;
		GeeHashMap* _tmp8_;
		const gchar* _tmp9_;
		const gchar* _tmp10_;
		_tmp3_ = self->priv->labels;
		_tmp4_ = objects_base_object_get_id ((ObjectsBaseObject*) label);
		_tmp5_ = _tmp4_;
		_tmp6_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp3_, _tmp5_);
		_tmp7_ = (WidgetsItemLabelChild*) _tmp6_;
		widgets_item_label_child_hide_destroy (_tmp7_);
		_g_object_unref0 (_tmp7_);
		_tmp8_ = self->priv->labels;
		_tmp9_ = objects_base_object_get_id ((ObjectsBaseObject*) label);
		_tmp10_ = _tmp9_;
		gee_abstract_map_unset ((GeeAbstractMap*) _tmp8_, _tmp10_, NULL);
	}
}

void
widgets_labels_summary_check_revealer (WidgetsLabelsSummary* self)
{
	GtkRevealer* _tmp0_;
	GeeHashMap* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->revealer;
	_tmp1_ = self->priv->labels;
	_tmp2_ = gee_abstract_map_get_size ((GeeAbstractMap*) _tmp1_);
	_tmp3_ = _tmp2_;
	gtk_revealer_set_reveal_child (_tmp0_, _tmp3_ > 0);
}

ObjectsItem*
widgets_labels_summary_get_item (WidgetsLabelsSummary* self)
{
	ObjectsItem* result;
	ObjectsItem* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_item;
	result = _tmp0_;
	return result;
}

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

static void
widgets_labels_summary_set_item (WidgetsLabelsSummary* self,
                                 ObjectsItem* value)
{
	ObjectsItem* old_value;
	g_return_if_fail (self != NULL);
	old_value = widgets_labels_summary_get_item (self);
	if (old_value != value) {
		ObjectsItem* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_item);
		self->priv->_item = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, widgets_labels_summary_properties[WIDGETS_LABELS_SUMMARY_ITEM_PROPERTY]);
	}
}

gint
widgets_labels_summary_get_max_items (WidgetsLabelsSummary* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_max_items;
	return result;
}

static void
widgets_labels_summary_set_max_items (WidgetsLabelsSummary* self,
                                      gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = widgets_labels_summary_get_max_items (self);
	if (old_value != value) {
		self->priv->_max_items = value;
		g_object_notify_by_pspec ((GObject *) self, widgets_labels_summary_properties[WIDGETS_LABELS_SUMMARY_MAX_ITEMS_PROPERTY]);
	}
}

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

static void
widgets_labels_summary_set_is_board (WidgetsLabelsSummary* self,
                                     gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = widgets_labels_summary_get_is_board (self);
	if (old_value != value) {
		self->priv->_is_board = value;
		g_object_notify_by_pspec ((GObject *) self, widgets_labels_summary_properties[WIDGETS_LABELS_SUMMARY_IS_BOARD_PROPERTY]);
	}
}

gboolean
widgets_labels_summary_get_reveal_child (WidgetsLabelsSummary* self)
{
	gboolean result;
	GtkRevealer* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->revealer;
	_tmp1_ = gtk_revealer_get_reveal_child (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

void
widgets_labels_summary_set_reveal_child (WidgetsLabelsSummary* self,
                                         gboolean value)
{
	GtkRevealer* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->revealer;
	gtk_revealer_set_reveal_child (_tmp0_, value);
	g_object_notify_by_pspec ((GObject *) self, widgets_labels_summary_properties[WIDGETS_LABELS_SUMMARY_REVEAL_CHILD_PROPERTY]);
}

void
widgets_labels_summary_set_start_margin (WidgetsLabelsSummary* self,
                                         gint value)
{
	GtkBox* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->content_box;
	gtk_widget_set_margin_start ((GtkWidget*) _tmp0_, value);
	g_object_notify_by_pspec ((GObject *) self, widgets_labels_summary_properties[WIDGETS_LABELS_SUMMARY_START_MARGIN_PROPERTY]);
}

void
widgets_labels_summary_set_end_margin (WidgetsLabelsSummary* self,
                                       gint value)
{
	GtkBox* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->content_box;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp0_, value);
	g_object_notify_by_pspec ((GObject *) self, widgets_labels_summary_properties[WIDGETS_LABELS_SUMMARY_END_MARGIN_PROPERTY]);
}

static void
_widgets_labels_summary___lambda40_ (WidgetsLabelsSummary* self,
                                     ObjectsLabel* label)
{
	g_return_if_fail (label != NULL);
	widgets_labels_summary_remove_item_label (self, label);
}

static void
__widgets_labels_summary___lambda40__objects_item_item_label_deleted (ObjectsItem* _sender,
                                                                      ObjectsLabel* label,
                                                                      gpointer self)
{
	_widgets_labels_summary___lambda40_ ((WidgetsLabelsSummary*) self, label);
}

static GObject *
widgets_labels_summary_constructor (GType type,
                                    guint n_construct_properties,
                                    GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	WidgetsLabelsSummary * self;
	GtkBox* _tmp0_ = NULL;
	gchar* _tmp1_;
	gchar** _tmp2_;
	GtkLabel* _tmp3_ = NULL;
	gchar* _tmp4_;
	gchar** _tmp5_;
	GtkLabel* _tmp6_;
	GtkWidget* _tmp7_;
	AdwBin* _tmp8_ = NULL;
	AdwBin* _tmp9_;
	GtkWidget* _tmp10_;
	GtkRevealer* _tmp11_ = NULL;
	GtkBox* _tmp12_ = NULL;
	GtkBox* _tmp13_;
	GtkBox* _tmp14_;
	GtkBox* _tmp15_;
	GtkRevealer* _tmp16_;
	GtkRevealerTransitionType _tmp17_ = 0;
	gboolean _tmp18_;
	GtkBox* _tmp19_;
	GtkWidget* _tmp20_;
	GtkRevealer* _tmp21_ = NULL;
	GtkRevealer* _tmp22_;
	ObjectsItem* _tmp23_;
	parent_class = G_OBJECT_CLASS (widgets_labels_summary_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIDGETS_TYPE_LABELS_SUMMARY, WidgetsLabelsSummary);
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	gtk_widget_set_halign ((GtkWidget*) _tmp0_, GTK_ALIGN_START);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->box_layout);
	self->priv->box_layout = _tmp0_;
	_tmp1_ = g_strdup ("caption");
	_tmp2_ = g_new0 (gchar*, 1 + 1);
	_tmp2_[0] = _tmp1_;
	_tmp3_ = (GtkLabel*) gtk_label_new (NULL);
	gtk_widget_set_css_classes ((GtkWidget*) _tmp3_, _tmp2_);
	_tmp2_ = (_vala_array_free (_tmp2_, 1, (GDestroyNotify) g_free), NULL);
	g_object_ref_sink (_tmp3_);
	_g_object_unref0 (self->priv->more_label);
	self->priv->more_label = _tmp3_;
	_tmp4_ = g_strdup ("item-label-child");
	_tmp5_ = g_new0 (gchar*, 1 + 1);
	_tmp5_[0] = _tmp4_;
	_tmp6_ = self->priv->more_label;
	_tmp7_ = _g_object_ref0 ((GtkWidget*) _tmp6_);
	_tmp8_ = (AdwBin*) adw_bin_new ();
	gtk_widget_set_css_classes ((GtkWidget*) _tmp8_, _tmp5_);
	_tmp5_ = (_vala_array_free (_tmp5_, 1, (GDestroyNotify) g_free), NULL);
	adw_bin_set_child (_tmp8_, _tmp7_);
	_g_object_unref0 (_tmp7_);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp8_, 6);
	g_object_ref_sink (_tmp8_);
	_g_object_unref0 (self->priv->more_label_grid);
	self->priv->more_label_grid = _tmp8_;
	_tmp9_ = self->priv->more_label_grid;
	_tmp10_ = _g_object_ref0 ((GtkWidget*) _tmp9_);
	_tmp11_ = (GtkRevealer*) gtk_revealer_new ();
	gtk_revealer_set_transition_type (_tmp11_, GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT);
	gtk_revealer_set_child (_tmp11_, _tmp10_);
	_g_object_unref0 (_tmp10_);
	g_object_ref_sink (_tmp11_);
	_g_object_unref0 (self->priv->more_label_revealer);
	self->priv->more_label_revealer = _tmp11_;
	_tmp12_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_widget_set_valign ((GtkWidget*) _tmp12_, GTK_ALIGN_CENTER);
	g_object_ref_sink (_tmp12_);
	_g_object_unref0 (self->content_box);
	self->content_box = _tmp12_;
	_tmp13_ = self->content_box;
	_tmp14_ = self->priv->box_layout;
	gtk_box_append (_tmp13_, (GtkWidget*) _tmp14_);
	_tmp15_ = self->content_box;
	_tmp16_ = self->priv->more_label_revealer;
	gtk_box_append (_tmp15_, (GtkWidget*) _tmp16_);
	_tmp18_ = self->priv->_is_board;
	if (_tmp18_) {
		_tmp17_ = GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT;
	} else {
		_tmp17_ = GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP;
	}
	_tmp19_ = self->content_box;
	_tmp20_ = _g_object_ref0 ((GtkWidget*) _tmp19_);
	_tmp21_ = (GtkRevealer*) gtk_revealer_new ();
	gtk_revealer_set_transition_type (_tmp21_, _tmp17_);
	gtk_revealer_set_child (_tmp21_, _tmp20_);
	_g_object_unref0 (_tmp20_);
	g_object_ref_sink (_tmp21_);
	_g_object_unref0 (self->priv->revealer);
	self->priv->revealer = _tmp21_;
	_tmp22_ = self->priv->revealer;
	adw_bin_set_child ((AdwBin*) self, (GtkWidget*) _tmp22_);
	widgets_labels_summary_update_request (self);
	_tmp23_ = self->priv->_item;
	g_signal_connect_object (_tmp23_, "item-label-deleted", (GCallback) __widgets_labels_summary___lambda40__objects_item_item_label_deleted, self, 0);
	return obj;
}

static void
widgets_labels_summary_class_init (WidgetsLabelsSummaryClass * klass,
                                   gpointer klass_data)
{
	widgets_labels_summary_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &WidgetsLabelsSummary_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_widgets_labels_summary_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_widgets_labels_summary_set_property;
	G_OBJECT_CLASS (klass)->constructor = widgets_labels_summary_constructor;
	G_OBJECT_CLASS (klass)->finalize = widgets_labels_summary_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), WIDGETS_LABELS_SUMMARY_ITEM_PROPERTY, widgets_labels_summary_properties[WIDGETS_LABELS_SUMMARY_ITEM_PROPERTY] = g_param_spec_object ("item", "item", "item", OBJECTS_TYPE_ITEM, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), WIDGETS_LABELS_SUMMARY_MAX_ITEMS_PROPERTY, widgets_labels_summary_properties[WIDGETS_LABELS_SUMMARY_MAX_ITEMS_PROPERTY] = g_param_spec_int ("max-items", "max-items", "max-items", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), WIDGETS_LABELS_SUMMARY_IS_BOARD_PROPERTY, widgets_labels_summary_properties[WIDGETS_LABELS_SUMMARY_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_LABELS_SUMMARY_REVEAL_CHILD_PROPERTY, widgets_labels_summary_properties[WIDGETS_LABELS_SUMMARY_REVEAL_CHILD_PROPERTY] = g_param_spec_boolean ("reveal-child", "reveal-child", "reveal-child", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), WIDGETS_LABELS_SUMMARY_START_MARGIN_PROPERTY, widgets_labels_summary_properties[WIDGETS_LABELS_SUMMARY_START_MARGIN_PROPERTY] = g_param_spec_int ("start-margin", "start-margin", "start-margin", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), WIDGETS_LABELS_SUMMARY_END_MARGIN_PROPERTY, widgets_labels_summary_properties[WIDGETS_LABELS_SUMMARY_END_MARGIN_PROPERTY] = g_param_spec_int ("end-margin", "end-margin", "end-margin", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_WRITABLE));
}

static void
widgets_labels_summary_instance_init (WidgetsLabelsSummary * self,
                                      gpointer klass)
{
	GeeHashMap* _tmp0_;
	self->priv = widgets_labels_summary_get_instance_private (self);
	_tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, WIDGETS_TYPE_ITEM_LABEL_CHILD, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	self->priv->labels = _tmp0_;
}

static void
widgets_labels_summary_finalize (GObject * obj)
{
	WidgetsLabelsSummary * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIDGETS_TYPE_LABELS_SUMMARY, WidgetsLabelsSummary);
	g_debug ("LabelsSummary.vala:67: Destroying - Widgets.LabelsSummary\n");
	_g_object_unref0 (self->priv->_item);
	_g_object_unref0 (self->priv->box_layout);
	_g_object_unref0 (self->priv->revealer);
	_g_object_unref0 (self->content_box);
	_g_object_unref0 (self->priv->more_label);
	_g_object_unref0 (self->priv->more_label_grid);
	_g_object_unref0 (self->priv->more_label_revealer);
	_g_object_unref0 (self->priv->labels);
	G_OBJECT_CLASS (widgets_labels_summary_parent_class)->finalize (obj);
}

static GType
widgets_labels_summary_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (WidgetsLabelsSummaryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) widgets_labels_summary_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WidgetsLabelsSummary), 0, (GInstanceInitFunc) widgets_labels_summary_instance_init, NULL };
	GType widgets_labels_summary_type_id;
	widgets_labels_summary_type_id = g_type_register_static (adw_bin_get_type (), "WidgetsLabelsSummary", &g_define_type_info, 0);
	WidgetsLabelsSummary_private_offset = g_type_add_instance_private (widgets_labels_summary_type_id, sizeof (WidgetsLabelsSummaryPrivate));
	return widgets_labels_summary_type_id;
}

GType
widgets_labels_summary_get_type (void)
{
	static volatile gsize widgets_labels_summary_type_id__once = 0;
	if (g_once_init_enter (&widgets_labels_summary_type_id__once)) {
		GType widgets_labels_summary_type_id;
		widgets_labels_summary_type_id = widgets_labels_summary_get_type_once ();
		g_once_init_leave (&widgets_labels_summary_type_id__once, widgets_labels_summary_type_id);
	}
	return widgets_labels_summary_type_id__once;
}

static void
_vala_widgets_labels_summary_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec)
{
	WidgetsLabelsSummary * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, WIDGETS_TYPE_LABELS_SUMMARY, WidgetsLabelsSummary);
	switch (property_id) {
		case WIDGETS_LABELS_SUMMARY_ITEM_PROPERTY:
		g_value_set_object (value, widgets_labels_summary_get_item (self));
		break;
		case WIDGETS_LABELS_SUMMARY_MAX_ITEMS_PROPERTY:
		g_value_set_int (value, widgets_labels_summary_get_max_items (self));
		break;
		case WIDGETS_LABELS_SUMMARY_IS_BOARD_PROPERTY:
		g_value_set_boolean (value, widgets_labels_summary_get_is_board (self));
		break;
		case WIDGETS_LABELS_SUMMARY_REVEAL_CHILD_PROPERTY:
		g_value_set_boolean (value, widgets_labels_summary_get_reveal_child (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_widgets_labels_summary_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec)
{
	WidgetsLabelsSummary * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, WIDGETS_TYPE_LABELS_SUMMARY, WidgetsLabelsSummary);
	switch (property_id) {
		case WIDGETS_LABELS_SUMMARY_ITEM_PROPERTY:
		widgets_labels_summary_set_item (self, g_value_get_object (value));
		break;
		case WIDGETS_LABELS_SUMMARY_MAX_ITEMS_PROPERTY:
		widgets_labels_summary_set_max_items (self, g_value_get_int (value));
		break;
		case WIDGETS_LABELS_SUMMARY_IS_BOARD_PROPERTY:
		widgets_labels_summary_set_is_board (self, g_value_get_boolean (value));
		break;
		case WIDGETS_LABELS_SUMMARY_REVEAL_CHILD_PROPERTY:
		widgets_labels_summary_set_reveal_child (self, g_value_get_boolean (value));
		break;
		case WIDGETS_LABELS_SUMMARY_START_MARGIN_PROPERTY:
		widgets_labels_summary_set_start_margin (self, g_value_get_int (value));
		break;
		case WIDGETS_LABELS_SUMMARY_END_MARGIN_PROPERTY:
		widgets_labels_summary_set_end_margin (self, g_value_get_int (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);
}

