/* panel_button.c generated by valac 0.56.17, the Vala compiler
 * generated from panel_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 <cairo-gobject.h>
#include <gdk/gdk.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include <pango/pango.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_CLICK_EVENT_BOX (widgets_click_event_box_get_type ())
#define WIDGETS_CLICK_EVENT_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIDGETS_TYPE_CLICK_EVENT_BOX, WidgetsClickEventBox))
#define WIDGETS_CLICK_EVENT_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIDGETS_TYPE_CLICK_EVENT_BOX, WidgetsClickEventBoxClass))
#define WIDGETS_IS_CLICK_EVENT_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIDGETS_TYPE_CLICK_EVENT_BOX))
#define WIDGETS_IS_CLICK_EVENT_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIDGETS_TYPE_CLICK_EVENT_BOX))
#define WIDGETS_CLICK_EVENT_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIDGETS_TYPE_CLICK_EVENT_BOX, WidgetsClickEventBoxClass))

typedef struct _WidgetsClickEventBox WidgetsClickEventBox;
typedef struct _WidgetsClickEventBoxClass WidgetsClickEventBoxClass;
typedef struct _WidgetsClickEventBoxPrivate WidgetsClickEventBoxPrivate;

#define WIDGETS_TYPE_PANEL_BUTTON (widgets_panel_button_get_type ())
#define WIDGETS_PANEL_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIDGETS_TYPE_PANEL_BUTTON, WidgetsPanelButton))
#define WIDGETS_PANEL_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIDGETS_TYPE_PANEL_BUTTON, WidgetsPanelButtonClass))
#define WIDGETS_IS_PANEL_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIDGETS_TYPE_PANEL_BUTTON))
#define WIDGETS_IS_PANEL_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIDGETS_TYPE_PANEL_BUTTON))
#define WIDGETS_PANEL_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIDGETS_TYPE_PANEL_BUTTON, WidgetsPanelButtonClass))

typedef struct _WidgetsPanelButton WidgetsPanelButton;
typedef struct _WidgetsPanelButtonClass WidgetsPanelButtonClass;
typedef struct _WidgetsPanelButtonPrivate WidgetsPanelButtonPrivate;
enum  {
	WIDGETS_PANEL_BUTTON_0_PROPERTY,
	WIDGETS_PANEL_BUTTON_NUM_PROPERTIES
};
static GParamSpec* widgets_panel_button_properties[WIDGETS_PANEL_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))

#define WIDGETS_TYPE_CONFIG_WINDOW (widgets_config_window_get_type ())
#define WIDGETS_CONFIG_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIDGETS_TYPE_CONFIG_WINDOW, WidgetsConfigWindow))
#define WIDGETS_CONFIG_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIDGETS_TYPE_CONFIG_WINDOW, WidgetsConfigWindowClass))
#define WIDGETS_IS_CONFIG_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIDGETS_TYPE_CONFIG_WINDOW))
#define WIDGETS_IS_CONFIG_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIDGETS_TYPE_CONFIG_WINDOW))
#define WIDGETS_CONFIG_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIDGETS_TYPE_CONFIG_WINDOW, WidgetsConfigWindowClass))

typedef struct _WidgetsConfigWindow WidgetsConfigWindow;
typedef struct _WidgetsConfigWindowClass WidgetsConfigWindowClass;
enum  {
	WIDGETS_PANEL_BUTTON_CLICK_BUTTON_SIGNAL,
	WIDGETS_PANEL_BUTTON_CLICK_EDIT_BUTTON_SIGNAL,
	WIDGETS_PANEL_BUTTON_NUM_SIGNALS
};
static guint widgets_panel_button_signals[WIDGETS_PANEL_BUTTON_NUM_SIGNALS] = {0};

struct _WidgetsClickEventBox {
	GtkEventBox parent_instance;
	WidgetsClickEventBoxPrivate * priv;
	gboolean is_press;
};

struct _WidgetsClickEventBoxClass {
	GtkEventBoxClass parent_class;
};

struct _WidgetsPanelButton {
	WidgetsClickEventBox parent_instance;
	WidgetsPanelButtonPrivate * priv;
	gboolean is_hover;
	cairo_surface_t* button_dark_surface;
	cairo_surface_t* button_edit_hover_dark_surface;
	cairo_surface_t* button_edit_hover_light_surface;
	cairo_surface_t* button_edit_normal_dark_surface;
	cairo_surface_t* button_edit_normal_light_surface;
	cairo_surface_t* button_edit_press_dark_surface;
	cairo_surface_t* button_edit_press_light_surface;
	cairo_surface_t* button_light_surface;
	GdkRGBA button_content_dark_color;
	GdkRGBA button_content_light_color;
	GdkRGBA button_name_dark_color;
	GdkRGBA button_name_light_color;
	GdkRGBA hover_dark_color;
	GdkRGBA hover_light_color;
	GdkRGBA line_dark_color;
	GdkRGBA line_light_color;
	GdkRGBA press_dark_color;
	GdkRGBA press_light_color;
	gboolean display_bottom_line;
	gboolean has_click;
	gboolean is_at_edit_button_area;
	gint button_content_size;
	gint button_content_y;
	gint button_name_size;
	gint button_name_y;
	gint edit_button_x;
	gint edit_button_y;
	gint height;
	gint image_x;
	gint text_width;
	gint text_x;
	gint width;
	gchar* button_content;
	gchar* button_name;
	gchar* button_display_name;
};

struct _WidgetsPanelButtonClass {
	WidgetsClickEventBoxClass parent_class;
};

static gpointer widgets_panel_button_parent_class = NULL;
VALA_EXTERN gint constant_SLIDER_PANEL_TEXT_WIDTH;
VALA_EXTERN gint constant_SLIDER_WIDTH;

VALA_EXTERN GType widgets_click_event_box_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WidgetsClickEventBox, g_object_unref)
VALA_EXTERN GType widgets_panel_button_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WidgetsPanelButton, g_object_unref)
VALA_EXTERN WidgetsPanelButton* widgets_panel_button_new (const gchar* name,
                                              const gchar* content,
                                              const gchar* display_name,
                                              const gchar* edit_button_name);
VALA_EXTERN WidgetsPanelButton* widgets_panel_button_construct (GType object_type,
                                                    const gchar* name,
                                                    const gchar* content,
                                                    const gchar* display_name,
                                                    const gchar* edit_button_name);
VALA_EXTERN WidgetsClickEventBox* widgets_click_event_box_new (void);
VALA_EXTERN WidgetsClickEventBox* widgets_click_event_box_construct (GType object_type);
VALA_EXTERN cairo_surface_t* utils_create_image_surface (const gchar* surface_path);
VALA_EXTERN void utils_hex_to_rgba (const gchar* hex_color,
                        gdouble alpha,
                        GdkRGBA* result);
static gboolean widgets_panel_button_on_draw (WidgetsPanelButton* self,
                                       GtkWidget* widget,
                                       cairo_t* cr);
static gboolean _widgets_panel_button_on_draw_gtk_widget_draw (GtkWidget* _sender,
                                                        cairo_t* cr,
                                                        gpointer self);
static gboolean __lambda33_ (WidgetsPanelButton* self,
                      GtkWidget* w,
                      GdkEventCrossing* e);
static gboolean ___lambda33__gtk_widget_enter_notify_event (GtkWidget* _sender,
                                                     GdkEventCrossing* event,
                                                     gpointer self);
static gboolean __lambda34_ (WidgetsPanelButton* self,
                      GtkWidget* w,
                      GdkEventCrossing* e);
static gboolean ___lambda34__gtk_widget_leave_notify_event (GtkWidget* _sender,
                                                     GdkEventCrossing* event,
                                                     gpointer self);
static gboolean __lambda35_ (WidgetsPanelButton* self,
                      GtkWidget* w,
                      GdkEventButton* e);
static gboolean ___lambda35__gtk_widget_button_press_event (GtkWidget* _sender,
                                                     GdkEventButton* event,
                                                     gpointer self);
static gboolean __lambda36_ (WidgetsPanelButton* self,
                      GtkWidget* w,
                      GdkEventButton* e);
static gboolean ___lambda36__gtk_widget_button_release_event (GtkWidget* _sender,
                                                       GdkEventButton* event,
                                                       gpointer self);
static void __lambda37_ (WidgetsPanelButton* self,
                  WidgetsClickEventBox* w,
                  GdkEventButton* e);
static void ___lambda37__widgets_click_event_box_clicked (WidgetsClickEventBox* _sender,
                                                   GdkEventButton* event,
                                                   gpointer self);
static gboolean __lambda38_ (WidgetsPanelButton* self,
                      GtkWidget* w,
                      GdkEventMotion* e);
static gboolean ___lambda38__gtk_widget_motion_notify_event (GtkWidget* _sender,
                                                      GdkEventMotion* event,
                                                      gpointer self);
VALA_EXTERN GType widgets_config_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WidgetsConfigWindow, g_object_unref)
VALA_EXTERN gboolean widgets_config_window_is_light_theme (WidgetsConfigWindow* self);
VALA_EXTERN void draw_draw_surface (cairo_t* cr,
                        cairo_surface_t* surface,
                        gint x,
                        gint y,
                        gint width,
                        gint height);
VALA_EXTERN void utils_set_context_color (cairo_t* cr,
                              GdkRGBA* color);
VALA_EXTERN void draw_draw_text (cairo_t* cr,
                     const gchar* text,
                     gint x,
                     gint y,
                     gint width,
                     gint height,
                     gint size,
                     PangoAlignment horizontal_alignment,
                     const gchar* vertical_align,
                     gint* wrap_width);
VALA_EXTERN void draw_draw_rectangle (cairo_t* cr,
                          gint x,
                          gint y,
                          gint w,
                          gint h,
                          gboolean fill);
static void widgets_panel_button_finalize (GObject * obj);
static GType widgets_panel_button_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static gboolean
_widgets_panel_button_on_draw_gtk_widget_draw (GtkWidget* _sender,
                                               cairo_t* cr,
                                               gpointer self)
{
	gboolean result;
	result = widgets_panel_button_on_draw ((WidgetsPanelButton*) self, _sender, cr);
	return result;
}

static gboolean
__lambda33_ (WidgetsPanelButton* self,
             GtkWidget* w,
             GdkEventCrossing* e)
{
	gboolean result;
	g_return_val_if_fail (w != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	self->is_hover = TRUE;
	gtk_widget_queue_draw ((GtkWidget*) self);
	result = FALSE;
	return result;
}

static gboolean
___lambda33__gtk_widget_enter_notify_event (GtkWidget* _sender,
                                            GdkEventCrossing* event,
                                            gpointer self)
{
	gboolean result;
	result = __lambda33_ ((WidgetsPanelButton*) self, _sender, event);
	return result;
}

static gboolean
__lambda34_ (WidgetsPanelButton* self,
             GtkWidget* w,
             GdkEventCrossing* e)
{
	gboolean result;
	g_return_val_if_fail (w != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	self->is_hover = FALSE;
	gtk_widget_queue_draw ((GtkWidget*) self);
	result = FALSE;
	return result;
}

static gboolean
___lambda34__gtk_widget_leave_notify_event (GtkWidget* _sender,
                                            GdkEventCrossing* event,
                                            gpointer self)
{
	gboolean result;
	result = __lambda34_ ((WidgetsPanelButton*) self, _sender, event);
	return result;
}

static gboolean
__lambda35_ (WidgetsPanelButton* self,
             GtkWidget* w,
             GdkEventButton* e)
{
	gboolean result;
	g_return_val_if_fail (w != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	gtk_widget_queue_draw ((GtkWidget*) self);
	result = FALSE;
	return result;
}

static gboolean
___lambda35__gtk_widget_button_press_event (GtkWidget* _sender,
                                            GdkEventButton* event,
                                            gpointer self)
{
	gboolean result;
	result = __lambda35_ ((WidgetsPanelButton*) self, _sender, event);
	return result;
}

static gboolean
__lambda36_ (WidgetsPanelButton* self,
             GtkWidget* w,
             GdkEventButton* e)
{
	gboolean result;
	g_return_val_if_fail (w != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	self->is_hover = FALSE;
	gtk_widget_queue_draw ((GtkWidget*) self);
	result = FALSE;
	return result;
}

static gboolean
___lambda36__gtk_widget_button_release_event (GtkWidget* _sender,
                                              GdkEventButton* event,
                                              gpointer self)
{
	gboolean result;
	result = __lambda36_ ((WidgetsPanelButton*) self, _sender, event);
	return result;
}

static void
__lambda37_ (WidgetsPanelButton* self,
             WidgetsClickEventBox* w,
             GdkEventButton* e)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	g_return_if_fail (w != NULL);
	g_return_if_fail (e != NULL);
	if (e->x > ((gdouble) self->edit_button_x)) {
		cairo_surface_t* _tmp3_;
		_tmp3_ = self->button_edit_normal_dark_surface;
		_tmp2_ = e->x < ((gdouble) (self->edit_button_x + cairo_image_surface_get_width (_tmp3_)));
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		_tmp1_ = e->y > ((gdouble) self->edit_button_y);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		cairo_surface_t* _tmp4_;
		_tmp4_ = self->button_edit_normal_dark_surface;
		_tmp0_ = e->y < ((gdouble) (self->height - cairo_image_surface_get_height (_tmp4_)));
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		g_signal_emit (self, widgets_panel_button_signals[WIDGETS_PANEL_BUTTON_CLICK_EDIT_BUTTON_SIGNAL], 0);
	} else {
		if (!self->has_click) {
			self->has_click = TRUE;
			g_signal_emit (self, widgets_panel_button_signals[WIDGETS_PANEL_BUTTON_CLICK_BUTTON_SIGNAL], 0);
		}
	}
}

static void
___lambda37__widgets_click_event_box_clicked (WidgetsClickEventBox* _sender,
                                              GdkEventButton* event,
                                              gpointer self)
{
	__lambda37_ ((WidgetsPanelButton*) self, _sender, event);
}

static gboolean
__lambda38_ (WidgetsPanelButton* self,
             GtkWidget* w,
             GdkEventMotion* e)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	gboolean result;
	g_return_val_if_fail (w != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	if (e->x > ((gdouble) self->edit_button_x)) {
		cairo_surface_t* _tmp3_;
		_tmp3_ = self->button_edit_normal_dark_surface;
		_tmp2_ = e->x < ((gdouble) (self->edit_button_x + cairo_image_surface_get_width (_tmp3_)));
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		_tmp1_ = e->y > ((gdouble) self->edit_button_y);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		cairo_surface_t* _tmp4_;
		_tmp4_ = self->button_edit_normal_dark_surface;
		_tmp0_ = e->y < ((gdouble) (self->height - cairo_image_surface_get_height (_tmp4_)));
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		self->is_at_edit_button_area = TRUE;
	} else {
		self->is_at_edit_button_area = FALSE;
	}
	gtk_widget_queue_draw ((GtkWidget*) self);
	result = FALSE;
	return result;
}

static gboolean
___lambda38__gtk_widget_motion_notify_event (GtkWidget* _sender,
                                             GdkEventMotion* event,
                                             gpointer self)
{
	gboolean result;
	result = __lambda38_ ((WidgetsPanelButton*) self, _sender, event);
	return result;
}

WidgetsPanelButton*
widgets_panel_button_construct (GType object_type,
                                const gchar* name,
                                const gchar* content,
                                const gchar* display_name,
                                const gchar* edit_button_name)
{
	WidgetsPanelButton * self = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	cairo_surface_t* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	cairo_surface_t* _tmp8_;
	cairo_surface_t* _tmp9_;
	cairo_surface_t* _tmp10_;
	cairo_surface_t* _tmp11_;
	cairo_surface_t* _tmp12_;
	cairo_surface_t* _tmp13_;
	cairo_surface_t* _tmp14_;
	GdkRGBA _tmp15_ = {0};
	GdkRGBA _tmp16_ = {0};
	GdkRGBA _tmp17_ = {0};
	GdkRGBA _tmp18_ = {0};
	GdkRGBA _tmp19_ = {0};
	GdkRGBA _tmp20_ = {0};
	GdkRGBA _tmp21_ = {0};
	GdkRGBA _tmp22_ = {0};
	GdkRGBA _tmp23_ = {0};
	GdkRGBA _tmp24_ = {0};
	cairo_surface_t* _tmp25_;
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (content != NULL, NULL);
	g_return_val_if_fail (edit_button_name != NULL, NULL);
	self = (WidgetsPanelButton*) widgets_click_event_box_construct (object_type);
	gtk_widget_add_events ((GtkWidget*) self, (gint) (((GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK) | GDK_POINTER_MOTION_MASK) | GDK_LEAVE_NOTIFY_MASK));
	_tmp0_ = g_strdup (name);
	_g_free0 (self->button_name);
	self->button_name = _tmp0_;
	_tmp1_ = g_strdup (content);
	_g_free0 (self->button_content);
	self->button_content = _tmp1_;
	_tmp2_ = g_strdup (display_name);
	_g_free0 (self->button_display_name);
	self->button_display_name = _tmp2_;
	_tmp3_ = g_strdup_printf ("%s_dark.svg", edit_button_name);
	_tmp4_ = _tmp3_;
	_tmp5_ = utils_create_image_surface (_tmp4_);
	_cairo_surface_destroy0 (self->button_dark_surface);
	self->button_dark_surface = _tmp5_;
	_g_free0 (_tmp4_);
	_tmp6_ = g_strdup_printf ("%s_light.svg", edit_button_name);
	_tmp7_ = _tmp6_;
	_tmp8_ = utils_create_image_surface (_tmp7_);
	_cairo_surface_destroy0 (self->button_light_surface);
	self->button_light_surface = _tmp8_;
	_g_free0 (_tmp7_);
	_tmp9_ = utils_create_image_surface ("button_edit_dark_normal.svg");
	_cairo_surface_destroy0 (self->button_edit_normal_dark_surface);
	self->button_edit_normal_dark_surface = _tmp9_;
	_tmp10_ = utils_create_image_surface ("button_edit_dark_hover.svg");
	_cairo_surface_destroy0 (self->button_edit_hover_dark_surface);
	self->button_edit_hover_dark_surface = _tmp10_;
	_tmp11_ = utils_create_image_surface ("button_edit_dark_press.svg");
	_cairo_surface_destroy0 (self->button_edit_press_dark_surface);
	self->button_edit_press_dark_surface = _tmp11_;
	_tmp12_ = utils_create_image_surface ("button_edit_light_normal.svg");
	_cairo_surface_destroy0 (self->button_edit_normal_light_surface);
	self->button_edit_normal_light_surface = _tmp12_;
	_tmp13_ = utils_create_image_surface ("button_edit_light_hover.svg");
	_cairo_surface_destroy0 (self->button_edit_hover_light_surface);
	self->button_edit_hover_light_surface = _tmp13_;
	_tmp14_ = utils_create_image_surface ("button_edit_light_press.svg");
	_cairo_surface_destroy0 (self->button_edit_press_light_surface);
	self->button_edit_press_light_surface = _tmp14_;
	utils_hex_to_rgba ("#FFFFFF", 1.0, &_tmp15_);
	self->button_name_dark_color = _tmp15_;
	utils_hex_to_rgba ("#FFFFFF", 0.5, &_tmp16_);
	self->button_content_dark_color = _tmp16_;
	utils_hex_to_rgba ("#FFFFFF", 0.1, &_tmp17_);
	self->press_dark_color = _tmp17_;
	utils_hex_to_rgba ("#FFFFFF", 0.1, &_tmp18_);
	self->hover_dark_color = _tmp18_;
	utils_hex_to_rgba ("#303030", 1.0, &_tmp19_);
	self->button_name_light_color = _tmp19_;
	utils_hex_to_rgba ("#000000", 0.5, &_tmp20_);
	self->button_content_light_color = _tmp20_;
	utils_hex_to_rgba ("#000000", 0.1, &_tmp21_);
	self->press_light_color = _tmp21_;
	utils_hex_to_rgba ("#000000", 0.1, &_tmp22_);
	self->hover_light_color = _tmp22_;
	utils_hex_to_rgba ("#ffffff", 0.05, &_tmp23_);
	self->line_dark_color = _tmp23_;
	utils_hex_to_rgba ("#000000", 0.05, &_tmp24_);
	self->line_light_color = _tmp24_;
	gtk_widget_set_size_request ((GtkWidget*) self, self->width, self->height);
	_tmp25_ = self->button_edit_press_dark_surface;
	self->edit_button_y = (self->height - cairo_image_surface_get_height (_tmp25_)) / 2;
	g_signal_connect_object ((GtkWidget*) self, "draw", (GCallback) _widgets_panel_button_on_draw_gtk_widget_draw, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "enter-notify-event", (GCallback) ___lambda33__gtk_widget_enter_notify_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "leave-notify-event", (GCallback) ___lambda34__gtk_widget_leave_notify_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "button-press-event", (GCallback) ___lambda35__gtk_widget_button_press_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "button-release-event", (GCallback) ___lambda36__gtk_widget_button_release_event, self, 0);
	g_signal_connect_object ((WidgetsClickEventBox*) self, "clicked", (GCallback) ___lambda37__widgets_click_event_box_clicked, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "motion-notify-event", (GCallback) ___lambda38__gtk_widget_motion_notify_event, self, 0);
	return self;
}

WidgetsPanelButton*
widgets_panel_button_new (const gchar* name,
                          const gchar* content,
                          const gchar* display_name,
                          const gchar* edit_button_name)
{
	return widgets_panel_button_construct (WIDGETS_TYPE_PANEL_BUTTON, name, content, display_name, edit_button_name);
}

static gboolean
widgets_panel_button_on_draw (WidgetsPanelButton* self,
                              GtkWidget* widget,
                              cairo_t* cr)
{
	gboolean is_light_theme = FALSE;
	GtkWidget* _tmp0_;
	const gchar* _tmp11_;
	const gchar* _tmp14_;
	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);
	_tmp0_ = gtk_widget_get_toplevel ((GtkWidget*) self);
	is_light_theme = widgets_config_window_is_light_theme (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, WIDGETS_TYPE_CONFIG_WINDOW, WidgetsConfigWindow));
	if (is_light_theme) {
		cairo_surface_t* _tmp1_;
		_tmp1_ = self->button_light_surface;
		draw_draw_surface (cr, _tmp1_, self->image_x, 0, 0, self->height);
	} else {
		cairo_surface_t* _tmp2_;
		_tmp2_ = self->button_dark_surface;
		draw_draw_surface (cr, _tmp2_, self->image_x, 0, 0, self->height);
	}
	if (self->is_hover) {
		if (self->is_at_edit_button_area) {
			if (((WidgetsClickEventBox*) self)->is_press) {
				if (is_light_theme) {
					cairo_surface_t* _tmp3_;
					_tmp3_ = self->button_edit_press_light_surface;
					draw_draw_surface (cr, _tmp3_, self->edit_button_x, 0, 0, self->height);
				} else {
					cairo_surface_t* _tmp4_;
					_tmp4_ = self->button_edit_press_dark_surface;
					draw_draw_surface (cr, _tmp4_, self->edit_button_x, 0, 0, self->height);
				}
			} else {
				if (self->is_hover) {
					if (is_light_theme) {
						cairo_surface_t* _tmp5_;
						_tmp5_ = self->button_edit_hover_light_surface;
						draw_draw_surface (cr, _tmp5_, self->edit_button_x, 0, 0, self->height);
					} else {
						cairo_surface_t* _tmp6_;
						_tmp6_ = self->button_edit_hover_dark_surface;
						draw_draw_surface (cr, _tmp6_, self->edit_button_x, 0, 0, self->height);
					}
				}
			}
		} else {
			if (is_light_theme) {
				cairo_surface_t* _tmp7_;
				_tmp7_ = self->button_edit_normal_light_surface;
				draw_draw_surface (cr, _tmp7_, self->edit_button_x, 0, 0, self->height);
			} else {
				cairo_surface_t* _tmp8_;
				_tmp8_ = self->button_edit_normal_dark_surface;
				draw_draw_surface (cr, _tmp8_, self->edit_button_x, 0, 0, self->height);
			}
		}
	}
	if (is_light_theme) {
		GdkRGBA _tmp9_;
		_tmp9_ = self->button_name_light_color;
		utils_set_context_color (cr, &_tmp9_);
	} else {
		GdkRGBA _tmp10_;
		_tmp10_ = self->button_name_dark_color;
		utils_set_context_color (cr, &_tmp10_);
	}
	_tmp11_ = self->button_name;
	draw_draw_text (cr, _tmp11_, self->text_x, self->button_name_y, self->text_width, self->height, self->button_name_size, PANGO_ALIGN_LEFT, "top", NULL);
	if (is_light_theme) {
		GdkRGBA _tmp12_;
		_tmp12_ = self->button_content_light_color;
		utils_set_context_color (cr, &_tmp12_);
	} else {
		GdkRGBA _tmp13_;
		_tmp13_ = self->button_content_dark_color;
		utils_set_context_color (cr, &_tmp13_);
	}
	_tmp14_ = self->button_display_name;
	if (_tmp14_ != NULL) {
		const gchar* _tmp15_;
		_tmp15_ = self->button_display_name;
		draw_draw_text (cr, _tmp15_, self->text_x, self->button_content_y, self->text_width, self->height, self->button_content_size, PANGO_ALIGN_LEFT, "top", NULL);
	} else {
		const gchar* _tmp16_;
		_tmp16_ = self->button_content;
		draw_draw_text (cr, _tmp16_, self->text_x, self->button_content_y, self->text_width, self->height, self->button_content_size, PANGO_ALIGN_LEFT, "top", NULL);
	}
	if (self->display_bottom_line) {
		if (is_light_theme) {
			GdkRGBA _tmp17_;
			_tmp17_ = self->line_light_color;
			utils_set_context_color (cr, &_tmp17_);
		} else {
			GdkRGBA _tmp18_;
			_tmp18_ = self->line_dark_color;
			utils_set_context_color (cr, &_tmp18_);
		}
		draw_draw_rectangle (cr, 8, self->height - 1, self->width - 16, 1, TRUE);
	}
	if (((WidgetsClickEventBox*) self)->is_press) {
		if (is_light_theme) {
			GdkRGBA _tmp19_;
			_tmp19_ = self->press_light_color;
			utils_set_context_color (cr, &_tmp19_);
		} else {
			GdkRGBA _tmp20_;
			_tmp20_ = self->press_dark_color;
			utils_set_context_color (cr, &_tmp20_);
		}
		draw_draw_rectangle (cr, 0, 0, self->width, self->height, TRUE);
	} else {
		if (self->is_hover) {
			if (is_light_theme) {
				GdkRGBA _tmp21_;
				_tmp21_ = self->hover_light_color;
				utils_set_context_color (cr, &_tmp21_);
			} else {
				GdkRGBA _tmp22_;
				_tmp22_ = self->hover_dark_color;
				utils_set_context_color (cr, &_tmp22_);
			}
			draw_draw_rectangle (cr, 0, 0, self->width, self->height, TRUE);
		}
	}
	result = TRUE;
	return result;
}

static void
widgets_panel_button_class_init (WidgetsPanelButtonClass * klass,
                                 gpointer klass_data)
{
	widgets_panel_button_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = widgets_panel_button_finalize;
	widgets_panel_button_signals[WIDGETS_PANEL_BUTTON_CLICK_BUTTON_SIGNAL] = g_signal_new ("click-button", WIDGETS_TYPE_PANEL_BUTTON, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	widgets_panel_button_signals[WIDGETS_PANEL_BUTTON_CLICK_EDIT_BUTTON_SIGNAL] = g_signal_new ("click-edit-button", WIDGETS_TYPE_PANEL_BUTTON, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
widgets_panel_button_instance_init (WidgetsPanelButton * self,
                                    gpointer klass)
{
	self->is_hover = FALSE;
	self->display_bottom_line = TRUE;
	self->has_click = FALSE;
	self->is_at_edit_button_area = FALSE;
	self->button_content_size = 10;
	self->button_content_y = 27;
	self->button_name_size = 11;
	self->button_name_y = 5;
	self->edit_button_x = 254;
	self->height = 56;
	self->image_x = 12;
	self->text_width = constant_SLIDER_PANEL_TEXT_WIDTH;
	self->text_x = 72;
	self->width = constant_SLIDER_WIDTH;
}

static void
widgets_panel_button_finalize (GObject * obj)
{
	WidgetsPanelButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIDGETS_TYPE_PANEL_BUTTON, WidgetsPanelButton);
	_cairo_surface_destroy0 (self->button_dark_surface);
	_cairo_surface_destroy0 (self->button_edit_hover_dark_surface);
	_cairo_surface_destroy0 (self->button_edit_hover_light_surface);
	_cairo_surface_destroy0 (self->button_edit_normal_dark_surface);
	_cairo_surface_destroy0 (self->button_edit_normal_light_surface);
	_cairo_surface_destroy0 (self->button_edit_press_dark_surface);
	_cairo_surface_destroy0 (self->button_edit_press_light_surface);
	_cairo_surface_destroy0 (self->button_light_surface);
	_g_free0 (self->button_content);
	_g_free0 (self->button_name);
	_g_free0 (self->button_display_name);
	G_OBJECT_CLASS (widgets_panel_button_parent_class)->finalize (obj);
}

static GType
widgets_panel_button_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (WidgetsPanelButtonClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) widgets_panel_button_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WidgetsPanelButton), 0, (GInstanceInitFunc) widgets_panel_button_instance_init, NULL };
	GType widgets_panel_button_type_id;
	widgets_panel_button_type_id = g_type_register_static (WIDGETS_TYPE_CLICK_EVENT_BOX, "WidgetsPanelButton", &g_define_type_info, 0);
	return widgets_panel_button_type_id;
}

GType
widgets_panel_button_get_type (void)
{
	static volatile gsize widgets_panel_button_type_id__once = 0;
	if (g_once_init_enter (&widgets_panel_button_type_id__once)) {
		GType widgets_panel_button_type_id;
		widgets_panel_button_type_id = widgets_panel_button_get_type_once ();
		g_once_init_leave (&widgets_panel_button_type_id__once, widgets_panel_button_type_id);
	}
	return widgets_panel_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;
}

