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

#include <glib-object.h>
#include <gtk/gtk.h>
#include <adwaita.h>
#include <glib.h>
#include <float.h>
#include <math.h>
#include <gsk/gsk.h>
#include <graphene-gobject.h>
#include <string.h>
#include <gdk/gdk.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

typedef enum  {
	SWIPE_DIRECTION_SWIPE_LEFT,
	SWIPE_DIRECTION_SWIPE_RIGHT
} SwipeDirection;

#define TYPE_SWIPE_DIRECTION (swipe_direction_get_type ())

#define TYPE_DISMISSIBLE_WIDGET (dismissible_widget_get_type ())
#define DISMISSIBLE_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DISMISSIBLE_WIDGET, DismissibleWidget))
#define DISMISSIBLE_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DISMISSIBLE_WIDGET, DismissibleWidgetClass))
#define IS_DISMISSIBLE_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DISMISSIBLE_WIDGET))
#define IS_DISMISSIBLE_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DISMISSIBLE_WIDGET))
#define DISMISSIBLE_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DISMISSIBLE_WIDGET, DismissibleWidgetClass))

typedef struct _DismissibleWidget DismissibleWidget;
typedef struct _DismissibleWidgetClass DismissibleWidgetClass;
typedef struct _DismissibleWidgetPrivate DismissibleWidgetPrivate;
enum  {
	DISMISSIBLE_WIDGET_0_PROPERTY,
	DISMISSIBLE_WIDGET_CHILD_PROPERTY,
	DISMISSIBLE_WIDGET_ORIENTATION_PROPERTY,
	DISMISSIBLE_WIDGET_SWIPE_PROGRESS_PROPERTY,
	DISMISSIBLE_WIDGET_NUM_PROPERTIES
};
static GParamSpec* dismissible_widget_properties[DISMISSIBLE_WIDGET_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _gsk_transform_unref0(var) ((var == NULL) ? NULL : (var = (gsk_transform_unref (var), NULL)))
enum  {
	DISMISSIBLE_WIDGET_DISMISSED_SIGNAL,
	DISMISSIBLE_WIDGET_NUM_SIGNALS
};
static guint dismissible_widget_signals[DISMISSIBLE_WIDGET_NUM_SIGNALS] = {0};

struct _DismissibleWidget {
	GtkWidget parent_instance;
	DismissibleWidgetPrivate * priv;
	GtkWidget* _child;
};

struct _DismissibleWidgetClass {
	GtkWidgetClass parent_class;
};

struct _DismissibleWidgetPrivate {
	GtkOrientation _orientation;
	AdwSpringAnimation* animation;
	AdwSwipeTracker* swipe_tracker;
	gboolean transition_running;
	gboolean gesture_active;
	gdouble _swipe_progress;
	SwipeDirection swipe_direction;
};

static gint DismissibleWidget_private_offset;
static gpointer dismissible_widget_parent_class = NULL;
static AdwSwipeableInterface * dismissible_widget_adw_swipeable_parent_iface = NULL;

VALA_EXTERN GType swipe_direction_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType dismissible_widget_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DismissibleWidget, g_object_unref)
static void dismissible_widget_real_dispose (GObject* base);
VALA_EXTERN GtkWidget* dismissible_widget_get_child (DismissibleWidget* self);
VALA_EXTERN void dismissible_widget_set_child (DismissibleWidget* self,
                                   GtkWidget* value);
VALA_EXTERN void dismissible_widget_set_can_dismiss (DismissibleWidget* self,
                                         gboolean state);
static GtkSizeRequestMode dismissible_widget_real_get_request_mode (GtkWidget* base);
static void dismissible_widget_real_measure (GtkWidget* base,
                                      GtkOrientation orientation,
                                      gint for_size,
                                      gint* minimum,
                                      gint* natural,
                                      gint* minimum_baseline,
                                      gint* natural_baseline);
static void dismissible_widget_real_size_allocate (GtkWidget* base,
                                            gint width,
                                            gint height,
                                            gint baseline);
VALA_EXTERN gdouble dismissible_widget_get_swipe_progress (DismissibleWidget* self);
static void dismissible_widget_real_snapshot (GtkWidget* base,
                                       GtkSnapshot* snapshot);
static void dismissible_widget_animation_done_cb (DismissibleWidget* self);
static void dismissible_widget_swipe_prepare_cb (DismissibleWidget* self,
                                          AdwNavigationDirection direction);
static void dismissible_widget_swipe_update_swipe_cb (DismissibleWidget* self,
                                               gdouble distance);
VALA_EXTERN void dismissible_widget_set_swipe_progress (DismissibleWidget* self,
                                            gdouble value);
static void dismissible_widget_swipe_end_swipe_cb (DismissibleWidget* self,
                                            gdouble velocity,
                                            gdouble to);
VALA_EXTERN void dismissible_widget_set_gesture_direction (DismissibleWidget* self,
                                               SwipeDirection swipe_direction);
static gdouble dismissible_widget_real_get_cancel_progress (AdwSwipeable* base);
static gdouble dismissible_widget_real_get_distance (AdwSwipeable* base);
static gdouble dismissible_widget_real_get_progress (AdwSwipeable* base);
static gdouble* dismissible_widget_real_get_snap_points (AdwSwipeable* base,
                                                  gint* result_length1);
static void dismissible_widget_real_get_swipe_area (AdwSwipeable* base,
                                             AdwNavigationDirection direction,
                                             gboolean is_drag,
                                             GdkRectangle* result);
VALA_EXTERN DismissibleWidget* dismissible_widget_new (void);
VALA_EXTERN DismissibleWidget* dismissible_widget_construct (GType object_type);
VALA_EXTERN GtkOrientation dismissible_widget_get_orientation (DismissibleWidget* self);
static void dismissible_widget_set_orientation (DismissibleWidget* self,
                                         GtkOrientation value);
static GObject * dismissible_widget_constructor (GType type,
                                          guint n_construct_properties,
                                          GObjectConstructParam * construct_properties);
static void _dismissible_widget_swipe_prepare_cb_adw_swipe_tracker_prepare (AdwSwipeTracker* _sender,
                                                                     AdwNavigationDirection direction,
                                                                     gpointer self);
static void _dismissible_widget_swipe_update_swipe_cb_adw_swipe_tracker_update_swipe (AdwSwipeTracker* _sender,
                                                                               gdouble progress,
                                                                               gpointer self);
static void _dismissible_widget_swipe_end_swipe_cb_adw_swipe_tracker_end_swipe (AdwSwipeTracker* _sender,
                                                                         gdouble velocity,
                                                                         gdouble to,
                                                                         gpointer self);
static void _dismissible_widget_animation_done_cb_adw_animation_done (AdwAnimation* _sender,
                                                               gpointer self);
static void dismissible_widget_finalize (GObject * obj);
static GType dismissible_widget_get_type_once (void);
static void _vala_dismissible_widget_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec);
static void _vala_dismissible_widget_set_property (GObject * object,
                                            guint property_id,
                                            const GValue * value,
                                            GParamSpec * pspec);

 G_GNUC_NO_INLINE static GType
swipe_direction_get_type_once (void)
{
	static const GEnumValue values[] = {{SWIPE_DIRECTION_SWIPE_LEFT, "SWIPE_DIRECTION_SWIPE_LEFT", "swipe-left"}, {SWIPE_DIRECTION_SWIPE_RIGHT, "SWIPE_DIRECTION_SWIPE_RIGHT", "swipe-right"}, {0, NULL, NULL}};
	GType swipe_direction_type_id;
	swipe_direction_type_id = g_enum_register_static ("SwipeDirection", values);
	return swipe_direction_type_id;
}

GType
swipe_direction_get_type (void)
{
	static gsize swipe_direction_type_id__once = 0;
	if (g_once_init_enter (&swipe_direction_type_id__once)) {
		GType swipe_direction_type_id;
		swipe_direction_type_id = swipe_direction_get_type_once ();
		g_once_init_leave (&swipe_direction_type_id__once, swipe_direction_type_id);
	}
	return swipe_direction_type_id__once;
}

static inline gpointer
dismissible_widget_get_instance_private (DismissibleWidget* self)
{
	return G_STRUCT_MEMBER_P (self, DismissibleWidget_private_offset);
}

static void
dismissible_widget_real_dispose (GObject* base)
{
	DismissibleWidget * self;
	GtkWidget* _tmp0_;
	GtkWidget* _tmp1_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_DISMISSIBLE_WIDGET, DismissibleWidget);
	_tmp0_ = dismissible_widget_get_child (self);
	_tmp1_ = _tmp0_;
	if (_tmp1_ != NULL) {
		GtkWidget* _tmp2_;
		GtkWidget* _tmp3_;
		_tmp2_ = dismissible_widget_get_child (self);
		_tmp3_ = _tmp2_;
		gtk_widget_unparent (_tmp3_);
		dismissible_widget_set_child (self, NULL);
	}
	G_OBJECT_CLASS (dismissible_widget_parent_class)->dispose (G_TYPE_CHECK_INSTANCE_CAST (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), G_TYPE_OBJECT, GObject));
}

void
dismissible_widget_set_can_dismiss (DismissibleWidget* self,
                                    gboolean state)
{
	AdwSwipeTracker* _tmp0_;
	g_return_if_fail (IS_DISMISSIBLE_WIDGET (self));
	_tmp0_ = self->priv->swipe_tracker;
	adw_swipe_tracker_set_enabled (_tmp0_, state);
}

static GtkSizeRequestMode
dismissible_widget_real_get_request_mode (GtkWidget* base)
{
	DismissibleWidget * self;
	GtkSizeRequestMode result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_DISMISSIBLE_WIDGET, DismissibleWidget);
	result = GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
	return result;
}

static void
dismissible_widget_real_measure (GtkWidget* base,
                                 GtkOrientation orientation,
                                 gint for_size,
                                 gint* minimum,
                                 gint* natural,
                                 gint* minimum_baseline,
                                 gint* natural_baseline)
{
	DismissibleWidget * self;
	gint _vala_minimum = 0;
	gint _vala_natural = 0;
	gint _vala_minimum_baseline = 0;
	gint _vala_natural_baseline = 0;
	gboolean _tmp0_ = FALSE;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp5_;
	GtkWidget* _tmp6_;
	gint _tmp7_ = 0;
	gint _tmp8_ = 0;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_DISMISSIBLE_WIDGET, DismissibleWidget);
	_vala_minimum = 0;
	_vala_natural = 0;
	_vala_minimum_baseline = -1;
	_vala_natural_baseline = -1;
	_tmp1_ = dismissible_widget_get_child (self);
	_tmp2_ = _tmp1_;
	if (_tmp2_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		GtkWidget* _tmp3_;
		GtkWidget* _tmp4_;
		_tmp3_ = dismissible_widget_get_child (self);
		_tmp4_ = _tmp3_;
		_tmp0_ = !gtk_widget_should_layout (_tmp4_);
	}
	if (_tmp0_) {
		if (minimum) {
			*minimum = _vala_minimum;
		}
		if (natural) {
			*natural = _vala_natural;
		}
		if (minimum_baseline) {
			*minimum_baseline = _vala_minimum_baseline;
		}
		if (natural_baseline) {
			*natural_baseline = _vala_natural_baseline;
		}
		return;
	}
	_tmp5_ = dismissible_widget_get_child (self);
	_tmp6_ = _tmp5_;
	gtk_widget_measure (_tmp6_, orientation, for_size, &_tmp7_, &_tmp8_, NULL, NULL);
	_vala_minimum = _tmp7_;
	_vala_natural = _tmp8_;
	if (minimum) {
		*minimum = _vala_minimum;
	}
	if (natural) {
		*natural = _vala_natural;
	}
	if (minimum_baseline) {
		*minimum_baseline = _vala_minimum_baseline;
	}
	if (natural_baseline) {
		*natural_baseline = _vala_natural_baseline;
	}
}

static gpointer
_gsk_transform_ref0 (gpointer self)
{
	return self ? gsk_transform_ref (self) : NULL;
}

static void
dismissible_widget_real_size_allocate (GtkWidget* base,
                                       gint width,
                                       gint height,
                                       gint baseline)
{
	DismissibleWidget * self;
	gboolean _tmp0_ = FALSE;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	gint child_width = 0;
	gint child_height = 0;
	gdouble x = 0.0;
	GskTransform* transform = NULL;
	GskTransform* _tmp9_;
	graphene_point_t _tmp10_ = {0};
	graphene_point_t _tmp11_;
	GskTransform* _tmp12_;
	GtkWidget* _tmp13_;
	GtkWidget* _tmp14_;
	GskTransform* _tmp15_;
	GskTransform* _tmp16_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_DISMISSIBLE_WIDGET, DismissibleWidget);
	_tmp1_ = dismissible_widget_get_child (self);
	_tmp2_ = _tmp1_;
	if (_tmp2_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		GtkWidget* _tmp3_;
		GtkWidget* _tmp4_;
		_tmp3_ = dismissible_widget_get_child (self);
		_tmp4_ = _tmp3_;
		_tmp0_ = !gtk_widget_should_layout (_tmp4_);
	}
	if (_tmp0_) {
		return;
	}
	child_width = width;
	child_height = height;
	x = (gdouble) 0;
	if (gtk_widget_get_direction (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget)) == GTK_TEXT_DIR_RTL) {
		gdouble _tmp5_;
		gdouble _tmp6_;
		_tmp5_ = dismissible_widget_get_swipe_progress (self);
		_tmp6_ = _tmp5_;
		x -= width * _tmp6_;
	} else {
		gdouble _tmp7_;
		gdouble _tmp8_;
		_tmp7_ = dismissible_widget_get_swipe_progress (self);
		_tmp8_ = _tmp7_;
		x += width * _tmp8_;
	}
	_tmp9_ = gsk_transform_new ();
	memset (&_tmp10_, 0, sizeof (graphene_point_t));
	_tmp11_ = *graphene_point_init (&_tmp10_, (gfloat) x, (gfloat) 0);
	_tmp12_ = gsk_transform_translate (_tmp9_, &_tmp11_);
	transform = _tmp12_;
	_tmp13_ = dismissible_widget_get_child (self);
	_tmp14_ = _tmp13_;
	_tmp15_ = transform;
	_tmp16_ = _gsk_transform_ref0 (_tmp15_);
	gtk_widget_allocate (_tmp14_, child_width, child_height, baseline, _tmp16_);
	_gsk_transform_unref0 (transform);
}

static void
dismissible_widget_real_snapshot (GtkWidget* base,
                                  GtkSnapshot* snapshot)
{
	DismissibleWidget * self;
	gdouble _tmp0_;
	gdouble _tmp1_;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp3_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_DISMISSIBLE_WIDGET, DismissibleWidget);
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (snapshot, gtk_snapshot_get_type ()));
	_tmp0_ = dismissible_widget_get_swipe_progress (self);
	_tmp1_ = _tmp0_;
	gtk_snapshot_push_opacity (snapshot, 1 - fabs (_tmp1_));
	_tmp2_ = dismissible_widget_get_child (self);
	_tmp3_ = _tmp2_;
	gtk_widget_snapshot_child (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), _tmp3_, snapshot);
	gtk_snapshot_pop (snapshot);
}

static void
dismissible_widget_animation_done_cb (DismissibleWidget* self)
{
	gdouble _tmp0_;
	gdouble _tmp1_;
	g_return_if_fail (IS_DISMISSIBLE_WIDGET (self));
	self->priv->transition_running = FALSE;
	_tmp0_ = dismissible_widget_get_swipe_progress (self);
	_tmp1_ = _tmp0_;
	if (_tmp1_ != ((gdouble) 0)) {
		g_signal_emit (self, dismissible_widget_signals[DISMISSIBLE_WIDGET_DISMISSED_SIGNAL], 0);
	}
}

static void
dismissible_widget_swipe_prepare_cb (DismissibleWidget* self,
                                     AdwNavigationDirection direction)
{
	g_return_if_fail (IS_DISMISSIBLE_WIDGET (self));
	self->priv->gesture_active = TRUE;
	if (self->priv->transition_running) {
		AdwSpringAnimation* _tmp0_;
		_tmp0_ = self->priv->animation;
		adw_animation_pause (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, adw_animation_get_type (), AdwAnimation));
	} else {
		self->priv->transition_running = TRUE;
	}
}

static void
dismissible_widget_swipe_update_swipe_cb (DismissibleWidget* self,
                                          gdouble distance)
{
	g_return_if_fail (IS_DISMISSIBLE_WIDGET (self));
	dismissible_widget_set_swipe_progress (self, distance);
}

static void
dismissible_widget_swipe_end_swipe_cb (DismissibleWidget* self,
                                       gdouble velocity,
                                       gdouble to)
{
	AdwSpringAnimation* _tmp0_;
	gdouble _tmp1_;
	gdouble _tmp2_;
	AdwSpringAnimation* _tmp3_;
	AdwSpringAnimation* _tmp4_;
	AdwSpringAnimation* _tmp5_;
	g_return_if_fail (IS_DISMISSIBLE_WIDGET (self));
	if (!self->priv->gesture_active) {
		return;
	}
	_tmp0_ = self->priv->animation;
	_tmp1_ = dismissible_widget_get_swipe_progress (self);
	_tmp2_ = _tmp1_;
	adw_spring_animation_set_value_from (_tmp0_, _tmp2_);
	_tmp3_ = self->priv->animation;
	adw_spring_animation_set_value_to (_tmp3_, to);
	_tmp4_ = self->priv->animation;
	adw_spring_animation_set_initial_velocity (_tmp4_, velocity);
	gtk_widget_set_can_target (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), to == ((gdouble) 0));
	_tmp5_ = self->priv->animation;
	adw_animation_play (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, adw_animation_get_type (), AdwAnimation));
	self->priv->gesture_active = FALSE;
}

void
dismissible_widget_set_gesture_direction (DismissibleWidget* self,
                                          SwipeDirection swipe_direction)
{
	g_return_if_fail (IS_DISMISSIBLE_WIDGET (self));
	self->priv->swipe_direction = swipe_direction;
	dismissible_widget_set_swipe_progress (self, 0.0);
}

/** Gets the progress this will snap back to after the gesture is canceled. */
static gdouble
dismissible_widget_real_get_cancel_progress (AdwSwipeable* base)
{
	DismissibleWidget * self;
	gdouble result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_DISMISSIBLE_WIDGET, DismissibleWidget);
	result = (gdouble) 0;
	return result;
}

/** Gets the swipe distance of this. */
static gdouble
dismissible_widget_real_get_distance (AdwSwipeable* base)
{
	DismissibleWidget * self;
	gdouble result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_DISMISSIBLE_WIDGET, DismissibleWidget);
	result = (gdouble) gtk_widget_get_width (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
	return result;
}

/** Gets the current progress of this. */
static gdouble
dismissible_widget_real_get_progress (AdwSwipeable* base)
{
	DismissibleWidget * self;
	gdouble _tmp0_;
	gdouble _tmp1_;
	gdouble result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_DISMISSIBLE_WIDGET, DismissibleWidget);
	if (!self->priv->transition_running) {
		result = (gdouble) 0;
		return result;
	}
	_tmp0_ = dismissible_widget_get_swipe_progress (self);
	_tmp1_ = _tmp0_;
	result = _tmp1_;
	return result;
}

/** Gets the snap points of this. */
static gdouble*
dismissible_widget_real_get_snap_points (AdwSwipeable* base,
                                         gint* result_length1)
{
	DismissibleWidget * self;
	gdouble* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_DISMISSIBLE_WIDGET, DismissibleWidget);
	switch (self->priv->swipe_direction) {
		case SWIPE_DIRECTION_SWIPE_LEFT:
		{
			gdouble* _tmp0_;
			gdouble* _tmp1_;
			gint _tmp1__length1;
			_tmp0_ = g_new0 (gdouble, 2);
			_tmp0_[0] = (gdouble) -1;
			_tmp0_[1] = (gdouble) 0;
			_tmp1_ = _tmp0_;
			_tmp1__length1 = 2;
			if (result_length1) {
				*result_length1 = _tmp1__length1;
			}
			result = _tmp1_;
			return result;
		}
		default:
		case SWIPE_DIRECTION_SWIPE_RIGHT:
		{
			gdouble* _tmp2_;
			gdouble* _tmp3_;
			gint _tmp3__length1;
			_tmp2_ = g_new0 (gdouble, 2);
			_tmp2_[0] = (gdouble) 0;
			_tmp2_[1] = (gdouble) 1;
			_tmp3_ = _tmp2_;
			_tmp3__length1 = 2;
			if (result_length1) {
				*result_length1 = _tmp3__length1;
			}
			result = _tmp3_;
			return result;
		}
	}
}

/**
     * Gets the area this can start a swipe from for the given direction
     * and gesture type.
     */
static void
dismissible_widget_real_get_swipe_area (AdwSwipeable* base,
                                        AdwNavigationDirection direction,
                                        gboolean is_drag,
                                        GdkRectangle* result)
{
	DismissibleWidget * self;
	GtkAllocation alloc = {0};
	graphene_rect_t bounds = {0};
	graphene_rect_t _tmp0_ = {0};
	graphene_rect_t _tmp1_;
	graphene_size_t _tmp2_;
	graphene_rect_t _tmp3_;
	graphene_size_t _tmp4_;
	graphene_rect_t _tmp5_;
	graphene_point_t _tmp6_;
	graphene_rect_t _tmp7_;
	graphene_point_t _tmp8_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_DISMISSIBLE_WIDGET, DismissibleWidget);
	memset (&alloc, 0, sizeof (GtkAllocation));
	gtk_widget_compute_bounds (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), &_tmp0_);
	bounds = _tmp0_;
	_tmp1_ = bounds;
	_tmp2_ = _tmp1_.size;
	alloc.width = (gint) _tmp2_.width;
	_tmp3_ = bounds;
	_tmp4_ = _tmp3_.size;
	alloc.height = (gint) _tmp4_.height;
	_tmp5_ = bounds;
	_tmp6_ = _tmp5_.origin;
	alloc.x = (gint) _tmp6_.x;
	_tmp7_ = bounds;
	_tmp8_ = _tmp7_.origin;
	alloc.y = (gint) _tmp8_.y;
	*result = alloc;
	return;
}

DismissibleWidget*
dismissible_widget_construct (GType object_type)
{
	DismissibleWidget * self = NULL;
	self = (DismissibleWidget*) g_object_new (object_type, NULL);
	return self;
}

DismissibleWidget*
dismissible_widget_new (void)
{
	return dismissible_widget_construct (TYPE_DISMISSIBLE_WIDGET);
}

GtkWidget*
dismissible_widget_get_child (DismissibleWidget* self)
{
	GtkWidget* result;
	GtkWidget* _tmp0_;
	g_return_val_if_fail (IS_DISMISSIBLE_WIDGET (self), NULL);
	_tmp0_ = self->_child;
	result = _tmp0_;
	return result;
}

void
dismissible_widget_set_child (DismissibleWidget* self,
                              GtkWidget* value)
{
	GtkWidget* _tmp0_;
	g_return_if_fail (IS_DISMISSIBLE_WIDGET (self));
	self->_child = value;
	_tmp0_ = self->_child;
	if (_tmp0_ != NULL) {
		GtkWidget* _tmp1_;
		GtkWidget* _tmp2_;
		_tmp1_ = self->_child;
		gtk_widget_unparent (_tmp1_);
		_tmp2_ = self->_child;
		gtk_widget_set_parent (_tmp2_, G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
	}
	g_object_notify_by_pspec ((GObject *) self, dismissible_widget_properties[DISMISSIBLE_WIDGET_CHILD_PROPERTY]);
}

GtkOrientation
dismissible_widget_get_orientation (DismissibleWidget* self)
{
	GtkOrientation result;
	g_return_val_if_fail (IS_DISMISSIBLE_WIDGET (self), 0);
	result = self->priv->_orientation;
	return result;
}

static void
dismissible_widget_set_orientation (DismissibleWidget* self,
                                    GtkOrientation value)
{
	GtkOrientation old_value;
	g_return_if_fail (IS_DISMISSIBLE_WIDGET (self));
	old_value = dismissible_widget_get_orientation (self);
	if (old_value != value) {
		self->priv->_orientation = value;
		g_object_notify_by_pspec ((GObject *) self, dismissible_widget_properties[DISMISSIBLE_WIDGET_ORIENTATION_PROPERTY]);
	}
}

gdouble
dismissible_widget_get_swipe_progress (DismissibleWidget* self)
{
	gdouble result;
	g_return_val_if_fail (IS_DISMISSIBLE_WIDGET (self), 0.0);
	result = self->priv->_swipe_progress;
	return result;
}

void
dismissible_widget_set_swipe_progress (DismissibleWidget* self,
                                       gdouble value)
{
	g_return_if_fail (IS_DISMISSIBLE_WIDGET (self));
	self->priv->_swipe_progress = value;
	gtk_widget_queue_allocate (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
	g_object_notify_by_pspec ((GObject *) self, dismissible_widget_properties[DISMISSIBLE_WIDGET_SWIPE_PROGRESS_PROPERTY]);
}

static void
_dismissible_widget_swipe_prepare_cb_adw_swipe_tracker_prepare (AdwSwipeTracker* _sender,
                                                                AdwNavigationDirection direction,
                                                                gpointer self)
{
	dismissible_widget_swipe_prepare_cb ((DismissibleWidget*) self, direction);
}

static void
_dismissible_widget_swipe_update_swipe_cb_adw_swipe_tracker_update_swipe (AdwSwipeTracker* _sender,
                                                                          gdouble progress,
                                                                          gpointer self)
{
	dismissible_widget_swipe_update_swipe_cb ((DismissibleWidget*) self, progress);
}

static void
_dismissible_widget_swipe_end_swipe_cb_adw_swipe_tracker_end_swipe (AdwSwipeTracker* _sender,
                                                                    gdouble velocity,
                                                                    gdouble to,
                                                                    gpointer self)
{
	dismissible_widget_swipe_end_swipe_cb ((DismissibleWidget*) self, velocity, to);
}

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

static void
_dismissible_widget_animation_done_cb_adw_animation_done (AdwAnimation* _sender,
                                                          gpointer self)
{
	dismissible_widget_animation_done_cb ((DismissibleWidget*) self);
}

static GObject *
dismissible_widget_constructor (GType type,
                                guint n_construct_properties,
                                GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	DismissibleWidget * self;
	AdwSwipeTracker* _tmp0_;
	AdwSwipeTracker* _tmp1_;
	GtkOrientation _tmp2_;
	AdwSwipeTracker* _tmp3_;
	AdwSwipeTracker* _tmp4_;
	AdwSwipeTracker* _tmp5_;
	AdwSwipeTracker* _tmp6_;
	AdwSwipeTracker* _tmp7_;
	AdwSwipeTracker* _tmp8_;
	AdwSwipeTracker* _tmp9_;
	AdwSwipeTracker* _tmp10_;
	AdwSwipeTracker* _tmp11_;
	gdouble* snap_dir = NULL;
	gint _tmp12_ = 0;
	gdouble* _tmp13_;
	gint snap_dir_length1;
	gint _snap_dir_size_;
	AdwPropertyAnimationTarget* target = NULL;
	AdwPropertyAnimationTarget* _tmp14_;
	gdouble* _tmp15_;
	gint _tmp15__length1;
	gdouble _tmp16_;
	gdouble* _tmp17_;
	gint _tmp17__length1;
	gdouble _tmp18_;
	AdwSpringParams* _tmp19_;
	AdwPropertyAnimationTarget* _tmp20_;
	AdwAnimationTarget* _tmp21_;
	AdwSpringAnimation* _tmp22_;
	AdwSpringAnimation* _tmp23_;
	AdwSpringAnimation* _tmp24_;
	parent_class = G_OBJECT_CLASS (dismissible_widget_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_DISMISSIBLE_WIDGET, DismissibleWidget);
	_tmp0_ = adw_swipe_tracker_new (G_TYPE_CHECK_INSTANCE_CAST (self, adw_swipeable_get_type (), AdwSwipeable));
	if (_tmp0_) {
		g_object_set_data ((GObject *) _tmp0_, "vala-creation-function", "");
	}
	_g_object_unref0 (self->priv->swipe_tracker);
	self->priv->swipe_tracker = _tmp0_;
	_tmp1_ = self->priv->swipe_tracker;
	_tmp2_ = self->priv->_orientation;
	gtk_orientable_set_orientation (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_orientable_get_type (), GtkOrientable), _tmp2_);
	_tmp3_ = self->priv->swipe_tracker;
	adw_swipe_tracker_set_reversed (_tmp3_, TRUE);
	_tmp4_ = self->priv->swipe_tracker;
	adw_swipe_tracker_set_upper_overshoot (_tmp4_, TRUE);
	_tmp5_ = self->priv->swipe_tracker;
	adw_swipe_tracker_set_lower_overshoot (_tmp5_, TRUE);
	_tmp6_ = self->priv->swipe_tracker;
	adw_swipe_tracker_set_allow_long_swipes (_tmp6_, TRUE);
	_tmp7_ = self->priv->swipe_tracker;
	adw_swipe_tracker_set_enabled (_tmp7_, TRUE);
	_tmp8_ = self->priv->swipe_tracker;
	adw_swipe_tracker_set_allow_mouse_drag (_tmp8_, TRUE);
	_tmp9_ = self->priv->swipe_tracker;
	g_signal_connect_object (_tmp9_, "prepare", (GCallback) _dismissible_widget_swipe_prepare_cb_adw_swipe_tracker_prepare, self, 0);
	_tmp10_ = self->priv->swipe_tracker;
	g_signal_connect_object (_tmp10_, "update-swipe", (GCallback) _dismissible_widget_swipe_update_swipe_cb_adw_swipe_tracker_update_swipe, self, 0);
	_tmp11_ = self->priv->swipe_tracker;
	g_signal_connect_object (_tmp11_, "end-swipe", (GCallback) _dismissible_widget_swipe_end_swipe_cb_adw_swipe_tracker_end_swipe, self, 0);
	_tmp13_ = adw_swipeable_get_snap_points (G_TYPE_CHECK_INSTANCE_CAST (self, adw_swipeable_get_type (), AdwSwipeable), &_tmp12_);
	snap_dir = _tmp13_;
	snap_dir_length1 = _tmp12_;
	_snap_dir_size_ = snap_dir_length1;
	_tmp14_ = (AdwPropertyAnimationTarget*) adw_property_animation_target_new (G_TYPE_CHECK_INSTANCE_CAST (self, G_TYPE_OBJECT, GObject), "swipe-progress");
	if (_tmp14_) {
		g_object_set_data ((GObject *) _tmp14_, "vala-creation-function", "");
	}
	target = _tmp14_;
	_tmp15_ = snap_dir;
	_tmp15__length1 = snap_dir_length1;
	_tmp16_ = _tmp15_[0];
	_tmp17_ = snap_dir;
	_tmp17__length1 = snap_dir_length1;
	_tmp18_ = _tmp17_[1];
	_tmp19_ = adw_spring_params_new ((gdouble) 1, 0.5, (gdouble) 500);
	_tmp20_ = target;
	_tmp21_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp20_, adw_animation_target_get_type (), AdwAnimationTarget));
	_tmp22_ = (AdwSpringAnimation*) adw_spring_animation_new (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), _tmp16_, _tmp18_, _tmp19_, _tmp21_);
	if (_tmp22_) {
		g_object_set_data ((GObject *) _tmp22_, "vala-creation-function", "");
	}
	_g_object_unref0 (self->priv->animation);
	self->priv->animation = _tmp22_;
	_tmp23_ = self->priv->animation;
	adw_spring_animation_set_clamp (_tmp23_, TRUE);
	_tmp24_ = self->priv->animation;
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (_tmp24_, adw_animation_get_type (), AdwAnimation), "done", (GCallback) _dismissible_widget_animation_done_cb_adw_animation_done, self, 0);
	_g_object_unref0 (target);
	snap_dir = (g_free (snap_dir), NULL);
	return obj;
}

static void
dismissible_widget_class_init (DismissibleWidgetClass * klass,
                               gpointer klass_data)
{
	dismissible_widget_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DismissibleWidget_private_offset);
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) dismissible_widget_real_dispose;
	((GtkWidgetClass *) klass)->get_request_mode = (GtkSizeRequestMode (*) (GtkWidget*)) dismissible_widget_real_get_request_mode;
	((GtkWidgetClass *) klass)->measure = (void (*) (GtkWidget*, GtkOrientation, gint, gint*, gint*, gint*, gint*)) dismissible_widget_real_measure;
	((GtkWidgetClass *) klass)->size_allocate = (void (*) (GtkWidget*, gint, gint, gint)) dismissible_widget_real_size_allocate;
	((GtkWidgetClass *) klass)->snapshot = (void (*) (GtkWidget*, GtkSnapshot*)) dismissible_widget_real_snapshot;
	G_OBJECT_CLASS (klass)->get_property = _vala_dismissible_widget_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_dismissible_widget_set_property;
	G_OBJECT_CLASS (klass)->constructor = dismissible_widget_constructor;
	G_OBJECT_CLASS (klass)->finalize = dismissible_widget_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DISMISSIBLE_WIDGET_CHILD_PROPERTY, dismissible_widget_properties[DISMISSIBLE_WIDGET_CHILD_PROPERTY] = g_param_spec_object ("child", "child", "child", gtk_widget_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DISMISSIBLE_WIDGET_ORIENTATION_PROPERTY, dismissible_widget_properties[DISMISSIBLE_WIDGET_ORIENTATION_PROPERTY] = g_param_spec_enum ("orientation", "orientation", "orientation", gtk_orientation_get_type (), GTK_ORIENTATION_HORIZONTAL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DISMISSIBLE_WIDGET_SWIPE_PROGRESS_PROPERTY, dismissible_widget_properties[DISMISSIBLE_WIDGET_SWIPE_PROGRESS_PROPERTY] = g_param_spec_double ("swipe-progress", "swipe-progress", "swipe-progress", -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	dismissible_widget_signals[DISMISSIBLE_WIDGET_DISMISSED_SIGNAL] = g_signal_new ("dismissed", TYPE_DISMISSIBLE_WIDGET, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
dismissible_widget_adw_swipeable_interface_init (AdwSwipeableInterface * iface,
                                                 gpointer iface_data)
{
	dismissible_widget_adw_swipeable_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_cancel_progress = (gdouble (*) (AdwSwipeable*)) dismissible_widget_real_get_cancel_progress;
	iface->get_distance = (gdouble (*) (AdwSwipeable*)) dismissible_widget_real_get_distance;
	iface->get_progress = (gdouble (*) (AdwSwipeable*)) dismissible_widget_real_get_progress;
	iface->get_snap_points = (gdouble* (*) (AdwSwipeable*, gint*)) dismissible_widget_real_get_snap_points;
	iface->get_swipe_area = (void (*) (AdwSwipeable*, AdwNavigationDirection, gboolean, GdkRectangle*)) dismissible_widget_real_get_swipe_area;
}

static void
dismissible_widget_instance_init (DismissibleWidget * self,
                                  gpointer klass)
{
	self->priv = dismissible_widget_get_instance_private (self);
	self->_child = NULL;
	self->priv->_orientation = GTK_ORIENTATION_HORIZONTAL;
	self->priv->transition_running = FALSE;
	self->priv->gesture_active = FALSE;
	self->priv->_swipe_progress = 0.0;
	self->priv->swipe_direction = SWIPE_DIRECTION_SWIPE_RIGHT;
}

static void
dismissible_widget_finalize (GObject * obj)
{
	DismissibleWidget * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_DISMISSIBLE_WIDGET, DismissibleWidget);
	_g_object_unref0 (self->priv->animation);
	_g_object_unref0 (self->priv->swipe_tracker);
	G_OBJECT_CLASS (dismissible_widget_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
dismissible_widget_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DismissibleWidgetClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dismissible_widget_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DismissibleWidget), 0, (GInstanceInitFunc) dismissible_widget_instance_init, NULL };
	static const GInterfaceInfo adw_swipeable_info = { (GInterfaceInitFunc) dismissible_widget_adw_swipeable_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType dismissible_widget_type_id;
	dismissible_widget_type_id = g_type_register_static (gtk_widget_get_type (), "DismissibleWidget", &g_define_type_info, 0);
	g_type_add_interface_static (dismissible_widget_type_id, adw_swipeable_get_type (), &adw_swipeable_info);
	DismissibleWidget_private_offset = g_type_add_instance_private (dismissible_widget_type_id, sizeof (DismissibleWidgetPrivate));
	return dismissible_widget_type_id;
}

GType
dismissible_widget_get_type (void)
{
	static gsize dismissible_widget_type_id__once = 0;
	if (g_once_init_enter (&dismissible_widget_type_id__once)) {
		GType dismissible_widget_type_id;
		dismissible_widget_type_id = dismissible_widget_get_type_once ();
		g_once_init_leave (&dismissible_widget_type_id__once, dismissible_widget_type_id);
	}
	return dismissible_widget_type_id__once;
}

static void
_vala_dismissible_widget_get_property (GObject * object,
                                       guint property_id,
                                       GValue * value,
                                       GParamSpec * pspec)
{
	DismissibleWidget * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_DISMISSIBLE_WIDGET, DismissibleWidget);
	switch (property_id) {
		case DISMISSIBLE_WIDGET_CHILD_PROPERTY:
		g_value_set_object (value, dismissible_widget_get_child (self));
		break;
		case DISMISSIBLE_WIDGET_ORIENTATION_PROPERTY:
		g_value_set_enum (value, dismissible_widget_get_orientation (self));
		break;
		case DISMISSIBLE_WIDGET_SWIPE_PROGRESS_PROPERTY:
		g_value_set_double (value, dismissible_widget_get_swipe_progress (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_dismissible_widget_set_property (GObject * object,
                                       guint property_id,
                                       const GValue * value,
                                       GParamSpec * pspec)
{
	DismissibleWidget * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_DISMISSIBLE_WIDGET, DismissibleWidget);
	switch (property_id) {
		case DISMISSIBLE_WIDGET_CHILD_PROPERTY:
		dismissible_widget_set_child (self, g_value_get_object (value));
		break;
		case DISMISSIBLE_WIDGET_ORIENTATION_PROPERTY:
		dismissible_widget_set_orientation (self, g_value_get_enum (value));
		break;
		case DISMISSIBLE_WIDGET_SWIPE_PROGRESS_PROPERTY:
		dismissible_widget_set_swipe_progress (self, g_value_get_double (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

