/* preferences-window.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from preferences-window.vala, do not modify */

/* This file is part of GNOME Games. License: GPL-3.0+.*/

#include <handy.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <string.h>
#include "gnome-games.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 GAMES_TYPE_PREFERENCES_WINDOW (games_preferences_window_get_type ())
#define GAMES_PREFERENCES_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_PREFERENCES_WINDOW, GamesPreferencesWindow))
#define GAMES_PREFERENCES_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_PREFERENCES_WINDOW, GamesPreferencesWindowClass))
#define GAMES_IS_PREFERENCES_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_PREFERENCES_WINDOW))
#define GAMES_IS_PREFERENCES_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_PREFERENCES_WINDOW))
#define GAMES_PREFERENCES_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_PREFERENCES_WINDOW, GamesPreferencesWindowClass))

typedef struct _GamesPreferencesWindow GamesPreferencesWindow;
typedef struct _GamesPreferencesWindowClass GamesPreferencesWindowClass;
typedef struct _GamesPreferencesWindowPrivate GamesPreferencesWindowPrivate;

#define GAMES_TYPE_PREFERENCES_SUBPAGE (games_preferences_subpage_get_type ())
#define GAMES_PREFERENCES_SUBPAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_PREFERENCES_SUBPAGE, GamesPreferencesSubpage))
#define GAMES_IS_PREFERENCES_SUBPAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_PREFERENCES_SUBPAGE))
#define GAMES_PREFERENCES_SUBPAGE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GAMES_TYPE_PREFERENCES_SUBPAGE, GamesPreferencesSubpageIface))

typedef struct _GamesPreferencesSubpage GamesPreferencesSubpage;
typedef struct _GamesPreferencesSubpageIface GamesPreferencesSubpageIface;
enum  {
	GAMES_PREFERENCES_WINDOW_0_PROPERTY,
	GAMES_PREFERENCES_WINDOW_NUM_PROPERTIES
};
static GParamSpec* games_preferences_window_properties[GAMES_PREFERENCES_WINDOW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _GamesPreferencesWindow {
	HdyWindow parent_instance;
	GamesPreferencesWindowPrivate * priv;
};

struct _GamesPreferencesWindowClass {
	HdyWindowClass parent_class;
};

struct _GamesPreferencesSubpageIface {
	GTypeInterface parent_iface;
	gboolean (*get_allow_back) (GamesPreferencesSubpage* self);
	void (*set_allow_back) (GamesPreferencesSubpage* self, gboolean value);
};

struct _GamesPreferencesWindowPrivate {
	HdyDeck* deck;
	GtkBox* main_box;
	GtkBox* subpage_box;
	GamesPreferencesSubpage* subpage;
	GBinding* swipe_back_binding;
};

static gint GamesPreferencesWindow_private_offset;
static gpointer games_preferences_window_parent_class = NULL;

VALA_EXTERN GType games_preferences_window_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType games_preferences_subpage_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void games_preferences_window_try_remove_subpage (GamesPreferencesWindow* self);
static void _games_preferences_window_try_remove_subpage_g_object_notify (GObject* _sender,
                                                                   GParamSpec* pspec,
                                                                   gpointer self);
VALA_EXTERN void games_preferences_window_open_subpage (GamesPreferencesWindow* self,
                                            GamesPreferencesSubpage* subpage);
static void __lambda17_ (GamesPreferencesWindow* self);
static void ___lambda17__games_preferences_subpage_back (GamesPreferencesSubpage* _sender,
                                                  gpointer self);
VALA_EXTERN GamesPreferencesWindow* games_preferences_window_new (void);
VALA_EXTERN GamesPreferencesWindow* games_preferences_window_construct (GType object_type);
static void games_preferences_window_finalize (GObject * obj);
static GType games_preferences_window_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
games_preferences_window_get_instance_private (GamesPreferencesWindow* self)
{
	return G_STRUCT_MEMBER_P (self, GamesPreferencesWindow_private_offset);
}

void
games_preferences_window_try_remove_subpage (GamesPreferencesWindow* self)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	HdyDeck* _tmp2_;
	gboolean _tmp3_;
	gboolean _tmp4_;
	GtkBox* _tmp10_;
	GamesPreferencesSubpage* _tmp11_;
	g_return_if_fail (self != NULL);
	_tmp2_ = self->priv->deck;
	_tmp3_ = hdy_deck_get_transition_running (_tmp2_);
	_tmp4_ = _tmp3_;
	if (_tmp4_) {
		_tmp1_ = TRUE;
	} else {
		HdyDeck* _tmp5_;
		GtkWidget* _tmp6_;
		GtkWidget* _tmp7_;
		GtkBox* _tmp8_;
		_tmp5_ = self->priv->deck;
		_tmp6_ = hdy_deck_get_visible_child (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp8_ = self->priv->main_box;
		_tmp1_ = _tmp7_ != G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, gtk_widget_get_type (), GtkWidget);
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		GamesPreferencesSubpage* _tmp9_;
		_tmp9_ = self->priv->subpage;
		_tmp0_ = _tmp9_ == NULL;
	}
	if (_tmp0_) {
		return;
	}
	_tmp10_ = self->priv->subpage_box;
	_tmp11_ = self->priv->subpage;
	gtk_container_remove ((GtkContainer*) _tmp10_, (GtkWidget*) _tmp11_);
	_g_object_unref0 (self->priv->subpage);
	self->priv->subpage = NULL;
}

static void
_games_preferences_window_try_remove_subpage_g_object_notify (GObject* _sender,
                                                              GParamSpec* pspec,
                                                              gpointer self)
{
	games_preferences_window_try_remove_subpage ((GamesPreferencesWindow*) self);
}

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

static void
__lambda17_ (GamesPreferencesWindow* self)
{
	HdyDeck* _tmp0_;
	GBinding* _tmp1_;
	GBinding* _tmp2_;
	_tmp0_ = self->priv->deck;
	hdy_deck_navigate (_tmp0_, HDY_NAVIGATION_DIRECTION_BACK);
	_tmp1_ = self->priv->swipe_back_binding;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	g_binding_unbind (_tmp2_);
}

static void
___lambda17__games_preferences_subpage_back (GamesPreferencesSubpage* _sender,
                                             gpointer self)
{
	__lambda17_ ((GamesPreferencesWindow*) self);
}

void
games_preferences_window_open_subpage (GamesPreferencesWindow* self,
                                       GamesPreferencesSubpage* subpage)
{
	GamesPreferencesSubpage* _tmp0_;
	GamesPreferencesSubpage* _tmp1_;
	HdyDeck* _tmp2_;
	GBinding* _tmp3_;
	GBinding* _tmp4_;
	GtkBox* _tmp5_;
	HdyDeck* _tmp6_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (subpage != NULL);
	_tmp0_ = self->priv->subpage;
	if (_tmp0_ != NULL) {
		return;
	}
	_tmp1_ = _g_object_ref0 (subpage);
	_g_object_unref0 (self->priv->subpage);
	self->priv->subpage = _tmp1_;
	_tmp2_ = self->priv->deck;
	_tmp3_ = g_object_bind_property_with_closures ((GObject*) subpage, "allow-back", (GObject*) _tmp2_, "can-swipe-back", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp4_ = _g_object_ref0 (_tmp3_);
	_g_object_unref0 (self->priv->swipe_back_binding);
	self->priv->swipe_back_binding = _tmp4_;
	_tmp5_ = self->priv->subpage_box;
	gtk_container_add ((GtkContainer*) _tmp5_, (GtkWidget*) subpage);
	g_signal_connect_object (subpage, "back", (GCallback) ___lambda17__games_preferences_subpage_back, self, 0);
	_tmp6_ = self->priv->deck;
	hdy_deck_navigate (_tmp6_, HDY_NAVIGATION_DIRECTION_FORWARD);
}

GamesPreferencesWindow*
games_preferences_window_construct (GType object_type)
{
	GamesPreferencesWindow * self = NULL;
	self = (GamesPreferencesWindow*) g_object_new (object_type, NULL);
	return self;
}

GamesPreferencesWindow*
games_preferences_window_new (void)
{
	return games_preferences_window_construct (GAMES_TYPE_PREFERENCES_WINDOW);
}

static void
games_preferences_window_class_init (GamesPreferencesWindowClass * klass,
                                     gpointer klass_data)
{
	games_preferences_window_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GamesPreferencesWindow_private_offset);
	G_OBJECT_CLASS (klass)->finalize = games_preferences_window_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Games/preferences/preferences-window.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "deck", FALSE, GamesPreferencesWindow_private_offset + G_STRUCT_OFFSET (GamesPreferencesWindowPrivate, deck));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "main_box", FALSE, GamesPreferencesWindow_private_offset + G_STRUCT_OFFSET (GamesPreferencesWindowPrivate, main_box));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "subpage_box", FALSE, GamesPreferencesWindow_private_offset + G_STRUCT_OFFSET (GamesPreferencesWindowPrivate, subpage_box));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "try_remove_subpage", G_CALLBACK(_games_preferences_window_try_remove_subpage_g_object_notify));
}

static void
games_preferences_window_instance_init (GamesPreferencesWindow * self,
                                        gpointer klass)
{
	self->priv = games_preferences_window_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
games_preferences_window_finalize (GObject * obj)
{
	GamesPreferencesWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_PREFERENCES_WINDOW, GamesPreferencesWindow);
	_g_object_unref0 (self->priv->subpage);
	_g_object_unref0 (self->priv->swipe_back_binding);
	G_OBJECT_CLASS (games_preferences_window_parent_class)->finalize (obj);
}

static GType
games_preferences_window_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GamesPreferencesWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_preferences_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesPreferencesWindow), 0, (GInstanceInitFunc) games_preferences_window_instance_init, NULL };
	GType games_preferences_window_type_id;
	games_preferences_window_type_id = g_type_register_static (hdy_window_get_type (), "GamesPreferencesWindow", &g_define_type_info, 0);
	GamesPreferencesWindow_private_offset = g_type_add_instance_private (games_preferences_window_type_id, sizeof (GamesPreferencesWindowPrivate));
	return games_preferences_window_type_id;
}

GType
games_preferences_window_get_type (void)
{
	static volatile gsize games_preferences_window_type_id__once = 0;
	if (g_once_init_enter (&games_preferences_window_type_id__once)) {
		GType games_preferences_window_type_id;
		games_preferences_window_type_id = games_preferences_window_get_type_once ();
		g_once_init_leave (&games_preferences_window_type_id__once, games_preferences_window_type_id);
	}
	return games_preferences_window_type_id__once;
}

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

