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


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

#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block1Data Block1Data;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _Block1Data {
	int _ref_count_;
	gchar* select_button_text;
};



void clicked_info_area_button (const gchar* bar, gint x, gint y, gint z);
gint _vala_main (gchar** args, int args_length1);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (Block1Data* _data1_);
static void _lambda0_ (Block1Data* _data1_);
static void __lambda0__gtk_button_clicked (GtkButton* _sender, gpointer self);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);


static const gchar* string_to_string (const gchar* self) {
	const gchar* result = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}


void clicked_info_area_button (const gchar* bar, gint x, gint y, gint z) {
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_;
	g_return_if_fail (bar != NULL);
	_tmp0_ = string_to_string (bar);
	_tmp1_ = g_strconcat ("bar: ", _tmp0_, "\n", NULL);
	_tmp2_ = _tmp1_;
	g_print ("%s", _tmp2_);
	_g_free0 (_tmp2_);
}


static Block1Data* block1_data_ref (Block1Data* _data1_) {
	g_atomic_int_inc (&_data1_->_ref_count_);
	return _data1_;
}


static void block1_data_unref (Block1Data* _data1_) {
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		_g_free0 (_data1_->select_button_text);
		g_slice_free (Block1Data, _data1_);
	}
}


static void _lambda0_ (Block1Data* _data1_) {
	clicked_info_area_button (_data1_->select_button_text, 1, 2, 3);
}


static void __lambda0__gtk_button_clicked (GtkButton* _sender, gpointer self) {
	_lambda0_ (self);
}


gint _vala_main (gchar** args, int args_length1) {
	gint result = 0;
	gchar* _tmp0_;
	gchar** _tmp1_ = NULL;
	gint button_strings_length1;
	gint _button_strings_size_;
	gchar** _tmp2_;
	gchar** button_strings;
	_tmp0_ = g_strdup ("and the cow says muh");
	_tmp1_ = g_new0 (gchar*, 1 + 1);
	_tmp1_[0] = _tmp0_;
	_tmp2_ = _tmp1_;
	button_strings_length1 = 1;
	_button_strings_size_ = button_strings_length1;
	button_strings = _tmp2_;
	{
		gchar** select_button_text_collection;
		int select_button_text_collection_length1;
		int select_button_text_it;
		select_button_text_collection = button_strings;
		select_button_text_collection_length1 = button_strings_length1;
		for (select_button_text_it = 0; select_button_text_it < button_strings_length1; select_button_text_it = select_button_text_it + 1) {
			gchar* _tmp3_;
			gchar* select_button_text;
			_tmp3_ = g_strdup (select_button_text_collection[select_button_text_it]);
			select_button_text = _tmp3_;
			{
				Block1Data* _data1_;
				const gchar* _tmp4_ = NULL;
				gchar* _tmp5_ = NULL;
				gchar* _tmp6_;
				GtkButton* _tmp7_ = NULL;
				GtkButton* button;
				_data1_ = g_slice_new0 (Block1Data);
				_data1_->_ref_count_ = 1;
				_tmp4_ = string_to_string (_data1_->select_button_text);
				_tmp5_ = g_strconcat ("foreach: ", _tmp4_, "\n", NULL);
				_tmp6_ = _tmp5_;
				g_print ("%s", _tmp6_);
				_g_free0 (_tmp6_);
				_tmp7_ = (GtkButton*) gtk_button_new ();
				button = g_object_ref_sink (_tmp7_);
				gtk_button_set_label (button, _data1_->select_button_text);
				g_signal_connect_data (button, "clicked", (GCallback) __lambda0__gtk_button_clicked, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0);
				_g_object_unref0 (button);
				block1_data_unref (_data1_);
			}
		}
	}
	button_strings = (_vala_array_free (button_strings, button_strings_length1, (GDestroyNotify) g_free), NULL);
}


int main (int argc, char ** argv) {
	g_type_init ();
	return _vala_main (argv, argc);
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}


static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}



