/* i-properties-provider.c generated by valac 0.16.0.2-f2187, the Vala compiler
 * generated from i-properties-provider.vala, do not modify */

/* This file is part of GNOME Boxes. License: LGPLv2+*/

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include <float.h>
#include <math.h>
#include <osinfo/osinfo.h>


#define BOXES_TYPE_IPROPERTIES_PROVIDER (boxes_iproperties_provider_get_type ())
#define BOXES_IPROPERTIES_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_IPROPERTIES_PROVIDER, BoxesIPropertiesProvider))
#define BOXES_IS_IPROPERTIES_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_IPROPERTIES_PROVIDER))
#define BOXES_IPROPERTIES_PROVIDER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), BOXES_TYPE_IPROPERTIES_PROVIDER, BoxesIPropertiesProviderIface))

typedef struct _BoxesIPropertiesProvider BoxesIPropertiesProvider;
typedef struct _BoxesIPropertiesProviderIface BoxesIPropertiesProviderIface;

#define BOXES_TYPE_PROPERTIES_PAGE (boxes_properties_page_get_type ())

#define BOXES_TYPE_PAIR (boxes_pair_get_type ())
#define BOXES_PAIR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_PAIR, BoxesPair))
#define BOXES_PAIR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_PAIR, BoxesPairClass))
#define BOXES_IS_PAIR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_PAIR))
#define BOXES_IS_PAIR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_PAIR))
#define BOXES_PAIR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_PAIR, BoxesPairClass))

typedef struct _BoxesPair BoxesPair;
typedef struct _BoxesPairClass BoxesPairClass;

#define BOXES_TYPE_EDITABLE_ENTRY (boxes_editable_entry_get_type ())
#define BOXES_EDITABLE_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_EDITABLE_ENTRY, BoxesEditableEntry))
#define BOXES_EDITABLE_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_EDITABLE_ENTRY, BoxesEditableEntryClass))
#define BOXES_IS_EDITABLE_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_EDITABLE_ENTRY))
#define BOXES_IS_EDITABLE_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_EDITABLE_ENTRY))
#define BOXES_EDITABLE_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_EDITABLE_ENTRY, BoxesEditableEntryClass))

typedef struct _BoxesEditableEntry BoxesEditableEntry;
typedef struct _BoxesEditableEntryClass BoxesEditableEntryClass;
typedef struct _Block21Data Block21Data;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _Block22Data Block22Data;

typedef void (*PropertyStringChanged) (const gchar* value, void* user_data, GError** error);
typedef void (*PropertySizeChanged) (guint64 value, void* user_data, GError** error);
typedef enum  {
	BOXES_PROPERTIES_PAGE_LOGIN,
	BOXES_PROPERTIES_PAGE_SYSTEM,
	BOXES_PROPERTIES_PAGE_DISPLAY,
	BOXES_PROPERTIES_PAGE_DEVICES,
	BOXES_PROPERTIES_PAGE_LAST
} BoxesPropertiesPage;

struct _BoxesIPropertiesProviderIface {
	GTypeInterface parent_iface;
	GList* (*get_properties) (BoxesIPropertiesProvider* self, BoxesPropertiesPage page);
};

struct _Block21Data {
	int _ref_count_;
	BoxesIPropertiesProvider * self;
	BoxesEditableEntry* entry;
	PropertyStringChanged changed;
	gpointer changed_target;
};

typedef enum  {
	BOXES_ERROR_INVALID,
	BOXES_ERROR_COMMAND_FAILED
} BoxesError;
#define BOXES_ERROR boxes_error_quark ()
struct _Block22Data {
	int _ref_count_;
	BoxesIPropertiesProvider * self;
	GtkHScale* scale;
	PropertySizeChanged changed;
	gpointer changed_target;
};



GType boxes_properties_page_get_type (void) G_GNUC_CONST;
gpointer boxes_pair_ref (gpointer instance);
void boxes_pair_unref (gpointer instance);
GParamSpec* boxes_param_spec_pair (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void boxes_value_set_pair (GValue* value, gpointer v_object);
void boxes_value_take_pair (GValue* value, gpointer v_object);
gpointer boxes_value_get_pair (const GValue* value);
GType boxes_pair_get_type (void) G_GNUC_CONST;
GType boxes_iproperties_provider_get_type (void) G_GNUC_CONST;
GList* boxes_iproperties_provider_get_properties (BoxesIPropertiesProvider* self, BoxesPropertiesPage page);
void boxes_iproperties_provider_add_property (BoxesIPropertiesProvider* self, GList** list, const gchar* name, GtkWidget* widget);
BoxesPair* boxes_pair_new (GType t1_type, GBoxedCopyFunc t1_dup_func, GDestroyNotify t1_destroy_func, GType t2_type, GBoxedCopyFunc t2_dup_func, GDestroyNotify t2_destroy_func, gconstpointer first, gconstpointer second);
BoxesPair* boxes_pair_construct (GType object_type, GType t1_type, GBoxedCopyFunc t1_dup_func, GDestroyNotify t1_destroy_func, GType t2_type, GBoxedCopyFunc t2_dup_func, GDestroyNotify t2_destroy_func, gconstpointer first, gconstpointer second);
void boxes_iproperties_provider_add_string_property (BoxesIPropertiesProvider* self, GList** list, const gchar* name, const gchar* value, PropertyStringChanged changed, void* changed_target);
GType boxes_editable_entry_get_type (void) G_GNUC_CONST;
static Block21Data* block21_data_ref (Block21Data* _data21_);
static void block21_data_unref (void * _userdata_);
BoxesEditableEntry* boxes_editable_entry_new (void);
BoxesEditableEntry* boxes_editable_entry_construct (GType object_type);
void boxes_editable_entry_set_text (BoxesEditableEntry* self, const gchar* value);
void boxes_editable_entry_set_selectable (BoxesEditableEntry* self, gboolean value);
void boxes_editable_entry_set_editable (BoxesEditableEntry* self, gboolean value);
static void __lambda14_ (Block21Data* _data21_);
const gchar* boxes_editable_entry_get_text (BoxesEditableEntry* self);
GQuark boxes_error_quark (void);
static void ___lambda14__boxes_editable_entry_editing_done (BoxesEditableEntry* _sender, gpointer self);
void boxes_iproperties_provider_add_size_property (BoxesIPropertiesProvider* self, GList** list, const gchar* name, guint64 size, guint64 min, guint64 max, guint64 step, PropertySizeChanged changed, void* changed_target);
static Block22Data* block22_data_ref (Block22Data* _data22_);
static void block22_data_unref (void * _userdata_);
static gchar* __lambda15_ (BoxesIPropertiesProvider* self, GtkScale* scale, gdouble value);
static gchar* ___lambda15__gtk_scale_format_value (GtkScale* _sender, gdouble value, gpointer self);
static void ___lambda16_ (Block22Data* _data22_);
static void ____lambda16__gtk_range_value_changed (GtkRange* _sender, gpointer self);


GList* boxes_iproperties_provider_get_properties (BoxesIPropertiesProvider* self, BoxesPropertiesPage page) {
	g_return_val_if_fail (self != NULL, NULL);
	return BOXES_IPROPERTIES_PROVIDER_GET_INTERFACE (self)->get_properties (self, page);
}


void boxes_iproperties_provider_add_property (BoxesIPropertiesProvider* self, GList** list, const gchar* name, GtkWidget* widget) {
	const gchar* _tmp0_;
	GtkWidget* _tmp1_;
	BoxesPair* _tmp2_;
	g_return_if_fail (name != NULL);
	g_return_if_fail (widget != NULL);
	_tmp0_ = name;
	_tmp1_ = widget;
	_tmp2_ = boxes_pair_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, GTK_TYPE_WIDGET, (GBoxedCopyFunc) g_object_ref, g_object_unref, _tmp0_, _tmp1_);
	*list = g_list_append (*list, _tmp2_);
}


static Block21Data* block21_data_ref (Block21Data* _data21_) {
	g_atomic_int_inc (&_data21_->_ref_count_);
	return _data21_;
}


static void block21_data_unref (void * _userdata_) {
	Block21Data* _data21_;
	_data21_ = (Block21Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data21_->_ref_count_)) {
		BoxesIPropertiesProvider * self;
		self = _data21_->self;
		_g_object_unref0 (_data21_->entry);
		_g_object_unref0 (self);
		g_slice_free (Block21Data, _data21_);
	}
}


static void __lambda14_ (Block21Data* _data21_) {
	BoxesIPropertiesProvider * self;
	GError * _inner_error_ = NULL;
	self = _data21_->self;
	{
		PropertyStringChanged _tmp0_;
		void* _tmp0__target;
		const gchar* _tmp1_;
		const gchar* _tmp2_;
		_tmp0_ = _data21_->changed;
		_tmp0__target = _data21_->changed_target;
		_tmp1_ = boxes_editable_entry_get_text (_data21_->entry);
		_tmp2_ = _tmp1_;
		_tmp0_ (_tmp2_, _tmp0__target, &_inner_error_);
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == BOXES_ERROR) {
				goto __catch42_boxes_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
	goto __finally42;
	__catch42_boxes_error:
	{
		GError* _error_ = NULL;
		GError* _tmp3_;
		const gchar* _tmp4_;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp3_ = _error_;
		_tmp4_ = _tmp3_->message;
		g_warning ("i-properties-provider.vala:28: %s", _tmp4_);
		_g_error_free0 (_error_);
	}
	__finally42:
	if (_inner_error_ != NULL) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
}


static void ___lambda14__boxes_editable_entry_editing_done (BoxesEditableEntry* _sender, gpointer self) {
	__lambda14_ (self);
}


void boxes_iproperties_provider_add_string_property (BoxesIPropertiesProvider* self, GList** list, const gchar* name, const gchar* value, PropertyStringChanged changed, void* changed_target) {
	Block21Data* _data21_;
	PropertyStringChanged _tmp0_;
	void* _tmp0__target;
	BoxesEditableEntry* _tmp1_;
	BoxesEditableEntry* _tmp2_;
	const gchar* _tmp3_;
	PropertyStringChanged _tmp4_;
	void* _tmp4__target;
	const gchar* _tmp5_;
	g_return_if_fail (name != NULL);
	g_return_if_fail (value != NULL);
	_data21_ = g_slice_new0 (Block21Data);
	_data21_->_ref_count_ = 1;
	_data21_->self = g_object_ref (self);
	_tmp0_ = changed;
	_tmp0__target = changed_target;
	_data21_->changed = _tmp0_;
	_data21_->changed_target = _tmp0__target;
	_tmp1_ = boxes_editable_entry_new ();
	_tmp2_ = g_object_ref_sink (_tmp1_);
	_data21_->entry = _tmp2_;
	_tmp3_ = value;
	boxes_editable_entry_set_text (_data21_->entry, _tmp3_);
	boxes_editable_entry_set_selectable (_data21_->entry, TRUE);
	_tmp4_ = _data21_->changed;
	_tmp4__target = _data21_->changed_target;
	boxes_editable_entry_set_editable (_data21_->entry, _tmp4_ != NULL);
	g_signal_connect_data (_data21_->entry, "editing-done", (GCallback) ___lambda14__boxes_editable_entry_editing_done, block21_data_ref (_data21_), (GClosureNotify) block21_data_unref, 0);
	_tmp5_ = name;
	boxes_iproperties_provider_add_property (self, list, _tmp5_, (GtkWidget*) _data21_->entry);
	block21_data_unref (_data21_);
	_data21_ = NULL;
}


static Block22Data* block22_data_ref (Block22Data* _data22_) {
	g_atomic_int_inc (&_data22_->_ref_count_);
	return _data22_;
}


static void block22_data_unref (void * _userdata_) {
	Block22Data* _data22_;
	_data22_ = (Block22Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data22_->_ref_count_)) {
		BoxesIPropertiesProvider * self;
		self = _data22_->self;
		_g_object_unref0 (_data22_->scale);
		_g_object_unref0 (self);
		g_slice_free (Block22Data, _data22_);
	}
}


static gchar* __lambda15_ (BoxesIPropertiesProvider* self, GtkScale* scale, gdouble value) {
	gchar* result = NULL;
	gdouble _tmp0_;
	gchar* _tmp1_ = NULL;
	g_return_val_if_fail (scale != NULL, NULL);
	_tmp0_ = value;
	_tmp1_ = g_format_size_full (((guint64) _tmp0_) * OSINFO_KIBIBYTES, G_FORMAT_SIZE_IEC_UNITS);
	result = _tmp1_;
	return result;
}


static gchar* ___lambda15__gtk_scale_format_value (GtkScale* _sender, gdouble value, gpointer self) {
	gchar* result;
	result = __lambda15_ (self, _sender, value);
	return result;
}


static void ___lambda16_ (Block22Data* _data22_) {
	BoxesIPropertiesProvider * self;
	GError * _inner_error_ = NULL;
	self = _data22_->self;
	{
		PropertySizeChanged _tmp0_;
		void* _tmp0__target;
		GtkHScale* _tmp1_;
		gdouble _tmp2_ = 0.0;
		_tmp0_ = _data22_->changed;
		_tmp0__target = _data22_->changed_target;
		_tmp1_ = _data22_->scale;
		_tmp2_ = gtk_range_get_value ((GtkRange*) _tmp1_);
		_tmp0_ ((guint64) _tmp2_, _tmp0__target, &_inner_error_);
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == BOXES_ERROR) {
				goto __catch43_boxes_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
	goto __finally43;
	__catch43_boxes_error:
	{
		GError* _error_ = NULL;
		GError* _tmp3_;
		const gchar* _tmp4_;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp3_ = _error_;
		_tmp4_ = _tmp3_->message;
		g_warning ("i-properties-provider.vala:58: %s", _tmp4_);
		_g_error_free0 (_error_);
	}
	__finally43:
	if (_inner_error_ != NULL) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
}


static void ____lambda16__gtk_range_value_changed (GtkRange* _sender, gpointer self) {
	___lambda16_ (self);
}


void boxes_iproperties_provider_add_size_property (BoxesIPropertiesProvider* self, GList** list, const gchar* name, guint64 size, guint64 min, guint64 max, guint64 step, PropertySizeChanged changed, void* changed_target) {
	Block22Data* _data22_;
	PropertySizeChanged _tmp0_;
	void* _tmp0__target;
	guint64 _tmp1_;
	guint64 _tmp2_;
	guint64 _tmp3_;
	GtkHScale* _tmp4_;
	GtkHScale* _tmp5_;
	GtkHScale* _tmp6_;
	GtkHScale* _tmp7_;
	guint64 _tmp8_;
	GtkHScale* _tmp9_;
	GtkHScale* _tmp10_;
	GtkHScale* _tmp11_;
	PropertySizeChanged _tmp12_;
	void* _tmp12__target;
	const gchar* _tmp14_;
	GtkHScale* _tmp15_;
	g_return_if_fail (name != NULL);
	_data22_ = g_slice_new0 (Block22Data);
	_data22_->_ref_count_ = 1;
	_data22_->self = g_object_ref (self);
	_tmp0_ = changed;
	_tmp0__target = changed_target;
	_data22_->changed = _tmp0_;
	_data22_->changed_target = _tmp0__target;
	_tmp1_ = min;
	_tmp2_ = max;
	_tmp3_ = step;
	_tmp4_ = (GtkHScale*) gtk_hscale_new_with_range ((gdouble) _tmp1_, (gdouble) _tmp2_, (gdouble) _tmp3_);
	_tmp5_ = g_object_ref_sink (_tmp4_);
	_data22_->scale = _tmp5_;
	_tmp6_ = _data22_->scale;
	g_signal_connect_object ((GtkScale*) _tmp6_, "format-value", (GCallback) ___lambda15__gtk_scale_format_value, self, 0);
	_tmp7_ = _data22_->scale;
	_tmp8_ = size;
	gtk_range_set_value ((GtkRange*) _tmp7_, (gdouble) _tmp8_);
	_tmp9_ = _data22_->scale;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp9_, TRUE);
	_tmp10_ = _data22_->scale;
	gtk_widget_set_vexpand ((GtkWidget*) _tmp10_, TRUE);
	_tmp11_ = _data22_->scale;
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp11_, 20);
	_tmp12_ = _data22_->changed;
	_tmp12__target = _data22_->changed_target;
	if (_tmp12_ != NULL) {
		GtkHScale* _tmp13_;
		_tmp13_ = _data22_->scale;
		g_signal_connect_data ((GtkRange*) _tmp13_, "value-changed", (GCallback) ____lambda16__gtk_range_value_changed, block22_data_ref (_data22_), (GClosureNotify) block22_data_unref, 0);
	}
	_tmp14_ = name;
	_tmp15_ = _data22_->scale;
	boxes_iproperties_provider_add_property (self, list, _tmp14_, (GtkWidget*) _tmp15_);
	block22_data_unref (_data22_);
	_data22_ = NULL;
}


static void boxes_iproperties_provider_base_init (BoxesIPropertiesProviderIface * iface) {
	static gboolean initialized = FALSE;
	if (!initialized) {
		initialized = TRUE;
	}
}


GType boxes_iproperties_provider_get_type (void) {
	static volatile gsize boxes_iproperties_provider_type_id__volatile = 0;
	if (g_once_init_enter (&boxes_iproperties_provider_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (BoxesIPropertiesProviderIface), (GBaseInitFunc) boxes_iproperties_provider_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
		GType boxes_iproperties_provider_type_id;
		boxes_iproperties_provider_type_id = g_type_register_static (G_TYPE_INTERFACE, "BoxesIPropertiesProvider", &g_define_type_info, 0);
		g_type_interface_add_prerequisite (boxes_iproperties_provider_type_id, G_TYPE_OBJECT);
		g_once_init_leave (&boxes_iproperties_provider_type_id__volatile, boxes_iproperties_provider_type_id);
	}
	return boxes_iproperties_provider_type_id__volatile;
}



