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

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <float.h>
#include <math.h>
#include <gdk/gdk.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_TILE (tile_get_type ())
#define TILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TILE, Tile))
#define TILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TILE, TileClass))
#define IS_TILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TILE))
#define IS_TILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TILE))
#define TILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TILE, TileClass))

typedef struct _Tile Tile;
typedef struct _TileClass TileClass;
typedef struct _TilePrivate TilePrivate;
enum  {
	TILE_0_PROPERTY,
	TILE_ROW_PROPERTY,
	TILE_COLUMN_PROPERTY,
	TILE_NUM_PROPERTIES
};
static GParamSpec* tile_properties[TILE_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	TILE_TILE_MOUSE_OVER_SIGNAL,
	TILE_TILE_PRESSED_SIGNAL,
	TILE_TILE_RELEASED_SIGNAL,
	TILE_TILE_LONG_PRESSED_SIGNAL,
	TILE_NUM_SIGNALS
};
static guint tile_signals[TILE_NUM_SIGNALS] = {0};

struct _Tile {
	GtkWidget parent_instance;
	TilePrivate * priv;
};

struct _TileClass {
	GtkWidgetClass parent_class;
};

struct _TilePrivate {
	gint _row;
	gint _column;
	GtkGestureLongPress* _gesture;
	GtkGestureClick* _click_controller;
};

static gint Tile_private_offset;
static gpointer tile_parent_class = NULL;

VALA_EXTERN GType tile_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Tile, g_object_unref)
VALA_EXTERN Tile* tile_new (gint prow,
                gint pcol);
VALA_EXTERN Tile* tile_construct (GType object_type,
                      gint prow,
                      gint pcol);
VALA_EXTERN gint tile_get_row (Tile* self);
static void tile_set_row (Tile* self,
                   gint value);
VALA_EXTERN gint tile_get_column (Tile* self);
static void tile_set_column (Tile* self,
                      gint value);
static void g_cclosure_user_marshal_VOID__INT_INT (GClosure * closure,
                                            GValue * return_value,
                                            guint n_param_values,
                                            const GValue * param_values,
                                            gpointer invocation_hint,
                                            gpointer marshal_data);
static void g_cclosure_user_marshal_VOID__INT_INT_UINT_INT_BOOLEAN (GClosure * closure,
                                                             GValue * return_value,
                                                             guint n_param_values,
                                                             const GValue * param_values,
                                                             gpointer invocation_hint,
                                                             gpointer marshal_data);
static void g_cclosure_user_marshal_VOID__INT_INT_UINT (GClosure * closure,
                                                 GValue * return_value,
                                                 guint n_param_values,
                                                 const GValue * param_values,
                                                 gpointer invocation_hint,
                                                 gpointer marshal_data);
static GObject * tile_constructor (GType type,
                            guint n_construct_properties,
                            GObjectConstructParam * construct_properties);
static void _tile___lambda5_ (Tile* self,
                       gdouble x,
                       gdouble y);
static void __tile___lambda5__gtk_gesture_long_press_pressed (GtkGestureLongPress* _sender,
                                                       gdouble x,
                                                       gdouble y,
                                                       gpointer self);
static void _tile___lambda6_ (Tile* self,
                       GtkGestureClick* click_controller,
                       gint n_press,
                       gdouble x,
                       gdouble y);
static void __tile___lambda6__gtk_gesture_click_pressed (GtkGestureClick* _sender,
                                                  gint n_press,
                                                  gdouble x,
                                                  gdouble y,
                                                  gpointer self);
static void _tile___lambda7_ (Tile* self,
                       GtkGestureClick* click_controller,
                       gint n_press,
                       gdouble x,
                       gdouble y);
static void __tile___lambda7__gtk_gesture_click_released (GtkGestureClick* _sender,
                                                   gint n_press,
                                                   gdouble x,
                                                   gdouble y,
                                                   gpointer self);
static void tile_finalize (GObject * obj);
static GType tile_get_type_once (void);
static void _vala_tile_get_property (GObject * object,
                              guint property_id,
                              GValue * value,
                              GParamSpec * pspec);
static void _vala_tile_set_property (GObject * object,
                              guint property_id,
                              const GValue * value,
                              GParamSpec * pspec);

static inline gpointer
tile_get_instance_private (Tile* self)
{
	return G_STRUCT_MEMBER_P (self, Tile_private_offset);
}

Tile*
tile_construct (GType object_type,
                gint prow,
                gint pcol)
{
	Tile * self = NULL;
	self = (Tile*) g_object_new (object_type, "row", prow, "column", pcol, NULL);
	return self;
}

Tile*
tile_new (gint prow,
          gint pcol)
{
	return tile_construct (TYPE_TILE, prow, pcol);
}

gint
tile_get_row (Tile* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_row;
	return result;
}

static void
tile_set_row (Tile* self,
              gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = tile_get_row (self);
	if (old_value != value) {
		self->priv->_row = value;
		g_object_notify_by_pspec ((GObject *) self, tile_properties[TILE_ROW_PROPERTY]);
	}
}

gint
tile_get_column (Tile* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_column;
	return result;
}

static void
tile_set_column (Tile* self,
                 gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = tile_get_column (self);
	if (old_value != value) {
		self->priv->_column = value;
		g_object_notify_by_pspec ((GObject *) self, tile_properties[TILE_COLUMN_PROPERTY]);
	}
}

static void
g_cclosure_user_marshal_VOID__INT_INT (GClosure * closure,
                                       GValue * return_value,
                                       guint n_param_values,
                                       const GValue * param_values,
                                       gpointer invocation_hint,
                                       gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__INT_INT) (gpointer data1, gint arg_1, gint arg_2, gpointer data2);
	register GMarshalFunc_VOID__INT_INT callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__INT_INT) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_int (param_values + 1), g_value_get_int (param_values + 2), data2);
}

static void
g_cclosure_user_marshal_VOID__INT_INT_UINT_INT_BOOLEAN (GClosure * closure,
                                                        GValue * return_value,
                                                        guint n_param_values,
                                                        const GValue * param_values,
                                                        gpointer invocation_hint,
                                                        gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__INT_INT_UINT_INT_BOOLEAN) (gpointer data1, gint arg_1, gint arg_2, guint arg_3, gint arg_4, gboolean arg_5, gpointer data2);
	register GMarshalFunc_VOID__INT_INT_UINT_INT_BOOLEAN callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 6);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__INT_INT_UINT_INT_BOOLEAN) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_int (param_values + 1), g_value_get_int (param_values + 2), g_value_get_uint (param_values + 3), g_value_get_int (param_values + 4), g_value_get_boolean (param_values + 5), data2);
}

static void
g_cclosure_user_marshal_VOID__INT_INT_UINT (GClosure * closure,
                                            GValue * return_value,
                                            guint n_param_values,
                                            const GValue * param_values,
                                            gpointer invocation_hint,
                                            gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__INT_INT_UINT) (gpointer data1, gint arg_1, gint arg_2, guint arg_3, gpointer data2);
	register GMarshalFunc_VOID__INT_INT_UINT callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 4);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__INT_INT_UINT) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_int (param_values + 1), g_value_get_int (param_values + 2), g_value_get_uint (param_values + 3), data2);
}

static void
_tile___lambda5_ (Tile* self,
                  gdouble x,
                  gdouble y)
{
	gint _tmp0_;
	gint _tmp1_;
	_tmp0_ = self->priv->_row;
	_tmp1_ = self->priv->_column;
	g_signal_emit (self, tile_signals[TILE_TILE_LONG_PRESSED_SIGNAL], 0, _tmp0_, _tmp1_);
}

static void
__tile___lambda5__gtk_gesture_long_press_pressed (GtkGestureLongPress* _sender,
                                                  gdouble x,
                                                  gdouble y,
                                                  gpointer self)
{
	_tile___lambda5_ ((Tile*) self, x, y);
}

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

static void
_tile___lambda6_ (Tile* self,
                  GtkGestureClick* click_controller,
                  gint n_press,
                  gdouble x,
                  gdouble y)
{
	GdkModifierType state = 0U;
	gboolean ctrl = FALSE;
	guint button = 0U;
	gint _tmp0_;
	gint _tmp1_;
	g_return_if_fail (click_controller != NULL);
	state = gtk_event_controller_get_current_event_state ((GtkEventController*) click_controller);
	ctrl = (state & GDK_CONTROL_MASK) != 0;
	button = gtk_gesture_single_get_current_button ((GtkGestureSingle*) click_controller);
	_tmp0_ = self->priv->_row;
	_tmp1_ = self->priv->_column;
	g_signal_emit (self, tile_signals[TILE_TILE_PRESSED_SIGNAL], 0, _tmp0_, _tmp1_, button, n_press, ctrl);
}

static void
__tile___lambda6__gtk_gesture_click_pressed (GtkGestureClick* _sender,
                                             gint n_press,
                                             gdouble x,
                                             gdouble y,
                                             gpointer self)
{
	_tile___lambda6_ ((Tile*) self, _sender, n_press, x, y);
}

static void
_tile___lambda7_ (Tile* self,
                  GtkGestureClick* click_controller,
                  gint n_press,
                  gdouble x,
                  gdouble y)
{
	guint button = 0U;
	gint _tmp0_;
	gint _tmp1_;
	g_return_if_fail (click_controller != NULL);
	button = gtk_gesture_single_get_current_button ((GtkGestureSingle*) click_controller);
	_tmp0_ = self->priv->_row;
	_tmp1_ = self->priv->_column;
	g_signal_emit (self, tile_signals[TILE_TILE_RELEASED_SIGNAL], 0, _tmp0_, _tmp1_, button);
}

static void
__tile___lambda7__gtk_gesture_click_released (GtkGestureClick* _sender,
                                              gint n_press,
                                              gdouble x,
                                              gdouble y,
                                              gpointer self)
{
	_tile___lambda7_ ((Tile*) self, _sender, n_press, x, y);
}

static GObject *
tile_constructor (GType type,
                  guint n_construct_properties,
                  GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	Tile * self;
	GtkGestureLongPress* _tmp0_;
	GtkGestureLongPress* _tmp1_;
	GtkGestureLongPress* _tmp2_;
	GtkGestureLongPress* _tmp3_;
	GtkEventController* _tmp4_;
	GtkGestureClick* _tmp5_;
	GtkGestureClick* _tmp6_;
	GtkGestureClick* _tmp7_;
	GtkGestureClick* _tmp8_;
	GtkGestureClick* _tmp9_;
	GtkEventController* _tmp10_;
	parent_class = G_OBJECT_CLASS (tile_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_TILE, Tile);
	gtk_widget_add_css_class ((GtkWidget*) self, "tile");
	_tmp0_ = (GtkGestureLongPress*) gtk_gesture_long_press_new ();
	_g_object_unref0 (self->priv->_gesture);
	self->priv->_gesture = _tmp0_;
	_tmp1_ = self->priv->_gesture;
	gtk_gesture_single_set_touch_only ((GtkGestureSingle*) _tmp1_, TRUE);
	_tmp2_ = self->priv->_gesture;
	g_signal_connect_object (_tmp2_, "pressed", (GCallback) __tile___lambda5__gtk_gesture_long_press_pressed, self, 0);
	_tmp3_ = self->priv->_gesture;
	_tmp4_ = _g_object_ref0 ((GtkEventController*) _tmp3_);
	gtk_widget_add_controller ((GtkWidget*) self, _tmp4_);
	_tmp5_ = (GtkGestureClick*) gtk_gesture_click_new ();
	_g_object_unref0 (self->priv->_click_controller);
	self->priv->_click_controller = _tmp5_;
	_tmp6_ = self->priv->_click_controller;
	gtk_gesture_single_set_button ((GtkGestureSingle*) _tmp6_, (guint) 0);
	_tmp7_ = self->priv->_click_controller;
	g_signal_connect_object (_tmp7_, "pressed", (GCallback) __tile___lambda6__gtk_gesture_click_pressed, self, 0);
	_tmp8_ = self->priv->_click_controller;
	g_signal_connect_object (_tmp8_, "released", (GCallback) __tile___lambda7__gtk_gesture_click_released, self, 0);
	_tmp9_ = self->priv->_click_controller;
	_tmp10_ = _g_object_ref0 ((GtkEventController*) _tmp9_);
	gtk_widget_add_controller ((GtkWidget*) self, _tmp10_);
	return obj;
}

static void
tile_class_init (TileClass * klass,
                 gpointer klass_data)
{
	tile_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &Tile_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_tile_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_tile_set_property;
	G_OBJECT_CLASS (klass)->constructor = tile_constructor;
	G_OBJECT_CLASS (klass)->finalize = tile_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), TILE_ROW_PROPERTY, tile_properties[TILE_ROW_PROPERTY] = g_param_spec_int ("row", "row", "row", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), TILE_COLUMN_PROPERTY, tile_properties[TILE_COLUMN_PROPERTY] = g_param_spec_int ("column", "column", "column", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	tile_signals[TILE_TILE_MOUSE_OVER_SIGNAL] = g_signal_new ("tile-mouse-over", TYPE_TILE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__INT_INT, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
	tile_signals[TILE_TILE_PRESSED_SIGNAL] = g_signal_new ("tile-pressed", TYPE_TILE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__INT_INT_UINT_INT_BOOLEAN, G_TYPE_NONE, 5, G_TYPE_INT, G_TYPE_INT, G_TYPE_UINT, G_TYPE_INT, G_TYPE_BOOLEAN);
	tile_signals[TILE_TILE_RELEASED_SIGNAL] = g_signal_new ("tile-released", TYPE_TILE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__INT_INT_UINT, G_TYPE_NONE, 3, G_TYPE_INT, G_TYPE_INT, G_TYPE_UINT);
	tile_signals[TILE_TILE_LONG_PRESSED_SIGNAL] = g_signal_new ("tile-long-pressed", TYPE_TILE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__INT_INT, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
}

static void
tile_instance_init (Tile * self,
                    gpointer klass)
{
	self->priv = tile_get_instance_private (self);
}

static void
tile_finalize (GObject * obj)
{
	Tile * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_TILE, Tile);
	_g_object_unref0 (self->priv->_gesture);
	_g_object_unref0 (self->priv->_click_controller);
	G_OBJECT_CLASS (tile_parent_class)->finalize (obj);
}

static GType
tile_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TileClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tile_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Tile), 0, (GInstanceInitFunc) tile_instance_init, NULL };
	GType tile_type_id;
	tile_type_id = g_type_register_static (gtk_widget_get_type (), "Tile", &g_define_type_info, 0);
	Tile_private_offset = g_type_add_instance_private (tile_type_id, sizeof (TilePrivate));
	return tile_type_id;
}

GType
tile_get_type (void)
{
	static volatile gsize tile_type_id__once = 0;
	if (g_once_init_enter (&tile_type_id__once)) {
		GType tile_type_id;
		tile_type_id = tile_get_type_once ();
		g_once_init_leave (&tile_type_id__once, tile_type_id);
	}
	return tile_type_id__once;
}

static void
_vala_tile_get_property (GObject * object,
                         guint property_id,
                         GValue * value,
                         GParamSpec * pspec)
{
	Tile * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TILE, Tile);
	switch (property_id) {
		case TILE_ROW_PROPERTY:
		g_value_set_int (value, tile_get_row (self));
		break;
		case TILE_COLUMN_PROPERTY:
		g_value_set_int (value, tile_get_column (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_tile_set_property (GObject * object,
                         guint property_id,
                         const GValue * value,
                         GParamSpec * pspec)
{
	Tile * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TILE, Tile);
	switch (property_id) {
		case TILE_ROW_PROPERTY:
		tile_set_row (self, g_value_get_int (value));
		break;
		case TILE_COLUMN_PROPERTY:
		tile_set_column (self, g_value_get_int (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

