/* number-picker.c generated by valac 0.34.2.2-0a595, the Vala compiler
 * generated from number-picker.vala, do not modify */

/* -*- Mode: vala; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * Copyright © 2014 Parin Porecha
 * Copyright © 2014 Michael Catanzaro
 *
 * 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 <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include "libsudoku.h"
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>


#define TYPE_NUMBER_PICKER (number_picker_get_type ())
#define NUMBER_PICKER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_NUMBER_PICKER, NumberPicker))
#define NUMBER_PICKER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_NUMBER_PICKER, NumberPickerClass))
#define IS_NUMBER_PICKER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_NUMBER_PICKER))
#define IS_NUMBER_PICKER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_NUMBER_PICKER))
#define NUMBER_PICKER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_NUMBER_PICKER, NumberPickerClass))

typedef struct _NumberPicker NumberPicker;
typedef struct _NumberPickerClass NumberPickerClass;
typedef struct _NumberPickerPrivate NumberPickerPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block7Data Block7Data;
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block8Data Block8Data;

struct _NumberPicker {
	GtkGrid parent_instance;
	NumberPickerPrivate * priv;
};

struct _NumberPickerClass {
	GtkGridClass parent_class;
};

struct _NumberPickerPrivate {
	SudokuBoard* board;
	GtkButton* clear_button;
	gint earmarks_active;
};

struct _Block7Data {
	int _ref_count_;
	NumberPicker* self;
	gint n;
};

struct _Block8Data {
	int _ref_count_;
	Block7Data * _data7_;
	GtkToggleButton* toggle_button;
};


static gpointer number_picker_parent_class = NULL;

GType number_picker_get_type (void) G_GNUC_CONST;
#define NUMBER_PICKER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_NUMBER_PICKER, NumberPickerPrivate))
enum  {
	NUMBER_PICKER_DUMMY_PROPERTY
};
#define NUMBER_PICKER_EARMARKS_MAX_ALLOWED 5
NumberPicker* number_picker_new (SudokuBoard** board, gboolean earmark);
NumberPicker* number_picker_construct (GType object_type, SudokuBoard** board, gboolean earmark);
static Block7Data* block7_data_ref (Block7Data* _data7_);
static void block7_data_unref (void * _userdata_);
static void _________lambda4_ (Block7Data* _data7_);
static void __________lambda4__gtk_button_clicked (GtkButton* _sender, gpointer self);
static Block8Data* block8_data_ref (Block8Data* _data8_);
static void block8_data_unref (void * _userdata_);
static void _________lambda5_ (Block8Data* _data8_);
static void number_picker_set_toggle_sensitive (NumberPicker* self, gboolean state);
static void __________lambda5__gtk_toggle_button_toggled (GtkToggleButton* _sender, gpointer self);
static void ___lambda6_ (NumberPicker* self);
static void ____lambda6__gtk_button_clicked (GtkButton* _sender, gpointer self);
void number_picker_set_clear_button_visibility (NumberPicker* self, gboolean visible);
void number_picker_set_earmarks (NumberPicker* self, gint row, gint col);
gboolean number_picker_set_earmark (NumberPicker* self, gint row, gint col, gint index, gboolean state);
static void g_cclosure_user_marshal_VOID__INT_BOOLEAN (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data);
static void number_picker_finalize (GObject* obj);


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


static Block7Data* block7_data_ref (Block7Data* _data7_) {
	g_atomic_int_inc (&_data7_->_ref_count_);
	return _data7_;
}


static void block7_data_unref (void * _userdata_) {
	Block7Data* _data7_;
	_data7_ = (Block7Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data7_->_ref_count_)) {
		NumberPicker* self;
		self = _data7_->self;
		_g_object_unref0 (self);
		g_slice_free (Block7Data, _data7_);
	}
}


static void _________lambda4_ (Block7Data* _data7_) {
	NumberPicker* self;
	gint _tmp0_ = 0;
	self = _data7_->self;
	_tmp0_ = _data7_->n;
	g_signal_emit_by_name (self, "number-picked", _tmp0_);
}


static void __________lambda4__gtk_button_clicked (GtkButton* _sender, gpointer self) {
	_________lambda4_ (self);
}


static Block8Data* block8_data_ref (Block8Data* _data8_) {
	g_atomic_int_inc (&_data8_->_ref_count_);
	return _data8_;
}


static void block8_data_unref (void * _userdata_) {
	Block8Data* _data8_;
	_data8_ = (Block8Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data8_->_ref_count_)) {
		NumberPicker* self;
		self = _data8_->_data7_->self;
		_g_object_unref0 (_data8_->toggle_button);
		block7_data_unref (_data8_->_data7_);
		_data8_->_data7_ = NULL;
		g_slice_free (Block8Data, _data8_);
	}
}


static void _________lambda5_ (Block8Data* _data8_) {
	Block7Data* _data7_;
	NumberPicker* self;
	gboolean toggle_active = FALSE;
	GtkToggleButton* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	gint _tmp2_ = 0;
	gboolean _tmp3_ = FALSE;
	gint _tmp4_ = 0;
	gboolean _tmp5_ = FALSE;
	gint _tmp8_ = 0;
	_data7_ = _data8_->_data7_;
	self = _data7_->self;
	_tmp0_ = _data8_->toggle_button;
	_tmp1_ = gtk_toggle_button_get_active (_tmp0_);
	toggle_active = _tmp1_;
	_tmp2_ = _data7_->n;
	_tmp3_ = toggle_active;
	g_signal_emit_by_name (self, "earmark-state-changed", _tmp2_, _tmp3_);
	_tmp5_ = toggle_active;
	if (_tmp5_) {
		gint _tmp6_ = 0;
		_tmp6_ = self->priv->earmarks_active;
		_tmp4_ = _tmp6_ + 1;
	} else {
		gint _tmp7_ = 0;
		_tmp7_ = self->priv->earmarks_active;
		_tmp4_ = _tmp7_ - 1;
	}
	self->priv->earmarks_active = _tmp4_;
	_tmp8_ = self->priv->earmarks_active;
	if (_tmp8_ < NUMBER_PICKER_EARMARKS_MAX_ALLOWED) {
		number_picker_set_toggle_sensitive (self, TRUE);
	} else {
		number_picker_set_toggle_sensitive (self, FALSE);
	}
}


static void __________lambda5__gtk_toggle_button_toggled (GtkToggleButton* _sender, gpointer self) {
	_________lambda5_ (self);
}


static void ___lambda6_ (NumberPicker* self) {
	g_signal_emit_by_name (self, "number-picked", 0);
}


static void ____lambda6__gtk_button_clicked (GtkButton* _sender, gpointer self) {
	___lambda6_ ((NumberPicker*) self);
}


NumberPicker* number_picker_construct (GType object_type, SudokuBoard** board, gboolean earmark) {
	NumberPicker * self = NULL;
	SudokuBoard* _tmp0_ = NULL;
	SudokuBoard* _tmp1_ = NULL;
	gboolean _tmp48_ = FALSE;
	g_return_val_if_fail (*board != NULL, NULL);
	self = (NumberPicker*) g_object_new (object_type, NULL);
	_tmp0_ = *board;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->board);
	self->priv->board = _tmp1_;
	self->priv->earmarks_active = 0;
	{
		gint col = 0;
		col = 0;
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = TRUE;
			while (TRUE) {
				gint _tmp4_ = 0;
				SudokuBoard* _tmp5_ = NULL;
				gint _tmp6_ = 0;
				gint _tmp7_ = 0;
				if (!_tmp2_) {
					gint _tmp3_ = 0;
					_tmp3_ = col;
					col = _tmp3_ + 1;
				}
				_tmp2_ = FALSE;
				_tmp4_ = col;
				_tmp5_ = *board;
				_tmp6_ = sudoku_board_get_block_cols (_tmp5_);
				_tmp7_ = _tmp6_;
				if (!(_tmp4_ < _tmp7_)) {
					break;
				}
				{
					gint row = 0;
					row = 0;
					{
						gboolean _tmp8_ = FALSE;
						_tmp8_ = TRUE;
						while (TRUE) {
							Block7Data* _data7_;
							gint _tmp10_ = 0;
							SudokuBoard* _tmp11_ = NULL;
							gint _tmp12_ = 0;
							gint _tmp13_ = 0;
							gint _tmp14_ = 0;
							gint _tmp15_ = 0;
							SudokuBoard* _tmp16_ = NULL;
							gint _tmp17_ = 0;
							gint _tmp18_ = 0;
							GtkButton* _tmp19_ = NULL;
							gboolean _tmp20_ = FALSE;
							GtkButton* button = NULL;
							GtkButton* _tmp23_ = NULL;
							GtkButton* _tmp24_ = NULL;
							GtkButton* _tmp25_ = NULL;
							gint _tmp26_ = 0;
							gint _tmp27_ = 0;
							GtkLabel* label = NULL;
							gint _tmp28_ = 0;
							gchar* _tmp29_ = NULL;
							gchar* _tmp30_ = NULL;
							GtkLabel* _tmp31_ = NULL;
							GtkLabel* _tmp32_ = NULL;
							GtkLabel* _tmp33_ = NULL;
							GtkLabel* _tmp34_ = NULL;
							GtkLabel* _tmp35_ = NULL;
							GtkLabel* _tmp36_ = NULL;
							GtkButton* _tmp37_ = NULL;
							GtkLabel* _tmp38_ = NULL;
							GtkLabel* _tmp39_ = NULL;
							gboolean _tmp40_ = FALSE;
							gint _tmp45_ = 0;
							GtkButton* _tmp47_ = NULL;
							_data7_ = g_slice_new0 (Block7Data);
							_data7_->_ref_count_ = 1;
							_data7_->self = g_object_ref (self);
							if (!_tmp8_) {
								gint _tmp9_ = 0;
								_tmp9_ = row;
								row = _tmp9_ + 1;
							}
							_tmp8_ = FALSE;
							_tmp10_ = row;
							_tmp11_ = *board;
							_tmp12_ = sudoku_board_get_block_rows (_tmp11_);
							_tmp13_ = _tmp12_;
							if (!(_tmp10_ < _tmp13_)) {
								block7_data_unref (_data7_);
								_data7_ = NULL;
								break;
							}
							_tmp14_ = col;
							_tmp15_ = row;
							_tmp16_ = *board;
							_tmp17_ = sudoku_board_get_block_cols (_tmp16_);
							_tmp18_ = _tmp17_;
							_data7_->n = (_tmp14_ + (_tmp15_ * _tmp18_)) + 1;
							_tmp20_ = earmark;
							if (_tmp20_) {
								GtkToggleButton* _tmp21_ = NULL;
								_tmp21_ = (GtkToggleButton*) gtk_toggle_button_new ();
								g_object_ref_sink (_tmp21_);
								_g_object_unref0 (_tmp19_);
								_tmp19_ = (GtkButton*) _tmp21_;
							} else {
								GtkButton* _tmp22_ = NULL;
								_tmp22_ = (GtkButton*) gtk_button_new ();
								g_object_ref_sink (_tmp22_);
								_g_object_unref0 (_tmp19_);
								_tmp19_ = _tmp22_;
							}
							_tmp23_ = _g_object_ref0 (_tmp19_);
							button = _tmp23_;
							_tmp24_ = button;
							gtk_widget_set_focus_on_click ((GtkWidget*) _tmp24_, FALSE);
							_tmp25_ = button;
							_tmp26_ = col;
							_tmp27_ = row;
							gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) _tmp25_, _tmp26_, _tmp27_, 1, 1);
							_tmp28_ = _data7_->n;
							_tmp29_ = g_strdup_printf ("<big>%d</big>", _tmp28_);
							_tmp30_ = _tmp29_;
							_tmp31_ = (GtkLabel*) gtk_label_new (_tmp30_);
							g_object_ref_sink (_tmp31_);
							_tmp32_ = _tmp31_;
							_g_free0 (_tmp30_);
							label = _tmp32_;
							_tmp33_ = label;
							gtk_label_set_use_markup (_tmp33_, TRUE);
							_tmp34_ = label;
							g_object_set ((GtkWidget*) _tmp34_, "margin", 4, NULL);
							_tmp35_ = label;
							gtk_widget_set_margin_start ((GtkWidget*) _tmp35_, 8);
							_tmp36_ = label;
							gtk_widget_set_margin_end ((GtkWidget*) _tmp36_, 8);
							_tmp37_ = button;
							_tmp38_ = label;
							gtk_container_add ((GtkContainer*) _tmp37_, (GtkWidget*) _tmp38_);
							_tmp39_ = label;
							gtk_widget_show ((GtkWidget*) _tmp39_);
							_tmp40_ = earmark;
							if (!_tmp40_) {
								GtkButton* _tmp41_ = NULL;
								_tmp41_ = button;
								g_signal_connect_data (_tmp41_, "clicked", (GCallback) __________lambda4__gtk_button_clicked, block7_data_ref (_data7_), (GClosureNotify) block7_data_unref, 0);
							} else {
								Block8Data* _data8_;
								GtkButton* _tmp42_ = NULL;
								GtkToggleButton* _tmp43_ = NULL;
								GtkToggleButton* _tmp44_ = NULL;
								_data8_ = g_slice_new0 (Block8Data);
								_data8_->_ref_count_ = 1;
								_data8_->_data7_ = block7_data_ref (_data7_);
								_tmp42_ = button;
								_tmp43_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp42_, gtk_toggle_button_get_type (), GtkToggleButton));
								_data8_->toggle_button = _tmp43_;
								_tmp44_ = _data8_->toggle_button;
								g_signal_connect_data (_tmp44_, "toggled", (GCallback) __________lambda5__gtk_toggle_button_toggled, block8_data_ref (_data8_), (GClosureNotify) block8_data_unref, 0);
								block8_data_unref (_data8_);
								_data8_ = NULL;
							}
							_tmp45_ = _data7_->n;
							if (_tmp45_ == 5) {
								GtkButton* _tmp46_ = NULL;
								_tmp46_ = button;
								gtk_widget_grab_focus ((GtkWidget*) _tmp46_);
							}
							_tmp47_ = button;
							gtk_widget_show ((GtkWidget*) _tmp47_);
							_g_object_unref0 (label);
							_g_object_unref0 (button);
							_g_object_unref0 (_tmp19_);
							block7_data_unref (_data7_);
							_data7_ = NULL;
						}
					}
				}
			}
		}
	}
	_tmp48_ = earmark;
	if (!_tmp48_) {
		GtkButton* _tmp49_ = NULL;
		GtkButton* _tmp50_ = NULL;
		GtkButton* _tmp51_ = NULL;
		GtkLabel* label = NULL;
		const gchar* _tmp52_ = NULL;
		gchar* _tmp53_ = NULL;
		gchar* _tmp54_ = NULL;
		GtkLabel* _tmp55_ = NULL;
		GtkLabel* _tmp56_ = NULL;
		GtkLabel* _tmp57_ = NULL;
		GtkButton* _tmp58_ = NULL;
		GtkLabel* _tmp59_ = NULL;
		GtkLabel* _tmp60_ = NULL;
		GtkButton* _tmp61_ = NULL;
		_tmp49_ = (GtkButton*) gtk_button_new ();
		g_object_ref_sink (_tmp49_);
		_g_object_unref0 (self->priv->clear_button);
		self->priv->clear_button = _tmp49_;
		_tmp50_ = self->priv->clear_button;
		gtk_widget_set_focus_on_click ((GtkWidget*) _tmp50_, FALSE);
		_tmp51_ = self->priv->clear_button;
		gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) _tmp51_, 0, 4, 3, 1);
		_tmp52_ = _ ("Clear");
		_tmp53_ = g_strdup_printf ("<big>%s</big>", _tmp52_);
		_tmp54_ = _tmp53_;
		_tmp55_ = (GtkLabel*) gtk_label_new (_tmp54_);
		g_object_ref_sink (_tmp55_);
		_tmp56_ = _tmp55_;
		_g_free0 (_tmp54_);
		label = _tmp56_;
		_tmp57_ = label;
		gtk_label_set_use_markup (_tmp57_, TRUE);
		_tmp58_ = self->priv->clear_button;
		_tmp59_ = label;
		gtk_container_add ((GtkContainer*) _tmp58_, (GtkWidget*) _tmp59_);
		_tmp60_ = label;
		gtk_widget_show ((GtkWidget*) _tmp60_);
		_tmp61_ = self->priv->clear_button;
		g_signal_connect_object (_tmp61_, "clicked", (GCallback) ____lambda6__gtk_button_clicked, self, 0);
		_g_object_unref0 (label);
	}
	gtk_widget_set_valign ((GtkWidget*) self, GTK_ALIGN_CENTER);
	gtk_widget_set_halign ((GtkWidget*) self, GTK_ALIGN_CENTER);
	g_object_set ((GtkWidget*) self, "margin", 2, NULL);
	gtk_grid_set_row_spacing ((GtkGrid*) self, 3);
	gtk_grid_set_column_spacing ((GtkGrid*) self, 3);
	gtk_widget_show ((GtkWidget*) self);
	return self;
}


NumberPicker* number_picker_new (SudokuBoard** board, gboolean earmark) {
	return number_picker_construct (TYPE_NUMBER_PICKER, board, earmark);
}


void number_picker_set_clear_button_visibility (NumberPicker* self, gboolean visible) {
	gboolean _tmp0_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = visible;
	if (_tmp0_) {
		GtkButton* _tmp1_ = NULL;
		_tmp1_ = self->priv->clear_button;
		gtk_widget_show ((GtkWidget*) _tmp1_);
	} else {
		GtkButton* _tmp2_ = NULL;
		_tmp2_ = self->priv->clear_button;
		gtk_widget_hide ((GtkWidget*) _tmp2_);
	}
}


void number_picker_set_earmarks (NumberPicker* self, gint row, gint col) {
	g_return_if_fail (self != NULL);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				gint _tmp2_ = 0;
				SudokuBoard* _tmp3_ = NULL;
				gint _tmp4_ = 0;
				gint _tmp5_ = 0;
				gint _tmp6_ = 0;
				gint _tmp7_ = 0;
				gint _tmp8_ = 0;
				SudokuBoard* _tmp9_ = NULL;
				gint _tmp10_ = 0;
				gint _tmp11_ = 0;
				gint _tmp12_ = 0;
				gboolean _tmp13_ = FALSE;
				if (!_tmp0_) {
					gint _tmp1_ = 0;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = i;
				_tmp3_ = self->priv->board;
				_tmp4_ = sudoku_board_get_max_val (_tmp3_);
				_tmp5_ = _tmp4_;
				if (!(_tmp2_ < _tmp5_)) {
					break;
				}
				_tmp6_ = row;
				_tmp7_ = col;
				_tmp8_ = i;
				_tmp9_ = self->priv->board;
				_tmp10_ = row;
				_tmp11_ = col;
				_tmp12_ = i;
				_tmp13_ = sudoku_board_is_earmark_enabled (_tmp9_, _tmp10_, _tmp11_, _tmp12_ + 1);
				number_picker_set_earmark (self, _tmp6_, _tmp7_, _tmp8_, _tmp13_);
			}
		}
	}
}


gboolean number_picker_set_earmark (NumberPicker* self, gint row, gint col, gint index, gboolean state) {
	gboolean result = FALSE;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	GtkToggleButton* button = NULL;
	gint _tmp3_ = 0;
	SudokuBoard* _tmp4_ = NULL;
	gint _tmp5_ = 0;
	gint _tmp6_ = 0;
	gint _tmp7_ = 0;
	SudokuBoard* _tmp8_ = NULL;
	gint _tmp9_ = 0;
	gint _tmp10_ = 0;
	GtkWidget* _tmp11_ = NULL;
	GtkToggleButton* _tmp12_ = NULL;
	GtkToggleButton* _tmp13_ = NULL;
	gboolean _tmp14_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp1_ = state;
	if (_tmp1_) {
		gint _tmp2_ = 0;
		_tmp2_ = self->priv->earmarks_active;
		_tmp0_ = _tmp2_ >= NUMBER_PICKER_EARMARKS_MAX_ALLOWED;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		result = FALSE;
		return result;
	}
	_tmp3_ = index;
	_tmp4_ = self->priv->board;
	_tmp5_ = sudoku_board_get_block_cols (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = index;
	_tmp8_ = self->priv->board;
	_tmp9_ = sudoku_board_get_block_rows (_tmp8_);
	_tmp10_ = _tmp9_;
	_tmp11_ = gtk_grid_get_child_at ((GtkGrid*) self, _tmp3_ % _tmp6_, _tmp7_ / _tmp10_);
	_tmp12_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, gtk_toggle_button_get_type (), GtkToggleButton));
	button = _tmp12_;
	_tmp13_ = button;
	_tmp14_ = state;
	gtk_toggle_button_set_active (_tmp13_, _tmp14_);
	result = TRUE;
	_g_object_unref0 (button);
	return result;
}


static void number_picker_set_toggle_sensitive (NumberPicker* self, gboolean state) {
	gboolean _tmp0_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = state;
	if (_tmp0_) {
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp1_ = FALSE;
				_tmp1_ = TRUE;
				while (TRUE) {
					gint _tmp3_ = 0;
					SudokuBoard* _tmp4_ = NULL;
					gint _tmp5_ = 0;
					gint _tmp6_ = 0;
					gint _tmp7_ = 0;
					SudokuBoard* _tmp8_ = NULL;
					gint _tmp9_ = 0;
					gint _tmp10_ = 0;
					gint _tmp11_ = 0;
					SudokuBoard* _tmp12_ = NULL;
					gint _tmp13_ = 0;
					gint _tmp14_ = 0;
					GtkWidget* _tmp15_ = NULL;
					if (!_tmp1_) {
						gint _tmp2_ = 0;
						_tmp2_ = i;
						i = _tmp2_ + 1;
					}
					_tmp1_ = FALSE;
					_tmp3_ = i;
					_tmp4_ = self->priv->board;
					_tmp5_ = sudoku_board_get_max_val (_tmp4_);
					_tmp6_ = _tmp5_;
					if (!(_tmp3_ < _tmp6_)) {
						break;
					}
					_tmp7_ = i;
					_tmp8_ = self->priv->board;
					_tmp9_ = sudoku_board_get_block_cols (_tmp8_);
					_tmp10_ = _tmp9_;
					_tmp11_ = i;
					_tmp12_ = self->priv->board;
					_tmp13_ = sudoku_board_get_block_rows (_tmp12_);
					_tmp14_ = _tmp13_;
					_tmp15_ = gtk_grid_get_child_at ((GtkGrid*) self, _tmp7_ % _tmp10_, _tmp11_ / _tmp14_);
					gtk_widget_set_sensitive (_tmp15_, TRUE);
				}
			}
		}
	} else {
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp16_ = FALSE;
				_tmp16_ = TRUE;
				while (TRUE) {
					gint _tmp18_ = 0;
					SudokuBoard* _tmp19_ = NULL;
					gint _tmp20_ = 0;
					gint _tmp21_ = 0;
					GtkToggleButton* button = NULL;
					gint _tmp22_ = 0;
					SudokuBoard* _tmp23_ = NULL;
					gint _tmp24_ = 0;
					gint _tmp25_ = 0;
					gint _tmp26_ = 0;
					SudokuBoard* _tmp27_ = NULL;
					gint _tmp28_ = 0;
					gint _tmp29_ = 0;
					GtkWidget* _tmp30_ = NULL;
					GtkToggleButton* _tmp31_ = NULL;
					GtkToggleButton* _tmp32_ = NULL;
					gboolean _tmp33_ = FALSE;
					gboolean _tmp34_ = FALSE;
					if (!_tmp16_) {
						gint _tmp17_ = 0;
						_tmp17_ = i;
						i = _tmp17_ + 1;
					}
					_tmp16_ = FALSE;
					_tmp18_ = i;
					_tmp19_ = self->priv->board;
					_tmp20_ = sudoku_board_get_max_val (_tmp19_);
					_tmp21_ = _tmp20_;
					if (!(_tmp18_ < _tmp21_)) {
						break;
					}
					_tmp22_ = i;
					_tmp23_ = self->priv->board;
					_tmp24_ = sudoku_board_get_block_cols (_tmp23_);
					_tmp25_ = _tmp24_;
					_tmp26_ = i;
					_tmp27_ = self->priv->board;
					_tmp28_ = sudoku_board_get_block_rows (_tmp27_);
					_tmp29_ = _tmp28_;
					_tmp30_ = gtk_grid_get_child_at ((GtkGrid*) self, _tmp22_ % _tmp25_, _tmp26_ / _tmp29_);
					_tmp31_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp30_, gtk_toggle_button_get_type (), GtkToggleButton));
					button = _tmp31_;
					_tmp32_ = button;
					_tmp33_ = gtk_toggle_button_get_active (_tmp32_);
					_tmp34_ = _tmp33_;
					if (!_tmp34_) {
						GtkToggleButton* _tmp35_ = NULL;
						_tmp35_ = button;
						gtk_widget_set_sensitive ((GtkWidget*) _tmp35_, FALSE);
					}
					_g_object_unref0 (button);
				}
			}
		}
	}
}


static void g_cclosure_user_marshal_VOID__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_BOOLEAN) (gpointer data1, gint arg_1, gboolean arg_2, gpointer data2);
	register GMarshalFunc_VOID__INT_BOOLEAN 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_BOOLEAN) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_int (param_values + 1), g_value_get_boolean (param_values + 2), data2);
}


static void number_picker_class_init (NumberPickerClass * klass) {
	number_picker_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (NumberPickerPrivate));
	G_OBJECT_CLASS (klass)->finalize = number_picker_finalize;
	g_signal_new ("number_picked", TYPE_NUMBER_PICKER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
	g_signal_new ("earmark_state_changed", TYPE_NUMBER_PICKER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__INT_BOOLEAN, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_BOOLEAN);
}


static void number_picker_instance_init (NumberPicker * self) {
	self->priv = NUMBER_PICKER_GET_PRIVATE (self);
}


static void number_picker_finalize (GObject* obj) {
	NumberPicker * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_NUMBER_PICKER, NumberPicker);
	_g_object_unref0 (self->priv->board);
	_g_object_unref0 (self->priv->clear_button);
	G_OBJECT_CLASS (number_picker_parent_class)->finalize (obj);
}


GType number_picker_get_type (void) {
	static volatile gsize number_picker_type_id__volatile = 0;
	if (g_once_init_enter (&number_picker_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (NumberPickerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) number_picker_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (NumberPicker), 0, (GInstanceInitFunc) number_picker_instance_init, NULL };
		GType number_picker_type_id;
		number_picker_type_id = g_type_register_static (gtk_grid_get_type (), "NumberPicker", &g_define_type_info, 0);
		g_once_init_leave (&number_picker_type_id__volatile, number_picker_type_id);
	}
	return number_picker_type_id__volatile;
}



