/* ReminderButton.c generated by valac 0.56.19, the Vala compiler
 * generated from ReminderButton.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 <glib.h>
#include <gtk/gtk.h>
#include <gee.h>
#include <glib-object.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include <pango/pango.h>
#include <adwaita.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_REMINDER_PICKER_REMINDER_BUTTON_0_PROPERTY,
	WIDGETS_REMINDER_PICKER_REMINDER_BUTTON_IS_BOARD_PROPERTY,
	WIDGETS_REMINDER_PICKER_REMINDER_BUTTON_IS_CREATING_PROPERTY,
	WIDGETS_REMINDER_PICKER_REMINDER_BUTTON_NUM_PROPERTIES
};
static GParamSpec* widgets_reminder_picker_reminder_button_properties[WIDGETS_REMINDER_PICKER_REMINDER_BUTTON_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))
enum  {
	WIDGETS_REMINDER_PICKER_REMINDER_BUTTON_REMINDER_ADDED_SIGNAL,
	WIDGETS_REMINDER_PICKER_REMINDER_BUTTON_PICKER_OPENED_SIGNAL,
	WIDGETS_REMINDER_PICKER_REMINDER_BUTTON_NUM_SIGNALS
};
static guint widgets_reminder_picker_reminder_button_signals[WIDGETS_REMINDER_PICKER_REMINDER_BUTTON_NUM_SIGNALS] = {0};

struct _WidgetsReminderPickerReminderButtonPrivate {
	gboolean _is_board;
	gboolean _is_creating;
	GtkRevealer* indicator_revealer;
	GtkLabel* value_label;
	WidgetsReminderPickerReminderPicker* reminder_picker;
	GtkMenuButton* button;
	GeeHashMap* signal_map;
};

static gint WidgetsReminderPickerReminderButton_private_offset;
static gpointer widgets_reminder_picker_reminder_button_parent_class = NULL;

static void widgets_reminder_picker_reminder_button_build_value_label (WidgetsReminderPickerReminderButton* self,
                                                                GeeArrayList* reminders);
static GObject * widgets_reminder_picker_reminder_button_constructor (GType type,
                                                               guint n_construct_properties,
                                                               GObjectConstructParam * construct_properties);
static void _widgets_reminder_picker_reminder_button___lambda249_ (WidgetsReminderPickerReminderButton* self,
                                                            ObjectsReminder* reminder);
static void __widgets_reminder_picker_reminder_button___lambda249__widgets_reminder_picker_reminder_picker_reminder_added (WidgetsReminderPickerReminderPicker* _sender,
                                                                                                                    ObjectsReminder* reminder,
                                                                                                                    gpointer self);
static void _widgets_reminder_picker_reminder_button___lambda250_ (WidgetsReminderPickerReminderButton* self);
static void __widgets_reminder_picker_reminder_button___lambda250__widgets_reminder_picker_reminder_picker_reminder_deleted (WidgetsReminderPickerReminderPicker* _sender,
                                                                                                                      ObjectsReminder* reminder,
                                                                                                                      gpointer self);
static void _widgets_reminder_picker_reminder_button___lambda251_ (WidgetsReminderPickerReminderButton* self);
static void __widgets_reminder_picker_reminder_button___lambda251__gtk_widget_show (GtkWidget* _sender,
                                                                             gpointer self);
static void _widgets_reminder_picker_reminder_button___lambda252_ (WidgetsReminderPickerReminderButton* self);
static void __widgets_reminder_picker_reminder_button___lambda252__gtk_popover_closed (GtkPopover* _sender,
                                                                                gpointer self);
static void widgets_reminder_picker_reminder_button_finalize (GObject * obj);
static GType widgets_reminder_picker_reminder_button_get_type_once (void);
static void _vala_widgets_reminder_picker_reminder_button_get_property (GObject * object,
                                                                 guint property_id,
                                                                 GValue * value,
                                                                 GParamSpec * pspec);
static void _vala_widgets_reminder_picker_reminder_button_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_reminder_picker_reminder_button_get_instance_private (WidgetsReminderPickerReminderButton* self)
{
	return G_STRUCT_MEMBER_P (self, WidgetsReminderPickerReminderButton_private_offset);
}

WidgetsReminderPickerReminderButton*
widgets_reminder_picker_reminder_button_construct (GType object_type,
                                                   gboolean is_creating)
{
	WidgetsReminderPickerReminderButton * self = NULL;
	self = (WidgetsReminderPickerReminderButton*) g_object_new (object_type, "is-board", FALSE, "is-creating", is_creating, "valign", GTK_ALIGN_CENTER, "halign", GTK_ALIGN_CENTER, "tooltip-text", _ ("Add Reminders"), NULL);
	return self;
}

WidgetsReminderPickerReminderButton*
widgets_reminder_picker_reminder_button_new (gboolean is_creating)
{
	return widgets_reminder_picker_reminder_button_construct (WIDGETS_REMINDER_PICKER_TYPE_REMINDER_BUTTON, is_creating);
}

WidgetsReminderPickerReminderButton*
widgets_reminder_picker_reminder_button_construct_for_board (GType object_type)
{
	WidgetsReminderPickerReminderButton * self = NULL;
	self = (WidgetsReminderPickerReminderButton*) g_object_new (object_type, "is-board", TRUE, "is-creating", FALSE, "tooltip-text", _ ("Add Reminders"), NULL);
	return self;
}

WidgetsReminderPickerReminderButton*
widgets_reminder_picker_reminder_button_new_for_board (void)
{
	return widgets_reminder_picker_reminder_button_construct_for_board (WIDGETS_REMINDER_PICKER_TYPE_REMINDER_BUTTON);
}

void
widgets_reminder_picker_reminder_button_set_reminders (WidgetsReminderPickerReminderButton* self,
                                                       GeeArrayList* reminders)
{
	gboolean _tmp0_;
	WidgetsReminderPickerReminderPicker* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	GtkRevealer* _tmp6_;
	WidgetsReminderPickerReminderPicker* _tmp7_;
	gboolean _tmp8_;
	gboolean _tmp9_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (reminders != NULL);
	_tmp0_ = self->priv->_is_board;
	if (_tmp0_) {
		GtkLabel* _tmp1_;
		GtkLabel* _tmp2_;
		_tmp1_ = self->priv->value_label;
		gtk_label_set_label (_tmp1_, _ ("Add Reminders"));
		_tmp2_ = self->priv->value_label;
		gtk_widget_set_tooltip_text ((GtkWidget*) _tmp2_, NULL);
	}
	_tmp3_ = self->priv->reminder_picker;
	widgets_reminder_picker_reminder_picker_set_reminders (_tmp3_, reminders);
	_tmp4_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) reminders);
	_tmp5_ = _tmp4_;
	if (_tmp5_ > 0) {
		widgets_reminder_picker_reminder_button_build_value_label (self, reminders);
	}
	_tmp6_ = self->priv->indicator_revealer;
	_tmp7_ = self->priv->reminder_picker;
	_tmp8_ = widgets_reminder_picker_reminder_picker_get_has_reminders (_tmp7_);
	_tmp9_ = _tmp8_;
	gtk_revealer_set_reveal_child (_tmp6_, _tmp9_);
}

void
widgets_reminder_picker_reminder_button_add_reminder (WidgetsReminderPickerReminderButton* self,
                                                      ObjectsReminder* reminder,
                                                      GeeArrayList* reminders)
{
	WidgetsReminderPickerReminderPicker* _tmp0_;
	gboolean _tmp1_ = FALSE;
	gint _tmp2_;
	gint _tmp3_;
	GtkRevealer* _tmp5_;
	WidgetsReminderPickerReminderPicker* _tmp6_;
	gboolean _tmp7_;
	gboolean _tmp8_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (reminder != NULL);
	g_return_if_fail (reminders != NULL);
	_tmp0_ = self->priv->reminder_picker;
	widgets_reminder_picker_reminder_picker_add_reminder (_tmp0_, reminder);
	_tmp2_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) reminders);
	_tmp3_ = _tmp2_;
	if (_tmp3_ > 0) {
		gboolean _tmp4_;
		_tmp4_ = self->priv->_is_board;
		_tmp1_ = _tmp4_;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		widgets_reminder_picker_reminder_button_build_value_label (self, reminders);
	}
	_tmp5_ = self->priv->indicator_revealer;
	_tmp6_ = self->priv->reminder_picker;
	_tmp7_ = widgets_reminder_picker_reminder_picker_get_has_reminders (_tmp6_);
	_tmp8_ = _tmp7_;
	gtk_revealer_set_reveal_child (_tmp5_, _tmp8_);
}

void
widgets_reminder_picker_reminder_button_delete_reminder (WidgetsReminderPickerReminderButton* self,
                                                         ObjectsReminder* reminder,
                                                         GeeArrayList* reminders)
{
	WidgetsReminderPickerReminderPicker* _tmp0_;
	gboolean _tmp1_;
	GtkRevealer* _tmp6_;
	WidgetsReminderPickerReminderPicker* _tmp7_;
	gboolean _tmp8_;
	gboolean _tmp9_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (reminder != NULL);
	g_return_if_fail (reminders != NULL);
	_tmp0_ = self->priv->reminder_picker;
	widgets_reminder_picker_reminder_picker_delete_reminder (_tmp0_, reminder);
	_tmp1_ = self->priv->_is_board;
	if (_tmp1_) {
		GtkLabel* _tmp2_;
		GtkLabel* _tmp3_;
		gint _tmp4_;
		gint _tmp5_;
		_tmp2_ = self->priv->value_label;
		gtk_label_set_label (_tmp2_, _ ("Add Reminders"));
		_tmp3_ = self->priv->value_label;
		gtk_widget_set_tooltip_text ((GtkWidget*) _tmp3_, NULL);
		_tmp4_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) reminders);
		_tmp5_ = _tmp4_;
		if (_tmp5_ > 0) {
			widgets_reminder_picker_reminder_button_build_value_label (self, reminders);
		}
	}
	_tmp6_ = self->priv->indicator_revealer;
	_tmp7_ = self->priv->reminder_picker;
	_tmp8_ = widgets_reminder_picker_reminder_picker_get_has_reminders (_tmp7_);
	_tmp9_ = _tmp8_;
	gtk_revealer_set_reveal_child (_tmp6_, _tmp9_);
}

static void
widgets_reminder_picker_reminder_button_build_value_label (WidgetsReminderPickerReminderButton* self,
                                                           GeeArrayList* reminders)
{
	GtkLabel* _tmp0_;
	GtkLabel* _tmp29_;
	GtkLabel* _tmp30_;
	const gchar* _tmp31_;
	const gchar* _tmp32_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (reminders != NULL);
	_tmp0_ = self->priv->value_label;
	gtk_label_set_label (_tmp0_, "");
	{
		gint index = 0;
		index = 0;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				gint _tmp3_;
				gint _tmp4_;
				gchar* date = NULL;
				gpointer _tmp5_;
				ObjectsReminder* _tmp6_;
				const gchar* _tmp7_;
				const gchar* _tmp8_;
				gchar* _tmp9_;
				gchar* _tmp10_;
				gint _tmp11_;
				gint _tmp12_;
				if (!_tmp1_) {
					gint _tmp2_;
					_tmp2_ = index;
					index = _tmp2_ + 1;
				}
				_tmp1_ = FALSE;
				_tmp3_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) reminders);
				_tmp4_ = _tmp3_;
				if (!(index < _tmp4_)) {
					break;
				}
				_tmp5_ = gee_abstract_list_get ((GeeAbstractList*) reminders, index);
				_tmp6_ = (ObjectsReminder*) _tmp5_;
				_tmp7_ = objects_reminder_get_relative_text (_tmp6_);
				_tmp8_ = _tmp7_;
				_tmp9_ = g_strdup (_tmp8_);
				_tmp10_ = _tmp9_;
				_g_object_unref0 (_tmp6_);
				date = _tmp10_;
				_tmp11_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) reminders);
				_tmp12_ = _tmp11_;
				if (index < (_tmp12_ - 1)) {
					GtkLabel* _tmp13_;
					GtkLabel* _tmp14_;
					const gchar* _tmp15_;
					const gchar* _tmp16_;
					const gchar* _tmp17_;
					gchar* _tmp18_;
					gchar* _tmp19_;
					gchar* _tmp20_;
					gchar* _tmp21_;
					_tmp13_ = self->priv->value_label;
					_tmp14_ = self->priv->value_label;
					_tmp15_ = gtk_label_get_label (_tmp14_);
					_tmp16_ = _tmp15_;
					_tmp17_ = date;
					_tmp18_ = g_strconcat (_tmp17_, ", ", NULL);
					_tmp19_ = _tmp18_;
					_tmp20_ = g_strconcat (_tmp16_, _tmp19_, NULL);
					_tmp21_ = _tmp20_;
					gtk_label_set_label (_tmp14_, _tmp21_);
					_g_free0 (_tmp21_);
					_g_free0 (_tmp19_);
				} else {
					GtkLabel* _tmp22_;
					GtkLabel* _tmp23_;
					const gchar* _tmp24_;
					const gchar* _tmp25_;
					const gchar* _tmp26_;
					gchar* _tmp27_;
					gchar* _tmp28_;
					_tmp22_ = self->priv->value_label;
					_tmp23_ = self->priv->value_label;
					_tmp24_ = gtk_label_get_label (_tmp23_);
					_tmp25_ = _tmp24_;
					_tmp26_ = date;
					_tmp27_ = g_strconcat (_tmp25_, _tmp26_, NULL);
					_tmp28_ = _tmp27_;
					gtk_label_set_label (_tmp23_, _tmp28_);
					_g_free0 (_tmp28_);
				}
				_g_free0 (date);
			}
		}
	}
	_tmp29_ = self->priv->value_label;
	_tmp30_ = self->priv->value_label;
	_tmp31_ = gtk_label_get_label (_tmp30_);
	_tmp32_ = _tmp31_;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp29_, _tmp32_);
}

GeeArrayList*
widgets_reminder_picker_reminder_button_reminders (WidgetsReminderPickerReminderButton* self)
{
	WidgetsReminderPickerReminderPicker* _tmp0_;
	GeeArrayList* _tmp1_;
	GeeArrayList* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->reminder_picker;
	_tmp1_ = widgets_reminder_picker_reminder_picker_reminders (_tmp0_);
	result = _tmp1_;
	return result;
}

void
widgets_reminder_picker_reminder_button_open_picker (WidgetsReminderPickerReminderButton* self,
                                                     gboolean suggestions_view)
{
	WidgetsReminderPickerReminderPicker* _tmp0_;
	GtkMenuButton* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->reminder_picker;
	widgets_reminder_picker_reminder_picker_set_suggestions_view (_tmp0_, suggestions_view);
	_tmp1_ = self->priv->button;
	gtk_menu_button_set_active (_tmp1_, TRUE);
}

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

gboolean
widgets_reminder_picker_reminder_button_get_is_board (WidgetsReminderPickerReminderButton* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_is_board;
	return result;
}

static void
widgets_reminder_picker_reminder_button_set_is_board (WidgetsReminderPickerReminderButton* self,
                                                      gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = widgets_reminder_picker_reminder_button_get_is_board (self);
	if (old_value != value) {
		self->priv->_is_board = value;
		g_object_notify_by_pspec ((GObject *) self, widgets_reminder_picker_reminder_button_properties[WIDGETS_REMINDER_PICKER_REMINDER_BUTTON_IS_BOARD_PROPERTY]);
	}
}

gboolean
widgets_reminder_picker_reminder_button_get_is_creating (WidgetsReminderPickerReminderButton* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_is_creating;
	return result;
}

static void
widgets_reminder_picker_reminder_button_set_is_creating (WidgetsReminderPickerReminderButton* self,
                                                         gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = widgets_reminder_picker_reminder_button_get_is_creating (self);
	if (old_value != value) {
		self->priv->_is_creating = value;
		g_object_notify_by_pspec ((GObject *) self, widgets_reminder_picker_reminder_button_properties[WIDGETS_REMINDER_PICKER_REMINDER_BUTTON_IS_CREATING_PROPERTY]);
	}
}

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

static void
_widgets_reminder_picker_reminder_button___lambda249_ (WidgetsReminderPickerReminderButton* self,
                                                       ObjectsReminder* reminder)
{
	gboolean _tmp0_;
	g_return_if_fail (reminder != NULL);
	g_signal_emit (self, widgets_reminder_picker_reminder_button_signals[WIDGETS_REMINDER_PICKER_REMINDER_BUTTON_REMINDER_ADDED_SIGNAL], 0, reminder);
	_tmp0_ = self->priv->_is_creating;
	if (_tmp0_) {
		Util* _tmp1_;
		Util* _tmp2_;
		gchar* _tmp3_;
		gchar* _tmp4_;
		GeeArrayList* _tmp5_;
		GeeArrayList* _tmp6_;
		_tmp1_ = util_get_default ();
		_tmp2_ = _tmp1_;
		_tmp3_ = util_generate_id (_tmp2_, (ObjectsBaseObject*) reminder);
		_tmp4_ = _tmp3_;
		objects_base_object_set_id ((ObjectsBaseObject*) reminder, _tmp4_);
		_g_free0 (_tmp4_);
		_g_object_unref0 (_tmp2_);
		_tmp5_ = gee_array_list_new (OBJECTS_TYPE_REMINDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
		_tmp6_ = _tmp5_;
		widgets_reminder_picker_reminder_button_add_reminder (self, reminder, _tmp6_);
		_g_object_unref0 (_tmp6_);
	}
}

static void
__widgets_reminder_picker_reminder_button___lambda249__widgets_reminder_picker_reminder_picker_reminder_added (WidgetsReminderPickerReminderPicker* _sender,
                                                                                                               ObjectsReminder* reminder,
                                                                                                               gpointer self)
{
	_widgets_reminder_picker_reminder_button___lambda249_ ((WidgetsReminderPickerReminderButton*) self, reminder);
}

static void
_widgets_reminder_picker_reminder_button___lambda250_ (WidgetsReminderPickerReminderButton* self)
{
	GtkRevealer* _tmp0_;
	WidgetsReminderPickerReminderPicker* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	_tmp0_ = self->priv->indicator_revealer;
	_tmp1_ = self->priv->reminder_picker;
	_tmp2_ = widgets_reminder_picker_reminder_picker_get_has_reminders (_tmp1_);
	_tmp3_ = _tmp2_;
	gtk_revealer_set_reveal_child (_tmp0_, _tmp3_);
}

static void
__widgets_reminder_picker_reminder_button___lambda250__widgets_reminder_picker_reminder_picker_reminder_deleted (WidgetsReminderPickerReminderPicker* _sender,
                                                                                                                 ObjectsReminder* reminder,
                                                                                                                 gpointer self)
{
	_widgets_reminder_picker_reminder_button___lambda250_ ((WidgetsReminderPickerReminderButton*) self);
}

static void
_widgets_reminder_picker_reminder_button___lambda251_ (WidgetsReminderPickerReminderButton* self)
{
	g_signal_emit (self, widgets_reminder_picker_reminder_button_signals[WIDGETS_REMINDER_PICKER_REMINDER_BUTTON_PICKER_OPENED_SIGNAL], 0, TRUE);
}

static void
__widgets_reminder_picker_reminder_button___lambda251__gtk_widget_show (GtkWidget* _sender,
                                                                        gpointer self)
{
	_widgets_reminder_picker_reminder_button___lambda251_ ((WidgetsReminderPickerReminderButton*) self);
}

static void
_widgets_reminder_picker_reminder_button___lambda252_ (WidgetsReminderPickerReminderButton* self)
{
	g_signal_emit (self, widgets_reminder_picker_reminder_button_signals[WIDGETS_REMINDER_PICKER_REMINDER_BUTTON_PICKER_OPENED_SIGNAL], 0, FALSE);
}

static void
__widgets_reminder_picker_reminder_button___lambda252__gtk_popover_closed (GtkPopover* _sender,
                                                                           gpointer self)
{
	_widgets_reminder_picker_reminder_button___lambda252_ ((WidgetsReminderPickerReminderButton*) self);
}

static GObject *
widgets_reminder_picker_reminder_button_constructor (GType type,
                                                     guint n_construct_properties,
                                                     GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	WidgetsReminderPickerReminderButton * self;
	gboolean _tmp0_;
	WidgetsReminderPickerReminderPicker* _tmp1_;
	gboolean _tmp2_;
	GeeHashMap* _tmp48_;
	WidgetsReminderPickerReminderPicker* _tmp49_;
	gulong _tmp50_;
	WidgetsReminderPickerReminderPicker* _tmp51_;
	GeeHashMap* _tmp52_;
	WidgetsReminderPickerReminderPicker* _tmp53_;
	gulong _tmp54_;
	WidgetsReminderPickerReminderPicker* _tmp55_;
	GeeHashMap* _tmp56_;
	WidgetsReminderPickerReminderPicker* _tmp57_;
	gulong _tmp58_;
	WidgetsReminderPickerReminderPicker* _tmp59_;
	GeeHashMap* _tmp60_;
	WidgetsReminderPickerReminderPicker* _tmp61_;
	gulong _tmp62_;
	WidgetsReminderPickerReminderPicker* _tmp63_;
	parent_class = G_OBJECT_CLASS (widgets_reminder_picker_reminder_button_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIDGETS_REMINDER_PICKER_TYPE_REMINDER_BUTTON, WidgetsReminderPickerReminderButton);
	_tmp0_ = self->priv->_is_creating;
	_tmp1_ = widgets_reminder_picker_reminder_picker_new (_tmp0_);
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->priv->reminder_picker);
	self->priv->reminder_picker = _tmp1_;
	_tmp2_ = self->priv->_is_board;
	if (_tmp2_) {
		GtkLabel* title_label = NULL;
		gchar* _tmp3_;
		gchar* _tmp4_;
		gchar* _tmp5_;
		gchar** _tmp6_;
		GtkLabel* _tmp7_ = NULL;
		gchar* _tmp8_;
		gchar** _tmp9_;
		GtkLabel* _tmp10_ = NULL;
		GtkGrid* card_grid = NULL;
		GtkGrid* _tmp11_ = NULL;
		GtkGrid* _tmp12_;
		GtkImage* _tmp13_;
		GtkImage* _tmp14_;
		GtkGrid* _tmp15_;
		GtkLabel* _tmp16_;
		GtkGrid* _tmp17_;
		GtkLabel* _tmp18_;
		WidgetsReminderPickerReminderPicker* _tmp19_;
		GtkPopover* _tmp20_;
		GtkGrid* _tmp21_;
		GtkWidget* _tmp22_;
		gchar* _tmp23_;
		gchar* _tmp24_;
		gchar* _tmp25_;
		gchar* _tmp26_;
		gchar** _tmp27_;
		GtkMenuButton* _tmp28_ = NULL;
		GtkMenuButton* _tmp29_;
		_tmp3_ = g_strdup ("title-4");
		_tmp4_ = g_strdup ("caption");
		_tmp5_ = g_strdup ("font-bold");
		_tmp6_ = g_new0 (gchar*, 3 + 1);
		_tmp6_[0] = _tmp3_;
		_tmp6_[1] = _tmp4_;
		_tmp6_[2] = _tmp5_;
		_tmp7_ = (GtkLabel*) gtk_label_new (_ ("Reminders"));
		gtk_widget_set_halign ((GtkWidget*) _tmp7_, GTK_ALIGN_START);
		gtk_widget_set_css_classes ((GtkWidget*) _tmp7_, _tmp6_);
		_tmp6_ = (_vala_array_free (_tmp6_, 3, (GDestroyNotify) g_free), NULL);
		g_object_ref_sink (_tmp7_);
		title_label = _tmp7_;
		_tmp8_ = g_strdup ("caption");
		_tmp9_ = g_new0 (gchar*, 1 + 1);
		_tmp9_[0] = _tmp8_;
		_tmp10_ = (GtkLabel*) gtk_label_new (_ ("Add Reminders"));
		gtk_label_set_xalign (_tmp10_, (gfloat) 0);
		gtk_label_set_use_markup (_tmp10_, TRUE);
		gtk_widget_set_halign ((GtkWidget*) _tmp10_, GTK_ALIGN_START);
		gtk_label_set_ellipsize (_tmp10_, PANGO_ELLIPSIZE_END);
		gtk_widget_set_css_classes ((GtkWidget*) _tmp10_, _tmp9_);
		_tmp9_ = (_vala_array_free (_tmp9_, 1, (GDestroyNotify) g_free), NULL);
		g_object_ref_sink (_tmp10_);
		_g_object_unref0 (self->priv->value_label);
		self->priv->value_label = _tmp10_;
		_tmp11_ = (GtkGrid*) gtk_grid_new ();
		gtk_grid_set_column_spacing (_tmp11_, 12);
		gtk_widget_set_margin_start ((GtkWidget*) _tmp11_, 12);
		gtk_widget_set_margin_end ((GtkWidget*) _tmp11_, 6);
		gtk_widget_set_margin_top ((GtkWidget*) _tmp11_, 6);
		gtk_widget_set_margin_bottom ((GtkWidget*) _tmp11_, 6);
		gtk_widget_set_vexpand ((GtkWidget*) _tmp11_, TRUE);
		gtk_widget_set_hexpand ((GtkWidget*) _tmp11_, TRUE);
		g_object_ref_sink (_tmp11_);
		card_grid = _tmp11_;
		_tmp12_ = card_grid;
		_tmp13_ = (GtkImage*) gtk_image_new_from_icon_name ("alarm-symbolic");
		g_object_ref_sink (_tmp13_);
		_tmp14_ = _tmp13_;
		gtk_grid_attach (_tmp12_, (GtkWidget*) _tmp14_, 0, 0, 1, 2);
		_g_object_unref0 (_tmp14_);
		_tmp15_ = card_grid;
		_tmp16_ = title_label;
		gtk_grid_attach (_tmp15_, (GtkWidget*) _tmp16_, 1, 0, 1, 1);
		_tmp17_ = card_grid;
		_tmp18_ = self->priv->value_label;
		gtk_grid_attach (_tmp17_, (GtkWidget*) _tmp18_, 1, 1, 1, 1);
		_tmp19_ = self->priv->reminder_picker;
		_tmp20_ = _g_object_ref0 ((GtkPopover*) _tmp19_);
		_tmp21_ = card_grid;
		_tmp22_ = _g_object_ref0 ((GtkWidget*) _tmp21_);
		_tmp23_ = g_strdup ("flat");
		_tmp24_ = g_strdup ("card");
		_tmp25_ = g_strdup ("activatable");
		_tmp26_ = g_strdup ("menu-button-no-padding");
		_tmp27_ = g_new0 (gchar*, 4 + 1);
		_tmp27_[0] = _tmp23_;
		_tmp27_[1] = _tmp24_;
		_tmp27_[2] = _tmp25_;
		_tmp27_[3] = _tmp26_;
		_tmp28_ = (GtkMenuButton*) gtk_menu_button_new ();
		gtk_menu_button_set_popover (_tmp28_, _tmp20_);
		_g_object_unref0 (_tmp20_);
		gtk_menu_button_set_child (_tmp28_, _tmp22_);
		_g_object_unref0 (_tmp22_);
		gtk_widget_set_css_classes ((GtkWidget*) _tmp28_, _tmp27_);
		_tmp27_ = (_vala_array_free (_tmp27_, 4, (GDestroyNotify) g_free), NULL);
		gtk_widget_set_hexpand ((GtkWidget*) _tmp28_, TRUE);
		g_object_ref_sink (_tmp28_);
		_g_object_unref0 (self->priv->button);
		self->priv->button = _tmp28_;
		_tmp29_ = self->priv->button;
		adw_bin_set_child ((AdwBin*) self, (GtkWidget*) _tmp29_);
		_g_object_unref0 (card_grid);
		_g_object_unref0 (title_label);
	} else {
		GtkGrid* indicator_grid = NULL;
		gchar* _tmp30_;
		gchar** _tmp31_;
		GtkGrid* _tmp32_ = NULL;
		GtkGrid* _tmp33_;
		GtkWidget* _tmp34_;
		GtkRevealer* _tmp35_ = NULL;
		gchar* _tmp36_;
		WidgetsReminderPickerReminderPicker* _tmp37_;
		GtkPopover* _tmp38_;
		gchar* _tmp39_;
		gchar** _tmp40_;
		GtkMenuButton* _tmp41_ = NULL;
		GtkOverlay* overlay = NULL;
		GtkOverlay* _tmp42_;
		GtkOverlay* _tmp43_;
		GtkMenuButton* _tmp44_;
		GtkOverlay* _tmp45_;
		GtkRevealer* _tmp46_;
		GtkOverlay* _tmp47_;
		_tmp30_ = g_strdup ("indicator");
		_tmp31_ = g_new0 (gchar*, 1 + 1);
		_tmp31_[0] = _tmp30_;
		_tmp32_ = (GtkGrid*) gtk_grid_new ();
		g_object_set ((GtkWidget*) _tmp32_, "width-request", 9, NULL);
		g_object_set ((GtkWidget*) _tmp32_, "height-request", 9, NULL);
		gtk_widget_set_margin_top ((GtkWidget*) _tmp32_, 3);
		gtk_widget_set_margin_end ((GtkWidget*) _tmp32_, 3);
		gtk_widget_set_css_classes ((GtkWidget*) _tmp32_, _tmp31_);
		_tmp31_ = (_vala_array_free (_tmp31_, 1, (GDestroyNotify) g_free), NULL);
		g_object_ref_sink (_tmp32_);
		indicator_grid = _tmp32_;
		_tmp33_ = indicator_grid;
		_tmp34_ = _g_object_ref0 ((GtkWidget*) _tmp33_);
		_tmp35_ = (GtkRevealer*) gtk_revealer_new ();
		gtk_revealer_set_transition_type (_tmp35_, GTK_REVEALER_TRANSITION_TYPE_CROSSFADE);
		gtk_revealer_set_child (_tmp35_, _tmp34_);
		_g_object_unref0 (_tmp34_);
		gtk_widget_set_halign ((GtkWidget*) _tmp35_, GTK_ALIGN_END);
		gtk_widget_set_valign ((GtkWidget*) _tmp35_, GTK_ALIGN_START);
		gtk_widget_set_sensitive ((GtkWidget*) _tmp35_, FALSE);
		g_object_ref_sink (_tmp35_);
		_g_object_unref0 (self->priv->indicator_revealer);
		self->priv->indicator_revealer = _tmp35_;
		_tmp36_ = g_strdup ("alarm-symbolic");
		_tmp37_ = self->priv->reminder_picker;
		_tmp38_ = _g_object_ref0 ((GtkPopover*) _tmp37_);
		_tmp39_ = g_strdup ("flat");
		_tmp40_ = g_new0 (gchar*, 1 + 1);
		_tmp40_[0] = _tmp39_;
		_tmp41_ = (GtkMenuButton*) gtk_menu_button_new ();
		gtk_menu_button_set_icon_name (_tmp41_, _tmp36_);
		_g_free0 (_tmp36_);
		gtk_menu_button_set_popover (_tmp41_, _tmp38_);
		_g_object_unref0 (_tmp38_);
		gtk_widget_set_css_classes ((GtkWidget*) _tmp41_, _tmp40_);
		_tmp40_ = (_vala_array_free (_tmp40_, 1, (GDestroyNotify) g_free), NULL);
		g_object_ref_sink (_tmp41_);
		_g_object_unref0 (self->priv->button);
		self->priv->button = _tmp41_;
		_tmp42_ = (GtkOverlay*) gtk_overlay_new ();
		g_object_ref_sink (_tmp42_);
		overlay = _tmp42_;
		_tmp43_ = overlay;
		_tmp44_ = self->priv->button;
		gtk_overlay_set_child (_tmp43_, (GtkWidget*) _tmp44_);
		_tmp45_ = overlay;
		_tmp46_ = self->priv->indicator_revealer;
		gtk_overlay_add_overlay (_tmp45_, (GtkWidget*) _tmp46_);
		_tmp47_ = overlay;
		adw_bin_set_child ((AdwBin*) self, (GtkWidget*) _tmp47_);
		_g_object_unref0 (overlay);
		_g_object_unref0 (indicator_grid);
	}
	_tmp48_ = self->priv->signal_map;
	_tmp49_ = self->priv->reminder_picker;
	_tmp50_ = g_signal_connect_object (_tmp49_, "reminder-added", (GCallback) __widgets_reminder_picker_reminder_button___lambda249__widgets_reminder_picker_reminder_picker_reminder_added, self, 0);
	_tmp51_ = self->priv->reminder_picker;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp48_, (gpointer) ((guintptr) _tmp50_), (GObject*) _tmp51_);
	_tmp52_ = self->priv->signal_map;
	_tmp53_ = self->priv->reminder_picker;
	_tmp54_ = g_signal_connect_object (_tmp53_, "reminder-deleted", (GCallback) __widgets_reminder_picker_reminder_button___lambda250__widgets_reminder_picker_reminder_picker_reminder_deleted, self, 0);
	_tmp55_ = self->priv->reminder_picker;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp52_, (gpointer) ((guintptr) _tmp54_), (GObject*) _tmp55_);
	_tmp56_ = self->priv->signal_map;
	_tmp57_ = self->priv->reminder_picker;
	_tmp58_ = g_signal_connect_object ((GtkWidget*) _tmp57_, "show", (GCallback) __widgets_reminder_picker_reminder_button___lambda251__gtk_widget_show, self, 0);
	_tmp59_ = self->priv->reminder_picker;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp56_, (gpointer) ((guintptr) _tmp58_), (GObject*) _tmp59_);
	_tmp60_ = self->priv->signal_map;
	_tmp61_ = self->priv->reminder_picker;
	_tmp62_ = g_signal_connect_object ((GtkPopover*) _tmp61_, "closed", (GCallback) __widgets_reminder_picker_reminder_button___lambda252__gtk_popover_closed, self, 0);
	_tmp63_ = self->priv->reminder_picker;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp60_, (gpointer) ((guintptr) _tmp62_), (GObject*) _tmp63_);
	return obj;
}

static void
widgets_reminder_picker_reminder_button_class_init (WidgetsReminderPickerReminderButtonClass * klass,
                                                    gpointer klass_data)
{
	widgets_reminder_picker_reminder_button_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &WidgetsReminderPickerReminderButton_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_widgets_reminder_picker_reminder_button_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_widgets_reminder_picker_reminder_button_set_property;
	G_OBJECT_CLASS (klass)->constructor = widgets_reminder_picker_reminder_button_constructor;
	G_OBJECT_CLASS (klass)->finalize = widgets_reminder_picker_reminder_button_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), WIDGETS_REMINDER_PICKER_REMINDER_BUTTON_IS_BOARD_PROPERTY, widgets_reminder_picker_reminder_button_properties[WIDGETS_REMINDER_PICKER_REMINDER_BUTTON_IS_BOARD_PROPERTY] = g_param_spec_boolean ("is-board", "is-board", "is-board", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), WIDGETS_REMINDER_PICKER_REMINDER_BUTTON_IS_CREATING_PROPERTY, widgets_reminder_picker_reminder_button_properties[WIDGETS_REMINDER_PICKER_REMINDER_BUTTON_IS_CREATING_PROPERTY] = g_param_spec_boolean ("is-creating", "is-creating", "is-creating", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	widgets_reminder_picker_reminder_button_signals[WIDGETS_REMINDER_PICKER_REMINDER_BUTTON_REMINDER_ADDED_SIGNAL] = g_signal_new ("reminder-added", WIDGETS_REMINDER_PICKER_TYPE_REMINDER_BUTTON, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, OBJECTS_TYPE_REMINDER);
	widgets_reminder_picker_reminder_button_signals[WIDGETS_REMINDER_PICKER_REMINDER_BUTTON_PICKER_OPENED_SIGNAL] = g_signal_new ("picker-opened", WIDGETS_REMINDER_PICKER_TYPE_REMINDER_BUTTON, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
}

static void
widgets_reminder_picker_reminder_button_instance_init (WidgetsReminderPickerReminderButton * self,
                                                       gpointer klass)
{
	GeeHashMap* _tmp0_;
	self->priv = widgets_reminder_picker_reminder_button_get_instance_private (self);
	_tmp0_ = gee_hash_map_new (G_TYPE_ULONG, NULL, NULL, G_TYPE_OBJECT, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	self->priv->signal_map = _tmp0_;
}

static void
widgets_reminder_picker_reminder_button_finalize (GObject * obj)
{
	WidgetsReminderPickerReminderButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIDGETS_REMINDER_PICKER_TYPE_REMINDER_BUTTON, WidgetsReminderPickerReminderButton);
	g_debug ("ReminderButton.vala:55: Destroying - Widgets.ReminderPicker.ReminderBu" \
"tton\n");
	_g_object_unref0 (self->priv->indicator_revealer);
	_g_object_unref0 (self->priv->value_label);
	_g_object_unref0 (self->priv->reminder_picker);
	_g_object_unref0 (self->priv->button);
	_g_object_unref0 (self->priv->signal_map);
	G_OBJECT_CLASS (widgets_reminder_picker_reminder_button_parent_class)->finalize (obj);
}

static GType
widgets_reminder_picker_reminder_button_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (WidgetsReminderPickerReminderButtonClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) widgets_reminder_picker_reminder_button_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WidgetsReminderPickerReminderButton), 0, (GInstanceInitFunc) widgets_reminder_picker_reminder_button_instance_init, NULL };
	GType widgets_reminder_picker_reminder_button_type_id;
	widgets_reminder_picker_reminder_button_type_id = g_type_register_static (adw_bin_get_type (), "WidgetsReminderPickerReminderButton", &g_define_type_info, 0);
	WidgetsReminderPickerReminderButton_private_offset = g_type_add_instance_private (widgets_reminder_picker_reminder_button_type_id, sizeof (WidgetsReminderPickerReminderButtonPrivate));
	return widgets_reminder_picker_reminder_button_type_id;
}

GType
widgets_reminder_picker_reminder_button_get_type (void)
{
	static volatile gsize widgets_reminder_picker_reminder_button_type_id__once = 0;
	if (g_once_init_enter (&widgets_reminder_picker_reminder_button_type_id__once)) {
		GType widgets_reminder_picker_reminder_button_type_id;
		widgets_reminder_picker_reminder_button_type_id = widgets_reminder_picker_reminder_button_get_type_once ();
		g_once_init_leave (&widgets_reminder_picker_reminder_button_type_id__once, widgets_reminder_picker_reminder_button_type_id);
	}
	return widgets_reminder_picker_reminder_button_type_id__once;
}

static void
_vala_widgets_reminder_picker_reminder_button_get_property (GObject * object,
                                                            guint property_id,
                                                            GValue * value,
                                                            GParamSpec * pspec)
{
	WidgetsReminderPickerReminderButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, WIDGETS_REMINDER_PICKER_TYPE_REMINDER_BUTTON, WidgetsReminderPickerReminderButton);
	switch (property_id) {
		case WIDGETS_REMINDER_PICKER_REMINDER_BUTTON_IS_BOARD_PROPERTY:
		g_value_set_boolean (value, widgets_reminder_picker_reminder_button_get_is_board (self));
		break;
		case WIDGETS_REMINDER_PICKER_REMINDER_BUTTON_IS_CREATING_PROPERTY:
		g_value_set_boolean (value, widgets_reminder_picker_reminder_button_get_is_creating (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_widgets_reminder_picker_reminder_button_set_property (GObject * object,
                                                            guint property_id,
                                                            const GValue * value,
                                                            GParamSpec * pspec)
{
	WidgetsReminderPickerReminderButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, WIDGETS_REMINDER_PICKER_TYPE_REMINDER_BUTTON, WidgetsReminderPickerReminderButton);
	switch (property_id) {
		case WIDGETS_REMINDER_PICKER_REMINDER_BUTTON_IS_BOARD_PROPERTY:
		widgets_reminder_picker_reminder_button_set_is_board (self, g_value_get_boolean (value));
		break;
		case WIDGETS_REMINDER_PICKER_REMINDER_BUTTON_IS_CREATING_PROPERTY:
		widgets_reminder_picker_reminder_button_set_is_creating (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);
}

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;
}

