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

/* -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-*/
/*-
 * Copyright (c) 2013-2014 Audience Developers (http://launchpad.net/pantheon-chat)
 *
 * 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 <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gst/gst.h>
#include <gdk/gdk.h>
#include <adwaita.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 AUDIENCE_WIDGETS_TYPE_PREVIEW_POPOVER (audience_widgets_preview_popover_get_type ())
#define AUDIENCE_WIDGETS_PREVIEW_POPOVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AUDIENCE_WIDGETS_TYPE_PREVIEW_POPOVER, AudienceWidgetsPreviewPopover))
#define AUDIENCE_WIDGETS_PREVIEW_POPOVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), AUDIENCE_WIDGETS_TYPE_PREVIEW_POPOVER, AudienceWidgetsPreviewPopoverClass))
#define AUDIENCE_WIDGETS_IS_PREVIEW_POPOVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AUDIENCE_WIDGETS_TYPE_PREVIEW_POPOVER))
#define AUDIENCE_WIDGETS_IS_PREVIEW_POPOVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), AUDIENCE_WIDGETS_TYPE_PREVIEW_POPOVER))
#define AUDIENCE_WIDGETS_PREVIEW_POPOVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), AUDIENCE_WIDGETS_TYPE_PREVIEW_POPOVER, AudienceWidgetsPreviewPopoverClass))

typedef struct _AudienceWidgetsPreviewPopover AudienceWidgetsPreviewPopover;
typedef struct _AudienceWidgetsPreviewPopoverClass AudienceWidgetsPreviewPopoverClass;
typedef struct _AudienceWidgetsPreviewPopoverPrivate AudienceWidgetsPreviewPopoverPrivate;
enum  {
	AUDIENCE_WIDGETS_PREVIEW_POPOVER_0_PROPERTY,
	AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAYBACK_URI_PROPERTY,
	AUDIENCE_WIDGETS_PREVIEW_POPOVER_NUM_PROPERTIES
};
static GParamSpec* audience_widgets_preview_popover_properties[AUDIENCE_WIDGETS_PREVIEW_POPOVER_NUM_PROPERTIES];
typedef enum  {
	AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_VIDEO = 1 << 0,
	AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_AUDIO = 1 << 1,
	AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_TEXT = 1 << 2,
	AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_VIS = 1 << 3,
	AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_SOFT_VOLUME = 1 << 4,
	AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_NATIVE_AUDIO = 1 << 5,
	AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_NATIVE_VIDEO = 1 << 6,
	AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_DOWNLOAD = 1 << 7,
	AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_BUFFERING = 1 << 8,
	AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_DEINTERLACE = 1 << 9,
	AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_SOFT_COLORBALANCE = 1 << 10
} AudienceWidgetsPreviewPopoverPlayFlags;

#define AUDIENCE_WIDGETS_PREVIEW_POPOVER_TYPE_PLAY_FLAGS (audience_widgets_preview_popover_play_flags_get_type ())
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block18Data Block18Data;

struct _AudienceWidgetsPreviewPopover {
	GtkPopover parent_instance;
	AudienceWidgetsPreviewPopoverPrivate * priv;
};

struct _AudienceWidgetsPreviewPopoverClass {
	GtkPopoverClass parent_class;
};

struct _AudienceWidgetsPreviewPopoverPrivate {
	gchar* _playback_uri;
	GstElement* playbin;
	GdkPaintable* paintable;
	guint loop_timer_id;
	guint show_timer_id;
	guint hide_timer_id;
	guint idle_id;
	gint64 req_position;
	gboolean req_loop;
};

struct _Block18Data {
	int _ref_count_;
	AudienceWidgetsPreviewPopover* self;
	gint64 position;
	gboolean loop;
};

static gint AudienceWidgetsPreviewPopover_private_offset;
static gpointer audience_widgets_preview_popover_parent_class = NULL;

VALA_EXTERN GType audience_widgets_preview_popover_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (AudienceWidgetsPreviewPopover, g_object_unref)
static void audience_widgets_preview_popover_cancel_loop_timer (AudienceWidgetsPreviewPopover* self);
static GType audience_widgets_preview_popover_play_flags_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
VALA_EXTERN void audience_widgets_preview_popover_set_preview_position (AudienceWidgetsPreviewPopover* self,
                                                            gint64 position,
                                                            gboolean loop);
static Block18Data* block18_data_ref (Block18Data* _data18_);
static void block18_data_unref (void * _userdata_);
static gboolean __lambda18_ (Block18Data* _data18_);
static gboolean ___lambda19_ (Block18Data* _data18_);
static gboolean ____lambda19__gsource_func (gpointer self);
static gboolean ___lambda18__gsource_func (gpointer self);
VALA_EXTERN void audience_widgets_preview_popover_schedule_show (AudienceWidgetsPreviewPopover* self);
static void audience_widgets_preview_popover_cancel_timer (AudienceWidgetsPreviewPopover* self,
                                                    guint* timer_id);
static gboolean __lambda20_ (AudienceWidgetsPreviewPopover* self);
static gboolean ___lambda20__gsource_func (gpointer self);
VALA_EXTERN void audience_widgets_preview_popover_schedule_hide (AudienceWidgetsPreviewPopover* self);
static gboolean __lambda21_ (AudienceWidgetsPreviewPopover* self);
static gboolean ___lambda21__gsource_func (gpointer self);
VALA_EXTERN AudienceWidgetsPreviewPopover* audience_widgets_preview_popover_new (void);
VALA_EXTERN AudienceWidgetsPreviewPopover* audience_widgets_preview_popover_construct (GType object_type);
VALA_EXTERN const gchar* audience_widgets_preview_popover_get_playback_uri (AudienceWidgetsPreviewPopover* self);
VALA_EXTERN void audience_widgets_preview_popover_set_playback_uri (AudienceWidgetsPreviewPopover* self,
                                                        const gchar* value);
static GObject * audience_widgets_preview_popover_constructor (GType type,
                                                        guint n_construct_properties,
                                                        GObjectConstructParam * construct_properties);
static void _audience_widgets_preview_popover___lambda22_ (AudienceWidgetsPreviewPopover* self);
static void __audience_widgets_preview_popover___lambda22__g_object_notify (GObject* _sender,
                                                                     GParamSpec* pspec,
                                                                     gpointer self);
static void _audience_widgets_preview_popover___lambda23_ (AudienceWidgetsPreviewPopover* self);
static void __audience_widgets_preview_popover___lambda23__gtk_popover_closed (GtkPopover* _sender,
                                                                        gpointer self);
static void audience_widgets_preview_popover_finalize (GObject * obj);
static GType audience_widgets_preview_popover_get_type_once (void);
static void _vala_audience_widgets_preview_popover_get_property (GObject * object,
                                                          guint property_id,
                                                          GValue * value,
                                                          GParamSpec * pspec);
static void _vala_audience_widgets_preview_popover_set_property (GObject * object,
                                                          guint property_id,
                                                          const GValue * value,
                                                          GParamSpec * pspec);

static inline gpointer
audience_widgets_preview_popover_get_instance_private (AudienceWidgetsPreviewPopover* self)
{
	return G_STRUCT_MEMBER_P (self, AudienceWidgetsPreviewPopover_private_offset);
}

static GType
audience_widgets_preview_popover_play_flags_get_type_once (void)
{
	static const GEnumValue values[] = {{AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_VIDEO, "AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_VIDEO", "video"}, {AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_AUDIO, "AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_AUDIO", "audio"}, {AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_TEXT, "AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_TEXT", "text"}, {AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_VIS, "AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_VIS", "vis"}, {AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_SOFT_VOLUME, "AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_SOFT_VOLUME", "soft-volume"}, {AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_NATIVE_AUDIO, "AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_NATIVE_AUDIO", "native-audio"}, {AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_NATIVE_VIDEO, "AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_NATIVE_VIDEO", "native-video"}, {AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_DOWNLOAD, "AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_DOWNLOAD", "download"}, {AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_BUFFERING, "AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_BUFFERING", "buffering"}, {AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_DEINTERLACE, "AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_DEINTERLACE", "deinterlace"}, {AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_SOFT_COLORBALANCE, "AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_SOFT_COLORBALANCE", "soft-colorbalance"}, {0, NULL, NULL}};
	GType audience_widgets_preview_popover_play_flags_type_id;
	audience_widgets_preview_popover_play_flags_type_id = g_enum_register_static ("AudienceWidgetsPreviewPopoverPlayFlags", values);
	return audience_widgets_preview_popover_play_flags_type_id;
}

static GType
audience_widgets_preview_popover_play_flags_get_type (void)
{
	static volatile gsize audience_widgets_preview_popover_play_flags_type_id__once = 0;
	if (g_once_init_enter (&audience_widgets_preview_popover_play_flags_type_id__once)) {
		GType audience_widgets_preview_popover_play_flags_type_id;
		audience_widgets_preview_popover_play_flags_type_id = audience_widgets_preview_popover_play_flags_get_type_once ();
		g_once_init_leave (&audience_widgets_preview_popover_play_flags_type_id__once, audience_widgets_preview_popover_play_flags_type_id);
	}
	return audience_widgets_preview_popover_play_flags_type_id__once;
}

static Block18Data*
block18_data_ref (Block18Data* _data18_)
{
	g_atomic_int_inc (&_data18_->_ref_count_);
	return _data18_;
}

static void
block18_data_unref (void * _userdata_)
{
	Block18Data* _data18_;
	_data18_ = (Block18Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data18_->_ref_count_)) {
		AudienceWidgetsPreviewPopover* self;
		self = _data18_->self;
		_g_object_unref0 (self);
		g_slice_free (Block18Data, _data18_);
	}
}

static gboolean
___lambda19_ (Block18Data* _data18_)
{
	AudienceWidgetsPreviewPopover* self;
	gboolean result;
	self = _data18_->self;
	audience_widgets_preview_popover_set_preview_position (self, _data18_->position, TRUE);
	self->priv->loop_timer_id = (guint) 0;
	result = FALSE;
	return result;
}

static gboolean
____lambda19__gsource_func (gpointer self)
{
	gboolean result;
	result = ___lambda19_ (self);
	return result;
}

static gboolean
__lambda18_ (Block18Data* _data18_)
{
	AudienceWidgetsPreviewPopover* self;
	GstElement* _tmp0_;
	GstElement* _tmp1_;
	gboolean result;
	self = _data18_->self;
	_tmp0_ = self->priv->playbin;
	gst_element_set_state (_tmp0_, GST_STATE_PAUSED);
	_tmp1_ = self->priv->playbin;
	gst_element_seek_simple (_tmp1_, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE, _data18_->position);
	if (_data18_->loop) {
		GstElement* _tmp2_;
		_tmp2_ = self->priv->playbin;
		gst_element_set_state (_tmp2_, GST_STATE_PLAYING);
		self->priv->loop_timer_id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 5, ____lambda19__gsource_func, block18_data_ref (_data18_), block18_data_unref);
	}
	self->priv->idle_id = (guint) 0;
	result = FALSE;
	return result;
}

static gboolean
___lambda18__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda18_ (self);
	return result;
}

void
audience_widgets_preview_popover_set_preview_position (AudienceWidgetsPreviewPopover* self,
                                                       gint64 position,
                                                       gboolean loop)
{
	Block18Data* _data18_;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_;
	gboolean _tmp2_;
	g_return_if_fail (self != NULL);
	_data18_ = g_slice_new0 (Block18Data);
	_data18_->_ref_count_ = 1;
	_data18_->self = g_object_ref (self);
	_data18_->position = position;
	_data18_->loop = loop;
	self->priv->req_position = _data18_->position;
	self->priv->req_loop = _data18_->loop;
	_tmp1_ = gtk_widget_get_visible ((GtkWidget*) self);
	_tmp2_ = _tmp1_;
	if (!_tmp2_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = self->priv->idle_id > ((guint) 0);
	}
	if (_tmp0_) {
		block18_data_unref (_data18_);
		_data18_ = NULL;
		return;
	}
	if (_data18_->loop) {
		audience_widgets_preview_popover_cancel_loop_timer (self);
	}
	self->priv->idle_id = g_idle_add_full (G_PRIORITY_LOW, ___lambda18__gsource_func, block18_data_ref (_data18_), block18_data_unref);
	block18_data_unref (_data18_);
	_data18_ = NULL;
}

static gboolean
__lambda20_ (AudienceWidgetsPreviewPopover* self)
{
	gboolean result;
	gtk_popover_popup ((GtkPopover*) self);
	if (self->priv->req_position >= ((gint64) 0)) {
		audience_widgets_preview_popover_set_preview_position (self, self->priv->req_position, self->priv->req_loop);
	}
	self->priv->show_timer_id = (guint) 0;
	result = FALSE;
	return result;
}

static gboolean
___lambda20__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda20_ ((AudienceWidgetsPreviewPopover*) self);
	return result;
}

void
audience_widgets_preview_popover_schedule_show (AudienceWidgetsPreviewPopover* self)
{
	g_return_if_fail (self != NULL);
	if (self->priv->show_timer_id > ((guint) 0)) {
		return;
	}
	audience_widgets_preview_popover_cancel_timer (self, &self->priv->hide_timer_id);
	self->priv->show_timer_id = g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 300, ___lambda20__gsource_func, g_object_ref (self), g_object_unref);
}

static gboolean
__lambda21_ (AudienceWidgetsPreviewPopover* self)
{
	gboolean result;
	gtk_popover_popdown ((GtkPopover*) self);
	self->priv->hide_timer_id = (guint) 0;
	result = FALSE;
	return result;
}

static gboolean
___lambda21__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda21_ ((AudienceWidgetsPreviewPopover*) self);
	return result;
}

void
audience_widgets_preview_popover_schedule_hide (AudienceWidgetsPreviewPopover* self)
{
	g_return_if_fail (self != NULL);
	if (self->priv->hide_timer_id > ((guint) 0)) {
		return;
	}
	audience_widgets_preview_popover_cancel_timer (self, &self->priv->show_timer_id);
	self->priv->hide_timer_id = g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 300, ___lambda21__gsource_func, g_object_ref (self), g_object_unref);
}

static void
audience_widgets_preview_popover_cancel_loop_timer (AudienceWidgetsPreviewPopover* self)
{
	g_return_if_fail (self != NULL);
	audience_widgets_preview_popover_cancel_timer (self, &self->priv->loop_timer_id);
}

static void
audience_widgets_preview_popover_cancel_timer (AudienceWidgetsPreviewPopover* self,
                                               guint* timer_id)
{
	g_return_if_fail (self != NULL);
	if ((*timer_id) > ((guint) 0)) {
		g_source_remove (*timer_id);
		*timer_id = (guint) 0;
	}
}

AudienceWidgetsPreviewPopover*
audience_widgets_preview_popover_construct (GType object_type)
{
	AudienceWidgetsPreviewPopover * self = NULL;
	self = (AudienceWidgetsPreviewPopover*) g_object_new (object_type, NULL);
	return self;
}

AudienceWidgetsPreviewPopover*
audience_widgets_preview_popover_new (void)
{
	return audience_widgets_preview_popover_construct (AUDIENCE_WIDGETS_TYPE_PREVIEW_POPOVER);
}

const gchar*
audience_widgets_preview_popover_get_playback_uri (AudienceWidgetsPreviewPopover* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_playback_uri;
	result = _tmp0_;
	return result;
}

void
audience_widgets_preview_popover_set_playback_uri (AudienceWidgetsPreviewPopover* self,
                                                   const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = audience_widgets_preview_popover_get_playback_uri (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_playback_uri);
		self->priv->_playback_uri = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, audience_widgets_preview_popover_properties[AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAYBACK_URI_PROPERTY]);
	}
}

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

static void
_audience_widgets_preview_popover___lambda22_ (AudienceWidgetsPreviewPopover* self)
{
	GstElement* _tmp0_;
	const gchar* _tmp1_;
	_tmp0_ = self->priv->playbin;
	_tmp1_ = self->priv->_playback_uri;
	g_object_set (_tmp0_, "uri", _tmp1_, NULL);
}

static void
__audience_widgets_preview_popover___lambda22__g_object_notify (GObject* _sender,
                                                                GParamSpec* pspec,
                                                                gpointer self)
{
	_audience_widgets_preview_popover___lambda22_ ((AudienceWidgetsPreviewPopover*) self);
}

static void
_audience_widgets_preview_popover___lambda23_ (AudienceWidgetsPreviewPopover* self)
{
	GstElement* _tmp0_;
	_tmp0_ = self->priv->playbin;
	gst_element_set_state (_tmp0_, GST_STATE_NULL);
	audience_widgets_preview_popover_cancel_loop_timer (self);
	audience_widgets_preview_popover_cancel_timer (self, &self->priv->show_timer_id);
	audience_widgets_preview_popover_cancel_timer (self, &self->priv->hide_timer_id);
}

static void
__audience_widgets_preview_popover___lambda23__gtk_popover_closed (GtkPopover* _sender,
                                                                   gpointer self)
{
	_audience_widgets_preview_popover___lambda23_ ((AudienceWidgetsPreviewPopover*) self);
}

static GObject *
audience_widgets_preview_popover_constructor (GType type,
                                              guint n_construct_properties,
                                              GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	AudienceWidgetsPreviewPopover * self;
	GstElement* gtksink = NULL;
	GstElement* _tmp0_;
	GstElement* _tmp1_;
	GdkPaintable* _tmp2_ = NULL;
	GstElement* _tmp3_;
	GstElement* _tmp4_;
	GstElement* _tmp5_;
	gint flags = 0;
	GstElement* _tmp6_;
	gint _tmp7_ = 0;
	GstElement* _tmp8_;
	GtkPicture* picture = NULL;
	GdkPaintable* _tmp9_;
	GtkPicture* _tmp10_ = NULL;
	AdwClamp* v_clamp = NULL;
	GtkPicture* _tmp11_;
	GtkWidget* _tmp12_;
	AdwClamp* _tmp13_ = NULL;
	AdwClamp* _tmp14_;
	parent_class = G_OBJECT_CLASS (audience_widgets_preview_popover_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, AUDIENCE_WIDGETS_TYPE_PREVIEW_POPOVER, AudienceWidgetsPreviewPopover);
	_tmp0_ = gst_element_factory_make ("gtk4paintablesink", "sink");
	if (_tmp0_ != NULL) {
		g_object_ref_sink (_tmp0_);
	}
	gtksink = _tmp0_;
	_tmp1_ = gtksink;
	g_object_get ((GObject*) _tmp1_, "paintable", &_tmp2_, NULL);
	_g_object_unref0 (self->priv->paintable);
	self->priv->paintable = _tmp2_;
	_tmp3_ = gst_element_factory_make ("playbin", "bin");
	if (_tmp3_ != NULL) {
		g_object_ref_sink (_tmp3_);
	}
	_g_object_unref0 (self->priv->playbin);
	self->priv->playbin = _tmp3_;
	_tmp4_ = self->priv->playbin;
	_tmp5_ = gtksink;
	g_object_set (_tmp4_, "video-sink", _tmp5_, NULL);
	_tmp6_ = self->priv->playbin;
	g_object_get ((GObject*) _tmp6_, "flags", &_tmp7_, NULL);
	flags = _tmp7_;
	flags &= (gint) (~AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_TEXT);
	flags &= (gint) (~AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAY_FLAGS_AUDIO);
	_tmp8_ = self->priv->playbin;
	g_object_set ((GObject*) _tmp8_, "flags", flags, NULL);
	_tmp9_ = self->priv->paintable;
	_tmp10_ = (GtkPicture*) gtk_picture_new_for_paintable (_tmp9_);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp10_, TRUE);
	gtk_widget_set_vexpand ((GtkWidget*) _tmp10_, TRUE);
	g_object_ref_sink (_tmp10_);
	picture = _tmp10_;
	_tmp11_ = picture;
	_tmp12_ = _g_object_ref0 ((GtkWidget*) _tmp11_);
	_tmp13_ = (AdwClamp*) adw_clamp_new ();
	adw_clamp_set_child (_tmp13_, _tmp12_);
	_g_object_unref0 (_tmp12_);
	adw_clamp_set_maximum_size (_tmp13_, 128);
	gtk_orientable_set_orientation ((GtkOrientable*) _tmp13_, GTK_ORIENTATION_VERTICAL);
	g_object_ref_sink (_tmp13_);
	v_clamp = _tmp13_;
	gtk_widget_set_can_focus ((GtkWidget*) self, FALSE);
	gtk_popover_set_has_arrow ((GtkPopover*) self, FALSE);
	gtk_widget_set_sensitive ((GtkWidget*) self, FALSE);
	gtk_popover_set_autohide ((GtkPopover*) self, FALSE);
	gtk_popover_set_position ((GtkPopover*) self, GTK_POS_TOP);
	_tmp14_ = v_clamp;
	gtk_popover_set_child ((GtkPopover*) self, (GtkWidget*) _tmp14_);
	gtk_widget_add_css_class ((GtkWidget*) self, "preview");
	g_signal_connect_object ((GObject*) self, "notify::playback-uri", (GCallback) __audience_widgets_preview_popover___lambda22__g_object_notify, self, 0);
	g_signal_connect_object ((GtkPopover*) self, "closed", (GCallback) __audience_widgets_preview_popover___lambda23__gtk_popover_closed, self, 0);
	_g_object_unref0 (v_clamp);
	_g_object_unref0 (picture);
	_g_object_unref0 (gtksink);
	return obj;
}

static void
audience_widgets_preview_popover_class_init (AudienceWidgetsPreviewPopoverClass * klass,
                                             gpointer klass_data)
{
	audience_widgets_preview_popover_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &AudienceWidgetsPreviewPopover_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_audience_widgets_preview_popover_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_audience_widgets_preview_popover_set_property;
	G_OBJECT_CLASS (klass)->constructor = audience_widgets_preview_popover_constructor;
	G_OBJECT_CLASS (klass)->finalize = audience_widgets_preview_popover_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAYBACK_URI_PROPERTY, audience_widgets_preview_popover_properties[AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAYBACK_URI_PROPERTY] = g_param_spec_string ("playback-uri", "playback-uri", "playback-uri", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
audience_widgets_preview_popover_instance_init (AudienceWidgetsPreviewPopover * self,
                                                gpointer klass)
{
	self->priv = audience_widgets_preview_popover_get_instance_private (self);
	self->priv->loop_timer_id = (guint) 0;
	self->priv->show_timer_id = (guint) 0;
	self->priv->hide_timer_id = (guint) 0;
	self->priv->idle_id = (guint) 0;
	self->priv->req_position = (gint64) -1;
	self->priv->req_loop = FALSE;
}

static void
audience_widgets_preview_popover_finalize (GObject * obj)
{
	AudienceWidgetsPreviewPopover * self;
	GstElement* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, AUDIENCE_WIDGETS_TYPE_PREVIEW_POPOVER, AudienceWidgetsPreviewPopover);
	_tmp0_ = self->priv->playbin;
	gst_element_set_state (_tmp0_, GST_STATE_NULL);
	audience_widgets_preview_popover_cancel_loop_timer (self);
	_g_free0 (self->priv->_playback_uri);
	_g_object_unref0 (self->priv->playbin);
	_g_object_unref0 (self->priv->paintable);
	G_OBJECT_CLASS (audience_widgets_preview_popover_parent_class)->finalize (obj);
}

static GType
audience_widgets_preview_popover_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (AudienceWidgetsPreviewPopoverClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) audience_widgets_preview_popover_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (AudienceWidgetsPreviewPopover), 0, (GInstanceInitFunc) audience_widgets_preview_popover_instance_init, NULL };
	GType audience_widgets_preview_popover_type_id;
	audience_widgets_preview_popover_type_id = g_type_register_static (gtk_popover_get_type (), "AudienceWidgetsPreviewPopover", &g_define_type_info, 0);
	AudienceWidgetsPreviewPopover_private_offset = g_type_add_instance_private (audience_widgets_preview_popover_type_id, sizeof (AudienceWidgetsPreviewPopoverPrivate));
	return audience_widgets_preview_popover_type_id;
}

GType
audience_widgets_preview_popover_get_type (void)
{
	static volatile gsize audience_widgets_preview_popover_type_id__once = 0;
	if (g_once_init_enter (&audience_widgets_preview_popover_type_id__once)) {
		GType audience_widgets_preview_popover_type_id;
		audience_widgets_preview_popover_type_id = audience_widgets_preview_popover_get_type_once ();
		g_once_init_leave (&audience_widgets_preview_popover_type_id__once, audience_widgets_preview_popover_type_id);
	}
	return audience_widgets_preview_popover_type_id__once;
}

static void
_vala_audience_widgets_preview_popover_get_property (GObject * object,
                                                     guint property_id,
                                                     GValue * value,
                                                     GParamSpec * pspec)
{
	AudienceWidgetsPreviewPopover * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, AUDIENCE_WIDGETS_TYPE_PREVIEW_POPOVER, AudienceWidgetsPreviewPopover);
	switch (property_id) {
		case AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAYBACK_URI_PROPERTY:
		g_value_set_string (value, audience_widgets_preview_popover_get_playback_uri (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_audience_widgets_preview_popover_set_property (GObject * object,
                                                     guint property_id,
                                                     const GValue * value,
                                                     GParamSpec * pspec)
{
	AudienceWidgetsPreviewPopover * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, AUDIENCE_WIDGETS_TYPE_PREVIEW_POPOVER, AudienceWidgetsPreviewPopover);
	switch (property_id) {
		case AUDIENCE_WIDGETS_PREVIEW_POPOVER_PLAYBACK_URI_PROPERTY:
		audience_widgets_preview_popover_set_playback_uri (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

