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

/* -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-*/
/*-
 * Copyright (c) 2011-2015 Maya Developers (http://launchpad.net/maya)
 *
 * 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
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <granite.h>
#include <glib.h>
#include <float.h>
#include <math.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#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 MAYA_VIEW_WIDGETS_TYPE_DATE_TIME_PICKER (maya_view_widgets_date_time_picker_get_type ())
#define MAYA_VIEW_WIDGETS_DATE_TIME_PICKER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAYA_VIEW_WIDGETS_TYPE_DATE_TIME_PICKER, MayaViewWidgetsDateTimePicker))
#define MAYA_VIEW_WIDGETS_DATE_TIME_PICKER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MAYA_VIEW_WIDGETS_TYPE_DATE_TIME_PICKER, MayaViewWidgetsDateTimePickerClass))
#define MAYA_VIEW_WIDGETS_IS_DATE_TIME_PICKER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAYA_VIEW_WIDGETS_TYPE_DATE_TIME_PICKER))
#define MAYA_VIEW_WIDGETS_IS_DATE_TIME_PICKER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MAYA_VIEW_WIDGETS_TYPE_DATE_TIME_PICKER))
#define MAYA_VIEW_WIDGETS_DATE_TIME_PICKER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MAYA_VIEW_WIDGETS_TYPE_DATE_TIME_PICKER, MayaViewWidgetsDateTimePickerClass))

typedef struct _MayaViewWidgetsDateTimePicker MayaViewWidgetsDateTimePicker;
typedef struct _MayaViewWidgetsDateTimePickerClass MayaViewWidgetsDateTimePickerClass;
typedef struct _MayaViewWidgetsDateTimePickerPrivate MayaViewWidgetsDateTimePickerPrivate;
enum  {
	MAYA_VIEW_WIDGETS_DATE_TIME_PICKER_0_PROPERTY,
	MAYA_VIEW_WIDGETS_DATE_TIME_PICKER_DATE_TIME_PROPERTY,
	MAYA_VIEW_WIDGETS_DATE_TIME_PICKER_DATE_PICKER_PROPERTY,
	MAYA_VIEW_WIDGETS_DATE_TIME_PICKER_TIME_PICKER_PROPERTY,
	MAYA_VIEW_WIDGETS_DATE_TIME_PICKER_NUM_PROPERTIES
};
static GParamSpec* maya_view_widgets_date_time_picker_properties[MAYA_VIEW_WIDGETS_DATE_TIME_PICKER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _MayaViewWidgetsDateTimePicker {
	GtkGrid parent_instance;
	MayaViewWidgetsDateTimePickerPrivate * priv;
};

struct _MayaViewWidgetsDateTimePickerClass {
	GtkGridClass parent_class;
};

struct _MayaViewWidgetsDateTimePickerPrivate {
	GraniteWidgetsDatePicker* _date_picker;
	GraniteWidgetsTimePicker* _time_picker;
};

static gint MayaViewWidgetsDateTimePicker_private_offset;
static gpointer maya_view_widgets_date_time_picker_parent_class = NULL;

VALA_EXTERN GType maya_view_widgets_date_time_picker_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MayaViewWidgetsDateTimePicker, g_object_unref)
VALA_EXTERN MayaViewWidgetsDateTimePicker* maya_view_widgets_date_time_picker_new (void);
VALA_EXTERN MayaViewWidgetsDateTimePicker* maya_view_widgets_date_time_picker_construct (GType object_type);
static void maya_view_widgets_date_time_picker_set_date_picker (MayaViewWidgetsDateTimePicker* self,
                                                         GraniteWidgetsDatePicker* value);
static void maya_view_widgets_date_time_picker_set_time_picker (MayaViewWidgetsDateTimePicker* self,
                                                         GraniteWidgetsTimePicker* value);
VALA_EXTERN GraniteWidgetsDatePicker* maya_view_widgets_date_time_picker_get_date_picker (MayaViewWidgetsDateTimePicker* self);
VALA_EXTERN GraniteWidgetsTimePicker* maya_view_widgets_date_time_picker_get_time_picker (MayaViewWidgetsDateTimePicker* self);
VALA_EXTERN GDateTime* maya_view_widgets_date_time_picker_get_date_time (MayaViewWidgetsDateTimePicker* self);
static void maya_view_widgets_date_time_picker_finalize (GObject * obj);
static GType maya_view_widgets_date_time_picker_get_type_once (void);
static void _vala_maya_view_widgets_date_time_picker_get_property (GObject * object,
                                                            guint property_id,
                                                            GValue * value,
                                                            GParamSpec * pspec);
static void _vala_maya_view_widgets_date_time_picker_set_property (GObject * object,
                                                            guint property_id,
                                                            const GValue * value,
                                                            GParamSpec * pspec);

static inline gpointer
maya_view_widgets_date_time_picker_get_instance_private (MayaViewWidgetsDateTimePicker* self)
{
	return G_STRUCT_MEMBER_P (self, MayaViewWidgetsDateTimePicker_private_offset);
}

MayaViewWidgetsDateTimePicker*
maya_view_widgets_date_time_picker_construct (GType object_type)
{
	MayaViewWidgetsDateTimePicker * self = NULL;
	GraniteWidgetsDatePicker* _tmp0_;
	GraniteWidgetsDatePicker* _tmp1_;
	GraniteWidgetsTimePicker* _tmp2_;
	GraniteWidgetsTimePicker* _tmp3_;
	GraniteWidgetsDatePicker* _tmp4_;
	GraniteWidgetsTimePicker* _tmp5_;
	self = (MayaViewWidgetsDateTimePicker*) g_object_new (object_type, NULL);
	_tmp0_ = granite_widgets_date_picker_new ();
	g_object_ref_sink (_tmp0_);
	_tmp1_ = _tmp0_;
	maya_view_widgets_date_time_picker_set_date_picker (self, _tmp1_);
	_g_object_unref0 (_tmp1_);
	_tmp2_ = granite_widgets_time_picker_new ();
	g_object_ref_sink (_tmp2_);
	_tmp3_ = _tmp2_;
	maya_view_widgets_date_time_picker_set_time_picker (self, _tmp3_);
	_g_object_unref0 (_tmp3_);
	gtk_grid_set_column_spacing ((GtkGrid*) self, (guint) 10);
	gtk_grid_set_column_homogeneous ((GtkGrid*) self, FALSE);
	_tmp4_ = self->priv->_date_picker;
	gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) _tmp4_, 0, 0, 1, 1);
	_tmp5_ = self->priv->_time_picker;
	gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) _tmp5_, 1, 0, 1, 1);
	return self;
}

MayaViewWidgetsDateTimePicker*
maya_view_widgets_date_time_picker_new (void)
{
	return maya_view_widgets_date_time_picker_construct (MAYA_VIEW_WIDGETS_TYPE_DATE_TIME_PICKER);
}

GDateTime*
maya_view_widgets_date_time_picker_get_date_time (MayaViewWidgetsDateTimePicker* self)
{
	GDateTime* result;
	GraniteWidgetsDatePicker* _tmp0_;
	GDateTime* _tmp1_;
	GDateTime* _tmp2_;
	GraniteWidgetsDatePicker* _tmp3_;
	GDateTime* _tmp4_;
	GDateTime* _tmp5_;
	GraniteWidgetsDatePicker* _tmp6_;
	GDateTime* _tmp7_;
	GDateTime* _tmp8_;
	GraniteWidgetsTimePicker* _tmp9_;
	GDateTime* _tmp10_;
	GDateTime* _tmp11_;
	GraniteWidgetsTimePicker* _tmp12_;
	GDateTime* _tmp13_;
	GDateTime* _tmp14_;
	GraniteWidgetsTimePicker* _tmp15_;
	GDateTime* _tmp16_;
	GDateTime* _tmp17_;
	GDateTime* _tmp18_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_date_picker;
	_tmp1_ = granite_widgets_date_picker_get_date (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = self->priv->_date_picker;
	_tmp4_ = granite_widgets_date_picker_get_date (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = self->priv->_date_picker;
	_tmp7_ = granite_widgets_date_picker_get_date (_tmp6_);
	_tmp8_ = _tmp7_;
	_tmp9_ = self->priv->_time_picker;
	_tmp10_ = granite_widgets_time_picker_get_time (_tmp9_);
	_tmp11_ = _tmp10_;
	_tmp12_ = self->priv->_time_picker;
	_tmp13_ = granite_widgets_time_picker_get_time (_tmp12_);
	_tmp14_ = _tmp13_;
	_tmp15_ = self->priv->_time_picker;
	_tmp16_ = granite_widgets_time_picker_get_time (_tmp15_);
	_tmp17_ = _tmp16_;
	_tmp18_ = g_date_time_new_local (g_date_time_get_year (_tmp2_), g_date_time_get_month (_tmp5_), g_date_time_get_day_of_month (_tmp8_), g_date_time_get_hour (_tmp11_), g_date_time_get_minute (_tmp14_), (gdouble) g_date_time_get_second (_tmp17_));
	result = _tmp18_;
	return result;
}

GraniteWidgetsDatePicker*
maya_view_widgets_date_time_picker_get_date_picker (MayaViewWidgetsDateTimePicker* self)
{
	GraniteWidgetsDatePicker* result;
	GraniteWidgetsDatePicker* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_date_picker;
	result = _tmp0_;
	return result;
}

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

static void
maya_view_widgets_date_time_picker_set_date_picker (MayaViewWidgetsDateTimePicker* self,
                                                    GraniteWidgetsDatePicker* value)
{
	GraniteWidgetsDatePicker* old_value;
	g_return_if_fail (self != NULL);
	old_value = maya_view_widgets_date_time_picker_get_date_picker (self);
	if (old_value != value) {
		GraniteWidgetsDatePicker* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_date_picker);
		self->priv->_date_picker = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, maya_view_widgets_date_time_picker_properties[MAYA_VIEW_WIDGETS_DATE_TIME_PICKER_DATE_PICKER_PROPERTY]);
	}
}

GraniteWidgetsTimePicker*
maya_view_widgets_date_time_picker_get_time_picker (MayaViewWidgetsDateTimePicker* self)
{
	GraniteWidgetsTimePicker* result;
	GraniteWidgetsTimePicker* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_time_picker;
	result = _tmp0_;
	return result;
}

static void
maya_view_widgets_date_time_picker_set_time_picker (MayaViewWidgetsDateTimePicker* self,
                                                    GraniteWidgetsTimePicker* value)
{
	GraniteWidgetsTimePicker* old_value;
	g_return_if_fail (self != NULL);
	old_value = maya_view_widgets_date_time_picker_get_time_picker (self);
	if (old_value != value) {
		GraniteWidgetsTimePicker* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_time_picker);
		self->priv->_time_picker = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, maya_view_widgets_date_time_picker_properties[MAYA_VIEW_WIDGETS_DATE_TIME_PICKER_TIME_PICKER_PROPERTY]);
	}
}

static void
maya_view_widgets_date_time_picker_class_init (MayaViewWidgetsDateTimePickerClass * klass,
                                               gpointer klass_data)
{
	maya_view_widgets_date_time_picker_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &MayaViewWidgetsDateTimePicker_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_maya_view_widgets_date_time_picker_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_maya_view_widgets_date_time_picker_set_property;
	G_OBJECT_CLASS (klass)->finalize = maya_view_widgets_date_time_picker_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), MAYA_VIEW_WIDGETS_DATE_TIME_PICKER_DATE_TIME_PROPERTY, maya_view_widgets_date_time_picker_properties[MAYA_VIEW_WIDGETS_DATE_TIME_PICKER_DATE_TIME_PROPERTY] = g_param_spec_boxed ("date-time", "date-time", "date-time", G_TYPE_DATE_TIME, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), MAYA_VIEW_WIDGETS_DATE_TIME_PICKER_DATE_PICKER_PROPERTY, maya_view_widgets_date_time_picker_properties[MAYA_VIEW_WIDGETS_DATE_TIME_PICKER_DATE_PICKER_PROPERTY] = g_param_spec_object ("date-picker", "date-picker", "date-picker", GRANITE_WIDGETS_TYPE_DATE_PICKER, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), MAYA_VIEW_WIDGETS_DATE_TIME_PICKER_TIME_PICKER_PROPERTY, maya_view_widgets_date_time_picker_properties[MAYA_VIEW_WIDGETS_DATE_TIME_PICKER_TIME_PICKER_PROPERTY] = g_param_spec_object ("time-picker", "time-picker", "time-picker", GRANITE_WIDGETS_TYPE_TIME_PICKER, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
maya_view_widgets_date_time_picker_instance_init (MayaViewWidgetsDateTimePicker * self,
                                                  gpointer klass)
{
	self->priv = maya_view_widgets_date_time_picker_get_instance_private (self);
}

static void
maya_view_widgets_date_time_picker_finalize (GObject * obj)
{
	MayaViewWidgetsDateTimePicker * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, MAYA_VIEW_WIDGETS_TYPE_DATE_TIME_PICKER, MayaViewWidgetsDateTimePicker);
	_g_object_unref0 (self->priv->_date_picker);
	_g_object_unref0 (self->priv->_time_picker);
	G_OBJECT_CLASS (maya_view_widgets_date_time_picker_parent_class)->finalize (obj);
}

static GType
maya_view_widgets_date_time_picker_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (MayaViewWidgetsDateTimePickerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) maya_view_widgets_date_time_picker_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MayaViewWidgetsDateTimePicker), 0, (GInstanceInitFunc) maya_view_widgets_date_time_picker_instance_init, NULL };
	GType maya_view_widgets_date_time_picker_type_id;
	maya_view_widgets_date_time_picker_type_id = g_type_register_static (gtk_grid_get_type (), "MayaViewWidgetsDateTimePicker", &g_define_type_info, 0);
	MayaViewWidgetsDateTimePicker_private_offset = g_type_add_instance_private (maya_view_widgets_date_time_picker_type_id, sizeof (MayaViewWidgetsDateTimePickerPrivate));
	return maya_view_widgets_date_time_picker_type_id;
}

GType
maya_view_widgets_date_time_picker_get_type (void)
{
	static volatile gsize maya_view_widgets_date_time_picker_type_id__once = 0;
	if (g_once_init_enter (&maya_view_widgets_date_time_picker_type_id__once)) {
		GType maya_view_widgets_date_time_picker_type_id;
		maya_view_widgets_date_time_picker_type_id = maya_view_widgets_date_time_picker_get_type_once ();
		g_once_init_leave (&maya_view_widgets_date_time_picker_type_id__once, maya_view_widgets_date_time_picker_type_id);
	}
	return maya_view_widgets_date_time_picker_type_id__once;
}

static void
_vala_maya_view_widgets_date_time_picker_get_property (GObject * object,
                                                       guint property_id,
                                                       GValue * value,
                                                       GParamSpec * pspec)
{
	MayaViewWidgetsDateTimePicker * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, MAYA_VIEW_WIDGETS_TYPE_DATE_TIME_PICKER, MayaViewWidgetsDateTimePicker);
	switch (property_id) {
		case MAYA_VIEW_WIDGETS_DATE_TIME_PICKER_DATE_TIME_PROPERTY:
		g_value_take_boxed (value, maya_view_widgets_date_time_picker_get_date_time (self));
		break;
		case MAYA_VIEW_WIDGETS_DATE_TIME_PICKER_DATE_PICKER_PROPERTY:
		g_value_set_object (value, maya_view_widgets_date_time_picker_get_date_picker (self));
		break;
		case MAYA_VIEW_WIDGETS_DATE_TIME_PICKER_TIME_PICKER_PROPERTY:
		g_value_set_object (value, maya_view_widgets_date_time_picker_get_time_picker (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_maya_view_widgets_date_time_picker_set_property (GObject * object,
                                                       guint property_id,
                                                       const GValue * value,
                                                       GParamSpec * pspec)
{
	MayaViewWidgetsDateTimePicker * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, MAYA_VIEW_WIDGETS_TYPE_DATE_TIME_PICKER, MayaViewWidgetsDateTimePicker);
	switch (property_id) {
		case MAYA_VIEW_WIDGETS_DATE_TIME_PICKER_DATE_PICKER_PROPERTY:
		maya_view_widgets_date_time_picker_set_date_picker (self, g_value_get_object (value));
		break;
		case MAYA_VIEW_WIDGETS_DATE_TIME_PICKER_TIME_PICKER_PROPERTY:
		maya_view_widgets_date_time_picker_set_time_picker (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

