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

#include <glib-object.h>
#include "protonplus_core.h"
#include <glib.h>
#include <gtk/gtk.h>
#include <gee.h>
#include <adwaita.h>
#include <gio/gio.h>
#include "config.h"
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.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 PROTON_PLUS_WIDGETS_TYPE_GTK_CONTROLLER_HOST_ADAPTER (proton_plus_widgets_gtk_controller_host_adapter_get_type ())
#define PROTON_PLUS_WIDGETS_GTK_CONTROLLER_HOST_ADAPTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PROTON_PLUS_WIDGETS_TYPE_GTK_CONTROLLER_HOST_ADAPTER, ProtonPlusWidgetsGtkControllerHostAdapter))
#define PROTON_PLUS_WIDGETS_GTK_CONTROLLER_HOST_ADAPTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PROTON_PLUS_WIDGETS_TYPE_GTK_CONTROLLER_HOST_ADAPTER, ProtonPlusWidgetsGtkControllerHostAdapterClass))
#define PROTON_PLUS_WIDGETS_IS_GTK_CONTROLLER_HOST_ADAPTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PROTON_PLUS_WIDGETS_TYPE_GTK_CONTROLLER_HOST_ADAPTER))
#define PROTON_PLUS_WIDGETS_IS_GTK_CONTROLLER_HOST_ADAPTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PROTON_PLUS_WIDGETS_TYPE_GTK_CONTROLLER_HOST_ADAPTER))
#define PROTON_PLUS_WIDGETS_GTK_CONTROLLER_HOST_ADAPTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PROTON_PLUS_WIDGETS_TYPE_GTK_CONTROLLER_HOST_ADAPTER, ProtonPlusWidgetsGtkControllerHostAdapterClass))

typedef struct _ProtonPlusWidgetsGtkControllerHostAdapter ProtonPlusWidgetsGtkControllerHostAdapter;
typedef struct _ProtonPlusWidgetsGtkControllerHostAdapterClass ProtonPlusWidgetsGtkControllerHostAdapterClass;
typedef struct _ProtonPlusWidgetsGtkControllerHostAdapterPrivate ProtonPlusWidgetsGtkControllerHostAdapterPrivate;
enum  {
	PROTON_PLUS_WIDGETS_GTK_CONTROLLER_HOST_ADAPTER_0_PROPERTY,
	PROTON_PLUS_WIDGETS_GTK_CONTROLLER_HOST_ADAPTER_NUM_PROPERTIES
};
static GParamSpec* proton_plus_widgets_gtk_controller_host_adapter_properties[PROTON_PLUS_WIDGETS_GTK_CONTROLLER_HOST_ADAPTER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define PROTON_PLUS_WIDGETS_TYPE_CONTROLLER_POPOVER_REGISTRATION (proton_plus_widgets_controller_popover_registration_get_type ())
#define PROTON_PLUS_WIDGETS_CONTROLLER_POPOVER_REGISTRATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PROTON_PLUS_WIDGETS_TYPE_CONTROLLER_POPOVER_REGISTRATION, ProtonPlusWidgetsControllerPopoverRegistration))
#define PROTON_PLUS_WIDGETS_CONTROLLER_POPOVER_REGISTRATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PROTON_PLUS_WIDGETS_TYPE_CONTROLLER_POPOVER_REGISTRATION, ProtonPlusWidgetsControllerPopoverRegistrationClass))
#define PROTON_PLUS_WIDGETS_IS_CONTROLLER_POPOVER_REGISTRATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PROTON_PLUS_WIDGETS_TYPE_CONTROLLER_POPOVER_REGISTRATION))
#define PROTON_PLUS_WIDGETS_IS_CONTROLLER_POPOVER_REGISTRATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PROTON_PLUS_WIDGETS_TYPE_CONTROLLER_POPOVER_REGISTRATION))
#define PROTON_PLUS_WIDGETS_CONTROLLER_POPOVER_REGISTRATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PROTON_PLUS_WIDGETS_TYPE_CONTROLLER_POPOVER_REGISTRATION, ProtonPlusWidgetsControllerPopoverRegistrationClass))

typedef struct _ProtonPlusWidgetsControllerPopoverRegistration ProtonPlusWidgetsControllerPopoverRegistration;
typedef struct _ProtonPlusWidgetsControllerPopoverRegistrationClass ProtonPlusWidgetsControllerPopoverRegistrationClass;
typedef struct _ProtonPlusWidgetsControllerPopoverRegistrationPrivate ProtonPlusWidgetsControllerPopoverRegistrationPrivate;
enum  {
	PROTON_PLUS_WIDGETS_CONTROLLER_POPOVER_REGISTRATION_0_PROPERTY,
	PROTON_PLUS_WIDGETS_CONTROLLER_POPOVER_REGISTRATION_NUM_PROPERTIES
};
static GParamSpec* proton_plus_widgets_controller_popover_registration_properties[PROTON_PLUS_WIDGETS_CONTROLLER_POPOVER_REGISTRATION_NUM_PROPERTIES];
enum  {
	PROTON_PLUS_WIDGETS_WINDOW_0_PROPERTY,
	PROTON_PLUS_WIDGETS_WINDOW_LAUNCHERS_PROPERTY,
	PROTON_PLUS_WIDGETS_WINDOW_MAIN_BOX_PROPERTY,
	PROTON_PLUS_WIDGETS_WINDOW_NUM_PROPERTIES
};
static GParamSpec* proton_plus_widgets_window_properties[PROTON_PLUS_WIDGETS_WINDOW_NUM_PROPERTIES];
typedef struct _Block1Data Block1Data;
#define _g_free0(var) (var = (g_free (var), NULL))

struct _ProtonPlusWidgetsGtkControllerHostAdapter {
	GObject parent_instance;
	ProtonPlusWidgetsGtkControllerHostAdapterPrivate * priv;
};

struct _ProtonPlusWidgetsGtkControllerHostAdapterClass {
	GObjectClass parent_class;
};

struct _ProtonPlusWidgetsControllerPopoverRegistration {
	GObject parent_instance;
	ProtonPlusWidgetsControllerPopoverRegistrationPrivate * priv;
};

struct _ProtonPlusWidgetsControllerPopoverRegistrationClass {
	GObjectClass parent_class;
};

struct _ProtonPlusWidgetsControllerPopoverRegistrationPrivate {
	GtkPopover* popover;
	GtkWidget* opener;
	GtkWidget* initial_focus;
	gulong visible_handler;
	gulong map_handler;
};

struct _ProtonPlusWidgetsWindowPrivate {
	GeeLinkedList* _launchers;
	ProtonPlusUtilsControllerManager* _controller_manager;
	ProtonPlusWidgetsHeaderBox* _header_box;
	ProtonPlusWidgetsLoadingBox* _loading_box;
	ProtonPlusWidgetsMainBox* _main_box;
	AdwToolbarView* _toolbar_view;
	ProtonPlusWidgetsControllerHintBar* _controller_hint_bar;
	gulong controller_presentation_handler;
	ProtonPlusServicesSteamRestartManager* restart_manager;
	ProtonPlusServicesSteamRestartOrchestrator* restart_orchestrator;
};

struct _Block1Data {
	int _ref_count_;
	ProtonPlusWidgetsWindow* self;
	AdwAlertDialog* alert_dialog;
};

static gpointer proton_plus_widgets_gtk_controller_host_adapter_parent_class = NULL;
static ProtonPlusUtilsControllerHostAdapterIface * proton_plus_widgets_gtk_controller_host_adapter_proton_plus_utils_controller_host_adapter_parent_iface = NULL;
static gint ProtonPlusWidgetsControllerPopoverRegistration_private_offset;
static gpointer proton_plus_widgets_controller_popover_registration_parent_class = NULL;
static gint ProtonPlusWidgetsWindow_private_offset;
static gpointer proton_plus_widgets_window_parent_class = NULL;

VALA_EXTERN GType proton_plus_widgets_gtk_controller_host_adapter_get_type (void) G_GNUC_CONST ;
static gboolean proton_plus_widgets_gtk_controller_host_adapter_real_is_controller_window (ProtonPlusUtilsControllerHostAdapter* base,
                                                                                    GObject* candidate);
static GObject* proton_plus_widgets_gtk_controller_host_adapter_real_get_root (ProtonPlusUtilsControllerHostAdapter* base,
                                                                        GObject* candidate);
VALA_EXTERN ProtonPlusWidgetsGtkControllerHostAdapter* proton_plus_widgets_gtk_controller_host_adapter_new (void);
VALA_EXTERN ProtonPlusWidgetsGtkControllerHostAdapter* proton_plus_widgets_gtk_controller_host_adapter_construct (GType object_type);
static GType proton_plus_widgets_gtk_controller_host_adapter_get_type_once (void);
VALA_EXTERN GType proton_plus_widgets_controller_popover_registration_get_type (void) G_GNUC_CONST ;
VALA_EXTERN ProtonPlusWidgetsControllerPopoverRegistration* proton_plus_widgets_controller_popover_registration_new (GtkPopover* popover,
                                                                                                         GtkWidget* opener,
                                                                                                         GtkWidget* initial_focus);
VALA_EXTERN ProtonPlusWidgetsControllerPopoverRegistration* proton_plus_widgets_controller_popover_registration_construct (GType object_type,
                                                                                                               GtkPopover* popover,
                                                                                                               GtkWidget* opener,
                                                                                                               GtkWidget* initial_focus);
VALA_EXTERN void proton_plus_widgets_controller_popover_registration_start (ProtonPlusWidgetsControllerPopoverRegistration* self);
static void proton_plus_widgets_controller_popover_registration_try_register (ProtonPlusWidgetsControllerPopoverRegistration* self);
static void _proton_plus_widgets_controller_popover_registration_try_register_g_object_notify (GObject* _sender,
                                                                                        GParamSpec* pspec,
                                                                                        gpointer self);
static void _proton_plus_widgets_controller_popover_registration_try_register_gtk_widget_map (GtkWidget* _sender,
                                                                                       gpointer self);
VALA_EXTERN ProtonPlusWidgetsWindow* proton_plus_widgets_window_resolve_controller_window (GtkWidget* parent);
VALA_EXTERN void proton_plus_widgets_window_register_controller_popover (ProtonPlusWidgetsWindow* self,
                                                             GtkPopover* popover,
                                                             GtkWidget* opener,
                                                             GtkWidget* initial_focus);
static void proton_plus_widgets_controller_popover_registration_finalize (GObject * obj);
static GType proton_plus_widgets_controller_popover_registration_get_type_once (void);
static void proton_plus_widgets_window_set_controller_manager (ProtonPlusWidgetsWindow* self,
                                                        ProtonPlusUtilsControllerManager* value);
static ProtonPlusUtilsControllerManager* proton_plus_widgets_window_get_controller_manager (ProtonPlusWidgetsWindow* self);
static void __lambda337_ (ProtonPlusWidgetsWindow* self,
                   ProtonPlusUtilsControllerPresentationState* state);
static ProtonPlusWidgetsControllerHintBar* proton_plus_widgets_window_get_controller_hint_bar (ProtonPlusWidgetsWindow* self);
static ProtonPlusWidgetsHeaderBox* proton_plus_widgets_window_get_header_box (ProtonPlusWidgetsWindow* self);
static void ___lambda337__proton_plus_utils_controller_manager_presentation_changed (ProtonPlusUtilsControllerManager* _sender,
                                                                              ProtonPlusUtilsControllerPresentationState* state,
                                                                              gpointer self);
static void __lambda338_ (ProtonPlusWidgetsWindow* self,
                   GVariant* parameter);
static void ___lambda338__g_simple_action_activate (GSimpleAction* _sender,
                                             GVariant* parameter,
                                             gpointer self);
static void proton_plus_widgets_window_build_ui (ProtonPlusWidgetsWindow* self);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
static void proton_plus_widgets_window_prepare_alert_dialog_focus (AdwAlertDialog* dialog);
static gboolean ___lambda40_ (Block1Data* _data1_);
static gboolean ____lambda40__gsource_func (gpointer self);
static void __lambda319_ (ProtonPlusWidgetsWindow* self,
                   const gchar* response);
static void ___lambda319__adw_alert_dialog_response (AdwAlertDialog* _sender,
                                              const gchar* response,
                                              gpointer self);
static void proton_plus_widgets_window_disable_alert_heading_focus (GtkWidget* root,
                                                             const gchar* heading);
static void proton_plus_widgets_window_update_alert_scroll_focus (GtkWidget* root);
static GtkWidget* proton_plus_widgets_window_find_button_with_label (GtkWidget* root,
                                                              const gchar* label);
static void proton_plus_widgets_window_set_header_box (ProtonPlusWidgetsWindow* self,
                                                ProtonPlusWidgetsHeaderBox* value);
static void __lambda339_ (ProtonPlusWidgetsWindow* self,
                   ProtonPlusModelsLauncher* launcher);
static void ___lambda339__proton_plus_widgets_header_box_launcher_selected (ProtonPlusWidgetsHeaderBox* _sender,
                                                                     ProtonPlusModelsLauncher* launcher,
                                                                     gpointer self);
static void proton_plus_widgets_window_set_loading_box (ProtonPlusWidgetsWindow* self,
                                                 ProtonPlusWidgetsLoadingBox* value);
static ProtonPlusWidgetsLoadingBox* proton_plus_widgets_window_get_loading_box (ProtonPlusWidgetsWindow* self);
static void __lambda340_ (ProtonPlusWidgetsWindow* self,
                   GeeLinkedList* launchers);
static AdwToolbarView* proton_plus_widgets_window_get_toolbar_view (ProtonPlusWidgetsWindow* self);
static void ___lambda340__proton_plus_widgets_loading_box_loaded (ProtonPlusWidgetsLoadingBox* _sender,
                                                           GeeLinkedList* launchers,
                                                           gpointer self);
static void __lambda341_ (ProtonPlusWidgetsWindow* self,
                   ProtonPlusServicesInstallJob* job);
static void ___lambda341__proton_plus_widgets_header_box_download_selected (ProtonPlusWidgetsHeaderBox* _sender,
                                                                     ProtonPlusServicesInstallJob* job,
                                                                     gpointer self);
static void proton_plus_widgets_window_set_toolbar_view (ProtonPlusWidgetsWindow* self,
                                                  AdwToolbarView* value);
static void proton_plus_widgets_window_set_controller_hint_bar (ProtonPlusWidgetsWindow* self,
                                                         ProtonPlusWidgetsControllerHintBar* value);
static gboolean proton_plus_widgets_window_real_close_request (GtkWindow* base);
static void __lambda342_ (ProtonPlusWidgetsWindow* self,
                   const gchar* response);
static void ___lambda342__adw_alert_dialog_response (AdwAlertDialog* _sender,
                                              const gchar* response,
                                              gpointer self);
static void proton_plus_widgets_window_real_dispose (GObject* base);
static void proton_plus_widgets_window_finalize (GObject * obj);
static GType proton_plus_widgets_window_get_type_once (void);
static void _vala_proton_plus_widgets_window_get_property (GObject * object,
                                                    guint property_id,
                                                    GValue * value,
                                                    GParamSpec * pspec);
static void _vala_proton_plus_widgets_window_set_property (GObject * object,
                                                    guint property_id,
                                                    const GValue * value,
                                                    GParamSpec * pspec);

static gboolean
proton_plus_widgets_gtk_controller_host_adapter_real_is_controller_window (ProtonPlusUtilsControllerHostAdapter* base,
                                                                           GObject* candidate)
{
	ProtonPlusWidgetsGtkControllerHostAdapter * self;
	gboolean result;
	self = (ProtonPlusWidgetsGtkControllerHostAdapter*) base;
	g_return_val_if_fail (candidate != NULL, FALSE);
	result = PROTON_PLUS_WIDGETS_IS_WINDOW (candidate);
	return result;
}

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

static GObject*
proton_plus_widgets_gtk_controller_host_adapter_real_get_root (ProtonPlusUtilsControllerHostAdapter* base,
                                                               GObject* candidate)
{
	ProtonPlusWidgetsGtkControllerHostAdapter * self;
	GtkWidget* widget = NULL;
	GtkWidget* _tmp0_;
	GtkWidget* _tmp1_ = NULL;
	GtkWidget* _tmp2_;
	GtkRoot* _tmp3_ = NULL;
	GObject* _tmp5_;
	GObject* result;
	self = (ProtonPlusWidgetsGtkControllerHostAdapter*) base;
	g_return_val_if_fail (candidate != NULL, NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (candidate, gtk_widget_get_type ()) ? ((GtkWidget*) candidate) : NULL);
	widget = _tmp0_;
	_tmp2_ = widget;
	_tmp1_ = _tmp2_;
	_tmp3_ = NULL;
	if (_tmp1_ != NULL) {
		GtkRoot* _tmp4_;
		_tmp4_ = gtk_widget_get_root (_tmp1_);
		_tmp3_ = _tmp4_;
	}
	_tmp5_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp3_, G_TYPE_OBJECT) ? ((GObject*) _tmp3_) : NULL);
	result = _tmp5_;
	_g_object_unref0 (widget);
	return result;
}

ProtonPlusWidgetsGtkControllerHostAdapter*
proton_plus_widgets_gtk_controller_host_adapter_construct (GType object_type)
{
	ProtonPlusWidgetsGtkControllerHostAdapter * self = NULL;
	self = (ProtonPlusWidgetsGtkControllerHostAdapter*) g_object_new (object_type, NULL);
	return self;
}

ProtonPlusWidgetsGtkControllerHostAdapter*
proton_plus_widgets_gtk_controller_host_adapter_new (void)
{
	return proton_plus_widgets_gtk_controller_host_adapter_construct (PROTON_PLUS_WIDGETS_TYPE_GTK_CONTROLLER_HOST_ADAPTER);
}

static void
proton_plus_widgets_gtk_controller_host_adapter_class_init (ProtonPlusWidgetsGtkControllerHostAdapterClass * klass,
                                                            gpointer klass_data)
{
	proton_plus_widgets_gtk_controller_host_adapter_parent_class = g_type_class_peek_parent (klass);
}

static void
proton_plus_widgets_gtk_controller_host_adapter_proton_plus_utils_controller_host_adapter_interface_init (ProtonPlusUtilsControllerHostAdapterIface * iface,
                                                                                                          gpointer iface_data)
{
	proton_plus_widgets_gtk_controller_host_adapter_proton_plus_utils_controller_host_adapter_parent_iface = g_type_interface_peek_parent (iface);
	iface->is_controller_window = (gboolean (*) (ProtonPlusUtilsControllerHostAdapter*, GObject*)) proton_plus_widgets_gtk_controller_host_adapter_real_is_controller_window;
	iface->get_root = (GObject* (*) (ProtonPlusUtilsControllerHostAdapter*, GObject*)) proton_plus_widgets_gtk_controller_host_adapter_real_get_root;
}

static void
proton_plus_widgets_gtk_controller_host_adapter_instance_init (ProtonPlusWidgetsGtkControllerHostAdapter * self,
                                                               gpointer klass)
{
}

static GType
proton_plus_widgets_gtk_controller_host_adapter_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusWidgetsGtkControllerHostAdapterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_widgets_gtk_controller_host_adapter_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusWidgetsGtkControllerHostAdapter), 0, (GInstanceInitFunc) proton_plus_widgets_gtk_controller_host_adapter_instance_init, NULL };
	static const GInterfaceInfo proton_plus_utils_controller_host_adapter_info = { (GInterfaceInitFunc) proton_plus_widgets_gtk_controller_host_adapter_proton_plus_utils_controller_host_adapter_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType proton_plus_widgets_gtk_controller_host_adapter_type_id;
	proton_plus_widgets_gtk_controller_host_adapter_type_id = g_type_register_static (G_TYPE_OBJECT, "ProtonPlusWidgetsGtkControllerHostAdapter", &g_define_type_info, 0);
	g_type_add_interface_static (proton_plus_widgets_gtk_controller_host_adapter_type_id, PROTON_PLUS_UTILS_TYPE_CONTROLLER_HOST_ADAPTER, &proton_plus_utils_controller_host_adapter_info);
	return proton_plus_widgets_gtk_controller_host_adapter_type_id;
}

GType
proton_plus_widgets_gtk_controller_host_adapter_get_type (void)
{
	static volatile gsize proton_plus_widgets_gtk_controller_host_adapter_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_widgets_gtk_controller_host_adapter_type_id__once)) {
		GType proton_plus_widgets_gtk_controller_host_adapter_type_id;
		proton_plus_widgets_gtk_controller_host_adapter_type_id = proton_plus_widgets_gtk_controller_host_adapter_get_type_once ();
		g_once_init_leave (&proton_plus_widgets_gtk_controller_host_adapter_type_id__once, proton_plus_widgets_gtk_controller_host_adapter_type_id);
	}
	return proton_plus_widgets_gtk_controller_host_adapter_type_id__once;
}

static inline gpointer
proton_plus_widgets_controller_popover_registration_get_instance_private (ProtonPlusWidgetsControllerPopoverRegistration* self)
{
	return G_STRUCT_MEMBER_P (self, ProtonPlusWidgetsControllerPopoverRegistration_private_offset);
}

ProtonPlusWidgetsControllerPopoverRegistration*
proton_plus_widgets_controller_popover_registration_construct (GType object_type,
                                                               GtkPopover* popover,
                                                               GtkWidget* opener,
                                                               GtkWidget* initial_focus)
{
	ProtonPlusWidgetsControllerPopoverRegistration * self = NULL;
	g_return_val_if_fail (popover != NULL, NULL);
	g_return_val_if_fail (opener != NULL, NULL);
	self = (ProtonPlusWidgetsControllerPopoverRegistration*) g_object_new (object_type, NULL);
	self->priv->popover = popover;
	self->priv->opener = opener;
	self->priv->initial_focus = initial_focus;
	return self;
}

ProtonPlusWidgetsControllerPopoverRegistration*
proton_plus_widgets_controller_popover_registration_new (GtkPopover* popover,
                                                         GtkWidget* opener,
                                                         GtkWidget* initial_focus)
{
	return proton_plus_widgets_controller_popover_registration_construct (PROTON_PLUS_WIDGETS_TYPE_CONTROLLER_POPOVER_REGISTRATION, popover, opener, initial_focus);
}

static void
_proton_plus_widgets_controller_popover_registration_try_register_g_object_notify (GObject* _sender,
                                                                                   GParamSpec* pspec,
                                                                                   gpointer self)
{
	proton_plus_widgets_controller_popover_registration_try_register ((ProtonPlusWidgetsControllerPopoverRegistration*) self);
}

static void
_proton_plus_widgets_controller_popover_registration_try_register_gtk_widget_map (GtkWidget* _sender,
                                                                                  gpointer self)
{
	proton_plus_widgets_controller_popover_registration_try_register ((ProtonPlusWidgetsControllerPopoverRegistration*) self);
}

void
proton_plus_widgets_controller_popover_registration_start (ProtonPlusWidgetsControllerPopoverRegistration* self)
{
	GtkPopover* _tmp0_;
	GtkPopover* _tmp1_;
	gulong _tmp2_;
	GtkPopover* _tmp3_;
	gulong _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->popover;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = self->priv->popover;
	_tmp2_ = g_signal_connect_object ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_popover_get_type (), GtkPopover), "notify::visible", (GCallback) _proton_plus_widgets_controller_popover_registration_try_register_g_object_notify, self, 0);
	self->priv->visible_handler = _tmp2_;
	_tmp3_ = self->priv->popover;
	_tmp4_ = g_signal_connect_object ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, gtk_popover_get_type (), GtkPopover), "map", (GCallback) _proton_plus_widgets_controller_popover_registration_try_register_gtk_widget_map, self, 0);
	self->priv->map_handler = _tmp4_;
	proton_plus_widgets_controller_popover_registration_try_register (self);
}

static void
proton_plus_widgets_controller_popover_registration_try_register (ProtonPlusWidgetsControllerPopoverRegistration* self)
{
	GtkPopover* current_popover = NULL;
	GtkPopover* _tmp0_;
	GtkPopover* _tmp1_;
	GtkWidget* current_opener = NULL;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp3_;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_ = FALSE;
	GtkPopover* _tmp6_;
	ProtonPlusWidgetsWindow* controller_window = NULL;
	GtkWidget* _tmp10_;
	ProtonPlusWidgetsWindow* _tmp11_;
	ProtonPlusWidgetsWindow* _tmp12_;
	ProtonPlusWidgetsWindow* _tmp15_;
	ProtonPlusWidgetsWindow* _tmp16_;
	GtkPopover* _tmp17_;
	GtkWidget* _tmp18_;
	GtkWidget* _tmp19_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->popover;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	current_popover = _tmp1_;
	_tmp2_ = self->priv->opener;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	current_opener = _tmp3_;
	_tmp6_ = current_popover;
	if (_tmp6_ == NULL) {
		_tmp5_ = TRUE;
	} else {
		GtkWidget* _tmp7_;
		_tmp7_ = current_opener;
		_tmp5_ = _tmp7_ == NULL;
	}
	if (_tmp5_) {
		_tmp4_ = TRUE;
	} else {
		GtkPopover* _tmp8_;
		GtkPopover* _tmp9_;
		_tmp8_ = current_popover;
		_tmp9_ = current_popover;
		_tmp4_ = !proton_plus_utils_controller_surface_policy_can_register_popover (gtk_widget_get_visible ((GtkWidget*) _tmp8_), gtk_widget_get_mapped ((GtkWidget*) _tmp9_));
	}
	if (_tmp4_) {
		_g_object_unref0 (current_opener);
		_g_object_unref0 (current_popover);
		return;
	}
	_tmp10_ = current_opener;
	_tmp11_ = proton_plus_widgets_window_resolve_controller_window (_tmp10_);
	controller_window = _tmp11_;
	_tmp12_ = controller_window;
	if (_tmp12_ == NULL) {
		GtkPopover* _tmp13_;
		ProtonPlusWidgetsWindow* _tmp14_;
		_tmp13_ = current_popover;
		_tmp14_ = proton_plus_widgets_window_resolve_controller_window ((GtkWidget*) _tmp13_);
		_g_object_unref0 (controller_window);
		controller_window = _tmp14_;
	}
	_tmp15_ = controller_window;
	if (_tmp15_ == NULL) {
		_g_object_unref0 (controller_window);
		_g_object_unref0 (current_opener);
		_g_object_unref0 (current_popover);
		return;
	}
	_tmp16_ = controller_window;
	_tmp17_ = current_popover;
	_tmp18_ = current_opener;
	_tmp19_ = self->priv->initial_focus;
	proton_plus_widgets_window_register_controller_popover (_tmp16_, _tmp17_, _tmp18_, _tmp19_);
	if (self->priv->visible_handler != ((gulong) 0)) {
		GtkPopover* _tmp20_;
		_tmp20_ = current_popover;
		g_signal_handler_disconnect ((GObject*) _tmp20_, self->priv->visible_handler);
		self->priv->visible_handler = (gulong) 0;
	}
	if (self->priv->map_handler != ((gulong) 0)) {
		GtkPopover* _tmp21_;
		_tmp21_ = current_popover;
		g_signal_handler_disconnect ((GObject*) _tmp21_, self->priv->map_handler);
		self->priv->map_handler = (gulong) 0;
	}
	_g_object_unref0 (controller_window);
	_g_object_unref0 (current_opener);
	_g_object_unref0 (current_popover);
}

static void
proton_plus_widgets_controller_popover_registration_class_init (ProtonPlusWidgetsControllerPopoverRegistrationClass * klass,
                                                                gpointer klass_data)
{
	proton_plus_widgets_controller_popover_registration_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ProtonPlusWidgetsControllerPopoverRegistration_private_offset);
	G_OBJECT_CLASS (klass)->finalize = proton_plus_widgets_controller_popover_registration_finalize;
}

static void
proton_plus_widgets_controller_popover_registration_instance_init (ProtonPlusWidgetsControllerPopoverRegistration * self,
                                                                   gpointer klass)
{
	self->priv = proton_plus_widgets_controller_popover_registration_get_instance_private (self);
	self->priv->visible_handler = (gulong) 0;
	self->priv->map_handler = (gulong) 0;
}

static void
proton_plus_widgets_controller_popover_registration_finalize (GObject * obj)
{
	ProtonPlusWidgetsControllerPopoverRegistration * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PROTON_PLUS_WIDGETS_TYPE_CONTROLLER_POPOVER_REGISTRATION, ProtonPlusWidgetsControllerPopoverRegistration);
	G_OBJECT_CLASS (proton_plus_widgets_controller_popover_registration_parent_class)->finalize (obj);
}

static GType
proton_plus_widgets_controller_popover_registration_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusWidgetsControllerPopoverRegistrationClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_widgets_controller_popover_registration_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusWidgetsControllerPopoverRegistration), 0, (GInstanceInitFunc) proton_plus_widgets_controller_popover_registration_instance_init, NULL };
	GType proton_plus_widgets_controller_popover_registration_type_id;
	proton_plus_widgets_controller_popover_registration_type_id = g_type_register_static (G_TYPE_OBJECT, "ProtonPlusWidgetsControllerPopoverRegistration", &g_define_type_info, 0);
	ProtonPlusWidgetsControllerPopoverRegistration_private_offset = g_type_add_instance_private (proton_plus_widgets_controller_popover_registration_type_id, sizeof (ProtonPlusWidgetsControllerPopoverRegistrationPrivate));
	return proton_plus_widgets_controller_popover_registration_type_id;
}

GType
proton_plus_widgets_controller_popover_registration_get_type (void)
{
	static volatile gsize proton_plus_widgets_controller_popover_registration_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_widgets_controller_popover_registration_type_id__once)) {
		GType proton_plus_widgets_controller_popover_registration_type_id;
		proton_plus_widgets_controller_popover_registration_type_id = proton_plus_widgets_controller_popover_registration_get_type_once ();
		g_once_init_leave (&proton_plus_widgets_controller_popover_registration_type_id__once, proton_plus_widgets_controller_popover_registration_type_id);
	}
	return proton_plus_widgets_controller_popover_registration_type_id__once;
}

static inline gpointer
proton_plus_widgets_window_get_instance_private (ProtonPlusWidgetsWindow* self)
{
	return G_STRUCT_MEMBER_P (self, ProtonPlusWidgetsWindow_private_offset);
}

static void
__lambda337_ (ProtonPlusWidgetsWindow* self,
              ProtonPlusUtilsControllerPresentationState* state)
{
	ProtonPlusWidgetsControllerHintBar* _tmp0_;
	ProtonPlusWidgetsHeaderBox* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	g_return_if_fail (state != NULL);
	_tmp0_ = self->priv->_controller_hint_bar;
	proton_plus_widgets_controller_hint_bar_update_state (_tmp0_, state);
	_tmp1_ = self->priv->_header_box;
	_tmp2_ = proton_plus_utils_controller_presentation_state_get_controller_mode_active (state);
	_tmp3_ = _tmp2_;
	proton_plus_widgets_header_box_set_controller_mode_active (_tmp1_, _tmp3_);
}

static void
___lambda337__proton_plus_utils_controller_manager_presentation_changed (ProtonPlusUtilsControllerManager* _sender,
                                                                         ProtonPlusUtilsControllerPresentationState* state,
                                                                         gpointer self)
{
	__lambda337_ ((ProtonPlusWidgetsWindow*) self, state);
}

static void
__lambda338_ (ProtonPlusWidgetsWindow* self,
              GVariant* parameter)
{
	ProtonPlusUtilsControllerManager* _tmp0_;
	_tmp0_ = self->priv->_controller_manager;
	proton_plus_utils_controller_manager_navigate_application_back (_tmp0_);
}

static void
___lambda338__g_simple_action_activate (GSimpleAction* _sender,
                                        GVariant* parameter,
                                        gpointer self)
{
	__lambda338_ ((ProtonPlusWidgetsWindow*) self, parameter);
}

ProtonPlusWidgetsWindow*
proton_plus_widgets_window_construct (GType object_type,
                                      ProtonPlusServicesSteamRestartManager* restart_manager,
                                      ProtonPlusServicesSteamRestartOrchestrator* restart_orchestrator)
{
	ProtonPlusWidgetsWindow * self = NULL;
	GApplication* _tmp0_;
	ProtonPlusServicesSteamRestartManager* _tmp1_;
	ProtonPlusServicesSteamRestartOrchestrator* _tmp2_;
	ProtonPlusUtilsControllerManager* _tmp3_;
	ProtonPlusUtilsControllerManager* _tmp4_;
	ProtonPlusUtilsControllerManager* _tmp5_;
	gulong _tmp6_;
	GSimpleAction* navigate_back_action = NULL;
	GSimpleAction* _tmp7_;
	ProtonPlusUtilsControllerManager* _tmp8_;
	g_return_val_if_fail (restart_manager != NULL, NULL);
	g_return_val_if_fail (restart_orchestrator != NULL, NULL);
	_tmp0_ = g_application_get_default ();
	self = (ProtonPlusWidgetsWindow*) g_object_new (object_type, "application", G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, adw_application_get_type (), AdwApplication), "title", APP_NAME, NULL);
	_tmp1_ = _g_object_ref0 (restart_manager);
	_g_object_unref0 (self->priv->restart_manager);
	self->priv->restart_manager = _tmp1_;
	_tmp2_ = _g_object_ref0 (restart_orchestrator);
	_g_object_unref0 (self->priv->restart_orchestrator);
	self->priv->restart_orchestrator = _tmp2_;
	_tmp3_ = proton_plus_utils_controller_manager_new (self);
	_tmp4_ = _tmp3_;
	proton_plus_widgets_window_set_controller_manager (self, _tmp4_);
	_g_object_unref0 (_tmp4_);
	_tmp5_ = self->priv->_controller_manager;
	_tmp6_ = g_signal_connect_object (_tmp5_, "presentation-changed", (GCallback) ___lambda337__proton_plus_utils_controller_manager_presentation_changed, self, 0);
	self->priv->controller_presentation_handler = _tmp6_;
	_tmp7_ = g_simple_action_new ("navigate-back", NULL);
	navigate_back_action = _tmp7_;
	g_signal_connect_object (navigate_back_action, "activate", (GCallback) ___lambda338__g_simple_action_activate, self, 0);
	g_action_map_add_action ((GActionMap*) self, (GAction*) navigate_back_action);
	proton_plus_widgets_window_build_ui (self);
	_tmp8_ = self->priv->_controller_manager;
	proton_plus_utils_controller_manager_start (_tmp8_);
	_g_object_unref0 (navigate_back_action);
	return self;
}

ProtonPlusWidgetsWindow*
proton_plus_widgets_window_new (ProtonPlusServicesSteamRestartManager* restart_manager,
                                ProtonPlusServicesSteamRestartOrchestrator* restart_orchestrator)
{
	return proton_plus_widgets_window_construct (PROTON_PLUS_WIDGETS_TYPE_WINDOW, restart_manager, restart_orchestrator);
}

void
proton_plus_widgets_window_present_dialog_for_controller (AdwDialog* dialog,
                                                          GtkWidget* parent)
{
	ProtonPlusWidgetsWindow* controller_window = NULL;
	ProtonPlusWidgetsWindow* _tmp0_;
	ProtonPlusWidgetsWindow* _tmp1_;
	g_return_if_fail (dialog != NULL);
	_tmp0_ = proton_plus_widgets_window_resolve_controller_window (parent);
	controller_window = _tmp0_;
	_tmp1_ = controller_window;
	if (_tmp1_ != NULL) {
		ProtonPlusWidgetsWindow* _tmp2_;
		_tmp2_ = controller_window;
		proton_plus_widgets_window_present_controller_dialog (_tmp2_, dialog, parent);
		_g_object_unref0 (controller_window);
		return;
	}
	adw_dialog_present (dialog, parent);
	_g_object_unref0 (controller_window);
}

void
proton_plus_widgets_window_register_popover_for_controller (GtkPopover* popover,
                                                            GtkWidget* opener,
                                                            GtkWidget* initial_focus)
{
	ProtonPlusWidgetsControllerPopoverRegistration* _tmp0_;
	ProtonPlusWidgetsControllerPopoverRegistration* _tmp1_;
	g_return_if_fail (popover != NULL);
	g_return_if_fail (opener != NULL);
	_tmp0_ = proton_plus_widgets_controller_popover_registration_new (popover, opener, initial_focus);
	_tmp1_ = _tmp0_;
	proton_plus_widgets_controller_popover_registration_start (_tmp1_);
	_g_object_unref0 (_tmp1_);
}

ProtonPlusWidgetsWindow*
proton_plus_widgets_window_resolve_controller_window (GtkWidget* parent)
{
	ProtonPlusWidgetsGtkControllerHostAdapter* _tmp0_;
	ProtonPlusWidgetsGtkControllerHostAdapter* _tmp1_;
	GObject* _tmp2_;
	ProtonPlusWidgetsWindow* _tmp3_;
	ProtonPlusWidgetsWindow* _tmp4_;
	ProtonPlusWidgetsWindow* result;
	_tmp0_ = proton_plus_widgets_gtk_controller_host_adapter_new ();
	_tmp1_ = _tmp0_;
	_tmp2_ = proton_plus_utils_controller_window_resolver_resolve ((GObject*) parent, (ProtonPlusUtilsControllerHostAdapter*) _tmp1_);
	_tmp3_ = PROTON_PLUS_WIDGETS_IS_WINDOW (_tmp2_) ? ((ProtonPlusWidgetsWindow*) _tmp2_) : NULL;
	if (_tmp3_ == NULL) {
		_g_object_unref0 (_tmp2_);
	}
	_tmp4_ = _tmp3_;
	_g_object_unref0 (_tmp1_);
	result = _tmp4_;
	return result;
}

static Block1Data*
block1_data_ref (Block1Data* _data1_)
{
	g_atomic_int_inc (&_data1_->_ref_count_);
	return _data1_;
}

static void
block1_data_unref (void * _userdata_)
{
	Block1Data* _data1_;
	_data1_ = (Block1Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		ProtonPlusWidgetsWindow* self;
		self = _data1_->self;
		_g_object_unref0 (_data1_->alert_dialog);
		_g_object_unref0 (self);
		g_slice_free (Block1Data, _data1_);
	}
}

static gboolean
___lambda40_ (Block1Data* _data1_)
{
	ProtonPlusWidgetsWindow* self;
	AdwAlertDialog* _tmp0_;
	gboolean result;
	self = _data1_->self;
	_tmp0_ = _data1_->alert_dialog;
	if (gtk_widget_get_mapped ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, adw_alert_dialog_get_type (), AdwAlertDialog))) {
		AdwAlertDialog* _tmp1_;
		_tmp1_ = _data1_->alert_dialog;
		proton_plus_widgets_window_prepare_alert_dialog_focus (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, adw_alert_dialog_get_type (), AdwAlertDialog));
	}
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
____lambda40__gsource_func (gpointer self)
{
	gboolean result;
	result = ___lambda40_ (self);
	return result;
}

void
proton_plus_widgets_window_present_controller_dialog (ProtonPlusWidgetsWindow* self,
                                                      AdwDialog* dialog,
                                                      GtkWidget* parent)
{
	Block1Data* _data1_;
	ProtonPlusUtilsControllerManager* _tmp0_;
	AdwAlertDialog* _tmp1_;
	AdwAlertDialog* _tmp2_;
	GtkWidget* _tmp4_ = NULL;
	AdwAlertDialog* _tmp5_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (dialog != NULL);
	_data1_ = g_slice_new0 (Block1Data);
	_data1_->_ref_count_ = 1;
	_data1_->self = g_object_ref (self);
	_tmp0_ = self->priv->_controller_manager;
	proton_plus_utils_controller_manager_register_dialog (_tmp0_, dialog);
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (dialog, adw_alert_dialog_get_type ()) ? ((AdwAlertDialog*) dialog) : NULL);
	_data1_->alert_dialog = _tmp1_;
	_tmp2_ = _data1_->alert_dialog;
	if (_tmp2_ != NULL) {
		AdwAlertDialog* _tmp3_;
		_tmp3_ = _data1_->alert_dialog;
		proton_plus_widgets_window_prepare_alert_dialog_focus (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, adw_alert_dialog_get_type (), AdwAlertDialog));
	}
	_tmp4_ = parent;
	if (_tmp4_ == NULL) {
		_tmp4_ = (GtkWidget*) self;
	}
	adw_dialog_present (dialog, _tmp4_);
	_tmp5_ = _data1_->alert_dialog;
	if (_tmp5_ != NULL) {
		g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, ____lambda40__gsource_func, block1_data_ref (_data1_), block1_data_unref);
	}
	block1_data_unref (_data1_);
	_data1_ = NULL;
}

void
proton_plus_widgets_window_register_controller_popover (ProtonPlusWidgetsWindow* self,
                                                        GtkPopover* popover,
                                                        GtkWidget* opener,
                                                        GtkWidget* initial_focus)
{
	ProtonPlusUtilsControllerManager* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (popover != NULL);
	g_return_if_fail (opener != NULL);
	_tmp0_ = self->priv->_controller_manager;
	proton_plus_utils_controller_manager_register_popover (_tmp0_, popover, opener, initial_focus);
}

void
proton_plus_widgets_window_open_menu (ProtonPlusWidgetsWindow* self)
{
	ProtonPlusWidgetsHeaderBox* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_header_box;
	proton_plus_widgets_header_box_open_menu (_tmp0_);
}

void
proton_plus_widgets_window_open_launchers (ProtonPlusWidgetsWindow* self)
{
	ProtonPlusWidgetsHeaderBox* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_header_box;
	proton_plus_widgets_header_box_open_launchers (_tmp0_);
}

static void
__lambda319_ (ProtonPlusWidgetsWindow* self,
              const gchar* response)
{
	g_return_if_fail (response != NULL);
	if (g_strcmp0 (response, "exit") != 0) {
		return;
	}
	gtk_window_close ((GtkWindow*) self);
}

static void
___lambda319__adw_alert_dialog_response (AdwAlertDialog* _sender,
                                         const gchar* response,
                                         gpointer self)
{
	__lambda319_ ((ProtonPlusWidgetsWindow*) self, response);
}

void
proton_plus_widgets_window_request_controller_exit (ProtonPlusWidgetsWindow* self)
{
	ProtonPlusUtilsDownloadManager* _tmp0_;
	ProtonPlusUtilsDownloadManager* _tmp1_;
	GeeLinkedList* _tmp2_;
	GeeLinkedList* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	AdwAlertDialog* dialog = NULL;
	AdwAlertDialog* _tmp6_;
	AdwAlertDialog* _tmp7_;
	AdwAlertDialog* _tmp8_;
	AdwAlertDialog* _tmp9_;
	AdwAlertDialog* _tmp10_;
	AdwAlertDialog* _tmp11_;
	AdwAlertDialog* _tmp12_;
	AdwAlertDialog* _tmp13_;
	g_return_if_fail (self != NULL);
	_tmp0_ = proton_plus_utils_download_manager_get_instance ();
	_tmp1_ = _tmp0_;
	_tmp2_ = proton_plus_utils_download_manager_get_active_downloads (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp3_);
	_tmp5_ = _tmp4_;
	if (_tmp5_ > 0) {
		gtk_window_close ((GtkWindow*) self);
		return;
	}
	_tmp6_ = (AdwAlertDialog*) adw_alert_dialog_new (_ ("Do you want to exit?"), "");
	g_object_ref_sink (_tmp6_);
	dialog = _tmp6_;
	_tmp7_ = dialog;
	adw_alert_dialog_add_response (_tmp7_, "cancel", _ ("Cancel"));
	_tmp8_ = dialog;
	adw_alert_dialog_add_response (_tmp8_, "exit", _ ("Exit"));
	_tmp9_ = dialog;
	adw_alert_dialog_set_response_appearance (_tmp9_, "exit", ADW_RESPONSE_DESTRUCTIVE);
	_tmp10_ = dialog;
	adw_alert_dialog_set_default_response (_tmp10_, "cancel");
	_tmp11_ = dialog;
	adw_alert_dialog_set_close_response (_tmp11_, "cancel");
	_tmp12_ = dialog;
	g_signal_connect_object (_tmp12_, "response", (GCallback) ___lambda319__adw_alert_dialog_response, self, 0);
	_tmp13_ = dialog;
	proton_plus_widgets_window_present_controller_dialog (self, (AdwDialog*) _tmp13_, NULL);
	_g_object_unref0 (dialog);
}

static void
proton_plus_widgets_window_prepare_alert_dialog_focus (AdwAlertDialog* dialog)
{
	const gchar* _tmp0_;
	GtkWidget* focus = NULL;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	gchar* default_response = NULL;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gboolean _tmp5_ = FALSE;
	GtkWidget* _tmp6_;
	GtkWidget* _tmp11_;
	GtkWidget* _tmp12_;
	GtkWidget* _tmp13_;
	g_return_if_fail (dialog != NULL);
	_tmp0_ = adw_alert_dialog_get_heading (dialog);
	proton_plus_widgets_window_disable_alert_heading_focus ((GtkWidget*) dialog, _tmp0_);
	proton_plus_widgets_window_update_alert_scroll_focus ((GtkWidget*) dialog);
	_tmp1_ = adw_dialog_get_default_widget ((AdwDialog*) dialog);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	focus = _tmp2_;
	_tmp3_ = adw_alert_dialog_get_default_response (dialog);
	_tmp4_ = g_strdup (_tmp3_);
	default_response = _tmp4_;
	_tmp6_ = focus;
	if (_tmp6_ == NULL) {
		const gchar* _tmp7_;
		_tmp7_ = default_response;
		_tmp5_ = _tmp7_ != NULL;
	} else {
		_tmp5_ = FALSE;
	}
	if (_tmp5_) {
		const gchar* _tmp8_;
		const gchar* _tmp9_;
		GtkWidget* _tmp10_;
		_tmp8_ = default_response;
		_tmp9_ = adw_alert_dialog_get_response_label (dialog, (const gchar*) _tmp8_);
		_tmp10_ = proton_plus_widgets_window_find_button_with_label ((GtkWidget*) dialog, _tmp9_);
		_g_object_unref0 (focus);
		focus = _tmp10_;
	}
	_tmp11_ = focus;
	if (_tmp11_ == NULL) {
		_g_free0 (default_response);
		_g_object_unref0 (focus);
		return;
	}
	_tmp12_ = focus;
	gtk_widget_set_focusable (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, gtk_widget_get_type (), GtkWidget), TRUE);
	_tmp13_ = focus;
	adw_dialog_set_focus ((AdwDialog*) dialog, _tmp13_);
	if (gtk_widget_get_mapped ((GtkWidget*) dialog)) {
		GtkWidget* _tmp14_;
		_tmp14_ = focus;
		gtk_widget_grab_focus (G_TYPE_CHECK_INSTANCE_CAST (_tmp14_, gtk_widget_get_type (), GtkWidget));
	}
	_g_free0 (default_response);
	_g_object_unref0 (focus);
}

static void
proton_plus_widgets_window_disable_alert_heading_focus (GtkWidget* root,
                                                        const gchar* heading)
{
	GtkWidget* child = NULL;
	GtkWidget* _tmp0_;
	GtkWidget* _tmp1_;
	g_return_if_fail (root != NULL);
	_tmp0_ = gtk_widget_get_first_child (root);
	_tmp1_ = _g_object_ref0 (_tmp0_);
	child = _tmp1_;
	while (TRUE) {
		GtkWidget* _tmp2_;
		GtkLabel* label = NULL;
		GtkWidget* _tmp3_;
		GtkLabel* _tmp4_;
		gboolean _tmp5_ = FALSE;
		gboolean _tmp6_ = FALSE;
		GtkLabel* _tmp7_;
		GtkWidget* _tmp12_;
		GtkWidget* _tmp13_;
		GtkWidget* _tmp14_;
		GtkWidget* _tmp15_;
		_tmp2_ = child;
		if (!(_tmp2_ != NULL)) {
			break;
		}
		_tmp3_ = child;
		_tmp4_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp3_, gtk_label_get_type ()) ? ((GtkLabel*) _tmp3_) : NULL);
		label = _tmp4_;
		_tmp7_ = label;
		if (_tmp7_ != NULL) {
			_tmp6_ = heading != NULL;
		} else {
			_tmp6_ = FALSE;
		}
		if (_tmp6_) {
			GtkLabel* _tmp8_;
			const gchar* _tmp9_;
			_tmp8_ = label;
			_tmp9_ = gtk_label_get_label (_tmp8_);
			_tmp5_ = g_strcmp0 (_tmp9_, heading) == 0;
		} else {
			_tmp5_ = FALSE;
		}
		if (_tmp5_) {
			GtkLabel* _tmp10_;
			GtkLabel* _tmp11_;
			_tmp10_ = label;
			gtk_label_set_selectable (_tmp10_, FALSE);
			_tmp11_ = label;
			gtk_widget_set_focusable ((GtkWidget*) _tmp11_, FALSE);
		}
		_tmp12_ = child;
		proton_plus_widgets_window_disable_alert_heading_focus (_tmp12_, heading);
		_tmp13_ = child;
		_tmp14_ = gtk_widget_get_next_sibling (_tmp13_);
		_tmp15_ = _g_object_ref0 (_tmp14_);
		_g_object_unref0 (child);
		child = _tmp15_;
		_g_object_unref0 (label);
	}
	_g_object_unref0 (child);
}

static void
proton_plus_widgets_window_update_alert_scroll_focus (GtkWidget* root)
{
	GtkWidget* child = NULL;
	GtkWidget* _tmp0_;
	GtkWidget* _tmp1_;
	g_return_if_fail (root != NULL);
	_tmp0_ = gtk_widget_get_first_child (root);
	_tmp1_ = _g_object_ref0 (_tmp0_);
	child = _tmp1_;
	while (TRUE) {
		GtkWidget* _tmp2_;
		GtkScrolledWindow* scrolled = NULL;
		GtkWidget* _tmp3_;
		GtkScrolledWindow* _tmp4_;
		gboolean _tmp5_ = FALSE;
		GtkScrolledWindow* _tmp6_;
		GtkWidget* _tmp14_;
		GtkWidget* _tmp15_;
		GtkWidget* _tmp16_;
		GtkWidget* _tmp17_;
		_tmp2_ = child;
		if (!(_tmp2_ != NULL)) {
			break;
		}
		_tmp3_ = child;
		_tmp4_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp3_, gtk_scrolled_window_get_type ()) ? ((GtkScrolledWindow*) _tmp3_) : NULL);
		scrolled = _tmp4_;
		_tmp6_ = scrolled;
		if (_tmp6_ != NULL) {
			GtkScrolledWindow* _tmp7_;
			_tmp7_ = scrolled;
			_tmp5_ = gtk_widget_has_css_class ((GtkWidget*) _tmp7_, "body-scrolled-window");
		} else {
			_tmp5_ = FALSE;
		}
		if (_tmp5_) {
			GtkAdjustment* adjustment = NULL;
			GtkScrolledWindow* _tmp8_;
			GtkAdjustment* _tmp9_;
			GtkAdjustment* _tmp10_;
			GtkScrolledWindow* _tmp11_;
			GtkAdjustment* _tmp12_;
			GtkAdjustment* _tmp13_;
			_tmp8_ = scrolled;
			_tmp9_ = gtk_scrolled_window_get_vadjustment (_tmp8_);
			_tmp10_ = _g_object_ref0 (_tmp9_);
			adjustment = _tmp10_;
			_tmp11_ = scrolled;
			_tmp12_ = adjustment;
			_tmp13_ = adjustment;
			gtk_widget_set_focusable ((GtkWidget*) _tmp11_, proton_plus_utils_controller_surface_policy_scroll_container_needs_focus (gtk_adjustment_get_upper (_tmp12_), gtk_adjustment_get_page_size (_tmp13_)));
			_g_object_unref0 (adjustment);
		}
		_tmp14_ = child;
		proton_plus_widgets_window_update_alert_scroll_focus (_tmp14_);
		_tmp15_ = child;
		_tmp16_ = gtk_widget_get_next_sibling (_tmp15_);
		_tmp17_ = _g_object_ref0 (_tmp16_);
		_g_object_unref0 (child);
		child = _tmp17_;
		_g_object_unref0 (scrolled);
	}
	_g_object_unref0 (child);
}

static GtkWidget*
proton_plus_widgets_window_find_button_with_label (GtkWidget* root,
                                                   const gchar* label)
{
	GtkWidget* child = NULL;
	GtkWidget* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* result;
	g_return_val_if_fail (root != NULL, NULL);
	g_return_val_if_fail (label != NULL, NULL);
	_tmp0_ = gtk_widget_get_first_child (root);
	_tmp1_ = _g_object_ref0 (_tmp0_);
	child = _tmp1_;
	while (TRUE) {
		GtkWidget* _tmp2_;
		GtkButton* button = NULL;
		GtkWidget* _tmp3_;
		GtkButton* _tmp4_;
		gboolean _tmp5_ = FALSE;
		GtkButton* _tmp6_;
		GtkWidget* nested = NULL;
		GtkWidget* _tmp9_;
		GtkWidget* _tmp10_;
		GtkWidget* _tmp11_;
		GtkWidget* _tmp12_;
		GtkWidget* _tmp13_;
		GtkWidget* _tmp14_;
		_tmp2_ = child;
		if (!(_tmp2_ != NULL)) {
			break;
		}
		_tmp3_ = child;
		_tmp4_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp3_, gtk_button_get_type ()) ? ((GtkButton*) _tmp3_) : NULL);
		button = _tmp4_;
		_tmp6_ = button;
		if (_tmp6_ != NULL) {
			GtkButton* _tmp7_;
			const gchar* _tmp8_;
			_tmp7_ = button;
			_tmp8_ = gtk_button_get_label (_tmp7_);
			_tmp5_ = g_strcmp0 (_tmp8_, label) == 0;
		} else {
			_tmp5_ = FALSE;
		}
		if (_tmp5_) {
			result = (GtkWidget*) button;
			_g_object_unref0 (child);
			return result;
		}
		_tmp9_ = child;
		_tmp10_ = proton_plus_widgets_window_find_button_with_label (_tmp9_, label);
		nested = _tmp10_;
		_tmp11_ = nested;
		if (_tmp11_ != NULL) {
			result = nested;
			_g_object_unref0 (button);
			_g_object_unref0 (child);
			return result;
		}
		_tmp12_ = child;
		_tmp13_ = gtk_widget_get_next_sibling (_tmp12_);
		_tmp14_ = _g_object_ref0 (_tmp13_);
		_g_object_unref0 (child);
		child = _tmp14_;
		_g_object_unref0 (nested);
		_g_object_unref0 (button);
	}
	result = NULL;
	_g_object_unref0 (child);
	return result;
}

static void
__lambda339_ (ProtonPlusWidgetsWindow* self,
              ProtonPlusModelsLauncher* launcher)
{
	ProtonPlusWidgetsMainBox* _tmp0_;
	g_return_if_fail (launcher != NULL);
	_tmp0_ = self->priv->_main_box;
	proton_plus_widgets_main_box_set_selected_launcher (_tmp0_, launcher);
}

static void
___lambda339__proton_plus_widgets_header_box_launcher_selected (ProtonPlusWidgetsHeaderBox* _sender,
                                                                ProtonPlusModelsLauncher* launcher,
                                                                gpointer self)
{
	__lambda339_ ((ProtonPlusWidgetsWindow*) self, launcher);
}

static void
__lambda340_ (ProtonPlusWidgetsWindow* self,
              GeeLinkedList* launchers)
{
	ProtonPlusWidgetsHeaderBox* _tmp0_;
	ProtonPlusWidgetsMainBox* _tmp1_;
	AdwViewSwitcher* _tmp2_;
	AdwViewSwitcher* _tmp3_;
	ProtonPlusWidgetsMainBox* _tmp4_;
	AdwToolbarView* _tmp5_;
	ProtonPlusWidgetsMainBox* _tmp6_;
	GSettings* _tmp7_;
	g_return_if_fail (launchers != NULL);
	proton_plus_widgets_window_set_launchers (self, launchers);
	_tmp0_ = self->priv->_header_box;
	_tmp1_ = self->priv->_main_box;
	_tmp2_ = proton_plus_widgets_main_box_get_view_switcher (_tmp1_);
	_tmp3_ = _tmp2_;
	proton_plus_widgets_header_box_initialize (_tmp0_, launchers, _tmp3_);
	_tmp4_ = self->priv->_main_box;
	proton_plus_widgets_main_box_initialize (_tmp4_, launchers);
	_tmp5_ = self->priv->_toolbar_view;
	_tmp6_ = self->priv->_main_box;
	adw_toolbar_view_set_content (_tmp5_, (GtkWidget*) _tmp6_);
	_tmp7_ = proton_plus_globals_SETTINGS;
	if (g_settings_get_boolean (_tmp7_, "check-updates-on-launch")) {
		ProtonPlusWidgetsMainBox* _tmp8_;
		_tmp8_ = self->priv->_main_box;
		proton_plus_widgets_main_box_check_for_updates (_tmp8_, launchers, NULL, NULL);
	}
}

static void
___lambda340__proton_plus_widgets_loading_box_loaded (ProtonPlusWidgetsLoadingBox* _sender,
                                                      GeeLinkedList* launchers,
                                                      gpointer self)
{
	__lambda340_ ((ProtonPlusWidgetsWindow*) self, launchers);
}

static void
__lambda341_ (ProtonPlusWidgetsWindow* self,
              ProtonPlusServicesInstallJob* job)
{
	ProtonPlusWidgetsMainBox* _tmp0_;
	g_return_if_fail (job != NULL);
	_tmp0_ = self->priv->_main_box;
	proton_plus_widgets_main_box_navigate_to_download (_tmp0_, job);
}

static void
___lambda341__proton_plus_widgets_header_box_download_selected (ProtonPlusWidgetsHeaderBox* _sender,
                                                                ProtonPlusServicesInstallJob* job,
                                                                gpointer self)
{
	__lambda341_ ((ProtonPlusWidgetsWindow*) self, job);
}

static void
proton_plus_widgets_window_build_ui (ProtonPlusWidgetsWindow* self)
{
	ProtonPlusWidgetsHeaderBox* _tmp0_;
	ProtonPlusWidgetsHeaderBox* _tmp1_;
	ProtonPlusWidgetsHeaderBox* _tmp2_;
	ProtonPlusUtilsControllerManager* _tmp3_;
	ProtonPlusUtilsControllerPresentationState* _tmp4_;
	ProtonPlusUtilsControllerPresentationState* _tmp5_;
	gboolean _tmp6_;
	gboolean _tmp7_;
	ProtonPlusWidgetsHeaderBox* _tmp8_;
	ProtonPlusWidgetsLoadingBox* _tmp9_;
	ProtonPlusWidgetsLoadingBox* _tmp10_;
	ProtonPlusWidgetsLoadingBox* _tmp11_;
	ProtonPlusServicesSteamRestartManager* _tmp12_;
	ProtonPlusServicesSteamRestartOrchestrator* _tmp13_;
	ProtonPlusWidgetsMainBox* _tmp14_;
	ProtonPlusWidgetsMainBox* _tmp15_;
	ProtonPlusWidgetsHeaderBox* _tmp16_;
	AdwToolbarView* _tmp17_;
	AdwToolbarView* _tmp18_;
	AdwToolbarView* _tmp19_;
	ProtonPlusWidgetsHeaderBox* _tmp20_;
	ProtonPlusWidgetsControllerHintBar* _tmp21_;
	ProtonPlusWidgetsControllerHintBar* _tmp22_;
	ProtonPlusWidgetsControllerHintBar* _tmp23_;
	ProtonPlusUtilsControllerManager* _tmp24_;
	ProtonPlusUtilsControllerPresentationState* _tmp25_;
	ProtonPlusUtilsControllerPresentationState* _tmp26_;
	AdwToolbarView* _tmp27_;
	ProtonPlusWidgetsControllerHintBar* _tmp28_;
	AdwToolbarView* _tmp29_;
	ProtonPlusWidgetsLoadingBox* _tmp30_;
	AdwToolbarView* _tmp31_;
	ProtonPlusUtilsControllerManager* _tmp32_;
	ProtonPlusWidgetsLoadingBox* _tmp33_;
	g_return_if_fail (self != NULL);
	_tmp0_ = proton_plus_widgets_header_box_new ();
	g_object_ref_sink (_tmp0_);
	_tmp1_ = _tmp0_;
	proton_plus_widgets_window_set_header_box (self, _tmp1_);
	_g_object_unref0 (_tmp1_);
	_tmp2_ = self->priv->_header_box;
	_tmp3_ = self->priv->_controller_manager;
	_tmp4_ = proton_plus_utils_controller_manager_get_presentation_state (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = proton_plus_utils_controller_presentation_state_get_controller_mode_active (_tmp5_);
	_tmp7_ = _tmp6_;
	proton_plus_widgets_header_box_set_controller_mode_active (_tmp2_, _tmp7_);
	_tmp8_ = self->priv->_header_box;
	g_signal_connect_object (_tmp8_, "launcher-selected", (GCallback) ___lambda339__proton_plus_widgets_header_box_launcher_selected, self, 0);
	_tmp9_ = proton_plus_widgets_loading_box_new ();
	g_object_ref_sink (_tmp9_);
	_tmp10_ = _tmp9_;
	proton_plus_widgets_window_set_loading_box (self, _tmp10_);
	_g_object_unref0 (_tmp10_);
	_tmp11_ = self->priv->_loading_box;
	g_signal_connect_object (_tmp11_, "loaded", (GCallback) ___lambda340__proton_plus_widgets_loading_box_loaded, self, 0);
	_tmp12_ = self->priv->restart_manager;
	_tmp13_ = self->priv->restart_orchestrator;
	_tmp14_ = proton_plus_widgets_main_box_new (_tmp12_, _tmp13_, NULL);
	g_object_ref_sink (_tmp14_);
	_tmp15_ = _tmp14_;
	proton_plus_widgets_window_set_main_box (self, _tmp15_);
	_g_object_unref0 (_tmp15_);
	_tmp16_ = self->priv->_header_box;
	g_signal_connect_object (_tmp16_, "download-selected", (GCallback) ___lambda341__proton_plus_widgets_header_box_download_selected, self, 0);
	_tmp17_ = (AdwToolbarView*) adw_toolbar_view_new ();
	g_object_ref_sink (_tmp17_);
	_tmp18_ = _tmp17_;
	proton_plus_widgets_window_set_toolbar_view (self, _tmp18_);
	_g_object_unref0 (_tmp18_);
	_tmp19_ = self->priv->_toolbar_view;
	_tmp20_ = self->priv->_header_box;
	adw_toolbar_view_add_top_bar (_tmp19_, (GtkWidget*) _tmp20_);
	_tmp21_ = proton_plus_widgets_controller_hint_bar_new ();
	g_object_ref_sink (_tmp21_);
	_tmp22_ = _tmp21_;
	proton_plus_widgets_window_set_controller_hint_bar (self, _tmp22_);
	_g_object_unref0 (_tmp22_);
	_tmp23_ = self->priv->_controller_hint_bar;
	_tmp24_ = self->priv->_controller_manager;
	_tmp25_ = proton_plus_utils_controller_manager_get_presentation_state (_tmp24_);
	_tmp26_ = _tmp25_;
	proton_plus_widgets_controller_hint_bar_update_state (_tmp23_, _tmp26_);
	_tmp27_ = self->priv->_toolbar_view;
	_tmp28_ = self->priv->_controller_hint_bar;
	adw_toolbar_view_add_bottom_bar (_tmp27_, (GtkWidget*) _tmp28_);
	_tmp29_ = self->priv->_toolbar_view;
	_tmp30_ = self->priv->_loading_box;
	adw_toolbar_view_set_content (_tmp29_, (GtkWidget*) _tmp30_);
	_tmp31_ = self->priv->_toolbar_view;
	adw_application_window_set_content ((AdwApplicationWindow*) self, (GtkWidget*) _tmp31_);
	_tmp32_ = self->priv->_controller_manager;
	proton_plus_utils_controller_manager_presentation_context_changed (_tmp32_);
	_tmp33_ = self->priv->_loading_box;
	proton_plus_widgets_loading_box_load (_tmp33_, NULL, NULL);
}

void
proton_plus_widgets_window_reload_ui (ProtonPlusWidgetsWindow* self)
{
	GListModel* toplevels = NULL;
	GListModel* _tmp0_;
	GListModel* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = gtk_window_get_toplevels ();
	_tmp1_ = _g_object_ref0 (_tmp0_);
	toplevels = _tmp1_;
	{
		guint i = 0U;
		i = (guint) 0;
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = TRUE;
			while (TRUE) {
				GListModel* _tmp4_;
				GtkPopover* popover = NULL;
				GListModel* _tmp5_;
				GObject* _tmp6_;
				GtkPopover* _tmp7_;
				gboolean _tmp8_ = FALSE;
				GtkPopover* _tmp9_;
				if (!_tmp2_) {
					guint _tmp3_;
					_tmp3_ = i;
					i = _tmp3_ + 1;
				}
				_tmp2_ = FALSE;
				_tmp4_ = toplevels;
				if (!(i < g_list_model_get_n_items (_tmp4_))) {
					break;
				}
				_tmp5_ = toplevels;
				_tmp6_ = g_list_model_get_item (_tmp5_, i);
				_tmp7_ = G_TYPE_CHECK_INSTANCE_TYPE (_tmp6_, gtk_popover_get_type ()) ? ((GtkPopover*) _tmp6_) : NULL;
				if (_tmp7_ == NULL) {
					_g_object_unref0 (_tmp6_);
				}
				popover = _tmp7_;
				_tmp9_ = popover;
				if (_tmp9_ != NULL) {
					GtkPopover* _tmp10_;
					GtkRoot* _tmp11_;
					_tmp10_ = popover;
					_tmp11_ = gtk_widget_get_root ((GtkWidget*) _tmp10_);
					_tmp8_ = _tmp11_ == G_TYPE_CHECK_INSTANCE_CAST (self, gtk_root_get_type (), GtkRoot);
				} else {
					_tmp8_ = FALSE;
				}
				if (_tmp8_) {
					GtkPopover* _tmp12_;
					_tmp12_ = popover;
					gtk_popover_popdown (_tmp12_);
				}
				_g_object_unref0 (popover);
			}
		}
	}
	proton_plus_widgets_window_build_ui (self);
	_g_object_unref0 (toplevels);
}

void
proton_plus_widgets_window_reload (ProtonPlusWidgetsWindow* self)
{
	AdwToolbarView* _tmp0_;
	ProtonPlusWidgetsLoadingBox* _tmp1_;
	ProtonPlusWidgetsLoadingBox* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_toolbar_view;
	_tmp1_ = self->priv->_loading_box;
	adw_toolbar_view_set_content (_tmp0_, (GtkWidget*) _tmp1_);
	_tmp2_ = self->priv->_loading_box;
	proton_plus_widgets_loading_box_load (_tmp2_, NULL, NULL);
}

static void
__lambda342_ (ProtonPlusWidgetsWindow* self,
              const gchar* response)
{
	ProtonPlusUtilsControllerManager* _tmp0_;
	GtkApplication* _tmp1_;
	GtkApplication* _tmp2_;
	g_return_if_fail (response != NULL);
	if (g_strcmp0 (response, "exit") != 0) {
		return;
	}
	_tmp0_ = self->priv->_controller_manager;
	proton_plus_utils_controller_manager_stop (_tmp0_);
	_tmp1_ = gtk_window_get_application ((GtkWindow*) self);
	_tmp2_ = _tmp1_;
	g_application_quit ((GApplication*) _tmp2_);
}

static void
___lambda342__adw_alert_dialog_response (AdwAlertDialog* _sender,
                                         const gchar* response,
                                         gpointer self)
{
	__lambda342_ ((ProtonPlusWidgetsWindow*) self, response);
}

static gboolean
proton_plus_widgets_window_real_close_request (GtkWindow* base)
{
	ProtonPlusWidgetsWindow * self;
	ProtonPlusUtilsDownloadManager* _tmp0_;
	ProtonPlusUtilsDownloadManager* _tmp1_;
	GeeLinkedList* _tmp2_;
	GeeLinkedList* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	AdwAlertDialog* dialog = NULL;
	AdwAlertDialog* _tmp7_;
	AdwAlertDialog* _tmp8_;
	AdwAlertDialog* _tmp9_;
	AdwAlertDialog* _tmp10_;
	AdwAlertDialog* _tmp11_;
	AdwAlertDialog* _tmp12_;
	AdwAlertDialog* _tmp13_;
	AdwAlertDialog* _tmp14_;
	AdwAlertDialog* _tmp15_;
	gboolean result;
	self = (ProtonPlusWidgetsWindow*) base;
	_tmp0_ = proton_plus_utils_download_manager_get_instance ();
	_tmp1_ = _tmp0_;
	_tmp2_ = proton_plus_utils_download_manager_get_active_downloads (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp3_);
	_tmp5_ = _tmp4_;
	if (_tmp5_ == 0) {
		ProtonPlusUtilsControllerManager* _tmp6_;
		_tmp6_ = self->priv->_controller_manager;
		proton_plus_utils_controller_manager_stop (_tmp6_);
		result = FALSE;
		return result;
	}
	_tmp7_ = (AdwAlertDialog*) adw_alert_dialog_new (_ ("Warning"), _ ("The application is currently downloading a tool.\n" \
"Exiting the application early may cause issues."));
	g_object_ref_sink (_tmp7_);
	dialog = _tmp7_;
	_tmp8_ = dialog;
	adw_alert_dialog_add_response (_tmp8_, "exit", _ ("Exit"));
	_tmp9_ = dialog;
	adw_alert_dialog_set_response_appearance (_tmp9_, "exit", ADW_RESPONSE_DESTRUCTIVE);
	_tmp10_ = dialog;
	adw_alert_dialog_add_response (_tmp10_, "cancel", _ ("Cancel"));
	_tmp11_ = dialog;
	adw_alert_dialog_set_response_appearance (_tmp11_, "cancel", ADW_RESPONSE_SUGGESTED);
	_tmp12_ = dialog;
	adw_alert_dialog_set_default_response (_tmp12_, "cancel");
	_tmp13_ = dialog;
	adw_alert_dialog_set_close_response (_tmp13_, "cancel");
	_tmp14_ = dialog;
	g_signal_connect_object (_tmp14_, "response", (GCallback) ___lambda342__adw_alert_dialog_response, self, 0);
	_tmp15_ = dialog;
	proton_plus_widgets_window_present_controller_dialog (self, (AdwDialog*) _tmp15_, NULL);
	result = TRUE;
	_g_object_unref0 (dialog);
	return result;
}

static void
proton_plus_widgets_window_real_dispose (GObject* base)
{
	ProtonPlusWidgetsWindow * self;
	ProtonPlusUtilsControllerManager* _tmp1_;
	self = (ProtonPlusWidgetsWindow*) base;
	if (self->priv->controller_presentation_handler != ((gulong) 0)) {
		ProtonPlusUtilsControllerManager* _tmp0_;
		_tmp0_ = self->priv->_controller_manager;
		g_signal_handler_disconnect ((GObject*) _tmp0_, self->priv->controller_presentation_handler);
		self->priv->controller_presentation_handler = (gulong) 0;
	}
	_tmp1_ = self->priv->_controller_manager;
	proton_plus_utils_controller_manager_stop (_tmp1_);
	G_OBJECT_CLASS (proton_plus_widgets_window_parent_class)->dispose ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, adw_application_window_get_type (), AdwApplicationWindow));
}

GeeLinkedList*
proton_plus_widgets_window_get_launchers (ProtonPlusWidgetsWindow* self)
{
	GeeLinkedList* result;
	GeeLinkedList* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_launchers;
	result = _tmp0_;
	return result;
}

void
proton_plus_widgets_window_set_launchers (ProtonPlusWidgetsWindow* self,
                                          GeeLinkedList* value)
{
	GeeLinkedList* old_value;
	g_return_if_fail (self != NULL);
	old_value = proton_plus_widgets_window_get_launchers (self);
	if (old_value != value) {
		GeeLinkedList* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_launchers);
		self->priv->_launchers = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, proton_plus_widgets_window_properties[PROTON_PLUS_WIDGETS_WINDOW_LAUNCHERS_PROPERTY]);
	}
}

static ProtonPlusUtilsControllerManager*
proton_plus_widgets_window_get_controller_manager (ProtonPlusWidgetsWindow* self)
{
	ProtonPlusUtilsControllerManager* result;
	ProtonPlusUtilsControllerManager* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_controller_manager;
	result = _tmp0_;
	return result;
}

static void
proton_plus_widgets_window_set_controller_manager (ProtonPlusWidgetsWindow* self,
                                                   ProtonPlusUtilsControllerManager* value)
{
	ProtonPlusUtilsControllerManager* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_controller_manager);
	self->priv->_controller_manager = _tmp0_;
}

static ProtonPlusWidgetsHeaderBox*
proton_plus_widgets_window_get_header_box (ProtonPlusWidgetsWindow* self)
{
	ProtonPlusWidgetsHeaderBox* result;
	ProtonPlusWidgetsHeaderBox* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_header_box;
	result = _tmp0_;
	return result;
}

static void
proton_plus_widgets_window_set_header_box (ProtonPlusWidgetsWindow* self,
                                           ProtonPlusWidgetsHeaderBox* value)
{
	ProtonPlusWidgetsHeaderBox* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_header_box);
	self->priv->_header_box = _tmp0_;
}

static ProtonPlusWidgetsLoadingBox*
proton_plus_widgets_window_get_loading_box (ProtonPlusWidgetsWindow* self)
{
	ProtonPlusWidgetsLoadingBox* result;
	ProtonPlusWidgetsLoadingBox* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_loading_box;
	result = _tmp0_;
	return result;
}

static void
proton_plus_widgets_window_set_loading_box (ProtonPlusWidgetsWindow* self,
                                            ProtonPlusWidgetsLoadingBox* value)
{
	ProtonPlusWidgetsLoadingBox* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_loading_box);
	self->priv->_loading_box = _tmp0_;
}

ProtonPlusWidgetsMainBox*
proton_plus_widgets_window_get_main_box (ProtonPlusWidgetsWindow* self)
{
	ProtonPlusWidgetsMainBox* result;
	ProtonPlusWidgetsMainBox* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_main_box;
	result = _tmp0_;
	return result;
}

void
proton_plus_widgets_window_set_main_box (ProtonPlusWidgetsWindow* self,
                                         ProtonPlusWidgetsMainBox* value)
{
	ProtonPlusWidgetsMainBox* old_value;
	g_return_if_fail (self != NULL);
	old_value = proton_plus_widgets_window_get_main_box (self);
	if (old_value != value) {
		ProtonPlusWidgetsMainBox* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_main_box);
		self->priv->_main_box = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, proton_plus_widgets_window_properties[PROTON_PLUS_WIDGETS_WINDOW_MAIN_BOX_PROPERTY]);
	}
}

static AdwToolbarView*
proton_plus_widgets_window_get_toolbar_view (ProtonPlusWidgetsWindow* self)
{
	AdwToolbarView* result;
	AdwToolbarView* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_toolbar_view;
	result = _tmp0_;
	return result;
}

static void
proton_plus_widgets_window_set_toolbar_view (ProtonPlusWidgetsWindow* self,
                                             AdwToolbarView* value)
{
	AdwToolbarView* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_toolbar_view);
	self->priv->_toolbar_view = _tmp0_;
}

static ProtonPlusWidgetsControllerHintBar*
proton_plus_widgets_window_get_controller_hint_bar (ProtonPlusWidgetsWindow* self)
{
	ProtonPlusWidgetsControllerHintBar* result;
	ProtonPlusWidgetsControllerHintBar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_controller_hint_bar;
	result = _tmp0_;
	return result;
}

static void
proton_plus_widgets_window_set_controller_hint_bar (ProtonPlusWidgetsWindow* self,
                                                    ProtonPlusWidgetsControllerHintBar* value)
{
	ProtonPlusWidgetsControllerHintBar* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_controller_hint_bar);
	self->priv->_controller_hint_bar = _tmp0_;
}

static void
proton_plus_widgets_window_class_init (ProtonPlusWidgetsWindowClass * klass,
                                       gpointer klass_data)
{
	proton_plus_widgets_window_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ProtonPlusWidgetsWindow_private_offset);
	((GtkWindowClass *) klass)->close_request = (gboolean (*) (GtkWindow*)) proton_plus_widgets_window_real_close_request;
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) proton_plus_widgets_window_real_dispose;
	G_OBJECT_CLASS (klass)->get_property = _vala_proton_plus_widgets_window_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_proton_plus_widgets_window_set_property;
	G_OBJECT_CLASS (klass)->finalize = proton_plus_widgets_window_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_WIDGETS_WINDOW_LAUNCHERS_PROPERTY, proton_plus_widgets_window_properties[PROTON_PLUS_WIDGETS_WINDOW_LAUNCHERS_PROPERTY] = g_param_spec_object ("launchers", "launchers", "launchers", GEE_TYPE_LINKED_LIST, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_WIDGETS_WINDOW_MAIN_BOX_PROPERTY, proton_plus_widgets_window_properties[PROTON_PLUS_WIDGETS_WINDOW_MAIN_BOX_PROPERTY] = g_param_spec_object ("main-box", "main-box", "main-box", PROTON_PLUS_WIDGETS_MAIN_TYPE_BOX, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
proton_plus_widgets_window_instance_init (ProtonPlusWidgetsWindow * self,
                                          gpointer klass)
{
	self->priv = proton_plus_widgets_window_get_instance_private (self);
	self->priv->controller_presentation_handler = (gulong) 0;
}

static void
proton_plus_widgets_window_finalize (GObject * obj)
{
	ProtonPlusWidgetsWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PROTON_PLUS_WIDGETS_TYPE_WINDOW, ProtonPlusWidgetsWindow);
	_g_object_unref0 (self->priv->_launchers);
	_g_object_unref0 (self->priv->_controller_manager);
	_g_object_unref0 (self->priv->_header_box);
	_g_object_unref0 (self->priv->_loading_box);
	_g_object_unref0 (self->priv->_main_box);
	_g_object_unref0 (self->priv->_toolbar_view);
	_g_object_unref0 (self->priv->_controller_hint_bar);
	_g_object_unref0 (self->priv->restart_manager);
	_g_object_unref0 (self->priv->restart_orchestrator);
	G_OBJECT_CLASS (proton_plus_widgets_window_parent_class)->finalize (obj);
}

static GType
proton_plus_widgets_window_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusWidgetsWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_widgets_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusWidgetsWindow), 0, (GInstanceInitFunc) proton_plus_widgets_window_instance_init, NULL };
	GType proton_plus_widgets_window_type_id;
	proton_plus_widgets_window_type_id = g_type_register_static (adw_application_window_get_type (), "ProtonPlusWidgetsWindow", &g_define_type_info, 0);
	ProtonPlusWidgetsWindow_private_offset = g_type_add_instance_private (proton_plus_widgets_window_type_id, sizeof (ProtonPlusWidgetsWindowPrivate));
	return proton_plus_widgets_window_type_id;
}

GType
proton_plus_widgets_window_get_type (void)
{
	static volatile gsize proton_plus_widgets_window_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_widgets_window_type_id__once)) {
		GType proton_plus_widgets_window_type_id;
		proton_plus_widgets_window_type_id = proton_plus_widgets_window_get_type_once ();
		g_once_init_leave (&proton_plus_widgets_window_type_id__once, proton_plus_widgets_window_type_id);
	}
	return proton_plus_widgets_window_type_id__once;
}

static void
_vala_proton_plus_widgets_window_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec)
{
	ProtonPlusWidgetsWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PROTON_PLUS_WIDGETS_TYPE_WINDOW, ProtonPlusWidgetsWindow);
	switch (property_id) {
		case PROTON_PLUS_WIDGETS_WINDOW_LAUNCHERS_PROPERTY:
		g_value_set_object (value, proton_plus_widgets_window_get_launchers (self));
		break;
		case PROTON_PLUS_WIDGETS_WINDOW_MAIN_BOX_PROPERTY:
		g_value_set_object (value, proton_plus_widgets_window_get_main_box (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_proton_plus_widgets_window_set_property (GObject * object,
                                               guint property_id,
                                               const GValue * value,
                                               GParamSpec * pspec)
{
	ProtonPlusWidgetsWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PROTON_PLUS_WIDGETS_TYPE_WINDOW, ProtonPlusWidgetsWindow);
	switch (property_id) {
		case PROTON_PLUS_WIDGETS_WINDOW_LAUNCHERS_PROPERTY:
		proton_plus_widgets_window_set_launchers (self, g_value_get_object (value));
		break;
		case PROTON_PLUS_WIDGETS_WINDOW_MAIN_BOX_PROPERTY:
		proton_plus_widgets_window_set_main_box (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

