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

/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 4 -*-
 * -*- coding: utf-8 -*-
 *
 * Copyright (C) 2011 ~ 2018 Deepin, Inc.
 *               2011 ~ 2018 Wang Yong
 *
 * Author:     Wang Yong <wangyong@deepin.com>
 * Maintainer: Wang Yong <wangyong@deepin.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
 * 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 <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <cairo-gobject.h>
#include <gdk/gdk.h>

#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 WIDGETS_TYPE_CURSOR_TOGGLE_BUTTON (widgets_cursor_toggle_button_get_type ())
#define WIDGETS_CURSOR_TOGGLE_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIDGETS_TYPE_CURSOR_TOGGLE_BUTTON, WidgetsCursorToggleButton))
#define WIDGETS_CURSOR_TOGGLE_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIDGETS_TYPE_CURSOR_TOGGLE_BUTTON, WidgetsCursorToggleButtonClass))
#define WIDGETS_IS_CURSOR_TOGGLE_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIDGETS_TYPE_CURSOR_TOGGLE_BUTTON))
#define WIDGETS_IS_CURSOR_TOGGLE_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIDGETS_TYPE_CURSOR_TOGGLE_BUTTON))
#define WIDGETS_CURSOR_TOGGLE_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIDGETS_TYPE_CURSOR_TOGGLE_BUTTON, WidgetsCursorToggleButtonClass))

typedef struct _WidgetsCursorToggleButton WidgetsCursorToggleButton;
typedef struct _WidgetsCursorToggleButtonClass WidgetsCursorToggleButtonClass;
typedef struct _WidgetsCursorToggleButtonPrivate WidgetsCursorToggleButtonPrivate;

#define WIDGETS_TYPE_CURSOR_STYLE_BUTTON (widgets_cursor_style_button_get_type ())
#define WIDGETS_CURSOR_STYLE_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIDGETS_TYPE_CURSOR_STYLE_BUTTON, WidgetsCursorStyleButton))
#define WIDGETS_CURSOR_STYLE_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIDGETS_TYPE_CURSOR_STYLE_BUTTON, WidgetsCursorStyleButtonClass))
#define WIDGETS_IS_CURSOR_STYLE_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIDGETS_TYPE_CURSOR_STYLE_BUTTON))
#define WIDGETS_IS_CURSOR_STYLE_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIDGETS_TYPE_CURSOR_STYLE_BUTTON))
#define WIDGETS_CURSOR_STYLE_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIDGETS_TYPE_CURSOR_STYLE_BUTTON, WidgetsCursorStyleButtonClass))

typedef struct _WidgetsCursorStyleButton WidgetsCursorStyleButton;
typedef struct _WidgetsCursorStyleButtonClass WidgetsCursorStyleButtonClass;
enum  {
	WIDGETS_CURSOR_TOGGLE_BUTTON_0_PROPERTY,
	WIDGETS_CURSOR_TOGGLE_BUTTON_NUM_PROPERTIES
};
static GParamSpec* widgets_cursor_toggle_button_properties[WIDGETS_CURSOR_TOGGLE_BUTTON_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	WIDGETS_CURSOR_TOGGLE_BUTTON_CHANGE_CURSOR_STATE_SIGNAL,
	WIDGETS_CURSOR_TOGGLE_BUTTON_NUM_SIGNALS
};
static guint widgets_cursor_toggle_button_signals[WIDGETS_CURSOR_TOGGLE_BUTTON_NUM_SIGNALS] = {0};
typedef struct _WidgetsCursorStyleButtonPrivate WidgetsCursorStyleButtonPrivate;
enum  {
	WIDGETS_CURSOR_STYLE_BUTTON_0_PROPERTY,
	WIDGETS_CURSOR_STYLE_BUTTON_NUM_PROPERTIES
};
static GParamSpec* widgets_cursor_style_button_properties[WIDGETS_CURSOR_STYLE_BUTTON_NUM_PROPERTIES];
#define _cairo_surface_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_surface_destroy (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
enum  {
	WIDGETS_CURSOR_STYLE_BUTTON_ACTIVE_SIGNAL,
	WIDGETS_CURSOR_STYLE_BUTTON_NUM_SIGNALS
};
static guint widgets_cursor_style_button_signals[WIDGETS_CURSOR_STYLE_BUTTON_NUM_SIGNALS] = {0};

struct _WidgetsCursorToggleButton {
	GtkBin parent_instance;
	WidgetsCursorToggleButtonPrivate * priv;
	WidgetsCursorStyleButton* block_button;
	WidgetsCursorStyleButton* ibeam_button;
	WidgetsCursorStyleButton* underline_button;
	gint cursor_height;
	gint cursor_width;
};

struct _WidgetsCursorToggleButtonClass {
	GtkBinClass parent_class;
};

struct _WidgetsCursorStyleButton {
	GtkButton parent_instance;
	WidgetsCursorStyleButtonPrivate * priv;
	gboolean is_active;
	gint cursor_width;
	gint cursor_height;
};

struct _WidgetsCursorStyleButtonClass {
	GtkButtonClass parent_class;
};

struct _WidgetsCursorStyleButtonPrivate {
	cairo_surface_t* normal_surface;
	cairo_surface_t* hover_surface;
	cairo_surface_t* press_surface;
	cairo_surface_t* checked_surface;
};

static gpointer widgets_cursor_toggle_button_parent_class = NULL;
static gint WidgetsCursorStyleButton_private_offset;
static gpointer widgets_cursor_style_button_parent_class = NULL;

VALA_EXTERN GType widgets_cursor_toggle_button_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WidgetsCursorToggleButton, g_object_unref)
VALA_EXTERN GType widgets_cursor_style_button_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WidgetsCursorStyleButton, g_object_unref)
VALA_EXTERN WidgetsCursorToggleButton* widgets_cursor_toggle_button_new (void);
VALA_EXTERN WidgetsCursorToggleButton* widgets_cursor_toggle_button_construct (GType object_type);
VALA_EXTERN WidgetsCursorStyleButton* widgets_cursor_style_button_new (const gchar* icon_name);
VALA_EXTERN WidgetsCursorStyleButton* widgets_cursor_style_button_construct (GType object_type,
                                                                 const gchar* icon_name);
static void __lambda162_ (WidgetsCursorToggleButton* self,
                   WidgetsCursorStyleButton* w);
VALA_EXTERN void widgets_cursor_toggle_button_set_cursor_state (WidgetsCursorToggleButton* self,
                                                    const gchar* name);
static void ___lambda162__widgets_cursor_style_button_active (WidgetsCursorStyleButton* _sender,
                                                       gpointer self);
static void __lambda163_ (WidgetsCursorToggleButton* self,
                   WidgetsCursorStyleButton* w);
static void ___lambda163__widgets_cursor_style_button_active (WidgetsCursorStyleButton* _sender,
                                                       gpointer self);
static void __lambda164_ (WidgetsCursorToggleButton* self,
                   WidgetsCursorStyleButton* w);
static void ___lambda164__widgets_cursor_style_button_active (WidgetsCursorStyleButton* _sender,
                                                       gpointer self);
VALA_EXTERN void widgets_cursor_style_button_set_active (WidgetsCursorStyleButton* self,
                                             gboolean active);
static void widgets_cursor_toggle_button_finalize (GObject * obj);
static GType widgets_cursor_toggle_button_get_type_once (void);
VALA_EXTERN cairo_surface_t* utils_create_image_surface (const gchar* surface_path);
static gboolean __lambda161_ (WidgetsCursorStyleButton* self,
                       GdkEventButton* w);
static gboolean ___lambda161__gtk_widget_button_press_event (GtkWidget* _sender,
                                                      GdkEventButton* event,
                                                      gpointer self);
static gboolean widgets_cursor_style_button_on_draw (WidgetsCursorStyleButton* self,
                                              GtkWidget* widget,
                                              cairo_t* cr);
static gboolean _widgets_cursor_style_button_on_draw_gtk_widget_draw (GtkWidget* _sender,
                                                               cairo_t* cr,
                                                               gpointer self);
VALA_EXTERN void draw_draw_surface (cairo_t* cr,
                        cairo_surface_t* surface,
                        gint x,
                        gint y,
                        gint width,
                        gint height);
static void widgets_cursor_style_button_finalize (GObject * obj);
static GType widgets_cursor_style_button_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static void
__lambda162_ (WidgetsCursorToggleButton* self,
              WidgetsCursorStyleButton* w)
{
	g_return_if_fail (w != NULL);
	widgets_cursor_toggle_button_set_cursor_state (self, "block");
	g_signal_emit (self, widgets_cursor_toggle_button_signals[WIDGETS_CURSOR_TOGGLE_BUTTON_CHANGE_CURSOR_STATE_SIGNAL], 0, "block");
}

static void
___lambda162__widgets_cursor_style_button_active (WidgetsCursorStyleButton* _sender,
                                                  gpointer self)
{
	__lambda162_ ((WidgetsCursorToggleButton*) self, _sender);
}

static void
__lambda163_ (WidgetsCursorToggleButton* self,
              WidgetsCursorStyleButton* w)
{
	g_return_if_fail (w != NULL);
	widgets_cursor_toggle_button_set_cursor_state (self, "ibeam");
	g_signal_emit (self, widgets_cursor_toggle_button_signals[WIDGETS_CURSOR_TOGGLE_BUTTON_CHANGE_CURSOR_STATE_SIGNAL], 0, "ibeam");
}

static void
___lambda163__widgets_cursor_style_button_active (WidgetsCursorStyleButton* _sender,
                                                  gpointer self)
{
	__lambda163_ ((WidgetsCursorToggleButton*) self, _sender);
}

static void
__lambda164_ (WidgetsCursorToggleButton* self,
              WidgetsCursorStyleButton* w)
{
	g_return_if_fail (w != NULL);
	widgets_cursor_toggle_button_set_cursor_state (self, "underline");
	g_signal_emit (self, widgets_cursor_toggle_button_signals[WIDGETS_CURSOR_TOGGLE_BUTTON_CHANGE_CURSOR_STATE_SIGNAL], 0, "underline");
}

static void
___lambda164__widgets_cursor_style_button_active (WidgetsCursorStyleButton* _sender,
                                                  gpointer self)
{
	__lambda164_ ((WidgetsCursorToggleButton*) self, _sender);
}

WidgetsCursorToggleButton*
widgets_cursor_toggle_button_construct (GType object_type)
{
	WidgetsCursorToggleButton * self = NULL;
	GtkBox* box = NULL;
	GtkBox* _tmp0_;
	WidgetsCursorStyleButton* _tmp1_;
	WidgetsCursorStyleButton* _tmp2_;
	WidgetsCursorStyleButton* _tmp3_;
	WidgetsCursorStyleButton* _tmp4_;
	WidgetsCursorStyleButton* _tmp5_;
	WidgetsCursorStyleButton* _tmp6_;
	WidgetsCursorStyleButton* _tmp7_;
	WidgetsCursorStyleButton* _tmp8_;
	WidgetsCursorStyleButton* _tmp9_;
	self = (WidgetsCursorToggleButton*) g_object_new (object_type, NULL);
	gtk_widget_set_size_request ((GtkWidget*) self, self->cursor_width, self->cursor_height * 3);
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	g_object_ref_sink (_tmp0_);
	box = _tmp0_;
	_tmp1_ = widgets_cursor_style_button_new ("cursor_block");
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->block_button);
	self->block_button = _tmp1_;
	_tmp2_ = widgets_cursor_style_button_new ("cursor_ibeam");
	g_object_ref_sink (_tmp2_);
	_g_object_unref0 (self->ibeam_button);
	self->ibeam_button = _tmp2_;
	_tmp3_ = widgets_cursor_style_button_new ("cursor_underline");
	g_object_ref_sink (_tmp3_);
	_g_object_unref0 (self->underline_button);
	self->underline_button = _tmp3_;
	_tmp4_ = self->block_button;
	g_signal_connect_object (_tmp4_, "active", (GCallback) ___lambda162__widgets_cursor_style_button_active, self, 0);
	_tmp5_ = self->ibeam_button;
	g_signal_connect_object (_tmp5_, "active", (GCallback) ___lambda163__widgets_cursor_style_button_active, self, 0);
	_tmp6_ = self->underline_button;
	g_signal_connect_object (_tmp6_, "active", (GCallback) ___lambda164__widgets_cursor_style_button_active, self, 0);
	_tmp7_ = self->block_button;
	gtk_box_pack_start (box, (GtkWidget*) _tmp7_, FALSE, FALSE, (guint) 0);
	_tmp8_ = self->ibeam_button;
	gtk_box_pack_start (box, (GtkWidget*) _tmp8_, FALSE, FALSE, (guint) 0);
	_tmp9_ = self->underline_button;
	gtk_box_pack_start (box, (GtkWidget*) _tmp9_, FALSE, FALSE, (guint) 0);
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) box);
	gtk_widget_show_all ((GtkWidget*) self);
	_g_object_unref0 (box);
	return self;
}

WidgetsCursorToggleButton*
widgets_cursor_toggle_button_new (void)
{
	return widgets_cursor_toggle_button_construct (WIDGETS_TYPE_CURSOR_TOGGLE_BUTTON);
}

void
widgets_cursor_toggle_button_set_cursor_state (WidgetsCursorToggleButton* self,
                                               const gchar* name)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (name != NULL);
	if (g_strcmp0 (name, "block") == 0) {
		WidgetsCursorStyleButton* _tmp0_;
		WidgetsCursorStyleButton* _tmp1_;
		WidgetsCursorStyleButton* _tmp2_;
		_tmp0_ = self->block_button;
		widgets_cursor_style_button_set_active (_tmp0_, TRUE);
		_tmp1_ = self->ibeam_button;
		widgets_cursor_style_button_set_active (_tmp1_, FALSE);
		_tmp2_ = self->underline_button;
		widgets_cursor_style_button_set_active (_tmp2_, FALSE);
	} else {
		if (g_strcmp0 (name, "ibeam") == 0) {
			WidgetsCursorStyleButton* _tmp3_;
			WidgetsCursorStyleButton* _tmp4_;
			WidgetsCursorStyleButton* _tmp5_;
			_tmp3_ = self->block_button;
			widgets_cursor_style_button_set_active (_tmp3_, FALSE);
			_tmp4_ = self->ibeam_button;
			widgets_cursor_style_button_set_active (_tmp4_, TRUE);
			_tmp5_ = self->underline_button;
			widgets_cursor_style_button_set_active (_tmp5_, FALSE);
		} else {
			if (g_strcmp0 (name, "underline") == 0) {
				WidgetsCursorStyleButton* _tmp6_;
				WidgetsCursorStyleButton* _tmp7_;
				WidgetsCursorStyleButton* _tmp8_;
				_tmp6_ = self->block_button;
				widgets_cursor_style_button_set_active (_tmp6_, FALSE);
				_tmp7_ = self->ibeam_button;
				widgets_cursor_style_button_set_active (_tmp7_, FALSE);
				_tmp8_ = self->underline_button;
				widgets_cursor_style_button_set_active (_tmp8_, TRUE);
			}
		}
	}
}

static void
widgets_cursor_toggle_button_class_init (WidgetsCursorToggleButtonClass * klass,
                                         gpointer klass_data)
{
	widgets_cursor_toggle_button_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = widgets_cursor_toggle_button_finalize;
	widgets_cursor_toggle_button_signals[WIDGETS_CURSOR_TOGGLE_BUTTON_CHANGE_CURSOR_STATE_SIGNAL] = g_signal_new ("change-cursor-state", WIDGETS_TYPE_CURSOR_TOGGLE_BUTTON, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
}

static void
widgets_cursor_toggle_button_instance_init (WidgetsCursorToggleButton * self,
                                            gpointer klass)
{
	self->cursor_height = 26;
	self->cursor_width = 36;
}

static void
widgets_cursor_toggle_button_finalize (GObject * obj)
{
	WidgetsCursorToggleButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIDGETS_TYPE_CURSOR_TOGGLE_BUTTON, WidgetsCursorToggleButton);
	_g_object_unref0 (self->block_button);
	_g_object_unref0 (self->ibeam_button);
	_g_object_unref0 (self->underline_button);
	G_OBJECT_CLASS (widgets_cursor_toggle_button_parent_class)->finalize (obj);
}

static GType
widgets_cursor_toggle_button_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (WidgetsCursorToggleButtonClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) widgets_cursor_toggle_button_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WidgetsCursorToggleButton), 0, (GInstanceInitFunc) widgets_cursor_toggle_button_instance_init, NULL };
	GType widgets_cursor_toggle_button_type_id;
	widgets_cursor_toggle_button_type_id = g_type_register_static (gtk_bin_get_type (), "WidgetsCursorToggleButton", &g_define_type_info, 0);
	return widgets_cursor_toggle_button_type_id;
}

GType
widgets_cursor_toggle_button_get_type (void)
{
	static volatile gsize widgets_cursor_toggle_button_type_id__once = 0;
	if (g_once_init_enter (&widgets_cursor_toggle_button_type_id__once)) {
		GType widgets_cursor_toggle_button_type_id;
		widgets_cursor_toggle_button_type_id = widgets_cursor_toggle_button_get_type_once ();
		g_once_init_leave (&widgets_cursor_toggle_button_type_id__once, widgets_cursor_toggle_button_type_id);
	}
	return widgets_cursor_toggle_button_type_id__once;
}

static inline gpointer
widgets_cursor_style_button_get_instance_private (WidgetsCursorStyleButton* self)
{
	return G_STRUCT_MEMBER_P (self, WidgetsCursorStyleButton_private_offset);
}

static gboolean
__lambda161_ (WidgetsCursorStyleButton* self,
              GdkEventButton* w)
{
	gboolean result;
	g_return_val_if_fail (w != NULL, FALSE);
	g_signal_emit (self, widgets_cursor_style_button_signals[WIDGETS_CURSOR_STYLE_BUTTON_ACTIVE_SIGNAL], 0);
	result = FALSE;
	return result;
}

static gboolean
___lambda161__gtk_widget_button_press_event (GtkWidget* _sender,
                                             GdkEventButton* event,
                                             gpointer self)
{
	gboolean result;
	result = __lambda161_ ((WidgetsCursorStyleButton*) self, event);
	return result;
}

static gboolean
_widgets_cursor_style_button_on_draw_gtk_widget_draw (GtkWidget* _sender,
                                                      cairo_t* cr,
                                                      gpointer self)
{
	gboolean result;
	result = widgets_cursor_style_button_on_draw ((WidgetsCursorStyleButton*) self, _sender, cr);
	return result;
}

WidgetsCursorStyleButton*
widgets_cursor_style_button_construct (GType object_type,
                                       const gchar* icon_name)
{
	WidgetsCursorStyleButton * self = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	cairo_surface_t* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	cairo_surface_t* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	cairo_surface_t* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	cairo_surface_t* _tmp11_;
	g_return_val_if_fail (icon_name != NULL, NULL);
	self = (WidgetsCursorStyleButton*) g_object_new (object_type, NULL);
	gtk_widget_set_size_request ((GtkWidget*) self, self->cursor_width, self->cursor_height);
	_tmp0_ = g_strconcat (icon_name, "_normal.svg", NULL);
	_tmp1_ = _tmp0_;
	_tmp2_ = utils_create_image_surface (_tmp1_);
	_cairo_surface_destroy0 (self->priv->normal_surface);
	self->priv->normal_surface = _tmp2_;
	_g_free0 (_tmp1_);
	_tmp3_ = g_strconcat (icon_name, "_hover.svg", NULL);
	_tmp4_ = _tmp3_;
	_tmp5_ = utils_create_image_surface (_tmp4_);
	_cairo_surface_destroy0 (self->priv->hover_surface);
	self->priv->hover_surface = _tmp5_;
	_g_free0 (_tmp4_);
	_tmp6_ = g_strconcat (icon_name, "_press.svg", NULL);
	_tmp7_ = _tmp6_;
	_tmp8_ = utils_create_image_surface (_tmp7_);
	_cairo_surface_destroy0 (self->priv->press_surface);
	self->priv->press_surface = _tmp8_;
	_g_free0 (_tmp7_);
	_tmp9_ = g_strconcat (icon_name, "_checked.svg", NULL);
	_tmp10_ = _tmp9_;
	_tmp11_ = utils_create_image_surface (_tmp10_);
	_cairo_surface_destroy0 (self->priv->checked_surface);
	self->priv->checked_surface = _tmp11_;
	_g_free0 (_tmp10_);
	g_signal_connect_object ((GtkWidget*) self, "button-press-event", (GCallback) ___lambda161__gtk_widget_button_press_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "draw", (GCallback) _widgets_cursor_style_button_on_draw_gtk_widget_draw, self, 0);
	return self;
}

WidgetsCursorStyleButton*
widgets_cursor_style_button_new (const gchar* icon_name)
{
	return widgets_cursor_style_button_construct (WIDGETS_TYPE_CURSOR_STYLE_BUTTON, icon_name);
}

void
widgets_cursor_style_button_set_active (WidgetsCursorStyleButton* self,
                                        gboolean active)
{
	g_return_if_fail (self != NULL);
	self->is_active = active;
	gtk_widget_queue_draw ((GtkWidget*) self);
}

static gboolean
widgets_cursor_style_button_on_draw (WidgetsCursorStyleButton* self,
                                     GtkWidget* widget,
                                     cairo_t* cr)
{
	GtkStateFlags state_flags = 0U;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (widget != NULL, FALSE);
	g_return_val_if_fail (cr != NULL, FALSE);
	state_flags = gtk_widget_get_state_flags (widget);
	if (self->is_active) {
		cairo_surface_t* _tmp0_;
		_tmp0_ = self->priv->checked_surface;
		draw_draw_surface (cr, _tmp0_, 0, 0, 0, 0);
	} else {
		if ((state_flags & GTK_STATE_FLAG_ACTIVE) != 0) {
			cairo_surface_t* _tmp1_;
			_tmp1_ = self->priv->press_surface;
			draw_draw_surface (cr, _tmp1_, 0, 0, 0, 0);
		} else {
			if ((state_flags & GTK_STATE_FLAG_PRELIGHT) != 0) {
				cairo_surface_t* _tmp2_;
				_tmp2_ = self->priv->hover_surface;
				draw_draw_surface (cr, _tmp2_, 0, 0, 0, 0);
			} else {
				cairo_surface_t* _tmp3_;
				_tmp3_ = self->priv->normal_surface;
				draw_draw_surface (cr, _tmp3_, 0, 0, 0, 0);
			}
		}
	}
	result = TRUE;
	return result;
}

static void
widgets_cursor_style_button_class_init (WidgetsCursorStyleButtonClass * klass,
                                        gpointer klass_data)
{
	widgets_cursor_style_button_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &WidgetsCursorStyleButton_private_offset);
	G_OBJECT_CLASS (klass)->finalize = widgets_cursor_style_button_finalize;
	widgets_cursor_style_button_signals[WIDGETS_CURSOR_STYLE_BUTTON_ACTIVE_SIGNAL] = g_signal_new ("active", WIDGETS_TYPE_CURSOR_STYLE_BUTTON, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
widgets_cursor_style_button_instance_init (WidgetsCursorStyleButton * self,
                                           gpointer klass)
{
	self->priv = widgets_cursor_style_button_get_instance_private (self);
	self->is_active = FALSE;
	self->cursor_width = 36;
	self->cursor_height = 26;
}

static void
widgets_cursor_style_button_finalize (GObject * obj)
{
	WidgetsCursorStyleButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIDGETS_TYPE_CURSOR_STYLE_BUTTON, WidgetsCursorStyleButton);
	_cairo_surface_destroy0 (self->priv->normal_surface);
	_cairo_surface_destroy0 (self->priv->hover_surface);
	_cairo_surface_destroy0 (self->priv->press_surface);
	_cairo_surface_destroy0 (self->priv->checked_surface);
	G_OBJECT_CLASS (widgets_cursor_style_button_parent_class)->finalize (obj);
}

static GType
widgets_cursor_style_button_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (WidgetsCursorStyleButtonClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) widgets_cursor_style_button_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WidgetsCursorStyleButton), 0, (GInstanceInitFunc) widgets_cursor_style_button_instance_init, NULL };
	GType widgets_cursor_style_button_type_id;
	widgets_cursor_style_button_type_id = g_type_register_static (gtk_button_get_type (), "WidgetsCursorStyleButton", &g_define_type_info, 0);
	WidgetsCursorStyleButton_private_offset = g_type_add_instance_private (widgets_cursor_style_button_type_id, sizeof (WidgetsCursorStyleButtonPrivate));
	return widgets_cursor_style_button_type_id;
}

GType
widgets_cursor_style_button_get_type (void)
{
	static volatile gsize widgets_cursor_style_button_type_id__once = 0;
	if (g_once_init_enter (&widgets_cursor_style_button_type_id__once)) {
		GType widgets_cursor_style_button_type_id;
		widgets_cursor_style_button_type_id = widgets_cursor_style_button_get_type_once ();
		g_once_init_leave (&widgets_cursor_style_button_type_id__once, widgets_cursor_style_button_type_id);
	}
	return widgets_cursor_style_button_type_id__once;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

