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

/*
 * Copyright (c) 2025 focus-timer contributors
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 *
 * Authors: Kamil Prusko <kamilprusko@gmail.com>
 */

#include <adwaita.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include "ft_core.h"
#include "ft_ui.h"

#define FT_MONTH_CHOOSER_MONTHS_PER_ROW 3
#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

typedef struct _FtMonthChooser FtMonthChooser;
typedef struct _FtMonthChooserClass FtMonthChooserClass;
typedef struct _FtMonthChooserPrivate FtMonthChooserPrivate;
enum  {
	FT_MONTH_CHOOSER_0_PROPERTY,
	FT_MONTH_CHOOSER_SELECTED_DATE_PROPERTY,
	FT_MONTH_CHOOSER_MIN_DATE_PROPERTY,
	FT_MONTH_CHOOSER_MAX_DATE_PROPERTY,
	FT_MONTH_CHOOSER_DISPLAY_YEAR_PROPERTY,
	FT_MONTH_CHOOSER_NUM_PROPERTIES
};
static GParamSpec* ft_month_chooser_properties[FT_MONTH_CHOOSER_NUM_PROPERTIES];
typedef struct _Block10Data Block10Data;
#define _g_free0(var) ((var == NULL) ? NULL : (var = (g_free (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	FT_MONTH_CHOOSER_SELECTED_SIGNAL,
	FT_MONTH_CHOOSER_NUM_SIGNALS
};
static guint ft_month_chooser_signals[FT_MONTH_CHOOSER_NUM_SIGNALS] = {0};

struct _FtMonthChooser {
	AdwBin parent_instance;
	FtMonthChooserPrivate * priv;
};

struct _FtMonthChooserClass {
	AdwBinClass parent_class;
};

struct _FtMonthChooserPrivate {
	GtkLabel* header_label;
	GtkButton* previous_button;
	GtkButton* next_button;
	GtkGrid* grid;
	GDate _selected_date;
	GDate _min_date;
	GDate _max_date;
	GtkWidget* selected_button;
	GDateYear _display_year;
};

struct _Block10Data {
	int _ref_count_;
	FtMonthChooser* self;
	FtMonthChooser* _self_;
	GDate* date_copy;
};

static gint FtMonthChooser_private_offset;
static gpointer ft_month_chooser_parent_class = NULL;

static void ft_month_chooser_set_display_year (FtMonthChooser* self,
                                        GDateYear year);
static void ft_month_chooser_update (FtMonthChooser* self);
static GtkButton* ft_month_chooser_create_month_button (FtMonthChooser* self,
                                                 GDate* date);
static Block10Data* block10_data_ref (Block10Data* _data10_);
static void block10_data_unref (void * _userdata_);
VALA_EXTERN gchar* ft_capitalize_words (const gchar* text);
static void __lambda21_ (Block10Data* _data10_);
static gboolean ft_month_chooser_select (FtMonthChooser* self,
                                  GDate* date);
static void ___lambda21__gtk_button_clicked (GtkButton* _sender,
                                      gpointer self);
static void ft_month_chooser_clear_months (FtMonthChooser* self);
static void ft_month_chooser_update_previous_button (FtMonthChooser* self);
static void ft_month_chooser_update_next_button (FtMonthChooser* self);
static void ft_month_chooser_update_header (FtMonthChooser* self);
static void ft_month_chooser_create_months (FtMonthChooser* self);
static void ft_month_chooser_update_months (FtMonthChooser* self);
static void ft_month_chooser_update_selection (FtMonthChooser* self);
static void ft_month_chooser_on_previous_button_clicked (FtMonthChooser* self);
static void _ft_month_chooser_on_previous_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                      gpointer self);
static void ft_month_chooser_on_next_button_clicked (FtMonthChooser* self);
static void _ft_month_chooser_on_next_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                  gpointer self);
static void ft_month_chooser_real_map (GtkWidget* base);
static void ft_month_chooser_real_unmap (GtkWidget* base);
static void ft_month_chooser_real_dispose (GObject* base);
static void ft_month_chooser_finalize (GObject * obj);
static GType ft_month_chooser_get_type_once (void);
static void _vala_ft_month_chooser_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec);
static void _vala_ft_month_chooser_set_property (GObject * object,
                                          guint property_id,
                                          const GValue * value,
                                          GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
ft_month_chooser_get_instance_private (FtMonthChooser* self)
{
	return G_STRUCT_MEMBER_P (self, FtMonthChooser_private_offset);
}

static void
ft_month_chooser_set_display_year (FtMonthChooser* self,
                                   GDateYear year)
{
	g_return_if_fail (self != NULL);
	if (self->priv->_display_year == year) {
		return;
	}
	self->priv->_display_year = year;
	ft_month_chooser_update (self);
}

static Block10Data*
block10_data_ref (Block10Data* _data10_)
{
	g_atomic_int_inc (&_data10_->_ref_count_);
	return _data10_;
}

static void
block10_data_unref (void * _userdata_)
{
	Block10Data* _data10_;
	_data10_ = (Block10Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data10_->_ref_count_)) {
		FtMonthChooser* self;
		self = _data10_->self;
		_g_free0 (_data10_->date_copy);
		_g_object_unref0 (self);
		g_slice_free (Block10Data, _data10_);
	}
}

static void
__lambda21_ (Block10Data* _data10_)
{
	FtMonthChooser* self;
	GDate _tmp0_;
	self = _data10_->self;
	_tmp0_ = *_data10_->date_copy;
	ft_month_chooser_select (_data10_->_self_, &_tmp0_);
}

static void
___lambda21__gtk_button_clicked (GtkButton* _sender,
                                 gpointer self)
{
	__lambda21_ (self);
}

static GtkButton*
ft_month_chooser_create_month_button (FtMonthChooser* self,
                                      GDate* date)
{
	Block10Data* _data10_;
	GtkButton* button = NULL;
	GtkButton* _tmp0_;
	GDate _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	GDate* _tmp6_;
	GtkButton* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (date != NULL, NULL);
	_data10_ = g_slice_new0 (Block10Data);
	_data10_->_ref_count_ = 1;
	_data10_->self = g_object_ref (self);
	_tmp0_ = (GtkButton*) gtk_button_new ();
	g_object_ref_sink (_tmp0_);
	button = _tmp0_;
	_tmp1_ = *date;
	_tmp2_ = ft_date_utils_format_date (&_tmp1_, "%b");
	_tmp3_ = _tmp2_;
	_tmp4_ = ft_capitalize_words (_tmp3_);
	_tmp5_ = _tmp4_;
	gtk_button_set_label (button, _tmp5_);
	_g_free0 (_tmp5_);
	_g_free0 (_tmp3_);
	gtk_widget_add_css_class ((GtkWidget*) button, "pill");
	gtk_widget_add_css_class ((GtkWidget*) button, "flat");
	gtk_widget_add_css_class ((GtkWidget*) button, "month");
	_data10_->_self_ = self;
	_tmp6_ = g_date_copy (date);
	_data10_->date_copy = _tmp6_;
	g_signal_connect_data (button, "clicked", (GCallback) ___lambda21__gtk_button_clicked, block10_data_ref (_data10_), (GClosureNotify) block10_data_unref, 0);
	result = button;
	block10_data_unref (_data10_);
	_data10_ = NULL;
	return result;
}

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

static void
ft_month_chooser_clear_months (FtMonthChooser* self)
{
	GtkWidget* child = NULL;
	GtkGrid* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->grid;
	_tmp1_ = gtk_widget_get_first_child ((GtkWidget*) _tmp0_);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	child = _tmp2_;
	while (TRUE) {
		GtkWidget* _tmp3_;
		GtkWidget* next_child = NULL;
		GtkWidget* _tmp4_;
		GtkWidget* _tmp5_;
		GtkWidget* _tmp6_;
		GtkGrid* _tmp7_;
		GtkWidget* _tmp8_;
		GtkWidget* _tmp9_;
		GtkWidget* _tmp10_;
		_tmp3_ = child;
		if (!(_tmp3_ != NULL)) {
			break;
		}
		_tmp4_ = child;
		_tmp5_ = gtk_widget_get_next_sibling (_tmp4_);
		_tmp6_ = _g_object_ref0 (_tmp5_);
		next_child = _tmp6_;
		_tmp7_ = self->priv->grid;
		_tmp8_ = child;
		gtk_grid_remove (_tmp7_, _tmp8_);
		_tmp9_ = next_child;
		_tmp10_ = _g_object_ref0 (_tmp9_);
		_g_object_unref0 (child);
		child = _tmp10_;
		_g_object_unref0 (next_child);
	}
	self->priv->selected_button = NULL;
	_g_object_unref0 (child);
}

static void
ft_month_chooser_update_previous_button (FtMonthChooser* self)
{
	gboolean _tmp0_ = FALSE;
	GtkButton* _tmp1_;
	g_return_if_fail (self != NULL);
	if (!g_date_valid (&self->priv->_min_date)) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = self->priv->_display_year > g_date_get_year (&self->priv->_min_date);
	}
	_tmp1_ = self->priv->previous_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp1_, _tmp0_);
}

static void
ft_month_chooser_update_next_button (FtMonthChooser* self)
{
	gboolean _tmp0_ = FALSE;
	GtkButton* _tmp1_;
	g_return_if_fail (self != NULL);
	if (!g_date_valid (&self->priv->_max_date)) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = self->priv->_display_year < g_date_get_year (&self->priv->_max_date);
	}
	_tmp1_ = self->priv->next_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp1_, _tmp0_);
}

static void
ft_month_chooser_update_header (FtMonthChooser* self)
{
	gint year = 0;
	GtkLabel* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	year = (gint) self->priv->_display_year;
	_tmp0_ = self->priv->header_label;
	_tmp1_ = g_strdup_printf ("%i", year);
	_tmp2_ = _tmp1_;
	gtk_label_set_label (_tmp0_, _tmp2_);
	_g_free0 (_tmp2_);
	ft_month_chooser_update_previous_button (self);
	ft_month_chooser_update_next_button (self);
}

static void
ft_month_chooser_create_months (FtMonthChooser* self)
{
	GDate date = {0};
	gboolean is_min_date_valid = FALSE;
	gboolean is_max_date_valid = FALSE;
	gint row = 0;
	gint column = 0;
	g_return_if_fail (self != NULL);
	memset (&date, 0, sizeof (GDate));
	g_date_set_dmy (&date, (GDateDay) 1, 1, self->priv->_display_year);
	is_min_date_valid = g_date_valid (&self->priv->_min_date);
	is_max_date_valid = g_date_valid (&self->priv->_max_date);
	row = 0;
	column = 0;
	{
		gint month = 0;
		month = 1;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GtkButton* button = NULL;
				GDate _tmp2_;
				GtkButton* _tmp3_;
				gboolean _tmp4_ = FALSE;
				gboolean _tmp5_ = FALSE;
				GtkButton* _tmp9_;
				GtkGrid* _tmp10_;
				GtkButton* _tmp11_;
				gint _tmp12_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = month;
					month = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				if (!(month <= 12)) {
					break;
				}
				_tmp2_ = date;
				_tmp3_ = ft_month_chooser_create_month_button (self, &_tmp2_);
				button = _tmp3_;
				if (!is_min_date_valid) {
					_tmp5_ = TRUE;
				} else {
					GDate _tmp6_;
					_tmp6_ = date;
					_tmp5_ = g_date_compare (&self->priv->_min_date, &_tmp6_) <= 0;
				}
				if (_tmp5_) {
					gboolean _tmp7_ = FALSE;
					if (!is_max_date_valid) {
						_tmp7_ = TRUE;
					} else {
						GDate _tmp8_;
						_tmp8_ = date;
						_tmp7_ = g_date_compare (&self->priv->_max_date, &_tmp8_) >= 0;
					}
					_tmp4_ = _tmp7_;
				} else {
					_tmp4_ = FALSE;
				}
				_tmp9_ = button;
				gtk_widget_set_sensitive ((GtkWidget*) _tmp9_, _tmp4_);
				_tmp10_ = self->priv->grid;
				_tmp11_ = button;
				gtk_grid_attach (_tmp10_, (GtkWidget*) _tmp11_, column, row, 1, 1);
				g_date_add_months (&date, 1U);
				_tmp12_ = column;
				column = _tmp12_ + 1;
				if (column >= FT_MONTH_CHOOSER_MONTHS_PER_ROW) {
					gint _tmp13_;
					column = 0;
					_tmp13_ = row;
					row = _tmp13_ + 1;
				}
				_g_object_unref0 (button);
			}
		}
	}
}

static void
ft_month_chooser_update_months (FtMonthChooser* self)
{
	g_return_if_fail (self != NULL);
	if (!gtk_widget_get_mapped ((GtkWidget*) self)) {
		return;
	}
	ft_month_chooser_clear_months (self);
	ft_month_chooser_create_months (self);
}

static void
ft_month_chooser_update_selection (FtMonthChooser* self)
{
	GtkWidget* _tmp0_;
	gboolean _tmp2_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->selected_button;
	if (_tmp0_ != NULL) {
		GtkWidget* _tmp1_;
		_tmp1_ = self->priv->selected_button;
		gtk_widget_unset_state_flags (_tmp1_, GTK_STATE_FLAG_SELECTED);
		self->priv->selected_button = NULL;
	}
	if (g_date_valid (&self->priv->_selected_date)) {
		_tmp2_ = g_date_get_year (&self->priv->_selected_date) == self->priv->_display_year;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		gint position = 0;
		gint column = 0;
		gint row = 0;
		GtkGrid* _tmp3_;
		GtkWidget* _tmp4_;
		GtkWidget* _tmp5_ = NULL;
		GtkWidget* _tmp6_;
		position = ((gint) g_date_get_month (&self->priv->_selected_date)) - 1;
		column = position % FT_MONTH_CHOOSER_MONTHS_PER_ROW;
		row = (position - column) / FT_MONTH_CHOOSER_MONTHS_PER_ROW;
		_tmp3_ = self->priv->grid;
		_tmp4_ = gtk_grid_get_child_at (_tmp3_, column, row);
		self->priv->selected_button = _tmp4_;
		_tmp6_ = self->priv->selected_button;
		_tmp5_ = _tmp6_;
		if (_tmp5_ != NULL) {
			gtk_widget_set_state_flags (_tmp5_, GTK_STATE_FLAG_SELECTED, FALSE);
		}
	}
}

static void
ft_month_chooser_update (FtMonthChooser* self)
{
	g_return_if_fail (self != NULL);
	ft_month_chooser_update_header (self);
	ft_month_chooser_update_months (self);
	ft_month_chooser_update_selection (self);
}

static void
ft_month_chooser_on_previous_button_clicked (FtMonthChooser* self)
{
	g_return_if_fail (self != NULL);
	ft_month_chooser_set_display_year (self, (GDateYear) (self->priv->_display_year - 1));
}

static void
_ft_month_chooser_on_previous_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                 gpointer self)
{
	ft_month_chooser_on_previous_button_clicked ((FtMonthChooser*) self);
}

static void
ft_month_chooser_on_next_button_clicked (FtMonthChooser* self)
{
	g_return_if_fail (self != NULL);
	ft_month_chooser_set_display_year (self, (GDateYear) (self->priv->_display_year + 1));
}

static void
_ft_month_chooser_on_next_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                             gpointer self)
{
	ft_month_chooser_on_next_button_clicked ((FtMonthChooser*) self);
}

static gboolean
ft_month_chooser_select (FtMonthChooser* self,
                         GDate* date)
{
	gboolean _tmp0_ = FALSE;
	GDate _tmp2_;
	GDate _tmp3_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (date != NULL, FALSE);
	if (!g_date_valid (date)) {
		result = FALSE;
		return result;
	}
	if (g_date_valid (&self->priv->_selected_date)) {
		GDate _tmp1_;
		_tmp1_ = *date;
		_tmp0_ = g_date_compare (&self->priv->_selected_date, &_tmp1_) == 0;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		result = TRUE;
		return result;
	}
	_tmp2_ = *date;
	ft_month_chooser_set_selected_date (self, &_tmp2_);
	_tmp3_ = self->priv->_selected_date;
	g_signal_emit (self, ft_month_chooser_signals[FT_MONTH_CHOOSER_SELECTED_SIGNAL], 0, &_tmp3_);
	result = TRUE;
	return result;
}

void
ft_month_chooser_reset (FtMonthChooser* self)
{
	g_return_if_fail (self != NULL);
	if (g_date_valid (&self->priv->_selected_date)) {
		ft_month_chooser_set_display_year (self, g_date_get_year (&self->priv->_selected_date));
	} else {
		GDate today = {0};
		GDate _tmp0_ = {0};
		ft_date_utils_get_today (&_tmp0_);
		today = _tmp0_;
		ft_month_chooser_set_display_year (self, g_date_get_year (&today));
	}
}

static void
ft_month_chooser_real_map (GtkWidget* base)
{
	FtMonthChooser * self;
	self = (FtMonthChooser*) base;
	ft_month_chooser_reset (self);
	ft_month_chooser_create_months (self);
	ft_month_chooser_update_selection (self);
	GTK_WIDGET_CLASS (ft_month_chooser_parent_class)->map ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, adw_bin_get_type (), AdwBin));
}

static void
ft_month_chooser_real_unmap (GtkWidget* base)
{
	FtMonthChooser * self;
	self = (FtMonthChooser*) base;
	GTK_WIDGET_CLASS (ft_month_chooser_parent_class)->unmap ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, adw_bin_get_type (), AdwBin));
	ft_month_chooser_clear_months (self);
}

static void
ft_month_chooser_real_dispose (GObject* base)
{
	FtMonthChooser * self;
	self = (FtMonthChooser*) base;
	self->priv->selected_button = NULL;
	G_OBJECT_CLASS (ft_month_chooser_parent_class)->dispose ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, adw_bin_get_type (), AdwBin));
}

FtMonthChooser*
ft_month_chooser_construct (GType object_type)
{
	FtMonthChooser * self = NULL;
	self = (FtMonthChooser*) g_object_new (object_type, NULL);
	return self;
}

FtMonthChooser*
ft_month_chooser_new (void)
{
	return ft_month_chooser_construct (FT_TYPE_MONTH_CHOOSER);
}

void
ft_month_chooser_get_selected_date (FtMonthChooser* self,
                                    GDate * result)
{
	GDate _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_selected_date;
	*result = _tmp0_;
	return;
}

void
ft_month_chooser_set_selected_date (FtMonthChooser* self,
                                    GDate * value)
{
	GDate* _tmp0_;
	GDate* _tmp1_;
	GDateYear display_year = (GDateYear) 0U;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_date_copy (value);
	_tmp1_ = _tmp0_;
	self->priv->_selected_date = *_tmp1_;
	_g_free0 (_tmp1_);
	if (!g_date_valid (&self->priv->_selected_date)) {
		ft_month_chooser_update_selection (self);
		return;
	}
	display_year = g_date_get_year (&self->priv->_selected_date);
	if (self->priv->_display_year != display_year) {
		ft_month_chooser_set_display_year (self, display_year);
	} else {
		ft_month_chooser_update_selection (self);
	}
	g_object_notify_by_pspec ((GObject *) self, ft_month_chooser_properties[FT_MONTH_CHOOSER_SELECTED_DATE_PROPERTY]);
}

void
ft_month_chooser_get_min_date (FtMonthChooser* self,
                               GDate * result)
{
	GDate _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_min_date;
	*result = _tmp0_;
	return;
}

void
ft_month_chooser_set_min_date (FtMonthChooser* self,
                               GDate * value)
{
	GDate* _tmp0_;
	GDate* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_date_copy (value);
	_tmp1_ = _tmp0_;
	self->priv->_min_date = *_tmp1_;
	_g_free0 (_tmp1_);
	ft_month_chooser_update_previous_button (self);
	g_object_notify_by_pspec ((GObject *) self, ft_month_chooser_properties[FT_MONTH_CHOOSER_MIN_DATE_PROPERTY]);
}

void
ft_month_chooser_get_max_date (FtMonthChooser* self,
                               GDate * result)
{
	GDate _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_max_date;
	*result = _tmp0_;
	return;
}

void
ft_month_chooser_set_max_date (FtMonthChooser* self,
                               GDate * value)
{
	GDate* _tmp0_;
	GDate* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_date_copy (value);
	_tmp1_ = _tmp0_;
	self->priv->_max_date = *_tmp1_;
	_g_free0 (_tmp1_);
	ft_month_chooser_update_next_button (self);
	g_object_notify_by_pspec ((GObject *) self, ft_month_chooser_properties[FT_MONTH_CHOOSER_MAX_DATE_PROPERTY]);
}

GDateYear
ft_month_chooser_get_display_year (FtMonthChooser* self)
{
	GDateYear result;
	g_return_val_if_fail (self != NULL, (GDateYear) 0U);
	result = self->priv->_display_year;
	return result;
}

static void
ft_month_chooser_class_init (FtMonthChooserClass * klass,
                             gpointer klass_data)
{
	ft_month_chooser_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FtMonthChooser_private_offset);
	((GtkWidgetClass *) klass)->map = (void (*) (GtkWidget*)) ft_month_chooser_real_map;
	((GtkWidgetClass *) klass)->unmap = (void (*) (GtkWidget*)) ft_month_chooser_real_unmap;
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) ft_month_chooser_real_dispose;
	G_OBJECT_CLASS (klass)->get_property = _vala_ft_month_chooser_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_ft_month_chooser_set_property;
	G_OBJECT_CLASS (klass)->finalize = ft_month_chooser_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_MONTH_CHOOSER_SELECTED_DATE_PROPERTY, ft_month_chooser_properties[FT_MONTH_CHOOSER_SELECTED_DATE_PROPERTY] = g_param_spec_boxed ("selected-date", "selected-date", "selected-date", G_TYPE_DATE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_MONTH_CHOOSER_MIN_DATE_PROPERTY, ft_month_chooser_properties[FT_MONTH_CHOOSER_MIN_DATE_PROPERTY] = g_param_spec_boxed ("min-date", "min-date", "min-date", G_TYPE_DATE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_MONTH_CHOOSER_MAX_DATE_PROPERTY, ft_month_chooser_properties[FT_MONTH_CHOOSER_MAX_DATE_PROPERTY] = g_param_spec_boxed ("max-date", "max-date", "max-date", G_TYPE_DATE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_MONTH_CHOOSER_DISPLAY_YEAR_PROPERTY, ft_month_chooser_properties[FT_MONTH_CHOOSER_DISPLAY_YEAR_PROPERTY] = g_param_spec_uint ("display-year", "display-year", "display-year", 0, G_MAXUINT, 0U, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/io/github/focustimerhq/FocusTimer/ui/main/stats/widgets/month-chooser.ui");
	ft_month_chooser_signals[FT_MONTH_CHOOSER_SELECTED_SIGNAL] = g_signal_new ("selected", FT_TYPE_MONTH_CHOOSER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__BOXED, G_TYPE_NONE, 1, G_TYPE_DATE);
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "header_label", FALSE, FtMonthChooser_private_offset + G_STRUCT_OFFSET (FtMonthChooserPrivate, header_label));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "previous_button", FALSE, FtMonthChooser_private_offset + G_STRUCT_OFFSET (FtMonthChooserPrivate, previous_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "next_button", FALSE, FtMonthChooser_private_offset + G_STRUCT_OFFSET (FtMonthChooserPrivate, next_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "grid", FALSE, FtMonthChooser_private_offset + G_STRUCT_OFFSET (FtMonthChooserPrivate, grid));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_previous_button_clicked", G_CALLBACK(_ft_month_chooser_on_previous_button_clicked_gtk_button_clicked));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_next_button_clicked", G_CALLBACK(_ft_month_chooser_on_next_button_clicked_gtk_button_clicked));
	gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (klass), "calendar");
}

static void
ft_month_chooser_instance_init (FtMonthChooser * self,
                                gpointer klass)
{
	self->priv = ft_month_chooser_get_instance_private (self);
	self->priv->selected_button = NULL;
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
ft_month_chooser_finalize (GObject * obj)
{
	FtMonthChooser * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_MONTH_CHOOSER, FtMonthChooser);
	G_OBJECT_CLASS (ft_month_chooser_parent_class)->finalize (obj);
}

static GType
ft_month_chooser_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtMonthChooserClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_month_chooser_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtMonthChooser), 0, (GInstanceInitFunc) ft_month_chooser_instance_init, NULL };
	GType ft_month_chooser_type_id;
	ft_month_chooser_type_id = g_type_register_static (adw_bin_get_type (), "FtMonthChooser", &g_define_type_info, 0);
	FtMonthChooser_private_offset = g_type_add_instance_private (ft_month_chooser_type_id, sizeof (FtMonthChooserPrivate));
	return ft_month_chooser_type_id;
}

GType
ft_month_chooser_get_type (void)
{
	static volatile gsize ft_month_chooser_type_id__once = 0;
	if (g_once_init_enter (&ft_month_chooser_type_id__once)) {
		GType ft_month_chooser_type_id;
		ft_month_chooser_type_id = ft_month_chooser_get_type_once ();
		g_once_init_leave (&ft_month_chooser_type_id__once, ft_month_chooser_type_id);
	}
	return ft_month_chooser_type_id__once;
}

static void
_vala_ft_month_chooser_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec)
{
	FtMonthChooser * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_MONTH_CHOOSER, FtMonthChooser);
	switch (property_id) {
		case FT_MONTH_CHOOSER_SELECTED_DATE_PROPERTY:
		{
			GDate boxed;
			ft_month_chooser_get_selected_date (self, &boxed);
			g_value_set_boxed (value, &boxed);
		}
		break;
		case FT_MONTH_CHOOSER_MIN_DATE_PROPERTY:
		{
			GDate boxed;
			ft_month_chooser_get_min_date (self, &boxed);
			g_value_set_boxed (value, &boxed);
		}
		break;
		case FT_MONTH_CHOOSER_MAX_DATE_PROPERTY:
		{
			GDate boxed;
			ft_month_chooser_get_max_date (self, &boxed);
			g_value_set_boxed (value, &boxed);
		}
		break;
		case FT_MONTH_CHOOSER_DISPLAY_YEAR_PROPERTY:
		g_value_set_uint (value, ft_month_chooser_get_display_year (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_ft_month_chooser_set_property (GObject * object,
                                     guint property_id,
                                     const GValue * value,
                                     GParamSpec * pspec)
{
	FtMonthChooser * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_MONTH_CHOOSER, FtMonthChooser);
	switch (property_id) {
		case FT_MONTH_CHOOSER_SELECTED_DATE_PROPERTY:
		ft_month_chooser_set_selected_date (self, g_value_get_boxed (value));
		break;
		case FT_MONTH_CHOOSER_MIN_DATE_PROPERTY:
		ft_month_chooser_set_min_date (self, g_value_get_boxed (value));
		break;
		case FT_MONTH_CHOOSER_MAX_DATE_PROPERTY:
		ft_month_chooser_set_max_date (self, g_value_get_boxed (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

