/* PriorityButton.c generated by valac 0.56.19, the Vala compiler
 * generated from PriorityButton.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 <adwaita.h>
#include <float.h>
#include <math.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_PRIORITY_BUTTON_0_PROPERTY,
	WIDGETS_PRIORITY_BUTTON_IS_BOARD_PROPERTY,
	WIDGETS_PRIORITY_BUTTON_NUM_PROPERTIES
};
static GParamSpec* widgets_priority_button_properties[WIDGETS_PRIORITY_BUTTON_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block16Data Block16Data;
#define _g_free0(var) (var = (g_free (var), NULL))
enum  {
	WIDGETS_PRIORITY_BUTTON_CHANGED_SIGNAL,
	WIDGETS_PRIORITY_BUTTON_PICKER_OPENED_SIGNAL,
	WIDGETS_PRIORITY_BUTTON_NUM_SIGNALS
};
static guint widgets_priority_button_signals[WIDGETS_PRIORITY_BUTTON_NUM_SIGNALS] = {0};

struct _WidgetsPriorityButtonPrivate {
	gboolean _is_board;
	GtkImage* priority_image;
	GtkLabel* priority_label;
	GtkMenuButton* button;
	GtkPopover* priority_picker;
	GeeHashMap* signal_map;
};

struct _Block16Data {
	int _ref_count_;
	WidgetsPriorityButton* self;
	GtkPopover* popover;
};

static gint WidgetsPriorityButton_private_offset;
static gpointer widgets_priority_button_parent_class = NULL;

static void widgets_priority_button_build_ui (WidgetsPriorityButton* self);
static void widgets_priority_button_build_card_ui (WidgetsPriorityButton* self);
static Block16Data* block16_data_ref (Block16Data* _data16_);
static void block16_data_unref (void * _userdata_);
static void __lambda226_ (Block16Data* _data16_);
static void ___lambda226__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void __lambda227_ (Block16Data* _data16_);
static void ___lambda227__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void __lambda228_ (Block16Data* _data16_);
static void ___lambda228__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void __lambda229_ (Block16Data* _data16_);
static void ___lambda229__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static gboolean __lambda230_ (WidgetsPriorityButton* self);
static gboolean __lambda231_ (WidgetsPriorityButton* self);
static gboolean ___lambda231__gsource_func (gpointer self);
static gboolean ___lambda230__gsource_func (gpointer self);
static GObject * widgets_priority_button_constructor (GType type,
                                               guint n_construct_properties,
                                               GObjectConstructParam * construct_properties);
static void _widgets_priority_button___lambda232_ (WidgetsPriorityButton* self);
static void __widgets_priority_button___lambda232__gtk_popover_closed (GtkPopover* _sender,
                                                                gpointer self);
static void _widgets_priority_button___lambda233_ (WidgetsPriorityButton* self);
static void __widgets_priority_button___lambda233__gtk_widget_show (GtkWidget* _sender,
                                                             gpointer self);
static void widgets_priority_button_finalize (GObject * obj);
static GType widgets_priority_button_get_type_once (void);
static void _vala_widgets_priority_button_get_property (GObject * object,
                                                 guint property_id,
                                                 GValue * value,
                                                 GParamSpec * pspec);
static void _vala_widgets_priority_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_priority_button_get_instance_private (WidgetsPriorityButton* self)
{
	return G_STRUCT_MEMBER_P (self, WidgetsPriorityButton_private_offset);
}

WidgetsPriorityButton*
widgets_priority_button_construct (GType object_type)
{
	WidgetsPriorityButton * self = NULL;
	self = (WidgetsPriorityButton*) g_object_new (object_type, "is-board", FALSE, "valign", GTK_ALIGN_CENTER, "halign", GTK_ALIGN_CENTER, "tooltip-text", _ ("Set The Priority"), NULL);
	return self;
}

WidgetsPriorityButton*
widgets_priority_button_new (void)
{
	return widgets_priority_button_construct (WIDGETS_TYPE_PRIORITY_BUTTON);
}

WidgetsPriorityButton*
widgets_priority_button_construct_for_board (GType object_type)
{
	WidgetsPriorityButton * self = NULL;
	self = (WidgetsPriorityButton*) g_object_new (object_type, "is-board", TRUE, "tooltip-text", _ ("Set The Priority"), NULL);
	return self;
}

WidgetsPriorityButton*
widgets_priority_button_new_for_board (void)
{
	return widgets_priority_button_construct_for_board (WIDGETS_TYPE_PRIORITY_BUTTON);
}

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

static void
widgets_priority_button_build_ui (WidgetsPriorityButton* self)
{
	GtkImage* _tmp0_;
	gchar* _tmp1_;
	gchar** _tmp2_;
	GtkImage* _tmp3_;
	GtkWidget* _tmp4_;
	GtkPopover* _tmp5_;
	GtkPopover* _tmp6_;
	GtkMenuButton* _tmp7_ = NULL;
	GtkMenuButton* _tmp8_;
	g_return_if_fail (self != NULL);
	_tmp0_ = (GtkImage*) gtk_image_new_from_icon_name ("flag-outline-thick-symbolic");
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->priority_image);
	self->priv->priority_image = _tmp0_;
	_tmp1_ = g_strdup ("flat");
	_tmp2_ = g_new0 (gchar*, 1 + 1);
	_tmp2_[0] = _tmp1_;
	_tmp3_ = self->priv->priority_image;
	_tmp4_ = _g_object_ref0 ((GtkWidget*) _tmp3_);
	_tmp5_ = self->priv->priority_picker;
	_tmp6_ = _g_object_ref0 (_tmp5_);
	_tmp7_ = (GtkMenuButton*) gtk_menu_button_new ();
	gtk_widget_set_css_classes ((GtkWidget*) _tmp7_, _tmp2_);
	_tmp2_ = (_vala_array_free (_tmp2_, 1, (GDestroyNotify) g_free), NULL);
	gtk_widget_set_valign ((GtkWidget*) _tmp7_, GTK_ALIGN_CENTER);
	gtk_widget_set_halign ((GtkWidget*) _tmp7_, GTK_ALIGN_CENTER);
	gtk_menu_button_set_child (_tmp7_, _tmp4_);
	_g_object_unref0 (_tmp4_);
	gtk_menu_button_set_popover (_tmp7_, _tmp6_);
	_g_object_unref0 (_tmp6_);
	g_object_ref_sink (_tmp7_);
	_g_object_unref0 (self->priv->button);
	self->priv->button = _tmp7_;
	_tmp8_ = self->priv->button;
	adw_bin_set_child ((AdwBin*) self, (GtkWidget*) _tmp8_);
}

static void
widgets_priority_button_build_card_ui (WidgetsPriorityButton* self)
{
	GtkImage* _tmp0_;
	GtkLabel* title_label = NULL;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar** _tmp4_;
	GtkLabel* _tmp5_ = NULL;
	gchar* _tmp6_;
	gchar** _tmp7_;
	GtkLabel* _tmp8_ = NULL;
	GtkGrid* card_grid = NULL;
	GtkGrid* _tmp9_ = NULL;
	GtkImage* _tmp10_;
	GtkLabel* _tmp11_;
	GtkPopover* _tmp12_;
	GtkPopover* _tmp13_;
	GtkWidget* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	gchar** _tmp20_;
	GtkMenuButton* _tmp21_ = NULL;
	GtkMenuButton* _tmp22_;
	g_return_if_fail (self != NULL);
	_tmp0_ = (GtkImage*) gtk_image_new_from_icon_name ("flag-outline-thick-symbolic");
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->priority_image);
	self->priv->priority_image = _tmp0_;
	_tmp1_ = g_strdup ("title-4");
	_tmp2_ = g_strdup ("caption");
	_tmp3_ = g_strdup ("font-bold");
	_tmp4_ = g_new0 (gchar*, 3 + 1);
	_tmp4_[0] = _tmp1_;
	_tmp4_[1] = _tmp2_;
	_tmp4_[2] = _tmp3_;
	_tmp5_ = (GtkLabel*) gtk_label_new (_ ("Priority"));
	gtk_widget_set_halign ((GtkWidget*) _tmp5_, GTK_ALIGN_START);
	gtk_widget_set_css_classes ((GtkWidget*) _tmp5_, _tmp4_);
	_tmp4_ = (_vala_array_free (_tmp4_, 3, (GDestroyNotify) g_free), NULL);
	g_object_ref_sink (_tmp5_);
	title_label = _tmp5_;
	_tmp6_ = g_strdup ("caption");
	_tmp7_ = g_new0 (gchar*, 1 + 1);
	_tmp7_[0] = _tmp6_;
	_tmp8_ = (GtkLabel*) gtk_label_new (_ ("Priority 4: None"));
	gtk_label_set_xalign (_tmp8_, (gfloat) 0);
	gtk_label_set_use_markup (_tmp8_, TRUE);
	gtk_widget_set_halign ((GtkWidget*) _tmp8_, GTK_ALIGN_START);
	gtk_widget_set_css_classes ((GtkWidget*) _tmp8_, _tmp7_);
	_tmp7_ = (_vala_array_free (_tmp7_, 1, (GDestroyNotify) g_free), NULL);
	g_object_ref_sink (_tmp8_);
	_g_object_unref0 (self->priv->priority_label);
	self->priv->priority_label = _tmp8_;
	_tmp9_ = (GtkGrid*) gtk_grid_new ();
	gtk_grid_set_column_spacing (_tmp9_, 12);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp9_, 12);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp9_, 6);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp9_, 6);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp9_, 6);
	gtk_widget_set_vexpand ((GtkWidget*) _tmp9_, TRUE);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp9_, TRUE);
	g_object_ref_sink (_tmp9_);
	card_grid = _tmp9_;
	_tmp10_ = self->priv->priority_image;
	gtk_grid_attach (card_grid, (GtkWidget*) _tmp10_, 0, 0, 1, 2);
	gtk_grid_attach (card_grid, (GtkWidget*) title_label, 1, 0, 1, 1);
	_tmp11_ = self->priv->priority_label;
	gtk_grid_attach (card_grid, (GtkWidget*) _tmp11_, 1, 1, 1, 1);
	_tmp12_ = self->priv->priority_picker;
	_tmp13_ = _g_object_ref0 (_tmp12_);
	_tmp14_ = _g_object_ref0 ((GtkWidget*) card_grid);
	_tmp15_ = g_strdup ("flat");
	_tmp16_ = g_strdup ("card");
	_tmp17_ = g_strdup ("activatable");
	_tmp18_ = g_strdup ("menu-button-no-padding");
	_tmp19_ = g_strdup ("transition");
	_tmp20_ = g_new0 (gchar*, 5 + 1);
	_tmp20_[0] = _tmp15_;
	_tmp20_[1] = _tmp16_;
	_tmp20_[2] = _tmp17_;
	_tmp20_[3] = _tmp18_;
	_tmp20_[4] = _tmp19_;
	_tmp21_ = (GtkMenuButton*) gtk_menu_button_new ();
	gtk_menu_button_set_popover (_tmp21_, _tmp13_);
	_g_object_unref0 (_tmp13_);
	gtk_menu_button_set_child (_tmp21_, _tmp14_);
	_g_object_unref0 (_tmp14_);
	gtk_widget_set_css_classes ((GtkWidget*) _tmp21_, _tmp20_);
	_tmp20_ = (_vala_array_free (_tmp20_, 5, (GDestroyNotify) g_free), NULL);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp21_, TRUE);
	g_object_ref_sink (_tmp21_);
	_g_object_unref0 (self->priv->button);
	self->priv->button = _tmp21_;
	_tmp22_ = self->priv->button;
	adw_bin_set_child ((AdwBin*) self, (GtkWidget*) _tmp22_);
	_g_object_unref0 (card_grid);
	_g_object_unref0 (title_label);
}

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

static void
block16_data_unref (void * _userdata_)
{
	Block16Data* _data16_;
	_data16_ = (Block16Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data16_->_ref_count_)) {
		WidgetsPriorityButton* self;
		self = _data16_->self;
		_g_object_unref0 (_data16_->popover);
		_g_object_unref0 (self);
		g_slice_free (Block16Data, _data16_);
	}
}

static void
__lambda226_ (Block16Data* _data16_)
{
	WidgetsPriorityButton* self;
	self = _data16_->self;
	gtk_popover_popdown (_data16_->popover);
	g_signal_emit (self, widgets_priority_button_signals[WIDGETS_PRIORITY_BUTTON_CHANGED_SIGNAL], 0, CONSTANTS_PRIORITY_1);
}

static void
___lambda226__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda226_ (self);
}

static void
__lambda227_ (Block16Data* _data16_)
{
	WidgetsPriorityButton* self;
	self = _data16_->self;
	gtk_popover_popdown (_data16_->popover);
	g_signal_emit (self, widgets_priority_button_signals[WIDGETS_PRIORITY_BUTTON_CHANGED_SIGNAL], 0, CONSTANTS_PRIORITY_2);
}

static void
___lambda227__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda227_ (self);
}

static void
__lambda228_ (Block16Data* _data16_)
{
	WidgetsPriorityButton* self;
	self = _data16_->self;
	gtk_popover_popdown (_data16_->popover);
	g_signal_emit (self, widgets_priority_button_signals[WIDGETS_PRIORITY_BUTTON_CHANGED_SIGNAL], 0, CONSTANTS_PRIORITY_3);
}

static void
___lambda228__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda228_ (self);
}

static void
__lambda229_ (Block16Data* _data16_)
{
	WidgetsPriorityButton* self;
	self = _data16_->self;
	gtk_popover_popdown (_data16_->popover);
	g_signal_emit (self, widgets_priority_button_signals[WIDGETS_PRIORITY_BUTTON_CHANGED_SIGNAL], 0, CONSTANTS_PRIORITY_4);
}

static void
___lambda229__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda229_ (self);
}

GtkPopover*
widgets_priority_button_build_popover (WidgetsPriorityButton* self)
{
	Block16Data* _data16_;
	WidgetsContextMenuMenuItem* priority_1_item = NULL;
	WidgetsContextMenuMenuItem* _tmp0_;
	WidgetsContextMenuMenuItem* priority_2_item = NULL;
	WidgetsContextMenuMenuItem* _tmp1_;
	WidgetsContextMenuMenuItem* priority_3_item = NULL;
	WidgetsContextMenuMenuItem* _tmp2_;
	WidgetsContextMenuMenuItem* priority_4_item = NULL;
	WidgetsContextMenuMenuItem* _tmp3_;
	GtkBox* menu_box = NULL;
	GtkBox* _tmp4_;
	GtkWidget* _tmp5_;
	GtkPopover* _tmp6_ = NULL;
	GeeHashMap* _tmp7_;
	gulong _tmp8_;
	GeeHashMap* _tmp9_;
	gulong _tmp10_;
	GeeHashMap* _tmp11_;
	gulong _tmp12_;
	GeeHashMap* _tmp13_;
	gulong _tmp14_;
	GtkPopover* _tmp15_;
	GtkPopover* result;
	g_return_val_if_fail (self != NULL, NULL);
	_data16_ = g_slice_new0 (Block16Data);
	_data16_->_ref_count_ = 1;
	_data16_->self = g_object_ref (self);
	_tmp0_ = widgets_context_menu_menu_item_new (_ ("Priority 1: High"), "flag-outline-thick-symbolic");
	g_object_ref_sink (_tmp0_);
	priority_1_item = _tmp0_;
	gtk_widget_add_css_class ((GtkWidget*) priority_1_item, "priority-1-button");
	_tmp1_ = widgets_context_menu_menu_item_new (_ ("Priority 2: Medium"), "flag-outline-thick-symbolic");
	g_object_ref_sink (_tmp1_);
	priority_2_item = _tmp1_;
	gtk_widget_add_css_class ((GtkWidget*) priority_2_item, "priority-2-button");
	_tmp2_ = widgets_context_menu_menu_item_new (_ ("Priority 3: Low"), "flag-outline-thick-symbolic");
	g_object_ref_sink (_tmp2_);
	priority_3_item = _tmp2_;
	gtk_widget_add_css_class ((GtkWidget*) priority_3_item, "priority-3-button");
	_tmp3_ = widgets_context_menu_menu_item_new (_ ("Priority 4: None"), "flag-outline-thick-symbolic");
	g_object_ref_sink (_tmp3_);
	priority_4_item = _tmp3_;
	_tmp4_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp4_);
	menu_box = _tmp4_;
	gtk_widget_set_margin_bottom ((GtkWidget*) menu_box, 3);
	gtk_widget_set_margin_top ((GtkWidget*) menu_box, 3);
	gtk_box_append (menu_box, (GtkWidget*) priority_1_item);
	gtk_box_append (menu_box, (GtkWidget*) priority_2_item);
	gtk_box_append (menu_box, (GtkWidget*) priority_3_item);
	gtk_box_append (menu_box, (GtkWidget*) priority_4_item);
	_tmp5_ = _g_object_ref0 ((GtkWidget*) menu_box);
	_tmp6_ = (GtkPopover*) gtk_popover_new ();
	gtk_popover_set_has_arrow (_tmp6_, FALSE);
	gtk_popover_set_child (_tmp6_, _tmp5_);
	_g_object_unref0 (_tmp5_);
	gtk_popover_set_position (_tmp6_, GTK_POS_BOTTOM);
	g_object_ref_sink (_tmp6_);
	_data16_->popover = _tmp6_;
	_tmp7_ = self->priv->signal_map;
	_tmp8_ = g_signal_connect_data ((GtkButton*) priority_1_item, "clicked", (GCallback) ___lambda226__gtk_button_clicked, block16_data_ref (_data16_), (GClosureNotify) block16_data_unref, 0);
	gee_abstract_map_set ((GeeAbstractMap*) _tmp7_, (gpointer) ((guintptr) _tmp8_), (GObject*) priority_1_item);
	_tmp9_ = self->priv->signal_map;
	_tmp10_ = g_signal_connect_data ((GtkButton*) priority_2_item, "clicked", (GCallback) ___lambda227__gtk_button_clicked, block16_data_ref (_data16_), (GClosureNotify) block16_data_unref, 0);
	gee_abstract_map_set ((GeeAbstractMap*) _tmp9_, (gpointer) ((guintptr) _tmp10_), (GObject*) priority_2_item);
	_tmp11_ = self->priv->signal_map;
	_tmp12_ = g_signal_connect_data ((GtkButton*) priority_3_item, "clicked", (GCallback) ___lambda228__gtk_button_clicked, block16_data_ref (_data16_), (GClosureNotify) block16_data_unref, 0);
	gee_abstract_map_set ((GeeAbstractMap*) _tmp11_, (gpointer) ((guintptr) _tmp12_), (GObject*) priority_3_item);
	_tmp13_ = self->priv->signal_map;
	_tmp14_ = g_signal_connect_data ((GtkButton*) priority_4_item, "clicked", (GCallback) ___lambda229__gtk_button_clicked, block16_data_ref (_data16_), (GClosureNotify) block16_data_unref, 0);
	gee_abstract_map_set ((GeeAbstractMap*) _tmp13_, (gpointer) ((guintptr) _tmp14_), (GObject*) priority_4_item);
	_tmp15_ = _g_object_ref0 (_data16_->popover);
	result = _tmp15_;
	_g_object_unref0 (menu_box);
	_g_object_unref0 (priority_4_item);
	_g_object_unref0 (priority_3_item);
	_g_object_unref0 (priority_2_item);
	_g_object_unref0 (priority_1_item);
	block16_data_unref (_data16_);
	_data16_ = NULL;
	return result;
}

void
widgets_priority_button_update_from_item (WidgetsPriorityButton* self,
                                          ObjectsItem* item)
{
	gint _tmp0_;
	gint _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (item != NULL);
	_tmp0_ = objects_item_get_priority (item);
	_tmp1_ = _tmp0_;
	widgets_priority_button_set_priority (self, _tmp1_);
}

void
widgets_priority_button_set_priority (WidgetsPriorityButton* self,
                                      gint priority)
{
	Util* _tmp23_;
	Util* _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_;
	GtkMenuButton* _tmp27_;
	g_return_if_fail (self != NULL);
	if (priority == CONSTANTS_PRIORITY_1) {
		GtkImage* _tmp0_;
		gchar* _tmp1_;
		gchar** _tmp2_;
		gchar** _tmp3_;
		gint _tmp3__length1;
		gboolean _tmp4_;
		_tmp0_ = self->priv->priority_image;
		_tmp1_ = g_strdup ("priority-1-icon");
		_tmp2_ = g_new0 (gchar*, 1 + 1);
		_tmp2_[0] = _tmp1_;
		_tmp3_ = _tmp2_;
		_tmp3__length1 = 1;
		gtk_widget_set_css_classes ((GtkWidget*) _tmp0_, _tmp3_);
		_tmp3_ = (_vala_array_free (_tmp3_, _tmp3__length1, (GDestroyNotify) g_free), NULL);
		_tmp4_ = self->priv->_is_board;
		if (_tmp4_) {
			GtkLabel* _tmp5_;
			_tmp5_ = self->priv->priority_label;
			gtk_label_set_label (_tmp5_, _ ("Priority 1: High"));
		}
	} else {
		if (priority == CONSTANTS_PRIORITY_2) {
			GtkImage* _tmp6_;
			gchar* _tmp7_;
			gchar** _tmp8_;
			gchar** _tmp9_;
			gint _tmp9__length1;
			gboolean _tmp10_;
			_tmp6_ = self->priv->priority_image;
			_tmp7_ = g_strdup ("priority-2-icon");
			_tmp8_ = g_new0 (gchar*, 1 + 1);
			_tmp8_[0] = _tmp7_;
			_tmp9_ = _tmp8_;
			_tmp9__length1 = 1;
			gtk_widget_set_css_classes ((GtkWidget*) _tmp6_, _tmp9_);
			_tmp9_ = (_vala_array_free (_tmp9_, _tmp9__length1, (GDestroyNotify) g_free), NULL);
			_tmp10_ = self->priv->_is_board;
			if (_tmp10_) {
				GtkLabel* _tmp11_;
				_tmp11_ = self->priv->priority_label;
				gtk_label_set_label (_tmp11_, _ ("Priority 1: Medium"));
			}
		} else {
			if (priority == CONSTANTS_PRIORITY_3) {
				GtkImage* _tmp12_;
				gchar* _tmp13_;
				gchar** _tmp14_;
				gchar** _tmp15_;
				gint _tmp15__length1;
				gboolean _tmp16_;
				_tmp12_ = self->priv->priority_image;
				_tmp13_ = g_strdup ("priority-3-icon");
				_tmp14_ = g_new0 (gchar*, 1 + 1);
				_tmp14_[0] = _tmp13_;
				_tmp15_ = _tmp14_;
				_tmp15__length1 = 1;
				gtk_widget_set_css_classes ((GtkWidget*) _tmp12_, _tmp15_);
				_tmp15_ = (_vala_array_free (_tmp15_, _tmp15__length1, (GDestroyNotify) g_free), NULL);
				_tmp16_ = self->priv->_is_board;
				if (_tmp16_) {
					GtkLabel* _tmp17_;
					_tmp17_ = self->priv->priority_label;
					gtk_label_set_label (_tmp17_, _ ("Priority 1: Low"));
				}
			} else {
				GtkImage* _tmp18_;
				gchar** _tmp19_;
				gchar** _tmp20_;
				gint _tmp20__length1;
				gboolean _tmp21_;
				_tmp18_ = self->priv->priority_image;
				_tmp19_ = g_new0 (gchar*, 0 + 1);
				_tmp20_ = _tmp19_;
				_tmp20__length1 = 0;
				gtk_widget_set_css_classes ((GtkWidget*) _tmp18_, _tmp20_);
				_tmp20_ = (_vala_array_free (_tmp20_, _tmp20__length1, (GDestroyNotify) g_free), NULL);
				_tmp21_ = self->priv->_is_board;
				if (_tmp21_) {
					GtkLabel* _tmp22_;
					_tmp22_ = self->priv->priority_label;
					gtk_label_set_label (_tmp22_, _ ("Priority 4: None"));
				}
			}
		}
	}
	_tmp23_ = util_get_default ();
	_tmp24_ = _tmp23_;
	_tmp25_ = item_priority_get_color ((ItemPriority) priority);
	_tmp26_ = _tmp25_;
	_tmp27_ = self->priv->button;
	util_set_widget_color (_tmp24_, _tmp26_, (GtkWidget*) _tmp27_);
	_g_free0 (_tmp26_);
	_g_object_unref0 (_tmp24_);
}

void
widgets_priority_button_reset (WidgetsPriorityButton* self)
{
	GtkImage* _tmp0_;
	GtkImage* _tmp1_;
	gchar** _tmp2_;
	gchar** _tmp3_;
	gint _tmp3__length1;
	Util* _tmp4_;
	Util* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	GtkMenuButton* _tmp8_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->priority_image;
	g_object_set (_tmp0_, "icon-name", "flag-outline-thick-symbolic", NULL);
	_tmp1_ = self->priv->priority_image;
	_tmp2_ = g_new0 (gchar*, 0 + 1);
	_tmp3_ = _tmp2_;
	_tmp3__length1 = 0;
	gtk_widget_set_css_classes ((GtkWidget*) _tmp1_, _tmp3_);
	_tmp3_ = (_vala_array_free (_tmp3_, _tmp3__length1, (GDestroyNotify) g_free), NULL);
	_tmp4_ = util_get_default ();
	_tmp5_ = _tmp4_;
	_tmp6_ = item_priority_get_color ((ItemPriority) CONSTANTS_PRIORITY_4);
	_tmp7_ = _tmp6_;
	_tmp8_ = self->priv->button;
	util_set_widget_color (_tmp5_, _tmp7_, (GtkWidget*) _tmp8_);
	_g_free0 (_tmp7_);
	_g_object_unref0 (_tmp5_);
}

static gboolean
__lambda231_ (WidgetsPriorityButton* self)
{
	GtkMenuButton* _tmp0_;
	gboolean result;
	_tmp0_ = self->priv->button;
	gtk_widget_remove_css_class ((GtkWidget*) _tmp0_, "priority-pulse-animation");
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
___lambda231__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda231_ ((WidgetsPriorityButton*) self);
	return result;
}

static gboolean
__lambda230_ (WidgetsPriorityButton* self)
{
	GtkMenuButton* _tmp0_;
	gboolean result;
	_tmp0_ = self->priv->button;
	gtk_widget_add_css_class ((GtkWidget*) _tmp0_, "priority-pulse-animation");
	g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 700, ___lambda231__gsource_func, g_object_ref (self), g_object_unref);
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
___lambda230__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda230_ ((WidgetsPriorityButton*) self);
	return result;
}

void
widgets_priority_button_animation (WidgetsPriorityButton* self)
{
	GtkMenuButton* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->button;
	gtk_widget_remove_css_class ((GtkWidget*) _tmp0_, "priority-pulse-animation");
	g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, ___lambda230__gsource_func, g_object_ref (self), g_object_unref);
}

void
widgets_priority_button_clean_up (WidgetsPriorityButton* self)
{
	GeeHashMap* _tmp15_;
	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_);
}

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

static void
widgets_priority_button_set_is_board (WidgetsPriorityButton* self,
                                      gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = widgets_priority_button_get_is_board (self);
	if (old_value != value) {
		self->priv->_is_board = value;
		g_object_notify_by_pspec ((GObject *) self, widgets_priority_button_properties[WIDGETS_PRIORITY_BUTTON_IS_BOARD_PROPERTY]);
	}
}

static void
_widgets_priority_button___lambda232_ (WidgetsPriorityButton* self)
{
	g_signal_emit (self, widgets_priority_button_signals[WIDGETS_PRIORITY_BUTTON_PICKER_OPENED_SIGNAL], 0, FALSE);
}

static void
__widgets_priority_button___lambda232__gtk_popover_closed (GtkPopover* _sender,
                                                           gpointer self)
{
	_widgets_priority_button___lambda232_ ((WidgetsPriorityButton*) self);
}

static void
_widgets_priority_button___lambda233_ (WidgetsPriorityButton* self)
{
	g_signal_emit (self, widgets_priority_button_signals[WIDGETS_PRIORITY_BUTTON_PICKER_OPENED_SIGNAL], 0, TRUE);
}

static void
__widgets_priority_button___lambda233__gtk_widget_show (GtkWidget* _sender,
                                                        gpointer self)
{
	_widgets_priority_button___lambda233_ ((WidgetsPriorityButton*) self);
}

static GObject *
widgets_priority_button_constructor (GType type,
                                     guint n_construct_properties,
                                     GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	WidgetsPriorityButton * self;
	GtkPopover* _tmp0_;
	gboolean _tmp1_;
	GeeHashMap* _tmp2_;
	GtkPopover* _tmp3_;
	gulong _tmp4_;
	GtkPopover* _tmp5_;
	GeeHashMap* _tmp6_;
	GtkPopover* _tmp7_;
	gulong _tmp8_;
	GtkPopover* _tmp9_;
	parent_class = G_OBJECT_CLASS (widgets_priority_button_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIDGETS_TYPE_PRIORITY_BUTTON, WidgetsPriorityButton);
	_tmp0_ = widgets_priority_button_build_popover (self);
	_g_object_unref0 (self->priv->priority_picker);
	self->priv->priority_picker = _tmp0_;
	_tmp1_ = self->priv->_is_board;
	if (_tmp1_) {
		widgets_priority_button_build_card_ui (self);
	} else {
		widgets_priority_button_build_ui (self);
	}
	_tmp2_ = self->priv->signal_map;
	_tmp3_ = self->priv->priority_picker;
	_tmp4_ = g_signal_connect_object (_tmp3_, "closed", (GCallback) __widgets_priority_button___lambda232__gtk_popover_closed, self, 0);
	_tmp5_ = self->priv->priority_picker;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp2_, (gpointer) ((guintptr) _tmp4_), (GObject*) _tmp5_);
	_tmp6_ = self->priv->signal_map;
	_tmp7_ = self->priv->priority_picker;
	_tmp8_ = g_signal_connect_object ((GtkWidget*) _tmp7_, "show", (GCallback) __widgets_priority_button___lambda233__gtk_widget_show, self, 0);
	_tmp9_ = self->priv->priority_picker;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp6_, (gpointer) ((guintptr) _tmp8_), (GObject*) _tmp9_);
	return obj;
}

static void
widgets_priority_button_class_init (WidgetsPriorityButtonClass * klass,
                                    gpointer klass_data)
{
	widgets_priority_button_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &WidgetsPriorityButton_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_widgets_priority_button_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_widgets_priority_button_set_property;
	G_OBJECT_CLASS (klass)->constructor = widgets_priority_button_constructor;
	G_OBJECT_CLASS (klass)->finalize = widgets_priority_button_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), WIDGETS_PRIORITY_BUTTON_IS_BOARD_PROPERTY, widgets_priority_button_properties[WIDGETS_PRIORITY_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));
	widgets_priority_button_signals[WIDGETS_PRIORITY_BUTTON_CHANGED_SIGNAL] = g_signal_new ("changed", WIDGETS_TYPE_PRIORITY_BUTTON, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
	widgets_priority_button_signals[WIDGETS_PRIORITY_BUTTON_PICKER_OPENED_SIGNAL] = g_signal_new ("picker-opened", WIDGETS_TYPE_PRIORITY_BUTTON, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
}

static void
widgets_priority_button_instance_init (WidgetsPriorityButton * self,
                                       gpointer klass)
{
	GeeHashMap* _tmp0_;
	self->priv = widgets_priority_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_priority_button_finalize (GObject * obj)
{
	WidgetsPriorityButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIDGETS_TYPE_PRIORITY_BUTTON, WidgetsPriorityButton);
	g_debug ("PriorityButton.vala:52: Destroying - Widgets.PriorityButton\n");
	_g_object_unref0 (self->priv->priority_image);
	_g_object_unref0 (self->priv->priority_label);
	_g_object_unref0 (self->priv->button);
	_g_object_unref0 (self->priv->priority_picker);
	_g_object_unref0 (self->priv->signal_map);
	G_OBJECT_CLASS (widgets_priority_button_parent_class)->finalize (obj);
}

static GType
widgets_priority_button_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (WidgetsPriorityButtonClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) widgets_priority_button_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WidgetsPriorityButton), 0, (GInstanceInitFunc) widgets_priority_button_instance_init, NULL };
	GType widgets_priority_button_type_id;
	widgets_priority_button_type_id = g_type_register_static (adw_bin_get_type (), "WidgetsPriorityButton", &g_define_type_info, 0);
	WidgetsPriorityButton_private_offset = g_type_add_instance_private (widgets_priority_button_type_id, sizeof (WidgetsPriorityButtonPrivate));
	return widgets_priority_button_type_id;
}

GType
widgets_priority_button_get_type (void)
{
	static volatile gsize widgets_priority_button_type_id__once = 0;
	if (g_once_init_enter (&widgets_priority_button_type_id__once)) {
		GType widgets_priority_button_type_id;
		widgets_priority_button_type_id = widgets_priority_button_get_type_once ();
		g_once_init_leave (&widgets_priority_button_type_id__once, widgets_priority_button_type_id);
	}
	return widgets_priority_button_type_id__once;
}

static void
_vala_widgets_priority_button_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec)
{
	WidgetsPriorityButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, WIDGETS_TYPE_PRIORITY_BUTTON, WidgetsPriorityButton);
	switch (property_id) {
		case WIDGETS_PRIORITY_BUTTON_IS_BOARD_PROPERTY:
		g_value_set_boolean (value, widgets_priority_button_get_is_board (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_widgets_priority_button_set_property (GObject * object,
                                            guint property_id,
                                            const GValue * value,
                                            GParamSpec * pspec)
{
	WidgetsPriorityButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, WIDGETS_TYPE_PRIORITY_BUTTON, WidgetsPriorityButton);
	switch (property_id) {
		case WIDGETS_PRIORITY_BUTTON_IS_BOARD_PROPERTY:
		widgets_priority_button_set_is_board (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

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

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

