/* ItemBase.c generated by valac 0.56.19, the Vala compiler
 * generated from ItemBase.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 <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <gee.h>
#include "planify.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
#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 LAYOUTS_TYPE_ITEM_BASE (layouts_item_base_get_type ())
#define LAYOUTS_ITEM_BASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LAYOUTS_TYPE_ITEM_BASE, LayoutsItemBase))
#define LAYOUTS_ITEM_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), LAYOUTS_TYPE_ITEM_BASE, LayoutsItemBaseClass))
#define LAYOUTS_IS_ITEM_BASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LAYOUTS_TYPE_ITEM_BASE))
#define LAYOUTS_IS_ITEM_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LAYOUTS_TYPE_ITEM_BASE))
#define LAYOUTS_ITEM_BASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), LAYOUTS_TYPE_ITEM_BASE, LayoutsItemBaseClass))

typedef struct _LayoutsItemBase LayoutsItemBase;
typedef struct _LayoutsItemBaseClass LayoutsItemBaseClass;
typedef struct _LayoutsItemBasePrivate LayoutsItemBasePrivate;
enum  {
	LAYOUTS_ITEM_BASE_0_PROPERTY,
	LAYOUTS_ITEM_BASE_ITEM_PROPERTY,
	LAYOUTS_ITEM_BASE_UPDATE_ID_PROPERTY,
	LAYOUTS_ITEM_BASE_NUM_PROPERTIES
};
static GParamSpec* layouts_item_base_properties[LAYOUTS_ITEM_BASE_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))

struct _LayoutsItemBase {
	GtkListBoxRow parent_instance;
	LayoutsItemBasePrivate * priv;
	GeeHashMap* signals_map;
};

struct _LayoutsItemBaseClass {
	GtkListBoxRowClass parent_class;
	void (*update_request) (LayoutsItemBase* self);
	void (*hide_destroy) (LayoutsItemBase* self);
	void (*delete_request) (LayoutsItemBase* self, gboolean undo);
	void (*select_row) (LayoutsItemBase* self, gboolean active);
	void (*checked_toggled) (LayoutsItemBase* self, gboolean active, guint* time);
	void (*clean_up) (LayoutsItemBase* self);
};

struct _LayoutsItemBasePrivate {
	ObjectsItem* _item;
	gchar* _update_id;
};

static gint LayoutsItemBase_private_offset;
static gpointer layouts_item_base_parent_class = NULL;

VALA_EXTERN GType layouts_item_base_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (LayoutsItemBase, g_object_unref)
VALA_EXTERN void layouts_item_base_update_request (LayoutsItemBase* self);
VALA_EXTERN void layouts_item_base_hide_destroy (LayoutsItemBase* self);
VALA_EXTERN void layouts_item_base_delete_request (LayoutsItemBase* self,
                                       gboolean undo);
VALA_EXTERN void layouts_item_base_select_row (LayoutsItemBase* self,
                                   gboolean active);
VALA_EXTERN void layouts_item_base_checked_toggled (LayoutsItemBase* self,
                                        gboolean active,
                                        guint* time);
VALA_EXTERN void layouts_item_base_clean_up (LayoutsItemBase* self);
static void layouts_item_base_real_update_request (LayoutsItemBase* self);
static void layouts_item_base_real_hide_destroy (LayoutsItemBase* self);
static void layouts_item_base_real_delete_request (LayoutsItemBase* self,
                                            gboolean undo);
static void layouts_item_base_real_select_row (LayoutsItemBase* self,
                                        gboolean active);
static void layouts_item_base_real_checked_toggled (LayoutsItemBase* self,
                                             gboolean active,
                                             guint* time);
static void layouts_item_base_real_clean_up (LayoutsItemBase* self);
VALA_EXTERN void _layouts_item_base_show_task_completed_toast (LayoutsItemBase* self);
VALA_EXTERN ObjectsItem* layouts_item_base_get_item (LayoutsItemBase* self);
VALA_EXTERN LayoutsItemBase* layouts_item_base_construct (GType object_type);
static void layouts_item_base_set_item (LayoutsItemBase* self,
                                 ObjectsItem* value);
VALA_EXTERN const gchar* layouts_item_base_get_update_id (LayoutsItemBase* self);
VALA_EXTERN void layouts_item_base_set_update_id (LayoutsItemBase* self,
                                      const gchar* value);
static void layouts_item_base_finalize (GObject * obj);
static GType layouts_item_base_get_type_once (void);
static void _vala_layouts_item_base_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec);
static void _vala_layouts_item_base_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec);

static inline gpointer
layouts_item_base_get_instance_private (LayoutsItemBase* self)
{
	return G_STRUCT_MEMBER_P (self, LayoutsItemBase_private_offset);
}

static void
layouts_item_base_real_update_request (LayoutsItemBase* self)
{
	g_critical ("Type `%s' does not implement abstract method `layouts_item_base_update_request'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return;
}

void
layouts_item_base_update_request (LayoutsItemBase* self)
{
	LayoutsItemBaseClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = LAYOUTS_ITEM_BASE_GET_CLASS (self);
	if (_klass_->update_request) {
		_klass_->update_request (self);
	}
}

static void
layouts_item_base_real_hide_destroy (LayoutsItemBase* self)
{
	g_critical ("Type `%s' does not implement abstract method `layouts_item_base_hide_destroy'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return;
}

void
layouts_item_base_hide_destroy (LayoutsItemBase* self)
{
	LayoutsItemBaseClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = LAYOUTS_ITEM_BASE_GET_CLASS (self);
	if (_klass_->hide_destroy) {
		_klass_->hide_destroy (self);
	}
}

static void
layouts_item_base_real_delete_request (LayoutsItemBase* self,
                                       gboolean undo)
{
	g_critical ("Type `%s' does not implement abstract method `layouts_item_base_delete_request'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return;
}

void
layouts_item_base_delete_request (LayoutsItemBase* self,
                                  gboolean undo)
{
	LayoutsItemBaseClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = LAYOUTS_ITEM_BASE_GET_CLASS (self);
	if (_klass_->delete_request) {
		_klass_->delete_request (self, undo);
	}
}

static void
layouts_item_base_real_select_row (LayoutsItemBase* self,
                                   gboolean active)
{
	g_critical ("Type `%s' does not implement abstract method `layouts_item_base_select_row'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return;
}

void
layouts_item_base_select_row (LayoutsItemBase* self,
                              gboolean active)
{
	LayoutsItemBaseClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = LAYOUTS_ITEM_BASE_GET_CLASS (self);
	if (_klass_->select_row) {
		_klass_->select_row (self, active);
	}
}

static void
layouts_item_base_real_checked_toggled (LayoutsItemBase* self,
                                        gboolean active,
                                        guint* time)
{
	g_critical ("Type `%s' does not implement abstract method `layouts_item_base_checked_toggled'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return;
}

void
layouts_item_base_checked_toggled (LayoutsItemBase* self,
                                   gboolean active,
                                   guint* time)
{
	LayoutsItemBaseClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = LAYOUTS_ITEM_BASE_GET_CLASS (self);
	if (_klass_->checked_toggled) {
		_klass_->checked_toggled (self, active, time);
	}
}

static void
layouts_item_base_real_clean_up (LayoutsItemBase* self)
{
	g_critical ("Type `%s' does not implement abstract method `layouts_item_base_clean_up'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return;
}

void
layouts_item_base_clean_up (LayoutsItemBase* self)
{
	LayoutsItemBaseClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = LAYOUTS_ITEM_BASE_GET_CLASS (self);
	if (_klass_->clean_up) {
		_klass_->clean_up (self);
	}
}

void
_layouts_item_base_show_task_completed_toast (LayoutsItemBase* self)
{
	ObjectsItem* _tmp0_;
	ObjectsProject* _tmp1_;
	ObjectsProject* _tmp2_;
	gboolean _tmp3_;
	gboolean _tmp4_;
	ServicesEventBus* _tmp5_;
	ServicesEventBus* _tmp6_;
	ObjectsItem* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_item;
	_tmp1_ = objects_item_get_project (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = objects_project_get_show_completed (_tmp2_);
	_tmp4_ = _tmp3_;
	if (_tmp4_) {
		return;
	}
	_tmp5_ = services_event_bus_get_default ();
	_tmp6_ = _tmp5_;
	_tmp7_ = self->priv->_item;
	_tmp8_ = objects_item_get_project_id (_tmp7_);
	_tmp9_ = _tmp8_;
	g_signal_emit_by_name (_tmp6_, "send-task-completed-toast", _tmp9_);
	_g_object_unref0 (_tmp6_);
}

LayoutsItemBase*
layouts_item_base_construct (GType object_type)
{
	LayoutsItemBase * self = NULL;
	self = (LayoutsItemBase*) g_object_new (object_type, NULL);
	return self;
}

ObjectsItem*
layouts_item_base_get_item (LayoutsItemBase* self)
{
	ObjectsItem* result;
	ObjectsItem* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_item;
	result = _tmp0_;
	return result;
}

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

static void
layouts_item_base_set_item (LayoutsItemBase* self,
                            ObjectsItem* value)
{
	ObjectsItem* old_value;
	g_return_if_fail (self != NULL);
	old_value = layouts_item_base_get_item (self);
	if (old_value != value) {
		ObjectsItem* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_item);
		self->priv->_item = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, layouts_item_base_properties[LAYOUTS_ITEM_BASE_ITEM_PROPERTY]);
	}
}

const gchar*
layouts_item_base_get_update_id (LayoutsItemBase* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_update_id;
	result = _tmp0_;
	return result;
}

void
layouts_item_base_set_update_id (LayoutsItemBase* self,
                                 const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = layouts_item_base_get_update_id (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_update_id);
		self->priv->_update_id = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, layouts_item_base_properties[LAYOUTS_ITEM_BASE_UPDATE_ID_PROPERTY]);
	}
}

static void
layouts_item_base_class_init (LayoutsItemBaseClass * klass,
                              gpointer klass_data)
{
	layouts_item_base_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &LayoutsItemBase_private_offset);
	((LayoutsItemBaseClass *) klass)->update_request = (void (*) (LayoutsItemBase*)) layouts_item_base_real_update_request;
	((LayoutsItemBaseClass *) klass)->hide_destroy = (void (*) (LayoutsItemBase*)) layouts_item_base_real_hide_destroy;
	((LayoutsItemBaseClass *) klass)->delete_request = (void (*) (LayoutsItemBase*, gboolean)) layouts_item_base_real_delete_request;
	((LayoutsItemBaseClass *) klass)->select_row = (void (*) (LayoutsItemBase*, gboolean)) layouts_item_base_real_select_row;
	((LayoutsItemBaseClass *) klass)->checked_toggled = (void (*) (LayoutsItemBase*, gboolean, guint*)) layouts_item_base_real_checked_toggled;
	((LayoutsItemBaseClass *) klass)->clean_up = (void (*) (LayoutsItemBase*)) layouts_item_base_real_clean_up;
	G_OBJECT_CLASS (klass)->get_property = _vala_layouts_item_base_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_layouts_item_base_set_property;
	G_OBJECT_CLASS (klass)->finalize = layouts_item_base_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), LAYOUTS_ITEM_BASE_ITEM_PROPERTY, layouts_item_base_properties[LAYOUTS_ITEM_BASE_ITEM_PROPERTY] = g_param_spec_object ("item", "item", "item", OBJECTS_TYPE_ITEM, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), LAYOUTS_ITEM_BASE_UPDATE_ID_PROPERTY, layouts_item_base_properties[LAYOUTS_ITEM_BASE_UPDATE_ID_PROPERTY] = g_param_spec_string ("update-id", "update-id", "update-id", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
layouts_item_base_instance_init (LayoutsItemBase * self,
                                 gpointer klass)
{
	Util* _tmp0_;
	Util* _tmp1_;
	gchar* _tmp2_;
	GeeHashMap* _tmp3_;
	self->priv = layouts_item_base_get_instance_private (self);
	_tmp0_ = util_get_default ();
	_tmp1_ = _tmp0_;
	_tmp2_ = util_generate_id (_tmp1_, NULL);
	self->priv->_update_id = _tmp2_;
	_g_object_unref0 (_tmp1_);
	_tmp3_ = gee_hash_map_new (G_TYPE_ULONG, NULL, NULL, G_TYPE_OBJECT, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	self->signals_map = _tmp3_;
}

static void
layouts_item_base_finalize (GObject * obj)
{
	LayoutsItemBase * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, LAYOUTS_TYPE_ITEM_BASE, LayoutsItemBase);
	_g_object_unref0 (self->priv->_item);
	_g_free0 (self->priv->_update_id);
	_g_object_unref0 (self->signals_map);
	G_OBJECT_CLASS (layouts_item_base_parent_class)->finalize (obj);
}

static GType
layouts_item_base_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (LayoutsItemBaseClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) layouts_item_base_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (LayoutsItemBase), 0, (GInstanceInitFunc) layouts_item_base_instance_init, NULL };
	GType layouts_item_base_type_id;
	layouts_item_base_type_id = g_type_register_static (gtk_list_box_row_get_type (), "LayoutsItemBase", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	LayoutsItemBase_private_offset = g_type_add_instance_private (layouts_item_base_type_id, sizeof (LayoutsItemBasePrivate));
	return layouts_item_base_type_id;
}

GType
layouts_item_base_get_type (void)
{
	static volatile gsize layouts_item_base_type_id__once = 0;
	if (g_once_init_enter (&layouts_item_base_type_id__once)) {
		GType layouts_item_base_type_id;
		layouts_item_base_type_id = layouts_item_base_get_type_once ();
		g_once_init_leave (&layouts_item_base_type_id__once, layouts_item_base_type_id);
	}
	return layouts_item_base_type_id__once;
}

static void
_vala_layouts_item_base_get_property (GObject * object,
                                      guint property_id,
                                      GValue * value,
                                      GParamSpec * pspec)
{
	LayoutsItemBase * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, LAYOUTS_TYPE_ITEM_BASE, LayoutsItemBase);
	switch (property_id) {
		case LAYOUTS_ITEM_BASE_ITEM_PROPERTY:
		g_value_set_object (value, layouts_item_base_get_item (self));
		break;
		case LAYOUTS_ITEM_BASE_UPDATE_ID_PROPERTY:
		g_value_set_string (value, layouts_item_base_get_update_id (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_layouts_item_base_set_property (GObject * object,
                                      guint property_id,
                                      const GValue * value,
                                      GParamSpec * pspec)
{
	LayoutsItemBase * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, LAYOUTS_TYPE_ITEM_BASE, LayoutsItemBase);
	switch (property_id) {
		case LAYOUTS_ITEM_BASE_ITEM_PROPERTY:
		layouts_item_base_set_item (self, g_value_get_object (value));
		break;
		case LAYOUTS_ITEM_BASE_UPDATE_ID_PROPERTY:
		layouts_item_base_set_update_id (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

