/* preferences-dialog.c generated by valac 0.35.2.5-825d5, the Vala compiler
 * generated from preferences-dialog.vala, do not modify */

/* -*- Mode: vala; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 * Gnome Nibbles: Gnome Worm Game
 * Copyright (C) 2015 Gabriel Ivascu <ivascu.gabriel59@gmail.com>
 *
 * This program 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.
 *
 * This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <gee.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.h>
#include <gdk/gdk.h>


#define TYPE_PREFERENCES_DIALOG (preferences_dialog_get_type ())
#define PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PREFERENCES_DIALOG, PreferencesDialog))
#define PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PREFERENCES_DIALOG, PreferencesDialogClass))
#define IS_PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PREFERENCES_DIALOG))
#define IS_PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PREFERENCES_DIALOG))
#define PREFERENCES_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PREFERENCES_DIALOG, PreferencesDialogClass))

typedef struct _PreferencesDialog PreferencesDialog;
typedef struct _PreferencesDialogClass PreferencesDialogClass;
typedef struct _PreferencesDialogPrivate PreferencesDialogPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _gtk_tree_path_free0(var) ((var == NULL) ? NULL : (var = (gtk_tree_path_free (var), NULL)))

struct _PreferencesDialog {
	GtkDialog parent_instance;
	PreferencesDialogPrivate * priv;
};

struct _PreferencesDialogClass {
	GtkDialogClass parent_class;
};

struct _PreferencesDialogPrivate {
	GtkApplicationWindow* window;
	GSettings* settings;
	GeeArrayList* worm_settings;
	GtkNotebook* notebook;
	GtkRadioButton* beginner_radio_button;
	GtkRadioButton* slow_radio_button;
	GtkRadioButton* medium_radio_button;
	GtkRadioButton* fast_radio_button;
	GtkCheckButton* sound_check_button;
	GtkCheckButton* fakes_check_button;
	GtkListStore* list_store_1;
	GtkListStore* list_store_2;
	GtkListStore* list_store_3;
	GtkListStore* list_store_4;
	GtkTreeView* tree_view_1;
	GtkTreeView* tree_view_2;
	GtkTreeView* tree_view_3;
	GtkTreeView* tree_view_4;
	GtkComboBoxText* combo_box_1;
	GtkComboBoxText* combo_box_2;
	GtkComboBoxText* combo_box_3;
	GtkComboBoxText* combo_box_4;
	GeeArrayList* radio_buttons;
	GeeArrayList* list_stores;
	GeeArrayList* tree_views;
	GeeArrayList* combo_boxes;
};


static gpointer preferences_dialog_parent_class = NULL;

GType preferences_dialog_get_type (void) G_GNUC_CONST;
#define PREFERENCES_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_PREFERENCES_DIALOG, PreferencesDialogPrivate))
enum  {
	PREFERENCES_DIALOG_DUMMY_PROPERTY
};
PreferencesDialog* preferences_dialog_new (GtkApplicationWindow* window, GSettings* settings, GeeArrayList* worm_settings);
PreferencesDialog* preferences_dialog_construct (GType object_type, GtkApplicationWindow* window, GSettings* settings, GeeArrayList* worm_settings);
static void __lambda4_ (PreferencesDialog* self);
static void ___lambda4__gtk_dialog_response (GtkDialog* _sender, gint response_id, gpointer self);
#define NIBBLES_GAME_MAX_SPEED 4
static void preferences_dialog_radio_button_toggled_cb (PreferencesDialog* self, GtkToggleButton* button);
static void _preferences_dialog_radio_button_toggled_cb_gtk_toggle_button_toggled (GtkToggleButton* _sender, gpointer self);
static void preferences_dialog_sound_toggled_cb (PreferencesDialog* self);
static void _preferences_dialog_sound_toggled_cb_gtk_toggle_button_toggled (GtkToggleButton* _sender, gpointer self);
static void preferences_dialog_fakes_toggles_cb (PreferencesDialog* self);
static void _preferences_dialog_fakes_toggles_cb_gtk_toggle_button_toggled (GtkToggleButton* _sender, gpointer self);
static void preferences_dialog_accel_edited_cb (PreferencesDialog* self, GtkCellRendererAccel* cell, const gchar* path_string, guint keyval, GdkModifierType mask, guint hardware_keycode);
static void _preferences_dialog_accel_edited_cb_gtk_cell_renderer_accel_accel_edited (GtkCellRendererAccel* _sender, const gchar* path_string, guint accel_key, GdkModifierType accel_mods, guint hardware_keycode, gpointer self);
static void preferences_dialog_accel_cleared_cb (PreferencesDialog* self, GtkCellRendererAccel* cell, const gchar* path_string);
static void _preferences_dialog_accel_cleared_cb_gtk_cell_renderer_accel_accel_cleared (GtkCellRendererAccel* _sender, const gchar* path_string, gpointer self);
#define NIBBLES_VIEW_NUM_COLORS 6
gchar* nibbles_view_colorval_name (gint colorval);
static void preferences_dialog_combo_box_changed_cb (PreferencesDialog* self, GtkComboBox* combo_box);
static void _preferences_dialog_combo_box_changed_cb_gtk_combo_box_changed (GtkComboBox* _sender, gpointer self);
#define NIBBLES_GAME_MAX_HUMANS 4
#define NIBBLES_GAME_MAX_WORMS 6
static void preferences_dialog_finalize (GObject * obj);


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


static void __lambda4_ (PreferencesDialog* self) {
	gtk_widget_destroy ((GtkWidget*) self);
}


static void ___lambda4__gtk_dialog_response (GtkDialog* _sender, gint response_id, gpointer self) {
	__lambda4_ ((PreferencesDialog*) self);
}


static void _preferences_dialog_radio_button_toggled_cb_gtk_toggle_button_toggled (GtkToggleButton* _sender, gpointer self) {
	preferences_dialog_radio_button_toggled_cb ((PreferencesDialog*) self, _sender);
}


static void _preferences_dialog_sound_toggled_cb_gtk_toggle_button_toggled (GtkToggleButton* _sender, gpointer self) {
	preferences_dialog_sound_toggled_cb ((PreferencesDialog*) self);
}


static void _preferences_dialog_fakes_toggles_cb_gtk_toggle_button_toggled (GtkToggleButton* _sender, gpointer self) {
	preferences_dialog_fakes_toggles_cb ((PreferencesDialog*) self);
}


static void _preferences_dialog_accel_edited_cb_gtk_cell_renderer_accel_accel_edited (GtkCellRendererAccel* _sender, const gchar* path_string, guint accel_key, GdkModifierType accel_mods, guint hardware_keycode, gpointer self) {
	preferences_dialog_accel_edited_cb ((PreferencesDialog*) self, _sender, path_string, accel_key, accel_mods, hardware_keycode);
}


static void _preferences_dialog_accel_cleared_cb_gtk_cell_renderer_accel_accel_cleared (GtkCellRendererAccel* _sender, const gchar* path_string, gpointer self) {
	preferences_dialog_accel_cleared_cb ((PreferencesDialog*) self, _sender, path_string);
}


static void _preferences_dialog_combo_box_changed_cb_gtk_combo_box_changed (GtkComboBox* _sender, gpointer self) {
	preferences_dialog_combo_box_changed_cb ((PreferencesDialog*) self, _sender);
}


PreferencesDialog* preferences_dialog_construct (GType object_type, GtkApplicationWindow* window, GSettings* settings, GeeArrayList* worm_settings) {
	PreferencesDialog * self = NULL;
	GSettings* _tmp0_;
	GSettings* _tmp1_;
	GeeArrayList* _tmp2_;
	GeeArrayList* _tmp3_;
	GtkApplicationWindow* _tmp4_;
	GtkApplicationWindow* _tmp5_;
	GtkApplicationWindow* _tmp6_;
	GeeArrayList* _tmp7_;
	GeeArrayList* _tmp8_;
	GtkRadioButton* _tmp9_;
	GeeArrayList* _tmp10_;
	GtkRadioButton* _tmp11_;
	GeeArrayList* _tmp12_;
	GtkRadioButton* _tmp13_;
	GeeArrayList* _tmp14_;
	GtkRadioButton* _tmp15_;
	GtkCheckButton* _tmp35_;
	GSettings* _tmp36_;
	gboolean _tmp37_;
	GtkCheckButton* _tmp38_;
	GtkCheckButton* _tmp39_;
	GSettings* _tmp40_;
	gboolean _tmp41_;
	GtkCheckButton* _tmp42_;
	GeeArrayList* _tmp43_;
	GeeArrayList* _tmp44_;
	GtkTreeView* _tmp45_;
	GeeArrayList* _tmp46_;
	GtkTreeView* _tmp47_;
	GeeArrayList* _tmp48_;
	GtkTreeView* _tmp49_;
	GeeArrayList* _tmp50_;
	GtkTreeView* _tmp51_;
	GeeArrayList* _tmp52_;
	GeeArrayList* _tmp53_;
	GtkListStore* _tmp54_;
	GeeArrayList* _tmp55_;
	GtkListStore* _tmp56_;
	GeeArrayList* _tmp57_;
	GtkListStore* _tmp58_;
	GeeArrayList* _tmp59_;
	GtkListStore* _tmp60_;
	GeeArrayList* _tmp129_;
	GeeArrayList* _tmp130_;
	GtkComboBoxText* _tmp131_;
	GeeArrayList* _tmp132_;
	GtkComboBoxText* _tmp133_;
	GeeArrayList* _tmp134_;
	GtkComboBoxText* _tmp135_;
	GeeArrayList* _tmp136_;
	GtkComboBoxText* _tmp137_;
	g_return_val_if_fail (window != NULL, NULL);
	g_return_val_if_fail (settings != NULL, NULL);
	g_return_val_if_fail (worm_settings != NULL, NULL);
	self = (PreferencesDialog*) g_object_new (object_type, "use-header-bar", 1, NULL);
	_tmp0_ = settings;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->settings);
	self->priv->settings = _tmp1_;
	_tmp2_ = worm_settings;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	_g_object_unref0 (self->priv->worm_settings);
	self->priv->worm_settings = _tmp3_;
	_tmp4_ = window;
	_tmp5_ = _g_object_ref0 (_tmp4_);
	_g_object_unref0 (self->priv->window);
	self->priv->window = _tmp5_;
	g_signal_connect_object ((GtkDialog*) self, "response", (GCallback) ___lambda4__gtk_dialog_response, self, 0);
	_tmp6_ = window;
	gtk_window_set_transient_for ((GtkWindow*) self, (GtkWindow*) _tmp6_);
	_tmp7_ = gee_array_list_new (gtk_radio_button_get_type (), (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->radio_buttons);
	self->priv->radio_buttons = _tmp7_;
	_tmp8_ = self->priv->radio_buttons;
	_tmp9_ = self->priv->beginner_radio_button;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp8_, _tmp9_);
	_tmp10_ = self->priv->radio_buttons;
	_tmp11_ = self->priv->slow_radio_button;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp10_, _tmp11_);
	_tmp12_ = self->priv->radio_buttons;
	_tmp13_ = self->priv->medium_radio_button;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp12_, _tmp13_);
	_tmp14_ = self->priv->radio_buttons;
	_tmp15_ = self->priv->fast_radio_button;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp14_, _tmp15_);
	{
		GeeArrayList* _radio_button_list;
		GeeArrayList* _tmp16_;
		GeeArrayList* _tmp17_;
		gint _radio_button_size;
		GeeArrayList* _tmp18_;
		gint _tmp19_;
		gint _tmp20_;
		gint _radio_button_index;
		_tmp16_ = self->priv->radio_buttons;
		_tmp17_ = _g_object_ref0 (_tmp16_);
		_radio_button_list = _tmp17_;
		_tmp18_ = _radio_button_list;
		_tmp19_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp18_);
		_tmp20_ = _tmp19_;
		_radio_button_size = _tmp20_;
		_radio_button_index = -1;
		while (TRUE) {
			gint _tmp21_;
			gint _tmp22_;
			gint _tmp23_;
			GtkRadioButton* radio_button;
			GeeArrayList* _tmp24_;
			gint _tmp25_;
			gpointer _tmp26_;
			gint speed;
			GeeArrayList* _tmp27_;
			GtkRadioButton* _tmp28_;
			gint _tmp29_;
			GtkRadioButton* _tmp30_;
			gint _tmp31_;
			GSettings* _tmp32_;
			gint _tmp33_;
			GtkRadioButton* _tmp34_;
			_tmp21_ = _radio_button_index;
			_radio_button_index = _tmp21_ + 1;
			_tmp22_ = _radio_button_index;
			_tmp23_ = _radio_button_size;
			if (!(_tmp22_ < _tmp23_)) {
				break;
			}
			_tmp24_ = _radio_button_list;
			_tmp25_ = _radio_button_index;
			_tmp26_ = gee_abstract_list_get ((GeeAbstractList*) _tmp24_, _tmp25_);
			radio_button = (GtkRadioButton*) _tmp26_;
			_tmp27_ = self->priv->radio_buttons;
			_tmp28_ = radio_button;
			_tmp29_ = gee_abstract_list_index_of ((GeeAbstractList*) _tmp27_, _tmp28_);
			speed = NIBBLES_GAME_MAX_SPEED - _tmp29_;
			_tmp30_ = radio_button;
			_tmp31_ = speed;
			_tmp32_ = settings;
			_tmp33_ = g_settings_get_int (_tmp32_, "speed");
			gtk_toggle_button_set_active ((GtkToggleButton*) _tmp30_, _tmp31_ == _tmp33_);
			_tmp34_ = radio_button;
			g_signal_connect_object ((GtkToggleButton*) _tmp34_, "toggled", (GCallback) _preferences_dialog_radio_button_toggled_cb_gtk_toggle_button_toggled, self, 0);
			_g_object_unref0 (radio_button);
		}
		_g_object_unref0 (_radio_button_list);
	}
	_tmp35_ = self->priv->sound_check_button;
	_tmp36_ = settings;
	_tmp37_ = g_settings_get_boolean (_tmp36_, "sound");
	gtk_toggle_button_set_active ((GtkToggleButton*) _tmp35_, _tmp37_);
	_tmp38_ = self->priv->sound_check_button;
	g_signal_connect_object ((GtkToggleButton*) _tmp38_, "toggled", (GCallback) _preferences_dialog_sound_toggled_cb_gtk_toggle_button_toggled, self, 0);
	_tmp39_ = self->priv->fakes_check_button;
	_tmp40_ = settings;
	_tmp41_ = g_settings_get_boolean (_tmp40_, "fakes");
	gtk_toggle_button_set_active ((GtkToggleButton*) _tmp39_, _tmp41_);
	_tmp42_ = self->priv->fakes_check_button;
	g_signal_connect_object ((GtkToggleButton*) _tmp42_, "toggled", (GCallback) _preferences_dialog_fakes_toggles_cb_gtk_toggle_button_toggled, self, 0);
	_tmp43_ = gee_array_list_new (gtk_tree_view_get_type (), (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->tree_views);
	self->priv->tree_views = _tmp43_;
	_tmp44_ = self->priv->tree_views;
	_tmp45_ = self->priv->tree_view_1;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp44_, _tmp45_);
	_tmp46_ = self->priv->tree_views;
	_tmp47_ = self->priv->tree_view_2;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp46_, _tmp47_);
	_tmp48_ = self->priv->tree_views;
	_tmp49_ = self->priv->tree_view_3;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp48_, _tmp49_);
	_tmp50_ = self->priv->tree_views;
	_tmp51_ = self->priv->tree_view_4;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp50_, _tmp51_);
	_tmp52_ = gee_array_list_new (gtk_list_store_get_type (), (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->list_stores);
	self->priv->list_stores = _tmp52_;
	_tmp53_ = self->priv->list_stores;
	_tmp54_ = self->priv->list_store_1;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp53_, _tmp54_);
	_tmp55_ = self->priv->list_stores;
	_tmp56_ = self->priv->list_store_2;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp55_, _tmp56_);
	_tmp57_ = self->priv->list_stores;
	_tmp58_ = self->priv->list_store_3;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp57_, _tmp58_);
	_tmp59_ = self->priv->list_stores;
	_tmp60_ = self->priv->list_store_4;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp59_, _tmp60_);
	{
		GeeArrayList* _list_store_list;
		GeeArrayList* _tmp61_;
		GeeArrayList* _tmp62_;
		gint _list_store_size;
		GeeArrayList* _tmp63_;
		gint _tmp64_;
		gint _tmp65_;
		gint _list_store_index;
		_tmp61_ = self->priv->list_stores;
		_tmp62_ = _g_object_ref0 (_tmp61_);
		_list_store_list = _tmp62_;
		_tmp63_ = _list_store_list;
		_tmp64_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp63_);
		_tmp65_ = _tmp64_;
		_list_store_size = _tmp65_;
		_list_store_index = -1;
		while (TRUE) {
			gint _tmp66_;
			gint _tmp67_;
			gint _tmp68_;
			GtkListStore* list_store;
			GeeArrayList* _tmp69_;
			gint _tmp70_;
			gpointer _tmp71_;
			gint id;
			GeeArrayList* _tmp72_;
			GtkListStore* _tmp73_;
			gint _tmp74_;
			GtkTreeView* tree_view;
			GeeArrayList* _tmp75_;
			gint _tmp76_;
			gpointer _tmp77_;
			GtkTreeIter iter = {0};
			GtkListStore* _tmp78_;
			GtkTreeIter _tmp79_ = {0};
			gint keyval;
			GeeArrayList* _tmp80_;
			gint _tmp81_;
			gpointer _tmp82_;
			GSettings* _tmp83_;
			gint _tmp84_;
			gint _tmp85_;
			GtkListStore* _tmp86_;
			GtkTreeIter _tmp87_;
			gint _tmp88_;
			GtkListStore* _tmp89_;
			GtkTreeIter _tmp90_ = {0};
			GeeArrayList* _tmp91_;
			gint _tmp92_;
			gpointer _tmp93_;
			GSettings* _tmp94_;
			gint _tmp95_;
			GtkListStore* _tmp96_;
			GtkTreeIter _tmp97_;
			gint _tmp98_;
			GtkListStore* _tmp99_;
			GtkTreeIter _tmp100_ = {0};
			GeeArrayList* _tmp101_;
			gint _tmp102_;
			gpointer _tmp103_;
			GSettings* _tmp104_;
			gint _tmp105_;
			GtkListStore* _tmp106_;
			GtkTreeIter _tmp107_;
			gint _tmp108_;
			GtkListStore* _tmp109_;
			GtkTreeIter _tmp110_ = {0};
			GeeArrayList* _tmp111_;
			gint _tmp112_;
			gpointer _tmp113_;
			GSettings* _tmp114_;
			gint _tmp115_;
			GtkListStore* _tmp116_;
			GtkTreeIter _tmp117_;
			gint _tmp118_;
			GtkCellRendererText* label_renderer;
			GtkCellRendererText* _tmp119_;
			GtkTreeView* _tmp120_;
			GtkCellRendererText* _tmp121_;
			GtkCellRendererAccel* key_renderer;
			GtkCellRendererAccel* _tmp122_;
			GtkCellRendererAccel* _tmp123_;
			GtkCellRendererAccel* _tmp124_;
			GtkCellRendererAccel* _tmp125_;
			GtkCellRendererAccel* _tmp126_;
			GtkTreeView* _tmp127_;
			GtkCellRendererAccel* _tmp128_;
			_tmp66_ = _list_store_index;
			_list_store_index = _tmp66_ + 1;
			_tmp67_ = _list_store_index;
			_tmp68_ = _list_store_size;
			if (!(_tmp67_ < _tmp68_)) {
				break;
			}
			_tmp69_ = _list_store_list;
			_tmp70_ = _list_store_index;
			_tmp71_ = gee_abstract_list_get ((GeeAbstractList*) _tmp69_, _tmp70_);
			list_store = (GtkListStore*) _tmp71_;
			_tmp72_ = self->priv->list_stores;
			_tmp73_ = list_store;
			_tmp74_ = gee_abstract_list_index_of ((GeeAbstractList*) _tmp72_, _tmp73_);
			id = _tmp74_;
			_tmp75_ = self->priv->tree_views;
			_tmp76_ = id;
			_tmp77_ = gee_abstract_list_get ((GeeAbstractList*) _tmp75_, _tmp76_);
			tree_view = (GtkTreeView*) _tmp77_;
			_tmp78_ = list_store;
			gtk_list_store_append (_tmp78_, &_tmp79_);
			iter = _tmp79_;
			_tmp80_ = worm_settings;
			_tmp81_ = id;
			_tmp82_ = gee_abstract_list_get ((GeeAbstractList*) _tmp80_, _tmp81_);
			_tmp83_ = (GSettings*) _tmp82_;
			_tmp84_ = g_settings_get_int (_tmp83_, "key-up");
			_tmp85_ = _tmp84_;
			_g_object_unref0 (_tmp83_);
			keyval = _tmp85_;
			_tmp86_ = list_store;
			_tmp87_ = iter;
			_tmp88_ = keyval;
			gtk_list_store_set (_tmp86_, &_tmp87_, 0, "key-up", 1, _ ("Move up"), 2, _tmp88_, -1);
			_tmp89_ = list_store;
			gtk_list_store_append (_tmp89_, &_tmp90_);
			iter = _tmp90_;
			_tmp91_ = worm_settings;
			_tmp92_ = id;
			_tmp93_ = gee_abstract_list_get ((GeeAbstractList*) _tmp91_, _tmp92_);
			_tmp94_ = (GSettings*) _tmp93_;
			_tmp95_ = g_settings_get_int (_tmp94_, "key-down");
			keyval = _tmp95_;
			_g_object_unref0 (_tmp94_);
			_tmp96_ = list_store;
			_tmp97_ = iter;
			_tmp98_ = keyval;
			gtk_list_store_set (_tmp96_, &_tmp97_, 0, "key-down", 1, _ ("Move down"), 2, _tmp98_, -1);
			_tmp99_ = list_store;
			gtk_list_store_append (_tmp99_, &_tmp100_);
			iter = _tmp100_;
			_tmp101_ = worm_settings;
			_tmp102_ = id;
			_tmp103_ = gee_abstract_list_get ((GeeAbstractList*) _tmp101_, _tmp102_);
			_tmp104_ = (GSettings*) _tmp103_;
			_tmp105_ = g_settings_get_int (_tmp104_, "key-left");
			keyval = _tmp105_;
			_g_object_unref0 (_tmp104_);
			_tmp106_ = list_store;
			_tmp107_ = iter;
			_tmp108_ = keyval;
			gtk_list_store_set (_tmp106_, &_tmp107_, 0, "key-left", 1, _ ("Move left"), 2, _tmp108_, -1);
			_tmp109_ = list_store;
			gtk_list_store_append (_tmp109_, &_tmp110_);
			iter = _tmp110_;
			_tmp111_ = worm_settings;
			_tmp112_ = id;
			_tmp113_ = gee_abstract_list_get ((GeeAbstractList*) _tmp111_, _tmp112_);
			_tmp114_ = (GSettings*) _tmp113_;
			_tmp115_ = g_settings_get_int (_tmp114_, "key-right");
			keyval = _tmp115_;
			_g_object_unref0 (_tmp114_);
			_tmp116_ = list_store;
			_tmp117_ = iter;
			_tmp118_ = keyval;
			gtk_list_store_set (_tmp116_, &_tmp117_, 0, "key-right", 1, _ ("Move right"), 2, _tmp118_, -1);
			_tmp119_ = (GtkCellRendererText*) gtk_cell_renderer_text_new ();
			g_object_ref_sink (_tmp119_);
			label_renderer = _tmp119_;
			_tmp120_ = tree_view;
			_tmp121_ = label_renderer;
			gtk_tree_view_insert_column_with_attributes (_tmp120_, -1, _ ("Action"), (GtkCellRenderer*) _tmp121_, "text", 1, NULL);
			_tmp122_ = (GtkCellRendererAccel*) gtk_cell_renderer_accel_new ();
			g_object_ref_sink (_tmp122_);
			key_renderer = _tmp122_;
			_tmp123_ = key_renderer;
			g_object_set ((GtkCellRendererText*) _tmp123_, "editable", TRUE, NULL);
			_tmp124_ = key_renderer;
			g_object_set (_tmp124_, "accel-mode", GTK_CELL_RENDERER_ACCEL_MODE_OTHER, NULL);
			_tmp125_ = key_renderer;
			g_signal_connect_object (_tmp125_, "accel-edited", (GCallback) _preferences_dialog_accel_edited_cb_gtk_cell_renderer_accel_accel_edited, self, 0);
			_tmp126_ = key_renderer;
			g_signal_connect_object (_tmp126_, "accel-cleared", (GCallback) _preferences_dialog_accel_cleared_cb_gtk_cell_renderer_accel_accel_cleared, self, 0);
			_tmp127_ = tree_view;
			_tmp128_ = key_renderer;
			gtk_tree_view_insert_column_with_attributes (_tmp127_, -1, _ ("Key"), (GtkCellRenderer*) _tmp128_, "accel-key", 2, NULL);
			_g_object_unref0 (key_renderer);
			_g_object_unref0 (label_renderer);
			_g_object_unref0 (tree_view);
			_g_object_unref0 (list_store);
		}
		_g_object_unref0 (_list_store_list);
	}
	_tmp129_ = gee_array_list_new (gtk_combo_box_text_get_type (), (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->combo_boxes);
	self->priv->combo_boxes = _tmp129_;
	_tmp130_ = self->priv->combo_boxes;
	_tmp131_ = self->priv->combo_box_1;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp130_, _tmp131_);
	_tmp132_ = self->priv->combo_boxes;
	_tmp133_ = self->priv->combo_box_2;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp132_, _tmp133_);
	_tmp134_ = self->priv->combo_boxes;
	_tmp135_ = self->priv->combo_box_3;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp134_, _tmp135_);
	_tmp136_ = self->priv->combo_boxes;
	_tmp137_ = self->priv->combo_box_4;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp136_, _tmp137_);
	{
		GeeArrayList* _combo_box_list;
		GeeArrayList* _tmp138_;
		GeeArrayList* _tmp139_;
		gint _combo_box_size;
		GeeArrayList* _tmp140_;
		gint _tmp141_;
		gint _tmp142_;
		gint _combo_box_index;
		_tmp138_ = self->priv->combo_boxes;
		_tmp139_ = _g_object_ref0 (_tmp138_);
		_combo_box_list = _tmp139_;
		_tmp140_ = _combo_box_list;
		_tmp141_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp140_);
		_tmp142_ = _tmp141_;
		_combo_box_size = _tmp142_;
		_combo_box_index = -1;
		while (TRUE) {
			gint _tmp143_;
			gint _tmp144_;
			gint _tmp145_;
			GtkComboBoxText* combo_box;
			GeeArrayList* _tmp146_;
			gint _tmp147_;
			gpointer _tmp148_;
			gint id;
			GeeArrayList* _tmp156_;
			GtkComboBoxText* _tmp157_;
			gint _tmp158_;
			gint color;
			GeeArrayList* _tmp159_;
			gint _tmp160_;
			gpointer _tmp161_;
			GSettings* _tmp162_;
			gint _tmp163_;
			gint _tmp164_;
			GtkComboBoxText* _tmp165_;
			gint _tmp166_;
			GtkComboBoxText* _tmp167_;
			_tmp143_ = _combo_box_index;
			_combo_box_index = _tmp143_ + 1;
			_tmp144_ = _combo_box_index;
			_tmp145_ = _combo_box_size;
			if (!(_tmp144_ < _tmp145_)) {
				break;
			}
			_tmp146_ = _combo_box_list;
			_tmp147_ = _combo_box_index;
			_tmp148_ = gee_abstract_list_get ((GeeAbstractList*) _tmp146_, _tmp147_);
			combo_box = (GtkComboBoxText*) _tmp148_;
			{
				gint i;
				i = 0;
				{
					gboolean _tmp149_;
					_tmp149_ = TRUE;
					while (TRUE) {
						gint _tmp151_;
						GtkComboBoxText* _tmp152_;
						gint _tmp153_;
						gchar* _tmp154_;
						gchar* _tmp155_;
						if (!_tmp149_) {
							gint _tmp150_;
							_tmp150_ = i;
							i = _tmp150_ + 1;
						}
						_tmp149_ = FALSE;
						_tmp151_ = i;
						if (!(_tmp151_ < NIBBLES_VIEW_NUM_COLORS)) {
							break;
						}
						_tmp152_ = combo_box;
						_tmp153_ = i;
						_tmp154_ = nibbles_view_colorval_name (_tmp153_);
						_tmp155_ = _tmp154_;
						gtk_combo_box_text_append_text (_tmp152_, _tmp155_);
						g_free (_tmp155_);
					}
				}
			}
			_tmp156_ = self->priv->combo_boxes;
			_tmp157_ = combo_box;
			_tmp158_ = gee_abstract_list_index_of ((GeeAbstractList*) _tmp156_, _tmp157_);
			id = _tmp158_;
			_tmp159_ = worm_settings;
			_tmp160_ = id;
			_tmp161_ = gee_abstract_list_get ((GeeAbstractList*) _tmp159_, _tmp160_);
			_tmp162_ = (GSettings*) _tmp161_;
			_tmp163_ = g_settings_get_enum (_tmp162_, "color");
			_tmp164_ = _tmp163_;
			_g_object_unref0 (_tmp162_);
			color = _tmp164_;
			_tmp165_ = combo_box;
			_tmp166_ = color;
			gtk_combo_box_set_active ((GtkComboBox*) _tmp165_, _tmp166_);
			_tmp167_ = combo_box;
			g_signal_connect_object ((GtkComboBox*) _tmp167_, "changed", (GCallback) _preferences_dialog_combo_box_changed_cb_gtk_combo_box_changed, self, 0);
			_g_object_unref0 (combo_box);
		}
		_g_object_unref0 (_combo_box_list);
	}
	return self;
}


PreferencesDialog* preferences_dialog_new (GtkApplicationWindow* window, GSettings* settings, GeeArrayList* worm_settings) {
	return preferences_dialog_construct (TYPE_PREFERENCES_DIALOG, window, settings, worm_settings);
}


static void preferences_dialog_radio_button_toggled_cb (PreferencesDialog* self, GtkToggleButton* button) {
	GtkToggleButton* _tmp0_;
	gboolean _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (button != NULL);
	_tmp0_ = button;
	_tmp1_ = gtk_toggle_button_get_active (_tmp0_);
	if (_tmp1_) {
		gint speed;
		GeeArrayList* _tmp2_;
		GtkToggleButton* _tmp3_;
		gint _tmp4_;
		GSettings* _tmp5_;
		gint _tmp6_;
		_tmp2_ = self->priv->radio_buttons;
		_tmp3_ = button;
		_tmp4_ = gee_abstract_list_index_of ((GeeAbstractList*) _tmp2_, G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, gtk_radio_button_get_type (), GtkRadioButton));
		speed = NIBBLES_GAME_MAX_SPEED - _tmp4_;
		_tmp5_ = self->priv->settings;
		_tmp6_ = speed;
		g_settings_set_int (_tmp5_, "speed", _tmp6_);
	}
}


static void preferences_dialog_sound_toggled_cb (PreferencesDialog* self) {
	gboolean play_sound;
	GtkCheckButton* _tmp0_;
	gboolean _tmp1_;
	GSettings* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->sound_check_button;
	_tmp1_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp0_);
	play_sound = _tmp1_;
	_tmp2_ = self->priv->settings;
	g_settings_set_boolean (_tmp2_, "sound", play_sound);
}


static void preferences_dialog_fakes_toggles_cb (PreferencesDialog* self) {
	gboolean has_fakes;
	GtkCheckButton* _tmp0_;
	gboolean _tmp1_;
	GSettings* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->fakes_check_button;
	_tmp1_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp0_);
	has_fakes = _tmp1_;
	_tmp2_ = self->priv->settings;
	g_settings_set_boolean (_tmp2_, "fakes", has_fakes);
}


static void preferences_dialog_accel_edited_cb (PreferencesDialog* self, GtkCellRendererAccel* cell, const gchar* path_string, guint keyval, GdkModifierType mask, guint hardware_keycode) {
	GtkTreePath* path;
	const gchar* _tmp0_;
	GtkTreePath* _tmp1_;
	GtkTreePath* _tmp2_;
	gint id;
	GtkNotebook* _tmp3_;
	gint _tmp4_;
	GtkListStore* list_store;
	GeeArrayList* _tmp5_;
	gint _tmp6_;
	gpointer _tmp7_;
	GtkTreeIter it = {0};
	GtkListStore* _tmp8_;
	GtkTreePath* _tmp9_;
	GtkTreeIter _tmp10_ = {0};
	gboolean _tmp11_;
	gchar* key;
	GtkListStore* _tmp12_;
	GtkTreeIter _tmp13_;
	const gchar* _tmp14_;
	GeeArrayList* _tmp15_;
	gint _tmp16_;
	gpointer _tmp17_;
	GSettings* _tmp18_;
	const gchar* _tmp19_;
	gint _tmp20_;
	guint _tmp21_;
	gboolean _tmp22_;
	gboolean valid;
	gboolean _tmp58_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (cell != NULL);
	g_return_if_fail (path_string != NULL);
	_tmp0_ = path_string;
	_tmp1_ = gtk_tree_path_new_from_string (_tmp0_);
	path = _tmp1_;
	_tmp2_ = path;
	if (_tmp2_ == NULL) {
		_gtk_tree_path_free0 (path);
		return;
	}
	_tmp3_ = self->priv->notebook;
	_tmp4_ = gtk_notebook_get_current_page (_tmp3_);
	id = _tmp4_ - 1;
	_tmp5_ = self->priv->list_stores;
	_tmp6_ = id;
	_tmp7_ = gee_abstract_list_get ((GeeAbstractList*) _tmp5_, _tmp6_);
	list_store = (GtkListStore*) _tmp7_;
	_tmp8_ = list_store;
	_tmp9_ = path;
	_tmp11_ = gtk_tree_model_get_iter ((GtkTreeModel*) _tmp8_, &_tmp10_, _tmp9_);
	it = _tmp10_;
	if (!_tmp11_) {
		_g_object_unref0 (list_store);
		_gtk_tree_path_free0 (path);
		return;
	}
	key = NULL;
	_tmp12_ = list_store;
	_tmp13_ = it;
	gtk_tree_model_get ((GtkTreeModel*) _tmp12_, &_tmp13_, 0, &key, -1);
	_tmp14_ = key;
	if (_tmp14_ == NULL) {
		g_free (key);
		_g_object_unref0 (list_store);
		_gtk_tree_path_free0 (path);
		return;
	}
	_tmp15_ = self->priv->worm_settings;
	_tmp16_ = id;
	_tmp17_ = gee_abstract_list_get ((GeeAbstractList*) _tmp15_, _tmp16_);
	_tmp18_ = (GSettings*) _tmp17_;
	_tmp19_ = key;
	_tmp20_ = g_settings_get_int (_tmp18_, _tmp19_);
	_tmp21_ = keyval;
	_tmp22_ = ((guint) _tmp20_) == _tmp21_;
	_g_object_unref0 (_tmp18_);
	if (_tmp22_) {
		g_free (key);
		_g_object_unref0 (list_store);
		_gtk_tree_path_free0 (path);
		return;
	}
	valid = TRUE;
	{
		gint i;
		i = 0;
		{
			gboolean _tmp23_;
			_tmp23_ = TRUE;
			while (TRUE) {
				gint _tmp25_;
				gboolean _tmp26_ = FALSE;
				gboolean _tmp27_ = FALSE;
				gboolean _tmp28_ = FALSE;
				GeeArrayList* _tmp29_;
				gint _tmp30_;
				gpointer _tmp31_;
				GSettings* _tmp32_;
				gint _tmp33_;
				guint _tmp34_;
				gboolean _tmp35_;
				if (!_tmp23_) {
					gint _tmp24_;
					_tmp24_ = i;
					i = _tmp24_ + 1;
				}
				_tmp23_ = FALSE;
				_tmp25_ = i;
				if (!(_tmp25_ < NIBBLES_GAME_MAX_HUMANS)) {
					break;
				}
				_tmp29_ = self->priv->worm_settings;
				_tmp30_ = i;
				_tmp31_ = gee_abstract_list_get ((GeeAbstractList*) _tmp29_, _tmp30_);
				_tmp32_ = (GSettings*) _tmp31_;
				_tmp33_ = g_settings_get_int (_tmp32_, "key-up");
				_tmp34_ = keyval;
				_tmp35_ = ((guint) _tmp33_) == _tmp34_;
				_g_object_unref0 (_tmp32_);
				if (_tmp35_) {
					_tmp28_ = TRUE;
				} else {
					GeeArrayList* _tmp36_;
					gint _tmp37_;
					gpointer _tmp38_;
					GSettings* _tmp39_;
					gint _tmp40_;
					guint _tmp41_;
					_tmp36_ = self->priv->worm_settings;
					_tmp37_ = i;
					_tmp38_ = gee_abstract_list_get ((GeeAbstractList*) _tmp36_, _tmp37_);
					_tmp39_ = (GSettings*) _tmp38_;
					_tmp40_ = g_settings_get_int (_tmp39_, "key-down");
					_tmp41_ = keyval;
					_tmp28_ = ((guint) _tmp40_) == _tmp41_;
					_g_object_unref0 (_tmp39_);
				}
				if (_tmp28_) {
					_tmp27_ = TRUE;
				} else {
					GeeArrayList* _tmp42_;
					gint _tmp43_;
					gpointer _tmp44_;
					GSettings* _tmp45_;
					gint _tmp46_;
					guint _tmp47_;
					_tmp42_ = self->priv->worm_settings;
					_tmp43_ = i;
					_tmp44_ = gee_abstract_list_get ((GeeAbstractList*) _tmp42_, _tmp43_);
					_tmp45_ = (GSettings*) _tmp44_;
					_tmp46_ = g_settings_get_int (_tmp45_, "key-left");
					_tmp47_ = keyval;
					_tmp27_ = ((guint) _tmp46_) == _tmp47_;
					_g_object_unref0 (_tmp45_);
				}
				if (_tmp27_) {
					_tmp26_ = TRUE;
				} else {
					GeeArrayList* _tmp48_;
					gint _tmp49_;
					gpointer _tmp50_;
					GSettings* _tmp51_;
					gint _tmp52_;
					guint _tmp53_;
					_tmp48_ = self->priv->worm_settings;
					_tmp49_ = i;
					_tmp50_ = gee_abstract_list_get ((GeeAbstractList*) _tmp48_, _tmp49_);
					_tmp51_ = (GSettings*) _tmp50_;
					_tmp52_ = g_settings_get_int (_tmp51_, "key-right");
					_tmp53_ = keyval;
					_tmp26_ = ((guint) _tmp52_) == _tmp53_;
					_g_object_unref0 (_tmp51_);
				}
				if (_tmp26_) {
					GtkMessageDialog* dialog;
					GtkApplicationWindow* _tmp54_;
					GtkMessageDialog* _tmp55_;
					GtkMessageDialog* _tmp56_;
					GtkMessageDialog* _tmp57_;
					valid = FALSE;
					_tmp54_ = self->priv->window;
					_tmp55_ = (GtkMessageDialog*) gtk_message_dialog_new ((GtkWindow*) _tmp54_, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, "%s", _ ("The key you selected is already assigned!"));
					g_object_ref_sink (_tmp55_);
					dialog = _tmp55_;
					_tmp56_ = dialog;
					gtk_dialog_run ((GtkDialog*) _tmp56_);
					_tmp57_ = dialog;
					gtk_widget_destroy ((GtkWidget*) _tmp57_);
					_g_object_unref0 (dialog);
					break;
				}
			}
		}
	}
	_tmp58_ = valid;
	if (_tmp58_) {
		GtkListStore* _tmp59_;
		GtkTreeIter _tmp60_;
		guint _tmp61_;
		GeeArrayList* _tmp62_;
		gint _tmp63_;
		gpointer _tmp64_;
		GSettings* _tmp65_;
		const gchar* _tmp66_;
		guint _tmp67_;
		_tmp59_ = list_store;
		_tmp60_ = it;
		_tmp61_ = keyval;
		gtk_list_store_set (_tmp59_, &_tmp60_, 2, _tmp61_, -1);
		_tmp62_ = self->priv->worm_settings;
		_tmp63_ = id;
		_tmp64_ = gee_abstract_list_get ((GeeAbstractList*) _tmp62_, _tmp63_);
		_tmp65_ = (GSettings*) _tmp64_;
		_tmp66_ = key;
		_tmp67_ = keyval;
		g_settings_set_int (_tmp65_, _tmp66_, (gint) _tmp67_);
		_g_object_unref0 (_tmp65_);
	}
	g_free (key);
	_g_object_unref0 (list_store);
	_gtk_tree_path_free0 (path);
}


static void preferences_dialog_accel_cleared_cb (PreferencesDialog* self, GtkCellRendererAccel* cell, const gchar* path_string) {
	GtkTreePath* path;
	const gchar* _tmp0_;
	GtkTreePath* _tmp1_;
	GtkTreePath* _tmp2_;
	gint id;
	GtkNotebook* _tmp3_;
	gint _tmp4_;
	GtkListStore* list_store;
	GeeArrayList* _tmp5_;
	gint _tmp6_;
	gpointer _tmp7_;
	GtkTreeIter it = {0};
	GtkListStore* _tmp8_;
	GtkTreePath* _tmp9_;
	GtkTreeIter _tmp10_ = {0};
	gboolean _tmp11_;
	gchar* key;
	GtkListStore* _tmp12_;
	GtkTreeIter _tmp13_;
	const gchar* _tmp14_;
	GtkListStore* _tmp15_;
	GtkTreeIter _tmp16_;
	GeeArrayList* _tmp17_;
	gint _tmp18_;
	gpointer _tmp19_;
	GSettings* _tmp20_;
	const gchar* _tmp21_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (cell != NULL);
	g_return_if_fail (path_string != NULL);
	_tmp0_ = path_string;
	_tmp1_ = gtk_tree_path_new_from_string (_tmp0_);
	path = _tmp1_;
	_tmp2_ = path;
	if (_tmp2_ == NULL) {
		_gtk_tree_path_free0 (path);
		return;
	}
	_tmp3_ = self->priv->notebook;
	_tmp4_ = gtk_notebook_get_current_page (_tmp3_);
	id = _tmp4_ - 1;
	_tmp5_ = self->priv->list_stores;
	_tmp6_ = id;
	_tmp7_ = gee_abstract_list_get ((GeeAbstractList*) _tmp5_, _tmp6_);
	list_store = (GtkListStore*) _tmp7_;
	_tmp8_ = list_store;
	_tmp9_ = path;
	_tmp11_ = gtk_tree_model_get_iter ((GtkTreeModel*) _tmp8_, &_tmp10_, _tmp9_);
	it = _tmp10_;
	if (!_tmp11_) {
		_g_object_unref0 (list_store);
		_gtk_tree_path_free0 (path);
		return;
	}
	key = NULL;
	_tmp12_ = list_store;
	_tmp13_ = it;
	gtk_tree_model_get ((GtkTreeModel*) _tmp12_, &_tmp13_, 0, &key, -1);
	_tmp14_ = key;
	if (_tmp14_ == NULL) {
		g_free (key);
		_g_object_unref0 (list_store);
		_gtk_tree_path_free0 (path);
		return;
	}
	_tmp15_ = list_store;
	_tmp16_ = it;
	gtk_list_store_set (_tmp15_, &_tmp16_, 2, 0, -1);
	_tmp17_ = self->priv->worm_settings;
	_tmp18_ = id;
	_tmp19_ = gee_abstract_list_get ((GeeAbstractList*) _tmp17_, _tmp18_);
	_tmp20_ = (GSettings*) _tmp19_;
	_tmp21_ = key;
	g_settings_set_int (_tmp20_, _tmp21_, 0);
	_g_object_unref0 (_tmp20_);
	g_free (key);
	_g_object_unref0 (list_store);
	_gtk_tree_path_free0 (path);
}


static void preferences_dialog_combo_box_changed_cb (PreferencesDialog* self, GtkComboBox* combo_box) {
	gint id;
	GeeArrayList* _tmp0_;
	GtkComboBox* _tmp1_;
	gint _tmp2_;
	gint color_new;
	GtkComboBox* _tmp3_;
	gint _tmp4_;
	gint color_old;
	GeeArrayList* _tmp5_;
	gint _tmp6_;
	gpointer _tmp7_;
	GSettings* _tmp8_;
	gint _tmp9_;
	gint _tmp10_;
	gint _tmp11_;
	gint _tmp12_;
	GeeArrayList* _tmp49_;
	gint _tmp50_;
	gpointer _tmp51_;
	GSettings* _tmp52_;
	gint _tmp53_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (combo_box != NULL);
	_tmp0_ = self->priv->combo_boxes;
	_tmp1_ = combo_box;
	_tmp2_ = gee_abstract_list_index_of ((GeeAbstractList*) _tmp0_, G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_combo_box_text_get_type (), GtkComboBoxText));
	id = _tmp2_;
	_tmp3_ = combo_box;
	_tmp4_ = gtk_combo_box_get_active (_tmp3_);
	color_new = _tmp4_;
	_tmp5_ = self->priv->worm_settings;
	_tmp6_ = id;
	_tmp7_ = gee_abstract_list_get ((GeeAbstractList*) _tmp5_, _tmp6_);
	_tmp8_ = (GSettings*) _tmp7_;
	_tmp9_ = g_settings_get_enum (_tmp8_, "color");
	_tmp10_ = _tmp9_;
	_g_object_unref0 (_tmp8_);
	color_old = _tmp10_;
	_tmp11_ = color_new;
	_tmp12_ = color_old;
	if (_tmp11_ == _tmp12_) {
		return;
	}
	{
		gint i;
		i = 0;
		{
			gboolean _tmp13_;
			_tmp13_ = TRUE;
			while (TRUE) {
				gint _tmp15_;
				gboolean _tmp16_ = FALSE;
				gint _tmp17_;
				gint _tmp18_;
				if (!_tmp13_) {
					gint _tmp14_;
					_tmp14_ = i;
					i = _tmp14_ + 1;
				}
				_tmp13_ = FALSE;
				_tmp15_ = i;
				if (!(_tmp15_ < NIBBLES_GAME_MAX_WORMS)) {
					break;
				}
				_tmp17_ = i;
				_tmp18_ = id;
				if (_tmp17_ != _tmp18_) {
					GeeArrayList* _tmp19_;
					gint _tmp20_;
					gpointer _tmp21_;
					GSettings* _tmp22_;
					gint _tmp23_;
					gint _tmp24_;
					_tmp19_ = self->priv->worm_settings;
					_tmp20_ = i;
					_tmp21_ = gee_abstract_list_get ((GeeAbstractList*) _tmp19_, _tmp20_);
					_tmp22_ = (GSettings*) _tmp21_;
					_tmp23_ = g_settings_get_enum (_tmp22_, "color");
					_tmp24_ = color_new;
					_tmp16_ = _tmp23_ == _tmp24_;
					_g_object_unref0 (_tmp22_);
				} else {
					_tmp16_ = FALSE;
				}
				if (_tmp16_) {
					GeeArrayList* _tmp25_;
					gint _tmp26_;
					gpointer _tmp27_;
					GSettings* _tmp28_;
					gint _tmp29_;
					gint _tmp30_;
					_tmp25_ = self->priv->worm_settings;
					_tmp26_ = i;
					_tmp27_ = gee_abstract_list_get ((GeeAbstractList*) _tmp25_, _tmp26_);
					_tmp28_ = (GSettings*) _tmp27_;
					_tmp29_ = color_old;
					g_settings_set_enum (_tmp28_, "color", _tmp29_);
					_g_object_unref0 (_tmp28_);
					_tmp30_ = i;
					if (_tmp30_ < NIBBLES_GAME_MAX_HUMANS) {
						{
							GeeArrayList* _cbox_list;
							GeeArrayList* _tmp31_;
							GeeArrayList* _tmp32_;
							gint _cbox_size;
							GeeArrayList* _tmp33_;
							gint _tmp34_;
							gint _tmp35_;
							gint _cbox_index;
							_tmp31_ = self->priv->combo_boxes;
							_tmp32_ = _g_object_ref0 (_tmp31_);
							_cbox_list = _tmp32_;
							_tmp33_ = _cbox_list;
							_tmp34_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp33_);
							_tmp35_ = _tmp34_;
							_cbox_size = _tmp35_;
							_cbox_index = -1;
							while (TRUE) {
								gint _tmp36_;
								gint _tmp37_;
								gint _tmp38_;
								GtkComboBoxText* cbox;
								GeeArrayList* _tmp39_;
								gint _tmp40_;
								gpointer _tmp41_;
								gint index;
								GeeArrayList* _tmp42_;
								GtkComboBoxText* _tmp43_;
								gint _tmp44_;
								gint _tmp45_;
								gint _tmp46_;
								_tmp36_ = _cbox_index;
								_cbox_index = _tmp36_ + 1;
								_tmp37_ = _cbox_index;
								_tmp38_ = _cbox_size;
								if (!(_tmp37_ < _tmp38_)) {
									break;
								}
								_tmp39_ = _cbox_list;
								_tmp40_ = _cbox_index;
								_tmp41_ = gee_abstract_list_get ((GeeAbstractList*) _tmp39_, _tmp40_);
								cbox = (GtkComboBoxText*) _tmp41_;
								_tmp42_ = self->priv->combo_boxes;
								_tmp43_ = cbox;
								_tmp44_ = gee_abstract_list_index_of ((GeeAbstractList*) _tmp42_, _tmp43_);
								index = _tmp44_;
								_tmp45_ = index;
								_tmp46_ = i;
								if (_tmp45_ == _tmp46_) {
									GtkComboBoxText* _tmp47_;
									gint _tmp48_;
									_tmp47_ = cbox;
									_tmp48_ = color_old;
									gtk_combo_box_set_active ((GtkComboBox*) _tmp47_, _tmp48_);
									_g_object_unref0 (cbox);
									break;
								}
								_g_object_unref0 (cbox);
							}
							_g_object_unref0 (_cbox_list);
						}
					}
					break;
				}
			}
		}
	}
	_tmp49_ = self->priv->worm_settings;
	_tmp50_ = id;
	_tmp51_ = gee_abstract_list_get ((GeeAbstractList*) _tmp49_, _tmp50_);
	_tmp52_ = (GSettings*) _tmp51_;
	_tmp53_ = color_new;
	g_settings_set_enum (_tmp52_, "color", _tmp53_);
	_g_object_unref0 (_tmp52_);
}


static void preferences_dialog_class_init (PreferencesDialogClass * klass) {
	gint PreferencesDialog_private_offset;
	preferences_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (PreferencesDialogPrivate));
	G_OBJECT_CLASS (klass)->finalize = preferences_dialog_finalize;
	PreferencesDialog_private_offset = g_type_class_get_instance_private_offset (klass);
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/nibbles/ui/preferences-dialog.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "notebook", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, notebook));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "beginner_radio_button", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, beginner_radio_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "slow_radio_button", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, slow_radio_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "medium_radio_button", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, medium_radio_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "fast_radio_button", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, fast_radio_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "sound_check_button", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, sound_check_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "fakes_check_button", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, fakes_check_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "list_store_1", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, list_store_1));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "list_store_2", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, list_store_2));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "list_store_3", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, list_store_3));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "list_store_4", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, list_store_4));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "tree_view_1", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, tree_view_1));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "tree_view_2", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, tree_view_2));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "tree_view_3", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, tree_view_3));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "tree_view_4", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, tree_view_4));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "combo_box_1", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, combo_box_1));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "combo_box_2", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, combo_box_2));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "combo_box_3", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, combo_box_3));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "combo_box_4", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, combo_box_4));
}


static void preferences_dialog_instance_init (PreferencesDialog * self) {
	self->priv = PREFERENCES_DIALOG_GET_PRIVATE (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}


static void preferences_dialog_finalize (GObject * obj) {
	PreferencesDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_PREFERENCES_DIALOG, PreferencesDialog);
	_g_object_unref0 (self->priv->window);
	_g_object_unref0 (self->priv->settings);
	_g_object_unref0 (self->priv->worm_settings);
	_g_object_unref0 (self->priv->notebook);
	_g_object_unref0 (self->priv->beginner_radio_button);
	_g_object_unref0 (self->priv->slow_radio_button);
	_g_object_unref0 (self->priv->medium_radio_button);
	_g_object_unref0 (self->priv->fast_radio_button);
	_g_object_unref0 (self->priv->sound_check_button);
	_g_object_unref0 (self->priv->fakes_check_button);
	_g_object_unref0 (self->priv->list_store_1);
	_g_object_unref0 (self->priv->list_store_2);
	_g_object_unref0 (self->priv->list_store_3);
	_g_object_unref0 (self->priv->list_store_4);
	_g_object_unref0 (self->priv->tree_view_1);
	_g_object_unref0 (self->priv->tree_view_2);
	_g_object_unref0 (self->priv->tree_view_3);
	_g_object_unref0 (self->priv->tree_view_4);
	_g_object_unref0 (self->priv->combo_box_1);
	_g_object_unref0 (self->priv->combo_box_2);
	_g_object_unref0 (self->priv->combo_box_3);
	_g_object_unref0 (self->priv->combo_box_4);
	_g_object_unref0 (self->priv->radio_buttons);
	_g_object_unref0 (self->priv->list_stores);
	_g_object_unref0 (self->priv->tree_views);
	_g_object_unref0 (self->priv->combo_boxes);
	G_OBJECT_CLASS (preferences_dialog_parent_class)->finalize (obj);
}


GType preferences_dialog_get_type (void) {
	static volatile gsize preferences_dialog_type_id__volatile = 0;
	if (g_once_init_enter (&preferences_dialog_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (PreferencesDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) preferences_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PreferencesDialog), 0, (GInstanceInitFunc) preferences_dialog_instance_init, NULL };
		GType preferences_dialog_type_id;
		preferences_dialog_type_id = g_type_register_static (gtk_dialog_get_type (), "PreferencesDialog", &g_define_type_info, 0);
		g_once_init_leave (&preferences_dialog_type_id__volatile, preferences_dialog_type_id);
	}
	return preferences_dialog_type_id__volatile;
}



