/* titlebar.c generated by valac 0.56.17, the Vala compiler
 * generated from titlebar.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 <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_TITLEBAR (widgets_titlebar_get_type ())
#define WIDGETS_TITLEBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIDGETS_TYPE_TITLEBAR, WidgetsTitlebar))
#define WIDGETS_TITLEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIDGETS_TYPE_TITLEBAR, WidgetsTitlebarClass))
#define WIDGETS_IS_TITLEBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIDGETS_TYPE_TITLEBAR))
#define WIDGETS_IS_TITLEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIDGETS_TYPE_TITLEBAR))
#define WIDGETS_TITLEBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIDGETS_TYPE_TITLEBAR, WidgetsTitlebarClass))

typedef struct _WidgetsTitlebar WidgetsTitlebar;
typedef struct _WidgetsTitlebarClass WidgetsTitlebarClass;
typedef struct _WidgetsTitlebarPrivate WidgetsTitlebarPrivate;

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

#define WIDGETS_TYPE_WINDOW_BUTTON (widgets_window_button_get_type ())
#define WIDGETS_WINDOW_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIDGETS_TYPE_WINDOW_BUTTON, WidgetsWindowButton))
#define WIDGETS_WINDOW_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIDGETS_TYPE_WINDOW_BUTTON, WidgetsWindowButtonClass))
#define WIDGETS_IS_WINDOW_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIDGETS_TYPE_WINDOW_BUTTON))
#define WIDGETS_IS_WINDOW_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIDGETS_TYPE_WINDOW_BUTTON))
#define WIDGETS_WINDOW_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIDGETS_TYPE_WINDOW_BUTTON, WidgetsWindowButtonClass))

typedef struct _WidgetsWindowButton WidgetsWindowButton;
typedef struct _WidgetsWindowButtonClass WidgetsWindowButtonClass;
enum  {
	WIDGETS_TITLEBAR_0_PROPERTY,
	WIDGETS_TITLEBAR_NUM_PROPERTIES
};
static GParamSpec* widgets_titlebar_properties[WIDGETS_TITLEBAR_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _WidgetsTitlebar {
	GtkOverlay parent_instance;
	WidgetsTitlebarPrivate * priv;
	WidgetsWindowEventArea* event_area;
	WidgetsWindowButton* close_button;
};

struct _WidgetsTitlebarClass {
	GtkOverlayClass parent_class;
};

static gpointer widgets_titlebar_parent_class = NULL;
VALA_EXTERN gint constant_CLOSE_BUTTON_WIDTH;
VALA_EXTERN gint constant_TITLEBAR_HEIGHT;

VALA_EXTERN GType widgets_titlebar_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WidgetsTitlebar, 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_click_event_box_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WidgetsClickEventBox, g_object_unref)
VALA_EXTERN GType widgets_window_button_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WidgetsWindowButton, g_object_unref)
VALA_EXTERN WidgetsTitlebar* widgets_titlebar_new (void);
VALA_EXTERN WidgetsTitlebar* widgets_titlebar_construct (GType object_type);
VALA_EXTERN WidgetsWindowButton* widgets_create_close_button (void);
VALA_EXTERN WidgetsWindowEventArea* widgets_window_event_area_new (GtkContainer* area);
VALA_EXTERN WidgetsWindowEventArea* widgets_window_event_area_construct (GType object_type,
                                                             GtkContainer* area);
static void widgets_titlebar_finalize (GObject * obj);
static GType widgets_titlebar_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

WidgetsTitlebar*
widgets_titlebar_construct (GType object_type)
{
	WidgetsTitlebar * self = NULL;
	WidgetsWindowButton* _tmp0_;
	GtkBox* box = NULL;
	GtkBox* _tmp1_;
	WidgetsWindowButton* _tmp2_;
	WidgetsWindowEventArea* _tmp3_;
	WidgetsWindowEventArea* _tmp4_;
	WidgetsWindowEventArea* _tmp5_;
	self = (WidgetsTitlebar*) g_object_new (object_type, NULL);
	_tmp0_ = widgets_create_close_button ();
	_g_object_unref0 (self->close_button);
	self->close_button = _tmp0_;
	_tmp1_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	g_object_ref_sink (_tmp1_);
	box = _tmp1_;
	_tmp2_ = self->close_button;
	gtk_box_pack_start (box, (GtkWidget*) _tmp2_, TRUE, TRUE, (guint) 0);
	_tmp3_ = widgets_window_event_area_new ((GtkContainer*) self);
	g_object_ref_sink (_tmp3_);
	_g_object_unref0 (self->event_area);
	self->event_area = _tmp3_;
	_tmp4_ = self->event_area;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp4_, constant_CLOSE_BUTTON_WIDTH);
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) box);
	_tmp5_ = self->event_area;
	gtk_overlay_add_overlay ((GtkOverlay*) self, (GtkWidget*) _tmp5_);
	gtk_widget_set_size_request ((GtkWidget*) self, -1, constant_TITLEBAR_HEIGHT);
	_g_object_unref0 (box);
	return self;
}

WidgetsTitlebar*
widgets_titlebar_new (void)
{
	return widgets_titlebar_construct (WIDGETS_TYPE_TITLEBAR);
}

static void
widgets_titlebar_class_init (WidgetsTitlebarClass * klass,
                             gpointer klass_data)
{
	widgets_titlebar_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = widgets_titlebar_finalize;
}

static void
widgets_titlebar_instance_init (WidgetsTitlebar * self,
                                gpointer klass)
{
}

static void
widgets_titlebar_finalize (GObject * obj)
{
	WidgetsTitlebar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIDGETS_TYPE_TITLEBAR, WidgetsTitlebar);
	_g_object_unref0 (self->event_area);
	_g_object_unref0 (self->close_button);
	G_OBJECT_CLASS (widgets_titlebar_parent_class)->finalize (obj);
}

static GType
widgets_titlebar_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (WidgetsTitlebarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) widgets_titlebar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WidgetsTitlebar), 0, (GInstanceInitFunc) widgets_titlebar_instance_init, NULL };
	GType widgets_titlebar_type_id;
	widgets_titlebar_type_id = g_type_register_static (gtk_overlay_get_type (), "WidgetsTitlebar", &g_define_type_info, 0);
	return widgets_titlebar_type_id;
}

GType
widgets_titlebar_get_type (void)
{
	static volatile gsize widgets_titlebar_type_id__once = 0;
	if (g_once_init_enter (&widgets_titlebar_type_id__once)) {
		GType widgets_titlebar_type_id;
		widgets_titlebar_type_id = widgets_titlebar_get_type_once ();
		g_once_init_leave (&widgets_titlebar_type_id__once, widgets_titlebar_type_id);
	}
	return widgets_titlebar_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;
}

