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

/* -*- Mode: vala; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * Copyright © 2025 Johan Gay
 *
 * This file is part of GNOME Sudoku.
 *
 * GNOME Sudoku is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * GNOME Sudoku is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with GNOME Sudoku. If not, see <http://www.gnu.org/licenses/>.
 */

#include <adwaita.h>
#include <glib-object.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "libsudoku.h"
#include <glib.h>
#include <gio/gio.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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define TYPE_SUDOKU_START_VIEW (sudoku_start_view_get_type ())
#define SUDOKU_START_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SUDOKU_START_VIEW, SudokuStartView))
#define SUDOKU_START_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SUDOKU_START_VIEW, SudokuStartViewClass))
#define IS_SUDOKU_START_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SUDOKU_START_VIEW))
#define IS_SUDOKU_START_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SUDOKU_START_VIEW))
#define SUDOKU_START_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SUDOKU_START_VIEW, SudokuStartViewClass))

typedef struct _SudokuStartView SudokuStartView;
typedef struct _SudokuStartViewClass SudokuStartViewClass;
typedef struct _SudokuStartViewPrivate SudokuStartViewPrivate;
enum  {
	SUDOKU_START_VIEW_0_PROPERTY,
	SUDOKU_START_VIEW_NUM_PROPERTIES
};
static GParamSpec* sudoku_start_view_properties[SUDOKU_START_VIEW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

#define TYPE_SUDOKU (sudoku_get_type ())
#define SUDOKU(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SUDOKU, Sudoku))
#define SUDOKU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SUDOKU, SudokuClass))
#define IS_SUDOKU(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SUDOKU))
#define IS_SUDOKU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SUDOKU))
#define SUDOKU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SUDOKU, SudokuClass))

typedef struct _Sudoku Sudoku;
typedef struct _SudokuClass SudokuClass;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

#define TYPE_SUDOKU_MENU_BUTTON (sudoku_menu_button_get_type ())
#define SUDOKU_MENU_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SUDOKU_MENU_BUTTON, SudokuMenuButton))
#define SUDOKU_MENU_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SUDOKU_MENU_BUTTON, SudokuMenuButtonClass))
#define IS_SUDOKU_MENU_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SUDOKU_MENU_BUTTON))
#define IS_SUDOKU_MENU_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SUDOKU_MENU_BUTTON))
#define SUDOKU_MENU_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SUDOKU_MENU_BUTTON, SudokuMenuButtonClass))

typedef struct _SudokuMenuButton SudokuMenuButton;
typedef struct _SudokuMenuButtonClass SudokuMenuButtonClass;

struct _SudokuStartView {
	AdwBin parent_instance;
	SudokuStartViewPrivate * priv;
	AdwHeaderBar* headerbar;
	GdkClipboard* clipboard;
};

struct _SudokuStartViewClass {
	AdwBinClass parent_class;
};

struct _SudokuStartViewPrivate {
	GtkCheckButton* custom_check;
	GtkCheckButton* easy_check;
	GtkCheckButton* medium_check;
	GtkCheckButton* hard_check;
	GtkCheckButton* very_hard_check;
	GtkButton* start_button;
	GtkButton* open_button_pill;
	GtkButton* back_button;
	GtkStack* start_open_stack;
	GtkBox* open_and_shared_box;
	SudokuBackend* backend;
	guint clipboard_timeout;
	gulong clipboard_handle;
	GCancellable* clipboard_cancellable;
	gchar* clipboard_string;
};

static gint SudokuStartView_private_offset;
static gpointer sudoku_start_view_parent_class = NULL;
VALA_EXTERN Sudoku* sudoku_app;

VALA_EXTERN GType sudoku_start_view_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SudokuStartView, g_object_unref)
VALA_EXTERN void sudoku_start_view_init (SudokuStartView* self,
                             SudokuBackend* backend,
                             GdkClipboard* clipboard);
VALA_EXTERN void sudoku_start_view_activate_difficulty_checkbutton (SudokuStartView* self);
static void __lambda5_ (SudokuStartView* self);
static void ___lambda5__g_object_notify (GObject* _sender,
                                  GParamSpec* pspec,
                                  gpointer self);
static void sudoku_start_view_start_game_cb (SudokuStartView* self,
                                      GtkButton* btn);
static gboolean* _bool_dup (gboolean* self);
static void _sudoku_start_view_start_game_cb_gtk_button_clicked (GtkButton* _sender,
                                                          gpointer self);
static void sudoku_start_view_open_file_cb (SudokuStartView* self);
static void _sudoku_start_view_open_file_cb_gtk_button_clicked (GtkButton* _sender,
                                                         gpointer self);
static void sudoku_start_view_custom_checkbutton_activated_cb (SudokuStartView* self);
static void sudoku_start_view_clipboard_cb (SudokuStartView* self);
static void _sudoku_start_view_clipboard_cb_gdk_clipboard_changed (GdkClipboard* _sender,
                                                            gpointer self);
static void _sudoku_start_view_custom_checkbutton_activated_cb_adw_action_row_activated (AdwActionRow* _sender,
                                                                                  gpointer self);
static void sudoku_start_view_difficulty_checkbutton_activated_cb (SudokuStartView* self);
static void _sudoku_start_view_difficulty_checkbutton_activated_cb_adw_action_row_activated (AdwActionRow* _sender,
                                                                                      gpointer self);
static void sudoku_start_view_start_shared_game_cb (SudokuStartView* self);
static void _sudoku_start_view_start_shared_game_cb_gtk_button_clicked (GtkButton* _sender,
                                                                 gpointer self);
VALA_EXTERN void sudoku_start_view_set_back_button_visible (SudokuStartView* self,
                                                gboolean enabled);
VALA_EXTERN GType sudoku_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Sudoku, g_object_unref)
VALA_EXTERN DifficultyCategory sudoku_get_start_button_selected (Sudoku* self);
VALA_EXTERN void sudoku_start_view_disconnect_clipboard (SudokuStartView* self);
VALA_EXTERN void sudoku_start_view_connect_clipboard (SudokuStartView* self);
static void __lambda6_ (SudokuStartView* self);
static void ___lambda6__gsource_once_func (gpointer self);
static void __lambda7_ (SudokuStartView* self,
                 GObject* obj,
                 GAsyncResult* res);
static void ___lambda7__gasync_ready_callback (GObject* source_object,
                                        GAsyncResult* res,
                                        gpointer self);
static gboolean sudoku_start_view_real_grab_focus (GtkWidget* base);
VALA_EXTERN SudokuStartView* sudoku_start_view_new (void);
VALA_EXTERN SudokuStartView* sudoku_start_view_construct (GType object_type);
VALA_EXTERN GType sudoku_menu_button_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SudokuMenuButton, g_object_unref)
static void sudoku_start_view_finalize (GObject * obj);
static GType sudoku_start_view_get_type_once (void);

static inline gpointer
sudoku_start_view_get_instance_private (SudokuStartView* self)
{
	return G_STRUCT_MEMBER_P (self, SudokuStartView_private_offset);
}

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

static void
__lambda5_ (SudokuStartView* self)
{
	SudokuBackend* _tmp0_;
	SudokuGame* _tmp1_;
	SudokuGame* _tmp2_;
	_tmp0_ = self->priv->backend;
	_tmp1_ = sudoku_backend_get_tgame (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ == NULL) {
		GtkStack* _tmp3_;
		GtkButton* _tmp4_;
		_tmp3_ = self->priv->start_open_stack;
		_tmp4_ = self->priv->open_button_pill;
		gtk_stack_set_visible_child (_tmp3_, (GtkWidget*) _tmp4_);
	} else {
		GtkCheckButton* _tmp5_;
		gboolean _tmp6_;
		gboolean _tmp7_;
		_tmp5_ = self->priv->custom_check;
		_tmp6_ = gtk_check_button_get_active (_tmp5_);
		_tmp7_ = _tmp6_;
		if (_tmp7_ == TRUE) {
			GtkStack* _tmp8_;
			GtkBox* _tmp9_;
			_tmp8_ = self->priv->start_open_stack;
			_tmp9_ = self->priv->open_and_shared_box;
			gtk_stack_set_visible_child (_tmp8_, (GtkWidget*) _tmp9_);
		}
	}
}

static void
___lambda5__g_object_notify (GObject* _sender,
                             GParamSpec* pspec,
                             gpointer self)
{
	__lambda5_ ((SudokuStartView*) self);
}

void
sudoku_start_view_init (SudokuStartView* self,
                        SudokuBackend* backend,
                        GdkClipboard* clipboard)
{
	SudokuBackend* _tmp0_;
	GdkClipboard* _tmp1_;
	SudokuBackend* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (backend != NULL);
	g_return_if_fail (clipboard != NULL);
	_tmp0_ = _g_object_ref0 (backend);
	_g_object_unref0 (self->priv->backend);
	self->priv->backend = _tmp0_;
	_tmp1_ = _g_object_ref0 (clipboard);
	_g_object_unref0 (self->clipboard);
	self->clipboard = _tmp1_;
	sudoku_start_view_activate_difficulty_checkbutton (self);
	_tmp2_ = self->priv->backend;
	g_signal_connect_object ((GObject*) _tmp2_, "notify::tgame", (GCallback) ___lambda5__g_object_notify, self, 0);
}

static gboolean*
_bool_dup (gboolean* self)
{
	gboolean* dup;
	dup = g_new0 (gboolean, 1);
	memcpy (dup, self, sizeof (gboolean));
	return dup;
}

static gpointer
__bool_dup0 (gpointer self)
{
	return self ? _bool_dup (self) : NULL;
}

static void
sudoku_start_view_start_game_cb (SudokuStartView* self,
                                 GtkButton* btn)
{
	GtkCheckButton* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (btn != NULL);
	_tmp0_ = self->priv->easy_check;
	_tmp1_ = gtk_check_button_get_active (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		GtkWidget* _tmp3_ = NULL;
		gboolean* _tmp4_ = NULL;
		_tmp3_ = G_TYPE_CHECK_INSTANCE_TYPE (self, gtk_widget_get_type ()) ? ((GtkWidget*) self) : NULL;
		_tmp4_ = NULL;
		if (_tmp3_ != NULL) {
			gboolean _tmp5_;
			gboolean* _tmp6_;
			_tmp5_ = gtk_widget_activate_action (_tmp3_, "app.start-game", "i", 1, NULL);
			_tmp6_ = __bool_dup0 (&_tmp5_);
			_g_free0 (_tmp4_);
			_tmp4_ = _tmp6_;
		}
		_g_free0 (_tmp4_);
	} else {
		GtkCheckButton* _tmp7_;
		gboolean _tmp8_;
		gboolean _tmp9_;
		_tmp7_ = self->priv->medium_check;
		_tmp8_ = gtk_check_button_get_active (_tmp7_);
		_tmp9_ = _tmp8_;
		if (_tmp9_) {
			GtkWidget* _tmp10_ = NULL;
			gboolean* _tmp11_ = NULL;
			_tmp10_ = G_TYPE_CHECK_INSTANCE_TYPE (self, gtk_widget_get_type ()) ? ((GtkWidget*) self) : NULL;
			_tmp11_ = NULL;
			if (_tmp10_ != NULL) {
				gboolean _tmp12_;
				gboolean* _tmp13_;
				_tmp12_ = gtk_widget_activate_action (_tmp10_, "app.start-game", "i", 2, NULL);
				_tmp13_ = __bool_dup0 (&_tmp12_);
				_g_free0 (_tmp11_);
				_tmp11_ = _tmp13_;
			}
			_g_free0 (_tmp11_);
		} else {
			GtkCheckButton* _tmp14_;
			gboolean _tmp15_;
			gboolean _tmp16_;
			_tmp14_ = self->priv->hard_check;
			_tmp15_ = gtk_check_button_get_active (_tmp14_);
			_tmp16_ = _tmp15_;
			if (_tmp16_) {
				GtkWidget* _tmp17_ = NULL;
				gboolean* _tmp18_ = NULL;
				_tmp17_ = G_TYPE_CHECK_INSTANCE_TYPE (self, gtk_widget_get_type ()) ? ((GtkWidget*) self) : NULL;
				_tmp18_ = NULL;
				if (_tmp17_ != NULL) {
					gboolean _tmp19_;
					gboolean* _tmp20_;
					_tmp19_ = gtk_widget_activate_action (_tmp17_, "app.start-game", "i", 3, NULL);
					_tmp20_ = __bool_dup0 (&_tmp19_);
					_g_free0 (_tmp18_);
					_tmp18_ = _tmp20_;
				}
				_g_free0 (_tmp18_);
			} else {
				GtkCheckButton* _tmp21_;
				gboolean _tmp22_;
				gboolean _tmp23_;
				_tmp21_ = self->priv->very_hard_check;
				_tmp22_ = gtk_check_button_get_active (_tmp21_);
				_tmp23_ = _tmp22_;
				if (_tmp23_) {
					GtkWidget* _tmp24_ = NULL;
					gboolean* _tmp25_ = NULL;
					_tmp24_ = G_TYPE_CHECK_INSTANCE_TYPE (self, gtk_widget_get_type ()) ? ((GtkWidget*) self) : NULL;
					_tmp25_ = NULL;
					if (_tmp24_ != NULL) {
						gboolean _tmp26_;
						gboolean* _tmp27_;
						_tmp26_ = gtk_widget_activate_action (_tmp24_, "app.start-game", "i", 4, NULL);
						_tmp27_ = __bool_dup0 (&_tmp26_);
						_g_free0 (_tmp25_);
						_tmp25_ = _tmp27_;
					}
					_g_free0 (_tmp25_);
				}
			}
		}
	}
}

static void
_sudoku_start_view_start_game_cb_gtk_button_clicked (GtkButton* _sender,
                                                     gpointer self)
{
	sudoku_start_view_start_game_cb ((SudokuStartView*) self, _sender);
}

static void
sudoku_start_view_open_file_cb (SudokuStartView* self)
{
	g_return_if_fail (self != NULL);
	gtk_widget_activate_action (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), "app.open-file", NULL, NULL);
}

static void
_sudoku_start_view_open_file_cb_gtk_button_clicked (GtkButton* _sender,
                                                    gpointer self)
{
	sudoku_start_view_open_file_cb ((SudokuStartView*) self);
}

static void
_sudoku_start_view_clipboard_cb_gdk_clipboard_changed (GdkClipboard* _sender,
                                                       gpointer self)
{
	sudoku_start_view_clipboard_cb ((SudokuStartView*) self);
}

static void
sudoku_start_view_custom_checkbutton_activated_cb (SudokuStartView* self)
{
	SudokuBackend* _tmp2_;
	SudokuGame* _tmp3_;
	SudokuGame* _tmp4_;
	g_return_if_fail (self != NULL);
	if (self->priv->clipboard_handle == ((gulong) 0)) {
		GdkClipboard* _tmp0_;
		gulong _tmp1_;
		_tmp0_ = self->clipboard;
		_tmp1_ = g_signal_connect_object (_tmp0_, "changed", (GCallback) _sudoku_start_view_clipboard_cb_gdk_clipboard_changed, self, 0);
		self->priv->clipboard_handle = _tmp1_;
		sudoku_start_view_clipboard_cb (self);
	}
	_tmp2_ = self->priv->backend;
	_tmp3_ = sudoku_backend_get_tgame (_tmp2_);
	_tmp4_ = _tmp3_;
	if (_tmp4_ == NULL) {
		GtkStack* _tmp5_;
		GtkButton* _tmp6_;
		_tmp5_ = self->priv->start_open_stack;
		_tmp6_ = self->priv->open_button_pill;
		gtk_stack_set_visible_child (_tmp5_, (GtkWidget*) _tmp6_);
	} else {
		GtkStack* _tmp7_;
		GtkBox* _tmp8_;
		_tmp7_ = self->priv->start_open_stack;
		_tmp8_ = self->priv->open_and_shared_box;
		gtk_stack_set_visible_child (_tmp7_, (GtkWidget*) _tmp8_);
	}
}

static void
_sudoku_start_view_custom_checkbutton_activated_cb_adw_action_row_activated (AdwActionRow* _sender,
                                                                             gpointer self)
{
	sudoku_start_view_custom_checkbutton_activated_cb ((SudokuStartView*) self);
}

static void
sudoku_start_view_difficulty_checkbutton_activated_cb (SudokuStartView* self)
{
	GtkStack* _tmp0_;
	GtkButton* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->start_open_stack;
	_tmp1_ = self->priv->start_button;
	gtk_stack_set_visible_child (_tmp0_, (GtkWidget*) _tmp1_);
	if (self->priv->clipboard_handle != ((gulong) 0)) {
		GdkClipboard* _tmp2_;
		guint _tmp3_;
		_tmp2_ = self->clipboard;
		g_signal_parse_name ("changed", gdk_clipboard_get_type (), &_tmp3_, NULL, FALSE);
		g_signal_handlers_disconnect_matched (_tmp2_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp3_, 0, NULL, (GCallback) _sudoku_start_view_clipboard_cb_gdk_clipboard_changed, self);
		self->priv->clipboard_handle = (gulong) 0;
	}
}

static void
_sudoku_start_view_difficulty_checkbutton_activated_cb_adw_action_row_activated (AdwActionRow* _sender,
                                                                                 gpointer self)
{
	sudoku_start_view_difficulty_checkbutton_activated_cb ((SudokuStartView*) self);
}

static void
sudoku_start_view_start_shared_game_cb (SudokuStartView* self)
{
	SudokuBackend* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->backend;
	sudoku_backend_start_shared_game (_tmp0_);
	_g_free0 (self->priv->clipboard_string);
	self->priv->clipboard_string = NULL;
}

static void
_sudoku_start_view_start_shared_game_cb_gtk_button_clicked (GtkButton* _sender,
                                                            gpointer self)
{
	sudoku_start_view_start_shared_game_cb ((SudokuStartView*) self);
}

void
sudoku_start_view_set_back_button_visible (SudokuStartView* self,
                                           gboolean enabled)
{
	GtkButton* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->back_button;
	gtk_widget_set_visible ((GtkWidget*) _tmp0_, enabled);
}

void
sudoku_start_view_activate_difficulty_checkbutton (SudokuStartView* self)
{
	Sudoku* _tmp0_;
	DifficultyCategory _tmp1_;
	DifficultyCategory _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = sudoku_app;
	_tmp1_ = sudoku_get_start_button_selected (_tmp0_);
	_tmp2_ = _tmp1_;
	switch (_tmp2_) {
		case DIFFICULTY_CATEGORY_EASY:
		{
			GtkCheckButton* _tmp3_;
			GtkStack* _tmp4_;
			GtkButton* _tmp5_;
			_tmp3_ = self->priv->easy_check;
			gtk_check_button_set_active (_tmp3_, TRUE);
			_tmp4_ = self->priv->start_open_stack;
			_tmp5_ = self->priv->start_button;
			gtk_stack_set_visible_child (_tmp4_, (GtkWidget*) _tmp5_);
			return;
		}
		case DIFFICULTY_CATEGORY_MEDIUM:
		{
			GtkCheckButton* _tmp6_;
			GtkStack* _tmp7_;
			GtkButton* _tmp8_;
			_tmp6_ = self->priv->medium_check;
			gtk_check_button_set_active (_tmp6_, TRUE);
			_tmp7_ = self->priv->start_open_stack;
			_tmp8_ = self->priv->start_button;
			gtk_stack_set_visible_child (_tmp7_, (GtkWidget*) _tmp8_);
			return;
		}
		case DIFFICULTY_CATEGORY_HARD:
		{
			GtkCheckButton* _tmp9_;
			GtkStack* _tmp10_;
			GtkButton* _tmp11_;
			_tmp9_ = self->priv->hard_check;
			gtk_check_button_set_active (_tmp9_, TRUE);
			_tmp10_ = self->priv->start_open_stack;
			_tmp11_ = self->priv->start_button;
			gtk_stack_set_visible_child (_tmp10_, (GtkWidget*) _tmp11_);
			return;
		}
		case DIFFICULTY_CATEGORY_VERY_HARD:
		{
			GtkCheckButton* _tmp12_;
			GtkStack* _tmp13_;
			GtkButton* _tmp14_;
			_tmp12_ = self->priv->very_hard_check;
			gtk_check_button_set_active (_tmp12_, TRUE);
			_tmp13_ = self->priv->start_open_stack;
			_tmp14_ = self->priv->start_button;
			gtk_stack_set_visible_child (_tmp13_, (GtkWidget*) _tmp14_);
			return;
		}
		case DIFFICULTY_CATEGORY_CUSTOM:
		{
			GtkStack* _tmp15_;
			GtkButton* _tmp16_;
			GtkCheckButton* _tmp17_;
			_tmp15_ = self->priv->start_open_stack;
			_tmp16_ = self->priv->open_button_pill;
			gtk_stack_set_visible_child (_tmp15_, (GtkWidget*) _tmp16_);
			_tmp17_ = self->priv->custom_check;
			gtk_check_button_set_active (_tmp17_, TRUE);
			return;
		}
		default:
		{
			g_assert_not_reached ();
		}
	}
}

void
sudoku_start_view_disconnect_clipboard (SudokuStartView* self)
{
	g_return_if_fail (self != NULL);
	if (self->priv->clipboard_handle != ((gulong) 0)) {
		GdkClipboard* _tmp0_;
		guint _tmp1_;
		_tmp0_ = self->clipboard;
		g_signal_parse_name ("changed", gdk_clipboard_get_type (), &_tmp1_, NULL, FALSE);
		g_signal_handlers_disconnect_matched (_tmp0_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp1_, 0, NULL, (GCallback) _sudoku_start_view_clipboard_cb_gdk_clipboard_changed, self);
		self->priv->clipboard_handle = (gulong) 0;
	}
}

void
sudoku_start_view_connect_clipboard (SudokuStartView* self)
{
	gboolean _tmp0_ = FALSE;
	g_return_if_fail (self != NULL);
	if (self->priv->clipboard_handle == ((gulong) 0)) {
		GtkCheckButton* _tmp1_;
		gboolean _tmp2_;
		gboolean _tmp3_;
		_tmp1_ = self->priv->custom_check;
		_tmp2_ = gtk_check_button_get_active (_tmp1_);
		_tmp3_ = _tmp2_;
		_tmp0_ = _tmp3_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		GdkClipboard* _tmp4_;
		gulong _tmp5_;
		_tmp4_ = self->clipboard;
		_tmp5_ = g_signal_connect_object (_tmp4_, "changed", (GCallback) _sudoku_start_view_clipboard_cb_gdk_clipboard_changed, self, 0);
		self->priv->clipboard_handle = _tmp5_;
		sudoku_start_view_clipboard_cb (self);
	}
}

static void
__lambda6_ (SudokuStartView* self)
{
	GCancellable* _tmp0_;
	_tmp0_ = self->priv->clipboard_cancellable;
	g_cancellable_cancel (_tmp0_);
}

static void
___lambda6__gsource_once_func (gpointer self)
{
	__lambda6_ ((SudokuStartView*) self);
	g_object_unref (self);
}

static void
__lambda7_ (SudokuStartView* self,
            GObject* obj,
            GAsyncResult* res)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (res != NULL);
	{
		gchar* string = NULL;
		GdkClipboard* _tmp0_;
		gchar* _tmp1_;
		gboolean _tmp2_ = FALSE;
		const gchar* _tmp3_;
		_tmp0_ = self->clipboard;
		_tmp1_ = gdk_clipboard_read_text_finish (_tmp0_, res, &_inner_error0_);
		string = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		if (self->priv->clipboard_timeout != ((guint) 0)) {
			g_source_remove (self->priv->clipboard_timeout);
			self->priv->clipboard_timeout = (guint) 0;
		}
		_tmp3_ = self->priv->clipboard_string;
		if (_tmp3_ == NULL) {
			_tmp2_ = TRUE;
		} else {
			const gchar* _tmp4_;
			_tmp4_ = self->priv->clipboard_string;
			_tmp2_ = g_strcmp0 (_tmp4_, string) != 0;
		}
		if (_tmp2_) {
			SudokuBackend* _tmp5_;
			gchar* _tmp6_;
			_tmp5_ = self->priv->backend;
			sudoku_backend_check_clipboard (_tmp5_, string);
			_tmp6_ = g_strdup (string);
			_g_free0 (self->priv->clipboard_string);
			self->priv->clipboard_string = _tmp6_;
		}
		_g_free0 (string);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp7_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp7_ = e;
		if (_tmp7_->code != G_IO_ERROR_NOT_FOUND) {
			GError* _tmp8_;
			const gchar* _tmp9_;
			_tmp8_ = e;
			_tmp9_ = _tmp8_->message;
			g_warning ("start-view.vala:202: Error: %s", _tmp9_);
		}
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

static void
___lambda7__gasync_ready_callback (GObject* source_object,
                                   GAsyncResult* res,
                                   gpointer self)
{
	__lambda7_ ((SudokuStartView*) self, source_object, res);
	g_object_unref (self);
}

static void
sudoku_start_view_clipboard_cb (SudokuStartView* self)
{
	GCancellable* _tmp0_;
	GdkClipboard* _tmp1_;
	GCancellable* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_cancellable_new ();
	_g_object_unref0 (self->priv->clipboard_cancellable);
	self->priv->clipboard_cancellable = _tmp0_;
	self->priv->clipboard_timeout = g_timeout_add_once ((guint) 200, ___lambda6__gsource_once_func, g_object_ref (self));
	_tmp1_ = self->clipboard;
	_tmp2_ = self->priv->clipboard_cancellable;
	gdk_clipboard_read_text_async (_tmp1_, _tmp2_, ___lambda7__gasync_ready_callback, g_object_ref (self));
}

static gboolean
sudoku_start_view_real_grab_focus (GtkWidget* base)
{
	SudokuStartView * self;
	GtkStack* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	gboolean result;
	self = (SudokuStartView*) base;
	_tmp0_ = self->priv->start_open_stack;
	_tmp1_ = gtk_stack_get_visible_child (_tmp0_);
	_tmp2_ = _tmp1_;
	result = gtk_widget_grab_focus (_tmp2_);
	return result;
}

SudokuStartView*
sudoku_start_view_construct (GType object_type)
{
	SudokuStartView * self = NULL;
	self = (SudokuStartView*) g_object_new (object_type, NULL);
	return self;
}

SudokuStartView*
sudoku_start_view_new (void)
{
	return sudoku_start_view_construct (TYPE_SUDOKU_START_VIEW);
}

static void
sudoku_start_view_class_init (SudokuStartViewClass * klass,
                              gpointer klass_data)
{
	GtkNamedAction* action = NULL;
	GtkNamedAction* _tmp0_;
	GtkShortcutTrigger* alt_trigger = NULL;
	GtkShortcutTrigger* _tmp1_;
	GtkShortcut* shortcut = NULL;
	GtkShortcutTrigger* _tmp2_;
	GtkShortcutTrigger* _tmp3_;
	GtkNamedAction* _tmp4_;
	GtkShortcutAction* _tmp5_;
	GtkShortcut* _tmp6_;
	GtkShortcut* _tmp7_;
	sudoku_start_view_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &SudokuStartView_private_offset);
	((GtkWidgetClass *) klass)->grab_focus = (gboolean (*) (GtkWidget*)) sudoku_start_view_real_grab_focus;
	G_OBJECT_CLASS (klass)->finalize = sudoku_start_view_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Sudoku/ui/start-view.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "headerbar", FALSE, G_STRUCT_OFFSET (SudokuStartView, headerbar));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "custom_check", FALSE, SudokuStartView_private_offset + G_STRUCT_OFFSET (SudokuStartViewPrivate, custom_check));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "easy_check", FALSE, SudokuStartView_private_offset + G_STRUCT_OFFSET (SudokuStartViewPrivate, easy_check));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "medium_check", FALSE, SudokuStartView_private_offset + G_STRUCT_OFFSET (SudokuStartViewPrivate, medium_check));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "hard_check", FALSE, SudokuStartView_private_offset + G_STRUCT_OFFSET (SudokuStartViewPrivate, hard_check));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "very_hard_check", FALSE, SudokuStartView_private_offset + G_STRUCT_OFFSET (SudokuStartViewPrivate, very_hard_check));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "start_button", FALSE, SudokuStartView_private_offset + G_STRUCT_OFFSET (SudokuStartViewPrivate, start_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "open_button_pill", FALSE, SudokuStartView_private_offset + G_STRUCT_OFFSET (SudokuStartViewPrivate, open_button_pill));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "back_button", FALSE, SudokuStartView_private_offset + G_STRUCT_OFFSET (SudokuStartViewPrivate, back_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "start_open_stack", FALSE, SudokuStartView_private_offset + G_STRUCT_OFFSET (SudokuStartViewPrivate, start_open_stack));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "open_and_shared_box", FALSE, SudokuStartView_private_offset + G_STRUCT_OFFSET (SudokuStartViewPrivate, open_and_shared_box));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "start_game_cb", G_CALLBACK(_sudoku_start_view_start_game_cb_gtk_button_clicked));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "open_file_cb", G_CALLBACK(_sudoku_start_view_open_file_cb_gtk_button_clicked));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "custom_checkbutton_activated_cb", G_CALLBACK(_sudoku_start_view_custom_checkbutton_activated_cb_adw_action_row_activated));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "difficulty_checkbutton_activated_cb", G_CALLBACK(_sudoku_start_view_difficulty_checkbutton_activated_cb_adw_action_row_activated));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "start_shared_game_cb", G_CALLBACK(_sudoku_start_view_start_shared_game_cb_gtk_button_clicked));
	g_type_ensure (TYPE_SUDOKU_MENU_BUTTON);
	_tmp0_ = (GtkNamedAction*) gtk_named_action_new ("app.back");
	action = _tmp0_;
	_tmp1_ = gtk_shortcut_trigger_parse_string ("<Alt>Left|<Alt>KP_Left");
	alt_trigger = _tmp1_;
	_tmp2_ = alt_trigger;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	_tmp4_ = action;
	_tmp5_ = _g_object_ref0 ((GtkShortcutAction*) _tmp4_);
	_tmp6_ = gtk_shortcut_new (_tmp3_, _tmp5_);
	shortcut = _tmp6_;
	_tmp7_ = shortcut;
	gtk_widget_class_add_shortcut (GTK_WIDGET_CLASS (klass), _tmp7_);
	_g_object_unref0 (shortcut);
	_g_object_unref0 (alt_trigger);
	_g_object_unref0 (action);
}

static void
sudoku_start_view_instance_init (SudokuStartView * self,
                                 gpointer klass)
{
	self->priv = sudoku_start_view_get_instance_private (self);
	self->priv->clipboard_handle = (gulong) 0;
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
sudoku_start_view_finalize (GObject * obj)
{
	SudokuStartView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_SUDOKU_START_VIEW, SudokuStartView);
	_g_object_unref0 (self->priv->backend);
	_g_object_unref0 (self->priv->clipboard_cancellable);
	_g_free0 (self->priv->clipboard_string);
	_g_object_unref0 (self->clipboard);
	G_OBJECT_CLASS (sudoku_start_view_parent_class)->finalize (obj);
}

static GType
sudoku_start_view_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SudokuStartViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) sudoku_start_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SudokuStartView), 0, (GInstanceInitFunc) sudoku_start_view_instance_init, NULL };
	GType sudoku_start_view_type_id;
	sudoku_start_view_type_id = g_type_register_static (adw_bin_get_type (), "SudokuStartView", &g_define_type_info, 0);
	SudokuStartView_private_offset = g_type_add_instance_private (sudoku_start_view_type_id, sizeof (SudokuStartViewPrivate));
	return sudoku_start_view_type_id;
}

GType
sudoku_start_view_get_type (void)
{
	static volatile gsize sudoku_start_view_type_id__once = 0;
	if (g_once_init_enter (&sudoku_start_view_type_id__once)) {
		GType sudoku_start_view_type_id;
		sudoku_start_view_type_id = sudoku_start_view_get_type_once ();
		g_once_init_leave (&sudoku_start_view_type_id__once, sudoku_start_view_type_id);
	}
	return sudoku_start_view_type_id__once;
}

