/* timer-progress-bar.c generated by valac 0.56.19, the Vala compiler
 * generated from timer-progress-bar.vala, do not modify */

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

#define _GNU_SOURCE

#include "ft_ui.h"
#include <gtk/gtk.h>
#include "ft_core.h"
#include <glib.h>
#include <float.h>
#include <math.h>
#include <adwaita.h>
#include <glib-object.h>
#include <gdk/gdk.h>
#include <graphene-gobject.h>
#include <string.h>
#include <gsk/gsk.h>

#define FT_TIMER_PROGRESS_BAR_MIN_LINE_WIDTH 6.0f
#define FT_TIMER_PROGRESS_BAR_MAX_LINE_WIDTH 8.0f
#define FT_TIMER_PROGRESS_BAR_MIN_WIDTH 100
#define FT_TIMER_PROGRESS_BAR_TIMEOUT_RESOLUTION 2U
#define FT_TIMER_PROGRESS_BAR_MIN_TIMEOUT_INTERVAL ((guint) 25)
#define FT_TIMER_PROGRESS_BAR_FADE_IN_DURATION ((guint) 500)
#define FT_TIMER_PROGRESS_BAR_FADE_OUT_DURATION ((guint) 500)
#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

typedef struct _FtTimerProgressBar FtTimerProgressBar;
typedef struct _FtTimerProgressBarClass FtTimerProgressBarClass;
typedef struct _FtTimerProgressBarPrivate FtTimerProgressBarPrivate;
typedef struct _FtGizmo FtGizmo;
typedef struct _FtGizmoClass FtGizmoClass;
enum  {
	FT_TIMER_PROGRESS_BAR_0_PROPERTY,
	FT_TIMER_PROGRESS_BAR_TIMER_PROPERTY,
	FT_TIMER_PROGRESS_BAR_SHAPE_PROPERTY,
	FT_TIMER_PROGRESS_BAR_LINE_WIDTH_PROPERTY,
	FT_TIMER_PROGRESS_BAR_LINE_WIDTH_SET_PROPERTY,
	FT_TIMER_PROGRESS_BAR_DISPLAY_VALUE_PROPERTY,
	FT_TIMER_PROGRESS_BAR_NUM_PROPERTIES
};
static GParamSpec* ft_timer_progress_bar_properties[FT_TIMER_PROGRESS_BAR_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _gsk_path_unref0(var) ((var == NULL) ? NULL : (var = (gsk_path_unref (var), NULL)))
#define __vala_GskStroke_free0(var) ((var == NULL) ? NULL : (var = (_vala_GskStroke_free (var), NULL)))
#define _gsk_path_builder_unref0(var) ((var == NULL) ? NULL : (var = (gsk_path_builder_unref (var), NULL)))
#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 _FtTimerProgressBar {
	GtkWidget parent_instance;
	FtTimerProgressBarPrivate * priv;
};

struct _FtTimerProgressBarClass {
	GtkWidgetClass parent_class;
};

struct _FtTimerProgressBarPrivate {
	FtTimerProgressShape _shape;
	FtTimer* _timer;
	gfloat _line_width;
	gboolean _line_width_set;
	gdouble _display_value;
	gdouble display_value_from;
	gdouble display_value_to;
	gint64 last_display_time;
	AdwTimedAnimation* value_animation;
	AdwTimedAnimation* opacity_animation;
	FtGizmo* through;
	FtGizmo* highlight;
	gulong tick_id;
	guint tick_callback_id;
	guint timeout_id;
	guint timeout_interval;
	guint timeout_inhibit_count;
	gfloat radius;
	gfloat line_cap_radius;
	gfloat line_cap_angle;
};

static gint FtTimerProgressBar_private_offset;
static gpointer ft_timer_progress_bar_parent_class = NULL;

static inline gint64 ft_timer_progress_bar_get_current_time (FtTimerProgressBar* self);
static void ft_timer_progress_bar_inhibit_timeout (FtTimerProgressBar* self);
static void ft_timer_progress_bar_stop_timeout (FtTimerProgressBar* self);
static void ft_timer_progress_bar_uninhibit_timeout (FtTimerProgressBar* self);
static void ft_timer_progress_bar_start_timeout (FtTimerProgressBar* self);
static guint ft_timer_progress_bar_calculate_timeout_interval (FtTimerProgressBar* self);
static void ___lambda36_ (FtTimerProgressBar* self,
                   gint64 timestamp);
static void ____lambda36__ft_timer_tick (FtTimer* _sender,
                                  gint64 timestamp,
                                  gpointer self);
static gboolean ____lambda37_ (FtTimerProgressBar* self);
static gboolean _____lambda37__gsource_func (gpointer self);
static gboolean _____lambda38_ (FtTimerProgressBar* self);
static gboolean ______lambda38__gtk_tick_callback (GtkWidget* widget,
                                            GdkFrameClock* frame_clock,
                                            gpointer self);
static void ft_timer_progress_bar_on_timer_state_changed (FtTimerProgressBar* self,
                                                   const FtTimerState* current_state,
                                                   const FtTimerState* previous_state);
static void ft_timer_progress_bar_fade_in (FtTimerProgressBar* self);
static void ft_timer_progress_bar_fade_out (FtTimerProgressBar* self);
static void ft_timer_progress_bar_animate_value (FtTimerProgressBar* self,
                                          gdouble value_from,
                                          gdouble value_to);
static void ft_timer_progress_bar_on_opacity_animation_done (FtTimerProgressBar* self);
static void ft_timer_progress_bar_on_value_animation_done (FtTimerProgressBar* self);
static gfloat ft_timer_progress_bar_calculate_line_width (FtTimerProgressBar* self,
                                                   gint size);
static guint ft_timer_progress_bar_calculate_animation_duration (FtTimerProgressBar* self,
                                                          gdouble value_from,
                                                          gdouble value_to);
static void _gtk_widget_queue_draw_adw_animation_target_func (gdouble value,
                                                       gpointer self);
static void _ft_timer_progress_bar_on_opacity_animation_done_adw_animation_done (AdwAnimation* _sender,
                                                                          gpointer self);
static void _ft_timer_progress_bar_on_value_animation_done_adw_animation_done (AdwAnimation* _sender,
                                                                        gpointer self);
static void ft_timer_progress_bar_measure_bar_cb (FtGizmo* gizmo,
                                           GtkOrientation orientation,
                                           gint for_size,
                                           gint* minimum,
                                           gint* natural,
                                           gint* minimum_baseline,
                                           gint* natural_baseline);
static void ft_timer_progress_bar_measure_bar (FtTimerProgressBar* self,
                                        FtGizmo* gizmo,
                                        GtkOrientation orientation,
                                        gint for_size,
                                        gint* minimum,
                                        gint* natural,
                                        gint* minimum_baseline,
                                        gint* natural_baseline);
static void ft_timer_progress_bar_snapshot_bar_through_cb (FtGizmo* gizmo,
                                                    GtkSnapshot* snapshot);
static void ft_timer_progress_bar_snapshot_bar_through (FtTimerProgressBar* self,
                                                 FtGizmo* gizmo,
                                                 GtkSnapshot* snapshot);
static void ft_timer_progress_bar_snapshot_bar_highlight_cb (FtGizmo* gizmo,
                                                      GtkSnapshot* snapshot);
static void ft_timer_progress_bar_snapshot_bar_highlight (FtTimerProgressBar* self,
                                                   FtGizmo* gizmo,
                                                   GtkSnapshot* snapshot);
static void ft_timer_progress_bar_measure_ring_cb (FtGizmo* gizmo,
                                            GtkOrientation orientation,
                                            gint for_size,
                                            gint* minimum,
                                            gint* natural,
                                            gint* minimum_baseline,
                                            gint* natural_baseline);
static void ft_timer_progress_bar_measure_ring (FtTimerProgressBar* self,
                                         FtGizmo* gizmo,
                                         GtkOrientation orientation,
                                         gint for_size,
                                         gint* minimum,
                                         gint* natural,
                                         gint* minimum_baseline,
                                         gint* natural_baseline);
static void ft_timer_progress_bar_snapshot_ring_through_cb (FtGizmo* gizmo,
                                                     GtkSnapshot* snapshot);
static void ft_timer_progress_bar_snapshot_ring_through (FtTimerProgressBar* self,
                                                  FtGizmo* gizmo,
                                                  GtkSnapshot* snapshot);
static void ft_timer_progress_bar_snapshot_ring_highlight_cb (FtGizmo* gizmo,
                                                       GtkSnapshot* snapshot);
static void ft_timer_progress_bar_snapshot_ring_highlight (FtTimerProgressBar* self,
                                                    FtGizmo* gizmo,
                                                    GtkSnapshot* snapshot);
static void _vala_GskStroke_free (GskStroke* self);
static GtkSizeRequestMode ft_timer_progress_bar_real_get_request_mode (GtkWidget* base);
static void ft_timer_progress_bar_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_timer_progress_bar_real_size_allocate (GtkWidget* base,
                                               gint width,
                                               gint height,
                                               gint baseline);
static void ft_timer_progress_bar_real_snapshot (GtkWidget* base,
                                          GtkSnapshot* snapshot);
static void ft_timer_progress_bar_real_map (GtkWidget* base);
static void _ft_timer_progress_bar_on_timer_state_changed_ft_timer_state_changed (FtTimer* _sender,
                                                                           const FtTimerState* current_state,
                                                                           const FtTimerState* previous_state,
                                                                           gpointer self);
static void ft_timer_progress_bar_real_unmap (GtkWidget* base);
static void ft_timer_progress_bar_real_dispose (GObject* base);
static void _ft_timer_progress_bar_measure_bar_cb_ft_gizmo_measure_func (FtGizmo* gizmo,
                                                                  GtkOrientation orientation,
                                                                  gint for_size,
                                                                  gint* minimum,
                                                                  gint* natural,
                                                                  gint* minimum_baseline,
                                                                  gint* natural_baseline,
                                                                  gpointer self);
static void _ft_timer_progress_bar_snapshot_bar_through_cb_ft_gizmo_snapshot_func (FtGizmo* gizmo,
                                                                            GtkSnapshot* snapshot,
                                                                            gpointer self);
static void _ft_timer_progress_bar_snapshot_bar_highlight_cb_ft_gizmo_snapshot_func (FtGizmo* gizmo,
                                                                              GtkSnapshot* snapshot,
                                                                              gpointer self);
static void _ft_timer_progress_bar_measure_ring_cb_ft_gizmo_measure_func (FtGizmo* gizmo,
                                                                   GtkOrientation orientation,
                                                                   gint for_size,
                                                                   gint* minimum,
                                                                   gint* natural,
                                                                   gint* minimum_baseline,
                                                                   gint* natural_baseline,
                                                                   gpointer self);
static void _ft_timer_progress_bar_snapshot_ring_through_cb_ft_gizmo_snapshot_func (FtGizmo* gizmo,
                                                                             GtkSnapshot* snapshot,
                                                                             gpointer self);
static void _ft_timer_progress_bar_snapshot_ring_highlight_cb_ft_gizmo_snapshot_func (FtGizmo* gizmo,
                                                                               GtkSnapshot* snapshot,
                                                                               gpointer self);
static void ft_timer_progress_bar_finalize (GObject * obj);
static GType ft_timer_progress_bar_get_type_once (void);
static void _vala_ft_timer_progress_bar_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec);
static void _vala_ft_timer_progress_bar_set_property (GObject * object,
                                               guint property_id,
                                               const GValue * value,
                                               GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static GType
ft_timer_progress_shape_get_type_once (void)
{
	static const GEnumValue values[] = {{FT_TIMER_PROGRESS_SHAPE_BAR, "FT_TIMER_PROGRESS_SHAPE_BAR", "bar"}, {FT_TIMER_PROGRESS_SHAPE_RING, "FT_TIMER_PROGRESS_SHAPE_RING", "ring"}, {0, NULL, NULL}};
	GType ft_timer_progress_shape_type_id;
	ft_timer_progress_shape_type_id = g_enum_register_static ("FtTimerProgressShape", values);
	return ft_timer_progress_shape_type_id;
}

GType
ft_timer_progress_shape_get_type (void)
{
	static volatile gsize ft_timer_progress_shape_type_id__once = 0;
	if (g_once_init_enter (&ft_timer_progress_shape_type_id__once)) {
		GType ft_timer_progress_shape_type_id;
		ft_timer_progress_shape_type_id = ft_timer_progress_shape_get_type_once ();
		g_once_init_leave (&ft_timer_progress_shape_type_id__once, ft_timer_progress_shape_type_id);
	}
	return ft_timer_progress_shape_type_id__once;
}

static inline gpointer
ft_timer_progress_bar_get_instance_private (FtTimerProgressBar* self)
{
	return G_STRUCT_MEMBER_P (self, FtTimerProgressBar_private_offset);
}

static inline gint64
ft_timer_progress_bar_get_current_time (FtTimerProgressBar* self)
{
	gint64 _tmp0_ = 0LL;
	FtTimer* _tmp1_;
	gint64 result;
	g_return_val_if_fail (self != NULL, -1LL);
	_tmp1_ = self->priv->_timer;
	if (ft_timer_is_running (_tmp1_)) {
		FtTimer* _tmp2_;
		GdkFrameClock* _tmp3_;
		_tmp2_ = self->priv->_timer;
		_tmp3_ = gtk_widget_get_frame_clock ((GtkWidget*) self);
		_tmp0_ = ft_timer_get_current_time (_tmp2_, gdk_frame_clock_get_frame_time (_tmp3_));
	} else {
		FtTimer* _tmp4_;
		_tmp4_ = self->priv->_timer;
		_tmp0_ = ft_timer_get_last_state_changed_time (_tmp4_);
	}
	result = _tmp0_;
	return result;
}

/**
         * Stop the timeout callbacks. Prioritise animations over the timeout. It's redundant to
         * run both.
         */
static void
ft_timer_progress_bar_inhibit_timeout (FtTimerProgressBar* self)
{
	guint _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->timeout_inhibit_count;
	self->priv->timeout_inhibit_count = _tmp0_ + 1;
	ft_timer_progress_bar_stop_timeout (self);
}

static void
ft_timer_progress_bar_uninhibit_timeout (FtTimerProgressBar* self)
{
	g_return_if_fail (self != NULL);
	if (self->priv->timeout_inhibit_count > ((guint) 0)) {
		guint _tmp0_;
		gboolean _tmp1_ = FALSE;
		_tmp0_ = self->priv->timeout_inhibit_count;
		self->priv->timeout_inhibit_count = _tmp0_ - 1;
		if (self->priv->timeout_inhibit_count == ((guint) 0)) {
			FtTimer* _tmp2_;
			_tmp2_ = self->priv->_timer;
			_tmp1_ = ft_timer_is_running (_tmp2_);
		} else {
			_tmp1_ = FALSE;
		}
		if (_tmp1_) {
			ft_timer_progress_bar_start_timeout (self);
		}
	}
}

static void
___lambda36_ (FtTimerProgressBar* self,
              gint64 timestamp)
{
	FtGizmo* _tmp0_;
	_tmp0_ = self->priv->highlight;
	gtk_widget_queue_draw ((GtkWidget*) _tmp0_);
}

static void
____lambda36__ft_timer_tick (FtTimer* _sender,
                             gint64 timestamp,
                             gpointer self)
{
	___lambda36_ ((FtTimerProgressBar*) self, timestamp);
}

static gboolean
____lambda37_ (FtTimerProgressBar* self)
{
	FtGizmo* _tmp0_;
	gboolean result;
	_tmp0_ = self->priv->highlight;
	gtk_widget_queue_draw ((GtkWidget*) _tmp0_);
	result = G_SOURCE_CONTINUE;
	return result;
}

static gboolean
_____lambda37__gsource_func (gpointer self)
{
	gboolean result;
	result = ____lambda37_ ((FtTimerProgressBar*) self);
	return result;
}

static gboolean
_____lambda38_ (FtTimerProgressBar* self)
{
	FtGizmo* _tmp0_;
	gboolean result;
	_tmp0_ = self->priv->highlight;
	gtk_widget_queue_draw ((GtkWidget*) _tmp0_);
	result = G_SOURCE_CONTINUE;
	return result;
}

static gboolean
______lambda38__gtk_tick_callback (GtkWidget* widget,
                                   GdkFrameClock* frame_clock,
                                   gpointer self)
{
	gboolean result;
	result = _____lambda38_ ((FtTimerProgressBar*) self);
	return result;
}

static void
ft_timer_progress_bar_start_timeout (FtTimerProgressBar* self)
{
	guint timeout_interval = 0U;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	g_return_if_fail (self != NULL);
	if (self->priv->timeout_inhibit_count > ((guint) 0)) {
		return;
	}
	timeout_interval = ft_timer_progress_bar_calculate_timeout_interval (self);
	if (timeout_interval < FT_TIMER_PROGRESS_BAR_MIN_TIMEOUT_INTERVAL) {
		timeout_interval = 0U;
	}
	if (self->priv->timeout_interval != timeout_interval) {
		self->priv->timeout_interval = timeout_interval;
		ft_timer_progress_bar_stop_timeout (self);
	}
	if (self->priv->tick_id == ((gulong) 0)) {
		_tmp1_ = timeout_interval > ((guint) 0);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		_tmp0_ = timeout_interval > ((guint) 500);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		FtTimer* _tmp2_;
		gulong _tmp3_;
		_tmp2_ = self->priv->_timer;
		_tmp3_ = g_signal_connect_object (_tmp2_, "tick", (GCallback) ____lambda36__ft_timer_tick, self, 0);
		self->priv->tick_id = _tmp3_;
	} else {
		gboolean _tmp4_ = FALSE;
		if (self->priv->timeout_id == ((guint) 0)) {
			_tmp4_ = timeout_interval > ((guint) 0);
		} else {
			_tmp4_ = FALSE;
		}
		if (_tmp4_) {
			self->priv->timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT, timeout_interval, _____lambda37__gsource_func, g_object_ref (self), g_object_unref);
			g_source_set_name_by_id (self->priv->timeout_id, "Ft.TimerProgressBar.queue_draw");
		} else {
			gboolean _tmp5_ = FALSE;
			if (self->priv->tick_callback_id == ((guint) 0)) {
				_tmp5_ = timeout_interval == ((guint) 0);
			} else {
				_tmp5_ = FALSE;
			}
			if (_tmp5_) {
				self->priv->tick_callback_id = gtk_widget_add_tick_callback ((GtkWidget*) self, ______lambda38__gtk_tick_callback, g_object_ref (self), g_object_unref);
			}
		}
	}
}

static void
ft_timer_progress_bar_stop_timeout (FtTimerProgressBar* self)
{
	g_return_if_fail (self != NULL);
	if (self->priv->tick_id != ((gulong) 0)) {
		FtTimer* _tmp0_;
		_tmp0_ = self->priv->_timer;
		g_signal_handler_disconnect ((GObject*) _tmp0_, self->priv->tick_id);
		self->priv->tick_id = (gulong) 0;
	}
	if (self->priv->timeout_id != ((guint) 0)) {
		g_source_remove (self->priv->timeout_id);
		self->priv->timeout_id = (guint) 0;
	}
	if (self->priv->tick_callback_id != ((guint) 0)) {
		gtk_widget_remove_tick_callback ((GtkWidget*) self, self->priv->tick_callback_id);
		self->priv->tick_callback_id = (guint) 0;
	}
}

static void
ft_timer_progress_bar_on_timer_state_changed (FtTimerProgressBar* self,
                                              const FtTimerState* current_state,
                                              const FtTimerState* previous_state)
{
	gint64 timestamp = 0LL;
	FtTimer* _tmp0_;
	gboolean is_ring = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp9_ = FALSE;
	AdwTimedAnimation* _tmp10_;
	FtGizmo* _tmp12_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (current_state != NULL);
	g_return_if_fail (previous_state != NULL);
	_tmp0_ = self->priv->_timer;
	timestamp = ft_timer_get_last_state_changed_time (_tmp0_);
	is_ring = self->priv->_shape == FT_TIMER_PROGRESS_SHAPE_RING;
	if (!ft_timer_state_is_finished (current_state)) {
		_tmp2_ = ft_timer_state_is_finished (previous_state);
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		_tmp1_ = is_ring;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		ft_timer_progress_bar_fade_in (self);
	} else {
		gboolean _tmp3_ = FALSE;
		FtTimerState _tmp4_;
		void* _tmp5_;
		_tmp4_ = *current_state;
		_tmp5_ = _tmp4_.user_data;
		if (_tmp5_ != NULL) {
			FtTimerState _tmp6_;
			void* _tmp7_;
			_tmp6_ = *previous_state;
			_tmp7_ = _tmp6_.user_data;
			_tmp3_ = _tmp7_ == NULL;
		} else {
			_tmp3_ = FALSE;
		}
		if (_tmp3_) {
			ft_timer_progress_bar_fade_in (self);
		} else {
			gboolean _tmp8_ = FALSE;
			if (!ft_timer_state_is_started (current_state)) {
				_tmp8_ = ft_timer_state_is_started (previous_state);
			} else {
				_tmp8_ = FALSE;
			}
			if (_tmp8_) {
				ft_timer_progress_bar_fade_out (self);
			}
		}
	}
	_tmp10_ = self->priv->opacity_animation;
	if (_tmp10_ == NULL) {
		_tmp9_ = (timestamp - self->priv->last_display_time) < (5 * FT_INTERVAL_SECOND);
	} else {
		_tmp9_ = FALSE;
	}
	if (_tmp9_) {
		gdouble value_from = 0.0;
		gdouble value_to = 0.0;
		FtTimer* _tmp11_;
		value_from = self->priv->_display_value;
		_tmp11_ = self->priv->_timer;
		value_to = ft_timer_calculate_progress (_tmp11_, timestamp);
		ft_timer_progress_bar_animate_value (self, value_from, value_to);
	}
	if (ft_timer_state_is_running (current_state)) {
		ft_timer_progress_bar_start_timeout (self);
	} else {
		ft_timer_progress_bar_stop_timeout (self);
	}
	_tmp12_ = self->priv->highlight;
	gtk_widget_queue_draw ((GtkWidget*) _tmp12_);
}

static void
ft_timer_progress_bar_on_opacity_animation_done (FtTimerProgressBar* self)
{
	g_return_if_fail (self != NULL);
	_g_object_unref0 (self->priv->opacity_animation);
	self->priv->opacity_animation = NULL;
	ft_timer_progress_bar_uninhibit_timeout (self);
}

static void
ft_timer_progress_bar_on_value_animation_done (FtTimerProgressBar* self)
{
	g_return_if_fail (self != NULL);
	_g_object_unref0 (self->priv->value_animation);
	self->priv->value_animation = NULL;
	ft_timer_progress_bar_uninhibit_timeout (self);
}

static gfloat
ft_timer_progress_bar_calculate_line_width (FtTimerProgressBar* self,
                                            gint size)
{
	gfloat size_float = 0.0F;
	gfloat min_size = 0.0F;
	gfloat max_size = 0.0F;
	gfloat t = 0.0F;
	gfloat result;
	g_return_val_if_fail (self != NULL, -1.0F);
	size_float = (gfloat) roundf ((gfloat) size);
	min_size = 300.0f;
	max_size = 450.0f;
	t = CLAMP ((size_float - min_size) / (max_size - min_size), 0.0f, 1.0f);
	result = roundf (ft_lerpf (FT_TIMER_PROGRESS_BAR_MIN_LINE_WIDTH, FT_TIMER_PROGRESS_BAR_MAX_LINE_WIDTH, t));
	return result;
}

static guint
ft_timer_progress_bar_calculate_timeout_interval (FtTimerProgressBar* self)
{
	gint64 distance = 0LL;
	guint _tmp0_ = 0U;
	guint result;
	g_return_val_if_fail (self != NULL, 0U);
	switch (self->priv->_shape) {
		case FT_TIMER_PROGRESS_SHAPE_BAR:
		{
			distance = (gint64) gtk_widget_get_width ((GtkWidget*) self);
			break;
		}
		case FT_TIMER_PROGRESS_SHAPE_RING:
		{
			distance = (gint64) ceil ((2.0 * G_PI) * ((gdouble) self->priv->radius));
			break;
		}
		default:
		{
			g_assert_not_reached ();
		}
	}
	distance *= (gint64) FT_TIMER_PROGRESS_BAR_TIMEOUT_RESOLUTION;
	if (distance > ((gint64) 0)) {
		FtTimer* _tmp1_;
		gint64 _tmp2_;
		gint64 _tmp3_;
		_tmp1_ = self->priv->_timer;
		_tmp2_ = ft_timer_get_duration (_tmp1_);
		_tmp3_ = _tmp2_;
		_tmp0_ = ft_timestamp_to_milliseconds_uint (_tmp3_ / distance);
	} else {
		_tmp0_ = (guint) 0;
	}
	result = _tmp0_;
	return result;
}

static guint
ft_timer_progress_bar_calculate_animation_duration (FtTimerProgressBar* self,
                                                    gdouble value_from,
                                                    gdouble value_to)
{
	guint result;
	g_return_val_if_fail (self != NULL, 0U);
	switch (self->priv->_shape) {
		case FT_TIMER_PROGRESS_SHAPE_BAR:
		{
			result = (guint) (sqrt (fabs (value_to - value_from)) * 500.0);
			return result;
		}
		case FT_TIMER_PROGRESS_SHAPE_RING:
		{
			result = (guint) (sqrt (fabs (value_to - value_from)) * 1000.0);
			return result;
		}
		default:
		{
			g_assert_not_reached ();
		}
	}
}

static void
_gtk_widget_queue_draw_adw_animation_target_func (gdouble value,
                                                  gpointer self)
{
	gtk_widget_queue_draw ((GtkWidget*) self);
}

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

static void
_ft_timer_progress_bar_on_opacity_animation_done_adw_animation_done (AdwAnimation* _sender,
                                                                     gpointer self)
{
	ft_timer_progress_bar_on_opacity_animation_done ((FtTimerProgressBar*) self);
}

static void
ft_timer_progress_bar_fade_in (FtTimerProgressBar* self)
{
	gdouble _tmp0_ = 0.0;
	AdwTimedAnimation* _tmp1_;
	gdouble opacity_from = 0.0;
	gdouble opacity_to = 0.0;
	AdwTimedAnimation* _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->opacity_animation;
	if (_tmp1_ != NULL) {
		AdwTimedAnimation* _tmp2_;
		gdouble _tmp3_;
		gdouble _tmp4_;
		_tmp2_ = self->priv->opacity_animation;
		_tmp3_ = adw_animation_get_value ((AdwAnimation*) _tmp2_);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_;
	} else {
		_tmp0_ = 0.0;
	}
	opacity_from = _tmp0_;
	opacity_to = 1.0;
	_tmp5_ = self->priv->opacity_animation;
	if (_tmp5_ != NULL) {
		AdwTimedAnimation* _tmp6_;
		_tmp6_ = self->priv->opacity_animation;
		adw_animation_pause ((AdwAnimation*) _tmp6_);
		_g_object_unref0 (self->priv->opacity_animation);
		self->priv->opacity_animation = NULL;
		ft_timer_progress_bar_uninhibit_timeout (self);
	}
	if (gtk_widget_get_mapped ((GtkWidget*) self)) {
		AdwCallbackAnimationTarget* animation_target = NULL;
		FtGizmo* _tmp7_;
		AdwCallbackAnimationTarget* _tmp8_;
		FtGizmo* _tmp9_;
		AdwCallbackAnimationTarget* _tmp10_;
		AdwAnimationTarget* _tmp11_;
		AdwTimedAnimation* _tmp12_;
		AdwTimedAnimation* _tmp13_;
		AdwTimedAnimation* _tmp14_;
		AdwTimedAnimation* _tmp15_;
		ft_timer_progress_bar_inhibit_timeout (self);
		_tmp7_ = self->priv->highlight;
		_tmp8_ = (AdwCallbackAnimationTarget*) adw_callback_animation_target_new (_gtk_widget_queue_draw_adw_animation_target_func, g_object_ref ((GtkWidget*) _tmp7_), g_object_unref);
		animation_target = _tmp8_;
		_tmp9_ = self->priv->highlight;
		_tmp10_ = animation_target;
		_tmp11_ = _g_object_ref0 ((AdwAnimationTarget*) _tmp10_);
		_tmp12_ = (AdwTimedAnimation*) adw_timed_animation_new ((GtkWidget*) _tmp9_, opacity_from, opacity_to, FT_TIMER_PROGRESS_BAR_FADE_IN_DURATION, _tmp11_);
		_g_object_unref0 (self->priv->opacity_animation);
		self->priv->opacity_animation = _tmp12_;
		_tmp13_ = self->priv->opacity_animation;
		adw_timed_animation_set_easing (_tmp13_, ADW_EASE_OUT_QUAD);
		_tmp14_ = self->priv->opacity_animation;
		g_signal_connect_object ((AdwAnimation*) _tmp14_, "done", (GCallback) _ft_timer_progress_bar_on_opacity_animation_done_adw_animation_done, self, 0);
		_tmp15_ = self->priv->opacity_animation;
		adw_animation_play ((AdwAnimation*) _tmp15_);
		_g_object_unref0 (animation_target);
	}
}

static void
ft_timer_progress_bar_fade_out (FtTimerProgressBar* self)
{
	gdouble _tmp0_ = 0.0;
	AdwTimedAnimation* _tmp1_;
	gdouble opacity_from = 0.0;
	gdouble opacity_to = 0.0;
	AdwTimedAnimation* _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->opacity_animation;
	if (_tmp1_ != NULL) {
		AdwTimedAnimation* _tmp2_;
		gdouble _tmp3_;
		gdouble _tmp4_;
		_tmp2_ = self->priv->opacity_animation;
		_tmp3_ = adw_animation_get_value ((AdwAnimation*) _tmp2_);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_;
	} else {
		_tmp0_ = 1.0;
	}
	opacity_from = _tmp0_;
	opacity_to = 0.0;
	_tmp5_ = self->priv->opacity_animation;
	if (_tmp5_ != NULL) {
		AdwTimedAnimation* _tmp6_;
		_tmp6_ = self->priv->opacity_animation;
		adw_animation_pause ((AdwAnimation*) _tmp6_);
		_g_object_unref0 (self->priv->opacity_animation);
		self->priv->opacity_animation = NULL;
		ft_timer_progress_bar_uninhibit_timeout (self);
	}
	if (gtk_widget_get_mapped ((GtkWidget*) self)) {
		AdwCallbackAnimationTarget* animation_target = NULL;
		FtGizmo* _tmp7_;
		AdwCallbackAnimationTarget* _tmp8_;
		FtGizmo* _tmp9_;
		AdwCallbackAnimationTarget* _tmp10_;
		AdwAnimationTarget* _tmp11_;
		AdwTimedAnimation* _tmp12_;
		AdwTimedAnimation* _tmp13_;
		AdwTimedAnimation* _tmp14_;
		AdwTimedAnimation* _tmp15_;
		ft_timer_progress_bar_inhibit_timeout (self);
		_tmp7_ = self->priv->highlight;
		_tmp8_ = (AdwCallbackAnimationTarget*) adw_callback_animation_target_new (_gtk_widget_queue_draw_adw_animation_target_func, g_object_ref ((GtkWidget*) _tmp7_), g_object_unref);
		animation_target = _tmp8_;
		_tmp9_ = self->priv->highlight;
		_tmp10_ = animation_target;
		_tmp11_ = _g_object_ref0 ((AdwAnimationTarget*) _tmp10_);
		_tmp12_ = (AdwTimedAnimation*) adw_timed_animation_new ((GtkWidget*) _tmp9_, opacity_from, opacity_to, FT_TIMER_PROGRESS_BAR_FADE_OUT_DURATION, _tmp11_);
		_g_object_unref0 (self->priv->opacity_animation);
		self->priv->opacity_animation = _tmp12_;
		_tmp13_ = self->priv->opacity_animation;
		adw_timed_animation_set_easing (_tmp13_, ADW_EASE_IN_OUT_CUBIC);
		_tmp14_ = self->priv->opacity_animation;
		g_signal_connect_object ((AdwAnimation*) _tmp14_, "done", (GCallback) _ft_timer_progress_bar_on_opacity_animation_done_adw_animation_done, self, 0);
		_tmp15_ = self->priv->opacity_animation;
		adw_animation_play ((AdwAnimation*) _tmp15_);
		_g_object_unref0 (animation_target);
	}
}

static void
_ft_timer_progress_bar_on_value_animation_done_adw_animation_done (AdwAnimation* _sender,
                                                                   gpointer self)
{
	ft_timer_progress_bar_on_value_animation_done ((FtTimerProgressBar*) self);
}

static void
ft_timer_progress_bar_animate_value (FtTimerProgressBar* self,
                                     gdouble value_from,
                                     gdouble value_to)
{
	AdwTimedAnimation* _tmp0_;
	g_return_if_fail (self != NULL);
	_vala_return_if_fail (isfinite (value_from), "value_from.is_finite ()");
	_vala_return_if_fail (isfinite (value_to), "value_to.is_finite ()");
	if (fabs (value_from - value_to) < 0.01) {
		return;
	}
	_tmp0_ = self->priv->value_animation;
	if (_tmp0_ != NULL) {
		AdwTimedAnimation* _tmp1_;
		_tmp1_ = self->priv->value_animation;
		adw_animation_pause ((AdwAnimation*) _tmp1_);
		_g_object_unref0 (self->priv->value_animation);
		self->priv->value_animation = NULL;
		ft_timer_progress_bar_uninhibit_timeout (self);
	}
	if (gtk_widget_get_mapped ((GtkWidget*) self)) {
		guint animation_duration = 0U;
		AdwCallbackAnimationTarget* animation_target = NULL;
		FtGizmo* _tmp2_;
		AdwCallbackAnimationTarget* _tmp3_;
		FtGizmo* _tmp4_;
		AdwCallbackAnimationTarget* _tmp5_;
		AdwAnimationTarget* _tmp6_;
		AdwTimedAnimation* _tmp7_;
		AdwEasing _tmp8_ = 0;
		FtTimer* _tmp9_;
		AdwTimedAnimation* _tmp10_;
		AdwTimedAnimation* _tmp11_;
		AdwTimedAnimation* _tmp12_;
		ft_timer_progress_bar_inhibit_timeout (self);
		animation_duration = ft_timer_progress_bar_calculate_animation_duration (self, value_from, value_to);
		_tmp2_ = self->priv->highlight;
		_tmp3_ = (AdwCallbackAnimationTarget*) adw_callback_animation_target_new (_gtk_widget_queue_draw_adw_animation_target_func, g_object_ref ((GtkWidget*) _tmp2_), g_object_unref);
		animation_target = _tmp3_;
		_tmp4_ = self->priv->highlight;
		_tmp5_ = animation_target;
		_tmp6_ = _g_object_ref0 ((AdwAnimationTarget*) _tmp5_);
		_tmp7_ = (AdwTimedAnimation*) adw_timed_animation_new ((GtkWidget*) _tmp4_, 0.0, 1.0, animation_duration, _tmp6_);
		_g_object_unref0 (self->priv->value_animation);
		self->priv->value_animation = _tmp7_;
		_tmp9_ = self->priv->_timer;
		if (ft_timer_is_paused (_tmp9_)) {
			_tmp8_ = ADW_EASE_IN_OUT_CUBIC;
		} else {
			_tmp8_ = ADW_EASE_OUT_QUAD;
		}
		_tmp10_ = self->priv->value_animation;
		adw_timed_animation_set_easing (_tmp10_, _tmp8_);
		_tmp11_ = self->priv->value_animation;
		g_signal_connect_object ((AdwAnimation*) _tmp11_, "done", (GCallback) _ft_timer_progress_bar_on_value_animation_done_adw_animation_done, self, 0);
		_tmp12_ = self->priv->value_animation;
		adw_animation_play ((AdwAnimation*) _tmp12_);
		self->priv->display_value_from = value_from;
		self->priv->display_value_to = value_to;
		_g_object_unref0 (animation_target);
	}
}

static void
ft_timer_progress_bar_measure_bar_cb (FtGizmo* gizmo,
                                      GtkOrientation orientation,
                                      gint for_size,
                                      gint* minimum,
                                      gint* natural,
                                      gint* minimum_baseline,
                                      gint* natural_baseline)
{
	gint _vala_minimum = 0;
	gint _vala_natural = 0;
	gint _vala_minimum_baseline = 0;
	gint _vala_natural_baseline = 0;
	FtTimerProgressBar* _self_ = NULL;
	GtkWidget* _tmp0_;
	GtkWidget* _tmp1_;
	FtTimerProgressBar* _tmp2_;
	g_return_if_fail (gizmo != NULL);
	_tmp0_ = gtk_widget_get_parent ((GtkWidget*) gizmo);
	_tmp1_ = _tmp0_;
	_self_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, FT_TYPE_TIMER_PROGRESS_BAR, FtTimerProgressBar);
	_tmp2_ = _self_;
	if (_tmp2_ != NULL) {
		FtTimerProgressBar* _tmp3_;
		gint _tmp4_ = 0;
		gint _tmp5_ = 0;
		gint _tmp6_ = 0;
		gint _tmp7_ = 0;
		_tmp3_ = _self_;
		ft_timer_progress_bar_measure_bar (_tmp3_, gizmo, orientation, for_size, &_tmp4_, &_tmp5_, &_tmp6_, &_tmp7_);
		_vala_minimum = _tmp4_;
		_vala_natural = _tmp5_;
		_vala_minimum_baseline = _tmp6_;
		_vala_natural_baseline = _tmp7_;
	} else {
		_vala_minimum = 0;
		_vala_natural = 0;
		_vala_minimum_baseline = -1;
		_vala_natural_baseline = -1;
	}
	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_timer_progress_bar_snapshot_bar_through_cb (FtGizmo* gizmo,
                                               GtkSnapshot* snapshot)
{
	FtTimerProgressBar* _self_ = NULL;
	GtkWidget* _tmp0_;
	GtkWidget* _tmp1_;
	FtTimerProgressBar* _tmp2_;
	g_return_if_fail (gizmo != NULL);
	g_return_if_fail (snapshot != NULL);
	_tmp0_ = gtk_widget_get_parent ((GtkWidget*) gizmo);
	_tmp1_ = _tmp0_;
	_self_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, FT_TYPE_TIMER_PROGRESS_BAR, FtTimerProgressBar);
	_tmp2_ = _self_;
	if (_tmp2_ != NULL) {
		FtTimerProgressBar* _tmp3_;
		_tmp3_ = _self_;
		ft_timer_progress_bar_snapshot_bar_through (_tmp3_, gizmo, snapshot);
	}
}

static void
ft_timer_progress_bar_snapshot_bar_highlight_cb (FtGizmo* gizmo,
                                                 GtkSnapshot* snapshot)
{
	FtTimerProgressBar* _self_ = NULL;
	GtkWidget* _tmp0_;
	GtkWidget* _tmp1_;
	FtTimerProgressBar* _tmp2_;
	g_return_if_fail (gizmo != NULL);
	g_return_if_fail (snapshot != NULL);
	_tmp0_ = gtk_widget_get_parent ((GtkWidget*) gizmo);
	_tmp1_ = _tmp0_;
	_self_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, FT_TYPE_TIMER_PROGRESS_BAR, FtTimerProgressBar);
	_tmp2_ = _self_;
	if (_tmp2_ != NULL) {
		FtTimerProgressBar* _tmp3_;
		_tmp3_ = _self_;
		ft_timer_progress_bar_snapshot_bar_highlight (_tmp3_, gizmo, snapshot);
	}
}

static void
ft_timer_progress_bar_measure_bar (FtTimerProgressBar* self,
                                   FtGizmo* gizmo,
                                   GtkOrientation orientation,
                                   gint for_size,
                                   gint* minimum,
                                   gint* natural,
                                   gint* minimum_baseline,
                                   gint* natural_baseline)
{
	gint _vala_minimum = 0;
	gint _vala_natural = 0;
	gint _vala_minimum_baseline = 0;
	gint _vala_natural_baseline = 0;
	g_return_if_fail (self != NULL);
	g_return_if_fail (gizmo != NULL);
	if (orientation == GTK_ORIENTATION_VERTICAL) {
		_vala_minimum = (gint) ceilf (self->priv->_line_width);
		_vala_natural = _vala_minimum;
	} else {
		_vala_minimum = FT_TIMER_PROGRESS_BAR_MIN_WIDTH;
		_vala_natural = _vala_minimum;
	}
	_vala_minimum_baseline = -1;
	_vala_natural_baseline = -1;
	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_timer_progress_bar_snapshot_bar_through (FtTimerProgressBar* self,
                                            FtGizmo* gizmo,
                                            GtkSnapshot* snapshot)
{
	gfloat width = 0.0F;
	gfloat height = 0.0F;
	GdkRGBA color = {0};
	GdkRGBA _tmp0_ = {0};
	gfloat through_width = 0.0F;
	gfloat through_height = 0.0F;
	gfloat through_x = 0.0F;
	gfloat through_y = 0.0F;
	graphene_rect_t through_bounds = {0};
	GskRoundedRect through_outline = {0};
	graphene_rect_t _tmp1_;
	GskRoundedRect _tmp2_;
	GdkRGBA _tmp3_;
	graphene_rect_t _tmp4_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (gizmo != NULL);
	g_return_if_fail (snapshot != NULL);
	width = (gfloat) gtk_widget_get_width ((GtkWidget*) gizmo);
	height = (gfloat) gtk_widget_get_height ((GtkWidget*) gizmo);
	gtk_widget_get_color ((GtkWidget*) gizmo, &_tmp0_);
	color = _tmp0_;
	through_width = width;
	through_height = self->priv->_line_width;
	through_x = 0.0f;
	through_y = (height - through_height) / 2.0f;
	memset (&through_bounds, 0, sizeof (graphene_rect_t));
	memset (&through_outline, 0, sizeof (GskRoundedRect));
	graphene_rect_init (&through_bounds, through_x, through_y, through_width, through_height);
	_tmp1_ = through_bounds;
	gsk_rounded_rect_init_from_rect (&through_outline, &_tmp1_, through_height / 2.0f);
	_tmp2_ = through_outline;
	gtk_snapshot_push_rounded_clip (snapshot, &_tmp2_);
	_tmp3_ = color;
	_tmp4_ = through_bounds;
	gtk_snapshot_append_color (snapshot, &_tmp3_, &_tmp4_);
	gtk_snapshot_pop (snapshot);
}

static void
ft_timer_progress_bar_snapshot_bar_highlight (FtTimerProgressBar* self,
                                              FtGizmo* gizmo,
                                              GtkSnapshot* snapshot)
{
	gdouble display_value = 0.0;
	gdouble _tmp0_ = 0.0;
	AdwTimedAnimation* _tmp1_;
	gdouble opacity = 0.0;
	gint64 timestamp = 0LL;
	gboolean _tmp5_ = FALSE;
	AdwTimedAnimation* _tmp6_;
	AdwTimedAnimation* _tmp15_;
	gboolean _tmp19_ = FALSE;
	gfloat width = 0.0F;
	gfloat height = 0.0F;
	GdkRGBA color = {0};
	GdkRGBA _tmp20_ = {0};
	gboolean clip_applied = FALSE;
	gboolean opacity_applied = FALSE;
	gfloat highlight_width = 0.0F;
	gfloat highlight_height = 0.0F;
	gfloat highlight_x = 0.0F;
	gfloat highlight_y = 0.0F;
	graphene_rect_t highlight_bounds = {0};
	GskRoundedRect highlight_outline = {0};
	graphene_rect_t _tmp26_;
	GskRoundedRect _tmp27_;
	GdkRGBA _tmp28_;
	graphene_rect_t _tmp29_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (gizmo != NULL);
	g_return_if_fail (snapshot != NULL);
	_tmp1_ = self->priv->opacity_animation;
	if (_tmp1_ != NULL) {
		AdwTimedAnimation* _tmp2_;
		gdouble _tmp3_;
		gdouble _tmp4_;
		_tmp2_ = self->priv->opacity_animation;
		_tmp3_ = adw_animation_get_value ((AdwAnimation*) _tmp2_);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_;
	} else {
		_tmp0_ = 1.0;
	}
	opacity = _tmp0_;
	timestamp = ft_timer_progress_bar_get_current_time (self);
	_tmp6_ = self->priv->opacity_animation;
	if (_tmp6_ == NULL) {
		_tmp5_ = TRUE;
	} else {
		AdwTimedAnimation* _tmp7_;
		gdouble _tmp8_;
		gdouble _tmp9_;
		_tmp7_ = self->priv->opacity_animation;
		_tmp8_ = adw_timed_animation_get_value_to (_tmp7_);
		_tmp9_ = _tmp8_;
		_tmp5_ = _tmp9_ > 0.0;
	}
	if (_tmp5_) {
		gdouble _tmp10_ = 0.0;
		FtTimer* _tmp11_;
		void* _tmp12_;
		void* _tmp13_;
		_tmp11_ = self->priv->_timer;
		_tmp12_ = ft_timer_get_user_data (_tmp11_);
		_tmp13_ = _tmp12_;
		if (_tmp13_ != NULL) {
			FtTimer* _tmp14_;
			_tmp14_ = self->priv->_timer;
			_tmp10_ = ft_timer_calculate_progress (_tmp14_, ft_timer_progress_bar_get_current_time (self));
		} else {
			_tmp10_ = 0.0;
		}
		display_value = _tmp10_;
	} else {
		display_value = self->priv->_display_value;
	}
	_tmp15_ = self->priv->value_animation;
	if (_tmp15_ != NULL) {
		AdwTimedAnimation* _tmp16_;
		gdouble _tmp17_;
		gdouble _tmp18_;
		_tmp16_ = self->priv->value_animation;
		_tmp17_ = adw_animation_get_value ((AdwAnimation*) _tmp16_);
		_tmp18_ = _tmp17_;
		display_value = ft_lerp (self->priv->display_value_from, display_value, _tmp18_);
	}
	if (display_value <= 0.0) {
		_tmp19_ = TRUE;
	} else {
		_tmp19_ = opacity == 0.0;
	}
	if (_tmp19_) {
		self->priv->_display_value = 0.0;
		self->priv->last_display_time = timestamp;
		return;
	}
	width = (gfloat) gtk_widget_get_width ((GtkWidget*) gizmo);
	height = (gfloat) gtk_widget_get_height ((GtkWidget*) gizmo);
	gtk_widget_get_color ((GtkWidget*) gizmo, &_tmp20_);
	color = _tmp20_;
	clip_applied = FALSE;
	opacity_applied = FALSE;
	if (opacity < 1.0) {
		AdwTimedAnimation* _tmp21_;
		gdouble _tmp22_;
		gdouble _tmp23_;
		_tmp21_ = self->priv->opacity_animation;
		_tmp22_ = adw_animation_get_value ((AdwAnimation*) _tmp21_);
		_tmp23_ = _tmp22_;
		gtk_snapshot_push_opacity (snapshot, _tmp23_);
		opacity_applied = TRUE;
	}
	highlight_width = width * MIN ((gfloat) display_value, 1.0f);
	highlight_height = self->priv->_line_width;
	highlight_x = 0.0f;
	highlight_y = (height - highlight_height) / 2.0f;
	memset (&highlight_bounds, 0, sizeof (graphene_rect_t));
	memset (&highlight_outline, 0, sizeof (GskRoundedRect));
	if (gtk_widget_get_direction ((GtkWidget*) self) == GTK_TEXT_DIR_RTL) {
		highlight_x = (width - highlight_x) - highlight_width;
	}
	if (highlight_width < highlight_height) {
		graphene_rect_t clip_bounds = {0};
		GskRoundedRect clip_outline = {0};
		graphene_rect_t _tmp24_;
		GskRoundedRect _tmp25_;
		memset (&clip_bounds, 0, sizeof (graphene_rect_t));
		memset (&clip_outline, 0, sizeof (GskRoundedRect));
		graphene_rect_init (&clip_bounds, 0.0f, highlight_y, width, highlight_height);
		_tmp24_ = clip_bounds;
		gsk_rounded_rect_init_from_rect (&clip_outline, &_tmp24_, highlight_height / 2.0f);
		_tmp25_ = clip_outline;
		gtk_snapshot_push_rounded_clip (snapshot, &_tmp25_);
		highlight_x -= highlight_height - highlight_width;
		highlight_width = highlight_height;
		clip_applied = TRUE;
	}
	graphene_rect_init (&highlight_bounds, highlight_x, highlight_y, highlight_width, highlight_height);
	_tmp26_ = highlight_bounds;
	gsk_rounded_rect_init_from_rect (&highlight_outline, &_tmp26_, highlight_height / 2.0f);
	_tmp27_ = highlight_outline;
	gtk_snapshot_push_rounded_clip (snapshot, &_tmp27_);
	_tmp28_ = color;
	_tmp29_ = highlight_bounds;
	gtk_snapshot_append_color (snapshot, &_tmp28_, &_tmp29_);
	gtk_snapshot_pop (snapshot);
	if (clip_applied) {
		gtk_snapshot_pop (snapshot);
	}
	if (opacity_applied) {
		gtk_snapshot_pop (snapshot);
	}
	self->priv->_display_value = display_value;
	self->priv->last_display_time = timestamp;
}

static void
ft_timer_progress_bar_measure_ring_cb (FtGizmo* gizmo,
                                       GtkOrientation orientation,
                                       gint for_size,
                                       gint* minimum,
                                       gint* natural,
                                       gint* minimum_baseline,
                                       gint* natural_baseline)
{
	gint _vala_minimum = 0;
	gint _vala_natural = 0;
	gint _vala_minimum_baseline = 0;
	gint _vala_natural_baseline = 0;
	FtTimerProgressBar* _self_ = NULL;
	GtkWidget* _tmp0_;
	GtkWidget* _tmp1_;
	FtTimerProgressBar* _tmp2_;
	g_return_if_fail (gizmo != NULL);
	_tmp0_ = gtk_widget_get_parent ((GtkWidget*) gizmo);
	_tmp1_ = _tmp0_;
	_self_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, FT_TYPE_TIMER_PROGRESS_BAR, FtTimerProgressBar);
	_tmp2_ = _self_;
	if (_tmp2_ != NULL) {
		FtTimerProgressBar* _tmp3_;
		gint _tmp4_ = 0;
		gint _tmp5_ = 0;
		gint _tmp6_ = 0;
		gint _tmp7_ = 0;
		_tmp3_ = _self_;
		ft_timer_progress_bar_measure_ring (_tmp3_, gizmo, orientation, for_size, &_tmp4_, &_tmp5_, &_tmp6_, &_tmp7_);
		_vala_minimum = _tmp4_;
		_vala_natural = _tmp5_;
		_vala_minimum_baseline = _tmp6_;
		_vala_natural_baseline = _tmp7_;
	} else {
		_vala_minimum = 0;
		_vala_natural = 0;
		_vala_minimum_baseline = -1;
		_vala_natural_baseline = -1;
	}
	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_timer_progress_bar_snapshot_ring_through_cb (FtGizmo* gizmo,
                                                GtkSnapshot* snapshot)
{
	FtTimerProgressBar* _self_ = NULL;
	GtkWidget* _tmp0_;
	GtkWidget* _tmp1_;
	FtTimerProgressBar* _tmp2_;
	g_return_if_fail (gizmo != NULL);
	g_return_if_fail (snapshot != NULL);
	_tmp0_ = gtk_widget_get_parent ((GtkWidget*) gizmo);
	_tmp1_ = _tmp0_;
	_self_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, FT_TYPE_TIMER_PROGRESS_BAR, FtTimerProgressBar);
	_tmp2_ = _self_;
	if (_tmp2_ != NULL) {
		FtTimerProgressBar* _tmp3_;
		_tmp3_ = _self_;
		ft_timer_progress_bar_snapshot_ring_through (_tmp3_, gizmo, snapshot);
	}
}

static void
ft_timer_progress_bar_snapshot_ring_highlight_cb (FtGizmo* gizmo,
                                                  GtkSnapshot* snapshot)
{
	FtTimerProgressBar* _self_ = NULL;
	GtkWidget* _tmp0_;
	GtkWidget* _tmp1_;
	FtTimerProgressBar* _tmp2_;
	g_return_if_fail (gizmo != NULL);
	g_return_if_fail (snapshot != NULL);
	_tmp0_ = gtk_widget_get_parent ((GtkWidget*) gizmo);
	_tmp1_ = _tmp0_;
	_self_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, FT_TYPE_TIMER_PROGRESS_BAR, FtTimerProgressBar);
	_tmp2_ = _self_;
	if (_tmp2_ != NULL) {
		FtTimerProgressBar* _tmp3_;
		_tmp3_ = _self_;
		ft_timer_progress_bar_snapshot_ring_highlight (_tmp3_, gizmo, snapshot);
	}
}

static void
ft_timer_progress_bar_measure_ring (FtTimerProgressBar* self,
                                    FtGizmo* gizmo,
                                    GtkOrientation orientation,
                                    gint for_size,
                                    gint* minimum,
                                    gint* natural,
                                    gint* minimum_baseline,
                                    gint* natural_baseline)
{
	gint _vala_minimum = 0;
	gint _vala_natural = 0;
	gint _vala_minimum_baseline = 0;
	gint _vala_natural_baseline = 0;
	g_return_if_fail (self != NULL);
	g_return_if_fail (gizmo != NULL);
	_vala_minimum = MAX (for_size, FT_TIMER_PROGRESS_BAR_MIN_WIDTH);
	_vala_natural = _vala_minimum;
	_vala_minimum_baseline = -1;
	_vala_natural_baseline = -1;
	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
_vala_GskStroke_free (GskStroke* self)
{
	g_boxed_free (gsk_stroke_get_type (), self);
}

static void
ft_timer_progress_bar_snapshot_ring_through (FtTimerProgressBar* self,
                                             FtGizmo* gizmo,
                                             GtkSnapshot* snapshot)
{
	GdkRGBA color = {0};
	GdkRGBA _tmp0_ = {0};
	graphene_point_t origin = {0};
	graphene_point_t _tmp1_ = {0};
	GskPathBuilder* path_builder = NULL;
	GskPathBuilder* _tmp2_;
	graphene_point_t _tmp3_;
	GskStroke* stroke = NULL;
	GskStroke* _tmp4_;
	GskPath* _tmp5_;
	GskPath* _tmp6_;
	GdkRGBA _tmp7_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (gizmo != NULL);
	g_return_if_fail (snapshot != NULL);
	gtk_widget_get_color ((GtkWidget*) gizmo, &_tmp0_);
	color = _tmp0_;
	memset (&_tmp1_, 0, sizeof (graphene_point_t));
	_tmp1_.x = ((gfloat) gtk_widget_get_width ((GtkWidget*) gizmo)) / 2.0f;
	_tmp1_.y = ((gfloat) gtk_widget_get_height ((GtkWidget*) gizmo)) / 2.0f;
	origin = _tmp1_;
	_tmp2_ = gsk_path_builder_new ();
	path_builder = _tmp2_;
	_tmp3_ = origin;
	gsk_path_builder_add_circle (path_builder, &_tmp3_, self->priv->radius);
	_tmp4_ = gsk_stroke_new (self->priv->_line_width);
	stroke = _tmp4_;
	_tmp5_ = gsk_path_builder_to_path (path_builder);
	_tmp6_ = _tmp5_;
	_tmp7_ = color;
	gtk_snapshot_append_stroke (snapshot, _tmp6_, stroke, &_tmp7_);
	_gsk_path_unref0 (_tmp6_);
	__vala_GskStroke_free0 (stroke);
	_gsk_path_builder_unref0 (path_builder);
}

static void
ft_timer_progress_bar_snapshot_ring_highlight (FtTimerProgressBar* self,
                                               FtGizmo* gizmo,
                                               GtkSnapshot* snapshot)
{
	gdouble display_value = 0.0;
	gdouble _tmp0_ = 0.0;
	AdwTimedAnimation* _tmp1_;
	gdouble opacity = 0.0;
	gint64 timestamp = 0LL;
	gboolean _tmp5_ = FALSE;
	AdwTimedAnimation* _tmp6_;
	AdwTimedAnimation* _tmp17_;
	gboolean _tmp21_ = FALSE;
	GdkRGBA color = {0};
	GdkRGBA _tmp22_ = {0};
	graphene_point_t origin = {0};
	graphene_point_t _tmp23_ = {0};
	GskPathBuilder* path_builder = NULL;
	GskPathBuilder* _tmp24_;
	gboolean clip_applied = FALSE;
	gboolean opacity_applied = FALSE;
	GskStroke* stroke = NULL;
	GskStroke* _tmp45_;
	GskStroke* _tmp46_;
	GskPathBuilder* _tmp47_;
	GskPath* _tmp48_;
	GskPath* _tmp49_;
	GskStroke* _tmp50_;
	GdkRGBA _tmp51_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (gizmo != NULL);
	g_return_if_fail (snapshot != NULL);
	_tmp1_ = self->priv->opacity_animation;
	if (_tmp1_ != NULL) {
		AdwTimedAnimation* _tmp2_;
		gdouble _tmp3_;
		gdouble _tmp4_;
		_tmp2_ = self->priv->opacity_animation;
		_tmp3_ = adw_animation_get_value ((AdwAnimation*) _tmp2_);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_;
	} else {
		_tmp0_ = 1.0;
	}
	opacity = _tmp0_;
	timestamp = ft_timer_progress_bar_get_current_time (self);
	_tmp6_ = self->priv->opacity_animation;
	if (_tmp6_ == NULL) {
		_tmp5_ = TRUE;
	} else {
		AdwTimedAnimation* _tmp7_;
		gdouble _tmp8_;
		gdouble _tmp9_;
		_tmp7_ = self->priv->opacity_animation;
		_tmp8_ = adw_timed_animation_get_value_to (_tmp7_);
		_tmp9_ = _tmp8_;
		_tmp5_ = _tmp9_ > 0.0;
	}
	if (_tmp5_) {
		gdouble _tmp10_ = 0.0;
		gboolean _tmp11_ = FALSE;
		FtTimer* _tmp12_;
		void* _tmp13_;
		void* _tmp14_;
		_tmp12_ = self->priv->_timer;
		_tmp13_ = ft_timer_get_user_data (_tmp12_);
		_tmp14_ = _tmp13_;
		if (_tmp14_ != NULL) {
			FtTimer* _tmp15_;
			_tmp15_ = self->priv->_timer;
			_tmp11_ = !ft_timer_is_finished (_tmp15_);
		} else {
			_tmp11_ = FALSE;
		}
		if (_tmp11_) {
			FtTimer* _tmp16_;
			_tmp16_ = self->priv->_timer;
			_tmp10_ = ft_timer_calculate_progress (_tmp16_, timestamp);
		} else {
			_tmp10_ = 1.0;
		}
		display_value = _tmp10_;
	} else {
		display_value = self->priv->_display_value;
	}
	_tmp17_ = self->priv->value_animation;
	if (_tmp17_ != NULL) {
		AdwTimedAnimation* _tmp18_;
		gdouble _tmp19_;
		gdouble _tmp20_;
		_tmp18_ = self->priv->value_animation;
		_tmp19_ = adw_animation_get_value ((AdwAnimation*) _tmp18_);
		_tmp20_ = _tmp19_;
		display_value = ft_lerp (self->priv->display_value_from, display_value, _tmp20_);
	}
	if (display_value >= 1.0) {
		_tmp21_ = TRUE;
	} else {
		_tmp21_ = opacity == 0.0;
	}
	if (_tmp21_) {
		self->priv->_display_value = 1.0;
		self->priv->last_display_time = timestamp;
		return;
	}
	gtk_widget_get_color ((GtkWidget*) gizmo, &_tmp22_);
	color = _tmp22_;
	memset (&_tmp23_, 0, sizeof (graphene_point_t));
	_tmp23_.x = ((gfloat) gtk_widget_get_width ((GtkWidget*) gizmo)) / 2.0f;
	_tmp23_.y = ((gfloat) gtk_widget_get_height ((GtkWidget*) gizmo)) / 2.0f;
	origin = _tmp23_;
	_tmp24_ = gsk_path_builder_new ();
	path_builder = _tmp24_;
	clip_applied = FALSE;
	opacity_applied = FALSE;
	if (opacity < 1.0) {
		gtk_snapshot_push_opacity (snapshot, opacity);
		opacity_applied = TRUE;
	}
	if (display_value < 0.001) {
		GskPathBuilder* _tmp25_;
		graphene_point_t _tmp26_;
		_tmp25_ = path_builder;
		_tmp26_ = origin;
		gsk_path_builder_add_circle (_tmp25_, &_tmp26_, self->priv->radius);
	} else {
		if (display_value < 0.999) {
			gdouble sweep_angle = 0.0;
			gfloat sin_angle = 0.0F;
			gfloat cos_angle = 0.0F;
			gfloat _tmp40_ = 0.0F;
			gfloat _tmp41_ = 0.0F;
			GskPathBuilder* _tmp42_;
			graphene_point_t _tmp43_;
			graphene_point_t _tmp44_;
			sweep_angle = (((2.0 * G_PI) + self->priv->line_cap_angle) * (1.0 - display_value)) - self->priv->line_cap_angle;
			if (sweep_angle > (2.0 * G_PI)) {
				GskPathBuilder* _tmp27_;
				graphene_point_t _tmp28_;
				graphene_point_t _tmp29_;
				_tmp27_ = path_builder;
				_tmp28_ = origin;
				_tmp29_ = origin;
				gsk_path_builder_move_to (_tmp27_, _tmp28_.x + self->priv->radius, _tmp29_.y);
				clip_applied = TRUE;
			} else {
				if (sweep_angle < 0.0) {
					GskPathBuilder* _tmp30_;
					graphene_point_t _tmp31_;
					graphene_point_t _tmp32_;
					_tmp30_ = path_builder;
					_tmp31_ = origin;
					_tmp32_ = origin;
					gsk_path_builder_move_to (_tmp30_, _tmp31_.x - self->priv->radius, _tmp32_.y);
					clip_applied = TRUE;
				} else {
					GskPathBuilder* _tmp33_;
					graphene_point_t _tmp34_;
					graphene_point_t _tmp35_;
					_tmp33_ = path_builder;
					_tmp34_ = origin;
					_tmp35_ = origin;
					gsk_path_builder_move_to (_tmp33_, _tmp34_.x, _tmp35_.y - self->priv->radius);
				}
			}
			if (clip_applied) {
				graphene_rect_t clip_bounds = {0};
				GskRoundedRect clip_outline = {0};
				graphene_point_t _tmp36_;
				graphene_point_t _tmp37_;
				graphene_rect_t _tmp38_;
				GskRoundedRect _tmp39_;
				memset (&clip_bounds, 0, sizeof (graphene_rect_t));
				memset (&clip_outline, 0, sizeof (GskRoundedRect));
				_tmp36_ = origin;
				_tmp37_ = origin;
				graphene_rect_init (&clip_bounds, _tmp36_.x - (self->priv->_line_width / 2.0f), (_tmp37_.y - self->priv->radius) - (self->priv->_line_width / 2.0f), self->priv->_line_width, self->priv->_line_width);
				_tmp38_ = clip_bounds;
				gsk_rounded_rect_init_from_rect (&clip_outline, &_tmp38_, self->priv->_line_width / 2.0f);
				_tmp39_ = clip_outline;
				gtk_snapshot_push_rounded_clip (snapshot, &_tmp39_);
			}
			sincosf ((gfloat) ((-G_PI_2) + sweep_angle), &_tmp40_, &_tmp41_);
			sin_angle = _tmp40_;
			cos_angle = _tmp41_;
			_tmp42_ = path_builder;
			_tmp43_ = origin;
			_tmp44_ = origin;
			gsk_path_builder_svg_arc_to (_tmp42_, self->priv->radius, self->priv->radius, 0.0f, sweep_angle > G_PI, TRUE, _tmp43_.x + (self->priv->radius * cos_angle), _tmp44_.y + (self->priv->radius * sin_angle));
		}
	}
	_tmp45_ = gsk_stroke_new (self->priv->_line_width);
	stroke = _tmp45_;
	_tmp46_ = stroke;
	gsk_stroke_set_line_cap (_tmp46_, GSK_LINE_CAP_ROUND);
	_tmp47_ = path_builder;
	_tmp48_ = gsk_path_builder_to_path (_tmp47_);
	_tmp49_ = _tmp48_;
	_tmp50_ = stroke;
	_tmp51_ = color;
	gtk_snapshot_append_stroke (snapshot, _tmp49_, _tmp50_, &_tmp51_);
	_gsk_path_unref0 (_tmp49_);
	if (clip_applied) {
		gtk_snapshot_pop (snapshot);
	}
	if (opacity_applied) {
		gtk_snapshot_pop (snapshot);
	}
	self->priv->_display_value = display_value;
	self->priv->last_display_time = timestamp;
	__vala_GskStroke_free0 (stroke);
	_gsk_path_builder_unref0 (path_builder);
}

static GtkSizeRequestMode
ft_timer_progress_bar_real_get_request_mode (GtkWidget* base)
{
	FtTimerProgressBar * self;
	GtkSizeRequestMode result;
	self = (FtTimerProgressBar*) base;
	result = GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
	return result;
}

static void
ft_timer_progress_bar_real_measure (GtkWidget* base,
                                    GtkOrientation orientation,
                                    gint for_size,
                                    gint* minimum,
                                    gint* natural,
                                    gint* minimum_baseline,
                                    gint* natural_baseline)
{
	FtTimerProgressBar * self;
	gint _vala_minimum = 0;
	gint _vala_natural = 0;
	gint _vala_minimum_baseline = 0;
	gint _vala_natural_baseline = 0;
	gint minimum_for_size = 0;
	FtGizmo* _tmp0_;
	gint _tmp1_ = 0;
	FtGizmo* _tmp2_;
	gint _tmp3_ = 0;
	gint _tmp4_ = 0;
	self = (FtTimerProgressBar*) base;
	minimum_for_size = 0;
	_tmp0_ = self->priv->through;
	gtk_widget_measure ((GtkWidget*) _tmp0_, ft_get_opposite_orientation (orientation), -1, &_tmp1_, NULL, NULL, NULL);
	minimum_for_size = _tmp1_;
	_tmp2_ = self->priv->through;
	gtk_widget_measure ((GtkWidget*) _tmp2_, orientation, MAX (minimum_for_size, for_size), &_tmp3_, &_tmp4_, NULL, NULL);
	_vala_minimum = _tmp3_;
	_vala_natural = _tmp4_;
	_vala_minimum_baseline = -1;
	_vala_natural_baseline = -1;
	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_timer_progress_bar_real_size_allocate (GtkWidget* base,
                                          gint width,
                                          gint height,
                                          gint baseline)
{
	FtTimerProgressBar * self;
	gfloat line_width = 0.0F;
	FtGizmo* _tmp0_;
	FtGizmo* _tmp1_;
	self = (FtTimerProgressBar*) base;
	if (!self->priv->_line_width_set) {
		switch (self->priv->_shape) {
			case FT_TIMER_PROGRESS_SHAPE_BAR:
			{
				line_width = ft_timer_progress_bar_calculate_line_width (self, width);
				break;
			}
			case FT_TIMER_PROGRESS_SHAPE_RING:
			{
				gint size = 0;
				size = MIN (width, height);
				line_width = ft_timer_progress_bar_calculate_line_width (self, size);
				self->priv->radius = (((gfloat) size) - line_width) / 2.0f;
				self->priv->line_cap_radius = line_width / 2.0f;
				self->priv->line_cap_angle = atan2f (2.0f * self->priv->line_cap_radius, self->priv->radius);
				break;
			}
			default:
			{
				g_assert_not_reached ();
			}
		}
	} else {
		line_width = self->priv->_line_width;
	}
	if (self->priv->_line_width != line_width) {
		self->priv->_line_width = line_width;
		g_object_notify ((GObject*) self, "line-width");
	}
	_tmp0_ = self->priv->through;
	gtk_widget_allocate ((GtkWidget*) _tmp0_, width, height, baseline, NULL);
	_tmp1_ = self->priv->highlight;
	gtk_widget_allocate ((GtkWidget*) _tmp1_, width, height, baseline, NULL);
}

static void
ft_timer_progress_bar_real_snapshot (GtkWidget* base,
                                     GtkSnapshot* snapshot)
{
	FtTimerProgressBar * self;
	FtGizmo* _tmp0_;
	FtGizmo* _tmp1_;
	self = (FtTimerProgressBar*) base;
	g_return_if_fail (snapshot != NULL);
	_tmp0_ = self->priv->through;
	gtk_widget_snapshot_child ((GtkWidget*) self, (GtkWidget*) _tmp0_, snapshot);
	_tmp1_ = self->priv->highlight;
	gtk_widget_snapshot_child ((GtkWidget*) self, (GtkWidget*) _tmp1_, snapshot);
}

static void
_ft_timer_progress_bar_on_timer_state_changed_ft_timer_state_changed (FtTimer* _sender,
                                                                      const FtTimerState* current_state,
                                                                      const FtTimerState* previous_state,
                                                                      gpointer self)
{
	ft_timer_progress_bar_on_timer_state_changed ((FtTimerProgressBar*) self, current_state, previous_state);
}

static void
ft_timer_progress_bar_real_map (GtkWidget* base)
{
	FtTimerProgressBar * self;
	FtTimer* _tmp0_;
	FtTimer* _tmp1_;
	self = (FtTimerProgressBar*) base;
	GTK_WIDGET_CLASS (ft_timer_progress_bar_parent_class)->map (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
	_tmp0_ = self->priv->_timer;
	g_signal_connect_object (_tmp0_, "state-changed", (GCallback) _ft_timer_progress_bar_on_timer_state_changed_ft_timer_state_changed, self, 0);
	self->priv->timeout_inhibit_count = (guint) 0;
	_tmp1_ = self->priv->_timer;
	if (ft_timer_is_running (_tmp1_)) {
		ft_timer_progress_bar_start_timeout (self);
	}
}

static void
ft_timer_progress_bar_real_unmap (GtkWidget* base)
{
	FtTimerProgressBar * self;
	FtTimer* _tmp0_;
	guint _tmp1_;
	AdwTimedAnimation* _tmp2_;
	AdwTimedAnimation* _tmp4_;
	self = (FtTimerProgressBar*) base;
	ft_timer_progress_bar_stop_timeout (self);
	_tmp0_ = self->priv->_timer;
	g_signal_parse_name ("state-changed", FT_TYPE_TIMER, &_tmp1_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp0_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp1_, 0, NULL, (GCallback) _ft_timer_progress_bar_on_timer_state_changed_ft_timer_state_changed, self);
	_tmp2_ = self->priv->value_animation;
	if (_tmp2_ != NULL) {
		AdwTimedAnimation* _tmp3_;
		_tmp3_ = self->priv->value_animation;
		adw_animation_pause ((AdwAnimation*) _tmp3_);
		_g_object_unref0 (self->priv->value_animation);
		self->priv->value_animation = NULL;
	}
	_tmp4_ = self->priv->opacity_animation;
	if (_tmp4_ != NULL) {
		AdwTimedAnimation* _tmp5_;
		_tmp5_ = self->priv->opacity_animation;
		adw_animation_pause ((AdwAnimation*) _tmp5_);
		_g_object_unref0 (self->priv->opacity_animation);
		self->priv->opacity_animation = NULL;
	}
	GTK_WIDGET_CLASS (ft_timer_progress_bar_parent_class)->unmap (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
}

static void
ft_timer_progress_bar_real_dispose (GObject* base)
{
	FtTimerProgressBar * self;
	AdwTimedAnimation* _tmp0_;
	AdwTimedAnimation* _tmp2_;
	FtGizmo* _tmp4_;
	FtGizmo* _tmp5_;
	self = (FtTimerProgressBar*) base;
	ft_timer_progress_bar_stop_timeout (self);
	_tmp0_ = self->priv->value_animation;
	if (_tmp0_ != NULL) {
		AdwTimedAnimation* _tmp1_;
		_tmp1_ = self->priv->value_animation;
		adw_animation_pause ((AdwAnimation*) _tmp1_);
		_g_object_unref0 (self->priv->value_animation);
		self->priv->value_animation = NULL;
	}
	_tmp2_ = self->priv->opacity_animation;
	if (_tmp2_ != NULL) {
		AdwTimedAnimation* _tmp3_;
		_tmp3_ = self->priv->opacity_animation;
		adw_animation_pause ((AdwAnimation*) _tmp3_);
		_g_object_unref0 (self->priv->opacity_animation);
		self->priv->opacity_animation = NULL;
	}
	_tmp4_ = self->priv->through;
	gtk_widget_unparent ((GtkWidget*) _tmp4_);
	_tmp5_ = self->priv->highlight;
	gtk_widget_unparent ((GtkWidget*) _tmp5_);
	self->priv->through = NULL;
	self->priv->highlight = NULL;
	_g_object_unref0 (self->priv->_timer);
	self->priv->_timer = NULL;
	G_OBJECT_CLASS (ft_timer_progress_bar_parent_class)->dispose ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
}

FtTimerProgressBar*
ft_timer_progress_bar_construct (GType object_type)
{
	FtTimerProgressBar * self = NULL;
	self = (FtTimerProgressBar*) g_object_new (object_type, NULL);
	return self;
}

FtTimerProgressBar*
ft_timer_progress_bar_new (void)
{
	return ft_timer_progress_bar_construct (FT_TYPE_TIMER_PROGRESS_BAR);
}

FtTimer*
ft_timer_progress_bar_get_timer (FtTimerProgressBar* self)
{
	FtTimer* result;
	FtTimer* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_timer;
	result = _tmp0_;
	return result;
}

static void
ft_timer_progress_bar_set_timer (FtTimerProgressBar* self,
                                 FtTimer* value)
{
	FtTimer* _tmp0_ = NULL;
	FtTimer* _tmp2_;
	g_return_if_fail (self != NULL);
	if (value != NULL) {
		_tmp0_ = value;
	} else {
		FtTimer* _tmp1_;
		_tmp1_ = ft_timer_get_default ();
		_tmp0_ = _tmp1_;
	}
	_tmp2_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->_timer);
	self->priv->_timer = _tmp2_;
	g_object_notify_by_pspec ((GObject *) self, ft_timer_progress_bar_properties[FT_TIMER_PROGRESS_BAR_TIMER_PROPERTY]);
}

FtTimerProgressShape
ft_timer_progress_bar_get_shape (FtTimerProgressBar* self)
{
	FtTimerProgressShape result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_shape;
	return result;
}

static void
_ft_timer_progress_bar_measure_bar_cb_ft_gizmo_measure_func (FtGizmo* gizmo,
                                                             GtkOrientation orientation,
                                                             gint for_size,
                                                             gint* minimum,
                                                             gint* natural,
                                                             gint* minimum_baseline,
                                                             gint* natural_baseline,
                                                             gpointer self)
{
	ft_timer_progress_bar_measure_bar_cb (gizmo, orientation, for_size, minimum, natural, minimum_baseline, natural_baseline);
}

static void
_ft_timer_progress_bar_snapshot_bar_through_cb_ft_gizmo_snapshot_func (FtGizmo* gizmo,
                                                                       GtkSnapshot* snapshot,
                                                                       gpointer self)
{
	ft_timer_progress_bar_snapshot_bar_through_cb (gizmo, snapshot);
}

static void
_ft_timer_progress_bar_snapshot_bar_highlight_cb_ft_gizmo_snapshot_func (FtGizmo* gizmo,
                                                                         GtkSnapshot* snapshot,
                                                                         gpointer self)
{
	ft_timer_progress_bar_snapshot_bar_highlight_cb (gizmo, snapshot);
}

static void
_ft_timer_progress_bar_measure_ring_cb_ft_gizmo_measure_func (FtGizmo* gizmo,
                                                              GtkOrientation orientation,
                                                              gint for_size,
                                                              gint* minimum,
                                                              gint* natural,
                                                              gint* minimum_baseline,
                                                              gint* natural_baseline,
                                                              gpointer self)
{
	ft_timer_progress_bar_measure_ring_cb (gizmo, orientation, for_size, minimum, natural, minimum_baseline, natural_baseline);
}

static void
_ft_timer_progress_bar_snapshot_ring_through_cb_ft_gizmo_snapshot_func (FtGizmo* gizmo,
                                                                        GtkSnapshot* snapshot,
                                                                        gpointer self)
{
	ft_timer_progress_bar_snapshot_ring_through_cb (gizmo, snapshot);
}

static void
_ft_timer_progress_bar_snapshot_ring_highlight_cb_ft_gizmo_snapshot_func (FtGizmo* gizmo,
                                                                          GtkSnapshot* snapshot,
                                                                          gpointer self)
{
	ft_timer_progress_bar_snapshot_ring_highlight_cb (gizmo, snapshot);
}

static void
ft_timer_progress_bar_set_shape (FtTimerProgressBar* self,
                                 FtTimerProgressShape value)
{
	FtGizmo* through = NULL;
	FtGizmo* highlight = NULL;
	FtGizmo* _tmp4_;
	FtGizmo* _tmp5_;
	FtGizmo* _tmp6_;
	FtGizmo* _tmp7_;
	FtGizmo* _tmp8_;
	FtGizmo* _tmp9_;
	FtGizmo* _tmp10_;
	FtGizmo* _tmp11_;
	g_return_if_fail (self != NULL);
	self->priv->_shape = value;
	switch (self->priv->_shape) {
		case FT_TIMER_PROGRESS_SHAPE_BAR:
		{
			FtGizmo* _tmp0_;
			FtGizmo* _tmp1_;
			_tmp0_ = ft_gizmo_new (_ft_timer_progress_bar_measure_bar_cb_ft_gizmo_measure_func, NULL, NULL, NULL, NULL, NULL, _ft_timer_progress_bar_snapshot_bar_through_cb_ft_gizmo_snapshot_func, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
			g_object_ref_sink (_tmp0_);
			_g_object_unref0 (through);
			through = _tmp0_;
			_tmp1_ = ft_gizmo_new (_ft_timer_progress_bar_measure_bar_cb_ft_gizmo_measure_func, NULL, NULL, NULL, NULL, NULL, _ft_timer_progress_bar_snapshot_bar_highlight_cb_ft_gizmo_snapshot_func, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
			g_object_ref_sink (_tmp1_);
			_g_object_unref0 (highlight);
			highlight = _tmp1_;
			break;
		}
		case FT_TIMER_PROGRESS_SHAPE_RING:
		{
			FtGizmo* _tmp2_;
			FtGizmo* _tmp3_;
			_tmp2_ = ft_gizmo_new (_ft_timer_progress_bar_measure_ring_cb_ft_gizmo_measure_func, NULL, NULL, NULL, NULL, NULL, _ft_timer_progress_bar_snapshot_ring_through_cb_ft_gizmo_snapshot_func, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
			g_object_ref_sink (_tmp2_);
			_g_object_unref0 (through);
			through = _tmp2_;
			_tmp3_ = ft_gizmo_new (_ft_timer_progress_bar_measure_ring_cb_ft_gizmo_measure_func, NULL, NULL, NULL, NULL, NULL, _ft_timer_progress_bar_snapshot_ring_highlight_cb_ft_gizmo_snapshot_func, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
			g_object_ref_sink (_tmp3_);
			_g_object_unref0 (highlight);
			highlight = _tmp3_;
			break;
		}
		default:
		{
			g_assert_not_reached ();
		}
	}
	_tmp4_ = through;
	gtk_widget_set_focusable ((GtkWidget*) _tmp4_, FALSE);
	_tmp5_ = through;
	gtk_widget_add_css_class ((GtkWidget*) _tmp5_, "through");
	_tmp6_ = through;
	gtk_widget_set_parent ((GtkWidget*) _tmp6_, (GtkWidget*) self);
	_tmp7_ = highlight;
	gtk_widget_set_focusable ((GtkWidget*) _tmp7_, FALSE);
	_tmp8_ = highlight;
	gtk_widget_add_css_class ((GtkWidget*) _tmp8_, "highlight");
	_tmp9_ = highlight;
	gtk_widget_set_parent ((GtkWidget*) _tmp9_, (GtkWidget*) self);
	_tmp10_ = through;
	self->priv->through = _tmp10_;
	_tmp11_ = highlight;
	self->priv->highlight = _tmp11_;
	gtk_widget_queue_resize ((GtkWidget*) self);
	_g_object_unref0 (highlight);
	_g_object_unref0 (through);
}

gfloat
ft_timer_progress_bar_get_line_width (FtTimerProgressBar* self)
{
	gfloat result;
	g_return_val_if_fail (self != NULL, -1.0F);
	result = self->priv->_line_width;
	return result;
}

void
ft_timer_progress_bar_set_line_width (FtTimerProgressBar* self,
                                      gfloat value)
{
	g_return_if_fail (self != NULL);
	if (self->priv->_line_width != value) {
		self->priv->_line_width = value;
		ft_timer_progress_bar_set_line_width_set (self, TRUE);
		g_object_notify ((GObject*) self, "line-width");
		gtk_widget_queue_allocate ((GtkWidget*) self);
	}
}

gboolean
ft_timer_progress_bar_get_line_width_set (FtTimerProgressBar* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_line_width_set;
	return result;
}

void
ft_timer_progress_bar_set_line_width_set (FtTimerProgressBar* self,
                                          gboolean value)
{
	g_return_if_fail (self != NULL);
	if (self->priv->_line_width_set != value) {
		self->priv->_line_width_set = value;
		g_object_notify ((GObject*) self, "line-width-set");
		gtk_widget_queue_allocate ((GtkWidget*) self);
	}
}

gfloat
ft_timer_progress_bar_get_display_value (FtTimerProgressBar* self)
{
	gfloat result;
	g_return_val_if_fail (self != NULL, -1.0F);
	result = (gfloat) self->priv->_display_value;
	return result;
}

static void
ft_timer_progress_bar_class_init (FtTimerProgressBarClass * klass,
                                  gpointer klass_data)
{
	ft_timer_progress_bar_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FtTimerProgressBar_private_offset);
	((GtkWidgetClass *) klass)->get_request_mode = (GtkSizeRequestMode (*) (GtkWidget*)) ft_timer_progress_bar_real_get_request_mode;
	((GtkWidgetClass *) klass)->measure = (void (*) (GtkWidget*, GtkOrientation, gint, gint*, gint*, gint*, gint*)) ft_timer_progress_bar_real_measure;
	((GtkWidgetClass *) klass)->size_allocate = (void (*) (GtkWidget*, gint, gint, gint)) ft_timer_progress_bar_real_size_allocate;
	((GtkWidgetClass *) klass)->snapshot = (void (*) (GtkWidget*, GtkSnapshot*)) ft_timer_progress_bar_real_snapshot;
	((GtkWidgetClass *) klass)->map = (void (*) (GtkWidget*)) ft_timer_progress_bar_real_map;
	((GtkWidgetClass *) klass)->unmap = (void (*) (GtkWidget*)) ft_timer_progress_bar_real_unmap;
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) ft_timer_progress_bar_real_dispose;
	G_OBJECT_CLASS (klass)->get_property = _vala_ft_timer_progress_bar_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_ft_timer_progress_bar_set_property;
	G_OBJECT_CLASS (klass)->finalize = ft_timer_progress_bar_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_TIMER_PROGRESS_BAR_TIMER_PROPERTY, ft_timer_progress_bar_properties[FT_TIMER_PROGRESS_BAR_TIMER_PROPERTY] = g_param_spec_object ("timer", "timer", "timer", FT_TYPE_TIMER, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_TIMER_PROGRESS_BAR_SHAPE_PROPERTY, ft_timer_progress_bar_properties[FT_TIMER_PROGRESS_BAR_SHAPE_PROPERTY] = g_param_spec_enum ("shape", "shape", "shape", FT_TYPE_TIMER_PROGRESS_SHAPE, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_EXPLICIT_NOTIFY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_TIMER_PROGRESS_BAR_LINE_WIDTH_PROPERTY, ft_timer_progress_bar_properties[FT_TIMER_PROGRESS_BAR_LINE_WIDTH_PROPERTY] = g_param_spec_float ("line-width", "line-width", "line-width", -G_MAXFLOAT, G_MAXFLOAT, 0.0F, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_EXPLICIT_NOTIFY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_TIMER_PROGRESS_BAR_LINE_WIDTH_SET_PROPERTY, ft_timer_progress_bar_properties[FT_TIMER_PROGRESS_BAR_LINE_WIDTH_SET_PROPERTY] = g_param_spec_boolean ("line-width-set", "line-width-set", "line-width-set", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_EXPLICIT_NOTIFY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_TIMER_PROGRESS_BAR_DISPLAY_VALUE_PROPERTY, ft_timer_progress_bar_properties[FT_TIMER_PROGRESS_BAR_DISPLAY_VALUE_PROPERTY] = g_param_spec_float ("display-value", "display-value", "display-value", -G_MAXFLOAT, G_MAXFLOAT, 0.0F, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (klass), "timerprogressbar");
}

static void
ft_timer_progress_bar_instance_init (FtTimerProgressBar * self,
                                     gpointer klass)
{
	self->priv = ft_timer_progress_bar_get_instance_private (self);
	self->priv->_shape = FT_TIMER_PROGRESS_SHAPE_BAR;
	self->priv->_line_width = FT_TIMER_PROGRESS_BAR_MIN_LINE_WIDTH;
	self->priv->_line_width_set = FALSE;
	self->priv->_display_value = 0.0;
	self->priv->display_value_from = 0.0;
	self->priv->display_value_to = 0.0;
	self->priv->last_display_time = FT_TIMESTAMP_UNDEFINED;
	self->priv->value_animation = NULL;
	self->priv->opacity_animation = NULL;
	self->priv->through = NULL;
	self->priv->highlight = NULL;
	self->priv->tick_id = (gulong) 0U;
	self->priv->tick_callback_id = 0U;
	self->priv->timeout_id = 0U;
	self->priv->timeout_interval = 0U;
	self->priv->timeout_inhibit_count = 0U;
}

static void
ft_timer_progress_bar_finalize (GObject * obj)
{
	FtTimerProgressBar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_TIMER_PROGRESS_BAR, FtTimerProgressBar);
	_g_object_unref0 (self->priv->_timer);
	_g_object_unref0 (self->priv->value_animation);
	_g_object_unref0 (self->priv->opacity_animation);
	G_OBJECT_CLASS (ft_timer_progress_bar_parent_class)->finalize (obj);
}

static GType
ft_timer_progress_bar_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtTimerProgressBarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_timer_progress_bar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtTimerProgressBar), 0, (GInstanceInitFunc) ft_timer_progress_bar_instance_init, NULL };
	GType ft_timer_progress_bar_type_id;
	ft_timer_progress_bar_type_id = g_type_register_static (gtk_widget_get_type (), "FtTimerProgressBar", &g_define_type_info, 0);
	FtTimerProgressBar_private_offset = g_type_add_instance_private (ft_timer_progress_bar_type_id, sizeof (FtTimerProgressBarPrivate));
	return ft_timer_progress_bar_type_id;
}

GType
ft_timer_progress_bar_get_type (void)
{
	static volatile gsize ft_timer_progress_bar_type_id__once = 0;
	if (g_once_init_enter (&ft_timer_progress_bar_type_id__once)) {
		GType ft_timer_progress_bar_type_id;
		ft_timer_progress_bar_type_id = ft_timer_progress_bar_get_type_once ();
		g_once_init_leave (&ft_timer_progress_bar_type_id__once, ft_timer_progress_bar_type_id);
	}
	return ft_timer_progress_bar_type_id__once;
}

static void
_vala_ft_timer_progress_bar_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec)
{
	FtTimerProgressBar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_TIMER_PROGRESS_BAR, FtTimerProgressBar);
	switch (property_id) {
		case FT_TIMER_PROGRESS_BAR_TIMER_PROPERTY:
		g_value_set_object (value, ft_timer_progress_bar_get_timer (self));
		break;
		case FT_TIMER_PROGRESS_BAR_SHAPE_PROPERTY:
		g_value_set_enum (value, ft_timer_progress_bar_get_shape (self));
		break;
		case FT_TIMER_PROGRESS_BAR_LINE_WIDTH_PROPERTY:
		g_value_set_float (value, ft_timer_progress_bar_get_line_width (self));
		break;
		case FT_TIMER_PROGRESS_BAR_LINE_WIDTH_SET_PROPERTY:
		g_value_set_boolean (value, ft_timer_progress_bar_get_line_width_set (self));
		break;
		case FT_TIMER_PROGRESS_BAR_DISPLAY_VALUE_PROPERTY:
		g_value_set_float (value, ft_timer_progress_bar_get_display_value (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_ft_timer_progress_bar_set_property (GObject * object,
                                          guint property_id,
                                          const GValue * value,
                                          GParamSpec * pspec)
{
	FtTimerProgressBar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_TIMER_PROGRESS_BAR, FtTimerProgressBar);
	switch (property_id) {
		case FT_TIMER_PROGRESS_BAR_TIMER_PROPERTY:
		ft_timer_progress_bar_set_timer (self, g_value_get_object (value));
		break;
		case FT_TIMER_PROGRESS_BAR_SHAPE_PROPERTY:
		ft_timer_progress_bar_set_shape (self, g_value_get_enum (value));
		break;
		case FT_TIMER_PROGRESS_BAR_LINE_WIDTH_PROPERTY:
		ft_timer_progress_bar_set_line_width (self, g_value_get_float (value));
		break;
		case FT_TIMER_PROGRESS_BAR_LINE_WIDTH_SET_PROPERTY:
		ft_timer_progress_bar_set_line_width_set (self, g_value_get_boolean (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;
}

