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

/*
 * Copyright (c) 2026 focus-timer contributors
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#include "ft_plugin_gnome.h"
#include "ft_core.h"
#include <gio/gio.h>
#include <glib.h>
#include <glib-object.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  {
	GNOME_INDICATOR_PROVIDER_0_PROPERTY,
	GNOME_INDICATOR_PROVIDER_VISIBLE_PROPERTY,
	GNOME_INDICATOR_PROVIDER_NUM_PROPERTIES
};
static GParamSpec* gnome_indicator_provider_properties[GNOME_INDICATOR_PROVIDER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _GnomeIndicatorProviderInitializeData GnomeIndicatorProviderInitializeData;
typedef struct _GnomeIndicatorProviderUninitializeData GnomeIndicatorProviderUninitializeData;
typedef struct _GnomeIndicatorProviderEnableData GnomeIndicatorProviderEnableData;
typedef struct _GnomeIndicatorProviderDisableData GnomeIndicatorProviderDisableData;

struct _GnomeIndicatorProviderPrivate {
	GnomeShellExtension* shell_extension;
};

struct _GnomeIndicatorProviderInitializeData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GnomeIndicatorProvider* self;
	GCancellable* cancellable;
	GnomeShellExtension* _tmp0_;
	GnomeShellExtension* _tmp1_;
	GnomeShellExtension* _tmp2_;
};

struct _GnomeIndicatorProviderUninitializeData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GnomeIndicatorProvider* self;
	GnomeShellExtension* _tmp0_;
	GnomeShellExtension* _tmp1_;
	guint _tmp2_;
	GQuark _tmp3_;
};

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

struct _GnomeIndicatorProviderDisableData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GnomeIndicatorProvider* self;
};

static gint GnomeIndicatorProvider_private_offset;
static gpointer gnome_indicator_provider_parent_class = NULL;
static FtIndicatorProviderIface * gnome_indicator_provider_ft_indicator_provider_parent_iface = NULL;
static GType gnome_indicator_provider_type_id = 0;

static void gnome_indicator_provider_update_available (GnomeIndicatorProvider* self);
static void gnome_indicator_provider_on_notify_extension_enabled (GnomeIndicatorProvider* self,
                                                           GObject* object,
                                                           GParamSpec* pspec);
static void gnome_indicator_provider_real_initialize_data_free (gpointer _data);
static void gnome_indicator_provider_real_initialize (FtProvider* base,
                                               GCancellable* cancellable,
                                               GAsyncReadyCallback _callback_,
                                               gpointer _user_data_);
static gboolean gnome_indicator_provider_real_initialize_co (GnomeIndicatorProviderInitializeData* _data_);
static void _gnome_indicator_provider_on_notify_extension_enabled_g_object_notify (GObject* _sender,
                                                                            GParamSpec* pspec,
                                                                            gpointer self);
static void gnome_indicator_provider_initialize_ready (GObject* source_object,
                                                GAsyncResult* _res_,
                                                gpointer _user_data_);
static void gnome_indicator_provider_real_uninitialize_data_free (gpointer _data);
static void gnome_indicator_provider_real_uninitialize (FtProvider* base,
                                                 GAsyncReadyCallback _callback_,
                                                 gpointer _user_data_);
static gboolean gnome_indicator_provider_real_uninitialize_co (GnomeIndicatorProviderUninitializeData* _data_);
static void gnome_indicator_provider_real_enable_data_free (gpointer _data);
static void gnome_indicator_provider_real_enable (FtProvider* base,
                                           GCancellable* cancellable,
                                           GAsyncReadyCallback _callback_,
                                           gpointer _user_data_);
static gboolean gnome_indicator_provider_real_enable_co (GnomeIndicatorProviderEnableData* _data_);
static void gnome_indicator_provider_real_disable_data_free (gpointer _data);
static void gnome_indicator_provider_real_disable (FtProvider* base,
                                            GAsyncReadyCallback _callback_,
                                            gpointer _user_data_);
static gboolean gnome_indicator_provider_real_disable_co (GnomeIndicatorProviderDisableData* _data_);
static void gnome_indicator_provider_finalize (GObject * obj);
static void _vala_gnome_indicator_provider_get_property (GObject * object,
                                                  guint property_id,
                                                  GValue * value,
                                                  GParamSpec * pspec);

static inline gpointer
gnome_indicator_provider_get_instance_private (GnomeIndicatorProvider* self)
{
	return G_STRUCT_MEMBER_P (self, GnomeIndicatorProvider_private_offset);
}

static void
gnome_indicator_provider_update_available (GnomeIndicatorProvider* self)
{
	gboolean _tmp0_ = FALSE;
	GnomeShellExtension* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->shell_extension;
	if (_tmp1_ != NULL) {
		GnomeShellExtension* _tmp2_;
		gboolean _tmp3_;
		gboolean _tmp4_;
		_tmp2_ = self->priv->shell_extension;
		_tmp3_ = gnome_shell_extension_get_enabled (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_;
	} else {
		_tmp0_ = FALSE;
	}
	ft_provider_set_available ((FtProvider*) self, _tmp0_);
}

static void
gnome_indicator_provider_on_notify_extension_enabled (GnomeIndicatorProvider* self,
                                                      GObject* object,
                                                      GParamSpec* pspec)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (object != NULL);
	g_return_if_fail (pspec != NULL);
	gnome_indicator_provider_update_available (self);
	g_object_notify ((GObject*) self, "visible");
}

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

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

static void
gnome_indicator_provider_real_initialize (FtProvider* base,
                                          GCancellable* cancellable,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_)
{
	GnomeIndicatorProvider * self;
	GnomeIndicatorProviderInitializeData* _data_;
	GnomeIndicatorProvider* _tmp0_;
	GCancellable* _tmp1_;
	self = (GnomeIndicatorProvider*) base;
	_data_ = g_slice_new0 (GnomeIndicatorProviderInitializeData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, gnome_indicator_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_;
	gnome_indicator_provider_real_initialize_co (_data_);
}

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

static void
_gnome_indicator_provider_on_notify_extension_enabled_g_object_notify (GObject* _sender,
                                                                       GParamSpec* pspec,
                                                                       gpointer self)
{
	gnome_indicator_provider_on_notify_extension_enabled ((GnomeIndicatorProvider*) self, _sender, pspec);
}

static void
gnome_indicator_provider_initialize_ready (GObject* source_object,
                                           GAsyncResult* _res_,
                                           gpointer _user_data_)
{
	GnomeIndicatorProviderInitializeData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	gnome_indicator_provider_real_initialize_co (_data_);
}

static gboolean
gnome_indicator_provider_real_initialize_co (GnomeIndicatorProviderInitializeData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = gnome_shell_extension_new ();
	_g_object_unref0 (_data_->self->priv->shell_extension);
	_data_->self->priv->shell_extension = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->self->priv->shell_extension;
	g_signal_connect_object ((GObject*) _data_->_tmp1_, "notify::enabled", (GCallback) _gnome_indicator_provider_on_notify_extension_enabled_g_object_notify, _data_->self, 0);
	_data_->_tmp2_ = _data_->self->priv->shell_extension;
	_data_->_state_ = 1;
	gnome_shell_extension_wait (_data_->_tmp2_, gnome_indicator_provider_initialize_ready, _data_);
	return FALSE;
	_state_1:
	gnome_shell_extension_wait_finish (_data_->_tmp2_, _data_->_res_);
	gnome_indicator_provider_update_available (_data_->self);
	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
gnome_indicator_provider_real_uninitialize_data_free (gpointer _data)
{
	GnomeIndicatorProviderUninitializeData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (GnomeIndicatorProviderUninitializeData, _data_);
}

static void
gnome_indicator_provider_real_uninitialize (FtProvider* base,
                                            GAsyncReadyCallback _callback_,
                                            gpointer _user_data_)
{
	GnomeIndicatorProvider * self;
	GnomeIndicatorProviderUninitializeData* _data_;
	GnomeIndicatorProvider* _tmp0_;
	self = (GnomeIndicatorProvider*) base;
	_data_ = g_slice_new0 (GnomeIndicatorProviderUninitializeData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, gnome_indicator_provider_real_uninitialize_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	gnome_indicator_provider_real_uninitialize_co (_data_);
}

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

static gboolean
gnome_indicator_provider_real_uninitialize_co (GnomeIndicatorProviderUninitializeData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->shell_extension;
	if (_data_->_tmp0_ != NULL) {
		_data_->_tmp1_ = _data_->self->priv->shell_extension;
		g_signal_parse_name ("notify::enabled", G_TYPE_OBJECT, &_data_->_tmp2_, &_data_->_tmp3_, TRUE);
		g_signal_handlers_disconnect_matched ((GObject*) _data_->_tmp1_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DETAIL | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp2_, _data_->_tmp3_, NULL, (GCallback) _gnome_indicator_provider_on_notify_extension_enabled_g_object_notify, _data_->self);
		_g_object_unref0 (_data_->self->priv->shell_extension);
		_data_->self->priv->shell_extension = NULL;
		gnome_indicator_provider_update_available (_data_->self);
	}
	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
gnome_indicator_provider_real_enable_data_free (gpointer _data)
{
	GnomeIndicatorProviderEnableData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (GnomeIndicatorProviderEnableData, _data_);
}

static void
gnome_indicator_provider_real_enable (FtProvider* base,
                                      GCancellable* cancellable,
                                      GAsyncReadyCallback _callback_,
                                      gpointer _user_data_)
{
	GnomeIndicatorProvider * self;
	GnomeIndicatorProviderEnableData* _data_;
	GnomeIndicatorProvider* _tmp0_;
	GCancellable* _tmp1_;
	self = (GnomeIndicatorProvider*) base;
	_data_ = g_slice_new0 (GnomeIndicatorProviderEnableData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, gnome_indicator_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_;
	gnome_indicator_provider_real_enable_co (_data_);
}

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

static gboolean
gnome_indicator_provider_real_enable_co (GnomeIndicatorProviderEnableData* _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
gnome_indicator_provider_real_disable_data_free (gpointer _data)
{
	GnomeIndicatorProviderDisableData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (GnomeIndicatorProviderDisableData, _data_);
}

static void
gnome_indicator_provider_real_disable (FtProvider* base,
                                       GAsyncReadyCallback _callback_,
                                       gpointer _user_data_)
{
	GnomeIndicatorProvider * self;
	GnomeIndicatorProviderDisableData* _data_;
	GnomeIndicatorProvider* _tmp0_;
	self = (GnomeIndicatorProvider*) base;
	_data_ = g_slice_new0 (GnomeIndicatorProviderDisableData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, gnome_indicator_provider_real_disable_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	gnome_indicator_provider_real_disable_co (_data_);
}

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

static gboolean
gnome_indicator_provider_real_disable_co (GnomeIndicatorProviderDisableData* _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;
}

GnomeIndicatorProvider*
gnome_indicator_provider_construct (GType object_type)
{
	GnomeIndicatorProvider * self = NULL;
	self = (GnomeIndicatorProvider*) ft_provider_construct (object_type);
	return self;
}

GnomeIndicatorProvider*
gnome_indicator_provider_new (void)
{
	return gnome_indicator_provider_construct (GNOME_TYPE_INDICATOR_PROVIDER);
}

static gboolean
gnome_indicator_provider_real_get_visible (FtIndicatorProvider* base)
{
	gboolean result;
	GnomeIndicatorProvider* self;
	gboolean _tmp0_ = FALSE;
	GnomeShellExtension* _tmp1_;
	self = (GnomeIndicatorProvider*) base;
	_tmp1_ = self->priv->shell_extension;
	if (_tmp1_ != NULL) {
		GnomeShellExtension* _tmp2_;
		gboolean _tmp3_;
		gboolean _tmp4_;
		_tmp2_ = self->priv->shell_extension;
		_tmp3_ = gnome_shell_extension_get_enabled (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_;
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

static void
gnome_indicator_provider_class_init (GnomeIndicatorProviderClass * klass,
                                     gpointer klass_data)
{
	gnome_indicator_provider_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GnomeIndicatorProvider_private_offset);
	((FtProviderClass *) klass)->initialize = (void (*) (FtProvider*, GCancellable*, GAsyncReadyCallback, gpointer)) gnome_indicator_provider_real_initialize;
	((FtProviderClass *) klass)->initialize_finish = (void (*) (FtProvider*, GAsyncResult*, GError**)) gnome_indicator_provider_initialize_finish;
	((FtProviderClass *) klass)->uninitialize = (void (*) (FtProvider*, GAsyncReadyCallback, gpointer)) gnome_indicator_provider_real_uninitialize;
	((FtProviderClass *) klass)->uninitialize_finish = (void (*) (FtProvider*, GAsyncResult*, GError**)) gnome_indicator_provider_uninitialize_finish;
	((FtProviderClass *) klass)->enable = (void (*) (FtProvider*, GCancellable*, GAsyncReadyCallback, gpointer)) gnome_indicator_provider_real_enable;
	((FtProviderClass *) klass)->enable_finish = (void (*) (FtProvider*, GAsyncResult*, GError**)) gnome_indicator_provider_enable_finish;
	((FtProviderClass *) klass)->disable = (void (*) (FtProvider*, GAsyncReadyCallback, gpointer)) gnome_indicator_provider_real_disable;
	((FtProviderClass *) klass)->disable_finish = (void (*) (FtProvider*, GAsyncResult*, GError**)) gnome_indicator_provider_disable_finish;
	G_OBJECT_CLASS (klass)->get_property = _vala_gnome_indicator_provider_get_property;
	G_OBJECT_CLASS (klass)->finalize = gnome_indicator_provider_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GNOME_INDICATOR_PROVIDER_VISIBLE_PROPERTY, gnome_indicator_provider_properties[GNOME_INDICATOR_PROVIDER_VISIBLE_PROPERTY] = g_param_spec_boolean ("visible", "visible", "visible", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
gnome_indicator_provider_ft_indicator_provider_interface_init (FtIndicatorProviderIface * iface,
                                                               gpointer iface_data)
{
	gnome_indicator_provider_ft_indicator_provider_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_visible = gnome_indicator_provider_real_get_visible;
}

static void
gnome_indicator_provider_instance_init (GnomeIndicatorProvider * self,
                                        gpointer klass)
{
	self->priv = gnome_indicator_provider_get_instance_private (self);
	self->priv->shell_extension = NULL;
}

static void
gnome_indicator_provider_finalize (GObject * obj)
{
	GnomeIndicatorProvider * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GNOME_TYPE_INDICATOR_PROVIDER, GnomeIndicatorProvider);
	_g_object_unref0 (self->priv->shell_extension);
	G_OBJECT_CLASS (gnome_indicator_provider_parent_class)->finalize (obj);
}

/**
     * Provider for the indicator when the extension is enabled.
     *
     * Extension manages the indicator. Just prevent other implementations from getting enabled.
     */
GType
gnome_indicator_provider_get_type (void)
{
	return gnome_indicator_provider_type_id;
}

GType
gnome_indicator_provider_register_type (GTypeModule * module)
{
	static const GTypeInfo g_define_type_info = { sizeof (GnomeIndicatorProviderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gnome_indicator_provider_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GnomeIndicatorProvider), 0, (GInstanceInitFunc) gnome_indicator_provider_instance_init, NULL };
	static const GInterfaceInfo ft_indicator_provider_info = { (GInterfaceInitFunc) gnome_indicator_provider_ft_indicator_provider_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	gnome_indicator_provider_type_id = g_type_module_register_type (module, FT_TYPE_PROVIDER, "GnomeIndicatorProvider", &g_define_type_info, 0);
	g_type_module_add_interface (module, gnome_indicator_provider_type_id, FT_TYPE_INDICATOR_PROVIDER, &ft_indicator_provider_info);
	GnomeIndicatorProvider_private_offset = sizeof (GnomeIndicatorProviderPrivate);
	return gnome_indicator_provider_type_id;
}

static void
_vala_gnome_indicator_provider_get_property (GObject * object,
                                             guint property_id,
                                             GValue * value,
                                             GParamSpec * pspec)
{
	GnomeIndicatorProvider * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GNOME_TYPE_INDICATOR_PROVIDER, GnomeIndicatorProvider);
	switch (property_id) {
		case GNOME_INDICATOR_PROVIDER_VISIBLE_PROPERTY:
		g_value_set_boolean (value, ft_indicator_provider_get_visible ((FtIndicatorProvider*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

