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

/*
 * Copyright (c) 2024-2025 focus-timer contributors
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 *
 * Authors: Kamil Prusko <kamilprusko@gmail.com>
 */

#include "ft_core.h"
#include <glib.h>
#include <glib-object.h>
#include <string.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  {
	FT_PROVIDED_OBJECT_0_PROPERTY,
	FT_PROVIDED_OBJECT_T_TYPE,
	FT_PROVIDED_OBJECT_T_DUP_FUNC,
	FT_PROVIDED_OBJECT_T_DESTROY_FUNC,
	FT_PROVIDED_OBJECT_AVAILABLE_PROPERTY,
	FT_PROVIDED_OBJECT_ENABLED_PROPERTY,
	FT_PROVIDED_OBJECT_PROVIDER_PROPERTY,
	FT_PROVIDED_OBJECT_NUM_PROPERTIES
};
static GParamSpec* ft_provided_object_properties[FT_PROVIDED_OBJECT_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _FtProvidedObjectPrivate {
	GType t_type;
	GBoxedCopyFunc t_dup_func;
	GDestroyNotify t_destroy_func;
	FtProvider* _provider;
	gboolean _available;
	gboolean _enabled;
	gulong provider_selected_id;
	gulong provider_unselected_id;
	gulong provider_enabled_id;
	gulong provider_disabled_id;
};

static gint FtProvidedObject_private_offset;
static gpointer ft_provided_object_parent_class = NULL;

static void ft_provided_object_on_provider_notify_available (FtProvidedObject* self,
                                                      GObject* object,
                                                      GParamSpec* pspec);
static void ft_provided_object_set_available (FtProvidedObject* self,
                                       gboolean value);
static void ft_provided_object_on_provider_selected (FtProvidedObject* self,
                                              gconstpointer provider);
static void _ft_provided_object_on_provider_notify_available_g_object_notify (GObject* _sender,
                                                                       GParamSpec* pspec,
                                                                       gpointer self);
static void ft_provided_object_set_provider (FtProvidedObject* self,
                                      gconstpointer value);
static void ft_provided_object_on_provider_unselected (FtProvidedObject* self,
                                                gconstpointer provider);
static void ft_provided_object_on_provider_enabled (FtProvidedObject* self,
                                             gconstpointer provider);
static void ft_provided_object_set_enabled (FtProvidedObject* self,
                                     gboolean value);
static void ft_provided_object_on_provider_disabled (FtProvidedObject* self,
                                              gconstpointer provider);
static void ft_provided_object_real_initialize (FtProvidedObject* self);
static void ft_provided_object_real_setup_providers (FtProvidedObject* self);
static void ft_provided_object_real_provider_enabled (FtProvidedObject* self,
                                               gconstpointer provider);
static void ft_provided_object_real_provider_disabled (FtProvidedObject* self,
                                                gconstpointer provider);
static void ft_provided_object_real_dispose (GObject* base);
static GObject * ft_provided_object_constructor (GType type,
                                          guint n_construct_properties,
                                          GObjectConstructParam * construct_properties);
static void _ft_provided_object_on_provider_selected_ft_provider_set_provider_selected (FtProviderSet* _sender,
                                                                                 gconstpointer provider,
                                                                                 gpointer self);
static void _ft_provided_object_on_provider_unselected_ft_provider_set_provider_unselected (FtProviderSet* _sender,
                                                                                     gconstpointer provider,
                                                                                     gpointer self);
static void _ft_provided_object_on_provider_enabled_ft_provider_set_provider_enabled (FtProviderSet* _sender,
                                                                               gconstpointer provider,
                                                                               gpointer self);
static void _ft_provided_object_on_provider_disabled_ft_provider_set_provider_disabled (FtProviderSet* _sender,
                                                                                 gconstpointer provider,
                                                                                 gpointer self);
static void ft_provided_object_finalize (GObject * obj);
static GType ft_provided_object_get_type_once (void);
static void _vala_ft_provided_object_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec);
static void _vala_ft_provided_object_set_property (GObject * object,
                                            guint property_id,
                                            const GValue * value,
                                            GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
ft_provided_object_get_instance_private (FtProvidedObject* self)
{
	return G_STRUCT_MEMBER_P (self, FtProvidedObject_private_offset);
}

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

static void
ft_provided_object_on_provider_notify_available (FtProvidedObject* self,
                                                 GObject* object,
                                                 GParamSpec* pspec)
{
	FtProvider* provider = NULL;
	FtProvider* _tmp0_;
	FtProvider* _tmp1_;
	FtProvider* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (object != NULL);
	g_return_if_fail (pspec != NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_PROVIDER, FtProvider));
	provider = _tmp0_;
	_tmp1_ = self->priv->_provider;
	_tmp2_ = provider;
	if (_tmp1_ == _tmp2_) {
		FtProvider* _tmp3_;
		gboolean _tmp4_;
		gboolean _tmp5_;
		_tmp3_ = provider;
		_tmp4_ = ft_provider_get_available (_tmp3_);
		_tmp5_ = _tmp4_;
		ft_provided_object_set_available (self, _tmp5_);
	}
	_g_object_unref0 (provider);
}

static void
_ft_provided_object_on_provider_notify_available_g_object_notify (GObject* _sender,
                                                                  GParamSpec* pspec,
                                                                  gpointer self)
{
	ft_provided_object_on_provider_notify_available ((FtProvidedObject*) self, _sender, pspec);
}

static void
ft_provided_object_on_provider_selected (FtProvidedObject* self,
                                         gconstpointer provider)
{
	FtProvider* _provider = NULL;
	FtProvider* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (provider, FT_TYPE_PROVIDER, FtProvider));
	_provider = _tmp0_;
	g_signal_connect_object ((GObject*) _provider, "notify::available", (GCallback) _ft_provided_object_on_provider_notify_available_g_object_notify, self, 0);
	ft_provided_object_set_provider (self, _provider);
	_g_object_unref0 (_provider);
}

static void
ft_provided_object_on_provider_unselected (FtProvidedObject* self,
                                           gconstpointer provider)
{
	FtProvider* _provider = NULL;
	FtProvider* _tmp0_;
	FtProvider* _tmp1_;
	guint _tmp2_;
	GQuark _tmp3_;
	FtProvider* _tmp4_;
	FtProvider* _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (provider, FT_TYPE_PROVIDER, FtProvider));
	_provider = _tmp0_;
	_tmp1_ = _provider;
	g_signal_parse_name ("notify::available", G_TYPE_OBJECT, &_tmp2_, &_tmp3_, TRUE);
	g_signal_handlers_disconnect_matched ((GObject*) _tmp1_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DETAIL | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp2_, _tmp3_, NULL, (GCallback) _ft_provided_object_on_provider_notify_available_g_object_notify, self);
	_tmp4_ = self->priv->_provider;
	_tmp5_ = _provider;
	if (_tmp4_ == _tmp5_) {
		ft_provided_object_set_provider (self, NULL);
	}
	_g_object_unref0 (_provider);
}

static void
ft_provided_object_on_provider_enabled (FtProvidedObject* self,
                                        gconstpointer provider)
{
	FtProvider* _provider = NULL;
	FtProvider* _tmp0_;
	FtProvider* _tmp1_;
	FtProvider* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (provider, FT_TYPE_PROVIDER, FtProvider));
	_provider = _tmp0_;
	_tmp1_ = self->priv->_provider;
	_tmp2_ = _provider;
	if (_tmp1_ == _tmp2_) {
		ft_provided_object_set_enabled (self, TRUE);
	}
	ft_provided_object_provider_enabled (self, provider);
	_g_object_unref0 (_provider);
}

static void
ft_provided_object_on_provider_disabled (FtProvidedObject* self,
                                         gconstpointer provider)
{
	FtProvider* _provider = NULL;
	FtProvider* _tmp0_;
	FtProvider* _tmp1_;
	FtProvider* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (provider, FT_TYPE_PROVIDER, FtProvider));
	_provider = _tmp0_;
	_tmp1_ = self->priv->_provider;
	_tmp2_ = _provider;
	if (_tmp1_ == _tmp2_) {
		ft_provided_object_set_enabled (self, FALSE);
	}
	ft_provided_object_provider_disabled (self, provider);
	_g_object_unref0 (_provider);
}

static void
ft_provided_object_real_initialize (FtProvidedObject* self)
{
	g_critical ("Type `%s' does not implement abstract method `ft_provided_object_initialize'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return;
}

void
ft_provided_object_initialize (FtProvidedObject* self)
{
	FtProvidedObjectClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = FT_PROVIDED_OBJECT_GET_CLASS (self);
	if (_klass_->initialize) {
		_klass_->initialize (self);
	}
}

static void
ft_provided_object_real_setup_providers (FtProvidedObject* self)
{
	g_critical ("Type `%s' does not implement abstract method `ft_provided_object_setup_providers'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return;
}

void
ft_provided_object_setup_providers (FtProvidedObject* self)
{
	FtProvidedObjectClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = FT_PROVIDED_OBJECT_GET_CLASS (self);
	if (_klass_->setup_providers) {
		_klass_->setup_providers (self);
	}
}

static void
ft_provided_object_real_provider_enabled (FtProvidedObject* self,
                                          gconstpointer provider)
{
	g_critical ("Type `%s' does not implement abstract method `ft_provided_object_provider_enabled'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return;
}

void
ft_provided_object_provider_enabled (FtProvidedObject* self,
                                     gconstpointer provider)
{
	FtProvidedObjectClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = FT_PROVIDED_OBJECT_GET_CLASS (self);
	if (_klass_->provider_enabled) {
		_klass_->provider_enabled (self, provider);
	}
}

static void
ft_provided_object_real_provider_disabled (FtProvidedObject* self,
                                           gconstpointer provider)
{
	g_critical ("Type `%s' does not implement abstract method `ft_provided_object_provider_disabled'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return;
}

void
ft_provided_object_provider_disabled (FtProvidedObject* self,
                                      gconstpointer provider)
{
	FtProvidedObjectClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = FT_PROVIDED_OBJECT_GET_CLASS (self);
	if (_klass_->provider_disabled) {
		_klass_->provider_disabled (self, provider);
	}
}

static void
ft_provided_object_real_dispose (GObject* base)
{
	FtProvidedObject * self;
	FtProvider* _tmp0_;
	self = (FtProvidedObject*) base;
	_tmp0_ = self->priv->_provider;
	if (_tmp0_ != NULL) {
		FtProvider* _tmp1_;
		guint _tmp2_;
		GQuark _tmp3_;
		_tmp1_ = self->priv->_provider;
		g_signal_parse_name ("notify::available", G_TYPE_OBJECT, &_tmp2_, &_tmp3_, TRUE);
		g_signal_handlers_disconnect_matched ((GObject*) _tmp1_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DETAIL | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp2_, _tmp3_, NULL, (GCallback) _ft_provided_object_on_provider_notify_available_g_object_notify, self);
	}
	if (self->priv->provider_selected_id != ((gulong) 0)) {
		FtProviderSet* _tmp4_;
		_tmp4_ = self->providers;
		g_signal_handler_disconnect ((GObject*) _tmp4_, self->priv->provider_selected_id);
		self->priv->provider_selected_id = (gulong) 0;
	}
	if (self->priv->provider_unselected_id != ((gulong) 0)) {
		FtProviderSet* _tmp5_;
		_tmp5_ = self->providers;
		g_signal_handler_disconnect ((GObject*) _tmp5_, self->priv->provider_unselected_id);
		self->priv->provider_unselected_id = (gulong) 0;
	}
	if (self->priv->provider_enabled_id != ((gulong) 0)) {
		FtProviderSet* _tmp6_;
		_tmp6_ = self->providers;
		g_signal_handler_disconnect ((GObject*) _tmp6_, self->priv->provider_enabled_id);
		self->priv->provider_enabled_id = (gulong) 0;
	}
	if (self->priv->provider_disabled_id != ((gulong) 0)) {
		FtProviderSet* _tmp7_;
		_tmp7_ = self->providers;
		g_signal_handler_disconnect ((GObject*) _tmp7_, self->priv->provider_disabled_id);
		self->priv->provider_disabled_id = (gulong) 0;
	}
	_g_object_unref0 (self->priv->_provider);
	self->priv->_provider = NULL;
	_g_object_unref0 (self->providers);
	self->providers = NULL;
	G_OBJECT_CLASS (ft_provided_object_parent_class)->dispose (G_TYPE_CHECK_INSTANCE_CAST (self, G_TYPE_OBJECT, GObject));
}

FtProvidedObject*
ft_provided_object_construct (GType object_type,
                              GType t_type,
                              GBoxedCopyFunc t_dup_func,
                              GDestroyNotify t_destroy_func)
{
	FtProvidedObject * self = NULL;
	self = (FtProvidedObject*) g_object_new (object_type, "t-type", t_type, "t-dup-func", t_dup_func, "t-destroy-func", t_destroy_func, NULL);
	self->priv->t_type = t_type;
	self->priv->t_dup_func = t_dup_func;
	self->priv->t_destroy_func = t_destroy_func;
	return self;
}

gboolean
ft_provided_object_get_available (FtProvidedObject* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_available;
	return result;
}

static void
ft_provided_object_set_available (FtProvidedObject* self,
                                  gboolean value)
{
	g_return_if_fail (self != NULL);
	if (self->priv->_available != value) {
		self->priv->_available = value;
		g_object_notify ((GObject*) self, "available");
	}
}

gboolean
ft_provided_object_get_enabled (FtProvidedObject* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_enabled;
	return result;
}

static void
ft_provided_object_set_enabled (FtProvidedObject* self,
                                gboolean value)
{
	g_return_if_fail (self != NULL);
	if (self->priv->_enabled != value) {
		self->priv->_enabled = value;
		g_object_notify ((GObject*) self, "enabled");
	}
}

gconstpointer
ft_provided_object_get_provider (FtProvidedObject* self)
{
	gconstpointer result;
	FtProvider* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_provider;
	result = (gconstpointer) _tmp0_;
	return result;
}

static void
ft_provided_object_set_provider (FtProvidedObject* self,
                                 gconstpointer value)
{
	FtProvider* provider = NULL;
	FtProvider* _tmp0_;
	FtProvider* _tmp1_;
	FtProvider* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (FT_IS_PROVIDER (value) ? ((FtProvider*) value) : NULL);
	provider = _tmp0_;
	_tmp1_ = self->priv->_provider;
	_tmp2_ = provider;
	if (_tmp1_ != _tmp2_) {
		FtProvider* _tmp3_;
		FtProvider* _tmp4_;
		gboolean _tmp5_ = FALSE;
		FtProvider* _tmp6_;
		gboolean _tmp10_ = FALSE;
		FtProvider* _tmp11_;
		_tmp3_ = provider;
		_tmp4_ = _g_object_ref0 (_tmp3_);
		_g_object_unref0 (self->priv->_provider);
		self->priv->_provider = _tmp4_;
		g_object_notify ((GObject*) self, "provider");
		_tmp6_ = provider;
		if (_tmp6_ != NULL) {
			FtProvider* _tmp7_;
			gboolean _tmp8_;
			gboolean _tmp9_;
			_tmp7_ = provider;
			_tmp8_ = ft_provider_get_available (_tmp7_);
			_tmp9_ = _tmp8_;
			_tmp5_ = _tmp9_;
		} else {
			_tmp5_ = FALSE;
		}
		ft_provided_object_set_available (self, _tmp5_);
		_tmp11_ = provider;
		if (_tmp11_ != NULL) {
			FtProvider* _tmp12_;
			gboolean _tmp13_;
			gboolean _tmp14_;
			_tmp12_ = provider;
			_tmp13_ = ft_provider_get_enabled (_tmp12_);
			_tmp14_ = _tmp13_;
			_tmp10_ = _tmp14_;
		} else {
			_tmp10_ = FALSE;
		}
		ft_provided_object_set_enabled (self, _tmp10_);
	}
	_g_object_unref0 (provider);
}

static void
_ft_provided_object_on_provider_selected_ft_provider_set_provider_selected (FtProviderSet* _sender,
                                                                            gconstpointer provider,
                                                                            gpointer self)
{
	ft_provided_object_on_provider_selected ((FtProvidedObject*) self, provider);
}

static void
_ft_provided_object_on_provider_unselected_ft_provider_set_provider_unselected (FtProviderSet* _sender,
                                                                                gconstpointer provider,
                                                                                gpointer self)
{
	ft_provided_object_on_provider_unselected ((FtProvidedObject*) self, provider);
}

static void
_ft_provided_object_on_provider_enabled_ft_provider_set_provider_enabled (FtProviderSet* _sender,
                                                                          gconstpointer provider,
                                                                          gpointer self)
{
	ft_provided_object_on_provider_enabled ((FtProvidedObject*) self, provider);
}

static void
_ft_provided_object_on_provider_disabled_ft_provider_set_provider_disabled (FtProviderSet* _sender,
                                                                            gconstpointer provider,
                                                                            gpointer self)
{
	ft_provided_object_on_provider_disabled ((FtProvidedObject*) self, provider);
}

static GObject *
ft_provided_object_constructor (GType type,
                                guint n_construct_properties,
                                GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	FtProvidedObject * self;
	FtProviderSet* _tmp0_;
	FtProviderSet* _tmp1_;
	gulong _tmp2_;
	FtProviderSet* _tmp3_;
	gulong _tmp4_;
	FtProviderSet* _tmp5_;
	gulong _tmp6_;
	FtProviderSet* _tmp7_;
	gulong _tmp8_;
	FtProviderSet* _tmp9_;
	FtProviderSet* _tmp10_;
	parent_class = G_OBJECT_CLASS (ft_provided_object_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_PROVIDED_OBJECT, FtProvidedObject);
	_tmp0_ = ft_provider_set_new (self->priv->t_type, (GBoxedCopyFunc) self->priv->t_dup_func, (GDestroyNotify) self->priv->t_destroy_func, FT_SELECTION_MODE_SINGLE);
	_g_object_unref0 (self->providers);
	self->providers = _tmp0_;
	_tmp1_ = self->providers;
	_tmp2_ = g_signal_connect_object (_tmp1_, "provider-selected", (GCallback) _ft_provided_object_on_provider_selected_ft_provider_set_provider_selected, self, 0);
	self->priv->provider_selected_id = _tmp2_;
	_tmp3_ = self->providers;
	_tmp4_ = g_signal_connect_object (_tmp3_, "provider-unselected", (GCallback) _ft_provided_object_on_provider_unselected_ft_provider_set_provider_unselected, self, 0);
	self->priv->provider_unselected_id = _tmp4_;
	_tmp5_ = self->providers;
	_tmp6_ = g_signal_connect_object (_tmp5_, "provider-enabled", (GCallback) _ft_provided_object_on_provider_enabled_ft_provider_set_provider_enabled, self, 0);
	self->priv->provider_enabled_id = _tmp6_;
	_tmp7_ = self->providers;
	_tmp8_ = g_signal_connect_object (_tmp7_, "provider-disabled", (GCallback) _ft_provided_object_on_provider_disabled_ft_provider_set_provider_disabled, self, 0);
	self->priv->provider_disabled_id = _tmp8_;
	ft_provided_object_initialize (self);
	ft_provided_object_setup_providers (self);
	_tmp9_ = self->providers;
	ft_provider_set_discover (_tmp9_);
	_tmp10_ = self->providers;
	ft_provider_set_enable (_tmp10_);
	return obj;
}

static void
ft_provided_object_class_init (FtProvidedObjectClass * klass,
                               gpointer klass_data)
{
	ft_provided_object_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FtProvidedObject_private_offset);
	((FtProvidedObjectClass *) klass)->initialize = (void (*) (FtProvidedObject*)) ft_provided_object_real_initialize;
	((FtProvidedObjectClass *) klass)->setup_providers = (void (*) (FtProvidedObject*)) ft_provided_object_real_setup_providers;
	((FtProvidedObjectClass *) klass)->provider_enabled = (void (*) (FtProvidedObject*, gconstpointer)) ft_provided_object_real_provider_enabled;
	((FtProvidedObjectClass *) klass)->provider_disabled = (void (*) (FtProvidedObject*, gconstpointer)) ft_provided_object_real_provider_disabled;
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) ft_provided_object_real_dispose;
	G_OBJECT_CLASS (klass)->get_property = _vala_ft_provided_object_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_ft_provided_object_set_property;
	G_OBJECT_CLASS (klass)->constructor = ft_provided_object_constructor;
	G_OBJECT_CLASS (klass)->finalize = ft_provided_object_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_PROVIDED_OBJECT_T_TYPE, g_param_spec_gtype ("t-type", "type", "type", G_TYPE_NONE, G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_PROVIDED_OBJECT_T_DUP_FUNC, g_param_spec_pointer ("t-dup-func", "dup func", "dup func", G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_PROVIDED_OBJECT_T_DESTROY_FUNC, g_param_spec_pointer ("t-destroy-func", "destroy func", "destroy func", G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_PROVIDED_OBJECT_AVAILABLE_PROPERTY, ft_provided_object_properties[FT_PROVIDED_OBJECT_AVAILABLE_PROPERTY] = g_param_spec_boolean ("available", "available", "available", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_PROVIDED_OBJECT_ENABLED_PROPERTY, ft_provided_object_properties[FT_PROVIDED_OBJECT_ENABLED_PROPERTY] = g_param_spec_boolean ("enabled", "enabled", "enabled", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY));
	/**
	         * A selected provider. It may not be available nor enabled.
	         */
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_PROVIDED_OBJECT_PROVIDER_PROPERTY, ft_provided_object_properties[FT_PROVIDED_OBJECT_PROVIDER_PROPERTY] = g_param_spec_pointer ("provider", "provider", "provider", G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY));
}

static void
ft_provided_object_instance_init (FtProvidedObject * self,
                                  gpointer klass)
{
	self->priv = ft_provided_object_get_instance_private (self);
	self->providers = NULL;
	self->priv->_provider = NULL;
	self->priv->_available = FALSE;
	self->priv->_enabled = FALSE;
	self->priv->provider_selected_id = (gulong) 0;
	self->priv->provider_unselected_id = (gulong) 0;
	self->priv->provider_enabled_id = (gulong) 0;
	self->priv->provider_disabled_id = (gulong) 0;
}

static void
ft_provided_object_finalize (GObject * obj)
{
	FtProvidedObject * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_PROVIDED_OBJECT, FtProvidedObject);
	_g_object_unref0 (self->providers);
	_g_object_unref0 (self->priv->_provider);
	G_OBJECT_CLASS (ft_provided_object_parent_class)->finalize (obj);
}

static GType
ft_provided_object_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtProvidedObjectClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_provided_object_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtProvidedObject), 0, (GInstanceInitFunc) ft_provided_object_instance_init, NULL };
	GType ft_provided_object_type_id;
	ft_provided_object_type_id = g_type_register_static (G_TYPE_OBJECT, "FtProvidedObject", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	FtProvidedObject_private_offset = g_type_add_instance_private (ft_provided_object_type_id, sizeof (FtProvidedObjectPrivate));
	return ft_provided_object_type_id;
}

GType
ft_provided_object_get_type (void)
{
	static volatile gsize ft_provided_object_type_id__once = 0;
	if (g_once_init_enter (&ft_provided_object_type_id__once)) {
		GType ft_provided_object_type_id;
		ft_provided_object_type_id = ft_provided_object_get_type_once ();
		g_once_init_leave (&ft_provided_object_type_id__once, ft_provided_object_type_id);
	}
	return ft_provided_object_type_id__once;
}

static void
_vala_ft_provided_object_get_property (GObject * object,
                                       guint property_id,
                                       GValue * value,
                                       GParamSpec * pspec)
{
	FtProvidedObject * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_PROVIDED_OBJECT, FtProvidedObject);
	switch (property_id) {
		case FT_PROVIDED_OBJECT_AVAILABLE_PROPERTY:
		g_value_set_boolean (value, ft_provided_object_get_available (self));
		break;
		case FT_PROVIDED_OBJECT_ENABLED_PROPERTY:
		g_value_set_boolean (value, ft_provided_object_get_enabled (self));
		break;
		case FT_PROVIDED_OBJECT_PROVIDER_PROPERTY:
		g_value_set_pointer (value, ft_provided_object_get_provider (self));
		break;
		case FT_PROVIDED_OBJECT_T_TYPE:
		g_value_set_gtype (value, self->priv->t_type);
		break;
		case FT_PROVIDED_OBJECT_T_DUP_FUNC:
		g_value_set_pointer (value, self->priv->t_dup_func);
		break;
		case FT_PROVIDED_OBJECT_T_DESTROY_FUNC:
		g_value_set_pointer (value, self->priv->t_destroy_func);
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_ft_provided_object_set_property (GObject * object,
                                       guint property_id,
                                       const GValue * value,
                                       GParamSpec * pspec)
{
	FtProvidedObject * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_PROVIDED_OBJECT, FtProvidedObject);
	switch (property_id) {
		case FT_PROVIDED_OBJECT_AVAILABLE_PROPERTY:
		ft_provided_object_set_available (self, g_value_get_boolean (value));
		break;
		case FT_PROVIDED_OBJECT_ENABLED_PROPERTY:
		ft_provided_object_set_enabled (self, g_value_get_boolean (value));
		break;
		case FT_PROVIDED_OBJECT_PROVIDER_PROPERTY:
		ft_provided_object_set_provider (self, g_value_get_pointer (value));
		break;
		case FT_PROVIDED_OBJECT_T_TYPE:
		self->priv->t_type = g_value_get_gtype (value);
		break;
		case FT_PROVIDED_OBJECT_T_DUP_FUNC:
		self->priv->t_dup_func = g_value_get_pointer (value);
		break;
		case FT_PROVIDED_OBJECT_T_DESTROY_FUNC:
		self->priv->t_destroy_func = g_value_get_pointer (value);
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

