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

/*-
 * Copyright 2011–2020 elementary, Inc. (https://elementary.io)
 *
 * 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, see <http://www.gnu.org/licenses/>.
 *
 * Authored by: Maxwell Barvian
 *              Corentin Noël <corentin@elementaryos.org>
 */

#include "datetime.h"
#include <glib.h>
#include <gee.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include <libedataserver/libedataserver.h>
#include <libical-glib/libical-glib.h>
#include <gio/gio.h>
#include <granite.h>
#include <gdk/gdk.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  {
	DATE_TIME_WIDGETS_GRID_DAY_0_PROPERTY,
	DATE_TIME_WIDGETS_GRID_DAY_DATE_PROPERTY,
	DATE_TIME_WIDGETS_GRID_DAY_NUM_PROPERTIES
};
static GParamSpec* date_time_widgets_grid_day_properties[DATE_TIME_WIDGETS_GRID_DAY_NUM_PROPERTIES];
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
enum  {
	DATE_TIME_WIDGETS_GRID_DAY_ON_EVENT_ADD_SIGNAL,
	DATE_TIME_WIDGETS_GRID_DAY_NUM_SIGNALS
};
static guint date_time_widgets_grid_day_signals[DATE_TIME_WIDGETS_GRID_DAY_NUM_SIGNALS] = {0};

struct _DateTimeWidgetsGridDayPrivate {
	GDateTime* _date;
	GeeHashMap* component_dots;
	GtkBox* event_box;
	GtkLabel* label;
	gboolean valid_grab;
};

static gint DateTimeWidgetsGridDay_private_offset;
static gpointer date_time_widgets_grid_day_parent_class = NULL;
static GtkCssProvider* date_time_widgets_grid_day_provider;
static GtkCssProvider* date_time_widgets_grid_day_provider = NULL;

static void date_time_widgets_grid_day_real_grab_focus (GtkWidget* base);
static gboolean date_time_widgets_grid_day_on_button_press (DateTimeWidgetsGridDay* self,
                                                     GdkEventButton* event);
static gboolean date_time_widgets_grid_day_on_key_press (DateTimeWidgetsGridDay* self,
                                                  GdkEventKey* event);
static GObject * date_time_widgets_grid_day_constructor (GType type,
                                                  guint n_construct_properties,
                                                  GObjectConstructParam * construct_properties);
static gboolean _date_time_widgets_grid_day_on_button_press_gtk_widget_button_press_event (GtkWidget* _sender,
                                                                                    GdkEventButton* event,
                                                                                    gpointer self);
static gboolean _date_time_widgets_grid_day_on_key_press_gtk_widget_key_press_event (GtkWidget* _sender,
                                                                              GdkEventKey* event,
                                                                              gpointer self);
static gboolean _date_time_widgets_grid_day___lambda22_ (DateTimeWidgetsGridDay* self,
                                                  GBinding* binding,
                                                  GValue* from_value,
                                                  GValue* to_value);
static gboolean __date_time_widgets_grid_day___lambda22__gbinding_transform_func (GBinding* binding,
                                                                           GValue* from_value,
                                                                           GValue* to_value,
                                                                           gpointer self);
static void date_time_widgets_grid_day_finalize (GObject * obj);
static GType date_time_widgets_grid_day_get_type_once (void);
static void _vala_date_time_widgets_grid_day_get_property (GObject * object,
                                                    guint property_id,
                                                    GValue * value,
                                                    GParamSpec * pspec);
static void _vala_date_time_widgets_grid_day_set_property (GObject * object,
                                                    guint property_id,
                                                    const GValue * value,
                                                    GParamSpec * pspec);

static inline gpointer
date_time_widgets_grid_day_get_instance_private (DateTimeWidgetsGridDay* self)
{
	return G_STRUCT_MEMBER_P (self, DateTimeWidgetsGridDay_private_offset);
}

DateTimeWidgetsGridDay*
date_time_widgets_grid_day_construct (GType object_type,
                                      GDateTime* date)
{
	DateTimeWidgetsGridDay * self = NULL;
	g_return_val_if_fail (date != NULL, NULL);
	self = (DateTimeWidgetsGridDay*) g_object_new (object_type, "date", date, NULL);
	return self;
}

DateTimeWidgetsGridDay*
date_time_widgets_grid_day_new (GDateTime* date)
{
	return date_time_widgets_grid_day_construct (DATE_TIME_WIDGETS_TYPE_GRID_DAY, date);
}

void
date_time_widgets_grid_day_add_component_dot (DateTimeWidgetsGridDay* self,
                                              ESource* source,
                                              ICalComponent* ical)
{
	GeeHashMap* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	gchar* component_uid = NULL;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	GeeHashMap* _tmp5_;
	const gchar* _tmp6_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (source != NULL);
	g_return_if_fail (ical != NULL);
	_tmp0_ = self->priv->component_dots;
	_tmp1_ = gee_abstract_map_get_size ((GeeAbstractMap*) _tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ >= 3) {
		return;
	}
	_tmp3_ = i_cal_component_get_uid (ical);
	_tmp4_ = g_strdup (_tmp3_);
	component_uid = _tmp4_;
	_tmp5_ = self->priv->component_dots;
	_tmp6_ = component_uid;
	if (!gee_abstract_map_has_key ((GeeAbstractMap*) _tmp5_, _tmp6_)) {
		GtkImage* event_dot = NULL;
		GThemedIcon* _tmp7_;
		GtkImage* _tmp8_ = NULL;
		GtkStyleContext* style_context = NULL;
		GtkImage* _tmp9_;
		GtkStyleContext* _tmp10_;
		GtkStyleContext* _tmp11_;
		GtkStyleContext* _tmp12_;
		GtkCssProvider* _tmp13_;
		ESourceSelectable* source_selectable = NULL;
		ESourceSelectable* _tmp16_;
		GtkImage* _tmp17_;
		GeeHashMap* _tmp18_;
		const gchar* _tmp19_;
		GtkImage* _tmp20_;
		GtkBox* _tmp21_;
		GtkImage* _tmp22_;
		_tmp7_ = (GThemedIcon*) g_themed_icon_new ("pager-checked-symbolic");
		_tmp8_ = (GtkImage*) gtk_image_new ();
		g_object_set (_tmp8_, "gicon", (GIcon*) _tmp7_, NULL);
		_g_object_unref0 (_tmp7_);
		gtk_image_set_pixel_size (_tmp8_, 6);
		g_object_ref_sink (_tmp8_);
		event_dot = _tmp8_;
		_tmp9_ = event_dot;
		_tmp10_ = gtk_widget_get_style_context ((GtkWidget*) _tmp9_);
		style_context = _tmp10_;
		_tmp11_ = style_context;
		gtk_style_context_add_class (_tmp11_, GRANITE_STYLE_CLASS_ACCENT);
		_tmp12_ = style_context;
		_tmp13_ = date_time_widgets_grid_day_provider;
		gtk_style_context_add_provider (_tmp12_, (GtkStyleProvider*) _tmp13_, (guint) GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
		source_selectable = NULL;
		if (e_source_has_extension (source, E_SOURCE_EXTENSION_TASK_LIST)) {
			ESourceExtension* _tmp14_;
			_tmp14_ = e_source_get_extension (source, E_SOURCE_EXTENSION_TASK_LIST);
			source_selectable = G_TYPE_CHECK_INSTANCE_CAST (_tmp14_, e_source_selectable_get_type (), ESourceSelectable);
		} else {
			ESourceExtension* _tmp15_;
			_tmp15_ = e_source_get_extension (source, E_SOURCE_EXTENSION_CALENDAR);
			source_selectable = G_TYPE_CHECK_INSTANCE_CAST (_tmp15_, e_source_selectable_get_type (), ESourceSelectable);
		}
		_tmp16_ = source_selectable;
		_tmp17_ = event_dot;
		util_set_component_calendar_color (_tmp16_, (GtkWidget*) _tmp17_);
		_tmp18_ = self->priv->component_dots;
		_tmp19_ = component_uid;
		_tmp20_ = event_dot;
		gee_abstract_map_set ((GeeAbstractMap*) _tmp18_, _tmp19_, (GtkWidget*) _tmp20_);
		_tmp21_ = self->priv->event_box;
		_tmp22_ = event_dot;
		gtk_container_add ((GtkContainer*) _tmp21_, (GtkWidget*) _tmp22_);
		_g_object_unref0 (event_dot);
	}
	_g_free0 (component_uid);
}

void
date_time_widgets_grid_day_remove_component_dot (DateTimeWidgetsGridDay* self,
                                                 const gchar* component_uid)
{
	GtkWidget* dot = NULL;
	GeeHashMap* _tmp0_;
	gpointer _tmp1_;
	GtkWidget* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (component_uid != NULL);
	_tmp0_ = self->priv->component_dots;
	_tmp1_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp0_, component_uid);
	dot = (GtkWidget*) _tmp1_;
	_tmp2_ = dot;
	if (_tmp2_ != NULL) {
		GtkWidget* _tmp3_;
		GeeHashMap* _tmp4_;
		_tmp3_ = dot;
		gtk_widget_destroy (_tmp3_);
		_tmp4_ = self->priv->component_dots;
		gee_abstract_map_unset ((GeeAbstractMap*) _tmp4_, component_uid, NULL);
	}
	_g_object_unref0 (dot);
}

void
date_time_widgets_grid_day_set_selected (DateTimeWidgetsGridDay* self,
                                         gboolean selected)
{
	g_return_if_fail (self != NULL);
	if (selected) {
		gtk_widget_set_state_flags ((GtkWidget*) self, GTK_STATE_FLAG_SELECTED, TRUE);
	} else {
		gtk_widget_set_state_flags ((GtkWidget*) self, GTK_STATE_FLAG_NORMAL, TRUE);
	}
}

void
date_time_widgets_grid_day_grab_focus_force (DateTimeWidgetsGridDay* self)
{
	g_return_if_fail (self != NULL);
	self->priv->valid_grab = TRUE;
	gtk_widget_grab_focus ((GtkWidget*) self);
}

static void
date_time_widgets_grid_day_real_grab_focus (GtkWidget* base)
{
	DateTimeWidgetsGridDay * self;
	self = (DateTimeWidgetsGridDay*) base;
	if (self->priv->valid_grab) {
		GTK_WIDGET_CLASS (date_time_widgets_grid_day_parent_class)->grab_focus ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_event_box_get_type (), GtkEventBox));
		self->priv->valid_grab = FALSE;
	}
}

void
date_time_widgets_grid_day_sensitive_container (DateTimeWidgetsGridDay* self,
                                                gboolean sens)
{
	GtkLabel* _tmp0_;
	GtkBox* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->label;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp0_, sens);
	_tmp1_ = self->priv->event_box;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp1_, sens);
}

static gboolean
date_time_widgets_grid_day_on_button_press (DateTimeWidgetsGridDay* self,
                                            GdkEventButton* event)
{
	gboolean _tmp0_ = FALSE;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	if (event->type == GDK_2BUTTON_PRESS) {
		_tmp0_ = event->button == ((guint) GDK_BUTTON_PRIMARY);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		GDateTime* _tmp1_;
		_tmp1_ = self->priv->_date;
		g_signal_emit (self, date_time_widgets_grid_day_signals[DATE_TIME_WIDGETS_GRID_DAY_ON_EVENT_ADD_SIGNAL], 0, _tmp1_);
	}
	self->priv->valid_grab = TRUE;
	gtk_widget_grab_focus ((GtkWidget*) self);
	result = FALSE;
	return result;
}

static gboolean
date_time_widgets_grid_day_on_key_press (DateTimeWidgetsGridDay* self,
                                         GdkEventKey* event)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	if (event->keyval == gdk_keyval_from_name ("Return")) {
		GDateTime* _tmp0_;
		_tmp0_ = self->priv->_date;
		g_signal_emit (self, date_time_widgets_grid_day_signals[DATE_TIME_WIDGETS_GRID_DAY_ON_EVENT_ADD_SIGNAL], 0, _tmp0_);
		result = TRUE;
		return result;
	}
	result = FALSE;
	return result;
}

GDateTime*
date_time_widgets_grid_day_get_date (DateTimeWidgetsGridDay* 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
date_time_widgets_grid_day_set_date (DateTimeWidgetsGridDay* self,
                                     GDateTime* value)
{
	GDateTime* old_value;
	g_return_if_fail (self != NULL);
	old_value = date_time_widgets_grid_day_get_date (self);
	if (old_value != value) {
		GDateTime* _tmp0_;
		_tmp0_ = _g_date_time_ref0 (value);
		_g_date_time_unref0 (self->priv->_date);
		self->priv->_date = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, date_time_widgets_grid_day_properties[DATE_TIME_WIDGETS_GRID_DAY_DATE_PROPERTY]);
	}
}

static gboolean
_date_time_widgets_grid_day_on_button_press_gtk_widget_button_press_event (GtkWidget* _sender,
                                                                           GdkEventButton* event,
                                                                           gpointer self)
{
	gboolean result;
	result = date_time_widgets_grid_day_on_button_press ((DateTimeWidgetsGridDay*) self, event);
	return result;
}

static gboolean
_date_time_widgets_grid_day_on_key_press_gtk_widget_key_press_event (GtkWidget* _sender,
                                                                     GdkEventKey* event,
                                                                     gpointer self)
{
	gboolean result;
	result = date_time_widgets_grid_day_on_key_press ((DateTimeWidgetsGridDay*) self, event);
	return result;
}

static gboolean
_date_time_widgets_grid_day___lambda22_ (DateTimeWidgetsGridDay* self,
                                         GBinding* binding,
                                         GValue* from_value,
                                         GValue* to_value)
{
	GDateTime* new_date = NULL;
	void* _tmp0_;
	GDateTime* _tmp1_;
	gchar* _tmp2_;
	gboolean result;
	g_return_val_if_fail (binding != NULL, FALSE);
	g_return_val_if_fail (from_value != NULL, FALSE);
	g_return_val_if_fail (to_value != NULL, FALSE);
	_tmp0_ = g_value_get_boxed (from_value);
	new_date = (GDateTime*) _tmp0_;
	_tmp1_ = new_date;
	_tmp2_ = g_strdup_printf ("%i", g_date_time_get_day_of_month (_tmp1_));
	g_value_take_string (to_value, _tmp2_);
	result = TRUE;
	return result;
}

static gboolean
__date_time_widgets_grid_day___lambda22__gbinding_transform_func (GBinding* binding,
                                                                  GValue* from_value,
                                                                  GValue* to_value,
                                                                  gpointer self)
{
	gboolean result;
	result = _date_time_widgets_grid_day___lambda22_ ((DateTimeWidgetsGridDay*) self, binding, from_value, to_value);
	return result;
}

static GObject *
date_time_widgets_grid_day_constructor (GType type,
                                        guint n_construct_properties,
                                        GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	DateTimeWidgetsGridDay * self;
	GtkLabel* _tmp0_;
	GtkStyleContext* label_style_context = NULL;
	GtkLabel* _tmp1_;
	GtkStyleContext* _tmp2_;
	GtkStyleContext* _tmp3_;
	GtkCssProvider* _tmp4_;
	GtkStyleContext* _tmp5_;
	GtkBox* _tmp6_ = NULL;
	GtkBox* box = NULL;
	GtkBox* _tmp7_ = NULL;
	GtkBox* _tmp8_;
	GtkLabel* _tmp9_;
	GtkBox* _tmp10_;
	GtkBox* _tmp11_;
	GdkEventMask _tmp12_;
	GdkEventMask _tmp13_;
	GdkEventMask _tmp14_;
	GdkEventMask _tmp15_;
	GtkStyleContext* _tmp16_;
	GtkCssProvider* _tmp17_;
	GtkBox* _tmp18_;
	GtkLabel* _tmp19_;
	GeeHashMap* _tmp20_;
	parent_class = G_OBJECT_CLASS (date_time_widgets_grid_day_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DATE_TIME_WIDGETS_TYPE_GRID_DAY, DateTimeWidgetsGridDay);
	_tmp0_ = (GtkLabel*) gtk_label_new (NULL);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->label);
	self->priv->label = _tmp0_;
	_tmp1_ = self->priv->label;
	_tmp2_ = gtk_widget_get_style_context ((GtkWidget*) _tmp1_);
	label_style_context = _tmp2_;
	_tmp3_ = label_style_context;
	_tmp4_ = date_time_widgets_grid_day_provider;
	gtk_style_context_add_provider (_tmp3_, (GtkStyleProvider*) _tmp4_, (guint) GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
	_tmp5_ = label_style_context;
	gtk_style_context_add_class (_tmp5_, "circular");
	_tmp6_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_widget_set_halign ((GtkWidget*) _tmp6_, GTK_ALIGN_CENTER);
	g_object_set ((GtkWidget*) _tmp6_, "height-request", 6, NULL);
	g_object_ref_sink (_tmp6_);
	_g_object_unref0 (self->priv->event_box);
	self->priv->event_box = _tmp6_;
	_tmp7_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_widget_set_halign ((GtkWidget*) _tmp7_, GTK_ALIGN_CENTER);
	gtk_widget_set_valign ((GtkWidget*) _tmp7_, GTK_ALIGN_CENTER);
	g_object_ref_sink (_tmp7_);
	box = _tmp7_;
	_tmp8_ = box;
	_tmp9_ = self->priv->label;
	gtk_container_add ((GtkContainer*) _tmp8_, (GtkWidget*) _tmp9_);
	_tmp10_ = box;
	_tmp11_ = self->priv->event_box;
	gtk_container_add ((GtkContainer*) _tmp10_, (GtkWidget*) _tmp11_);
	gtk_widget_set_can_focus ((GtkWidget*) self, TRUE);
	_tmp12_ = gtk_widget_get_events ((GtkWidget*) self);
	_tmp13_ = _tmp12_;
	gtk_widget_set_events ((GtkWidget*) self, _tmp13_ | GDK_BUTTON_PRESS_MASK);
	_tmp14_ = gtk_widget_get_events ((GtkWidget*) self);
	_tmp15_ = _tmp14_;
	gtk_widget_set_events ((GtkWidget*) self, _tmp15_ | GDK_KEY_PRESS_MASK);
	gtk_widget_class_set_css_name (G_TYPE_INSTANCE_GET_CLASS (self, gtk_widget_get_type (), GtkWidgetClass), "grid-day");
	gtk_widget_set_halign ((GtkWidget*) self, GTK_ALIGN_CENTER);
	gtk_widget_set_hexpand ((GtkWidget*) self, TRUE);
	_tmp16_ = gtk_widget_get_style_context ((GtkWidget*) self);
	_tmp17_ = date_time_widgets_grid_day_provider;
	gtk_style_context_add_provider (_tmp16_, (GtkStyleProvider*) _tmp17_, (guint) GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
	_tmp18_ = box;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp18_);
	gtk_widget_show_all ((GtkWidget*) self);
	g_signal_connect_object ((GtkWidget*) self, "button-press-event", (GCallback) _date_time_widgets_grid_day_on_button_press_gtk_widget_button_press_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "key-press-event", (GCallback) _date_time_widgets_grid_day_on_key_press_gtk_widget_key_press_event, self, 0);
	_tmp19_ = self->priv->label;
	g_object_bind_property_with_closures ((GObject*) self, "date", (GObject*) _tmp19_, "label", G_BINDING_SYNC_CREATE, (GClosure*) ((__date_time_widgets_grid_day___lambda22__gbinding_transform_func == NULL) ? NULL : g_cclosure_new ((GCallback) __date_time_widgets_grid_day___lambda22__gbinding_transform_func, g_object_ref (self), (GClosureNotify) g_object_unref)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp20_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, gtk_widget_get_type (), (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->component_dots);
	self->priv->component_dots = _tmp20_;
	_g_object_unref0 (box);
	return obj;
}

static void
date_time_widgets_grid_day_class_init (DateTimeWidgetsGridDayClass * klass,
                                       gpointer klass_data)
{
	GtkCssProvider* _tmp0_;
	GtkCssProvider* _tmp1_;
	date_time_widgets_grid_day_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DateTimeWidgetsGridDay_private_offset);
	((GtkWidgetClass *) klass)->grab_focus = (void (*) (GtkWidget*)) date_time_widgets_grid_day_real_grab_focus;
	G_OBJECT_CLASS (klass)->get_property = _vala_date_time_widgets_grid_day_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_date_time_widgets_grid_day_set_property;
	G_OBJECT_CLASS (klass)->constructor = date_time_widgets_grid_day_constructor;
	G_OBJECT_CLASS (klass)->finalize = date_time_widgets_grid_day_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DATE_TIME_WIDGETS_GRID_DAY_DATE_PROPERTY, date_time_widgets_grid_day_properties[DATE_TIME_WIDGETS_GRID_DAY_DATE_PROPERTY] = g_param_spec_boxed ("date", "date", "date", G_TYPE_DATE_TIME, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	date_time_widgets_grid_day_signals[DATE_TIME_WIDGETS_GRID_DAY_ON_EVENT_ADD_SIGNAL] = g_signal_new ("on-event-add", DATE_TIME_WIDGETS_TYPE_GRID_DAY, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__BOXED, G_TYPE_NONE, 1, G_TYPE_DATE_TIME);
	_tmp0_ = gtk_css_provider_new ();
	_g_object_unref0 (date_time_widgets_grid_day_provider);
	date_time_widgets_grid_day_provider = _tmp0_;
	_tmp1_ = date_time_widgets_grid_day_provider;
	gtk_css_provider_load_from_resource (_tmp1_, "/io/elementary/desktop/wingpanel/datetime/GridDay.css");
}

static void
date_time_widgets_grid_day_instance_init (DateTimeWidgetsGridDay * self,
                                          gpointer klass)
{
	self->priv = date_time_widgets_grid_day_get_instance_private (self);
	self->priv->valid_grab = FALSE;
}

static void
date_time_widgets_grid_day_finalize (GObject * obj)
{
	DateTimeWidgetsGridDay * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DATE_TIME_WIDGETS_TYPE_GRID_DAY, DateTimeWidgetsGridDay);
	_g_date_time_unref0 (self->priv->_date);
	_g_object_unref0 (self->priv->component_dots);
	_g_object_unref0 (self->priv->event_box);
	_g_object_unref0 (self->priv->label);
	G_OBJECT_CLASS (date_time_widgets_grid_day_parent_class)->finalize (obj);
}

/**
 * Represents a single day on the grid.
 */
static GType
date_time_widgets_grid_day_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DateTimeWidgetsGridDayClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) date_time_widgets_grid_day_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DateTimeWidgetsGridDay), 0, (GInstanceInitFunc) date_time_widgets_grid_day_instance_init, NULL };
	GType date_time_widgets_grid_day_type_id;
	date_time_widgets_grid_day_type_id = g_type_register_static (gtk_event_box_get_type (), "DateTimeWidgetsGridDay", &g_define_type_info, 0);
	DateTimeWidgetsGridDay_private_offset = g_type_add_instance_private (date_time_widgets_grid_day_type_id, sizeof (DateTimeWidgetsGridDayPrivate));
	return date_time_widgets_grid_day_type_id;
}

GType
date_time_widgets_grid_day_get_type (void)
{
	static volatile gsize date_time_widgets_grid_day_type_id__once = 0;
	if (g_once_init_enter (&date_time_widgets_grid_day_type_id__once)) {
		GType date_time_widgets_grid_day_type_id;
		date_time_widgets_grid_day_type_id = date_time_widgets_grid_day_get_type_once ();
		g_once_init_leave (&date_time_widgets_grid_day_type_id__once, date_time_widgets_grid_day_type_id);
	}
	return date_time_widgets_grid_day_type_id__once;
}

static void
_vala_date_time_widgets_grid_day_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec)
{
	DateTimeWidgetsGridDay * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DATE_TIME_WIDGETS_TYPE_GRID_DAY, DateTimeWidgetsGridDay);
	switch (property_id) {
		case DATE_TIME_WIDGETS_GRID_DAY_DATE_PROPERTY:
		g_value_set_boxed (value, date_time_widgets_grid_day_get_date (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_date_time_widgets_grid_day_set_property (GObject * object,
                                               guint property_id,
                                               const GValue * value,
                                               GParamSpec * pspec)
{
	DateTimeWidgetsGridDay * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DATE_TIME_WIDGETS_TYPE_GRID_DAY, DateTimeWidgetsGridDay);
	switch (property_id) {
		case DATE_TIME_WIDGETS_GRID_DAY_DATE_PROPERTY:
		date_time_widgets_grid_day_set_date (self, g_value_get_boxed (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

