/* test-ui-color-button-gtkbuilder.c generated by valac 0.10.4, the Vala compiler
 * generated from test-ui-color-button-gtkbuilder.vala, do not modify */

/*
 * Tests the GtkColorButton wrapper class with GtkBuilder.
 *
 * Copyright (C) 2009 Mark Lee <libdesktop-agnostic@lazymalevolence.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 2 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, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA.
 *
 * Author : Mark Lee <libdesktop-agnostic@lazymalevolence.com>
 */

#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <libdesktop-agnostic/ui.h>
#include <libdesktop-agnostic/desktop-agnostic.h>
#include <stdlib.h>
#include <string.h>

#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))



gboolean on_quit (GtkWidget* widget, GdkEvent* event);
void on_color_set (GtkColorButton* button);
gint _vala_main (char** args, int args_length1);
static gboolean _on_quit_gtk_widget_delete_event (GtkWidget* _sender, GdkEvent* event, gpointer self);
static void _on_color_set_gtk_color_button_color_set (GtkColorButton* _sender, gpointer self);



gboolean on_quit (GtkWidget* widget, GdkEvent* event) {
	gboolean result = FALSE;
	g_return_val_if_fail (widget != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	gtk_main_quit ();
	result = TRUE;
	return result;
}


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


void on_color_set (GtkColorButton* button) {
	GtkColorButton* _tmp0_;
	DesktopAgnosticUIColorButton* real_button;
	char* _tmp1_;
	g_return_if_fail (button != NULL);
	real_button = _g_object_ref0 ((_tmp0_ = button, DESKTOP_AGNOSTIC_UI_IS_COLOR_BUTTON (_tmp0_) ? ((DesktopAgnosticUIColorButton*) _tmp0_) : NULL));
	g_message ("test-ui-color-button-gtkbuilder.vala:36: Selected color: %s", _tmp1_ = desktop_agnostic_color_to_string (desktop_agnostic_ui_color_button_get_da_color (real_button)));
	_g_free0 (_tmp1_);
	gtk_main_quit ();
	_g_object_unref0 (real_button);
}


static gboolean _on_quit_gtk_widget_delete_event (GtkWidget* _sender, GdkEvent* event, gpointer self) {
	gboolean result;
	result = on_quit (_sender, event);
	return result;
}


static void _on_color_set_gtk_color_button_color_set (GtkColorButton* _sender, gpointer self) {
	on_color_set (_sender);
}


gint _vala_main (char** args, int args_length1) {
	gint result = 0;
	GtkBuilder* builder;
	GtkWindow* window;
	DesktopAgnosticUIColorButton* button;
	GtkBuilder* _tmp0_;
	GError * _inner_error_ = NULL;
	builder = NULL;
	window = NULL;
	button = NULL;
	gtk_init (&args_length1, &args);
	builder = (_tmp0_ = gtk_builder_new (), _g_object_unref0 (builder), _tmp0_);
	{
		GObject* _tmp1_;
		GtkWidget* _tmp2_;
		gtk_builder_add_from_file (builder, "test-ui-color-button-gtkbuilder.ui", &_inner_error_);
		if (_inner_error_ != NULL) {
			goto __catch0_g_error;
		}
		window = (_tmp1_ = gtk_builder_get_object (builder, "window1"), GTK_IS_WINDOW (_tmp1_) ? ((GtkWindow*) _tmp1_) : NULL);
		g_signal_connect ((GtkWidget*) window, "delete-event", (GCallback) _on_quit_gtk_widget_delete_event, NULL);
		button = (_tmp2_ = gtk_bin_get_child ((GtkBin*) window), DESKTOP_AGNOSTIC_UI_IS_COLOR_BUTTON (_tmp2_) ? ((DesktopAgnosticUIColorButton*) _tmp2_) : NULL);
		g_signal_connect ((GtkColorButton*) button, "color-set", (GCallback) _on_color_set_gtk_color_button_color_set, NULL);
		gtk_widget_show_all ((GtkWidget*) window);
		gtk_main ();
		result = 0;
		_g_object_unref0 (builder);
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError * err;
		err = _inner_error_;
		_inner_error_ = NULL;
		{
			g_critical ("test-ui-color-button-gtkbuilder.vala:61: Error: %s", err->message);
			result = 1;
			_g_error_free0 (err);
			_g_object_unref0 (builder);
			return result;
		}
	}
	__finally0:
	{
		_g_object_unref0 (builder);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return 0;
	}
	_g_object_unref0 (builder);
}


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




