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

/*
 * Copyright (c) 2022-2025 focus-timer contributors
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 *
 * Authors: Kamil Prusko <kamilprusko@gmail.com>
 */

#include "ft_ui.h"
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.h>
#include <adwaita.h>
#include <float.h>
#include <math.h>
#include <gdk/gdk.h>
#include "ft_core.h"
#include <cairo-gobject.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

enum  {
	FT_SIZE_STACK_PAGE_0_PROPERTY,
	FT_SIZE_STACK_PAGE_CHILD_PROPERTY,
	FT_SIZE_STACK_PAGE_NAME_PROPERTY,
	FT_SIZE_STACK_PAGE_RESIZABLE_PROPERTY,
	FT_SIZE_STACK_PAGE_NUM_PROPERTIES
};
static GParamSpec* ft_size_stack_page_properties[FT_SIZE_STACK_PAGE_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))
enum  {
	FT_SIZE_STACK_0_PROPERTY,
	FT_SIZE_STACK_VISIBLE_CHILD_PROPERTY,
	FT_SIZE_STACK_VISIBLE_CHILD_NAME_PROPERTY,
	FT_SIZE_STACK_TRANSITION_DURATION_PROPERTY,
	FT_SIZE_STACK_NUM_PROPERTIES
};
static GParamSpec* ft_size_stack_properties[FT_SIZE_STACK_NUM_PROPERTIES];
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _FtSizeStackPagePrivate {
	GtkWidget* _child;
	gchar* _name;
	gboolean _resizable;
};

struct _FtSizeStackPrivate {
	guint _transition_duration;
	GList* pages;
	AdwTimedAnimation* transition_animation;
	FtSizeStackPage* current_page;
	FtSizeStackPage* previous_page;
	gboolean size_request_set;
};

static gint FtSizeStackPage_private_offset;
static gpointer ft_size_stack_page_parent_class = NULL;
static gint FtSizeStack_private_offset;
static gpointer ft_size_stack_parent_class = NULL;
static GtkBuildableIface * ft_size_stack_gtk_buildable_parent_iface = NULL;

static void ft_size_stack_page_real_dispose (GObject* base);
static void ft_size_stack_page_finalize (GObject * obj);
static GType ft_size_stack_page_get_type_once (void);
static void _vala_ft_size_stack_page_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec);
static void _vala_ft_size_stack_page_set_property (GObject * object,
                                            guint property_id,
                                            const GValue * value,
                                            GParamSpec * pspec);
static void _g_object_unref0_ (gpointer var);
static inline void _g_list_free__g_object_unref0_ (GList* self);
static FtSizeStackPage* ft_size_stack_find_page_by_child (FtSizeStack* self,
                                                   GtkWidget* child);
static FtSizeStackPage* ft_size_stack_find_page_by_name (FtSizeStack* self,
                                                  const gchar* name);
static gfloat ft_size_stack_get_transition_progress (FtSizeStack* self);
static void ft_size_stack_stop_resizing_window (FtSizeStack* self);
static gboolean ___lambda33_ (FtSizeStack* self);
static gboolean ____lambda33__gtk_tick_callback (GtkWidget* widget,
                                          GdkFrameClock* frame_clock,
                                          gpointer self);
static void ft_size_stack_start_resizing_window (FtSizeStack* self);
static inline void ft_size_stack_invalidate_window_default_size (FtSizeStack* self);
static void ft_size_stack_start_transition (FtSizeStack* self,
                                     guint transition_duration);
static void __lambda34_ (FtSizeStack* self,
                  gdouble value);
static void ___lambda34__adw_animation_target_func (gdouble value,
                                             gpointer self);
static void __lambda35_ (FtSizeStack* self);
static void ___lambda35__adw_animation_done (AdwAnimation* _sender,
                                      gpointer self);
static void ft_size_stack_select_page (FtSizeStack* self,
                                FtSizeStackPage* page,
                                gboolean transition);
static void ft_size_stack_remove_page (FtSizeStack* self,
                                FtSizeStackPage* page);
static void ft_size_stack_add_page (FtSizeStack* self,
                             FtSizeStackPage* page);
static void ft_size_stack_real_add_child (GtkBuildable* base,
                                   GtkBuilder* builder,
                                   GObject* object,
                                   const gchar* type);
static void ft_size_stack_real_realize (GtkWidget* base);
static void ft_size_stack_real_compute_expand_internal (GtkWidget* base,
                                                 gboolean* hexpand,
                                                 gboolean* vexpand);
static GtkSizeRequestMode ft_size_stack_real_get_request_mode (GtkWidget* base);
static void ft_size_stack_real_measure (GtkWidget* base,
                                 GtkOrientation orientation,
                                 gint for_size,
                                 gint* minimum,
                                 gint* natural,
                                 gint* minimum_baseline,
                                 gint* natural_baseline);
VALA_EXTERN GtkOrientation ft_get_opposite_orientation (GtkOrientation orientation);
static void ft_size_stack_real_size_allocate (GtkWidget* base,
                                       gint width,
                                       gint height,
                                       gint baseline);
static void ft_size_stack_real_snapshot (GtkWidget* base,
                                  GtkSnapshot* snapshot);
static void ft_size_stack_real_dispose (GObject* base);
static void ft_size_stack_finalize (GObject * obj);
static GType ft_size_stack_get_type_once (void);
static void _vala_ft_size_stack_get_property (GObject * object,
                                       guint property_id,
                                       GValue * value,
                                       GParamSpec * pspec);
static void _vala_ft_size_stack_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
ft_size_stack_page_get_instance_private (FtSizeStackPage* self)
{
	return G_STRUCT_MEMBER_P (self, FtSizeStackPage_private_offset);
}

FtSizeStackPage*
ft_size_stack_page_construct (GType object_type,
                              GtkWidget* child)
{
	FtSizeStackPage * self = NULL;
	g_return_val_if_fail (child != NULL, NULL);
	self = (FtSizeStackPage*) g_object_new (object_type, "child", child, NULL);
	return self;
}

FtSizeStackPage*
ft_size_stack_page_new (GtkWidget* child)
{
	return ft_size_stack_page_construct (FT_TYPE_SIZE_STACK_PAGE, child);
}

static void
ft_size_stack_page_real_dispose (GObject* base)
{
	FtSizeStackPage * self;
	self = (FtSizeStackPage*) base;
	self->last_focus = NULL;
	G_OBJECT_CLASS (ft_size_stack_page_parent_class)->dispose (G_TYPE_CHECK_INSTANCE_CAST (self, G_TYPE_OBJECT, GObject));
}

GtkWidget*
ft_size_stack_page_get_child (FtSizeStackPage* self)
{
	GtkWidget* result;
	GtkWidget* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_child;
	result = _tmp0_;
	return result;
}

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

static void
ft_size_stack_page_set_child (FtSizeStackPage* self,
                              GtkWidget* value)
{
	GtkWidget* old_value;
	g_return_if_fail (self != NULL);
	old_value = ft_size_stack_page_get_child (self);
	if (old_value != value) {
		GtkWidget* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_child);
		self->priv->_child = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, ft_size_stack_page_properties[FT_SIZE_STACK_PAGE_CHILD_PROPERTY]);
	}
}

const gchar*
ft_size_stack_page_get_name (FtSizeStackPage* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_name;
	result = _tmp0_;
	return result;
}

void
ft_size_stack_page_set_name (FtSizeStackPage* self,
                             const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = ft_size_stack_page_get_name (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_name);
		self->priv->_name = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, ft_size_stack_page_properties[FT_SIZE_STACK_PAGE_NAME_PROPERTY]);
	}
}

gboolean
ft_size_stack_page_get_resizable (FtSizeStackPage* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_resizable;
	return result;
}

void
ft_size_stack_page_set_resizable (FtSizeStackPage* self,
                                  gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = ft_size_stack_page_get_resizable (self);
	if (old_value != value) {
		self->priv->_resizable = value;
		g_object_notify_by_pspec ((GObject *) self, ft_size_stack_page_properties[FT_SIZE_STACK_PAGE_RESIZABLE_PROPERTY]);
	}
}

static void
ft_size_stack_page_class_init (FtSizeStackPageClass * klass,
                               gpointer klass_data)
{
	ft_size_stack_page_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FtSizeStackPage_private_offset);
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) ft_size_stack_page_real_dispose;
	G_OBJECT_CLASS (klass)->get_property = _vala_ft_size_stack_page_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_ft_size_stack_page_set_property;
	G_OBJECT_CLASS (klass)->finalize = ft_size_stack_page_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_SIZE_STACK_PAGE_CHILD_PROPERTY, ft_size_stack_page_properties[FT_SIZE_STACK_PAGE_CHILD_PROPERTY] = g_param_spec_object ("child", "child", "child", gtk_widget_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_SIZE_STACK_PAGE_NAME_PROPERTY, ft_size_stack_page_properties[FT_SIZE_STACK_PAGE_NAME_PROPERTY] = g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_SIZE_STACK_PAGE_RESIZABLE_PROPERTY, ft_size_stack_page_properties[FT_SIZE_STACK_PAGE_RESIZABLE_PROPERTY] = g_param_spec_boolean ("resizable", "resizable", "resizable", TRUE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
ft_size_stack_page_instance_init (FtSizeStackPage * self,
                                  gpointer klass)
{
	self->priv = ft_size_stack_page_get_instance_private (self);
	self->priv->_resizable = TRUE;
	self->last_focus = NULL;
	self->last_width = -1;
	self->last_height = -1;
}

static void
ft_size_stack_page_finalize (GObject * obj)
{
	FtSizeStackPage * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_SIZE_STACK_PAGE, FtSizeStackPage);
	_g_object_unref0 (self->priv->_child);
	_g_free0 (self->priv->_name);
	G_OBJECT_CLASS (ft_size_stack_page_parent_class)->finalize (obj);
}

static GType
ft_size_stack_page_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtSizeStackPageClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_size_stack_page_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtSizeStackPage), 0, (GInstanceInitFunc) ft_size_stack_page_instance_init, NULL };
	GType ft_size_stack_page_type_id;
	ft_size_stack_page_type_id = g_type_register_static (G_TYPE_OBJECT, "FtSizeStackPage", &g_define_type_info, 0);
	FtSizeStackPage_private_offset = g_type_add_instance_private (ft_size_stack_page_type_id, sizeof (FtSizeStackPagePrivate));
	return ft_size_stack_page_type_id;
}

GType
ft_size_stack_page_get_type (void)
{
	static volatile gsize ft_size_stack_page_type_id__once = 0;
	if (g_once_init_enter (&ft_size_stack_page_type_id__once)) {
		GType ft_size_stack_page_type_id;
		ft_size_stack_page_type_id = ft_size_stack_page_get_type_once ();
		g_once_init_leave (&ft_size_stack_page_type_id__once, ft_size_stack_page_type_id);
	}
	return ft_size_stack_page_type_id__once;
}

static void
_vala_ft_size_stack_page_get_property (GObject * object,
                                       guint property_id,
                                       GValue * value,
                                       GParamSpec * pspec)
{
	FtSizeStackPage * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_SIZE_STACK_PAGE, FtSizeStackPage);
	switch (property_id) {
		case FT_SIZE_STACK_PAGE_CHILD_PROPERTY:
		g_value_set_object (value, ft_size_stack_page_get_child (self));
		break;
		case FT_SIZE_STACK_PAGE_NAME_PROPERTY:
		g_value_set_string (value, ft_size_stack_page_get_name (self));
		break;
		case FT_SIZE_STACK_PAGE_RESIZABLE_PROPERTY:
		g_value_set_boolean (value, ft_size_stack_page_get_resizable (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_ft_size_stack_page_set_property (GObject * object,
                                       guint property_id,
                                       const GValue * value,
                                       GParamSpec * pspec)
{
	FtSizeStackPage * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_SIZE_STACK_PAGE, FtSizeStackPage);
	switch (property_id) {
		case FT_SIZE_STACK_PAGE_CHILD_PROPERTY:
		ft_size_stack_page_set_child (self, g_value_get_object (value));
		break;
		case FT_SIZE_STACK_PAGE_NAME_PROPERTY:
		ft_size_stack_page_set_name (self, g_value_get_string (value));
		break;
		case FT_SIZE_STACK_PAGE_RESIZABLE_PROPERTY:
		ft_size_stack_page_set_resizable (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
ft_size_stack_get_instance_private (FtSizeStack* self)
{
	return G_STRUCT_MEMBER_P (self, FtSizeStack_private_offset);
}

static void
_g_object_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}

static inline void
_g_list_free__g_object_unref0_ (GList* self)
{
	g_list_free_full (self, (GDestroyNotify) _g_object_unref0_);
}

static FtSizeStackPage*
ft_size_stack_find_page_by_child (FtSizeStack* self,
                                  GtkWidget* child)
{
	GList* link = NULL;
	GList* _tmp0_;
	GList* _tmp1_;
	FtSizeStackPage* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (child != NULL, NULL);
	_tmp0_ = self->priv->pages;
	_tmp1_ = g_list_first (_tmp0_);
	link = _tmp1_;
	while (TRUE) {
		GList* _tmp2_;
		GList* _tmp3_;
		gconstpointer _tmp4_;
		GtkWidget* _tmp5_;
		GtkWidget* _tmp6_;
		GList* _tmp9_;
		GList* _tmp10_;
		_tmp2_ = link;
		if (!(_tmp2_ != NULL)) {
			break;
		}
		_tmp3_ = link;
		_tmp4_ = _tmp3_->data;
		_tmp5_ = ft_size_stack_page_get_child ((FtSizeStackPage*) _tmp4_);
		_tmp6_ = _tmp5_;
		if (_tmp6_ == child) {
			GList* _tmp7_;
			gconstpointer _tmp8_;
			_tmp7_ = link;
			_tmp8_ = _tmp7_->data;
			result = (FtSizeStackPage*) _tmp8_;
			return result;
		}
		_tmp9_ = link;
		_tmp10_ = _tmp9_->next;
		link = _tmp10_;
	}
	result = NULL;
	return result;
}

static FtSizeStackPage*
ft_size_stack_find_page_by_name (FtSizeStack* self,
                                 const gchar* name)
{
	GList* link = NULL;
	GList* _tmp0_;
	GList* _tmp1_;
	FtSizeStackPage* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	_tmp0_ = self->priv->pages;
	_tmp1_ = g_list_first (_tmp0_);
	link = _tmp1_;
	while (TRUE) {
		GList* _tmp2_;
		GList* _tmp3_;
		gconstpointer _tmp4_;
		const gchar* _tmp5_;
		const gchar* _tmp6_;
		GList* _tmp9_;
		GList* _tmp10_;
		_tmp2_ = link;
		if (!(_tmp2_ != NULL)) {
			break;
		}
		_tmp3_ = link;
		_tmp4_ = _tmp3_->data;
		_tmp5_ = ft_size_stack_page_get_name ((FtSizeStackPage*) _tmp4_);
		_tmp6_ = _tmp5_;
		if (g_strcmp0 (_tmp6_, name) == 0) {
			GList* _tmp7_;
			gconstpointer _tmp8_;
			_tmp7_ = link;
			_tmp8_ = _tmp7_->data;
			result = (FtSizeStackPage*) _tmp8_;
			return result;
		}
		_tmp9_ = link;
		_tmp10_ = _tmp9_->next;
		link = _tmp10_;
	}
	result = NULL;
	return result;
}

static gfloat
ft_size_stack_get_transition_progress (FtSizeStack* self)
{
	gfloat _tmp0_ = 0.0F;
	AdwTimedAnimation* _tmp1_;
	gfloat result;
	g_return_val_if_fail (self != NULL, -1.0F);
	_tmp1_ = self->priv->transition_animation;
	if (_tmp1_ != NULL) {
		AdwTimedAnimation* _tmp2_;
		gdouble _tmp3_;
		gdouble _tmp4_;
		_tmp2_ = self->priv->transition_animation;
		_tmp3_ = adw_animation_get_value ((AdwAnimation*) _tmp2_);
		_tmp4_ = _tmp3_;
		_tmp0_ = (gfloat) _tmp4_;
	} else {
		_tmp0_ = 1.0f;
	}
	result = _tmp0_;
	return result;
}

static gboolean
___lambda33_ (FtSizeStack* self)
{
	gboolean result;
	self->priv->size_request_set = TRUE;
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
____lambda33__gtk_tick_callback (GtkWidget* widget,
                                 GdkFrameClock* frame_clock,
                                 gpointer self)
{
	gboolean result;
	result = ___lambda33_ ((FtSizeStack*) self);
	return result;
}

static void
ft_size_stack_stop_resizing_window (FtSizeStack* self)
{
	GtkWindow* window = NULL;
	GtkRoot* _tmp0_;
	GtkWindow* _tmp1_;
	gboolean _tmp2_ = FALSE;
	FtSizeStackPage* _tmp3_;
	gboolean resizable = FALSE;
	GtkWindow* _tmp7_;
	GtkWindow* _tmp8_;
	GtkWindow* _tmp9_;
	GtkWindow* _tmp10_;
	gboolean _tmp11_;
	gboolean _tmp12_;
	g_return_if_fail (self != NULL);
	_tmp0_ = gtk_widget_get_root ((GtkWidget*) self);
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, gtk_window_get_type ()) ? ((GtkWindow*) _tmp0_) : NULL);
	window = _tmp1_;
	_tmp3_ = self->priv->current_page;
	if (_tmp3_ != NULL) {
		FtSizeStackPage* _tmp4_;
		gboolean _tmp5_;
		gboolean _tmp6_;
		_tmp4_ = self->priv->current_page;
		_tmp5_ = ft_size_stack_page_get_resizable (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp2_ = _tmp6_;
	} else {
		_tmp2_ = TRUE;
	}
	resizable = _tmp2_;
	_tmp7_ = window;
	if (_tmp7_ == NULL) {
		_g_object_unref0 (window);
		return;
	}
	_tmp8_ = window;
	gtk_widget_set_halign ((GtkWidget*) _tmp8_, GTK_ALIGN_FILL);
	_tmp9_ = window;
	gtk_widget_set_valign ((GtkWidget*) _tmp9_, GTK_ALIGN_FILL);
	_tmp10_ = window;
	_tmp11_ = gtk_window_get_resizable (_tmp10_);
	_tmp12_ = _tmp11_;
	if (_tmp12_ != resizable) {
		GtkWindow* _tmp13_;
		_tmp13_ = window;
		gtk_window_set_resizable (_tmp13_, resizable);
	} else {
		gint width = 0;
		GtkWindow* _tmp14_;
		gint height = 0;
		GtkWindow* _tmp15_;
		GtkWindow* _tmp16_;
		_tmp14_ = window;
		width = gtk_widget_get_width ((GtkWidget*) _tmp14_);
		_tmp15_ = window;
		height = gtk_widget_get_height ((GtkWidget*) _tmp15_);
		_tmp16_ = window;
		gtk_widget_set_size_request ((GtkWidget*) _tmp16_, width, height);
		gtk_widget_add_tick_callback ((GtkWidget*) self, ____lambda33__gtk_tick_callback, g_object_ref (self), g_object_unref);
	}
	_g_object_unref0 (window);
}

static void
ft_size_stack_start_resizing_window (FtSizeStack* self)
{
	GtkWindow* window = NULL;
	GtkRoot* _tmp0_;
	GtkWindow* _tmp1_;
	GtkWindow* _tmp2_;
	GtkWindow* _tmp3_;
	GtkWindow* _tmp4_;
	GtkWindow* _tmp5_;
	GtkWindow* _tmp6_;
	g_return_if_fail (self != NULL);
	_tmp0_ = gtk_widget_get_root ((GtkWidget*) self);
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, gtk_window_get_type ()) ? ((GtkWindow*) _tmp0_) : NULL);
	window = _tmp1_;
	_tmp2_ = window;
	if (_tmp2_ == NULL) {
		_g_object_unref0 (window);
		return;
	}
	_tmp3_ = window;
	gtk_widget_set_halign ((GtkWidget*) _tmp3_, GTK_ALIGN_START);
	_tmp4_ = window;
	gtk_widget_set_valign ((GtkWidget*) _tmp4_, GTK_ALIGN_START);
	_tmp5_ = window;
	gtk_widget_set_size_request ((GtkWidget*) _tmp5_, -1, -1);
	_tmp6_ = window;
	gtk_window_set_resizable (_tmp6_, TRUE);
	_g_object_unref0 (window);
}

/**
         * In GTK4, Window insists on preserving its remembered size. We need to invalidate it.
         * See `gtk_window_compute_default_size`.
         */
static inline void
ft_size_stack_invalidate_window_default_size (FtSizeStack* self)
{
	GtkWindow* window = NULL;
	GtkRoot* _tmp0_;
	GtkWindow* _tmp1_;
	GtkWindow* _tmp2_ = NULL;
	GtkWindow* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = gtk_widget_get_root ((GtkWidget*) self);
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, gtk_window_get_type ()) ? ((GtkWindow*) _tmp0_) : NULL);
	window = _tmp1_;
	_tmp3_ = window;
	_tmp2_ = _tmp3_;
	if (_tmp2_ != NULL) {
		gtk_window_set_default_size (_tmp2_, -1, -1);
	}
	_g_object_unref0 (window);
}

/**
         * Call it after setting `visible_child` and `last_visible_child`.
         */
static void
__lambda34_ (FtSizeStack* self,
             gdouble value)
{
	gtk_widget_queue_resize ((GtkWidget*) self);
	ft_size_stack_invalidate_window_default_size (self);
}

static void
___lambda34__adw_animation_target_func (gdouble value,
                                        gpointer self)
{
	__lambda34_ ((FtSizeStack*) self, value);
}

static void
__lambda35_ (FtSizeStack* self)
{
	FtSizeStackPage* _tmp0_;
	_g_object_unref0 (self->priv->transition_animation);
	self->priv->transition_animation = NULL;
	_tmp0_ = self->priv->previous_page;
	if (_tmp0_ != NULL) {
		FtSizeStackPage* _tmp1_;
		GtkWidget* _tmp2_;
		GtkWidget* _tmp3_;
		_tmp1_ = self->priv->previous_page;
		_tmp2_ = ft_size_stack_page_get_child (_tmp1_);
		_tmp3_ = _tmp2_;
		gtk_widget_set_child_visible (_tmp3_, FALSE);
		self->priv->previous_page = NULL;
	}
	ft_size_stack_stop_resizing_window (self);
	gtk_widget_queue_resize ((GtkWidget*) self);
}

static void
___lambda35__adw_animation_done (AdwAnimation* _sender,
                                 gpointer self)
{
	__lambda35_ ((FtSizeStack*) self);
}

static void
ft_size_stack_start_transition (FtSizeStack* self,
                                guint transition_duration)
{
	FtSizeStackPage* _tmp0_;
	FtSizeStackPage* _tmp1_;
	AdwTimedAnimation* _tmp2_;
	AdwCallbackAnimationTarget* animation_target = NULL;
	AdwCallbackAnimationTarget* _tmp4_;
	AdwTimedAnimation* animation = NULL;
	AdwAnimationTarget* _tmp5_;
	AdwTimedAnimation* _tmp6_;
	AdwTimedAnimation* _tmp7_;
	AdwTimedAnimation* _tmp8_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->current_page;
	_tmp1_ = self->priv->previous_page;
	_vala_return_if_fail ((_tmp0_ != NULL) && (_tmp1_ != NULL), "this.current_page != null && this.previous_page != null");
	_tmp2_ = self->priv->transition_animation;
	if (_tmp2_ != NULL) {
		AdwTimedAnimation* _tmp3_;
		_tmp3_ = self->priv->transition_animation;
		adw_animation_pause ((AdwAnimation*) _tmp3_);
		_g_object_unref0 (self->priv->transition_animation);
		self->priv->transition_animation = NULL;
	}
	ft_size_stack_start_resizing_window (self);
	_tmp4_ = (AdwCallbackAnimationTarget*) adw_callback_animation_target_new (___lambda34__adw_animation_target_func, g_object_ref (self), g_object_unref);
	animation_target = _tmp4_;
	_tmp5_ = _g_object_ref0 ((AdwAnimationTarget*) animation_target);
	_tmp6_ = (AdwTimedAnimation*) adw_timed_animation_new ((GtkWidget*) self, 0.0, 1.0, transition_duration, _tmp5_);
	animation = _tmp6_;
	adw_timed_animation_set_easing (animation, ADW_EASE_IN_OUT_CUBIC);
	g_signal_connect_object ((AdwAnimation*) animation, "done", (GCallback) ___lambda35__adw_animation_done, self, 0);
	_tmp7_ = _g_object_ref0 (animation);
	_g_object_unref0 (self->priv->transition_animation);
	self->priv->transition_animation = _tmp7_;
	_tmp8_ = self->priv->transition_animation;
	adw_animation_play ((AdwAnimation*) _tmp8_);
	_g_object_unref0 (animation);
	_g_object_unref0 (animation_target);
}

static void
ft_size_stack_select_page (FtSizeStack* self,
                           FtSizeStackPage* page,
                           gboolean transition)
{
	gboolean _tmp0_ = FALSE;
	FtSizeStackPage* _tmp1_;
	gboolean contains_focus = FALSE;
	FtSizeStackPage* _tmp2_ = NULL;
	FtSizeStackPage* _tmp3_;
	GtkWidget* _tmp4_ = NULL;
	GtkWidget* current_child = NULL;
	GtkWidget* _tmp7_;
	gboolean _tmp8_ = FALSE;
	GtkWidget* _tmp9_;
	gboolean _tmp34_ = FALSE;
	FtSizeStackPage* _tmp35_;
	FtSizeStackPage* _tmp40_;
	GtkWidget* _tmp41_;
	GtkWidget* _tmp42_;
	gboolean _tmp47_ = FALSE;
	FtSizeStackPage* _tmp48_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (page != NULL);
	_tmp1_ = self->priv->current_page;
	if (page == _tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = gtk_widget_in_destruction ((GtkWidget*) self);
	}
	if (_tmp0_) {
		return;
	}
	contains_focus = FALSE;
	_tmp3_ = self->priv->current_page;
	_tmp2_ = _tmp3_;
	_tmp4_ = NULL;
	if (_tmp2_ != NULL) {
		GtkWidget* _tmp5_;
		GtkWidget* _tmp6_;
		_tmp5_ = ft_size_stack_page_get_child (_tmp2_);
		_tmp6_ = _tmp5_;
		_tmp4_ = _tmp6_;
	}
	_tmp7_ = _g_object_ref0 (_tmp4_);
	current_child = _tmp7_;
	_tmp9_ = current_child;
	if (_tmp9_ != NULL) {
		AdwTimedAnimation* _tmp10_;
		_tmp10_ = self->priv->transition_animation;
		_tmp8_ = _tmp10_ == NULL;
	} else {
		_tmp8_ = FALSE;
	}
	if (_tmp8_) {
		GtkRoot* _tmp11_ = NULL;
		GtkRoot* _tmp12_;
		GtkRoot* _tmp13_;
		GtkWidget* _tmp14_ = NULL;
		GtkWidget* focus = NULL;
		GtkWidget* _tmp16_;
		GtkRequisition minimum_size = {0};
		GtkRequisition natural_size = {0};
		gint last_width = 0;
		gint last_height = 0;
		GtkWidget* last_focus = NULL;
		gboolean _tmp17_ = FALSE;
		GtkWidget* _tmp18_;
		GtkWidget* _tmp22_;
		GtkWidget* _tmp23_;
		gboolean _tmp24_ = FALSE;
		FtSizeStackPage* _tmp30_;
		GtkWidget* _tmp31_;
		FtSizeStackPage* _tmp32_;
		FtSizeStackPage* _tmp33_;
		_tmp12_ = gtk_widget_get_root ((GtkWidget*) self);
		_tmp13_ = _tmp12_;
		_tmp11_ = _tmp13_;
		_tmp14_ = NULL;
		if (_tmp11_ != NULL) {
			GtkWidget* _tmp15_;
			_tmp15_ = gtk_root_get_focus (_tmp11_);
			_tmp14_ = _tmp15_;
		}
		_tmp16_ = _g_object_ref0 (_tmp14_);
		focus = _tmp16_;
		memset (&minimum_size, 0, sizeof (GtkRequisition));
		memset (&natural_size, 0, sizeof (GtkRequisition));
		last_width = -1;
		last_height = -1;
		last_focus = NULL;
		_tmp18_ = focus;
		if (_tmp18_ != NULL) {
			GtkWidget* _tmp19_;
			GtkWidget* _tmp20_;
			_tmp19_ = focus;
			_tmp20_ = current_child;
			_tmp17_ = gtk_widget_is_ancestor (_tmp19_, _tmp20_);
		} else {
			_tmp17_ = FALSE;
		}
		if (_tmp17_) {
			GtkWidget* _tmp21_;
			contains_focus = TRUE;
			_tmp21_ = focus;
			last_focus = _tmp21_;
		} else {
			last_focus = NULL;
		}
		_tmp22_ = current_child;
		last_width = gtk_widget_get_width (_tmp22_);
		_tmp23_ = current_child;
		last_height = gtk_widget_get_height (_tmp23_);
		if (last_width <= 0) {
			_tmp24_ = TRUE;
		} else {
			_tmp24_ = last_height <= 0;
		}
		if (_tmp24_) {
			GtkWidget* _tmp25_;
			GtkRequisition _tmp26_ = {0};
			GtkRequisition _tmp27_ = {0};
			GtkRequisition _tmp28_;
			GtkRequisition _tmp29_;
			_tmp25_ = current_child;
			gtk_widget_get_preferred_size (_tmp25_, &_tmp26_, &_tmp27_);
			minimum_size = _tmp26_;
			natural_size = _tmp27_;
			_tmp28_ = natural_size;
			last_width = _tmp28_.width;
			_tmp29_ = natural_size;
			last_height = _tmp29_.height;
		}
		_tmp30_ = self->priv->current_page;
		_tmp31_ = last_focus;
		_tmp30_->last_focus = _tmp31_;
		_tmp32_ = self->priv->current_page;
		_tmp32_->last_width = last_width;
		_tmp33_ = self->priv->current_page;
		_tmp33_->last_height = last_height;
		_g_object_unref0 (focus);
	}
	_tmp35_ = self->priv->previous_page;
	if (_tmp35_ != NULL) {
		FtSizeStackPage* _tmp36_;
		_tmp36_ = self->priv->previous_page;
		_tmp34_ = _tmp36_ != page;
	} else {
		_tmp34_ = FALSE;
	}
	if (_tmp34_) {
		FtSizeStackPage* _tmp37_;
		GtkWidget* _tmp38_;
		GtkWidget* _tmp39_;
		_tmp37_ = self->priv->previous_page;
		_tmp38_ = ft_size_stack_page_get_child (_tmp37_);
		_tmp39_ = _tmp38_;
		gtk_widget_set_child_visible (_tmp39_, FALSE);
		self->priv->previous_page = NULL;
	}
	_tmp40_ = self->priv->current_page;
	self->priv->previous_page = _tmp40_;
	self->priv->current_page = page;
	_tmp41_ = ft_size_stack_page_get_child (page);
	_tmp42_ = _tmp41_;
	gtk_widget_set_child_visible (_tmp42_, TRUE);
	if (contains_focus) {
		GtkWidget* _tmp43_;
		_tmp43_ = page->last_focus;
		if (_tmp43_ != NULL) {
			GtkWidget* _tmp44_;
			_tmp44_ = page->last_focus;
			gtk_widget_grab_focus (_tmp44_);
		} else {
			GtkWidget* _tmp45_;
			GtkWidget* _tmp46_;
			_tmp45_ = ft_size_stack_page_get_child (page);
			_tmp46_ = _tmp45_;
			gtk_widget_child_focus (_tmp46_, GTK_DIR_TAB_FORWARD);
		}
	}
	_tmp48_ = self->priv->current_page;
	if (_tmp48_ != NULL) {
		FtSizeStackPage* _tmp49_;
		_tmp49_ = self->priv->previous_page;
		_tmp47_ = _tmp49_ != NULL;
	} else {
		_tmp47_ = FALSE;
	}
	if (_tmp47_) {
		guint _tmp50_ = 0U;
		if (transition) {
			guint _tmp51_;
			_tmp51_ = self->priv->_transition_duration;
			_tmp50_ = _tmp51_;
		} else {
			_tmp50_ = (guint) 0;
		}
		ft_size_stack_start_transition (self, _tmp50_);
	} else {
		gtk_widget_queue_resize ((GtkWidget*) self);
	}
	g_object_notify ((GObject*) self, "visible-child");
	g_object_notify ((GObject*) self, "visible-child-name");
	_g_object_unref0 (current_child);
}

static GList*
vala_g_list_remove_full (GList* self,
                         gconstpointer data,
                         GFreeFunc func)
{
	GList* l = NULL;
	GList* result;
	l = self;
	while (TRUE) {
		GList* _tmp0_;
		GList* _tmp1_;
		gconstpointer _tmp2_;
		_tmp0_ = l;
		if (!(_tmp0_ != NULL)) {
			break;
		}
		_tmp1_ = l;
		_tmp2_ = ((GList*) _tmp1_)->data;
		if (_tmp2_ != data) {
			GList* _tmp3_;
			GList* _tmp4_;
			_tmp3_ = l;
			_tmp4_ = ((GList*) _tmp3_)->next;
			l = _tmp4_;
		} else {
			GList* _tmp5_;
			gconstpointer _tmp6_;
			GList* _tmp7_;
			_tmp5_ = l;
			_tmp6_ = ((GList*) _tmp5_)->data;
			func (_tmp6_);
			_tmp7_ = l;
			self = g_list_delete_link (self, (GList*) _tmp7_);
			break;
		}
	}
	result = self;
	return result;
}

static void
ft_size_stack_remove_page (FtSizeStack* self,
                           FtSizeStackPage* page)
{
	GList* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	FtSizeStackPage* _tmp3_;
	FtSizeStackPage* _tmp4_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (page != NULL);
	_tmp0_ = self->priv->pages;
	if (g_list_index (_tmp0_, page) < 0) {
		return;
	}
	_tmp1_ = ft_size_stack_page_get_child (page);
	_tmp2_ = _tmp1_;
	gtk_widget_unparent (_tmp2_);
	_tmp3_ = self->priv->current_page;
	if (_tmp3_ == page) {
		self->priv->current_page = NULL;
	}
	_tmp4_ = self->priv->previous_page;
	if (_tmp4_ == page) {
		self->priv->previous_page = NULL;
	}
	self->priv->pages = vala_g_list_remove_full (self->priv->pages, page, _g_object_unref0_);
}

static void
ft_size_stack_add_page (FtSizeStack* self,
                        FtSizeStackPage* page)
{
	GList* _tmp0_;
	GtkWidget* child = NULL;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp3_;
	GtkWidget* _tmp4_;
	GtkWidget* _tmp5_;
	FtSizeStackPage* _tmp6_;
	FtSizeStackPage* _tmp7_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (page != NULL);
	_tmp0_ = self->priv->pages;
	if (g_list_index (_tmp0_, page) >= 0) {
		return;
	}
	_tmp1_ = ft_size_stack_page_get_child (page);
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	child = _tmp3_;
	_tmp4_ = child;
	gtk_widget_set_child_visible (_tmp4_, FALSE);
	_tmp5_ = child;
	gtk_widget_set_parent (_tmp5_, (GtkWidget*) self);
	_tmp6_ = _g_object_ref0 (page);
	self->priv->pages = g_list_append (self->priv->pages, _tmp6_);
	_tmp7_ = self->priv->current_page;
	if (_tmp7_ == NULL) {
		ft_size_stack_select_page (self, page, FALSE);
	}
	_g_object_unref0 (child);
}

static void
ft_size_stack_real_add_child (GtkBuildable* base,
                              GtkBuilder* builder,
                              GObject* object,
                              const gchar* type)
{
	FtSizeStack * self;
	self = (FtSizeStack*) base;
	g_return_if_fail (builder != NULL);
	g_return_if_fail (object != NULL);
	if (FT_IS_SIZE_STACK_PAGE (object)) {
		ft_size_stack_add_page (self, G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_SIZE_STACK_PAGE, FtSizeStackPage));
	} else {
		if (G_TYPE_CHECK_INSTANCE_TYPE (object, gtk_widget_get_type ())) {
			FtSizeStackPage* _tmp0_;
			FtSizeStackPage* _tmp1_;
			_tmp0_ = ft_size_stack_page_new (G_TYPE_CHECK_INSTANCE_CAST (object, gtk_widget_get_type (), GtkWidget));
			_tmp1_ = _tmp0_;
			ft_size_stack_add_page (self, _tmp1_);
			_g_object_unref0 (_tmp1_);
		} else {
			ft_size_stack_gtk_buildable_parent_iface->add_child ((GtkBuildable*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), builder, object, type);
		}
	}
}

static void
ft_size_stack_real_realize (GtkWidget* base)
{
	FtSizeStack * self;
	self = (FtSizeStack*) base;
	GTK_WIDGET_CLASS (ft_size_stack_parent_class)->realize (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
	ft_size_stack_invalidate_window_default_size (self);
}

static void
ft_size_stack_real_compute_expand_internal (GtkWidget* base,
                                            gboolean* hexpand,
                                            gboolean* vexpand)
{
	FtSizeStack * self;
	gboolean _vala_hexpand = FALSE;
	gboolean _vala_vexpand = FALSE;
	GtkWidget* child = NULL;
	GtkWidget* _tmp0_;
	self = (FtSizeStack*) base;
	_tmp0_ = gtk_widget_get_first_child ((GtkWidget*) self);
	child = _tmp0_;
	_vala_hexpand = FALSE;
	_vala_vexpand = FALSE;
	while (TRUE) {
		GtkWidget* _tmp1_;
		gboolean _tmp2_ = FALSE;
		GtkWidget* _tmp3_;
		gboolean _tmp4_;
		gboolean _tmp5_;
		gboolean _tmp9_ = FALSE;
		GtkWidget* _tmp10_;
		gboolean _tmp11_;
		gboolean _tmp12_;
		GtkWidget* _tmp16_;
		GtkWidget* _tmp17_;
		_tmp1_ = child;
		if (!(_tmp1_ != NULL)) {
			break;
		}
		_tmp3_ = child;
		_tmp4_ = gtk_widget_get_hexpand_set (_tmp3_);
		_tmp5_ = _tmp4_;
		if (_tmp5_) {
			GtkWidget* _tmp6_;
			gboolean _tmp7_;
			gboolean _tmp8_;
			_tmp6_ = child;
			_tmp7_ = gtk_widget_get_hexpand (_tmp6_);
			_tmp8_ = _tmp7_;
			_tmp2_ = _tmp8_;
		} else {
			_tmp2_ = FALSE;
		}
		_vala_hexpand = _vala_hexpand | _tmp2_;
		_tmp10_ = child;
		_tmp11_ = gtk_widget_get_vexpand_set (_tmp10_);
		_tmp12_ = _tmp11_;
		if (_tmp12_) {
			GtkWidget* _tmp13_;
			gboolean _tmp14_;
			gboolean _tmp15_;
			_tmp13_ = child;
			_tmp14_ = gtk_widget_get_vexpand (_tmp13_);
			_tmp15_ = _tmp14_;
			_tmp9_ = _tmp15_;
		} else {
			_tmp9_ = FALSE;
		}
		_vala_vexpand = _vala_vexpand | _tmp9_;
		_tmp16_ = child;
		_tmp17_ = gtk_widget_get_next_sibling (_tmp16_);
		child = _tmp17_;
	}
	if (hexpand) {
		*hexpand = _vala_hexpand;
	}
	if (vexpand) {
		*vexpand = _vala_vexpand;
	}
}

static GtkSizeRequestMode
ft_size_stack_real_get_request_mode (GtkWidget* base)
{
	FtSizeStack * self;
	GtkSizeRequestMode result;
	self = (FtSizeStack*) base;
	result = GTK_SIZE_REQUEST_CONSTANT_SIZE;
	return result;
}

static void
ft_size_stack_real_measure (GtkWidget* base,
                            GtkOrientation orientation,
                            gint for_size,
                            gint* minimum,
                            gint* natural,
                            gint* minimum_baseline,
                            gint* natural_baseline)
{
	FtSizeStack * self;
	gint _vala_minimum = 0;
	gint _vala_natural = 0;
	gint _vala_minimum_baseline = 0;
	gint _vala_natural_baseline = 0;
	FtSizeStackPage* _tmp0_;
	gint _tmp1_ = 0;
	gint last_size = 0;
	gint minimum_for_size = 0;
	gboolean _tmp4_ = FALSE;
	FtSizeStackPage* _tmp15_;
	self = (FtSizeStack*) base;
	_vala_minimum = 0;
	_vala_natural = 0;
	_vala_minimum_baseline = -1;
	_vala_natural_baseline = -1;
	_tmp0_ = self->priv->current_page;
	if (_tmp0_ == NULL) {
		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;
	}
	if (orientation == GTK_ORIENTATION_HORIZONTAL) {
		FtSizeStackPage* _tmp2_;
		_tmp2_ = self->priv->current_page;
		_tmp1_ = _tmp2_->last_width;
	} else {
		FtSizeStackPage* _tmp3_;
		_tmp3_ = self->priv->current_page;
		_tmp1_ = _tmp3_->last_height;
	}
	last_size = _tmp1_;
	minimum_for_size = 0;
	if (last_size <= 0) {
		_tmp4_ = TRUE;
	} else {
		AdwTimedAnimation* _tmp5_;
		_tmp5_ = self->priv->transition_animation;
		_tmp4_ = _tmp5_ == NULL;
	}
	if (_tmp4_) {
		FtSizeStackPage* _tmp6_;
		GtkWidget* _tmp7_;
		GtkWidget* _tmp8_;
		gint _tmp9_ = 0;
		FtSizeStackPage* _tmp10_;
		GtkWidget* _tmp11_;
		GtkWidget* _tmp12_;
		gint _tmp13_ = 0;
		gint _tmp14_ = 0;
		_tmp6_ = self->priv->current_page;
		_tmp7_ = ft_size_stack_page_get_child (_tmp6_);
		_tmp8_ = _tmp7_;
		gtk_widget_measure (_tmp8_, ft_get_opposite_orientation (orientation), -1, &_tmp9_, NULL, NULL, NULL);
		minimum_for_size = _tmp9_;
		_tmp10_ = self->priv->current_page;
		_tmp11_ = ft_size_stack_page_get_child (_tmp10_);
		_tmp12_ = _tmp11_;
		gtk_widget_measure (_tmp12_, orientation, minimum_for_size, &_tmp13_, &_tmp14_, NULL, NULL);
		_vala_minimum = _tmp13_;
		_vala_natural = _tmp14_;
	} else {
		_vala_minimum = 0;
		_vala_natural = last_size;
	}
	_tmp15_ = self->priv->previous_page;
	if (_tmp15_ != NULL) {
		gint _tmp16_ = 0;
		gint previous_size = 0;
		gfloat t = 0.0F;
		if (orientation == GTK_ORIENTATION_HORIZONTAL) {
			FtSizeStackPage* _tmp17_;
			_tmp17_ = self->priv->previous_page;
			_tmp16_ = _tmp17_->last_width;
		} else {
			FtSizeStackPage* _tmp18_;
			_tmp18_ = self->priv->previous_page;
			_tmp16_ = _tmp18_->last_height;
		}
		previous_size = _tmp16_;
		t = ft_size_stack_get_transition_progress (self);
		_vala_natural = (gint) roundf (ft_lerpf ((gfloat) previous_size, (gfloat) _vala_natural, t));
	}
	if (_vala_natural < _vala_minimum) {
		_vala_natural = _vala_minimum;
	}
	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 void
ft_size_stack_real_size_allocate (GtkWidget* base,
                                  gint width,
                                  gint height,
                                  gint baseline)
{
	FtSizeStack * self;
	FtSizeStackPage* _tmp0_ = NULL;
	FtSizeStackPage* _tmp1_;
	GtkWidget* _tmp2_ = NULL;
	GtkWidget* current_child = NULL;
	FtSizeStackPage* _tmp5_ = NULL;
	FtSizeStackPage* _tmp6_;
	GtkWidget* _tmp7_ = NULL;
	GtkWidget* previous_child = NULL;
	GtkWidget* _tmp14_;
	GtkWidget* _tmp23_;
	self = (FtSizeStack*) base;
	_tmp1_ = self->priv->current_page;
	_tmp0_ = _tmp1_;
	_tmp2_ = NULL;
	if (_tmp0_ != NULL) {
		GtkWidget* _tmp3_;
		GtkWidget* _tmp4_;
		_tmp3_ = ft_size_stack_page_get_child (_tmp0_);
		_tmp4_ = _tmp3_;
		_tmp2_ = _tmp4_;
	}
	current_child = _tmp2_;
	_tmp6_ = self->priv->previous_page;
	_tmp5_ = _tmp6_;
	_tmp7_ = NULL;
	if (_tmp5_ != NULL) {
		GtkWidget* _tmp8_;
		GtkWidget* _tmp9_;
		_tmp8_ = ft_size_stack_page_get_child (_tmp5_);
		_tmp9_ = _tmp8_;
		_tmp7_ = _tmp9_;
	}
	previous_child = _tmp7_;
	if (self->priv->size_request_set) {
		GtkWindow* window = NULL;
		GtkRoot* _tmp10_;
		GtkWindow* _tmp11_;
		GtkWindow* _tmp12_ = NULL;
		GtkWindow* _tmp13_;
		self->priv->size_request_set = FALSE;
		_tmp10_ = gtk_widget_get_root ((GtkWidget*) self);
		_tmp11_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp10_, gtk_window_get_type ()) ? ((GtkWindow*) _tmp10_) : NULL);
		window = _tmp11_;
		_tmp13_ = window;
		_tmp12_ = _tmp13_;
		if (_tmp12_ != NULL) {
			gtk_widget_set_size_request ((GtkWidget*) _tmp12_, -1, -1);
		}
		_g_object_unref0 (window);
	}
	_tmp14_ = previous_child;
	if (_tmp14_ != NULL) {
		GtkAllocation previous_child_allocation = {0};
		FtSizeStackPage* _tmp15_;
		FtSizeStackPage* _tmp16_;
		GtkAllocation _tmp17_ = {0};
		FtSizeStackPage* _tmp18_;
		FtSizeStackPage* _tmp19_;
		GtkWidget* _tmp21_;
		GtkAllocation _tmp22_;
		_tmp15_ = self->priv->previous_page;
		_tmp16_ = self->priv->previous_page;
		memset (&_tmp17_, 0, sizeof (GtkAllocation));
		_tmp17_.x = 0;
		_tmp17_.y = 0;
		_tmp17_.width = MAX (_tmp15_->last_width, width);
		_tmp17_.height = MAX (_tmp16_->last_height, height);
		previous_child_allocation = _tmp17_;
		_tmp18_ = self->priv->current_page;
		_tmp19_ = self->priv->previous_page;
		if (_tmp18_->last_width > (2 * _tmp19_->last_width)) {
			FtSizeStackPage* _tmp20_;
			_tmp20_ = self->priv->previous_page;
			previous_child_allocation.width = _tmp20_->last_width;
		}
		_tmp21_ = previous_child;
		_tmp22_ = previous_child_allocation;
		gtk_widget_size_allocate (_tmp21_, &_tmp22_, baseline);
	}
	_tmp23_ = current_child;
	if (_tmp23_ != NULL) {
		GtkAllocation current_child_allocation = {0};
		GtkAllocation _tmp24_ = {0};
		AdwTimedAnimation* _tmp25_;
		GtkWidget* _tmp30_;
		GtkAllocation _tmp31_;
		memset (&_tmp24_, 0, sizeof (GtkAllocation));
		_tmp24_.x = 0;
		_tmp24_.y = 0;
		_tmp24_.width = width;
		_tmp24_.height = height;
		current_child_allocation = _tmp24_;
		_tmp25_ = self->priv->transition_animation;
		if (_tmp25_ != NULL) {
			FtSizeStackPage* _tmp26_;
			FtSizeStackPage* _tmp27_;
			_tmp26_ = self->priv->current_page;
			current_child_allocation.width = MAX (_tmp26_->last_width, width);
			_tmp27_ = self->priv->current_page;
			current_child_allocation.height = MAX (_tmp27_->last_height, height);
		} else {
			FtSizeStackPage* _tmp28_;
			FtSizeStackPage* _tmp29_;
			_tmp28_ = self->priv->current_page;
			_tmp28_->last_width = width;
			_tmp29_ = self->priv->current_page;
			_tmp29_->last_height = height;
		}
		_tmp30_ = current_child;
		_tmp31_ = current_child_allocation;
		gtk_widget_size_allocate (_tmp30_, &_tmp31_, baseline);
	}
}

static void
ft_size_stack_real_snapshot (GtkWidget* base,
                             GtkSnapshot* snapshot)
{
	FtSizeStack * self;
	FtSizeStackPage* _tmp0_ = NULL;
	FtSizeStackPage* _tmp1_;
	GtkWidget* _tmp2_ = NULL;
	GtkWidget* current_child = NULL;
	FtSizeStackPage* _tmp5_ = NULL;
	FtSizeStackPage* _tmp6_;
	GtkWidget* _tmp7_ = NULL;
	GtkWidget* previous_child = NULL;
	gboolean _tmp10_ = FALSE;
	GtkWidget* _tmp11_;
	gboolean _tmp15_ = FALSE;
	gboolean _tmp16_ = FALSE;
	AdwTimedAnimation* _tmp17_;
	self = (FtSizeStack*) base;
	g_return_if_fail (snapshot != NULL);
	_tmp1_ = self->priv->current_page;
	_tmp0_ = _tmp1_;
	_tmp2_ = NULL;
	if (_tmp0_ != NULL) {
		GtkWidget* _tmp3_;
		GtkWidget* _tmp4_;
		_tmp3_ = ft_size_stack_page_get_child (_tmp0_);
		_tmp4_ = _tmp3_;
		_tmp2_ = _tmp4_;
	}
	current_child = _tmp2_;
	_tmp6_ = self->priv->previous_page;
	_tmp5_ = _tmp6_;
	_tmp7_ = NULL;
	if (_tmp5_ != NULL) {
		GtkWidget* _tmp8_;
		GtkWidget* _tmp9_;
		_tmp8_ = ft_size_stack_page_get_child (_tmp5_);
		_tmp9_ = _tmp8_;
		_tmp7_ = _tmp9_;
	}
	previous_child = _tmp7_;
	_tmp11_ = current_child;
	if (_tmp11_ == NULL) {
		_tmp10_ = TRUE;
	} else {
		GtkWidget* _tmp12_;
		gboolean _tmp13_;
		gboolean _tmp14_;
		_tmp12_ = current_child;
		_tmp13_ = gtk_widget_get_visible (_tmp12_);
		_tmp14_ = _tmp13_;
		_tmp10_ = !_tmp14_;
	}
	if (_tmp10_) {
		return;
	}
	_tmp17_ = self->priv->transition_animation;
	if (_tmp17_ != NULL) {
		GtkWidget* _tmp18_;
		_tmp18_ = previous_child;
		_tmp16_ = _tmp18_ != NULL;
	} else {
		_tmp16_ = FALSE;
	}
	if (_tmp16_) {
		GtkWidget* _tmp19_;
		gboolean _tmp20_;
		gboolean _tmp21_;
		_tmp19_ = previous_child;
		_tmp20_ = gtk_widget_get_visible (_tmp19_);
		_tmp21_ = _tmp20_;
		_tmp15_ = _tmp21_;
	} else {
		_tmp15_ = FALSE;
	}
	if (_tmp15_) {
		gdouble progress = 0.0;
		GtkWidget* _tmp22_;
		GtkWidget* _tmp23_;
		progress = (gdouble) powf ((gfloat) ft_size_stack_get_transition_progress (self), 1.5f);
		gtk_snapshot_push_cross_fade (snapshot, progress);
		_tmp22_ = previous_child;
		gtk_widget_snapshot_child ((GtkWidget*) self, _tmp22_, snapshot);
		gtk_snapshot_pop (snapshot);
		_tmp23_ = current_child;
		gtk_widget_snapshot_child ((GtkWidget*) self, _tmp23_, snapshot);
		gtk_snapshot_pop (snapshot);
	} else {
		GtkWidget* _tmp24_;
		_tmp24_ = current_child;
		gtk_widget_snapshot_child ((GtkWidget*) self, _tmp24_, snapshot);
	}
}

static void
ft_size_stack_real_dispose (GObject* base)
{
	FtSizeStack * self;
	GList* link = NULL;
	GList* _tmp0_;
	GList* _tmp1_;
	self = (FtSizeStack*) base;
	_tmp0_ = self->priv->pages;
	_tmp1_ = g_list_first (_tmp0_);
	link = _tmp1_;
	while (TRUE) {
		GList* _tmp2_;
		GList* _tmp3_;
		gconstpointer _tmp4_;
		GList* _tmp5_;
		GList* _tmp6_;
		_tmp2_ = link;
		if (!(_tmp2_ != NULL)) {
			break;
		}
		_tmp3_ = link;
		_tmp4_ = _tmp3_->data;
		ft_size_stack_remove_page (self, (FtSizeStackPage*) _tmp4_);
		_tmp5_ = self->priv->pages;
		_tmp6_ = g_list_first (_tmp5_);
		link = _tmp6_;
	}
	(self->priv->pages == NULL) ? NULL : (self->priv->pages = (_g_list_free__g_object_unref0_ (self->priv->pages), NULL));
	self->priv->pages = NULL;
	_g_object_unref0 (self->priv->transition_animation);
	self->priv->transition_animation = NULL;
	self->priv->current_page = NULL;
	self->priv->previous_page = NULL;
	G_OBJECT_CLASS (ft_size_stack_parent_class)->dispose ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
}

FtSizeStack*
ft_size_stack_construct (GType object_type)
{
	FtSizeStack * self = NULL;
	self = (FtSizeStack*) g_object_new (object_type, NULL);
	return self;
}

FtSizeStack*
ft_size_stack_new (void)
{
	return ft_size_stack_construct (FT_TYPE_SIZE_STACK);
}

GtkWidget*
ft_size_stack_get_visible_child (FtSizeStack* self)
{
	GtkWidget* result;
	FtSizeStackPage* _tmp0_ = NULL;
	FtSizeStackPage* _tmp1_;
	GtkWidget* _tmp2_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp1_ = self->priv->current_page;
	_tmp0_ = _tmp1_;
	_tmp2_ = NULL;
	if (_tmp0_ != NULL) {
		GtkWidget* _tmp3_;
		GtkWidget* _tmp4_;
		_tmp3_ = ft_size_stack_page_get_child (_tmp0_);
		_tmp4_ = _tmp3_;
		_tmp2_ = _tmp4_;
	}
	result = _tmp2_;
	return result;
}

void
ft_size_stack_set_visible_child (FtSizeStack* self,
                                 GtkWidget* value)
{
	FtSizeStackPage* page = NULL;
	FtSizeStackPage* _tmp0_;
	FtSizeStackPage* _tmp1_;
	FtSizeStackPage* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = ft_size_stack_find_page_by_child (self, value);
	page = _tmp0_;
	_tmp1_ = page;
	if (_tmp1_ == NULL) {
		const gchar* _tmp2_;
		_tmp2_ = g_type_name (G_TYPE_FROM_INSTANCE ((GObject*) value));
		g_warning ("size-stack.vala:53: Given child of type '%s' not found in PomodoroSize" \
"Stack", _tmp2_);
		return;
	}
	_tmp3_ = page;
	ft_size_stack_select_page (self, _tmp3_, TRUE);
	g_object_notify_by_pspec ((GObject *) self, ft_size_stack_properties[FT_SIZE_STACK_VISIBLE_CHILD_PROPERTY]);
}

const gchar*
ft_size_stack_get_visible_child_name (FtSizeStack* self)
{
	const gchar* result;
	const gchar* _tmp0_ = NULL;
	FtSizeStackPage* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp1_ = self->priv->current_page;
	if (_tmp1_ != NULL) {
		FtSizeStackPage* _tmp2_;
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		_tmp2_ = self->priv->current_page;
		_tmp3_ = ft_size_stack_page_get_name (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_;
	} else {
		_tmp0_ = "";
	}
	result = _tmp0_;
	return result;
}

void
ft_size_stack_set_visible_child_name (FtSizeStack* self,
                                      const gchar* value)
{
	FtSizeStackPage* page = NULL;
	FtSizeStackPage* _tmp0_;
	FtSizeStackPage* _tmp1_;
	FtSizeStackPage* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = ft_size_stack_find_page_by_name (self, value);
	page = _tmp0_;
	_tmp1_ = page;
	if (_tmp1_ == NULL) {
		g_warning ("size-stack.vala:72: Page with name '%s' not found in PomodoroSizeStack", value);
		return;
	}
	_tmp2_ = page;
	ft_size_stack_select_page (self, _tmp2_, TRUE);
	g_object_notify_by_pspec ((GObject *) self, ft_size_stack_properties[FT_SIZE_STACK_VISIBLE_CHILD_NAME_PROPERTY]);
}

guint
ft_size_stack_get_transition_duration (FtSizeStack* self)
{
	guint result;
	g_return_val_if_fail (self != NULL, 0U);
	result = self->priv->_transition_duration;
	return result;
}

void
ft_size_stack_set_transition_duration (FtSizeStack* self,
                                       guint value)
{
	guint old_value;
	g_return_if_fail (self != NULL);
	old_value = ft_size_stack_get_transition_duration (self);
	if (old_value != value) {
		self->priv->_transition_duration = value;
		g_object_notify_by_pspec ((GObject *) self, ft_size_stack_properties[FT_SIZE_STACK_TRANSITION_DURATION_PROPERTY]);
	}
}

static void
ft_size_stack_class_init (FtSizeStackClass * klass,
                          gpointer klass_data)
{
	ft_size_stack_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FtSizeStack_private_offset);
	((GtkWidgetClass *) klass)->realize = (void (*) (GtkWidget*)) ft_size_stack_real_realize;
	((GtkWidgetClass *) klass)->compute_expand = (void (*) (GtkWidget*, gboolean*, gboolean*)) ft_size_stack_real_compute_expand_internal;
	((GtkWidgetClass *) klass)->get_request_mode = (GtkSizeRequestMode (*) (GtkWidget*)) ft_size_stack_real_get_request_mode;
	((GtkWidgetClass *) klass)->measure = (void (*) (GtkWidget*, GtkOrientation, gint, gint*, gint*, gint*, gint*)) ft_size_stack_real_measure;
	((GtkWidgetClass *) klass)->size_allocate = (void (*) (GtkWidget*, gint, gint, gint)) ft_size_stack_real_size_allocate;
	((GtkWidgetClass *) klass)->snapshot = (void (*) (GtkWidget*, GtkSnapshot*)) ft_size_stack_real_snapshot;
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) ft_size_stack_real_dispose;
	G_OBJECT_CLASS (klass)->get_property = _vala_ft_size_stack_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_ft_size_stack_set_property;
	G_OBJECT_CLASS (klass)->finalize = ft_size_stack_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_SIZE_STACK_VISIBLE_CHILD_PROPERTY, ft_size_stack_properties[FT_SIZE_STACK_VISIBLE_CHILD_PROPERTY] = g_param_spec_object ("visible-child", "visible-child", "visible-child", gtk_widget_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_SIZE_STACK_VISIBLE_CHILD_NAME_PROPERTY, ft_size_stack_properties[FT_SIZE_STACK_VISIBLE_CHILD_NAME_PROPERTY] = g_param_spec_string ("visible-child-name", "visible-child-name", "visible-child-name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_SIZE_STACK_TRANSITION_DURATION_PROPERTY, ft_size_stack_properties[FT_SIZE_STACK_TRANSITION_DURATION_PROPERTY] = g_param_spec_uint ("transition-duration", "transition-duration", "transition-duration", 0, G_MAXUINT, (guint) 500, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
ft_size_stack_gtk_buildable_interface_init (GtkBuildableIface * iface,
                                            gpointer iface_data)
{
	ft_size_stack_gtk_buildable_parent_iface = g_type_interface_peek_parent (iface);
	iface->add_child = (void (*) (GtkBuildable*, GtkBuilder*, GObject*, const gchar*)) ft_size_stack_real_add_child;
}

static void
ft_size_stack_instance_init (FtSizeStack * self,
                             gpointer klass)
{
	self->priv = ft_size_stack_get_instance_private (self);
	self->priv->_transition_duration = (guint) 500;
	self->priv->pages = NULL;
	self->priv->transition_animation = NULL;
	self->priv->current_page = NULL;
	self->priv->previous_page = NULL;
	self->priv->size_request_set = FALSE;
}

static void
ft_size_stack_finalize (GObject * obj)
{
	FtSizeStack * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_SIZE_STACK, FtSizeStack);
	(self->priv->pages == NULL) ? NULL : (self->priv->pages = (_g_list_free__g_object_unref0_ (self->priv->pages), NULL));
	_g_object_unref0 (self->priv->transition_animation);
	G_OBJECT_CLASS (ft_size_stack_parent_class)->finalize (obj);
}

/**
     * Container for transitioning between widgets of varying sizes.
     *
     * The purpose is to swap widgets of varying complexity or just different variants.
     * It's tailored for interpolating window size - origin of the transition is at top left corner.
     */
static GType
ft_size_stack_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtSizeStackClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_size_stack_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtSizeStack), 0, (GInstanceInitFunc) ft_size_stack_instance_init, NULL };
	static const GInterfaceInfo gtk_buildable_info = { (GInterfaceInitFunc) ft_size_stack_gtk_buildable_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType ft_size_stack_type_id;
	ft_size_stack_type_id = g_type_register_static (gtk_widget_get_type (), "FtSizeStack", &g_define_type_info, 0);
	g_type_add_interface_static (ft_size_stack_type_id, gtk_buildable_get_type (), &gtk_buildable_info);
	FtSizeStack_private_offset = g_type_add_instance_private (ft_size_stack_type_id, sizeof (FtSizeStackPrivate));
	return ft_size_stack_type_id;
}

GType
ft_size_stack_get_type (void)
{
	static volatile gsize ft_size_stack_type_id__once = 0;
	if (g_once_init_enter (&ft_size_stack_type_id__once)) {
		GType ft_size_stack_type_id;
		ft_size_stack_type_id = ft_size_stack_get_type_once ();
		g_once_init_leave (&ft_size_stack_type_id__once, ft_size_stack_type_id);
	}
	return ft_size_stack_type_id__once;
}

static void
_vala_ft_size_stack_get_property (GObject * object,
                                  guint property_id,
                                  GValue * value,
                                  GParamSpec * pspec)
{
	FtSizeStack * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_SIZE_STACK, FtSizeStack);
	switch (property_id) {
		case FT_SIZE_STACK_VISIBLE_CHILD_PROPERTY:
		g_value_set_object (value, ft_size_stack_get_visible_child (self));
		break;
		case FT_SIZE_STACK_VISIBLE_CHILD_NAME_PROPERTY:
		g_value_set_string (value, ft_size_stack_get_visible_child_name (self));
		break;
		case FT_SIZE_STACK_TRANSITION_DURATION_PROPERTY:
		g_value_set_uint (value, ft_size_stack_get_transition_duration (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_ft_size_stack_set_property (GObject * object,
                                  guint property_id,
                                  const GValue * value,
                                  GParamSpec * pspec)
{
	FtSizeStack * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_SIZE_STACK, FtSizeStack);
	switch (property_id) {
		case FT_SIZE_STACK_VISIBLE_CHILD_PROPERTY:
		ft_size_stack_set_visible_child (self, g_value_get_object (value));
		break;
		case FT_SIZE_STACK_VISIBLE_CHILD_NAME_PROPERTY:
		ft_size_stack_set_visible_child_name (self, g_value_get_string (value));
		break;
		case FT_SIZE_STACK_TRANSITION_DURATION_PROPERTY:
		ft_size_stack_set_transition_duration (self, g_value_get_uint (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;
}

