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

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

#include "graphs.h"
#include <glib.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <gee.h>
#include <glib-object.h>
#include "config.h"
#include <float.h>
#include <math.h>
#include <adwaita.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_DATA_0_PROPERTY,
	GRAPHS_DATA_CAN_UNDO_PROPERTY,
	GRAPHS_DATA_CAN_REDO_PROPERTY,
	GRAPHS_DATA_CAN_VIEW_BACK_PROPERTY,
	GRAPHS_DATA_CAN_VIEW_FORWARD_PROPERTY,
	GRAPHS_DATA_FILE_PROPERTY,
	GRAPHS_DATA_UNSAVED_PROPERTY,
	GRAPHS_DATA_STYLE_SELECTION_MODEL_PROPERTY,
	GRAPHS_DATA_SELECTED_STYLENAME_PROPERTY,
	GRAPHS_DATA_FIGURE_SETTINGS_PROPERTY,
	GRAPHS_DATA_NUM_PROPERTIES
};
static GParamSpec* graphs_data_properties[GRAPHS_DATA_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _graphs_limits_unref0(var) ((var == NULL) ? NULL : (var = (graphs_limits_unref (var), NULL)))
typedef struct _Block20Data Block20Data;
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _GraphsDataHandleStyleChangeData GraphsDataHandleStyleChangeData;

#define GRAPHS_DATA_TYPE_ITEM_ITERATOR (graphs_data_item_iterator_get_type ())
#define GRAPHS_DATA_ITEM_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GRAPHS_DATA_TYPE_ITEM_ITERATOR, GraphsDataItemIterator))
#define GRAPHS_DATA_ITEM_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GRAPHS_DATA_TYPE_ITEM_ITERATOR, GraphsDataItemIteratorClass))
#define GRAPHS_DATA_IS_ITEM_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GRAPHS_DATA_TYPE_ITEM_ITERATOR))
#define GRAPHS_DATA_IS_ITEM_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GRAPHS_DATA_TYPE_ITEM_ITERATOR))
#define GRAPHS_DATA_ITEM_ITERATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GRAPHS_DATA_TYPE_ITEM_ITERATOR, GraphsDataItemIteratorClass))

typedef struct _GraphsDataItemIterator GraphsDataItemIterator;
typedef struct _GraphsDataItemIteratorClass GraphsDataItemIteratorClass;
typedef struct _GraphsDataOnUseCustomStyleData GraphsDataOnUseCustomStyleData;
typedef struct _GraphsDataOnCustomStyleData GraphsDataOnCustomStyleData;
typedef struct _GraphsDataItemIteratorPrivate GraphsDataItemIteratorPrivate;
enum  {
	GRAPHS_DATA_ITEM_ITERATOR_0_PROPERTY,
	GRAPHS_DATA_ITEM_ITERATOR_READ_ONLY_PROPERTY,
	GRAPHS_DATA_ITEM_ITERATOR_VALID_PROPERTY,
	GRAPHS_DATA_ITEM_ITERATOR_NUM_PROPERTIES
};
static GParamSpec* graphs_data_item_iterator_properties[GRAPHS_DATA_ITEM_ITERATOR_NUM_PROPERTIES];
enum  {
	GRAPHS_DATA_STYLE_CHANGED_SIGNAL,
	GRAPHS_DATA_LOAD_REQUEST_SIGNAL,
	GRAPHS_DATA_ADD_HISTORY_STATE_REQUEST_SIGNAL,
	GRAPHS_DATA_POSITION_CHANGED_SIGNAL,
	GRAPHS_DATA_ITEM_CHANGED_SIGNAL,
	GRAPHS_DATA_ITEM_ADDED_SIGNAL,
	GRAPHS_DATA_ITEM_REMOVED_SIGNAL,
	GRAPHS_DATA_FIGURE_SETTINGS_CHANGED_SIGNAL,
	GRAPHS_DATA_NUM_SIGNALS
};
static guint graphs_data_signals[GRAPHS_DATA_NUM_SIGNALS] = {0};

struct _GraphsDataPrivate {
	gboolean _can_undo;
	gboolean _can_redo;
	gboolean _can_view_back;
	gboolean _can_view_forward;
	GFile* _file;
	gboolean _unsaved;
	GtkSingleSelection* _style_selection_model;
	GraphsFigureSettings* _figure_settings;
	gboolean* _used_positions;
	gint _used_positions_length1;
	gint __used_positions_size_;
	GraphsItem** _items;
	gint _items_length1;
	gint __items_size_;
	gint _n_items;
	gchar** _color_cycle;
	gint _color_cycle_length1;
	gint __color_cycle_size_;
	gchar** _used_colors;
	gint _used_colors_length1;
	gint __used_colors_size_;
	gchar** _errbar_color_cycle;
	gint _errbar_color_cycle_length1;
	gint __errbar_color_cycle_size_;
	gchar** _used_errbar_colors;
	gint _used_errbar_colors_length1;
	gint __used_errbar_colors_size_;
	GSettings* _settings;
	gboolean _notify_selection_changed;
	GeeList* _view_history_states;
	gint _view_history_pos;
};

struct _Block20Data {
	int _ref_count_;
	GraphsData* self;
	GraphsItem* item;
};

struct _GraphsDataHandleStyleChangeData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GraphsData* self;
	gboolean recolor_items;
};

struct _GraphsDataOnUseCustomStyleData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GraphsData* self;
	GraphsFigureSettings* _tmp0_;
	GraphsFigureSettings* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	GtkSingleSelection* _tmp4_;
};

struct _GraphsDataOnCustomStyleData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GraphsData* self;
	GraphsFigureSettings* _tmp0_;
	GraphsFigureSettings* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	GListModel* style_model;
	GtkSingleSelection* _tmp4_;
	GListModel* _tmp5_;
	GListModel* _tmp6_;
	guint i;
	gboolean _tmp7_;
	guint _tmp8_;
	GListModel* _tmp9_;
	GraphsStyle* style;
	GListModel* _tmp10_;
	GObject* _tmp11_;
	GraphsStyle* _tmp12_;
	const gchar* _tmp13_;
	const gchar* _tmp14_;
	GraphsFigureSettings* _tmp15_;
	GraphsFigureSettings* _tmp16_;
	const gchar* _tmp17_;
	const gchar* _tmp18_;
	GtkSingleSelection* _tmp19_;
};

struct _GraphsDataItemIterator {
	GObject parent_instance;
	GraphsDataItemIteratorPrivate * priv;
};

struct _GraphsDataItemIteratorClass {
	GObjectClass parent_class;
};

struct _GraphsDataItemIteratorPrivate {
	GraphsData* _data;
	gint _index;
	gboolean _read_only;
};

static gint GraphsData_private_offset;
static gpointer graphs_data_parent_class = NULL;
static gint GraphsDataItemIterator_private_offset;
static gpointer graphs_data_item_iterator_parent_class = NULL;
static GeeTraversableIface * graphs_data_item_iterator_gee_traversable_parent_iface = NULL;
static GeeIteratorIface * graphs_data_item_iterator_gee_iterator_parent_iface = NULL;
static GListModelInterface * graphs_data_g_list_model_parent_iface = NULL;
static GtkSelectionModelInterface * graphs_data_gtk_selection_model_parent_iface = NULL;
static GeeTraversableIface * graphs_data_gee_traversable_parent_iface = NULL;
static GeeIterableIface * graphs_data_gee_iterable_parent_iface = NULL;

static void graphs_data_run_python_method (GraphsData* self,
                                    const gchar* method);
static GObject* graphs_data_real_get_item (GListModel* base,
                                    guint position);
static GType graphs_data_real_get_item_type (GListModel* base);
static guint graphs_data_real_get_n_items (GListModel* base);
static void graphs_data_clear_selection (GraphsData* self);
static GtkBitset* graphs_data_real_get_selection_in_range (GtkSelectionModel* base,
                                                    guint position,
                                                    guint n_items);
static gboolean graphs_data_real_is_selected (GtkSelectionModel* base,
                                       guint position);
static gboolean graphs_data_real_select_all (GtkSelectionModel* base);
static gboolean graphs_data_real_select_item (GtkSelectionModel* base,
                                       guint position,
                                       gboolean unselect_rest);
static gboolean graphs_data_real_select_range (GtkSelectionModel* base,
                                        guint position,
                                        guint n_items,
                                        gboolean unselect_rest);
static gboolean graphs_data_real_set_selection (GtkSelectionModel* base,
                                         GtkBitset* selection,
                                         GtkBitset* mask);
static gboolean graphs_data_real_unselect_all (GtkSelectionModel* base);
static gboolean graphs_data_real_unselect_item (GtkSelectionModel* base,
                                         guint position);
static gboolean graphs_data_real_unselect_range (GtkSelectionModel* base,
                                          guint position,
                                          guint n_items);
static void graphs_data_set_can_view_back (GraphsData* self,
                                    gboolean value);
static void graphs_data_set_can_view_forward (GraphsData* self,
                                       gboolean value);
static void graphs_data_grow_if_needed (GraphsData* self,
                                 gint grow_size);
static gboolean* _vala_array_dup18 (gboolean* self,
                             gssize length);
static void _graphs_data_connect_to_item (GraphsData* self,
                                   GraphsItem* item);
static Block20Data* block20_data_ref (Block20Data* _data20_);
static void block20_data_unref (void * _userdata_);
static void __lambda17_ (Block20Data* _data20_);
static void ___lambda17__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
static void _graphs_data_on_item_change (GraphsData* self,
                                  GObject* item,
                                  GParamSpec* spec);
static void __graphs_data_on_item_change_g_object_notify (GObject* _sender,
                                                   GParamSpec* pspec,
                                                   gpointer self);
static void _graphs_data_on_item_position_change (GraphsData* self);
static void __graphs_data_on_item_position_change_g_object_notify (GObject* _sender,
                                                            GParamSpec* pspec,
                                                            gpointer self);
static gboolean graphs_data_is_default (GraphsData* self,
                                 const gchar* prop);
static void graphs_data_append_used_color (GraphsData* self,
                                    const gchar* color);
static gboolean _vala_string_array_contains (gchar* * stack,
                                      gssize stack_length,
                                      const gchar* needle);
static void _vala_array_add2 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static void graphs_data_append_used_errbar_color (GraphsData* self,
                                           const gchar* color);
static void _vala_array_add3 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static void _vala_array_add4 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static GraphsItem** _vala_array_dup19 (GraphsItem** self,
                                gssize length);
static void graphs_data_handle_style_change_data_free (gpointer _data);
static void graphs_data_handle_style_change (GraphsData* self,
                                      gboolean recolor_items,
                                      GAsyncReadyCallback _callback_,
                                      gpointer _user_data_);
static void graphs_data_handle_style_change_finish (GraphsData* self,
                                             GAsyncResult* _res_);
static gboolean graphs_data_handle_style_change_co (GraphsDataHandleStyleChangeData* _data_);
static gchar** _vala_array_dup20 (gchar** self,
                           gssize length);
static gchar** _vala_array_dup21 (gchar** self,
                           gssize length);
static GeeIterator* graphs_data_real_iterator (GeeIterable* base);
static GraphsDataItemIterator* graphs_data_item_iterator_new (GraphsData* data);
static GraphsDataItemIterator* graphs_data_item_iterator_construct (GType object_type,
                                                             GraphsData* data);
static GType graphs_data_item_iterator_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static gboolean graphs_data_real_foreach (GeeTraversable* base,
                                   GeeForallFunc f,
                                   gpointer f_target);
static GraphsItem** _vala_array_dup22 (GraphsItem** self,
                                gssize length);
static gboolean* _vala_array_dup23 (gboolean* self,
                             gssize length);
static GraphsLimits** _vala_array_dup24 (GraphsLimits** self,
                                  gssize length);
static void _graphs_data_on_use_custom_style_data_free (gpointer _data);
static void _graphs_data_on_use_custom_style (GraphsData* self,
                                       GAsyncReadyCallback _callback_,
                                       gpointer _user_data_);
static void _graphs_data_on_use_custom_style_finish (GraphsData* self,
                                              GAsyncResult* _res_);
static gboolean _graphs_data_on_use_custom_style_co (GraphsDataOnUseCustomStyleData* _data_);
static void _graphs_data_on_custom_style (GraphsData* self,
                                   GAsyncReadyCallback _callback_,
                                   gpointer _user_data_);
static void _graphs_data_on_custom_style_finish (GraphsData* self,
                                          GAsyncResult* _res_);
static void _graphs_data_on_use_custom_style_ready (GObject* source_object,
                                             GAsyncResult* _res_,
                                             gpointer _user_data_);
static void _graphs_data_on_custom_style_data_free (gpointer _data);
static gboolean _graphs_data_on_custom_style_co (GraphsDataOnCustomStyleData* _data_);
static void _graphs_data_on_custom_style_ready (GObject* source_object,
                                         GAsyncResult* _res_,
                                         gpointer _user_data_);
static void graphs_data_set_style_selection_model (GraphsData* self,
                                            GtkSingleSelection* value);
static void __graphs_data_on_custom_style_g_object_notify (GObject* _sender,
                                                    GParamSpec* pspec,
                                                    gpointer self);
static void __graphs_data_on_use_custom_style_g_object_notify (GObject* _sender,
                                                        GParamSpec* pspec,
                                                        gpointer self);
static void _graphs_data_figure_settings___lambda13_ (GraphsData* self,
                                               GObject* v,
                                               GParamSpec* param);
static void __graphs_data_figure_settings___lambda13__g_object_notify (GObject* _sender,
                                                                GParamSpec* pspec,
                                                                gpointer self);
static void g_cclosure_user_marshal_STRING__OBJECT_FLAGS (GClosure * closure,
                                                   GValue * return_value,
                                                   guint n_param_values,
                                                   const GValue * param_values,
                                                   gpointer invocation_hint,
                                                   gpointer marshal_data);
static void g_cclosure_user_marshal_BOOLEAN__VOID (GClosure * closure,
                                            GValue * return_value,
                                            guint n_param_values,
                                            const GValue * param_values,
                                            gpointer invocation_hint,
                                            gpointer marshal_data);
static void g_cclosure_user_marshal_VOID__UINT_UINT (GClosure * closure,
                                              GValue * return_value,
                                              guint n_param_values,
                                              const GValue * param_values,
                                              gpointer invocation_hint,
                                              gpointer marshal_data);
static void g_cclosure_user_marshal_VOID__OBJECT_STRING (GClosure * closure,
                                                  GValue * return_value,
                                                  guint n_param_values,
                                                  const GValue * param_values,
                                                  gpointer invocation_hint,
                                                  gpointer marshal_data);
static void g_cclosure_user_marshal_VOID__OBJECT_UINT (GClosure * closure,
                                                GValue * return_value,
                                                guint n_param_values,
                                                const GValue * param_values,
                                                gpointer invocation_hint,
                                                gpointer marshal_data);
static gboolean graphs_data_item_iterator_real_foreach (GeeTraversable* base,
                                                 GeeForallFunc f,
                                                 gpointer f_target);
static gboolean graphs_data_item_iterator_real_has_next (GeeIterator* base);
static gboolean graphs_data_item_iterator_real_next (GeeIterator* base);
static GraphsItem* graphs_data_item_iterator_real_get (GeeIterator* base);
static void graphs_data_item_iterator_real_remove (GeeIterator* base);
static void graphs_data_item_iterator_finalize (GObject * obj);
static GType graphs_data_item_iterator_get_type_once (void);
static void _vala_graphs_data_item_iterator_get_property (GObject * object,
                                                   guint property_id,
                                                   GValue * value,
                                                   GParamSpec * pspec);
static GObject * graphs_data_constructor (GType type,
                                   guint n_construct_properties,
                                   GObjectConstructParam * construct_properties);
static void __graphs_data_update_used_positions_g_list_model_items_changed (GListModel* _sender,
                                                                     guint position,
                                                                     guint removed,
                                                                     guint added,
                                                                     gpointer self);
static void _graphs_data___lambda88_ (GraphsData* self,
                               const gchar* stylename);
static void __graphs_data___lambda88__graphs_style_manager_style_changed (GraphsStyleManager* _sender,
                                                                   const gchar* stylename,
                                                                   gpointer self);
static void _graphs_data___lambda89_ (GraphsData* self,
                               const gchar* stylename);
static void __graphs_data___lambda89__graphs_style_manager_style_deleted (GraphsStyleManager* _sender,
                                                                   const gchar* stylename,
                                                                   gpointer self);
static void _graphs_data___lambda90_ (GraphsData* self,
                               const gchar* old_name,
                               const gchar* new_name);
static void __graphs_data___lambda90__graphs_style_manager_style_renamed (GraphsStyleManager* _sender,
                                                                   const gchar* old_name,
                                                                   const gchar* new_name,
                                                                   gpointer self);
static void _graphs_data___lambda91_ (GraphsData* self);
static void __graphs_data___lambda91__g_object_notify (GObject* _sender,
                                                GParamSpec* pspec,
                                                gpointer self);
static void _graphs_data___lambda92_ (GraphsData* self);
static void __graphs_data___lambda92__gtk_selection_model_selection_changed (GtkSelectionModel* _sender,
                                                                      guint position,
                                                                      guint n_items,
                                                                      gpointer self);
static void graphs_data_finalize (GObject * obj);
static GType graphs_data_get_type_once (void);
static void _vala_graphs_data_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec);
static void _vala_graphs_data_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 void _vala_array_move (gpointer array,
                       gsize element_size,
                       gssize src,
                       gssize dest,
                       gssize length);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
graphs_data_get_instance_private (GraphsData* self)
{
	return G_STRUCT_MEMBER_P (self, GraphsData_private_offset);
}

static void
graphs_data_run_python_method (GraphsData* self,
                               const gchar* method)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (method != NULL);
	graphs_python_helper_run_method ((GObject*) self, method);
}

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

static GObject*
graphs_data_real_get_item (GListModel* base,
                           guint position)
{
	GraphsData * self;
	GraphsItem** _tmp0_;
	gint _tmp0__length1;
	GraphsItem* _tmp1_;
	GObject* _tmp2_;
	GObject* result;
	self = (GraphsData*) base;
	_tmp0_ = self->priv->_items;
	_tmp0__length1 = self->priv->_items_length1;
	_tmp1_ = _tmp0_[(gint) position];
	_tmp2_ = _g_object_ref0 ((GObject*) _tmp1_);
	result = _tmp2_;
	return result;
}

static GType
graphs_data_real_get_item_type (GListModel* base)
{
	GraphsData * self;
	GType result;
	self = (GraphsData*) base;
	result = GRAPHS_TYPE_ITEM;
	return result;
}

static guint
graphs_data_real_get_n_items (GListModel* base)
{
	GraphsData * self;
	guint result;
	self = (GraphsData*) base;
	result = (guint) self->priv->_n_items;
	return result;
}

GraphsItem*
graphs_data_last (GraphsData* self)
{
	GraphsItem** _tmp0_;
	gint _tmp0__length1;
	GraphsItem* _tmp1_;
	GraphsItem* _tmp2_;
	GraphsItem* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_items;
	_tmp0__length1 = self->priv->_items_length1;
	_tmp1_ = _tmp0_[self->priv->_n_items - 1];
	_tmp2_ = _g_object_ref0 (_tmp1_);
	result = _tmp2_;
	return result;
}

static void
graphs_data_clear_selection (GraphsData* self)
{
	g_return_if_fail (self != NULL);
	{
		guint index = 0U;
		index = (guint) 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GraphsItem** _tmp2_;
				gint _tmp2__length1;
				GraphsItem* _tmp3_;
				if (!_tmp0_) {
					guint _tmp1_;
					_tmp1_ = index;
					index = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				if (!(index < ((guint) self->priv->_n_items))) {
					break;
				}
				_tmp2_ = self->priv->_items;
				_tmp2__length1 = self->priv->_items_length1;
				_tmp3_ = _tmp2_[index];
				graphs_item_set_selected (_tmp3_, FALSE);
			}
		}
	}
}

static GtkBitset*
graphs_data_real_get_selection_in_range (GtkSelectionModel* base,
                                         guint position,
                                         guint n_items)
{
	GraphsData * self;
	GtkBitset* bitset = NULL;
	GtkBitset* _tmp0_;
	GtkBitset* result;
	self = (GraphsData*) base;
	_tmp0_ = gtk_bitset_new_empty ();
	bitset = _tmp0_;
	{
		guint index = 0U;
		index = position;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				GraphsItem** _tmp3_;
				gint _tmp3__length1;
				GraphsItem* _tmp4_;
				gboolean _tmp5_;
				gboolean _tmp6_;
				if (!_tmp1_) {
					guint _tmp2_;
					_tmp2_ = index;
					index = _tmp2_ + 1;
				}
				_tmp1_ = FALSE;
				if (!(index < (position + n_items))) {
					break;
				}
				_tmp3_ = self->priv->_items;
				_tmp3__length1 = self->priv->_items_length1;
				_tmp4_ = _tmp3_[index];
				_tmp5_ = graphs_item_get_selected (_tmp4_);
				_tmp6_ = _tmp5_;
				if (_tmp6_) {
					GtkBitset* _tmp7_;
					_tmp7_ = bitset;
					gtk_bitset_add (_tmp7_, index);
				}
			}
		}
	}
	result = bitset;
	return result;
}

static gboolean
graphs_data_real_is_selected (GtkSelectionModel* base,
                              guint position)
{
	GraphsData * self;
	GraphsItem** _tmp0_;
	gint _tmp0__length1;
	GraphsItem* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	gboolean result;
	self = (GraphsData*) base;
	_tmp0_ = self->priv->_items;
	_tmp0__length1 = self->priv->_items_length1;
	_tmp1_ = _tmp0_[position];
	_tmp2_ = graphs_item_get_selected (_tmp1_);
	_tmp3_ = _tmp2_;
	result = _tmp3_;
	return result;
}

static gboolean
graphs_data_real_select_all (GtkSelectionModel* base)
{
	GraphsData * self;
	gboolean result;
	self = (GraphsData*) base;
	self->priv->_notify_selection_changed = FALSE;
	{
		guint index = 0U;
		index = (guint) 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GraphsItem** _tmp2_;
				gint _tmp2__length1;
				GraphsItem* _tmp3_;
				if (!_tmp0_) {
					guint _tmp1_;
					_tmp1_ = index;
					index = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				if (!(index < ((guint) self->priv->_n_items))) {
					break;
				}
				_tmp2_ = self->priv->_items;
				_tmp2__length1 = self->priv->_items_length1;
				_tmp3_ = _tmp2_[index];
				graphs_item_set_selected (_tmp3_, TRUE);
			}
		}
	}
	self->priv->_notify_selection_changed = TRUE;
	gtk_selection_model_selection_changed ((GtkSelectionModel*) self, (guint) 0, (guint) self->priv->_n_items);
	result = TRUE;
	return result;
}

static gboolean
graphs_data_real_select_item (GtkSelectionModel* base,
                              guint position,
                              gboolean unselect_rest)
{
	GraphsData * self;
	gboolean result;
	self = (GraphsData*) base;
	if (unselect_rest) {
		GraphsItem** _tmp0_;
		gint _tmp0__length1;
		GraphsItem* _tmp1_;
		self->priv->_notify_selection_changed = FALSE;
		graphs_data_clear_selection (self);
		_tmp0_ = self->priv->_items;
		_tmp0__length1 = self->priv->_items_length1;
		_tmp1_ = _tmp0_[position];
		graphs_item_set_selected (_tmp1_, TRUE);
		self->priv->_notify_selection_changed = TRUE;
		gtk_selection_model_selection_changed ((GtkSelectionModel*) self, (guint) 0, (guint) self->priv->_n_items);
	} else {
		GraphsItem** _tmp2_;
		gint _tmp2__length1;
		GraphsItem* _tmp3_;
		_tmp2_ = self->priv->_items;
		_tmp2__length1 = self->priv->_items_length1;
		_tmp3_ = _tmp2_[position];
		graphs_item_set_selected (_tmp3_, TRUE);
	}
	result = TRUE;
	return result;
}

static gboolean
graphs_data_real_select_range (GtkSelectionModel* base,
                               guint position,
                               guint n_items,
                               gboolean unselect_rest)
{
	GraphsData * self;
	gboolean result;
	self = (GraphsData*) base;
	self->priv->_notify_selection_changed = FALSE;
	if (unselect_rest) {
		graphs_data_clear_selection (self);
		{
			guint index = 0U;
			index = position;
			{
				gboolean _tmp0_ = FALSE;
				_tmp0_ = TRUE;
				while (TRUE) {
					GraphsItem** _tmp2_;
					gint _tmp2__length1;
					GraphsItem* _tmp3_;
					if (!_tmp0_) {
						guint _tmp1_;
						_tmp1_ = index;
						index = _tmp1_ + 1;
					}
					_tmp0_ = FALSE;
					if (!(index < (position + n_items))) {
						break;
					}
					_tmp2_ = self->priv->_items;
					_tmp2__length1 = self->priv->_items_length1;
					_tmp3_ = _tmp2_[index];
					graphs_item_set_selected (_tmp3_, TRUE);
				}
			}
		}
		gtk_selection_model_selection_changed ((GtkSelectionModel*) self, (guint) 0, (guint) self->priv->_n_items);
	} else {
		{
			guint index = 0U;
			index = position;
			{
				gboolean _tmp4_ = FALSE;
				_tmp4_ = TRUE;
				while (TRUE) {
					GraphsItem** _tmp6_;
					gint _tmp6__length1;
					GraphsItem* _tmp7_;
					if (!_tmp4_) {
						guint _tmp5_;
						_tmp5_ = index;
						index = _tmp5_ + 1;
					}
					_tmp4_ = FALSE;
					if (!(index < (position + n_items))) {
						break;
					}
					_tmp6_ = self->priv->_items;
					_tmp6__length1 = self->priv->_items_length1;
					_tmp7_ = _tmp6_[index];
					graphs_item_set_selected (_tmp7_, TRUE);
				}
			}
		}
		gtk_selection_model_selection_changed ((GtkSelectionModel*) self, position, n_items);
	}
	self->priv->_notify_selection_changed = TRUE;
	result = TRUE;
	return result;
}

static gboolean
graphs_data_real_set_selection (GtkSelectionModel* base,
                                GtkBitset* selection,
                                GtkBitset* mask)
{
	GraphsData * self;
	gboolean result;
	self = (GraphsData*) base;
	g_return_val_if_fail (selection != NULL, FALSE);
	g_return_val_if_fail (mask != NULL, FALSE);
	if (gtk_bitset_is_empty (mask)) {
		result = TRUE;
		return result;
	}
	self->priv->_notify_selection_changed = FALSE;
	{
		gint index = 0;
		index = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GraphsItem** _tmp2_;
				gint _tmp2__length1;
				GraphsItem* _tmp3_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = index;
					index = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				if (!(index < self->priv->_n_items)) {
					break;
				}
				if (!gtk_bitset_contains (mask, (guint) index)) {
					continue;
				}
				_tmp2_ = self->priv->_items;
				_tmp2__length1 = self->priv->_items_length1;
				_tmp3_ = _tmp2_[index];
				graphs_item_set_selected (_tmp3_, gtk_bitset_contains (selection, (guint) index));
			}
		}
	}
	self->priv->_notify_selection_changed = TRUE;
	gtk_selection_model_selection_changed ((GtkSelectionModel*) self, (guint) 0, (guint) self->priv->_n_items);
	result = TRUE;
	return result;
}

static gboolean
graphs_data_real_unselect_all (GtkSelectionModel* base)
{
	GraphsData * self;
	gboolean result;
	self = (GraphsData*) base;
	self->priv->_notify_selection_changed = FALSE;
	graphs_data_clear_selection (self);
	self->priv->_notify_selection_changed = TRUE;
	gtk_selection_model_selection_changed ((GtkSelectionModel*) self, (guint) 0, (guint) self->priv->_n_items);
	result = TRUE;
	return result;
}

static gboolean
graphs_data_real_unselect_item (GtkSelectionModel* base,
                                guint position)
{
	GraphsData * self;
	GraphsItem** _tmp0_;
	gint _tmp0__length1;
	GraphsItem* _tmp1_;
	gboolean result;
	self = (GraphsData*) base;
	_tmp0_ = self->priv->_items;
	_tmp0__length1 = self->priv->_items_length1;
	_tmp1_ = _tmp0_[position];
	graphs_item_set_selected (_tmp1_, FALSE);
	result = TRUE;
	return result;
}

static gboolean
graphs_data_real_unselect_range (GtkSelectionModel* base,
                                 guint position,
                                 guint n_items)
{
	GraphsData * self;
	gboolean result;
	self = (GraphsData*) base;
	self->priv->_notify_selection_changed = FALSE;
	{
		guint index = 0U;
		index = position;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GraphsItem** _tmp2_;
				gint _tmp2__length1;
				GraphsItem* _tmp3_;
				if (!_tmp0_) {
					guint _tmp1_;
					_tmp1_ = index;
					index = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				if (!(index < (position + n_items))) {
					break;
				}
				_tmp2_ = self->priv->_items;
				_tmp2__length1 = self->priv->_items_length1;
				_tmp3_ = _tmp2_[index];
				graphs_item_set_selected (_tmp3_, FALSE);
			}
		}
	}
	self->priv->_notify_selection_changed = TRUE;
	gtk_selection_model_selection_changed ((GtkSelectionModel*) self, position, n_items);
	result = TRUE;
	return result;
}

void
graphs_data_clear (GraphsData* self)
{
	guint n_items = 0U;
	GSettings* _tmp3_;
	GraphsFigureSettings* _tmp4_;
	GraphsFigureSettings* _tmp5_;
	GeeList* _tmp6_;
	GeeList* _tmp7_;
	GraphsFigureSettings* _tmp8_;
	GraphsFigureSettings* _tmp9_;
	GraphsLimits* _tmp10_;
	GraphsLimits* _tmp11_;
	g_return_if_fail (self != NULL);
	n_items = g_list_model_get_n_items ((GListModel*) self);
	{
		gint index = 0;
		index = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GraphsItem** _tmp2_;
				gint _tmp2__length1;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = index;
					index = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				if (!(((guint) index) < n_items)) {
					break;
				}
				_tmp2_ = self->priv->_items;
				_tmp2__length1 = self->priv->_items_length1;
				_g_object_unref0 (_tmp2_[index]);
				_tmp2_[index] = NULL;
			}
		}
	}
	self->priv->_n_items = 0;
	g_list_model_items_changed ((GListModel*) self, (guint) 0, n_items, (guint) 0);
	graphs_data_set_can_undo (self, FALSE);
	graphs_data_set_can_redo (self, FALSE);
	graphs_data_set_can_view_back (self, FALSE);
	graphs_data_set_can_view_forward (self, FALSE);
	_tmp3_ = self->priv->_settings;
	_tmp4_ = graphs_figure_settings_new (_tmp3_);
	_tmp5_ = _tmp4_;
	graphs_data_set_figure_settings (self, _tmp5_);
	_g_object_unref0 (_tmp5_);
	_tmp6_ = self->priv->_view_history_states;
	gee_collection_clear ((GeeCollection*) _tmp6_);
	_tmp7_ = self->priv->_view_history_states;
	_tmp8_ = graphs_data_get_figure_settings (self);
	_tmp9_ = _tmp8_;
	_tmp10_ = graphs_figure_settings_get_limits (_tmp9_);
	_tmp11_ = _tmp10_;
	gee_collection_add ((GeeCollection*) _tmp7_, _tmp11_);
	_graphs_limits_unref0 (_tmp11_);
	graphs_data_run_python_method (self, "_init_history_states");
	graphs_data_set_file (self, NULL);
	graphs_data_set_unsaved (self, FALSE);
	g_object_notify ((GObject*) self, "unsaved");
}

static void
graphs_data_grow_if_needed (GraphsData* self,
                            gint grow_size)
{
	gint minimum_size = 0;
	GraphsItem** _tmp0_;
	gint _tmp0__length1;
	g_return_if_fail (self != NULL);
	minimum_size = self->priv->_n_items + grow_size;
	_tmp0_ = self->priv->_items;
	_tmp0__length1 = self->priv->_items_length1;
	if (minimum_size > _tmp0__length1) {
		gint _tmp1_ = 0;
		GraphsItem** _tmp2_;
		gint _tmp2__length1;
		gint _tmp4_;
		_tmp2_ = self->priv->_items;
		_tmp2__length1 = self->priv->_items_length1;
		if (grow_size > _tmp2__length1) {
			_tmp1_ = minimum_size;
		} else {
			GraphsItem** _tmp3_;
			gint _tmp3__length1;
			_tmp3_ = self->priv->_items;
			_tmp3__length1 = self->priv->_items_length1;
			_tmp1_ = 2 * _tmp3__length1;
		}
		_tmp4_ = _tmp1_;
		self->priv->_items = g_renew (GraphsItem*, self->priv->_items, _tmp1_);
		(_tmp4_ > self->priv->_items_length1) ? memset (self->priv->_items + self->priv->_items_length1, 0, sizeof (GraphsItem*) * (_tmp4_ - self->priv->_items_length1)) : NULL;
		self->priv->_items_length1 = _tmp4_;
		self->priv->__items_size_ = _tmp4_;
	}
}

static gboolean*
_vala_array_dup18 (gboolean* self,
                   gssize length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (gboolean));
	}
	return NULL;
}

void
_graphs_data_update_used_positions (GraphsData* self)
{
	gboolean* used_positions = NULL;
	gboolean* _tmp1_;
	gint used_positions_length1;
	gint _used_positions_size_;
	GraphsItem* item = NULL;
	gboolean* _tmp23_;
	gint _tmp23__length1;
	gboolean* _tmp24_;
	gint _tmp24__length1;
	g_return_if_fail (self != NULL);
	if (self->priv->_n_items == 0) {
		gboolean* _tmp0_;
		_tmp0_ = g_new0 (gboolean, 4);
		_tmp0_[0] = TRUE;
		_tmp0_[1] = FALSE;
		_tmp0_[2] = TRUE;
		_tmp0_[3] = FALSE;
		self->priv->_used_positions = (g_free (self->priv->_used_positions), NULL);
		self->priv->_used_positions = _tmp0_;
		self->priv->_used_positions_length1 = 4;
		self->priv->__used_positions_size_ = self->priv->_used_positions_length1;
		return;
	}
	_tmp1_ = g_new0 (gboolean, 4);
	_tmp1_[0] = FALSE;
	_tmp1_[1] = FALSE;
	_tmp1_[2] = FALSE;
	_tmp1_[3] = FALSE;
	used_positions = _tmp1_;
	used_positions_length1 = 4;
	_used_positions_size_ = used_positions_length1;
	{
		guint index = 0U;
		index = (guint) 0;
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = TRUE;
			while (TRUE) {
				GraphsItem** _tmp4_;
				gint _tmp4__length1;
				GraphsItem* _tmp5_;
				GraphsItem* _tmp6_;
				gboolean _tmp7_ = FALSE;
				GraphsFigureSettings* _tmp8_;
				GraphsFigureSettings* _tmp9_;
				gboolean _tmp10_;
				gboolean _tmp11_;
				gboolean* _tmp15_;
				gint _tmp15__length1;
				GraphsItem* _tmp16_;
				GraphsXPosition _tmp17_;
				GraphsXPosition _tmp18_;
				gboolean* _tmp19_;
				gint _tmp19__length1;
				GraphsItem* _tmp20_;
				GraphsYPosition _tmp21_;
				GraphsYPosition _tmp22_;
				if (!_tmp2_) {
					guint _tmp3_;
					_tmp3_ = index;
					index = _tmp3_ + 1;
				}
				_tmp2_ = FALSE;
				if (!(index < ((guint) self->priv->_n_items))) {
					break;
				}
				_tmp4_ = self->priv->_items;
				_tmp4__length1 = self->priv->_items_length1;
				_tmp5_ = _tmp4_[index];
				_tmp6_ = _g_object_ref0 (_tmp5_);
				_g_object_unref0 (item);
				item = _tmp6_;
				_tmp8_ = graphs_data_get_figure_settings (self);
				_tmp9_ = _tmp8_;
				_tmp10_ = graphs_figure_settings_get_hide_unselected (_tmp9_);
				_tmp11_ = _tmp10_;
				if (_tmp11_) {
					GraphsItem* _tmp12_;
					gboolean _tmp13_;
					gboolean _tmp14_;
					_tmp12_ = item;
					_tmp13_ = graphs_item_get_selected (_tmp12_);
					_tmp14_ = _tmp13_;
					_tmp7_ = !_tmp14_;
				} else {
					_tmp7_ = FALSE;
				}
				if (_tmp7_) {
					continue;
				}
				_tmp15_ = used_positions;
				_tmp15__length1 = used_positions_length1;
				_tmp16_ = item;
				_tmp17_ = graphs_item_get_xposition (_tmp16_);
				_tmp18_ = _tmp17_;
				_tmp15_[_tmp18_] = TRUE;
				_tmp19_ = used_positions;
				_tmp19__length1 = used_positions_length1;
				_tmp20_ = item;
				_tmp21_ = graphs_item_get_yposition (_tmp20_);
				_tmp22_ = _tmp21_;
				_tmp19_[_tmp22_ + 2] = TRUE;
			}
		}
	}
	_tmp23_ = used_positions;
	_tmp23__length1 = used_positions_length1;
	_tmp24_ = (_tmp23_ != NULL) ? _vala_array_dup18 (_tmp23_, _tmp23__length1) : _tmp23_;
	_tmp24__length1 = _tmp23__length1;
	self->priv->_used_positions = (g_free (self->priv->_used_positions), NULL);
	self->priv->_used_positions = _tmp24_;
	self->priv->_used_positions_length1 = _tmp24__length1;
	self->priv->__used_positions_size_ = self->priv->_used_positions_length1;
	_g_object_unref0 (item);
	used_positions = (g_free (used_positions), NULL);
}

static Block20Data*
block20_data_ref (Block20Data* _data20_)
{
	g_atomic_int_inc (&_data20_->_ref_count_);
	return _data20_;
}

static void
block20_data_unref (void * _userdata_)
{
	Block20Data* _data20_;
	_data20_ = (Block20Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data20_->_ref_count_)) {
		GraphsData* self;
		self = _data20_->self;
		_g_object_unref0 (_data20_->item);
		_g_object_unref0 (self);
		g_slice_free (Block20Data, _data20_);
	}
}

static void
__lambda17_ (Block20Data* _data20_)
{
	GraphsData* self;
	self = _data20_->self;
	if (self->priv->_notify_selection_changed) {
		gtk_selection_model_selection_changed ((GtkSelectionModel*) self, graphs_data_index (self, _data20_->item), (guint) 1);
	}
}

static void
___lambda17__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda17_ (self);
}

static void
__graphs_data_on_item_change_g_object_notify (GObject* _sender,
                                              GParamSpec* pspec,
                                              gpointer self)
{
	_graphs_data_on_item_change ((GraphsData*) self, _sender, pspec);
}

static void
__graphs_data_on_item_position_change_g_object_notify (GObject* _sender,
                                                       GParamSpec* pspec,
                                                       gpointer self)
{
	_graphs_data_on_item_position_change ((GraphsData*) self);
}

static void
_graphs_data_connect_to_item (GraphsData* self,
                              GraphsItem* item)
{
	Block20Data* _data20_;
	GraphsItem* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (item != NULL);
	_data20_ = g_slice_new0 (Block20Data);
	_data20_->_ref_count_ = 1;
	_data20_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (item);
	_g_object_unref0 (_data20_->item);
	_data20_->item = _tmp0_;
	g_signal_connect_data ((GObject*) _data20_->item, "notify::selected", (GCallback) ___lambda17__g_object_notify, block20_data_ref (_data20_), (GClosureNotify) block20_data_unref, 0);
	g_signal_connect_object ((GObject*) _data20_->item, "notify", (GCallback) __graphs_data_on_item_change_g_object_notify, self, 0);
	g_signal_connect_object ((GObject*) _data20_->item, "notify::xposition", (GCallback) __graphs_data_on_item_position_change_g_object_notify, self, 0);
	g_signal_connect_object ((GObject*) _data20_->item, "notify::yposition", (GCallback) __graphs_data_on_item_position_change_g_object_notify, self, 0);
	block20_data_unref (_data20_);
	_data20_ = NULL;
}

void
_graphs_data_add_item (GraphsData* self,
                       GraphsItem* item)
{
	GraphsItem** _tmp0_;
	gint _tmp0__length1;
	GraphsItem* _tmp1_;
	gint _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (item != NULL);
	_graphs_data_connect_to_item (self, item);
	graphs_data_grow_if_needed (self, 1);
	_tmp0_ = self->priv->_items;
	_tmp0__length1 = self->priv->_items_length1;
	_tmp1_ = _g_object_ref0 (item);
	_g_object_unref0 (_tmp0_[self->priv->_n_items]);
	_tmp0_[self->priv->_n_items] = _tmp1_;
	_tmp2_ = self->priv->_n_items;
	self->priv->_n_items = _tmp2_ + 1;
	g_list_model_items_changed ((GListModel*) self, (guint) _tmp2_, (guint) 0, (guint) 1);
}

void
_graphs_data_insert_item (GraphsData* self,
                          GraphsItem* item,
                          gint index)
{
	GraphsItem** _tmp0_;
	gint _tmp0__length1;
	GraphsItem* _tmp1_;
	gint _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (item != NULL);
	_graphs_data_connect_to_item (self, item);
	graphs_data_grow_if_needed (self, 1);
	_vala_array_move (self->priv->_items, sizeof (GraphsItem*), index, index + 1, self->priv->_n_items - index);
	_tmp0_ = self->priv->_items;
	_tmp0__length1 = self->priv->_items_length1;
	_tmp1_ = _g_object_ref0 (item);
	_g_object_unref0 (_tmp0_[index]);
	_tmp0_[index] = _tmp1_;
	_tmp2_ = self->priv->_n_items;
	self->priv->_n_items = _tmp2_ + 1;
	g_list_model_items_changed ((GListModel*) self, (guint) index, (guint) 0, (guint) 1);
}

void
_graphs_data_remove_item (GraphsData* self,
                          guint index)
{
	GraphsItem** _tmp0_;
	gint _tmp0__length1;
	gint _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_items;
	_tmp0__length1 = self->priv->_items_length1;
	_g_object_unref0 (_tmp0_[index]);
	_tmp0_[index] = NULL;
	_vala_array_move (self->priv->_items, sizeof (GraphsItem*), ((gint) index) + 1, (gint) index, (gint) ((self->priv->_n_items - index) - 1));
	_tmp1_ = self->priv->_n_items;
	self->priv->_n_items = _tmp1_ - 1;
	g_list_model_items_changed ((GListModel*) self, index, (guint) 1, (guint) 0);
}

static gboolean
graphs_data_is_default (GraphsData* self,
                        const gchar* prop)
{
	gchar* figure_settings_value = NULL;
	GraphsFigureSettings* _tmp0_;
	GraphsFigureSettings* _tmp1_;
	gchar* _tmp2_ = NULL;
	GSettings* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gboolean _tmp6_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (prop != NULL, FALSE);
	_tmp0_ = graphs_data_get_figure_settings (self);
	_tmp1_ = _tmp0_;
	g_object_get ((GObject*) _tmp1_, prop, &_tmp2_, NULL);
	_g_free0 (figure_settings_value);
	figure_settings_value = _tmp2_;
	_tmp3_ = self->priv->_settings;
	_tmp4_ = g_settings_get_string (_tmp3_, prop);
	_tmp5_ = _tmp4_;
	_tmp6_ = g_strcmp0 (figure_settings_value, _tmp5_) == 0;
	_g_free0 (_tmp5_);
	result = _tmp6_;
	_g_free0 (figure_settings_value);
	return result;
}

static gboolean
_vala_string_array_contains (gchar* * stack,
                             gssize stack_length,
                             const gchar* needle)
{
	gssize i;
	for (i = 0; i < stack_length; i++) {
		if (g_strcmp0 (stack[i], needle) == 0) {
			return TRUE;
		}
	}
	return FALSE;
}

static void
_vala_array_add2 (gchar** * array,
                  gint* length,
                  gint* size,
                  gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
graphs_data_append_used_color (GraphsData* self,
                               const gchar* color)
{
	gchar** _tmp0_;
	gint _tmp0__length1;
	gchar** _tmp1_;
	gint _tmp1__length1;
	gchar* _tmp2_;
	gchar** _tmp3_;
	gint _tmp3__length1;
	gchar** _tmp4_;
	gint _tmp4__length1;
	g_return_if_fail (self != NULL);
	g_return_if_fail (color != NULL);
	_tmp0_ = self->priv->_used_colors;
	_tmp0__length1 = self->priv->_used_colors_length1;
	if (_vala_string_array_contains (_tmp0_, _tmp0__length1, color)) {
		return;
	}
	_tmp1_ = self->priv->_color_cycle;
	_tmp1__length1 = self->priv->_color_cycle_length1;
	if (!_vala_string_array_contains (_tmp1_, _tmp1__length1, color)) {
		return;
	}
	_tmp2_ = g_strdup (color);
	_vala_array_add2 (&self->priv->_used_colors, &self->priv->_used_colors_length1, &self->priv->__used_colors_size_, _tmp2_);
	_tmp3_ = self->priv->_used_colors;
	_tmp3__length1 = self->priv->_used_colors_length1;
	_tmp4_ = self->priv->_color_cycle;
	_tmp4__length1 = self->priv->_color_cycle_length1;
	if (_tmp3__length1 == _tmp4__length1) {
		gchar** _tmp5_;
		_tmp5_ = g_new0 (gchar*, 0 + 1);
		self->priv->_used_colors = (_vala_array_free (self->priv->_used_colors, self->priv->_used_colors_length1, (GDestroyNotify) g_free), NULL);
		self->priv->_used_colors = _tmp5_;
		self->priv->_used_colors_length1 = 0;
		self->priv->__used_colors_size_ = self->priv->_used_colors_length1;
	}
}

static void
_vala_array_add3 (gchar** * array,
                  gint* length,
                  gint* size,
                  gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
graphs_data_append_used_errbar_color (GraphsData* self,
                                      const gchar* color)
{
	gchar** _tmp0_;
	gint _tmp0__length1;
	gchar** _tmp1_;
	gint _tmp1__length1;
	gchar* _tmp2_;
	gchar** _tmp3_;
	gint _tmp3__length1;
	gchar** _tmp4_;
	gint _tmp4__length1;
	g_return_if_fail (self != NULL);
	g_return_if_fail (color != NULL);
	_tmp0_ = self->priv->_used_errbar_colors;
	_tmp0__length1 = self->priv->_used_errbar_colors_length1;
	if (_vala_string_array_contains (_tmp0_, _tmp0__length1, color)) {
		return;
	}
	_tmp1_ = self->priv->_errbar_color_cycle;
	_tmp1__length1 = self->priv->_errbar_color_cycle_length1;
	if (!_vala_string_array_contains (_tmp1_, _tmp1__length1, color)) {
		return;
	}
	_tmp2_ = g_strdup (color);
	_vala_array_add3 (&self->priv->_used_errbar_colors, &self->priv->_used_errbar_colors_length1, &self->priv->__used_errbar_colors_size_, _tmp2_);
	_tmp3_ = self->priv->_used_errbar_colors;
	_tmp3__length1 = self->priv->_used_errbar_colors_length1;
	_tmp4_ = self->priv->_errbar_color_cycle;
	_tmp4__length1 = self->priv->_errbar_color_cycle_length1;
	if (_tmp3__length1 == _tmp4__length1) {
		gchar** _tmp5_;
		_tmp5_ = g_new0 (gchar*, 0 + 1);
		self->priv->_used_errbar_colors = (_vala_array_free (self->priv->_used_errbar_colors, self->priv->_used_errbar_colors_length1, (GDestroyNotify) g_free), NULL);
		self->priv->_used_errbar_colors = _tmp5_;
		self->priv->_used_errbar_colors_length1 = 0;
		self->priv->__used_errbar_colors_size_ = self->priv->_used_errbar_colors_length1;
	}
}

/**
         * Add items to be managed.
         *
         * Respects settings in regards to handling duplicate names.
         * New Items with a x- or y-label change the figures current labels if
         * they are still the default. If they are already modified and do not
         * match the items label, they get moved to another axis.
         */
static void
_vala_array_add4 (gchar** * array,
                  gint* length,
                  gint* size,
                  gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

void
graphs_data_add_items (GraphsData* self,
                       GraphsItem** items,
                       gint items_length1)
{
	gchar** _tmp0_;
	gchar** _tmp1_;
	gchar** used_names = NULL;
	gint _tmp21_ = 0;
	gchar** _tmp22_;
	gint used_names_length1;
	gint _used_names_size_;
	guint prev_size = 0U;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_new0 (gchar*, 0 + 1);
	self->priv->_used_colors = (_vala_array_free (self->priv->_used_colors, self->priv->_used_colors_length1, (GDestroyNotify) g_free), NULL);
	self->priv->_used_colors = _tmp0_;
	self->priv->_used_colors_length1 = 0;
	self->priv->__used_colors_size_ = self->priv->_used_colors_length1;
	_tmp1_ = g_new0 (gchar*, 0 + 1);
	self->priv->_used_errbar_colors = (_vala_array_free (self->priv->_used_errbar_colors, self->priv->_used_errbar_colors_length1, (GDestroyNotify) g_free), NULL);
	self->priv->_used_errbar_colors = _tmp1_;
	self->priv->_used_errbar_colors_length1 = 0;
	self->priv->__used_errbar_colors_size_ = self->priv->_used_errbar_colors_length1;
	{
		GeeIterator* _item_it = NULL;
		GeeIterator* _tmp2_;
		_tmp2_ = gee_iterable_iterator ((GeeIterable*) self);
		_item_it = _tmp2_;
		while (TRUE) {
			GeeIterator* _tmp3_;
			GraphsItem* item = NULL;
			GeeIterator* _tmp4_;
			gpointer _tmp5_;
			GraphsItem* _tmp6_;
			const gchar* _tmp7_;
			const gchar* _tmp8_;
			gchar** _tmp9_;
			gint _tmp9__length1;
			GraphsItem* _tmp13_;
			_tmp3_ = _item_it;
			if (!gee_iterator_next (_tmp3_)) {
				break;
			}
			_tmp4_ = _item_it;
			_tmp5_ = gee_iterator_get (_tmp4_);
			item = (GraphsItem*) _tmp5_;
			_tmp6_ = item;
			_tmp7_ = graphs_item_get_color (_tmp6_);
			_tmp8_ = _tmp7_;
			_tmp9_ = self->priv->_color_cycle;
			_tmp9__length1 = self->priv->_color_cycle_length1;
			if (_vala_string_array_contains (_tmp9_, _tmp9__length1, _tmp8_)) {
				GraphsItem* _tmp10_;
				const gchar* _tmp11_;
				const gchar* _tmp12_;
				_tmp10_ = item;
				_tmp11_ = graphs_item_get_color (_tmp10_);
				_tmp12_ = _tmp11_;
				graphs_data_append_used_color (self, _tmp12_);
			}
			_tmp13_ = item;
			if (GRAPHS_IS_DATA_ITEM (_tmp13_)) {
				gchar* errcolor = NULL;
				GraphsItem* _tmp14_;
				const gchar* _tmp15_;
				const gchar* _tmp16_;
				gchar* _tmp17_;
				const gchar* _tmp18_;
				gchar** _tmp19_;
				gint _tmp19__length1;
				_tmp14_ = item;
				_tmp15_ = graphs_data_item_get_errcolor (G_TYPE_CHECK_INSTANCE_CAST (_tmp14_, GRAPHS_TYPE_DATA_ITEM, GraphsDataItem));
				_tmp16_ = _tmp15_;
				_tmp17_ = g_strdup (_tmp16_);
				errcolor = _tmp17_;
				_tmp18_ = errcolor;
				_tmp19_ = self->priv->_errbar_color_cycle;
				_tmp19__length1 = self->priv->_errbar_color_cycle_length1;
				if (_vala_string_array_contains (_tmp19_, _tmp19__length1, _tmp18_)) {
					const gchar* _tmp20_;
					_tmp20_ = errcolor;
					graphs_data_append_used_errbar_color (self, _tmp20_);
				}
				_g_free0 (errcolor);
			}
			_g_object_unref0 (item);
		}
		_g_object_unref0 (_item_it);
	}
	_tmp22_ = graphs_data_get_names (self, &_tmp21_);
	used_names = _tmp22_;
	used_names_length1 = _tmp21_;
	_used_names_size_ = used_names_length1;
	prev_size = (guint) self->priv->_n_items;
	graphs_data_grow_if_needed (self, items_length1);
	{
		GraphsItem** item_collection = NULL;
		gint item_collection_length1 = 0;
		gint _item_collection_size_ = 0;
		gint item_it = 0;
		item_collection = items;
		item_collection_length1 = items_length1;
		for (item_it = 0; item_it < item_collection_length1; item_it = item_it + 1) {
			GraphsItem* _tmp23_;
			GraphsItem* item = NULL;
			_tmp23_ = _g_object_ref0 (item_collection[item_it]);
			item = _tmp23_;
			{
				GraphsItem* _tmp24_;
				GraphsItem* _tmp25_;
				const gchar* _tmp26_;
				const gchar* _tmp27_;
				gchar** _tmp28_;
				gint _tmp28__length1;
				gchar* _tmp29_;
				gchar* _tmp30_;
				GraphsItem* _tmp31_;
				const gchar* _tmp32_;
				const gchar* _tmp33_;
				gchar* _tmp34_;
				GraphsItem* _tmp35_;
				const gchar* _tmp36_;
				const gchar* _tmp37_;
				GraphsItem* _tmp45_;
				GraphsItem* _tmp58_;
				const gchar* _tmp59_;
				const gchar* _tmp60_;
				GraphsItem* _tmp93_;
				const gchar* _tmp94_;
				const gchar* _tmp95_;
				GraphsItem* _tmp128_;
				GraphsItem** _tmp129_;
				gint _tmp129__length1;
				gint _tmp130_;
				GraphsItem* _tmp131_;
				GraphsItem* _tmp132_;
				GraphsItem* _tmp133_;
				_tmp24_ = item;
				_tmp25_ = item;
				_tmp26_ = graphs_item_get_name (_tmp25_);
				_tmp27_ = _tmp26_;
				_tmp28_ = used_names;
				_tmp28__length1 = used_names_length1;
				_tmp29_ = graphs_tools_get_duplicate_string (_tmp27_, _tmp28_, (gint) _tmp28__length1);
				_tmp30_ = _tmp29_;
				graphs_item_set_name (_tmp24_, _tmp30_);
				_g_free0 (_tmp30_);
				_tmp31_ = item;
				_tmp32_ = graphs_item_get_name (_tmp31_);
				_tmp33_ = _tmp32_;
				_tmp34_ = g_strdup (_tmp33_);
				_vala_array_add4 (&used_names, &used_names_length1, &_used_names_size_, _tmp34_);
				_tmp35_ = item;
				_tmp36_ = graphs_item_get_color (_tmp35_);
				_tmp37_ = _tmp36_;
				if (g_strcmp0 (_tmp37_, "") == 0) {
					gchar** _tmp38_;
					gint _tmp38__length1;
					_tmp38_ = self->priv->_color_cycle;
					_tmp38__length1 = self->priv->_color_cycle_length1;
					{
						gchar** color_collection = NULL;
						gint color_collection_length1 = 0;
						gint _color_collection_size_ = 0;
						gint color_it = 0;
						color_collection = _tmp38_;
						color_collection_length1 = _tmp38__length1;
						for (color_it = 0; color_it < color_collection_length1; color_it = color_it + 1) {
							gchar* _tmp39_;
							gchar* color = NULL;
							_tmp39_ = g_strdup (color_collection[color_it]);
							color = _tmp39_;
							{
								const gchar* _tmp40_;
								gchar** _tmp41_;
								gint _tmp41__length1;
								_tmp40_ = color;
								_tmp41_ = self->priv->_used_colors;
								_tmp41__length1 = self->priv->_used_colors_length1;
								if (!_vala_string_array_contains (_tmp41_, _tmp41__length1, _tmp40_)) {
									const gchar* _tmp42_;
									GraphsItem* _tmp43_;
									const gchar* _tmp44_;
									_tmp42_ = color;
									graphs_data_append_used_color (self, _tmp42_);
									_tmp43_ = item;
									_tmp44_ = color;
									graphs_item_set_color (_tmp43_, _tmp44_);
									_g_free0 (color);
									break;
								}
								_g_free0 (color);
							}
						}
					}
				}
				_tmp45_ = item;
				if (GRAPHS_IS_DATA_ITEM (_tmp45_)) {
					gchar* errcolor = NULL;
					GraphsItem* _tmp46_;
					const gchar* _tmp47_;
					const gchar* _tmp48_;
					gchar* _tmp49_;
					const gchar* _tmp50_;
					_tmp46_ = item;
					_tmp47_ = graphs_data_item_get_errcolor (G_TYPE_CHECK_INSTANCE_CAST (_tmp46_, GRAPHS_TYPE_DATA_ITEM, GraphsDataItem));
					_tmp48_ = _tmp47_;
					_tmp49_ = g_strdup (_tmp48_);
					errcolor = _tmp49_;
					_tmp50_ = errcolor;
					if (g_strcmp0 (_tmp50_, "") == 0) {
						gchar** _tmp51_;
						gint _tmp51__length1;
						_tmp51_ = self->priv->_errbar_color_cycle;
						_tmp51__length1 = self->priv->_errbar_color_cycle_length1;
						{
							gchar** color_collection = NULL;
							gint color_collection_length1 = 0;
							gint _color_collection_size_ = 0;
							gint color_it = 0;
							color_collection = _tmp51_;
							color_collection_length1 = _tmp51__length1;
							for (color_it = 0; color_it < color_collection_length1; color_it = color_it + 1) {
								gchar* _tmp52_;
								gchar* color = NULL;
								_tmp52_ = g_strdup (color_collection[color_it]);
								color = _tmp52_;
								{
									const gchar* _tmp53_;
									gchar** _tmp54_;
									gint _tmp54__length1;
									_tmp53_ = color;
									_tmp54_ = self->priv->_used_errbar_colors;
									_tmp54__length1 = self->priv->_used_errbar_colors_length1;
									if (!_vala_string_array_contains (_tmp54_, _tmp54__length1, _tmp53_)) {
										const gchar* _tmp55_;
										GraphsItem* _tmp56_;
										const gchar* _tmp57_;
										_tmp55_ = color;
										graphs_data_append_used_errbar_color (self, _tmp55_);
										_tmp56_ = item;
										_tmp57_ = color;
										g_object_set ((GObject*) _tmp56_, "errcolor", _tmp57_, NULL);
										_g_free0 (color);
										break;
									}
									_g_free0 (color);
								}
							}
						}
					}
					_g_free0 (errcolor);
				}
				_tmp58_ = item;
				_tmp59_ = graphs_item_get_xlabel (_tmp58_);
				_tmp60_ = _tmp59_;
				if (g_strcmp0 (_tmp60_, "") != 0) {
					GraphsXPosition original_position = 0;
					GraphsItem* _tmp61_;
					GraphsXPosition _tmp62_;
					GraphsXPosition _tmp63_;
					GraphsItem* _tmp77_;
					GraphsXPosition _tmp78_;
					GraphsXPosition _tmp79_;
					_tmp61_ = item;
					_tmp62_ = graphs_item_get_xposition (_tmp61_);
					_tmp63_ = _tmp62_;
					original_position = _tmp63_;
					if (original_position == GRAPHS_XPOSITION_BOTTOM) {
						if (graphs_data_is_default (self, "bottom-label") | graphs_data_is_empty (self)) {
							GraphsFigureSettings* _tmp64_;
							GraphsFigureSettings* _tmp65_;
							GraphsItem* _tmp66_;
							const gchar* _tmp67_;
							const gchar* _tmp68_;
							_tmp64_ = graphs_data_get_figure_settings (self);
							_tmp65_ = _tmp64_;
							_tmp66_ = item;
							_tmp67_ = graphs_item_get_xlabel (_tmp66_);
							_tmp68_ = _tmp67_;
							graphs_figure_settings_set_bottom_label (_tmp65_, _tmp68_);
						} else {
							GraphsItem* _tmp69_;
							const gchar* _tmp70_;
							const gchar* _tmp71_;
							GraphsFigureSettings* _tmp72_;
							GraphsFigureSettings* _tmp73_;
							const gchar* _tmp74_;
							const gchar* _tmp75_;
							_tmp69_ = item;
							_tmp70_ = graphs_item_get_xlabel (_tmp69_);
							_tmp71_ = _tmp70_;
							_tmp72_ = graphs_data_get_figure_settings (self);
							_tmp73_ = _tmp72_;
							_tmp74_ = graphs_figure_settings_get_bottom_label (_tmp73_);
							_tmp75_ = _tmp74_;
							if (g_strcmp0 (_tmp71_, _tmp75_) != 0) {
								GraphsItem* _tmp76_;
								_tmp76_ = item;
								graphs_item_set_xposition (_tmp76_, GRAPHS_XPOSITION_TOP);
							}
						}
					}
					_tmp77_ = item;
					_tmp78_ = graphs_item_get_xposition (_tmp77_);
					_tmp79_ = _tmp78_;
					if (_tmp79_ == GRAPHS_XPOSITION_TOP) {
						if (graphs_data_is_default (self, "top-label")) {
							GraphsFigureSettings* _tmp80_;
							GraphsFigureSettings* _tmp81_;
							GraphsItem* _tmp82_;
							const gchar* _tmp83_;
							const gchar* _tmp84_;
							_tmp80_ = graphs_data_get_figure_settings (self);
							_tmp81_ = _tmp80_;
							_tmp82_ = item;
							_tmp83_ = graphs_item_get_xlabel (_tmp82_);
							_tmp84_ = _tmp83_;
							graphs_figure_settings_set_top_label (_tmp81_, _tmp84_);
						} else {
							GraphsItem* _tmp85_;
							const gchar* _tmp86_;
							const gchar* _tmp87_;
							GraphsFigureSettings* _tmp88_;
							GraphsFigureSettings* _tmp89_;
							const gchar* _tmp90_;
							const gchar* _tmp91_;
							_tmp85_ = item;
							_tmp86_ = graphs_item_get_xlabel (_tmp85_);
							_tmp87_ = _tmp86_;
							_tmp88_ = graphs_data_get_figure_settings (self);
							_tmp89_ = _tmp88_;
							_tmp90_ = graphs_figure_settings_get_top_label (_tmp89_);
							_tmp91_ = _tmp90_;
							if (g_strcmp0 (_tmp87_, _tmp91_) != 0) {
								GraphsItem* _tmp92_;
								_tmp92_ = item;
								graphs_item_set_xposition (_tmp92_, original_position);
							}
						}
					}
				}
				_tmp93_ = item;
				_tmp94_ = graphs_item_get_ylabel (_tmp93_);
				_tmp95_ = _tmp94_;
				if (g_strcmp0 (_tmp95_, "") != 0) {
					GraphsYPosition original_position = 0;
					GraphsItem* _tmp96_;
					GraphsYPosition _tmp97_;
					GraphsYPosition _tmp98_;
					GraphsItem* _tmp112_;
					GraphsYPosition _tmp113_;
					GraphsYPosition _tmp114_;
					_tmp96_ = item;
					_tmp97_ = graphs_item_get_yposition (_tmp96_);
					_tmp98_ = _tmp97_;
					original_position = _tmp98_;
					if (original_position == GRAPHS_YPOSITION_LEFT) {
						if (graphs_data_is_default (self, "left-label") | graphs_data_is_empty (self)) {
							GraphsFigureSettings* _tmp99_;
							GraphsFigureSettings* _tmp100_;
							GraphsItem* _tmp101_;
							const gchar* _tmp102_;
							const gchar* _tmp103_;
							_tmp99_ = graphs_data_get_figure_settings (self);
							_tmp100_ = _tmp99_;
							_tmp101_ = item;
							_tmp102_ = graphs_item_get_ylabel (_tmp101_);
							_tmp103_ = _tmp102_;
							graphs_figure_settings_set_left_label (_tmp100_, _tmp103_);
						} else {
							GraphsItem* _tmp104_;
							const gchar* _tmp105_;
							const gchar* _tmp106_;
							GraphsFigureSettings* _tmp107_;
							GraphsFigureSettings* _tmp108_;
							const gchar* _tmp109_;
							const gchar* _tmp110_;
							_tmp104_ = item;
							_tmp105_ = graphs_item_get_ylabel (_tmp104_);
							_tmp106_ = _tmp105_;
							_tmp107_ = graphs_data_get_figure_settings (self);
							_tmp108_ = _tmp107_;
							_tmp109_ = graphs_figure_settings_get_left_label (_tmp108_);
							_tmp110_ = _tmp109_;
							if (g_strcmp0 (_tmp106_, _tmp110_) != 0) {
								GraphsItem* _tmp111_;
								_tmp111_ = item;
								graphs_item_set_yposition (_tmp111_, GRAPHS_YPOSITION_RIGHT);
							}
						}
					}
					_tmp112_ = item;
					_tmp113_ = graphs_item_get_yposition (_tmp112_);
					_tmp114_ = _tmp113_;
					if (_tmp114_ == GRAPHS_YPOSITION_RIGHT) {
						if (graphs_data_is_default (self, "right-label")) {
							GraphsFigureSettings* _tmp115_;
							GraphsFigureSettings* _tmp116_;
							GraphsItem* _tmp117_;
							const gchar* _tmp118_;
							const gchar* _tmp119_;
							_tmp115_ = graphs_data_get_figure_settings (self);
							_tmp116_ = _tmp115_;
							_tmp117_ = item;
							_tmp118_ = graphs_item_get_ylabel (_tmp117_);
							_tmp119_ = _tmp118_;
							graphs_figure_settings_set_right_label (_tmp116_, _tmp119_);
						} else {
							GraphsItem* _tmp120_;
							const gchar* _tmp121_;
							const gchar* _tmp122_;
							GraphsFigureSettings* _tmp123_;
							GraphsFigureSettings* _tmp124_;
							const gchar* _tmp125_;
							const gchar* _tmp126_;
							_tmp120_ = item;
							_tmp121_ = graphs_item_get_ylabel (_tmp120_);
							_tmp122_ = _tmp121_;
							_tmp123_ = graphs_data_get_figure_settings (self);
							_tmp124_ = _tmp123_;
							_tmp125_ = graphs_figure_settings_get_right_label (_tmp124_);
							_tmp126_ = _tmp125_;
							if (g_strcmp0 (_tmp122_, _tmp126_) != 0) {
								GraphsItem* _tmp127_;
								_tmp127_ = item;
								graphs_item_set_yposition (_tmp127_, original_position);
							}
						}
					}
				}
				_tmp128_ = item;
				_graphs_data_connect_to_item (self, _tmp128_);
				_tmp129_ = self->priv->_items;
				_tmp129__length1 = self->priv->_items_length1;
				_tmp130_ = self->priv->_n_items;
				self->priv->_n_items = _tmp130_ + 1;
				_tmp131_ = item;
				_tmp132_ = _g_object_ref0 (_tmp131_);
				_g_object_unref0 (_tmp129_[_tmp130_]);
				_tmp129_[_tmp130_] = _tmp132_;
				_tmp133_ = item;
				g_signal_emit (self, graphs_data_signals[GRAPHS_DATA_ITEM_ADDED_SIGNAL], 0, _tmp133_);
				_g_object_unref0 (item);
			}
		}
	}
	g_list_model_items_changed ((GListModel*) self, prev_size, (guint) 0, (guint) items_length1);
	graphs_data_optimize_limits (self);
	graphs_data_add_history_state (self);
	used_names = (_vala_array_free (used_names, used_names_length1, (GDestroyNotify) g_free), NULL);
}

static GraphsItem**
_vala_array_dup19 (GraphsItem** self,
                   gssize length)
{
	if (length >= 0) {
		GraphsItem** result;
		gssize i;
		result = g_new0 (GraphsItem*, length + 1);
		for (i = 0; i < length; i++) {
			GraphsItem* _tmp0_;
			_tmp0_ = _g_object_ref0 (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

void
graphs_data_set_items (GraphsData* self,
                       GraphsItem** items,
                       gint items_length1)
{
	guint removed = 0U;
	GraphsItem** _tmp2_;
	gint _tmp2__length1;
	g_return_if_fail (self != NULL);
	removed = (guint) self->priv->_n_items;
	{
		GraphsItem** item_collection = NULL;
		gint item_collection_length1 = 0;
		gint _item_collection_size_ = 0;
		gint item_it = 0;
		item_collection = items;
		item_collection_length1 = items_length1;
		for (item_it = 0; item_it < item_collection_length1; item_it = item_it + 1) {
			GraphsItem* _tmp0_;
			GraphsItem* item = NULL;
			_tmp0_ = _g_object_ref0 (item_collection[item_it]);
			item = _tmp0_;
			{
				GraphsItem* _tmp1_;
				_tmp1_ = item;
				_graphs_data_connect_to_item (self, _tmp1_);
				_g_object_unref0 (item);
			}
		}
	}
	self->priv->_n_items = items_length1;
	_tmp2_ = (items != NULL) ? _vala_array_dup19 (items, items_length1) : items;
	_tmp2__length1 = items_length1;
	self->priv->_items = (_vala_array_free (self->priv->_items, self->priv->_items_length1, (GDestroyNotify) g_object_unref), NULL);
	self->priv->_items = _tmp2_;
	self->priv->_items_length1 = _tmp2__length1;
	self->priv->__items_size_ = self->priv->_items_length1;
	_graphs_data_update_used_positions (self);
	g_list_model_items_changed ((GListModel*) self, (guint) 0, removed, (guint) self->priv->_n_items);
}

void
graphs_data_delete_items (GraphsData* self,
                          GraphsItem** items,
                          gint items_length1)
{
	g_return_if_fail (self != NULL);
	{
		GraphsItem** item_collection = NULL;
		gint item_collection_length1 = 0;
		gint _item_collection_size_ = 0;
		gint item_it = 0;
		item_collection = items;
		item_collection_length1 = items_length1;
		for (item_it = 0; item_it < item_collection_length1; item_it = item_it + 1) {
			GraphsItem* _tmp0_;
			GraphsItem* item = NULL;
			_tmp0_ = _g_object_ref0 (item_collection[item_it]);
			item = _tmp0_;
			{
				guint index = 0U;
				GraphsItem* _tmp1_;
				GraphsItem* _tmp2_;
				gchar* axis_label = NULL;
				gchar* prop = NULL;
				GraphsItem* _tmp3_;
				GraphsXPosition _tmp4_;
				GraphsXPosition _tmp5_;
				gchar* _tmp6_;
				gchar* _tmp7_;
				gchar* _tmp8_;
				GraphsFigureSettings* _tmp9_;
				GraphsFigureSettings* _tmp10_;
				const gchar* _tmp11_;
				gchar* _tmp12_ = NULL;
				gboolean _tmp13_ = FALSE;
				gboolean* _tmp14_;
				gint _tmp14__length1;
				GraphsItem* _tmp15_;
				GraphsXPosition _tmp16_;
				GraphsXPosition _tmp17_;
				gboolean _tmp18_;
				GraphsItem* _tmp30_;
				GraphsYPosition _tmp31_;
				GraphsYPosition _tmp32_;
				gchar* _tmp33_;
				gchar* _tmp34_;
				gchar* _tmp35_;
				GraphsFigureSettings* _tmp36_;
				GraphsFigureSettings* _tmp37_;
				const gchar* _tmp38_;
				gchar* _tmp39_ = NULL;
				gboolean _tmp40_ = FALSE;
				gboolean* _tmp41_;
				gint _tmp41__length1;
				GraphsItem* _tmp42_;
				GraphsYPosition _tmp43_;
				GraphsYPosition _tmp44_;
				gboolean _tmp45_;
				_tmp1_ = item;
				index = graphs_data_index (self, _tmp1_);
				_tmp2_ = item;
				g_signal_emit (self, graphs_data_signals[GRAPHS_DATA_ITEM_REMOVED_SIGNAL], 0, _tmp2_, index);
				_graphs_data_remove_item (self, index);
				_tmp3_ = item;
				_tmp4_ = graphs_item_get_xposition (_tmp3_);
				_tmp5_ = _tmp4_;
				_tmp6_ = graphs_xposition_friendly_string (_tmp5_);
				_tmp7_ = _tmp6_;
				_tmp8_ = g_strconcat (_tmp7_, "-label", NULL);
				_g_free0 (prop);
				prop = _tmp8_;
				_g_free0 (_tmp7_);
				_tmp9_ = graphs_data_get_figure_settings (self);
				_tmp10_ = _tmp9_;
				_tmp11_ = prop;
				g_object_get ((GObject*) _tmp10_, _tmp11_, &_tmp12_, NULL);
				_g_free0 (axis_label);
				axis_label = _tmp12_;
				_tmp14_ = self->priv->_used_positions;
				_tmp14__length1 = self->priv->_used_positions_length1;
				_tmp15_ = item;
				_tmp16_ = graphs_item_get_xposition (_tmp15_);
				_tmp17_ = _tmp16_;
				_tmp18_ = _tmp14_[_tmp17_];
				if (_tmp18_) {
					GraphsItem* _tmp19_;
					const gchar* _tmp20_;
					const gchar* _tmp21_;
					const gchar* _tmp22_;
					_tmp19_ = item;
					_tmp20_ = graphs_item_get_xlabel (_tmp19_);
					_tmp21_ = _tmp20_;
					_tmp22_ = axis_label;
					_tmp13_ = g_strcmp0 (_tmp21_, _tmp22_) == 0;
				} else {
					_tmp13_ = FALSE;
				}
				if (_tmp13_) {
					GraphsFigureSettings* _tmp23_;
					GraphsFigureSettings* _tmp24_;
					const gchar* _tmp25_;
					GSettings* _tmp26_;
					const gchar* _tmp27_;
					gchar* _tmp28_;
					gchar* _tmp29_;
					_tmp23_ = graphs_data_get_figure_settings (self);
					_tmp24_ = _tmp23_;
					_tmp25_ = prop;
					_tmp26_ = self->priv->_settings;
					_tmp27_ = prop;
					_tmp28_ = g_settings_get_string (_tmp26_, _tmp27_);
					_tmp29_ = _tmp28_;
					g_object_set ((GObject*) _tmp24_, _tmp25_, _tmp29_, NULL);
					_g_free0 (_tmp29_);
				}
				_tmp30_ = item;
				_tmp31_ = graphs_item_get_yposition (_tmp30_);
				_tmp32_ = _tmp31_;
				_tmp33_ = graphs_yposition_friendly_string (_tmp32_);
				_tmp34_ = _tmp33_;
				_tmp35_ = g_strconcat (_tmp34_, "-label", NULL);
				_g_free0 (prop);
				prop = _tmp35_;
				_g_free0 (_tmp34_);
				_tmp36_ = graphs_data_get_figure_settings (self);
				_tmp37_ = _tmp36_;
				_tmp38_ = prop;
				g_object_get ((GObject*) _tmp37_, _tmp38_, &_tmp39_, NULL);
				_g_free0 (axis_label);
				axis_label = _tmp39_;
				_tmp41_ = self->priv->_used_positions;
				_tmp41__length1 = self->priv->_used_positions_length1;
				_tmp42_ = item;
				_tmp43_ = graphs_item_get_yposition (_tmp42_);
				_tmp44_ = _tmp43_;
				_tmp45_ = _tmp41_[_tmp44_ + 2];
				if (_tmp45_) {
					GraphsItem* _tmp46_;
					const gchar* _tmp47_;
					const gchar* _tmp48_;
					const gchar* _tmp49_;
					_tmp46_ = item;
					_tmp47_ = graphs_item_get_ylabel (_tmp46_);
					_tmp48_ = _tmp47_;
					_tmp49_ = axis_label;
					_tmp40_ = g_strcmp0 (_tmp48_, _tmp49_) == 0;
				} else {
					_tmp40_ = FALSE;
				}
				if (_tmp40_) {
					GraphsFigureSettings* _tmp50_;
					GraphsFigureSettings* _tmp51_;
					const gchar* _tmp52_;
					GSettings* _tmp53_;
					const gchar* _tmp54_;
					gchar* _tmp55_;
					gchar* _tmp56_;
					_tmp50_ = graphs_data_get_figure_settings (self);
					_tmp51_ = _tmp50_;
					_tmp52_ = prop;
					_tmp53_ = self->priv->_settings;
					_tmp54_ = prop;
					_tmp55_ = g_settings_get_string (_tmp53_, _tmp54_);
					_tmp56_ = _tmp55_;
					g_object_set ((GObject*) _tmp51_, _tmp52_, _tmp56_, NULL);
					_g_free0 (_tmp56_);
				}
				_g_free0 (prop);
				_g_free0 (axis_label);
				_g_object_unref0 (item);
			}
		}
	}
	graphs_data_add_history_state (self);
}

static void
graphs_data_handle_style_change_data_free (gpointer _data)
{
	GraphsDataHandleStyleChangeData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (GraphsDataHandleStyleChangeData, _data_);
}

static void
graphs_data_handle_style_change (GraphsData* self,
                                 gboolean recolor_items,
                                 GAsyncReadyCallback _callback_,
                                 gpointer _user_data_)
{
	GraphsDataHandleStyleChangeData* _data_;
	GraphsData* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (GraphsDataHandleStyleChangeData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, graphs_data_handle_style_change_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->recolor_items = recolor_items;
	graphs_data_handle_style_change_co (_data_);
}

static void
graphs_data_handle_style_change_finish (GraphsData* self,
                                        GAsyncResult* _res_)
{
	GraphsDataHandleStyleChangeData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static gboolean
graphs_data_handle_style_change_co (GraphsDataHandleStyleChangeData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	g_object_notify ((GObject*) _data_->self, "selected_stylename");
	graphs_data_run_python_method (_data_->self, "_update_selected_style");
	g_signal_emit (_data_->self, graphs_data_signals[GRAPHS_DATA_STYLE_CHANGED_SIGNAL], 0, _data_->recolor_items);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

GraphsStyle*
graphs_data_get_selected_style (GraphsData* self)
{
	GtkSingleSelection* _tmp0_;
	GObject* _tmp1_;
	GraphsStyle* _tmp2_;
	GraphsStyle* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_style_selection_model;
	_tmp1_ = gtk_single_selection_get_selected_item (_tmp0_);
	_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GRAPHS_TYPE_STYLE, GraphsStyle));
	result = _tmp2_;
	return result;
}

static gchar**
_vala_array_dup20 (gchar** self,
                   gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

void
graphs_data_set_color_cycle (GraphsData* self,
                             gchar** color_cycle,
                             gint color_cycle_length1)
{
	gchar** _tmp0_;
	gint _tmp0__length1;
	g_return_if_fail (self != NULL);
	_tmp0_ = (color_cycle != NULL) ? _vala_array_dup20 (color_cycle, color_cycle_length1) : color_cycle;
	_tmp0__length1 = color_cycle_length1;
	self->priv->_color_cycle = (_vala_array_free (self->priv->_color_cycle, self->priv->_color_cycle_length1, (GDestroyNotify) g_free), NULL);
	self->priv->_color_cycle = _tmp0_;
	self->priv->_color_cycle_length1 = _tmp0__length1;
	self->priv->__color_cycle_size_ = self->priv->_color_cycle_length1;
}

static gchar**
_vala_array_dup21 (gchar** self,
                   gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

void
graphs_data_set_errbar_color_cycle (GraphsData* self,
                                    gchar** color_cycle,
                                    gint color_cycle_length1)
{
	gchar** _tmp0_;
	gint _tmp0__length1;
	g_return_if_fail (self != NULL);
	_tmp0_ = (color_cycle != NULL) ? _vala_array_dup21 (color_cycle, color_cycle_length1) : color_cycle;
	_tmp0__length1 = color_cycle_length1;
	self->priv->_errbar_color_cycle = (_vala_array_free (self->priv->_errbar_color_cycle, self->priv->_errbar_color_cycle_length1, (GDestroyNotify) g_free), NULL);
	self->priv->_errbar_color_cycle = _tmp0_;
	self->priv->_errbar_color_cycle_length1 = _tmp0__length1;
	self->priv->__errbar_color_cycle_size_ = self->priv->_errbar_color_cycle_length1;
}

static GeeIterator*
graphs_data_real_iterator (GeeIterable* base)
{
	GraphsData * self;
	GraphsDataItemIterator* _tmp0_;
	GeeIterator* result;
	self = (GraphsData*) base;
	_tmp0_ = graphs_data_item_iterator_new (self);
	result = (GeeIterator*) _tmp0_;
	return result;
}

static gboolean
graphs_data_real_foreach (GeeTraversable* base,
                          GeeForallFunc f,
                          gpointer f_target)
{
	GraphsData * self;
	gboolean result;
	self = (GraphsData*) base;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GraphsItem** _tmp2_;
				gint _tmp2__length1;
				GraphsItem* _tmp3_;
				GraphsItem* _tmp4_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				if (!(i < self->priv->_n_items)) {
					break;
				}
				_tmp2_ = self->priv->_items;
				_tmp2__length1 = self->priv->_items_length1;
				_tmp3_ = _tmp2_[i];
				_tmp4_ = _g_object_ref0 (_tmp3_);
				if (!f (_tmp4_, f_target)) {
					result = FALSE;
					return result;
				}
			}
		}
	}
	result = TRUE;
	return result;
}

gchar*
graphs_data_get_version (GraphsData* self)
{
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (VERSION);
	result = _tmp0_;
	return result;
}

gboolean
graphs_data_is_empty (GraphsData* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_n_items == 0;
	return result;
}

static GraphsItem**
_vala_array_dup22 (GraphsItem** self,
                   gssize length)
{
	if (length >= 0) {
		GraphsItem** result;
		gssize i;
		result = g_new0 (GraphsItem*, length + 1);
		for (i = 0; i < length; i++) {
			GraphsItem* _tmp0_;
			_tmp0_ = _g_object_ref0 (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

GraphsItem**
graphs_data_get_items (GraphsData* self,
                       gint* result_length1)
{
	GraphsItem** _tmp0_;
	gint _tmp0__length1;
	GraphsItem** _tmp1_;
	gint _tmp1__length1;
	GraphsItem** _tmp2_;
	gint _tmp2__length1;
	GraphsItem** result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_items;
	_tmp0__length1 = self->priv->_items_length1;
	_tmp1_ = (_tmp0_ != NULL) ? _vala_array_dup22 (_tmp0_ + 0, self->priv->_n_items - 0) : _tmp0_;
	_tmp1__length1 = self->priv->_n_items - 0;
	_tmp2_ = _tmp1_;
	_tmp2__length1 = _tmp1__length1;
	if (result_length1) {
		*result_length1 = _tmp2__length1;
	}
	result = _tmp2_;
	return result;
}

gchar**
graphs_data_get_names (GraphsData* self,
                       gint* result_length1)
{
	gchar** names = NULL;
	gchar** _tmp0_;
	gint names_length1;
	gint _names_size_;
	gchar** _tmp9_;
	gint _tmp9__length1;
	gchar** result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_new0 (gchar*, self->priv->_n_items + 1);
	names = _tmp0_;
	names_length1 = self->priv->_n_items;
	_names_size_ = names_length1;
	{
		gint index = 0;
		index = 0;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				gchar** _tmp3_;
				gint _tmp3__length1;
				GraphsItem** _tmp4_;
				gint _tmp4__length1;
				GraphsItem* _tmp5_;
				const gchar* _tmp6_;
				const gchar* _tmp7_;
				gchar* _tmp8_;
				if (!_tmp1_) {
					gint _tmp2_;
					_tmp2_ = index;
					index = _tmp2_ + 1;
				}
				_tmp1_ = FALSE;
				if (!(index < self->priv->_n_items)) {
					break;
				}
				_tmp3_ = names;
				_tmp3__length1 = names_length1;
				_tmp4_ = self->priv->_items;
				_tmp4__length1 = self->priv->_items_length1;
				_tmp5_ = _tmp4_[index];
				_tmp6_ = graphs_item_get_name (_tmp5_);
				_tmp7_ = _tmp6_;
				_tmp8_ = g_strdup (_tmp7_);
				_g_free0 (_tmp3_[index]);
				_tmp3_[index] = _tmp8_;
			}
		}
	}
	_tmp9_ = names;
	_tmp9__length1 = names_length1;
	if (result_length1) {
		*result_length1 = _tmp9__length1;
	}
	result = _tmp9_;
	return result;
}

guint
graphs_data_index (GraphsData* self,
                   GraphsItem* item)
{
	guint result;
	g_return_val_if_fail (self != NULL, 0U);
	g_return_val_if_fail (item != NULL, 0U);
	{
		guint index = 0U;
		index = (guint) 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GraphsItem** _tmp2_;
				gint _tmp2__length1;
				GraphsItem* _tmp3_;
				if (!_tmp0_) {
					guint _tmp1_;
					_tmp1_ = index;
					index = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				if (!(index < ((guint) self->priv->_n_items))) {
					break;
				}
				_tmp2_ = self->priv->_items;
				_tmp2__length1 = self->priv->_items_length1;
				_tmp3_ = _tmp2_[index];
				if (_tmp3_ == item) {
					result = index;
					return result;
				}
			}
		}
	}
	g_assert_not_reached ();
}

static gboolean*
_vala_array_dup23 (gboolean* self,
                   gssize length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (gboolean));
	}
	return NULL;
}

gboolean*
graphs_data_get_used_positions (GraphsData* self,
                                gint* result_length1)
{
	gboolean* _tmp0_;
	gint _tmp0__length1;
	gboolean* _tmp1_;
	gint _tmp1__length1;
	gboolean* _tmp2_;
	gint _tmp2__length1;
	gboolean* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_used_positions;
	_tmp0__length1 = self->priv->_used_positions_length1;
	_tmp1_ = (_tmp0_ != NULL) ? _vala_array_dup23 (_tmp0_, _tmp0__length1) : _tmp0_;
	_tmp1__length1 = _tmp0__length1;
	_tmp2_ = _tmp1_;
	_tmp2__length1 = _tmp1__length1;
	if (result_length1) {
		*result_length1 = _tmp2__length1;
	}
	result = _tmp2_;
	return result;
}

void
graphs_data_change_position (GraphsData* self,
                             guint index1,
                             guint index2)
{
	GraphsItem* item = NULL;
	GraphsItem** _tmp0_;
	gint _tmp0__length1;
	GraphsItem* _tmp1_;
	GraphsItem* _tmp2_;
	GraphsItem** _tmp3_;
	gint _tmp3__length1;
	GraphsItem* _tmp4_;
	GraphsItem* _tmp5_;
	guint position = 0U;
	guint changed = 0U;
	g_return_if_fail (self != NULL);
	if (index1 == index2) {
		return;
	}
	_tmp0_ = self->priv->_items;
	_tmp0__length1 = self->priv->_items_length1;
	_tmp1_ = _tmp0_[index2];
	_tmp2_ = _g_object_ref0 (_tmp1_);
	item = _tmp2_;
	if (index1 < index2) {
		_vala_array_move (self->priv->_items, sizeof (GraphsItem*), (gint) index1, ((gint) index1) + 1, (gint) (index2 - index1));
	} else {
		_vala_array_move (self->priv->_items, sizeof (GraphsItem*), ((gint) index2) + 1, (gint) index2, (gint) (index1 - index2));
	}
	_tmp3_ = self->priv->_items;
	_tmp3__length1 = self->priv->_items_length1;
	_tmp4_ = item;
	_tmp5_ = _g_object_ref0 (_tmp4_);
	_g_object_unref0 (_tmp3_[index1]);
	_tmp3_[index1] = _tmp5_;
	position = MIN (index1, index2);
	changed = (MAX (index1, index2) - position) + 1;
	g_list_model_items_changed ((GListModel*) self, position, changed, changed);
	g_signal_emit (self, graphs_data_signals[GRAPHS_DATA_POSITION_CHANGED_SIGNAL], 0, index1, index2);
	_g_object_unref0 (item);
}

void
graphs_data_optimize_limits (GraphsData* self)
{
	g_return_if_fail (self != NULL);
	graphs_data_run_python_method (self, "_optimize_limits");
	graphs_data_add_view_history_state (self);
}

void
graphs_data_add_history_state (GraphsData* self)
{
	gboolean _tmp0_ = FALSE;
	g_return_if_fail (self != NULL);
	g_signal_emit (self, graphs_data_signals[GRAPHS_DATA_ADD_HISTORY_STATE_REQUEST_SIGNAL], 0, &_tmp0_);
	if (!_tmp0_) {
		return;
	}
	graphs_data_set_can_undo (self, TRUE);
	graphs_data_set_can_redo (self, FALSE);
	graphs_data_set_unsaved (self, TRUE);
	g_object_notify ((GObject*) self, "unsaved");
}

void
graphs_data_undo (GraphsData* self)
{
	g_return_if_fail (self != NULL);
	graphs_data_run_python_method (self, "_undo");
	graphs_data_add_view_history_state (self);
}

void
graphs_data_redo (GraphsData* self)
{
	g_return_if_fail (self != NULL);
	graphs_data_run_python_method (self, "_redo");
	graphs_data_add_view_history_state (self);
}

void
graphs_data_add_view_history_state (GraphsData* self)
{
	GraphsLimits* limits = NULL;
	GraphsFigureSettings* _tmp0_;
	GraphsFigureSettings* _tmp1_;
	GraphsLimits* _tmp2_;
	GraphsLimits* last = NULL;
	GeeList* _tmp3_;
	gpointer _tmp4_;
	GraphsLimits* _tmp5_;
	gint _tmp6_ = 0;
	gdouble* _tmp7_;
	gdouble* _tmp8_;
	gint _tmp8__length1;
	GraphsLimits* _tmp9_;
	gint _tmp10_ = 0;
	gdouble* _tmp11_;
	gdouble* _tmp12_;
	gint _tmp12__length1;
	gboolean _tmp13_;
	GeeList* _tmp26_;
	gint _tmp27_;
	gint _tmp28_;
	GeeList* _tmp32_;
	GraphsLimits* _tmp33_;
	g_return_if_fail (self != NULL);
	_tmp0_ = graphs_data_get_figure_settings (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = graphs_figure_settings_get_limits (_tmp1_);
	limits = _tmp2_;
	_tmp3_ = self->priv->_view_history_states;
	_tmp4_ = gee_list_last (_tmp3_);
	last = (GraphsLimits*) _tmp4_;
	_tmp5_ = limits;
	_tmp7_ = graphs_limits_values (_tmp5_, &_tmp6_);
	_tmp8_ = _tmp7_;
	_tmp8__length1 = _tmp6_;
	_tmp9_ = last;
	_tmp11_ = graphs_limits_values (_tmp9_, &_tmp10_);
	_tmp12_ = _tmp11_;
	_tmp12__length1 = _tmp10_;
	_tmp13_ = graphs_math_tools_all_close (_tmp8_, (gint) _tmp6_, _tmp12_, (gint) _tmp10_);
	_tmp12_ = (g_free (_tmp12_), NULL);
	_tmp8_ = (g_free (_tmp8_), NULL);
	if (_tmp13_) {
		_graphs_limits_unref0 (last);
		_graphs_limits_unref0 (limits);
		return;
	}
	if (self->priv->_view_history_pos != -1) {
		gint new_size = 0;
		GeeList* _tmp14_;
		gint _tmp15_;
		gint _tmp16_;
		_tmp14_ = self->priv->_view_history_states;
		_tmp15_ = gee_collection_get_size ((GeeCollection*) _tmp14_);
		_tmp16_ = _tmp15_;
		new_size = (_tmp16_ + self->priv->_view_history_pos) + 1;
		while (TRUE) {
			GeeList* _tmp17_;
			gint _tmp18_;
			gint _tmp19_;
			GeeList* _tmp20_;
			GeeList* _tmp21_;
			gint _tmp22_;
			gint _tmp23_;
			gpointer _tmp24_;
			GraphsLimits* _tmp25_;
			_tmp17_ = self->priv->_view_history_states;
			_tmp18_ = gee_collection_get_size ((GeeCollection*) _tmp17_);
			_tmp19_ = _tmp18_;
			if (!(_tmp19_ > new_size)) {
				break;
			}
			_tmp20_ = self->priv->_view_history_states;
			_tmp21_ = self->priv->_view_history_states;
			_tmp22_ = gee_collection_get_size ((GeeCollection*) _tmp21_);
			_tmp23_ = _tmp22_;
			_tmp24_ = gee_list_remove_at (_tmp20_, _tmp23_ - 1);
			_tmp25_ = (GraphsLimits*) _tmp24_;
			_graphs_limits_unref0 (_tmp25_);
		}
	}
	_tmp26_ = self->priv->_view_history_states;
	_tmp27_ = gee_collection_get_size ((GeeCollection*) _tmp26_);
	_tmp28_ = _tmp27_;
	if (_tmp28_ > 101) {
		GeeList* _tmp29_;
		gpointer _tmp30_;
		GraphsLimits* _tmp31_;
		_tmp29_ = self->priv->_view_history_states;
		_tmp30_ = gee_list_remove_at (_tmp29_, 0);
		_tmp31_ = (GraphsLimits*) _tmp30_;
		_graphs_limits_unref0 (_tmp31_);
	}
	self->priv->_view_history_pos = -1;
	_tmp32_ = self->priv->_view_history_states;
	_tmp33_ = limits;
	gee_collection_add ((GeeCollection*) _tmp32_, _tmp33_);
	graphs_data_set_can_view_back (self, TRUE);
	graphs_data_set_can_view_forward (self, FALSE);
	graphs_data_set_unsaved (self, TRUE);
	g_object_notify ((GObject*) self, "unsaved");
	_graphs_limits_unref0 (last);
	_graphs_limits_unref0 (limits);
}

void
graphs_data_view_back (GraphsData* self)
{
	gboolean _tmp0_;
	gint index = 0;
	GeeList* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	GraphsFigureSettings* _tmp5_;
	GraphsFigureSettings* _tmp6_;
	GeeList* _tmp7_;
	gpointer _tmp8_;
	GraphsLimits* _tmp9_;
	GeeList* _tmp10_;
	gint _tmp11_;
	gint _tmp12_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_can_view_back;
	if (!_tmp0_) {
		return;
	}
	_tmp1_ = self->priv->_view_history_states;
	_tmp2_ = gee_collection_get_size ((GeeCollection*) _tmp1_);
	_tmp3_ = _tmp2_;
	self->priv->_view_history_pos = self->priv->_view_history_pos - 1;
	_tmp4_ = self->priv->_view_history_pos;
	index = _tmp3_ + _tmp4_;
	_tmp5_ = graphs_data_get_figure_settings (self);
	_tmp6_ = _tmp5_;
	_tmp7_ = self->priv->_view_history_states;
	_tmp8_ = gee_list_get (_tmp7_, index);
	_tmp9_ = (GraphsLimits*) _tmp8_;
	graphs_figure_settings_set_limits (_tmp6_, _tmp9_);
	_graphs_limits_unref0 (_tmp9_);
	_tmp10_ = self->priv->_view_history_states;
	_tmp11_ = gee_collection_get_size ((GeeCollection*) _tmp10_);
	_tmp12_ = _tmp11_;
	graphs_data_set_can_view_back (self, abs (self->priv->_view_history_pos) < _tmp12_);
	graphs_data_set_can_view_forward (self, TRUE);
}

void
graphs_data_view_forward (GraphsData* self)
{
	gboolean _tmp0_;
	gint index = 0;
	GeeList* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	GraphsFigureSettings* _tmp5_;
	GraphsFigureSettings* _tmp6_;
	GeeList* _tmp7_;
	gpointer _tmp8_;
	GraphsLimits* _tmp9_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_can_view_forward;
	if (!_tmp0_) {
		return;
	}
	_tmp1_ = self->priv->_view_history_states;
	_tmp2_ = gee_collection_get_size ((GeeCollection*) _tmp1_);
	_tmp3_ = _tmp2_;
	self->priv->_view_history_pos = self->priv->_view_history_pos + 1;
	_tmp4_ = self->priv->_view_history_pos;
	index = _tmp3_ + _tmp4_;
	_tmp5_ = graphs_data_get_figure_settings (self);
	_tmp6_ = _tmp5_;
	_tmp7_ = self->priv->_view_history_states;
	_tmp8_ = gee_list_get (_tmp7_, index);
	_tmp9_ = (GraphsLimits*) _tmp8_;
	graphs_figure_settings_set_limits (_tmp6_, _tmp9_);
	_graphs_limits_unref0 (_tmp9_);
	graphs_data_set_can_view_back (self, TRUE);
	graphs_data_set_can_view_forward (self, self->priv->_view_history_pos < -1);
}

gint
graphs_data_get_view_history (GraphsData* self,
                              GraphsLimits*** history,
                              gint* history_length1)
{
	GraphsLimits** _vala_history = NULL;
	gint _vala_history_length1 = 0;
	GeeList* _tmp0_;
	gint _tmp1_ = 0;
	gpointer* _tmp2_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	_tmp0_ = self->priv->_view_history_states;
	_tmp2_ = gee_collection_to_array ((GeeCollection*) _tmp0_, &_tmp1_);
	_vala_history = (_vala_array_free (_vala_history, _vala_history_length1, (GDestroyNotify) graphs_limits_unref), NULL);
	_vala_history = _tmp2_;
	_vala_history_length1 = _tmp1_;
	result = self->priv->_view_history_pos;
	if (history) {
		*history = _vala_history;
	} else {
		_vala_history = (_vala_array_free (_vala_history, _vala_history_length1, (GDestroyNotify) graphs_limits_unref), NULL);
	}
	if (history_length1) {
		*history_length1 = _vala_history_length1;
	}
	return result;
}

static gpointer
_graphs_limits_ref0 (gpointer self)
{
	return self ? graphs_limits_ref (self) : NULL;
}

static GraphsLimits**
_vala_array_dup24 (GraphsLimits** self,
                   gssize length)
{
	if (length >= 0) {
		GraphsLimits** result;
		gssize i;
		result = g_new0 (GraphsLimits*, length + 1);
		for (i = 0; i < length; i++) {
			GraphsLimits* _tmp0_;
			_tmp0_ = _graphs_limits_ref0 (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

void
graphs_data_set_view_history (GraphsData* self,
                              gint pos,
                              GraphsLimits** history,
                              gint history_length1)
{
	GraphsLimits** _tmp0_;
	gint _tmp0__length1;
	GeeArrayList* _tmp1_;
	GeeList* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp0_ = (history != NULL) ? _vala_array_dup24 (history, history_length1) : history;
	_tmp0__length1 = history_length1;
	_tmp1_ = gee_array_list_new_wrap (GRAPHS_TYPE_LIMITS, (GBoxedCopyFunc) graphs_limits_ref, (GDestroyNotify) graphs_limits_unref, _tmp0_, _tmp0__length1, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->_view_history_states);
	self->priv->_view_history_states = (GeeList*) _tmp1_;
	self->priv->_view_history_pos = pos;
	_tmp2_ = self->priv->_view_history_states;
	_tmp3_ = gee_collection_get_size ((GeeCollection*) _tmp2_);
	_tmp4_ = _tmp3_;
	graphs_data_set_can_view_back (self, abs (self->priv->_view_history_pos) < _tmp4_);
	graphs_data_set_can_view_forward (self, self->priv->_view_history_pos < -1);
}

void
graphs_data_save (GraphsData* self)
{
	g_return_if_fail (self != NULL);
	graphs_data_run_python_method (self, "_save");
	graphs_data_set_unsaved (self, FALSE);
	g_object_notify ((GObject*) self, "unsaved");
}

void
graphs_data_load (GraphsData* self,
                  GFile* file,
                  GraphsProjectParseFlags flags,
                  GError** error)
{
	gchar* _error_ = NULL;
	gchar* _tmp0_ = NULL;
	const gchar* _tmp1_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (file != NULL);
	g_signal_emit (self, graphs_data_signals[GRAPHS_DATA_LOAD_REQUEST_SIGNAL], 0, file, flags, &_tmp0_);
	_error_ = _tmp0_;
	_tmp1_ = _error_;
	if (g_strcmp0 (_tmp1_, "") == 0) {
		graphs_data_set_file (self, file);
		graphs_data_set_unsaved (self, FALSE);
		g_object_notify ((GObject*) self, "unsaved");
	} else {
		const gchar* _tmp2_;
		const gchar* _tmp3_;
		GQuark _tmp5_ = 0U;
		static GQuark _tmp4_label0 = 0;
		static GQuark _tmp4_label1 = 0;
		_tmp2_ = _error_;
		_tmp3_ = _tmp2_;
		_tmp5_ = (NULL == _tmp3_) ? 0 : g_quark_from_string (_tmp3_);
		if (_tmp5_ == ((0 != _tmp4_label0) ? _tmp4_label0 : (_tmp4_label0 = g_quark_from_static_string ("LEGACY_MIGRATION_DISALLOWED")))) {
			switch (0) {
				default:
				{
					GError* _tmp6_;
					_tmp6_ = g_error_new_literal (GRAPHS_PROJECT_PARSE_ERROR, GRAPHS_PROJECT_PARSE_ERROR_LEGACY_MIGRATION_DISALLOWED, "");
					_inner_error0_ = _tmp6_;
					if (_inner_error0_->domain == GRAPHS_PROJECT_PARSE_ERROR) {
						g_propagate_error (error, _inner_error0_);
						_g_free0 (_error_);
						return;
					} else {
						_g_free0 (_error_);
						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;
					}
				}
			}
		} else if (_tmp5_ == ((0 != _tmp4_label1) ? _tmp4_label1 : (_tmp4_label1 = g_quark_from_static_string ("BETA_DISALLOWED")))) {
			switch (0) {
				default:
				{
					GError* _tmp7_;
					_tmp7_ = g_error_new_literal (GRAPHS_PROJECT_PARSE_ERROR, GRAPHS_PROJECT_PARSE_ERROR_BETA_DISALLOWED, "");
					_inner_error0_ = _tmp7_;
					if (_inner_error0_->domain == GRAPHS_PROJECT_PARSE_ERROR) {
						g_propagate_error (error, _inner_error0_);
						_g_free0 (_error_);
						return;
					} else {
						_g_free0 (_error_);
						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;
					}
				}
			}
		} else {
			switch (0) {
				default:
				{
					const gchar* _tmp8_;
					GError* _tmp9_;
					_tmp8_ = _error_;
					_tmp9_ = g_error_new_literal (GRAPHS_PROJECT_PARSE_ERROR, GRAPHS_PROJECT_PARSE_ERROR_INVALID_PROJECT, _tmp8_);
					_inner_error0_ = _tmp9_;
					if (_inner_error0_->domain == GRAPHS_PROJECT_PARSE_ERROR) {
						g_propagate_error (error, _inner_error0_);
						_g_free0 (_error_);
						return;
					} else {
						_g_free0 (_error_);
						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;
					}
				}
			}
		}
	}
	_g_free0 (_error_);
}

static void
_graphs_data_on_item_change (GraphsData* self,
                             GObject* item,
                             GParamSpec* spec)
{
	const gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (item != NULL);
	g_return_if_fail (spec != NULL);
	_tmp0_ = spec->name;
	g_signal_emit (self, graphs_data_signals[GRAPHS_DATA_ITEM_CHANGED_SIGNAL], 0, G_TYPE_CHECK_INSTANCE_CAST (item, GRAPHS_TYPE_ITEM, GraphsItem), _tmp0_);
}

static void
_graphs_data_on_item_position_change (GraphsData* self)
{
	g_return_if_fail (self != NULL);
	graphs_data_optimize_limits (self);
	_graphs_data_update_used_positions (self);
	g_list_model_items_changed ((GListModel*) self, (guint) 0, (guint) 0, (guint) 0);
}

static void
_graphs_data_on_use_custom_style_data_free (gpointer _data)
{
	GraphsDataOnUseCustomStyleData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (GraphsDataOnUseCustomStyleData, _data_);
}

static void
_graphs_data_on_use_custom_style (GraphsData* self,
                                  GAsyncReadyCallback _callback_,
                                  gpointer _user_data_)
{
	GraphsDataOnUseCustomStyleData* _data_;
	GraphsData* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (GraphsDataOnUseCustomStyleData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, _graphs_data_on_use_custom_style_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_graphs_data_on_use_custom_style_co (_data_);
}

static void
_graphs_data_on_use_custom_style_finish (GraphsData* self,
                                         GAsyncResult* _res_)
{
	GraphsDataOnUseCustomStyleData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
_graphs_data_on_use_custom_style_ready (GObject* source_object,
                                        GAsyncResult* _res_,
                                        gpointer _user_data_)
{
	GraphsDataOnUseCustomStyleData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	_graphs_data_on_use_custom_style_co (_data_);
}

static gboolean
_graphs_data_on_use_custom_style_co (GraphsDataOnUseCustomStyleData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = graphs_data_get_figure_settings (_data_->self);
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_tmp2_ = graphs_figure_settings_get_use_custom_style (_data_->_tmp1_);
	_data_->_tmp3_ = _data_->_tmp2_;
	if (_data_->_tmp3_) {
		_data_->_state_ = 1;
		_graphs_data_on_custom_style (_data_->self, _graphs_data_on_use_custom_style_ready, _data_);
		return FALSE;
		_state_1:
		_graphs_data_on_custom_style_finish (_data_->self, _data_->_res_);
	} else {
		_data_->_tmp4_ = _data_->self->priv->_style_selection_model;
		gtk_single_selection_set_selected (_data_->_tmp4_, (guint) 0);
		_data_->_state_ = 2;
		graphs_data_handle_style_change (_data_->self, TRUE, _graphs_data_on_use_custom_style_ready, _data_);
		return FALSE;
		_state_2:
		graphs_data_handle_style_change_finish (_data_->self, _data_->_res_);
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
_graphs_data_on_custom_style_data_free (gpointer _data)
{
	GraphsDataOnCustomStyleData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (GraphsDataOnCustomStyleData, _data_);
}

static void
_graphs_data_on_custom_style (GraphsData* self,
                              GAsyncReadyCallback _callback_,
                              gpointer _user_data_)
{
	GraphsDataOnCustomStyleData* _data_;
	GraphsData* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (GraphsDataOnCustomStyleData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, _graphs_data_on_custom_style_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_graphs_data_on_custom_style_co (_data_);
}

static void
_graphs_data_on_custom_style_finish (GraphsData* self,
                                     GAsyncResult* _res_)
{
	GraphsDataOnCustomStyleData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
_graphs_data_on_custom_style_ready (GObject* source_object,
                                    GAsyncResult* _res_,
                                    gpointer _user_data_)
{
	GraphsDataOnCustomStyleData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	_graphs_data_on_custom_style_co (_data_);
}

static gboolean
_graphs_data_on_custom_style_co (GraphsDataOnCustomStyleData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = graphs_data_get_figure_settings (_data_->self);
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_tmp2_ = graphs_figure_settings_get_use_custom_style (_data_->_tmp1_);
	_data_->_tmp3_ = _data_->_tmp2_;
	if (!_data_->_tmp3_) {
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp4_ = _data_->self->priv->_style_selection_model;
	_data_->_tmp5_ = gtk_single_selection_get_model (_data_->_tmp4_);
	_data_->_tmp6_ = _g_object_ref0 (_data_->_tmp5_);
	_data_->style_model = _data_->_tmp6_;
	{
		_data_->i = (guint) 1;
		{
			_data_->_tmp7_ = TRUE;
			while (TRUE) {
				if (!_data_->_tmp7_) {
					_data_->_tmp8_ = _data_->i;
					_data_->i = _data_->_tmp8_ + 1;
				}
				_data_->_tmp7_ = FALSE;
				_data_->_tmp9_ = _data_->style_model;
				if (!(_data_->i < g_list_model_get_n_items (_data_->_tmp9_))) {
					break;
				}
				_data_->_tmp10_ = _data_->style_model;
				_data_->_tmp11_ = g_list_model_get_item (_data_->_tmp10_, _data_->i);
				_data_->style = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp11_, GRAPHS_TYPE_STYLE, GraphsStyle);
				_data_->_tmp12_ = _data_->style;
				_data_->_tmp13_ = graphs_style_get_name (_data_->_tmp12_);
				_data_->_tmp14_ = _data_->_tmp13_;
				_data_->_tmp15_ = graphs_data_get_figure_settings (_data_->self);
				_data_->_tmp16_ = _data_->_tmp15_;
				_data_->_tmp17_ = graphs_figure_settings_get_custom_style (_data_->_tmp16_);
				_data_->_tmp18_ = _data_->_tmp17_;
				if (g_strcmp0 (_data_->_tmp14_, _data_->_tmp18_) == 0) {
					_data_->_tmp19_ = _data_->self->priv->_style_selection_model;
					gtk_single_selection_set_selected (_data_->_tmp19_, _data_->i);
					_g_object_unref0 (_data_->style);
					break;
				}
				_g_object_unref0 (_data_->style);
			}
		}
	}
	_data_->_state_ = 1;
	graphs_data_handle_style_change (_data_->self, TRUE, _graphs_data_on_custom_style_ready, _data_);
	return FALSE;
	_state_1:
	graphs_data_handle_style_change_finish (_data_->self, _data_->_res_);
	_g_object_unref0 (_data_->style_model);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

GraphsData*
graphs_data_construct (GType object_type)
{
	GraphsData * self = NULL;
	self = (GraphsData*) g_object_new (object_type, NULL);
	return self;
}

GraphsData*
graphs_data_new (void)
{
	return graphs_data_construct (GRAPHS_TYPE_DATA);
}

gboolean
graphs_data_get_can_undo (GraphsData* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_can_undo;
	return result;
}

void
graphs_data_set_can_undo (GraphsData* self,
                          gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_data_get_can_undo (self);
	if (old_value != value) {
		self->priv->_can_undo = value;
		g_object_notify_by_pspec ((GObject *) self, graphs_data_properties[GRAPHS_DATA_CAN_UNDO_PROPERTY]);
	}
}

gboolean
graphs_data_get_can_redo (GraphsData* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_can_redo;
	return result;
}

void
graphs_data_set_can_redo (GraphsData* self,
                          gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_data_get_can_redo (self);
	if (old_value != value) {
		self->priv->_can_redo = value;
		g_object_notify_by_pspec ((GObject *) self, graphs_data_properties[GRAPHS_DATA_CAN_REDO_PROPERTY]);
	}
}

gboolean
graphs_data_get_can_view_back (GraphsData* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_can_view_back;
	return result;
}

static void
graphs_data_set_can_view_back (GraphsData* self,
                               gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_data_get_can_view_back (self);
	if (old_value != value) {
		self->priv->_can_view_back = value;
		g_object_notify_by_pspec ((GObject *) self, graphs_data_properties[GRAPHS_DATA_CAN_VIEW_BACK_PROPERTY]);
	}
}

gboolean
graphs_data_get_can_view_forward (GraphsData* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_can_view_forward;
	return result;
}

static void
graphs_data_set_can_view_forward (GraphsData* self,
                                  gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_data_get_can_view_forward (self);
	if (old_value != value) {
		self->priv->_can_view_forward = value;
		g_object_notify_by_pspec ((GObject *) self, graphs_data_properties[GRAPHS_DATA_CAN_VIEW_FORWARD_PROPERTY]);
	}
}

GFile*
graphs_data_get_file (GraphsData* self)
{
	GFile* result;
	GFile* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_file;
	result = _tmp0_;
	return result;
}

void
graphs_data_set_file (GraphsData* self,
                      GFile* value)
{
	GFile* old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_data_get_file (self);
	if (old_value != value) {
		GFile* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_file);
		self->priv->_file = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, graphs_data_properties[GRAPHS_DATA_FILE_PROPERTY]);
	}
}

gboolean
graphs_data_get_unsaved (GraphsData* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_unsaved;
	return result;
}

void
graphs_data_set_unsaved (GraphsData* self,
                         gboolean value)
{
	g_return_if_fail (self != NULL);
	self->priv->_unsaved = value;
}

GtkSingleSelection*
graphs_data_get_style_selection_model (GraphsData* self)
{
	GtkSingleSelection* result;
	GtkSingleSelection* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_style_selection_model;
	result = _tmp0_;
	return result;
}

static void
graphs_data_set_style_selection_model (GraphsData* self,
                                       GtkSingleSelection* value)
{
	GtkSingleSelection* old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_data_get_style_selection_model (self);
	if (old_value != value) {
		GtkSingleSelection* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_style_selection_model);
		self->priv->_style_selection_model = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, graphs_data_properties[GRAPHS_DATA_STYLE_SELECTION_MODEL_PROPERTY]);
	}
}

const gchar*
graphs_data_get_selected_stylename (GraphsData* self)
{
	const gchar* result;
	GraphsStyle* _tmp0_;
	GraphsStyle* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = graphs_data_get_selected_style (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = graphs_style_get_name (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = _tmp3_;
	_g_object_unref0 (_tmp1_);
	result = _tmp4_;
	return result;
}

GraphsFigureSettings*
graphs_data_get_figure_settings (GraphsData* self)
{
	GraphsFigureSettings* result;
	GraphsFigureSettings* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_figure_settings;
	result = _tmp0_;
	return result;
}

static void
__graphs_data_on_custom_style_g_object_notify (GObject* _sender,
                                               GParamSpec* pspec,
                                               gpointer self)
{
	_graphs_data_on_custom_style ((GraphsData*) self, NULL, NULL);
}

static void
__graphs_data_on_use_custom_style_g_object_notify (GObject* _sender,
                                                   GParamSpec* pspec,
                                                   gpointer self)
{
	_graphs_data_on_use_custom_style ((GraphsData*) self, NULL, NULL);
}

static void
_graphs_data_figure_settings___lambda13_ (GraphsData* self,
                                          GObject* v,
                                          GParamSpec* param)
{
	const gchar* _tmp0_;
	g_return_if_fail (v != NULL);
	g_return_if_fail (param != NULL);
	_tmp0_ = param->name;
	g_signal_emit (self, graphs_data_signals[GRAPHS_DATA_FIGURE_SETTINGS_CHANGED_SIGNAL], 0, _tmp0_);
}

static void
__graphs_data_figure_settings___lambda13__g_object_notify (GObject* _sender,
                                                           GParamSpec* pspec,
                                                           gpointer self)
{
	_graphs_data_figure_settings___lambda13_ ((GraphsData*) self, _sender, pspec);
}

void
graphs_data_set_figure_settings (GraphsData* self,
                                 GraphsFigureSettings* value)
{
	GraphsFigureSettings* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_figure_settings);
	self->priv->_figure_settings = _tmp0_;
	g_signal_connect_object ((GObject*) value, "notify::custom-style", (GCallback) __graphs_data_on_custom_style_g_object_notify, self, 0);
	g_signal_connect_object ((GObject*) value, "notify::use-custom-style", (GCallback) __graphs_data_on_use_custom_style_g_object_notify, self, 0);
	g_signal_connect_object ((GObject*) value, "notify", (GCallback) __graphs_data_figure_settings___lambda13__g_object_notify, self, 0);
	_graphs_data_update_used_positions (self);
	graphs_data_handle_style_change (self, FALSE, NULL, NULL);
	g_object_notify_by_pspec ((GObject *) self, graphs_data_properties[GRAPHS_DATA_FIGURE_SETTINGS_PROPERTY]);
}

static void
g_cclosure_user_marshal_STRING__OBJECT_FLAGS (GClosure * closure,
                                              GValue * return_value,
                                              guint n_param_values,
                                              const GValue * param_values,
                                              gpointer invocation_hint,
                                              gpointer marshal_data)
{
	typedef const char* (*GMarshalFunc_STRING__OBJECT_FLAGS) (gpointer data1, gpointer arg_1, guint arg_2, gpointer data2);
	register GMarshalFunc_STRING__OBJECT_FLAGS callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	const char* v_return;
	cc = (GCClosure *) closure;
	g_return_if_fail (return_value != NULL);
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_STRING__OBJECT_FLAGS) (marshal_data ? marshal_data : cc->callback);
	v_return = callback (data1, g_value_get_object (param_values + 1), g_value_get_flags (param_values + 2), data2);
	g_value_take_string (return_value, v_return);
}

static void
g_cclosure_user_marshal_BOOLEAN__VOID (GClosure * closure,
                                       GValue * return_value,
                                       guint n_param_values,
                                       const GValue * param_values,
                                       gpointer invocation_hint,
                                       gpointer marshal_data)
{
	typedef gboolean (*GMarshalFunc_BOOLEAN__VOID) (gpointer data1, gpointer data2);
	register GMarshalFunc_BOOLEAN__VOID callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	gboolean v_return;
	cc = (GCClosure *) closure;
	g_return_if_fail (return_value != NULL);
	g_return_if_fail (n_param_values == 1);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_BOOLEAN__VOID) (marshal_data ? marshal_data : cc->callback);
	v_return = callback (data1, data2);
	g_value_set_boolean (return_value, v_return);
}

static void
g_cclosure_user_marshal_VOID__UINT_UINT (GClosure * closure,
                                         GValue * return_value,
                                         guint n_param_values,
                                         const GValue * param_values,
                                         gpointer invocation_hint,
                                         gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__UINT_UINT) (gpointer data1, guint arg_1, guint arg_2, gpointer data2);
	register GMarshalFunc_VOID__UINT_UINT callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__UINT_UINT) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_uint (param_values + 1), g_value_get_uint (param_values + 2), data2);
}

static void
g_cclosure_user_marshal_VOID__OBJECT_STRING (GClosure * closure,
                                             GValue * return_value,
                                             guint n_param_values,
                                             const GValue * param_values,
                                             gpointer invocation_hint,
                                             gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__OBJECT_STRING) (gpointer data1, gpointer arg_1, const char* arg_2, gpointer data2);
	register GMarshalFunc_VOID__OBJECT_STRING callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__OBJECT_STRING) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_object (param_values + 1), g_value_get_string (param_values + 2), data2);
}

static void
g_cclosure_user_marshal_VOID__OBJECT_UINT (GClosure * closure,
                                           GValue * return_value,
                                           guint n_param_values,
                                           const GValue * param_values,
                                           gpointer invocation_hint,
                                           gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__OBJECT_UINT) (gpointer data1, gpointer arg_1, guint arg_2, gpointer data2);
	register GMarshalFunc_VOID__OBJECT_UINT callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__OBJECT_UINT) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_object (param_values + 1), g_value_get_uint (param_values + 2), data2);
}

static inline gpointer
graphs_data_item_iterator_get_instance_private (GraphsDataItemIterator* self)
{
	return G_STRUCT_MEMBER_P (self, GraphsDataItemIterator_private_offset);
}

static GraphsDataItemIterator*
graphs_data_item_iterator_construct (GType object_type,
                                     GraphsData* data)
{
	GraphsDataItemIterator * self = NULL;
	GraphsData* _tmp0_;
	g_return_val_if_fail (data != NULL, NULL);
	self = (GraphsDataItemIterator*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (data);
	_g_object_unref0 (self->priv->_data);
	self->priv->_data = _tmp0_;
	return self;
}

static GraphsDataItemIterator*
graphs_data_item_iterator_new (GraphsData* data)
{
	return graphs_data_item_iterator_construct (GRAPHS_DATA_TYPE_ITEM_ITERATOR, data);
}

static gboolean
graphs_data_item_iterator_real_foreach (GeeTraversable* base,
                                        GeeForallFunc f,
                                        gpointer f_target)
{
	GraphsDataItemIterator * self;
	guint n_items = 0U;
	GraphsData* _tmp0_;
	gint _tmp4_;
	gboolean result;
	self = (GraphsDataItemIterator*) base;
	_tmp0_ = self->priv->_data;
	n_items = g_list_model_get_n_items ((GListModel*) _tmp0_);
	while (TRUE) {
		GraphsData* _tmp1_;
		GObject* _tmp2_;
		gint _tmp3_;
		if (!(((guint) self->priv->_index) < n_items)) {
			break;
		}
		_tmp1_ = self->priv->_data;
		_tmp2_ = g_list_model_get_item ((GListModel*) _tmp1_, (guint) self->priv->_index);
		if (!f (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GRAPHS_TYPE_ITEM, GraphsItem), f_target)) {
			result = FALSE;
			return result;
		}
		_tmp3_ = self->priv->_index;
		self->priv->_index = _tmp3_ + 1;
	}
	_tmp4_ = self->priv->_index;
	self->priv->_index = _tmp4_ - 1;
	result = TRUE;
	return result;
}

static gboolean
graphs_data_item_iterator_real_has_next (GeeIterator* base)
{
	GraphsDataItemIterator * self;
	GraphsData* _tmp0_;
	gboolean result;
	self = (GraphsDataItemIterator*) base;
	_tmp0_ = self->priv->_data;
	result = ((guint) (self->priv->_index + 1)) < g_list_model_get_n_items ((GListModel*) _tmp0_);
	return result;
}

static gboolean
graphs_data_item_iterator_real_next (GeeIterator* base)
{
	GraphsDataItemIterator * self;
	gboolean result;
	self = (GraphsDataItemIterator*) base;
	if (gee_iterator_has_next ((GeeIterator*) self)) {
		gint _tmp0_;
		_tmp0_ = self->priv->_index;
		self->priv->_index = _tmp0_ + 1;
		result = TRUE;
		return result;
	}
	result = FALSE;
	return result;
}

static GraphsItem*
graphs_data_item_iterator_real_get (GeeIterator* base)
{
	GraphsDataItemIterator * self;
	GraphsData* _tmp0_;
	GObject* _tmp1_;
	GraphsItem* result;
	self = (GraphsDataItemIterator*) base;
	_tmp0_ = self->priv->_data;
	_tmp1_ = g_list_model_get_item ((GListModel*) _tmp0_, (guint) self->priv->_index);
	result = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GRAPHS_TYPE_ITEM, GraphsItem);
	return result;
}

static void
graphs_data_item_iterator_real_remove (GeeIterator* base)
{
	GraphsDataItemIterator * self;
	self = (GraphsDataItemIterator*) base;
	g_assert_not_reached ();
}

static gboolean
graphs_data_item_iterator_real_get_read_only (GeeIterator* base)
{
	gboolean result;
	GraphsDataItemIterator* self;
	self = (GraphsDataItemIterator*) base;
	result = self->priv->_read_only;
	return result;
}

static gboolean
graphs_data_item_iterator_real_get_valid (GeeIterator* base)
{
	gboolean result;
	GraphsDataItemIterator* self;
	gboolean _tmp0_ = FALSE;
	self = (GraphsDataItemIterator*) base;
	if (self->priv->_index >= 0) {
		_tmp0_ = gee_iterator_has_next ((GeeIterator*) self);
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

static void
graphs_data_item_iterator_class_init (GraphsDataItemIteratorClass * klass,
                                      gpointer klass_data)
{
	graphs_data_item_iterator_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GraphsDataItemIterator_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_graphs_data_item_iterator_get_property;
	G_OBJECT_CLASS (klass)->finalize = graphs_data_item_iterator_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_DATA_ITEM_ITERATOR_READ_ONLY_PROPERTY, graphs_data_item_iterator_properties[GRAPHS_DATA_ITEM_ITERATOR_READ_ONLY_PROPERTY] = g_param_spec_boolean ("read-only", "read-only", "read-only", TRUE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_DATA_ITEM_ITERATOR_VALID_PROPERTY, graphs_data_item_iterator_properties[GRAPHS_DATA_ITEM_ITERATOR_VALID_PROPERTY] = g_param_spec_boolean ("valid", "valid", "valid", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static GType
graphs_data_item_iterator_gee_traversable_get_g_type (GraphsDataItemIterator* self)
{
	return (GType) GRAPHS_TYPE_ITEM;
}

static GBoxedCopyFunc
graphs_data_item_iterator_gee_traversable_get_g_dup_func (GraphsDataItemIterator* self)
{
	return (GBoxedCopyFunc) g_object_ref;
}

static GDestroyNotify
graphs_data_item_iterator_gee_traversable_get_g_destroy_func (GraphsDataItemIterator* self)
{
	return (GDestroyNotify) g_object_unref;
}

static void
graphs_data_item_iterator_gee_traversable_interface_init (GeeTraversableIface * iface,
                                                          gpointer iface_data)
{
	graphs_data_item_iterator_gee_traversable_parent_iface = g_type_interface_peek_parent (iface);
	iface->foreach = (gboolean (*) (GeeTraversable*, GeeForallFunc, gpointer)) graphs_data_item_iterator_real_foreach;
	iface->get_g_type = (GType (*) (GeeTraversable *)) graphs_data_item_iterator_gee_traversable_get_g_type;
	iface->get_g_dup_func = (GBoxedCopyFunc (*) (GeeTraversable *)) graphs_data_item_iterator_gee_traversable_get_g_dup_func;
	iface->get_g_destroy_func = (GDestroyNotify (*) (GeeTraversable *)) graphs_data_item_iterator_gee_traversable_get_g_destroy_func;
}

static void
graphs_data_item_iterator_gee_iterator_interface_init (GeeIteratorIface * iface,
                                                       gpointer iface_data)
{
	graphs_data_item_iterator_gee_iterator_parent_iface = g_type_interface_peek_parent (iface);
	iface->has_next = (gboolean (*) (GeeIterator*)) graphs_data_item_iterator_real_has_next;
	iface->next = (gboolean (*) (GeeIterator*)) graphs_data_item_iterator_real_next;
	iface->get = (gpointer (*) (GeeIterator*)) graphs_data_item_iterator_real_get;
	iface->remove = (void (*) (GeeIterator*)) graphs_data_item_iterator_real_remove;
	iface->get_read_only = graphs_data_item_iterator_real_get_read_only;
	iface->get_valid = graphs_data_item_iterator_real_get_valid;
}

static void
graphs_data_item_iterator_instance_init (GraphsDataItemIterator * self,
                                         gpointer klass)
{
	self->priv = graphs_data_item_iterator_get_instance_private (self);
	self->priv->_index = -1;
	self->priv->_read_only = TRUE;
}

static void
graphs_data_item_iterator_finalize (GObject * obj)
{
	GraphsDataItemIterator * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRAPHS_DATA_TYPE_ITEM_ITERATOR, GraphsDataItemIterator);
	_g_object_unref0 (self->priv->_data);
	G_OBJECT_CLASS (graphs_data_item_iterator_parent_class)->finalize (obj);
}

static GType
graphs_data_item_iterator_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GraphsDataItemIteratorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) graphs_data_item_iterator_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GraphsDataItemIterator), 0, (GInstanceInitFunc) graphs_data_item_iterator_instance_init, NULL };
	static const GInterfaceInfo gee_traversable_info = { (GInterfaceInitFunc) graphs_data_item_iterator_gee_traversable_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	static const GInterfaceInfo gee_iterator_info = { (GInterfaceInitFunc) graphs_data_item_iterator_gee_iterator_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType graphs_data_item_iterator_type_id;
	graphs_data_item_iterator_type_id = g_type_register_static (G_TYPE_OBJECT, "GraphsDataItemIterator", &g_define_type_info, 0);
	g_type_add_interface_static (graphs_data_item_iterator_type_id, GEE_TYPE_TRAVERSABLE, &gee_traversable_info);
	g_type_add_interface_static (graphs_data_item_iterator_type_id, GEE_TYPE_ITERATOR, &gee_iterator_info);
	GraphsDataItemIterator_private_offset = g_type_add_instance_private (graphs_data_item_iterator_type_id, sizeof (GraphsDataItemIteratorPrivate));
	return graphs_data_item_iterator_type_id;
}

static GType
graphs_data_item_iterator_get_type (void)
{
	static volatile gsize graphs_data_item_iterator_type_id__once = 0;
	if (g_once_init_enter (&graphs_data_item_iterator_type_id__once)) {
		GType graphs_data_item_iterator_type_id;
		graphs_data_item_iterator_type_id = graphs_data_item_iterator_get_type_once ();
		g_once_init_leave (&graphs_data_item_iterator_type_id__once, graphs_data_item_iterator_type_id);
	}
	return graphs_data_item_iterator_type_id__once;
}

static void
_vala_graphs_data_item_iterator_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec)
{
	GraphsDataItemIterator * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRAPHS_DATA_TYPE_ITEM_ITERATOR, GraphsDataItemIterator);
	switch (property_id) {
		case GRAPHS_DATA_ITEM_ITERATOR_READ_ONLY_PROPERTY:
		g_value_set_boolean (value, gee_iterator_get_read_only ((GeeIterator*) self));
		break;
		case GRAPHS_DATA_ITEM_ITERATOR_VALID_PROPERTY:
		g_value_set_boolean (value, gee_iterator_get_valid ((GeeIterator*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
__graphs_data_update_used_positions_g_list_model_items_changed (GListModel* _sender,
                                                                guint position,
                                                                guint removed,
                                                                guint added,
                                                                gpointer self)
{
	_graphs_data_update_used_positions ((GraphsData*) self);
}

static void
_graphs_data___lambda88_ (GraphsData* self,
                          const gchar* stylename)
{
	GraphsFigureSettings* _tmp0_;
	GraphsFigureSettings* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	GraphsFigureSettings* _tmp4_;
	GraphsFigureSettings* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	g_return_if_fail (stylename != NULL);
	_tmp0_ = graphs_data_get_figure_settings (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = graphs_figure_settings_get_use_custom_style (_tmp1_);
	_tmp3_ = _tmp2_;
	if (!_tmp3_) {
		return;
	}
	_tmp4_ = graphs_data_get_figure_settings (self);
	_tmp5_ = _tmp4_;
	_tmp6_ = graphs_figure_settings_get_custom_style (_tmp5_);
	_tmp7_ = _tmp6_;
	if (g_strcmp0 (_tmp7_, stylename) == 0) {
		graphs_data_handle_style_change (self, FALSE, NULL, NULL);
	}
}

static void
__graphs_data___lambda88__graphs_style_manager_style_changed (GraphsStyleManager* _sender,
                                                              const gchar* stylename,
                                                              gpointer self)
{
	_graphs_data___lambda88_ ((GraphsData*) self, stylename);
}

static void
_graphs_data___lambda89_ (GraphsData* self,
                          const gchar* stylename)
{
	GraphsFigureSettings* _tmp0_;
	GraphsFigureSettings* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	GraphsFigureSettings* _tmp4_;
	GraphsFigureSettings* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	g_return_if_fail (stylename != NULL);
	_tmp0_ = graphs_data_get_figure_settings (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = graphs_figure_settings_get_use_custom_style (_tmp1_);
	_tmp3_ = _tmp2_;
	if (!_tmp3_) {
		return;
	}
	_tmp4_ = graphs_data_get_figure_settings (self);
	_tmp5_ = _tmp4_;
	_tmp6_ = graphs_figure_settings_get_custom_style (_tmp5_);
	_tmp7_ = _tmp6_;
	if (g_strcmp0 (_tmp7_, stylename) == 0) {
		GraphsFigureSettings* _tmp8_;
		GraphsFigureSettings* _tmp9_;
		_tmp8_ = graphs_data_get_figure_settings (self);
		_tmp9_ = _tmp8_;
		graphs_figure_settings_set_use_custom_style (_tmp9_, FALSE);
	}
}

static void
__graphs_data___lambda89__graphs_style_manager_style_deleted (GraphsStyleManager* _sender,
                                                              const gchar* stylename,
                                                              gpointer self)
{
	_graphs_data___lambda89_ ((GraphsData*) self, stylename);
}

static void
_graphs_data___lambda90_ (GraphsData* self,
                          const gchar* old_name,
                          const gchar* new_name)
{
	GraphsFigureSettings* _tmp0_;
	GraphsFigureSettings* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	g_return_if_fail (old_name != NULL);
	g_return_if_fail (new_name != NULL);
	_tmp0_ = graphs_data_get_figure_settings (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = graphs_figure_settings_get_custom_style (_tmp1_);
	_tmp3_ = _tmp2_;
	if (g_strcmp0 (_tmp3_, old_name) == 0) {
		GraphsFigureSettings* _tmp4_;
		GraphsFigureSettings* _tmp5_;
		_tmp4_ = graphs_data_get_figure_settings (self);
		_tmp5_ = _tmp4_;
		graphs_figure_settings_set_custom_style (_tmp5_, new_name);
	}
}

static void
__graphs_data___lambda90__graphs_style_manager_style_renamed (GraphsStyleManager* _sender,
                                                              const gchar* old_name,
                                                              const gchar* new_name,
                                                              gpointer self)
{
	_graphs_data___lambda90_ ((GraphsData*) self, old_name, new_name);
}

static void
_graphs_data___lambda91_ (GraphsData* self)
{
	GraphsFigureSettings* _tmp0_;
	GraphsFigureSettings* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	_tmp0_ = graphs_data_get_figure_settings (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = graphs_figure_settings_get_use_custom_style (_tmp1_);
	_tmp3_ = _tmp2_;
	if (!_tmp3_) {
		graphs_data_handle_style_change (self, FALSE, NULL, NULL);
	}
}

static void
__graphs_data___lambda91__g_object_notify (GObject* _sender,
                                           GParamSpec* pspec,
                                           gpointer self)
{
	_graphs_data___lambda91_ ((GraphsData*) self);
}

static void
_graphs_data___lambda92_ (GraphsData* self)
{
	GraphsStyle* style = NULL;
	GraphsStyle* _tmp0_;
	GraphsStyle* _tmp1_;
	GFile* _tmp2_;
	GFile* _tmp3_;
	_tmp0_ = graphs_data_get_selected_style (self);
	style = _tmp0_;
	_tmp1_ = style;
	_tmp2_ = graphs_style_get_file (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_ == NULL) {
		GraphsFigureSettings* _tmp4_;
		GraphsFigureSettings* _tmp5_;
		gboolean _tmp6_;
		gboolean _tmp7_;
		_tmp4_ = graphs_data_get_figure_settings (self);
		_tmp5_ = _tmp4_;
		_tmp6_ = graphs_figure_settings_get_use_custom_style (_tmp5_);
		_tmp7_ = _tmp6_;
		if (_tmp7_) {
			GraphsFigureSettings* _tmp8_;
			GraphsFigureSettings* _tmp9_;
			_tmp8_ = graphs_data_get_figure_settings (self);
			_tmp9_ = _tmp8_;
			graphs_figure_settings_set_use_custom_style (_tmp9_, FALSE);
		}
	} else {
		GraphsStyle* _tmp10_;
		const gchar* _tmp11_;
		const gchar* _tmp12_;
		GraphsFigureSettings* _tmp13_;
		GraphsFigureSettings* _tmp14_;
		const gchar* _tmp15_;
		const gchar* _tmp16_;
		GraphsFigureSettings* _tmp22_;
		GraphsFigureSettings* _tmp23_;
		gboolean _tmp24_;
		gboolean _tmp25_;
		_tmp10_ = style;
		_tmp11_ = graphs_style_get_name (_tmp10_);
		_tmp12_ = _tmp11_;
		_tmp13_ = graphs_data_get_figure_settings (self);
		_tmp14_ = _tmp13_;
		_tmp15_ = graphs_figure_settings_get_custom_style (_tmp14_);
		_tmp16_ = _tmp15_;
		if (g_strcmp0 (_tmp12_, _tmp16_) != 0) {
			GraphsFigureSettings* _tmp17_;
			GraphsFigureSettings* _tmp18_;
			GraphsStyle* _tmp19_;
			const gchar* _tmp20_;
			const gchar* _tmp21_;
			_tmp17_ = graphs_data_get_figure_settings (self);
			_tmp18_ = _tmp17_;
			_tmp19_ = style;
			_tmp20_ = graphs_style_get_name (_tmp19_);
			_tmp21_ = _tmp20_;
			graphs_figure_settings_set_custom_style (_tmp18_, _tmp21_);
		}
		_tmp22_ = graphs_data_get_figure_settings (self);
		_tmp23_ = _tmp22_;
		_tmp24_ = graphs_figure_settings_get_use_custom_style (_tmp23_);
		_tmp25_ = _tmp24_;
		if (!_tmp25_) {
			GraphsFigureSettings* _tmp26_;
			GraphsFigureSettings* _tmp27_;
			_tmp26_ = graphs_data_get_figure_settings (self);
			_tmp27_ = _tmp26_;
			graphs_figure_settings_set_use_custom_style (_tmp27_, TRUE);
		}
	}
	_g_object_unref0 (style);
}

static void
__graphs_data___lambda92__gtk_selection_model_selection_changed (GtkSelectionModel* _sender,
                                                                 guint position,
                                                                 guint n_items,
                                                                 gpointer self)
{
	_graphs_data___lambda92_ ((GraphsData*) self);
}

static GObject *
graphs_data_constructor (GType type,
                         guint n_construct_properties,
                         GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GraphsData * self;
	gchar** _tmp0_;
	gchar** _tmp1_;
	GSettings* _tmp2_;
	GListStore* _tmp3_;
	GListStore* _tmp4_;
	GListModel* _tmp5_;
	GtkSingleSelection* _tmp6_;
	GtkSingleSelection* _tmp7_;
	GSettings* _tmp8_;
	GraphsFigureSettings* _tmp9_;
	GraphsFigureSettings* _tmp10_;
	GraphsStyleManager* style_manager = NULL;
	GraphsStyleManager* _tmp11_;
	GraphsStyleManager* _tmp12_;
	GraphsStyleManager* _tmp13_;
	GraphsStyleManager* _tmp14_;
	GraphsStyleManager* _tmp15_;
	GraphsStyleManager* _tmp16_;
	AdwStyleManager* _tmp17_;
	GtkSingleSelection* _tmp18_;
	GeeList* _tmp19_;
	GraphsFigureSettings* _tmp20_;
	GraphsFigureSettings* _tmp21_;
	GraphsLimits* _tmp22_;
	GraphsLimits* _tmp23_;
	GraphsFigureSettings* _tmp24_;
	GraphsFigureSettings* _tmp25_;
	gboolean _tmp26_;
	gboolean _tmp27_;
	parent_class = G_OBJECT_CLASS (graphs_data_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRAPHS_TYPE_DATA, GraphsData);
	_tmp0_ = g_new0 (gchar*, 0 + 1);
	self->priv->_color_cycle = (_vala_array_free (self->priv->_color_cycle, self->priv->_color_cycle_length1, (GDestroyNotify) g_free), NULL);
	self->priv->_color_cycle = _tmp0_;
	self->priv->_color_cycle_length1 = 0;
	self->priv->__color_cycle_size_ = self->priv->_color_cycle_length1;
	_tmp1_ = g_new0 (gchar*, 0 + 1);
	self->priv->_errbar_color_cycle = (_vala_array_free (self->priv->_errbar_color_cycle, self->priv->_errbar_color_cycle_length1, (GDestroyNotify) g_free), NULL);
	self->priv->_errbar_color_cycle = _tmp1_;
	self->priv->_errbar_color_cycle_length1 = 0;
	self->priv->__errbar_color_cycle_size_ = self->priv->_errbar_color_cycle_length1;
	g_signal_connect_object ((GListModel*) self, "items-changed", (GCallback) __graphs_data_update_used_positions_g_list_model_items_changed, self, 0);
	_tmp2_ = graphs_application_get_settings_child ("figure");
	_g_object_unref0 (self->priv->_settings);
	self->priv->_settings = _tmp2_;
	_tmp3_ = graphs_style_manager_get_style_model ();
	_tmp4_ = _tmp3_;
	_tmp5_ = _g_object_ref0 ((GListModel*) _tmp4_);
	_tmp6_ = gtk_single_selection_new (_tmp5_);
	_tmp7_ = _tmp6_;
	graphs_data_set_style_selection_model (self, _tmp7_);
	_g_object_unref0 (_tmp7_);
	_tmp8_ = self->priv->_settings;
	_tmp9_ = graphs_figure_settings_new (_tmp8_);
	_tmp10_ = _tmp9_;
	graphs_data_set_figure_settings (self, _tmp10_);
	_g_object_unref0 (_tmp10_);
	_tmp11_ = graphs_style_manager_get_instance ();
	_tmp12_ = _tmp11_;
	_tmp13_ = _g_object_ref0 (_tmp12_);
	style_manager = _tmp13_;
	_tmp14_ = style_manager;
	g_signal_connect_object (_tmp14_, "style-changed", (GCallback) __graphs_data___lambda88__graphs_style_manager_style_changed, self, 0);
	_tmp15_ = style_manager;
	g_signal_connect_object (_tmp15_, "style-deleted", (GCallback) __graphs_data___lambda89__graphs_style_manager_style_deleted, self, 0);
	_tmp16_ = style_manager;
	g_signal_connect_object (_tmp16_, "style-renamed", (GCallback) __graphs_data___lambda90__graphs_style_manager_style_renamed, self, 0);
	_tmp17_ = adw_style_manager_get_default ();
	g_signal_connect_object ((GObject*) _tmp17_, "notify", (GCallback) __graphs_data___lambda91__g_object_notify, self, 0);
	_tmp18_ = self->priv->_style_selection_model;
	g_signal_connect_object ((GtkSelectionModel*) _tmp18_, "selection-changed", (GCallback) __graphs_data___lambda92__gtk_selection_model_selection_changed, self, 0);
	_tmp19_ = self->priv->_view_history_states;
	_tmp20_ = graphs_data_get_figure_settings (self);
	_tmp21_ = _tmp20_;
	_tmp22_ = graphs_figure_settings_get_limits (_tmp21_);
	_tmp23_ = _tmp22_;
	gee_collection_add ((GeeCollection*) _tmp19_, _tmp23_);
	_graphs_limits_unref0 (_tmp23_);
	graphs_data_run_python_method (self, "_init_history_states");
	_tmp24_ = graphs_data_get_figure_settings (self);
	_tmp25_ = _tmp24_;
	_tmp26_ = graphs_figure_settings_get_use_custom_style (_tmp25_);
	_tmp27_ = _tmp26_;
	if (_tmp27_) {
		_graphs_data_on_custom_style (self, NULL, NULL);
	}
	_g_object_unref0 (style_manager);
	return obj;
}

static void
graphs_data_class_init (GraphsDataClass * klass,
                        gpointer klass_data)
{
	graphs_data_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GraphsData_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_graphs_data_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_graphs_data_set_property;
	G_OBJECT_CLASS (klass)->constructor = graphs_data_constructor;
	G_OBJECT_CLASS (klass)->finalize = graphs_data_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_DATA_CAN_UNDO_PROPERTY, graphs_data_properties[GRAPHS_DATA_CAN_UNDO_PROPERTY] = g_param_spec_boolean ("can-undo", "can-undo", "can-undo", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_DATA_CAN_REDO_PROPERTY, graphs_data_properties[GRAPHS_DATA_CAN_REDO_PROPERTY] = g_param_spec_boolean ("can-redo", "can-redo", "can-redo", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_DATA_CAN_VIEW_BACK_PROPERTY, graphs_data_properties[GRAPHS_DATA_CAN_VIEW_BACK_PROPERTY] = g_param_spec_boolean ("can-view-back", "can-view-back", "can-view-back", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_DATA_CAN_VIEW_FORWARD_PROPERTY, graphs_data_properties[GRAPHS_DATA_CAN_VIEW_FORWARD_PROPERTY] = g_param_spec_boolean ("can-view-forward", "can-view-forward", "can-view-forward", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_DATA_FILE_PROPERTY, graphs_data_properties[GRAPHS_DATA_FILE_PROPERTY] = g_param_spec_object ("file", "file", "file", g_file_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_DATA_UNSAVED_PROPERTY, graphs_data_properties[GRAPHS_DATA_UNSAVED_PROPERTY] = g_param_spec_boolean ("unsaved", "unsaved", "unsaved", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_EXPLICIT_NOTIFY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_DATA_STYLE_SELECTION_MODEL_PROPERTY, graphs_data_properties[GRAPHS_DATA_STYLE_SELECTION_MODEL_PROPERTY] = g_param_spec_object ("style-selection-model", "style-selection-model", "style-selection-model", gtk_single_selection_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_DATA_SELECTED_STYLENAME_PROPERTY, graphs_data_properties[GRAPHS_DATA_SELECTED_STYLENAME_PROPERTY] = g_param_spec_string ("selected-stylename", "selected-stylename", "selected-stylename", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_DATA_FIGURE_SETTINGS_PROPERTY, graphs_data_properties[GRAPHS_DATA_FIGURE_SETTINGS_PROPERTY] = g_param_spec_object ("figure-settings", "figure-settings", "figure-settings", GRAPHS_TYPE_FIGURE_SETTINGS, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	graphs_data_signals[GRAPHS_DATA_STYLE_CHANGED_SIGNAL] = g_signal_new ("style-changed", GRAPHS_TYPE_DATA, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
	graphs_data_signals[GRAPHS_DATA_LOAD_REQUEST_SIGNAL] = g_signal_new ("load-request", GRAPHS_TYPE_DATA, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_STRING__OBJECT_FLAGS, G_TYPE_STRING, 2, g_file_get_type (), GRAPHS_TYPE_PROJECT_PARSE_FLAGS);
	graphs_data_signals[GRAPHS_DATA_ADD_HISTORY_STATE_REQUEST_SIGNAL] = g_signal_new ("add-history-state-request", GRAPHS_TYPE_DATA, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_BOOLEAN__VOID, G_TYPE_BOOLEAN, 0);
	graphs_data_signals[GRAPHS_DATA_POSITION_CHANGED_SIGNAL] = g_signal_new ("position-changed", GRAPHS_TYPE_DATA, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__UINT_UINT, G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
	graphs_data_signals[GRAPHS_DATA_ITEM_CHANGED_SIGNAL] = g_signal_new ("item-changed", GRAPHS_TYPE_DATA, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_STRING, G_TYPE_NONE, 2, GRAPHS_TYPE_ITEM, G_TYPE_STRING);
	graphs_data_signals[GRAPHS_DATA_ITEM_ADDED_SIGNAL] = g_signal_new ("item-added", GRAPHS_TYPE_DATA, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GRAPHS_TYPE_ITEM);
	graphs_data_signals[GRAPHS_DATA_ITEM_REMOVED_SIGNAL] = g_signal_new ("item-removed", GRAPHS_TYPE_DATA, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_UINT, G_TYPE_NONE, 2, GRAPHS_TYPE_ITEM, G_TYPE_UINT);
	graphs_data_signals[GRAPHS_DATA_FIGURE_SETTINGS_CHANGED_SIGNAL] = g_signal_new ("figure-settings-changed", GRAPHS_TYPE_DATA, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
}

static void
graphs_data_g_list_model_interface_init (GListModelInterface * iface,
                                         gpointer iface_data)
{
	graphs_data_g_list_model_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_item = (GObject* (*) (GListModel*, guint)) graphs_data_real_get_item;
	iface->get_item_type = (GType (*) (GListModel*)) graphs_data_real_get_item_type;
	iface->get_n_items = (guint (*) (GListModel*)) graphs_data_real_get_n_items;
}

static void
graphs_data_gtk_selection_model_interface_init (GtkSelectionModelInterface * iface,
                                                gpointer iface_data)
{
	graphs_data_gtk_selection_model_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_selection_in_range = (GtkBitset* (*) (GtkSelectionModel*, guint, guint)) graphs_data_real_get_selection_in_range;
	iface->is_selected = (gboolean (*) (GtkSelectionModel*, guint)) graphs_data_real_is_selected;
	iface->select_all = (gboolean (*) (GtkSelectionModel*)) graphs_data_real_select_all;
	iface->select_item = (gboolean (*) (GtkSelectionModel*, guint, gboolean)) graphs_data_real_select_item;
	iface->select_range = (gboolean (*) (GtkSelectionModel*, guint, guint, gboolean)) graphs_data_real_select_range;
	iface->set_selection = (gboolean (*) (GtkSelectionModel*, GtkBitset*, GtkBitset*)) graphs_data_real_set_selection;
	iface->unselect_all = (gboolean (*) (GtkSelectionModel*)) graphs_data_real_unselect_all;
	iface->unselect_item = (gboolean (*) (GtkSelectionModel*, guint)) graphs_data_real_unselect_item;
	iface->unselect_range = (gboolean (*) (GtkSelectionModel*, guint, guint)) graphs_data_real_unselect_range;
}

static GType
graphs_data_gee_traversable_get_g_type (GraphsData* self)
{
	return (GType) GRAPHS_TYPE_ITEM;
}

static GBoxedCopyFunc
graphs_data_gee_traversable_get_g_dup_func (GraphsData* self)
{
	return (GBoxedCopyFunc) g_object_ref;
}

static GDestroyNotify
graphs_data_gee_traversable_get_g_destroy_func (GraphsData* self)
{
	return (GDestroyNotify) g_object_unref;
}

static void
graphs_data_gee_traversable_interface_init (GeeTraversableIface * iface,
                                            gpointer iface_data)
{
	graphs_data_gee_traversable_parent_iface = g_type_interface_peek_parent (iface);
	iface->foreach = (gboolean (*) (GeeTraversable*, GeeForallFunc, gpointer)) graphs_data_real_foreach;
	iface->get_g_type = (GType (*) (GeeTraversable *)) graphs_data_gee_traversable_get_g_type;
	iface->get_g_dup_func = (GBoxedCopyFunc (*) (GeeTraversable *)) graphs_data_gee_traversable_get_g_dup_func;
	iface->get_g_destroy_func = (GDestroyNotify (*) (GeeTraversable *)) graphs_data_gee_traversable_get_g_destroy_func;
}

static GType
graphs_data_gee_iterable_get_g_type (GraphsData* self)
{
	return (GType) GRAPHS_TYPE_ITEM;
}

static GBoxedCopyFunc
graphs_data_gee_iterable_get_g_dup_func (GraphsData* self)
{
	return (GBoxedCopyFunc) g_object_ref;
}

static GDestroyNotify
graphs_data_gee_iterable_get_g_destroy_func (GraphsData* self)
{
	return (GDestroyNotify) g_object_unref;
}

static void
graphs_data_gee_iterable_interface_init (GeeIterableIface * iface,
                                         gpointer iface_data)
{
	graphs_data_gee_iterable_parent_iface = g_type_interface_peek_parent (iface);
	iface->iterator = (GeeIterator* (*) (GeeIterable*)) graphs_data_real_iterator;
	iface->get_g_type = (GType (*) (GeeIterable *)) graphs_data_gee_iterable_get_g_type;
	iface->get_g_dup_func = (GBoxedCopyFunc (*) (GeeIterable *)) graphs_data_gee_iterable_get_g_dup_func;
	iface->get_g_destroy_func = (GDestroyNotify (*) (GeeIterable *)) graphs_data_gee_iterable_get_g_destroy_func;
}

static void
graphs_data_instance_init (GraphsData * self,
                           gpointer klass)
{
	GraphsItem** _tmp0_;
	GeeArrayList* _tmp1_;
	self->priv = graphs_data_get_instance_private (self);
	self->priv->_can_undo = FALSE;
	self->priv->_can_redo = FALSE;
	self->priv->_can_view_back = FALSE;
	self->priv->_can_view_forward = FALSE;
	self->priv->_unsaved = FALSE;
	_tmp0_ = g_new0 (GraphsItem*, 8 + 1);
	self->priv->_items = _tmp0_;
	self->priv->_items_length1 = 8;
	self->priv->__items_size_ = self->priv->_items_length1;
	self->priv->_n_items = 0;
	self->priv->_notify_selection_changed = TRUE;
	_tmp1_ = gee_array_list_new (GRAPHS_TYPE_LIMITS, (GBoxedCopyFunc) graphs_limits_ref, (GDestroyNotify) graphs_limits_unref, NULL, NULL, NULL);
	self->priv->_view_history_states = (GeeList*) _tmp1_;
	self->priv->_view_history_pos = -1;
}

static void
graphs_data_finalize (GObject * obj)
{
	GraphsData * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRAPHS_TYPE_DATA, GraphsData);
	_g_object_unref0 (self->priv->_file);
	_g_object_unref0 (self->priv->_style_selection_model);
	_g_object_unref0 (self->priv->_figure_settings);
	self->priv->_used_positions = (g_free (self->priv->_used_positions), NULL);
	self->priv->_items = (_vala_array_free (self->priv->_items, self->priv->_items_length1, (GDestroyNotify) g_object_unref), NULL);
	self->priv->_color_cycle = (_vala_array_free (self->priv->_color_cycle, self->priv->_color_cycle_length1, (GDestroyNotify) g_free), NULL);
	self->priv->_used_colors = (_vala_array_free (self->priv->_used_colors, self->priv->_used_colors_length1, (GDestroyNotify) g_free), NULL);
	self->priv->_errbar_color_cycle = (_vala_array_free (self->priv->_errbar_color_cycle, self->priv->_errbar_color_cycle_length1, (GDestroyNotify) g_free), NULL);
	self->priv->_used_errbar_colors = (_vala_array_free (self->priv->_used_errbar_colors, self->priv->_used_errbar_colors_length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (self->priv->_settings);
	_g_object_unref0 (self->priv->_view_history_states);
	G_OBJECT_CLASS (graphs_data_parent_class)->finalize (obj);
}

/**
     * Data class
     */
static GType
graphs_data_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GraphsDataClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) graphs_data_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GraphsData), 0, (GInstanceInitFunc) graphs_data_instance_init, NULL };
	static const GInterfaceInfo g_list_model_info = { (GInterfaceInitFunc) graphs_data_g_list_model_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	static const GInterfaceInfo gtk_selection_model_info = { (GInterfaceInitFunc) graphs_data_gtk_selection_model_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	static const GInterfaceInfo gee_traversable_info = { (GInterfaceInitFunc) graphs_data_gee_traversable_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	static const GInterfaceInfo gee_iterable_info = { (GInterfaceInitFunc) graphs_data_gee_iterable_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType graphs_data_type_id;
	graphs_data_type_id = g_type_register_static (G_TYPE_OBJECT, "GraphsData", &g_define_type_info, 0);
	g_type_add_interface_static (graphs_data_type_id, g_list_model_get_type (), &g_list_model_info);
	g_type_add_interface_static (graphs_data_type_id, gtk_selection_model_get_type (), &gtk_selection_model_info);
	g_type_add_interface_static (graphs_data_type_id, GEE_TYPE_TRAVERSABLE, &gee_traversable_info);
	g_type_add_interface_static (graphs_data_type_id, GEE_TYPE_ITERABLE, &gee_iterable_info);
	GraphsData_private_offset = g_type_add_instance_private (graphs_data_type_id, sizeof (GraphsDataPrivate));
	return graphs_data_type_id;
}

GType
graphs_data_get_type (void)
{
	static volatile gsize graphs_data_type_id__once = 0;
	if (g_once_init_enter (&graphs_data_type_id__once)) {
		GType graphs_data_type_id;
		graphs_data_type_id = graphs_data_get_type_once ();
		g_once_init_leave (&graphs_data_type_id__once, graphs_data_type_id);
	}
	return graphs_data_type_id__once;
}

static void
_vala_graphs_data_get_property (GObject * object,
                                guint property_id,
                                GValue * value,
                                GParamSpec * pspec)
{
	GraphsData * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRAPHS_TYPE_DATA, GraphsData);
	switch (property_id) {
		case GRAPHS_DATA_CAN_UNDO_PROPERTY:
		g_value_set_boolean (value, graphs_data_get_can_undo (self));
		break;
		case GRAPHS_DATA_CAN_REDO_PROPERTY:
		g_value_set_boolean (value, graphs_data_get_can_redo (self));
		break;
		case GRAPHS_DATA_CAN_VIEW_BACK_PROPERTY:
		g_value_set_boolean (value, graphs_data_get_can_view_back (self));
		break;
		case GRAPHS_DATA_CAN_VIEW_FORWARD_PROPERTY:
		g_value_set_boolean (value, graphs_data_get_can_view_forward (self));
		break;
		case GRAPHS_DATA_FILE_PROPERTY:
		g_value_set_object (value, graphs_data_get_file (self));
		break;
		case GRAPHS_DATA_UNSAVED_PROPERTY:
		g_value_set_boolean (value, graphs_data_get_unsaved (self));
		break;
		case GRAPHS_DATA_STYLE_SELECTION_MODEL_PROPERTY:
		g_value_set_object (value, graphs_data_get_style_selection_model (self));
		break;
		case GRAPHS_DATA_SELECTED_STYLENAME_PROPERTY:
		g_value_set_string (value, graphs_data_get_selected_stylename (self));
		break;
		case GRAPHS_DATA_FIGURE_SETTINGS_PROPERTY:
		g_value_set_object (value, graphs_data_get_figure_settings (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_graphs_data_set_property (GObject * object,
                                guint property_id,
                                const GValue * value,
                                GParamSpec * pspec)
{
	GraphsData * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRAPHS_TYPE_DATA, GraphsData);
	switch (property_id) {
		case GRAPHS_DATA_CAN_UNDO_PROPERTY:
		graphs_data_set_can_undo (self, g_value_get_boolean (value));
		break;
		case GRAPHS_DATA_CAN_REDO_PROPERTY:
		graphs_data_set_can_redo (self, g_value_get_boolean (value));
		break;
		case GRAPHS_DATA_CAN_VIEW_BACK_PROPERTY:
		graphs_data_set_can_view_back (self, g_value_get_boolean (value));
		break;
		case GRAPHS_DATA_CAN_VIEW_FORWARD_PROPERTY:
		graphs_data_set_can_view_forward (self, g_value_get_boolean (value));
		break;
		case GRAPHS_DATA_FILE_PROPERTY:
		graphs_data_set_file (self, g_value_get_object (value));
		break;
		case GRAPHS_DATA_UNSAVED_PROPERTY:
		graphs_data_set_unsaved (self, g_value_get_boolean (value));
		break;
		case GRAPHS_DATA_STYLE_SELECTION_MODEL_PROPERTY:
		graphs_data_set_style_selection_model (self, g_value_get_object (value));
		break;
		case GRAPHS_DATA_FIGURE_SETTINGS_PROPERTY:
		graphs_data_set_figure_settings (self, g_value_get_object (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 void
_vala_array_move (gpointer array,
                  gsize element_size,
                  gssize src,
                  gssize dest,
                  gssize length)
{
	memmove (((char*) array) + (dest * element_size), ((char*) array) + (src * element_size), length * element_size);
	if ((src < dest) && ((src + length) > dest)) {
		memset (((char*) array) + (src * element_size), 0, (dest - src) * element_size);
	} else if ((src > dest) && (src < (dest + length))) {
		memset (((char*) array) + ((dest + length) * element_size), 0, (src - dest) * element_size);
	} else if (src != dest) {
		memset (((char*) array) + (src * element_size), 0, length * element_size);
	}
}

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

