/* 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 <float.h>
#include <math.h>
#include <gdk/gdk.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.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_APPLICATION_PROPERTY,
	GRAPHS_ITEM_BOX_ITEM_PROPERTY,
	GRAPHS_ITEM_BOX_INDEX_PROPERTY,
	GRAPHS_ITEM_BOX_CLICK_GESTURE_PROPERTY,
	GRAPHS_ITEM_BOX_DRAG_SOURCE_PROPERTY,
	GRAPHS_ITEM_BOX_DROP_TARGET_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 _Block12Data Block12Data;
#define __vala_GdkRGBA_free0(var) ((var == NULL) ? NULL : (var = (_vala_GdkRGBA_free (var), NULL)))

struct _GraphsItemBoxPrivate {
	GtkLabel* _label;
	GtkCheckButton* _check_button;
	GtkButton* _color_button;
	GraphsApplication* _application;
	GraphsItem* _item;
	gint _index;
	GtkGestureClick* _click_gesture;
	GtkDragSource* _drag_source;
	GtkDropTarget* _drop_target;
	GtkCssProvider* provider;
};

struct _Block12Data {
	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 GtkLabel* graphs_item_box_get_label (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 graphs_item_box_set_click_gesture (GraphsItemBox* self,
                                        GtkGestureClick* value);
static void __lambda33_ (GraphsItemBox* self);
static void ___lambda33__gtk_gesture_click_released (GtkGestureClick* _sender,
                                              gint n_press,
                                              gdouble x,
                                              gdouble y,
                                              gpointer self);
static void graphs_item_box_set_drag_source (GraphsItemBox* self,
                                      GtkDragSource* value);
static GdkContentProvider* __lambda34_ (GraphsItemBox* self,
                                 GtkDragSource* s,
                                 gdouble x,
                                 gdouble y);
static GdkContentProvider* ___lambda34__gtk_drag_source_prepare (GtkDragSource* _sender,
                                                          gdouble x,
                                                          gdouble y,
                                                          gpointer self);
static void graphs_item_box_set_drop_target (GraphsItemBox* self,
                                      GtkDropTarget* value);
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 Block12Data* block12_data_ref (Block12Data* _data12_);
static void block12_data_unref (void * _userdata_);
static void __lambda35_ (Block12Data* _data12_,
                  GObject* d,
                  GAsyncResult* _result_);
static void _vala_GdkRGBA_free (GdkRGBA* self);
static void ___lambda35__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 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);
}

static void
__lambda33_ (GraphsItemBox* self)
{
	GtkCheckButton* _tmp0_;
	GtkCheckButton* _tmp1_;
	_tmp0_ = self->priv->_check_button;
	_tmp1_ = self->priv->_check_button;
	gtk_check_button_set_active (_tmp0_, !gtk_check_button_get_active (_tmp1_));
}

static void
___lambda33__gtk_gesture_click_released (GtkGestureClick* _sender,
                                         gint n_press,
                                         gdouble x,
                                         gdouble y,
                                         gpointer self)
{
	__lambda33_ ((GraphsItemBox*) self);
}

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

static GdkContentProvider*
__lambda34_ (GraphsItemBox* self,
             GtkDragSource* s,
             gdouble x,
             gdouble y)
{
	GtkWidget* widget = NULL;
	GtkWidget* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidgetPaintable* paintable = NULL;
	GtkWidgetPaintable* _tmp2_;
	GtkDragSource* _tmp3_;
	gint _tmp4_;
	GValue _tmp5_ = {0};
	GdkContentProvider* _tmp6_;
	GdkContentProvider* _tmp7_;
	GdkContentProvider* result;
	g_return_val_if_fail (s != NULL, NULL);
	_tmp0_ = gtk_widget_get_parent ((GtkWidget*) self);
	_tmp1_ = _g_object_ref0 (_tmp0_);
	widget = _tmp1_;
	gtk_widget_add_css_class (widget, "card");
	_tmp2_ = (GtkWidgetPaintable*) gtk_widget_paintable_new (widget);
	paintable = _tmp2_;
	_tmp3_ = self->priv->_drag_source;
	gtk_drag_source_set_icon (_tmp3_, (GdkPaintable*) paintable, (gint) x, (gint) y);
	_tmp4_ = self->priv->_index;
	g_value_init (&_tmp5_, G_TYPE_INT);
	g_value_set_int (&_tmp5_, _tmp4_);
	_tmp6_ = gdk_content_provider_new_for_value (&_tmp5_);
	_tmp7_ = _tmp6_;
	G_IS_VALUE (&_tmp5_) ? (g_value_unset (&_tmp5_), NULL) : NULL;
	result = _tmp7_;
	_g_object_unref0 (paintable);
	_g_object_unref0 (widget);
	return result;
}

static GdkContentProvider*
___lambda34__gtk_drag_source_prepare (GtkDragSource* _sender,
                                      gdouble x,
                                      gdouble y,
                                      gpointer self)
{
	GdkContentProvider* result;
	result = __lambda34_ ((GraphsItemBox*) self, _sender, x, y);
	return result;
}

void
graphs_item_box_setup (GraphsItemBox* self)
{
	GtkCssProvider* _tmp0_;
	GtkButton* _tmp1_;
	GtkStyleContext* _tmp2_;
	GtkCssProvider* _tmp3_;
	GraphsItem* _tmp4_;
	GtkLabel* _tmp5_;
	GraphsItem* _tmp6_;
	GtkCheckButton* _tmp7_;
	GraphsItem* _tmp8_;
	GtkGestureClick* _tmp9_;
	GtkGestureClick* _tmp10_;
	GtkGestureClick* _tmp11_;
	GtkDragSource* _tmp12_;
	GtkDragSource* _tmp13_;
	GtkDragSource* _tmp14_;
	GtkDragSource* _tmp15_;
	GtkDropTarget* _tmp16_;
	GtkDropTarget* _tmp17_;
	g_return_if_fail (self != 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_ = self->priv->_item;
	_tmp5_ = self->priv->_label;
	g_object_bind_property_with_closures ((GObject*) _tmp4_, "name", (GObject*) _tmp5_, "label", 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->_item;
	_tmp7_ = self->priv->_check_button;
	g_object_bind_property_with_closures ((GObject*) _tmp6_, "selected", (GObject*) _tmp7_, "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)));
	_tmp8_ = self->priv->_item;
	g_signal_connect_object ((GObject*) _tmp8_, "notify::color", (GCallback) _graphs_item_box_on_color_change_g_object_notify, self, 0);
	graphs_item_box_on_color_change (self);
	_tmp9_ = (GtkGestureClick*) gtk_gesture_click_new ();
	_tmp10_ = _tmp9_;
	graphs_item_box_set_click_gesture (self, _tmp10_);
	_g_object_unref0 (_tmp10_);
	_tmp11_ = self->priv->_click_gesture;
	g_signal_connect_object (_tmp11_, "released", (GCallback) ___lambda33__gtk_gesture_click_released, self, 0);
	_tmp12_ = gtk_drag_source_new ();
	_tmp13_ = _tmp12_;
	graphs_item_box_set_drag_source (self, _tmp13_);
	_g_object_unref0 (_tmp13_);
	_tmp14_ = self->priv->_drag_source;
	gtk_drag_source_set_actions (_tmp14_, GDK_ACTION_COPY);
	_tmp15_ = self->priv->_drag_source;
	g_signal_connect_object (_tmp15_, "prepare", (GCallback) ___lambda34__gtk_drag_source_prepare, self, 0);
	_tmp16_ = gtk_drop_target_new (G_TYPE_INT, GDK_ACTION_COPY);
	_tmp17_ = _tmp16_;
	graphs_item_box_set_drop_target (self, _tmp17_);
	_g_object_unref0 (_tmp17_);
}

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_;
		GraphsApplication* _tmp5_;
		GraphsData* _tmp6_;
		GraphsData* _tmp7_;
		_tmp4_ = self->priv->_item;
		graphs_item_set_selected (_tmp4_, new_value);
		_tmp5_ = self->priv->_application;
		_tmp6_ = graphs_application_get_data (_tmp5_);
		_tmp7_ = _tmp6_;
		g_signal_emit_by_name (_tmp7_, "add-history-state-request");
	}
}

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

static Block12Data*
block12_data_ref (Block12Data* _data12_)
{
	g_atomic_int_inc (&_data12_->_ref_count_);
	return _data12_;
}

static void
block12_data_unref (void * _userdata_)
{
	Block12Data* _data12_;
	_data12_ = (Block12Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data12_->_ref_count_)) {
		GraphsItemBox* self;
		self = _data12_->self;
		_g_object_unref0 (_data12_->dialog);
		_g_object_unref0 (self);
		g_slice_free (Block12Data, _data12_);
	}
}

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

static void
__lambda35_ (Block12Data* _data12_,
             GObject* d,
             GAsyncResult* _result_)
{
	GraphsItemBox* self;
	GError* _inner_error0_ = NULL;
	self = _data12_->self;
	g_return_if_fail (_result_ != NULL);
	{
		GdkRGBA* _tmp0_ = NULL;
		GdkRGBA* _tmp1_;
		GraphsItem* _tmp2_;
		GdkRGBA _tmp3_;
		GraphsApplication* _tmp4_;
		GraphsData* _tmp5_;
		GraphsData* _tmp6_;
		_tmp1_ = gtk_color_dialog_choose_rgba_finish (_data12_->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->_application;
		_tmp5_ = graphs_application_get_data (_tmp4_);
		_tmp6_ = _tmp5_;
		g_signal_emit_by_name (_tmp6_, "add-history-state-request");
		__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
___lambda35__gasync_ready_callback (GObject* source_object,
                                    GAsyncResult* res,
                                    gpointer self)
{
	__lambda35_ (self, source_object, res);
	block12_data_unref (self);
}

static void
graphs_item_box_choose_color (GraphsItemBox* self)
{
	Block12Data* _data12_;
	GtkColorDialog* _tmp0_;
	GraphsApplication* _tmp1_;
	GraphsWindow* _tmp2_;
	GraphsWindow* _tmp3_;
	GraphsItem* _tmp4_;
	GdkRGBA _tmp5_ = {0};
	g_return_if_fail (self != NULL);
	_data12_ = g_slice_new0 (Block12Data);
	_data12_->_ref_count_ = 1;
	_data12_->self = g_object_ref (self);
	_tmp0_ = gtk_color_dialog_new ();
	_data12_->dialog = _tmp0_;
	_tmp1_ = self->priv->_application;
	_tmp2_ = graphs_application_get_window (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = self->priv->_item;
	graphs_item_get_rgba (_tmp4_, &_tmp5_);
	gtk_color_dialog_choose_rgba (_data12_->dialog, (GtkWindow*) _tmp3_, &_tmp5_, NULL, ___lambda35__gasync_ready_callback, block12_data_ref (_data12_));
	block12_data_unref (_data12_);
	_data12_ = NULL;
}

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

GraphsItemBox*
graphs_item_box_construct (GType object_type)
{
	GraphsItemBox * self = NULL;
	self = (GraphsItemBox*) g_object_new (object_type, NULL);
	return self;
}

GraphsItemBox*
graphs_item_box_new (void)
{
	return graphs_item_box_construct (GRAPHS_TYPE_ITEM_BOX);
}

static GtkLabel*
graphs_item_box_get_label (GraphsItemBox* self)
{
	GtkLabel* result;
	GtkLabel* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_label;
	result = _tmp0_;
	return result;
}

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

GraphsApplication*
graphs_item_box_get_application (GraphsItemBox* self)
{
	GraphsApplication* result;
	GraphsApplication* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_application;
	result = _tmp0_;
	return result;
}

void
graphs_item_box_set_application (GraphsItemBox* self,
                                 GraphsApplication* value)
{
	GraphsApplication* old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_item_box_get_application (self);
	if (old_value != value) {
		GraphsApplication* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_application);
		self->priv->_application = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, graphs_item_box_properties[GRAPHS_ITEM_BOX_APPLICATION_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]);
	}
}

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

void
graphs_item_box_set_index (GraphsItemBox* self,
                           gint value)
{
	gint 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]);
	}
}

GtkGestureClick*
graphs_item_box_get_click_gesture (GraphsItemBox* self)
{
	GtkGestureClick* result;
	GtkGestureClick* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_click_gesture;
	result = _tmp0_;
	return result;
}

static void
graphs_item_box_set_click_gesture (GraphsItemBox* self,
                                   GtkGestureClick* value)
{
	GtkGestureClick* old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_item_box_get_click_gesture (self);
	if (old_value != value) {
		GtkGestureClick* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_click_gesture);
		self->priv->_click_gesture = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, graphs_item_box_properties[GRAPHS_ITEM_BOX_CLICK_GESTURE_PROPERTY]);
	}
}

GtkDragSource*
graphs_item_box_get_drag_source (GraphsItemBox* self)
{
	GtkDragSource* result;
	GtkDragSource* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_drag_source;
	result = _tmp0_;
	return result;
}

static void
graphs_item_box_set_drag_source (GraphsItemBox* self,
                                 GtkDragSource* value)
{
	GtkDragSource* old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_item_box_get_drag_source (self);
	if (old_value != value) {
		GtkDragSource* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_drag_source);
		self->priv->_drag_source = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, graphs_item_box_properties[GRAPHS_ITEM_BOX_DRAG_SOURCE_PROPERTY]);
	}
}

GtkDropTarget*
graphs_item_box_get_drop_target (GraphsItemBox* self)
{
	GtkDropTarget* result;
	GtkDropTarget* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_drop_target;
	result = _tmp0_;
	return result;
}

static void
graphs_item_box_set_drop_target (GraphsItemBox* self,
                                 GtkDropTarget* value)
{
	GtkDropTarget* old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_item_box_get_drop_target (self);
	if (old_value != value) {
		GtkDropTarget* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_drop_target);
		self->priv->_drop_target = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, graphs_item_box_properties[GRAPHS_ITEM_BOX_DROP_TARGET_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_APPLICATION_PROPERTY, graphs_item_box_properties[GRAPHS_ITEM_BOX_APPLICATION_PROPERTY] = g_param_spec_object ("application", "application", "application", GRAPHS_TYPE_APPLICATION, 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_int ("index", "index", "index", G_MININT, G_MAXINT, 0, 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_CLICK_GESTURE_PROPERTY, graphs_item_box_properties[GRAPHS_ITEM_BOX_CLICK_GESTURE_PROPERTY] = g_param_spec_object ("click-gesture", "click-gesture", "click-gesture", gtk_gesture_click_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_ITEM_BOX_DRAG_SOURCE_PROPERTY, graphs_item_box_properties[GRAPHS_ITEM_BOX_DRAG_SOURCE_PROPERTY] = g_param_spec_object ("drag-source", "drag-source", "drag-source", gtk_drag_source_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_ITEM_BOX_DROP_TARGET_PROPERTY, graphs_item_box_properties[GRAPHS_ITEM_BOX_DROP_TARGET_PROPERTY] = g_param_spec_object ("drop-target", "drop-target", "drop-target", gtk_drop_target_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	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), "label", FALSE, GraphsItemBox_private_offset + G_STRUCT_OFFSET (GraphsItemBoxPrivate, _label));
	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->_application);
	_g_object_unref0 (self->priv->_item);
	_g_object_unref0 (self->priv->_click_gesture);
	_g_object_unref0 (self->priv->_drag_source);
	_g_object_unref0 (self->priv->_drop_target);
	_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 (gtk_box_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_APPLICATION_PROPERTY:
		g_value_set_object (value, graphs_item_box_get_application (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_int (value, graphs_item_box_get_index (self));
		break;
		case GRAPHS_ITEM_BOX_CLICK_GESTURE_PROPERTY:
		g_value_set_object (value, graphs_item_box_get_click_gesture (self));
		break;
		case GRAPHS_ITEM_BOX_DRAG_SOURCE_PROPERTY:
		g_value_set_object (value, graphs_item_box_get_drag_source (self));
		break;
		case GRAPHS_ITEM_BOX_DROP_TARGET_PROPERTY:
		g_value_set_object (value, graphs_item_box_get_drop_target (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_APPLICATION_PROPERTY:
		graphs_item_box_set_application (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_int (value));
		break;
		case GRAPHS_ITEM_BOX_CLICK_GESTURE_PROPERTY:
		graphs_item_box_set_click_gesture (self, g_value_get_object (value));
		break;
		case GRAPHS_ITEM_BOX_DRAG_SOURCE_PROPERTY:
		graphs_item_box_set_drag_source (self, g_value_get_object (value));
		break;
		case GRAPHS_ITEM_BOX_DROP_TARGET_PROPERTY:
		graphs_item_box_set_drop_target (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;
}

