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

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

#include <gdk/gdk.h>
#include <glib.h>
#include <gio/gio.h>
#include <glib-object.h>
#include <string.h>
#include <cairo-gobject.h>
#include <gtk/gtk.h>
#include "ft_ui.h"
#include <stdlib.h>
#include <adwaita.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define FT_TYPE_MONITOR_CONSTRAINED_LAYOUT_MANAGER (ft_monitor_constrained_layout_manager_get_type ())
#define FT_MONITOR_CONSTRAINED_LAYOUT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FT_TYPE_MONITOR_CONSTRAINED_LAYOUT_MANAGER, FtMonitorConstrainedLayoutManager))
#define FT_MONITOR_CONSTRAINED_LAYOUT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FT_TYPE_MONITOR_CONSTRAINED_LAYOUT_MANAGER, FtMonitorConstrainedLayoutManagerClass))
#define FT_IS_MONITOR_CONSTRAINED_LAYOUT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FT_TYPE_MONITOR_CONSTRAINED_LAYOUT_MANAGER))
#define FT_IS_MONITOR_CONSTRAINED_LAYOUT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FT_TYPE_MONITOR_CONSTRAINED_LAYOUT_MANAGER))
#define FT_MONITOR_CONSTRAINED_LAYOUT_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FT_TYPE_MONITOR_CONSTRAINED_LAYOUT_MANAGER, FtMonitorConstrainedLayoutManagerClass))

typedef struct _FtMonitorConstrainedLayoutManager FtMonitorConstrainedLayoutManager;
typedef struct _FtMonitorConstrainedLayoutManagerClass FtMonitorConstrainedLayoutManagerClass;
typedef struct _FtMonitorConstrainedLayoutManagerPrivate FtMonitorConstrainedLayoutManagerPrivate;
enum  {
	FT_MONITOR_CONSTRAINED_LAYOUT_MANAGER_0_PROPERTY,
	FT_MONITOR_CONSTRAINED_LAYOUT_MANAGER_MONITOR_PROPERTY,
	FT_MONITOR_CONSTRAINED_LAYOUT_MANAGER_NUM_PROPERTIES
};
static GParamSpec* ft_monitor_constrained_layout_manager_properties[FT_MONITOR_CONSTRAINED_LAYOUT_MANAGER_NUM_PROPERTIES];

#define FT_TYPE_LIGHTBOX_ERROR (ft_lightbox_error_get_type ())
enum  {
	FT_LIGHTBOX_GROUP_0_PROPERTY,
	FT_LIGHTBOX_GROUP_NUM_PROPERTIES
};
static GParamSpec* ft_lightbox_group_properties[FT_LIGHTBOX_GROUP_NUM_PROPERTIES];
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
typedef struct _Block18Data Block18Data;
typedef struct _Block19Data Block19Data;
typedef struct _Block20Data Block20Data;
typedef struct _FtLightboxGroupOpenData FtLightboxGroupOpenData;
enum  {
	FT_LIGHTBOX_0_PROPERTY,
	FT_LIGHTBOX_MONITOR_REQUEST_PROPERTY,
	FT_LIGHTBOX_MONITOR_PROPERTY,
	FT_LIGHTBOX_CONTENTS_PROPERTY,
	FT_LIGHTBOX_ALL_MONITORS_MODE_PROPERTY,
	FT_LIGHTBOX_SHOW_CONTENTS_PROPERTY,
	FT_LIGHTBOX_NUM_PROPERTIES
};
static GParamSpec* ft_lightbox_properties[FT_LIGHTBOX_NUM_PROPERTIES];
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _FtMonitorConstrainedLayoutManager {
	GtkLayoutManager parent_instance;
	FtMonitorConstrainedLayoutManagerPrivate * priv;
};

struct _FtMonitorConstrainedLayoutManagerClass {
	GtkLayoutManagerClass parent_class;
};

struct _FtMonitorConstrainedLayoutManagerPrivate {
	GdkMonitor* _monitor;
};

typedef enum  {
	FT_LIGHTBOX_ERROR_NO_MONITORS
} FtLightboxError;
#define FT_LIGHTBOX_ERROR ft_lightbox_error_quark ()

struct _FtLightboxGroupPrivate {
	GType lightbox_type;
	GHashTable* lightboxes;
	GtkWindowGroup* window_group;
	GListModel* monitors;
	gulong monitors_changed_id;
	guint updating_count;
	guint update_idle_id;
	GSourceFunc open_callback;
	gpointer open_callback_target;
	GDestroyNotify open_callback_target_destroy_notify;
};

struct _Block18Data {
	int _ref_count_;
	FtLightboxGroup* self;
	FtLightbox* first_lightbox;
};

struct _Block19Data {
	int _ref_count_;
	GHashTable* self;
	GFunc func;
	gpointer func_target;
};

struct _Block20Data {
	int _ref_count_;
	FtLightboxGroup* self;
	GHashTable* paired_monitors;
	GHashTable* paired_lightboxes;
};

struct _FtLightboxGroupOpenData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	FtLightboxGroup* self;
	GCancellable* cancellable;
	GSourceFunc _tmp0_;
	gpointer _tmp0__target;
	GListModel* _tmp1_;
	GdkDisplay* _tmp2_;
	GdkDisplay* _tmp3_;
	GListModel* _tmp4_;
	GListModel* _tmp5_;
	GListModel* _tmp6_;
	GListModel* _tmp7_;
	GError* _tmp8_;
	GListModel* _tmp9_;
	gulong _tmp10_;
	GtkWindowGroup* _tmp11_;
	GListModel* _tmp12_;
	GHashTable* _tmp13_;
	GList* _tmp14_;
	GList* _tmp15_;
	GError* _inner_error0_;
};

struct _FtLightboxPrivate {
	AdwBin* container;
	GdkMonitor* _monitor_request;
	GdkMonitor* _monitor;
	GHashTable* monitors;
	gboolean _all_monitors_mode;
	gboolean closing;
};

static gint FtMonitorConstrainedLayoutManager_private_offset;
static gpointer ft_monitor_constrained_layout_manager_parent_class = NULL;
static gint FtLightboxGroup_private_offset;
static gpointer ft_lightbox_group_parent_class = NULL;
static gint FtLightbox_private_offset;
static gpointer ft_lightbox_parent_class = NULL;
static guint ft_lightbox_next_id;
static guint ft_lightbox_next_id = (guint) 0;
static GtkBuildableIface * ft_lightbox_gtk_buildable_parent_iface = NULL;

VALA_EXTERN GdkMonitor* ft_get_primary_monitor (GdkDisplay* display);
VALA_EXTERN void ft_get_display_geometry (GdkDisplay* display,
                              GdkRectangle* result);
VALA_EXTERN GType ft_monitor_constrained_layout_manager_get_type (void) G_GNUC_CONST ;
VALA_EXTERN FtMonitorConstrainedLayoutManager* ft_monitor_constrained_layout_manager_new (GdkMonitor* monitor);
VALA_EXTERN FtMonitorConstrainedLayoutManager* ft_monitor_constrained_layout_manager_construct (GType object_type,
                                                                                    GdkMonitor* monitor);
VALA_EXTERN void ft_monitor_constrained_layout_manager_set_monitor (FtMonitorConstrainedLayoutManager* self,
                                                        GdkMonitor* value);
static GtkSizeRequestMode ft_monitor_constrained_layout_manager_real_get_request_mode (GtkLayoutManager* base,
                                                                                GtkWidget* widget);
static void ft_monitor_constrained_layout_manager_real_measure (GtkLayoutManager* base,
                                                         GtkWidget* widget,
                                                         GtkOrientation orientation,
                                                         gint for_size,
                                                         gint* minimum,
                                                         gint* natural,
                                                         gint* minimum_baseline,
                                                         gint* natural_baseline);
static void ft_monitor_constrained_layout_manager_real_allocate (GtkLayoutManager* base,
                                                          GtkWidget* widget,
                                                          gint width,
                                                          gint height,
                                                          gint baseline);
VALA_EXTERN GdkMonitor* ft_monitor_constrained_layout_manager_get_monitor (FtMonitorConstrainedLayoutManager* self);
static void ft_monitor_constrained_layout_manager_finalize (GObject * obj);
static GType ft_monitor_constrained_layout_manager_get_type_once (void);
static void _vala_ft_monitor_constrained_layout_manager_get_property (GObject * object,
                                                               guint property_id,
                                                               GValue * value,
                                                               GParamSpec * pspec);
static void _vala_ft_monitor_constrained_layout_manager_set_property (GObject * object,
                                                               guint property_id,
                                                               const GValue * value,
                                                               GParamSpec * pspec);
VALA_EXTERN GQuark ft_lightbox_error_quark (void);
VALA_EXTERN GType ft_lightbox_error_get_type (void) G_GNUC_CONST ;
static void _g_object_unref0_ (gpointer var);
static FtLightbox* ft_lightbox_group_get_first_lightbox (FtLightboxGroup* self);
static Block18Data* block18_data_ref (Block18Data* _data18_);
static void block18_data_unref (void * _userdata_);
static Block19Data* block19_data_ref (Block19Data* _data19_);
static void block19_data_unref (void * _userdata_);
static void ___lambda2__gh_func (gconstpointer key,
                          gconstpointer value,
                          gpointer self);
static void __lambda62_ (Block18Data* _data18_,
                  FtLightbox* lightbox);
static void ___lambda62__gfunc (gconstpointer data,
                         gpointer self);
static FtLightbox* ft_lightbox_group_create_lightbox (FtLightboxGroup* self,
                                               GdkMonitor* monitor_request);
static void _vala_GValue_array_free (GValue * array,
                              gssize array_length);
static void ft_lightbox_group_on_lightbox_notify_monitor (FtLightboxGroup* self,
                                                   GObject* object,
                                                   GParamSpec* pspec);
static void _ft_lightbox_group_on_lightbox_notify_monitor_g_object_notify (GObject* _sender,
                                                                    GParamSpec* pspec,
                                                                    gpointer self);
static gboolean ft_lightbox_group_on_lightbox_close_request (FtLightboxGroup* self,
                                                      GtkWindow* window);
static gboolean _ft_lightbox_group_on_lightbox_close_request_gtk_window_close_request (GtkWindow* _sender,
                                                                                gpointer self);
static void ft_lightbox_group_on_lightbox_unrealize (FtLightboxGroup* self,
                                              GtkWidget* widget);
static void _ft_lightbox_group_on_lightbox_unrealize_gtk_widget_unrealize (GtkWidget* _sender,
                                                                    gpointer self);
static void ft_lightbox_group_destroy_lightbox (FtLightboxGroup* self,
                                         FtLightbox* lightbox);
static void ft_lightbox_group_update_lightboxes (FtLightboxGroup* self);
static Block20Data* block20_data_ref (Block20Data* _data20_);
static void block20_data_unref (void * _userdata_);
static void __lambda64_ (Block20Data* _data20_,
                  FtLightbox* lightbox);
static void ___lambda64__gfunc (gconstpointer data,
                         gpointer self);
static void __lambda65_ (Block20Data* _data20_,
                  FtLightbox* lightbox);
static void ___lambda65__gfunc (gconstpointer data,
                         gpointer self);
static void __lambda66_ (Block20Data* _data20_,
                  FtLightbox* lightbox);
static void ___lambda66__gfunc (gconstpointer data,
                         gpointer self);
static void ft_lightbox_group_update (FtLightboxGroup* self);
static void ft_lightbox_group_queue_update (FtLightboxGroup* self);
static gboolean __lambda63_ (FtLightboxGroup* self);
static gboolean ___lambda63__gsource_func (gpointer self);
static void ft_lightbox_group_on_monitors_changed (FtLightboxGroup* self,
                                            GListModel* model,
                                            guint position,
                                            guint removed,
                                            guint added);
static void __lambda67_ (FtLightboxGroup* self,
                  FtLightbox* lightbox);
static void ___lambda67__gfunc (gconstpointer data,
                         gpointer self);
static void ft_lightbox_group_close (FtLightboxGroup* self);
static void ft_lightbox_group_open_data_free (gpointer _data);
static gboolean ft_lightbox_group_open_co (FtLightboxGroupOpenData* _data_);
static void _ft_lightbox_group_on_monitors_changed_g_list_model_items_changed (GListModel* _sender,
                                                                        guint position,
                                                                        guint removed,
                                                                        guint added,
                                                                        gpointer self);
static gboolean _ft_lightbox_group_open_co_gsource_func (gpointer self);
static void _ft_lightbox_group_close_g_cancellable_cancelled (GCancellable* _sender,
                                                       gpointer self);
static void __lambda68_ (FtLightboxGroup* self,
                  FtLightbox* lightbox);
static void ___lambda68__gfunc (gconstpointer data,
                         gpointer self);
static void ft_lightbox_group_real_dispose (GObject* base);
static void ft_lightbox_group_finalize (GObject * obj);
static GType ft_lightbox_group_get_type_once (void);
static void ft_lightbox_update_monitor (FtLightbox* self);
static void ft_lightbox_on_monitor_notify_valid (FtLightbox* self,
                                          GObject* object,
                                          GParamSpec* pspec);
static void _ft_lightbox_on_monitor_notify_valid_g_object_notify (GObject* _sender,
                                                           GParamSpec* pspec,
                                                           gpointer self);
static void ft_lightbox_remove_invalid_monitors (FtLightbox* self);
static void __lambda61_ (FtLightbox* self,
                  GdkMonitor* monitor);
static void ___lambda61__gfunc (gconstpointer data,
                         gpointer self);
static void ft_lightbox_on_notify_fullscreened (FtLightbox* self,
                                         GObject* object,
                                         GParamSpec* pspec);
static void ft_lightbox_on_enter_monitor (FtLightbox* self,
                                   GdkMonitor* monitor);
static void ft_lightbox_on_leave_monitor (FtLightbox* self,
                                   GdkMonitor* monitor);
static gboolean ft_lightbox_on_key_pressed (FtLightbox* self,
                                     GtkEventControllerKey* event_controller,
                                     guint keyval,
                                     guint keycode,
                                     GdkModifierType state);
static gboolean _ft_lightbox_on_key_pressed_gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                                           guint keyval,
                                                                           guint keycode,
                                                                           GdkModifierType state,
                                                                           gpointer self);
static gboolean ft_lightbox_resolve_all_monitors_mode (FtLightbox* self,
                                                gint width,
                                                gint height);
static void ft_lightbox_update_all_monitors_mode (FtLightbox* self,
                                           gint width,
                                           gint height);
static GtkSizeRequestMode ft_lightbox_real_get_request_mode (GtkWidget* base);
static void ft_lightbox_real_measure (GtkWidget* base,
                               GtkOrientation orientation,
                               gint for_size,
                               gint* minimum,
                               gint* natural,
                               gint* minimum_baseline,
                               gint* natural_baseline);
static void ft_lightbox_real_size_allocate (GtkWidget* base,
                                     gint width,
                                     gint height,
                                     gint baseline);
static void ft_lightbox_real_map (GtkWidget* base);
static void _ft_lightbox_on_enter_monitor_gdk_surface_enter_monitor (GdkSurface* _sender,
                                                              GdkMonitor* monitor,
                                                              gpointer self);
static void _ft_lightbox_on_leave_monitor_gdk_surface_leave_monitor (GdkSurface* _sender,
                                                              GdkMonitor* monitor,
                                                              gpointer self);
static void ft_lightbox_real_unmap (GtkWidget* base);
static void ft_lightbox_real_dispose (GObject* base);
static void _ft_lightbox_on_notify_fullscreened_g_object_notify (GObject* _sender,
                                                          GParamSpec* pspec,
                                                          gpointer self);
static GObject * ft_lightbox_constructor (GType type,
                                   guint n_construct_properties,
                                   GObjectConstructParam * construct_properties);
static void ft_lightbox_finalize (GObject * obj);
static GType ft_lightbox_get_type_once (void);
static void _vala_ft_lightbox_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec);
static void _vala_ft_lightbox_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);

/**
     * A primary monitor used to be defined in X11. Nowadays a primary monitor might be chosen
     * by the compositor. It's unlikely that we will integrate properly with all compositors.
     */
static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

GdkMonitor*
ft_get_primary_monitor (GdkDisplay* display)
{
	GdkMonitor* primary_monitor = NULL;
	gint primary_monitor_area = 0;
	GdkDisplay* _tmp1_ = NULL;
	GListModel* _tmp2_ = NULL;
	GListModel* monitors = NULL;
	GListModel* _tmp4_;
	GListModel* _tmp5_;
	GdkMonitor* _tmp22_;
	GdkMonitor* _tmp32_;
	GdkMonitor* result;
	if (display == NULL) {
		GdkDisplay* _tmp0_;
		_tmp0_ = gdk_display_get_default ();
		display = _tmp0_;
	}
	primary_monitor = NULL;
	primary_monitor_area = 0;
	_tmp1_ = display;
	_tmp2_ = NULL;
	if (_tmp1_ != NULL) {
		GListModel* _tmp3_;
		_tmp3_ = gdk_display_get_monitors (_tmp1_);
		_tmp2_ = _tmp3_;
	}
	_tmp4_ = _g_object_ref0 (_tmp2_);
	monitors = _tmp4_;
	_tmp5_ = monitors;
	if (_tmp5_ == NULL) {
		result = NULL;
		_g_object_unref0 (monitors);
		return result;
	}
	{
		gint index = 0;
		index = 0;
		{
			gboolean _tmp6_ = FALSE;
			_tmp6_ = TRUE;
			while (TRUE) {
				GListModel* _tmp8_;
				GdkMonitor* monitor = NULL;
				GListModel* _tmp9_;
				GObject* _tmp10_;
				gint _tmp11_ = 0;
				GdkMonitor* _tmp12_;
				gboolean _tmp13_;
				gboolean _tmp14_;
				gint monitor_area = 0;
				if (!_tmp6_) {
					gint _tmp7_;
					_tmp7_ = index;
					index = _tmp7_ + 1;
				}
				_tmp6_ = FALSE;
				_tmp8_ = monitors;
				if (!(((guint) index) < g_list_model_get_n_items (_tmp8_))) {
					break;
				}
				_tmp9_ = monitors;
				_tmp10_ = g_list_model_get_item (_tmp9_, (guint) index);
				monitor = G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, gdk_monitor_get_type (), GdkMonitor);
				_tmp12_ = monitor;
				g_object_get (_tmp12_, "valid", &_tmp13_, NULL);
				_tmp14_ = _tmp13_;
				if (_tmp14_) {
					GdkMonitor* _tmp15_;
					gint _tmp16_;
					gint _tmp17_;
					GdkMonitor* _tmp18_;
					gint _tmp19_;
					gint _tmp20_;
					_tmp15_ = monitor;
					_tmp16_ = gdk_monitor_get_width_mm (_tmp15_);
					_tmp17_ = _tmp16_;
					_tmp18_ = monitor;
					_tmp19_ = gdk_monitor_get_height_mm (_tmp18_);
					_tmp20_ = _tmp19_;
					_tmp11_ = _tmp17_ * _tmp20_;
				} else {
					_tmp11_ = 0;
				}
				monitor_area = _tmp11_;
				if (monitor_area > primary_monitor_area) {
					GdkMonitor* _tmp21_;
					_tmp21_ = monitor;
					primary_monitor = _tmp21_;
					primary_monitor_area = monitor_area;
				}
				_g_object_unref0 (monitor);
			}
		}
	}
	_tmp22_ = primary_monitor;
	if (_tmp22_ == NULL) {
		{
			gint index = 0;
			index = 0;
			{
				gboolean _tmp23_ = FALSE;
				_tmp23_ = TRUE;
				while (TRUE) {
					GListModel* _tmp25_;
					GdkMonitor* monitor = NULL;
					GListModel* _tmp26_;
					GObject* _tmp27_;
					GdkMonitor* _tmp28_;
					gboolean _tmp29_;
					gboolean _tmp30_;
					if (!_tmp23_) {
						gint _tmp24_;
						_tmp24_ = index;
						index = _tmp24_ + 1;
					}
					_tmp23_ = FALSE;
					_tmp25_ = monitors;
					if (!(((guint) index) < g_list_model_get_n_items (_tmp25_))) {
						break;
					}
					_tmp26_ = monitors;
					_tmp27_ = g_list_model_get_item (_tmp26_, (guint) index);
					monitor = G_TYPE_CHECK_INSTANCE_CAST (_tmp27_, gdk_monitor_get_type (), GdkMonitor);
					_tmp28_ = monitor;
					g_object_get (_tmp28_, "valid", &_tmp29_, NULL);
					_tmp30_ = _tmp29_;
					if (_tmp30_) {
						GdkMonitor* _tmp31_;
						_tmp31_ = monitor;
						primary_monitor = _tmp31_;
						_g_object_unref0 (monitor);
						break;
					}
					_g_object_unref0 (monitor);
				}
			}
		}
	}
	_tmp32_ = primary_monitor;
	result = _tmp32_;
	_g_object_unref0 (monitors);
	return result;
}

void
ft_get_display_geometry (GdkDisplay* display,
                         GdkRectangle* result)
{
	GdkRectangle display_geometry = {0};
	GdkRectangle _tmp1_ = {0};
	GdkDisplay* _tmp2_ = NULL;
	GListModel* _tmp3_ = NULL;
	GListModel* monitors = NULL;
	GListModel* _tmp5_;
	GListModel* _tmp6_;
	if (display == NULL) {
		GdkDisplay* _tmp0_;
		_tmp0_ = gdk_display_get_default ();
		display = _tmp0_;
	}
	memset (&_tmp1_, 0, sizeof (GdkRectangle));
	_tmp1_.x = 0;
	_tmp1_.y = 0;
	_tmp1_.width = 0;
	_tmp1_.height = 0;
	display_geometry = _tmp1_;
	_tmp2_ = display;
	_tmp3_ = NULL;
	if (_tmp2_ != NULL) {
		GListModel* _tmp4_;
		_tmp4_ = gdk_display_get_monitors (_tmp2_);
		_tmp3_ = _tmp4_;
	}
	_tmp5_ = _g_object_ref0 (_tmp3_);
	monitors = _tmp5_;
	_tmp6_ = monitors;
	if (_tmp6_ == NULL) {
		*result = display_geometry;
		_g_object_unref0 (monitors);
		return;
	}
	{
		gint index = 0;
		index = 0;
		{
			gboolean _tmp7_ = FALSE;
			_tmp7_ = TRUE;
			while (TRUE) {
				GListModel* _tmp9_;
				GdkMonitor* monitor = NULL;
				GListModel* _tmp10_;
				GObject* _tmp11_;
				GdkMonitor* _tmp12_;
				if (!_tmp7_) {
					gint _tmp8_;
					_tmp8_ = index;
					index = _tmp8_ + 1;
				}
				_tmp7_ = FALSE;
				_tmp9_ = monitors;
				if (!(((guint) index) < g_list_model_get_n_items (_tmp9_))) {
					break;
				}
				_tmp10_ = monitors;
				_tmp11_ = g_list_model_get_item (_tmp10_, (guint) index);
				monitor = G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, gdk_monitor_get_type (), GdkMonitor);
				_tmp12_ = monitor;
				if (_tmp12_ == NULL) {
					_g_object_unref0 (monitor);
					continue;
				}
				if (index == 0) {
					GdkMonitor* _tmp13_;
					GdkRectangle _tmp14_ = {0};
					_tmp13_ = monitor;
					gdk_monitor_get_geometry (_tmp13_, &_tmp14_);
					display_geometry = _tmp14_;
				} else {
					GdkMonitor* _tmp15_;
					GdkRectangle _tmp16_ = {0};
					GdkRectangle _tmp17_ = {0};
					_tmp15_ = monitor;
					gdk_monitor_get_geometry (_tmp15_, &_tmp16_);
					gdk_rectangle_union (&display_geometry, &_tmp16_, &_tmp17_);
					display_geometry = _tmp17_;
				}
				_g_object_unref0 (monitor);
			}
		}
	}
	*result = display_geometry;
	_g_object_unref0 (monitors);
	return;
}

static inline gpointer
ft_monitor_constrained_layout_manager_get_instance_private (FtMonitorConstrainedLayoutManager* self)
{
	return G_STRUCT_MEMBER_P (self, FtMonitorConstrainedLayoutManager_private_offset);
}

FtMonitorConstrainedLayoutManager*
ft_monitor_constrained_layout_manager_construct (GType object_type,
                                                 GdkMonitor* monitor)
{
	FtMonitorConstrainedLayoutManager * self = NULL;
	self = (FtMonitorConstrainedLayoutManager*) g_object_new (object_type, NULL);
	ft_monitor_constrained_layout_manager_set_monitor (self, monitor);
	return self;
}

FtMonitorConstrainedLayoutManager*
ft_monitor_constrained_layout_manager_new (GdkMonitor* monitor)
{
	return ft_monitor_constrained_layout_manager_construct (FT_TYPE_MONITOR_CONSTRAINED_LAYOUT_MANAGER, monitor);
}

static GtkSizeRequestMode
ft_monitor_constrained_layout_manager_real_get_request_mode (GtkLayoutManager* base,
                                                             GtkWidget* widget)
{
	FtMonitorConstrainedLayoutManager * self;
	GtkSizeRequestMode result;
	self = (FtMonitorConstrainedLayoutManager*) base;
	g_return_val_if_fail (widget != NULL, 0);
	result = GTK_SIZE_REQUEST_CONSTANT_SIZE;
	return result;
}

static void
ft_monitor_constrained_layout_manager_real_measure (GtkLayoutManager* base,
                                                    GtkWidget* widget,
                                                    GtkOrientation orientation,
                                                    gint for_size,
                                                    gint* minimum,
                                                    gint* natural,
                                                    gint* minimum_baseline,
                                                    gint* natural_baseline)
{
	FtMonitorConstrainedLayoutManager * self;
	gint _vala_minimum = 0;
	gint _vala_natural = 0;
	gint _vala_minimum_baseline = 0;
	gint _vala_natural_baseline = 0;
	GdkMonitor* _tmp0_;
	self = (FtMonitorConstrainedLayoutManager*) base;
	g_return_if_fail (widget != NULL);
	_tmp0_ = self->priv->_monitor;
	if (_tmp0_ != NULL) {
		gint _tmp1_ = 0;
		if (orientation == GTK_ORIENTATION_HORIZONTAL) {
			GdkMonitor* _tmp2_;
			GdkRectangle _tmp3_ = {0};
			GdkRectangle _tmp4_;
			_tmp2_ = self->priv->_monitor;
			gdk_monitor_get_geometry (_tmp2_, &_tmp3_);
			_tmp4_ = _tmp3_;
			_tmp1_ = _tmp4_.width;
		} else {
			GdkMonitor* _tmp5_;
			GdkRectangle _tmp6_ = {0};
			GdkRectangle _tmp7_;
			_tmp5_ = self->priv->_monitor;
			gdk_monitor_get_geometry (_tmp5_, &_tmp6_);
			_tmp7_ = _tmp6_;
			_tmp1_ = _tmp7_.height;
		}
		_vala_natural = _tmp1_;
		_vala_minimum = _vala_natural;
	} else {
		_vala_natural = 0;
		_vala_minimum = _vala_natural;
	}
	_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_monitor_constrained_layout_manager_real_allocate (GtkLayoutManager* base,
                                                     GtkWidget* widget,
                                                     gint width,
                                                     gint height,
                                                     gint baseline)
{
	FtMonitorConstrainedLayoutManager * self;
	GtkAllocation allocation = {0};
	GtkAllocation _tmp0_ = {0};
	GdkMonitor* _tmp1_;
	GtkWidget* child = NULL;
	GtkWidget* _tmp8_;
	GtkWidget* _tmp9_;
	self = (FtMonitorConstrainedLayoutManager*) base;
	g_return_if_fail (widget != NULL);
	memset (&_tmp0_, 0, sizeof (GtkAllocation));
	_tmp0_.x = 0;
	_tmp0_.y = 0;
	_tmp0_.width = width;
	_tmp0_.height = height;
	allocation = _tmp0_;
	_tmp1_ = self->priv->_monitor;
	if (_tmp1_ != NULL) {
		GdkRectangle monitor_geometry = {0};
		GdkMonitor* _tmp2_;
		GdkRectangle _tmp3_ = {0};
		GdkRectangle _tmp4_;
		GdkRectangle _tmp5_;
		GdkRectangle _tmp6_;
		GdkRectangle _tmp7_;
		_tmp2_ = self->priv->_monitor;
		gdk_monitor_get_geometry (_tmp2_, &_tmp3_);
		monitor_geometry = _tmp3_;
		_tmp4_ = monitor_geometry;
		allocation.x = _tmp4_.x;
		_tmp5_ = monitor_geometry;
		allocation.y = _tmp5_.y;
		_tmp6_ = monitor_geometry;
		allocation.width = _tmp6_.width;
		_tmp7_ = monitor_geometry;
		allocation.height = _tmp7_.height;
	}
	_tmp8_ = gtk_widget_get_first_child (widget);
	_tmp9_ = _g_object_ref0 (_tmp8_);
	child = _tmp9_;
	while (TRUE) {
		GtkWidget* _tmp10_;
		GtkWidget* _tmp11_;
		GtkWidget* _tmp12_;
		GtkAllocation _tmp13_;
		GtkWidget* _tmp14_;
		GtkWidget* _tmp15_;
		GtkWidget* _tmp16_;
		_tmp10_ = child;
		if (!(_tmp10_ != NULL)) {
			break;
		}
		_tmp11_ = child;
		if (!gtk_widget_should_layout (_tmp11_)) {
			continue;
		}
		_tmp12_ = child;
		_tmp13_ = allocation;
		gtk_widget_size_allocate (_tmp12_, &_tmp13_, -1);
		_tmp14_ = child;
		_tmp15_ = gtk_widget_get_next_sibling (_tmp14_);
		_tmp16_ = _g_object_ref0 (_tmp15_);
		_g_object_unref0 (child);
		child = _tmp16_;
	}
	_g_object_unref0 (child);
}

GdkMonitor*
ft_monitor_constrained_layout_manager_get_monitor (FtMonitorConstrainedLayoutManager* self)
{
	GdkMonitor* result;
	GdkMonitor* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_monitor;
	result = _tmp0_;
	return result;
}

void
ft_monitor_constrained_layout_manager_set_monitor (FtMonitorConstrainedLayoutManager* self,
                                                   GdkMonitor* value)
{
	GdkMonitor* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_monitor);
	self->priv->_monitor = _tmp0_;
	gtk_layout_manager_layout_changed ((GtkLayoutManager*) self);
	g_object_notify_by_pspec ((GObject *) self, ft_monitor_constrained_layout_manager_properties[FT_MONITOR_CONSTRAINED_LAYOUT_MANAGER_MONITOR_PROPERTY]);
}

static void
ft_monitor_constrained_layout_manager_class_init (FtMonitorConstrainedLayoutManagerClass * klass,
                                                  gpointer klass_data)
{
	ft_monitor_constrained_layout_manager_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FtMonitorConstrainedLayoutManager_private_offset);
	((GtkLayoutManagerClass *) klass)->get_request_mode = (GtkSizeRequestMode (*) (GtkLayoutManager*, GtkWidget*)) ft_monitor_constrained_layout_manager_real_get_request_mode;
	((GtkLayoutManagerClass *) klass)->measure = (void (*) (GtkLayoutManager*, GtkWidget*, GtkOrientation, gint, gint*, gint*, gint*, gint*)) ft_monitor_constrained_layout_manager_real_measure;
	((GtkLayoutManagerClass *) klass)->allocate = (void (*) (GtkLayoutManager*, GtkWidget*, gint, gint, gint)) ft_monitor_constrained_layout_manager_real_allocate;
	G_OBJECT_CLASS (klass)->get_property = _vala_ft_monitor_constrained_layout_manager_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_ft_monitor_constrained_layout_manager_set_property;
	G_OBJECT_CLASS (klass)->finalize = ft_monitor_constrained_layout_manager_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_MONITOR_CONSTRAINED_LAYOUT_MANAGER_MONITOR_PROPERTY, ft_monitor_constrained_layout_manager_properties[FT_MONITOR_CONSTRAINED_LAYOUT_MANAGER_MONITOR_PROPERTY] = g_param_spec_object ("monitor", "monitor", "monitor", gdk_monitor_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
ft_monitor_constrained_layout_manager_instance_init (FtMonitorConstrainedLayoutManager * self,
                                                     gpointer klass)
{
	self->priv = ft_monitor_constrained_layout_manager_get_instance_private (self);
	self->priv->_monitor = NULL;
}

static void
ft_monitor_constrained_layout_manager_finalize (GObject * obj)
{
	FtMonitorConstrainedLayoutManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_MONITOR_CONSTRAINED_LAYOUT_MANAGER, FtMonitorConstrainedLayoutManager);
	_g_object_unref0 (self->priv->_monitor);
	G_OBJECT_CLASS (ft_monitor_constrained_layout_manager_parent_class)->finalize (obj);
}

/**
     * Layout manager that positions window contents within the bounds of a monitor.
     *
     * It's necessary for handling `Gdk.FullscreenMode.ALL_MONITORS`.
     */
static GType
ft_monitor_constrained_layout_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtMonitorConstrainedLayoutManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_monitor_constrained_layout_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtMonitorConstrainedLayoutManager), 0, (GInstanceInitFunc) ft_monitor_constrained_layout_manager_instance_init, NULL };
	GType ft_monitor_constrained_layout_manager_type_id;
	ft_monitor_constrained_layout_manager_type_id = g_type_register_static (gtk_layout_manager_get_type (), "FtMonitorConstrainedLayoutManager", &g_define_type_info, 0);
	FtMonitorConstrainedLayoutManager_private_offset = g_type_add_instance_private (ft_monitor_constrained_layout_manager_type_id, sizeof (FtMonitorConstrainedLayoutManagerPrivate));
	return ft_monitor_constrained_layout_manager_type_id;
}

GType
ft_monitor_constrained_layout_manager_get_type (void)
{
	static volatile gsize ft_monitor_constrained_layout_manager_type_id__once = 0;
	if (g_once_init_enter (&ft_monitor_constrained_layout_manager_type_id__once)) {
		GType ft_monitor_constrained_layout_manager_type_id;
		ft_monitor_constrained_layout_manager_type_id = ft_monitor_constrained_layout_manager_get_type_once ();
		g_once_init_leave (&ft_monitor_constrained_layout_manager_type_id__once, ft_monitor_constrained_layout_manager_type_id);
	}
	return ft_monitor_constrained_layout_manager_type_id__once;
}

static void
_vala_ft_monitor_constrained_layout_manager_get_property (GObject * object,
                                                          guint property_id,
                                                          GValue * value,
                                                          GParamSpec * pspec)
{
	FtMonitorConstrainedLayoutManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_MONITOR_CONSTRAINED_LAYOUT_MANAGER, FtMonitorConstrainedLayoutManager);
	switch (property_id) {
		case FT_MONITOR_CONSTRAINED_LAYOUT_MANAGER_MONITOR_PROPERTY:
		g_value_set_object (value, ft_monitor_constrained_layout_manager_get_monitor (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_ft_monitor_constrained_layout_manager_set_property (GObject * object,
                                                          guint property_id,
                                                          const GValue * value,
                                                          GParamSpec * pspec)
{
	FtMonitorConstrainedLayoutManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_MONITOR_CONSTRAINED_LAYOUT_MANAGER, FtMonitorConstrainedLayoutManager);
	switch (property_id) {
		case FT_MONITOR_CONSTRAINED_LAYOUT_MANAGER_MONITOR_PROPERTY:
		ft_monitor_constrained_layout_manager_set_monitor (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

GQuark
ft_lightbox_error_quark (void)
{
	return g_quark_from_static_string ("ft-lightbox-error-quark");
}

static GType
ft_lightbox_error_get_type_once (void)
{
	static const GEnumValue values[] = {{FT_LIGHTBOX_ERROR_NO_MONITORS, "FT_LIGHTBOX_ERROR_NO_MONITORS", "no-monitors"}, {0, NULL, NULL}};
	GType ft_lightbox_error_type_id;
	ft_lightbox_error_type_id = g_enum_register_static ("FtLightboxError", values);
	return ft_lightbox_error_type_id;
}

GType
ft_lightbox_error_get_type (void)
{
	static volatile gsize ft_lightbox_error_type_id__once = 0;
	if (g_once_init_enter (&ft_lightbox_error_type_id__once)) {
		GType ft_lightbox_error_type_id;
		ft_lightbox_error_type_id = ft_lightbox_error_get_type_once ();
		g_once_init_leave (&ft_lightbox_error_type_id__once, ft_lightbox_error_type_id);
	}
	return ft_lightbox_error_type_id__once;
}

static inline gpointer
ft_lightbox_group_get_instance_private (FtLightboxGroup* self)
{
	return G_STRUCT_MEMBER_P (self, FtLightboxGroup_private_offset);
}

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

FtLightboxGroup*
ft_lightbox_group_construct (GType object_type,
                             GType lightbox_type)
{
	FtLightboxGroup * self = NULL;
	GHashFunc _tmp0_;
	GEqualFunc _tmp1_;
	GHashTable* _tmp2_;
	self = (FtLightboxGroup*) g_object_new (object_type, NULL);
	self->priv->lightbox_type = lightbox_type;
	_tmp0_ = g_direct_hash;
	_tmp1_ = g_direct_equal;
	_tmp2_ = g_hash_table_new_full (_tmp0_, _tmp1_, NULL, _g_object_unref0_);
	_g_hash_table_unref0 (self->priv->lightboxes);
	self->priv->lightboxes = _tmp2_;
	return self;
}

FtLightboxGroup*
ft_lightbox_group_new (GType lightbox_type)
{
	return ft_lightbox_group_construct (FT_TYPE_LIGHTBOX_GROUP, lightbox_type);
}

static Block18Data*
block18_data_ref (Block18Data* _data18_)
{
	g_atomic_int_inc (&_data18_->_ref_count_);
	return _data18_;
}

static void
block18_data_unref (void * _userdata_)
{
	Block18Data* _data18_;
	_data18_ = (Block18Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data18_->_ref_count_)) {
		FtLightboxGroup* self;
		self = _data18_->self;
		_g_object_unref0 (self);
		g_slice_free (Block18Data, _data18_);
	}
}

static Block19Data*
block19_data_ref (Block19Data* _data19_)
{
	g_atomic_int_inc (&_data19_->_ref_count_);
	return _data19_;
}

static void
block19_data_unref (void * _userdata_)
{
	Block19Data* _data19_;
	_data19_ = (Block19Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data19_->_ref_count_)) {
		GHashTable* self;
		self = _data19_->self;
		_g_hash_table_unref0 (self);
		g_slice_free (Block19Data, _data19_);
	}
}

static void
__lambda2_ (Block19Data* _data19_,
            gconstpointer k,
            gconstpointer v)
{
	GHashTable* self;
	self = _data19_->self;
	_data19_->func (v, _data19_->func_target);
}

static void
___lambda2__gh_func (gconstpointer key,
                     gconstpointer value,
                     gpointer self)
{
	__lambda2_ (self, key, value);
}

static void
_vala_g_hash_set_foreach (GHashTable* self,
                          GFunc func,
                          gpointer func_target)
{
	Block19Data* _data19_;
	g_return_if_fail (self != NULL);
	_data19_ = g_slice_new0 (Block19Data);
	_data19_->_ref_count_ = 1;
	_data19_->self = g_hash_table_ref (self);
	_data19_->func = func;
	_data19_->func_target = func_target;
	g_hash_table_foreach ((GHashTable*) self, ___lambda2__gh_func, _data19_);
	block19_data_unref (_data19_);
	_data19_ = NULL;
}

static void
__lambda62_ (Block18Data* _data18_,
             FtLightbox* lightbox)
{
	FtLightboxGroup* self;
	self = _data18_->self;
	g_return_if_fail (lightbox != NULL);
	if (lightbox != NULL) {
		_data18_->first_lightbox = lightbox;
	}
}

static void
___lambda62__gfunc (gconstpointer data,
                    gpointer self)
{
	__lambda62_ (self, (FtLightbox*) data);
}

static FtLightbox*
ft_lightbox_group_get_first_lightbox (FtLightboxGroup* self)
{
	Block18Data* _data18_;
	GHashTable* _tmp0_;
	FtLightbox* result;
	g_return_val_if_fail (self != NULL, NULL);
	_data18_ = g_slice_new0 (Block18Data);
	_data18_->_ref_count_ = 1;
	_data18_->self = g_object_ref (self);
	_data18_->first_lightbox = NULL;
	_tmp0_ = self->priv->lightboxes;
	_vala_g_hash_set_foreach (_tmp0_, ___lambda62__gfunc, _data18_);
	result = _data18_->first_lightbox;
	block18_data_unref (_data18_);
	_data18_ = NULL;
	return result;
}

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_lightbox_group_on_lightbox_notify_monitor_g_object_notify (GObject* _sender,
                                                               GParamSpec* pspec,
                                                               gpointer self)
{
	ft_lightbox_group_on_lightbox_notify_monitor ((FtLightboxGroup*) self, _sender, pspec);
}

static gboolean
_ft_lightbox_group_on_lightbox_close_request_gtk_window_close_request (GtkWindow* _sender,
                                                                       gpointer self)
{
	gboolean result;
	result = ft_lightbox_group_on_lightbox_close_request ((FtLightboxGroup*) self, _sender);
	return result;
}

static void
_ft_lightbox_group_on_lightbox_unrealize_gtk_widget_unrealize (GtkWidget* _sender,
                                                               gpointer self)
{
	ft_lightbox_group_on_lightbox_unrealize ((FtLightboxGroup*) self, _sender);
}

static FtLightbox*
ft_lightbox_group_create_lightbox (FtLightboxGroup* self,
                                   GdkMonitor* monitor_request)
{
	GValue monitor_request_value = {0};
	GValue _tmp0_ = {0};
	GValue show_contents_value = {0};
	GValue _tmp1_ = {0};
	FtLightbox* lightbox = NULL;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar** _tmp4_;
	gchar** _tmp5_;
	gint _tmp5__length1;
	GValue _tmp6_;
	GValue _tmp7_;
	GValue _tmp8_ = {0};
	GValue _tmp9_;
	GValue _tmp10_;
	GValue _tmp11_ = {0};
	GValue* _tmp12_;
	GValue* _tmp13_;
	gint _tmp13__length1;
	GObject* _tmp14_;
	GObject* _tmp15_;
	FtLightbox* _tmp16_;
	GtkWidget* lightbox_widget = NULL;
	GtkWidget* _tmp17_;
	GtkWindowGroup* _tmp18_;
	GHashTable* _tmp19_;
	FtLightbox* _tmp20_;
	FtLightbox* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_value_init (&_tmp0_, gdk_monitor_get_type ());
	monitor_request_value = _tmp0_;
	g_value_set_object (&monitor_request_value, (GObject*) monitor_request);
	g_value_init (&_tmp1_, G_TYPE_BOOLEAN);
	show_contents_value = _tmp1_;
	g_value_set_boolean (&show_contents_value, FALSE);
	_tmp2_ = g_strdup ("monitor-request");
	_tmp3_ = g_strdup ("show-contents");
	_tmp4_ = g_new0 (gchar*, 2 + 1);
	_tmp4_[0] = _tmp2_;
	_tmp4_[1] = _tmp3_;
	_tmp5_ = _tmp4_;
	_tmp5__length1 = 2;
	_tmp6_ = monitor_request_value;
	_tmp7_ = _tmp6_;
	if (G_IS_VALUE (&_tmp7_)) {
		g_value_init (&_tmp8_, G_VALUE_TYPE (&_tmp7_));
		g_value_copy (&_tmp7_, &_tmp8_);
	} else {
		_tmp8_ = _tmp7_;
	}
	_tmp9_ = show_contents_value;
	_tmp10_ = _tmp9_;
	if (G_IS_VALUE (&_tmp10_)) {
		g_value_init (&_tmp11_, G_VALUE_TYPE (&_tmp10_));
		g_value_copy (&_tmp10_, &_tmp11_);
	} else {
		_tmp11_ = _tmp10_;
	}
	_tmp12_ = g_new0 (GValue, 2);
	_tmp12_[0] = _tmp8_;
	_tmp12_[1] = _tmp11_;
	_tmp13_ = _tmp12_;
	_tmp13__length1 = 2;
	_tmp14_ = g_object_new_with_properties (self->priv->lightbox_type, (guint) 2, _tmp5_, _tmp13_);
	_tmp15_ = G_IS_INITIALLY_UNOWNED (_tmp14_) ? g_object_ref_sink (_tmp14_) : _tmp14_;
	_tmp16_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp15_, FT_TYPE_LIGHTBOX, FtLightbox);
	_tmp13_ = (_vala_GValue_array_free (_tmp13_, _tmp13__length1), NULL);
	_tmp5_ = (_vala_array_free (_tmp5_, _tmp5__length1, (GDestroyNotify) g_free), NULL);
	lightbox = _tmp16_;
	g_signal_connect_object ((GObject*) lightbox, "notify::monitor", (GCallback) _ft_lightbox_group_on_lightbox_notify_monitor_g_object_notify, self, 0);
	g_signal_connect_object ((GtkWindow*) lightbox, "close-request", (GCallback) _ft_lightbox_group_on_lightbox_close_request_gtk_window_close_request, self, 0);
	_tmp17_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (lightbox, gtk_widget_get_type (), GtkWidget));
	lightbox_widget = _tmp17_;
	g_signal_connect_object (lightbox_widget, "unrealize", (GCallback) _ft_lightbox_group_on_lightbox_unrealize_gtk_widget_unrealize, self, 0);
	_tmp18_ = self->priv->window_group;
	gtk_window_group_add_window (_tmp18_, (GtkWindow*) lightbox);
	_tmp19_ = self->priv->lightboxes;
	_tmp20_ = _g_object_ref0 (lightbox);
	g_hash_table_add (_tmp19_, _tmp20_);
	gtk_window_present ((GtkWindow*) lightbox);
	result = lightbox;
	_g_object_unref0 (lightbox_widget);
	G_IS_VALUE (&show_contents_value) ? (g_value_unset (&show_contents_value), NULL) : NULL;
	G_IS_VALUE (&monitor_request_value) ? (g_value_unset (&monitor_request_value), NULL) : NULL;
	return result;
}

static void
ft_lightbox_group_destroy_lightbox (FtLightboxGroup* self,
                                    FtLightbox* lightbox)
{
	guint _tmp0_;
	GQuark _tmp1_;
	guint _tmp2_;
	GtkWidget* lightbox_widget = NULL;
	GtkWidget* _tmp3_;
	guint _tmp4_;
	GHashTable* _tmp5_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (lightbox != NULL);
	g_signal_parse_name ("notify::monitor", G_TYPE_OBJECT, &_tmp0_, &_tmp1_, TRUE);
	g_signal_handlers_disconnect_matched ((GObject*) lightbox, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DETAIL | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp0_, _tmp1_, NULL, (GCallback) _ft_lightbox_group_on_lightbox_notify_monitor_g_object_notify, self);
	g_signal_parse_name ("close-request", gtk_window_get_type (), &_tmp2_, NULL, FALSE);
	g_signal_handlers_disconnect_matched ((GtkWindow*) lightbox, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp2_, 0, NULL, (GCallback) _ft_lightbox_group_on_lightbox_close_request_gtk_window_close_request, self);
	_tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (lightbox, gtk_widget_get_type (), GtkWidget));
	lightbox_widget = _tmp3_;
	g_signal_parse_name ("unrealize", gtk_widget_get_type (), &_tmp4_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (lightbox_widget, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp4_, 0, NULL, (GCallback) _ft_lightbox_group_on_lightbox_unrealize_gtk_widget_unrealize, self);
	_tmp5_ = self->priv->lightboxes;
	g_hash_table_remove (_tmp5_, lightbox);
	gtk_window_close ((GtkWindow*) lightbox);
	_g_object_unref0 (lightbox_widget);
}

static Block20Data*
block20_data_ref (Block20Data* _data20_)
{
	g_atomic_int_inc (&_data20_->_ref_count_);
	return _data20_;
}

static void
block20_data_unref (void * _userdata_)
{
	Block20Data* _data20_;
	_data20_ = (Block20Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data20_->_ref_count_)) {
		FtLightboxGroup* self;
		self = _data20_->self;
		_g_hash_table_unref0 (_data20_->paired_lightboxes);
		_g_hash_table_unref0 (_data20_->paired_monitors);
		_g_object_unref0 (self);
		g_slice_free (Block20Data, _data20_);
	}
}

static void
__lambda64_ (Block20Data* _data20_,
             FtLightbox* lightbox)
{
	FtLightboxGroup* self;
	GdkMonitor* lightbox_monitor = NULL;
	GdkMonitor* _tmp0_;
	GdkMonitor* _tmp1_;
	GdkMonitor* _tmp2_;
	GdkMonitor* _tmp3_;
	gboolean _tmp5_ = FALSE;
	GdkMonitor* _tmp6_;
	self = _data20_->self;
	g_return_if_fail (lightbox != NULL);
	_tmp0_ = ft_lightbox_get_monitor (lightbox);
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	lightbox_monitor = _tmp2_;
	_tmp3_ = lightbox_monitor;
	if (_tmp3_ != NULL) {
		GdkMonitor* _tmp4_;
		_tmp4_ = lightbox_monitor;
		ft_lightbox_set_monitor_request (lightbox, _tmp4_);
	}
	_tmp6_ = lightbox_monitor;
	if (_tmp6_ != NULL) {
		GHashTable* _tmp7_;
		GdkMonitor* _tmp8_;
		_tmp7_ = _data20_->paired_monitors;
		_tmp8_ = lightbox_monitor;
		_tmp5_ = !g_hash_table_contains (_tmp7_, _tmp8_);
	} else {
		_tmp5_ = FALSE;
	}
	if (_tmp5_) {
		GHashTable* _tmp9_;
		GdkMonitor* _tmp10_;
		GHashTable* _tmp11_;
		_tmp9_ = _data20_->paired_monitors;
		_tmp10_ = lightbox_monitor;
		g_hash_table_add (_tmp9_, _tmp10_);
		_tmp11_ = _data20_->paired_lightboxes;
		g_hash_table_add (_tmp11_, lightbox);
	}
	_g_object_unref0 (lightbox_monitor);
}

static void
___lambda64__gfunc (gconstpointer data,
                    gpointer self)
{
	__lambda64_ (self, (FtLightbox*) data);
}

static void
__lambda65_ (Block20Data* _data20_,
             FtLightbox* lightbox)
{
	FtLightboxGroup* self;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	GdkMonitor* _tmp3_;
	GdkMonitor* _tmp4_;
	self = _data20_->self;
	g_return_if_fail (lightbox != NULL);
	_tmp3_ = ft_lightbox_get_monitor_request (lightbox);
	_tmp4_ = _tmp3_;
	if (_tmp4_ != NULL) {
		_tmp2_ = !gtk_widget_get_mapped ((GtkWidget*) lightbox);
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		GHashTable* _tmp5_;
		GdkMonitor* _tmp6_;
		GdkMonitor* _tmp7_;
		_tmp5_ = _data20_->paired_monitors;
		_tmp6_ = ft_lightbox_get_monitor_request (lightbox);
		_tmp7_ = _tmp6_;
		_tmp1_ = !g_hash_table_contains (_tmp5_, _tmp7_);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		GHashTable* _tmp8_;
		_tmp8_ = _data20_->paired_lightboxes;
		_tmp0_ = !g_hash_table_contains (_tmp8_, lightbox);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		GHashTable* _tmp9_;
		GdkMonitor* _tmp10_;
		GdkMonitor* _tmp11_;
		GHashTable* _tmp12_;
		_tmp9_ = _data20_->paired_monitors;
		_tmp10_ = ft_lightbox_get_monitor_request (lightbox);
		_tmp11_ = _tmp10_;
		g_hash_table_add (_tmp9_, _tmp11_);
		_tmp12_ = _data20_->paired_lightboxes;
		g_hash_table_add (_tmp12_, lightbox);
	}
}

static void
___lambda65__gfunc (gconstpointer data,
                    gpointer self)
{
	__lambda65_ (self, (FtLightbox*) data);
}

static void
__lambda66_ (Block20Data* _data20_,
             FtLightbox* lightbox)
{
	FtLightboxGroup* self;
	GHashTable* _tmp0_;
	self = _data20_->self;
	g_return_if_fail (lightbox != NULL);
	_tmp0_ = _data20_->paired_lightboxes;
	if (!g_hash_table_contains (_tmp0_, lightbox)) {
		ft_lightbox_group_destroy_lightbox (self, lightbox);
	}
}

static void
___lambda66__gfunc (gconstpointer data,
                    gpointer self)
{
	__lambda66_ (self, (FtLightbox*) data);
}

static void
ft_lightbox_group_update_lightboxes (FtLightboxGroup* self)
{
	Block20Data* _data20_;
	GHashTable* _tmp0_;
	guint _tmp1_;
	guint _tmp2_;
	GHashTable* _tmp5_;
	guint _tmp6_;
	guint _tmp7_;
	GHashFunc _tmp13_;
	GEqualFunc _tmp14_;
	GHashTable* _tmp15_;
	GHashFunc _tmp16_;
	GEqualFunc _tmp17_;
	GHashTable* _tmp18_;
	GHashTable* _tmp19_;
	GHashTable* _tmp20_;
	GHashTable* _tmp21_;
	GList* _tmp22_;
	GList* _tmp23_;
	GHashTable* _tmp43_;
	guint _tmp44_;
	guint _tmp45_;
	GHashTable* _tmp46_;
	guint _tmp47_;
	guint _tmp48_;
	g_return_if_fail (self != NULL);
	_data20_ = g_slice_new0 (Block20Data);
	_data20_->_ref_count_ = 1;
	_data20_->self = g_object_ref (self);
	_tmp0_ = self->priv->lightboxes;
	_tmp1_ = g_hash_table_size (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ == ((guint) 0)) {
		FtLightbox* _tmp3_;
		FtLightbox* _tmp4_;
		_tmp3_ = ft_lightbox_group_create_lightbox (self, NULL);
		_tmp4_ = _tmp3_;
		_g_object_unref0 (_tmp4_);
		block20_data_unref (_data20_);
		_data20_ = NULL;
		return;
	}
	_tmp5_ = self->priv->lightboxes;
	_tmp6_ = g_hash_table_size (_tmp5_);
	_tmp7_ = _tmp6_;
	if (_tmp7_ == ((guint) 1)) {
		FtLightbox* lightbox = NULL;
		FtLightbox* _tmp8_;
		FtLightbox* _tmp9_;
		FtLightbox* _tmp10_;
		gboolean _tmp11_;
		gboolean _tmp12_;
		_tmp8_ = ft_lightbox_group_get_first_lightbox (self);
		_tmp9_ = _g_object_ref0 (_tmp8_);
		lightbox = _tmp9_;
		_tmp10_ = lightbox;
		_tmp11_ = ft_lightbox_get_all_monitors_mode (_tmp10_);
		_tmp12_ = _tmp11_;
		if (_tmp12_) {
			_g_object_unref0 (lightbox);
			block20_data_unref (_data20_);
			_data20_ = NULL;
			return;
		}
		_g_object_unref0 (lightbox);
	}
	_tmp13_ = g_direct_hash;
	_tmp14_ = g_direct_equal;
	_tmp15_ = g_hash_table_new_full (_tmp13_, _tmp14_, NULL, NULL);
	_data20_->paired_monitors = _tmp15_;
	_tmp16_ = g_direct_hash;
	_tmp17_ = g_direct_equal;
	_tmp18_ = g_hash_table_new_full (_tmp16_, _tmp17_, NULL, NULL);
	_data20_->paired_lightboxes = _tmp18_;
	_tmp19_ = self->priv->lightboxes;
	_vala_g_hash_set_foreach (_tmp19_, ___lambda64__gfunc, _data20_);
	_tmp20_ = self->priv->lightboxes;
	_vala_g_hash_set_foreach (_tmp20_, ___lambda65__gfunc, _data20_);
	_tmp21_ = self->priv->lightboxes;
	_tmp22_ = g_hash_table_get_values (_tmp21_);
	_tmp23_ = _tmp22_;
	g_list_foreach (_tmp23_, ___lambda66__gfunc, _data20_);
	(_tmp23_ == NULL) ? NULL : (_tmp23_ = (g_list_free (_tmp23_), NULL));
	{
		guint index = 0U;
		index = 0U;
		{
			gboolean _tmp24_ = FALSE;
			_tmp24_ = TRUE;
			while (TRUE) {
				GListModel* _tmp26_;
				GdkMonitor* monitor = NULL;
				GListModel* _tmp27_;
				GObject* _tmp28_;
				gboolean _tmp29_ = FALSE;
				gboolean _tmp30_ = FALSE;
				GdkMonitor* _tmp31_;
				if (!_tmp24_) {
					guint _tmp25_;
					_tmp25_ = index;
					index = _tmp25_ + 1;
				}
				_tmp24_ = FALSE;
				_tmp26_ = self->priv->monitors;
				if (!(index < g_list_model_get_n_items (_tmp26_))) {
					break;
				}
				_tmp27_ = self->priv->monitors;
				_tmp28_ = g_list_model_get_item (_tmp27_, index);
				monitor = G_TYPE_CHECK_INSTANCE_CAST (_tmp28_, gdk_monitor_get_type (), GdkMonitor);
				_tmp31_ = monitor;
				if (_tmp31_ != NULL) {
					GdkMonitor* _tmp32_;
					gboolean _tmp33_;
					gboolean _tmp34_;
					_tmp32_ = monitor;
					g_object_get (_tmp32_, "valid", &_tmp33_, NULL);
					_tmp34_ = _tmp33_;
					_tmp30_ = _tmp34_;
				} else {
					_tmp30_ = FALSE;
				}
				if (_tmp30_) {
					GHashTable* _tmp35_;
					GdkMonitor* _tmp36_;
					_tmp35_ = _data20_->paired_monitors;
					_tmp36_ = monitor;
					_tmp29_ = !g_hash_table_contains (_tmp35_, _tmp36_);
				} else {
					_tmp29_ = FALSE;
				}
				if (_tmp29_) {
					FtLightbox* lightbox = NULL;
					GdkMonitor* _tmp37_;
					FtLightbox* _tmp38_;
					GHashTable* _tmp39_;
					GdkMonitor* _tmp40_;
					GHashTable* _tmp41_;
					FtLightbox* _tmp42_;
					_tmp37_ = monitor;
					_tmp38_ = ft_lightbox_group_create_lightbox (self, _tmp37_);
					lightbox = _tmp38_;
					_tmp39_ = _data20_->paired_monitors;
					_tmp40_ = monitor;
					g_hash_table_add (_tmp39_, _tmp40_);
					_tmp41_ = _data20_->paired_lightboxes;
					_tmp42_ = lightbox;
					g_hash_table_add (_tmp41_, _tmp42_);
					_g_object_unref0 (lightbox);
				}
				_g_object_unref0 (monitor);
			}
		}
	}
	_tmp43_ = _data20_->paired_monitors;
	_tmp44_ = g_hash_table_size (_tmp43_);
	_tmp45_ = _tmp44_;
	_tmp46_ = _data20_->paired_lightboxes;
	_tmp47_ = g_hash_table_size (_tmp46_);
	_tmp48_ = _tmp47_;
	if (_tmp45_ != _tmp48_) {
		GHashTable* _tmp49_;
		guint _tmp50_;
		guint _tmp51_;
		GHashTable* _tmp52_;
		guint _tmp53_;
		guint _tmp54_;
		_tmp49_ = _data20_->paired_lightboxes;
		_tmp50_ = g_hash_table_size (_tmp49_);
		_tmp51_ = _tmp50_;
		_tmp52_ = _data20_->paired_monitors;
		_tmp53_ = g_hash_table_size (_tmp52_);
		_tmp54_ = _tmp53_;
		g_warning ("lightbox.vala:333: Mismatch between number of windows (%u) and monitor" \
"s (%u).", _tmp51_, _tmp54_);
	}
	block20_data_unref (_data20_);
	_data20_ = NULL;
}

static void
ft_lightbox_group_update (FtLightboxGroup* self)
{
	gboolean _tmp0_ = FALSE;
	guint _tmp2_;
	guint _tmp3_;
	g_return_if_fail (self != NULL);
	if (self->priv->updating_count > ((guint) 0)) {
		_tmp0_ = TRUE;
	} else {
		GListModel* _tmp1_;
		_tmp1_ = self->priv->monitors;
		_tmp0_ = _tmp1_ == NULL;
	}
	if (_tmp0_) {
		return;
	}
	if (self->priv->update_idle_id != ((guint) 0)) {
		g_source_remove (self->priv->update_idle_id);
		self->priv->update_idle_id = (guint) 0;
	}
	_tmp2_ = self->priv->updating_count;
	self->priv->updating_count = _tmp2_ + 1;
	ft_lightbox_group_update_lightboxes (self);
	_tmp3_ = self->priv->updating_count;
	self->priv->updating_count = _tmp3_ - 1;
}

static gboolean
__lambda63_ (FtLightboxGroup* self)
{
	gboolean result;
	self->priv->update_idle_id = (guint) 0;
	ft_lightbox_group_update (self);
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
___lambda63__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda63_ ((FtLightboxGroup*) self);
	return result;
}

static void
ft_lightbox_group_queue_update (FtLightboxGroup* self)
{
	g_return_if_fail (self != NULL);
	if (self->priv->update_idle_id != ((guint) 0)) {
		return;
	}
	self->priv->update_idle_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, ___lambda63__gsource_func, g_object_ref (self), g_object_unref);
	g_source_set_name_by_id (self->priv->update_idle_id, "Ft.LightboxGroup.update");
}

static void
__lambda67_ (FtLightboxGroup* self,
             FtLightbox* lightbox)
{
	g_return_if_fail (lightbox != NULL);
	gtk_widget_queue_resize ((GtkWidget*) lightbox);
}

static void
___lambda67__gfunc (gconstpointer data,
                    gpointer self)
{
	__lambda67_ ((FtLightboxGroup*) self, (FtLightbox*) data);
}

static void
ft_lightbox_group_on_monitors_changed (FtLightboxGroup* self,
                                       GListModel* model,
                                       guint position,
                                       guint removed,
                                       guint added)
{
	GHashTable* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (model != NULL);
	_tmp0_ = self->priv->lightboxes;
	_vala_g_hash_set_foreach (_tmp0_, ___lambda67__gfunc, self);
	ft_lightbox_group_queue_update (self);
}

static void
ft_lightbox_group_on_lightbox_notify_monitor (FtLightboxGroup* self,
                                              GObject* object,
                                              GParamSpec* pspec)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (object != NULL);
	g_return_if_fail (pspec != NULL);
	ft_lightbox_group_queue_update (self);
}

static gboolean
ft_lightbox_group_on_lightbox_close_request (FtLightboxGroup* self,
                                             GtkWindow* window)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (window != NULL, FALSE);
	if (self->priv->updating_count == ((guint) 0)) {
		ft_lightbox_group_close (self);
	}
	result = FALSE;
	return result;
}

static void
ft_lightbox_group_on_lightbox_unrealize (FtLightboxGroup* self,
                                         GtkWidget* widget)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (widget != NULL);
	ft_lightbox_group_destroy_lightbox (self, G_TYPE_CHECK_INSTANCE_CAST (widget, FT_TYPE_LIGHTBOX, FtLightbox));
}

static void
ft_lightbox_group_open_data_free (gpointer _data)
{
	FtLightboxGroupOpenData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (FtLightboxGroupOpenData, _data_);
}

void
ft_lightbox_group_open (FtLightboxGroup* self,
                        GCancellable* cancellable,
                        GAsyncReadyCallback _callback_,
                        gpointer _user_data_)
{
	FtLightboxGroupOpenData* _data_;
	FtLightboxGroup* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (FtLightboxGroupOpenData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, ft_lightbox_group_open_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	ft_lightbox_group_open_co (_data_);
}

void
ft_lightbox_group_open_finish (FtLightboxGroup* self,
                               GAsyncResult* _res_,
                               GError** error)
{
	FtLightboxGroupOpenData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
_ft_lightbox_group_on_monitors_changed_g_list_model_items_changed (GListModel* _sender,
                                                                   guint position,
                                                                   guint removed,
                                                                   guint added,
                                                                   gpointer self)
{
	ft_lightbox_group_on_monitors_changed ((FtLightboxGroup*) self, _sender, position, removed, added);
}

static gboolean
_ft_lightbox_group_open_co_gsource_func (gpointer self)
{
	gboolean result;
	result = ft_lightbox_group_open_co (self);
	return result;
}

static void
_ft_lightbox_group_close_g_cancellable_cancelled (GCancellable* _sender,
                                                  gpointer self)
{
	ft_lightbox_group_close ((FtLightboxGroup*) self);
}

static void
__lambda68_ (FtLightboxGroup* self,
             FtLightbox* lightbox)
{
	g_return_if_fail (lightbox != NULL);
	gtk_window_close ((GtkWindow*) lightbox);
}

static void
___lambda68__gfunc (gconstpointer data,
                    gpointer self)
{
	__lambda68_ ((FtLightboxGroup*) self, (FtLightbox*) data);
}

static gboolean
ft_lightbox_group_open_co (FtLightboxGroupOpenData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->open_callback;
	_data_->_tmp0__target = _data_->self->priv->open_callback_target;
	_vala_return_val_if_fail (_data_->_tmp0_ == NULL, "this.open_callback == null", FALSE);
	_data_->_tmp1_ = _data_->self->priv->monitors;
	if (_data_->_tmp1_ == NULL) {
		_data_->_tmp3_ = gdk_display_get_default ();
		_data_->_tmp2_ = _data_->_tmp3_;
		_data_->_tmp4_ = NULL;
		if (_data_->_tmp2_ != NULL) {
			_data_->_tmp5_ = gdk_display_get_monitors (_data_->_tmp2_);
			_data_->_tmp4_ = _data_->_tmp5_;
		}
		_data_->_tmp6_ = _g_object_ref0 (_data_->_tmp4_);
		_g_object_unref0 (_data_->self->priv->monitors);
		_data_->self->priv->monitors = _data_->_tmp6_;
	}
	_data_->_tmp7_ = _data_->self->priv->monitors;
	if (_data_->_tmp7_ == NULL) {
		_data_->_tmp8_ = g_error_new_literal (FT_LIGHTBOX_ERROR, FT_LIGHTBOX_ERROR_NO_MONITORS, "Could not list monitors.");
		_data_->_inner_error0_ = _data_->_tmp8_;
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	if (_data_->self->priv->monitors_changed_id == ((gulong) 0)) {
		_data_->_tmp9_ = _data_->self->priv->monitors;
		_data_->_tmp10_ = g_signal_connect_object (_data_->_tmp9_, "items-changed", (GCallback) _ft_lightbox_group_on_monitors_changed_g_list_model_items_changed, _data_->self, 0);
		_data_->self->priv->monitors_changed_id = _data_->_tmp10_;
	}
	_data_->_tmp11_ = gtk_window_group_new ();
	_g_object_unref0 (_data_->self->priv->window_group);
	_data_->self->priv->window_group = _data_->_tmp11_;
	ft_lightbox_group_update (_data_->self);
	(_data_->self->priv->open_callback_target_destroy_notify == NULL) ? NULL : (_data_->self->priv->open_callback_target_destroy_notify (_data_->self->priv->open_callback_target), NULL);
	_data_->self->priv->open_callback = NULL;
	_data_->self->priv->open_callback_target = NULL;
	_data_->self->priv->open_callback_target_destroy_notify = NULL;
	_data_->self->priv->open_callback = _ft_lightbox_group_open_co_gsource_func;
	_data_->self->priv->open_callback_target = _data_;
	_data_->self->priv->open_callback_target_destroy_notify = NULL;
	if (_data_->cancellable != NULL) {
		g_signal_connect_object (_data_->cancellable, "cancelled", (GCallback) _ft_lightbox_group_close_g_cancellable_cancelled, _data_->self, 0);
	}
	_data_->_state_ = 1;
	return FALSE;
	_state_1:
	;
	(_data_->self->priv->open_callback_target_destroy_notify == NULL) ? NULL : (_data_->self->priv->open_callback_target_destroy_notify (_data_->self->priv->open_callback_target), NULL);
	_data_->self->priv->open_callback = NULL;
	_data_->self->priv->open_callback_target = NULL;
	_data_->self->priv->open_callback_target_destroy_notify = NULL;
	_data_->self->priv->open_callback = NULL;
	_data_->self->priv->open_callback_target = NULL;
	_data_->self->priv->open_callback_target_destroy_notify = NULL;
	if (_data_->self->priv->monitors_changed_id != ((gulong) 0)) {
		_data_->_tmp12_ = _data_->self->priv->monitors;
		g_signal_handler_disconnect ((GObject*) _data_->_tmp12_, _data_->self->priv->monitors_changed_id);
		_data_->self->priv->monitors_changed_id = (gulong) 0;
	}
	_data_->_tmp13_ = _data_->self->priv->lightboxes;
	_data_->_tmp14_ = g_hash_table_get_values (_data_->_tmp13_);
	_data_->_tmp15_ = _data_->_tmp14_;
	g_list_foreach (_data_->_tmp15_, ___lambda68__gfunc, _data_->self);
	(_data_->_tmp15_ == NULL) ? NULL : (_data_->_tmp15_ = (g_list_free (_data_->_tmp15_), NULL));
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
ft_lightbox_group_close (FtLightboxGroup* self)
{
	GSourceFunc _tmp0_;
	gpointer _tmp0__target;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->open_callback;
	_tmp0__target = self->priv->open_callback_target;
	if (_tmp0_ != NULL) {
		GSourceFunc _tmp1_;
		gpointer _tmp1__target;
		_tmp1_ = self->priv->open_callback;
		_tmp1__target = self->priv->open_callback_target;
		_tmp1_ (_tmp1__target);
	}
}

static void
ft_lightbox_group_real_dispose (GObject* base)
{
	FtLightboxGroup * self;
	GHashTable* _tmp1_;
	self = (FtLightboxGroup*) base;
	if (self->priv->update_idle_id != ((guint) 0)) {
		g_source_remove (self->priv->update_idle_id);
		self->priv->update_idle_id = (guint) 0;
	}
	if (self->priv->monitors_changed_id != ((gulong) 0)) {
		GListModel* _tmp0_;
		_tmp0_ = self->priv->monitors;
		g_signal_handler_disconnect ((GObject*) _tmp0_, self->priv->monitors_changed_id);
		self->priv->monitors_changed_id = (gulong) 0;
	}
	_tmp1_ = self->priv->lightboxes;
	if (_tmp1_ != NULL) {
		GHashTable* _tmp2_;
		_tmp2_ = self->priv->lightboxes;
		g_hash_table_remove_all (_tmp2_);
		_g_hash_table_unref0 (self->priv->lightboxes);
		self->priv->lightboxes = NULL;
	}
	_g_object_unref0 (self->priv->window_group);
	self->priv->window_group = NULL;
	_g_object_unref0 (self->priv->monitors);
	self->priv->monitors = NULL;
	G_OBJECT_CLASS (ft_lightbox_group_parent_class)->dispose ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, G_TYPE_INITIALLY_UNOWNED, GInitiallyUnowned));
}

static void
ft_lightbox_group_class_init (FtLightboxGroupClass * klass,
                              gpointer klass_data)
{
	ft_lightbox_group_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FtLightboxGroup_private_offset);
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) ft_lightbox_group_real_dispose;
	G_OBJECT_CLASS (klass)->finalize = ft_lightbox_group_finalize;
}

static void
ft_lightbox_group_instance_init (FtLightboxGroup * self,
                                 gpointer klass)
{
	self->priv = ft_lightbox_group_get_instance_private (self);
	self->priv->lightboxes = NULL;
	self->priv->window_group = NULL;
	self->priv->monitors = NULL;
	self->priv->monitors_changed_id = (gulong) 0;
	self->priv->updating_count = (guint) 0;
	self->priv->update_idle_id = (guint) 0;
	self->priv->open_callback = NULL;
	self->priv->open_callback_target = NULL;
	self->priv->open_callback_target_destroy_notify = NULL;
}

static void
ft_lightbox_group_finalize (GObject * obj)
{
	FtLightboxGroup * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_LIGHTBOX_GROUP, FtLightboxGroup);
	_g_hash_table_unref0 (self->priv->lightboxes);
	_g_object_unref0 (self->priv->window_group);
	_g_object_unref0 (self->priv->monitors);
	(self->priv->open_callback_target_destroy_notify == NULL) ? NULL : (self->priv->open_callback_target_destroy_notify (self->priv->open_callback_target), NULL);
	self->priv->open_callback = NULL;
	self->priv->open_callback_target = NULL;
	self->priv->open_callback_target_destroy_notify = NULL;
	G_OBJECT_CLASS (ft_lightbox_group_parent_class)->finalize (obj);
}

/**
     * Helper class for handling overlays on multiple screens.
     */
static GType
ft_lightbox_group_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtLightboxGroupClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_lightbox_group_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtLightboxGroup), 0, (GInstanceInitFunc) ft_lightbox_group_instance_init, NULL };
	GType ft_lightbox_group_type_id;
	ft_lightbox_group_type_id = g_type_register_static (G_TYPE_INITIALLY_UNOWNED, "FtLightboxGroup", &g_define_type_info, 0);
	FtLightboxGroup_private_offset = g_type_add_instance_private (ft_lightbox_group_type_id, sizeof (FtLightboxGroupPrivate));
	return ft_lightbox_group_type_id;
}

GType
ft_lightbox_group_get_type (void)
{
	static volatile gsize ft_lightbox_group_type_id__once = 0;
	if (g_once_init_enter (&ft_lightbox_group_type_id__once)) {
		GType ft_lightbox_group_type_id;
		ft_lightbox_group_type_id = ft_lightbox_group_get_type_once ();
		g_once_init_leave (&ft_lightbox_group_type_id__once, ft_lightbox_group_type_id);
	}
	return ft_lightbox_group_type_id__once;
}

static inline gpointer
ft_lightbox_get_instance_private (FtLightbox* self)
{
	return G_STRUCT_MEMBER_P (self, FtLightbox_private_offset);
}

static void
_ft_lightbox_on_monitor_notify_valid_g_object_notify (GObject* _sender,
                                                      GParamSpec* pspec,
                                                      gpointer self)
{
	ft_lightbox_on_monitor_notify_valid ((FtLightbox*) self, _sender, pspec);
}

static void
ft_lightbox_update_monitor (FtLightbox* self)
{
	GdkMonitor* monitor = NULL;
	FtMonitorConstrainedLayoutManager* layout_manager = NULL;
	AdwBin* _tmp0_;
	GtkLayoutManager* _tmp1_;
	GtkLayoutManager* _tmp2_;
	FtMonitorConstrainedLayoutManager* _tmp3_;
	GdkDisplay* display = NULL;
	GdkDisplay* _tmp4_;
	GdkDisplay* _tmp5_;
	GdkSurface* surface = NULL;
	GdkSurface* _tmp6_;
	GdkSurface* _tmp7_;
	GdkMonitor* _tmp8_ = NULL;
	GdkSurface* _tmp9_;
	GdkMonitor* surface_monitor = NULL;
	GdkMonitor* _tmp15_;
	GdkMonitor* primary_monitor = NULL;
	GdkDisplay* _tmp16_;
	GdkMonitor* _tmp17_;
	GdkMonitor* _tmp18_;
	GdkMonitor* _tmp31_;
	GdkMonitor* _tmp32_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->container;
	_tmp1_ = gtk_widget_get_layout_manager ((GtkWidget*) _tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, FT_TYPE_MONITOR_CONSTRAINED_LAYOUT_MANAGER, FtMonitorConstrainedLayoutManager));
	layout_manager = _tmp3_;
	_tmp4_ = gtk_root_get_display ((GtkRoot*) self);
	_tmp5_ = _g_object_ref0 (_tmp4_);
	display = _tmp5_;
	_tmp6_ = gtk_native_get_surface ((GtkNative*) self);
	_tmp7_ = _g_object_ref0 (_tmp6_);
	surface = _tmp7_;
	_tmp9_ = surface;
	if (_tmp9_ != NULL) {
		GdkDisplay* _tmp10_ = NULL;
		GdkDisplay* _tmp11_;
		GdkMonitor* _tmp12_ = NULL;
		_tmp11_ = display;
		_tmp10_ = _tmp11_;
		_tmp12_ = NULL;
		if (_tmp10_ != NULL) {
			GdkSurface* _tmp13_;
			GdkMonitor* _tmp14_;
			_tmp13_ = surface;
			_tmp14_ = gdk_display_get_monitor_at_surface (_tmp10_, _tmp13_);
			_tmp12_ = _tmp14_;
		}
		_tmp8_ = _tmp12_;
	} else {
		_tmp8_ = NULL;
	}
	_tmp15_ = _g_object_ref0 (_tmp8_);
	surface_monitor = _tmp15_;
	_tmp16_ = display;
	_tmp17_ = ft_get_primary_monitor (_tmp16_);
	_tmp18_ = _g_object_ref0 (_tmp17_);
	primary_monitor = _tmp18_;
	if (self->priv->_all_monitors_mode) {
		GHashTable* _tmp19_;
		GdkMonitor* _tmp20_;
		_tmp19_ = self->priv->monitors;
		_tmp20_ = primary_monitor;
		if (g_hash_table_contains (_tmp19_, _tmp20_)) {
			GdkMonitor* _tmp21_;
			FtMonitorConstrainedLayoutManager* _tmp22_;
			GdkMonitor* _tmp23_;
			_tmp21_ = primary_monitor;
			monitor = _tmp21_;
			_tmp22_ = layout_manager;
			_tmp23_ = primary_monitor;
			ft_monitor_constrained_layout_manager_set_monitor (_tmp22_, _tmp23_);
		} else {
			GdkMonitor* _tmp24_;
			FtMonitorConstrainedLayoutManager* _tmp25_;
			GdkMonitor* _tmp26_;
			_tmp24_ = surface_monitor;
			monitor = _tmp24_;
			_tmp25_ = layout_manager;
			_tmp26_ = surface_monitor;
			ft_monitor_constrained_layout_manager_set_monitor (_tmp25_, _tmp26_);
		}
		ft_lightbox_set_show_contents (self, TRUE);
	} else {
		GdkMonitor* _tmp27_;
		FtMonitorConstrainedLayoutManager* _tmp28_;
		GdkMonitor* _tmp29_;
		GdkMonitor* _tmp30_;
		_tmp27_ = surface_monitor;
		monitor = _tmp27_;
		_tmp28_ = layout_manager;
		ft_monitor_constrained_layout_manager_set_monitor (_tmp28_, NULL);
		_tmp29_ = monitor;
		_tmp30_ = primary_monitor;
		ft_lightbox_set_show_contents (self, _tmp29_ == _tmp30_);
	}
	_tmp31_ = self->priv->_monitor;
	_tmp32_ = monitor;
	if (_tmp31_ != _tmp32_) {
		GdkMonitor* _tmp33_;
		GdkMonitor* _tmp37_;
		GdkMonitor* _tmp38_;
		GdkMonitor* _tmp39_;
		_tmp33_ = self->priv->_monitor;
		if (_tmp33_ != NULL) {
			GdkMonitor* _tmp34_;
			guint _tmp35_;
			GQuark _tmp36_;
			_tmp34_ = self->priv->_monitor;
			g_signal_parse_name ("notify::valid", G_TYPE_OBJECT, &_tmp35_, &_tmp36_, TRUE);
			g_signal_handlers_disconnect_matched ((GObject*) _tmp34_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DETAIL | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp35_, _tmp36_, NULL, (GCallback) _ft_lightbox_on_monitor_notify_valid_g_object_notify, self);
		}
		_tmp37_ = monitor;
		_tmp38_ = _g_object_ref0 (_tmp37_);
		_g_object_unref0 (self->priv->_monitor);
		self->priv->_monitor = _tmp38_;
		_tmp39_ = self->priv->_monitor;
		if (_tmp39_ != NULL) {
			GdkMonitor* _tmp40_;
			_tmp40_ = self->priv->_monitor;
			g_signal_connect_object ((GObject*) _tmp40_, "notify::valid", (GCallback) _ft_lightbox_on_monitor_notify_valid_g_object_notify, self, 0);
		}
		g_object_notify ((GObject*) self, "monitor");
	}
	_g_object_unref0 (primary_monitor);
	_g_object_unref0 (surface_monitor);
	_g_object_unref0 (surface);
	_g_object_unref0 (display);
	_g_object_unref0 (layout_manager);
}

static void
__lambda61_ (FtLightbox* self,
             GdkMonitor* monitor)
{
	gboolean _tmp0_;
	gboolean _tmp1_;
	g_return_if_fail (monitor != NULL);
	g_object_get (monitor, "valid", &_tmp0_, NULL);
	_tmp1_ = _tmp0_;
	if (!_tmp1_) {
		GHashTable* _tmp2_;
		_tmp2_ = self->priv->monitors;
		g_hash_table_remove (_tmp2_, monitor);
	}
}

static void
___lambda61__gfunc (gconstpointer data,
                    gpointer self)
{
	__lambda61_ ((FtLightbox*) self, (GdkMonitor*) data);
}

static void
ft_lightbox_remove_invalid_monitors (FtLightbox* self)
{
	GHashTable* _tmp0_;
	GList* _tmp1_;
	GList* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->monitors;
	_tmp1_ = g_hash_table_get_values (_tmp0_);
	_tmp2_ = _tmp1_;
	g_list_foreach (_tmp2_, ___lambda61__gfunc, self);
	(_tmp2_ == NULL) ? NULL : (_tmp2_ = (g_list_free (_tmp2_), NULL));
}

static void
ft_lightbox_on_notify_fullscreened (FtLightbox* self,
                                    GObject* object,
                                    GParamSpec* pspec)
{
	gboolean _tmp0_;
	gboolean _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (object != NULL);
	g_return_if_fail (pspec != NULL);
	if (self->priv->closing) {
		return;
	}
	g_object_get ((GtkWindow*) self, "fullscreened", &_tmp0_, NULL);
	_tmp1_ = _tmp0_;
	if (!_tmp1_) {
		g_debug ("lightbox.vala:626: Failed to make lightbox fullscreen. Closing...");
		gtk_window_close ((GtkWindow*) self);
	}
}

static void
ft_lightbox_on_monitor_notify_valid (FtLightbox* self,
                                     GObject* object,
                                     GParamSpec* pspec)
{
	GdkMonitor* _tmp0_;
	GdkMonitor* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (object != NULL);
	g_return_if_fail (pspec != NULL);
	_tmp0_ = ft_lightbox_get_monitor (self);
	_tmp1_ = _tmp0_;
	g_object_get (_tmp1_, "valid", &_tmp2_, NULL);
	_tmp3_ = _tmp2_;
	if (!_tmp3_) {
		gtk_widget_queue_allocate ((GtkWidget*) self);
	}
}

static void
ft_lightbox_on_enter_monitor (FtLightbox* self,
                              GdkMonitor* monitor)
{
	g_return_if_fail (self != NULL);
	if (monitor != NULL) {
		GHashTable* _tmp0_;
		GdkMonitor* _tmp1_;
		_tmp0_ = self->priv->monitors;
		_tmp1_ = _g_object_ref0 (monitor);
		g_hash_table_add (_tmp0_, _tmp1_);
		gtk_widget_queue_allocate ((GtkWidget*) self);
	}
	ft_lightbox_remove_invalid_monitors (self);
}

static void
ft_lightbox_on_leave_monitor (FtLightbox* self,
                              GdkMonitor* monitor)
{
	g_return_if_fail (self != NULL);
	if (monitor != NULL) {
		GHashTable* _tmp0_;
		_tmp0_ = self->priv->monitors;
		g_hash_table_remove (_tmp0_, monitor);
		gtk_widget_queue_allocate ((GtkWidget*) self);
	}
	ft_lightbox_remove_invalid_monitors (self);
}

static gboolean
ft_lightbox_on_key_pressed (FtLightbox* self,
                            GtkEventControllerKey* event_controller,
                            guint keyval,
                            guint keycode,
                            GdkModifierType state)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (event_controller != NULL, FALSE);
	switch (keyval) {
		case GDK_KEY_Escape:
		{
			gtk_window_close ((GtkWindow*) self);
			result = TRUE;
			return result;
		}
		default:
		break;
	}
	result = FALSE;
	return result;
}

static gboolean
_ft_lightbox_on_key_pressed_gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                                  guint keyval,
                                                                  guint keycode,
                                                                  GdkModifierType state,
                                                                  gpointer self)
{
	gboolean result;
	result = ft_lightbox_on_key_pressed ((FtLightbox*) self, _sender, keyval, keycode, state);
	return result;
}

static gboolean
ft_lightbox_resolve_all_monitors_mode (FtLightbox* self,
                                       gint width,
                                       gint height)
{
	GdkMonitor* _tmp0_;
	GdkDisplay* display = NULL;
	GdkDisplay* _tmp1_;
	GdkDisplay* _tmp2_;
	GdkRectangle display_geometry = {0};
	GdkDisplay* _tmp3_;
	GdkRectangle _tmp4_ = {0};
	GListModel* monitors = NULL;
	GdkDisplay* _tmp5_;
	GListModel* _tmp6_;
	GListModel* _tmp7_;
	guint monitors_count = 0U;
	GListModel* _tmp8_;
	gboolean _tmp20_ = FALSE;
	GdkRectangle _tmp21_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->_monitor_request;
	if (_tmp0_ != NULL) {
		result = FALSE;
		return result;
	}
	_tmp1_ = gtk_root_get_display ((GtkRoot*) self);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	display = _tmp2_;
	_tmp3_ = display;
	ft_get_display_geometry (_tmp3_, &_tmp4_);
	display_geometry = _tmp4_;
	_tmp5_ = display;
	_tmp6_ = gdk_display_get_monitors (_tmp5_);
	_tmp7_ = _g_object_ref0 (_tmp6_);
	monitors = _tmp7_;
	_tmp8_ = monitors;
	monitors_count = g_list_model_get_n_items (_tmp8_);
	if (monitors_count == ((guint) 0)) {
		result = FALSE;
		_g_object_unref0 (monitors);
		_g_object_unref0 (display);
		return result;
	}
	if (monitors_count == ((guint) 1)) {
		result = TRUE;
		_g_object_unref0 (monitors);
		_g_object_unref0 (display);
		return result;
	}
	{
		gint index = 0;
		index = 0;
		{
			gboolean _tmp9_ = FALSE;
			_tmp9_ = TRUE;
			while (TRUE) {
				GListModel* _tmp11_;
				GdkMonitor* monitor = NULL;
				GListModel* _tmp12_;
				GObject* _tmp13_;
				gboolean _tmp14_ = FALSE;
				GdkMonitor* _tmp15_;
				gboolean _tmp16_;
				gboolean _tmp17_;
				if (!_tmp9_) {
					gint _tmp10_;
					_tmp10_ = index;
					index = _tmp10_ + 1;
				}
				_tmp9_ = FALSE;
				_tmp11_ = monitors;
				if (!(((guint) index) < g_list_model_get_n_items (_tmp11_))) {
					break;
				}
				_tmp12_ = monitors;
				_tmp13_ = g_list_model_get_item (_tmp12_, (guint) index);
				monitor = G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, gdk_monitor_get_type (), GdkMonitor);
				_tmp15_ = monitor;
				g_object_get (_tmp15_, "valid", &_tmp16_, NULL);
				_tmp17_ = _tmp16_;
				if (_tmp17_) {
					GHashTable* _tmp18_;
					GdkMonitor* _tmp19_;
					_tmp18_ = self->priv->monitors;
					_tmp19_ = monitor;
					_tmp14_ = !g_hash_table_contains (_tmp18_, _tmp19_);
				} else {
					_tmp14_ = FALSE;
				}
				if (_tmp14_) {
					result = FALSE;
					_g_object_unref0 (monitor);
					_g_object_unref0 (monitors);
					_g_object_unref0 (display);
					return result;
				}
				_g_object_unref0 (monitor);
			}
		}
	}
	_tmp21_ = display_geometry;
	if (width >= _tmp21_.width) {
		GdkRectangle _tmp22_;
		_tmp22_ = display_geometry;
		_tmp20_ = height >= _tmp22_.height;
	} else {
		_tmp20_ = FALSE;
	}
	result = _tmp20_;
	_g_object_unref0 (monitors);
	_g_object_unref0 (display);
	return result;
}

/**
         * We don't have access to compositor coordinates.
         */
static void
ft_lightbox_update_all_monitors_mode (FtLightbox* self,
                                      gint width,
                                      gint height)
{
	gboolean all_monitors_mode = FALSE;
	g_return_if_fail (self != NULL);
	all_monitors_mode = ft_lightbox_resolve_all_monitors_mode (self, width, height);
	if (self->priv->_all_monitors_mode != all_monitors_mode) {
		self->priv->_all_monitors_mode = all_monitors_mode;
		g_object_notify ((GObject*) self, "all-monitors-mode");
	}
}

static GtkSizeRequestMode
ft_lightbox_real_get_request_mode (GtkWidget* base)
{
	FtLightbox * self;
	GtkSizeRequestMode result;
	self = (FtLightbox*) base;
	result = GTK_SIZE_REQUEST_CONSTANT_SIZE;
	return result;
}

static void
ft_lightbox_real_measure (GtkWidget* base,
                          GtkOrientation orientation,
                          gint for_size,
                          gint* minimum,
                          gint* natural,
                          gint* minimum_baseline,
                          gint* natural_baseline)
{
	FtLightbox * self;
	gint _vala_minimum = 0;
	gint _vala_natural = 0;
	gint _vala_minimum_baseline = 0;
	gint _vala_natural_baseline = 0;
	GdkMonitor* _tmp0_ = NULL;
	GdkMonitor* _tmp1_;
	GdkMonitor* monitor = NULL;
	GdkMonitor* _tmp4_;
	gboolean _tmp5_ = FALSE;
	GdkMonitor* _tmp6_;
	self = (FtLightbox*) base;
	_tmp1_ = self->priv->_monitor;
	if (_tmp1_ != NULL) {
		GdkMonitor* _tmp2_;
		_tmp2_ = self->priv->_monitor;
		_tmp0_ = _tmp2_;
	} else {
		GdkMonitor* _tmp3_;
		_tmp3_ = self->priv->_monitor_request;
		_tmp0_ = _tmp3_;
	}
	_tmp4_ = _g_object_ref0 (_tmp0_);
	monitor = _tmp4_;
	_tmp6_ = self->priv->_monitor_request;
	if (_tmp6_ == NULL) {
		GHashTable* _tmp7_;
		guint _tmp8_;
		guint _tmp9_;
		_tmp7_ = self->priv->monitors;
		_tmp8_ = g_hash_table_size (_tmp7_);
		_tmp9_ = _tmp8_;
		_tmp5_ = _tmp9_ > ((guint) 1);
	} else {
		_tmp5_ = FALSE;
	}
	if (_tmp5_) {
		GdkRectangle display_geometry = {0};
		GdkDisplay* _tmp10_;
		GdkRectangle _tmp11_ = {0};
		gint _tmp12_ = 0;
		_tmp10_ = gtk_root_get_display ((GtkRoot*) self);
		ft_get_display_geometry (_tmp10_, &_tmp11_);
		display_geometry = _tmp11_;
		if (orientation == GTK_ORIENTATION_HORIZONTAL) {
			GdkRectangle _tmp13_;
			_tmp13_ = display_geometry;
			_tmp12_ = _tmp13_.width;
		} else {
			GdkRectangle _tmp14_;
			_tmp14_ = display_geometry;
			_tmp12_ = _tmp14_.height;
		}
		_vala_natural = _tmp12_;
		_vala_minimum = _vala_natural;
	} else {
		gboolean _tmp15_ = FALSE;
		GdkMonitor* _tmp16_;
		_tmp16_ = monitor;
		if (_tmp16_ != NULL) {
			GHashTable* _tmp17_;
			guint _tmp18_;
			guint _tmp19_;
			_tmp17_ = self->priv->monitors;
			_tmp18_ = g_hash_table_size (_tmp17_);
			_tmp19_ = _tmp18_;
			_tmp15_ = _tmp19_ == ((guint) 1);
		} else {
			_tmp15_ = FALSE;
		}
		if (_tmp15_) {
			GdkRectangle monitor_geometry = {0};
			GdkMonitor* _tmp20_;
			GdkRectangle _tmp21_ = {0};
			GdkRectangle _tmp22_;
			gint _tmp23_ = 0;
			_tmp20_ = monitor;
			gdk_monitor_get_geometry (_tmp20_, &_tmp21_);
			_tmp22_ = _tmp21_;
			monitor_geometry = _tmp22_;
			if (orientation == GTK_ORIENTATION_HORIZONTAL) {
				GdkRectangle _tmp24_;
				_tmp24_ = monitor_geometry;
				_tmp23_ = _tmp24_.width;
			} else {
				GdkRectangle _tmp25_;
				_tmp25_ = monitor_geometry;
				_tmp23_ = _tmp25_.height;
			}
			_vala_natural = _tmp23_;
			_vala_minimum = _vala_natural;
		} else {
			gint _tmp26_ = 0;
			gint _tmp27_ = 0;
			gint _tmp28_ = 0;
			gint _tmp29_ = 0;
			GTK_WIDGET_CLASS (ft_lightbox_parent_class)->measure ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_window_get_type (), GtkWindow), orientation, for_size, &_tmp26_, &_tmp27_, &_tmp28_, &_tmp29_);
			_vala_minimum = _tmp26_;
			_vala_natural = _tmp27_;
			_vala_minimum_baseline = _tmp28_;
			_vala_natural_baseline = _tmp29_;
		}
	}
	_vala_minimum_baseline = -1;
	_vala_natural_baseline = -1;
	_g_object_unref0 (monitor);
	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_lightbox_real_size_allocate (GtkWidget* base,
                                gint width,
                                gint height,
                                gint baseline)
{
	FtLightbox * self;
	GHashTable* _tmp0_;
	guint _tmp1_;
	guint _tmp2_;
	self = (FtLightbox*) base;
	_tmp0_ = self->priv->monitors;
	_tmp1_ = g_hash_table_size (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ > ((guint) 0)) {
		GdkToplevel* toplevel = NULL;
		GdkSurface* _tmp3_;
		GdkToplevel* _tmp4_;
		ft_lightbox_update_all_monitors_mode (self, width, height);
		ft_lightbox_update_monitor (self);
		_tmp3_ = gtk_native_get_surface ((GtkNative*) self);
		_tmp4_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, gdk_toplevel_get_type (), GdkToplevel));
		toplevel = _tmp4_;
		if (self->priv->_all_monitors_mode) {
			GdkToplevel* _tmp5_;
			_tmp5_ = toplevel;
			g_object_set (_tmp5_, "fullscreen-mode", GDK_FULLSCREEN_ON_ALL_MONITORS, NULL);
			gtk_window_fullscreen ((GtkWindow*) self);
		} else {
			GdkMonitor* _tmp6_;
			_tmp6_ = self->priv->_monitor;
			if (_tmp6_ != NULL) {
				GdkToplevel* _tmp7_;
				GdkMonitor* _tmp8_;
				_tmp7_ = toplevel;
				g_object_set (_tmp7_, "fullscreen-mode", GDK_FULLSCREEN_ON_CURRENT_MONITOR, NULL);
				_tmp8_ = self->priv->_monitor;
				gtk_window_fullscreen_on_monitor ((GtkWindow*) self, _tmp8_);
			} else {
				GdkMonitor* _tmp9_;
				_tmp9_ = self->priv->_monitor_request;
				if (_tmp9_ != NULL) {
					GdkToplevel* _tmp10_;
					GdkMonitor* _tmp11_;
					_tmp10_ = toplevel;
					g_object_set (_tmp10_, "fullscreen-mode", GDK_FULLSCREEN_ON_CURRENT_MONITOR, NULL);
					_tmp11_ = self->priv->_monitor_request;
					gtk_window_fullscreen_on_monitor ((GtkWindow*) self, _tmp11_);
				} else {
					GdkToplevel* _tmp12_;
					_tmp12_ = toplevel;
					g_object_set (_tmp12_, "fullscreen-mode", GDK_FULLSCREEN_ON_CURRENT_MONITOR, NULL);
					gtk_window_fullscreen ((GtkWindow*) self);
				}
			}
		}
		_g_object_unref0 (toplevel);
	}
	GTK_WIDGET_CLASS (ft_lightbox_parent_class)->size_allocate ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_window_get_type (), GtkWindow), width, height, baseline);
}

static void
_ft_lightbox_on_enter_monitor_gdk_surface_enter_monitor (GdkSurface* _sender,
                                                         GdkMonitor* monitor,
                                                         gpointer self)
{
	ft_lightbox_on_enter_monitor ((FtLightbox*) self, monitor);
}

static void
_ft_lightbox_on_leave_monitor_gdk_surface_leave_monitor (GdkSurface* _sender,
                                                         GdkMonitor* monitor,
                                                         gpointer self)
{
	ft_lightbox_on_leave_monitor ((FtLightbox*) self, monitor);
}

static void
ft_lightbox_real_map (GtkWidget* base)
{
	FtLightbox * self;
	GdkToplevel* toplevel = NULL;
	GdkSurface* _tmp0_;
	GdkToplevel* _tmp1_;
	GdkToplevel* _tmp2_;
	GdkToplevel* _tmp3_;
	GdkMonitor* _tmp4_;
	self = (FtLightbox*) base;
	_tmp0_ = gtk_native_get_surface ((GtkNative*) self);
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gdk_toplevel_get_type (), GdkToplevel));
	toplevel = _tmp1_;
	_tmp2_ = toplevel;
	g_signal_connect_object ((GdkSurface*) _tmp2_, "enter-monitor", (GCallback) _ft_lightbox_on_enter_monitor_gdk_surface_enter_monitor, self, 0);
	_tmp3_ = toplevel;
	g_signal_connect_object ((GdkSurface*) _tmp3_, "leave-monitor", (GCallback) _ft_lightbox_on_leave_monitor_gdk_surface_leave_monitor, self, 0);
	_tmp4_ = self->priv->_monitor_request;
	if (_tmp4_ == NULL) {
		GdkToplevel* _tmp5_;
		_tmp5_ = toplevel;
		g_object_set (_tmp5_, "fullscreen-mode", GDK_FULLSCREEN_ON_ALL_MONITORS, NULL);
		gtk_window_fullscreen ((GtkWindow*) self);
	} else {
		GdkMonitor* _tmp6_;
		_tmp6_ = self->priv->_monitor_request;
		gtk_window_fullscreen_on_monitor ((GtkWindow*) self, _tmp6_);
	}
	GTK_WIDGET_CLASS (ft_lightbox_parent_class)->map ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_window_get_type (), GtkWindow));
	_g_object_unref0 (toplevel);
}

static void
ft_lightbox_real_unmap (GtkWidget* base)
{
	FtLightbox * self;
	GdkToplevel* toplevel = NULL;
	GdkSurface* _tmp0_;
	GdkToplevel* _tmp1_;
	guint _tmp2_;
	guint _tmp3_;
	self = (FtLightbox*) base;
	_tmp0_ = gtk_native_get_surface ((GtkNative*) self);
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gdk_toplevel_get_type (), GdkToplevel));
	toplevel = _tmp1_;
	g_signal_parse_name ("enter-monitor", gdk_surface_get_type (), &_tmp2_, NULL, FALSE);
	g_signal_handlers_disconnect_matched ((GdkSurface*) toplevel, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp2_, 0, NULL, (GCallback) _ft_lightbox_on_enter_monitor_gdk_surface_enter_monitor, self);
	g_signal_parse_name ("leave-monitor", gdk_surface_get_type (), &_tmp3_, NULL, FALSE);
	g_signal_handlers_disconnect_matched ((GdkSurface*) toplevel, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp3_, 0, NULL, (GCallback) _ft_lightbox_on_leave_monitor_gdk_surface_leave_monitor, self);
	GTK_WIDGET_CLASS (ft_lightbox_parent_class)->unmap ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_window_get_type (), GtkWindow));
	_g_object_unref0 (toplevel);
}

static void
_ft_lightbox_on_notify_fullscreened_g_object_notify (GObject* _sender,
                                                     GParamSpec* pspec,
                                                     gpointer self)
{
	ft_lightbox_on_notify_fullscreened ((FtLightbox*) self, _sender, pspec);
}

static void
ft_lightbox_real_dispose (GObject* base)
{
	FtLightbox * self;
	GdkMonitor* _tmp0_;
	GHashTable* _tmp4_;
	guint _tmp6_;
	GQuark _tmp7_;
	self = (FtLightbox*) base;
	_tmp0_ = self->priv->_monitor;
	if (_tmp0_ != NULL) {
		GdkMonitor* _tmp1_;
		guint _tmp2_;
		GQuark _tmp3_;
		_tmp1_ = self->priv->_monitor;
		g_signal_parse_name ("notify::valid", G_TYPE_OBJECT, &_tmp2_, &_tmp3_, TRUE);
		g_signal_handlers_disconnect_matched ((GObject*) _tmp1_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DETAIL | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp2_, _tmp3_, NULL, (GCallback) _ft_lightbox_on_monitor_notify_valid_g_object_notify, self);
	}
	_tmp4_ = self->priv->monitors;
	if (_tmp4_ != NULL) {
		GHashTable* _tmp5_;
		_tmp5_ = self->priv->monitors;
		g_hash_table_remove_all (_tmp5_);
		_g_hash_table_unref0 (self->priv->monitors);
		self->priv->monitors = NULL;
	}
	g_signal_parse_name ("notify::fullscreened", G_TYPE_OBJECT, &_tmp6_, &_tmp7_, TRUE);
	g_signal_handlers_disconnect_matched ((GObject*) self, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DETAIL | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp6_, _tmp7_, NULL, (GCallback) _ft_lightbox_on_notify_fullscreened_g_object_notify, self);
	_g_object_unref0 (self->priv->_monitor_request);
	self->priv->_monitor_request = NULL;
	_g_object_unref0 (self->priv->_monitor);
	self->priv->_monitor = NULL;
	G_OBJECT_CLASS (ft_lightbox_parent_class)->dispose ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_window_get_type (), GtkWindow));
}

FtLightbox*
ft_lightbox_construct (GType object_type)
{
	FtLightbox * self = NULL;
	self = (FtLightbox*) g_object_new (object_type, NULL);
	return self;
}

FtLightbox*
ft_lightbox_new (void)
{
	return ft_lightbox_construct (FT_TYPE_LIGHTBOX);
}

GdkMonitor*
ft_lightbox_get_monitor_request (FtLightbox* self)
{
	GdkMonitor* result;
	GdkMonitor* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_monitor_request;
	result = _tmp0_;
	return result;
}

void
ft_lightbox_set_monitor_request (FtLightbox* self,
                                 GdkMonitor* value)
{
	GdkMonitor* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_monitor_request);
	self->priv->_monitor_request = _tmp0_;
	g_object_notify_by_pspec ((GObject *) self, ft_lightbox_properties[FT_LIGHTBOX_MONITOR_REQUEST_PROPERTY]);
}

GdkMonitor*
ft_lightbox_get_monitor (FtLightbox* self)
{
	GdkMonitor* result;
	GdkMonitor* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_monitor;
	result = _tmp0_;
	return result;
}

GtkWidget*
ft_lightbox_get_contents (FtLightbox* self)
{
	GtkWidget* result;
	AdwBin* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->container;
	_tmp1_ = adw_bin_get_child (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

void
ft_lightbox_set_contents (FtLightbox* self,
                          GtkWidget* value)
{
	GtkWidget* previous_child = NULL;
	AdwBin* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp3_;
	GtkWidget* _tmp4_;
	AdwBin* _tmp6_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->container;
	_tmp1_ = adw_bin_get_child (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	previous_child = _tmp3_;
	_tmp4_ = previous_child;
	if (_tmp4_ != NULL) {
		GtkWidget* _tmp5_;
		_tmp5_ = previous_child;
		gtk_widget_remove_css_class (_tmp5_, "contents");
	}
	_tmp6_ = self->priv->container;
	adw_bin_set_child (_tmp6_, value);
	if (value != NULL) {
		gtk_widget_add_css_class (value, "contents");
	}
	_g_object_unref0 (previous_child);
	g_object_notify_by_pspec ((GObject *) self, ft_lightbox_properties[FT_LIGHTBOX_CONTENTS_PROPERTY]);
}

gboolean
ft_lightbox_get_all_monitors_mode (FtLightbox* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_all_monitors_mode;
	return result;
}

gboolean
ft_lightbox_get_show_contents (FtLightbox* self)
{
	gboolean result;
	AdwBin* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->container;
	_tmp1_ = gtk_widget_get_visible ((GtkWidget*) _tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

void
ft_lightbox_set_show_contents (FtLightbox* self,
                               gboolean value)
{
	AdwBin* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->container;
	gtk_widget_set_visible ((GtkWidget*) _tmp0_, value);
	g_object_notify_by_pspec ((GObject *) self, ft_lightbox_properties[FT_LIGHTBOX_SHOW_CONTENTS_PROPERTY]);
}

static GObject *
ft_lightbox_constructor (GType type,
                         guint n_construct_properties,
                         GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	FtLightbox * self;
	guint _tmp0_;
	GHashFunc _tmp1_;
	GEqualFunc _tmp2_;
	GHashTable* _tmp3_;
	parent_class = G_OBJECT_CLASS (ft_lightbox_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_LIGHTBOX, FtLightbox);
	self->id = ft_lightbox_next_id;
	_tmp0_ = ft_lightbox_next_id;
	ft_lightbox_next_id = _tmp0_ + 1;
	_tmp1_ = g_direct_hash;
	_tmp2_ = g_direct_equal;
	_tmp3_ = g_hash_table_new_full (_tmp1_, _tmp2_, NULL, _g_object_unref0_);
	_g_hash_table_unref0 (self->priv->monitors);
	self->priv->monitors = _tmp3_;
	g_signal_connect_object ((GObject*) self, "notify::fullscreened", (GCallback) _ft_lightbox_on_notify_fullscreened_g_object_notify, self, 0);
	return obj;
}

static void
ft_lightbox_class_init (FtLightboxClass * klass,
                        gpointer klass_data)
{
	ft_lightbox_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FtLightbox_private_offset);
	((GtkWidgetClass *) klass)->get_request_mode = (GtkSizeRequestMode (*) (GtkWidget*)) ft_lightbox_real_get_request_mode;
	((GtkWidgetClass *) klass)->measure = (void (*) (GtkWidget*, GtkOrientation, gint, gint*, gint*, gint*, gint*)) ft_lightbox_real_measure;
	((GtkWidgetClass *) klass)->size_allocate = (void (*) (GtkWidget*, gint, gint, gint)) ft_lightbox_real_size_allocate;
	((GtkWidgetClass *) klass)->map = (void (*) (GtkWidget*)) ft_lightbox_real_map;
	((GtkWidgetClass *) klass)->unmap = (void (*) (GtkWidget*)) ft_lightbox_real_unmap;
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) ft_lightbox_real_dispose;
	G_OBJECT_CLASS (klass)->get_property = _vala_ft_lightbox_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_ft_lightbox_set_property;
	G_OBJECT_CLASS (klass)->constructor = ft_lightbox_constructor;
	G_OBJECT_CLASS (klass)->finalize = ft_lightbox_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_LIGHTBOX_MONITOR_REQUEST_PROPERTY, ft_lightbox_properties[FT_LIGHTBOX_MONITOR_REQUEST_PROPERTY] = g_param_spec_object ("monitor-request", "monitor-request", "monitor-request", gdk_monitor_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_LIGHTBOX_MONITOR_PROPERTY, ft_lightbox_properties[FT_LIGHTBOX_MONITOR_PROPERTY] = g_param_spec_object ("monitor", "monitor", "monitor", gdk_monitor_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_LIGHTBOX_CONTENTS_PROPERTY, ft_lightbox_properties[FT_LIGHTBOX_CONTENTS_PROPERTY] = g_param_spec_object ("contents", "contents", "contents", gtk_widget_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_LIGHTBOX_ALL_MONITORS_MODE_PROPERTY, ft_lightbox_properties[FT_LIGHTBOX_ALL_MONITORS_MODE_PROPERTY] = g_param_spec_boolean ("all-monitors-mode", "all-monitors-mode", "all-monitors-mode", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_LIGHTBOX_SHOW_CONTENTS_PROPERTY, ft_lightbox_properties[FT_LIGHTBOX_SHOW_CONTENTS_PROPERTY] = g_param_spec_boolean ("show-contents", "show-contents", "show-contents", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/io/github/focustimerhq/FocusTimer/ui/overlays/lightbox.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "container", FALSE, FtLightbox_private_offset + G_STRUCT_OFFSET (FtLightboxPrivate, container));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_key_pressed", G_CALLBACK(_ft_lightbox_on_key_pressed_gtk_event_controller_key_key_pressed));
	gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (klass), "lightbox");
	gtk_window_set_auto_startup_notification (FALSE);
}

static void
ft_lightbox_gtk_buildable_interface_init (GtkBuildableIface * iface,
                                          gpointer iface_data)
{
	ft_lightbox_gtk_buildable_parent_iface = g_type_interface_peek_parent (iface);
}

static void
ft_lightbox_instance_init (FtLightbox * self,
                           gpointer klass)
{
	self->priv = ft_lightbox_get_instance_private (self);
	self->priv->_monitor_request = NULL;
	self->priv->_monitor = NULL;
	self->priv->monitors = NULL;
	self->priv->_all_monitors_mode = FALSE;
	self->priv->closing = FALSE;
	self->id = (guint) 0;
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
ft_lightbox_finalize (GObject * obj)
{
	FtLightbox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_LIGHTBOX, FtLightbox);
	_g_object_unref0 (self->priv->_monitor_request);
	_g_object_unref0 (self->priv->_monitor);
	_g_hash_table_unref0 (self->priv->monitors);
	G_OBJECT_CLASS (ft_lightbox_parent_class)->finalize (obj);
}

static GType
ft_lightbox_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtLightboxClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_lightbox_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtLightbox), 0, (GInstanceInitFunc) ft_lightbox_instance_init, NULL };
	static const GInterfaceInfo gtk_buildable_info = { (GInterfaceInitFunc) ft_lightbox_gtk_buildable_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType ft_lightbox_type_id;
	ft_lightbox_type_id = g_type_register_static (gtk_window_get_type (), "FtLightbox", &g_define_type_info, 0);
	g_type_add_interface_static (ft_lightbox_type_id, gtk_buildable_get_type (), &gtk_buildable_info);
	FtLightbox_private_offset = g_type_add_instance_private (ft_lightbox_type_id, sizeof (FtLightboxPrivate));
	return ft_lightbox_type_id;
}

GType
ft_lightbox_get_type (void)
{
	static volatile gsize ft_lightbox_type_id__once = 0;
	if (g_once_init_enter (&ft_lightbox_type_id__once)) {
		GType ft_lightbox_type_id;
		ft_lightbox_type_id = ft_lightbox_get_type_once ();
		g_once_init_leave (&ft_lightbox_type_id__once, ft_lightbox_type_id);
	}
	return ft_lightbox_type_id__once;
}

static void
_vala_ft_lightbox_get_property (GObject * object,
                                guint property_id,
                                GValue * value,
                                GParamSpec * pspec)
{
	FtLightbox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_LIGHTBOX, FtLightbox);
	switch (property_id) {
		case FT_LIGHTBOX_MONITOR_REQUEST_PROPERTY:
		g_value_set_object (value, ft_lightbox_get_monitor_request (self));
		break;
		case FT_LIGHTBOX_MONITOR_PROPERTY:
		g_value_set_object (value, ft_lightbox_get_monitor (self));
		break;
		case FT_LIGHTBOX_CONTENTS_PROPERTY:
		g_value_set_object (value, ft_lightbox_get_contents (self));
		break;
		case FT_LIGHTBOX_ALL_MONITORS_MODE_PROPERTY:
		g_value_set_boolean (value, ft_lightbox_get_all_monitors_mode (self));
		break;
		case FT_LIGHTBOX_SHOW_CONTENTS_PROPERTY:
		g_value_set_boolean (value, ft_lightbox_get_show_contents (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_ft_lightbox_set_property (GObject * object,
                                guint property_id,
                                const GValue * value,
                                GParamSpec * pspec)
{
	FtLightbox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_LIGHTBOX, FtLightbox);
	switch (property_id) {
		case FT_LIGHTBOX_MONITOR_REQUEST_PROPERTY:
		ft_lightbox_set_monitor_request (self, g_value_get_object (value));
		break;
		case FT_LIGHTBOX_CONTENTS_PROPERTY:
		ft_lightbox_set_contents (self, g_value_get_object (value));
		break;
		case FT_LIGHTBOX_SHOW_CONTENTS_PROPERTY:
		ft_lightbox_set_show_contents (self, g_value_get_boolean (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;
}

