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

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

#include "ft_core.h"
#include <gio/gio.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib-object.h>
#include <config.h>

#define FT_DEFAULT_BACKGROUND_PROVIDER_AUTOSTART_TEMPLATE "[Desktop Entry]\n" \
"Type=Application\n" \
"Name=${APPLICATION_ID}\n" \
"X-XDP-Autostart=${APPLICATION_ID}\n" \
"Exec=focus-timer --gapplication-service\n"
#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

#define FT_TYPE_DEFAULT_BACKGROUND_PROVIDER (ft_default_background_provider_get_type ())
#define FT_DEFAULT_BACKGROUND_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FT_TYPE_DEFAULT_BACKGROUND_PROVIDER, FtDefaultBackgroundProvider))
#define FT_DEFAULT_BACKGROUND_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FT_TYPE_DEFAULT_BACKGROUND_PROVIDER, FtDefaultBackgroundProviderClass))
#define FT_IS_DEFAULT_BACKGROUND_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FT_TYPE_DEFAULT_BACKGROUND_PROVIDER))
#define FT_IS_DEFAULT_BACKGROUND_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FT_TYPE_DEFAULT_BACKGROUND_PROVIDER))
#define FT_DEFAULT_BACKGROUND_PROVIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FT_TYPE_DEFAULT_BACKGROUND_PROVIDER, FtDefaultBackgroundProviderClass))

typedef struct _FtDefaultBackgroundProvider FtDefaultBackgroundProvider;
typedef struct _FtDefaultBackgroundProviderClass FtDefaultBackgroundProviderClass;
typedef struct _FtDefaultBackgroundProviderPrivate FtDefaultBackgroundProviderPrivate;
enum  {
	FT_DEFAULT_BACKGROUND_PROVIDER_0_PROPERTY,
	FT_DEFAULT_BACKGROUND_PROVIDER_BACKGROUND_ALLOWED_PROPERTY,
	FT_DEFAULT_BACKGROUND_PROVIDER_AUTOSTART_ALLOWED_PROPERTY,
	FT_DEFAULT_BACKGROUND_PROVIDER_NUM_PROPERTIES
};
static GParamSpec* ft_default_background_provider_properties[FT_DEFAULT_BACKGROUND_PROVIDER_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _FtDefaultBackgroundProviderInitializeData FtDefaultBackgroundProviderInitializeData;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _FtDefaultBackgroundProviderEnableData FtDefaultBackgroundProviderEnableData;
typedef struct _FtDefaultBackgroundProviderDisableData FtDefaultBackgroundProviderDisableData;
typedef struct _FtDefaultBackgroundProviderUninitializeData FtDefaultBackgroundProviderUninitializeData;
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
typedef struct _FtDefaultBackgroundProviderRequestBackgroundData FtDefaultBackgroundProviderRequestBackgroundData;
enum  {
	FT_BACKGROUND_MANAGER_0_PROPERTY,
	FT_BACKGROUND_MANAGER_ACTIVE_PROPERTY,
	FT_BACKGROUND_MANAGER_BACKGROUND_ALLOWED_PROPERTY,
	FT_BACKGROUND_MANAGER_AUTOSTART_ALLOWED_PROPERTY,
	FT_BACKGROUND_MANAGER_NUM_PROPERTIES
};
static GParamSpec* ft_background_manager_properties[FT_BACKGROUND_MANAGER_NUM_PROPERTIES];
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
typedef struct _FtBackgroundManagerRequestBackgroundData FtBackgroundManagerRequestBackgroundData;
typedef struct _FtBackgroundManagerHoldData FtBackgroundManagerHoldData;

struct _FtDefaultBackgroundProvider {
	FtProvider parent_instance;
	FtDefaultBackgroundProviderPrivate * priv;
};

struct _FtDefaultBackgroundProviderClass {
	FtProviderClass parent_class;
};

struct _FtDefaultBackgroundProviderPrivate {
	gboolean _autostart_allowed;
};

struct _FtDefaultBackgroundProviderInitializeData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	FtDefaultBackgroundProvider* self;
	GCancellable* cancellable;
};

struct _FtDefaultBackgroundProviderEnableData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	FtDefaultBackgroundProvider* self;
	GCancellable* cancellable;
	GFile* autostart_file;
	GFile* _tmp0_;
	gboolean autostart_allowed;
	GFile* _tmp1_;
	GFileInfo* _tmp2_;
	GFileInfo* _tmp3_;
	GError* _error_;
	GError* _tmp4_;
	const gchar* _tmp5_;
	GError* _inner_error0_;
};

struct _FtDefaultBackgroundProviderDisableData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	FtDefaultBackgroundProvider* self;
};

struct _FtDefaultBackgroundProviderUninitializeData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	FtDefaultBackgroundProvider* self;
};

struct _FtDefaultBackgroundProviderRequestBackgroundData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	FtDefaultBackgroundProvider* self;
	gboolean autostart;
	gchar* parent_window;
	GFile* autostart_file;
	GFile* _tmp0_;
	gchar* autostart_contents;
	gchar* _tmp1_;
	GFile* _tmp2_;
	const gchar* _tmp3_;
	guint8* _tmp4_;
	gint _tmp4__length1;
	gint _tmp5_;
	guint8* _tmp6_;
	gint _tmp6__length1;
	GFile* _tmp7_;
	GError* _error_;
	GError* _tmp8_;
	const gchar* _tmp9_;
	GError* _inner_error0_;
};

struct _FtBackgroundManagerPrivate {
	GApplication* application;
	GSettings* settings;
	gboolean has_application_hold;
	GHashTable* holds;
	gboolean _background_allowed;
	gboolean _autostart_allowed;
};

struct _FtBackgroundManagerRequestBackgroundData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	FtBackgroundManager* self;
	gchar* parent_window;
	gboolean _tmp0_;
	gconstpointer _tmp1_;
	gconstpointer _tmp2_;
	gconstpointer _tmp3_;
	gconstpointer _tmp4_;
	gboolean _tmp5_;
	gboolean _tmp6_;
	GApplication* _tmp7_;
	gconstpointer _tmp8_;
	gconstpointer _tmp9_;
	GSettings* _tmp10_;
	GApplication* _tmp11_;
};

struct _FtBackgroundManagerHoldData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	FtBackgroundManager* self;
	gchar* parent_window;
	guint result;
	guint hold_id;
	guint _tmp0_;
	GHashTable* _tmp1_;
};

static gint FtDefaultBackgroundProvider_private_offset;
static gpointer ft_default_background_provider_parent_class = NULL;
static FtBackgroundProviderIface * ft_default_background_provider_ft_background_provider_parent_iface = NULL;
static gint FtBackgroundManager_private_offset;
static gpointer ft_background_manager_parent_class = NULL;
static guint ft_background_manager_next_hold_id;
static guint ft_background_manager_next_hold_id = 1U;

static GType ft_background_provider_get_type_once (void);
VALA_EXTERN GType ft_default_background_provider_get_type (void) G_GNUC_CONST ;
static GFile* ft_default_background_provider_get_autostart_file (FtDefaultBackgroundProvider* self);
static void ft_default_background_provider_real_initialize_data_free (gpointer _data);
static void ft_default_background_provider_real_initialize (FtProvider* base,
                                                     GCancellable* cancellable,
                                                     GAsyncReadyCallback _callback_,
                                                     gpointer _user_data_);
static gboolean ft_default_background_provider_real_initialize_co (FtDefaultBackgroundProviderInitializeData* _data_);
static void ft_default_background_provider_real_enable_data_free (gpointer _data);
static void ft_default_background_provider_real_enable (FtProvider* base,
                                                 GCancellable* cancellable,
                                                 GAsyncReadyCallback _callback_,
                                                 gpointer _user_data_);
static gboolean ft_default_background_provider_real_enable_co (FtDefaultBackgroundProviderEnableData* _data_);
static void ft_default_background_provider_enable_ready (GObject* source_object,
                                                  GAsyncResult* _res_,
                                                  gpointer _user_data_);
static void ft_default_background_provider_real_disable_data_free (gpointer _data);
static void ft_default_background_provider_real_disable (FtProvider* base,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_);
static gboolean ft_default_background_provider_real_disable_co (FtDefaultBackgroundProviderDisableData* _data_);
static void ft_default_background_provider_real_uninitialize_data_free (gpointer _data);
static void ft_default_background_provider_real_uninitialize (FtProvider* base,
                                                       GAsyncReadyCallback _callback_,
                                                       gpointer _user_data_);
static gboolean ft_default_background_provider_real_uninitialize_co (FtDefaultBackgroundProviderUninitializeData* _data_);
static void ft_default_background_provider_real_request_background_data_free (gpointer _data);
static void ft_default_background_provider_real_request_background (FtBackgroundProvider* base,
                                                             gboolean autostart,
                                                             const gchar* parent_window,
                                                             GAsyncReadyCallback _callback_,
                                                             gpointer _user_data_);
static gboolean ft_default_background_provider_real_request_background_co (FtDefaultBackgroundProviderRequestBackgroundData* _data_);
static void ft_default_background_provider_request_background_ready (GObject* source_object,
                                                              GAsyncResult* _res_,
                                                              gpointer _user_data_);
VALA_EXTERN FtDefaultBackgroundProvider* ft_default_background_provider_new (void);
VALA_EXTERN FtDefaultBackgroundProvider* ft_default_background_provider_construct (GType object_type);
static void ft_default_background_provider_finalize (GObject * obj);
static GType ft_default_background_provider_get_type_once (void);
static void _vala_ft_default_background_provider_get_property (GObject * object,
                                                        guint property_id,
                                                        GValue * value,
                                                        GParamSpec * pspec);
static void ft_background_manager_request_background_data_free (gpointer _data);
static void ft_background_manager_request_background (FtBackgroundManager* self,
                                               const gchar* parent_window,
                                               GAsyncReadyCallback _callback_,
                                               gpointer _user_data_);
static void ft_background_manager_request_background_finish (FtBackgroundManager* self,
                                                      GAsyncResult* _res_);
static gboolean ft_background_manager_request_background_co (FtBackgroundManagerRequestBackgroundData* _data_);
static void ft_background_manager_request_background_ready (GObject* source_object,
                                                     GAsyncResult* _res_,
                                                     gpointer _user_data_);
static void ft_background_manager_update_application_hold (FtBackgroundManager* self);
static void ft_background_manager_hold_application (FtBackgroundManager* self);
static void ft_background_manager_release_application (FtBackgroundManager* self);
static void ft_background_manager_hold_data_free (gpointer _data);
static gboolean ft_background_manager_hold_co (FtBackgroundManagerHoldData* _data_);
static void ft_background_manager_hold_ready (GObject* source_object,
                                       GAsyncResult* _res_,
                                       gpointer _user_data_);
static void ft_background_manager_update_properties (FtBackgroundManager* self);
static void ft_background_manager_real_initialize (FtProvidedObject* base);
static void ft_background_manager_on_settings_changed (FtBackgroundManager* self,
                                                GSettings* settings,
                                                const gchar* key);
static void _ft_background_manager_on_settings_changed_g_settings_changed (GSettings* _sender,
                                                                    const gchar* key,
                                                                    gpointer self);
static void ft_background_manager_real_setup_providers (FtProvidedObject* base);
static void ft_background_manager_real_provider_enabled (FtProvidedObject* base,
                                                  FtBackgroundProvider* provider);
static void ft_background_manager_on_notify_background_allowed (FtBackgroundManager* self,
                                                         GObject* object,
                                                         GParamSpec* pspec);
static void _ft_background_manager_on_notify_background_allowed_g_object_notify (GObject* _sender,
                                                                          GParamSpec* pspec,
                                                                          gpointer self);
static void ft_background_manager_on_notify_autostart_allowed (FtBackgroundManager* self,
                                                        GObject* object,
                                                        GParamSpec* pspec);
static void _ft_background_manager_on_notify_autostart_allowed_g_object_notify (GObject* _sender,
                                                                         GParamSpec* pspec,
                                                                         gpointer self);
static void ft_background_manager_real_provider_disabled (FtProvidedObject* base,
                                                   FtBackgroundProvider* provider);
static void ft_background_manager_real_dispose (GObject* base);
static GObject * ft_background_manager_constructor (GType type,
                                             guint n_construct_properties,
                                             GObjectConstructParam * construct_properties);
static void ft_background_manager_finalize (GObject * obj);
static GType ft_background_manager_get_type_once (void);
static void _vala_ft_background_manager_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec);

void
ft_background_provider_request_background (FtBackgroundProvider* self,
                                           gboolean autostart,
                                           const gchar* parent_window,
                                           GAsyncReadyCallback _callback_,
                                           gpointer _user_data_)
{
	FtBackgroundProviderIface* _iface_;
	_iface_ = FT_BACKGROUND_PROVIDER_GET_INTERFACE (self);
	if (_iface_->request_background) {
		_iface_->request_background (self, autostart, parent_window, _callback_, _user_data_);
	}
}

void
ft_background_provider_request_background_finish (FtBackgroundProvider* self,
                                                  GAsyncResult* _res_)
{
	FtBackgroundProviderIface* _iface_;
	_iface_ = FT_BACKGROUND_PROVIDER_GET_INTERFACE (self);
	if (_iface_->request_background_finish) {
		_iface_->request_background_finish (self, _res_);
	}
}

gboolean
ft_background_provider_get_background_allowed (FtBackgroundProvider* self)
{
	FtBackgroundProviderIface* _iface_;
	g_return_val_if_fail (self != NULL, FALSE);
	_iface_ = FT_BACKGROUND_PROVIDER_GET_INTERFACE (self);
	if (_iface_->get_background_allowed) {
		return _iface_->get_background_allowed (self);
	}
	return FALSE;
}

gboolean
ft_background_provider_get_autostart_allowed (FtBackgroundProvider* self)
{
	FtBackgroundProviderIface* _iface_;
	g_return_val_if_fail (self != NULL, FALSE);
	_iface_ = FT_BACKGROUND_PROVIDER_GET_INTERFACE (self);
	if (_iface_->get_autostart_allowed) {
		return _iface_->get_autostart_allowed (self);
	}
	return FALSE;
}

static void
ft_background_provider_default_init (FtBackgroundProviderIface * iface,
                                     gpointer iface_data)
{
	g_object_interface_install_property (iface, g_param_spec_boolean ("background-allowed", "background-allowed", "background-allowed", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_interface_install_property (iface, g_param_spec_boolean ("autostart-allowed", "autostart-allowed", "autostart-allowed", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static GType
ft_background_provider_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtBackgroundProviderIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_background_provider_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType ft_background_provider_type_id;
	ft_background_provider_type_id = g_type_register_static (G_TYPE_INTERFACE, "FtBackgroundProvider", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (ft_background_provider_type_id, FT_TYPE_PROVIDER);
	return ft_background_provider_type_id;
}

GType
ft_background_provider_get_type (void)
{
	static volatile gsize ft_background_provider_type_id__once = 0;
	if (g_once_init_enter (&ft_background_provider_type_id__once)) {
		GType ft_background_provider_type_id;
		ft_background_provider_type_id = ft_background_provider_get_type_once ();
		g_once_init_leave (&ft_background_provider_type_id__once, ft_background_provider_type_id);
	}
	return ft_background_provider_type_id__once;
}

static inline gpointer
ft_default_background_provider_get_instance_private (FtDefaultBackgroundProvider* self)
{
	return G_STRUCT_MEMBER_P (self, FtDefaultBackgroundProvider_private_offset);
}

static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

static GFile*
ft_default_background_provider_get_autostart_file (FtDefaultBackgroundProvider* self)
{
	gchar* path = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	GFile* _tmp6_;
	GFile* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_get_user_config_dir ();
	_tmp1_ = string_to_string (APPLICATION_ID);
	_tmp2_ = g_strconcat (_tmp1_, ".desktop", NULL);
	_tmp3_ = _tmp2_;
	_tmp4_ = g_build_filename (_tmp0_, "autostart", _tmp3_, NULL);
	_tmp5_ = _tmp4_;
	_g_free0 (_tmp3_);
	path = _tmp5_;
	_tmp6_ = g_file_new_for_path (path);
	result = _tmp6_;
	_g_free0 (path);
	return result;
}

static void
ft_default_background_provider_real_initialize_data_free (gpointer _data)
{
	FtDefaultBackgroundProviderInitializeData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (FtDefaultBackgroundProviderInitializeData, _data_);
}

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

static void
ft_default_background_provider_real_initialize (FtProvider* base,
                                                GCancellable* cancellable,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_)
{
	FtDefaultBackgroundProvider * self;
	FtDefaultBackgroundProviderInitializeData* _data_;
	FtDefaultBackgroundProvider* _tmp0_;
	GCancellable* _tmp1_;
	self = (FtDefaultBackgroundProvider*) base;
	_data_ = g_slice_new0 (FtDefaultBackgroundProviderInitializeData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, ft_default_background_provider_real_initialize_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	ft_default_background_provider_real_initialize_co (_data_);
}

static void
ft_default_background_provider_initialize_finish (FtProvider* base,
                                                  GAsyncResult* _res_,
                                                  GError** error)
{
	FtDefaultBackgroundProviderInitializeData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static gboolean
ft_default_background_provider_real_initialize_co (FtDefaultBackgroundProviderInitializeData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	ft_provider_set_available ((FtProvider*) _data_->self, !ft_is_flatpak ());
	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
ft_default_background_provider_real_enable_data_free (gpointer _data)
{
	FtDefaultBackgroundProviderEnableData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (FtDefaultBackgroundProviderEnableData, _data_);
}

static void
ft_default_background_provider_real_enable (FtProvider* base,
                                            GCancellable* cancellable,
                                            GAsyncReadyCallback _callback_,
                                            gpointer _user_data_)
{
	FtDefaultBackgroundProvider * self;
	FtDefaultBackgroundProviderEnableData* _data_;
	FtDefaultBackgroundProvider* _tmp0_;
	GCancellable* _tmp1_;
	self = (FtDefaultBackgroundProvider*) base;
	_data_ = g_slice_new0 (FtDefaultBackgroundProviderEnableData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, ft_default_background_provider_real_enable_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	ft_default_background_provider_real_enable_co (_data_);
}

static void
ft_default_background_provider_enable_finish (FtProvider* base,
                                              GAsyncResult* _res_,
                                              GError** error)
{
	FtDefaultBackgroundProviderEnableData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
ft_default_background_provider_enable_ready (GObject* source_object,
                                             GAsyncResult* _res_,
                                             gpointer _user_data_)
{
	FtDefaultBackgroundProviderEnableData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	ft_default_background_provider_real_enable_co (_data_);
}

static gboolean
ft_default_background_provider_real_enable_co (FtDefaultBackgroundProviderEnableData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = ft_default_background_provider_get_autostart_file (_data_->self);
	_data_->autostart_file = _data_->_tmp0_;
	_data_->autostart_allowed = FALSE;
	{
		_data_->_tmp1_ = _data_->autostart_file;
		_data_->_state_ = 1;
		g_file_query_info_async (_data_->_tmp1_, G_FILE_ATTRIBUTE_STANDARD_TYPE, G_FILE_QUERY_INFO_NONE, G_PRIORITY_DEFAULT, _data_->cancellable, ft_default_background_provider_enable_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp2_ = g_file_query_info_finish (_data_->_tmp1_, _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp3_ = _data_->_tmp2_;
		_g_object_unref0 (_data_->_tmp3_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			if (g_error_matches (_data_->_inner_error0_, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) {
				goto __catch0_g_io_error_not_found;
			}
			goto __catch0_g_error;
		}
		_data_->autostart_allowed = TRUE;
	}
	goto __finally0;
	__catch0_g_io_error_not_found:
	{
		g_clear_error (&_data_->_inner_error0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->_error_ = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp4_ = _data_->_error_;
		_data_->_tmp5_ = _data_->_tmp4_->message;
		g_warning ("background-manager.vala:81: Failed to query autostart file: %s", _data_->_tmp5_);
		_g_error_free0 (_data_->_error_);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->autostart_file);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->self->priv->_autostart_allowed = _data_->autostart_allowed;
	g_object_notify ((GObject*) _data_->self, "autostart-allowed");
	_g_object_unref0 (_data_->autostart_file);
	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
ft_default_background_provider_real_disable_data_free (gpointer _data)
{
	FtDefaultBackgroundProviderDisableData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (FtDefaultBackgroundProviderDisableData, _data_);
}

static void
ft_default_background_provider_real_disable (FtProvider* base,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_)
{
	FtDefaultBackgroundProvider * self;
	FtDefaultBackgroundProviderDisableData* _data_;
	FtDefaultBackgroundProvider* _tmp0_;
	self = (FtDefaultBackgroundProvider*) base;
	_data_ = g_slice_new0 (FtDefaultBackgroundProviderDisableData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, ft_default_background_provider_real_disable_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	ft_default_background_provider_real_disable_co (_data_);
}

static void
ft_default_background_provider_disable_finish (FtProvider* base,
                                               GAsyncResult* _res_,
                                               GError** error)
{
	FtDefaultBackgroundProviderDisableData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static gboolean
ft_default_background_provider_real_disable_co (FtDefaultBackgroundProviderDisableData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	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
ft_default_background_provider_real_uninitialize_data_free (gpointer _data)
{
	FtDefaultBackgroundProviderUninitializeData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (FtDefaultBackgroundProviderUninitializeData, _data_);
}

static void
ft_default_background_provider_real_uninitialize (FtProvider* base,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_)
{
	FtDefaultBackgroundProvider * self;
	FtDefaultBackgroundProviderUninitializeData* _data_;
	FtDefaultBackgroundProvider* _tmp0_;
	self = (FtDefaultBackgroundProvider*) base;
	_data_ = g_slice_new0 (FtDefaultBackgroundProviderUninitializeData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, ft_default_background_provider_real_uninitialize_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	ft_default_background_provider_real_uninitialize_co (_data_);
}

static void
ft_default_background_provider_uninitialize_finish (FtProvider* base,
                                                    GAsyncResult* _res_,
                                                    GError** error)
{
	FtDefaultBackgroundProviderUninitializeData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static gboolean
ft_default_background_provider_real_uninitialize_co (FtDefaultBackgroundProviderUninitializeData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	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
ft_default_background_provider_real_request_background_data_free (gpointer _data)
{
	FtDefaultBackgroundProviderRequestBackgroundData* _data_;
	_data_ = _data;
	_g_free0 (_data_->parent_window);
	_g_object_unref0 (_data_->self);
	g_slice_free (FtDefaultBackgroundProviderRequestBackgroundData, _data_);
}

static void
ft_default_background_provider_real_request_background (FtBackgroundProvider* base,
                                                        gboolean autostart,
                                                        const gchar* parent_window,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_)
{
	FtDefaultBackgroundProvider * self;
	FtDefaultBackgroundProviderRequestBackgroundData* _data_;
	FtDefaultBackgroundProvider* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (parent_window != NULL);
	self = (FtDefaultBackgroundProvider*) base;
	_data_ = g_slice_new0 (FtDefaultBackgroundProviderRequestBackgroundData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, ft_default_background_provider_real_request_background_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->autostart = autostart;
	_tmp1_ = g_strdup (parent_window);
	_g_free0 (_data_->parent_window);
	_data_->parent_window = _tmp1_;
	ft_default_background_provider_real_request_background_co (_data_);
}

static void
ft_default_background_provider_request_background_finish (FtBackgroundProvider* base,
                                                          GAsyncResult* _res_)
{
	FtDefaultBackgroundProviderRequestBackgroundData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static gchar*
string_replace (const gchar* self,
                const gchar* old,
                const gchar* replacement)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	if ((*((gchar*) self)) == '\0') {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = (*((gchar*) old)) == '\0';
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = g_strcmp0 (old, replacement) == 0;
	}
	if (_tmp0_) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup (self);
		result = _tmp2_;
		return result;
	}
	{
		GRegex* regex = NULL;
		gchar* _tmp3_;
		gchar* _tmp4_;
		GRegex* _tmp5_;
		GRegex* _tmp6_;
		gchar* _tmp7_ = NULL;
		GRegex* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp3_ = g_regex_escape_string (old, -1);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_regex_new (_tmp4_, 0, 0, &_inner_error0_);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		regex = _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected 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 NULL;
		}
		_tmp8_ = regex;
		_tmp9_ = g_regex_replace_literal (_tmp8_, self, (gssize) -1, 0, replacement, 0, &_inner_error0_);
		_tmp7_ = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_regex_unref0 (regex);
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected 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 NULL;
		}
		_tmp10_ = _tmp7_;
		_tmp7_ = NULL;
		result = _tmp10_;
		_g_free0 (_tmp7_);
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally0:
	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 NULL;
}

static guint8*
string_get_data (const gchar* self,
                 gint* result_length1)
{
	guint8* result;
	guint8* res = NULL;
	gint res_length1;
	gint _res_size_;
	gint _tmp0_;
	gint _tmp1_;
	guint8* _tmp2_;
	gint _tmp2__length1;
	g_return_val_if_fail (self != NULL, NULL);
	res = (guint8*) self;
	res_length1 = -1;
	_res_size_ = res_length1;
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	res_length1 = (gint) _tmp1_;
	_tmp2_ = res;
	_tmp2__length1 = res_length1;
	if (result_length1) {
		*result_length1 = _tmp2__length1;
	}
	result = _tmp2_;
	return result;
}

static void
ft_default_background_provider_request_background_ready (GObject* source_object,
                                                         GAsyncResult* _res_,
                                                         gpointer _user_data_)
{
	FtDefaultBackgroundProviderRequestBackgroundData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	ft_default_background_provider_real_request_background_co (_data_);
}

static gboolean
ft_default_background_provider_real_request_background_co (FtDefaultBackgroundProviderRequestBackgroundData* _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_ = ft_default_background_provider_get_autostart_file (_data_->self);
	_data_->autostart_file = _data_->_tmp0_;
	_data_->_tmp1_ = string_replace (FT_DEFAULT_BACKGROUND_PROVIDER_AUTOSTART_TEMPLATE, "${APPLICATION_ID}", APPLICATION_ID);
	_data_->autostart_contents = _data_->_tmp1_;
	{
		if (_data_->autostart) {
			_data_->_tmp2_ = _data_->autostart_file;
			_data_->_tmp3_ = _data_->autostart_contents;
			_data_->_tmp5_ = 0;
			_data_->_tmp4_ = string_get_data (_data_->_tmp3_, &_data_->_tmp5_);
			_data_->_tmp4__length1 = _data_->_tmp5_;
			_data_->_tmp6_ = _data_->_tmp4_;
			_data_->_tmp6__length1 = _data_->_tmp4__length1;
			_data_->_state_ = 1;
			g_file_replace_contents_async (_data_->_tmp2_, (const char*) _data_->_tmp6_, (gsize) _data_->_tmp6__length1, NULL, FALSE, G_FILE_CREATE_NONE, NULL, ft_default_background_provider_request_background_ready, _data_);
			return FALSE;
			_state_1:
			g_file_replace_contents_finish (_data_->_tmp2_, _data_->_res_, NULL, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				if (g_error_matches (_data_->_inner_error0_, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) {
					goto __catch0_g_io_error_not_found;
				}
				goto __catch0_g_error;
			}
		} else {
			_data_->_tmp7_ = _data_->autostart_file;
			_data_->_state_ = 2;
			g_file_delete_async (_data_->_tmp7_, G_PRIORITY_DEFAULT, NULL, ft_default_background_provider_request_background_ready, _data_);
			return FALSE;
			_state_2:
			g_file_delete_finish (_data_->_tmp7_, _data_->_res_, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				if (g_error_matches (_data_->_inner_error0_, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) {
					goto __catch0_g_io_error_not_found;
				}
				goto __catch0_g_error;
			}
		}
	}
	goto __finally0;
	__catch0_g_io_error_not_found:
	{
		g_clear_error (&_data_->_inner_error0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->_error_ = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp8_ = _data_->_error_;
		_data_->_tmp9_ = _data_->_tmp8_->message;
		g_warning ("background-manager.vala:122: Failed to update autostart file: %s", _data_->_tmp9_);
		_g_error_free0 (_data_->_error_);
		_g_free0 (_data_->autostart_contents);
		_g_object_unref0 (_data_->autostart_file);
		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;
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_free0 (_data_->autostart_contents);
		_g_object_unref0 (_data_->autostart_file);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->self->priv->_autostart_allowed = _data_->autostart;
	g_object_notify ((GObject*) _data_->self, "autostart-allowed");
	_g_free0 (_data_->autostart_contents);
	_g_object_unref0 (_data_->autostart_file);
	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;
}

FtDefaultBackgroundProvider*
ft_default_background_provider_construct (GType object_type)
{
	FtDefaultBackgroundProvider * self = NULL;
	self = (FtDefaultBackgroundProvider*) ft_provider_construct (object_type);
	return self;
}

FtDefaultBackgroundProvider*
ft_default_background_provider_new (void)
{
	return ft_default_background_provider_construct (FT_TYPE_DEFAULT_BACKGROUND_PROVIDER);
}

static gboolean
ft_default_background_provider_real_get_background_allowed (FtBackgroundProvider* base)
{
	gboolean result;
	FtDefaultBackgroundProvider* self;
	gboolean _tmp0_;
	gboolean _tmp1_;
	self = (FtDefaultBackgroundProvider*) base;
	_tmp0_ = ft_provider_get_available ((FtProvider*) self);
	_tmp1_ = _tmp0_;
	result = _tmp1_;
	return result;
}

static gboolean
ft_default_background_provider_real_get_autostart_allowed (FtBackgroundProvider* base)
{
	gboolean result;
	FtDefaultBackgroundProvider* self;
	self = (FtDefaultBackgroundProvider*) base;
	result = self->priv->_autostart_allowed;
	return result;
}

static void
ft_default_background_provider_class_init (FtDefaultBackgroundProviderClass * klass,
                                           gpointer klass_data)
{
	ft_default_background_provider_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FtDefaultBackgroundProvider_private_offset);
	((FtProviderClass *) klass)->initialize = (void (*) (FtProvider*, GCancellable*, GAsyncReadyCallback, gpointer)) ft_default_background_provider_real_initialize;
	((FtProviderClass *) klass)->initialize_finish = (void (*) (FtProvider*, GAsyncResult*, GError**)) ft_default_background_provider_initialize_finish;
	((FtProviderClass *) klass)->enable = (void (*) (FtProvider*, GCancellable*, GAsyncReadyCallback, gpointer)) ft_default_background_provider_real_enable;
	((FtProviderClass *) klass)->enable_finish = (void (*) (FtProvider*, GAsyncResult*, GError**)) ft_default_background_provider_enable_finish;
	((FtProviderClass *) klass)->disable = (void (*) (FtProvider*, GAsyncReadyCallback, gpointer)) ft_default_background_provider_real_disable;
	((FtProviderClass *) klass)->disable_finish = (void (*) (FtProvider*, GAsyncResult*, GError**)) ft_default_background_provider_disable_finish;
	((FtProviderClass *) klass)->uninitialize = (void (*) (FtProvider*, GAsyncReadyCallback, gpointer)) ft_default_background_provider_real_uninitialize;
	((FtProviderClass *) klass)->uninitialize_finish = (void (*) (FtProvider*, GAsyncResult*, GError**)) ft_default_background_provider_uninitialize_finish;
	G_OBJECT_CLASS (klass)->get_property = _vala_ft_default_background_provider_get_property;
	G_OBJECT_CLASS (klass)->finalize = ft_default_background_provider_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_DEFAULT_BACKGROUND_PROVIDER_BACKGROUND_ALLOWED_PROPERTY, ft_default_background_provider_properties[FT_DEFAULT_BACKGROUND_PROVIDER_BACKGROUND_ALLOWED_PROPERTY] = g_param_spec_boolean ("background-allowed", "background-allowed", "background-allowed", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_DEFAULT_BACKGROUND_PROVIDER_AUTOSTART_ALLOWED_PROPERTY, ft_default_background_provider_properties[FT_DEFAULT_BACKGROUND_PROVIDER_AUTOSTART_ALLOWED_PROPERTY] = g_param_spec_boolean ("autostart-allowed", "autostart-allowed", "autostart-allowed", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
ft_default_background_provider_ft_background_provider_interface_init (FtBackgroundProviderIface * iface,
                                                                      gpointer iface_data)
{
	ft_default_background_provider_ft_background_provider_parent_iface = g_type_interface_peek_parent (iface);
	iface->request_background = (void (*) (FtBackgroundProvider*, gboolean, const gchar*, GAsyncReadyCallback, gpointer)) ft_default_background_provider_real_request_background;
	iface->request_background_finish = (void (*) (FtBackgroundProvider*, GAsyncResult*)) ft_default_background_provider_request_background_finish;
	iface->get_background_allowed = ft_default_background_provider_real_get_background_allowed;
	iface->get_autostart_allowed = ft_default_background_provider_real_get_autostart_allowed;
}

static void
ft_default_background_provider_instance_init (FtDefaultBackgroundProvider * self,
                                              gpointer klass)
{
	self->priv = ft_default_background_provider_get_instance_private (self);
	self->priv->_autostart_allowed = FALSE;
}

static void
ft_default_background_provider_finalize (GObject * obj)
{
	FtDefaultBackgroundProvider * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_DEFAULT_BACKGROUND_PROVIDER, FtDefaultBackgroundProvider);
	G_OBJECT_CLASS (ft_default_background_provider_parent_class)->finalize (obj);
}

/**
     * A fallback implementation for missing Background portal.
     *
     * `BackgroundManager` already handles the application hold. Only thing to do
     * is managing the autostart file.
     */
static GType
ft_default_background_provider_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtDefaultBackgroundProviderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_default_background_provider_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtDefaultBackgroundProvider), 0, (GInstanceInitFunc) ft_default_background_provider_instance_init, NULL };
	static const GInterfaceInfo ft_background_provider_info = { (GInterfaceInitFunc) ft_default_background_provider_ft_background_provider_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType ft_default_background_provider_type_id;
	ft_default_background_provider_type_id = g_type_register_static (FT_TYPE_PROVIDER, "FtDefaultBackgroundProvider", &g_define_type_info, 0);
	g_type_add_interface_static (ft_default_background_provider_type_id, FT_TYPE_BACKGROUND_PROVIDER, &ft_background_provider_info);
	FtDefaultBackgroundProvider_private_offset = g_type_add_instance_private (ft_default_background_provider_type_id, sizeof (FtDefaultBackgroundProviderPrivate));
	return ft_default_background_provider_type_id;
}

GType
ft_default_background_provider_get_type (void)
{
	static volatile gsize ft_default_background_provider_type_id__once = 0;
	if (g_once_init_enter (&ft_default_background_provider_type_id__once)) {
		GType ft_default_background_provider_type_id;
		ft_default_background_provider_type_id = ft_default_background_provider_get_type_once ();
		g_once_init_leave (&ft_default_background_provider_type_id__once, ft_default_background_provider_type_id);
	}
	return ft_default_background_provider_type_id__once;
}

static void
_vala_ft_default_background_provider_get_property (GObject * object,
                                                   guint property_id,
                                                   GValue * value,
                                                   GParamSpec * pspec)
{
	FtDefaultBackgroundProvider * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_DEFAULT_BACKGROUND_PROVIDER, FtDefaultBackgroundProvider);
	switch (property_id) {
		case FT_DEFAULT_BACKGROUND_PROVIDER_BACKGROUND_ALLOWED_PROPERTY:
		g_value_set_boolean (value, ft_background_provider_get_background_allowed ((FtBackgroundProvider*) self));
		break;
		case FT_DEFAULT_BACKGROUND_PROVIDER_AUTOSTART_ALLOWED_PROPERTY:
		g_value_set_boolean (value, ft_background_provider_get_autostart_allowed ((FtBackgroundProvider*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
ft_background_manager_get_instance_private (FtBackgroundManager* self)
{
	return G_STRUCT_MEMBER_P (self, FtBackgroundManager_private_offset);
}

static void
ft_background_manager_request_background_data_free (gpointer _data)
{
	FtBackgroundManagerRequestBackgroundData* _data_;
	_data_ = _data;
	_g_free0 (_data_->parent_window);
	_g_object_unref0 (_data_->self);
	g_slice_free (FtBackgroundManagerRequestBackgroundData, _data_);
}

static void
ft_background_manager_request_background (FtBackgroundManager* self,
                                          const gchar* parent_window,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_)
{
	FtBackgroundManagerRequestBackgroundData* _data_;
	FtBackgroundManager* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (parent_window != NULL);
	_data_ = g_slice_new0 (FtBackgroundManagerRequestBackgroundData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, ft_background_manager_request_background_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (parent_window);
	_g_free0 (_data_->parent_window);
	_data_->parent_window = _tmp1_;
	ft_background_manager_request_background_co (_data_);
}

static void
ft_background_manager_request_background_finish (FtBackgroundManager* self,
                                                 GAsyncResult* _res_)
{
	FtBackgroundManagerRequestBackgroundData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
ft_background_manager_request_background_ready (GObject* source_object,
                                                GAsyncResult* _res_,
                                                gpointer _user_data_)
{
	FtBackgroundManagerRequestBackgroundData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	ft_background_manager_request_background_co (_data_);
}

static gboolean
ft_background_manager_request_background_co (FtBackgroundManagerRequestBackgroundData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp1_ = ft_provided_object_get_provider ((FtProvidedObject*) _data_->self);
	_data_->_tmp2_ = _data_->_tmp1_;
	if (((FtBackgroundProvider*) _data_->_tmp2_) == NULL) {
		_data_->_tmp0_ = TRUE;
	} else {
		_data_->_tmp3_ = ft_provided_object_get_provider ((FtProvidedObject*) _data_->self);
		_data_->_tmp4_ = _data_->_tmp3_;
		_data_->_tmp5_ = ft_provider_get_enabled ((FtProvider*) ((FtBackgroundProvider*) _data_->_tmp4_));
		_data_->_tmp6_ = _data_->_tmp5_;
		_data_->_tmp0_ = !_data_->_tmp6_;
	}
	if (_data_->_tmp0_) {
		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_->_tmp7_ = _data_->self->priv->application;
	g_application_hold (_data_->_tmp7_);
	_data_->_tmp8_ = ft_provided_object_get_provider ((FtProvidedObject*) _data_->self);
	_data_->_tmp9_ = _data_->_tmp8_;
	_data_->_tmp10_ = _data_->self->priv->settings;
	_data_->_state_ = 1;
	ft_background_provider_request_background ((FtBackgroundProvider*) _data_->_tmp9_, g_settings_get_boolean (_data_->_tmp10_, "autostart"), _data_->parent_window, ft_background_manager_request_background_ready, _data_);
	return FALSE;
	_state_1:
	ft_background_provider_request_background_finish ((FtBackgroundProvider*) _data_->_tmp9_, _data_->_res_);
	ft_background_manager_update_application_hold (_data_->self);
	_data_->_tmp11_ = _data_->self->priv->application;
	g_application_release (_data_->_tmp11_);
	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
ft_background_manager_hold_application (FtBackgroundManager* self)
{
	g_return_if_fail (self != NULL);
	if (!self->priv->has_application_hold) {
		GApplication* _tmp0_;
		_tmp0_ = self->priv->application;
		g_application_hold (_tmp0_);
		self->priv->has_application_hold = TRUE;
	}
}

static void
ft_background_manager_release_application (FtBackgroundManager* self)
{
	g_return_if_fail (self != NULL);
	if (self->priv->has_application_hold) {
		GApplication* _tmp0_;
		_tmp0_ = self->priv->application;
		g_application_release (_tmp0_);
		self->priv->has_application_hold = FALSE;
	}
}

static void
ft_background_manager_update_application_hold (FtBackgroundManager* self)
{
	gboolean _tmp0_ = FALSE;
	gconstpointer _tmp1_;
	gconstpointer _tmp2_;
	gboolean is_provider_enabled = FALSE;
	gboolean _tmp7_ = FALSE;
	GHashTable* _tmp8_;
	guint _tmp9_;
	guint _tmp10_;
	g_return_if_fail (self != NULL);
	_tmp1_ = ft_provided_object_get_provider ((FtProvidedObject*) self);
	_tmp2_ = _tmp1_;
	if (((FtBackgroundProvider*) _tmp2_) != NULL) {
		gconstpointer _tmp3_;
		gconstpointer _tmp4_;
		gboolean _tmp5_;
		gboolean _tmp6_;
		_tmp3_ = ft_provided_object_get_provider ((FtProvidedObject*) self);
		_tmp4_ = _tmp3_;
		_tmp5_ = ft_provider_get_enabled ((FtProvider*) ((FtBackgroundProvider*) _tmp4_));
		_tmp6_ = _tmp5_;
		_tmp0_ = _tmp6_;
	} else {
		_tmp0_ = FALSE;
	}
	is_provider_enabled = _tmp0_;
	_tmp8_ = self->priv->holds;
	_tmp9_ = g_hash_table_size (_tmp8_);
	_tmp10_ = _tmp9_;
	if (_tmp10_ > 0U) {
		gboolean _tmp11_ = FALSE;
		if (self->priv->_background_allowed) {
			_tmp11_ = TRUE;
		} else {
			_tmp11_ = !is_provider_enabled;
		}
		_tmp7_ = _tmp11_;
	} else {
		_tmp7_ = FALSE;
	}
	if (_tmp7_) {
		ft_background_manager_hold_application (self);
	} else {
		ft_background_manager_release_application (self);
	}
}

static void
ft_background_manager_hold_data_free (gpointer _data)
{
	FtBackgroundManagerHoldData* _data_;
	_data_ = _data;
	_g_free0 (_data_->parent_window);
	_g_object_unref0 (_data_->self);
	g_slice_free (FtBackgroundManagerHoldData, _data_);
}

void
ft_background_manager_hold (FtBackgroundManager* self,
                            const gchar* parent_window,
                            GAsyncReadyCallback _callback_,
                            gpointer _user_data_)
{
	FtBackgroundManagerHoldData* _data_;
	FtBackgroundManager* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (parent_window != NULL);
	_data_ = g_slice_new0 (FtBackgroundManagerHoldData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, ft_background_manager_hold_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (parent_window);
	_g_free0 (_data_->parent_window);
	_data_->parent_window = _tmp1_;
	ft_background_manager_hold_co (_data_);
}

guint
ft_background_manager_hold_finish (FtBackgroundManager* self,
                                   GAsyncResult* _res_)
{
	guint result;
	FtBackgroundManagerHoldData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	return result;
}

static void
ft_background_manager_hold_ready (GObject* source_object,
                                  GAsyncResult* _res_,
                                  gpointer _user_data_)
{
	FtBackgroundManagerHoldData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	ft_background_manager_hold_co (_data_);
}

static gboolean
ft_background_manager_hold_co (FtBackgroundManagerHoldData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->hold_id = ft_background_manager_next_hold_id;
	_data_->_tmp0_ = ft_background_manager_next_hold_id;
	ft_background_manager_next_hold_id = _data_->_tmp0_ + 1;
	_data_->_tmp1_ = _data_->self->priv->holds;
	g_hash_table_add (_data_->_tmp1_, (gpointer) ((guintptr) _data_->hold_id));
	ft_background_manager_hold_application (_data_->self);
	_data_->_state_ = 1;
	ft_background_manager_request_background (_data_->self, _data_->parent_window, ft_background_manager_hold_ready, _data_);
	return FALSE;
	_state_1:
	ft_background_manager_request_background_finish (_data_->self, _data_->_res_);
	_data_->result = _data_->hold_id;
	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;
}

guint
ft_background_manager_hold_sync (FtBackgroundManager* self,
                                 const gchar* parent_window)
{
	guint hold_id = 0U;
	guint _tmp0_;
	GHashTable* _tmp1_;
	guint result;
	g_return_val_if_fail (self != NULL, 0U);
	g_return_val_if_fail (parent_window != NULL, 0U);
	hold_id = ft_background_manager_next_hold_id;
	_tmp0_ = ft_background_manager_next_hold_id;
	ft_background_manager_next_hold_id = _tmp0_ + 1;
	_tmp1_ = self->priv->holds;
	g_hash_table_add (_tmp1_, (gpointer) ((guintptr) hold_id));
	ft_background_manager_hold_application (self);
	ft_background_manager_request_background (self, parent_window, NULL, NULL);
	result = hold_id;
	return result;
}

void
ft_background_manager_release (FtBackgroundManager* self,
                               guint hold_id)
{
	gboolean removed = FALSE;
	GHashTable* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->holds;
	removed = g_hash_table_remove (_tmp0_, (gpointer) ((guintptr) hold_id));
	if (removed) {
		ft_background_manager_update_application_hold (self);
	}
}

static void
ft_background_manager_update_properties (FtBackgroundManager* self)
{
	FtBackgroundProvider* provider = NULL;
	gconstpointer _tmp0_;
	gconstpointer _tmp1_;
	FtBackgroundProvider* _tmp2_;
	gboolean _tmp3_ = FALSE;
	FtBackgroundProvider* _tmp4_;
	gboolean background_allowed = FALSE;
	gboolean _tmp8_ = FALSE;
	FtBackgroundProvider* _tmp9_;
	gboolean autostart_allowed = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = ft_provided_object_get_provider ((FtProvidedObject*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 ((FtBackgroundProvider*) _tmp1_);
	provider = _tmp2_;
	_tmp4_ = provider;
	if (_tmp4_ != NULL) {
		FtBackgroundProvider* _tmp5_;
		gboolean _tmp6_;
		gboolean _tmp7_;
		_tmp5_ = provider;
		_tmp6_ = ft_background_provider_get_background_allowed (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp3_ = _tmp7_;
	} else {
		_tmp3_ = FALSE;
	}
	background_allowed = _tmp3_;
	_tmp9_ = provider;
	if (_tmp9_ != NULL) {
		FtBackgroundProvider* _tmp10_;
		gboolean _tmp11_;
		gboolean _tmp12_;
		_tmp10_ = provider;
		_tmp11_ = ft_background_provider_get_autostart_allowed (_tmp10_);
		_tmp12_ = _tmp11_;
		_tmp8_ = _tmp12_;
	} else {
		_tmp8_ = FALSE;
	}
	autostart_allowed = _tmp8_;
	if (self->priv->_background_allowed != background_allowed) {
		self->priv->_background_allowed = background_allowed;
		g_object_notify ((GObject*) self, "background-allowed");
	}
	if (self->priv->_autostart_allowed != autostart_allowed) {
		self->priv->_autostart_allowed = autostart_allowed;
		g_object_notify ((GObject*) self, "autostart-allowed");
	}
	_g_object_unref0 (provider);
}

static void
_ft_background_manager_on_settings_changed_g_settings_changed (GSettings* _sender,
                                                               const gchar* key,
                                                               gpointer self)
{
	ft_background_manager_on_settings_changed ((FtBackgroundManager*) self, _sender, key);
}

static void
ft_background_manager_real_initialize (FtProvidedObject* base)
{
	FtBackgroundManager * self;
	GApplication* _tmp0_;
	GHashFunc _tmp1_;
	GEqualFunc _tmp2_;
	GHashTable* _tmp3_;
	GSettings* _tmp4_;
	GSettings* _tmp5_;
	GSettings* _tmp6_;
	self = (FtBackgroundManager*) base;
	_tmp0_ = g_application_get_default ();
	self->priv->application = _tmp0_;
	_tmp1_ = g_direct_hash;
	_tmp2_ = g_direct_equal;
	_tmp3_ = g_hash_table_new_full (_tmp1_, _tmp2_, NULL, NULL);
	_g_hash_table_unref0 (self->priv->holds);
	self->priv->holds = _tmp3_;
	_tmp4_ = ft_get_settings ();
	_tmp5_ = _g_object_ref0 (_tmp4_);
	_g_object_unref0 (self->priv->settings);
	self->priv->settings = _tmp5_;
	_tmp6_ = self->priv->settings;
	g_signal_connect_object (_tmp6_, "changed", (GCallback) _ft_background_manager_on_settings_changed_g_settings_changed, self, 0);
}

static void
ft_background_manager_real_setup_providers (FtProvidedObject* base)
{
	FtBackgroundManager * self;
	FtProviderSet* _tmp0_;
	FtDefaultBackgroundProvider* _tmp1_;
	FtDefaultBackgroundProvider* _tmp2_;
	self = (FtBackgroundManager*) base;
	_tmp0_ = ((FtProvidedObject*) self)->providers;
	_tmp1_ = ft_default_background_provider_new ();
	_tmp2_ = _tmp1_;
	ft_provider_set_add (_tmp0_, (FtBackgroundProvider*) _tmp2_, FT_PRIORITY_DEFAULT);
	_g_object_unref0 (_tmp2_);
}

static void
_ft_background_manager_on_notify_background_allowed_g_object_notify (GObject* _sender,
                                                                     GParamSpec* pspec,
                                                                     gpointer self)
{
	ft_background_manager_on_notify_background_allowed ((FtBackgroundManager*) self, _sender, pspec);
}

static void
_ft_background_manager_on_notify_autostart_allowed_g_object_notify (GObject* _sender,
                                                                    GParamSpec* pspec,
                                                                    gpointer self)
{
	ft_background_manager_on_notify_autostart_allowed ((FtBackgroundManager*) self, _sender, pspec);
}

static void
ft_background_manager_real_provider_enabled (FtProvidedObject* base,
                                             FtBackgroundProvider* provider)
{
	FtBackgroundManager * self;
	gboolean _tmp0_ = FALSE;
	GHashTable* _tmp1_;
	guint _tmp2_;
	guint _tmp3_;
	self = (FtBackgroundManager*) base;
	g_return_if_fail (provider != NULL);
	g_signal_connect_object ((GObject*) provider, "notify::background-allowed", (GCallback) _ft_background_manager_on_notify_background_allowed_g_object_notify, self, 0);
	g_signal_connect_object ((GObject*) provider, "notify::autostart-allowed", (GCallback) _ft_background_manager_on_notify_autostart_allowed_g_object_notify, self, 0);
	ft_background_manager_update_properties (self);
	_tmp1_ = self->priv->holds;
	_tmp2_ = g_hash_table_size (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_ > 0U) {
		_tmp0_ = TRUE;
	} else {
		GSettings* _tmp4_;
		_tmp4_ = self->priv->settings;
		_tmp0_ = g_settings_get_boolean (_tmp4_, "autostart");
	}
	if (_tmp0_) {
		ft_background_manager_request_background (self, "", NULL, NULL);
	}
}

static void
ft_background_manager_real_provider_disabled (FtProvidedObject* base,
                                              FtBackgroundProvider* provider)
{
	FtBackgroundManager * self;
	guint _tmp0_;
	GQuark _tmp1_;
	guint _tmp2_;
	GQuark _tmp3_;
	self = (FtBackgroundManager*) base;
	g_return_if_fail (provider != NULL);
	g_signal_parse_name ("notify::background-allowed", G_TYPE_OBJECT, &_tmp0_, &_tmp1_, TRUE);
	g_signal_handlers_disconnect_matched ((GObject*) provider, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DETAIL | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp0_, _tmp1_, NULL, (GCallback) _ft_background_manager_on_notify_background_allowed_g_object_notify, self);
	g_signal_parse_name ("notify::autostart-allowed", G_TYPE_OBJECT, &_tmp2_, &_tmp3_, TRUE);
	g_signal_handlers_disconnect_matched ((GObject*) provider, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DETAIL | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp2_, _tmp3_, NULL, (GCallback) _ft_background_manager_on_notify_autostart_allowed_g_object_notify, self);
	ft_background_manager_update_properties (self);
	ft_background_manager_release_application (self);
}

static void
ft_background_manager_on_notify_background_allowed (FtBackgroundManager* self,
                                                    GObject* object,
                                                    GParamSpec* pspec)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (object != NULL);
	g_return_if_fail (pspec != NULL);
	ft_background_manager_update_properties (self);
}

static void
ft_background_manager_on_notify_autostart_allowed (FtBackgroundManager* self,
                                                   GObject* object,
                                                   GParamSpec* pspec)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (object != NULL);
	g_return_if_fail (pspec != NULL);
	ft_background_manager_update_properties (self);
}

static void
ft_background_manager_on_settings_changed (FtBackgroundManager* self,
                                           GSettings* settings,
                                           const gchar* key)
{
	const gchar* _tmp0_;
	GQuark _tmp2_ = 0U;
	static GQuark _tmp1_label0 = 0;
	g_return_if_fail (self != NULL);
	g_return_if_fail (settings != NULL);
	g_return_if_fail (key != NULL);
	_tmp0_ = key;
	_tmp2_ = (NULL == _tmp0_) ? 0 : g_quark_from_string (_tmp0_);
	if (_tmp2_ == ((0 != _tmp1_label0) ? _tmp1_label0 : (_tmp1_label0 = g_quark_from_static_string ("autostart")))) {
		switch (0) {
			default:
			{
				if (g_settings_get_boolean (settings, key) != self->priv->_autostart_allowed) {
					ft_background_manager_request_background (self, "", NULL, NULL);
				}
				break;
			}
		}
	}
}

void
ft_background_manager_destroy (FtBackgroundManager* self)
{
	GHashTable* _tmp0_ = NULL;
	GHashTable* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->holds;
	_tmp0_ = _tmp1_;
	if (_tmp0_ != NULL) {
		g_hash_table_remove_all (_tmp0_);
	}
	ft_background_manager_release_application (self);
}

static void
ft_background_manager_real_dispose (GObject* base)
{
	FtBackgroundManager * self;
	GSettings* _tmp0_;
	self = (FtBackgroundManager*) base;
	ft_background_manager_destroy (self);
	_tmp0_ = self->priv->settings;
	if (_tmp0_ != NULL) {
		GSettings* _tmp1_;
		guint _tmp2_;
		_tmp1_ = self->priv->settings;
		g_signal_parse_name ("changed", g_settings_get_type (), &_tmp2_, NULL, FALSE);
		g_signal_handlers_disconnect_matched (_tmp1_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp2_, 0, NULL, (GCallback) _ft_background_manager_on_settings_changed_g_settings_changed, self);
		_g_object_unref0 (self->priv->settings);
		self->priv->settings = NULL;
	}
	self->priv->application = NULL;
	_g_hash_table_unref0 (self->priv->holds);
	self->priv->holds = NULL;
	G_OBJECT_CLASS (ft_background_manager_parent_class)->dispose ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, FT_TYPE_PROVIDED_OBJECT, FtProvidedObject));
}

FtBackgroundManager*
ft_background_manager_construct (GType object_type)
{
	FtBackgroundManager * self = NULL;
	self = (FtBackgroundManager*) ft_provided_object_construct (object_type, FT_TYPE_BACKGROUND_PROVIDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref);
	return self;
}

FtBackgroundManager*
ft_background_manager_new (void)
{
	return ft_background_manager_construct (FT_TYPE_BACKGROUND_MANAGER);
}

gboolean
ft_background_manager_get_active (FtBackgroundManager* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->has_application_hold;
	return result;
}

gboolean
ft_background_manager_get_background_allowed (FtBackgroundManager* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_background_allowed;
	return result;
}

gboolean
ft_background_manager_get_autostart_allowed (FtBackgroundManager* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_autostart_allowed;
	return result;
}

static GObject *
ft_background_manager_constructor (GType type,
                                   guint n_construct_properties,
                                   GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	static GWeakRef FtBackgroundManager_singleton__ref;
	static GMutex FtBackgroundManager_singleton__lock;
	FtBackgroundManager * self;
	g_mutex_lock (&FtBackgroundManager_singleton__lock);
	obj = g_weak_ref_get (&FtBackgroundManager_singleton__ref);
	if (obj != NULL) {
		g_mutex_unlock (&FtBackgroundManager_singleton__lock);
		return obj;
	}
	parent_class = G_OBJECT_CLASS (ft_background_manager_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_BACKGROUND_MANAGER, FtBackgroundManager);
	g_weak_ref_set (&FtBackgroundManager_singleton__ref, obj);
	g_mutex_unlock (&FtBackgroundManager_singleton__lock);
	return obj;
}

static void
ft_background_manager_class_init (FtBackgroundManagerClass * klass,
                                  gpointer klass_data)
{
	ft_background_manager_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FtBackgroundManager_private_offset);
	((FtProvidedObjectClass *) klass)->initialize = (void (*) (FtProvidedObject*)) ft_background_manager_real_initialize;
	((FtProvidedObjectClass *) klass)->setup_providers = (void (*) (FtProvidedObject*)) ft_background_manager_real_setup_providers;
	((FtProvidedObjectClass *) klass)->provider_enabled = (void (*) (FtProvidedObject*, gconstpointer)) ft_background_manager_real_provider_enabled;
	((FtProvidedObjectClass *) klass)->provider_disabled = (void (*) (FtProvidedObject*, gconstpointer)) ft_background_manager_real_provider_disabled;
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) ft_background_manager_real_dispose;
	G_OBJECT_CLASS (klass)->get_property = _vala_ft_background_manager_get_property;
	G_OBJECT_CLASS (klass)->constructor = ft_background_manager_constructor;
	G_OBJECT_CLASS (klass)->finalize = ft_background_manager_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_BACKGROUND_MANAGER_ACTIVE_PROPERTY, ft_background_manager_properties[FT_BACKGROUND_MANAGER_ACTIVE_PROPERTY] = g_param_spec_boolean ("active", "active", "active", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_BACKGROUND_MANAGER_BACKGROUND_ALLOWED_PROPERTY, ft_background_manager_properties[FT_BACKGROUND_MANAGER_BACKGROUND_ALLOWED_PROPERTY] = g_param_spec_boolean ("background-allowed", "background-allowed", "background-allowed", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_BACKGROUND_MANAGER_AUTOSTART_ALLOWED_PROPERTY, ft_background_manager_properties[FT_BACKGROUND_MANAGER_AUTOSTART_ALLOWED_PROPERTY] = g_param_spec_boolean ("autostart-allowed", "autostart-allowed", "autostart-allowed", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
ft_background_manager_instance_init (FtBackgroundManager * self,
                                     gpointer klass)
{
	self->priv = ft_background_manager_get_instance_private (self);
	self->priv->application = NULL;
	self->priv->settings = NULL;
	self->priv->has_application_hold = FALSE;
	self->priv->holds = NULL;
	self->priv->_background_allowed = FALSE;
	self->priv->_autostart_allowed = FALSE;
}

static void
ft_background_manager_finalize (GObject * obj)
{
	FtBackgroundManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_BACKGROUND_MANAGER, FtBackgroundManager);
	_g_object_unref0 (self->priv->settings);
	_g_hash_table_unref0 (self->priv->holds);
	G_OBJECT_CLASS (ft_background_manager_parent_class)->finalize (obj);
}

static GType
ft_background_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtBackgroundManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_background_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtBackgroundManager), 0, (GInstanceInitFunc) ft_background_manager_instance_init, NULL };
	GType ft_background_manager_type_id;
	ft_background_manager_type_id = g_type_register_static (FT_TYPE_PROVIDED_OBJECT, "FtBackgroundManager", &g_define_type_info, 0);
	FtBackgroundManager_private_offset = g_type_add_instance_private (ft_background_manager_type_id, sizeof (FtBackgroundManagerPrivate));
	return ft_background_manager_type_id;
}

GType
ft_background_manager_get_type (void)
{
	static volatile gsize ft_background_manager_type_id__once = 0;
	if (g_once_init_enter (&ft_background_manager_type_id__once)) {
		GType ft_background_manager_type_id;
		ft_background_manager_type_id = ft_background_manager_get_type_once ();
		g_once_init_leave (&ft_background_manager_type_id__once, ft_background_manager_type_id);
	}
	return ft_background_manager_type_id__once;
}

static void
_vala_ft_background_manager_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec)
{
	FtBackgroundManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_BACKGROUND_MANAGER, FtBackgroundManager);
	switch (property_id) {
		case FT_BACKGROUND_MANAGER_ACTIVE_PROPERTY:
		g_value_set_boolean (value, ft_background_manager_get_active (self));
		break;
		case FT_BACKGROUND_MANAGER_BACKGROUND_ALLOWED_PROPERTY:
		g_value_set_boolean (value, ft_background_manager_get_background_allowed (self));
		break;
		case FT_BACKGROUND_MANAGER_AUTOSTART_ALLOWED_PROPERTY:
		g_value_set_boolean (value, ft_background_manager_get_autostart_allowed (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

