/* command_button.c generated by valac 0.56.17, the Vala compiler
 * generated from command_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>

#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;

#define WIDGETS_TYPE_COMMAND_BUTTON (widgets_command_button_get_type ())
#define WIDGETS_COMMAND_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIDGETS_TYPE_COMMAND_BUTTON, WidgetsCommandButton))
#define WIDGETS_COMMAND_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIDGETS_TYPE_COMMAND_BUTTON, WidgetsCommandButtonClass))
#define WIDGETS_IS_COMMAND_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIDGETS_TYPE_COMMAND_BUTTON))
#define WIDGETS_IS_COMMAND_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIDGETS_TYPE_COMMAND_BUTTON))
#define WIDGETS_COMMAND_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIDGETS_TYPE_COMMAND_BUTTON, WidgetsCommandButtonClass))

typedef struct _WidgetsCommandButton WidgetsCommandButton;
typedef struct _WidgetsCommandButtonClass WidgetsCommandButtonClass;
typedef struct _WidgetsCommandButtonPrivate WidgetsCommandButtonPrivate;
enum  {
	WIDGETS_COMMAND_BUTTON_0_PROPERTY,
	WIDGETS_COMMAND_BUTTON_NUM_PROPERTIES
};
static GParamSpec* widgets_command_button_properties[WIDGETS_COMMAND_BUTTON_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block6Data Block6Data;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	WIDGETS_COMMAND_BUTTON_EDIT_COMMAND_SIGNAL,
	WIDGETS_COMMAND_BUTTON_EXECUTE_COMMAND_SIGNAL,
	WIDGETS_COMMAND_BUTTON_NUM_SIGNALS
};
static guint widgets_command_button_signals[WIDGETS_COMMAND_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;
};

struct _WidgetsCommandButton {
	WidgetsPanelButton parent_instance;
	WidgetsCommandButtonPrivate * priv;
};

struct _WidgetsCommandButtonClass {
	WidgetsPanelButtonClass parent_class;
};

struct _Block6Data {
	int _ref_count_;
	WidgetsCommandButton* self;
	gchar* name;
	gchar* value;
};

static gpointer widgets_command_button_parent_class = NULL;

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 GType widgets_command_button_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WidgetsCommandButton, g_object_unref)
VALA_EXTERN WidgetsCommandButton* widgets_command_button_new (const gchar* name,
                                                  const gchar* value,
                                                  const gchar* shortcut);
VALA_EXTERN WidgetsCommandButton* widgets_command_button_construct (GType object_type,
                                                        const gchar* name,
                                                        const gchar* value,
                                                        const gchar* shortcut);
static Block6Data* block6_data_ref (Block6Data* _data6_);
static void block6_data_unref (void * _userdata_);
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);
static void __lambda39_ (Block6Data* _data6_,
                  WidgetsPanelButton* w);
static void ___lambda39__widgets_panel_button_click_edit_button (WidgetsPanelButton* _sender,
                                                          gpointer self);
static void __lambda40_ (Block6Data* _data6_,
                  WidgetsPanelButton* w);
static void ___lambda40__widgets_panel_button_click_button (WidgetsPanelButton* _sender,
                                                     gpointer self);
static GType widgets_command_button_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static Block6Data*
block6_data_ref (Block6Data* _data6_)
{
	g_atomic_int_inc (&_data6_->_ref_count_);
	return _data6_;
}

static void
block6_data_unref (void * _userdata_)
{
	Block6Data* _data6_;
	_data6_ = (Block6Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data6_->_ref_count_)) {
		WidgetsCommandButton* self;
		self = _data6_->self;
		_g_free0 (_data6_->name);
		_g_free0 (_data6_->value);
		_g_object_unref0 (self);
		g_slice_free (Block6Data, _data6_);
	}
}

static void
__lambda39_ (Block6Data* _data6_,
             WidgetsPanelButton* w)
{
	WidgetsCommandButton* self;
	self = _data6_->self;
	g_return_if_fail (w != NULL);
	g_signal_emit (self, widgets_command_button_signals[WIDGETS_COMMAND_BUTTON_EDIT_COMMAND_SIGNAL], 0, _data6_->name);
}

static void
___lambda39__widgets_panel_button_click_edit_button (WidgetsPanelButton* _sender,
                                                     gpointer self)
{
	__lambda39_ (self, _sender);
}

static void
__lambda40_ (Block6Data* _data6_,
             WidgetsPanelButton* w)
{
	WidgetsCommandButton* self;
	self = _data6_->self;
	g_return_if_fail (w != NULL);
	g_signal_emit (self, widgets_command_button_signals[WIDGETS_COMMAND_BUTTON_EXECUTE_COMMAND_SIGNAL], 0, _data6_->value);
}

static void
___lambda40__widgets_panel_button_click_button (WidgetsPanelButton* _sender,
                                                gpointer self)
{
	__lambda40_ (self, _sender);
}

WidgetsCommandButton*
widgets_command_button_construct (GType object_type,
                                  const gchar* name,
                                  const gchar* value,
                                  const gchar* shortcut)
{
	WidgetsCommandButton * self = NULL;
	Block6Data* _data6_;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (value != NULL, NULL);
	g_return_val_if_fail (shortcut != NULL, NULL);
	_data6_ = g_slice_new0 (Block6Data);
	_data6_->_ref_count_ = 1;
	_tmp0_ = g_strdup (name);
	_g_free0 (_data6_->name);
	_data6_->name = _tmp0_;
	_tmp1_ = g_strdup (value);
	_g_free0 (_data6_->value);
	_data6_->value = _tmp1_;
	_tmp2_ = g_markup_escape_text (_data6_->name, (gssize) -1);
	_tmp3_ = _tmp2_;
	self = (WidgetsCommandButton*) widgets_panel_button_construct (object_type, _tmp3_, shortcut, NULL, "command");
	_data6_->self = g_object_ref (self);
	_g_free0 (_tmp3_);
	g_signal_connect_data ((WidgetsPanelButton*) self, "click-edit-button", (GCallback) ___lambda39__widgets_panel_button_click_edit_button, block6_data_ref (_data6_), (GClosureNotify) block6_data_unref, 0);
	g_signal_connect_data ((WidgetsPanelButton*) self, "click-button", (GCallback) ___lambda40__widgets_panel_button_click_button, block6_data_ref (_data6_), (GClosureNotify) block6_data_unref, 0);
	block6_data_unref (_data6_);
	_data6_ = NULL;
	return self;
}

WidgetsCommandButton*
widgets_command_button_new (const gchar* name,
                            const gchar* value,
                            const gchar* shortcut)
{
	return widgets_command_button_construct (WIDGETS_TYPE_COMMAND_BUTTON, name, value, shortcut);
}

static void
widgets_command_button_class_init (WidgetsCommandButtonClass * klass,
                                   gpointer klass_data)
{
	widgets_command_button_parent_class = g_type_class_peek_parent (klass);
	widgets_command_button_signals[WIDGETS_COMMAND_BUTTON_EDIT_COMMAND_SIGNAL] = g_signal_new ("edit-command", WIDGETS_TYPE_COMMAND_BUTTON, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
	widgets_command_button_signals[WIDGETS_COMMAND_BUTTON_EXECUTE_COMMAND_SIGNAL] = g_signal_new ("execute-command", WIDGETS_TYPE_COMMAND_BUTTON, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
}

static void
widgets_command_button_instance_init (WidgetsCommandButton * self,
                                      gpointer klass)
{
}

static GType
widgets_command_button_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (WidgetsCommandButtonClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) widgets_command_button_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WidgetsCommandButton), 0, (GInstanceInitFunc) widgets_command_button_instance_init, NULL };
	GType widgets_command_button_type_id;
	widgets_command_button_type_id = g_type_register_static (WIDGETS_TYPE_PANEL_BUTTON, "WidgetsCommandButton", &g_define_type_info, 0);
	return widgets_command_button_type_id;
}

GType
widgets_command_button_get_type (void)
{
	static volatile gsize widgets_command_button_type_id__once = 0;
	if (g_once_init_enter (&widgets_command_button_type_id__once)) {
		GType widgets_command_button_type_id;
		widgets_command_button_type_id = widgets_command_button_get_type_once ();
		g_once_init_leave (&widgets_command_button_type_id__once, widgets_command_button_type_id);
	}
	return widgets_command_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;
}

