/* dialog.c generated by valac 0.56.17, the Vala compiler
 * generated from dialog.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 <cairo-gobject.h>
#include <gdk/gdk.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.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_DIALOG (widgets_dialog_get_type ())
#define WIDGETS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIDGETS_TYPE_DIALOG, WidgetsDialog))
#define WIDGETS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIDGETS_TYPE_DIALOG, WidgetsDialogClass))
#define WIDGETS_IS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIDGETS_TYPE_DIALOG))
#define WIDGETS_IS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIDGETS_TYPE_DIALOG))
#define WIDGETS_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIDGETS_TYPE_DIALOG, WidgetsDialogClass))

typedef struct _WidgetsDialog WidgetsDialog;
typedef struct _WidgetsDialogClass WidgetsDialogClass;
typedef struct _WidgetsDialogPrivate WidgetsDialogPrivate;

#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_DIALOG_0_PROPERTY,
	WIDGETS_DIALOG_NUM_PROPERTIES
};
static GParamSpec* widgets_dialog_properties[WIDGETS_DIALOG_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _cairo_region_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_region_destroy (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _WidgetsDialog {
	GtkWindow parent_instance;
	WidgetsDialogPrivate * priv;
	GdkScreen* screen_monitor;
	GtkBox* window_frame_box;
	GtkBox* window_widget_box;
	WidgetsConfigWindow* transient_window;
	gint option_widget_margin_end;
	gint option_widget_margin_top;
	gint window_frame_margin_bottom;
	gint window_frame_margin_end;
	gint window_frame_margin_start;
	gint window_frame_margin_top;
	gint window_frame_radius;
	gint window_init_height;
	gint window_init_width;
};

struct _WidgetsDialogClass {
	GtkWindowClass parent_class;
	void (*draw_window_above) (WidgetsDialog* self, cairo_t* cr);
};

static gpointer widgets_dialog_parent_class = NULL;

VALA_EXTERN GType widgets_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WidgetsDialog, 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 void widgets_dialog_draw_window_above (WidgetsDialog* self,
                                       cairo_t* cr);
VALA_EXTERN WidgetsDialog* widgets_dialog_new (void);
VALA_EXTERN WidgetsDialog* widgets_dialog_construct (GType object_type);
static void __lambda14_ (WidgetsDialog* self);
VALA_EXTERN void widgets_dialog_update_frame (WidgetsDialog* self);
static void ___lambda14__gdk_screen_composited_changed (GdkScreen* _sender,
                                                 gpointer self);
static gboolean __lambda15_ (WidgetsDialog* self,
                      GdkEventFocus* w);
VALA_EXTERN void widgets_dialog_shadow_active (WidgetsDialog* self);
static gboolean ___lambda15__gtk_widget_focus_in_event (GtkWidget* _sender,
                                                 GdkEventFocus* event,
                                                 gpointer self);
static gboolean __lambda16_ (WidgetsDialog* self,
                      GdkEventFocus* w);
VALA_EXTERN void widgets_dialog_shadow_inactive (WidgetsDialog* self);
static gboolean ___lambda16__gtk_widget_focus_out_event (GtkWidget* _sender,
                                                  GdkEventFocus* event,
                                                  gpointer self);
static gboolean __lambda17_ (WidgetsDialog* self,
                      GdkEventConfigure* w);
static gboolean ___lambda17__gtk_widget_configure_event (GtkWidget* _sender,
                                                  GdkEventConfigure* event,
                                                  gpointer self);
static gboolean __lambda18_ (WidgetsDialog* self,
                      GtkWidget* w,
                      GdkEventWindowState* e);
static gboolean ___lambda18__gtk_widget_window_state_event (GtkWidget* _sender,
                                                     GdkEventWindowState* event,
                                                     gpointer self);
static gboolean __lambda19_ (WidgetsDialog* self,
                      GtkWidget* w,
                      GdkEventKey* e);
VALA_EXTERN gchar* keymap_get_keyevent_name (GdkEventKey* key_event);
static gboolean ___lambda19__gtk_widget_key_press_event (GtkWidget* _sender,
                                                  GdkEventKey* event,
                                                  gpointer self);
static gboolean __lambda20_ (WidgetsDialog* self,
                      GtkWidget* w,
                      cairo_t* cr);
VALA_EXTERN void widgets_dialog_draw_window_below (WidgetsDialog* self,
                                       cairo_t* cr);
VALA_EXTERN void widgets_dialog_draw_window_widgets (WidgetsDialog* self,
                                         cairo_t* cr);
VALA_EXTERN void widgets_dialog_draw_window_frame (WidgetsDialog* self,
                                       cairo_t* cr);
static gboolean ___lambda20__gtk_widget_draw (GtkWidget* _sender,
                                       cairo_t* cr,
                                       gpointer self);
VALA_EXTERN void widgets_dialog_set_init_size (WidgetsDialog* self,
                                   gint width,
                                   gint height);
VALA_EXTERN void widgets_dialog_transient_for_window (WidgetsDialog* self,
                                          WidgetsConfigWindow* window);
VALA_EXTERN void utils_propagate_draw (GtkContainer* widget,
                           cairo_t* cr);
VALA_EXTERN void widgets_dialog_add_widget (WidgetsDialog* self,
                                GtkWidget* widget);
VALA_EXTERN void draw_fill_rounded_rectangle (cairo_t* cr,
                                  gint x,
                                  gint y,
                                  gint width,
                                  gint height,
                                  gdouble r);
VALA_EXTERN void widgets_dialog_grid_attach (WidgetsDialog* self,
                                 GtkGrid* grid,
                                 GtkWidget* child,
                                 gint left,
                                 gint top,
                                 gint width,
                                 gint height);
VALA_EXTERN void widgets_dialog_grid_attach_next_to (WidgetsDialog* self,
                                         GtkGrid* grid,
                                         GtkWidget* child,
                                         GtkWidget* sibling,
                                         GtkPositionType side,
                                         gint width,
                                         gint height);
static void widgets_dialog_real_draw_window_above (WidgetsDialog* self,
                                            cairo_t* cr);
static void widgets_dialog_finalize (GObject * obj);
static GType widgets_dialog_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

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

static void
__lambda14_ (WidgetsDialog* self)
{
	widgets_dialog_update_frame (self);
}

static void
___lambda14__gdk_screen_composited_changed (GdkScreen* _sender,
                                            gpointer self)
{
	__lambda14_ ((WidgetsDialog*) self);
}

static gboolean
__lambda15_ (WidgetsDialog* self,
             GdkEventFocus* w)
{
	gboolean result;
	g_return_val_if_fail (w != NULL, FALSE);
	widgets_dialog_shadow_active (self);
	result = FALSE;
	return result;
}

static gboolean
___lambda15__gtk_widget_focus_in_event (GtkWidget* _sender,
                                        GdkEventFocus* event,
                                        gpointer self)
{
	gboolean result;
	result = __lambda15_ ((WidgetsDialog*) self, event);
	return result;
}

static gboolean
__lambda16_ (WidgetsDialog* self,
             GdkEventFocus* w)
{
	gboolean result;
	g_return_val_if_fail (w != NULL, FALSE);
	widgets_dialog_shadow_inactive (self);
	result = FALSE;
	return result;
}

static gboolean
___lambda16__gtk_widget_focus_out_event (GtkWidget* _sender,
                                         GdkEventFocus* event,
                                         gpointer self)
{
	gboolean result;
	result = __lambda16_ ((WidgetsDialog*) self, event);
	return result;
}

static gboolean
__lambda17_ (WidgetsDialog* self,
             GdkEventConfigure* w)
{
	gint width = 0;
	gint height = 0;
	gint _tmp0_ = 0;
	gint _tmp1_ = 0;
	GdkScreen* _tmp2_;
	gboolean result;
	g_return_val_if_fail (w != NULL, FALSE);
	gtk_window_get_size ((GtkWindow*) self, &_tmp0_, &_tmp1_);
	width = _tmp0_;
	height = _tmp1_;
	_tmp2_ = self->screen_monitor;
	if (gdk_screen_is_composited (_tmp2_)) {
		cairo_rectangle_int_t rect = {0};
		GdkWindow* _tmp3_;
		GdkRectangle _tmp4_ = {0};
		cairo_region_t* shape = NULL;
		cairo_rectangle_int_t _tmp5_;
		cairo_region_t* _tmp6_;
		GdkWindow* _tmp7_;
		cairo_region_t* _tmp8_;
		_tmp3_ = gtk_widget_get_window ((GtkWidget*) self);
		gdk_window_get_frame_extents (_tmp3_, &_tmp4_);
		rect = _tmp4_;
		rect.x = self->window_frame_margin_start;
		rect.y = self->window_frame_margin_top;
		rect.width = (width - self->window_frame_margin_start) - self->window_frame_margin_end;
		rect.height = (height - self->window_frame_margin_top) - self->window_frame_margin_bottom;
		_tmp5_ = rect;
		_tmp6_ = cairo_region_create_rectangle (&_tmp5_);
		shape = _tmp6_;
		_tmp7_ = gtk_widget_get_window ((GtkWidget*) self);
		_tmp8_ = shape;
		gdk_window_input_shape_combine_region (_tmp7_, _tmp8_, 0, 0);
		_cairo_region_destroy0 (shape);
	}
	gtk_widget_queue_draw ((GtkWidget*) self);
	result = FALSE;
	return result;
}

static gboolean
___lambda17__gtk_widget_configure_event (GtkWidget* _sender,
                                         GdkEventConfigure* event,
                                         gpointer self)
{
	gboolean result;
	result = __lambda17_ ((WidgetsDialog*) self, event);
	return result;
}

static gboolean
__lambda18_ (WidgetsDialog* self,
             GtkWidget* w,
             GdkEventWindowState* e)
{
	gboolean result;
	g_return_val_if_fail (w != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	widgets_dialog_update_frame (self);
	result = FALSE;
	return result;
}

static gboolean
___lambda18__gtk_widget_window_state_event (GtkWidget* _sender,
                                            GdkEventWindowState* event,
                                            gpointer self)
{
	gboolean result;
	result = __lambda18_ ((WidgetsDialog*) self, _sender, event);
	return result;
}

static gboolean
__lambda19_ (WidgetsDialog* self,
             GtkWidget* w,
             GdkEventKey* e)
{
	gchar* keyname = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	gboolean result;
	g_return_val_if_fail (w != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	_tmp0_ = keymap_get_keyevent_name (e);
	keyname = _tmp0_;
	_tmp1_ = keyname;
	if (g_strcmp0 (_tmp1_, "Esc") == 0) {
		gtk_widget_destroy ((GtkWidget*) self);
	}
	result = FALSE;
	_g_free0 (keyname);
	return result;
}

static gboolean
___lambda19__gtk_widget_key_press_event (GtkWidget* _sender,
                                         GdkEventKey* event,
                                         gpointer self)
{
	gboolean result;
	result = __lambda19_ ((WidgetsDialog*) self, _sender, event);
	return result;
}

static gboolean
__lambda20_ (WidgetsDialog* self,
             GtkWidget* w,
             cairo_t* cr)
{
	gboolean result;
	g_return_val_if_fail (w != NULL, FALSE);
	g_return_val_if_fail (cr != NULL, FALSE);
	widgets_dialog_draw_window_below (self, cr);
	widgets_dialog_draw_window_widgets (self, cr);
	widgets_dialog_draw_window_frame (self, cr);
	widgets_dialog_draw_window_above (self, cr);
	result = TRUE;
	return result;
}

static gboolean
___lambda20__gtk_widget_draw (GtkWidget* _sender,
                              cairo_t* cr,
                              gpointer self)
{
	gboolean result;
	result = __lambda20_ ((WidgetsDialog*) self, _sender, cr);
	return result;
}

WidgetsDialog*
widgets_dialog_construct (GType object_type)
{
	WidgetsDialog * self = NULL;
	GdkScreen* _tmp0_;
	GdkScreen* _tmp1_;
	GdkScreen* _tmp2_;
	GdkScreen* _tmp3_;
	GdkVisual* _tmp4_;
	GtkBox* _tmp5_;
	GtkBox* _tmp6_;
	GtkBox* _tmp7_;
	GtkBox* _tmp8_;
	GtkBox* _tmp9_;
	GdkScreen* _tmp10_;
	self = (WidgetsDialog*) g_object_new (object_type, NULL);
	gtk_widget_set_app_paintable ((GtkWidget*) self, TRUE);
	_tmp0_ = gdk_screen_get_default ();
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->screen_monitor);
	self->screen_monitor = _tmp1_;
	_tmp2_ = gtk_window_get_screen ((GtkWindow*) self);
	_tmp3_ = _tmp2_;
	_tmp4_ = gdk_screen_get_rgba_visual (_tmp3_);
	gtk_widget_set_visual ((GtkWidget*) self, _tmp4_);
	gtk_window_set_skip_taskbar_hint ((GtkWindow*) self, TRUE);
	gtk_window_set_skip_pager_hint ((GtkWindow*) self, TRUE);
	gtk_window_set_modal ((GtkWindow*) self, TRUE);
	gtk_window_set_resizable ((GtkWindow*) self, FALSE);
	gtk_window_set_type_hint ((GtkWindow*) self, GDK_WINDOW_TYPE_HINT_DIALOG);
	gtk_window_set_decorated ((GtkWindow*) self, FALSE);
	_tmp5_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp5_);
	_g_object_unref0 (self->window_frame_box);
	self->window_frame_box = _tmp5_;
	_tmp6_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp6_);
	_g_object_unref0 (self->window_widget_box);
	self->window_widget_box = _tmp6_;
	_tmp7_ = self->window_frame_box;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp7_);
	_tmp8_ = self->window_frame_box;
	_tmp9_ = self->window_widget_box;
	gtk_box_pack_start (_tmp8_, (GtkWidget*) _tmp9_, TRUE, TRUE, (guint) 0);
	_tmp10_ = self->screen_monitor;
	g_signal_connect_object (_tmp10_, "composited-changed", (GCallback) ___lambda14__gdk_screen_composited_changed, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "focus-in-event", (GCallback) ___lambda15__gtk_widget_focus_in_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "focus-out-event", (GCallback) ___lambda16__gtk_widget_focus_out_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "configure-event", (GCallback) ___lambda17__gtk_widget_configure_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "window-state-event", (GCallback) ___lambda18__gtk_widget_window_state_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "key-press-event", (GCallback) ___lambda19__gtk_widget_key_press_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "draw", (GCallback) ___lambda20__gtk_widget_draw, self, G_CONNECT_AFTER);
	return self;
}

WidgetsDialog*
widgets_dialog_new (void)
{
	return widgets_dialog_construct (WIDGETS_TYPE_DIALOG);
}

void
widgets_dialog_set_init_size (WidgetsDialog* self,
                              gint width,
                              gint height)
{
	GdkScreen* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->screen_monitor;
	if (!gdk_screen_is_composited (_tmp0_)) {
		self->window_init_width = (width - self->window_frame_margin_start) - self->window_frame_margin_end;
		self->window_init_height = (height - self->window_frame_margin_top) - self->window_frame_margin_bottom;
	} else {
		self->window_init_width = width;
		self->window_init_height = height;
	}
}

void
widgets_dialog_transient_for_window (WidgetsDialog* self,
                                     WidgetsConfigWindow* window)
{
	WidgetsConfigWindow* _tmp0_;
	GdkWindow* gdk_window = NULL;
	GdkWindow* _tmp1_;
	GdkWindow* _tmp2_;
	gint x = 0;
	gint y = 0;
	gint _tmp3_ = 0;
	gint _tmp4_ = 0;
	GtkAllocation window_alloc = {0};
	GtkAllocation _tmp5_ = {0};
	GtkAllocation _tmp6_;
	GtkAllocation _tmp7_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (window != NULL);
	_tmp0_ = _g_object_ref0 (window);
	_g_object_unref0 (self->transient_window);
	self->transient_window = _tmp0_;
	gtk_window_set_default_geometry ((GtkWindow*) self, self->window_init_width, self->window_init_height);
	gtk_window_set_transient_for ((GtkWindow*) self, (GtkWindow*) window);
	_tmp1_ = gtk_widget_get_window ((GtkWidget*) window);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	gdk_window = _tmp2_;
	gdk_window_get_root_origin (gdk_window, &_tmp3_, &_tmp4_);
	x = _tmp3_;
	y = _tmp4_;
	gtk_widget_get_allocation ((GtkWidget*) window, &_tmp5_);
	window_alloc = _tmp5_;
	_tmp6_ = window_alloc;
	_tmp7_ = window_alloc;
	gtk_window_move ((GtkWindow*) self, x + ((_tmp6_.width - self->window_init_width) / 2), y + ((_tmp7_.height - self->window_init_height) / 2));
	gtk_widget_show_all ((GtkWidget*) self);
	_g_object_unref0 (gdk_window);
}

void
widgets_dialog_shadow_active (WidgetsDialog* self)
{
	GdkScreen* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->screen_monitor;
	if (gdk_screen_is_composited (_tmp0_)) {
		GtkBox* _tmp1_;
		GtkStyleContext* _tmp2_;
		GtkBox* _tmp3_;
		GtkStyleContext* _tmp4_;
		_tmp1_ = self->window_frame_box;
		_tmp2_ = gtk_widget_get_style_context ((GtkWidget*) _tmp1_);
		gtk_style_context_remove_class (_tmp2_, "dialog_shadow_inactive");
		_tmp3_ = self->window_frame_box;
		_tmp4_ = gtk_widget_get_style_context ((GtkWidget*) _tmp3_);
		gtk_style_context_add_class (_tmp4_, "dialog_shadow_active");
	} else {
		GtkBox* _tmp5_;
		GtkStyleContext* _tmp6_;
		GtkBox* _tmp7_;
		GtkStyleContext* _tmp8_;
		_tmp5_ = self->window_frame_box;
		_tmp6_ = gtk_widget_get_style_context ((GtkWidget*) _tmp5_);
		gtk_style_context_remove_class (_tmp6_, "dialog_noshadow_inactive");
		_tmp7_ = self->window_frame_box;
		_tmp8_ = gtk_widget_get_style_context ((GtkWidget*) _tmp7_);
		gtk_style_context_add_class (_tmp8_, "dialog_noshadow_active");
	}
}

void
widgets_dialog_shadow_inactive (WidgetsDialog* self)
{
	GdkScreen* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->screen_monitor;
	if (gdk_screen_is_composited (_tmp0_)) {
		GtkBox* _tmp1_;
		GtkStyleContext* _tmp2_;
		GtkBox* _tmp3_;
		GtkStyleContext* _tmp4_;
		_tmp1_ = self->window_frame_box;
		_tmp2_ = gtk_widget_get_style_context ((GtkWidget*) _tmp1_);
		gtk_style_context_remove_class (_tmp2_, "dialog_shadow_active");
		_tmp3_ = self->window_frame_box;
		_tmp4_ = gtk_widget_get_style_context ((GtkWidget*) _tmp3_);
		gtk_style_context_add_class (_tmp4_, "dialog_shadow_inactive");
	} else {
		GtkBox* _tmp5_;
		GtkStyleContext* _tmp6_;
		GtkBox* _tmp7_;
		GtkStyleContext* _tmp8_;
		_tmp5_ = self->window_frame_box;
		_tmp6_ = gtk_widget_get_style_context ((GtkWidget*) _tmp5_);
		gtk_style_context_remove_class (_tmp6_, "dialog_noshadow_active");
		_tmp7_ = self->window_frame_box;
		_tmp8_ = gtk_widget_get_style_context ((GtkWidget*) _tmp7_);
		gtk_style_context_add_class (_tmp8_, "dialog_noshadow_inactive");
	}
}

void
widgets_dialog_draw_window_widgets (WidgetsDialog* self,
                                    cairo_t* cr)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (cr != NULL);
	utils_propagate_draw ((GtkContainer*) self, cr);
}

void
widgets_dialog_add_widget (WidgetsDialog* self,
                           GtkWidget* widget)
{
	GtkBox* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (widget != NULL);
	_tmp0_ = self->window_widget_box;
	gtk_box_pack_start (_tmp0_, widget, TRUE, TRUE, (guint) 0);
}

void
widgets_dialog_draw_window_below (WidgetsDialog* self,
                                  cairo_t* cr)
{
	GtkAllocation window_rect = {0};
	GtkBox* _tmp0_;
	GtkAllocation _tmp1_ = {0};
	GdkScreen* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (cr != NULL);
	_tmp0_ = self->window_frame_box;
	gtk_widget_get_allocation ((GtkWidget*) _tmp0_, &_tmp1_);
	window_rect = _tmp1_;
	cairo_set_source_rgba (cr, (gdouble) 1, (gdouble) 1, (gdouble) 1, (gdouble) 1);
	_tmp2_ = self->screen_monitor;
	if (gdk_screen_is_composited (_tmp2_)) {
		GtkAllocation _tmp3_;
		GtkAllocation _tmp4_;
		_tmp3_ = window_rect;
		_tmp4_ = window_rect;
		draw_fill_rounded_rectangle (cr, self->window_frame_margin_start, self->window_frame_margin_top, _tmp3_.width, _tmp4_.height, (gdouble) self->window_frame_radius);
	} else {
		GtkAllocation _tmp5_;
		GtkAllocation _tmp6_;
		_tmp5_ = window_rect;
		_tmp6_ = window_rect;
		draw_fill_rounded_rectangle (cr, 0, 0, _tmp5_.width, _tmp6_.height, (gdouble) 0);
	}
}

void
widgets_dialog_grid_attach (WidgetsDialog* self,
                            GtkGrid* grid,
                            GtkWidget* child,
                            gint left,
                            gint top,
                            gint width,
                            gint height)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (grid != NULL);
	g_return_if_fail (child != NULL);
	gtk_widget_set_margin_top (child, self->option_widget_margin_top);
	gtk_widget_set_margin_bottom (child, self->option_widget_margin_end);
	gtk_grid_attach (grid, child, left, top, width, height);
}

void
widgets_dialog_grid_attach_next_to (WidgetsDialog* self,
                                    GtkGrid* grid,
                                    GtkWidget* child,
                                    GtkWidget* sibling,
                                    GtkPositionType side,
                                    gint width,
                                    gint height)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (grid != NULL);
	g_return_if_fail (child != NULL);
	g_return_if_fail (sibling != NULL);
	gtk_widget_set_margin_top (child, self->option_widget_margin_top);
	gtk_widget_set_margin_bottom (child, self->option_widget_margin_end);
	gtk_grid_attach_next_to (grid, child, sibling, side, width, height);
}

void
widgets_dialog_draw_window_frame (WidgetsDialog* self,
                                  cairo_t* cr)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (cr != NULL);
}

void
widgets_dialog_update_frame (WidgetsDialog* self)
{
	GdkScreen* _tmp0_;
	GtkBox* _tmp11_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->screen_monitor;
	if (gdk_screen_is_composited (_tmp0_)) {
		GdkWindow* _tmp1_;
		GtkBox* _tmp2_;
		GtkBox* _tmp3_;
		GtkBox* _tmp4_;
		GtkBox* _tmp5_;
		_tmp1_ = gtk_widget_get_window ((GtkWidget*) self);
		gdk_window_set_shadow_width (_tmp1_, self->window_frame_margin_start, self->window_frame_margin_end, self->window_frame_margin_top, self->window_frame_margin_bottom);
		_tmp2_ = self->window_frame_box;
		gtk_widget_set_margin_top ((GtkWidget*) _tmp2_, self->window_frame_margin_top);
		_tmp3_ = self->window_frame_box;
		gtk_widget_set_margin_bottom ((GtkWidget*) _tmp3_, self->window_frame_margin_bottom);
		_tmp4_ = self->window_frame_box;
		gtk_widget_set_margin_start ((GtkWidget*) _tmp4_, self->window_frame_margin_start);
		_tmp5_ = self->window_frame_box;
		gtk_widget_set_margin_end ((GtkWidget*) _tmp5_, self->window_frame_margin_end);
	} else {
		GdkWindow* _tmp6_;
		GtkBox* _tmp7_;
		GtkBox* _tmp8_;
		GtkBox* _tmp9_;
		GtkBox* _tmp10_;
		_tmp6_ = gtk_widget_get_window ((GtkWidget*) self);
		gdk_window_set_shadow_width (_tmp6_, 0, 0, 0, 0);
		_tmp7_ = self->window_frame_box;
		gtk_widget_set_margin_top ((GtkWidget*) _tmp7_, 0);
		_tmp8_ = self->window_frame_box;
		gtk_widget_set_margin_bottom ((GtkWidget*) _tmp8_, 0);
		_tmp9_ = self->window_frame_box;
		gtk_widget_set_margin_start ((GtkWidget*) _tmp9_, 0);
		_tmp10_ = self->window_frame_box;
		gtk_widget_set_margin_end ((GtkWidget*) _tmp10_, 0);
	}
	_tmp11_ = self->window_widget_box;
	g_object_set ((GtkWidget*) _tmp11_, "margin", 0, NULL);
}

static void
widgets_dialog_real_draw_window_above (WidgetsDialog* self,
                                       cairo_t* cr)
{
	g_return_if_fail (cr != NULL);
}

void
widgets_dialog_draw_window_above (WidgetsDialog* self,
                                  cairo_t* cr)
{
	WidgetsDialogClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = WIDGETS_DIALOG_GET_CLASS (self);
	if (_klass_->draw_window_above) {
		_klass_->draw_window_above (self, cr);
	}
}

static void
widgets_dialog_class_init (WidgetsDialogClass * klass,
                           gpointer klass_data)
{
	widgets_dialog_parent_class = g_type_class_peek_parent (klass);
	((WidgetsDialogClass *) klass)->draw_window_above = (void (*) (WidgetsDialog*, cairo_t*)) widgets_dialog_real_draw_window_above;
	G_OBJECT_CLASS (klass)->finalize = widgets_dialog_finalize;
}

static void
widgets_dialog_instance_init (WidgetsDialog * self,
                              gpointer klass)
{
	self->option_widget_margin_end = 5;
	self->option_widget_margin_top = 5;
	self->window_frame_margin_bottom = 60;
	self->window_frame_margin_end = 50;
	self->window_frame_margin_start = 50;
	self->window_frame_margin_top = 50;
	self->window_frame_radius = 5;
}

static void
widgets_dialog_finalize (GObject * obj)
{
	WidgetsDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIDGETS_TYPE_DIALOG, WidgetsDialog);
	_g_object_unref0 (self->screen_monitor);
	_g_object_unref0 (self->window_frame_box);
	_g_object_unref0 (self->window_widget_box);
	_g_object_unref0 (self->transient_window);
	G_OBJECT_CLASS (widgets_dialog_parent_class)->finalize (obj);
}

static GType
widgets_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (WidgetsDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) widgets_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WidgetsDialog), 0, (GInstanceInitFunc) widgets_dialog_instance_init, NULL };
	GType widgets_dialog_type_id;
	widgets_dialog_type_id = g_type_register_static (gtk_window_get_type (), "WidgetsDialog", &g_define_type_info, 0);
	return widgets_dialog_type_id;
}

GType
widgets_dialog_get_type (void)
{
	static volatile gsize widgets_dialog_type_id__once = 0;
	if (g_once_init_enter (&widgets_dialog_type_id__once)) {
		GType widgets_dialog_type_id;
		widgets_dialog_type_id = widgets_dialog_get_type_once ();
		g_once_init_leave (&widgets_dialog_type_id__once, widgets_dialog_type_id);
	}
	return widgets_dialog_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;
}

