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

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

#include "graphs.h"
#include <gtk/gtk.h>
#include <gee.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gdk/gdk.h>
#include <float.h>
#include <math.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_STYLE_COLOR_MANAGER_0_PROPERTY,
	GRAPHS_STYLE_COLOR_MANAGER_NUM_PROPERTIES
};
static GParamSpec* graphs_style_color_manager_properties[GRAPHS_STYLE_COLOR_MANAGER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block10Data Block10Data;
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block11Data Block11Data;
enum  {
	GRAPHS_STYLE_COLOR_MANAGER_COLORS_CHANGED_SIGNAL,
	GRAPHS_STYLE_COLOR_MANAGER_NUM_SIGNALS
};
static guint graphs_style_color_manager_signals[GRAPHS_STYLE_COLOR_MANAGER_NUM_SIGNALS] = {0};

struct _GraphsStyleColorManagerPrivate {
	GtkListBox* box;
	GeeArrayList* colors;
};

struct _Block10Data {
	int _ref_count_;
	GraphsStyleColorManager* self;
	GtkListBox* box;
};

struct _Block11Data {
	int _ref_count_;
	GraphsStyleColorManager* self;
	GraphsStyleItemColorRow* row;
	gdouble drag_x;
	gdouble drag_y;
	gint index;
};

static gint GraphsStyleColorManager_private_offset;
static gpointer graphs_style_color_manager_parent_class = NULL;

static Block10Data* block10_data_ref (Block10Data* _data10_);
static void block10_data_unref (void * _userdata_);
static gboolean __lambda102_ (Block10Data* _data10_,
                       GtkDropTarget* drop,
                       GValue* val,
                       gdouble x,
                       gdouble y);
static gboolean ___lambda102__gtk_drop_target_drop (GtkDropTarget* _sender,
                                             GValue* value,
                                             gdouble x,
                                             gdouble y,
                                             gpointer self);
static void graphs_style_color_manager_reload_color_boxes (GraphsStyleColorManager* self);
static void graphs_style_color_manager_append_style_color_box (GraphsStyleColorManager* self,
                                                        gint index);
static Block11Data* block11_data_ref (Block11Data* _data11_);
static void block11_data_unref (void * _userdata_);
static void __lambda103_ (Block11Data* _data11_);
static void ___lambda103__graphs_style_item_color_row_color_removed (GraphsStyleItemColorRow* _sender,
                                                              gpointer self);
static void __lambda104_ (Block11Data* _data11_,
                   GraphsStyleItemColorRow* b,
                   const gchar* color);
static void ___lambda104__graphs_style_item_color_row_color_changed (GraphsStyleItemColorRow* _sender,
                                                              const gchar* color,
                                                              gpointer self);
static GdkContentProvider* __lambda105_ (Block11Data* _data11_,
                                  gdouble x,
                                  gdouble y);
static GdkContentProvider* ___lambda105__gtk_drag_source_prepare (GtkDragSource* _sender,
                                                           gdouble x,
                                                           gdouble y,
                                                           gpointer self);
static void __lambda106_ (Block11Data* _data11_,
                   GdkDrag* drag);
static void ___lambda106__gtk_drag_source_drag_begin (GtkDragSource* _sender,
                                               GdkDrag* drag,
                                               gpointer self);
static void __lambda107_ (Block11Data* _data11_);
static void ___lambda107__gtk_drop_controller_motion_enter (GtkDropControllerMotion* _sender,
                                                     gdouble x,
                                                     gdouble y,
                                                     gpointer self);
static void __lambda108_ (GraphsStyleColorManager* self);
static void ___lambda108__gtk_drop_controller_motion_leave (GtkDropControllerMotion* _sender,
                                                     gpointer self);
static void graphs_style_color_manager_finalize (GObject * obj);
static GType graphs_style_color_manager_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
graphs_style_color_manager_get_instance_private (GraphsStyleColorManager* self)
{
	return G_STRUCT_MEMBER_P (self, GraphsStyleColorManager_private_offset);
}

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

static Block10Data*
block10_data_ref (Block10Data* _data10_)
{
	g_atomic_int_inc (&_data10_->_ref_count_);
	return _data10_;
}

static void
block10_data_unref (void * _userdata_)
{
	Block10Data* _data10_;
	_data10_ = (Block10Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data10_->_ref_count_)) {
		GraphsStyleColorManager* self;
		self = _data10_->self;
		_g_object_unref0 (_data10_->box);
		_g_object_unref0 (self);
		g_slice_free (Block10Data, _data10_);
	}
}

static gboolean
__lambda102_ (Block10Data* _data10_,
              GtkDropTarget* drop,
              GValue* val,
              gdouble x,
              gdouble y)
{
	GraphsStyleColorManager* self;
	GraphsStyleItemColorRow* value_row = NULL;
	GObject* _tmp0_;
	GraphsStyleItemColorRow* _tmp1_;
	GraphsStyleItemColorRow* target_row = NULL;
	GtkListBoxRow* _tmp2_;
	GraphsStyleItemColorRow* _tmp3_;
	gboolean _tmp4_ = FALSE;
	GraphsStyleItemColorRow* _tmp5_;
	GraphsStyleItemColorRow* _tmp7_;
	GraphsStyleColorManager* _tmp8_;
	GraphsStyleItemColorRow* _tmp9_;
	gint _tmp10_;
	gint _tmp11_;
	GraphsStyleItemColorRow* _tmp12_;
	gint _tmp13_;
	gint _tmp14_;
	GraphsStyleItemColorRow* _tmp15_;
	gboolean result;
	self = _data10_->self;
	g_return_val_if_fail (drop != NULL, FALSE);
	g_return_val_if_fail (val != NULL, FALSE);
	_tmp0_ = g_value_get_object (val);
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GRAPHS_TYPE_STYLE_ITEM_COLOR_ROW, GraphsStyleItemColorRow));
	value_row = _tmp1_;
	_tmp2_ = gtk_list_box_get_row_at_y (_data10_->box, (gint) y);
	_tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GRAPHS_TYPE_STYLE_ITEM_COLOR_ROW, GraphsStyleItemColorRow));
	target_row = _tmp3_;
	_tmp5_ = value_row;
	if (_tmp5_ == NULL) {
		_tmp4_ = TRUE;
	} else {
		GraphsStyleItemColorRow* _tmp6_;
		_tmp6_ = target_row;
		_tmp4_ = _tmp6_ == NULL;
	}
	if (_tmp4_) {
		result = FALSE;
		_g_object_unref0 (target_row);
		_g_object_unref0 (value_row);
		return result;
	}
	_tmp7_ = value_row;
	_tmp8_ = _tmp7_->color_manager;
	if (_tmp8_ != self) {
		result = FALSE;
		_g_object_unref0 (target_row);
		_g_object_unref0 (value_row);
		return result;
	}
	_tmp9_ = target_row;
	_tmp10_ = graphs_style_item_color_row_get_index (_tmp9_);
	_tmp11_ = _tmp10_;
	_tmp12_ = value_row;
	_tmp13_ = graphs_style_item_color_row_get_index (_tmp12_);
	_tmp14_ = _tmp13_;
	graphs_style_color_manager_change_position (self, _tmp11_, _tmp14_);
	_tmp15_ = target_row;
	gtk_widget_set_state_flags ((GtkWidget*) _tmp15_, GTK_STATE_FLAG_NORMAL, TRUE);
	result = TRUE;
	_g_object_unref0 (target_row);
	_g_object_unref0 (value_row);
	return result;
}

static gboolean
___lambda102__gtk_drop_target_drop (GtkDropTarget* _sender,
                                    GValue* value,
                                    gdouble x,
                                    gdouble y,
                                    gpointer self)
{
	gboolean result;
	result = __lambda102_ (self, _sender, value, x, y);
	return result;
}

GraphsStyleColorManager*
graphs_style_color_manager_construct (GType object_type,
                                      GtkListBox* box)
{
	GraphsStyleColorManager * self = NULL;
	Block10Data* _data10_;
	GtkListBox* _tmp0_;
	GtkListBox* _tmp1_;
	GtkDropTarget* drop_target = NULL;
	GtkDropTarget* _tmp2_;
	GtkEventController* _tmp3_;
	g_return_val_if_fail (box != NULL, NULL);
	_data10_ = g_slice_new0 (Block10Data);
	_data10_->_ref_count_ = 1;
	_tmp0_ = _g_object_ref0 (box);
	_g_object_unref0 (_data10_->box);
	_data10_->box = _tmp0_;
	self = (GraphsStyleColorManager*) g_object_new (object_type, NULL);
	_data10_->self = g_object_ref (self);
	_tmp1_ = _g_object_ref0 (_data10_->box);
	_g_object_unref0 (self->priv->box);
	self->priv->box = _tmp1_;
	_tmp2_ = gtk_drop_target_new (GRAPHS_TYPE_STYLE_ITEM_COLOR_ROW, GDK_ACTION_MOVE);
	drop_target = _tmp2_;
	g_signal_connect_data (drop_target, "drop", (GCallback) ___lambda102__gtk_drop_target_drop, block10_data_ref (_data10_), (GClosureNotify) block10_data_unref, 0);
	_tmp3_ = _g_object_ref0 ((GtkEventController*) drop_target);
	gtk_widget_add_controller ((GtkWidget*) _data10_->box, _tmp3_);
	_g_object_unref0 (drop_target);
	block10_data_unref (_data10_);
	_data10_ = NULL;
	return self;
}

GraphsStyleColorManager*
graphs_style_color_manager_new (GtkListBox* box)
{
	return graphs_style_color_manager_construct (GRAPHS_TYPE_STYLE_COLOR_MANAGER, box);
}

void
graphs_style_color_manager_set_colors (GraphsStyleColorManager* self,
                                       gchar** colors,
                                       gint colors_length1)
{
	GeeArrayList* _tmp0_;
	GeeArrayList* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->colors;
	gee_abstract_collection_clear ((GeeAbstractCollection*) _tmp0_);
	_tmp1_ = self->priv->colors;
	gee_collection_add_all_array ((GeeCollection*) _tmp1_, colors, (gint) colors_length1);
	graphs_style_color_manager_reload_color_boxes (self);
}

void
graphs_style_color_manager_add_color (GraphsStyleColorManager* self,
                                      const gchar* color)
{
	GeeArrayList* _tmp0_;
	GeeArrayList* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (color != NULL);
	_tmp0_ = self->priv->colors;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp0_, color);
	_tmp1_ = self->priv->colors;
	_tmp2_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp1_);
	_tmp3_ = _tmp2_;
	graphs_style_color_manager_append_style_color_box (self, _tmp3_ - 1);
	g_signal_emit (self, graphs_style_color_manager_signals[GRAPHS_STYLE_COLOR_MANAGER_COLORS_CHANGED_SIGNAL], 0);
}

gchar**
graphs_style_color_manager_get_colors (GraphsStyleColorManager* self,
                                       gint* result_length1)
{
	GeeArrayList* _tmp0_;
	gint _tmp1_ = 0;
	gpointer* _tmp2_;
	gchar** _tmp3_;
	gint _tmp3__length1;
	gchar** result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->colors;
	_tmp2_ = gee_collection_to_array ((GeeCollection*) _tmp0_, &_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp3__length1 = _tmp1_;
	if (result_length1) {
		*result_length1 = _tmp3__length1;
	}
	result = _tmp3_;
	return result;
}

void
graphs_style_color_manager_change_position (GraphsStyleColorManager* self,
                                            gint index1,
                                            gint index2)
{
	gchar* color = NULL;
	GeeArrayList* _tmp0_;
	gpointer _tmp1_;
	GeeArrayList* _tmp2_;
	gpointer _tmp3_;
	gchar* _tmp4_;
	GeeArrayList* _tmp5_;
	const gchar* _tmp6_;
	g_return_if_fail (self != NULL);
	if (index1 == index2) {
		return;
	}
	_tmp0_ = self->priv->colors;
	_tmp1_ = gee_abstract_list_get ((GeeAbstractList*) _tmp0_, index2);
	color = (gchar*) _tmp1_;
	_tmp2_ = self->priv->colors;
	_tmp3_ = gee_abstract_list_remove_at ((GeeAbstractList*) _tmp2_, index2);
	_tmp4_ = (gchar*) _tmp3_;
	_g_free0 (_tmp4_);
	_tmp5_ = self->priv->colors;
	_tmp6_ = color;
	gee_abstract_list_insert ((GeeAbstractList*) _tmp5_, index1, _tmp6_);
	graphs_style_color_manager_reload_color_boxes (self);
	g_signal_emit (self, graphs_style_color_manager_signals[GRAPHS_STYLE_COLOR_MANAGER_COLORS_CHANGED_SIGNAL], 0);
	_g_free0 (color);
}

static Block11Data*
block11_data_ref (Block11Data* _data11_)
{
	g_atomic_int_inc (&_data11_->_ref_count_);
	return _data11_;
}

static void
block11_data_unref (void * _userdata_)
{
	Block11Data* _data11_;
	_data11_ = (Block11Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data11_->_ref_count_)) {
		GraphsStyleColorManager* self;
		self = _data11_->self;
		_g_object_unref0 (_data11_->row);
		_g_object_unref0 (self);
		g_slice_free (Block11Data, _data11_);
	}
}

static void
__lambda103_ (Block11Data* _data11_)
{
	GraphsStyleColorManager* self;
	GeeArrayList* _tmp0_;
	gpointer _tmp1_;
	gchar* _tmp2_;
	self = _data11_->self;
	_tmp0_ = self->priv->colors;
	_tmp1_ = gee_abstract_list_remove_at ((GeeAbstractList*) _tmp0_, _data11_->index);
	_tmp2_ = (gchar*) _tmp1_;
	_g_free0 (_tmp2_);
	graphs_style_color_manager_reload_color_boxes (self);
	g_signal_emit (self, graphs_style_color_manager_signals[GRAPHS_STYLE_COLOR_MANAGER_COLORS_CHANGED_SIGNAL], 0);
}

static void
___lambda103__graphs_style_item_color_row_color_removed (GraphsStyleItemColorRow* _sender,
                                                         gpointer self)
{
	__lambda103_ (self);
}

static void
__lambda104_ (Block11Data* _data11_,
              GraphsStyleItemColorRow* b,
              const gchar* color)
{
	GraphsStyleColorManager* self;
	GeeArrayList* _tmp0_;
	self = _data11_->self;
	g_return_if_fail (b != NULL);
	g_return_if_fail (color != NULL);
	_tmp0_ = self->priv->colors;
	gee_abstract_list_set ((GeeAbstractList*) _tmp0_, _data11_->index, color);
	g_signal_emit (self, graphs_style_color_manager_signals[GRAPHS_STYLE_COLOR_MANAGER_COLORS_CHANGED_SIGNAL], 0);
}

static void
___lambda104__graphs_style_item_color_row_color_changed (GraphsStyleItemColorRow* _sender,
                                                         const gchar* color,
                                                         gpointer self)
{
	__lambda104_ (self, _sender, color);
}

static GdkContentProvider*
__lambda105_ (Block11Data* _data11_,
              gdouble x,
              gdouble y)
{
	GraphsStyleColorManager* self;
	GValue val = {0};
	GValue _tmp0_ = {0};
	GValue _tmp1_;
	GdkContentProvider* _tmp2_;
	GdkContentProvider* result;
	self = _data11_->self;
	_data11_->drag_x = x;
	_data11_->drag_y = y;
	g_value_init (&_tmp0_, GRAPHS_TYPE_STYLE_ITEM_COLOR_ROW);
	val = _tmp0_;
	g_value_set_object (&val, (GObject*) _data11_->row);
	_tmp1_ = val;
	_tmp2_ = gdk_content_provider_new_for_value (&_tmp1_);
	result = _tmp2_;
	G_IS_VALUE (&val) ? (g_value_unset (&val), NULL) : NULL;
	return result;
}

static GdkContentProvider*
___lambda105__gtk_drag_source_prepare (GtkDragSource* _sender,
                                       gdouble x,
                                       gdouble y,
                                       gpointer self)
{
	GdkContentProvider* result;
	result = __lambda105_ (self, x, y);
	return result;
}

static void
__lambda106_ (Block11Data* _data11_,
              GdkDrag* drag)
{
	GraphsStyleColorManager* self;
	GtkListBox* drag_widget = NULL;
	GtkListBox* _tmp0_;
	GraphsStyleItemColorRow* drag_row = NULL;
	GeeArrayList* _tmp1_;
	gpointer _tmp2_;
	gchar* _tmp3_;
	GraphsStyleItemColorRow* _tmp4_;
	GraphsStyleItemColorRow* _tmp5_;
	GtkDragIcon* icon = NULL;
	GtkDragIcon* _tmp6_;
	self = _data11_->self;
	g_return_if_fail (drag != NULL);
	_tmp0_ = (GtkListBox*) gtk_list_box_new ();
	g_object_ref_sink (_tmp0_);
	drag_widget = _tmp0_;
	gtk_widget_set_size_request ((GtkWidget*) drag_widget, gtk_widget_get_width ((GtkWidget*) _data11_->row), gtk_widget_get_height ((GtkWidget*) _data11_->row));
	gtk_widget_add_css_class ((GtkWidget*) drag_widget, "boxed-list");
	_tmp1_ = self->priv->colors;
	_tmp2_ = gee_abstract_list_get ((GeeAbstractList*) _tmp1_, _data11_->index);
	_tmp3_ = (gchar*) _tmp2_;
	_tmp4_ = graphs_style_item_color_row_new (self, _data11_->index, _tmp3_);
	g_object_ref_sink (_tmp4_);
	_tmp5_ = _tmp4_;
	_g_free0 (_tmp3_);
	drag_row = _tmp5_;
	gtk_list_box_append (drag_widget, (GtkWidget*) drag_row);
	gtk_list_box_drag_highlight_row (drag_widget, (GtkListBoxRow*) drag_row);
	_tmp6_ = (GtkDragIcon*) gtk_drag_icon_get_for_drag (drag);
	g_object_ref_sink (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, gtk_drag_icon_get_type (), GtkDragIcon));
	icon = G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, gtk_drag_icon_get_type (), GtkDragIcon);
	gtk_drag_icon_set_child (icon, (GtkWidget*) drag_widget);
	gdk_drag_set_hotspot (drag, (gint) _data11_->drag_x, (gint) _data11_->drag_y);
	_g_object_unref0 (icon);
	_g_object_unref0 (drag_row);
	_g_object_unref0 (drag_widget);
}

static void
___lambda106__gtk_drag_source_drag_begin (GtkDragSource* _sender,
                                          GdkDrag* drag,
                                          gpointer self)
{
	__lambda106_ (self, drag);
}

static void
__lambda107_ (Block11Data* _data11_)
{
	GraphsStyleColorManager* self;
	GtkListBox* _tmp0_;
	self = _data11_->self;
	_tmp0_ = self->priv->box;
	gtk_list_box_drag_highlight_row (_tmp0_, (GtkListBoxRow*) _data11_->row);
}

static void
___lambda107__gtk_drop_controller_motion_enter (GtkDropControllerMotion* _sender,
                                                gdouble x,
                                                gdouble y,
                                                gpointer self)
{
	__lambda107_ (self);
}

static void
__lambda108_ (GraphsStyleColorManager* self)
{
	GtkListBox* _tmp0_;
	_tmp0_ = self->priv->box;
	gtk_list_box_drag_unhighlight_row (_tmp0_);
}

static void
___lambda108__gtk_drop_controller_motion_leave (GtkDropControllerMotion* _sender,
                                                gpointer self)
{
	__lambda108_ ((GraphsStyleColorManager*) self);
}

static void
graphs_style_color_manager_append_style_color_box (GraphsStyleColorManager* self,
                                                   gint index)
{
	Block11Data* _data11_;
	GeeArrayList* _tmp0_;
	gpointer _tmp1_;
	gchar* _tmp2_;
	GraphsStyleItemColorRow* _tmp3_;
	GraphsStyleItemColorRow* _tmp4_;
	GtkDropControllerMotion* drop_controller = NULL;
	GtkDropControllerMotion* _tmp5_;
	GtkDragSource* drag_source = NULL;
	GtkDragSource* _tmp6_ = NULL;
	GtkEventController* _tmp7_;
	GtkEventController* _tmp8_;
	GtkListBox* _tmp9_;
	g_return_if_fail (self != NULL);
	_data11_ = g_slice_new0 (Block11Data);
	_data11_->_ref_count_ = 1;
	_data11_->self = g_object_ref (self);
	_data11_->index = index;
	_tmp0_ = self->priv->colors;
	_tmp1_ = gee_abstract_list_get ((GeeAbstractList*) _tmp0_, _data11_->index);
	_tmp2_ = (gchar*) _tmp1_;
	_tmp3_ = graphs_style_item_color_row_new (self, _data11_->index, _tmp2_);
	g_object_ref_sink (_tmp3_);
	_tmp4_ = _tmp3_;
	_g_free0 (_tmp2_);
	_data11_->row = _tmp4_;
	g_signal_connect_data (_data11_->row, "color-removed", (GCallback) ___lambda103__graphs_style_item_color_row_color_removed, block11_data_ref (_data11_), (GClosureNotify) block11_data_unref, 0);
	g_signal_connect_data (_data11_->row, "color-changed", (GCallback) ___lambda104__graphs_style_item_color_row_color_changed, block11_data_ref (_data11_), (GClosureNotify) block11_data_unref, 0);
	_data11_->drag_x = 0.0;
	_data11_->drag_y = 0.0;
	_tmp5_ = (GtkDropControllerMotion*) gtk_drop_controller_motion_new ();
	drop_controller = _tmp5_;
	_tmp6_ = gtk_drag_source_new ();
	gtk_drag_source_set_actions (_tmp6_, GDK_ACTION_MOVE);
	drag_source = _tmp6_;
	_tmp7_ = _g_object_ref0 ((GtkEventController*) drag_source);
	gtk_widget_add_controller ((GtkWidget*) _data11_->row, _tmp7_);
	_tmp8_ = _g_object_ref0 ((GtkEventController*) drop_controller);
	gtk_widget_add_controller ((GtkWidget*) _data11_->row, _tmp8_);
	g_signal_connect_data (drag_source, "prepare", (GCallback) ___lambda105__gtk_drag_source_prepare, block11_data_ref (_data11_), (GClosureNotify) block11_data_unref, 0);
	g_signal_connect_data (drag_source, "drag-begin", (GCallback) ___lambda106__gtk_drag_source_drag_begin, block11_data_ref (_data11_), (GClosureNotify) block11_data_unref, 0);
	g_signal_connect_data (drop_controller, "enter", (GCallback) ___lambda107__gtk_drop_controller_motion_enter, block11_data_ref (_data11_), (GClosureNotify) block11_data_unref, 0);
	g_signal_connect_object (drop_controller, "leave", (GCallback) ___lambda108__gtk_drop_controller_motion_leave, self, 0);
	_tmp9_ = self->priv->box;
	gtk_list_box_append (_tmp9_, (GtkWidget*) _data11_->row);
	_g_object_unref0 (drag_source);
	_g_object_unref0 (drop_controller);
	block11_data_unref (_data11_);
	_data11_ = NULL;
}

static void
graphs_style_color_manager_reload_color_boxes (GraphsStyleColorManager* self)
{
	GeeArrayList* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	GtkListBox* _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->colors;
	_tmp1_ = gee_collection_get_is_empty ((GeeCollection*) _tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		GeeArrayList* _tmp3_;
		_tmp3_ = self->priv->colors;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp3_, "#000000");
	}
	_tmp4_ = self->priv->box;
	gtk_list_box_remove_all (_tmp4_);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp5_ = FALSE;
			_tmp5_ = TRUE;
			while (TRUE) {
				GeeArrayList* _tmp7_;
				gint _tmp8_;
				gint _tmp9_;
				if (!_tmp5_) {
					gint _tmp6_;
					_tmp6_ = i;
					i = _tmp6_ + 1;
				}
				_tmp5_ = FALSE;
				_tmp7_ = self->priv->colors;
				_tmp8_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp7_);
				_tmp9_ = _tmp8_;
				if (!(i < _tmp9_)) {
					break;
				}
				graphs_style_color_manager_append_style_color_box (self, i);
			}
		}
	}
}

static void
graphs_style_color_manager_class_init (GraphsStyleColorManagerClass * klass,
                                       gpointer klass_data)
{
	graphs_style_color_manager_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GraphsStyleColorManager_private_offset);
	G_OBJECT_CLASS (klass)->finalize = graphs_style_color_manager_finalize;
	graphs_style_color_manager_signals[GRAPHS_STYLE_COLOR_MANAGER_COLORS_CHANGED_SIGNAL] = g_signal_new ("colors-changed", GRAPHS_TYPE_STYLE_COLOR_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
graphs_style_color_manager_instance_init (GraphsStyleColorManager * self,
                                          gpointer klass)
{
	GeeArrayList* _tmp0_;
	self->priv = graphs_style_color_manager_get_instance_private (self);
	_tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	self->priv->colors = _tmp0_;
}

static void
graphs_style_color_manager_finalize (GObject * obj)
{
	GraphsStyleColorManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRAPHS_TYPE_STYLE_COLOR_MANAGER, GraphsStyleColorManager);
	_g_object_unref0 (self->priv->box);
	_g_object_unref0 (self->priv->colors);
	G_OBJECT_CLASS (graphs_style_color_manager_parent_class)->finalize (obj);
}

static GType
graphs_style_color_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GraphsStyleColorManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) graphs_style_color_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GraphsStyleColorManager), 0, (GInstanceInitFunc) graphs_style_color_manager_instance_init, NULL };
	GType graphs_style_color_manager_type_id;
	graphs_style_color_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "GraphsStyleColorManager", &g_define_type_info, 0);
	GraphsStyleColorManager_private_offset = g_type_add_instance_private (graphs_style_color_manager_type_id, sizeof (GraphsStyleColorManagerPrivate));
	return graphs_style_color_manager_type_id;
}

GType
graphs_style_color_manager_get_type (void)
{
	static volatile gsize graphs_style_color_manager_type_id__once = 0;
	if (g_once_init_enter (&graphs_style_color_manager_type_id__once)) {
		GType graphs_style_color_manager_type_id;
		graphs_style_color_manager_type_id = graphs_style_color_manager_get_type_once ();
		g_once_init_leave (&graphs_style_color_manager_type_id__once, graphs_style_color_manager_type_id);
	}
	return graphs_style_color_manager_type_id__once;
}

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

