/* click_event_box.c generated by valac 0.56.17, the Vala compiler
 * generated from click_event_box.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 <gdk/gdk.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;
enum  {
	WIDGETS_CLICK_EVENT_BOX_0_PROPERTY,
	WIDGETS_CLICK_EVENT_BOX_NUM_PROPERTIES
};
static GParamSpec* widgets_click_event_box_properties[WIDGETS_CLICK_EVENT_BOX_NUM_PROPERTIES];
enum  {
	WIDGETS_CLICK_EVENT_BOX_CLICKED_SIGNAL,
	WIDGETS_CLICK_EVENT_BOX_NUM_SIGNALS
};
static guint widgets_click_event_box_signals[WIDGETS_CLICK_EVENT_BOX_NUM_SIGNALS] = {0};

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

struct _WidgetsClickEventBoxClass {
	GtkEventBoxClass parent_class;
};

static gpointer widgets_click_event_box_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 WidgetsClickEventBox* widgets_click_event_box_new (void);
VALA_EXTERN WidgetsClickEventBox* widgets_click_event_box_construct (GType object_type);
static gboolean __lambda12_ (WidgetsClickEventBox* self,
                      GtkWidget* w,
                      GdkEventButton* e);
static gboolean ___lambda12__gtk_widget_button_press_event (GtkWidget* _sender,
                                                     GdkEventButton* event,
                                                     gpointer self);
static gboolean __lambda13_ (WidgetsClickEventBox* self,
                      GtkWidget* w,
                      GdkEventButton* e);
VALA_EXTERN gboolean utils_is_left_button (GdkEventButton* event);
VALA_EXTERN gboolean utils_pointer_in_widget_area (GtkWidget* widget);
static gboolean ___lambda13__gtk_widget_button_release_event (GtkWidget* _sender,
                                                       GdkEventButton* event,
                                                       gpointer self);
static void widgets_click_event_box_finalize (GObject * obj);
static GType widgets_click_event_box_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static gboolean
__lambda12_ (WidgetsClickEventBox* 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_press = TRUE;
	result = FALSE;
	return result;
}

static gboolean
___lambda12__gtk_widget_button_press_event (GtkWidget* _sender,
                                            GdkEventButton* event,
                                            gpointer self)
{
	gboolean result;
	result = __lambda12_ ((WidgetsClickEventBox*) self, _sender, event);
	return result;
}

static gboolean
__lambda13_ (WidgetsClickEventBox* self,
             GtkWidget* w,
             GdkEventButton* e)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean result;
	g_return_val_if_fail (w != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	if (self->is_press) {
		_tmp1_ = utils_is_left_button (e);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		_tmp0_ = utils_pointer_in_widget_area ((GtkWidget*) self);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		g_signal_emit (self, widgets_click_event_box_signals[WIDGETS_CLICK_EVENT_BOX_CLICKED_SIGNAL], 0, e);
	}
	self->is_press = FALSE;
	result = FALSE;
	return result;
}

static gboolean
___lambda13__gtk_widget_button_release_event (GtkWidget* _sender,
                                              GdkEventButton* event,
                                              gpointer self)
{
	gboolean result;
	result = __lambda13_ ((WidgetsClickEventBox*) self, _sender, event);
	return result;
}

WidgetsClickEventBox*
widgets_click_event_box_construct (GType object_type)
{
	WidgetsClickEventBox * self = NULL;
	self = (WidgetsClickEventBox*) g_object_new (object_type, NULL);
	g_signal_connect_object ((GtkWidget*) self, "button-press-event", (GCallback) ___lambda12__gtk_widget_button_press_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "button-release-event", (GCallback) ___lambda13__gtk_widget_button_release_event, self, 0);
	return self;
}

WidgetsClickEventBox*
widgets_click_event_box_new (void)
{
	return widgets_click_event_box_construct (WIDGETS_TYPE_CLICK_EVENT_BOX);
}

static void
widgets_click_event_box_class_init (WidgetsClickEventBoxClass * klass,
                                    gpointer klass_data)
{
	widgets_click_event_box_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = widgets_click_event_box_finalize;
	widgets_click_event_box_signals[WIDGETS_CLICK_EVENT_BOX_CLICKED_SIGNAL] = g_signal_new ("clicked", WIDGETS_TYPE_CLICK_EVENT_BOX, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__BOXED, G_TYPE_NONE, 1, gdk_event_get_type ());
}

static void
widgets_click_event_box_instance_init (WidgetsClickEventBox * self,
                                       gpointer klass)
{
	self->is_press = FALSE;
}

static void
widgets_click_event_box_finalize (GObject * obj)
{
	WidgetsClickEventBox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIDGETS_TYPE_CLICK_EVENT_BOX, WidgetsClickEventBox);
	G_OBJECT_CLASS (widgets_click_event_box_parent_class)->finalize (obj);
}

static GType
widgets_click_event_box_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (WidgetsClickEventBoxClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) widgets_click_event_box_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WidgetsClickEventBox), 0, (GInstanceInitFunc) widgets_click_event_box_instance_init, NULL };
	GType widgets_click_event_box_type_id;
	widgets_click_event_box_type_id = g_type_register_static (gtk_event_box_get_type (), "WidgetsClickEventBox", &g_define_type_info, 0);
	return widgets_click_event_box_type_id;
}

GType
widgets_click_event_box_get_type (void)
{
	static volatile gsize widgets_click_event_box_type_id__once = 0;
	if (g_once_init_enter (&widgets_click_event_box_type_id__once)) {
		GType widgets_click_event_box_type_id;
		widgets_click_event_box_type_id = widgets_click_event_box_get_type_once ();
		g_once_init_leave (&widgets_click_event_box_type_id__once, widgets_click_event_box_type_id);
	}
	return widgets_click_event_box_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;
}

