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

/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 4 -*-
 * -*- coding: utf-8 -*-
 *
 * Copyright (C) 2019 Deepin, Inc.
 *               2019 Gary Wang
 *
 * Author:     Gary Wang <wzc782970009@gmail.com>
 * Maintainer: Gary Wang <wzc782970009@gmail.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 <glib.h>
#include <gtk/gtk.h>
#include <glib-object.h>
#include <cairo-gobject.h>
#include <stdlib.h>
#include <string.h>
#include <gdk/gdk.h>
#include <float.h>
#include <math.h>
#include <gee.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_GRIP (widgets_grip_get_type ())
#define WIDGETS_GRIP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIDGETS_TYPE_GRIP, WidgetsGrip))
#define WIDGETS_GRIP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIDGETS_TYPE_GRIP, WidgetsGripClass))
#define WIDGETS_IS_GRIP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIDGETS_TYPE_GRIP))
#define WIDGETS_IS_GRIP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIDGETS_TYPE_GRIP))
#define WIDGETS_GRIP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIDGETS_TYPE_GRIP, WidgetsGripClass))

typedef struct _WidgetsGrip WidgetsGrip;
typedef struct _WidgetsGripClass WidgetsGripClass;
typedef struct _WidgetsGripPrivate WidgetsGripPrivate;
enum  {
	WIDGETS_GRIP_0_PROPERTY,
	WIDGETS_GRIP_NUM_PROPERTIES
};
static GParamSpec* widgets_grip_properties[WIDGETS_GRIP_NUM_PROPERTIES];
#define _cairo_surface_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_surface_destroy (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	WIDGETS_GRIP_CLICKED_SIGNAL,
	WIDGETS_GRIP_NUM_SIGNALS
};
static guint widgets_grip_signals[WIDGETS_GRIP_NUM_SIGNALS] = {0};

#define WIDGETS_TYPE_RESIZE_GRIP (widgets_resize_grip_get_type ())
#define WIDGETS_RESIZE_GRIP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIDGETS_TYPE_RESIZE_GRIP, WidgetsResizeGrip))
#define WIDGETS_RESIZE_GRIP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIDGETS_TYPE_RESIZE_GRIP, WidgetsResizeGripClass))
#define WIDGETS_IS_RESIZE_GRIP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIDGETS_TYPE_RESIZE_GRIP))
#define WIDGETS_IS_RESIZE_GRIP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIDGETS_TYPE_RESIZE_GRIP))
#define WIDGETS_RESIZE_GRIP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIDGETS_TYPE_RESIZE_GRIP, WidgetsResizeGripClass))

typedef struct _WidgetsResizeGrip WidgetsResizeGrip;
typedef struct _WidgetsResizeGripClass WidgetsResizeGripClass;
typedef struct _WidgetsResizeGripPrivate WidgetsResizeGripPrivate;

#define WIDGETS_TYPE_WINDOW_EVENT_AREA (widgets_window_event_area_get_type ())
#define WIDGETS_WINDOW_EVENT_AREA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIDGETS_TYPE_WINDOW_EVENT_AREA, WidgetsWindowEventArea))
#define WIDGETS_WINDOW_EVENT_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIDGETS_TYPE_WINDOW_EVENT_AREA, WidgetsWindowEventAreaClass))
#define WIDGETS_IS_WINDOW_EVENT_AREA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIDGETS_TYPE_WINDOW_EVENT_AREA))
#define WIDGETS_IS_WINDOW_EVENT_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIDGETS_TYPE_WINDOW_EVENT_AREA))
#define WIDGETS_WINDOW_EVENT_AREA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIDGETS_TYPE_WINDOW_EVENT_AREA, WidgetsWindowEventAreaClass))

typedef struct _WidgetsWindowEventArea WidgetsWindowEventArea;
typedef struct _WidgetsWindowEventAreaClass WidgetsWindowEventAreaClass;

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

#define WIDGETS_TYPE_WINDOW (widgets_window_get_type ())
#define WIDGETS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIDGETS_TYPE_WINDOW, WidgetsWindow))
#define WIDGETS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIDGETS_TYPE_WINDOW, WidgetsWindowClass))
#define WIDGETS_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIDGETS_TYPE_WINDOW))
#define WIDGETS_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIDGETS_TYPE_WINDOW))
#define WIDGETS_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIDGETS_TYPE_WINDOW, WidgetsWindowClass))

typedef struct _WidgetsWindow WidgetsWindow;
typedef struct _WidgetsWindowClass WidgetsWindowClass;
enum  {
	WIDGETS_RESIZE_GRIP_0_PROPERTY,
	WIDGETS_RESIZE_GRIP_NUM_PROPERTIES
};
static GParamSpec* widgets_resize_grip_properties[WIDGETS_RESIZE_GRIP_NUM_PROPERTIES];
typedef struct _Block37Data Block37Data;
typedef struct _WidgetsConfigWindowPrivate WidgetsConfigWindowPrivate;

#define CONFIG_TYPE_CONFIG (config_config_get_type ())
#define CONFIG_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONFIG_TYPE_CONFIG, ConfigConfig))
#define CONFIG_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONFIG_TYPE_CONFIG, ConfigConfigClass))
#define CONFIG_IS_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONFIG_TYPE_CONFIG))
#define CONFIG_IS_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONFIG_TYPE_CONFIG))
#define CONFIG_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONFIG_TYPE_CONFIG, ConfigConfigClass))

typedef struct _ConfigConfig ConfigConfig;
typedef struct _ConfigConfigClass ConfigConfigClass;

#define WIDGETS_TYPE_WORKSPACE_MANAGER (widgets_workspace_manager_get_type ())
#define WIDGETS_WORKSPACE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIDGETS_TYPE_WORKSPACE_MANAGER, WidgetsWorkspaceManager))
#define WIDGETS_WORKSPACE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIDGETS_TYPE_WORKSPACE_MANAGER, WidgetsWorkspaceManagerClass))
#define WIDGETS_IS_WORKSPACE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIDGETS_TYPE_WORKSPACE_MANAGER))
#define WIDGETS_IS_WORKSPACE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIDGETS_TYPE_WORKSPACE_MANAGER))
#define WIDGETS_WORKSPACE_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIDGETS_TYPE_WORKSPACE_MANAGER, WidgetsWorkspaceManagerClass))

typedef struct _WidgetsWorkspaceManager WidgetsWorkspaceManager;
typedef struct _WidgetsWorkspaceManagerClass WidgetsWorkspaceManagerClass;
typedef struct _ConfigConfigPrivate ConfigConfigPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _WidgetsGrip {
	GtkEventBox parent_instance;
	WidgetsGripPrivate * priv;
	cairo_surface_t* resize_grip_surface;
	gint surface_y;
};

struct _WidgetsGripClass {
	GtkEventBoxClass parent_class;
};

struct _WidgetsResizeGrip {
	GtkOverlay parent_instance;
	WidgetsResizeGripPrivate * priv;
	WidgetsWindowEventArea* event_area;
	WidgetsWindow* window;
	WidgetsGrip* grip;
};

struct _WidgetsResizeGripClass {
	GtkOverlayClass parent_class;
};

struct _Block37Data {
	int _ref_count_;
	WidgetsResizeGrip* self;
	GdkRGBA background_color;
};

struct _WidgetsConfigWindow {
	GtkWindow parent_instance;
	WidgetsConfigWindowPrivate * priv;
	ConfigConfig* config;
	GdkRGBA title_line_dark_color;
	GdkRGBA title_line_light_color;
	GdkScreen* screen_monitor;
	GtkBox* box;
	GtkBox* top_box;
	GtkBox* window_frame_box;
	GtkBox* window_widget_box;
	WidgetsWorkspaceManager* workspace_manager;
	gboolean quake_mode;
	gboolean show_quake_menu;
	gboolean* config_theme_is_light;
	gint active_tab_underline_width;
	gint active_tab_underline_x;
	gint cache_height;
	gint cache_width;
	gint reset_timeout_delay;
	gint resize_cache_x;
	gint resize_cache_y;
	gint resize_cache_width;
	gint resize_cache_height;
	gint resize_timeout_delay;
	guint* reset_timeout_source_id;
	guint* resize_timeout_source_id;
};

struct _WidgetsConfigWindowClass {
	GtkWindowClass parent_class;
	void (*toggle_fullscreen) (WidgetsConfigWindow* self);
	void (*window_save_before_quit) (WidgetsConfigWindow* self);
	GdkCursorType* (*get_frame_cursor_type) (WidgetsConfigWindow* self, gdouble x, gdouble y);
	void (*update_frame) (WidgetsConfigWindow* self);
	GdkCursorType* (*get_cursor_type) (WidgetsConfigWindow* self, gdouble x, gdouble y);
};

struct _ConfigConfig {
	GObject parent_instance;
	ConfigConfigPrivate * priv;
	GeeArrayList* backspace_key_erase_names;
	GeeArrayList* del_key_erase_names;
	GeeArrayList* encoding_names;
	GeeHashMap* erase_map;
	gdouble default_opacity;
	gint default_size;
	gchar* default_mono_font;
	GKeyFile* config_file;
	gchar* config_file_path;
	gchar* temp_theme;
};

struct _ConfigConfigClass {
	GObjectClass parent_class;
};

VALA_EXTERN gint widgets_GRIP_WIDTH;
gint widgets_GRIP_WIDTH = 8;
VALA_EXTERN gint widgets_GRIP_HEIGHT;
gint widgets_GRIP_HEIGHT = 8;
static gpointer widgets_grip_parent_class = NULL;
static gpointer widgets_resize_grip_parent_class = NULL;
VALA_EXTERN gint constant_CLOSE_BUTTON_WIDTH;

VALA_EXTERN GType widgets_grip_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WidgetsGrip, g_object_unref)
VALA_EXTERN WidgetsGrip* widgets_grip_new (void);
VALA_EXTERN WidgetsGrip* widgets_grip_construct (GType object_type);
VALA_EXTERN cairo_surface_t* utils_create_image_surface (const gchar* surface_path);
static gboolean widgets_grip_on_draw (WidgetsGrip* self,
                               GtkWidget* widget,
                               cairo_t* cr);
static gboolean _widgets_grip_on_draw_gtk_widget_draw (GtkWidget* _sender,
                                                cairo_t* cr,
                                                gpointer self);
static gboolean __lambda61_ (WidgetsGrip* self,
                      GtkWidget* w,
                      GdkEventCrossing* e);
static gboolean ___lambda61__gtk_widget_enter_notify_event (GtkWidget* _sender,
                                                     GdkEventCrossing* event,
                                                     gpointer self);
static gboolean __lambda62_ (WidgetsGrip* self,
                      GtkWidget* w,
                      GdkEventCrossing* e);
static gboolean ___lambda62__gtk_widget_leave_notify_event (GtkWidget* _sender,
                                                     GdkEventCrossing* event,
                                                     gpointer self);
static gboolean __lambda63_ (WidgetsGrip* self,
                      GtkWidget* w,
                      GdkEventButton* e);
static gboolean ___lambda63__gtk_widget_button_press_event (GtkWidget* _sender,
                                                     GdkEventButton* event,
                                                     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_grip_finalize (GObject * obj);
static GType widgets_grip_get_type_once (void);
VALA_EXTERN GType widgets_resize_grip_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WidgetsResizeGrip, g_object_unref)
VALA_EXTERN GType widgets_window_event_area_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WidgetsWindowEventArea, g_object_unref)
VALA_EXTERN GType widgets_config_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WidgetsConfigWindow, g_object_unref)
VALA_EXTERN GType widgets_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WidgetsWindow, g_object_unref)
VALA_EXTERN WidgetsResizeGrip* widgets_resize_grip_new (WidgetsWindow* win);
VALA_EXTERN WidgetsResizeGrip* widgets_resize_grip_construct (GType object_type,
                                                  WidgetsWindow* win);
static Block37Data* block37_data_ref (Block37Data* _data37_);
static void block37_data_unref (void * _userdata_);
VALA_EXTERN WidgetsWindowEventArea* widgets_window_event_area_new (GtkContainer* area);
VALA_EXTERN WidgetsWindowEventArea* widgets_window_event_area_construct (GType object_type,
                                                             GtkContainer* area);
static gboolean __lambda64_ (Block37Data* _data37_,
                      GtkWidget* w,
                      cairo_t* cr);
VALA_EXTERN GType config_config_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConfigConfig, g_object_unref)
VALA_EXTERN GType widgets_workspace_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WidgetsWorkspaceManager, g_object_unref)
VALA_EXTERN void utils_hex_to_rgba (const gchar* hex_color,
                        gdouble alpha,
                        GdkRGBA* result);
VALA_EXTERN void draw_draw_rectangle (cairo_t* cr,
                          gint x,
                          gint y,
                          gint w,
                          gint h,
                          gboolean fill);
VALA_EXTERN void utils_propagate_draw (GtkContainer* widget,
                           cairo_t* cr);
static gboolean ___lambda64__gtk_widget_draw (GtkWidget* _sender,
                                       cairo_t* cr,
                                       gpointer self);
static void widgets_resize_grip_finalize (GObject * obj);
static GType widgets_resize_grip_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static gboolean
_widgets_grip_on_draw_gtk_widget_draw (GtkWidget* _sender,
                                       cairo_t* cr,
                                       gpointer self)
{
	gboolean result;
	result = widgets_grip_on_draw ((WidgetsGrip*) self, _sender, cr);
	return result;
}

static gboolean
__lambda61_ (WidgetsGrip* self,
             GtkWidget* w,
             GdkEventCrossing* e)
{
	GdkWindow* _tmp0_;
	GdkDisplay* _tmp1_;
	GdkCursor* _tmp2_;
	GdkCursor* _tmp3_;
	gboolean result;
	g_return_val_if_fail (w != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	_tmp0_ = gtk_widget_get_window ((GtkWidget*) self);
	_tmp1_ = gdk_display_get_default ();
	_tmp2_ = gdk_cursor_new_for_display (_tmp1_, GDK_BOTTOM_RIGHT_CORNER);
	_tmp3_ = _tmp2_;
	gdk_window_set_cursor (_tmp0_, _tmp3_);
	_g_object_unref0 (_tmp3_);
	result = FALSE;
	return result;
}

static gboolean
___lambda61__gtk_widget_enter_notify_event (GtkWidget* _sender,
                                            GdkEventCrossing* event,
                                            gpointer self)
{
	gboolean result;
	result = __lambda61_ ((WidgetsGrip*) self, _sender, event);
	return result;
}

static gboolean
__lambda62_ (WidgetsGrip* self,
             GtkWidget* w,
             GdkEventCrossing* e)
{
	GdkWindow* _tmp0_;
	gboolean result;
	g_return_val_if_fail (w != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	_tmp0_ = gtk_widget_get_window ((GtkWidget*) self);
	gdk_window_set_cursor (_tmp0_, NULL);
	result = FALSE;
	return result;
}

static gboolean
___lambda62__gtk_widget_leave_notify_event (GtkWidget* _sender,
                                            GdkEventCrossing* event,
                                            gpointer self)
{
	gboolean result;
	result = __lambda62_ ((WidgetsGrip*) self, _sender, event);
	return result;
}

static gboolean
__lambda63_ (WidgetsGrip* self,
             GtkWidget* w,
             GdkEventButton* e)
{
	GdkWindow* _tmp0_;
	gboolean result;
	g_return_val_if_fail (w != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	_tmp0_ = gtk_widget_get_window ((GtkWidget*) self);
	gdk_window_begin_resize_drag (_tmp0_, GDK_WINDOW_EDGE_SOUTH_EAST, (gint) e->button, (gint) e->x_root, (gint) e->y_root, gdk_event_get_time ((GdkEvent*) e));
	result = FALSE;
	return result;
}

static gboolean
___lambda63__gtk_widget_button_press_event (GtkWidget* _sender,
                                            GdkEventButton* event,
                                            gpointer self)
{
	gboolean result;
	result = __lambda63_ ((WidgetsGrip*) self, _sender, event);
	return result;
}

WidgetsGrip*
widgets_grip_construct (GType object_type)
{
	WidgetsGrip * self = NULL;
	cairo_surface_t* _tmp0_;
	cairo_surface_t* _tmp1_;
	self = (WidgetsGrip*) g_object_new (object_type, NULL);
	_tmp0_ = utils_create_image_surface ("resize_grip.svg");
	_cairo_surface_destroy0 (self->resize_grip_surface);
	self->resize_grip_surface = _tmp0_;
	gtk_widget_set_size_request ((GtkWidget*) self, widgets_GRIP_WIDTH, widgets_GRIP_HEIGHT);
	_tmp1_ = self->resize_grip_surface;
	self->surface_y = (widgets_GRIP_HEIGHT - (cairo_image_surface_get_height (_tmp1_) / gtk_widget_get_scale_factor ((GtkWidget*) self))) / 2;
	g_signal_connect_object ((GtkWidget*) self, "draw", (GCallback) _widgets_grip_on_draw_gtk_widget_draw, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "enter-notify-event", (GCallback) ___lambda61__gtk_widget_enter_notify_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "leave-notify-event", (GCallback) ___lambda62__gtk_widget_leave_notify_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "button-press-event", (GCallback) ___lambda63__gtk_widget_button_press_event, self, 0);
	return self;
}

WidgetsGrip*
widgets_grip_new (void)
{
	return widgets_grip_construct (WIDGETS_TYPE_GRIP);
}

static gboolean
widgets_grip_on_draw (WidgetsGrip* self,
                      GtkWidget* widget,
                      cairo_t* cr)
{
	cairo_surface_t* _tmp0_;
	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_ = self->resize_grip_surface;
	draw_draw_surface (cr, _tmp0_, 0, self->surface_y, 0, 0);
	result = TRUE;
	return result;
}

static void
widgets_grip_class_init (WidgetsGripClass * klass,
                         gpointer klass_data)
{
	widgets_grip_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = widgets_grip_finalize;
	widgets_grip_signals[WIDGETS_GRIP_CLICKED_SIGNAL] = g_signal_new ("clicked", WIDGETS_TYPE_GRIP, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__BOXED, G_TYPE_NONE, 1, gdk_event_get_type ());
}

static void
widgets_grip_instance_init (WidgetsGrip * self,
                            gpointer klass)
{
}

static void
widgets_grip_finalize (GObject * obj)
{
	WidgetsGrip * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIDGETS_TYPE_GRIP, WidgetsGrip);
	_cairo_surface_destroy0 (self->resize_grip_surface);
	G_OBJECT_CLASS (widgets_grip_parent_class)->finalize (obj);
}

static GType
widgets_grip_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (WidgetsGripClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) widgets_grip_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WidgetsGrip), 0, (GInstanceInitFunc) widgets_grip_instance_init, NULL };
	GType widgets_grip_type_id;
	widgets_grip_type_id = g_type_register_static (gtk_event_box_get_type (), "WidgetsGrip", &g_define_type_info, 0);
	return widgets_grip_type_id;
}

GType
widgets_grip_get_type (void)
{
	static volatile gsize widgets_grip_type_id__once = 0;
	if (g_once_init_enter (&widgets_grip_type_id__once)) {
		GType widgets_grip_type_id;
		widgets_grip_type_id = widgets_grip_get_type_once ();
		g_once_init_leave (&widgets_grip_type_id__once, widgets_grip_type_id);
	}
	return widgets_grip_type_id__once;
}

static Block37Data*
block37_data_ref (Block37Data* _data37_)
{
	g_atomic_int_inc (&_data37_->_ref_count_);
	return _data37_;
}

static void
block37_data_unref (void * _userdata_)
{
	Block37Data* _data37_;
	_data37_ = (Block37Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data37_->_ref_count_)) {
		WidgetsResizeGrip* self;
		self = _data37_->self;
		_g_object_unref0 (self);
		g_slice_free (Block37Data, _data37_);
	}
}

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

static gboolean
__lambda64_ (Block37Data* _data37_,
             GtkWidget* w,
             cairo_t* cr)
{
	WidgetsResizeGrip* self;
	GtkAllocation rect = {0};
	GtkAllocation _tmp0_ = {0};
	GError* _inner_error0_ = NULL;
	gboolean result;
	self = _data37_->self;
	g_return_val_if_fail (w != NULL, FALSE);
	g_return_val_if_fail (cr != NULL, FALSE);
	gtk_widget_get_allocation (w, &_tmp0_);
	rect = _tmp0_;
	{
		gchar* _tmp1_ = NULL;
		WidgetsWindow* _tmp2_;
		ConfigConfig* _tmp3_;
		GKeyFile* _tmp4_;
		gchar* _tmp5_;
		GdkRGBA _tmp6_ = {0};
		gdouble _tmp7_ = 0.0;
		WidgetsWindow* _tmp8_;
		ConfigConfig* _tmp9_;
		GKeyFile* _tmp10_;
		GdkRGBA _tmp11_;
		GdkRGBA _tmp12_;
		GdkRGBA _tmp13_;
		GtkAllocation _tmp14_;
		GtkAllocation _tmp15_;
		_tmp2_ = self->window;
		_tmp3_ = ((WidgetsConfigWindow*) _tmp2_)->config;
		_tmp4_ = _tmp3_->config_file;
		_tmp5_ = g_key_file_get_string (_tmp4_, "theme", "background", &_inner_error0_);
		_tmp1_ = _tmp5_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		utils_hex_to_rgba (_tmp1_, 1.0, &_tmp6_);
		_data37_->background_color = _tmp6_;
		_tmp8_ = self->window;
		_tmp9_ = ((WidgetsConfigWindow*) _tmp8_)->config;
		_tmp10_ = _tmp9_->config_file;
		_tmp7_ = g_key_file_get_double (_tmp10_, "general", "opacity", &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_free0 (_tmp1_);
			goto __catch0_g_error;
		}
		_tmp11_ = _data37_->background_color;
		_tmp12_ = _data37_->background_color;
		_tmp13_ = _data37_->background_color;
		cairo_set_source_rgba (cr, _tmp11_.red, _tmp12_.green, _tmp13_.blue, _tmp7_);
		_tmp14_ = rect;
		_tmp15_ = rect;
		draw_draw_rectangle (cr, 0, 0, _tmp14_.width, _tmp15_.height, TRUE);
		_g_free0 (_tmp1_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp16_;
		const gchar* _tmp17_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp16_ = e;
		_tmp17_ = _tmp16_->message;
		g_print ("ResizeGrip draw: %s\n", _tmp17_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp18_ = FALSE;
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return _tmp18_;
	}
	utils_propagate_draw (G_TYPE_CHECK_INSTANCE_CAST (w, gtk_container_get_type (), GtkContainer), cr);
	result = TRUE;
	return result;
}

static gboolean
___lambda64__gtk_widget_draw (GtkWidget* _sender,
                              cairo_t* cr,
                              gpointer self)
{
	gboolean result;
	result = __lambda64_ (self, _sender, cr);
	return result;
}

WidgetsResizeGrip*
widgets_resize_grip_construct (GType object_type,
                               WidgetsWindow* win)
{
	WidgetsResizeGrip * self = NULL;
	Block37Data* _data37_;
	WidgetsWindow* _tmp0_;
	WidgetsGrip* _tmp1_;
	WidgetsGrip* _tmp2_;
	GtkBox* box = NULL;
	GtkBox* _tmp3_;
	WidgetsGrip* _tmp4_;
	WidgetsWindowEventArea* _tmp5_;
	WidgetsWindowEventArea* _tmp6_;
	WidgetsWindowEventArea* _tmp7_;
	g_return_val_if_fail (win != NULL, NULL);
	_data37_ = g_slice_new0 (Block37Data);
	_data37_->_ref_count_ = 1;
	self = (WidgetsResizeGrip*) g_object_new (object_type, NULL);
	_data37_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (win);
	_g_object_unref0 (self->window);
	self->window = _tmp0_;
	_tmp1_ = widgets_grip_new ();
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->grip);
	self->grip = _tmp1_;
	_tmp2_ = self->grip;
	gtk_widget_set_halign ((GtkWidget*) _tmp2_, GTK_ALIGN_END);
	_tmp3_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	g_object_ref_sink (_tmp3_);
	box = _tmp3_;
	_tmp4_ = self->grip;
	gtk_box_pack_start (box, (GtkWidget*) _tmp4_, TRUE, TRUE, (guint) 0);
	_tmp5_ = widgets_window_event_area_new ((GtkContainer*) self);
	g_object_ref_sink (_tmp5_);
	_g_object_unref0 (self->event_area);
	self->event_area = _tmp5_;
	_tmp6_ = self->event_area;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp6_, constant_CLOSE_BUTTON_WIDTH);
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) box);
	_tmp7_ = self->event_area;
	gtk_overlay_add_overlay ((GtkOverlay*) self, (GtkWidget*) _tmp7_);
	gtk_widget_set_size_request ((GtkWidget*) self, -1, widgets_GRIP_HEIGHT);
	memset (&_data37_->background_color, 0, sizeof (GdkRGBA));
	g_signal_connect_data ((GtkWidget*) box, "draw", (GCallback) ___lambda64__gtk_widget_draw, block37_data_ref (_data37_), (GClosureNotify) block37_data_unref, 0);
	_g_object_unref0 (box);
	block37_data_unref (_data37_);
	_data37_ = NULL;
	return self;
}

WidgetsResizeGrip*
widgets_resize_grip_new (WidgetsWindow* win)
{
	return widgets_resize_grip_construct (WIDGETS_TYPE_RESIZE_GRIP, win);
}

static void
widgets_resize_grip_class_init (WidgetsResizeGripClass * klass,
                                gpointer klass_data)
{
	widgets_resize_grip_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = widgets_resize_grip_finalize;
}

static void
widgets_resize_grip_instance_init (WidgetsResizeGrip * self,
                                   gpointer klass)
{
}

static void
widgets_resize_grip_finalize (GObject * obj)
{
	WidgetsResizeGrip * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIDGETS_TYPE_RESIZE_GRIP, WidgetsResizeGrip);
	_g_object_unref0 (self->event_area);
	_g_object_unref0 (self->window);
	_g_object_unref0 (self->grip);
	G_OBJECT_CLASS (widgets_resize_grip_parent_class)->finalize (obj);
}

static GType
widgets_resize_grip_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (WidgetsResizeGripClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) widgets_resize_grip_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WidgetsResizeGrip), 0, (GInstanceInitFunc) widgets_resize_grip_instance_init, NULL };
	GType widgets_resize_grip_type_id;
	widgets_resize_grip_type_id = g_type_register_static (gtk_overlay_get_type (), "WidgetsResizeGrip", &g_define_type_info, 0);
	return widgets_resize_grip_type_id;
}

GType
widgets_resize_grip_get_type (void)
{
	static volatile gsize widgets_resize_grip_type_id__once = 0;
	if (g_once_init_enter (&widgets_resize_grip_type_id__once)) {
		GType widgets_resize_grip_type_id;
		widgets_resize_grip_type_id = widgets_resize_grip_get_type_once ();
		g_once_init_leave (&widgets_resize_grip_type_id__once, widgets_resize_grip_type_id);
	}
	return widgets_resize_grip_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;
}

