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

/*
* Copyright (c) 2018 Felipe Escoto (https://github.com/Philip-Scott/Spice-up)
*
* 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., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authored by: Felipe Escoto <felescoto95@hotmail.com>
*/

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

#define SPICE_COLOR_BUTTON_STYLE_CSS "\n" \
"        .color-button.flat {\n" \
"            border: none;\n" \
"            padding: 0;\n" \
"        }\n" \
"    "
#define SPICE_COLOR_BUTTON_CHECKERED_CSS "\n" \
"        .checkered {\n" \
"            background-image: url('resource:///com/github/philip-scott" \
"/spice-up/patterns/ps-neutral.png');\n" \
"        }\n" \
"    "
#define SPICE_COLOR_BUTTON_SURFACE_STYLE_CSS "\n" \
"        .colored {\n" \
"            background: %s;\n" \
"        }\n" \
"\n" \
"        .color-button:active .colored {\n" \
"            opacity: 0.9;\n" \
"        }\n" \
"\n" \
"        .color-button:focus .colored {\n" \
"            border: 1px solid black;\n" \
"        }\n" \
"    "
#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define SPICE_TYPE_COLOR_BUTTON (spice_color_button_get_type ())
#define SPICE_COLOR_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPICE_TYPE_COLOR_BUTTON, SpiceColorButton))
#define SPICE_COLOR_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SPICE_TYPE_COLOR_BUTTON, SpiceColorButtonClass))
#define SPICE_IS_COLOR_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SPICE_TYPE_COLOR_BUTTON))
#define SPICE_IS_COLOR_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SPICE_TYPE_COLOR_BUTTON))
#define SPICE_COLOR_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SPICE_TYPE_COLOR_BUTTON, SpiceColorButtonClass))

typedef struct _SpiceColorButton SpiceColorButton;
typedef struct _SpiceColorButtonClass SpiceColorButtonClass;
typedef struct _SpiceColorButtonPrivate SpiceColorButtonPrivate;
enum  {
	SPICE_COLOR_BUTTON_0_PROPERTY,
	SPICE_COLOR_BUTTON_COLOR_PROPERTY,
	SPICE_COLOR_BUTTON_NUM_PROPERTIES
};
static GParamSpec* spice_color_button_properties[SPICE_COLOR_BUTTON_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _SpiceColorButton {
	GtkButton parent_instance;
	SpiceColorButtonPrivate * priv;
	GtkEventBox* surface;
	GtkEventBox* checkered_bg;
	gchar* _color;
};

struct _SpiceColorButtonClass {
	GtkButtonClass parent_class;
};

static gpointer spice_color_button_parent_class = NULL;

VALA_EXTERN GType spice_color_button_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SpiceColorButton, g_object_unref)
VALA_EXTERN SpiceColorButton* spice_color_button_new (const gchar* color);
VALA_EXTERN SpiceColorButton* spice_color_button_construct (GType object_type,
                                                const gchar* color);
VALA_EXTERN void spice_color_button_set_size (SpiceColorButton* self,
                                  gint x,
                                  gint y);
VALA_EXTERN void spice_color_button_style (SpiceColorButton* self);
VALA_EXTERN void spice_utils_set_style (GtkWidget* widget,
                            const gchar* css);
VALA_EXTERN const gchar* spice_color_button_get_color (SpiceColorButton* self);
VALA_EXTERN void spice_color_button_set_color (SpiceColorButton* self,
                                   const gchar* value);
static GObject * spice_color_button_constructor (GType type,
                                          guint n_construct_properties,
                                          GObjectConstructParam * construct_properties);
static void spice_color_button_finalize (GObject * obj);
static GType spice_color_button_get_type_once (void);
static void _vala_spice_color_button_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec);
static void _vala_spice_color_button_set_property (GObject * object,
                                            guint property_id,
                                            const GValue * value,
                                            GParamSpec * pspec);

SpiceColorButton*
spice_color_button_construct (GType object_type,
                              const gchar* color)
{
	SpiceColorButton * self = NULL;
#line 38 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	g_return_val_if_fail (color != NULL, NULL);
#line 39 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	self = (SpiceColorButton*) g_object_new (object_type, "color", color, NULL);
#line 38 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	return self;
#line 125 "ColorButton.c"
}

SpiceColorButton*
spice_color_button_new (const gchar* color)
{
#line 38 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	return spice_color_button_construct (SPICE_TYPE_COLOR_BUTTON, color);
#line 133 "ColorButton.c"
}

void
spice_color_button_set_size (SpiceColorButton* self,
                             gint x,
                             gint y)
{
	GtkEventBox* _tmp0_;
#line 58 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	g_return_if_fail (self != NULL);
#line 59 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	_tmp0_ = self->surface;
#line 59 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	gtk_widget_set_size_request ((GtkWidget*) _tmp0_, x, y);
#line 148 "ColorButton.c"
}

void
spice_color_button_style (SpiceColorButton* self)
{
	GtkEventBox* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
#line 62 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	g_return_if_fail (self != NULL);
#line 63 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	_tmp0_ = self->surface;
#line 63 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	_tmp1_ = self->_color;
#line 63 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	_tmp2_ = g_strdup_printf (SPICE_COLOR_BUTTON_SURFACE_STYLE_CSS, _tmp1_);
#line 63 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	_tmp3_ = _tmp2_;
#line 63 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	spice_utils_set_style ((GtkWidget*) _tmp0_, _tmp3_);
#line 63 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	_g_free0 (_tmp3_);
#line 172 "ColorButton.c"
}

const gchar*
spice_color_button_get_color (SpiceColorButton* self)
{
	const gchar* result;
	const gchar* _tmp0_;
#line 28 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	g_return_val_if_fail (self != NULL, NULL);
#line 29 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	_tmp0_ = self->_color;
#line 29 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	result = _tmp0_;
#line 29 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	return result;
#line 188 "ColorButton.c"
}

void
spice_color_button_set_color (SpiceColorButton* self,
                              const gchar* value)
{
#line 30 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	g_return_if_fail (self != NULL);
#line 31 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	if (g_strcmp0 (value, "") != 0) {
#line 199 "ColorButton.c"
		gchar* _tmp0_;
#line 32 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
		_tmp0_ = g_strdup (value);
#line 32 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
		_g_free0 (self->_color);
#line 32 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
		self->_color = _tmp0_;
#line 33 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
		spice_color_button_style (self);
#line 209 "ColorButton.c"
	}
#line 30 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	g_object_notify_by_pspec ((GObject *) self, spice_color_button_properties[SPICE_COLOR_BUTTON_COLOR_PROPERTY]);
#line 213 "ColorButton.c"
}

static GObject *
spice_color_button_constructor (GType type,
                                guint n_construct_properties,
                                GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	SpiceColorButton * self;
	GtkEventBox* _tmp0_;
	GtkEventBox* _tmp1_;
	GtkEventBox* _tmp2_;
	GtkStyleContext* _tmp3_;
	GtkStyleContext* _tmp4_;
	GtkEventBox* _tmp5_;
	GtkEventBox* _tmp6_;
	GtkStyleContext* _tmp7_;
	GtkEventBox* _tmp8_;
	GtkEventBox* _tmp9_;
	GtkEventBox* _tmp10_;
	GtkEventBox* _tmp11_;
#line 42 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	parent_class = G_OBJECT_CLASS (spice_color_button_parent_class);
#line 42 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
#line 42 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SPICE_TYPE_COLOR_BUTTON, SpiceColorButton);
#line 43 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	_tmp0_ = (GtkEventBox*) gtk_event_box_new ();
#line 43 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	g_object_ref_sink (_tmp0_);
#line 43 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	_g_object_unref0 (self->surface);
#line 43 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	self->surface = _tmp0_;
#line 44 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	_tmp1_ = self->surface;
#line 44 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	gtk_widget_set_size_request ((GtkWidget*) _tmp1_, 24, 24);
#line 45 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	_tmp2_ = self->surface;
#line 45 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	_tmp3_ = gtk_widget_get_style_context ((GtkWidget*) _tmp2_);
#line 45 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	gtk_style_context_add_class (_tmp3_, "colored");
#line 46 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	_tmp4_ = gtk_widget_get_style_context ((GtkWidget*) self);
#line 46 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	gtk_style_context_add_class (_tmp4_, "color-button");
#line 47 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	spice_utils_set_style ((GtkWidget*) self, SPICE_COLOR_BUTTON_STYLE_CSS);
#line 49 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	_tmp5_ = (GtkEventBox*) gtk_event_box_new ();
#line 49 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	g_object_ref_sink (_tmp5_);
#line 49 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	_g_object_unref0 (self->checkered_bg);
#line 49 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	self->checkered_bg = _tmp5_;
#line 50 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	_tmp6_ = self->checkered_bg;
#line 50 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	_tmp7_ = gtk_widget_get_style_context ((GtkWidget*) _tmp6_);
#line 50 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	gtk_style_context_add_class (_tmp7_, "checkered");
#line 51 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	_tmp8_ = self->checkered_bg;
#line 51 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	spice_utils_set_style ((GtkWidget*) _tmp8_, SPICE_COLOR_BUTTON_CHECKERED_CSS);
#line 53 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	gtk_widget_set_can_focus ((GtkWidget*) self, FALSE);
#line 54 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	_tmp9_ = self->checkered_bg;
#line 54 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp9_);
#line 55 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	_tmp10_ = self->checkered_bg;
#line 55 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	_tmp11_ = self->surface;
#line 55 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	gtk_container_add ((GtkContainer*) _tmp10_, (GtkWidget*) _tmp11_);
#line 42 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	return obj;
#line 298 "ColorButton.c"
}

static void
spice_color_button_class_init (SpiceColorButtonClass * klass,
                               gpointer klass_data)
{
#line 22 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	spice_color_button_parent_class = g_type_class_peek_parent (klass);
#line 22 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	G_OBJECT_CLASS (klass)->get_property = _vala_spice_color_button_get_property;
#line 22 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	G_OBJECT_CLASS (klass)->set_property = _vala_spice_color_button_set_property;
#line 22 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	G_OBJECT_CLASS (klass)->constructor = spice_color_button_constructor;
#line 22 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	G_OBJECT_CLASS (klass)->finalize = spice_color_button_finalize;
#line 22 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	g_object_class_install_property (G_OBJECT_CLASS (klass), SPICE_COLOR_BUTTON_COLOR_PROPERTY, spice_color_button_properties[SPICE_COLOR_BUTTON_COLOR_PROPERTY] = g_param_spec_string ("color", "color", "color", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
#line 317 "ColorButton.c"
}

static void
spice_color_button_instance_init (SpiceColorButton * self,
                                  gpointer klass)
{
	gchar* _tmp0_;
#line 26 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	_tmp0_ = g_strdup ("none");
#line 26 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	self->_color = _tmp0_;
#line 329 "ColorButton.c"
}

static void
spice_color_button_finalize (GObject * obj)
{
	SpiceColorButton * self;
#line 22 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SPICE_TYPE_COLOR_BUTTON, SpiceColorButton);
#line 23 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	_g_object_unref0 (self->surface);
#line 24 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	_g_object_unref0 (self->checkered_bg);
#line 26 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	_g_free0 (self->_color);
#line 22 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	G_OBJECT_CLASS (spice_color_button_parent_class)->finalize (obj);
#line 346 "ColorButton.c"
}

static GType
spice_color_button_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SpiceColorButtonClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) spice_color_button_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SpiceColorButton), 0, (GInstanceInitFunc) spice_color_button_instance_init, NULL };
	GType spice_color_button_type_id;
	spice_color_button_type_id = g_type_register_static (gtk_button_get_type (), "SpiceColorButton", &g_define_type_info, 0);
	return spice_color_button_type_id;
}

GType
spice_color_button_get_type (void)
{
	static volatile gsize spice_color_button_type_id__once = 0;
	if (g_once_init_enter (&spice_color_button_type_id__once)) {
		GType spice_color_button_type_id;
		spice_color_button_type_id = spice_color_button_get_type_once ();
		g_once_init_leave (&spice_color_button_type_id__once, spice_color_button_type_id);
	}
	return spice_color_button_type_id__once;
}

static void
_vala_spice_color_button_get_property (GObject * object,
                                       guint property_id,
                                       GValue * value,
                                       GParamSpec * pspec)
{
	SpiceColorButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SPICE_TYPE_COLOR_BUTTON, SpiceColorButton);
#line 22 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	switch (property_id) {
#line 22 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
		case SPICE_COLOR_BUTTON_COLOR_PROPERTY:
#line 22 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
		g_value_set_string (value, spice_color_button_get_color (self));
#line 22 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
		break;
#line 386 "ColorButton.c"
		default:
#line 22 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
#line 22 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
		break;
#line 392 "ColorButton.c"
	}
}

static void
_vala_spice_color_button_set_property (GObject * object,
                                       guint property_id,
                                       const GValue * value,
                                       GParamSpec * pspec)
{
	SpiceColorButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SPICE_TYPE_COLOR_BUTTON, SpiceColorButton);
#line 22 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
	switch (property_id) {
#line 22 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
		case SPICE_COLOR_BUTTON_COLOR_PROPERTY:
#line 22 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
		spice_color_button_set_color (self, g_value_get_string (value));
#line 22 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
		break;
#line 412 "ColorButton.c"
		default:
#line 22 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
#line 22 "../Spice-up-1.9.1/src/Widgets/ColorPicker/ColorButton.vala"
		break;
#line 418 "ColorButton.c"
	}
}

