/* DatePicker.c generated by valac 0.56.19, the Vala compiler
 * generated from DatePicker.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>
#include <glib/gi18n-lib.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 DIALOGS_TYPE_DATE_PICKER (dialogs_date_picker_get_type ())
#define DIALOGS_DATE_PICKER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DIALOGS_TYPE_DATE_PICKER, DialogsDatePicker))
#define DIALOGS_DATE_PICKER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DIALOGS_TYPE_DATE_PICKER, DialogsDatePickerClass))
#define DIALOGS_IS_DATE_PICKER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DIALOGS_TYPE_DATE_PICKER))
#define DIALOGS_IS_DATE_PICKER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DIALOGS_TYPE_DATE_PICKER))
#define DIALOGS_DATE_PICKER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DIALOGS_TYPE_DATE_PICKER, DialogsDatePickerClass))

typedef struct _DialogsDatePicker DialogsDatePicker;
typedef struct _DialogsDatePickerClass DialogsDatePickerClass;
typedef struct _DialogsDatePickerPrivate DialogsDatePickerPrivate;
enum  {
	DIALOGS_DATE_PICKER_0_PROPERTY,
	DIALOGS_DATE_PICKER_DATETIME_PROPERTY,
	DIALOGS_DATE_PICKER_CLEAR_PROPERTY,
	DIALOGS_DATE_PICKER_NUM_PROPERTIES
};
static GParamSpec* dialogs_date_picker_properties[DIALOGS_DATE_PICKER_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)))
#define _g_free0(var) (var = (g_free (var), NULL))
enum  {
	DIALOGS_DATE_PICKER_DATE_CHANGED_SIGNAL,
	DIALOGS_DATE_PICKER_NUM_SIGNALS
};
static guint dialogs_date_picker_signals[DIALOGS_DATE_PICKER_NUM_SIGNALS] = {0};

struct _DialogsDatePicker {
	AdwDialog parent_instance;
	DialogsDatePickerPrivate * priv;
};

struct _DialogsDatePickerClass {
	AdwDialogClass parent_class;
};

struct _DialogsDatePickerPrivate {
	GtkRevealer* clear_revealer;
	WidgetsCalendarCalendar* calendar_view;
	WidgetsContextMenuMenuItem* no_date_item;
	GDateTime* _datetime;
	GeeHashMap* signal_map;
};

static gint DialogsDatePicker_private_offset;
static gpointer dialogs_date_picker_parent_class = NULL;

VALA_EXTERN GType dialogs_date_picker_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DialogsDatePicker, g_object_unref)
VALA_EXTERN DialogsDatePicker* dialogs_date_picker_new (const gchar* title);
VALA_EXTERN DialogsDatePicker* dialogs_date_picker_construct (GType object_type,
                                                  const gchar* title);
static void dialogs_date_picker_set_date (DialogsDatePicker* self,
                                   GDateTime* date);
VALA_EXTERN void dialogs_date_picker_clean_up (DialogsDatePicker* self);
VALA_EXTERN GDateTime* dialogs_date_picker_get_datetime (DialogsDatePicker* self);
VALA_EXTERN void dialogs_date_picker_set_datetime (DialogsDatePicker* self,
                                       GDateTime* value);
VALA_EXTERN void dialogs_date_picker_set_clear (DialogsDatePicker* self,
                                    gboolean value);
static GObject * dialogs_date_picker_constructor (GType type,
                                           guint n_construct_properties,
                                           GObjectConstructParam * construct_properties);
static void _dialogs_date_picker___lambda658_ (DialogsDatePicker* self);
static void __dialogs_date_picker___lambda658__widgets_context_menu_menu_item_activate_item (WidgetsContextMenuMenuItem* _sender,
                                                                                      gpointer self);
static void _dialogs_date_picker___lambda659_ (DialogsDatePicker* self);
static void __dialogs_date_picker___lambda659__widgets_context_menu_menu_item_activate_item (WidgetsContextMenuMenuItem* _sender,
                                                                                      gpointer self);
static void _dialogs_date_picker___lambda660_ (DialogsDatePicker* self);
static void __dialogs_date_picker___lambda660__widgets_context_menu_menu_item_activate_item (WidgetsContextMenuMenuItem* _sender,
                                                                                      gpointer self);
static void _dialogs_date_picker___lambda661_ (DialogsDatePicker* self);
static void __dialogs_date_picker___lambda661__widgets_context_menu_menu_item_activate_item (WidgetsContextMenuMenuItem* _sender,
                                                                                      gpointer self);
static void _dialogs_date_picker___lambda662_ (DialogsDatePicker* self);
static void __dialogs_date_picker___lambda662__widgets_calendar_calendar_day_selected (WidgetsCalendarCalendar* _sender,
                                                                                gpointer self);
static void _dialogs_date_picker___lambda663_ (DialogsDatePicker* self);
static void __dialogs_date_picker___lambda663__gtk_button_clicked (GtkButton* _sender,
                                                            gpointer self);
static void _dialogs_date_picker___lambda664_ (DialogsDatePicker* self);
static void __dialogs_date_picker___lambda664__adw_dialog_closed (AdwDialog* _sender,
                                                           gpointer self);
static void dialogs_date_picker_finalize (GObject * obj);
static GType dialogs_date_picker_get_type_once (void);
static void _vala_dialogs_date_picker_get_property (GObject * object,
                                             guint property_id,
                                             GValue * value,
                                             GParamSpec * pspec);
static void _vala_dialogs_date_picker_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
dialogs_date_picker_get_instance_private (DialogsDatePicker* self)
{
	return G_STRUCT_MEMBER_P (self, DialogsDatePicker_private_offset);
}

DialogsDatePicker*
dialogs_date_picker_construct (GType object_type,
                               const gchar* title)
{
	DialogsDatePicker * self = NULL;
	g_return_val_if_fail (title != NULL, NULL);
	self = (DialogsDatePicker*) g_object_new (object_type, "title", title, "content-width", 320, "content-height", 450, NULL);
	return self;
}

DialogsDatePicker*
dialogs_date_picker_new (const gchar* title)
{
	return dialogs_date_picker_construct (DIALOGS_TYPE_DATE_PICKER, title);
}

static void
dialogs_date_picker_set_date (DialogsDatePicker* self,
                              GDateTime* date)
{
	GDateTime* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = utils_datetime_get_date_only (date);
	_g_date_time_unref0 (self->priv->_datetime);
	self->priv->_datetime = _tmp0_;
	g_signal_emit (self, dialogs_date_picker_signals[DIALOGS_DATE_PICKER_DATE_CHANGED_SIGNAL], 0);
	adw_dialog_close ((AdwDialog*) self);
}

void
dialogs_date_picker_clean_up (DialogsDatePicker* self)
{
	GeeHashMap* _tmp15_;
	WidgetsCalendarCalendar* _tmp16_;
	g_return_if_fail (self != NULL);
	{
		GeeIterator* _entry_it = NULL;
		GeeHashMap* _tmp0_;
		GeeSet* _tmp1_;
		GeeSet* _tmp2_;
		GeeSet* _tmp3_;
		GeeIterator* _tmp4_;
		GeeIterator* _tmp5_;
		_tmp0_ = self->priv->signal_map;
		_tmp1_ = gee_abstract_map_get_entries ((GeeAbstractMap*) _tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = _tmp2_;
		_tmp4_ = gee_iterable_iterator ((GeeIterable*) _tmp3_);
		_tmp5_ = _tmp4_;
		_g_object_unref0 (_tmp3_);
		_entry_it = _tmp5_;
		while (TRUE) {
			GeeIterator* _tmp6_;
			GeeMapEntry* entry = NULL;
			GeeIterator* _tmp7_;
			gpointer _tmp8_;
			GeeMapEntry* _tmp9_;
			gconstpointer _tmp10_;
			gconstpointer _tmp11_;
			GeeMapEntry* _tmp12_;
			gconstpointer _tmp13_;
			gconstpointer _tmp14_;
			_tmp6_ = _entry_it;
			if (!gee_iterator_next (_tmp6_)) {
				break;
			}
			_tmp7_ = _entry_it;
			_tmp8_ = gee_iterator_get (_tmp7_);
			entry = (GeeMapEntry*) _tmp8_;
			_tmp9_ = entry;
			_tmp10_ = gee_map_entry_get_value (_tmp9_);
			_tmp11_ = _tmp10_;
			_tmp12_ = entry;
			_tmp13_ = gee_map_entry_get_key (_tmp12_);
			_tmp14_ = _tmp13_;
			g_signal_handler_disconnect ((GObject*) _tmp11_, (gulong) ((guintptr) _tmp14_));
			_g_object_unref0 (entry);
		}
		_g_object_unref0 (_entry_it);
	}
	_tmp15_ = self->priv->signal_map;
	gee_abstract_map_clear ((GeeAbstractMap*) _tmp15_);
	_tmp16_ = self->priv->calendar_view;
	if (_tmp16_ != NULL) {
		WidgetsCalendarCalendar* _tmp17_;
		_tmp17_ = self->priv->calendar_view;
		widgets_calendar_calendar_clean_up (_tmp17_);
	}
}

GDateTime*
dialogs_date_picker_get_datetime (DialogsDatePicker* self)
{
	GDateTime* result;
	GDateTime* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_datetime;
	result = _tmp0_;
	return result;
}

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

void
dialogs_date_picker_set_datetime (DialogsDatePicker* self,
                                  GDateTime* value)
{
	GDateTime* _tmp0_;
	WidgetsCalendarCalendar* _tmp1_;
	GDateTime* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_date_time_ref0 (value);
	_g_date_time_unref0 (self->priv->_datetime);
	self->priv->_datetime = _tmp0_;
	_tmp1_ = self->priv->calendar_view;
	_tmp2_ = self->priv->_datetime;
	widgets_calendar_calendar_set_date (_tmp1_, _tmp2_);
	g_object_notify_by_pspec ((GObject *) self, dialogs_date_picker_properties[DIALOGS_DATE_PICKER_DATETIME_PROPERTY]);
}

void
dialogs_date_picker_set_clear (DialogsDatePicker* self,
                               gboolean value)
{
	GtkRevealer* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->clear_revealer;
	gtk_revealer_set_reveal_child (_tmp0_, value);
	g_object_notify_by_pspec ((GObject *) self, dialogs_date_picker_properties[DIALOGS_DATE_PICKER_CLEAR_PROPERTY]);
}

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

static void
_dialogs_date_picker___lambda658_ (DialogsDatePicker* self)
{
	GDateTime* _tmp0_;
	GDateTime* _tmp1_;
	_tmp0_ = g_date_time_new_now_local ();
	_tmp1_ = _tmp0_;
	dialogs_date_picker_set_date (self, _tmp1_);
	_g_date_time_unref0 (_tmp1_);
}

static void
__dialogs_date_picker___lambda658__widgets_context_menu_menu_item_activate_item (WidgetsContextMenuMenuItem* _sender,
                                                                                 gpointer self)
{
	_dialogs_date_picker___lambda658_ ((DialogsDatePicker*) self);
}

static void
_dialogs_date_picker___lambda659_ (DialogsDatePicker* self)
{
	GDateTime* _tmp0_;
	GDateTime* _tmp1_;
	GDateTime* _tmp2_;
	GDateTime* _tmp3_;
	_tmp0_ = g_date_time_new_now_local ();
	_tmp1_ = _tmp0_;
	_tmp2_ = g_date_time_add_days (_tmp1_, 1);
	_tmp3_ = _tmp2_;
	dialogs_date_picker_set_date (self, _tmp3_);
	_g_date_time_unref0 (_tmp3_);
	_g_date_time_unref0 (_tmp1_);
}

static void
__dialogs_date_picker___lambda659__widgets_context_menu_menu_item_activate_item (WidgetsContextMenuMenuItem* _sender,
                                                                                 gpointer self)
{
	_dialogs_date_picker___lambda659_ ((DialogsDatePicker*) self);
}

static void
_dialogs_date_picker___lambda660_ (DialogsDatePicker* self)
{
	GDateTime* _tmp0_;
	GDateTime* _tmp1_;
	GDateTime* _tmp2_;
	GDateTime* _tmp3_;
	_tmp0_ = g_date_time_new_now_local ();
	_tmp1_ = _tmp0_;
	_tmp2_ = g_date_time_add_days (_tmp1_, 7);
	_tmp3_ = _tmp2_;
	dialogs_date_picker_set_date (self, _tmp3_);
	_g_date_time_unref0 (_tmp3_);
	_g_date_time_unref0 (_tmp1_);
}

static void
__dialogs_date_picker___lambda660__widgets_context_menu_menu_item_activate_item (WidgetsContextMenuMenuItem* _sender,
                                                                                 gpointer self)
{
	_dialogs_date_picker___lambda660_ ((DialogsDatePicker*) self);
}

static void
_dialogs_date_picker___lambda661_ (DialogsDatePicker* self)
{
	_g_date_time_unref0 (self->priv->_datetime);
	self->priv->_datetime = NULL;
	g_signal_emit (self, dialogs_date_picker_signals[DIALOGS_DATE_PICKER_DATE_CHANGED_SIGNAL], 0);
	adw_dialog_close ((AdwDialog*) self);
}

static void
__dialogs_date_picker___lambda661__widgets_context_menu_menu_item_activate_item (WidgetsContextMenuMenuItem* _sender,
                                                                                 gpointer self)
{
	_dialogs_date_picker___lambda661_ ((DialogsDatePicker*) self);
}

static void
_dialogs_date_picker___lambda662_ (DialogsDatePicker* self)
{
	WidgetsCalendarCalendar* _tmp0_;
	GDateTime* _tmp1_;
	GDateTime* _tmp2_;
	GDateTime* _tmp3_;
	_tmp0_ = self->priv->calendar_view;
	_tmp1_ = widgets_calendar_calendar_get_date (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_date_time_ref0 (_tmp2_);
	_g_date_time_unref0 (self->priv->_datetime);
	self->priv->_datetime = _tmp3_;
}

static void
__dialogs_date_picker___lambda662__widgets_calendar_calendar_day_selected (WidgetsCalendarCalendar* _sender,
                                                                           gpointer self)
{
	_dialogs_date_picker___lambda662_ ((DialogsDatePicker*) self);
}

static void
_dialogs_date_picker___lambda663_ (DialogsDatePicker* self)
{
	GDateTime* _tmp0_;
	_tmp0_ = self->priv->_datetime;
	dialogs_date_picker_set_date (self, _tmp0_);
	g_signal_emit (self, dialogs_date_picker_signals[DIALOGS_DATE_PICKER_DATE_CHANGED_SIGNAL], 0);
	adw_dialog_close ((AdwDialog*) self);
}

static void
__dialogs_date_picker___lambda663__gtk_button_clicked (GtkButton* _sender,
                                                       gpointer self)
{
	_dialogs_date_picker___lambda663_ ((DialogsDatePicker*) self);
}

static void
_dialogs_date_picker___lambda664_ (DialogsDatePicker* self)
{
	ServicesEventBus* _tmp0_;
	ServicesEventBus* _tmp1_;
	dialogs_date_picker_clean_up (self);
	_tmp0_ = services_event_bus_get_default ();
	_tmp1_ = _tmp0_;
	g_signal_emit_by_name (_tmp1_, "connect-typing-accel");
	_g_object_unref0 (_tmp1_);
}

static void
__dialogs_date_picker___lambda664__adw_dialog_closed (AdwDialog* _sender,
                                                      gpointer self)
{
	_dialogs_date_picker___lambda664_ ((DialogsDatePicker*) self);
}

static GObject *
dialogs_date_picker_constructor (GType type,
                                 guint n_construct_properties,
                                 GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	DialogsDatePicker * self;
	WidgetsContextMenuMenuItem* today_item = NULL;
	WidgetsContextMenuMenuItem* _tmp0_;
	WidgetsContextMenuMenuItem* _tmp1_;
	GDateTime* _tmp2_;
	GDateTime* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	WidgetsContextMenuMenuItem* _tmp6_;
	WidgetsContextMenuMenuItem* tomorrow_item = NULL;
	WidgetsContextMenuMenuItem* _tmp7_;
	WidgetsContextMenuMenuItem* _tmp8_;
	GDateTime* _tmp9_;
	GDateTime* _tmp10_;
	GDateTime* _tmp11_;
	GDateTime* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	WidgetsContextMenuMenuItem* next_week_item = NULL;
	WidgetsContextMenuMenuItem* _tmp15_;
	WidgetsContextMenuMenuItem* _tmp16_;
	GDateTime* _tmp17_;
	GDateTime* _tmp18_;
	GDateTime* _tmp19_;
	GDateTime* _tmp20_;
	GDateTime* _tmp21_;
	GDateTime* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	WidgetsContextMenuMenuItem* _tmp25_;
	WidgetsContextMenuMenuItem* _tmp26_;
	WidgetsContextMenuMenuItem* _tmp27_;
	GtkWidget* _tmp28_;
	GtkRevealer* _tmp29_ = NULL;
	GtkBox* items_card = NULL;
	gchar* _tmp30_;
	gchar** _tmp31_;
	GtkBox* _tmp32_ = NULL;
	GtkBox* _tmp33_;
	WidgetsContextMenuMenuItem* _tmp34_;
	GtkBox* _tmp35_;
	WidgetsContextMenuMenuItem* _tmp36_;
	GtkBox* _tmp37_;
	WidgetsContextMenuMenuItem* _tmp38_;
	GtkBox* _tmp39_;
	GtkRevealer* _tmp40_;
	WidgetsCalendarCalendar* _tmp41_ = NULL;
	AdwBin* calendar_card = NULL;
	gchar* _tmp42_;
	gchar** _tmp43_;
	WidgetsCalendarCalendar* _tmp44_;
	GtkWidget* _tmp45_;
	AdwBin* _tmp46_ = NULL;
	WidgetsLoadingButton* done_button = NULL;
	WidgetsLoadingButton* _tmp47_ = NULL;
	WidgetsLoadingButton* _tmp48_;
	GtkBox* content_box = NULL;
	GtkBox* _tmp49_ = NULL;
	GtkBox* _tmp50_;
	GtkBox* _tmp51_;
	GtkBox* _tmp52_;
	AdwBin* _tmp53_;
	GtkBox* _tmp54_;
	WidgetsLoadingButton* _tmp55_;
	AdwClamp* content_clamp = NULL;
	GtkBox* _tmp56_;
	GtkWidget* _tmp57_;
	AdwClamp* _tmp58_ = NULL;
	AdwToolbarView* toolbar_view = NULL;
	AdwClamp* _tmp59_;
	GtkWidget* _tmp60_;
	AdwToolbarView* _tmp61_ = NULL;
	AdwToolbarView* _tmp62_;
	gchar* _tmp63_;
	gchar** _tmp64_;
	AdwHeaderBar* _tmp65_ = NULL;
	AdwHeaderBar* _tmp66_;
	AdwToolbarView* _tmp67_;
	ServicesEventBus* _tmp68_;
	ServicesEventBus* _tmp69_;
	GeeHashMap* _tmp70_;
	WidgetsContextMenuMenuItem* _tmp71_;
	gulong _tmp72_;
	WidgetsContextMenuMenuItem* _tmp73_;
	GeeHashMap* _tmp74_;
	WidgetsContextMenuMenuItem* _tmp75_;
	gulong _tmp76_;
	WidgetsContextMenuMenuItem* _tmp77_;
	GeeHashMap* _tmp78_;
	WidgetsContextMenuMenuItem* _tmp79_;
	gulong _tmp80_;
	WidgetsContextMenuMenuItem* _tmp81_;
	GeeHashMap* _tmp82_;
	WidgetsContextMenuMenuItem* _tmp83_;
	gulong _tmp84_;
	WidgetsContextMenuMenuItem* _tmp85_;
	GeeHashMap* _tmp86_;
	WidgetsCalendarCalendar* _tmp87_;
	gulong _tmp88_;
	WidgetsCalendarCalendar* _tmp89_;
	GeeHashMap* _tmp90_;
	WidgetsLoadingButton* _tmp91_;
	gulong _tmp92_;
	WidgetsLoadingButton* _tmp93_;
	parent_class = G_OBJECT_CLASS (dialogs_date_picker_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DIALOGS_TYPE_DATE_PICKER, DialogsDatePicker);
	_tmp0_ = widgets_context_menu_menu_item_new (_ ("Today"), "star-outline-thick-symbolic");
	g_object_ref_sink (_tmp0_);
	today_item = _tmp0_;
	_tmp1_ = today_item;
	_tmp2_ = g_date_time_new_now_local ();
	_tmp3_ = _tmp2_;
	_tmp4_ = g_date_time_format (_tmp3_, "%a");
	_tmp5_ = _tmp4_;
	widgets_context_menu_menu_item_set_secondary_text (_tmp1_, _tmp5_);
	_g_free0 (_tmp5_);
	_g_date_time_unref0 (_tmp3_);
	_tmp6_ = today_item;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp6_, 6);
	_tmp7_ = widgets_context_menu_menu_item_new (_ ("Tomorrow"), "today-calendar-symbolic");
	g_object_ref_sink (_tmp7_);
	tomorrow_item = _tmp7_;
	_tmp8_ = tomorrow_item;
	_tmp9_ = g_date_time_new_now_local ();
	_tmp10_ = _tmp9_;
	_tmp11_ = g_date_time_add_days (_tmp10_, 1);
	_tmp12_ = _tmp11_;
	_tmp13_ = g_date_time_format (_tmp12_, "%a");
	_tmp14_ = _tmp13_;
	widgets_context_menu_menu_item_set_secondary_text (_tmp8_, _tmp14_);
	_g_free0 (_tmp14_);
	_g_date_time_unref0 (_tmp12_);
	_g_date_time_unref0 (_tmp10_);
	_tmp15_ = widgets_context_menu_menu_item_new (_ ("Next Week"), "work-week-symbolic");
	g_object_ref_sink (_tmp15_);
	next_week_item = _tmp15_;
	_tmp16_ = next_week_item;
	_tmp17_ = g_date_time_new_now_local ();
	_tmp18_ = _tmp17_;
	_tmp19_ = g_date_time_add_days (_tmp18_, 7);
	_tmp20_ = _tmp19_;
	_tmp21_ = utils_datetime_get_date_only (_tmp20_);
	_tmp22_ = _tmp21_;
	_tmp23_ = utils_datetime_get_relative_date_from_date (_tmp22_);
	_tmp24_ = _tmp23_;
	widgets_context_menu_menu_item_set_secondary_text (_tmp16_, _tmp24_);
	_g_free0 (_tmp24_);
	_g_date_time_unref0 (_tmp22_);
	_g_date_time_unref0 (_tmp20_);
	_g_date_time_unref0 (_tmp18_);
	_tmp25_ = widgets_context_menu_menu_item_new (_ ("No Date"), "cross-large-circle-filled-symbolic");
	g_object_ref_sink (_tmp25_);
	_g_object_unref0 (self->priv->no_date_item);
	self->priv->no_date_item = _tmp25_;
	_tmp26_ = self->priv->no_date_item;
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp26_, 6);
	_tmp27_ = self->priv->no_date_item;
	_tmp28_ = _g_object_ref0 ((GtkWidget*) _tmp27_);
	_tmp29_ = (GtkRevealer*) gtk_revealer_new ();
	gtk_revealer_set_child (_tmp29_, _tmp28_);
	_g_object_unref0 (_tmp28_);
	g_object_ref_sink (_tmp29_);
	_g_object_unref0 (self->priv->clear_revealer);
	self->priv->clear_revealer = _tmp29_;
	_tmp30_ = g_strdup ("card");
	_tmp31_ = g_new0 (gchar*, 1 + 1);
	_tmp31_[0] = _tmp30_;
	_tmp32_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp32_, 12);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp32_, 12);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp32_, 12);
	gtk_widget_set_css_classes ((GtkWidget*) _tmp32_, _tmp31_);
	_tmp31_ = (_vala_array_free (_tmp31_, 1, (GDestroyNotify) g_free), NULL);
	g_object_ref_sink (_tmp32_);
	items_card = _tmp32_;
	_tmp33_ = items_card;
	_tmp34_ = today_item;
	gtk_box_append (_tmp33_, (GtkWidget*) _tmp34_);
	_tmp35_ = items_card;
	_tmp36_ = tomorrow_item;
	gtk_box_append (_tmp35_, (GtkWidget*) _tmp36_);
	_tmp37_ = items_card;
	_tmp38_ = next_week_item;
	gtk_box_append (_tmp37_, (GtkWidget*) _tmp38_);
	_tmp39_ = items_card;
	_tmp40_ = self->priv->clear_revealer;
	gtk_box_append (_tmp39_, (GtkWidget*) _tmp40_);
	_tmp41_ = widgets_calendar_calendar_new (CONSTANTS_BLOCK_PAST_DAYS);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp41_, 6);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp41_, 6);
	g_object_ref_sink (_tmp41_);
	_g_object_unref0 (self->priv->calendar_view);
	self->priv->calendar_view = _tmp41_;
	_tmp42_ = g_strdup ("card");
	_tmp43_ = g_new0 (gchar*, 1 + 1);
	_tmp43_[0] = _tmp42_;
	_tmp44_ = self->priv->calendar_view;
	_tmp45_ = _g_object_ref0 ((GtkWidget*) _tmp44_);
	_tmp46_ = (AdwBin*) adw_bin_new ();
	gtk_widget_set_margin_start ((GtkWidget*) _tmp46_, 12);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp46_, 12);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp46_, 12);
	gtk_widget_set_css_classes ((GtkWidget*) _tmp46_, _tmp43_);
	_tmp43_ = (_vala_array_free (_tmp43_, 1, (GDestroyNotify) g_free), NULL);
	adw_bin_set_child (_tmp46_, _tmp45_);
	_g_object_unref0 (_tmp45_);
	g_object_ref_sink (_tmp46_);
	calendar_card = _tmp46_;
	_tmp47_ = widgets_loading_button_new (LOADING_BUTTON_TYPE_LABEL, _ ("Done"));
	gtk_widget_set_margin_start ((GtkWidget*) _tmp47_, 12);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp47_, 12);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp47_, 12);
	gtk_widget_set_vexpand ((GtkWidget*) _tmp47_, TRUE);
	gtk_widget_set_valign ((GtkWidget*) _tmp47_, GTK_ALIGN_END);
	g_object_ref_sink (_tmp47_);
	done_button = _tmp47_;
	_tmp48_ = done_button;
	gtk_widget_add_css_class ((GtkWidget*) _tmp48_, "suggested-action");
	_tmp49_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_set ((GtkWidget*) _tmp49_, "width-request", 225, NULL);
	g_object_ref_sink (_tmp49_);
	content_box = _tmp49_;
	_tmp50_ = content_box;
	_tmp51_ = items_card;
	gtk_box_append (_tmp50_, (GtkWidget*) _tmp51_);
	_tmp52_ = content_box;
	_tmp53_ = calendar_card;
	gtk_box_append (_tmp52_, (GtkWidget*) _tmp53_);
	_tmp54_ = content_box;
	_tmp55_ = done_button;
	gtk_box_append (_tmp54_, (GtkWidget*) _tmp55_);
	_tmp56_ = content_box;
	_tmp57_ = _g_object_ref0 ((GtkWidget*) _tmp56_);
	_tmp58_ = (AdwClamp*) adw_clamp_new ();
	adw_clamp_set_maximum_size (_tmp58_, 600);
	adw_clamp_set_child (_tmp58_, _tmp57_);
	_g_object_unref0 (_tmp57_);
	g_object_ref_sink (_tmp58_);
	content_clamp = _tmp58_;
	_tmp59_ = content_clamp;
	_tmp60_ = _g_object_ref0 ((GtkWidget*) _tmp59_);
	_tmp61_ = (AdwToolbarView*) adw_toolbar_view_new ();
	adw_toolbar_view_set_content (_tmp61_, _tmp60_);
	_g_object_unref0 (_tmp60_);
	g_object_ref_sink (_tmp61_);
	toolbar_view = _tmp61_;
	_tmp62_ = toolbar_view;
	_tmp63_ = g_strdup ("flat");
	_tmp64_ = g_new0 (gchar*, 1 + 1);
	_tmp64_[0] = _tmp63_;
	_tmp65_ = (AdwHeaderBar*) adw_header_bar_new ();
	gtk_widget_set_css_classes ((GtkWidget*) _tmp65_, _tmp64_);
	_tmp64_ = (_vala_array_free (_tmp64_, 1, (GDestroyNotify) g_free), NULL);
	g_object_ref_sink (_tmp65_);
	_tmp66_ = _tmp65_;
	adw_toolbar_view_add_top_bar (_tmp62_, (GtkWidget*) _tmp66_);
	_g_object_unref0 (_tmp66_);
	_tmp67_ = toolbar_view;
	adw_dialog_set_child ((AdwDialog*) self, (GtkWidget*) _tmp67_);
	_tmp68_ = services_event_bus_get_default ();
	_tmp69_ = _tmp68_;
	g_signal_emit_by_name (_tmp69_, "disconnect-typing-accel");
	_g_object_unref0 (_tmp69_);
	_tmp70_ = self->priv->signal_map;
	_tmp71_ = today_item;
	_tmp72_ = g_signal_connect_object (_tmp71_, "activate-item", (GCallback) __dialogs_date_picker___lambda658__widgets_context_menu_menu_item_activate_item, self, 0);
	_tmp73_ = today_item;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp70_, (gpointer) ((guintptr) _tmp72_), (GObject*) _tmp73_);
	_tmp74_ = self->priv->signal_map;
	_tmp75_ = tomorrow_item;
	_tmp76_ = g_signal_connect_object (_tmp75_, "activate-item", (GCallback) __dialogs_date_picker___lambda659__widgets_context_menu_menu_item_activate_item, self, 0);
	_tmp77_ = tomorrow_item;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp74_, (gpointer) ((guintptr) _tmp76_), (GObject*) _tmp77_);
	_tmp78_ = self->priv->signal_map;
	_tmp79_ = next_week_item;
	_tmp80_ = g_signal_connect_object (_tmp79_, "activate-item", (GCallback) __dialogs_date_picker___lambda660__widgets_context_menu_menu_item_activate_item, self, 0);
	_tmp81_ = next_week_item;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp78_, (gpointer) ((guintptr) _tmp80_), (GObject*) _tmp81_);
	_tmp82_ = self->priv->signal_map;
	_tmp83_ = self->priv->no_date_item;
	_tmp84_ = g_signal_connect_object (_tmp83_, "activate-item", (GCallback) __dialogs_date_picker___lambda661__widgets_context_menu_menu_item_activate_item, self, 0);
	_tmp85_ = self->priv->no_date_item;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp82_, (gpointer) ((guintptr) _tmp84_), (GObject*) _tmp85_);
	_tmp86_ = self->priv->signal_map;
	_tmp87_ = self->priv->calendar_view;
	_tmp88_ = g_signal_connect_object (_tmp87_, "day-selected", (GCallback) __dialogs_date_picker___lambda662__widgets_calendar_calendar_day_selected, self, 0);
	_tmp89_ = self->priv->calendar_view;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp86_, (gpointer) ((guintptr) _tmp88_), (GObject*) _tmp89_);
	_tmp90_ = self->priv->signal_map;
	_tmp91_ = done_button;
	_tmp92_ = g_signal_connect_object ((GtkButton*) _tmp91_, "clicked", (GCallback) __dialogs_date_picker___lambda663__gtk_button_clicked, self, 0);
	_tmp93_ = done_button;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp90_, (gpointer) ((guintptr) _tmp92_), (GObject*) _tmp93_);
	g_signal_connect_object ((AdwDialog*) self, "closed", (GCallback) __dialogs_date_picker___lambda664__adw_dialog_closed, self, 0);
	_g_object_unref0 (toolbar_view);
	_g_object_unref0 (content_clamp);
	_g_object_unref0 (content_box);
	_g_object_unref0 (done_button);
	_g_object_unref0 (calendar_card);
	_g_object_unref0 (items_card);
	_g_object_unref0 (next_week_item);
	_g_object_unref0 (tomorrow_item);
	_g_object_unref0 (today_item);
	return obj;
}

static void
dialogs_date_picker_class_init (DialogsDatePickerClass * klass,
                                gpointer klass_data)
{
	dialogs_date_picker_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DialogsDatePicker_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dialogs_date_picker_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_dialogs_date_picker_set_property;
	G_OBJECT_CLASS (klass)->constructor = dialogs_date_picker_constructor;
	G_OBJECT_CLASS (klass)->finalize = dialogs_date_picker_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DIALOGS_DATE_PICKER_DATETIME_PROPERTY, dialogs_date_picker_properties[DIALOGS_DATE_PICKER_DATETIME_PROPERTY] = g_param_spec_boxed ("datetime", "datetime", "datetime", G_TYPE_DATE_TIME, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DIALOGS_DATE_PICKER_CLEAR_PROPERTY, dialogs_date_picker_properties[DIALOGS_DATE_PICKER_CLEAR_PROPERTY] = g_param_spec_boolean ("clear", "clear", "clear", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_WRITABLE));
	dialogs_date_picker_signals[DIALOGS_DATE_PICKER_DATE_CHANGED_SIGNAL] = g_signal_new ("date-changed", DIALOGS_TYPE_DATE_PICKER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
dialogs_date_picker_instance_init (DialogsDatePicker * self,
                                   gpointer klass)
{
	GeeHashMap* _tmp0_;
	self->priv = dialogs_date_picker_get_instance_private (self);
	self->priv->_datetime = NULL;
	_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
dialogs_date_picker_finalize (GObject * obj)
{
	DialogsDatePicker * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DIALOGS_TYPE_DATE_PICKER, DialogsDatePicker);
	g_debug ("DatePicker.vala:58: Destroying - Dialogs.DatePicker\n");
	_g_object_unref0 (self->priv->clear_revealer);
	_g_object_unref0 (self->priv->calendar_view);
	_g_object_unref0 (self->priv->no_date_item);
	_g_date_time_unref0 (self->priv->_datetime);
	_g_object_unref0 (self->priv->signal_map);
	G_OBJECT_CLASS (dialogs_date_picker_parent_class)->finalize (obj);
}

static GType
dialogs_date_picker_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DialogsDatePickerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dialogs_date_picker_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DialogsDatePicker), 0, (GInstanceInitFunc) dialogs_date_picker_instance_init, NULL };
	GType dialogs_date_picker_type_id;
	dialogs_date_picker_type_id = g_type_register_static (adw_dialog_get_type (), "DialogsDatePicker", &g_define_type_info, 0);
	DialogsDatePicker_private_offset = g_type_add_instance_private (dialogs_date_picker_type_id, sizeof (DialogsDatePickerPrivate));
	return dialogs_date_picker_type_id;
}

GType
dialogs_date_picker_get_type (void)
{
	static volatile gsize dialogs_date_picker_type_id__once = 0;
	if (g_once_init_enter (&dialogs_date_picker_type_id__once)) {
		GType dialogs_date_picker_type_id;
		dialogs_date_picker_type_id = dialogs_date_picker_get_type_once ();
		g_once_init_leave (&dialogs_date_picker_type_id__once, dialogs_date_picker_type_id);
	}
	return dialogs_date_picker_type_id__once;
}

static void
_vala_dialogs_date_picker_get_property (GObject * object,
                                        guint property_id,
                                        GValue * value,
                                        GParamSpec * pspec)
{
	DialogsDatePicker * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DIALOGS_TYPE_DATE_PICKER, DialogsDatePicker);
	switch (property_id) {
		case DIALOGS_DATE_PICKER_DATETIME_PROPERTY:
		g_value_set_boxed (value, dialogs_date_picker_get_datetime (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_dialogs_date_picker_set_property (GObject * object,
                                        guint property_id,
                                        const GValue * value,
                                        GParamSpec * pspec)
{
	DialogsDatePicker * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DIALOGS_TYPE_DATE_PICKER, DialogsDatePicker);
	switch (property_id) {
		case DIALOGS_DATE_PICKER_DATETIME_PROPERTY:
		dialogs_date_picker_set_datetime (self, g_value_get_boxed (value));
		break;
		case DIALOGS_DATE_PICKER_CLEAR_PROPERTY:
		dialogs_date_picker_set_clear (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);
}

