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

/*
 * Copyright © 2023 Alain M. (https://github.com/alainm23/planify)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA
 *
 * Authored by: Alain M. <alainmh23@gmail.com>
 */

#include "planify.h"
#include <gtk/gtk.h>
#include <glib.h>
#include <glib-object.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	WIDGETS_CALENDAR_CALENDAR_HEADER_0_PROPERTY,
	WIDGETS_CALENDAR_CALENDAR_HEADER_DATE_PROPERTY,
	WIDGETS_CALENDAR_CALENDAR_HEADER_NUM_PROPERTIES
};
static GParamSpec* widgets_calendar_calendar_header_properties[WIDGETS_CALENDAR_CALENDAR_HEADER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))
enum  {
	WIDGETS_CALENDAR_CALENDAR_HEADER_LEFT_CLICKED_SIGNAL,
	WIDGETS_CALENDAR_CALENDAR_HEADER_RIGHT_CLICKED_SIGNAL,
	WIDGETS_CALENDAR_CALENDAR_HEADER_CENTER_CLICKED_SIGNAL,
	WIDGETS_CALENDAR_CALENDAR_HEADER_NUM_SIGNALS
};
static guint widgets_calendar_calendar_header_signals[WIDGETS_CALENDAR_CALENDAR_HEADER_NUM_SIGNALS] = {0};

struct _WidgetsCalendarCalendarHeaderPrivate {
	GtkLabel* month_label;
	GtkLabel* year_label;
	GtkButton* left_button;
	GtkButton* right_button;
	GtkButton* center_button;
};

static gint WidgetsCalendarCalendarHeader_private_offset;
static gpointer widgets_calendar_calendar_header_parent_class = NULL;

static void widgets_calendar_calendar_header_update_button_labels (WidgetsCalendarCalendarHeader* self,
                                                            GDateTime* date);
static GObject * widgets_calendar_calendar_header_constructor (GType type,
                                                        guint n_construct_properties,
                                                        GObjectConstructParam * construct_properties);
static void _widgets_calendar_calendar_header___lambda157_ (WidgetsCalendarCalendarHeader* self);
static void __widgets_calendar_calendar_header___lambda157__gtk_button_clicked (GtkButton* _sender,
                                                                         gpointer self);
static void _widgets_calendar_calendar_header___lambda158_ (WidgetsCalendarCalendarHeader* self);
static void __widgets_calendar_calendar_header___lambda158__gtk_button_clicked (GtkButton* _sender,
                                                                         gpointer self);
static void _widgets_calendar_calendar_header___lambda159_ (WidgetsCalendarCalendarHeader* self);
static void __widgets_calendar_calendar_header___lambda159__gtk_button_clicked (GtkButton* _sender,
                                                                         gpointer self);
static void widgets_calendar_calendar_header_finalize (GObject * obj);
static GType widgets_calendar_calendar_header_get_type_once (void);
static void _vala_widgets_calendar_calendar_header_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 _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
widgets_calendar_calendar_header_get_instance_private (WidgetsCalendarCalendarHeader* self)
{
	return G_STRUCT_MEMBER_P (self, WidgetsCalendarCalendarHeader_private_offset);
}

WidgetsCalendarCalendarHeader*
widgets_calendar_calendar_header_construct (GType object_type)
{
	WidgetsCalendarCalendarHeader * self = NULL;
	self = (WidgetsCalendarCalendarHeader*) g_object_new (object_type, "hexpand", TRUE, "orientation", GTK_ORIENTATION_HORIZONTAL, "valign", GTK_ALIGN_CENTER, NULL);
	return self;
}

WidgetsCalendarCalendarHeader*
widgets_calendar_calendar_header_new (void)
{
	return widgets_calendar_calendar_header_construct (WIDGETS_CALENDAR_TYPE_CALENDAR_HEADER);
}

static void
widgets_calendar_calendar_header_update_button_labels (WidgetsCalendarCalendarHeader* self,
                                                       GDateTime* date)
{
	GDateTime* prev_month = NULL;
	GDateTime* _tmp0_;
	GDateTime* next_month = NULL;
	GDateTime* _tmp1_;
	GtkButton* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	GtkButton* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (date != NULL);
	_tmp0_ = g_date_time_add_months (date, -1);
	prev_month = _tmp0_;
	_tmp1_ = g_date_time_add_months (date, 1);
	next_month = _tmp1_;
	_tmp2_ = self->priv->left_button;
	_tmp3_ = g_date_time_format (prev_month, _ ("%B %Y"));
	_tmp4_ = _tmp3_;
	_tmp5_ = g_strdup_printf (_ ("Previous month, %s"), _tmp4_);
	_tmp6_ = _tmp5_;
	gtk_accessible_update_property ((GtkAccessible*) _tmp2_, GTK_ACCESSIBLE_PROPERTY_LABEL, _tmp6_, -1, -1);
	_g_free0 (_tmp6_);
	_g_free0 (_tmp4_);
	_tmp7_ = self->priv->right_button;
	_tmp8_ = g_date_time_format (next_month, _ ("%B %Y"));
	_tmp9_ = _tmp8_;
	_tmp10_ = g_strdup_printf (_ ("Next month, %s"), _tmp9_);
	_tmp11_ = _tmp10_;
	gtk_accessible_update_property ((GtkAccessible*) _tmp7_, GTK_ACCESSIBLE_PROPERTY_LABEL, _tmp11_, -1, -1);
	_g_free0 (_tmp11_);
	_g_free0 (_tmp9_);
	_g_date_time_unref0 (next_month);
	_g_date_time_unref0 (prev_month);
}

void
widgets_calendar_calendar_header_set_date (WidgetsCalendarCalendarHeader* self,
                                           GDateTime* value)
{
	GtkLabel* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	GtkLabel* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->month_label;
	_tmp1_ = g_date_time_format (value, _ ("%OB"));
	_tmp2_ = _tmp1_;
	gtk_label_set_label (_tmp0_, _tmp2_);
	_g_free0 (_tmp2_);
	_tmp3_ = self->priv->year_label;
	_tmp4_ = g_date_time_format (value, _ ("%Y"));
	_tmp5_ = _tmp4_;
	gtk_label_set_label (_tmp3_, _tmp5_);
	_g_free0 (_tmp5_);
	widgets_calendar_calendar_header_update_button_labels (self, value);
	g_object_notify_by_pspec ((GObject *) self, widgets_calendar_calendar_header_properties[WIDGETS_CALENDAR_CALENDAR_HEADER_DATE_PROPERTY]);
}

static void
_widgets_calendar_calendar_header___lambda157_ (WidgetsCalendarCalendarHeader* self)
{
	g_signal_emit (self, widgets_calendar_calendar_header_signals[WIDGETS_CALENDAR_CALENDAR_HEADER_LEFT_CLICKED_SIGNAL], 0);
}

static void
__widgets_calendar_calendar_header___lambda157__gtk_button_clicked (GtkButton* _sender,
                                                                    gpointer self)
{
	_widgets_calendar_calendar_header___lambda157_ ((WidgetsCalendarCalendarHeader*) self);
}

static void
_widgets_calendar_calendar_header___lambda158_ (WidgetsCalendarCalendarHeader* self)
{
	g_signal_emit (self, widgets_calendar_calendar_header_signals[WIDGETS_CALENDAR_CALENDAR_HEADER_RIGHT_CLICKED_SIGNAL], 0);
}

static void
__widgets_calendar_calendar_header___lambda158__gtk_button_clicked (GtkButton* _sender,
                                                                    gpointer self)
{
	_widgets_calendar_calendar_header___lambda158_ ((WidgetsCalendarCalendarHeader*) self);
}

static void
_widgets_calendar_calendar_header___lambda159_ (WidgetsCalendarCalendarHeader* self)
{
	g_signal_emit (self, widgets_calendar_calendar_header_signals[WIDGETS_CALENDAR_CALENDAR_HEADER_CENTER_CLICKED_SIGNAL], 0);
}

static void
__widgets_calendar_calendar_header___lambda159__gtk_button_clicked (GtkButton* _sender,
                                                                    gpointer self)
{
	_widgets_calendar_calendar_header___lambda159_ ((WidgetsCalendarCalendarHeader*) self);
}

static GObject *
widgets_calendar_calendar_header_constructor (GType type,
                                              guint n_construct_properties,
                                              GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	WidgetsCalendarCalendarHeader * self;
	GDateTime* _tmp0_;
	GDateTime* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	GtkLabel* _tmp4_;
	GtkLabel* _tmp5_;
	GDateTime* _tmp6_;
	GDateTime* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	GtkLabel* _tmp10_;
	GtkLabel* _tmp11_;
	GtkLabel* _tmp12_;
	gchar* _tmp13_;
	gchar** _tmp14_;
	gchar* _tmp15_;
	GtkButton* _tmp16_ = NULL;
	GtkButton* _tmp17_;
	gchar* _tmp18_;
	gchar** _tmp19_;
	gchar* _tmp20_;
	GtkButton* _tmp21_ = NULL;
	GtkButton* _tmp22_;
	GtkBox* date_grid = NULL;
	GtkBox* _tmp23_;
	GtkBox* _tmp24_;
	GtkLabel* _tmp25_;
	GtkBox* _tmp26_;
	GtkLabel* _tmp27_;
	gchar* _tmp28_;
	GtkButton* _tmp29_ = NULL;
	GtkButton* _tmp30_;
	GtkButton* _tmp31_;
	GtkButton* _tmp32_;
	GtkBox* _tmp33_;
	GtkButton* _tmp34_;
	GtkButton* _tmp35_;
	GtkButton* _tmp36_;
	GtkButton* _tmp37_;
	GtkButton* _tmp38_;
	GtkButton* _tmp39_;
	parent_class = G_OBJECT_CLASS (widgets_calendar_calendar_header_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIDGETS_CALENDAR_TYPE_CALENDAR_HEADER, WidgetsCalendarCalendarHeader);
	_tmp0_ = g_date_time_new_now_local ();
	_tmp1_ = _tmp0_;
	_tmp2_ = g_date_time_format (_tmp1_, _ ("%OB"));
	_tmp3_ = _tmp2_;
	_tmp4_ = (GtkLabel*) gtk_label_new (_tmp3_);
	g_object_ref_sink (_tmp4_);
	_g_object_unref0 (self->priv->month_label);
	self->priv->month_label = _tmp4_;
	_g_free0 (_tmp3_);
	_g_date_time_unref0 (_tmp1_);
	_tmp5_ = self->priv->month_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp5_, "font-bold");
	_tmp6_ = g_date_time_new_now_local ();
	_tmp7_ = _tmp6_;
	_tmp8_ = g_date_time_format (_tmp7_, _ ("%Y"));
	_tmp9_ = _tmp8_;
	_tmp10_ = (GtkLabel*) gtk_label_new (_tmp9_);
	g_object_ref_sink (_tmp10_);
	_g_object_unref0 (self->priv->year_label);
	self->priv->year_label = _tmp10_;
	_g_free0 (_tmp9_);
	_g_date_time_unref0 (_tmp7_);
	_tmp11_ = self->priv->year_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp11_, "font-bold");
	_tmp12_ = self->priv->year_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp12_, "primary-color");
	_tmp13_ = g_strdup ("flat");
	_tmp14_ = g_new0 (gchar*, 1 + 1);
	_tmp14_[0] = _tmp13_;
	_tmp15_ = g_strdup (_ ("Back"));
	_tmp16_ = (GtkButton*) gtk_button_new_from_icon_name ("pan-start-symbolic");
	gtk_widget_set_valign ((GtkWidget*) _tmp16_, GTK_ALIGN_CENTER);
	gtk_widget_set_css_classes ((GtkWidget*) _tmp16_, _tmp14_);
	_tmp14_ = (_vala_array_free (_tmp14_, 1, (GDestroyNotify) g_free), NULL);
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp16_, _tmp15_);
	_g_free0 (_tmp15_);
	g_object_ref_sink (_tmp16_);
	_g_object_unref0 (self->priv->left_button);
	self->priv->left_button = _tmp16_;
	_tmp17_ = self->priv->left_button;
	gtk_accessible_update_property ((GtkAccessible*) _tmp17_, GTK_ACCESSIBLE_PROPERTY_LABEL, _ ("Previous month"), -1, -1);
	_tmp18_ = g_strdup ("flat");
	_tmp19_ = g_new0 (gchar*, 1 + 1);
	_tmp19_[0] = _tmp18_;
	_tmp20_ = g_strdup (_ ("Forward"));
	_tmp21_ = (GtkButton*) gtk_button_new_from_icon_name ("pan-end-symbolic");
	gtk_widget_set_valign ((GtkWidget*) _tmp21_, GTK_ALIGN_CENTER);
	gtk_widget_set_css_classes ((GtkWidget*) _tmp21_, _tmp19_);
	_tmp19_ = (_vala_array_free (_tmp19_, 1, (GDestroyNotify) g_free), NULL);
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp21_, _tmp20_);
	_g_free0 (_tmp20_);
	g_object_ref_sink (_tmp21_);
	_g_object_unref0 (self->priv->right_button);
	self->priv->right_button = _tmp21_;
	_tmp22_ = self->priv->right_button;
	gtk_accessible_update_property ((GtkAccessible*) _tmp22_, GTK_ACCESSIBLE_PROPERTY_LABEL, _ ("Next month"), -1, -1);
	_tmp23_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	g_object_ref_sink (_tmp23_);
	date_grid = _tmp23_;
	_tmp24_ = date_grid;
	_tmp25_ = self->priv->month_label;
	gtk_box_append (_tmp24_, (GtkWidget*) _tmp25_);
	_tmp26_ = date_grid;
	_tmp27_ = self->priv->year_label;
	gtk_box_append (_tmp26_, (GtkWidget*) _tmp27_);
	_tmp28_ = g_strdup (_ ("Today"));
	_tmp29_ = (GtkButton*) gtk_button_new ();
	gtk_widget_set_valign ((GtkWidget*) _tmp29_, GTK_ALIGN_CENTER);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp29_, TRUE);
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp29_, _tmp28_);
	_g_free0 (_tmp28_);
	g_object_ref_sink (_tmp29_);
	_g_object_unref0 (self->priv->center_button);
	self->priv->center_button = _tmp29_;
	_tmp30_ = self->priv->center_button;
	gtk_widget_add_css_class ((GtkWidget*) _tmp30_, "flat");
	_tmp31_ = self->priv->center_button;
	gtk_widget_set_can_focus ((GtkWidget*) _tmp31_, FALSE);
	_tmp32_ = self->priv->center_button;
	_tmp33_ = date_grid;
	gtk_button_set_child (_tmp32_, (GtkWidget*) _tmp33_);
	_tmp34_ = self->priv->center_button;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp34_);
	_tmp35_ = self->priv->left_button;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp35_);
	_tmp36_ = self->priv->right_button;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp36_);
	_tmp37_ = self->priv->left_button;
	g_signal_connect_object (_tmp37_, "clicked", (GCallback) __widgets_calendar_calendar_header___lambda157__gtk_button_clicked, self, 0);
	_tmp38_ = self->priv->right_button;
	g_signal_connect_object (_tmp38_, "clicked", (GCallback) __widgets_calendar_calendar_header___lambda158__gtk_button_clicked, self, 0);
	_tmp39_ = self->priv->center_button;
	g_signal_connect_object (_tmp39_, "clicked", (GCallback) __widgets_calendar_calendar_header___lambda159__gtk_button_clicked, self, 0);
	_g_object_unref0 (date_grid);
	return obj;
}

static void
widgets_calendar_calendar_header_class_init (WidgetsCalendarCalendarHeaderClass * klass,
                                             gpointer klass_data)
{
	widgets_calendar_calendar_header_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &WidgetsCalendarCalendarHeader_private_offset);
	G_OBJECT_CLASS (klass)->set_property = _vala_widgets_calendar_calendar_header_set_property;
	G_OBJECT_CLASS (klass)->constructor = widgets_calendar_calendar_header_constructor;
	G_OBJECT_CLASS (klass)->finalize = widgets_calendar_calendar_header_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), WIDGETS_CALENDAR_CALENDAR_HEADER_DATE_PROPERTY, widgets_calendar_calendar_header_properties[WIDGETS_CALENDAR_CALENDAR_HEADER_DATE_PROPERTY] = g_param_spec_boxed ("date", "date", "date", G_TYPE_DATE_TIME, G_PARAM_STATIC_STRINGS | G_PARAM_WRITABLE));
	widgets_calendar_calendar_header_signals[WIDGETS_CALENDAR_CALENDAR_HEADER_LEFT_CLICKED_SIGNAL] = g_signal_new ("left-clicked", WIDGETS_CALENDAR_TYPE_CALENDAR_HEADER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	widgets_calendar_calendar_header_signals[WIDGETS_CALENDAR_CALENDAR_HEADER_RIGHT_CLICKED_SIGNAL] = g_signal_new ("right-clicked", WIDGETS_CALENDAR_TYPE_CALENDAR_HEADER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	widgets_calendar_calendar_header_signals[WIDGETS_CALENDAR_CALENDAR_HEADER_CENTER_CLICKED_SIGNAL] = g_signal_new ("center-clicked", WIDGETS_CALENDAR_TYPE_CALENDAR_HEADER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
widgets_calendar_calendar_header_instance_init (WidgetsCalendarCalendarHeader * self,
                                                gpointer klass)
{
	self->priv = widgets_calendar_calendar_header_get_instance_private (self);
}

static void
widgets_calendar_calendar_header_finalize (GObject * obj)
{
	WidgetsCalendarCalendarHeader * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIDGETS_CALENDAR_TYPE_CALENDAR_HEADER, WidgetsCalendarCalendarHeader);
	g_debug ("CalendarHeader.vala:50: Destroying - Widgets.Calendar.CalendarHeader\n");
	_g_object_unref0 (self->priv->month_label);
	_g_object_unref0 (self->priv->year_label);
	_g_object_unref0 (self->priv->left_button);
	_g_object_unref0 (self->priv->right_button);
	_g_object_unref0 (self->priv->center_button);
	G_OBJECT_CLASS (widgets_calendar_calendar_header_parent_class)->finalize (obj);
}

static GType
widgets_calendar_calendar_header_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (WidgetsCalendarCalendarHeaderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) widgets_calendar_calendar_header_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WidgetsCalendarCalendarHeader), 0, (GInstanceInitFunc) widgets_calendar_calendar_header_instance_init, NULL };
	GType widgets_calendar_calendar_header_type_id;
	widgets_calendar_calendar_header_type_id = g_type_register_static (gtk_box_get_type (), "WidgetsCalendarCalendarHeader", &g_define_type_info, 0);
	WidgetsCalendarCalendarHeader_private_offset = g_type_add_instance_private (widgets_calendar_calendar_header_type_id, sizeof (WidgetsCalendarCalendarHeaderPrivate));
	return widgets_calendar_calendar_header_type_id;
}

GType
widgets_calendar_calendar_header_get_type (void)
{
	static volatile gsize widgets_calendar_calendar_header_type_id__once = 0;
	if (g_once_init_enter (&widgets_calendar_calendar_header_type_id__once)) {
		GType widgets_calendar_calendar_header_type_id;
		widgets_calendar_calendar_header_type_id = widgets_calendar_calendar_header_get_type_once ();
		g_once_init_leave (&widgets_calendar_calendar_header_type_id__once, widgets_calendar_calendar_header_type_id);
	}
	return widgets_calendar_calendar_header_type_id__once;
}

static void
_vala_widgets_calendar_calendar_header_set_property (GObject * object,
                                                     guint property_id,
                                                     const GValue * value,
                                                     GParamSpec * pspec)
{
	WidgetsCalendarCalendarHeader * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, WIDGETS_CALENDAR_TYPE_CALENDAR_HEADER, WidgetsCalendarCalendarHeader);
	switch (property_id) {
		case WIDGETS_CALENDAR_CALENDAR_HEADER_DATE_PROPERTY:
		widgets_calendar_calendar_header_set_date (self, g_value_get_boxed (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);
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

