/* pulseSinkInput.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from pulseSinkInput.vala, do not modify */

/* From SwaySettings PulseAudio page: https://github.com/ErikReider/SwaySettings/blob/2b05776bce2fd55933a7fbdec995f54849e39e7d/src/Pages/Pulse/PulseSinkInput.vala*/

#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include <pulse/pulseaudio.h>
#include <gee.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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define SWAY_NOTIFICATION_CENTER_WIDGETS_TYPE_PULSE_SINK_INPUT (sway_notification_center_widgets_pulse_sink_input_get_type ())
#define SWAY_NOTIFICATION_CENTER_WIDGETS_PULSE_SINK_INPUT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWAY_NOTIFICATION_CENTER_WIDGETS_TYPE_PULSE_SINK_INPUT, SwayNotificationCenterWidgetsPulseSinkInput))
#define SWAY_NOTIFICATION_CENTER_WIDGETS_PULSE_SINK_INPUT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWAY_NOTIFICATION_CENTER_WIDGETS_TYPE_PULSE_SINK_INPUT, SwayNotificationCenterWidgetsPulseSinkInputClass))
#define SWAY_NOTIFICATION_CENTER_WIDGETS_IS_PULSE_SINK_INPUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWAY_NOTIFICATION_CENTER_WIDGETS_TYPE_PULSE_SINK_INPUT))
#define SWAY_NOTIFICATION_CENTER_WIDGETS_IS_PULSE_SINK_INPUT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWAY_NOTIFICATION_CENTER_WIDGETS_TYPE_PULSE_SINK_INPUT))
#define SWAY_NOTIFICATION_CENTER_WIDGETS_PULSE_SINK_INPUT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWAY_NOTIFICATION_CENTER_WIDGETS_TYPE_PULSE_SINK_INPUT, SwayNotificationCenterWidgetsPulseSinkInputClass))

typedef struct _SwayNotificationCenterWidgetsPulseSinkInput SwayNotificationCenterWidgetsPulseSinkInput;
typedef struct _SwayNotificationCenterWidgetsPulseSinkInputClass SwayNotificationCenterWidgetsPulseSinkInputClass;
typedef struct _SwayNotificationCenterWidgetsPulseSinkInputPrivate SwayNotificationCenterWidgetsPulseSinkInputPrivate;
enum  {
	SWAY_NOTIFICATION_CENTER_WIDGETS_PULSE_SINK_INPUT_0_PROPERTY,
	SWAY_NOTIFICATION_CENTER_WIDGETS_PULSE_SINK_INPUT_BALANCE_PROPERTY,
	SWAY_NOTIFICATION_CENTER_WIDGETS_PULSE_SINK_INPUT_NUM_PROPERTIES
};
static GParamSpec* sway_notification_center_widgets_pulse_sink_input_properties[SWAY_NOTIFICATION_CENTER_WIDGETS_PULSE_SINK_INPUT_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)))

struct _SwayNotificationCenterWidgetsPulseSinkInput {
	GObject parent_instance;
	SwayNotificationCenterWidgetsPulseSinkInputPrivate * priv;
	guint32 index;
	guint32 sink_index;
	guint32 client_index;
	gchar* name;
	gchar* application_binary;
	gchar* application_icon_name;
	gchar* media_name;
	gboolean is_muted;
	gdouble volume;
	pa_cvolume cvolume;
	pa_channel_map channel_map;
	GeeLinkedList* volume_operations;
	gboolean active;
};

struct _SwayNotificationCenterWidgetsPulseSinkInputClass {
	GObjectClass parent_class;
};

struct _SwayNotificationCenterWidgetsPulseSinkInputPrivate {
	gfloat _balance;
};

static gint SwayNotificationCenterWidgetsPulseSinkInput_private_offset;
static gpointer sway_notification_center_widgets_pulse_sink_input_parent_class = NULL;

VALA_EXTERN GType sway_notification_center_widgets_pulse_sink_input_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SwayNotificationCenterWidgetsPulseSinkInput, g_object_unref)
VALA_EXTERN gchar* sway_notification_center_widgets_pulse_sink_input_get_display_name (SwayNotificationCenterWidgetsPulseSinkInput* self);
VALA_EXTERN gboolean sway_notification_center_widgets_pulse_sink_input_cmp (SwayNotificationCenterWidgetsPulseSinkInput* self,
                                                                SwayNotificationCenterWidgetsPulseSinkInput* sink_input);
VALA_EXTERN guint32 sway_notification_center_widgets_pulse_sink_input_get_hash_map_key (guint32 i);
VALA_EXTERN SwayNotificationCenterWidgetsPulseSinkInput* sway_notification_center_widgets_pulse_sink_input_new (void);
VALA_EXTERN SwayNotificationCenterWidgetsPulseSinkInput* sway_notification_center_widgets_pulse_sink_input_construct (GType object_type);
VALA_EXTERN gfloat sway_notification_center_widgets_pulse_sink_input_get_balance (SwayNotificationCenterWidgetsPulseSinkInput* self);
VALA_EXTERN void sway_notification_center_widgets_pulse_sink_input_set_balance (SwayNotificationCenterWidgetsPulseSinkInput* self,
                                                                    gfloat value);
static GObject * sway_notification_center_widgets_pulse_sink_input_constructor (GType type,
                                                                         guint n_construct_properties,
                                                                         GObjectConstructParam * construct_properties);
static void sway_notification_center_widgets_pulse_sink_input_finalize (GObject * obj);
static GType sway_notification_center_widgets_pulse_sink_input_get_type_once (void);
static void _vala_sway_notification_center_widgets_pulse_sink_input_get_property (GObject * object,
                                                                           guint property_id,
                                                                           GValue * value,
                                                                           GParamSpec * pspec);
static void _vala_sway_notification_center_widgets_pulse_sink_input_set_property (GObject * object,
                                                                           guint property_id,
                                                                           const GValue * value,
                                                                           GParamSpec * pspec);

static inline gpointer
sway_notification_center_widgets_pulse_sink_input_get_instance_private (SwayNotificationCenterWidgetsPulseSinkInput* self)
{
	return G_STRUCT_MEMBER_P (self, SwayNotificationCenterWidgetsPulseSinkInput_private_offset);
}

/** Gets the name to be shown to the user:
         * "application_name"
         */
gchar*
sway_notification_center_widgets_pulse_sink_input_get_display_name (SwayNotificationCenterWidgetsPulseSinkInput* self)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* result;
	g_return_val_if_fail (SWAY_NOTIFICATION_CENTER_WIDGETS_IS_PULSE_SINK_INPUT (self), NULL);
	_tmp0_ = self->name;
	_tmp1_ = g_strdup (_tmp0_);
	result = _tmp1_;
	return result;
}

gboolean
sway_notification_center_widgets_pulse_sink_input_cmp (SwayNotificationCenterWidgetsPulseSinkInput* self,
                                                       SwayNotificationCenterWidgetsPulseSinkInput* sink_input)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_ = FALSE;
	gboolean result;
	g_return_val_if_fail (SWAY_NOTIFICATION_CENTER_WIDGETS_IS_PULSE_SINK_INPUT (self), FALSE);
	g_return_val_if_fail (SWAY_NOTIFICATION_CENTER_WIDGETS_IS_PULSE_SINK_INPUT (sink_input), FALSE);
	if (sink_input->index == self->index) {
		_tmp5_ = sink_input->sink_index == self->sink_index;
	} else {
		_tmp5_ = FALSE;
	}
	if (_tmp5_) {
		_tmp4_ = sink_input->client_index == self->client_index;
	} else {
		_tmp4_ = FALSE;
	}
	if (_tmp4_) {
		const gchar* _tmp6_;
		const gchar* _tmp7_;
		_tmp6_ = sink_input->name;
		_tmp7_ = self->name;
		_tmp3_ = g_strcmp0 (_tmp6_, _tmp7_) == 0;
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		const gchar* _tmp8_;
		const gchar* _tmp9_;
		_tmp8_ = sink_input->application_binary;
		_tmp9_ = self->application_binary;
		_tmp2_ = g_strcmp0 (_tmp8_, _tmp9_) == 0;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		_tmp1_ = sink_input->is_muted == self->is_muted;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		_tmp0_ = sink_input->volume == self->volume;
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

/** Gets the name to be shown to the user:
         * "index:application_name"
         */
guint32
sway_notification_center_widgets_pulse_sink_input_get_hash_map_key (guint32 i)
{
	guint32 result;
	result = i;
	return result;
}

SwayNotificationCenterWidgetsPulseSinkInput*
sway_notification_center_widgets_pulse_sink_input_construct (GType object_type)
{
	SwayNotificationCenterWidgetsPulseSinkInput * self = NULL;
	self = (SwayNotificationCenterWidgetsPulseSinkInput*) g_object_new (object_type, NULL);
	return self;
}

SwayNotificationCenterWidgetsPulseSinkInput*
sway_notification_center_widgets_pulse_sink_input_new (void)
{
	return sway_notification_center_widgets_pulse_sink_input_construct (SWAY_NOTIFICATION_CENTER_WIDGETS_TYPE_PULSE_SINK_INPUT);
}

gfloat
sway_notification_center_widgets_pulse_sink_input_get_balance (SwayNotificationCenterWidgetsPulseSinkInput* self)
{
	gfloat result;
	g_return_val_if_fail (SWAY_NOTIFICATION_CENTER_WIDGETS_IS_PULSE_SINK_INPUT (self), 0.0F);
	result = self->priv->_balance;
	return result;
}

void
sway_notification_center_widgets_pulse_sink_input_set_balance (SwayNotificationCenterWidgetsPulseSinkInput* self,
                                                               gfloat value)
{
	gfloat old_value;
	g_return_if_fail (SWAY_NOTIFICATION_CENTER_WIDGETS_IS_PULSE_SINK_INPUT (self));
	old_value = sway_notification_center_widgets_pulse_sink_input_get_balance (self);
	if (old_value != value) {
		self->priv->_balance = value;
		g_object_notify_by_pspec ((GObject *) self, sway_notification_center_widgets_pulse_sink_input_properties[SWAY_NOTIFICATION_CENTER_WIDGETS_PULSE_SINK_INPUT_BALANCE_PROPERTY]);
	}
}

static GObject *
sway_notification_center_widgets_pulse_sink_input_constructor (GType type,
                                                               guint n_construct_properties,
                                                               GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	SwayNotificationCenterWidgetsPulseSinkInput * self;
	GeeLinkedList* _tmp0_;
	parent_class = G_OBJECT_CLASS (sway_notification_center_widgets_pulse_sink_input_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SWAY_NOTIFICATION_CENTER_WIDGETS_TYPE_PULSE_SINK_INPUT, SwayNotificationCenterWidgetsPulseSinkInput);
	_tmp0_ = gee_linked_list_new (G_TYPE_POINTER, (GBoxedCopyFunc) pa_operation_ref, (GDestroyNotify) pa_operation_unref, NULL, NULL, NULL);
	if (_tmp0_) {
		g_object_set_data ((GObject *) _tmp0_, "vala-creation-function", "");
	}
	_g_object_unref0 (self->volume_operations);
	self->volume_operations = _tmp0_;
	return obj;
}

static void
sway_notification_center_widgets_pulse_sink_input_class_init (SwayNotificationCenterWidgetsPulseSinkInputClass * klass,
                                                              gpointer klass_data)
{
	sway_notification_center_widgets_pulse_sink_input_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &SwayNotificationCenterWidgetsPulseSinkInput_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_sway_notification_center_widgets_pulse_sink_input_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_sway_notification_center_widgets_pulse_sink_input_set_property;
	G_OBJECT_CLASS (klass)->constructor = sway_notification_center_widgets_pulse_sink_input_constructor;
	G_OBJECT_CLASS (klass)->finalize = sway_notification_center_widgets_pulse_sink_input_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), SWAY_NOTIFICATION_CENTER_WIDGETS_PULSE_SINK_INPUT_BALANCE_PROPERTY, sway_notification_center_widgets_pulse_sink_input_properties[SWAY_NOTIFICATION_CENTER_WIDGETS_PULSE_SINK_INPUT_BALANCE_PROPERTY] = g_param_spec_float ("balance", "balance", "balance", -G_MAXFLOAT, G_MAXFLOAT, (gfloat) 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
sway_notification_center_widgets_pulse_sink_input_instance_init (SwayNotificationCenterWidgetsPulseSinkInput * self,
                                                                 gpointer klass)
{
	self->priv = sway_notification_center_widgets_pulse_sink_input_get_instance_private (self);
	self->priv->_balance = (gfloat) 0;
}

static void
sway_notification_center_widgets_pulse_sink_input_finalize (GObject * obj)
{
	SwayNotificationCenterWidgetsPulseSinkInput * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SWAY_NOTIFICATION_CENTER_WIDGETS_TYPE_PULSE_SINK_INPUT, SwayNotificationCenterWidgetsPulseSinkInput);
	_g_free0 (self->name);
	_g_free0 (self->application_binary);
	_g_free0 (self->application_icon_name);
	_g_free0 (self->media_name);
	_g_object_unref0 (self->volume_operations);
	G_OBJECT_CLASS (sway_notification_center_widgets_pulse_sink_input_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
sway_notification_center_widgets_pulse_sink_input_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SwayNotificationCenterWidgetsPulseSinkInputClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) sway_notification_center_widgets_pulse_sink_input_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SwayNotificationCenterWidgetsPulseSinkInput), 0, (GInstanceInitFunc) sway_notification_center_widgets_pulse_sink_input_instance_init, NULL };
	GType sway_notification_center_widgets_pulse_sink_input_type_id;
	sway_notification_center_widgets_pulse_sink_input_type_id = g_type_register_static (G_TYPE_OBJECT, "SwayNotificationCenterWidgetsPulseSinkInput", &g_define_type_info, 0);
	SwayNotificationCenterWidgetsPulseSinkInput_private_offset = g_type_add_instance_private (sway_notification_center_widgets_pulse_sink_input_type_id, sizeof (SwayNotificationCenterWidgetsPulseSinkInputPrivate));
	return sway_notification_center_widgets_pulse_sink_input_type_id;
}

GType
sway_notification_center_widgets_pulse_sink_input_get_type (void)
{
	static gsize sway_notification_center_widgets_pulse_sink_input_type_id__once = 0;
	if (g_once_init_enter (&sway_notification_center_widgets_pulse_sink_input_type_id__once)) {
		GType sway_notification_center_widgets_pulse_sink_input_type_id;
		sway_notification_center_widgets_pulse_sink_input_type_id = sway_notification_center_widgets_pulse_sink_input_get_type_once ();
		g_once_init_leave (&sway_notification_center_widgets_pulse_sink_input_type_id__once, sway_notification_center_widgets_pulse_sink_input_type_id);
	}
	return sway_notification_center_widgets_pulse_sink_input_type_id__once;
}

static void
_vala_sway_notification_center_widgets_pulse_sink_input_get_property (GObject * object,
                                                                      guint property_id,
                                                                      GValue * value,
                                                                      GParamSpec * pspec)
{
	SwayNotificationCenterWidgetsPulseSinkInput * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SWAY_NOTIFICATION_CENTER_WIDGETS_TYPE_PULSE_SINK_INPUT, SwayNotificationCenterWidgetsPulseSinkInput);
	switch (property_id) {
		case SWAY_NOTIFICATION_CENTER_WIDGETS_PULSE_SINK_INPUT_BALANCE_PROPERTY:
		g_value_set_float (value, sway_notification_center_widgets_pulse_sink_input_get_balance (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_sway_notification_center_widgets_pulse_sink_input_set_property (GObject * object,
                                                                      guint property_id,
                                                                      const GValue * value,
                                                                      GParamSpec * pspec)
{
	SwayNotificationCenterWidgetsPulseSinkInput * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SWAY_NOTIFICATION_CENTER_WIDGETS_TYPE_PULSE_SINK_INPUT, SwayNotificationCenterWidgetsPulseSinkInput);
	switch (property_id) {
		case SWAY_NOTIFICATION_CENTER_WIDGETS_PULSE_SINK_INPUT_BALANCE_PROPERTY:
		sway_notification_center_widgets_pulse_sink_input_set_balance (self, g_value_get_float (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

