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


#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <cairo.h>
#include <gdk/gdk.h>


#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;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block2Data Block2Data;

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

struct _TileClass {
	GtkButtonClass parent_class;
};

struct _TilePrivate {
	gint _row;
	gint _column;
	GtkImage* scaling_image;
};

struct _Block2Data {
	int _ref_count_;
	Tile* self;
	gint prow;
	gint pcol;
};


static gpointer tile_parent_class = NULL;
static gchar** tile_IMAGE_CLASSES;
static gint tile_IMAGE_CLASSES_length1;
static gchar** tile_IMAGE_CLASSES = NULL;
static gint tile_IMAGE_CLASSES_length1 = 0;
static gint _tile_IMAGE_CLASSES_size_ = 0;

GType tile_get_type (void) G_GNUC_CONST;
#define TILE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_TILE, TilePrivate))
enum  {
	TILE_DUMMY_PROPERTY,
	TILE_ROW,
	TILE_COLUMN
};
void tile_refresh_icon (Tile* self);
Tile* tile_new (gint prow, gint pcol);
Tile* tile_construct (GType object_type, gint prow, gint pcol);
static Block2Data* block2_data_ref (Block2Data* _data2_);
static void block2_data_unref (void * _userdata_);
void tile_add_class (Tile* self, const gchar* style_class);
static void __lambda4_ (Tile* self, GtkAllocation* allocation);
static void ___lambda4__gtk_widget_size_allocate (GtkWidget* _sender, GtkAllocation* allocation, gpointer self);
static gboolean __lambda5_ (Block2Data* _data2_, GdkEventButton* event);
static gboolean ___lambda5__gtk_widget_button_press_event (GtkWidget* _sender, GdkEventButton* event, gpointer self);
static gboolean __lambda6_ (Block2Data* _data2_, GdkEventButton* event);
static gboolean ___lambda6__gtk_widget_button_release_event (GtkWidget* _sender, GdkEventButton* event, gpointer self);
static gboolean _vala_string_array_contains (gchar** stack, int stack_length, gchar* needle);
void tile_remove_class (Tile* self, const gchar* style_class);
gint tile_get_row (Tile* self);
gint tile_get_column (Tile* self);
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_BOXED (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data);
static void tile_finalize (GObject* obj);
static void _vala_tile_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);


void tile_refresh_icon (Tile* self) {
	gchar* name = NULL;
	GtkIconSize size = 0;
	GtkImage* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	GtkIconSize _tmp2_ = 0;
	gchar* _tmp3_ = NULL;
	GtkImage* _tmp4_ = NULL;
	GtkImage* _tmp5_ = NULL;
	GtkImage* _tmp6_ = NULL;
	gint _tmp7_ = 0;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->scaling_image;
	gtk_image_get_icon_name (_tmp0_, &_tmp1_, &_tmp2_);
	_g_free0 (name);
	_tmp3_ = g_strdup (_tmp1_);
	name = _tmp3_;
	size = _tmp2_;
	_tmp4_ = self->priv->scaling_image;
	gtk_image_clear (_tmp4_);
	_tmp5_ = self->priv->scaling_image;
	gtk_image_set_from_icon_name (_tmp5_, name, size);
	_tmp6_ = self->priv->scaling_image;
	_tmp7_ = gtk_widget_get_allocated_height ((GtkWidget*) self);
	gtk_image_set_pixel_size (_tmp6_, (_tmp7_ / 3) * 2);
	_g_free0 (name);
}


static Block2Data* block2_data_ref (Block2Data* _data2_) {
	g_atomic_int_inc (&_data2_->_ref_count_);
	return _data2_;
}


static void block2_data_unref (void * _userdata_) {
	Block2Data* _data2_;
	_data2_ = (Block2Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data2_->_ref_count_)) {
		Tile* self;
		self = _data2_->self;
		_g_object_unref0 (self);
		g_slice_free (Block2Data, _data2_);
	}
}


static void __lambda4_ (Tile* self, GtkAllocation* allocation) {
	GtkImage* _tmp0_ = NULL;
	GtkAllocation _tmp1_ = {0};
	gint _tmp2_ = 0;
	g_return_if_fail (allocation != NULL);
	_tmp0_ = self->priv->scaling_image;
	_tmp1_ = *allocation;
	_tmp2_ = _tmp1_.height;
	gtk_image_set_pixel_size (_tmp0_, (_tmp2_ / 3) * 2);
}


static void ___lambda4__gtk_widget_size_allocate (GtkWidget* _sender, GtkAllocation* allocation, gpointer self) {
	__lambda4_ ((Tile*) self, allocation);
}


static gboolean __lambda5_ (Block2Data* _data2_, GdkEventButton* event) {
	Tile* self;
	gboolean result = FALSE;
	GdkEventButton* _tmp0_ = NULL;
	GdkSeat* _tmp1_ = NULL;
	gint _tmp2_ = 0;
	gint _tmp3_ = 0;
	GdkEventButton* _tmp4_ = NULL;
	self = _data2_->self;
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = event;
	_tmp1_ = gdk_event_get_seat ((GdkEvent*) _tmp0_);
	gdk_seat_ungrab (_tmp1_);
	_tmp2_ = _data2_->prow;
	_tmp3_ = _data2_->pcol;
	_tmp4_ = event;
	g_signal_emit_by_name (self, "tile-pressed", _tmp2_, _tmp3_, _tmp4_);
	result = FALSE;
	return result;
}


static gboolean ___lambda5__gtk_widget_button_press_event (GtkWidget* _sender, GdkEventButton* event, gpointer self) {
	gboolean result;
	result = __lambda5_ (self, event);
	return result;
}


static gboolean __lambda6_ (Block2Data* _data2_, GdkEventButton* event) {
	Tile* self;
	gboolean result = FALSE;
	gint _tmp0_ = 0;
	gint _tmp1_ = 0;
	GdkEventButton* _tmp2_ = NULL;
	self = _data2_->self;
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = _data2_->prow;
	_tmp1_ = _data2_->pcol;
	_tmp2_ = event;
	g_signal_emit_by_name (self, "tile-released", _tmp0_, _tmp1_, _tmp2_);
	result = FALSE;
	return result;
}


static gboolean ___lambda6__gtk_widget_button_release_event (GtkWidget* _sender, GdkEventButton* event, gpointer self) {
	gboolean result;
	result = __lambda6_ (self, event);
	return result;
}


Tile* tile_construct (GType object_type, gint prow, gint pcol) {
	Tile * self = NULL;
	Block2Data* _data2_;
	gint _tmp0_ = 0;
	gint _tmp1_ = 0;
	gint _tmp2_ = 0;
	gint _tmp3_ = 0;
	GtkImage* _tmp4_ = NULL;
	GtkImage* _tmp5_ = NULL;
	_data2_ = g_slice_new0 (Block2Data);
	_data2_->_ref_count_ = 1;
	_tmp0_ = prow;
	_data2_->prow = _tmp0_;
	_tmp1_ = pcol;
	_data2_->pcol = _tmp1_;
	self = (Tile*) g_object_new (object_type, NULL);
	_data2_->self = g_object_ref (self);
	_tmp2_ = _data2_->prow;
	self->priv->_row = _tmp2_;
	_tmp3_ = _data2_->pcol;
	self->priv->_column = _tmp3_;
	_tmp4_ = (GtkImage*) gtk_image_new ();
	g_object_ref_sink (_tmp4_);
	_g_object_unref0 (self->priv->scaling_image);
	self->priv->scaling_image = _tmp4_;
	g_object_set ((GtkWidget*) self, "can-focus", FALSE, NULL);
	tile_add_class (self, "tile");
	_tmp5_ = self->priv->scaling_image;
	gtk_button_set_image ((GtkButton*) self, (GtkWidget*) _tmp5_);
	g_signal_connect_object ((GtkWidget*) self, "size-allocate", (GCallback) ___lambda4__gtk_widget_size_allocate, self, 0);
	g_signal_connect_data ((GtkWidget*) self, "button-press-event", (GCallback) ___lambda5__gtk_widget_button_press_event, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	g_signal_connect_data ((GtkWidget*) self, "button-release-event", (GCallback) ___lambda6__gtk_widget_button_release_event, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	block2_data_unref (_data2_);
	_data2_ = NULL;
	return self;
}


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


static gboolean _vala_string_array_contains (gchar** stack, int stack_length, gchar* needle) {
	int i;
	for (i = 0; i < stack_length; i++) {
		if (g_strcmp0 (stack[i], needle) == 0) {
			return TRUE;
		}
	}
	return FALSE;
}


void tile_add_class (Tile* self, const gchar* style_class) {
	GtkStyleContext* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	gchar** _tmp3_ = NULL;
	gint _tmp3__length1 = 0;
	g_return_if_fail (self != NULL);
	g_return_if_fail (style_class != NULL);
	_tmp0_ = gtk_widget_get_style_context ((GtkWidget*) self);
	_tmp1_ = style_class;
	gtk_style_context_add_class (_tmp0_, _tmp1_);
	_tmp2_ = style_class;
	_tmp3_ = tile_IMAGE_CLASSES;
	_tmp3__length1 = tile_IMAGE_CLASSES_length1;
	if (_vala_string_array_contains (_tmp3_, _tmp3__length1, _tmp2_)) {
		GtkImage* _tmp4_ = NULL;
		const gchar* _tmp5_ = NULL;
		GtkImage* _tmp6_ = NULL;
		gint _tmp7_ = 0;
		_tmp4_ = self->priv->scaling_image;
		_tmp5_ = style_class;
		gtk_image_set_from_icon_name (_tmp4_, _tmp5_, GTK_ICON_SIZE_DND);
		_tmp6_ = self->priv->scaling_image;
		_tmp7_ = gtk_widget_get_allocated_height ((GtkWidget*) self);
		gtk_image_set_pixel_size (_tmp6_, (_tmp7_ / 3) * 2);
	}
}


void tile_remove_class (Tile* self, const gchar* style_class) {
	GtkStyleContext* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	gchar** _tmp3_ = NULL;
	gint _tmp3__length1 = 0;
	g_return_if_fail (self != NULL);
	g_return_if_fail (style_class != NULL);
	_tmp0_ = gtk_widget_get_style_context ((GtkWidget*) self);
	_tmp1_ = style_class;
	gtk_style_context_remove_class (_tmp0_, _tmp1_);
	_tmp2_ = style_class;
	_tmp3_ = tile_IMAGE_CLASSES;
	_tmp3__length1 = tile_IMAGE_CLASSES_length1;
	if (_vala_string_array_contains (_tmp3_, _tmp3__length1, _tmp2_)) {
		GtkImage* _tmp4_ = NULL;
		GtkImage* _tmp5_ = NULL;
		_tmp4_ = (GtkImage*) gtk_image_new ();
		g_object_ref_sink (_tmp4_);
		_g_object_unref0 (self->priv->scaling_image);
		self->priv->scaling_image = _tmp4_;
		_tmp5_ = self->priv->scaling_image;
		gtk_button_set_image ((GtkButton*) self, (GtkWidget*) _tmp5_);
	}
}


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


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


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_BOXED (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_BOXED) (gpointer data1, gint arg_1, gint arg_2, gpointer arg_3, gpointer data2);
	register GMarshalFunc_VOID__INT_INT_BOXED 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_BOXED) (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_boxed (param_values + 3), data2);
}


static void tile_class_init (TileClass * klass) {
	gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	gchar* _tmp4_ = NULL;
	gchar* _tmp5_ = NULL;
	gchar* _tmp6_ = NULL;
	gchar* _tmp7_ = NULL;
	gchar* _tmp8_ = NULL;
	gchar* _tmp9_ = NULL;
	gchar* _tmp10_ = NULL;
	gchar* _tmp11_ = NULL;
	gchar* _tmp12_ = NULL;
	gchar* _tmp13_ = NULL;
	gchar** _tmp14_ = NULL;
	tile_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (TilePrivate));
	G_OBJECT_CLASS (klass)->get_property = _vala_tile_get_property;
	G_OBJECT_CLASS (klass)->finalize = tile_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), TILE_ROW, g_param_spec_int ("row", "row", "row", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), TILE_COLUMN, g_param_spec_int ("column", "column", "column", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	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);
	g_signal_new ("tile_pressed", TYPE_TILE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__INT_INT_BOXED, G_TYPE_NONE, 3, G_TYPE_INT, G_TYPE_INT, gdk_event_get_type ());
	g_signal_new ("tile_released", TYPE_TILE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__INT_INT_BOXED, G_TYPE_NONE, 3, G_TYPE_INT, G_TYPE_INT, gdk_event_get_type ());
	_tmp0_ = g_strdup ("mine");
	_tmp1_ = g_strdup ("flag");
	_tmp2_ = g_strdup ("incorrect");
	_tmp3_ = g_strdup ("maybe");
	_tmp4_ = g_strdup ("overmine");
	_tmp5_ = g_strdup ("exploded");
	_tmp6_ = g_strdup ("1mines");
	_tmp7_ = g_strdup ("2mines");
	_tmp8_ = g_strdup ("3mines");
	_tmp9_ = g_strdup ("4mines");
	_tmp10_ = g_strdup ("5mines");
	_tmp11_ = g_strdup ("6mines");
	_tmp12_ = g_strdup ("7mines");
	_tmp13_ = g_strdup ("8mines");
	_tmp14_ = g_new0 (gchar*, 14 + 1);
	_tmp14_[0] = _tmp0_;
	_tmp14_[1] = _tmp1_;
	_tmp14_[2] = _tmp2_;
	_tmp14_[3] = _tmp3_;
	_tmp14_[4] = _tmp4_;
	_tmp14_[5] = _tmp5_;
	_tmp14_[6] = _tmp6_;
	_tmp14_[7] = _tmp7_;
	_tmp14_[8] = _tmp8_;
	_tmp14_[9] = _tmp9_;
	_tmp14_[10] = _tmp10_;
	_tmp14_[11] = _tmp11_;
	_tmp14_[12] = _tmp12_;
	_tmp14_[13] = _tmp13_;
	tile_IMAGE_CLASSES = _tmp14_;
	tile_IMAGE_CLASSES_length1 = 14;
}


static void tile_instance_init (Tile * self) {
	self->priv = TILE_GET_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->scaling_image);
	G_OBJECT_CLASS (tile_parent_class)->finalize (obj);
}


GType tile_get_type (void) {
	static volatile gsize tile_type_id__volatile = 0;
	if (g_once_init_enter (&tile_type_id__volatile)) {
		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_button_get_type (), "Tile", &g_define_type_info, 0);
		g_once_init_leave (&tile_type_id__volatile, tile_type_id);
	}
	return tile_type_id__volatile;
}


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:
		g_value_set_int (value, tile_get_row (self));
		break;
		case TILE_COLUMN:
		g_value_set_int (value, tile_get_column (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



