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

/* SPDX-License-Identifier: GPL-3.0-or-later*/

#include "graphs.h"
#include <gtk/gtk.h>
#include <glib.h>
#include <glib-object.h>
#include <adwaita.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <glib/gi18n-lib.h>
#include <float.h>
#include <math.h>
#include <gdk/gdk.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  {
	GRAPHS_ITEM_BOX_0_PROPERTY,
	GRAPHS_ITEM_BOX_CHECK_BUTTON_PROPERTY,
	GRAPHS_ITEM_BOX_WINDOW_PROPERTY,
	GRAPHS_ITEM_BOX_ITEM_PROPERTY,
	GRAPHS_ITEM_BOX_INDEX_PROPERTY,
	GRAPHS_ITEM_BOX_NUM_PROPERTIES
};
static GParamSpec* graphs_item_box_properties[GRAPHS_ITEM_BOX_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))
typedef struct _Block23Data Block23Data;
#define __vala_GdkRGBA_free0(var) ((var == NULL) ? NULL : (var = (_vala_GdkRGBA_free (var), NULL)))

struct _GraphsItemBoxPrivate {
	GtkCheckButton* _check_button;
	GtkButton* _color_button;
	GraphsWindow* _window;
	GraphsItem* _item;
	guint _index;
	GtkCssProvider* provider;
};

struct _Block23Data {
	int _ref_count_;
	GraphsItemBox* self;
	GtkColorDialog* dialog;
};

static gint GraphsItemBox_private_offset;
static gpointer graphs_item_box_parent_class = NULL;

static GtkButton* graphs_item_box_get_color_button (GraphsItemBox* self);
static void graphs_item_box_on_color_change (GraphsItemBox* self);
static void _graphs_item_box_on_color_change_g_object_notify (GObject* _sender,
                                                       GParamSpec* pspec,
                                                       gpointer self);
static void __lambda15_ (GraphsItemBox* self);
static void ___lambda15__g_simple_action_activate (GSimpleAction* _sender,
                                            GVariant* parameter,
                                            gpointer self);
static void ___lambda16_ (GraphsItemBox* self);
static void ____lambda16__g_simple_action_activate (GSimpleAction* _sender,
                                             GVariant* parameter,
                                             gpointer self);
static void ___lambda23_ (GraphsItemBox* self);
static void ____lambda23__g_simple_action_activate (GSimpleAction* _sender,
                                             GVariant* parameter,
                                             gpointer self);
static void ___lambda24_ (GraphsItemBox* self);
static void ____lambda24__g_simple_action_activate (GSimpleAction* _sender,
                                             GVariant* parameter,
                                             gpointer self);
static void graphs_item_box_on_toggle (GraphsItemBox* self);
static void _graphs_item_box_on_toggle_g_object_notify (GObject* _sender,
                                                 GParamSpec* pspec,
                                                 gpointer self);
static void graphs_item_box_choose_color (GraphsItemBox* self);
static Block23Data* block23_data_ref (Block23Data* _data23_);
static void block23_data_unref (void * _userdata_);
static void __lambda25_ (Block23Data* _data23_,
                  GObject* d,
                  GAsyncResult* _result_);
static void _vala_GdkRGBA_free (GdkRGBA* self);
static void ___lambda25__gasync_ready_callback (GObject* source_object,
                                         GAsyncResult* res,
                                         gpointer self);
static void _graphs_item_box_choose_color_gtk_button_clicked (GtkButton* _sender,
                                                       gpointer self);
static void graphs_item_box_finalize (GObject * obj);
static GType graphs_item_box_get_type_once (void);
static void _vala_graphs_item_box_get_property (GObject * object,
                                         guint property_id,
                                         GValue * value,
                                         GParamSpec * pspec);
static void _vala_graphs_item_box_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
graphs_item_box_get_instance_private (GraphsItemBox* self)
{
	return G_STRUCT_MEMBER_P (self, GraphsItemBox_private_offset);
}

static void
_graphs_item_box_on_color_change_g_object_notify (GObject* _sender,
                                                  GParamSpec* pspec,
                                                  gpointer self)
{
	graphs_item_box_on_color_change ((GraphsItemBox*) self);
}

GraphsItemBox*
graphs_item_box_construct (GType object_type,
                           GraphsWindow* window,
                           GraphsItem* item,
                           guint index)
{
	GraphsItemBox * self = NULL;
	GtkCssProvider* _tmp0_;
	GtkButton* _tmp1_;
	GtkStyleContext* _tmp2_;
	GtkCssProvider* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	GtkCheckButton* _tmp6_;
	g_return_val_if_fail (window != NULL, NULL);
	g_return_val_if_fail (item != NULL, NULL);
	self = (GraphsItemBox*) g_object_new (object_type, "window", window, "item", item, "index", index, NULL);
	_tmp0_ = gtk_css_provider_new ();
	_g_object_unref0 (self->priv->provider);
	self->priv->provider = _tmp0_;
	_tmp1_ = self->priv->_color_button;
	_tmp2_ = gtk_widget_get_style_context ((GtkWidget*) _tmp1_);
	_tmp3_ = self->priv->provider;
	gtk_style_context_add_provider (_tmp2_, (GtkStyleProvider*) _tmp3_, (guint) GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
	_tmp4_ = graphs_item_get_typename (item);
	_tmp5_ = _tmp4_;
	adw_action_row_set_subtitle ((AdwActionRow*) self, _tmp5_);
	g_object_bind_property_with_closures ((GObject*) item, "name", (GObject*) self, "title", 2, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp6_ = self->priv->_check_button;
	g_object_bind_property_with_closures ((GObject*) item, "selected", (GObject*) _tmp6_, "active", 2, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	g_signal_connect_object ((GObject*) item, "notify::color", (GCallback) _graphs_item_box_on_color_change_g_object_notify, self, 0);
	graphs_item_box_on_color_change (self);
	return self;
}

GraphsItemBox*
graphs_item_box_new (GraphsWindow* window,
                     GraphsItem* item,
                     guint index)
{
	return graphs_item_box_construct (GRAPHS_TYPE_ITEM_BOX, window, item, index);
}

/**
         * Setup the actions for the ItemBox. This is omitted for rows created
         * for drag and drop.
         */
static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static void
__lambda15_ (GraphsItemBox* self)
{
	gchar* name = NULL;
	GraphsItem* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	GraphsItem** list = NULL;
	GraphsItem* _tmp4_;
	GraphsItem* _tmp5_;
	GraphsItem** _tmp6_;
	gint list_length1;
	gint _list_size_;
	GraphsWindow* _tmp7_;
	GraphsData* _tmp8_;
	GraphsData* _tmp9_;
	GraphsWindow* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	_tmp0_ = self->priv->_item;
	_tmp1_ = graphs_item_get_name (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strdup (_tmp2_);
	name = _tmp3_;
	_tmp4_ = self->priv->_item;
	_tmp5_ = _g_object_ref0 (_tmp4_);
	_tmp6_ = g_new0 (GraphsItem*, 1 + 1);
	_tmp6_[0] = _tmp5_;
	list = _tmp6_;
	list_length1 = 1;
	_list_size_ = list_length1;
	_tmp7_ = self->priv->_window;
	_tmp8_ = graphs_window_get_data (_tmp7_);
	_tmp9_ = _tmp8_;
	graphs_data_delete_items (_tmp9_, list, (gint) list_length1);
	_tmp10_ = self->priv->_window;
	_tmp11_ = g_strdup_printf (_ ("Deleted %s"), name);
	_tmp12_ = _tmp11_;
	graphs_window_add_undo_toast (_tmp10_, _tmp12_);
	_g_free0 (_tmp12_);
	list = (_vala_array_free (list, list_length1, (GDestroyNotify) g_object_unref), NULL);
	_g_free0 (name);
}

static void
___lambda15__g_simple_action_activate (GSimpleAction* _sender,
                                       GVariant* parameter,
                                       gpointer self)
{
	__lambda15_ ((GraphsItemBox*) self);
}

static void
___lambda16_ (GraphsItemBox* self)
{
	GraphsWindow* _tmp0_;
	GraphsItem* _tmp1_;
	GraphsCurveFittingDialog* _tmp2_;
	GraphsCurveFittingDialog* _tmp3_;
	_tmp0_ = self->priv->_window;
	_tmp1_ = self->priv->_item;
	_tmp2_ = graphs_python_helper_create_curve_fitting_dialog (_tmp0_, _tmp1_);
	_tmp3_ = _tmp2_;
	_g_object_unref0 (_tmp3_);
}

static void
____lambda16__g_simple_action_activate (GSimpleAction* _sender,
                                        GVariant* parameter,
                                        gpointer self)
{
	___lambda16_ ((GraphsItemBox*) self);
}

static void
___lambda23_ (GraphsItemBox* self)
{
	guint _tmp0_;
	_tmp0_ = self->priv->_index;
	graphs_item_box_change_position (self, _tmp0_ - 1);
}

static void
____lambda23__g_simple_action_activate (GSimpleAction* _sender,
                                        GVariant* parameter,
                                        gpointer self)
{
	___lambda23_ ((GraphsItemBox*) self);
}

static void
___lambda24_ (GraphsItemBox* self)
{
	guint _tmp0_;
	_tmp0_ = self->priv->_index;
	graphs_item_box_change_position (self, _tmp0_ + 1);
}

static void
____lambda24__g_simple_action_activate (GSimpleAction* _sender,
                                        GVariant* parameter,
                                        gpointer self)
{
	___lambda24_ ((GraphsItemBox*) self);
}

void
graphs_item_box_setup_interactions (GraphsItemBox* self,
                                    gboolean is_data_item)
{
	GSimpleActionGroup* action_group = NULL;
	GSimpleActionGroup* _tmp0_;
	GSimpleAction* delete_action = NULL;
	GSimpleAction* _tmp1_;
	GSimpleAction* _tmp2_;
	GSimpleActionGroup* _tmp3_;
	GSimpleAction* _tmp4_;
	guint _tmp9_;
	guint _tmp14_;
	GraphsWindow* _tmp15_;
	GraphsData* _tmp16_;
	GraphsData* _tmp17_;
	GSimpleActionGroup* _tmp22_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_simple_action_group_new ();
	action_group = _tmp0_;
	_tmp1_ = g_simple_action_new ("delete", NULL);
	delete_action = _tmp1_;
	_tmp2_ = delete_action;
	g_signal_connect_object (_tmp2_, "activate", (GCallback) ___lambda15__g_simple_action_activate, self, 0);
	_tmp3_ = action_group;
	_tmp4_ = delete_action;
	g_action_map_add_action ((GActionMap*) _tmp3_, (GAction*) _tmp4_);
	if (is_data_item) {
		GSimpleAction* curve_fitting_action = NULL;
		GSimpleAction* _tmp5_;
		GSimpleAction* _tmp6_;
		GSimpleActionGroup* _tmp7_;
		GSimpleAction* _tmp8_;
		_tmp5_ = g_simple_action_new ("curve_fitting", NULL);
		curve_fitting_action = _tmp5_;
		_tmp6_ = curve_fitting_action;
		g_signal_connect_object (_tmp6_, "activate", (GCallback) ____lambda16__g_simple_action_activate, self, 0);
		_tmp7_ = action_group;
		_tmp8_ = curve_fitting_action;
		g_action_map_add_action ((GActionMap*) _tmp7_, (GAction*) _tmp8_);
		_g_object_unref0 (curve_fitting_action);
	}
	_tmp9_ = self->priv->_index;
	if (_tmp9_ > ((guint) 0)) {
		GSimpleAction* move_up_action = NULL;
		GSimpleAction* _tmp10_;
		GSimpleAction* _tmp11_;
		GSimpleActionGroup* _tmp12_;
		GSimpleAction* _tmp13_;
		_tmp10_ = g_simple_action_new ("move_up", NULL);
		move_up_action = _tmp10_;
		_tmp11_ = move_up_action;
		g_signal_connect_object (_tmp11_, "activate", (GCallback) ____lambda23__g_simple_action_activate, self, 0);
		_tmp12_ = action_group;
		_tmp13_ = move_up_action;
		g_action_map_add_action ((GActionMap*) _tmp12_, (GAction*) _tmp13_);
		_g_object_unref0 (move_up_action);
	}
	_tmp14_ = self->priv->_index;
	_tmp15_ = self->priv->_window;
	_tmp16_ = graphs_window_get_data (_tmp15_);
	_tmp17_ = _tmp16_;
	if ((_tmp14_ + 1) < g_list_model_get_n_items ((GListModel*) _tmp17_)) {
		GSimpleAction* move_down_action = NULL;
		GSimpleAction* _tmp18_;
		GSimpleAction* _tmp19_;
		GSimpleActionGroup* _tmp20_;
		GSimpleAction* _tmp21_;
		_tmp18_ = g_simple_action_new ("move_down", NULL);
		move_down_action = _tmp18_;
		_tmp19_ = move_down_action;
		g_signal_connect_object (_tmp19_, "activate", (GCallback) ____lambda24__g_simple_action_activate, self, 0);
		_tmp20_ = action_group;
		_tmp21_ = move_down_action;
		g_action_map_add_action ((GActionMap*) _tmp20_, (GAction*) _tmp21_);
		_g_object_unref0 (move_down_action);
	}
	_tmp22_ = action_group;
	gtk_widget_insert_action_group ((GtkWidget*) self, "item_box", (GActionGroup*) _tmp22_);
	_g_object_unref0 (delete_action);
	_g_object_unref0 (action_group);
}

static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

static void
graphs_item_box_on_color_change (GraphsItemBox* self)
{
	gchar* c = NULL;
	GraphsItem* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* o = NULL;
	GraphsItem* _tmp4_;
	gfloat _tmp5_;
	gfloat _tmp6_;
	gchar* _tmp7_;
	GtkCssProvider* _tmp8_;
	const gchar* _tmp9_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_item;
	_tmp1_ = graphs_item_get_color (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strdup (_tmp2_);
	c = _tmp3_;
	_tmp4_ = self->priv->_item;
	_tmp5_ = graphs_item_get_alpha (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = g_strdup_printf ("%g", _tmp6_);
	o = _tmp7_;
	_tmp8_ = self->priv->provider;
	_tmp9_ = string_to_string (c);
	_tmp10_ = string_to_string (o);
	_tmp11_ = g_strconcat ("button { color: ", _tmp9_, "; opacity: ", _tmp10_, "; }", NULL);
	_tmp12_ = _tmp11_;
	gtk_css_provider_load_from_string (_tmp8_, _tmp12_);
	_g_free0 (_tmp12_);
	_g_free0 (o);
	_g_free0 (c);
}

static void
graphs_item_box_on_toggle (GraphsItemBox* self)
{
	gboolean new_value = FALSE;
	GtkCheckButton* _tmp0_;
	GraphsItem* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_check_button;
	new_value = gtk_check_button_get_active (_tmp0_);
	_tmp1_ = self->priv->_item;
	_tmp2_ = graphs_item_get_selected (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_ != new_value) {
		GraphsItem* _tmp4_;
		GraphsWindow* _tmp5_;
		GraphsData* _tmp6_;
		GraphsData* _tmp7_;
		_tmp4_ = self->priv->_item;
		graphs_item_set_selected (_tmp4_, new_value);
		_tmp5_ = self->priv->_window;
		_tmp6_ = graphs_window_get_data (_tmp5_);
		_tmp7_ = _tmp6_;
		graphs_data_add_history_state (_tmp7_);
	}
}

static void
_graphs_item_box_on_toggle_g_object_notify (GObject* _sender,
                                            GParamSpec* pspec,
                                            gpointer self)
{
	graphs_item_box_on_toggle ((GraphsItemBox*) self);
}

static Block23Data*
block23_data_ref (Block23Data* _data23_)
{
	g_atomic_int_inc (&_data23_->_ref_count_);
	return _data23_;
}

static void
block23_data_unref (void * _userdata_)
{
	Block23Data* _data23_;
	_data23_ = (Block23Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data23_->_ref_count_)) {
		GraphsItemBox* self;
		self = _data23_->self;
		_g_object_unref0 (_data23_->dialog);
		_g_object_unref0 (self);
		g_slice_free (Block23Data, _data23_);
	}
}

static void
_vala_GdkRGBA_free (GdkRGBA* self)
{
	g_boxed_free (gdk_rgba_get_type (), self);
}

static void
__lambda25_ (Block23Data* _data23_,
             GObject* d,
             GAsyncResult* _result_)
{
	GraphsItemBox* self;
	GError* _inner_error0_ = NULL;
	self = _data23_->self;
	g_return_if_fail (_result_ != NULL);
	{
		GdkRGBA* _tmp0_ = NULL;
		GdkRGBA* _tmp1_;
		GraphsItem* _tmp2_;
		GdkRGBA _tmp3_;
		GraphsWindow* _tmp4_;
		GraphsData* _tmp5_;
		GraphsData* _tmp6_;
		_tmp1_ = gtk_color_dialog_choose_rgba_finish (_data23_->dialog, _result_, &_inner_error0_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp2_ = self->priv->_item;
		_tmp3_ = *_tmp0_;
		graphs_item_set_rgba (_tmp2_, &_tmp3_);
		_tmp4_ = self->priv->_window;
		_tmp5_ = graphs_window_get_data (_tmp4_);
		_tmp6_ = _tmp5_;
		graphs_data_add_history_state (_tmp6_);
		__vala_GdkRGBA_free0 (_tmp0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

static void
___lambda25__gasync_ready_callback (GObject* source_object,
                                    GAsyncResult* res,
                                    gpointer self)
{
	__lambda25_ (self, source_object, res);
	block23_data_unref (self);
}

static void
graphs_item_box_choose_color (GraphsItemBox* self)
{
	Block23Data* _data23_;
	GtkColorDialog* _tmp0_;
	GraphsWindow* _tmp1_;
	GraphsItem* _tmp2_;
	GdkRGBA _tmp3_ = {0};
	g_return_if_fail (self != NULL);
	_data23_ = g_slice_new0 (Block23Data);
	_data23_->_ref_count_ = 1;
	_data23_->self = g_object_ref (self);
	_tmp0_ = gtk_color_dialog_new ();
	_data23_->dialog = _tmp0_;
	_tmp1_ = self->priv->_window;
	_tmp2_ = self->priv->_item;
	graphs_item_get_rgba (_tmp2_, &_tmp3_);
	gtk_color_dialog_choose_rgba (_data23_->dialog, (GtkWindow*) _tmp1_, &_tmp3_, NULL, ___lambda25__gasync_ready_callback, block23_data_ref (_data23_));
	block23_data_unref (_data23_);
	_data23_ = NULL;
}

static void
_graphs_item_box_choose_color_gtk_button_clicked (GtkButton* _sender,
                                                  gpointer self)
{
	graphs_item_box_choose_color ((GraphsItemBox*) self);
}

void
graphs_item_box_change_position (GraphsItemBox* self,
                                 guint source_index)
{
	GraphsWindow* _tmp0_;
	GraphsData* _tmp1_;
	GraphsData* _tmp2_;
	guint _tmp3_;
	GraphsWindow* _tmp4_;
	GraphsData* _tmp5_;
	GraphsData* _tmp6_;
	GraphsWindow* _tmp7_;
	GraphsData* _tmp8_;
	GraphsData* _tmp9_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_window;
	_tmp1_ = graphs_window_get_data (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = self->priv->_index;
	graphs_data_change_position (_tmp2_, _tmp3_, source_index);
	_tmp4_ = self->priv->_window;
	_tmp5_ = graphs_window_get_data (_tmp4_);
	_tmp6_ = _tmp5_;
	graphs_data_add_history_state (_tmp6_);
	_tmp7_ = self->priv->_window;
	_tmp8_ = graphs_window_get_data (_tmp7_);
	_tmp9_ = _tmp8_;
	graphs_data_add_view_history_state (_tmp9_);
}

GtkCheckButton*
graphs_item_box_get_check_button (GraphsItemBox* self)
{
	GtkCheckButton* result;
	GtkCheckButton* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_check_button;
	result = _tmp0_;
	return result;
}

static GtkButton*
graphs_item_box_get_color_button (GraphsItemBox* self)
{
	GtkButton* result;
	GtkButton* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_color_button;
	result = _tmp0_;
	return result;
}

GraphsWindow*
graphs_item_box_get_window (GraphsItemBox* self)
{
	GraphsWindow* result;
	GraphsWindow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_window;
	result = _tmp0_;
	return result;
}

void
graphs_item_box_set_window (GraphsItemBox* self,
                            GraphsWindow* value)
{
	GraphsWindow* old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_item_box_get_window (self);
	if (old_value != value) {
		GraphsWindow* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_window);
		self->priv->_window = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, graphs_item_box_properties[GRAPHS_ITEM_BOX_WINDOW_PROPERTY]);
	}
}

GraphsItem*
graphs_item_box_get_item (GraphsItemBox* self)
{
	GraphsItem* result;
	GraphsItem* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_item;
	result = _tmp0_;
	return result;
}

void
graphs_item_box_set_item (GraphsItemBox* self,
                          GraphsItem* value)
{
	GraphsItem* old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_item_box_get_item (self);
	if (old_value != value) {
		GraphsItem* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_item);
		self->priv->_item = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, graphs_item_box_properties[GRAPHS_ITEM_BOX_ITEM_PROPERTY]);
	}
}

guint
graphs_item_box_get_index (GraphsItemBox* self)
{
	guint result;
	g_return_val_if_fail (self != NULL, 0U);
	result = self->priv->_index;
	return result;
}

void
graphs_item_box_set_index (GraphsItemBox* self,
                           guint value)
{
	guint old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_item_box_get_index (self);
	if (old_value != value) {
		self->priv->_index = value;
		g_object_notify_by_pspec ((GObject *) self, graphs_item_box_properties[GRAPHS_ITEM_BOX_INDEX_PROPERTY]);
	}
}

static void
graphs_item_box_class_init (GraphsItemBoxClass * klass,
                            gpointer klass_data)
{
	graphs_item_box_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GraphsItemBox_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_graphs_item_box_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_graphs_item_box_set_property;
	G_OBJECT_CLASS (klass)->finalize = graphs_item_box_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_ITEM_BOX_CHECK_BUTTON_PROPERTY, graphs_item_box_properties[GRAPHS_ITEM_BOX_CHECK_BUTTON_PROPERTY] = g_param_spec_object ("check-button", "check-button", "check-button", gtk_check_button_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_ITEM_BOX_WINDOW_PROPERTY, graphs_item_box_properties[GRAPHS_ITEM_BOX_WINDOW_PROPERTY] = g_param_spec_object ("window", "window", "window", GRAPHS_TYPE_WINDOW, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_ITEM_BOX_ITEM_PROPERTY, graphs_item_box_properties[GRAPHS_ITEM_BOX_ITEM_PROPERTY] = g_param_spec_object ("item", "item", "item", GRAPHS_TYPE_ITEM, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_ITEM_BOX_INDEX_PROPERTY, graphs_item_box_properties[GRAPHS_ITEM_BOX_INDEX_PROPERTY] = g_param_spec_uint ("index", "index", "index", 0, G_MAXUINT, 0U, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/se/sjoerd/Graphs/ui/item-box.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "check_button", FALSE, GraphsItemBox_private_offset + G_STRUCT_OFFSET (GraphsItemBoxPrivate, _check_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "color_button", FALSE, GraphsItemBox_private_offset + G_STRUCT_OFFSET (GraphsItemBoxPrivate, _color_button));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_toggle", G_CALLBACK(_graphs_item_box_on_toggle_g_object_notify));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "choose_color", G_CALLBACK(_graphs_item_box_choose_color_gtk_button_clicked));
}

static void
graphs_item_box_instance_init (GraphsItemBox * self,
                               gpointer klass)
{
	self->priv = graphs_item_box_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
graphs_item_box_finalize (GObject * obj)
{
	GraphsItemBox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRAPHS_TYPE_ITEM_BOX, GraphsItemBox);
	_g_object_unref0 (self->priv->_window);
	_g_object_unref0 (self->priv->_item);
	_g_object_unref0 (self->priv->provider);
	G_OBJECT_CLASS (graphs_item_box_parent_class)->finalize (obj);
}

/**
     * Item Box widget
     */
static GType
graphs_item_box_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GraphsItemBoxClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) graphs_item_box_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GraphsItemBox), 0, (GInstanceInitFunc) graphs_item_box_instance_init, NULL };
	GType graphs_item_box_type_id;
	graphs_item_box_type_id = g_type_register_static (adw_action_row_get_type (), "GraphsItemBox", &g_define_type_info, 0);
	GraphsItemBox_private_offset = g_type_add_instance_private (graphs_item_box_type_id, sizeof (GraphsItemBoxPrivate));
	return graphs_item_box_type_id;
}

GType
graphs_item_box_get_type (void)
{
	static volatile gsize graphs_item_box_type_id__once = 0;
	if (g_once_init_enter (&graphs_item_box_type_id__once)) {
		GType graphs_item_box_type_id;
		graphs_item_box_type_id = graphs_item_box_get_type_once ();
		g_once_init_leave (&graphs_item_box_type_id__once, graphs_item_box_type_id);
	}
	return graphs_item_box_type_id__once;
}

static void
_vala_graphs_item_box_get_property (GObject * object,
                                    guint property_id,
                                    GValue * value,
                                    GParamSpec * pspec)
{
	GraphsItemBox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRAPHS_TYPE_ITEM_BOX, GraphsItemBox);
	switch (property_id) {
		case GRAPHS_ITEM_BOX_CHECK_BUTTON_PROPERTY:
		g_value_set_object (value, graphs_item_box_get_check_button (self));
		break;
		case GRAPHS_ITEM_BOX_WINDOW_PROPERTY:
		g_value_set_object (value, graphs_item_box_get_window (self));
		break;
		case GRAPHS_ITEM_BOX_ITEM_PROPERTY:
		g_value_set_object (value, graphs_item_box_get_item (self));
		break;
		case GRAPHS_ITEM_BOX_INDEX_PROPERTY:
		g_value_set_uint (value, graphs_item_box_get_index (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_graphs_item_box_set_property (GObject * object,
                                    guint property_id,
                                    const GValue * value,
                                    GParamSpec * pspec)
{
	GraphsItemBox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRAPHS_TYPE_ITEM_BOX, GraphsItemBox);
	switch (property_id) {
		case GRAPHS_ITEM_BOX_WINDOW_PROPERTY:
		graphs_item_box_set_window (self, g_value_get_object (value));
		break;
		case GRAPHS_ITEM_BOX_ITEM_PROPERTY:
		graphs_item_box_set_item (self, g_value_get_object (value));
		break;
		case GRAPHS_ITEM_BOX_INDEX_PROPERTY:
		graphs_item_box_set_index (self, g_value_get_uint (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;
}

