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

#include <adwaita.h>
#include <glib-object.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include <gio/gio.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 TUBA_DIALOGS_COMPOSER_TYPE_PREFERRED_SIZEABLE (tuba_dialogs_composer_preferred_sizeable_get_type ())
#define TUBA_DIALOGS_COMPOSER_PREFERRED_SIZEABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUBA_DIALOGS_COMPOSER_TYPE_PREFERRED_SIZEABLE, TubaDialogsComposerPreferredSizeable))
#define TUBA_DIALOGS_COMPOSER_IS_PREFERRED_SIZEABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUBA_DIALOGS_COMPOSER_TYPE_PREFERRED_SIZEABLE))
#define TUBA_DIALOGS_COMPOSER_PREFERRED_SIZEABLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TUBA_DIALOGS_COMPOSER_TYPE_PREFERRED_SIZEABLE, TubaDialogsComposerPreferredSizeableIface))

typedef struct _TubaDialogsComposerPreferredSizeable TubaDialogsComposerPreferredSizeable;
typedef struct _TubaDialogsComposerPreferredSizeableIface TubaDialogsComposerPreferredSizeableIface;

#define TUBA_DIALOGS_TYPE_SCHEDULE (tuba_dialogs_schedule_get_type ())
#define TUBA_DIALOGS_SCHEDULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUBA_DIALOGS_TYPE_SCHEDULE, TubaDialogsSchedule))
#define TUBA_DIALOGS_SCHEDULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TUBA_DIALOGS_TYPE_SCHEDULE, TubaDialogsScheduleClass))
#define TUBA_DIALOGS_IS_SCHEDULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUBA_DIALOGS_TYPE_SCHEDULE))
#define TUBA_DIALOGS_IS_SCHEDULE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TUBA_DIALOGS_TYPE_SCHEDULE))
#define TUBA_DIALOGS_SCHEDULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TUBA_DIALOGS_TYPE_SCHEDULE, TubaDialogsScheduleClass))

typedef struct _TubaDialogsSchedule TubaDialogsSchedule;
typedef struct _TubaDialogsScheduleClass TubaDialogsScheduleClass;
typedef struct _TubaDialogsSchedulePrivate TubaDialogsSchedulePrivate;

#define TUBA_DIALOGS_COMPOSER_TYPE_PREFERRED_SIZE_BIN (tuba_dialogs_composer_preferred_size_bin_get_type ())
#define TUBA_DIALOGS_COMPOSER_PREFERRED_SIZE_BIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUBA_DIALOGS_COMPOSER_TYPE_PREFERRED_SIZE_BIN, TubaDialogsComposerPreferredSizeBin))
#define TUBA_DIALOGS_COMPOSER_PREFERRED_SIZE_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TUBA_DIALOGS_COMPOSER_TYPE_PREFERRED_SIZE_BIN, TubaDialogsComposerPreferredSizeBinClass))
#define TUBA_DIALOGS_COMPOSER_IS_PREFERRED_SIZE_BIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUBA_DIALOGS_COMPOSER_TYPE_PREFERRED_SIZE_BIN))
#define TUBA_DIALOGS_COMPOSER_IS_PREFERRED_SIZE_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TUBA_DIALOGS_COMPOSER_TYPE_PREFERRED_SIZE_BIN))
#define TUBA_DIALOGS_COMPOSER_PREFERRED_SIZE_BIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TUBA_DIALOGS_COMPOSER_TYPE_PREFERRED_SIZE_BIN, TubaDialogsComposerPreferredSizeBinClass))

typedef struct _TubaDialogsComposerPreferredSizeBin TubaDialogsComposerPreferredSizeBin;
typedef struct _TubaDialogsComposerPreferredSizeBinClass TubaDialogsComposerPreferredSizeBinClass;
enum  {
	TUBA_DIALOGS_SCHEDULE_0_PROPERTY,
	TUBA_DIALOGS_SCHEDULE_PREFERRED_HEIGHT_PROPERTY,
	TUBA_DIALOGS_SCHEDULE_PREFERRED_WIDTH_PROPERTY,
	TUBA_DIALOGS_SCHEDULE_CAN_CANCEL_PROPERTY,
	TUBA_DIALOGS_SCHEDULE_NUM_PROPERTIES
};
static GParamSpec* tuba_dialogs_schedule_properties[TUBA_DIALOGS_SCHEDULE_NUM_PROPERTIES];
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))
#define _g_time_zone_unref0(var) ((var == NULL) ? NULL : (var = (g_time_zone_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	TUBA_DIALOGS_SCHEDULE_SCHEDULE_PICKED_SIGNAL,
	TUBA_DIALOGS_SCHEDULE_CANCELLED_SIGNAL,
	TUBA_DIALOGS_SCHEDULE_NUM_SIGNALS
};
static guint tuba_dialogs_schedule_signals[TUBA_DIALOGS_SCHEDULE_NUM_SIGNALS] = {0};

struct _TubaDialogsComposerPreferredSizeableIface {
	GTypeInterface parent_iface;
	gint (*get_preferred_height) (TubaDialogsComposerPreferredSizeable* self);
	void (*set_preferred_height) (TubaDialogsComposerPreferredSizeable* self, gint value);
	gint (*get_preferred_width) (TubaDialogsComposerPreferredSizeable* self);
	void (*set_preferred_width) (TubaDialogsComposerPreferredSizeable* self, gint value);
};

struct _TubaDialogsSchedule {
	AdwNavigationPage parent_instance;
	TubaDialogsSchedulePrivate * priv;
};

struct _TubaDialogsScheduleClass {
	AdwNavigationPageClass parent_class;
};

struct _TubaDialogsSchedulePrivate {
	gint _preferred_height;
	gint _preferred_width;
	GtkCalendar* calendar;
	GtkSpinButton* hours_spin_button;
	GtkSpinButton* minutes_spin_button;
	GtkSpinButton* seconds_spin_button;
	AdwComboRow* timezone_combo_row;
	GtkButton* schedule_button;
	GtkButton* cancel_button;
	TubaDialogsComposerPreferredSizeBin* size_bin;
	GDateTime* result_dt;
};

static gint TubaDialogsSchedule_private_offset;
static gpointer tuba_dialogs_schedule_parent_class = NULL;
static TubaDialogsComposerPreferredSizeableIface * tuba_dialogs_schedule_tuba_dialogs_composer_preferred_sizeable_parent_iface = NULL;

VALA_EXTERN GType tuba_dialogs_composer_preferred_sizeable_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaDialogsComposerPreferredSizeable, g_object_unref)
VALA_EXTERN GType tuba_dialogs_schedule_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaDialogsSchedule, g_object_unref)
VALA_EXTERN GType tuba_dialogs_composer_preferred_size_bin_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaDialogsComposerPreferredSizeBin, g_object_unref)
VALA_EXTERN TubaDialogsSchedule* tuba_dialogs_schedule_new (const gchar* iso8601,
                                                const gchar* button_label);
VALA_EXTERN TubaDialogsSchedule* tuba_dialogs_schedule_construct (GType object_type,
                                                      const gchar* iso8601,
                                                      const gchar* button_label);
static void tuba_dialogs_schedule_validate (TubaDialogsSchedule* self);
static void _tuba_dialogs_schedule_validate_gtk_calendar_day_selected (GtkCalendar* _sender,
                                                                gpointer self);
static void _tuba_dialogs_schedule_validate_gtk_spin_button_value_changed (GtkSpinButton* _sender,
                                                                    gpointer self);
static void _tuba_dialogs_schedule_validate_g_object_notify (GObject* _sender,
                                                      GParamSpec* pspec,
                                                      gpointer self);
static void tuba_dialogs_schedule_on_schedule (TubaDialogsSchedule* self);
static void _tuba_dialogs_schedule_on_schedule_gtk_button_clicked (GtkButton* _sender,
                                                            gpointer self);
static void tuba_dialogs_schedule_on_cancel (TubaDialogsSchedule* self);
static void _tuba_dialogs_schedule_on_cancel_gtk_button_clicked (GtkButton* _sender,
                                                          gpointer self);
static void tuba_dialogs_schedule_real_measure (GtkWidget* base,
                                         GtkOrientation orientation,
                                         gint for_size,
                                         gint* minimum,
                                         gint* natural,
                                         gint* minimum_baseline,
                                         gint* natural_baseline);
VALA_EXTERN gboolean tuba_dialogs_schedule_get_can_cancel (TubaDialogsSchedule* self);
VALA_EXTERN void tuba_dialogs_schedule_set_can_cancel (TubaDialogsSchedule* self,
                                           gboolean value);
static GObject * tuba_dialogs_schedule_constructor (GType type,
                                             guint n_construct_properties,
                                             GObjectConstructParam * construct_properties);
static void _vala_array_add48 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
VALA_EXTERN gint tuba_dialogs_composer_preferred_sizeable_get_preferred_height (TubaDialogsComposerPreferredSizeable* self);
VALA_EXTERN void tuba_dialogs_composer_preferred_sizeable_set_preferred_height (TubaDialogsComposerPreferredSizeable* self,
                                                                    gint value);
VALA_EXTERN gint tuba_dialogs_composer_preferred_sizeable_get_preferred_width (TubaDialogsComposerPreferredSizeable* self);
VALA_EXTERN void tuba_dialogs_composer_preferred_sizeable_set_preferred_width (TubaDialogsComposerPreferredSizeable* self,
                                                                   gint value);
static void tuba_dialogs_schedule_finalize (GObject * obj);
static GType tuba_dialogs_schedule_get_type_once (void);
static void _vala_tuba_dialogs_schedule_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec);
static void _vala_tuba_dialogs_schedule_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
tuba_dialogs_schedule_get_instance_private (TubaDialogsSchedule* self)
{
	return G_STRUCT_MEMBER_P (self, TubaDialogsSchedule_private_offset);
}

static void
_tuba_dialogs_schedule_validate_gtk_calendar_day_selected (GtkCalendar* _sender,
                                                           gpointer self)
{
	tuba_dialogs_schedule_validate ((TubaDialogsSchedule*) self);
}

static void
_tuba_dialogs_schedule_validate_gtk_spin_button_value_changed (GtkSpinButton* _sender,
                                                               gpointer self)
{
	tuba_dialogs_schedule_validate ((TubaDialogsSchedule*) self);
}

static void
_tuba_dialogs_schedule_validate_g_object_notify (GObject* _sender,
                                                 GParamSpec* pspec,
                                                 gpointer self)
{
	tuba_dialogs_schedule_validate ((TubaDialogsSchedule*) self);
}

TubaDialogsSchedule*
tuba_dialogs_schedule_construct (GType object_type,
                                 const gchar* iso8601,
                                 const gchar* button_label)
{
	TubaDialogsSchedule * self = NULL;
	GtkCalendar* _tmp22_;
	GtkSpinButton* _tmp23_;
	GtkSpinButton* _tmp24_;
	GtkSpinButton* _tmp25_;
	AdwComboRow* _tmp26_;
	self = (TubaDialogsSchedule*) g_object_new (object_type, NULL);
	if (iso8601 == NULL) {
		GDateTime* now = NULL;
		GDateTime* _tmp0_;
		GtkSpinButton* _tmp1_;
		GDateTime* _tmp2_;
		GtkSpinButton* _tmp3_;
		GDateTime* _tmp4_;
		GtkSpinButton* _tmp5_;
		GDateTime* _tmp6_;
		_tmp0_ = g_date_time_new_now_local ();
		now = _tmp0_;
		_tmp1_ = self->priv->hours_spin_button;
		_tmp2_ = now;
		gtk_spin_button_set_value (_tmp1_, (gdouble) g_date_time_get_hour (_tmp2_));
		_tmp3_ = self->priv->minutes_spin_button;
		_tmp4_ = now;
		gtk_spin_button_set_value (_tmp3_, (gdouble) g_date_time_get_minute (_tmp4_));
		_tmp5_ = self->priv->seconds_spin_button;
		_tmp6_ = now;
		gtk_spin_button_set_value (_tmp5_, (gdouble) g_date_time_get_second (_tmp6_));
		_g_date_time_unref0 (now);
	} else {
		GDateTime* iso8601_datetime = NULL;
		GDateTime* _tmp7_;
		GDateTime* _tmp8_;
		GTimeZone* _tmp9_;
		GTimeZone* _tmp10_;
		GDateTime* _tmp11_;
		GDateTime* _tmp12_;
		GtkSpinButton* _tmp13_;
		GDateTime* _tmp14_;
		GtkSpinButton* _tmp15_;
		GDateTime* _tmp16_;
		GtkSpinButton* _tmp17_;
		GDateTime* _tmp18_;
		GtkCalendar* _tmp19_;
		GDateTime* _tmp20_;
		_tmp7_ = g_date_time_new_from_iso8601 (iso8601, NULL);
		_tmp8_ = _tmp7_;
		_tmp9_ = g_time_zone_new_local ();
		_tmp10_ = _tmp9_;
		_tmp11_ = g_date_time_to_timezone (_tmp8_, _tmp10_);
		_tmp12_ = _tmp11_;
		_g_time_zone_unref0 (_tmp10_);
		_g_date_time_unref0 (_tmp8_);
		iso8601_datetime = _tmp12_;
		_tmp13_ = self->priv->hours_spin_button;
		_tmp14_ = iso8601_datetime;
		gtk_spin_button_set_value (_tmp13_, (gdouble) g_date_time_get_hour (_tmp14_));
		_tmp15_ = self->priv->minutes_spin_button;
		_tmp16_ = iso8601_datetime;
		gtk_spin_button_set_value (_tmp15_, (gdouble) g_date_time_get_minute (_tmp16_));
		_tmp17_ = self->priv->seconds_spin_button;
		_tmp18_ = iso8601_datetime;
		gtk_spin_button_set_value (_tmp17_, (gdouble) g_date_time_get_second (_tmp18_));
		_tmp19_ = self->priv->calendar;
		_tmp20_ = iso8601_datetime;
		gtk_calendar_set_date (_tmp19_, _tmp20_);
		_g_date_time_unref0 (iso8601_datetime);
	}
	if (button_label != NULL) {
		GtkButton* _tmp21_;
		_tmp21_ = self->priv->schedule_button;
		gtk_button_set_label (_tmp21_, button_label);
	}
	_tmp22_ = self->priv->calendar;
	g_signal_connect_object (_tmp22_, "day-selected", (GCallback) _tuba_dialogs_schedule_validate_gtk_calendar_day_selected, self, 0);
	_tmp23_ = self->priv->hours_spin_button;
	g_signal_connect_object (_tmp23_, "value-changed", (GCallback) _tuba_dialogs_schedule_validate_gtk_spin_button_value_changed, self, 0);
	_tmp24_ = self->priv->minutes_spin_button;
	g_signal_connect_object (_tmp24_, "value-changed", (GCallback) _tuba_dialogs_schedule_validate_gtk_spin_button_value_changed, self, 0);
	_tmp25_ = self->priv->seconds_spin_button;
	g_signal_connect_object (_tmp25_, "value-changed", (GCallback) _tuba_dialogs_schedule_validate_gtk_spin_button_value_changed, self, 0);
	_tmp26_ = self->priv->timezone_combo_row;
	g_signal_connect_object ((GObject*) _tmp26_, "notify::selected", (GCallback) _tuba_dialogs_schedule_validate_g_object_notify, self, 0);
	tuba_dialogs_schedule_validate (self);
	return self;
}

TubaDialogsSchedule*
tuba_dialogs_schedule_new (const gchar* iso8601,
                           const gchar* button_label)
{
	return tuba_dialogs_schedule_construct (TUBA_DIALOGS_TYPE_SCHEDULE, iso8601, button_label);
}

static void
tuba_dialogs_schedule_on_schedule (TubaDialogsSchedule* self)
{
	GDateTime* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->result_dt;
	_tmp1_ = g_date_time_format_iso8601 (_tmp0_);
	_tmp2_ = _tmp1_;
	g_signal_emit (self, tuba_dialogs_schedule_signals[TUBA_DIALOGS_SCHEDULE_SCHEDULE_PICKED_SIGNAL], 0, _tmp2_);
	_g_free0 (_tmp2_);
}

static void
_tuba_dialogs_schedule_on_schedule_gtk_button_clicked (GtkButton* _sender,
                                                       gpointer self)
{
	tuba_dialogs_schedule_on_schedule ((TubaDialogsSchedule*) self);
}

static void
tuba_dialogs_schedule_on_cancel (TubaDialogsSchedule* self)
{
	g_return_if_fail (self != NULL);
	g_signal_emit (self, tuba_dialogs_schedule_signals[TUBA_DIALOGS_SCHEDULE_CANCELLED_SIGNAL], 0);
}

static void
_tuba_dialogs_schedule_on_cancel_gtk_button_clicked (GtkButton* _sender,
                                                     gpointer self)
{
	tuba_dialogs_schedule_on_cancel ((TubaDialogsSchedule*) self);
}

static void
tuba_dialogs_schedule_validate (TubaDialogsSchedule* self)
{
	gboolean valid = FALSE;
	GDateTime* now = NULL;
	GDateTime* _tmp0_;
	gboolean _tmp1_ = FALSE;
	AdwComboRow* _tmp2_;
	guint _tmp3_;
	guint _tmp4_;
	GTimeSpan delta = 0LL;
	GDateTime* _tmp38_;
	GDateTime* _tmp39_;
	GtkButton* _tmp40_;
	g_return_if_fail (self != NULL);
	valid = TRUE;
	_tmp0_ = g_date_time_new_now_utc ();
	now = _tmp0_;
	_tmp2_ = self->priv->timezone_combo_row;
	_tmp3_ = adw_combo_row_get_selected (_tmp2_);
	_tmp4_ = _tmp3_;
	if (_tmp4_ != GTK_INVALID_LIST_POSITION) {
		AdwComboRow* _tmp5_;
		GObject* _tmp6_;
		GObject* _tmp7_;
		const gchar* _tmp8_;
		const gchar* _tmp9_;
		_tmp5_ = self->priv->timezone_combo_row;
		_tmp6_ = adw_combo_row_get_selected_item (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp8_ = gtk_string_object_get_string (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, gtk_string_object_get_type (), GtkStringObject));
		_tmp9_ = _tmp8_;
		_tmp1_ = g_strcmp0 (_tmp9_, "UTC") == 0;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		GtkCalendar* _tmp10_;
		GtkCalendar* _tmp11_;
		GtkCalendar* _tmp12_;
		GtkSpinButton* _tmp13_;
		gdouble _tmp14_;
		gdouble _tmp15_;
		GtkSpinButton* _tmp16_;
		gdouble _tmp17_;
		gdouble _tmp18_;
		GtkSpinButton* _tmp19_;
		gdouble _tmp20_;
		gdouble _tmp21_;
		GDateTime* _tmp22_;
		_tmp10_ = self->priv->calendar;
		_tmp11_ = self->priv->calendar;
		_tmp12_ = self->priv->calendar;
		_tmp13_ = self->priv->hours_spin_button;
		_tmp14_ = gtk_spin_button_get_value (_tmp13_);
		_tmp15_ = _tmp14_;
		_tmp16_ = self->priv->minutes_spin_button;
		_tmp17_ = gtk_spin_button_get_value (_tmp16_);
		_tmp18_ = _tmp17_;
		_tmp19_ = self->priv->seconds_spin_button;
		_tmp20_ = gtk_spin_button_get_value (_tmp19_);
		_tmp21_ = _tmp20_;
		_tmp22_ = g_date_time_new_utc (gtk_calendar_get_year (_tmp10_), gtk_calendar_get_month (_tmp11_) + 1, gtk_calendar_get_day (_tmp12_), (gint) _tmp15_, (gint) _tmp18_, _tmp21_);
		_g_date_time_unref0 (self->priv->result_dt);
		self->priv->result_dt = _tmp22_;
	} else {
		GtkCalendar* _tmp23_;
		GtkCalendar* _tmp24_;
		GtkCalendar* _tmp25_;
		GtkSpinButton* _tmp26_;
		gdouble _tmp27_;
		gdouble _tmp28_;
		GtkSpinButton* _tmp29_;
		gdouble _tmp30_;
		gdouble _tmp31_;
		GtkSpinButton* _tmp32_;
		gdouble _tmp33_;
		gdouble _tmp34_;
		GDateTime* _tmp35_;
		GDateTime* _tmp36_;
		GDateTime* _tmp37_;
		_tmp23_ = self->priv->calendar;
		_tmp24_ = self->priv->calendar;
		_tmp25_ = self->priv->calendar;
		_tmp26_ = self->priv->hours_spin_button;
		_tmp27_ = gtk_spin_button_get_value (_tmp26_);
		_tmp28_ = _tmp27_;
		_tmp29_ = self->priv->minutes_spin_button;
		_tmp30_ = gtk_spin_button_get_value (_tmp29_);
		_tmp31_ = _tmp30_;
		_tmp32_ = self->priv->seconds_spin_button;
		_tmp33_ = gtk_spin_button_get_value (_tmp32_);
		_tmp34_ = _tmp33_;
		_tmp35_ = g_date_time_new_local (gtk_calendar_get_year (_tmp23_), gtk_calendar_get_month (_tmp24_) + 1, gtk_calendar_get_day (_tmp25_), (gint) _tmp28_, (gint) _tmp31_, _tmp34_);
		_tmp36_ = _tmp35_;
		_tmp37_ = g_date_time_to_utc (_tmp36_);
		_g_date_time_unref0 (self->priv->result_dt);
		self->priv->result_dt = _tmp37_;
		_g_date_time_unref0 (_tmp36_);
	}
	_tmp38_ = self->priv->result_dt;
	_tmp39_ = now;
	delta = g_date_time_difference (_tmp38_, _tmp39_);
	if (delta < G_TIME_SPAN_HOUR) {
		valid = (delta / G_TIME_SPAN_MINUTE) > ((GTimeSpan) 5);
	}
	_tmp40_ = self->priv->schedule_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp40_, valid);
	_g_date_time_unref0 (now);
}

static void
tuba_dialogs_schedule_real_measure (GtkWidget* base,
                                    GtkOrientation orientation,
                                    gint for_size,
                                    gint* minimum,
                                    gint* natural,
                                    gint* minimum_baseline,
                                    gint* natural_baseline)
{
	TubaDialogsSchedule * self;
	gint _vala_minimum = 0;
	gint _vala_natural = 0;
	gint _vala_minimum_baseline = 0;
	gint _vala_natural_baseline = 0;
	gint _tmp0_ = 0;
	gint _tmp1_ = 0;
	gint _tmp2_ = 0;
	gint _tmp3_ = 0;
	self = (TubaDialogsSchedule*) base;
	GTK_WIDGET_CLASS (tuba_dialogs_schedule_parent_class)->measure ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, adw_navigation_page_get_type (), AdwNavigationPage), orientation, for_size, &_tmp0_, &_tmp1_, &_tmp2_, &_tmp3_);
	_vala_minimum = _tmp0_;
	_vala_natural = _tmp1_;
	_vala_minimum_baseline = _tmp2_;
	_vala_natural_baseline = _tmp3_;
	if (orientation == GTK_ORIENTATION_HORIZONTAL) {
		_vala_natural = MAX (_vala_minimum, MAX (_vala_natural, 423));
	}
	if (minimum) {
		*minimum = _vala_minimum;
	}
	if (natural) {
		*natural = _vala_natural;
	}
	if (minimum_baseline) {
		*minimum_baseline = _vala_minimum_baseline;
	}
	if (natural_baseline) {
		*natural_baseline = _vala_natural_baseline;
	}
}

static gint
tuba_dialogs_schedule_real_get_preferred_height (TubaDialogsComposerPreferredSizeable* base)
{
	gint result;
	TubaDialogsSchedule* self;
	self = (TubaDialogsSchedule*) base;
	result = self->priv->_preferred_height;
	return result;
}

static void
tuba_dialogs_schedule_real_set_preferred_height (TubaDialogsComposerPreferredSizeable* base,
                                                 gint value)
{
	TubaDialogsSchedule* self;
	gint old_value;
	self = (TubaDialogsSchedule*) base;
	old_value = tuba_dialogs_schedule_real_get_preferred_height (base);
	if (old_value != value) {
		self->priv->_preferred_height = value;
		g_object_notify_by_pspec ((GObject *) self, tuba_dialogs_schedule_properties[TUBA_DIALOGS_SCHEDULE_PREFERRED_HEIGHT_PROPERTY]);
	}
}

static gint
tuba_dialogs_schedule_real_get_preferred_width (TubaDialogsComposerPreferredSizeable* base)
{
	gint result;
	TubaDialogsSchedule* self;
	self = (TubaDialogsSchedule*) base;
	result = self->priv->_preferred_width;
	return result;
}

static void
tuba_dialogs_schedule_real_set_preferred_width (TubaDialogsComposerPreferredSizeable* base,
                                                gint value)
{
	TubaDialogsSchedule* self;
	gint old_value;
	self = (TubaDialogsSchedule*) base;
	old_value = tuba_dialogs_schedule_real_get_preferred_width (base);
	if (old_value != value) {
		self->priv->_preferred_width = value;
		g_object_notify_by_pspec ((GObject *) self, tuba_dialogs_schedule_properties[TUBA_DIALOGS_SCHEDULE_PREFERRED_WIDTH_PROPERTY]);
	}
}

gboolean
tuba_dialogs_schedule_get_can_cancel (TubaDialogsSchedule* self)
{
	gboolean result;
	GtkButton* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->cancel_button;
	_tmp1_ = gtk_widget_get_visible ((GtkWidget*) _tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

void
tuba_dialogs_schedule_set_can_cancel (TubaDialogsSchedule* self,
                                      gboolean value)
{
	GtkButton* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->cancel_button;
	gtk_widget_set_visible ((GtkWidget*) _tmp0_, value);
	g_object_notify_by_pspec ((GObject *) self, tuba_dialogs_schedule_properties[TUBA_DIALOGS_SCHEDULE_CAN_CANCEL_PROPERTY]);
}

static void
_vala_array_add48 (gchar** * array,
                   gint* length,
                   gint* size,
                   gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static GObject *
tuba_dialogs_schedule_constructor (GType type,
                                   guint n_construct_properties,
                                   GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	TubaDialogsSchedule * self;
	GtkCalendar* _tmp0_;
	gchar* local = NULL;
	GTimeZone* _tmp1_;
	GTimeZone* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar** timezones = NULL;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	gchar** _tmp8_;
	gint timezones_length1;
	gint _timezones_size_;
	const gchar* _tmp9_;
	AdwComboRow* _tmp11_;
	gchar** _tmp12_;
	gint _tmp12__length1;
	GtkStringList* _tmp13_;
	GtkStringList* _tmp14_;
	TubaDialogsComposerPreferredSizeBin* _tmp15_;
	TubaDialogsComposerPreferredSizeBin* _tmp16_;
	parent_class = G_OBJECT_CLASS (tuba_dialogs_schedule_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TUBA_DIALOGS_TYPE_SCHEDULE, TubaDialogsSchedule);
	_tmp0_ = self->priv->calendar;
	gtk_widget_remove_css_class ((GtkWidget*) _tmp0_, "view");
	_tmp1_ = g_time_zone_new_local ();
	_tmp2_ = _tmp1_;
	_tmp3_ = g_time_zone_get_identifier (_tmp2_);
	_tmp4_ = g_strdup (_tmp3_);
	_tmp5_ = _tmp4_;
	_g_time_zone_unref0 (_tmp2_);
	local = _tmp5_;
	_tmp6_ = local;
	_tmp7_ = g_strdup (_tmp6_);
	_tmp8_ = g_new0 (gchar*, 1 + 1);
	_tmp8_[0] = _tmp7_;
	timezones = _tmp8_;
	timezones_length1 = 1;
	_timezones_size_ = timezones_length1;
	_tmp9_ = local;
	if (g_strcmp0 (_tmp9_, "UTC") != 0) {
		gchar* _tmp10_;
		_tmp10_ = g_strdup ("UTC");
		_vala_array_add48 (&timezones, &timezones_length1, &_timezones_size_, _tmp10_);
	}
	_tmp11_ = self->priv->timezone_combo_row;
	_tmp12_ = timezones;
	_tmp12__length1 = timezones_length1;
	_tmp13_ = gtk_string_list_new (_tmp12_);
	_tmp14_ = _tmp13_;
	adw_combo_row_set_model (_tmp11_, (GListModel*) _tmp14_);
	_g_object_unref0 (_tmp14_);
	_tmp15_ = self->priv->size_bin;
	g_object_bind_property_with_closures ((GObject*) self, "preferred-height", (GObject*) _tmp15_, "height", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp16_ = self->priv->size_bin;
	g_object_bind_property_with_closures ((GObject*) self, "preferred-width", (GObject*) _tmp16_, "width", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	timezones = (_vala_array_free (timezones, timezones_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (local);
	return obj;
}

static void
tuba_dialogs_schedule_class_init (TubaDialogsScheduleClass * klass,
                                  gpointer klass_data)
{
	tuba_dialogs_schedule_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &TubaDialogsSchedule_private_offset);
	((GtkWidgetClass *) klass)->measure = (void (*) (GtkWidget*, GtkOrientation, gint, gint*, gint*, gint*, gint*)) tuba_dialogs_schedule_real_measure;
	G_OBJECT_CLASS (klass)->get_property = _vala_tuba_dialogs_schedule_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_tuba_dialogs_schedule_set_property;
	G_OBJECT_CLASS (klass)->constructor = tuba_dialogs_schedule_constructor;
	G_OBJECT_CLASS (klass)->finalize = tuba_dialogs_schedule_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), TUBA_DIALOGS_SCHEDULE_PREFERRED_HEIGHT_PROPERTY, tuba_dialogs_schedule_properties[TUBA_DIALOGS_SCHEDULE_PREFERRED_HEIGHT_PROPERTY] = g_param_spec_int ("preferred-height", "preferred-height", "preferred-height", G_MININT, G_MAXINT, -1, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), TUBA_DIALOGS_SCHEDULE_PREFERRED_WIDTH_PROPERTY, tuba_dialogs_schedule_properties[TUBA_DIALOGS_SCHEDULE_PREFERRED_WIDTH_PROPERTY] = g_param_spec_int ("preferred-width", "preferred-width", "preferred-width", G_MININT, G_MAXINT, -1, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), TUBA_DIALOGS_SCHEDULE_CAN_CANCEL_PROPERTY, tuba_dialogs_schedule_properties[TUBA_DIALOGS_SCHEDULE_CAN_CANCEL_PROPERTY] = g_param_spec_boolean ("can-cancel", "can-cancel", "can-cancel", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/dev/geopjr/Tuba/ui/dialogs/schedule.ui");
	tuba_dialogs_schedule_signals[TUBA_DIALOGS_SCHEDULE_SCHEDULE_PICKED_SIGNAL] = g_signal_new ("schedule-picked", TUBA_DIALOGS_TYPE_SCHEDULE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
	tuba_dialogs_schedule_signals[TUBA_DIALOGS_SCHEDULE_CANCELLED_SIGNAL] = g_signal_new ("cancelled", TUBA_DIALOGS_TYPE_SCHEDULE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "calendar", FALSE, TubaDialogsSchedule_private_offset + G_STRUCT_OFFSET (TubaDialogsSchedulePrivate, calendar));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "hours_spin_button", FALSE, TubaDialogsSchedule_private_offset + G_STRUCT_OFFSET (TubaDialogsSchedulePrivate, hours_spin_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "minutes_spin_button", FALSE, TubaDialogsSchedule_private_offset + G_STRUCT_OFFSET (TubaDialogsSchedulePrivate, minutes_spin_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "seconds_spin_button", FALSE, TubaDialogsSchedule_private_offset + G_STRUCT_OFFSET (TubaDialogsSchedulePrivate, seconds_spin_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "timezone_combo_row", FALSE, TubaDialogsSchedule_private_offset + G_STRUCT_OFFSET (TubaDialogsSchedulePrivate, timezone_combo_row));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "schedule_button", FALSE, TubaDialogsSchedule_private_offset + G_STRUCT_OFFSET (TubaDialogsSchedulePrivate, schedule_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "cancel_button", FALSE, TubaDialogsSchedule_private_offset + G_STRUCT_OFFSET (TubaDialogsSchedulePrivate, cancel_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "size_bin", FALSE, TubaDialogsSchedule_private_offset + G_STRUCT_OFFSET (TubaDialogsSchedulePrivate, size_bin));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_schedule", G_CALLBACK(_tuba_dialogs_schedule_on_schedule_gtk_button_clicked));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_cancel", G_CALLBACK(_tuba_dialogs_schedule_on_cancel_gtk_button_clicked));
	g_type_ensure (TUBA_DIALOGS_COMPOSER_TYPE_PREFERRED_SIZE_BIN);
}

static void
tuba_dialogs_schedule_tuba_dialogs_composer_preferred_sizeable_interface_init (TubaDialogsComposerPreferredSizeableIface * iface,
                                                                               gpointer iface_data)
{
	tuba_dialogs_schedule_tuba_dialogs_composer_preferred_sizeable_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_preferred_height = tuba_dialogs_schedule_real_get_preferred_height;
	iface->set_preferred_height = tuba_dialogs_schedule_real_set_preferred_height;
	iface->get_preferred_width = tuba_dialogs_schedule_real_get_preferred_width;
	iface->set_preferred_width = tuba_dialogs_schedule_real_set_preferred_width;
}

static void
tuba_dialogs_schedule_instance_init (TubaDialogsSchedule * self,
                                     gpointer klass)
{
	self->priv = tuba_dialogs_schedule_get_instance_private (self);
	self->priv->_preferred_height = -1;
	self->priv->_preferred_width = -1;
	g_type_ensure (TUBA_DIALOGS_COMPOSER_TYPE_PREFERRED_SIZE_BIN);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
tuba_dialogs_schedule_finalize (GObject * obj)
{
	TubaDialogsSchedule * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TUBA_DIALOGS_TYPE_SCHEDULE, TubaDialogsSchedule);
	g_debug ("Schedule.vala:9: Destroying Schedule");
	_g_date_time_unref0 (self->priv->result_dt);
	G_OBJECT_CLASS (tuba_dialogs_schedule_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
tuba_dialogs_schedule_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TubaDialogsScheduleClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tuba_dialogs_schedule_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TubaDialogsSchedule), 0, (GInstanceInitFunc) tuba_dialogs_schedule_instance_init, NULL };
	static const GInterfaceInfo tuba_dialogs_composer_preferred_sizeable_info = { (GInterfaceInitFunc) tuba_dialogs_schedule_tuba_dialogs_composer_preferred_sizeable_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType tuba_dialogs_schedule_type_id;
	tuba_dialogs_schedule_type_id = g_type_register_static (adw_navigation_page_get_type (), "TubaDialogsSchedule", &g_define_type_info, G_TYPE_FLAG_NONE);
	g_type_add_interface_static (tuba_dialogs_schedule_type_id, TUBA_DIALOGS_COMPOSER_TYPE_PREFERRED_SIZEABLE, &tuba_dialogs_composer_preferred_sizeable_info);
	TubaDialogsSchedule_private_offset = g_type_add_instance_private (tuba_dialogs_schedule_type_id, sizeof (TubaDialogsSchedulePrivate));
	return tuba_dialogs_schedule_type_id;
}

GType
tuba_dialogs_schedule_get_type (void)
{
	static GType tuba_dialogs_schedule_type_id__once = 0;
	if (g_once_init_enter_pointer (&tuba_dialogs_schedule_type_id__once)) {
		GType tuba_dialogs_schedule_type_id;
		tuba_dialogs_schedule_type_id = tuba_dialogs_schedule_get_type_once ();
		g_once_init_leave_pointer (&tuba_dialogs_schedule_type_id__once, tuba_dialogs_schedule_type_id);
	}
	return tuba_dialogs_schedule_type_id__once;
}

static void
_vala_tuba_dialogs_schedule_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec)
{
	TubaDialogsSchedule * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TUBA_DIALOGS_TYPE_SCHEDULE, TubaDialogsSchedule);
	switch (property_id) {
		case TUBA_DIALOGS_SCHEDULE_PREFERRED_HEIGHT_PROPERTY:
		g_value_set_int (value, tuba_dialogs_composer_preferred_sizeable_get_preferred_height ((TubaDialogsComposerPreferredSizeable*) self));
		break;
		case TUBA_DIALOGS_SCHEDULE_PREFERRED_WIDTH_PROPERTY:
		g_value_set_int (value, tuba_dialogs_composer_preferred_sizeable_get_preferred_width ((TubaDialogsComposerPreferredSizeable*) self));
		break;
		case TUBA_DIALOGS_SCHEDULE_CAN_CANCEL_PROPERTY:
		g_value_set_boolean (value, tuba_dialogs_schedule_get_can_cancel (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_tuba_dialogs_schedule_set_property (GObject * object,
                                          guint property_id,
                                          const GValue * value,
                                          GParamSpec * pspec)
{
	TubaDialogsSchedule * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TUBA_DIALOGS_TYPE_SCHEDULE, TubaDialogsSchedule);
	switch (property_id) {
		case TUBA_DIALOGS_SCHEDULE_PREFERRED_HEIGHT_PROPERTY:
		tuba_dialogs_composer_preferred_sizeable_set_preferred_height ((TubaDialogsComposerPreferredSizeable*) self, g_value_get_int (value));
		break;
		case TUBA_DIALOGS_SCHEDULE_PREFERRED_WIDTH_PROPERTY:
		tuba_dialogs_composer_preferred_sizeable_set_preferred_width ((TubaDialogsComposerPreferredSizeable*) self, g_value_get_int (value));
		break;
		case TUBA_DIALOGS_SCHEDULE_CAN_CANCEL_PROPERTY:
		tuba_dialogs_schedule_set_can_cancel (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);
}

