/* new-game-screen.c generated by valac 0.56.18, the Vala compiler
 * generated from new-game-screen.vala, do not modify */

/* -*- Mode: vala; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
   This file is part of GNOME Four-in-a-row.

   Copyright 2010-2013 Robert Ancell
   Copyright 2013-2014 Michael Catanzaro
   Copyright 2014-2019 Arnaud Bonatti

   GNOME Four-in-a-row 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 Four-in-a-row 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 Four-in-a-row.  If not, see <https://www.gnu.org/licenses/>.
*/

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.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_ADAPTATIVE_WIDGET (adaptative_widget_get_type ())
#define ADAPTATIVE_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ADAPTATIVE_WIDGET, AdaptativeWidget))
#define IS_ADAPTATIVE_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ADAPTATIVE_WIDGET))
#define ADAPTATIVE_WIDGET_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_ADAPTATIVE_WIDGET, AdaptativeWidgetIface))

typedef struct _AdaptativeWidget AdaptativeWidget;
typedef struct _AdaptativeWidgetIface AdaptativeWidgetIface;
typedef enum  {
	ADAPTATIVE_WIDGET_WINDOW_SIZE_START_SIZE,
	ADAPTATIVE_WIDGET_WINDOW_SIZE_USUAL_SIZE,
	ADAPTATIVE_WIDGET_WINDOW_SIZE_QUITE_THIN,
	ADAPTATIVE_WIDGET_WINDOW_SIZE_PHONE_VERT,
	ADAPTATIVE_WIDGET_WINDOW_SIZE_PHONE_HZTL,
	ADAPTATIVE_WIDGET_WINDOW_SIZE_PHONE_BOTH,
	ADAPTATIVE_WIDGET_WINDOW_SIZE_EXTRA_THIN,
	ADAPTATIVE_WIDGET_WINDOW_SIZE_EXTRA_FLAT
} AdaptativeWidgetWindowSize;

#define ADAPTATIVE_WIDGET_TYPE_WINDOW_SIZE (adaptative_widget_window_size_get_type ())

#define TYPE_NEW_GAME_SCREEN (new_game_screen_get_type ())
#define NEW_GAME_SCREEN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_NEW_GAME_SCREEN, NewGameScreen))
#define NEW_GAME_SCREEN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_NEW_GAME_SCREEN, NewGameScreenClass))
#define IS_NEW_GAME_SCREEN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_NEW_GAME_SCREEN))
#define IS_NEW_GAME_SCREEN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_NEW_GAME_SCREEN))
#define NEW_GAME_SCREEN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_NEW_GAME_SCREEN, NewGameScreenClass))

typedef struct _NewGameScreen NewGameScreen;
typedef struct _NewGameScreenClass NewGameScreenClass;
typedef struct _NewGameScreenPrivate NewGameScreenPrivate;
enum  {
	NEW_GAME_SCREEN_0_PROPERTY,
	NEW_GAME_SCREEN_NUM_PROPERTIES
};
static GParamSpec* new_game_screen_properties[NEW_GAME_SCREEN_NUM_PROPERTIES];

struct _AdaptativeWidgetIface {
	GTypeInterface parent_iface;
	void (*set_window_size) (AdaptativeWidget* self, AdaptativeWidgetWindowSize new_size);
};

struct _NewGameScreen {
	GtkBox parent_instance;
	NewGameScreenPrivate * priv;
};

struct _NewGameScreenClass {
	GtkBoxClass parent_class;
};

struct _NewGameScreenPrivate {
	GtkBox* infos_section;
	GtkBox* users_section;
	GtkBox* start_section;
	GtkBox* users_box;
	GtkBox* level_box;
	GtkBox* start_box;
	gboolean quite_thin;
	gboolean extra_thin;
	gboolean extra_flat;
};

static gint NewGameScreen_private_offset;
static gpointer new_game_screen_parent_class = NULL;
static AdaptativeWidgetIface * new_game_screen_adaptative_widget_parent_iface = NULL;

VALA_EXTERN GType adaptative_widget_window_size_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType adaptative_widget_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (AdaptativeWidget, g_object_unref)
VALA_EXTERN GType new_game_screen_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (NewGameScreen, g_object_unref)
VALA_EXTERN void new_game_screen_update_sensitivity (NewGameScreen* self,
                                         gboolean new_sensitivity);
static void new_game_screen_real_set_window_size (AdaptativeWidget* base,
                                           AdaptativeWidgetWindowSize new_size);
VALA_EXTERN gboolean adaptative_widget_window_size_is_quite_thin (AdaptativeWidgetWindowSize window_size);
VALA_EXTERN gboolean adaptative_widget_window_size_is_extra_thin (AdaptativeWidgetWindowSize window_size);
VALA_EXTERN gboolean adaptative_widget_window_size_is_extra_flat (AdaptativeWidgetWindowSize window_size);
VALA_EXTERN NewGameScreen* new_game_screen_new (void);
VALA_EXTERN NewGameScreen* new_game_screen_construct (GType object_type);
VALA_EXTERN void adaptative_widget_set_window_size (AdaptativeWidget* self,
                                        AdaptativeWidgetWindowSize new_size);
static void new_game_screen_finalize (GObject * obj);
static GType new_game_screen_get_type_once (void);

static inline gpointer
new_game_screen_get_instance_private (NewGameScreen* self)
{
	return G_STRUCT_MEMBER_P (self, NewGameScreen_private_offset);
}

void
new_game_screen_update_sensitivity (NewGameScreen* self,
                                    gboolean new_sensitivity)
{
	GtkBox* _tmp0_;
	GtkBox* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->level_box;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp0_, new_sensitivity);
	_tmp1_ = self->priv->start_box;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp1_, new_sensitivity);
}

static void
new_game_screen_real_set_window_size (AdaptativeWidget* base,
                                      AdaptativeWidgetWindowSize new_size)
{
	NewGameScreen * self;
	gboolean _quite_thin = FALSE;
	gboolean _extra_thin = FALSE;
	gboolean _extra_flat = FALSE;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	self = (NewGameScreen*) base;
	_quite_thin = adaptative_widget_window_size_is_quite_thin (new_size);
	_extra_thin = adaptative_widget_window_size_is_extra_thin (new_size);
	_extra_flat = adaptative_widget_window_size_is_extra_flat (new_size);
	if (_quite_thin == self->priv->quite_thin) {
		_tmp1_ = _extra_thin == self->priv->extra_thin;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		_tmp0_ = _extra_flat == self->priv->extra_flat;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		return;
	}
	self->priv->quite_thin = _quite_thin;
	self->priv->extra_thin = _extra_thin;
	self->priv->extra_flat = _extra_flat;
	if (self->priv->extra_thin) {
		GtkBox* _tmp2_;
		GtkBox* _tmp3_;
		GtkBox* _tmp4_;
		GtkBox* _tmp5_;
		GtkBox* _tmp6_;
		GtkBox* _tmp7_;
		GtkBox* _tmp8_;
		GtkBox* _tmp9_;
		GtkStyleContext* _tmp10_;
		GtkBox* _tmp11_;
		GtkStyleContext* _tmp12_;
		GtkBox* _tmp13_;
		GtkStyleContext* _tmp14_;
		gtk_orientable_set_orientation ((GtkOrientable*) self, GTK_ORIENTATION_VERTICAL);
		gtk_box_set_spacing ((GtkBox*) self, 18);
		gtk_box_set_homogeneous ((GtkBox*) self, FALSE);
		g_object_set ((GtkWidget*) self, "height-request", 360, NULL);
		g_object_set ((GtkWidget*) self, "width-request", 250, NULL);
		gtk_widget_set_margin_bottom ((GtkWidget*) self, 22);
		_tmp2_ = self->priv->users_section;
		gtk_widget_hide ((GtkWidget*) _tmp2_);
		_tmp3_ = self->priv->start_section;
		gtk_widget_hide ((GtkWidget*) _tmp3_);
		_tmp4_ = self->priv->infos_section;
		gtk_widget_show ((GtkWidget*) _tmp4_);
		_tmp5_ = self->priv->level_box;
		gtk_orientable_set_orientation ((GtkOrientable*) _tmp5_, GTK_ORIENTATION_VERTICAL);
		_tmp6_ = self->priv->users_box;
		gtk_box_set_spacing (_tmp6_, 0);
		_tmp7_ = self->priv->level_box;
		gtk_box_set_spacing (_tmp7_, 0);
		_tmp8_ = self->priv->start_box;
		gtk_box_set_spacing (_tmp8_, 0);
		_tmp9_ = self->priv->users_box;
		_tmp10_ = gtk_widget_get_style_context ((GtkWidget*) _tmp9_);
		gtk_style_context_add_class (_tmp10_, "linked");
		_tmp11_ = self->priv->level_box;
		_tmp12_ = gtk_widget_get_style_context ((GtkWidget*) _tmp11_);
		gtk_style_context_add_class (_tmp12_, "linked");
		_tmp13_ = self->priv->start_box;
		_tmp14_ = gtk_widget_get_style_context ((GtkWidget*) _tmp13_);
		gtk_style_context_add_class (_tmp14_, "linked");
	} else {
		if (self->priv->extra_flat) {
			GtkBox* _tmp15_;
			GtkBox* _tmp16_;
			GtkBox* _tmp17_;
			GtkBox* _tmp18_;
			GtkBox* _tmp19_;
			GtkBox* _tmp20_;
			GtkBox* _tmp21_;
			GtkBox* _tmp22_;
			GtkStyleContext* _tmp23_;
			GtkBox* _tmp24_;
			GtkStyleContext* _tmp25_;
			GtkBox* _tmp26_;
			GtkStyleContext* _tmp27_;
			gtk_orientable_set_orientation ((GtkOrientable*) self, GTK_ORIENTATION_HORIZONTAL);
			gtk_box_set_homogeneous ((GtkBox*) self, TRUE);
			g_object_set ((GtkWidget*) self, "height-request", 113, NULL);
			gtk_widget_set_margin_bottom ((GtkWidget*) self, 6);
			if (self->priv->quite_thin) {
				gtk_box_set_spacing ((GtkBox*) self, 21);
				g_object_set ((GtkWidget*) self, "width-request", 420, NULL);
			} else {
				gtk_box_set_spacing ((GtkBox*) self, 24);
				g_object_set ((GtkWidget*) self, "width-request", 450, NULL);
			}
			_tmp15_ = self->priv->users_section;
			gtk_widget_hide ((GtkWidget*) _tmp15_);
			_tmp16_ = self->priv->start_section;
			gtk_widget_hide ((GtkWidget*) _tmp16_);
			_tmp17_ = self->priv->infos_section;
			gtk_widget_show ((GtkWidget*) _tmp17_);
			_tmp18_ = self->priv->level_box;
			gtk_orientable_set_orientation ((GtkOrientable*) _tmp18_, GTK_ORIENTATION_VERTICAL);
			_tmp19_ = self->priv->users_box;
			gtk_box_set_spacing (_tmp19_, 0);
			_tmp20_ = self->priv->level_box;
			gtk_box_set_spacing (_tmp20_, 0);
			_tmp21_ = self->priv->start_box;
			gtk_box_set_spacing (_tmp21_, 0);
			_tmp22_ = self->priv->users_box;
			_tmp23_ = gtk_widget_get_style_context ((GtkWidget*) _tmp22_);
			gtk_style_context_add_class (_tmp23_, "linked");
			_tmp24_ = self->priv->level_box;
			_tmp25_ = gtk_widget_get_style_context ((GtkWidget*) _tmp24_);
			gtk_style_context_add_class (_tmp25_, "linked");
			_tmp26_ = self->priv->start_box;
			_tmp27_ = gtk_widget_get_style_context ((GtkWidget*) _tmp26_);
			gtk_style_context_add_class (_tmp27_, "linked");
		} else {
			gint boxes_spacing = 0;
			GtkBox* _tmp28_;
			GtkBox* _tmp29_;
			GtkBox* _tmp30_;
			GtkBox* _tmp31_;
			GtkBox* _tmp32_;
			GtkStyleContext* _tmp33_;
			GtkBox* _tmp34_;
			GtkStyleContext* _tmp35_;
			GtkBox* _tmp36_;
			GtkStyleContext* _tmp37_;
			GtkBox* _tmp38_;
			GtkBox* _tmp39_;
			GtkBox* _tmp40_;
			gtk_orientable_set_orientation ((GtkOrientable*) self, GTK_ORIENTATION_VERTICAL);
			gtk_box_set_spacing ((GtkBox*) self, 18);
			g_object_set ((GtkWidget*) self, "height-request", 263, NULL);
			if (self->priv->quite_thin) {
				boxes_spacing = 10;
				g_object_set ((GtkWidget*) self, "width-request", 380, NULL);
			} else {
				boxes_spacing = 12;
				g_object_set ((GtkWidget*) self, "width-request", 400, NULL);
			}
			gtk_widget_set_margin_bottom ((GtkWidget*) self, 22);
			_tmp28_ = self->priv->infos_section;
			gtk_widget_hide ((GtkWidget*) _tmp28_);
			_tmp29_ = self->priv->users_section;
			gtk_widget_show ((GtkWidget*) _tmp29_);
			_tmp30_ = self->priv->start_section;
			gtk_widget_show ((GtkWidget*) _tmp30_);
			_tmp31_ = self->priv->level_box;
			gtk_orientable_set_orientation ((GtkOrientable*) _tmp31_, GTK_ORIENTATION_HORIZONTAL);
			_tmp32_ = self->priv->users_box;
			_tmp33_ = gtk_widget_get_style_context ((GtkWidget*) _tmp32_);
			gtk_style_context_remove_class (_tmp33_, "linked");
			_tmp34_ = self->priv->level_box;
			_tmp35_ = gtk_widget_get_style_context ((GtkWidget*) _tmp34_);
			gtk_style_context_remove_class (_tmp35_, "linked");
			_tmp36_ = self->priv->start_box;
			_tmp37_ = gtk_widget_get_style_context ((GtkWidget*) _tmp36_);
			gtk_style_context_remove_class (_tmp37_, "linked");
			_tmp38_ = self->priv->users_box;
			gtk_box_set_spacing (_tmp38_, boxes_spacing);
			_tmp39_ = self->priv->level_box;
			gtk_box_set_spacing (_tmp39_, boxes_spacing);
			_tmp40_ = self->priv->start_box;
			gtk_box_set_spacing (_tmp40_, boxes_spacing);
			gtk_box_set_homogeneous ((GtkBox*) self, TRUE);
		}
	}
	gtk_widget_queue_allocate ((GtkWidget*) self);
}

NewGameScreen*
new_game_screen_construct (GType object_type)
{
	NewGameScreen * self = NULL;
	self = (NewGameScreen*) g_object_new (object_type, NULL);
	return self;
}

NewGameScreen*
new_game_screen_new (void)
{
	return new_game_screen_construct (TYPE_NEW_GAME_SCREEN);
}

static void
new_game_screen_class_init (NewGameScreenClass * klass,
                            gpointer klass_data)
{
	new_game_screen_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &NewGameScreen_private_offset);
	G_OBJECT_CLASS (klass)->finalize = new_game_screen_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Four-in-a-row/ui/fiar-screens.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "infos_section", FALSE, NewGameScreen_private_offset + G_STRUCT_OFFSET (NewGameScreenPrivate, infos_section));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "users_section", FALSE, NewGameScreen_private_offset + G_STRUCT_OFFSET (NewGameScreenPrivate, users_section));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "start_section", FALSE, NewGameScreen_private_offset + G_STRUCT_OFFSET (NewGameScreenPrivate, start_section));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "users_box", FALSE, NewGameScreen_private_offset + G_STRUCT_OFFSET (NewGameScreenPrivate, users_box));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "level_box", FALSE, NewGameScreen_private_offset + G_STRUCT_OFFSET (NewGameScreenPrivate, level_box));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "start_box", FALSE, NewGameScreen_private_offset + G_STRUCT_OFFSET (NewGameScreenPrivate, start_box));
}

static void
new_game_screen_adaptative_widget_interface_init (AdaptativeWidgetIface * iface,
                                                  gpointer iface_data)
{
	new_game_screen_adaptative_widget_parent_iface = g_type_interface_peek_parent (iface);
	iface->set_window_size = (void (*) (AdaptativeWidget*, AdaptativeWidgetWindowSize)) new_game_screen_real_set_window_size;
}

static void
new_game_screen_instance_init (NewGameScreen * self,
                               gpointer klass)
{
	self->priv = new_game_screen_get_instance_private (self);
	self->priv->quite_thin = FALSE;
	self->priv->extra_thin = TRUE;
	self->priv->extra_flat = FALSE;
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
new_game_screen_finalize (GObject * obj)
{
	NewGameScreen * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_NEW_GAME_SCREEN, NewGameScreen);
	G_OBJECT_CLASS (new_game_screen_parent_class)->finalize (obj);
}

static GType
new_game_screen_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (NewGameScreenClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) new_game_screen_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (NewGameScreen), 0, (GInstanceInitFunc) new_game_screen_instance_init, NULL };
	static const GInterfaceInfo adaptative_widget_info = { (GInterfaceInitFunc) new_game_screen_adaptative_widget_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType new_game_screen_type_id;
	new_game_screen_type_id = g_type_register_static (gtk_box_get_type (), "NewGameScreen", &g_define_type_info, 0);
	g_type_add_interface_static (new_game_screen_type_id, TYPE_ADAPTATIVE_WIDGET, &adaptative_widget_info);
	NewGameScreen_private_offset = g_type_add_instance_private (new_game_screen_type_id, sizeof (NewGameScreenPrivate));
	return new_game_screen_type_id;
}

GType
new_game_screen_get_type (void)
{
	static volatile gsize new_game_screen_type_id__once = 0;
	if (g_once_init_enter (&new_game_screen_type_id__once)) {
		GType new_game_screen_type_id;
		new_game_screen_type_id = new_game_screen_get_type_once ();
		g_once_init_leave (&new_game_screen_type_id__once, new_game_screen_type_id);
	}
	return new_game_screen_type_id__once;
}

