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

/*
 * Copyright (C) 2018 Elias Entrup <elias-git@flump.de>
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#include <adwaita.h>
#include <glib-object.h>
#include <cc-crop-area.h>
#include <gdk/gdk.h>
#include <glib.h>
#include <libportal/portal.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <gst/gst.h>
#include <libportal-gtk4/portal-gtk4.h>
#include <stdlib.h>
#include <string.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 CONTACTS_TYPE_CROP_DIALOG (contacts_crop_dialog_get_type ())
#define CONTACTS_CROP_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONTACTS_TYPE_CROP_DIALOG, ContactsCropDialog))
#define CONTACTS_CROP_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONTACTS_TYPE_CROP_DIALOG, ContactsCropDialogClass))
#define CONTACTS_IS_CROP_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONTACTS_TYPE_CROP_DIALOG))
#define CONTACTS_IS_CROP_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONTACTS_TYPE_CROP_DIALOG))
#define CONTACTS_CROP_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONTACTS_TYPE_CROP_DIALOG, ContactsCropDialogClass))

typedef struct _ContactsCropDialog ContactsCropDialog;
typedef struct _ContactsCropDialogClass ContactsCropDialogClass;
typedef struct _ContactsCropDialogPrivate ContactsCropDialogPrivate;
enum  {
	CONTACTS_CROP_DIALOG_0_PROPERTY,
	CONTACTS_CROP_DIALOG_NUM_PROPERTIES
};
static GParamSpec* contacts_crop_dialog_properties[CONTACTS_CROP_DIALOG_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block24Data Block24Data;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define __vala_XdpParent_free0(var) ((var == NULL) ? NULL : (var = (_vala_XdpParent_free (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _ContactsCropDialogDoCameraData ContactsCropDialogDoCameraData;
enum  {
	CONTACTS_CROP_DIALOG_CROPPED_SIGNAL,
	CONTACTS_CROP_DIALOG_NUM_SIGNALS
};
static guint contacts_crop_dialog_signals[CONTACTS_CROP_DIALOG_NUM_SIGNALS] = {0};

struct _ContactsCropDialog {
	AdwDialog parent_instance;
	ContactsCropDialogPrivate * priv;
};

struct _ContactsCropDialogClass {
	AdwDialogClass parent_class;
};

struct _ContactsCropDialogPrivate {
	CcCropArea* crop_area;
};

struct _Block24Data {
	int _ref_count_;
	ContactsCropDialog* self;
	GstPipeline* pipeline;
	gpointer _async_data_;
};

struct _ContactsCropDialogDoCameraData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ContactsCropDialog* self;
	XdpPortal* portal;
	GtkWindow* parent_window;
	Block24Data* _data24_;
	XdpParent* parent;
	XdpParent* _tmp0_;
	XdpParent* _tmp1_;
	GError* err;
	GError* _tmp2_;
	const gchar* _tmp3_;
	gint pw_fd;
	GstPipeline* _tmp4_;
	GstElement* source;
	GstElement* _tmp5_;
	GstElement* queue;
	GstElement* _tmp6_;
	GstElement* paintable_sink;
	GstElement* _tmp7_;
	gboolean _tmp8_;
	gboolean _tmp9_;
	GstElement* _tmp10_;
	GstElement* _tmp11_;
	GstElement* _tmp12_;
	GValue paintable_value;
	GValue _tmp13_;
	GstElement* _tmp14_;
	GdkPaintable* paintable;
	GValue _tmp15_;
	GdkPaintable* _tmp16_;
	GValue gl_context_value;
	GValue _tmp17_;
	GdkPaintable* _tmp18_;
	GdkGLContext* gl_context;
	GValue _tmp19_;
	GdkGLContext* _tmp20_;
	gboolean is_gl_supported;
	GdkGLContext* _tmp21_;
	GstElement* sink;
	GstElement* glsinkbin;
	GstElement* _tmp22_;
	GstElement* _tmp23_;
	GstElement* _tmp24_;
	GstElement* _tmp25_;
	GValue _tmp26_;
	GstElement* _tmp27_;
	GstElement* _tmp28_;
	GstBin* bin;
	GstBin* _tmp29_;
	GstElement* convert;
	GstElement* _tmp30_;
	GstElement* _tmp31_;
	GstBin* _tmp32_;
	GstElement* _tmp33_;
	GstElement* _tmp34_;
	GstElement* _tmp35_;
	GstElement* _tmp36_;
	GstGhostPad* ghost_pad;
	GstElement* _tmp37_;
	GstPad* _tmp38_;
	GstPad* _tmp39_;
	GstGhostPad* _tmp40_;
	GstGhostPad* _tmp41_;
	GstBin* _tmp42_;
	GstGhostPad* _tmp43_;
	GstBin* _tmp44_;
	GstElement* _tmp45_;
	GstPipeline* _tmp46_;
	GstElement* _tmp47_;
	GstElement* _tmp48_;
	GstElement* _tmp49_;
	GstElement* _tmp50_;
	GstElement* _tmp51_;
	GstElement* _tmp52_;
	CcCropArea* _tmp53_;
	GdkPaintable* _tmp54_;
	GstElement* _tmp55_;
	GValue _tmp56_;
	GstPipeline* _tmp57_;
	GstBus* bus;
	GstPipeline* _tmp58_;
	GstBus* _tmp59_;
	GstBus* _tmp60_;
	GstBus* _tmp61_;
	GError* _inner_error0_;
};

static gint ContactsCropDialog_private_offset;
static gpointer contacts_crop_dialog_parent_class = NULL;

VALA_EXTERN GType contacts_crop_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ContactsCropDialog, g_object_unref)
VALA_EXTERN ContactsCropDialog* contacts_crop_dialog_new_for_paintable (GdkPaintable* paintable);
VALA_EXTERN ContactsCropDialog* contacts_crop_dialog_construct_for_paintable (GType object_type,
                                                                  GdkPaintable* paintable);
VALA_EXTERN ContactsCropDialog* contacts_crop_dialog_new_for_portal (XdpPortal* portal,
                                                         GtkWindow* parent);
VALA_EXTERN ContactsCropDialog* contacts_crop_dialog_construct_for_portal (GType object_type,
                                                               XdpPortal* portal,
                                                               GtkWindow* parent);
static void contacts_crop_dialog_do_camera (ContactsCropDialog* self,
                                     XdpPortal* portal,
                                     GtkWindow* parent_window,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_);
static void contacts_crop_dialog_do_camera_finish (ContactsCropDialog* self,
                                            GAsyncResult* _res_);
static void __lambda21_ (ContactsCropDialog* self,
                  GObject* obj,
                  GAsyncResult* res);
static void ___lambda21__gasync_ready_callback (GObject* source_object,
                                         GAsyncResult* res,
                                         gpointer self);
static void contacts_crop_dialog_do_camera_data_free (gpointer _data);
static gboolean contacts_crop_dialog_do_camera_co (ContactsCropDialogDoCameraData* _data_);
static Block24Data* block24_data_ref (Block24Data* _data24_);
static void block24_data_unref (void * _userdata_);
static void contacts_crop_dialog_do_camera_ready (GObject* source_object,
                                           GAsyncResult* _res_,
                                           gpointer _user_data_);
static void _vala_XdpParent_free (XdpParent* self);
static void __lambda19_ (Block24Data* _data24_);
static void ___lambda19__adw_dialog_closed (AdwDialog* _sender,
                                     gpointer self);
static void __lambda20_ (ContactsCropDialog* self,
                  GstBus* bus,
                  GstMessage* message);
static void ___lambda20__gst_bus_message (GstBus* _sender,
                                   GstMessage* message,
                                   gpointer self);
static void contacts_crop_dialog_on_crop (ContactsCropDialog* self,
                                   const gchar* action_name,
                                   GVariant* param);
VALA_EXTERN ContactsCropDialog* contacts_crop_dialog_new (void);
VALA_EXTERN ContactsCropDialog* contacts_crop_dialog_construct (GType object_type);
static GObject * contacts_crop_dialog_constructor (GType type,
                                            guint n_construct_properties,
                                            GObjectConstructParam * construct_properties);
static void contacts_crop_dialog_finalize (GObject * obj);
static GType contacts_crop_dialog_get_type_once (void);

static inline gpointer
contacts_crop_dialog_get_instance_private (ContactsCropDialog* self)
{
	return G_STRUCT_MEMBER_P (self, ContactsCropDialog_private_offset);
}

ContactsCropDialog*
contacts_crop_dialog_construct_for_paintable (GType object_type,
                                              GdkPaintable* paintable)
{
	ContactsCropDialog * self = NULL;
	CcCropArea* _tmp0_;
	g_return_val_if_fail (paintable != NULL, NULL);
	self = (ContactsCropDialog*) g_object_new (object_type, NULL);
	_tmp0_ = self->priv->crop_area;
	cc_crop_area_set_paintable (_tmp0_, paintable);
	return self;
}

ContactsCropDialog*
contacts_crop_dialog_new_for_paintable (GdkPaintable* paintable)
{
	return contacts_crop_dialog_construct_for_paintable (CONTACTS_TYPE_CROP_DIALOG, paintable);
}

static void
__lambda21_ (ContactsCropDialog* self,
             GObject* obj,
             GAsyncResult* res)
{
	g_return_if_fail (res != NULL);
	contacts_crop_dialog_do_camera_finish (self, res);
}

static void
___lambda21__gasync_ready_callback (GObject* source_object,
                                    GAsyncResult* res,
                                    gpointer self)
{
	__lambda21_ ((ContactsCropDialog*) self, source_object, res);
	g_object_unref (self);
}

ContactsCropDialog*
contacts_crop_dialog_construct_for_portal (GType object_type,
                                           XdpPortal* portal,
                                           GtkWindow* parent)
{
	ContactsCropDialog * self = NULL;
	g_return_val_if_fail (portal != NULL, NULL);
	self = (ContactsCropDialog*) g_object_new (object_type, NULL);
	contacts_crop_dialog_do_camera (self, portal, parent, ___lambda21__gasync_ready_callback, g_object_ref (self));
	return self;
}

ContactsCropDialog*
contacts_crop_dialog_new_for_portal (XdpPortal* portal,
                                     GtkWindow* parent)
{
	return contacts_crop_dialog_construct_for_portal (CONTACTS_TYPE_CROP_DIALOG, portal, parent);
}

static void
contacts_crop_dialog_do_camera_data_free (gpointer _data)
{
	ContactsCropDialogDoCameraData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->portal);
	_g_object_unref0 (_data_->parent_window);
	_g_object_unref0 (_data_->self);
	g_slice_free (ContactsCropDialogDoCameraData, _data_);
}

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

static void
contacts_crop_dialog_do_camera (ContactsCropDialog* self,
                                XdpPortal* portal,
                                GtkWindow* parent_window,
                                GAsyncReadyCallback _callback_,
                                gpointer _user_data_)
{
	ContactsCropDialogDoCameraData* _data_;
	ContactsCropDialog* _tmp0_;
	XdpPortal* _tmp1_;
	GtkWindow* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (portal != NULL);
	_data_ = g_slice_new0 (ContactsCropDialogDoCameraData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, contacts_crop_dialog_do_camera_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (portal);
	_g_object_unref0 (_data_->portal);
	_data_->portal = _tmp1_;
	_tmp2_ = _g_object_ref0 (parent_window);
	_g_object_unref0 (_data_->parent_window);
	_data_->parent_window = _tmp2_;
	contacts_crop_dialog_do_camera_co (_data_);
}

static void
contacts_crop_dialog_do_camera_finish (ContactsCropDialog* self,
                                       GAsyncResult* _res_)
{
	ContactsCropDialogDoCameraData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static Block24Data*
block24_data_ref (Block24Data* _data24_)
{
	g_atomic_int_inc (&_data24_->_ref_count_);
	return _data24_;
}

static void
block24_data_unref (void * _userdata_)
{
	Block24Data* _data24_;
	_data24_ = (Block24Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data24_->_ref_count_)) {
		ContactsCropDialog* self;
		self = _data24_->self;
		_g_object_unref0 (_data24_->pipeline);
		_g_object_unref0 (self);
		g_slice_free (Block24Data, _data24_);
	}
}

static void
contacts_crop_dialog_do_camera_ready (GObject* source_object,
                                      GAsyncResult* _res_,
                                      gpointer _user_data_)
{
	ContactsCropDialogDoCameraData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	contacts_crop_dialog_do_camera_co (_data_);
}

static void
_vala_XdpParent_free (XdpParent* self)
{
	g_boxed_free (xdp_parent_get_type (), self);
}

static void
__lambda19_ (Block24Data* _data24_)
{
	ContactsCropDialog* self;
	GstPipeline* _tmp0_;
	self = _data24_->self;
	_tmp0_ = _data24_->pipeline;
	gst_element_set_state ((GstElement*) _tmp0_, GST_STATE_NULL);
}

static void
___lambda19__adw_dialog_closed (AdwDialog* _sender,
                                gpointer self)
{
	__lambda19_ (self);
}

static void
__lambda20_ (ContactsCropDialog* self,
             GstBus* bus,
             GstMessage* message)
{
	g_return_if_fail (bus != NULL);
	g_return_if_fail (message != NULL);
	if (message->type == GST_MESSAGE_ERROR) {
		GError* err = NULL;
		gchar* debug = NULL;
		GError* _tmp0_ = NULL;
		gchar* _tmp1_ = NULL;
		GError* _tmp2_;
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		gst_message_parse_error (message, &_tmp0_, &_tmp1_);
		_g_error_free0 (err);
		err = _tmp0_;
		_g_free0 (debug);
		debug = _tmp1_;
		_tmp2_ = err;
		_tmp3_ = _tmp2_->message;
		_tmp4_ = debug;
		g_warning ("contacts-crop-dialog.vala:122: GStreamer error: %s. %s", _tmp3_, _tmp4_);
		_g_free0 (debug);
		_g_error_free0 (err);
	} else {
		if (message->type == GST_MESSAGE_EOS) {
			g_warning ("contacts-crop-dialog.vala:124: EOS");
		}
	}
}

static void
___lambda20__gst_bus_message (GstBus* _sender,
                              GstMessage* message,
                              gpointer self)
{
	__lambda20_ ((ContactsCropDialog*) self, _sender, message);
}

static gboolean
contacts_crop_dialog_do_camera_co (ContactsCropDialogDoCameraData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_data24_ = g_slice_new0 (Block24Data);
	_data_->_data24_->_ref_count_ = 1;
	_data_->_data24_->self = g_object_ref (_data_->self);
	_data_->_data24_->_async_data_ = _data_;
	_data_->_tmp0_ = xdp_parent_new_gtk (_data_->parent_window);
	_data_->parent = _data_->_tmp0_;
	{
		g_debug ("contacts-crop-dialog.vala:38: Requesting camera access");
		_data_->_tmp1_ = _data_->parent;
		_data_->_state_ = 1;
		xdp_portal_access_camera (_data_->portal, _data_->_tmp1_, XDP_CAMERA_FLAG_NONE, NULL, contacts_crop_dialog_do_camera_ready, _data_);
		return FALSE;
		_state_1:
		xdp_portal_access_camera_finish (_data_->portal, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		g_debug ("contacts-crop-dialog.vala:40: Camera access success");
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->err = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp2_ = _data_->err;
		_data_->_tmp3_ = _data_->_tmp2_->message;
		g_warning ("contacts-crop-dialog.vala:42: Couldn't access camera: %s", _data_->_tmp3_);
		_g_error_free0 (_data_->err);
		__vala_XdpParent_free0 (_data_->parent);
		block24_data_unref (_data_->_data24_);
		_data_->_data24_ = NULL;
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		__vala_XdpParent_free0 (_data_->parent);
		block24_data_unref (_data_->_data24_);
		_data_->_data24_ = NULL;
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->pw_fd = xdp_portal_open_pipewire_remote_for_camera (_data_->portal);
	g_debug ("contacts-crop-dialog.vala:47: Got Pipewire fd %d", _data_->pw_fd);
	_data_->_tmp4_ = (GstPipeline*) gst_pipeline_new (NULL);
	g_object_ref_sink (_data_->_tmp4_);
	_data_->_data24_->pipeline = _data_->_tmp4_;
	_data_->_tmp5_ = gst_element_factory_make ("pipewiresrc", NULL);
	if (_data_->_tmp5_ != NULL) {
		g_object_ref_sink (_data_->_tmp5_);
	}
	_data_->source = _data_->_tmp5_;
	_data_->_tmp6_ = gst_element_factory_make ("queue", NULL);
	if (_data_->_tmp6_ != NULL) {
		g_object_ref_sink (_data_->_tmp6_);
	}
	_data_->queue = _data_->_tmp6_;
	_data_->_tmp7_ = gst_element_factory_make ("gtk4paintablesink", NULL);
	if (_data_->_tmp7_ != NULL) {
		g_object_ref_sink (_data_->_tmp7_);
	}
	_data_->paintable_sink = _data_->_tmp7_;
	_data_->_tmp10_ = _data_->source;
	if (_data_->_tmp10_ == NULL) {
		_data_->_tmp9_ = TRUE;
	} else {
		_data_->_tmp11_ = _data_->queue;
		_data_->_tmp9_ = _data_->_tmp11_ == NULL;
	}
	if (_data_->_tmp9_) {
		_data_->_tmp8_ = TRUE;
	} else {
		_data_->_tmp12_ = _data_->paintable_sink;
		_data_->_tmp8_ = _data_->_tmp12_ == NULL;
	}
	if (_data_->_tmp8_) {
		g_warning ("contacts-crop-dialog.vala:56: Your GStreamer installation is missing s" \
"ome required elements");
		_g_object_unref0 (_data_->paintable_sink);
		_g_object_unref0 (_data_->queue);
		_g_object_unref0 (_data_->source);
		__vala_XdpParent_free0 (_data_->parent);
		block24_data_unref (_data_->_data24_);
		_data_->_data24_ = NULL;
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	memset (&_data_->_tmp13_, 0, sizeof (GValue));
	g_value_init (&_data_->_tmp13_, gdk_paintable_get_type ());
	_data_->paintable_value = _data_->_tmp13_;
	_data_->_tmp14_ = _data_->paintable_sink;
	g_object_get_property ((GObject*) _data_->_tmp14_, "paintable", &_data_->paintable_value);
	_data_->_tmp15_ = _data_->paintable_value;
	_data_->_tmp16_ = _g_object_ref0 (g_value_get_object (&_data_->_tmp15_));
	_data_->paintable = _data_->_tmp16_;
	memset (&_data_->_tmp17_, 0, sizeof (GValue));
	g_value_init (&_data_->_tmp17_, gdk_gl_context_get_type ());
	_data_->gl_context_value = _data_->_tmp17_;
	_data_->_tmp18_ = _data_->paintable;
	g_object_get_property ((GObject*) _data_->_tmp18_, "gl-context", &_data_->gl_context_value);
	_data_->_tmp19_ = _data_->gl_context_value;
	_data_->_tmp20_ = _g_object_ref0 (g_value_get_object (&_data_->_tmp19_));
	_data_->gl_context = _data_->_tmp20_;
	_data_->_tmp21_ = _data_->gl_context;
	_data_->is_gl_supported = _data_->_tmp21_ != NULL;
	if (_data_->is_gl_supported) {
		_data_->_tmp22_ = gst_element_factory_make ("glsinkbin", NULL);
		if (_data_->_tmp22_ != NULL) {
			g_object_ref_sink (_data_->_tmp22_);
		}
		_data_->glsinkbin = _data_->_tmp22_;
		_data_->_tmp23_ = _data_->glsinkbin;
		if (_data_->_tmp23_ == NULL) {
			g_warning ("contacts-crop-dialog.vala:76: Your GStreamer installation is missing t" \
"he glsinkbin element");
			_g_object_unref0 (_data_->glsinkbin);
			_g_object_unref0 (_data_->sink);
			_g_object_unref0 (_data_->gl_context);
			G_IS_VALUE (&_data_->gl_context_value) ? (g_value_unset (&_data_->gl_context_value), NULL) : NULL;
			_g_object_unref0 (_data_->paintable);
			G_IS_VALUE (&_data_->paintable_value) ? (g_value_unset (&_data_->paintable_value), NULL) : NULL;
			_g_object_unref0 (_data_->paintable_sink);
			_g_object_unref0 (_data_->queue);
			_g_object_unref0 (_data_->source);
			__vala_XdpParent_free0 (_data_->parent);
			block24_data_unref (_data_->_data24_);
			_data_->_data24_ = NULL;
			g_task_return_pointer (_data_->_async_result, _data_, NULL);
			if (_data_->_state_ != 0) {
				while (!g_task_get_completed (_data_->_async_result)) {
					g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
				}
			}
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_tmp24_ = _data_->glsinkbin;
		_data_->_tmp25_ = _data_->paintable_sink;
		memset (&_data_->_tmp26_, 0, sizeof (GValue));
		g_value_init (&_data_->_tmp26_, gst_element_get_type ());
		g_value_set_object (&_data_->_tmp26_, _data_->_tmp25_);
		g_object_set_property ((GObject*) _data_->_tmp24_, "sink", &_data_->_tmp26_);
		G_IS_VALUE (&_data_->_tmp26_) ? (g_value_unset (&_data_->_tmp26_), NULL) : NULL;
		_data_->_tmp27_ = _data_->glsinkbin;
		_data_->_tmp28_ = _g_object_ref0 (_data_->_tmp27_);
		_g_object_unref0 (_data_->sink);
		_data_->sink = _data_->_tmp28_;
		_g_object_unref0 (_data_->glsinkbin);
	} else {
		_data_->_tmp29_ = (GstBin*) gst_bin_new (NULL);
		g_object_ref_sink (_data_->_tmp29_);
		_data_->bin = _data_->_tmp29_;
		_data_->_tmp30_ = gst_element_factory_make ("videoconvert", NULL);
		if (_data_->_tmp30_ != NULL) {
			g_object_ref_sink (_data_->_tmp30_);
		}
		_data_->convert = _data_->_tmp30_;
		_data_->_tmp31_ = _data_->convert;
		if (_data_->_tmp31_ == NULL) {
			g_warning ("contacts-crop-dialog.vala:86: Your GStreamer installation is missing t" \
"he videoconvert element");
			_g_object_unref0 (_data_->convert);
			_g_object_unref0 (_data_->bin);
			_g_object_unref0 (_data_->sink);
			_g_object_unref0 (_data_->gl_context);
			G_IS_VALUE (&_data_->gl_context_value) ? (g_value_unset (&_data_->gl_context_value), NULL) : NULL;
			_g_object_unref0 (_data_->paintable);
			G_IS_VALUE (&_data_->paintable_value) ? (g_value_unset (&_data_->paintable_value), NULL) : NULL;
			_g_object_unref0 (_data_->paintable_sink);
			_g_object_unref0 (_data_->queue);
			_g_object_unref0 (_data_->source);
			__vala_XdpParent_free0 (_data_->parent);
			block24_data_unref (_data_->_data24_);
			_data_->_data24_ = NULL;
			g_task_return_pointer (_data_->_async_result, _data_, NULL);
			if (_data_->_state_ != 0) {
				while (!g_task_get_completed (_data_->_async_result)) {
					g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
				}
			}
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_tmp32_ = _data_->bin;
		_data_->_tmp33_ = _data_->convert;
		_data_->_tmp34_ = _data_->paintable_sink;
		gst_bin_add_many (_data_->_tmp32_, _data_->_tmp33_, _data_->_tmp34_, NULL);
		_data_->_tmp35_ = _data_->convert;
		_data_->_tmp36_ = _data_->paintable_sink;
		gst_element_link (_data_->_tmp35_, _data_->_tmp36_);
		_data_->_tmp37_ = _data_->convert;
		_data_->_tmp38_ = gst_element_get_static_pad (_data_->_tmp37_, "sink");
		_data_->_tmp39_ = _data_->_tmp38_;
		_data_->_tmp40_ = (GstGhostPad*) gst_ghost_pad_new ("sink", _data_->_tmp39_);
		g_object_ref_sink (_data_->_tmp40_);
		_data_->_tmp41_ = _data_->_tmp40_;
		_g_object_unref0 (_data_->_tmp39_);
		_data_->ghost_pad = _data_->_tmp41_;
		_data_->_tmp42_ = _data_->bin;
		_data_->_tmp43_ = _data_->ghost_pad;
		gst_element_add_pad ((GstElement*) _data_->_tmp42_, (GstPad*) _data_->_tmp43_);
		_data_->_tmp44_ = _data_->bin;
		_data_->_tmp45_ = _g_object_ref0 ((GstElement*) _data_->_tmp44_);
		_g_object_unref0 (_data_->sink);
		_data_->sink = _data_->_tmp45_;
		_g_object_unref0 (_data_->ghost_pad);
		_g_object_unref0 (_data_->convert);
		_g_object_unref0 (_data_->bin);
	}
	_data_->_tmp46_ = _data_->_data24_->pipeline;
	_data_->_tmp47_ = _data_->source;
	_data_->_tmp48_ = _data_->queue;
	_data_->_tmp49_ = _data_->sink;
	gst_bin_add_many ((GstBin*) _data_->_tmp46_, _data_->_tmp47_, _data_->_tmp48_, _data_->_tmp49_, NULL);
	_data_->_tmp50_ = _data_->source;
	_data_->_tmp51_ = _data_->queue;
	_data_->_tmp52_ = _data_->sink;
	gst_element_link_many (_data_->_tmp50_, _data_->_tmp51_, _data_->_tmp52_, NULL);
	_data_->_tmp53_ = _data_->self->priv->crop_area;
	_data_->_tmp54_ = _data_->paintable;
	cc_crop_area_set_paintable (_data_->_tmp53_, _data_->_tmp54_);
	_data_->_tmp55_ = _data_->source;
	memset (&_data_->_tmp56_, 0, sizeof (GValue));
	g_value_init (&_data_->_tmp56_, G_TYPE_INT);
	g_value_set_int (&_data_->_tmp56_, _data_->pw_fd);
	g_object_set_property ((GObject*) _data_->_tmp55_, "fd", &_data_->_tmp56_);
	G_IS_VALUE (&_data_->_tmp56_) ? (g_value_unset (&_data_->_tmp56_), NULL) : NULL;
	_data_->_tmp57_ = _data_->_data24_->pipeline;
	gst_element_set_state ((GstElement*) _data_->_tmp57_, GST_STATE_PLAYING);
	g_signal_connect_data ((AdwDialog*) _data_->self, "closed", (GCallback) ___lambda19__adw_dialog_closed, block24_data_ref (_data_->_data24_), (GClosureNotify) block24_data_unref, 0);
	_data_->_tmp58_ = _data_->_data24_->pipeline;
	_data_->_tmp59_ = gst_pipeline_get_bus (_data_->_tmp58_);
	_data_->bus = _data_->_tmp59_;
	_data_->_tmp60_ = _data_->bus;
	gst_bus_add_signal_watch_full (_data_->_tmp60_, G_PRIORITY_DEFAULT);
	_data_->_tmp61_ = _data_->bus;
	g_signal_connect_object (_data_->_tmp61_, "message", (GCallback) ___lambda20__gst_bus_message, _data_->self, 0);
	_g_object_unref0 (_data_->bus);
	_g_object_unref0 (_data_->sink);
	_g_object_unref0 (_data_->gl_context);
	G_IS_VALUE (&_data_->gl_context_value) ? (g_value_unset (&_data_->gl_context_value), NULL) : NULL;
	_g_object_unref0 (_data_->paintable);
	G_IS_VALUE (&_data_->paintable_value) ? (g_value_unset (&_data_->paintable_value), NULL) : NULL;
	_g_object_unref0 (_data_->paintable_sink);
	_g_object_unref0 (_data_->queue);
	_g_object_unref0 (_data_->source);
	__vala_XdpParent_free0 (_data_->parent);
	block24_data_unref (_data_->_data24_);
	_data_->_data24_ = NULL;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
contacts_crop_dialog_on_crop (ContactsCropDialog* self,
                              const gchar* action_name,
                              GVariant* param)
{
	GdkTexture* texture = NULL;
	CcCropArea* _tmp0_;
	GdkTexture* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (action_name != NULL);
	_tmp0_ = self->priv->crop_area;
	_tmp1_ = cc_crop_area_create_texture (_tmp0_);
	texture = _tmp1_;
	adw_dialog_close ((AdwDialog*) self);
	g_signal_emit (self, contacts_crop_dialog_signals[CONTACTS_CROP_DIALOG_CROPPED_SIGNAL], 0, texture);
	_g_object_unref0 (texture);
}

ContactsCropDialog*
contacts_crop_dialog_construct (GType object_type)
{
	ContactsCropDialog * self = NULL;
	self = (ContactsCropDialog*) g_object_new (object_type, NULL);
	return self;
}

ContactsCropDialog*
contacts_crop_dialog_new (void)
{
	return contacts_crop_dialog_construct (CONTACTS_TYPE_CROP_DIALOG);
}

static GObject *
contacts_crop_dialog_constructor (GType type,
                                  guint n_construct_properties,
                                  GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	ContactsCropDialog * self;
	CcCropArea* _tmp0_;
	parent_class = G_OBJECT_CLASS (contacts_crop_dialog_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CONTACTS_TYPE_CROP_DIALOG, ContactsCropDialog);
	_tmp0_ = self->priv->crop_area;
	cc_crop_area_set_min_size (_tmp0_, 48, 48);
	return obj;
}

static void
contacts_crop_dialog_class_init (ContactsCropDialogClass * klass,
                                 gpointer klass_data)
{
	contacts_crop_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ContactsCropDialog_private_offset);
	G_OBJECT_CLASS (klass)->constructor = contacts_crop_dialog_constructor;
	G_OBJECT_CLASS (klass)->finalize = contacts_crop_dialog_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Contacts/ui/contacts-crop-dialog.ui");
	contacts_crop_dialog_signals[CONTACTS_CROP_DIALOG_CROPPED_SIGNAL] = g_signal_new ("cropped", CONTACTS_TYPE_CROP_DIALOG, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, gdk_texture_get_type ());
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "crop_area", FALSE, ContactsCropDialog_private_offset + G_STRUCT_OFFSET (ContactsCropDialogPrivate, crop_area));
	g_type_ensure (CC_TYPE_CROP_AREA);
	gtk_widget_class_install_action (GTK_WIDGET_CLASS (klass), "crop", NULL, (GtkWidgetActionActivateFunc) contacts_crop_dialog_on_crop);
}

static void
contacts_crop_dialog_instance_init (ContactsCropDialog * self,
                                    gpointer klass)
{
	self->priv = contacts_crop_dialog_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
contacts_crop_dialog_finalize (GObject * obj)
{
	ContactsCropDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CONTACTS_TYPE_CROP_DIALOG, ContactsCropDialog);
	G_OBJECT_CLASS (contacts_crop_dialog_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
contacts_crop_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ContactsCropDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) contacts_crop_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ContactsCropDialog), 0, (GInstanceInitFunc) contacts_crop_dialog_instance_init, NULL };
	GType contacts_crop_dialog_type_id;
	contacts_crop_dialog_type_id = g_type_register_static (adw_dialog_get_type (), "ContactsCropDialog", &g_define_type_info, 0);
	ContactsCropDialog_private_offset = g_type_add_instance_private (contacts_crop_dialog_type_id, sizeof (ContactsCropDialogPrivate));
	return contacts_crop_dialog_type_id;
}

GType
contacts_crop_dialog_get_type (void)
{
	static volatile gsize contacts_crop_dialog_type_id__once = 0;
	if (g_once_init_enter (&contacts_crop_dialog_type_id__once)) {
		GType contacts_crop_dialog_type_id;
		contacts_crop_dialog_type_id = contacts_crop_dialog_get_type_once ();
		g_once_init_leave (&contacts_crop_dialog_type_id__once, contacts_crop_dialog_type_id);
	}
	return contacts_crop_dialog_type_id__once;
}

