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

/*-
 * Copyright (c) 2015-2023 elementary LLC. (https://elementary.io)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Library General Public License as published by
 * the Free Software Foundation, either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "bluetooth.h"
#include <glib.h>
#include <wingpanel.h>
#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib/gi18n-lib.h>
#include <gmodule.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  {
	BLUETOOTH_INDICATOR_INDICATOR_0_PROPERTY,
	BLUETOOTH_INDICATOR_INDICATOR_IS_IN_SESSION_PROPERTY,
	BLUETOOTH_INDICATOR_INDICATOR_NUM_PROPERTIES
};
static GParamSpec* bluetooth_indicator_indicator_properties[BLUETOOTH_INDICATOR_INDICATOR_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _BluetoothIndicatorIndicatorPrivate {
	gboolean _is_in_session;
	BluetoothIndicatorWidgetsPopoverWidget* popover_widget;
	BluetoothIndicatorWidgetsDisplayWidget* dynamic_icon;
	BluetoothIndicatorServicesObjectManager* object_manager;
	BluetoothIndicatorServicesObexManager* obex_manager;
};

static gint BluetoothIndicatorIndicator_private_offset;
static gpointer bluetooth_indicator_indicator_parent_class = NULL;

static GtkWidget* bluetooth_indicator_indicator_real_get_display_widget (WingpanelIndicator* base);
static GtkWidget* bluetooth_indicator_indicator_real_get_widget (WingpanelIndicator* base);
static void bluetooth_indicator_indicator_real_opened (WingpanelIndicator* base);
static void bluetooth_indicator_indicator_real_closed (WingpanelIndicator* base);
static GObject * bluetooth_indicator_indicator_constructor (GType type,
                                                     guint n_construct_properties,
                                                     GObjectConstructParam * construct_properties);
static void _bluetooth_indicator_indicator___lambda33_ (BluetoothIndicatorIndicator* self);
static void __bluetooth_indicator_indicator___lambda33__g_object_notify (GObject* _sender,
                                                                  GParamSpec* pspec,
                                                                  gpointer self);
static void bluetooth_indicator_indicator_finalize (GObject * obj);
static GType bluetooth_indicator_indicator_get_type_once (void);
static void _vala_bluetooth_indicator_indicator_get_property (GObject * object,
                                                       guint property_id,
                                                       GValue * value,
                                                       GParamSpec * pspec);
static void _vala_bluetooth_indicator_indicator_set_property (GObject * object,
                                                       guint property_id,
                                                       const GValue * value,
                                                       GParamSpec * pspec);

static inline gpointer
bluetooth_indicator_indicator_get_instance_private (BluetoothIndicatorIndicator* self)
{
	return G_STRUCT_MEMBER_P (self, BluetoothIndicatorIndicator_private_offset);
}

BluetoothIndicatorIndicator*
bluetooth_indicator_indicator_construct (GType object_type,
                                         gboolean is_in_session)
{
	BluetoothIndicatorIndicator * self = NULL;
	self = (BluetoothIndicatorIndicator*) g_object_new (object_type, "code-name", WINGPANEL_INDICATOR_BLUETOOTH, "is-in-session", is_in_session, NULL);
	return self;
}

BluetoothIndicatorIndicator*
bluetooth_indicator_indicator_new (gboolean is_in_session)
{
	return bluetooth_indicator_indicator_construct (BLUETOOTH_INDICATOR_TYPE_INDICATOR, is_in_session);
}

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

static GtkWidget*
bluetooth_indicator_indicator_real_get_display_widget (WingpanelIndicator* base)
{
	BluetoothIndicatorIndicator * self;
	BluetoothIndicatorWidgetsDisplayWidget* _tmp0_;
	BluetoothIndicatorWidgetsDisplayWidget* _tmp3_;
	GtkWidget* _tmp4_;
	GtkWidget* result;
	self = (BluetoothIndicatorIndicator*) base;
	_tmp0_ = self->priv->dynamic_icon;
	if (_tmp0_ == NULL) {
		BluetoothIndicatorServicesObjectManager* _tmp1_;
		BluetoothIndicatorWidgetsDisplayWidget* _tmp2_;
		_tmp1_ = self->priv->object_manager;
		_tmp2_ = bluetooth_indicator_widgets_display_widget_new (_tmp1_);
		g_object_ref_sink (_tmp2_);
		_g_object_unref0 (self->priv->dynamic_icon);
		self->priv->dynamic_icon = _tmp2_;
	}
	_tmp3_ = self->priv->dynamic_icon;
	_tmp4_ = _g_object_ref0 ((GtkWidget*) _tmp3_);
	result = _tmp4_;
	return result;
}

static GtkWidget*
bluetooth_indicator_indicator_real_get_widget (WingpanelIndicator* base)
{
	BluetoothIndicatorIndicator * self;
	BluetoothIndicatorWidgetsPopoverWidget* _tmp0_;
	BluetoothIndicatorWidgetsPopoverWidget* _tmp5_;
	GtkWidget* _tmp6_;
	GtkWidget* result;
	self = (BluetoothIndicatorIndicator*) base;
	_tmp0_ = self->priv->popover_widget;
	if (_tmp0_ == NULL) {
		BluetoothIndicatorServicesObjectManager* _tmp1_;
		BluetoothIndicatorServicesObexManager* _tmp2_;
		gboolean _tmp3_;
		BluetoothIndicatorWidgetsPopoverWidget* _tmp4_;
		_tmp1_ = self->priv->object_manager;
		_tmp2_ = self->priv->obex_manager;
		_tmp3_ = self->priv->_is_in_session;
		_tmp4_ = bluetooth_indicator_widgets_popover_widget_new (_tmp1_, _tmp2_, _tmp3_);
		g_object_ref_sink (_tmp4_);
		_g_object_unref0 (self->priv->popover_widget);
		self->priv->popover_widget = _tmp4_;
	}
	_tmp5_ = self->priv->popover_widget;
	_tmp6_ = _g_object_ref0 ((GtkWidget*) _tmp5_);
	result = _tmp6_;
	return result;
}

static void
bluetooth_indicator_indicator_real_opened (WingpanelIndicator* base)
{
	BluetoothIndicatorIndicator * self;
	self = (BluetoothIndicatorIndicator*) base;
}

static void
bluetooth_indicator_indicator_real_closed (WingpanelIndicator* base)
{
	BluetoothIndicatorIndicator * self;
	self = (BluetoothIndicatorIndicator*) base;
}

gboolean
bluetooth_indicator_indicator_get_is_in_session (BluetoothIndicatorIndicator* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_is_in_session;
	return result;
}

static void
bluetooth_indicator_indicator_set_is_in_session (BluetoothIndicatorIndicator* self,
                                                 gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = bluetooth_indicator_indicator_get_is_in_session (self);
	if (old_value != value) {
		self->priv->_is_in_session = value;
		g_object_notify_by_pspec ((GObject *) self, bluetooth_indicator_indicator_properties[BLUETOOTH_INDICATOR_INDICATOR_IS_IN_SESSION_PROPERTY]);
	}
}

static void
_bluetooth_indicator_indicator___lambda33_ (BluetoothIndicatorIndicator* self)
{
	BluetoothIndicatorServicesObjectManager* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	_tmp0_ = self->priv->object_manager;
	_tmp1_ = bluetooth_indicator_services_object_manager_get_has_object (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		BluetoothIndicatorServicesObjectManager* _tmp3_;
		_tmp3_ = self->priv->object_manager;
		bluetooth_indicator_services_object_manager_set_state_from_settings (_tmp3_, NULL, NULL);
	}
}

static void
__bluetooth_indicator_indicator___lambda33__g_object_notify (GObject* _sender,
                                                             GParamSpec* pspec,
                                                             gpointer self)
{
	_bluetooth_indicator_indicator___lambda33_ ((BluetoothIndicatorIndicator*) self);
}

static GObject *
bluetooth_indicator_indicator_constructor (GType type,
                                           guint n_construct_properties,
                                           GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	BluetoothIndicatorIndicator * self;
	BluetoothIndicatorServicesObjectManager* _tmp0_;
	BluetoothIndicatorServicesObjectManager* _tmp1_;
	BluetoothIndicatorServicesObexManager* _tmp2_;
	BluetoothIndicatorServicesObjectManager* _tmp3_;
	gboolean _tmp4_;
	gboolean _tmp5_;
	BluetoothIndicatorServicesObjectManager* _tmp7_;
	parent_class = G_OBJECT_CLASS (bluetooth_indicator_indicator_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BLUETOOTH_INDICATOR_TYPE_INDICATOR, BluetoothIndicatorIndicator);
	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	_tmp0_ = bluetooth_indicator_services_object_manager_new ();
	_g_object_unref0 (self->priv->object_manager);
	self->priv->object_manager = _tmp0_;
	_tmp1_ = self->priv->object_manager;
	g_object_bind_property_with_closures ((GObject*) _tmp1_, "has-object", (GObject*) self, "visible", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp2_ = bluetooth_indicator_services_obex_manager_new ();
	_g_object_unref0 (self->priv->obex_manager);
	self->priv->obex_manager = _tmp2_;
	_tmp3_ = self->priv->object_manager;
	_tmp4_ = bluetooth_indicator_services_object_manager_get_has_object (_tmp3_);
	_tmp5_ = _tmp4_;
	if (_tmp5_) {
		BluetoothIndicatorServicesObjectManager* _tmp6_;
		_tmp6_ = self->priv->object_manager;
		bluetooth_indicator_services_object_manager_set_state_from_settings (_tmp6_, NULL, NULL);
	}
	_tmp7_ = self->priv->object_manager;
	g_signal_connect_object ((GObject*) _tmp7_, "notify::has-object", (GCallback) __bluetooth_indicator_indicator___lambda33__g_object_notify, self, 0);
	return obj;
}

static void
bluetooth_indicator_indicator_class_init (BluetoothIndicatorIndicatorClass * klass,
                                          gpointer klass_data)
{
	bluetooth_indicator_indicator_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BluetoothIndicatorIndicator_private_offset);
	((WingpanelIndicatorClass *) klass)->get_display_widget = (GtkWidget* (*) (WingpanelIndicator*)) bluetooth_indicator_indicator_real_get_display_widget;
	((WingpanelIndicatorClass *) klass)->get_widget = (GtkWidget* (*) (WingpanelIndicator*)) bluetooth_indicator_indicator_real_get_widget;
	((WingpanelIndicatorClass *) klass)->opened = (void (*) (WingpanelIndicator*)) bluetooth_indicator_indicator_real_opened;
	((WingpanelIndicatorClass *) klass)->closed = (void (*) (WingpanelIndicator*)) bluetooth_indicator_indicator_real_closed;
	G_OBJECT_CLASS (klass)->get_property = _vala_bluetooth_indicator_indicator_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_bluetooth_indicator_indicator_set_property;
	G_OBJECT_CLASS (klass)->constructor = bluetooth_indicator_indicator_constructor;
	G_OBJECT_CLASS (klass)->finalize = bluetooth_indicator_indicator_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), BLUETOOTH_INDICATOR_INDICATOR_IS_IN_SESSION_PROPERTY, bluetooth_indicator_indicator_properties[BLUETOOTH_INDICATOR_INDICATOR_IS_IN_SESSION_PROPERTY] = g_param_spec_boolean ("is-in-session", "is-in-session", "is-in-session", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
bluetooth_indicator_indicator_instance_init (BluetoothIndicatorIndicator * self,
                                             gpointer klass)
{
	self->priv = bluetooth_indicator_indicator_get_instance_private (self);
	self->priv->_is_in_session = FALSE;
}

static void
bluetooth_indicator_indicator_finalize (GObject * obj)
{
	BluetoothIndicatorIndicator * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BLUETOOTH_INDICATOR_TYPE_INDICATOR, BluetoothIndicatorIndicator);
	_g_object_unref0 (self->priv->popover_widget);
	_g_object_unref0 (self->priv->dynamic_icon);
	_g_object_unref0 (self->priv->object_manager);
	_g_object_unref0 (self->priv->obex_manager);
	G_OBJECT_CLASS (bluetooth_indicator_indicator_parent_class)->finalize (obj);
}

static GType
bluetooth_indicator_indicator_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BluetoothIndicatorIndicatorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bluetooth_indicator_indicator_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BluetoothIndicatorIndicator), 0, (GInstanceInitFunc) bluetooth_indicator_indicator_instance_init, NULL };
	GType bluetooth_indicator_indicator_type_id;
	bluetooth_indicator_indicator_type_id = g_type_register_static (WINGPANEL_TYPE_INDICATOR, "BluetoothIndicatorIndicator", &g_define_type_info, 0);
	BluetoothIndicatorIndicator_private_offset = g_type_add_instance_private (bluetooth_indicator_indicator_type_id, sizeof (BluetoothIndicatorIndicatorPrivate));
	return bluetooth_indicator_indicator_type_id;
}

GType
bluetooth_indicator_indicator_get_type (void)
{
	static volatile gsize bluetooth_indicator_indicator_type_id__once = 0;
	if (g_once_init_enter (&bluetooth_indicator_indicator_type_id__once)) {
		GType bluetooth_indicator_indicator_type_id;
		bluetooth_indicator_indicator_type_id = bluetooth_indicator_indicator_get_type_once ();
		g_once_init_leave (&bluetooth_indicator_indicator_type_id__once, bluetooth_indicator_indicator_type_id);
	}
	return bluetooth_indicator_indicator_type_id__once;
}

static void
_vala_bluetooth_indicator_indicator_get_property (GObject * object,
                                                  guint property_id,
                                                  GValue * value,
                                                  GParamSpec * pspec)
{
	BluetoothIndicatorIndicator * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, BLUETOOTH_INDICATOR_TYPE_INDICATOR, BluetoothIndicatorIndicator);
	switch (property_id) {
		case BLUETOOTH_INDICATOR_INDICATOR_IS_IN_SESSION_PROPERTY:
		g_value_set_boolean (value, bluetooth_indicator_indicator_get_is_in_session (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_bluetooth_indicator_indicator_set_property (GObject * object,
                                                  guint property_id,
                                                  const GValue * value,
                                                  GParamSpec * pspec)
{
	BluetoothIndicatorIndicator * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, BLUETOOTH_INDICATOR_TYPE_INDICATOR, BluetoothIndicatorIndicator);
	switch (property_id) {
		case BLUETOOTH_INDICATOR_INDICATOR_IS_IN_SESSION_PROPERTY:
		bluetooth_indicator_indicator_set_is_in_session (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

WingpanelIndicator*
get_indicator (GModule* module,
               WingpanelIndicatorManagerServerType server_type)
{
	BluetoothIndicatorIndicator* indicator = NULL;
	BluetoothIndicatorIndicator* _tmp0_;
	WingpanelIndicator* result;
	g_return_val_if_fail (module != NULL, NULL);
	g_debug ("Indicator.vala:76: Activating Bluetooth Indicator");
	_tmp0_ = bluetooth_indicator_indicator_new (server_type == WINGPANEL_INDICATOR_MANAGER_SERVER_TYPE_SESSION);
	indicator = _tmp0_;
	result = (WingpanelIndicator*) indicator;
	return result;
}

