/* Calendar.c generated by valac 0.56.19, the Vala compiler
 * generated from Calendar.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 <gee.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <float.h>
#include <math.h>
#include <gio/gio.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

enum  {
	WIDGETS_CALENDAR_CALENDAR_0_PROPERTY,
	WIDGETS_CALENDAR_CALENDAR_BLOCK_PAST_DAYS_PROPERTY,
	WIDGETS_CALENDAR_CALENDAR_CURRENT_DATE_PROPERTY,
	WIDGETS_CALENDAR_CALENDAR_DATE_PROPERTY,
	WIDGETS_CALENDAR_CALENDAR_NUM_PROPERTIES
};
static GParamSpec* widgets_calendar_calendar_properties[WIDGETS_CALENDAR_CALENDAR_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))
enum  {
	WIDGETS_CALENDAR_CALENDAR_DAY_SELECTED_SIGNAL,
	WIDGETS_CALENDAR_CALENDAR_NUM_SIGNALS
};
static guint widgets_calendar_calendar_signals[WIDGETS_CALENDAR_CALENDAR_NUM_SIGNALS] = {0};

struct _WidgetsCalendarCalendarPrivate {
	WidgetsCalendarCalendarHeader* calendar_header;
	WidgetsCalendarCalendarWeek* calendar_week;
	WidgetsCalendarCalendarView* calendar_view;
	gboolean _block_past_days;
	gint month_nav;
	gint year_nav;
	gint day_nav;
	GDateTime* _current_date;
	GDateTime* _date;
	GeeHashMap* signal_map;
};

static gint WidgetsCalendarCalendar_private_offset;
static gpointer widgets_calendar_calendar_parent_class = NULL;

static void widgets_calendar_calendar_fill_days (WidgetsCalendarCalendar* self,
                                          GDateTime* date,
                                          gboolean show_day);
static void widgets_calendar_calendar_today (WidgetsCalendarCalendar* self);
static void widgets_calendar_calendar_view_date (WidgetsCalendarCalendar* self,
                                          GDateTime* date);
static GObject * widgets_calendar_calendar_constructor (GType type,
                                                 guint n_construct_properties,
                                                 GObjectConstructParam * construct_properties);
static void _widgets_calendar_calendar___lambda161_ (WidgetsCalendarCalendar* self);
static void __widgets_calendar_calendar___lambda161__widgets_calendar_calendar_header_left_clicked (WidgetsCalendarCalendarHeader* _sender,
                                                                                             gpointer self);
static void _widgets_calendar_calendar___lambda162_ (WidgetsCalendarCalendar* self);
static void __widgets_calendar_calendar___lambda162__widgets_calendar_calendar_header_center_clicked (WidgetsCalendarCalendarHeader* _sender,
                                                                                               gpointer self);
static void _widgets_calendar_calendar___lambda163_ (WidgetsCalendarCalendar* self);
static void __widgets_calendar_calendar___lambda163__widgets_calendar_calendar_header_right_clicked (WidgetsCalendarCalendarHeader* _sender,
                                                                                              gpointer self);
static void _widgets_calendar_calendar___lambda164_ (WidgetsCalendarCalendar* self,
                                              gint day);
static void __widgets_calendar_calendar___lambda164__widgets_calendar_calendar_view_day_selected (WidgetsCalendarCalendarView* _sender,
                                                                                           gint day,
                                                                                           gpointer self);
static void _widgets_calendar_calendar___lambda165_ (WidgetsCalendarCalendar* self);
static void __widgets_calendar_calendar___lambda165__g_settings_changed (GSettings* _sender,
                                                                  const gchar* key,
                                                                  gpointer self);
static void _widgets_calendar_calendar___lambda166_ (WidgetsCalendarCalendar* self);
static void __widgets_calendar_calendar___lambda166__gtk_widget_destroy (GtkWidget* _sender,
                                                                  gpointer self);
static void widgets_calendar_calendar_finalize (GObject * obj);
static GType widgets_calendar_calendar_get_type_once (void);
static void _vala_widgets_calendar_calendar_get_property (GObject * object,
                                                   guint property_id,
                                                   GValue * value,
                                                   GParamSpec * pspec);
static void _vala_widgets_calendar_calendar_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
widgets_calendar_calendar_get_instance_private (WidgetsCalendarCalendar* self)
{
	return G_STRUCT_MEMBER_P (self, WidgetsCalendarCalendar_private_offset);
}

WidgetsCalendarCalendar*
widgets_calendar_calendar_construct (GType object_type,
                                     gboolean block_past_days)
{
	WidgetsCalendarCalendar * self = NULL;
	self = (WidgetsCalendarCalendar*) g_object_new (object_type, "block-past-days", block_past_days, "orientation", GTK_ORIENTATION_VERTICAL, NULL);
	return self;
}

WidgetsCalendarCalendar*
widgets_calendar_calendar_new (gboolean block_past_days)
{
	return widgets_calendar_calendar_construct (WIDGETS_CALENDAR_TYPE_CALENDAR, block_past_days);
}

void
widgets_calendar_calendar_next_month (WidgetsCalendarCalendar* self)
{
	GDateTime* date = NULL;
	GDateTime* _tmp0_;
	g_return_if_fail (self != NULL);
	self->priv->month_nav = self->priv->month_nav + 1;
	if (self->priv->month_nav > 12) {
		self->priv->year_nav = self->priv->year_nav + 1;
		self->priv->month_nav = 1;
	}
	_tmp0_ = g_date_time_new_local (self->priv->year_nav, self->priv->month_nav, 1, 0, 0, (gdouble) 0);
	date = _tmp0_;
	widgets_calendar_calendar_fill_days (self, date, FALSE);
	_g_date_time_unref0 (date);
}

void
widgets_calendar_calendar_previous_month (WidgetsCalendarCalendar* self)
{
	GDateTime* date = NULL;
	GDateTime* _tmp0_;
	g_return_if_fail (self != NULL);
	self->priv->month_nav = self->priv->month_nav - 1;
	if (self->priv->month_nav < 1) {
		self->priv->year_nav = self->priv->year_nav - 1;
		self->priv->month_nav = 12;
	}
	_tmp0_ = g_date_time_new_local (self->priv->year_nav, self->priv->month_nav, 1, 0, 0, (gdouble) 0);
	date = _tmp0_;
	widgets_calendar_calendar_fill_days (self, date, FALSE);
	_g_date_time_unref0 (date);
}

static void
widgets_calendar_calendar_today (WidgetsCalendarCalendar* self)
{
	GDateTime* _tmp0_;
	GDateTime* _tmp1_;
	GDateTime* _tmp2_;
	GDateTime* _tmp3_;
	GDateTime* _tmp4_;
	GDateTime* _tmp5_;
	GDateTime* _tmp6_;
	GDateTime* _tmp7_;
	g_return_if_fail (self != NULL);
	_tmp0_ = widgets_calendar_calendar_get_current_date (self);
	_tmp1_ = _tmp0_;
	self->priv->year_nav = g_date_time_get_year (_tmp1_);
	_tmp2_ = widgets_calendar_calendar_get_current_date (self);
	_tmp3_ = _tmp2_;
	self->priv->month_nav = g_date_time_get_month (_tmp3_);
	_tmp4_ = widgets_calendar_calendar_get_current_date (self);
	_tmp5_ = _tmp4_;
	self->priv->day_nav = g_date_time_get_day_of_month (_tmp5_);
	_tmp6_ = widgets_calendar_calendar_get_current_date (self);
	_tmp7_ = _tmp6_;
	widgets_calendar_calendar_fill_days (self, _tmp7_, FALSE);
}

static void
widgets_calendar_calendar_view_date (WidgetsCalendarCalendar* self,
                                     GDateTime* date)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (date != NULL);
	if (date == NULL) {
		return;
	}
	self->priv->year_nav = g_date_time_get_year (date);
	self->priv->month_nav = g_date_time_get_month (date);
	self->priv->day_nav = g_date_time_get_day_of_month (date);
	widgets_calendar_calendar_fill_days (self, date, TRUE);
}

static void
widgets_calendar_calendar_fill_days (WidgetsCalendarCalendar* self,
                                     GDateTime* date,
                                     gboolean show_day)
{
	GDateTime* firts_week = NULL;
	GDateTime* _tmp0_;
	gint start_day = 0;
	GDateTime* _tmp1_;
	ServicesSettings* _tmp2_;
	ServicesSettings* _tmp3_;
	GSettings* _tmp4_;
	gint _tmp5_;
	gint max_days = 0;
	WidgetsCalendarCalendarView* _tmp6_;
	gboolean _tmp7_;
	WidgetsCalendarCalendarHeader* _tmp8_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (date != NULL);
	_tmp0_ = g_date_time_new_local (self->priv->year_nav, self->priv->month_nav, 1, 0, 0, (gdouble) 0);
	firts_week = _tmp0_;
	_tmp1_ = firts_week;
	_tmp2_ = services_settings_get_default ();
	_tmp3_ = _tmp2_;
	_tmp4_ = _tmp3_->settings;
	_tmp5_ = g_date_time_get_day_of_week (_tmp1_) - g_settings_get_enum (_tmp4_, "start-week");
	_g_object_unref0 (_tmp3_);
	start_day = _tmp5_;
	if (start_day < 0) {
		start_day += 7;
	}
	start_day = (start_day + 7) % 7;
	max_days = utils_datetime_get_days_of_month (g_date_time_get_month (date), self->priv->year_nav);
	_tmp6_ = self->priv->calendar_view;
	_tmp7_ = self->priv->_block_past_days;
	widgets_calendar_calendar_view_fill_grid_days (_tmp6_, start_day, max_days, date, show_day, _tmp7_);
	_tmp8_ = self->priv->calendar_header;
	widgets_calendar_calendar_header_set_date (_tmp8_, date);
	_g_date_time_unref0 (firts_week);
}

void
widgets_calendar_calendar_reset (WidgetsCalendarCalendar* self)
{
	WidgetsCalendarCalendarView* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->calendar_view;
	widgets_calendar_calendar_view_clear_style (_tmp0_);
}

void
widgets_calendar_calendar_clean_up (WidgetsCalendarCalendar* self)
{
	WidgetsCalendarCalendarView* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->calendar_view;
	widgets_calendar_calendar_view_clean_up (_tmp0_);
}

gboolean
widgets_calendar_calendar_get_block_past_days (WidgetsCalendarCalendar* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_block_past_days;
	return result;
}

static void
widgets_calendar_calendar_set_block_past_days (WidgetsCalendarCalendar* self,
                                               gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = widgets_calendar_calendar_get_block_past_days (self);
	if (old_value != value) {
		self->priv->_block_past_days = value;
		g_object_notify_by_pspec ((GObject *) self, widgets_calendar_calendar_properties[WIDGETS_CALENDAR_CALENDAR_BLOCK_PAST_DAYS_PROPERTY]);
	}
}

GDateTime*
widgets_calendar_calendar_get_current_date (WidgetsCalendarCalendar* self)
{
	GDateTime* result;
	GDateTime* _tmp0_;
	GDateTime* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_date_time_new_now_local ();
	_g_date_time_unref0 (self->priv->_current_date);
	self->priv->_current_date = _tmp0_;
	_tmp1_ = self->priv->_current_date;
	result = _tmp1_;
	return result;
}

GDateTime*
widgets_calendar_calendar_get_date (WidgetsCalendarCalendar* self)
{
	GDateTime* result;
	GDateTime* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_date;
	result = _tmp0_;
	return result;
}

static gpointer
_g_date_time_ref0 (gpointer self)
{
	return self ? g_date_time_ref (self) : NULL;
}

void
widgets_calendar_calendar_set_date (WidgetsCalendarCalendar* self,
                                    GDateTime* value)
{
	GDateTime* _tmp0_;
	GDateTime* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_date_time_ref0 (value);
	_g_date_time_unref0 (self->priv->_date);
	self->priv->_date = _tmp0_;
	_tmp1_ = self->priv->_date;
	if (_tmp1_ != NULL) {
		GDateTime* _tmp2_;
		_tmp2_ = self->priv->_date;
		widgets_calendar_calendar_view_date (self, _tmp2_);
	}
	g_object_notify_by_pspec ((GObject *) self, widgets_calendar_calendar_properties[WIDGETS_CALENDAR_CALENDAR_DATE_PROPERTY]);
}

static void
_widgets_calendar_calendar___lambda161_ (WidgetsCalendarCalendar* self)
{
	widgets_calendar_calendar_previous_month (self);
}

static void
__widgets_calendar_calendar___lambda161__widgets_calendar_calendar_header_left_clicked (WidgetsCalendarCalendarHeader* _sender,
                                                                                        gpointer self)
{
	_widgets_calendar_calendar___lambda161_ ((WidgetsCalendarCalendar*) self);
}

static void
_widgets_calendar_calendar___lambda162_ (WidgetsCalendarCalendar* self)
{
	widgets_calendar_calendar_today (self);
}

static void
__widgets_calendar_calendar___lambda162__widgets_calendar_calendar_header_center_clicked (WidgetsCalendarCalendarHeader* _sender,
                                                                                          gpointer self)
{
	_widgets_calendar_calendar___lambda162_ ((WidgetsCalendarCalendar*) self);
}

static void
_widgets_calendar_calendar___lambda163_ (WidgetsCalendarCalendar* self)
{
	widgets_calendar_calendar_next_month (self);
}

static void
__widgets_calendar_calendar___lambda163__widgets_calendar_calendar_header_right_clicked (WidgetsCalendarCalendarHeader* _sender,
                                                                                         gpointer self)
{
	_widgets_calendar_calendar___lambda163_ ((WidgetsCalendarCalendar*) self);
}

static void
_widgets_calendar_calendar___lambda164_ (WidgetsCalendarCalendar* self,
                                         gint day)
{
	GDateTime* _tmp0_;
	self->priv->day_nav = day;
	_tmp0_ = g_date_time_new_local (self->priv->year_nav, self->priv->month_nav, self->priv->day_nav, 0, 0, (gdouble) 0);
	_g_date_time_unref0 (self->priv->_date);
	self->priv->_date = _tmp0_;
	g_signal_emit (self, widgets_calendar_calendar_signals[WIDGETS_CALENDAR_CALENDAR_DAY_SELECTED_SIGNAL], 0);
}

static void
__widgets_calendar_calendar___lambda164__widgets_calendar_calendar_view_day_selected (WidgetsCalendarCalendarView* _sender,
                                                                                      gint day,
                                                                                      gpointer self)
{
	_widgets_calendar_calendar___lambda164_ ((WidgetsCalendarCalendar*) self, day);
}

static void
_widgets_calendar_calendar___lambda165_ (WidgetsCalendarCalendar* self)
{
	WidgetsCalendarCalendarWeek* _tmp0_;
	_tmp0_ = self->priv->calendar_week;
	widgets_calendar_calendar_week_update (_tmp0_);
	widgets_calendar_calendar_today (self);
}

static void
__widgets_calendar_calendar___lambda165__g_settings_changed (GSettings* _sender,
                                                             const gchar* key,
                                                             gpointer self)
{
	_widgets_calendar_calendar___lambda165_ ((WidgetsCalendarCalendar*) self);
}

static void
_widgets_calendar_calendar___lambda166_ (WidgetsCalendarCalendar* self)
{
	widgets_calendar_calendar_clean_up (self);
}

static void
__widgets_calendar_calendar___lambda166__gtk_widget_destroy (GtkWidget* _sender,
                                                             gpointer self)
{
	_widgets_calendar_calendar___lambda166_ ((WidgetsCalendarCalendar*) self);
}

static GObject *
widgets_calendar_calendar_constructor (GType type,
                                       guint n_construct_properties,
                                       GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	WidgetsCalendarCalendar * self;
	WidgetsCalendarCalendarHeader* _tmp0_;
	WidgetsCalendarCalendarWeek* _tmp1_;
	WidgetsCalendarCalendarView* _tmp2_;
	WidgetsCalendarCalendarHeader* _tmp3_;
	WidgetsCalendarCalendarWeek* _tmp4_;
	WidgetsCalendarCalendarView* _tmp5_;
	GeeHashMap* _tmp6_;
	WidgetsCalendarCalendarHeader* _tmp7_;
	gulong _tmp8_;
	WidgetsCalendarCalendarHeader* _tmp9_;
	GeeHashMap* _tmp10_;
	WidgetsCalendarCalendarHeader* _tmp11_;
	gulong _tmp12_;
	WidgetsCalendarCalendarHeader* _tmp13_;
	GeeHashMap* _tmp14_;
	WidgetsCalendarCalendarHeader* _tmp15_;
	gulong _tmp16_;
	WidgetsCalendarCalendarHeader* _tmp17_;
	GeeHashMap* _tmp18_;
	WidgetsCalendarCalendarView* _tmp19_;
	gulong _tmp20_;
	WidgetsCalendarCalendarView* _tmp21_;
	ServicesSettings* _tmp22_;
	ServicesSettings* _tmp23_;
	GSettings* _tmp24_;
	parent_class = G_OBJECT_CLASS (widgets_calendar_calendar_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIDGETS_CALENDAR_TYPE_CALENDAR, WidgetsCalendarCalendar);
	_tmp0_ = widgets_calendar_calendar_header_new ();
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->calendar_header);
	self->priv->calendar_header = _tmp0_;
	_tmp1_ = widgets_calendar_calendar_week_new ();
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->priv->calendar_week);
	self->priv->calendar_week = _tmp1_;
	_tmp2_ = widgets_calendar_calendar_view_new ();
	g_object_ref_sink (_tmp2_);
	_g_object_unref0 (self->priv->calendar_view);
	self->priv->calendar_view = _tmp2_;
	_tmp3_ = self->priv->calendar_header;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp3_);
	_tmp4_ = self->priv->calendar_week;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp4_);
	_tmp5_ = self->priv->calendar_view;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp5_);
	widgets_calendar_calendar_today (self);
	_tmp6_ = self->priv->signal_map;
	_tmp7_ = self->priv->calendar_header;
	_tmp8_ = g_signal_connect_object (_tmp7_, "left-clicked", (GCallback) __widgets_calendar_calendar___lambda161__widgets_calendar_calendar_header_left_clicked, self, 0);
	_tmp9_ = self->priv->calendar_header;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp6_, (gpointer) ((guintptr) _tmp8_), (GObject*) _tmp9_);
	_tmp10_ = self->priv->signal_map;
	_tmp11_ = self->priv->calendar_header;
	_tmp12_ = g_signal_connect_object (_tmp11_, "center-clicked", (GCallback) __widgets_calendar_calendar___lambda162__widgets_calendar_calendar_header_center_clicked, self, 0);
	_tmp13_ = self->priv->calendar_header;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp10_, (gpointer) ((guintptr) _tmp12_), (GObject*) _tmp13_);
	_tmp14_ = self->priv->signal_map;
	_tmp15_ = self->priv->calendar_header;
	_tmp16_ = g_signal_connect_object (_tmp15_, "right-clicked", (GCallback) __widgets_calendar_calendar___lambda163__widgets_calendar_calendar_header_right_clicked, self, 0);
	_tmp17_ = self->priv->calendar_header;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp14_, (gpointer) ((guintptr) _tmp16_), (GObject*) _tmp17_);
	_tmp18_ = self->priv->signal_map;
	_tmp19_ = self->priv->calendar_view;
	_tmp20_ = g_signal_connect_object (_tmp19_, "day-selected", (GCallback) __widgets_calendar_calendar___lambda164__widgets_calendar_calendar_view_day_selected, self, 0);
	_tmp21_ = self->priv->calendar_view;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp18_, (gpointer) ((guintptr) _tmp20_), (GObject*) _tmp21_);
	_tmp22_ = services_settings_get_default ();
	_tmp23_ = _tmp22_;
	_tmp24_ = _tmp23_->settings;
	g_signal_connect_object (_tmp24_, "changed::start-week", (GCallback) __widgets_calendar_calendar___lambda165__g_settings_changed, self, 0);
	_g_object_unref0 (_tmp23_);
	g_signal_connect_object ((GtkWidget*) self, "destroy", (GCallback) __widgets_calendar_calendar___lambda166__gtk_widget_destroy, self, 0);
	return obj;
}

static void
widgets_calendar_calendar_class_init (WidgetsCalendarCalendarClass * klass,
                                      gpointer klass_data)
{
	widgets_calendar_calendar_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &WidgetsCalendarCalendar_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_widgets_calendar_calendar_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_widgets_calendar_calendar_set_property;
	G_OBJECT_CLASS (klass)->constructor = widgets_calendar_calendar_constructor;
	G_OBJECT_CLASS (klass)->finalize = widgets_calendar_calendar_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), WIDGETS_CALENDAR_CALENDAR_BLOCK_PAST_DAYS_PROPERTY, widgets_calendar_calendar_properties[WIDGETS_CALENDAR_CALENDAR_BLOCK_PAST_DAYS_PROPERTY] = g_param_spec_boolean ("block-past-days", "block-past-days", "block-past-days", 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_CALENDAR_CALENDAR_CURRENT_DATE_PROPERTY, widgets_calendar_calendar_properties[WIDGETS_CALENDAR_CALENDAR_CURRENT_DATE_PROPERTY] = g_param_spec_boxed ("current-date", "current-date", "current-date", G_TYPE_DATE_TIME, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), WIDGETS_CALENDAR_CALENDAR_DATE_PROPERTY, widgets_calendar_calendar_properties[WIDGETS_CALENDAR_CALENDAR_DATE_PROPERTY] = g_param_spec_boxed ("date", "date", "date", G_TYPE_DATE_TIME, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	widgets_calendar_calendar_signals[WIDGETS_CALENDAR_CALENDAR_DAY_SELECTED_SIGNAL] = g_signal_new ("day-selected", WIDGETS_CALENDAR_TYPE_CALENDAR, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
widgets_calendar_calendar_instance_init (WidgetsCalendarCalendar * self,
                                         gpointer klass)
{
	GeeHashMap* _tmp0_;
	self->priv = widgets_calendar_calendar_get_instance_private (self);
	_tmp0_ = gee_hash_map_new (G_TYPE_ULONG, NULL, NULL, G_TYPE_OBJECT, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	self->priv->signal_map = _tmp0_;
}

static void
widgets_calendar_calendar_finalize (GObject * obj)
{
	WidgetsCalendarCalendar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIDGETS_CALENDAR_TYPE_CALENDAR, WidgetsCalendarCalendar);
	g_debug ("Calendar.vala:67: Destroying - Widgets.Calendar.Calendar\n");
	_g_object_unref0 (self->priv->calendar_header);
	_g_object_unref0 (self->priv->calendar_week);
	_g_object_unref0 (self->priv->calendar_view);
	_g_date_time_unref0 (self->priv->_current_date);
	_g_date_time_unref0 (self->priv->_date);
	_g_object_unref0 (self->priv->signal_map);
	G_OBJECT_CLASS (widgets_calendar_calendar_parent_class)->finalize (obj);
}

static GType
widgets_calendar_calendar_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (WidgetsCalendarCalendarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) widgets_calendar_calendar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WidgetsCalendarCalendar), 0, (GInstanceInitFunc) widgets_calendar_calendar_instance_init, NULL };
	GType widgets_calendar_calendar_type_id;
	widgets_calendar_calendar_type_id = g_type_register_static (gtk_box_get_type (), "WidgetsCalendarCalendar", &g_define_type_info, 0);
	WidgetsCalendarCalendar_private_offset = g_type_add_instance_private (widgets_calendar_calendar_type_id, sizeof (WidgetsCalendarCalendarPrivate));
	return widgets_calendar_calendar_type_id;
}

GType
widgets_calendar_calendar_get_type (void)
{
	static volatile gsize widgets_calendar_calendar_type_id__once = 0;
	if (g_once_init_enter (&widgets_calendar_calendar_type_id__once)) {
		GType widgets_calendar_calendar_type_id;
		widgets_calendar_calendar_type_id = widgets_calendar_calendar_get_type_once ();
		g_once_init_leave (&widgets_calendar_calendar_type_id__once, widgets_calendar_calendar_type_id);
	}
	return widgets_calendar_calendar_type_id__once;
}

static void
_vala_widgets_calendar_calendar_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec)
{
	WidgetsCalendarCalendar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, WIDGETS_CALENDAR_TYPE_CALENDAR, WidgetsCalendarCalendar);
	switch (property_id) {
		case WIDGETS_CALENDAR_CALENDAR_BLOCK_PAST_DAYS_PROPERTY:
		g_value_set_boolean (value, widgets_calendar_calendar_get_block_past_days (self));
		break;
		case WIDGETS_CALENDAR_CALENDAR_CURRENT_DATE_PROPERTY:
		g_value_set_boxed (value, widgets_calendar_calendar_get_current_date (self));
		break;
		case WIDGETS_CALENDAR_CALENDAR_DATE_PROPERTY:
		g_value_set_boxed (value, widgets_calendar_calendar_get_date (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_widgets_calendar_calendar_set_property (GObject * object,
                                              guint property_id,
                                              const GValue * value,
                                              GParamSpec * pspec)
{
	WidgetsCalendarCalendar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, WIDGETS_CALENDAR_TYPE_CALENDAR, WidgetsCalendarCalendar);
	switch (property_id) {
		case WIDGETS_CALENDAR_CALENDAR_BLOCK_PAST_DAYS_PROPERTY:
		widgets_calendar_calendar_set_block_past_days (self, g_value_get_boolean (value));
		break;
		case WIDGETS_CALENDAR_CALENDAR_DATE_PROPERTY:
		widgets_calendar_calendar_set_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;
}

