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

#include <glib.h>
#include <adwaita.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <gst/gst.h>
#include <gio/gio.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.h>

#define G4_BLUR_MODE_NEVER ((guint) 0)
#define G4_BLUR_MODE_ALWAYS ((guint) 1)
#define G4_BLUR_MODE_ART_ONLY ((guint) 2)
#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 G4_TYPE_PREFERENCES_WINDOW (g4_preferences_window_get_type ())
#define G4_PREFERENCES_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G4_TYPE_PREFERENCES_WINDOW, G4PreferencesWindow))
#define G4_PREFERENCES_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), G4_TYPE_PREFERENCES_WINDOW, G4PreferencesWindowClass))
#define G4_IS_PREFERENCES_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G4_TYPE_PREFERENCES_WINDOW))
#define G4_IS_PREFERENCES_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), G4_TYPE_PREFERENCES_WINDOW))
#define G4_PREFERENCES_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), G4_TYPE_PREFERENCES_WINDOW, G4PreferencesWindowClass))

typedef struct _G4PreferencesWindow G4PreferencesWindow;
typedef struct _G4PreferencesWindowClass G4PreferencesWindowClass;
typedef struct _G4PreferencesWindowPrivate G4PreferencesWindowPrivate;
enum  {
	G4_PREFERENCES_WINDOW_0_PROPERTY,
	G4_PREFERENCES_WINDOW_AUDIO_SINK_PROPERTY,
	G4_PREFERENCES_WINDOW_NUM_PROPERTIES
};
static GParamSpec* g4_preferences_window_properties[G4_PREFERENCES_WINDOW_NUM_PROPERTIES];
#define _g_ptr_array_unref0(var) ((var == NULL) ? NULL : (var = (g_ptr_array_unref (var), NULL)))

#define G4_TYPE_APPLICATION (g4_application_get_type ())
#define G4_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G4_TYPE_APPLICATION, G4Application))
#define G4_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), G4_TYPE_APPLICATION, G4ApplicationClass))
#define G4_IS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G4_TYPE_APPLICATION))
#define G4_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), G4_TYPE_APPLICATION))
#define G4_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), G4_TYPE_APPLICATION, G4ApplicationClass))

typedef struct _G4Application G4Application;
typedef struct _G4ApplicationClass G4ApplicationClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block35Data Block35Data;
#define _g_free0(var) (var = (g_free (var), NULL))
typedef void (*G4FolderPicked) (GFile* dir, gpointer user_data);

#define G4_TYPE_GST_PLAYER (g4_gst_player_get_type ())
#define G4_GST_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G4_TYPE_GST_PLAYER, G4GstPlayer))
#define G4_GST_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), G4_TYPE_GST_PLAYER, G4GstPlayerClass))
#define G4_IS_GST_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G4_TYPE_GST_PLAYER))
#define G4_IS_GST_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), G4_TYPE_GST_PLAYER))
#define G4_GST_PLAYER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), G4_TYPE_GST_PLAYER, G4GstPlayerClass))

typedef struct _G4GstPlayer G4GstPlayer;
typedef struct _G4GstPlayerClass G4GstPlayerClass;
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
typedef struct _Block36Data Block36Data;

struct _G4PreferencesWindow {
	AdwPreferencesWindow parent_instance;
	G4PreferencesWindowPrivate * priv;
};

struct _G4PreferencesWindowClass {
	AdwPreferencesWindowClass parent_class;
};

struct _G4PreferencesWindowPrivate {
	AdwComboRow* blur_row;
	GtkSwitch* compact_btn;
	GtkSwitch* grid_btn;
	GtkSwitch* single_btn;
	GtkButton* music_dir_btn;
	GtkSwitch* monitor_btn;
	GtkSwitch* thumbnail_btn;
	GtkSwitch* playbkgnd_btn;
	GtkSwitch* rotate_btn;
	GtkSwitch* gapless_btn;
	AdwComboRow* replaygain_row;
	AdwComboRow* audiosink_row;
	AdwExpanderRow* peak_row;
	GtkEntry* peak_entry;
	GPtrArray* _audio_sinks;
};

struct _Block35Data {
	int _ref_count_;
	G4PreferencesWindow* self;
	G4Application* app;
};

struct _Block36Data {
	int _ref_count_;
	G4Application* app;
	G4FolderPicked picked;
	gpointer picked_target;
};

static gint G4PreferencesWindow_private_offset;
static gpointer g4_preferences_window_parent_class = NULL;

VALA_EXTERN GType g4_preferences_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (G4PreferencesWindow, g_object_unref)
static void _g_object_unref0_ (gpointer var);
VALA_EXTERN GType g4_application_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (G4Application, g_object_unref)
VALA_EXTERN G4PreferencesWindow* g4_preferences_window_new (G4Application* app);
VALA_EXTERN G4PreferencesWindow* g4_preferences_window_construct (GType object_type,
                                                      G4Application* app);
static Block35Data* block35_data_ref (Block35Data* _data35_);
static void block35_data_unref (void * _userdata_);
VALA_EXTERN GSettings* g4_application_get_settings (G4Application* self);
VALA_EXTERN gchar* g4_get_display_name (const gchar* uri);
VALA_EXTERN const gchar* g4_application_get_music_folder (G4Application* self);
static void __lambda143_ (Block35Data* _data35_);
VALA_EXTERN void g4_pick_music_folder (G4Application* app,
                           GtkWindow* parent,
                           G4FolderPicked picked,
                           gpointer picked_target);
static void __lambda144_ (Block35Data* _data35_,
                   GFile* dir);
static void ___lambda144__g4_folder_picked (GFile* dir,
                                     gpointer self);
static void ___lambda143__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
VALA_EXTERN void g4_gst_player_get_audio_sinks (GPtrArray* sinks);
VALA_EXTERN gchar* g4_get_audio_sink_name (GstElementFactory* factory);
VALA_EXTERN guint g4_preferences_window_get_audio_sink (G4PreferencesWindow* self);
VALA_EXTERN GType g4_gst_player_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (G4GstPlayer, g_object_unref)
VALA_EXTERN G4GstPlayer* g4_application_get_player (G4Application* self);
VALA_EXTERN const gchar* g4_gst_player_get_audio_sink (G4GstPlayer* self);
VALA_EXTERN void g4_preferences_window_set_audio_sink (G4PreferencesWindow* self,
                                           guint value);
VALA_EXTERN void g4_gst_player_set_audio_sink (G4GstPlayer* self,
                                   const gchar* value);
static void g4_preferences_window_finalize (GObject * obj);
static GType g4_preferences_window_get_type_once (void);
static void _vala_g4_preferences_window_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec);
static void _vala_g4_preferences_window_set_property (GObject * object,
                                               guint property_id,
                                               const GValue * value,
                                               GParamSpec * pspec);
static Block36Data* block36_data_ref (Block36Data* _data36_);
static void block36_data_unref (void * _userdata_);
VALA_EXTERN void g4_show_select_folder_dialog (GtkWindow* parent,
                                   GFile* initial,
                                   GAsyncReadyCallback _callback_,
                                   gpointer _user_data_);
VALA_EXTERN GFile* g4_show_select_folder_dialog_finish (GAsyncResult* _res_);
static void __lambda123_ (Block36Data* _data36_,
                   GObject* obj,
                   GAsyncResult* res);
VALA_EXTERN void g4_application_set_music_folder (G4Application* self,
                                      const gchar* value);
static void ___lambda123__gasync_ready_callback (GObject* source_object,
                                          GAsyncResult* res,
                                          gpointer self);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
g4_preferences_window_get_instance_private (G4PreferencesWindow* self)
{
	return G_STRUCT_MEMBER_P (self, G4PreferencesWindow_private_offset);
}

static void
_g_object_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}

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

static Block35Data*
block35_data_ref (Block35Data* _data35_)
{
	g_atomic_int_inc (&_data35_->_ref_count_);
	return _data35_;
}

static void
block35_data_unref (void * _userdata_)
{
	Block35Data* _data35_;
	_data35_ = (Block35Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data35_->_ref_count_)) {
		G4PreferencesWindow* self;
		self = _data35_->self;
		_g_object_unref0 (_data35_->app);
		_g_object_unref0 (self);
		g_slice_free (Block35Data, _data35_);
	}
}

static void
__lambda144_ (Block35Data* _data35_,
              GFile* dir)
{
	G4PreferencesWindow* self;
	GtkButton* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	self = _data35_->self;
	g_return_if_fail (dir != NULL);
	_tmp0_ = self->priv->music_dir_btn;
	_tmp1_ = g4_application_get_music_folder (_data35_->app);
	_tmp2_ = _tmp1_;
	_tmp3_ = g4_get_display_name (_tmp2_);
	_tmp4_ = _tmp3_;
	gtk_button_set_label (_tmp0_, _tmp4_);
	_g_free0 (_tmp4_);
}

static void
___lambda144__g4_folder_picked (GFile* dir,
                                gpointer self)
{
	__lambda144_ (self, dir);
}

static void
__lambda143_ (Block35Data* _data35_)
{
	G4PreferencesWindow* self;
	self = _data35_->self;
	g4_pick_music_folder (_data35_->app, (GtkWindow*) self, ___lambda144__g4_folder_picked, _data35_);
}

static void
___lambda143__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda143_ (self);
}

static gint
vala_g_ptr_array_get_length (GPtrArray* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = (gint) self->len;
	return result;
}

G4PreferencesWindow*
g4_preferences_window_construct (GType object_type,
                                 G4Application* app)
{
	G4PreferencesWindow * self = NULL;
	Block35Data* _data35_;
	G4Application* _tmp0_;
	GSettings* settings = NULL;
	GSettings* _tmp1_;
	GSettings* _tmp2_;
	GSettings* _tmp3_;
	AdwComboRow* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar** _tmp8_;
	gchar** _tmp9_;
	gint _tmp9__length1;
	GtkStringList* _tmp10_;
	GtkStringList* _tmp11_;
	GSettings* _tmp12_;
	AdwComboRow* _tmp13_;
	GSettings* _tmp14_;
	GtkSwitch* _tmp15_;
	GSettings* _tmp16_;
	GtkSwitch* _tmp17_;
	GSettings* _tmp18_;
	GtkSwitch* _tmp19_;
	GtkButton* _tmp20_;
	const gchar* _tmp21_;
	const gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	GtkButton* _tmp25_;
	GSettings* _tmp26_;
	GtkSwitch* _tmp27_;
	GSettings* _tmp28_;
	GtkSwitch* _tmp29_;
	GSettings* _tmp30_;
	GtkSwitch* _tmp31_;
	GSettings* _tmp32_;
	GtkSwitch* _tmp33_;
	AdwComboRow* _tmp34_;
	gchar* _tmp35_;
	gchar* _tmp36_;
	gchar* _tmp37_;
	gchar** _tmp38_;
	gchar** _tmp39_;
	gint _tmp39__length1;
	GtkStringList* _tmp40_;
	GtkStringList* _tmp41_;
	GSettings* _tmp42_;
	AdwComboRow* _tmp43_;
	GSettings* _tmp44_;
	GtkSwitch* _tmp45_;
	GSettings* _tmp46_;
	AdwExpanderRow* _tmp47_;
	GSettings* _tmp48_;
	GtkEntry* _tmp49_;
	GPtrArray* _tmp50_;
	gchar** sink_names = NULL;
	GPtrArray* _tmp51_;
	gint _tmp52_;
	gint _tmp53_;
	gchar** _tmp54_;
	gint sink_names_length1;
	gint _sink_names_size_;
	AdwComboRow* _tmp64_;
	gchar** _tmp65_;
	gint _tmp65__length1;
	GtkStringList* _tmp66_;
	GtkStringList* _tmp67_;
	AdwComboRow* _tmp68_;
	g_return_val_if_fail (app != NULL, NULL);
	_data35_ = g_slice_new0 (Block35Data);
	_data35_->_ref_count_ = 1;
	_tmp0_ = _g_object_ref0 (app);
	_g_object_unref0 (_data35_->app);
	_data35_->app = _tmp0_;
	self = (G4PreferencesWindow*) g_object_new (object_type, NULL);
	_data35_->self = g_object_ref (self);
	_tmp1_ = g4_application_get_settings (_data35_->app);
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	settings = _tmp3_;
	_tmp4_ = self->priv->blur_row;
	_tmp5_ = g_strdup (_ ("Never"));
	_tmp6_ = g_strdup (_ ("Always"));
	_tmp7_ = g_strdup (_ ("Art Only"));
	_tmp8_ = g_new0 (gchar*, 3 + 1);
	_tmp8_[0] = _tmp5_;
	_tmp8_[1] = _tmp6_;
	_tmp8_[2] = _tmp7_;
	_tmp9_ = _tmp8_;
	_tmp9__length1 = 3;
	_tmp10_ = gtk_string_list_new (_tmp9_);
	_tmp11_ = _tmp10_;
	adw_combo_row_set_model (_tmp4_, (GListModel*) _tmp11_);
	_g_object_unref0 (_tmp11_);
	_tmp9_ = (_vala_array_free (_tmp9_, _tmp9__length1, (GDestroyNotify) g_free), NULL);
	_tmp12_ = settings;
	_tmp13_ = self->priv->blur_row;
	g_settings_bind (_tmp12_, "blur-mode", (GObject*) _tmp13_, "selected", G_SETTINGS_BIND_DEFAULT);
	_tmp14_ = settings;
	_tmp15_ = self->priv->compact_btn;
	g_settings_bind (_tmp14_, "compact-playlist", (GObject*) _tmp15_, "active", G_SETTINGS_BIND_DEFAULT);
	_tmp16_ = settings;
	_tmp17_ = self->priv->grid_btn;
	g_settings_bind (_tmp16_, "grid-mode", (GObject*) _tmp17_, "active", G_SETTINGS_BIND_DEFAULT);
	_tmp18_ = settings;
	_tmp19_ = self->priv->single_btn;
	g_settings_bind (_tmp18_, "single-click-activate", (GObject*) _tmp19_, "active", G_SETTINGS_BIND_DEFAULT);
	_tmp20_ = self->priv->music_dir_btn;
	_tmp21_ = g4_application_get_music_folder (_data35_->app);
	_tmp22_ = _tmp21_;
	_tmp23_ = g4_get_display_name (_tmp22_);
	_tmp24_ = _tmp23_;
	gtk_button_set_label (_tmp20_, _tmp24_);
	_g_free0 (_tmp24_);
	_tmp25_ = self->priv->music_dir_btn;
	g_signal_connect_data (_tmp25_, "clicked", (GCallback) ___lambda143__gtk_button_clicked, block35_data_ref (_data35_), (GClosureNotify) block35_data_unref, 0);
	_tmp26_ = settings;
	_tmp27_ = self->priv->monitor_btn;
	g_settings_bind (_tmp26_, "monitor-changes", (GObject*) _tmp27_, "active", G_SETTINGS_BIND_DEFAULT);
	_tmp28_ = settings;
	_tmp29_ = self->priv->thumbnail_btn;
	g_settings_bind (_tmp28_, "remote-thumbnail", (GObject*) _tmp29_, "active", G_SETTINGS_BIND_DEFAULT);
	_tmp30_ = settings;
	_tmp31_ = self->priv->playbkgnd_btn;
	g_settings_bind (_tmp30_, "play-background", (GObject*) _tmp31_, "active", G_SETTINGS_BIND_DEFAULT);
	_tmp32_ = settings;
	_tmp33_ = self->priv->rotate_btn;
	g_settings_bind (_tmp32_, "rotate-cover", (GObject*) _tmp33_, "active", G_SETTINGS_BIND_DEFAULT);
	_tmp34_ = self->priv->replaygain_row;
	_tmp35_ = g_strdup (_ ("Never"));
	_tmp36_ = g_strdup (_ ("Track"));
	_tmp37_ = g_strdup (_ ("Album"));
	_tmp38_ = g_new0 (gchar*, 3 + 1);
	_tmp38_[0] = _tmp35_;
	_tmp38_[1] = _tmp36_;
	_tmp38_[2] = _tmp37_;
	_tmp39_ = _tmp38_;
	_tmp39__length1 = 3;
	_tmp40_ = gtk_string_list_new (_tmp39_);
	_tmp41_ = _tmp40_;
	adw_combo_row_set_model (_tmp34_, (GListModel*) _tmp41_);
	_g_object_unref0 (_tmp41_);
	_tmp39_ = (_vala_array_free (_tmp39_, _tmp39__length1, (GDestroyNotify) g_free), NULL);
	_tmp42_ = settings;
	_tmp43_ = self->priv->replaygain_row;
	g_settings_bind (_tmp42_, "replay-gain", (GObject*) _tmp43_, "selected", G_SETTINGS_BIND_DEFAULT);
	_tmp44_ = settings;
	_tmp45_ = self->priv->gapless_btn;
	g_settings_bind (_tmp44_, "gapless-playback", (GObject*) _tmp45_, "active", G_SETTINGS_BIND_DEFAULT);
	_tmp46_ = settings;
	_tmp47_ = self->priv->peak_row;
	g_settings_bind (_tmp46_, "show-peak", (GObject*) _tmp47_, "enable_expansion", G_SETTINGS_BIND_DEFAULT);
	_tmp48_ = settings;
	_tmp49_ = self->priv->peak_entry;
	g_settings_bind (_tmp48_, "peak-characters", (GObject*) _tmp49_, "text", G_SETTINGS_BIND_DEFAULT);
	_tmp50_ = self->priv->_audio_sinks;
	g4_gst_player_get_audio_sinks (_tmp50_);
	_tmp51_ = self->priv->_audio_sinks;
	_tmp52_ = vala_g_ptr_array_get_length (_tmp51_);
	_tmp53_ = _tmp52_;
	_tmp54_ = g_new0 (gchar*, _tmp53_ + 1);
	sink_names = _tmp54_;
	sink_names_length1 = _tmp53_;
	_sink_names_size_ = sink_names_length1;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp55_ = FALSE;
			_tmp55_ = TRUE;
			while (TRUE) {
				GPtrArray* _tmp57_;
				gint _tmp58_;
				gint _tmp59_;
				gchar** _tmp60_;
				gint _tmp60__length1;
				GPtrArray* _tmp61_;
				gconstpointer _tmp62_;
				gchar* _tmp63_;
				if (!_tmp55_) {
					gint _tmp56_;
					_tmp56_ = i;
					i = _tmp56_ + 1;
				}
				_tmp55_ = FALSE;
				_tmp57_ = self->priv->_audio_sinks;
				_tmp58_ = vala_g_ptr_array_get_length (_tmp57_);
				_tmp59_ = _tmp58_;
				if (!(i < _tmp59_)) {
					break;
				}
				_tmp60_ = sink_names;
				_tmp60__length1 = sink_names_length1;
				_tmp61_ = self->priv->_audio_sinks;
				_tmp62_ = g_ptr_array_index (_tmp61_, (guint) i);
				_tmp63_ = g4_get_audio_sink_name ((GstElementFactory*) _tmp62_);
				_g_free0 (_tmp60_[i]);
				_tmp60_[i] = _tmp63_;
			}
		}
	}
	_tmp64_ = self->priv->audiosink_row;
	_tmp65_ = sink_names;
	_tmp65__length1 = sink_names_length1;
	_tmp66_ = gtk_string_list_new (_tmp65_);
	_tmp67_ = _tmp66_;
	adw_combo_row_set_model (_tmp64_, (GListModel*) _tmp67_);
	_g_object_unref0 (_tmp67_);
	_tmp68_ = self->priv->audiosink_row;
	g_object_bind_property_with_closures ((GObject*) self, "audio_sink", (GObject*) _tmp68_, "selected", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	sink_names = (_vala_array_free (sink_names, sink_names_length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (settings);
	block35_data_unref (_data35_);
	_data35_ = NULL;
	return self;
}

G4PreferencesWindow*
g4_preferences_window_new (G4Application* app)
{
	return g4_preferences_window_construct (G4_TYPE_PREFERENCES_WINDOW, app);
}

guint
g4_preferences_window_get_audio_sink (G4PreferencesWindow* self)
{
	guint result;
	G4Application* app = NULL;
	GApplication* _tmp0_;
	G4Application* _tmp1_;
	gchar* sink_name = NULL;
	G4Application* _tmp2_;
	G4GstPlayer* _tmp3_;
	G4GstPlayer* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	gint _tmp20_ = 0;
	GPtrArray* _tmp21_;
	gint _tmp22_;
	gint _tmp23_;
	g_return_val_if_fail (self != NULL, 0U);
	_tmp0_ = g_application_get_default ();
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, G4_TYPE_APPLICATION, G4Application));
	app = _tmp1_;
	_tmp2_ = app;
	_tmp3_ = g4_application_get_player (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = g4_gst_player_get_audio_sink (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = g_strdup (_tmp6_);
	sink_name = _tmp7_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp8_ = FALSE;
			_tmp8_ = TRUE;
			while (TRUE) {
				GPtrArray* _tmp10_;
				gint _tmp11_;
				gint _tmp12_;
				const gchar* _tmp13_;
				GPtrArray* _tmp14_;
				gconstpointer _tmp15_;
				gchar* _tmp16_;
				gchar* _tmp17_;
				gchar* _tmp18_;
				gboolean _tmp19_;
				if (!_tmp8_) {
					gint _tmp9_;
					_tmp9_ = i;
					i = _tmp9_ + 1;
				}
				_tmp8_ = FALSE;
				_tmp10_ = self->priv->_audio_sinks;
				_tmp11_ = vala_g_ptr_array_get_length (_tmp10_);
				_tmp12_ = _tmp11_;
				if (!(i < _tmp12_)) {
					break;
				}
				_tmp13_ = sink_name;
				_tmp14_ = self->priv->_audio_sinks;
				_tmp15_ = g_ptr_array_index (_tmp14_, (guint) i);
				_tmp16_ = gst_object_get_name ((GstObject*) ((GstElementFactory*) _tmp15_));
				_tmp17_ = _tmp16_;
				_tmp18_ = _tmp17_;
				_tmp19_ = g_strcmp0 (_tmp13_, _tmp18_) == 0;
				_g_free0 (_tmp18_);
				if (_tmp19_) {
					result = (guint) i;
					_g_free0 (sink_name);
					_g_object_unref0 (app);
					return result;
				}
			}
		}
	}
	_tmp21_ = self->priv->_audio_sinks;
	_tmp22_ = vala_g_ptr_array_get_length (_tmp21_);
	_tmp23_ = _tmp22_;
	if (_tmp23_ > 0) {
		_tmp20_ = 0;
	} else {
		_tmp20_ = -1;
	}
	result = (guint) _tmp20_;
	_g_free0 (sink_name);
	_g_object_unref0 (app);
	return result;
}

void
g4_preferences_window_set_audio_sink (G4PreferencesWindow* self,
                                      guint value)
{
	GPtrArray* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_audio_sinks;
	_tmp1_ = vala_g_ptr_array_get_length (_tmp0_);
	_tmp2_ = _tmp1_;
	if (value < ((guint) _tmp2_)) {
		G4Application* app = NULL;
		GApplication* _tmp3_;
		G4Application* _tmp4_;
		G4Application* _tmp5_;
		G4GstPlayer* _tmp6_;
		G4GstPlayer* _tmp7_;
		GPtrArray* _tmp8_;
		gconstpointer _tmp9_;
		gchar* _tmp10_;
		gchar* _tmp11_;
		gchar* _tmp12_;
		_tmp3_ = g_application_get_default ();
		_tmp4_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, G4_TYPE_APPLICATION, G4Application));
		app = _tmp4_;
		_tmp5_ = app;
		_tmp6_ = g4_application_get_player (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp8_ = self->priv->_audio_sinks;
		_tmp9_ = g_ptr_array_index (_tmp8_, value);
		_tmp10_ = gst_object_get_name ((GstObject*) ((GstElementFactory*) _tmp9_));
		_tmp11_ = _tmp10_;
		_tmp12_ = _tmp11_;
		g4_gst_player_set_audio_sink (_tmp7_, _tmp12_);
		_g_free0 (_tmp12_);
		_g_object_unref0 (app);
	}
	g_object_notify_by_pspec ((GObject *) self, g4_preferences_window_properties[G4_PREFERENCES_WINDOW_AUDIO_SINK_PROPERTY]);
}

static void
g4_preferences_window_class_init (G4PreferencesWindowClass * klass,
                                  gpointer klass_data)
{
	g4_preferences_window_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &G4PreferencesWindow_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_g4_preferences_window_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_g4_preferences_window_set_property;
	G_OBJECT_CLASS (klass)->finalize = g4_preferences_window_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), G4_PREFERENCES_WINDOW_AUDIO_SINK_PROPERTY, g4_preferences_window_properties[G4_PREFERENCES_WINDOW_AUDIO_SINK_PROPERTY] = g_param_spec_uint ("audio-sink", "audio-sink", "audio-sink", 0, G_MAXUINT, 0U, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/com/github/neithern/g4music/gtk/preferences.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "blur_row", FALSE, G4PreferencesWindow_private_offset + G_STRUCT_OFFSET (G4PreferencesWindowPrivate, blur_row));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "compact_btn", FALSE, G4PreferencesWindow_private_offset + G_STRUCT_OFFSET (G4PreferencesWindowPrivate, compact_btn));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "grid_btn", FALSE, G4PreferencesWindow_private_offset + G_STRUCT_OFFSET (G4PreferencesWindowPrivate, grid_btn));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "single_btn", FALSE, G4PreferencesWindow_private_offset + G_STRUCT_OFFSET (G4PreferencesWindowPrivate, single_btn));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "music_dir_btn", FALSE, G4PreferencesWindow_private_offset + G_STRUCT_OFFSET (G4PreferencesWindowPrivate, music_dir_btn));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "monitor_btn", FALSE, G4PreferencesWindow_private_offset + G_STRUCT_OFFSET (G4PreferencesWindowPrivate, monitor_btn));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "thumbnail_btn", FALSE, G4PreferencesWindow_private_offset + G_STRUCT_OFFSET (G4PreferencesWindowPrivate, thumbnail_btn));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "playbkgnd_btn", FALSE, G4PreferencesWindow_private_offset + G_STRUCT_OFFSET (G4PreferencesWindowPrivate, playbkgnd_btn));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "rotate_btn", FALSE, G4PreferencesWindow_private_offset + G_STRUCT_OFFSET (G4PreferencesWindowPrivate, rotate_btn));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "gapless_btn", FALSE, G4PreferencesWindow_private_offset + G_STRUCT_OFFSET (G4PreferencesWindowPrivate, gapless_btn));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "replaygain_row", FALSE, G4PreferencesWindow_private_offset + G_STRUCT_OFFSET (G4PreferencesWindowPrivate, replaygain_row));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "audiosink_row", FALSE, G4PreferencesWindow_private_offset + G_STRUCT_OFFSET (G4PreferencesWindowPrivate, audiosink_row));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "peak_row", FALSE, G4PreferencesWindow_private_offset + G_STRUCT_OFFSET (G4PreferencesWindowPrivate, peak_row));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "peak_entry", FALSE, G4PreferencesWindow_private_offset + G_STRUCT_OFFSET (G4PreferencesWindowPrivate, peak_entry));
}

static void
g4_preferences_window_instance_init (G4PreferencesWindow * self,
                                     gpointer klass)
{
	GPtrArray* _tmp0_;
	self->priv = g4_preferences_window_get_instance_private (self);
	_tmp0_ = g_ptr_array_new_full ((guint) 8, _g_object_unref0_);
	self->priv->_audio_sinks = _tmp0_;
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
g4_preferences_window_finalize (GObject * obj)
{
	G4PreferencesWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, G4_TYPE_PREFERENCES_WINDOW, G4PreferencesWindow);
	_g_ptr_array_unref0 (self->priv->_audio_sinks);
	G_OBJECT_CLASS (g4_preferences_window_parent_class)->finalize (obj);
}

static GType
g4_preferences_window_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (G4PreferencesWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) g4_preferences_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (G4PreferencesWindow), 0, (GInstanceInitFunc) g4_preferences_window_instance_init, NULL };
	GType g4_preferences_window_type_id;
	g4_preferences_window_type_id = g_type_register_static (adw_preferences_window_get_type (), "G4PreferencesWindow", &g_define_type_info, 0);
	G4PreferencesWindow_private_offset = g_type_add_instance_private (g4_preferences_window_type_id, sizeof (G4PreferencesWindowPrivate));
	return g4_preferences_window_type_id;
}

GType
g4_preferences_window_get_type (void)
{
	static volatile gsize g4_preferences_window_type_id__once = 0;
	if (g_once_init_enter (&g4_preferences_window_type_id__once)) {
		GType g4_preferences_window_type_id;
		g4_preferences_window_type_id = g4_preferences_window_get_type_once ();
		g_once_init_leave (&g4_preferences_window_type_id__once, g4_preferences_window_type_id);
	}
	return g4_preferences_window_type_id__once;
}

static void
_vala_g4_preferences_window_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec)
{
	G4PreferencesWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, G4_TYPE_PREFERENCES_WINDOW, G4PreferencesWindow);
	switch (property_id) {
		case G4_PREFERENCES_WINDOW_AUDIO_SINK_PROPERTY:
		g_value_set_uint (value, g4_preferences_window_get_audio_sink (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_g4_preferences_window_set_property (GObject * object,
                                          guint property_id,
                                          const GValue * value,
                                          GParamSpec * pspec)
{
	G4PreferencesWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, G4_TYPE_PREFERENCES_WINDOW, G4PreferencesWindow);
	switch (property_id) {
		case G4_PREFERENCES_WINDOW_AUDIO_SINK_PROPERTY:
		g4_preferences_window_set_audio_sink (self, g_value_get_uint (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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 gchar*
string_strip (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strstrip (_result_);
	result = _result_;
	return result;
}

gchar*
g4_get_audio_sink_name (GstElementFactory* factory)
{
	gchar* _tmp0_ = NULL;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* name = NULL;
	gchar* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	const gchar* _tmp16_;
	gchar* _tmp17_;
	gchar* result;
	g_return_val_if_fail (factory != NULL, NULL);
	_tmp1_ = gst_element_factory_get_metadata (factory, "long-name");
	_tmp2_ = g_strdup (_tmp1_);
	_tmp0_ = _tmp2_;
	if (_tmp0_ == NULL) {
		gchar* _tmp3_;
		gchar* _tmp4_;
		_tmp3_ = gst_object_get_name ((GstObject*) factory);
		_tmp4_ = _tmp3_;
		_g_free0 (_tmp0_);
		_tmp0_ = _tmp4_;
	}
	_tmp5_ = _tmp0_;
	_tmp0_ = NULL;
	name = (gchar*) _tmp5_;
	_tmp6_ = name;
	_tmp7_ = string_replace (_tmp6_, "Audio sink", "");
	_tmp8_ = _tmp7_;
	_tmp9_ = string_replace (_tmp8_, "Audio Sink", "");
	_tmp10_ = _tmp9_;
	_tmp11_ = string_replace (_tmp10_, "sink", "");
	_tmp12_ = _tmp11_;
	_tmp13_ = string_replace (_tmp12_, "(", "");
	_tmp14_ = _tmp13_;
	_tmp15_ = string_replace (_tmp14_, ")", "");
	_g_free0 (name);
	name = _tmp15_;
	_g_free0 (_tmp14_);
	_g_free0 (_tmp12_);
	_g_free0 (_tmp10_);
	_g_free0 (_tmp8_);
	_tmp16_ = name;
	_tmp17_ = string_strip (_tmp16_);
	result = _tmp17_;
	_g_free0 (name);
	_g_free0 (_tmp0_);
	return result;
}

static Block36Data*
block36_data_ref (Block36Data* _data36_)
{
	g_atomic_int_inc (&_data36_->_ref_count_);
	return _data36_;
}

static void
block36_data_unref (void * _userdata_)
{
	Block36Data* _data36_;
	_data36_ = (Block36Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data36_->_ref_count_)) {
		_g_object_unref0 (_data36_->app);
		g_slice_free (Block36Data, _data36_);
	}
}

static void
__lambda123_ (Block36Data* _data36_,
              GObject* obj,
              GAsyncResult* res)
{
	GFile* dir = NULL;
	GFile* _tmp0_;
	GFile* _tmp1_;
	g_return_if_fail (res != NULL);
	_tmp0_ = g4_show_select_folder_dialog_finish (res);
	dir = _tmp0_;
	_tmp1_ = dir;
	if (_tmp1_ != NULL) {
		gchar* uri = NULL;
		GFile* _tmp2_;
		gchar* _tmp3_;
		const gchar* _tmp4_;
		const gchar* _tmp5_;
		const gchar* _tmp6_;
		GFile* _tmp8_;
		_tmp2_ = dir;
		_tmp3_ = g_file_get_uri (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, g_file_get_type (), GFile));
		uri = _tmp3_;
		_tmp4_ = g4_application_get_music_folder (_data36_->app);
		_tmp5_ = _tmp4_;
		_tmp6_ = uri;
		if (g_strcmp0 (_tmp5_, _tmp6_) != 0) {
			const gchar* _tmp7_;
			_tmp7_ = uri;
			g4_application_set_music_folder (_data36_->app, _tmp7_);
		}
		_tmp8_ = dir;
		_data36_->picked (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, g_file_get_type (), GFile), _data36_->picked_target);
		_g_free0 (uri);
	}
	_g_object_unref0 (dir);
}

static void
___lambda123__gasync_ready_callback (GObject* source_object,
                                     GAsyncResult* res,
                                     gpointer self)
{
	__lambda123_ (self, source_object, res);
	block36_data_unref (self);
}

void
g4_pick_music_folder (G4Application* app,
                      GtkWindow* parent,
                      G4FolderPicked picked,
                      gpointer picked_target)
{
	Block36Data* _data36_;
	G4Application* _tmp0_;
	GFile* music_dir = NULL;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	GFile* _tmp3_;
	g_return_if_fail (app != NULL);
	_data36_ = g_slice_new0 (Block36Data);
	_data36_->_ref_count_ = 1;
	_tmp0_ = _g_object_ref0 (app);
	_g_object_unref0 (_data36_->app);
	_data36_->app = _tmp0_;
	_data36_->picked = picked;
	_data36_->picked_target = picked_target;
	_tmp1_ = g4_application_get_music_folder (_data36_->app);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_file_new_for_uri (_tmp2_);
	music_dir = _tmp3_;
	g4_show_select_folder_dialog (parent, music_dir, ___lambda123__gasync_ready_callback, block36_data_ref (_data36_));
	_g_object_unref0 (music_dir);
	block36_data_unref (_data36_);
	_data36_ = NULL;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

