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

#include "pantheon-files-core.h"
#include <canberra.h>
#include <glib.h>
#include <gio/gio.h>
#include <glib-object.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.h>

#define PF_SOUND_APP_TITLE "Files"
#define PF_SOUND_APP_ID "io.elementary.files"
#define PF_SOUND_APP_LOGO "system-file-manager"
#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  {
	PF_SOUND_MANAGER_0_PROPERTY,
	PF_SOUND_MANAGER_NUM_PROPERTIES
};
static GParamSpec* pf_sound_manager_properties[PF_SOUND_MANAGER_NUM_PROPERTIES];
#define _ca_context_destroy0(var) ((var == NULL) ? NULL : (var = (ca_context_destroy (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _PFSoundManagerPrivate {
	ca_context* ca_context;
};

static gint PFSoundManager_private_offset;
static gpointer pf_sound_manager_parent_class = NULL;
static PFSoundManager* pf_sound_manager_instance;
static PFSoundManager* pf_sound_manager_instance = NULL;
static GSettings* pf_sound_manager_sound_settings;
static GSettings* pf_sound_manager_sound_settings = NULL;

static PFSoundManager* pf_sound_manager_new (void);
static PFSoundManager* pf_sound_manager_construct (GType object_type);
static void pf_sound_manager_finalize (GObject * obj);
static GType pf_sound_manager_get_type_once (void);

static inline gpointer
pf_sound_manager_get_instance_private (PFSoundManager* self)
{
	return G_STRUCT_MEMBER_P (self, PFSoundManager_private_offset);
}

PFSoundManager*
pf_sound_manager_get_instance (void)
{
	PFSoundManager* _tmp0_;
	PFSoundManager* _tmp2_;
	PFSoundManager* result;
	_tmp0_ = pf_sound_manager_instance;
	if (_tmp0_ == NULL) {
		PFSoundManager* _tmp1_;
		_tmp1_ = pf_sound_manager_new ();
		_g_object_unref0 (pf_sound_manager_instance);
		pf_sound_manager_instance = _tmp1_;
	}
	_tmp2_ = pf_sound_manager_instance;
	result = _tmp2_;
	return result;
}

static PFSoundManager*
pf_sound_manager_construct (GType object_type)
{
	PFSoundManager * self = NULL;
	ca_context* _tmp0_ = NULL;
	ca_context* _tmp1_;
	self = (PFSoundManager*) g_object_new (object_type, NULL);
	_ca_context_destroy0 (self->priv->ca_context);
	self->priv->ca_context = NULL;
	ca_context_create (&_tmp0_);
	_ca_context_destroy0 (self->priv->ca_context);
	self->priv->ca_context = _tmp0_;
	_tmp1_ = self->priv->ca_context;
	if (_tmp1_ != NULL) {
		ca_context* _tmp2_;
		ca_context* _tmp3_;
		_tmp2_ = self->priv->ca_context;
		ca_context_change_props (_tmp2_, CA_PROP_APPLICATION_NAME, _ (PF_SOUND_APP_TITLE), CA_PROP_APPLICATION_ID, PF_SOUND_APP_ID, CA_PROP_CANBERRA_XDG_THEME_NAME, PF_SOUND_THEME, CA_PROP_APPLICATION_ICON_NAME, PF_SOUND_APP_LOGO, NULL);
		_tmp3_ = self->priv->ca_context;
		ca_context_open (_tmp3_);
	}
	return self;
}

static PFSoundManager*
pf_sound_manager_new (void)
{
	return pf_sound_manager_construct (PF_TYPE_SOUND_MANAGER);
}

void
pf_sound_manager_play_delete_sound (PFSoundManager* self)
{
	g_return_if_fail (self != NULL);
	pf_sound_manager_play_sound (self, PF_SOUND_DELETE);
}

void
pf_sound_manager_play_empty_trash_sound (PFSoundManager* self)
{
	g_return_if_fail (self != NULL);
	pf_sound_manager_play_sound (self, PF_SOUND_EMPTY_TRASH);
}

void
pf_sound_manager_play_sound (PFSoundManager* self,
                             const gchar* pf_sound_id)
{
	ca_context* _tmp0_;
	GSettings* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (pf_sound_id != NULL);
	_tmp0_ = self->priv->ca_context;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = pf_sound_manager_sound_settings;
	if (g_settings_get_boolean (_tmp1_, "event-sounds")) {
		ca_context* _tmp2_;
		_tmp2_ = self->priv->ca_context;
		ca_context_play (_tmp2_, (guint32) 0, CA_PROP_EVENT_ID, pf_sound_id, NULL);
	}
}

static void
pf_sound_manager_class_init (PFSoundManagerClass * klass,
                             gpointer klass_data)
{
	GSettings* _tmp0_;
	pf_sound_manager_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &PFSoundManager_private_offset);
	G_OBJECT_CLASS (klass)->finalize = pf_sound_manager_finalize;
	_tmp0_ = g_settings_new ("org.gnome.desktop.sound");
	_g_object_unref0 (pf_sound_manager_sound_settings);
	pf_sound_manager_sound_settings = _tmp0_;
}

static void
pf_sound_manager_instance_init (PFSoundManager * self,
                                gpointer klass)
{
	self->priv = pf_sound_manager_get_instance_private (self);
}

static void
pf_sound_manager_finalize (GObject * obj)
{
	PFSoundManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PF_TYPE_SOUND_MANAGER, PFSoundManager);
	_ca_context_destroy0 (self->priv->ca_context);
	G_OBJECT_CLASS (pf_sound_manager_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
pf_sound_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (PFSoundManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) pf_sound_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PFSoundManager), 0, (GInstanceInitFunc) pf_sound_manager_instance_init, NULL };
	GType pf_sound_manager_type_id;
	pf_sound_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "PFSoundManager", &g_define_type_info, 0);
	PFSoundManager_private_offset = g_type_add_instance_private (pf_sound_manager_type_id, sizeof (PFSoundManagerPrivate));
	return pf_sound_manager_type_id;
}

GType
pf_sound_manager_get_type (void)
{
	static volatile gsize pf_sound_manager_type_id__once = 0;
	if (g_once_init_enter (&pf_sound_manager_type_id__once)) {
		GType pf_sound_manager_type_id;
		pf_sound_manager_type_id = pf_sound_manager_get_type_once ();
		g_once_init_leave (&pf_sound_manager_type_id__once, pf_sound_manager_type_id);
	}
	return pf_sound_manager_type_id__once;
}

