/* LabelPicker.c generated by valac 0.56.19, the Vala compiler
 * generated from LabelPicker.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 <glib-object.h>
#include <gtk/gtk.h>
#include <gee.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_LABEL_PICKER_LABEL_PICKER_0_PROPERTY,
	WIDGETS_LABEL_PICKER_LABEL_PICKER_LABELS_PROPERTY,
	WIDGETS_LABEL_PICKER_LABEL_PICKER_SOURCE_PROPERTY,
	WIDGETS_LABEL_PICKER_LABEL_PICKER_PICKED_PROPERTY,
	WIDGETS_LABEL_PICKER_LABEL_PICKER_NUM_PROPERTIES
};
static GParamSpec* widgets_label_picker_label_picker_properties[WIDGETS_LABEL_PICKER_LABEL_PICKER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _WidgetsLabelPickerLabelPickerPrivate {
	WidgetsLabelsPickerCore* labels_picker_core;
};

static gint WidgetsLabelPickerLabelPicker_private_offset;
static gpointer widgets_label_picker_label_picker_parent_class = NULL;

static GObject * widgets_label_picker_label_picker_constructor (GType type,
                                                         guint n_construct_properties,
                                                         GObjectConstructParam * construct_properties);
static void _widgets_label_picker_label_picker___lambda269_ (WidgetsLabelPickerLabelPicker* self);
static void __widgets_label_picker_label_picker___lambda269__widgets_labels_picker_core_close (WidgetsLabelsPickerCore* _sender,
                                                                                        gpointer self);
static void _widgets_label_picker_label_picker___lambda270_ (WidgetsLabelPickerLabelPicker* self);
static void __widgets_label_picker_label_picker___lambda270__gtk_widget_destroy (GtkWidget* _sender,
                                                                          gpointer self);
static void widgets_label_picker_label_picker_finalize (GObject * obj);
static GType widgets_label_picker_label_picker_get_type_once (void);
static void _vala_widgets_label_picker_label_picker_get_property (GObject * object,
                                                           guint property_id,
                                                           GValue * value,
                                                           GParamSpec * pspec);
static void _vala_widgets_label_picker_label_picker_set_property (GObject * object,
                                                           guint property_id,
                                                           const GValue * value,
                                                           GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
widgets_label_picker_label_picker_get_instance_private (WidgetsLabelPickerLabelPicker* self)
{
	return G_STRUCT_MEMBER_P (self, WidgetsLabelPickerLabelPicker_private_offset);
}

WidgetsLabelPickerLabelPicker*
widgets_label_picker_label_picker_construct (GType object_type)
{
	WidgetsLabelPickerLabelPicker * self = NULL;
	self = (WidgetsLabelPickerLabelPicker*) g_object_new (object_type, "has-arrow", FALSE, "position", GTK_POS_BOTTOM, "width-request", 275, "height-request", 300, NULL);
	return self;
}

WidgetsLabelPickerLabelPicker*
widgets_label_picker_label_picker_new (void)
{
	return widgets_label_picker_label_picker_construct (WIDGETS_LABEL_PICKER_TYPE_LABEL_PICKER);
}

void
widgets_label_picker_label_picker_reset (WidgetsLabelPickerLabelPicker* self)
{
	WidgetsLabelsPickerCore* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->labels_picker_core;
	widgets_labels_picker_core_reset (_tmp0_);
}

void
widgets_label_picker_label_picker_clean_up (WidgetsLabelPickerLabelPicker* self)
{
	WidgetsLabelsPickerCore* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->labels_picker_core;
	widgets_labels_picker_core_clean_up (_tmp0_);
}

void
widgets_label_picker_label_picker_set_labels (WidgetsLabelPickerLabelPicker* self,
                                              GeeArrayList* value)
{
	WidgetsLabelsPickerCore* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->labels_picker_core;
	widgets_labels_picker_core_set_labels (_tmp0_, value);
	g_object_notify_by_pspec ((GObject *) self, widgets_label_picker_label_picker_properties[WIDGETS_LABEL_PICKER_LABEL_PICKER_LABELS_PROPERTY]);
}

void
widgets_label_picker_label_picker_set_source (WidgetsLabelPickerLabelPicker* self,
                                              ObjectsSource* value)
{
	WidgetsLabelsPickerCore* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->labels_picker_core;
	widgets_labels_picker_core_set_source (_tmp0_, value);
	g_object_notify_by_pspec ((GObject *) self, widgets_label_picker_label_picker_properties[WIDGETS_LABEL_PICKER_LABEL_PICKER_SOURCE_PROPERTY]);
}

GeeHashMap*
widgets_label_picker_label_picker_get_picked (WidgetsLabelPickerLabelPicker* self)
{
	GeeHashMap* result;
	WidgetsLabelsPickerCore* _tmp0_;
	GeeHashMap* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->labels_picker_core;
	_tmp1_ = _tmp0_->picked;
	result = _tmp1_;
	return result;
}

static void
_widgets_label_picker_label_picker___lambda269_ (WidgetsLabelPickerLabelPicker* self)
{
	gtk_popover_popdown ((GtkPopover*) self);
}

static void
__widgets_label_picker_label_picker___lambda269__widgets_labels_picker_core_close (WidgetsLabelsPickerCore* _sender,
                                                                                   gpointer self)
{
	_widgets_label_picker_label_picker___lambda269_ ((WidgetsLabelPickerLabelPicker*) self);
}

static void
_widgets_label_picker_label_picker___lambda270_ (WidgetsLabelPickerLabelPicker* self)
{
	WidgetsLabelsPickerCore* _tmp0_;
	_tmp0_ = self->priv->labels_picker_core;
	widgets_labels_picker_core_clean_up (_tmp0_);
}

static void
__widgets_label_picker_label_picker___lambda270__gtk_widget_destroy (GtkWidget* _sender,
                                                                     gpointer self)
{
	_widgets_label_picker_label_picker___lambda270_ ((WidgetsLabelPickerLabelPicker*) self);
}

static GObject *
widgets_label_picker_label_picker_constructor (GType type,
                                               guint n_construct_properties,
                                               GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	WidgetsLabelPickerLabelPicker * self;
	WidgetsLabelsPickerCore* _tmp0_ = NULL;
	WidgetsLabelsPickerCore* _tmp1_;
	WidgetsLabelsPickerCore* _tmp2_;
	parent_class = G_OBJECT_CLASS (widgets_label_picker_label_picker_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIDGETS_LABEL_PICKER_TYPE_LABEL_PICKER, WidgetsLabelPickerLabelPicker);
	_tmp0_ = widgets_labels_picker_core_new (LABEL_PICKER_TYPE_FILTER_AND_CREATE);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp0_, 12);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->labels_picker_core);
	self->priv->labels_picker_core = _tmp0_;
	_tmp1_ = self->priv->labels_picker_core;
	gtk_popover_set_child ((GtkPopover*) self, (GtkWidget*) _tmp1_);
	gtk_widget_add_css_class ((GtkWidget*) self, "popover-contents");
	_tmp2_ = self->priv->labels_picker_core;
	g_signal_connect_object (_tmp2_, "close", (GCallback) __widgets_label_picker_label_picker___lambda269__widgets_labels_picker_core_close, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "destroy", (GCallback) __widgets_label_picker_label_picker___lambda270__gtk_widget_destroy, self, 0);
	return obj;
}

static void
widgets_label_picker_label_picker_class_init (WidgetsLabelPickerLabelPickerClass * klass,
                                              gpointer klass_data)
{
	widgets_label_picker_label_picker_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &WidgetsLabelPickerLabelPicker_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_widgets_label_picker_label_picker_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_widgets_label_picker_label_picker_set_property;
	G_OBJECT_CLASS (klass)->constructor = widgets_label_picker_label_picker_constructor;
	G_OBJECT_CLASS (klass)->finalize = widgets_label_picker_label_picker_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), WIDGETS_LABEL_PICKER_LABEL_PICKER_LABELS_PROPERTY, widgets_label_picker_label_picker_properties[WIDGETS_LABEL_PICKER_LABEL_PICKER_LABELS_PROPERTY] = g_param_spec_object ("labels", "labels", "labels", GEE_TYPE_ARRAY_LIST, G_PARAM_STATIC_STRINGS | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), WIDGETS_LABEL_PICKER_LABEL_PICKER_SOURCE_PROPERTY, widgets_label_picker_label_picker_properties[WIDGETS_LABEL_PICKER_LABEL_PICKER_SOURCE_PROPERTY] = g_param_spec_object ("source", "source", "source", OBJECTS_TYPE_SOURCE, G_PARAM_STATIC_STRINGS | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), WIDGETS_LABEL_PICKER_LABEL_PICKER_PICKED_PROPERTY, widgets_label_picker_label_picker_properties[WIDGETS_LABEL_PICKER_LABEL_PICKER_PICKED_PROPERTY] = g_param_spec_object ("picked", "picked", "picked", GEE_TYPE_HASH_MAP, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
widgets_label_picker_label_picker_instance_init (WidgetsLabelPickerLabelPicker * self,
                                                 gpointer klass)
{
	self->priv = widgets_label_picker_label_picker_get_instance_private (self);
}

static void
widgets_label_picker_label_picker_finalize (GObject * obj)
{
	WidgetsLabelPickerLabelPicker * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIDGETS_LABEL_PICKER_TYPE_LABEL_PICKER, WidgetsLabelPickerLabelPicker);
	g_debug ("LabelPicker.vala:53: Destroying - Widgets.LabelPicker.LabelPicker\n");
	_g_object_unref0 (self->priv->labels_picker_core);
	G_OBJECT_CLASS (widgets_label_picker_label_picker_parent_class)->finalize (obj);
}

static GType
widgets_label_picker_label_picker_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (WidgetsLabelPickerLabelPickerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) widgets_label_picker_label_picker_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WidgetsLabelPickerLabelPicker), 0, (GInstanceInitFunc) widgets_label_picker_label_picker_instance_init, NULL };
	GType widgets_label_picker_label_picker_type_id;
	widgets_label_picker_label_picker_type_id = g_type_register_static (gtk_popover_get_type (), "WidgetsLabelPickerLabelPicker", &g_define_type_info, 0);
	WidgetsLabelPickerLabelPicker_private_offset = g_type_add_instance_private (widgets_label_picker_label_picker_type_id, sizeof (WidgetsLabelPickerLabelPickerPrivate));
	return widgets_label_picker_label_picker_type_id;
}

GType
widgets_label_picker_label_picker_get_type (void)
{
	static volatile gsize widgets_label_picker_label_picker_type_id__once = 0;
	if (g_once_init_enter (&widgets_label_picker_label_picker_type_id__once)) {
		GType widgets_label_picker_label_picker_type_id;
		widgets_label_picker_label_picker_type_id = widgets_label_picker_label_picker_get_type_once ();
		g_once_init_leave (&widgets_label_picker_label_picker_type_id__once, widgets_label_picker_label_picker_type_id);
	}
	return widgets_label_picker_label_picker_type_id__once;
}

static void
_vala_widgets_label_picker_label_picker_get_property (GObject * object,
                                                      guint property_id,
                                                      GValue * value,
                                                      GParamSpec * pspec)
{
	WidgetsLabelPickerLabelPicker * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, WIDGETS_LABEL_PICKER_TYPE_LABEL_PICKER, WidgetsLabelPickerLabelPicker);
	switch (property_id) {
		case WIDGETS_LABEL_PICKER_LABEL_PICKER_PICKED_PROPERTY:
		g_value_set_object (value, widgets_label_picker_label_picker_get_picked (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_widgets_label_picker_label_picker_set_property (GObject * object,
                                                      guint property_id,
                                                      const GValue * value,
                                                      GParamSpec * pspec)
{
	WidgetsLabelPickerLabelPicker * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, WIDGETS_LABEL_PICKER_TYPE_LABEL_PICKER, WidgetsLabelPickerLabelPicker);
	switch (property_id) {
		case WIDGETS_LABEL_PICKER_LABEL_PICKER_LABELS_PROPERTY:
		widgets_label_picker_label_picker_set_labels (self, g_value_get_object (value));
		break;
		case WIDGETS_LABEL_PICKER_LABEL_PICKER_SOURCE_PROPERTY:
		widgets_label_picker_label_picker_set_source (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

