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

#include <glib-object.h>
#include <gtk/gtk.h>
#include <adwaita.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <float.h>
#include <math.h>
#include <gdk/gdk.h>
#include <gio/gio.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 DC_TYPE_VIDEO_PLAYER (dc_video_player_get_type ())
#define DC_VIDEO_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_VIDEO_PLAYER, DcVideoPlayer))
#define DC_VIDEO_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_VIDEO_PLAYER, DcVideoPlayerClass))
#define DC_IS_VIDEO_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_VIDEO_PLAYER))
#define DC_IS_VIDEO_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_VIDEO_PLAYER))
#define DC_VIDEO_PLAYER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_VIDEO_PLAYER, DcVideoPlayerClass))

typedef struct _DcVideoPlayer DcVideoPlayer;
typedef struct _DcVideoPlayerClass DcVideoPlayerClass;
typedef struct _DcVideoPlayerPrivate DcVideoPlayerPrivate;

#define DC_TYPE_WINDOW (dc_window_get_type ())
#define DC_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_WINDOW, DcWindow))
#define DC_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_WINDOW, DcWindowClass))
#define DC_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_WINDOW))
#define DC_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_WINDOW))
#define DC_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_WINDOW, DcWindowClass))

typedef struct _DcWindow DcWindow;
typedef struct _DcWindowClass DcWindowClass;
enum  {
	DC_VIDEO_PLAYER_0_PROPERTY,
	DC_VIDEO_PLAYER_WIDGET_PROPERTY,
	DC_VIDEO_PLAYER_VISIBLE_PROPERTY,
	DC_VIDEO_PLAYER_NUM_PROPERTIES
};
static GParamSpec* dc_video_player_properties[DC_VIDEO_PLAYER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block28Data Block28Data;

#define DC_TYPE_POPOVER_BUTTON (dc_popover_button_get_type ())
#define DC_POPOVER_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_POPOVER_BUTTON, DcPopoverButton))
#define DC_POPOVER_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_POPOVER_BUTTON, DcPopoverButtonClass))
#define DC_IS_POPOVER_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_POPOVER_BUTTON))
#define DC_IS_POPOVER_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_POPOVER_BUTTON))
#define DC_POPOVER_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_POPOVER_BUTTON, DcPopoverButtonClass))

typedef struct _DcPopoverButton DcPopoverButton;
typedef struct _DcPopoverButtonClass DcPopoverButtonClass;

struct _DcVideoPlayer {
	GObject parent_instance;
	DcVideoPlayerPrivate * priv;
};

struct _DcVideoPlayerClass {
	GObjectClass parent_class;
};

struct _DcVideoPlayerPrivate {
	GtkWidget* _widget;
	DcWindow* window;
	GtkVideo* video;
	gchar* current_path;
	gchar* current_name;
};

struct _Block28Data {
	int _ref_count_;
	DcVideoPlayer* self;
	gchar* path;
	gchar* name;
};

static gint DcVideoPlayer_private_offset;
static gpointer dc_video_player_parent_class = NULL;

VALA_EXTERN GType dc_video_player_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcVideoPlayer, g_object_unref)
VALA_EXTERN GType dc_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcWindow, g_object_unref)
VALA_EXTERN DcVideoPlayer* dc_video_player_new (void);
VALA_EXTERN DcVideoPlayer* dc_video_player_construct (GType object_type);
static void __lambda175_ (DcVideoPlayer* self);
VALA_EXTERN void dc_video_player_hide (DcVideoPlayer* self);
static void ___lambda175__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void dc_video_player_set_widget (DcVideoPlayer* self,
                                 GtkWidget* value);
static void __lambda176_ (DcVideoPlayer* self,
                   gint n,
                   gdouble x,
                   gdouble y);
static void dc_video_player_show_menu (DcVideoPlayer* self,
                                gdouble x,
                                gdouble y);
static void ___lambda176__gtk_gesture_click_pressed (GtkGestureClick* _sender,
                                              gint n_press,
                                              gdouble x,
                                              gdouble y,
                                              gpointer self);
VALA_EXTERN GtkWidget* dc_video_player_get_widget (DcVideoPlayer* self);
VALA_EXTERN void dc_video_player_set_window (DcVideoPlayer* self,
                                 DcWindow* w);
VALA_EXTERN void dc_video_player_show (DcVideoPlayer* self,
                           const gchar* path,
                           const gchar* name);
VALA_EXTERN gboolean dc_video_player_handle_key (DcVideoPlayer* self,
                                     guint keyval);
static Block28Data* block28_data_ref (Block28Data* _data28_);
static void block28_data_unref (void * _userdata_);
VALA_EXTERN GType dc_popover_button_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcPopoverButton, g_object_unref)
VALA_EXTERN DcPopoverButton* dc_popover_button_new (GtkPopover* popover,
                                        const gchar* label,
                                        gboolean destructive,
                                        gboolean hexpand);
VALA_EXTERN DcPopoverButton* dc_popover_button_construct (GType object_type,
                                              GtkPopover* popover,
                                              const gchar* label,
                                              gboolean destructive,
                                              gboolean hexpand);
static void __lambda177_ (Block28Data* _data28_);
VALA_EXTERN void dc_window_save_attachment (DcWindow* self,
                                const gchar* src_path,
                                const gchar* name,
                                GAsyncReadyCallback _callback_,
                                gpointer _user_data_);
VALA_EXTERN void dc_window_save_attachment_finish (DcWindow* self,
                                       GAsyncResult* _res_);
static void ___lambda177__dc_popover_button_selected (DcPopoverButton* _sender,
                                               gpointer self);
VALA_EXTERN void dc_unparent_on_close (GtkPopover* popover);
VALA_EXTERN gboolean dc_video_player_get_visible (DcVideoPlayer* self);
static void dc_video_player_finalize (GObject * obj);
static GType dc_video_player_get_type_once (void);
static void _vala_dc_video_player_get_property (GObject * object,
                                         guint property_id,
                                         GValue * value,
                                         GParamSpec * pspec);
static void _vala_dc_video_player_set_property (GObject * object,
                                         guint property_id,
                                         const GValue * value,
                                         GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
dc_video_player_get_instance_private (DcVideoPlayer* self)
{
	return G_STRUCT_MEMBER_P (self, DcVideoPlayer_private_offset);
}

static void
__lambda175_ (DcVideoPlayer* self)
{
	dc_video_player_hide (self);
}

static void
___lambda175__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda175_ ((DcVideoPlayer*) self);
}

static void
__lambda176_ (DcVideoPlayer* self,
              gint n,
              gdouble x,
              gdouble y)
{
	dc_video_player_show_menu (self, x, y);
}

static void
___lambda176__gtk_gesture_click_pressed (GtkGestureClick* _sender,
                                         gint n_press,
                                         gdouble x,
                                         gdouble y,
                                         gpointer self)
{
	__lambda176_ ((DcVideoPlayer*) self, n_press, x, y);
}

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

DcVideoPlayer*
dc_video_player_construct (GType object_type)
{
	DcVideoPlayer * self = NULL;
	GtkVideo* _tmp0_;
	GtkVideo* _tmp1_;
	GtkVideo* _tmp2_;
	GtkVideo* _tmp3_;
	GtkVideo* _tmp4_;
	GtkVideo* _tmp5_;
	GtkVideo* _tmp6_;
	GtkVideo* _tmp7_;
	GtkVideo* _tmp8_;
	GtkVideo* _tmp9_;
	GtkOverlay* overlay = NULL;
	GtkOverlay* _tmp10_;
	GtkVideo* _tmp11_;
	GtkButton* close_btn = NULL;
	GtkButton* _tmp12_;
	GtkGestureClick* right_click = NULL;
	GtkGestureClick* _tmp13_;
	GtkWidget* _tmp14_;
	GtkEventController* _tmp15_;
	self = (DcVideoPlayer*) g_object_new (object_type, NULL);
	_tmp0_ = (GtkVideo*) gtk_video_new ();
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->video);
	self->priv->video = _tmp0_;
	_tmp1_ = self->priv->video;
	gtk_video_set_autoplay (_tmp1_, TRUE);
	_tmp2_ = self->priv->video;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp2_, TRUE);
	_tmp3_ = self->priv->video;
	gtk_widget_set_vexpand ((GtkWidget*) _tmp3_, TRUE);
	_tmp4_ = self->priv->video;
	gtk_widget_set_halign ((GtkWidget*) _tmp4_, GTK_ALIGN_FILL);
	_tmp5_ = self->priv->video;
	gtk_widget_set_valign ((GtkWidget*) _tmp5_, GTK_ALIGN_FILL);
	_tmp6_ = self->priv->video;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp6_, 24);
	_tmp7_ = self->priv->video;
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp7_, 24);
	_tmp8_ = self->priv->video;
	gtk_widget_set_margin_start ((GtkWidget*) _tmp8_, 24);
	_tmp9_ = self->priv->video;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp9_, 24);
	_tmp10_ = (GtkOverlay*) gtk_overlay_new ();
	g_object_ref_sink (_tmp10_);
	overlay = _tmp10_;
	gtk_widget_add_css_class ((GtkWidget*) overlay, "image-viewer-overlay");
	gtk_widget_set_hexpand ((GtkWidget*) overlay, TRUE);
	gtk_widget_set_vexpand ((GtkWidget*) overlay, TRUE);
	_tmp11_ = self->priv->video;
	gtk_overlay_set_child (overlay, (GtkWidget*) _tmp11_);
	gtk_widget_set_focusable ((GtkWidget*) overlay, TRUE);
	gtk_widget_set_can_focus ((GtkWidget*) overlay, TRUE);
	gtk_widget_set_visible ((GtkWidget*) overlay, FALSE);
	_tmp12_ = (GtkButton*) gtk_button_new ();
	g_object_ref_sink (_tmp12_);
	close_btn = _tmp12_;
	gtk_button_set_icon_name (close_btn, "window-close-symbolic");
	gtk_widget_add_css_class ((GtkWidget*) close_btn, "circular");
	gtk_widget_add_css_class ((GtkWidget*) close_btn, "osd");
	gtk_widget_set_halign ((GtkWidget*) close_btn, GTK_ALIGN_END);
	gtk_widget_set_valign ((GtkWidget*) close_btn, GTK_ALIGN_START);
	gtk_widget_set_margin_top ((GtkWidget*) close_btn, 12);
	gtk_widget_set_margin_end ((GtkWidget*) close_btn, 12);
	g_signal_connect_object (close_btn, "clicked", (GCallback) ___lambda175__gtk_button_clicked, self, 0);
	gtk_overlay_add_overlay (overlay, (GtkWidget*) close_btn);
	dc_video_player_set_widget (self, (GtkWidget*) overlay);
	_tmp13_ = (GtkGestureClick*) gtk_gesture_click_new ();
	right_click = _tmp13_;
	gtk_gesture_single_set_button ((GtkGestureSingle*) right_click, (guint) 3);
	g_signal_connect_object (right_click, "pressed", (GCallback) ___lambda176__gtk_gesture_click_pressed, self, 0);
	_tmp14_ = self->priv->_widget;
	_tmp15_ = _g_object_ref0 ((GtkEventController*) right_click);
	gtk_widget_add_controller (_tmp14_, _tmp15_);
	_g_object_unref0 (right_click);
	_g_object_unref0 (close_btn);
	_g_object_unref0 (overlay);
	return self;
}

DcVideoPlayer*
dc_video_player_new (void)
{
	return dc_video_player_construct (DC_TYPE_VIDEO_PLAYER);
}

void
dc_video_player_set_window (DcVideoPlayer* self,
                            DcWindow* w)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (w != NULL);
	self->priv->window = w;
}

void
dc_video_player_show (DcVideoPlayer* self,
                      const gchar* path,
                      const gchar* name)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	GtkVideo* _tmp2_;
	GtkWidget* _tmp3_;
	GtkWidget* _tmp4_;
	GtkMediaStream* ms = NULL;
	GtkVideo* _tmp5_;
	GtkMediaStream* _tmp6_;
	GtkMediaStream* _tmp7_;
	GtkMediaStream* _tmp8_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (path != NULL);
	_tmp0_ = g_strdup (path);
	_g_free0 (self->priv->current_path);
	self->priv->current_path = _tmp0_;
	_tmp1_ = g_strdup (name);
	_g_free0 (self->priv->current_name);
	self->priv->current_name = _tmp1_;
	_tmp2_ = self->priv->video;
	gtk_video_set_filename (_tmp2_, path);
	_tmp3_ = self->priv->_widget;
	gtk_widget_set_visible (_tmp3_, TRUE);
	_tmp4_ = self->priv->_widget;
	gtk_widget_grab_focus (_tmp4_);
	_tmp5_ = self->priv->video;
	_tmp6_ = gtk_video_get_media_stream (_tmp5_);
	_tmp7_ = _g_object_ref0 (_tmp6_);
	ms = _tmp7_;
	_tmp8_ = ms;
	if (_tmp8_ != NULL) {
		GtkMediaStream* _tmp9_;
		_tmp9_ = ms;
		G_TYPE_INSTANCE_GET_CLASS (_tmp9_, gtk_media_stream_get_type (), GtkMediaStreamClass)->play (_tmp9_);
	}
	_g_object_unref0 (ms);
}

void
dc_video_player_hide (DcVideoPlayer* self)
{
	GtkMediaStream* ms = NULL;
	GtkVideo* _tmp0_;
	GtkMediaStream* _tmp1_;
	GtkMediaStream* _tmp2_;
	GtkMediaStream* _tmp3_;
	GtkVideo* _tmp5_;
	GtkWidget* _tmp6_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->video;
	_tmp1_ = gtk_video_get_media_stream (_tmp0_);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	ms = _tmp2_;
	_tmp3_ = ms;
	if (_tmp3_ != NULL) {
		GtkMediaStream* _tmp4_;
		_tmp4_ = ms;
		gtk_media_stream_pause (_tmp4_);
	}
	_tmp5_ = self->priv->video;
	gtk_video_set_media_stream (_tmp5_, NULL);
	_tmp6_ = self->priv->_widget;
	gtk_widget_set_visible (_tmp6_, FALSE);
	_g_free0 (self->priv->current_path);
	self->priv->current_path = NULL;
	_g_free0 (self->priv->current_name);
	self->priv->current_name = NULL;
	_g_object_unref0 (ms);
}

/**
         * Called by Window's key handler while the player is visible. Escape
         * (or q) closes; space toggles play/pause. Any other key is swallowed
         * so conversation shortcuts don't fire behind the overlay.
         */
gboolean
dc_video_player_handle_key (DcVideoPlayer* self,
                            guint keyval)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	switch (keyval) {
		case GDK_KEY_Escape:
		case GDK_KEY_q:
		case GDK_KEY_Q:
		{
			dc_video_player_hide (self);
			result = TRUE;
			return result;
		}
		case GDK_KEY_space:
		{
			GtkMediaStream* ms = NULL;
			GtkVideo* _tmp0_;
			GtkMediaStream* _tmp1_;
			GtkMediaStream* _tmp2_;
			GtkMediaStream* _tmp3_;
			_tmp0_ = self->priv->video;
			_tmp1_ = gtk_video_get_media_stream (_tmp0_);
			_tmp2_ = _g_object_ref0 (_tmp1_);
			ms = _tmp2_;
			_tmp3_ = ms;
			if (_tmp3_ != NULL) {
				GtkMediaStream* _tmp4_;
				gboolean _tmp5_;
				gboolean _tmp6_;
				_tmp4_ = ms;
				_tmp5_ = gtk_media_stream_get_playing (_tmp4_);
				_tmp6_ = _tmp5_;
				if (_tmp6_) {
					GtkMediaStream* _tmp7_;
					_tmp7_ = ms;
					gtk_media_stream_pause (_tmp7_);
				} else {
					GtkMediaStream* _tmp8_;
					_tmp8_ = ms;
					G_TYPE_INSTANCE_GET_CLASS (_tmp8_, gtk_media_stream_get_type (), GtkMediaStreamClass)->play (_tmp8_);
				}
			}
			result = TRUE;
			_g_object_unref0 (ms);
			return result;
		}
		default:
		break;
	}
	result = TRUE;
	return result;
}

static Block28Data*
block28_data_ref (Block28Data* _data28_)
{
	g_atomic_int_inc (&_data28_->_ref_count_);
	return _data28_;
}

static void
block28_data_unref (void * _userdata_)
{
	Block28Data* _data28_;
	_data28_ = (Block28Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data28_->_ref_count_)) {
		DcVideoPlayer* self;
		self = _data28_->self;
		_g_free0 (_data28_->name);
		_g_free0 (_data28_->path);
		_g_object_unref0 (self);
		g_slice_free (Block28Data, _data28_);
	}
}

static void
__lambda177_ (Block28Data* _data28_)
{
	DcVideoPlayer* self;
	DcWindow* _tmp0_;
	self = _data28_->self;
	_tmp0_ = self->priv->window;
	if (_tmp0_ != NULL) {
		gchar* _tmp1_ = NULL;
		const gchar* _tmp2_;
		gchar* _tmp3_;
		DcWindow* _tmp6_;
		const gchar* _tmp7_;
		_tmp2_ = _data28_->name;
		_tmp3_ = g_strdup (_tmp2_);
		_tmp1_ = _tmp3_;
		if (_tmp1_ == NULL) {
			const gchar* _tmp4_;
			gchar* _tmp5_;
			_tmp4_ = _data28_->path;
			_tmp5_ = g_path_get_basename (_tmp4_);
			_g_free0 (_tmp1_);
			_tmp1_ = _tmp5_;
		}
		_tmp6_ = self->priv->window;
		_tmp7_ = _data28_->path;
		dc_window_save_attachment (_tmp6_, _tmp7_, _tmp1_, NULL, NULL);
		_g_free0 (_tmp1_);
	}
}

static void
___lambda177__dc_popover_button_selected (DcPopoverButton* _sender,
                                          gpointer self)
{
	__lambda177_ (self);
}

static void
dc_video_player_show_menu (DcVideoPlayer* self,
                           gdouble x,
                           gdouble y)
{
	Block28Data* _data28_;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	GtkPopover* popover = NULL;
	GtkPopover* _tmp5_;
	GtkBox* vbox = NULL;
	GtkBox* _tmp6_;
	GtkBox* _tmp7_;
	GtkBox* _tmp8_;
	GtkBox* _tmp9_;
	GtkBox* _tmp10_;
	DcPopoverButton* save_btn = NULL;
	GtkPopover* _tmp11_;
	DcPopoverButton* _tmp12_;
	DcPopoverButton* _tmp13_;
	GtkBox* _tmp14_;
	DcPopoverButton* _tmp15_;
	GtkPopover* _tmp16_;
	GtkBox* _tmp17_;
	GtkPopover* _tmp18_;
	GtkWidget* _tmp19_;
	GtkPopover* _tmp20_;
	GdkRectangle _tmp21_ = {0};
	GtkPopover* _tmp22_;
	GtkPopover* _tmp23_;
	g_return_if_fail (self != NULL);
	_data28_ = g_slice_new0 (Block28Data);
	_data28_->_ref_count_ = 1;
	_data28_->self = g_object_ref (self);
	_tmp0_ = self->priv->current_path;
	if (_tmp0_ == NULL) {
		block28_data_unref (_data28_);
		_data28_ = NULL;
		return;
	}
	_tmp1_ = self->priv->current_path;
	_tmp2_ = g_strdup (_tmp1_);
	_data28_->path = _tmp2_;
	_tmp3_ = self->priv->current_name;
	_tmp4_ = g_strdup (_tmp3_);
	_data28_->name = _tmp4_;
	_tmp5_ = (GtkPopover*) gtk_popover_new ();
	g_object_ref_sink (_tmp5_);
	popover = _tmp5_;
	_tmp6_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
	g_object_ref_sink (_tmp6_);
	vbox = _tmp6_;
	_tmp7_ = vbox;
	gtk_widget_set_margin_start ((GtkWidget*) _tmp7_, 4);
	_tmp8_ = vbox;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp8_, 4);
	_tmp9_ = vbox;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp9_, 4);
	_tmp10_ = vbox;
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp10_, 4);
	_tmp11_ = popover;
	_tmp12_ = dc_popover_button_new (_tmp11_, "Save video", FALSE, FALSE);
	g_object_ref_sink (_tmp12_);
	save_btn = _tmp12_;
	_tmp13_ = save_btn;
	g_signal_connect_data (_tmp13_, "selected", (GCallback) ___lambda177__dc_popover_button_selected, block28_data_ref (_data28_), (GClosureNotify) block28_data_unref, 0);
	_tmp14_ = vbox;
	_tmp15_ = save_btn;
	gtk_box_append (_tmp14_, (GtkWidget*) _tmp15_);
	_tmp16_ = popover;
	_tmp17_ = vbox;
	gtk_popover_set_child (_tmp16_, (GtkWidget*) _tmp17_);
	_tmp18_ = popover;
	_tmp19_ = self->priv->_widget;
	gtk_widget_set_parent ((GtkWidget*) _tmp18_, _tmp19_);
	_tmp20_ = popover;
	_tmp21_.x = (gint) x;
	_tmp21_.y = (gint) y;
	_tmp21_.width = 1;
	_tmp21_.height = 1;
	gtk_popover_set_pointing_to (_tmp20_, &_tmp21_);
	_tmp22_ = popover;
	dc_unparent_on_close (_tmp22_);
	_tmp23_ = popover;
	gtk_popover_popup (_tmp23_);
	_g_object_unref0 (save_btn);
	_g_object_unref0 (vbox);
	_g_object_unref0 (popover);
	block28_data_unref (_data28_);
	_data28_ = NULL;
}

GtkWidget*
dc_video_player_get_widget (DcVideoPlayer* self)
{
	GtkWidget* result;
	GtkWidget* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_widget;
	result = _tmp0_;
	return result;
}

static void
dc_video_player_set_widget (DcVideoPlayer* self,
                            GtkWidget* value)
{
	GtkWidget* old_value;
	g_return_if_fail (self != NULL);
	old_value = dc_video_player_get_widget (self);
	if (old_value != value) {
		GtkWidget* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_widget);
		self->priv->_widget = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, dc_video_player_properties[DC_VIDEO_PLAYER_WIDGET_PROPERTY]);
	}
}

gboolean
dc_video_player_get_visible (DcVideoPlayer* self)
{
	gboolean result;
	GtkWidget* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->_widget;
	_tmp1_ = gtk_widget_get_visible (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

static void
dc_video_player_class_init (DcVideoPlayerClass * klass,
                            gpointer klass_data)
{
	dc_video_player_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcVideoPlayer_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dc_video_player_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_dc_video_player_set_property;
	G_OBJECT_CLASS (klass)->finalize = dc_video_player_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DC_VIDEO_PLAYER_WIDGET_PROPERTY, dc_video_player_properties[DC_VIDEO_PLAYER_WIDGET_PROPERTY] = g_param_spec_object ("widget", "widget", "widget", gtk_widget_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DC_VIDEO_PLAYER_VISIBLE_PROPERTY, dc_video_player_properties[DC_VIDEO_PLAYER_VISIBLE_PROPERTY] = g_param_spec_boolean ("visible", "visible", "visible", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
dc_video_player_instance_init (DcVideoPlayer * self,
                               gpointer klass)
{
	self->priv = dc_video_player_get_instance_private (self);
	self->priv->window = NULL;
	self->priv->current_path = NULL;
	self->priv->current_name = NULL;
}

static void
dc_video_player_finalize (GObject * obj)
{
	DcVideoPlayer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_VIDEO_PLAYER, DcVideoPlayer);
	_g_object_unref0 (self->priv->_widget);
	_g_object_unref0 (self->priv->video);
	_g_free0 (self->priv->current_path);
	_g_free0 (self->priv->current_name);
	G_OBJECT_CLASS (dc_video_player_parent_class)->finalize (obj);
}

/**
     * Fullscreen video overlay shown on top of the conversation, mirroring
     * ImageViewer. Plays the file with Gtk.Video's built-in controls; Escape
     * or the close button dismisses it, and right-click offers "Save video".
     */
static GType
dc_video_player_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcVideoPlayerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_video_player_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcVideoPlayer), 0, (GInstanceInitFunc) dc_video_player_instance_init, NULL };
	GType dc_video_player_type_id;
	dc_video_player_type_id = g_type_register_static (G_TYPE_OBJECT, "DcVideoPlayer", &g_define_type_info, 0);
	DcVideoPlayer_private_offset = g_type_add_instance_private (dc_video_player_type_id, sizeof (DcVideoPlayerPrivate));
	return dc_video_player_type_id;
}

GType
dc_video_player_get_type (void)
{
	static volatile gsize dc_video_player_type_id__once = 0;
	if (g_once_init_enter (&dc_video_player_type_id__once)) {
		GType dc_video_player_type_id;
		dc_video_player_type_id = dc_video_player_get_type_once ();
		g_once_init_leave (&dc_video_player_type_id__once, dc_video_player_type_id);
	}
	return dc_video_player_type_id__once;
}

static void
_vala_dc_video_player_get_property (GObject * object,
                                    guint property_id,
                                    GValue * value,
                                    GParamSpec * pspec)
{
	DcVideoPlayer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DC_TYPE_VIDEO_PLAYER, DcVideoPlayer);
	switch (property_id) {
		case DC_VIDEO_PLAYER_WIDGET_PROPERTY:
		g_value_set_object (value, dc_video_player_get_widget (self));
		break;
		case DC_VIDEO_PLAYER_VISIBLE_PROPERTY:
		g_value_set_boolean (value, dc_video_player_get_visible (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_dc_video_player_set_property (GObject * object,
                                    guint property_id,
                                    const GValue * value,
                                    GParamSpec * pspec)
{
	DcVideoPlayer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DC_TYPE_VIDEO_PLAYER, DcVideoPlayer);
	switch (property_id) {
		case DC_VIDEO_PLAYER_WIDGET_PROPERTY:
		dc_video_player_set_widget (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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;
}

