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

/*-
 * Copyright 2013-2021 elementary, Inc. (https://elementary.io)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 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 General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 * Authored by: Corentin Noël <corentin@elementaryos.org>
 */

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

#define AUDIENCE_WIDGETS_PLAYLIST_POPOVER_HEIGHT_OFFSET 300
#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 AUDIENCE_WIDGETS_TYPE_PLAYLIST_POPOVER (audience_widgets_playlist_popover_get_type ())
#define AUDIENCE_WIDGETS_PLAYLIST_POPOVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AUDIENCE_WIDGETS_TYPE_PLAYLIST_POPOVER, AudienceWidgetsPlaylistPopover))
#define AUDIENCE_WIDGETS_PLAYLIST_POPOVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), AUDIENCE_WIDGETS_TYPE_PLAYLIST_POPOVER, AudienceWidgetsPlaylistPopoverClass))
#define AUDIENCE_WIDGETS_IS_PLAYLIST_POPOVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AUDIENCE_WIDGETS_TYPE_PLAYLIST_POPOVER))
#define AUDIENCE_WIDGETS_IS_PLAYLIST_POPOVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), AUDIENCE_WIDGETS_TYPE_PLAYLIST_POPOVER))
#define AUDIENCE_WIDGETS_PLAYLIST_POPOVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), AUDIENCE_WIDGETS_TYPE_PLAYLIST_POPOVER, AudienceWidgetsPlaylistPopoverClass))

typedef struct _AudienceWidgetsPlaylistPopover AudienceWidgetsPlaylistPopover;
typedef struct _AudienceWidgetsPlaylistPopoverClass AudienceWidgetsPlaylistPopoverClass;
typedef struct _AudienceWidgetsPlaylistPopoverPrivate AudienceWidgetsPlaylistPopoverPrivate;
enum  {
	AUDIENCE_WIDGETS_PLAYLIST_POPOVER_0_PROPERTY,
	AUDIENCE_WIDGETS_PLAYLIST_POPOVER_NUM_PROPERTIES
};
static GParamSpec* audience_widgets_playlist_popover_properties[AUDIENCE_WIDGETS_PLAYLIST_POPOVER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef enum  {
	AUDIENCE_PLAYBACK_MANAGER_REPEAT_MODE_DISABLED,
	AUDIENCE_PLAYBACK_MANAGER_REPEAT_MODE_ALL,
	AUDIENCE_PLAYBACK_MANAGER_REPEAT_MODE_ONE
} AudiencePlaybackManagerRepeatMode;

#define AUDIENCE_PLAYBACK_MANAGER_TYPE_REPEAT_MODE (audience_playback_manager_repeat_mode_get_type ())

#define AUDIENCE_WIDGETS_TYPE_PLAYLIST_ITEM (audience_widgets_playlist_item_get_type ())
#define AUDIENCE_WIDGETS_PLAYLIST_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AUDIENCE_WIDGETS_TYPE_PLAYLIST_ITEM, AudienceWidgetsPlaylistItem))
#define AUDIENCE_WIDGETS_PLAYLIST_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), AUDIENCE_WIDGETS_TYPE_PLAYLIST_ITEM, AudienceWidgetsPlaylistItemClass))
#define AUDIENCE_WIDGETS_IS_PLAYLIST_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AUDIENCE_WIDGETS_TYPE_PLAYLIST_ITEM))
#define AUDIENCE_WIDGETS_IS_PLAYLIST_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), AUDIENCE_WIDGETS_TYPE_PLAYLIST_ITEM))
#define AUDIENCE_WIDGETS_PLAYLIST_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), AUDIENCE_WIDGETS_TYPE_PLAYLIST_ITEM, AudienceWidgetsPlaylistItemClass))

typedef struct _AudienceWidgetsPlaylistItem AudienceWidgetsPlaylistItem;
typedef struct _AudienceWidgetsPlaylistItemClass AudienceWidgetsPlaylistItemClass;
#define _g_free0(var) (var = (g_free (var), NULL))

#define AUDIENCE_TYPE_PLAYBACK_MANAGER (audience_playback_manager_get_type ())
#define AUDIENCE_PLAYBACK_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AUDIENCE_TYPE_PLAYBACK_MANAGER, AudiencePlaybackManager))
#define AUDIENCE_PLAYBACK_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), AUDIENCE_TYPE_PLAYBACK_MANAGER, AudiencePlaybackManagerClass))
#define AUDIENCE_IS_PLAYBACK_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AUDIENCE_TYPE_PLAYBACK_MANAGER))
#define AUDIENCE_IS_PLAYBACK_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), AUDIENCE_TYPE_PLAYBACK_MANAGER))
#define AUDIENCE_PLAYBACK_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), AUDIENCE_TYPE_PLAYBACK_MANAGER, AudiencePlaybackManagerClass))

typedef struct _AudiencePlaybackManager AudiencePlaybackManager;
typedef struct _AudiencePlaybackManagerClass AudiencePlaybackManagerClass;
typedef struct _Block17Data Block17Data;

#define AUDIENCE_TYPE_WINDOW (audience_window_get_type ())
#define AUDIENCE_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AUDIENCE_TYPE_WINDOW, AudienceWindow))
#define AUDIENCE_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), AUDIENCE_TYPE_WINDOW, AudienceWindowClass))
#define AUDIENCE_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AUDIENCE_TYPE_WINDOW))
#define AUDIENCE_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), AUDIENCE_TYPE_WINDOW))
#define AUDIENCE_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), AUDIENCE_TYPE_WINDOW, AudienceWindowClass))

typedef struct _AudienceWindow AudienceWindow;
typedef struct _AudienceWindowClass AudienceWindowClass;

struct _AudienceWidgetsPlaylistPopover {
	GtkPopover parent_instance;
	AudienceWidgetsPlaylistPopoverPrivate * priv;
};

struct _AudienceWidgetsPlaylistPopoverClass {
	GtkPopoverClass parent_class;
};

struct _AudienceWidgetsPlaylistPopoverPrivate {
	GtkListBox* playlist;
	GtkButton* repeat_button;
};

struct _Block17Data {
	int _ref_count_;
	AudienceWidgetsPlaylistPopover* self;
	GtkScrolledWindow* playlist_scrolled;
};

static gint AudienceWidgetsPlaylistPopover_private_offset;
static gpointer audience_widgets_playlist_popover_parent_class = NULL;
VALA_EXTERN GSettings* audience_settings;

VALA_EXTERN GType audience_widgets_playlist_popover_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (AudienceWidgetsPlaylistPopover, g_object_unref)
static void audience_widgets_playlist_popover_update_repeat_button (AudienceWidgetsPlaylistPopover* self);
VALA_EXTERN GType audience_playback_manager_repeat_mode_get_type (void) G_GNUC_CONST ;
static GtkWidget* audience_widgets_playlist_popover_widget_create_func (AudienceWidgetsPlaylistPopover* self,
                                                                 GObject* item);
VALA_EXTERN gchar* audience_get_title (const gchar* filename);
VALA_EXTERN AudienceWidgetsPlaylistItem* audience_widgets_playlist_item_new (const gchar* title,
                                                                 const gchar* filename);
VALA_EXTERN AudienceWidgetsPlaylistItem* audience_widgets_playlist_item_construct (GType object_type,
                                                                       const gchar* title,
                                                                       const gchar* filename);
VALA_EXTERN GType audience_widgets_playlist_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (AudienceWidgetsPlaylistItem, g_object_unref)
static void audience_widgets_playlist_popover_set_current (AudienceWidgetsPlaylistPopover* self,
                                                    const gchar* current_file);
VALA_EXTERN GType audience_playback_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (AudiencePlaybackManager, g_object_unref)
VALA_EXTERN AudiencePlaybackManager* audience_playback_manager_get_default (void);
VALA_EXTERN GtkStringList* audience_playback_manager_get_play_queue (AudiencePlaybackManager* self);
VALA_EXTERN const gchar* audience_widgets_playlist_item_get_filename (AudienceWidgetsPlaylistItem* self);
VALA_EXTERN void audience_widgets_playlist_item_set_is_playing (AudienceWidgetsPlaylistItem* self,
                                                    gboolean value);
VALA_EXTERN AudienceWidgetsPlaylistPopover* audience_widgets_playlist_popover_new (void);
VALA_EXTERN AudienceWidgetsPlaylistPopover* audience_widgets_playlist_popover_construct (GType object_type);
static GObject * audience_widgets_playlist_popover_constructor (GType type,
                                                         guint n_construct_properties,
                                                         GObjectConstructParam * construct_properties);
static Block17Data* block17_data_ref (Block17Data* _data17_);
static void block17_data_unref (void * _userdata_);
static GtkWidget* _audience_widgets_playlist_popover_widget_create_func_gtk_list_box_create_widget_func (GObject* item,
                                                                                                  gpointer self);
static void _audience_widgets_playlist_popover___lambda24_ (AudienceWidgetsPlaylistPopover* self,
                                                     GtkListBoxRow* item);
VALA_EXTERN void audience_playback_manager_play_file (AudiencePlaybackManager* self,
                                          const gchar* uri,
                                          gboolean from_beginning);
static void __audience_widgets_playlist_popover___lambda24__gtk_list_box_row_activated (GtkListBox* _sender,
                                                                                 GtkListBoxRow* row,
                                                                                 gpointer self);
static void _audience_widgets_playlist_popover___lambda25_ (AudienceWidgetsPlaylistPopover* self);
VALA_EXTERN GType audience_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (AudienceWindow, g_object_unref)
VALA_EXTERN void audience_window_run_open_file (AudienceWindow* self,
                                    gboolean clear_playlist,
                                    gboolean force_play);
static void __audience_widgets_playlist_popover___lambda25__gtk_button_clicked (GtkButton* _sender,
                                                                         gpointer self);
static void _audience_widgets_playlist_popover___lambda40_ (AudienceWidgetsPlaylistPopover* self);
VALA_EXTERN void audience_playback_manager_clear_playlist (AudiencePlaybackManager* self,
                                               gboolean should_stop);
static void __audience_widgets_playlist_popover___lambda40__gtk_button_clicked (GtkButton* _sender,
                                                                         gpointer self);
static void _audience_widgets_playlist_popover_update_repeat_button_g_settings_changed (GSettings* _sender,
                                                                                 const gchar* key,
                                                                                 gpointer self);
static void _audience_widgets_playlist_popover___lambda41_ (AudienceWidgetsPlaylistPopover* self);
static void __audience_widgets_playlist_popover___lambda41__gtk_button_clicked (GtkButton* _sender,
                                                                         gpointer self);
static void _audience_widgets_playlist_popover_set_current_audience_playback_manager_uri_changed (AudiencePlaybackManager* _sender,
                                                                                           const gchar* uri,
                                                                                           gpointer self);
static void _audience_widgets_playlist_popover___lambda42_ (Block17Data* _data17_);
static void __audience_widgets_playlist_popover___lambda42__gtk_widget_map (GtkWidget* _sender,
                                                                     gpointer self);
static void audience_widgets_playlist_popover_finalize (GObject * obj);
static GType audience_widgets_playlist_popover_get_type_once (void);

static inline gpointer
audience_widgets_playlist_popover_get_instance_private (AudienceWidgetsPlaylistPopover* self)
{
	return G_STRUCT_MEMBER_P (self, AudienceWidgetsPlaylistPopover_private_offset);
}

static void
audience_widgets_playlist_popover_update_repeat_button (AudienceWidgetsPlaylistPopover* self)
{
	GSettings* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = audience_settings;
	switch ((AudiencePlaybackManagerRepeatMode) g_settings_get_enum (_tmp0_, "repeat-mode")) {
		case AUDIENCE_PLAYBACK_MANAGER_REPEAT_MODE_DISABLED:
		{
			GtkButton* _tmp1_;
			GtkButton* _tmp2_;
			_tmp1_ = self->priv->repeat_button;
			gtk_button_set_icon_name (_tmp1_, "media-playlist-no-repeat-symbolic");
			_tmp2_ = self->priv->repeat_button;
			gtk_widget_set_tooltip_text ((GtkWidget*) _tmp2_, _ ("Repeat None"));
			break;
		}
		case AUDIENCE_PLAYBACK_MANAGER_REPEAT_MODE_ALL:
		{
			GtkButton* _tmp3_;
			GtkButton* _tmp4_;
			_tmp3_ = self->priv->repeat_button;
			gtk_button_set_icon_name (_tmp3_, "media-playlist-repeat-symbolic");
			_tmp4_ = self->priv->repeat_button;
			gtk_widget_set_tooltip_text ((GtkWidget*) _tmp4_, _ ("Repeat All"));
			break;
		}
		case AUDIENCE_PLAYBACK_MANAGER_REPEAT_MODE_ONE:
		{
			GtkButton* _tmp5_;
			GtkButton* _tmp6_;
			_tmp5_ = self->priv->repeat_button;
			gtk_button_set_icon_name (_tmp5_, "media-playlist-repeat-song-symbolic");
			_tmp6_ = self->priv->repeat_button;
			gtk_widget_set_tooltip_text ((GtkWidget*) _tmp6_, _ ("Repeat One"));
			break;
		}
		default:
		break;
	}
}

static GtkWidget*
audience_widgets_playlist_popover_widget_create_func (AudienceWidgetsPlaylistPopover* self,
                                                      GObject* item)
{
	gchar* uri = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	AudienceWidgetsPlaylistItem* _tmp5_;
	GtkWidget* _tmp6_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (item != NULL, NULL);
	_tmp0_ = gtk_string_object_get_string (G_TYPE_CHECK_INSTANCE_CAST (item, gtk_string_object_get_type (), GtkStringObject));
	_tmp1_ = _tmp0_;
	_tmp2_ = g_strdup (_tmp1_);
	uri = _tmp2_;
	_tmp3_ = audience_get_title (uri);
	_tmp4_ = _tmp3_;
	_tmp5_ = audience_widgets_playlist_item_new (_tmp4_, uri);
	g_object_ref_sink (_tmp5_);
	_tmp6_ = (GtkWidget*) _tmp5_;
	_g_free0 (_tmp4_);
	result = _tmp6_;
	_g_free0 (uri);
	return result;
}

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

static void
audience_widgets_playlist_popover_set_current (AudienceWidgetsPlaylistPopover* self,
                                               const gchar* current_file)
{
	AudiencePlaybackManager* playback_manager = NULL;
	AudiencePlaybackManager* _tmp0_;
	AudiencePlaybackManager* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (current_file != NULL);
	_tmp0_ = audience_playback_manager_get_default ();
	_tmp1_ = _g_object_ref0 (_tmp0_);
	playback_manager = _tmp1_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = TRUE;
			while (TRUE) {
				AudiencePlaybackManager* _tmp4_;
				GtkStringList* _tmp5_;
				GtkStringList* _tmp6_;
				AudienceWidgetsPlaylistItem* row = NULL;
				GtkListBox* _tmp7_;
				GtkListBoxRow* _tmp8_;
				AudienceWidgetsPlaylistItem* _tmp9_;
				AudienceWidgetsPlaylistItem* _tmp10_;
				const gchar* _tmp11_;
				const gchar* _tmp12_;
				if (!_tmp2_) {
					gint _tmp3_;
					_tmp3_ = i;
					i = _tmp3_ + 1;
				}
				_tmp2_ = FALSE;
				_tmp4_ = playback_manager;
				_tmp5_ = audience_playback_manager_get_play_queue (_tmp4_);
				_tmp6_ = _tmp5_;
				if (!(((guint) i) < g_list_model_get_n_items ((GListModel*) _tmp6_))) {
					break;
				}
				_tmp7_ = self->priv->playlist;
				_tmp8_ = gtk_list_box_get_row_at_index (_tmp7_, i);
				_tmp9_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, AUDIENCE_WIDGETS_TYPE_PLAYLIST_ITEM, AudienceWidgetsPlaylistItem));
				row = _tmp9_;
				_tmp10_ = row;
				_tmp11_ = audience_widgets_playlist_item_get_filename (_tmp10_);
				_tmp12_ = _tmp11_;
				if (g_strcmp0 (_tmp12_, current_file) == 0) {
					AudienceWidgetsPlaylistItem* _tmp13_;
					_tmp13_ = row;
					audience_widgets_playlist_item_set_is_playing (_tmp13_, TRUE);
				} else {
					AudienceWidgetsPlaylistItem* _tmp14_;
					_tmp14_ = row;
					audience_widgets_playlist_item_set_is_playing (_tmp14_, FALSE);
				}
				_g_object_unref0 (row);
			}
		}
	}
	_g_object_unref0 (playback_manager);
}

AudienceWidgetsPlaylistPopover*
audience_widgets_playlist_popover_construct (GType object_type)
{
	AudienceWidgetsPlaylistPopover * self = NULL;
	self = (AudienceWidgetsPlaylistPopover*) g_object_new (object_type, NULL);
	return self;
}

AudienceWidgetsPlaylistPopover*
audience_widgets_playlist_popover_new (void)
{
	return audience_widgets_playlist_popover_construct (AUDIENCE_WIDGETS_TYPE_PLAYLIST_POPOVER);
}

static Block17Data*
block17_data_ref (Block17Data* _data17_)
{
	g_atomic_int_inc (&_data17_->_ref_count_);
	return _data17_;
}

static void
block17_data_unref (void * _userdata_)
{
	Block17Data* _data17_;
	_data17_ = (Block17Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data17_->_ref_count_)) {
		AudienceWidgetsPlaylistPopover* self;
		self = _data17_->self;
		_g_object_unref0 (_data17_->playlist_scrolled);
		_g_object_unref0 (self);
		g_slice_free (Block17Data, _data17_);
	}
}

static GtkWidget*
_audience_widgets_playlist_popover_widget_create_func_gtk_list_box_create_widget_func (GObject* item,
                                                                                       gpointer self)
{
	GtkWidget* result;
	result = audience_widgets_playlist_popover_widget_create_func ((AudienceWidgetsPlaylistPopover*) self, item);
	return result;
}

static void
_audience_widgets_playlist_popover___lambda24_ (AudienceWidgetsPlaylistPopover* self,
                                                GtkListBoxRow* item)
{
	AudiencePlaybackManager* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	g_return_if_fail (item != NULL);
	_tmp0_ = audience_playback_manager_get_default ();
	_tmp1_ = audience_widgets_playlist_item_get_filename (G_TYPE_CHECK_INSTANCE_CAST (item, AUDIENCE_WIDGETS_TYPE_PLAYLIST_ITEM, AudienceWidgetsPlaylistItem));
	_tmp2_ = _tmp1_;
	audience_playback_manager_play_file (_tmp0_, _tmp2_, TRUE);
}

static void
__audience_widgets_playlist_popover___lambda24__gtk_list_box_row_activated (GtkListBox* _sender,
                                                                            GtkListBoxRow* row,
                                                                            gpointer self)
{
	_audience_widgets_playlist_popover___lambda24_ ((AudienceWidgetsPlaylistPopover*) self, row);
}

static void
_audience_widgets_playlist_popover___lambda25_ (AudienceWidgetsPlaylistPopover* self)
{
	GApplication* _tmp0_;
	GtkWindow* _tmp1_;
	GtkWindow* _tmp2_;
	gtk_popover_popdown ((GtkPopover*) self);
	_tmp0_ = g_application_get_default ();
	_tmp1_ = gtk_application_get_active_window (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gtk_application_get_type (), GtkApplication));
	_tmp2_ = _tmp1_;
	audience_window_run_open_file (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, AUDIENCE_TYPE_WINDOW, AudienceWindow), FALSE, FALSE);
}

static void
__audience_widgets_playlist_popover___lambda25__gtk_button_clicked (GtkButton* _sender,
                                                                    gpointer self)
{
	_audience_widgets_playlist_popover___lambda25_ ((AudienceWidgetsPlaylistPopover*) self);
}

static void
_audience_widgets_playlist_popover___lambda40_ (AudienceWidgetsPlaylistPopover* self)
{
	AudiencePlaybackManager* _tmp0_;
	gtk_popover_popdown ((GtkPopover*) self);
	_tmp0_ = audience_playback_manager_get_default ();
	audience_playback_manager_clear_playlist (_tmp0_, TRUE);
}

static void
__audience_widgets_playlist_popover___lambda40__gtk_button_clicked (GtkButton* _sender,
                                                                    gpointer self)
{
	_audience_widgets_playlist_popover___lambda40_ ((AudienceWidgetsPlaylistPopover*) self);
}

static void
_audience_widgets_playlist_popover_update_repeat_button_g_settings_changed (GSettings* _sender,
                                                                            const gchar* key,
                                                                            gpointer self)
{
	audience_widgets_playlist_popover_update_repeat_button ((AudienceWidgetsPlaylistPopover*) self);
}

static void
_audience_widgets_playlist_popover___lambda41_ (AudienceWidgetsPlaylistPopover* self)
{
	gint current = 0;
	GSettings* _tmp0_;
	gint _tmp1_ = 0;
	GSettings* _tmp2_;
	_tmp0_ = audience_settings;
	current = g_settings_get_enum (_tmp0_, "repeat-mode");
	if (current > 1) {
		_tmp1_ = 0;
	} else {
		_tmp1_ = current + 1;
	}
	_tmp2_ = audience_settings;
	g_settings_set_enum (_tmp2_, "repeat-mode", _tmp1_);
}

static void
__audience_widgets_playlist_popover___lambda41__gtk_button_clicked (GtkButton* _sender,
                                                                    gpointer self)
{
	_audience_widgets_playlist_popover___lambda41_ ((AudienceWidgetsPlaylistPopover*) self);
}

static void
_audience_widgets_playlist_popover_set_current_audience_playback_manager_uri_changed (AudiencePlaybackManager* _sender,
                                                                                      const gchar* uri,
                                                                                      gpointer self)
{
	audience_widgets_playlist_popover_set_current ((AudienceWidgetsPlaylistPopover*) self, uri);
}

static void
_audience_widgets_playlist_popover___lambda42_ (Block17Data* _data17_)
{
	AudienceWidgetsPlaylistPopover* self;
	gint window_height = 0;
	GApplication* _tmp0_;
	GtkWindow* _tmp1_;
	GtkWindow* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	GtkScrolledWindow* _tmp5_;
	self = _data17_->self;
	_tmp0_ = g_application_get_default ();
	_tmp1_ = gtk_application_get_active_window (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gtk_application_get_type (), GtkApplication));
	_tmp2_ = _tmp1_;
	g_object_get (_tmp2_, "default-height", &_tmp3_, NULL);
	_tmp4_ = _tmp3_;
	window_height = _tmp4_;
	_tmp5_ = _data17_->playlist_scrolled;
	gtk_scrolled_window_set_max_content_height (_tmp5_, window_height - AUDIENCE_WIDGETS_PLAYLIST_POPOVER_HEIGHT_OFFSET);
}

static void
__audience_widgets_playlist_popover___lambda42__gtk_widget_map (GtkWidget* _sender,
                                                                gpointer self)
{
	_audience_widgets_playlist_popover___lambda42_ (self);
}

static GObject *
audience_widgets_playlist_popover_constructor (GType type,
                                               guint n_construct_properties,
                                               GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	AudienceWidgetsPlaylistPopover * self;
	Block17Data* _data17_;
	GtkButton* fil = NULL;
	gchar* _tmp0_;
	GtkButton* _tmp1_ = NULL;
	GtkButton* clear_playlist_button = NULL;
	gchar* _tmp2_;
	GtkButton* _tmp3_ = NULL;
	GtkButton* _tmp4_;
	AudiencePlaybackManager* playback_manager = NULL;
	AudiencePlaybackManager* _tmp5_;
	AudiencePlaybackManager* _tmp6_;
	GtkListBox* _tmp7_ = NULL;
	GtkListBox* _tmp8_;
	AudiencePlaybackManager* _tmp9_;
	GtkStringList* _tmp10_;
	GtkStringList* _tmp11_;
	GtkListBox* _tmp12_;
	GtkWidget* _tmp13_;
	GtkScrolledWindow* _tmp14_ = NULL;
	GtkGrid* grid = NULL;
	GtkGrid* _tmp15_ = NULL;
	GtkGrid* _tmp16_;
	GtkScrolledWindow* _tmp17_;
	GtkGrid* _tmp18_;
	GtkButton* _tmp19_;
	GtkGrid* _tmp20_;
	GtkButton* _tmp21_;
	GtkGrid* _tmp22_;
	GtkButton* _tmp23_;
	GtkGrid* _tmp24_;
	GtkListBox* _tmp25_;
	GtkButton* _tmp26_;
	GtkButton* _tmp27_;
	GSettings* _tmp28_;
	GtkButton* _tmp29_;
	AudiencePlaybackManager* _tmp30_;
	parent_class = G_OBJECT_CLASS (audience_widgets_playlist_popover_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, AUDIENCE_WIDGETS_TYPE_PLAYLIST_POPOVER, AudienceWidgetsPlaylistPopover);
	_data17_ = g_slice_new0 (Block17Data);
	_data17_->_ref_count_ = 1;
	_data17_->self = g_object_ref (self);
	_tmp0_ = g_strdup (_ ("Open file"));
	_tmp1_ = (GtkButton*) gtk_button_new_from_icon_name ("document-open-symbolic");
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp1_, _tmp0_);
	_g_free0 (_tmp0_);
	g_object_ref_sink (_tmp1_);
	fil = _tmp1_;
	_tmp2_ = g_strdup (_ ("Clear Playlist"));
	_tmp3_ = (GtkButton*) gtk_button_new_from_icon_name ("edit-delete-symbolic");
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp3_, _tmp2_);
	_g_free0 (_tmp2_);
	g_object_ref_sink (_tmp3_);
	clear_playlist_button = _tmp3_;
	_tmp4_ = (GtkButton*) gtk_button_new ();
	g_object_ref_sink (_tmp4_);
	_g_object_unref0 (self->priv->repeat_button);
	self->priv->repeat_button = _tmp4_;
	_tmp5_ = audience_playback_manager_get_default ();
	_tmp6_ = _g_object_ref0 (_tmp5_);
	playback_manager = _tmp6_;
	_tmp7_ = (GtkListBox*) gtk_list_box_new ();
	gtk_widget_set_can_focus ((GtkWidget*) _tmp7_, TRUE);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp7_, TRUE);
	gtk_widget_set_vexpand ((GtkWidget*) _tmp7_, TRUE);
	gtk_list_box_set_selection_mode (_tmp7_, GTK_SELECTION_BROWSE);
	g_object_ref_sink (_tmp7_);
	_g_object_unref0 (self->priv->playlist);
	self->priv->playlist = _tmp7_;
	_tmp8_ = self->priv->playlist;
	_tmp9_ = playback_manager;
	_tmp10_ = audience_playback_manager_get_play_queue (_tmp9_);
	_tmp11_ = _tmp10_;
	gtk_list_box_bind_model (_tmp8_, (GListModel*) _tmp11_, _audience_widgets_playlist_popover_widget_create_func_gtk_list_box_create_widget_func, g_object_ref (self), g_object_unref);
	_tmp12_ = self->priv->playlist;
	_tmp13_ = _g_object_ref0 ((GtkWidget*) _tmp12_);
	_tmp14_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	gtk_scrolled_window_set_min_content_height (_tmp14_, 100);
	gtk_scrolled_window_set_min_content_width (_tmp14_, 260);
	gtk_scrolled_window_set_propagate_natural_height (_tmp14_, TRUE);
	gtk_scrolled_window_set_child (_tmp14_, _tmp13_);
	_g_object_unref0 (_tmp13_);
	g_object_ref_sink (_tmp14_);
	_data17_->playlist_scrolled = _tmp14_;
	_tmp15_ = (GtkGrid*) gtk_grid_new ();
	gtk_grid_set_column_spacing (_tmp15_, 12);
	gtk_grid_set_row_spacing (_tmp15_, 6);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp15_, 6);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp15_, 6);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp15_, 6);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp15_, 6);
	g_object_ref_sink (_tmp15_);
	grid = _tmp15_;
	_tmp16_ = grid;
	_tmp17_ = _data17_->playlist_scrolled;
	gtk_grid_attach (_tmp16_, (GtkWidget*) _tmp17_, 0, 0, 7, 1);
	_tmp18_ = grid;
	_tmp19_ = fil;
	gtk_grid_attach (_tmp18_, (GtkWidget*) _tmp19_, 0, 1, 1, 1);
	_tmp20_ = grid;
	_tmp21_ = clear_playlist_button;
	gtk_grid_attach (_tmp20_, (GtkWidget*) _tmp21_, 1, 1, 1, 1);
	_tmp22_ = grid;
	_tmp23_ = self->priv->repeat_button;
	gtk_grid_attach (_tmp22_, (GtkWidget*) _tmp23_, 6, 1, 1, 1);
	gtk_popover_set_position ((GtkPopover*) self, GTK_POS_TOP);
	_tmp24_ = grid;
	gtk_popover_set_child ((GtkPopover*) self, (GtkWidget*) _tmp24_);
	_tmp25_ = self->priv->playlist;
	g_signal_connect_object (_tmp25_, "row-activated", (GCallback) __audience_widgets_playlist_popover___lambda24__gtk_list_box_row_activated, self, 0);
	_tmp26_ = fil;
	g_signal_connect_object (_tmp26_, "clicked", (GCallback) __audience_widgets_playlist_popover___lambda25__gtk_button_clicked, self, 0);
	_tmp27_ = clear_playlist_button;
	g_signal_connect_object (_tmp27_, "clicked", (GCallback) __audience_widgets_playlist_popover___lambda40__gtk_button_clicked, self, 0);
	_tmp28_ = audience_settings;
	g_signal_connect_object (_tmp28_, "changed::repeat-mode", (GCallback) _audience_widgets_playlist_popover_update_repeat_button_g_settings_changed, self, 0);
	audience_widgets_playlist_popover_update_repeat_button (self);
	_tmp29_ = self->priv->repeat_button;
	g_signal_connect_object (_tmp29_, "clicked", (GCallback) __audience_widgets_playlist_popover___lambda41__gtk_button_clicked, self, 0);
	_tmp30_ = playback_manager;
	g_signal_connect_object (_tmp30_, "uri-changed", (GCallback) _audience_widgets_playlist_popover_set_current_audience_playback_manager_uri_changed, self, 0);
	g_signal_connect_data ((GtkWidget*) self, "map", (GCallback) __audience_widgets_playlist_popover___lambda42__gtk_widget_map, block17_data_ref (_data17_), (GClosureNotify) block17_data_unref, 0);
	_g_object_unref0 (grid);
	_g_object_unref0 (playback_manager);
	_g_object_unref0 (clear_playlist_button);
	_g_object_unref0 (fil);
	block17_data_unref (_data17_);
	_data17_ = NULL;
	return obj;
}

static void
audience_widgets_playlist_popover_class_init (AudienceWidgetsPlaylistPopoverClass * klass,
                                              gpointer klass_data)
{
	audience_widgets_playlist_popover_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &AudienceWidgetsPlaylistPopover_private_offset);
	G_OBJECT_CLASS (klass)->constructor = audience_widgets_playlist_popover_constructor;
	G_OBJECT_CLASS (klass)->finalize = audience_widgets_playlist_popover_finalize;
}

static void
audience_widgets_playlist_popover_instance_init (AudienceWidgetsPlaylistPopover * self,
                                                 gpointer klass)
{
	self->priv = audience_widgets_playlist_popover_get_instance_private (self);
}

static void
audience_widgets_playlist_popover_finalize (GObject * obj)
{
	AudienceWidgetsPlaylistPopover * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, AUDIENCE_WIDGETS_TYPE_PLAYLIST_POPOVER, AudienceWidgetsPlaylistPopover);
	_g_object_unref0 (self->priv->playlist);
	_g_object_unref0 (self->priv->repeat_button);
	G_OBJECT_CLASS (audience_widgets_playlist_popover_parent_class)->finalize (obj);
}

static GType
audience_widgets_playlist_popover_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (AudienceWidgetsPlaylistPopoverClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) audience_widgets_playlist_popover_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (AudienceWidgetsPlaylistPopover), 0, (GInstanceInitFunc) audience_widgets_playlist_popover_instance_init, NULL };
	GType audience_widgets_playlist_popover_type_id;
	audience_widgets_playlist_popover_type_id = g_type_register_static (gtk_popover_get_type (), "AudienceWidgetsPlaylistPopover", &g_define_type_info, 0);
	AudienceWidgetsPlaylistPopover_private_offset = g_type_add_instance_private (audience_widgets_playlist_popover_type_id, sizeof (AudienceWidgetsPlaylistPopoverPrivate));
	return audience_widgets_playlist_popover_type_id;
}

GType
audience_widgets_playlist_popover_get_type (void)
{
	static volatile gsize audience_widgets_playlist_popover_type_id__once = 0;
	if (g_once_init_enter (&audience_widgets_playlist_popover_type_id__once)) {
		GType audience_widgets_playlist_popover_type_id;
		audience_widgets_playlist_popover_type_id = audience_widgets_playlist_popover_get_type_once ();
		g_once_init_leave (&audience_widgets_playlist_popover_type_id__once, audience_widgets_playlist_popover_type_id);
	}
	return audience_widgets_playlist_popover_type_id__once;
}

