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

/*
 * Copyright (c) 2016-2025 focus-timer contributors
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#include "ft_ui.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <adwaita.h>
#include "ft_core.h"
#include <libpeas.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
#include <gio/gio.h>
#include <float.h>
#include <math.h>
#include <gdk/gdk.h>

#define FT_WINDOW_TOAST_DISMISS_TIMEOUT ((guint) 3)
#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_WINDOW_0_PROPERTY,
	FT_WINDOW_SIZE_PROPERTY,
	FT_WINDOW_VIEW_PROPERTY,
	FT_WINDOW_NUM_PROPERTIES
};
static GParamSpec* ft_window_properties[FT_WINDOW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _FtWindowCloseToBackgroundInternalData FtWindowCloseToBackgroundInternalData;
typedef struct _Block16Data Block16Data;
typedef struct _Block17Data Block17Data;
#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 _FtWindowPrivate {
	FtSizeStack* size_stack;
	AdwViewStack* view_stack;
	AdwToastOverlay* toast_overlay;
	FtTimerView* timer_view;
	FtWindowSize _size;
	FtWindowView _view;
	FtSessionManager* session_manager;
	FtTimer* timer;
	FtTimerActionGroup* timer_action_group;
	FtBackgroundManager* background_manager;
	PeasExtensionSet* extensions;
};

struct _FtWindowCloseToBackgroundInternalData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	FtWindow* self;
	gchar* window_id;
	gchar* _tmp0_;
	FtBackgroundManager* _tmp1_;
	const gchar* _tmp2_;
};

struct _Block16Data {
	int _ref_count_;
	FtWindow* self;
	gulong state_flags_changed_id;
	AdwToast* toast;
};

struct _Block17Data {
	int _ref_count_;
	FtWindow* self;
	FtWindow* _self_;
	AdwAlertDialog* dialog;
};

static gint FtWindow_private_offset;
static gpointer ft_window_parent_class = NULL;
static guint ft_window_background_hold_id;
static guint ft_window_background_hold_id = 0U;
static GtkBuildableIface * ft_window_gtk_buildable_parent_iface = NULL;

static void ft_window_update_title (FtWindow* self);
static void ft_window_update_timer_indicator (FtWindow* self);
static void ft_window_close_to_background_internal_data_free (gpointer _data);
static void ft_window_close_to_background_internal (FtWindow* self,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_);
static void ft_window_close_to_background_internal_finish (FtWindow* self,
                                                    GAsyncResult* _res_);
static gboolean ft_window_close_to_background_internal_co (FtWindowCloseToBackgroundInternalData* _data_);
VALA_EXTERN void ft_get_window_identifier (GtkWindow* window,
                               GAsyncReadyCallback _callback_,
                               gpointer _user_data_);
VALA_EXTERN gchar* ft_get_window_identifier_finish (GAsyncResult* _res_);
static void ft_window_close_to_background_internal_ready (GObject* source_object,
                                                   GAsyncResult* _res_,
                                                   gpointer _user_data_);
static void ft_window_dismiss_toast_once_focused (FtWindow* self,
                                           AdwToast* toast);
static Block16Data* block16_data_ref (Block16Data* _data16_);
static void block16_data_unref (void * _userdata_);
static void __lambda49_ (Block16Data* _data16_,
                  GtkStateFlags previous_state_flags);
static void ___lambda49__gtk_widget_state_flags_changed (GtkWidget* _sender,
                                                  GtkStateFlags previous_state_flags,
                                                  gpointer self);
static void __lambda50_ (Block16Data* _data16_);
static void ___lambda50__adw_toast_dismissed (AdwToast* _sender,
                                       gpointer self);
static void ft_window_dismiss_toast_once_user_becomes_active (FtWindow* self,
                                                       AdwToast* toast);
static void ft_window_show_close_confirmation_dialog (FtWindow* self);
static Block17Data* block17_data_ref (Block17Data* _data17_);
static void block17_data_unref (void * _userdata_);
static void __lambda52_ (Block17Data* _data17_,
                  const gchar* response);
static void ___lambda52__adw_alert_dialog_response (AdwAlertDialog* _sender,
                                             const gchar* response,
                                             gpointer self);
static void ft_window_on_size_stack_visible_child_notify (FtWindow* self,
                                                   GObject* object,
                                                   GParamSpec* pspec);
static void _ft_window_on_size_stack_visible_child_notify_g_object_notify (GObject* _sender,
                                                                    GParamSpec* pspec,
                                                                    gpointer self);
static void ft_window_on_view_stack_visible_child_notify (FtWindow* self,
                                                   GObject* object,
                                                   GParamSpec* pspec);
static void _ft_window_on_view_stack_visible_child_notify_g_object_notify (GObject* _sender,
                                                                    GParamSpec* pspec,
                                                                    gpointer self);
static void ft_window_on_gesture_click_pressed (FtWindow* self,
                                         GtkGestureClick* gesture,
                                         gint n_press,
                                         gdouble x,
                                         gdouble y);
static void _ft_window_on_gesture_click_pressed_gtk_gesture_click_pressed (GtkGestureClick* _sender,
                                                                    gint n_press,
                                                                    gdouble x,
                                                                    gdouble y,
                                                                    gpointer self);
static gboolean ft_window_on_close_request (FtWindow* self);
static gboolean _ft_window_on_close_request_gtk_window_close_request (GtkWindow* _sender,
                                                               gpointer self);
static void ft_window_on_notify_is_active (FtWindow* self,
                                    GObject* object,
                                    GParamSpec* pspec);
static void ft_window_on_notify_maximized (FtWindow* self,
                                    GObject* object,
                                    GParamSpec* pspec);
static void ft_window_on_compact_size_activate (FtWindow* self,
                                         GSimpleAction* action,
                                         GVariant* parameter);
static void ft_window_on_normal_size_activate (FtWindow* self,
                                        GSimpleAction* action,
                                        GVariant* parameter);
static void ft_window_on_toggle_compact_size_activate (FtWindow* self,
                                                GSimpleAction* action,
                                                GVariant* parameter);
static void ft_window_on_extension_added (FtWindow* self,
                                   PeasExtensionSet* extension_set,
                                   PeasPluginInfo* plugin_info,
                                   GObject* object);
static void ft_window_setup_extension (FtWindow* self,
                                GObject* object);
static void ft_window_setup_actions (FtWindow* self);
static void _ft_window_on_compact_size_activate_g_simple_action_activate (GSimpleAction* _sender,
                                                                   GVariant* parameter,
                                                                   gpointer self);
static void _ft_window_on_normal_size_activate_g_simple_action_activate (GSimpleAction* _sender,
                                                                  GVariant* parameter,
                                                                  gpointer self);
static void _ft_window_on_toggle_compact_size_activate_g_simple_action_activate (GSimpleAction* _sender,
                                                                          GVariant* parameter,
                                                                          gpointer self);
static void ft_window_real_parser_finished (GtkBuildable* base,
                                     GtkBuilder* builder);
static void ft_window_real_dispose (GObject* base);
static GObject * ft_window_constructor (GType type,
                                 guint n_construct_properties,
                                 GObjectConstructParam * construct_properties);
static void _ft_window___lambda53_ (FtWindow* self);
static void __ft_window___lambda53__ft_timer_state_changed (FtTimer* _sender,
                                                     const FtTimerState* current_state,
                                                     const FtTimerState* previous_state,
                                                     gpointer self);
static void _ft_window_on_notify_is_active_g_object_notify (GObject* _sender,
                                                     GParamSpec* pspec,
                                                     gpointer self);
static void _ft_window_on_notify_maximized_g_object_notify (GObject* _sender,
                                                     GParamSpec* pspec,
                                                     gpointer self);
static void _vala_GValue_array_free (GValue * array,
                              gssize array_length);
static void _ft_window_on_extension_added_peas_extension_set_extension_added (PeasExtensionSet* _sender,
                                                                       PeasPluginInfo* info,
                                                                       GObject* extension,
                                                                       gpointer self);
static void _ft_window___lambda54_ (FtWindow* self,
                             GObject* object);
static void __ft_window___lambda54__ft_extension_set_foreach_func (GObject* object,
                                                            gpointer self);
static void ft_window_finalize (GObject * obj);
static GType ft_window_get_type_once (void);
static void _vala_ft_window_get_property (GObject * object,
                                   guint property_id,
                                   GValue * value,
                                   GParamSpec * pspec);
static void _vala_ft_window_set_property (GObject * object,
                                   guint property_id,
                                   const GValue * value,
                                   GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

FtWindowSize
ft_window_size_from_string (const gchar* name)
{
	const gchar* _tmp0_;
	GQuark _tmp2_ = 0U;
	static GQuark _tmp1_label0 = 0;
	FtWindowSize result;
	_tmp0_ = name;
	_tmp2_ = (NULL == _tmp0_) ? 0 : g_quark_from_string (_tmp0_);
	if (_tmp2_ == ((0 != _tmp1_label0) ? _tmp1_label0 : (_tmp1_label0 = g_quark_from_static_string ("compact")))) {
		switch (0) {
			default:
			{
				result = FT_WINDOW_SIZE_COMPACT;
				return result;
			}
		}
	} else {
		switch (0) {
			default:
			{
				result = FT_WINDOW_SIZE_NORMAL;
				return result;
			}
		}
	}
}

gchar*
ft_window_size_to_string (FtWindowSize self)
{
	gchar* result;
	switch (self) {
		case FT_WINDOW_SIZE_NORMAL:
		{
			gchar* _tmp0_;
			_tmp0_ = g_strdup ("normal");
			result = _tmp0_;
			return result;
		}
		case FT_WINDOW_SIZE_COMPACT:
		{
			gchar* _tmp1_;
			_tmp1_ = g_strdup ("compact");
			result = _tmp1_;
			return result;
		}
		default:
		{
			g_assert_not_reached ();
		}
	}
}

static GType
ft_window_size_get_type_once (void)
{
	static const GEnumValue values[] = {{FT_WINDOW_SIZE_NORMAL, "FT_WINDOW_SIZE_NORMAL", "normal"}, {FT_WINDOW_SIZE_COMPACT, "FT_WINDOW_SIZE_COMPACT", "compact"}, {0, NULL, NULL}};
	GType ft_window_size_type_id;
	ft_window_size_type_id = g_enum_register_static ("FtWindowSize", values);
	return ft_window_size_type_id;
}

GType
ft_window_size_get_type (void)
{
	static volatile gsize ft_window_size_type_id__once = 0;
	if (g_once_init_enter (&ft_window_size_type_id__once)) {
		GType ft_window_size_type_id;
		ft_window_size_type_id = ft_window_size_get_type_once ();
		g_once_init_leave (&ft_window_size_type_id__once, ft_window_size_type_id);
	}
	return ft_window_size_type_id__once;
}

FtWindowView
ft_window_view_from_string (const gchar* view_name)
{
	const gchar* _tmp0_;
	GQuark _tmp2_ = 0U;
	static GQuark _tmp1_label0 = 0;
	static GQuark _tmp1_label1 = 0;
	FtWindowView result;
	_tmp0_ = view_name;
	_tmp2_ = (NULL == _tmp0_) ? 0 : g_quark_from_string (_tmp0_);
	if (_tmp2_ == ((0 != _tmp1_label0) ? _tmp1_label0 : (_tmp1_label0 = g_quark_from_static_string ("timer")))) {
		switch (0) {
			default:
			{
				result = FT_WINDOW_VIEW_TIMER;
				return result;
			}
		}
	} else if (_tmp2_ == ((0 != _tmp1_label1) ? _tmp1_label1 : (_tmp1_label1 = g_quark_from_static_string ("stats")))) {
		switch (0) {
			default:
			{
				result = FT_WINDOW_VIEW_STATS;
				return result;
			}
		}
	} else {
		switch (0) {
			default:
			{
				result = FT_WINDOW_VIEW_DEFAULT;
				return result;
			}
		}
	}
}

gchar*
ft_window_view_to_string (FtWindowView self)
{
	gchar* result;
	switch (self) {
		case FT_WINDOW_VIEW_TIMER:
		{
			gchar* _tmp0_;
			_tmp0_ = g_strdup ("timer");
			result = _tmp0_;
			return result;
		}
		case FT_WINDOW_VIEW_STATS:
		{
			gchar* _tmp1_;
			_tmp1_ = g_strdup ("stats");
			result = _tmp1_;
			return result;
		}
		case FT_WINDOW_VIEW_DEFAULT:
		{
			gchar* _tmp2_;
			_tmp2_ = g_strdup ("");
			result = _tmp2_;
			return result;
		}
		default:
		{
			g_assert_not_reached ();
		}
	}
}

static GType
ft_window_view_get_type_once (void)
{
	static const GEnumValue values[] = {{FT_WINDOW_VIEW_DEFAULT, "FT_WINDOW_VIEW_DEFAULT", "default"}, {FT_WINDOW_VIEW_TIMER, "FT_WINDOW_VIEW_TIMER", "timer"}, {FT_WINDOW_VIEW_STATS, "FT_WINDOW_VIEW_STATS", "stats"}, {0, NULL, NULL}};
	GType ft_window_view_type_id;
	ft_window_view_type_id = g_enum_register_static ("FtWindowView", values);
	return ft_window_view_type_id;
}

GType
ft_window_view_get_type (void)
{
	static volatile gsize ft_window_view_type_id__once = 0;
	if (g_once_init_enter (&ft_window_view_type_id__once)) {
		GType ft_window_view_type_id;
		ft_window_view_type_id = ft_window_view_get_type_once ();
		g_once_init_leave (&ft_window_view_type_id__once, ft_window_view_type_id);
	}
	return ft_window_view_type_id__once;
}

static inline gpointer
ft_window_get_instance_private (FtWindow* self)
{
	return G_STRUCT_MEMBER_P (self, FtWindow_private_offset);
}

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

static void
ft_window_update_title (FtWindow* self)
{
	AdwViewStackPage* _tmp0_ = NULL;
	AdwViewStackPage* page = NULL;
	AdwViewStackPage* _tmp6_;
	const gchar* _tmp7_ = NULL;
	AdwViewStackPage* _tmp8_;
	g_return_if_fail (self != NULL);
	if (self->priv->_size == FT_WINDOW_SIZE_NORMAL) {
		AdwViewStack* _tmp1_;
		AdwViewStack* _tmp2_;
		GtkWidget* _tmp3_;
		GtkWidget* _tmp4_;
		AdwViewStackPage* _tmp5_;
		_tmp1_ = self->priv->view_stack;
		_tmp2_ = self->priv->view_stack;
		_tmp3_ = adw_view_stack_get_visible_child (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp5_ = adw_view_stack_get_page (_tmp1_, _tmp4_);
		_tmp0_ = _tmp5_;
	} else {
		_tmp0_ = NULL;
	}
	_tmp6_ = _g_object_ref0 (_tmp0_);
	page = _tmp6_;
	_tmp8_ = page;
	if (_tmp8_ != NULL) {
		AdwViewStackPage* _tmp9_;
		const gchar* _tmp10_;
		const gchar* _tmp11_;
		_tmp9_ = page;
		_tmp10_ = adw_view_stack_page_get_title (_tmp9_);
		_tmp11_ = _tmp10_;
		_tmp7_ = _tmp11_;
	} else {
		_tmp7_ = _ ("Pomodoro");
	}
	gtk_window_set_title ((GtkWindow*) self, _tmp7_);
	_g_object_unref0 (page);
}

static void
ft_window_update_timer_indicator (FtWindow* self)
{
	AdwViewStackPage* timer_page = NULL;
	AdwViewStack* _tmp0_;
	FtTimerView* _tmp1_;
	AdwViewStackPage* _tmp2_;
	AdwViewStackPage* _tmp3_;
	FtTimer* timer = NULL;
	FtTimer* _tmp4_;
	FtTimer* _tmp5_;
	gboolean _tmp6_ = FALSE;
	AdwViewStack* _tmp7_;
	GtkWidget* _tmp8_;
	GtkWidget* _tmp9_;
	AdwViewStackPage* _tmp10_;
	GtkWidget* _tmp11_;
	GtkWidget* _tmp12_;
	AdwViewStackPage* _tmp14_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->view_stack;
	_tmp1_ = self->priv->timer_view;
	_tmp2_ = adw_view_stack_get_page (_tmp0_, (GtkWidget*) _tmp1_);
	_tmp3_ = _g_object_ref0 (_tmp2_);
	timer_page = _tmp3_;
	_tmp4_ = ft_timer_get_default ();
	_tmp5_ = _g_object_ref0 (_tmp4_);
	timer = _tmp5_;
	_tmp7_ = self->priv->view_stack;
	_tmp8_ = adw_view_stack_get_visible_child (_tmp7_);
	_tmp9_ = _tmp8_;
	_tmp10_ = timer_page;
	_tmp11_ = adw_view_stack_page_get_child (_tmp10_);
	_tmp12_ = _tmp11_;
	if (_tmp9_ != _tmp12_) {
		FtTimer* _tmp13_;
		_tmp13_ = timer;
		_tmp6_ = ft_timer_is_started (_tmp13_);
	} else {
		_tmp6_ = FALSE;
	}
	_tmp14_ = timer_page;
	adw_view_stack_page_set_needs_attention (_tmp14_, _tmp6_);
	_g_object_unref0 (timer);
	_g_object_unref0 (timer_page);
}

FtWindowView
ft_window_get_default_view (FtWindow* self)
{
	FtWindowView result;
	g_return_val_if_fail (self != NULL, 0);
	result = FT_WINDOW_VIEW_TIMER;
	_vala_warn_if_fail (result != FT_WINDOW_VIEW_DEFAULT, "result != Ft.WindowView.DEFAULT");
	return result;
}

static void
ft_window_close_to_background_internal_data_free (gpointer _data)
{
	FtWindowCloseToBackgroundInternalData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (FtWindowCloseToBackgroundInternalData, _data_);
}

static void
ft_window_close_to_background_internal (FtWindow* self,
                                        GAsyncReadyCallback _callback_,
                                        gpointer _user_data_)
{
	FtWindowCloseToBackgroundInternalData* _data_;
	FtWindow* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (FtWindowCloseToBackgroundInternalData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, ft_window_close_to_background_internal_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	ft_window_close_to_background_internal_co (_data_);
}

static void
ft_window_close_to_background_internal_finish (FtWindow* self,
                                               GAsyncResult* _res_)
{
	FtWindowCloseToBackgroundInternalData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
ft_window_close_to_background_internal_ready (GObject* source_object,
                                              GAsyncResult* _res_,
                                              gpointer _user_data_)
{
	FtWindowCloseToBackgroundInternalData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	ft_window_close_to_background_internal_co (_data_);
}

static gboolean
ft_window_close_to_background_internal_co (FtWindowCloseToBackgroundInternalData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_state_ = 1;
	ft_get_window_identifier ((GtkWindow*) _data_->self, ft_window_close_to_background_internal_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp0_ = ft_get_window_identifier_finish (_data_->_res_);
	_data_->window_id = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->self->priv->background_manager;
	_data_->_tmp2_ = _data_->window_id;
	_data_->_state_ = 2;
	ft_background_manager_hold (_data_->_tmp1_, _data_->_tmp2_, ft_window_close_to_background_internal_ready, _data_);
	return FALSE;
	_state_2:
	ft_window_background_hold_id = ft_background_manager_hold_finish (_data_->_tmp1_, _data_->_res_);
	if (ft_window_background_hold_id != 0U) {
		gtk_window_close ((GtkWindow*) _data_->self);
	} else {
		gtk_window_minimize ((GtkWindow*) _data_->self);
	}
	_g_free0 (_data_->window_id);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

void
ft_window_close_to_background (FtWindow* self)
{
	g_return_if_fail (self != NULL);
	ft_window_close_to_background_internal (self, NULL, NULL);
}

/**
         *  Keep the toast until window is focused.
         */
static Block16Data*
block16_data_ref (Block16Data* _data16_)
{
	g_atomic_int_inc (&_data16_->_ref_count_);
	return _data16_;
}

static void
block16_data_unref (void * _userdata_)
{
	Block16Data* _data16_;
	_data16_ = (Block16Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data16_->_ref_count_)) {
		FtWindow* self;
		self = _data16_->self;
		_g_object_unref0 (_data16_->toast);
		_g_object_unref0 (self);
		g_slice_free (Block16Data, _data16_);
	}
}

static void
__lambda49_ (Block16Data* _data16_,
             GtkStateFlags previous_state_flags)
{
	FtWindow* self;
	gboolean is_backdrop = FALSE;
	self = _data16_->self;
	is_backdrop = (gtk_widget_get_state_flags ((GtkWidget*) self) & GTK_STATE_FLAG_BACKDROP) == GTK_STATE_FLAG_BACKDROP;
	if (!is_backdrop) {
		AdwToastOverlay* _tmp0_;
		AdwToast* _tmp1_;
		adw_toast_set_timeout (_data16_->toast, FT_WINDOW_TOAST_DISMISS_TIMEOUT);
		_tmp0_ = self->priv->toast_overlay;
		_tmp1_ = _g_object_ref0 (_data16_->toast);
		adw_toast_overlay_add_toast (_tmp0_, _tmp1_);
	}
}

static void
___lambda49__gtk_widget_state_flags_changed (GtkWidget* _sender,
                                             GtkStateFlags previous_state_flags,
                                             gpointer self)
{
	__lambda49_ (self, previous_state_flags);
}

static void
__lambda50_ (Block16Data* _data16_)
{
	FtWindow* self;
	self = _data16_->self;
	if (_data16_->state_flags_changed_id != ((gulong) 0)) {
		g_signal_handler_disconnect ((GObject*) self, _data16_->state_flags_changed_id);
		_data16_->state_flags_changed_id = (gulong) 0;
	}
}

static void
___lambda50__adw_toast_dismissed (AdwToast* _sender,
                                  gpointer self)
{
	__lambda50_ (self);
}

static void
ft_window_dismiss_toast_once_focused (FtWindow* self,
                                      AdwToast* toast)
{
	Block16Data* _data16_;
	AdwToast* _tmp0_;
	gulong _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (toast != NULL);
	_data16_ = g_slice_new0 (Block16Data);
	_data16_->_ref_count_ = 1;
	_data16_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (toast);
	_g_object_unref0 (_data16_->toast);
	_data16_->toast = _tmp0_;
	adw_toast_set_timeout (_data16_->toast, (guint) 0);
	_tmp1_ = g_signal_connect_data ((GtkWidget*) self, "state-flags-changed", (GCallback) ___lambda49__gtk_widget_state_flags_changed, block16_data_ref (_data16_), (GClosureNotify) block16_data_unref, 0);
	_data16_->state_flags_changed_id = _tmp1_;
	g_signal_connect_data (_data16_->toast, "dismissed", (GCallback) ___lambda50__adw_toast_dismissed, block16_data_ref (_data16_), (GClosureNotify) block16_data_unref, 0);
	block16_data_unref (_data16_);
	_data16_ = NULL;
}

/**
         * Monitor user activity and dismiss notification once user becomes active.
         */
static void
ft_window_dismiss_toast_once_user_becomes_active (FtWindow* self,
                                                  AdwToast* toast)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (toast != NULL);
}

void
ft_window_add_toast (FtWindow* self,
                     AdwToast* toast)
{
	gboolean _tmp0_ = FALSE;
	guint _tmp1_;
	guint _tmp2_;
	AdwToastOverlay* _tmp3_;
	AdwToast* _tmp4_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (toast != NULL);
	_tmp1_ = adw_toast_get_timeout (toast);
	_tmp2_ = _tmp1_;
	if (_tmp2_ != ((guint) 0)) {
		_tmp0_ = self->priv->_size == FT_WINDOW_SIZE_NORMAL;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		if ((gtk_widget_get_state_flags ((GtkWidget*) self) & GTK_STATE_FLAG_BACKDROP) == GTK_STATE_FLAG_BACKDROP) {
			ft_window_dismiss_toast_once_focused (self, toast);
		} else {
			ft_window_dismiss_toast_once_user_becomes_active (self, toast);
		}
	}
	_tmp3_ = self->priv->toast_overlay;
	_tmp4_ = _g_object_ref0 (toast);
	adw_toast_overlay_add_toast (_tmp3_, _tmp4_);
	_g_object_unref0 (toast);
}

static Block17Data*
block17_data_ref (Block17Data* _data17_)
{
	g_atomic_int_inc (&_data17_->_ref_count_);
	return _data17_;
}

static void
block17_data_unref (void * _userdata_)
{
	Block17Data* _data17_;
	_data17_ = (Block17Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data17_->_ref_count_)) {
		FtWindow* self;
		self = _data17_->self;
		_g_object_unref0 (_data17_->dialog);
		_g_object_unref0 (self);
		g_slice_free (Block17Data, _data17_);
	}
}

static void
__lambda52_ (Block17Data* _data17_,
             const gchar* response)
{
	FtWindow* self;
	const gchar* _tmp0_;
	GQuark _tmp2_ = 0U;
	static GQuark _tmp1_label0 = 0;
	static GQuark _tmp1_label1 = 0;
	static GQuark _tmp1_label2 = 0;
	self = _data17_->self;
	g_return_if_fail (response != NULL);
	_tmp0_ = response;
	_tmp2_ = (NULL == _tmp0_) ? 0 : g_quark_from_string (_tmp0_);
	if (_tmp2_ == ((0 != _tmp1_label0) ? _tmp1_label0 : (_tmp1_label0 = g_quark_from_static_string ("run-in-background")))) {
		switch (0) {
			default:
			{
				ft_window_close_to_background (_data17_->_self_);
				break;
			}
		}
	} else if (_tmp2_ == ((0 != _tmp1_label1) ? _tmp1_label1 : (_tmp1_label1 = g_quark_from_static_string ("quit")))) {
		switch (0) {
			default:
			{
				GtkApplication* _tmp3_;
				GtkApplication* _tmp4_;
				_tmp3_ = gtk_window_get_application ((GtkWindow*) _data17_->_self_);
				_tmp4_ = _tmp3_;
				g_application_quit ((GApplication*) _tmp4_);
				break;
			}
		}
	} else if (_tmp2_ == ((0 != _tmp1_label2) ? _tmp1_label2 : (_tmp1_label2 = g_quark_from_static_string ("cancel")))) {
		switch (0) {
			default:
			{
				adw_dialog_close ((AdwDialog*) _data17_->dialog);
				break;
			}
		}
	} else {
		switch (0) {
			default:
			{
				g_assert_not_reached ();
			}
		}
	}
}

static void
___lambda52__adw_alert_dialog_response (AdwAlertDialog* _sender,
                                        const gchar* response,
                                        gpointer self)
{
	__lambda52_ (self, response);
}

static void
ft_window_show_close_confirmation_dialog (FtWindow* self)
{
	Block17Data* _data17_;
	AdwAlertDialog* _tmp0_;
	g_return_if_fail (self != NULL);
	_data17_ = g_slice_new0 (Block17Data);
	_data17_->_ref_count_ = 1;
	_data17_->self = g_object_ref (self);
	_data17_->_self_ = self;
	_tmp0_ = (AdwAlertDialog*) adw_alert_dialog_new (_ ("Keep timer running?"), _ ("You can keep it running in the background — notifications and keyboard" \
" shortcuts will still work."));
	g_object_ref_sink (_tmp0_);
	_data17_->dialog = _tmp0_;
	adw_alert_dialog_set_prefer_wide_layout (_data17_->dialog, TRUE);
	adw_alert_dialog_add_response (_data17_->dialog, "quit", _ ("Quit"));
	adw_alert_dialog_set_response_appearance (_data17_->dialog, "quit", ADW_RESPONSE_DEFAULT);
	adw_alert_dialog_add_response (_data17_->dialog, "run-in-background", _ ("Run in background"));
	adw_alert_dialog_set_response_appearance (_data17_->dialog, "run-in-background", ADW_RESPONSE_SUGGESTED);
	adw_alert_dialog_set_default_response (_data17_->dialog, "run-in-background");
	adw_alert_dialog_set_close_response (_data17_->dialog, "cancel");
	g_signal_connect_data (_data17_->dialog, "response", (GCallback) ___lambda52__adw_alert_dialog_response, block17_data_ref (_data17_), (GClosureNotify) block17_data_unref, 0);
	adw_dialog_present ((AdwDialog*) _data17_->dialog, (GtkWidget*) _data17_->_self_);
	block17_data_unref (_data17_);
	_data17_ = NULL;
}

static void
ft_window_on_size_stack_visible_child_notify (FtWindow* self,
                                              GObject* object,
                                              GParamSpec* pspec)
{
	FtSizeStack* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (object != NULL);
	g_return_if_fail (pspec != NULL);
	_tmp0_ = self->priv->size_stack;
	_tmp1_ = ft_size_stack_get_visible_child_name (_tmp0_);
	_tmp2_ = _tmp1_;
	ft_window_set_size (self, ft_window_size_from_string (_tmp2_));
}

static void
_ft_window_on_size_stack_visible_child_notify_g_object_notify (GObject* _sender,
                                                               GParamSpec* pspec,
                                                               gpointer self)
{
	ft_window_on_size_stack_visible_child_notify ((FtWindow*) self, _sender, pspec);
}

static void
ft_window_on_view_stack_visible_child_notify (FtWindow* self,
                                              GObject* object,
                                              GParamSpec* pspec)
{
	FtWindowView view = 0;
	AdwViewStack* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	FtWindowView _tmp3_ = 0;
	gboolean _tmp4_ = FALSE;
	g_return_if_fail (self != NULL);
	g_return_if_fail (object != NULL);
	g_return_if_fail (pspec != NULL);
	_tmp0_ = self->priv->view_stack;
	_tmp1_ = adw_view_stack_get_visible_child_name (_tmp0_);
	_tmp2_ = _tmp1_;
	view = ft_window_view_from_string (_tmp2_);
	if (self->priv->_view == FT_WINDOW_VIEW_DEFAULT) {
		_tmp4_ = ft_window_get_default_view (self) == view;
	} else {
		_tmp4_ = FALSE;
	}
	if (_tmp4_) {
		_tmp3_ = FT_WINDOW_VIEW_DEFAULT;
	} else {
		_tmp3_ = view;
	}
	self->priv->_view = _tmp3_;
	ft_window_update_title (self);
	ft_window_update_timer_indicator (self);
}

static void
_ft_window_on_view_stack_visible_child_notify_g_object_notify (GObject* _sender,
                                                               GParamSpec* pspec,
                                                               gpointer self)
{
	ft_window_on_view_stack_visible_child_notify ((FtWindow*) self, _sender, pspec);
}

static void
ft_window_on_gesture_click_pressed (FtWindow* self,
                                    GtkGestureClick* gesture,
                                    gint n_press,
                                    gdouble x,
                                    gdouble y)
{
	GAction* toggle_compact_size_action = NULL;
	GAction* _tmp0_;
	GAction* _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	GAction* _tmp4_;
	gboolean _tmp5_;
	gboolean _tmp6_;
	gboolean _tmp8_ = FALSE;
	g_return_if_fail (self != NULL);
	g_return_if_fail (gesture != NULL);
	_tmp0_ = g_action_map_lookup_action ((GActionMap*) self, "toggle-compact-size");
	_tmp1_ = _g_object_ref0 (_tmp0_);
	toggle_compact_size_action = _tmp1_;
	_tmp4_ = toggle_compact_size_action;
	_tmp5_ = g_action_get_enabled (_tmp4_);
	_tmp6_ = _tmp5_;
	if (_tmp6_) {
		_tmp3_ = gtk_gesture_single_get_current_button ((GtkGestureSingle*) gesture) == ((guint) GDK_BUTTON_PRIMARY);
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		_tmp2_ = n_press == 2;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		GAction* _tmp7_;
		_tmp7_ = toggle_compact_size_action;
		g_action_activate (_tmp7_, NULL);
		gtk_gesture_set_state ((GtkGesture*) gesture, GTK_EVENT_SEQUENCE_CLAIMED);
	}
	if (gtk_gesture_single_get_current_button ((GtkGestureSingle*) gesture) == ((guint) GDK_BUTTON_MIDDLE)) {
		_tmp8_ = n_press == 1;
	} else {
		_tmp8_ = FALSE;
	}
	if (_tmp8_) {
		FtTimerActionGroup* _tmp9_ = NULL;
		FtTimerActionGroup* _tmp10_;
		_tmp10_ = self->priv->timer_action_group;
		_tmp9_ = _tmp10_;
		if (_tmp9_ != NULL) {
			g_action_group_activate_action ((GActionGroup*) _tmp9_, "start-pause-resume", NULL);
		}
		gtk_gesture_set_state ((GtkGesture*) gesture, GTK_EVENT_SEQUENCE_CLAIMED);
	}
	_g_object_unref0 (toggle_compact_size_action);
}

static void
_ft_window_on_gesture_click_pressed_gtk_gesture_click_pressed (GtkGestureClick* _sender,
                                                               gint n_press,
                                                               gdouble x,
                                                               gdouble y,
                                                               gpointer self)
{
	ft_window_on_gesture_click_pressed ((FtWindow*) self, _sender, n_press, x, y);
}

static gboolean
ft_window_on_close_request (FtWindow* self)
{
	FtBackgroundManager* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	FtTimer* _tmp3_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->background_manager;
	_tmp1_ = ft_background_manager_get_active (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		result = FALSE;
		return result;
	}
	_tmp3_ = self->priv->timer;
	if (ft_timer_is_running (_tmp3_)) {
		ft_window_show_close_confirmation_dialog (self);
		result = TRUE;
		return result;
	} else {
		GtkApplication* _tmp4_;
		GtkApplication* _tmp5_;
		_tmp4_ = gtk_window_get_application ((GtkWindow*) self);
		_tmp5_ = _tmp4_;
		g_application_quit ((GApplication*) _tmp5_);
		result = FALSE;
		return result;
	}
}

static gboolean
_ft_window_on_close_request_gtk_window_close_request (GtkWindow* _sender,
                                                      gpointer self)
{
	gboolean result;
	result = ft_window_on_close_request ((FtWindow*) self);
	return result;
}

static void
ft_window_on_notify_is_active (FtWindow* self,
                               GObject* object,
                               GParamSpec* pspec)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_;
	gboolean _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (object != NULL);
	g_return_if_fail (pspec != NULL);
	g_object_get ((GtkWindow*) self, "is-active", &_tmp1_, NULL);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		_tmp0_ = ft_window_background_hold_id != 0U;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		FtBackgroundManager* _tmp3_;
		_tmp3_ = self->priv->background_manager;
		ft_background_manager_release (_tmp3_, ft_window_background_hold_id);
		ft_window_background_hold_id = 0U;
	}
}

static void
ft_window_on_notify_maximized (FtWindow* self,
                               GObject* object,
                               GParamSpec* pspec)
{
	gboolean can_change_size = FALSE;
	gboolean _tmp0_;
	gboolean _tmp1_;
	GSimpleAction* compact_size_action = NULL;
	GAction* _tmp2_;
	GSimpleAction* _tmp3_;
	GSimpleAction* toggle_compact_size_action = NULL;
	GAction* _tmp4_;
	GSimpleAction* _tmp5_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (object != NULL);
	g_return_if_fail (pspec != NULL);
	g_object_get ((GtkWindow*) self, "maximized", &_tmp0_, NULL);
	_tmp1_ = _tmp0_;
	can_change_size = !_tmp1_;
	_tmp2_ = g_action_map_lookup_action ((GActionMap*) self, "compact-size");
	_tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, g_simple_action_get_type (), GSimpleAction));
	compact_size_action = _tmp3_;
	g_simple_action_set_enabled (compact_size_action, can_change_size);
	_tmp4_ = g_action_map_lookup_action ((GActionMap*) self, "toggle-compact-size");
	_tmp5_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, g_simple_action_get_type (), GSimpleAction));
	toggle_compact_size_action = _tmp5_;
	g_simple_action_set_enabled (toggle_compact_size_action, can_change_size);
	_g_object_unref0 (toggle_compact_size_action);
	_g_object_unref0 (compact_size_action);
}

static void
ft_window_on_compact_size_activate (FtWindow* self,
                                    GSimpleAction* action,
                                    GVariant* parameter)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (action != NULL);
	ft_window_set_size (self, FT_WINDOW_SIZE_COMPACT);
}

static void
ft_window_on_normal_size_activate (FtWindow* self,
                                   GSimpleAction* action,
                                   GVariant* parameter)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (action != NULL);
	ft_window_set_size (self, FT_WINDOW_SIZE_NORMAL);
	ft_window_set_view (self, FT_WINDOW_VIEW_TIMER);
}

static void
ft_window_on_toggle_compact_size_activate (FtWindow* self,
                                           GSimpleAction* action,
                                           GVariant* parameter)
{
	FtWindowSize _tmp0_;
	FtWindowSize _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (action != NULL);
	_tmp0_ = ft_window_get_size (self);
	_tmp1_ = _tmp0_;
	if (_tmp1_ == FT_WINDOW_SIZE_NORMAL) {
		GAction* _tmp2_;
		_tmp2_ = g_action_map_lookup_action ((GActionMap*) self, "compact-size");
		g_action_activate (_tmp2_, NULL);
	} else {
		GAction* _tmp3_;
		_tmp3_ = g_action_map_lookup_action ((GActionMap*) self, "normal-size");
		g_action_activate (_tmp3_, NULL);
	}
}

static void
ft_window_on_extension_added (FtWindow* self,
                              PeasExtensionSet* extension_set,
                              PeasPluginInfo* plugin_info,
                              GObject* object)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (extension_set != NULL);
	g_return_if_fail (plugin_info != NULL);
	g_return_if_fail (object != NULL);
	ft_window_setup_extension (self, object);
}

static void
ft_window_setup_extension (FtWindow* self,
                           GObject* object)
{
	FtWindowExtension* extension = NULL;
	FtWindowExtension* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (object != NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_WINDOW_EXTENSION, FtWindowExtension));
	extension = _tmp0_;
	ft_window_extension_set_window (extension, self);
	_g_object_unref0 (extension);
}

static void
_ft_window_on_compact_size_activate_g_simple_action_activate (GSimpleAction* _sender,
                                                              GVariant* parameter,
                                                              gpointer self)
{
	ft_window_on_compact_size_activate ((FtWindow*) self, _sender, parameter);
}

static void
_ft_window_on_normal_size_activate_g_simple_action_activate (GSimpleAction* _sender,
                                                             GVariant* parameter,
                                                             gpointer self)
{
	ft_window_on_normal_size_activate ((FtWindow*) self, _sender, parameter);
}

static void
_ft_window_on_toggle_compact_size_activate_g_simple_action_activate (GSimpleAction* _sender,
                                                                     GVariant* parameter,
                                                                     gpointer self)
{
	ft_window_on_toggle_compact_size_activate ((FtWindow*) self, _sender, parameter);
}

static void
ft_window_setup_actions (FtWindow* self)
{
	GActionMap* action_map = NULL;
	GActionMap* _tmp0_;
	GSimpleAction* compact_size_action = NULL;
	GSimpleAction* _tmp1_;
	GSimpleAction* normal_size_action = NULL;
	GSimpleAction* _tmp2_;
	GSimpleAction* toggle_compact_size_action = NULL;
	GSimpleAction* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (self, g_action_map_get_type (), GActionMap));
	action_map = _tmp0_;
	_tmp1_ = g_simple_action_new ("compact-size", NULL);
	compact_size_action = _tmp1_;
	g_signal_connect_object (compact_size_action, "activate", (GCallback) _ft_window_on_compact_size_activate_g_simple_action_activate, self, 0);
	g_action_map_add_action (action_map, (GAction*) compact_size_action);
	_tmp2_ = g_simple_action_new ("normal-size", NULL);
	normal_size_action = _tmp2_;
	g_signal_connect_object (normal_size_action, "activate", (GCallback) _ft_window_on_normal_size_activate_g_simple_action_activate, self, 0);
	g_action_map_add_action (action_map, (GAction*) normal_size_action);
	_tmp3_ = g_simple_action_new ("toggle-compact-size", NULL);
	toggle_compact_size_action = _tmp3_;
	g_signal_connect_object (toggle_compact_size_action, "activate", (GCallback) _ft_window_on_toggle_compact_size_activate_g_simple_action_activate, self, 0);
	g_action_map_add_action (action_map, (GAction*) toggle_compact_size_action);
	_g_object_unref0 (toggle_compact_size_action);
	_g_object_unref0 (normal_size_action);
	_g_object_unref0 (compact_size_action);
	_g_object_unref0 (action_map);
}

static void
ft_window_real_parser_finished (GtkBuildable* base,
                                GtkBuilder* builder)
{
	FtWindow * self;
	self = (FtWindow*) base;
	g_return_if_fail (builder != NULL);
	ft_window_setup_actions (self);
}

static void
ft_window_real_dispose (GObject* base)
{
	FtWindow * self;
	self = (FtWindow*) base;
	_g_object_unref0 (self->priv->extensions);
	self->priv->extensions = NULL;
	_g_object_unref0 (self->priv->background_manager);
	self->priv->background_manager = NULL;
	_g_object_unref0 (self->priv->timer_action_group);
	self->priv->timer_action_group = NULL;
	G_OBJECT_CLASS (ft_window_parent_class)->dispose ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, adw_application_window_get_type (), AdwApplicationWindow));
}

FtWindow*
ft_window_construct (GType object_type)
{
	FtWindow * self = NULL;
	self = (FtWindow*) g_object_new (object_type, NULL);
	return self;
}

FtWindow*
ft_window_new (void)
{
	return ft_window_construct (FT_TYPE_WINDOW);
}

FtWindowSize
ft_window_get_size (FtWindow* self)
{
	FtWindowSize result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_size;
	return result;
}

void
ft_window_set_size (FtWindow* self,
                    FtWindowSize value)
{
	FtSizeStack* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	if (self->priv->_size == value) {
		return;
	}
	self->priv->_size = value;
	_tmp0_ = self->priv->size_stack;
	_tmp1_ = ft_window_size_to_string (value);
	_tmp2_ = _tmp1_;
	ft_size_stack_set_visible_child_name (_tmp0_, _tmp2_);
	_g_free0 (_tmp2_);
	g_object_notify ((GObject*) self, "size");
}

FtWindowView
ft_window_get_view (FtWindow* self)
{
	FtWindowView result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_view;
	return result;
}

void
ft_window_set_view (FtWindow* self,
                    FtWindowView value)
{
	FtWindowView resolved_view = 0;
	AdwViewStack* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	if (self->priv->_view == value) {
		return;
	}
	self->priv->_view = value;
	resolved_view = value;
	if (resolved_view == FT_WINDOW_VIEW_DEFAULT) {
		resolved_view = ft_window_get_default_view (self);
	}
	_tmp0_ = self->priv->view_stack;
	_tmp1_ = ft_window_view_to_string (resolved_view);
	_tmp2_ = _tmp1_;
	adw_view_stack_set_visible_child_name (_tmp0_, _tmp2_);
	_g_free0 (_tmp2_);
	g_object_notify ((GObject*) self, "view");
}

static void
_ft_window___lambda53_ (FtWindow* self)
{
	ft_window_update_timer_indicator (self);
}

static void
__ft_window___lambda53__ft_timer_state_changed (FtTimer* _sender,
                                                const FtTimerState* current_state,
                                                const FtTimerState* previous_state,
                                                gpointer self)
{
	_ft_window___lambda53_ ((FtWindow*) self);
}

static void
_ft_window_on_notify_is_active_g_object_notify (GObject* _sender,
                                                GParamSpec* pspec,
                                                gpointer self)
{
	ft_window_on_notify_is_active ((FtWindow*) self, _sender, pspec);
}

static void
_ft_window_on_notify_maximized_g_object_notify (GObject* _sender,
                                                GParamSpec* pspec,
                                                gpointer self)
{
	ft_window_on_notify_maximized ((FtWindow*) self, _sender, pspec);
}

static void
_vala_GValue_array_free (GValue * array,
                         gssize array_length)
{
	if (array != NULL) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			g_value_unset (&array[i]);
		}
	}
	g_free (array);
}

static void
_ft_window_on_extension_added_peas_extension_set_extension_added (PeasExtensionSet* _sender,
                                                                  PeasPluginInfo* info,
                                                                  GObject* extension,
                                                                  gpointer self)
{
	ft_window_on_extension_added ((FtWindow*) self, _sender, info, extension);
}

static void
_ft_window___lambda54_ (FtWindow* self,
                        GObject* object)
{
	g_return_if_fail (object != NULL);
	ft_window_setup_extension (self, object);
}

static void
__ft_window___lambda54__ft_extension_set_foreach_func (GObject* object,
                                                       gpointer self)
{
	_ft_window___lambda54_ ((FtWindow*) self, object);
}

static GObject *
ft_window_constructor (GType type,
                       guint n_construct_properties,
                       GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	FtWindow * self;
	GSettings* settings = NULL;
	GSettings* _tmp0_;
	GSettings* _tmp1_;
	FtSessionManager* _tmp2_;
	FtSessionManager* _tmp3_;
	FtSessionManager* _tmp4_;
	FtTimer* _tmp5_;
	FtTimer* _tmp6_;
	FtTimer* _tmp7_;
	FtTimer* _tmp8_;
	FtTimerActionGroup* _tmp9_;
	FtSessionManagerActionGroup* _tmp10_;
	FtSessionManagerActionGroup* _tmp11_;
	FtTimerActionGroup* _tmp12_;
	GSettings* _tmp13_;
	FtBackgroundManager* _tmp14_;
	PeasEngine* _tmp15_;
	gchar** _tmp16_;
	gchar** _tmp17_;
	gint _tmp17__length1;
	GValue* _tmp18_;
	GValue* _tmp19_;
	gint _tmp19__length1;
	PeasExtensionSet* _tmp20_;
	PeasExtensionSet* _tmp21_;
	PeasExtensionSet* _tmp22_;
	parent_class = G_OBJECT_CLASS (ft_window_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_WINDOW, FtWindow);
	_tmp0_ = ft_get_settings ();
	_tmp1_ = _g_object_ref0 (_tmp0_);
	settings = _tmp1_;
	_tmp2_ = ft_session_manager_get_default ();
	_tmp3_ = _g_object_ref0 (_tmp2_);
	_g_object_unref0 (self->priv->session_manager);
	self->priv->session_manager = _tmp3_;
	_tmp4_ = self->priv->session_manager;
	_tmp5_ = ft_session_manager_get_timer (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = _g_object_ref0 (_tmp6_);
	_g_object_unref0 (self->priv->timer);
	self->priv->timer = _tmp7_;
	_tmp8_ = self->priv->timer;
	g_signal_connect_object (_tmp8_, "state-changed", (GCallback) __ft_window___lambda53__ft_timer_state_changed, self, 0);
	_tmp9_ = ft_timer_action_group_new ();
	_g_object_unref0 (self->priv->timer_action_group);
	self->priv->timer_action_group = _tmp9_;
	_tmp10_ = ft_session_manager_action_group_new ();
	_tmp11_ = _tmp10_;
	gtk_widget_insert_action_group ((GtkWidget*) self, "session-manager", (GActionGroup*) _tmp11_);
	_g_object_unref0 (_tmp11_);
	_tmp12_ = self->priv->timer_action_group;
	gtk_widget_insert_action_group ((GtkWidget*) self, "timer", (GActionGroup*) _tmp12_);
	_tmp13_ = settings;
	if (g_settings_get_boolean (_tmp13_, "prefer-compact-size")) {
		ft_window_set_size (self, FT_WINDOW_SIZE_COMPACT);
	}
	_tmp14_ = ft_background_manager_new ();
	_g_object_unref0 (self->priv->background_manager);
	self->priv->background_manager = _tmp14_;
	g_signal_connect_object ((GObject*) self, "notify::is-active", (GCallback) _ft_window_on_notify_is_active_g_object_notify, self, 0);
	g_signal_connect_object ((GObject*) self, "notify::maximized", (GCallback) _ft_window_on_notify_maximized_g_object_notify, self, 0);
	ft_window_update_title (self);
	ft_window_update_timer_indicator (self);
	_tmp15_ = peas_engine_get_default ();
	_tmp16_ = g_new0 (gchar*, 0 + 1);
	_tmp17_ = _tmp16_;
	_tmp17__length1 = 0;
	_tmp18_ = g_new0 (GValue, 0);
	_tmp19_ = _tmp18_;
	_tmp19__length1 = 0;
	_tmp20_ = peas_extension_set_new_with_properties (_tmp15_, FT_TYPE_WINDOW_EXTENSION, 0, _tmp17_, _tmp19_);
	_g_object_unref0 (self->priv->extensions);
	self->priv->extensions = _tmp20_;
	_tmp19_ = (_vala_GValue_array_free (_tmp19_, _tmp19__length1), NULL);
	_tmp17_ = (_vala_array_free (_tmp17_, _tmp17__length1, (GDestroyNotify) g_free), NULL);
	_tmp21_ = self->priv->extensions;
	g_signal_connect_object (_tmp21_, "extension-added", (GCallback) _ft_window_on_extension_added_peas_extension_set_extension_added, self, 0);
	_tmp22_ = self->priv->extensions;
	ft_foreach_extension (_tmp22_, __ft_window___lambda54__ft_extension_set_foreach_func, self);
	_g_object_unref0 (settings);
	return obj;
}

static void
ft_window_class_init (FtWindowClass * klass,
                      gpointer klass_data)
{
	ft_window_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FtWindow_private_offset);
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) ft_window_real_dispose;
	G_OBJECT_CLASS (klass)->get_property = _vala_ft_window_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_ft_window_set_property;
	G_OBJECT_CLASS (klass)->constructor = ft_window_constructor;
	G_OBJECT_CLASS (klass)->finalize = ft_window_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_WINDOW_SIZE_PROPERTY, ft_window_properties[FT_WINDOW_SIZE_PROPERTY] = g_param_spec_enum ("size", "size", "size", FT_TYPE_WINDOW_SIZE, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_EXPLICIT_NOTIFY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_WINDOW_VIEW_PROPERTY, ft_window_properties[FT_WINDOW_VIEW_PROPERTY] = g_param_spec_enum ("view", "view", "view", FT_TYPE_WINDOW_VIEW, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_EXPLICIT_NOTIFY));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/io/github/focustimerhq/FocusTimer/ui/main/window.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "size_stack", FALSE, FtWindow_private_offset + G_STRUCT_OFFSET (FtWindowPrivate, size_stack));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "view_stack", FALSE, FtWindow_private_offset + G_STRUCT_OFFSET (FtWindowPrivate, view_stack));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "toast_overlay", FALSE, FtWindow_private_offset + G_STRUCT_OFFSET (FtWindowPrivate, toast_overlay));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "timer_view", FALSE, FtWindow_private_offset + G_STRUCT_OFFSET (FtWindowPrivate, timer_view));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_size_stack_visible_child_notify", G_CALLBACK(_ft_window_on_size_stack_visible_child_notify_g_object_notify));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_view_stack_visible_child_notify", G_CALLBACK(_ft_window_on_view_stack_visible_child_notify_g_object_notify));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_gesture_click_pressed", G_CALLBACK(_ft_window_on_gesture_click_pressed_gtk_gesture_click_pressed));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_close_request", G_CALLBACK(_ft_window_on_close_request_gtk_window_close_request));
}

static void
ft_window_gtk_buildable_interface_init (GtkBuildableIface * iface,
                                        gpointer iface_data)
{
	ft_window_gtk_buildable_parent_iface = g_type_interface_peek_parent (iface);
	iface->parser_finished = (void (*) (GtkBuildable*, GtkBuilder*)) ft_window_real_parser_finished;
}

static void
ft_window_instance_init (FtWindow * self,
                         gpointer klass)
{
	self->priv = ft_window_get_instance_private (self);
	self->priv->_size = FT_WINDOW_SIZE_NORMAL;
	self->priv->_view = FT_WINDOW_VIEW_DEFAULT;
	self->priv->session_manager = NULL;
	self->priv->timer = NULL;
	self->priv->timer_action_group = NULL;
	self->priv->background_manager = NULL;
	self->priv->extensions = NULL;
	g_type_ensure (FT_TYPE_SIZE_STACK);
	g_type_ensure (FT_TYPE_TIMER_VIEW);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
ft_window_finalize (GObject * obj)
{
	FtWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_WINDOW, FtWindow);
	_g_object_unref0 (self->priv->session_manager);
	_g_object_unref0 (self->priv->timer);
	_g_object_unref0 (self->priv->timer_action_group);
	_g_object_unref0 (self->priv->background_manager);
	_g_object_unref0 (self->priv->extensions);
	G_OBJECT_CLASS (ft_window_parent_class)->finalize (obj);
}

static GType
ft_window_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtWindow), 0, (GInstanceInitFunc) ft_window_instance_init, NULL };
	static const GInterfaceInfo gtk_buildable_info = { (GInterfaceInitFunc) ft_window_gtk_buildable_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType ft_window_type_id;
	ft_window_type_id = g_type_register_static (adw_application_window_get_type (), "FtWindow", &g_define_type_info, 0);
	g_type_add_interface_static (ft_window_type_id, gtk_buildable_get_type (), &gtk_buildable_info);
	FtWindow_private_offset = g_type_add_instance_private (ft_window_type_id, sizeof (FtWindowPrivate));
	return ft_window_type_id;
}

GType
ft_window_get_type (void)
{
	static volatile gsize ft_window_type_id__once = 0;
	if (g_once_init_enter (&ft_window_type_id__once)) {
		GType ft_window_type_id;
		ft_window_type_id = ft_window_get_type_once ();
		g_once_init_leave (&ft_window_type_id__once, ft_window_type_id);
	}
	return ft_window_type_id__once;
}

static void
_vala_ft_window_get_property (GObject * object,
                              guint property_id,
                              GValue * value,
                              GParamSpec * pspec)
{
	FtWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_WINDOW, FtWindow);
	switch (property_id) {
		case FT_WINDOW_SIZE_PROPERTY:
		g_value_set_enum (value, ft_window_get_size (self));
		break;
		case FT_WINDOW_VIEW_PROPERTY:
		g_value_set_enum (value, ft_window_get_view (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_ft_window_set_property (GObject * object,
                              guint property_id,
                              const GValue * value,
                              GParamSpec * pspec)
{
	FtWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_WINDOW, FtWindow);
	switch (property_id) {
		case FT_WINDOW_SIZE_PROPERTY:
		ft_window_set_size (self, g_value_get_enum (value));
		break;
		case FT_WINDOW_VIEW_PROPERTY:
		ft_window_set_view (self, g_value_get_enum (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

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

