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

/*
Peek Copyright (c) 2015-2017 by Philipp Wolfer <ph.wolfer@gmail.com>

This file is part of Peek.

This software is licensed under the GNU General Public License
(version 3 or later). See the LICENSE file in this distribution.
*/

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <gdk/gdk.h>
#include <string.h>
#include "../../application.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

#define PEEK_UI_TYPE_ABOUT_DIALOG (peek_ui_about_dialog_get_type ())
#define PEEK_UI_ABOUT_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PEEK_UI_TYPE_ABOUT_DIALOG, PeekUiAboutDialog))
#define PEEK_UI_ABOUT_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PEEK_UI_TYPE_ABOUT_DIALOG, PeekUiAboutDialogClass))
#define PEEK_UI_IS_ABOUT_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PEEK_UI_TYPE_ABOUT_DIALOG))
#define PEEK_UI_IS_ABOUT_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PEEK_UI_TYPE_ABOUT_DIALOG))
#define PEEK_UI_ABOUT_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PEEK_UI_TYPE_ABOUT_DIALOG, PeekUiAboutDialogClass))

typedef struct _PeekUiAboutDialog PeekUiAboutDialog;
typedef struct _PeekUiAboutDialogClass PeekUiAboutDialogClass;
typedef struct _PeekUiAboutDialogPrivate PeekUiAboutDialogPrivate;
enum  {
	PEEK_UI_ABOUT_DIALOG_0_PROPERTY,
	PEEK_UI_ABOUT_DIALOG_NUM_PROPERTIES
};
static GParamSpec* peek_ui_about_dialog_properties[PEEK_UI_ABOUT_DIALOG_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block2Data Block2Data;

struct _PeekUiAboutDialog {
	GtkAboutDialog parent_instance;
	PeekUiAboutDialogPrivate * priv;
};

struct _PeekUiAboutDialogClass {
	GtkAboutDialogClass parent_class;
};

struct _Block2Data {
	int _ref_count_;
	GtkWindow* main_window;
};

static gpointer peek_ui_about_dialog_parent_class = NULL;
static GtkDialog* peek_ui_about_dialog_instance;
static GtkDialog* peek_ui_about_dialog_instance = NULL;

VALA_EXTERN GType peek_ui_about_dialog_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GtkDialog* peek_ui_about_dialog_present_single_instance (GtkWindow* main_window);
static Block2Data* block2_data_ref (Block2Data* _data2_);
static void block2_data_unref (void * _userdata_);
VALA_EXTERN PeekUiAboutDialog* peek_ui_about_dialog_new (void);
VALA_EXTERN PeekUiAboutDialog* peek_ui_about_dialog_construct (GType object_type);
static gboolean ___lambda21_ (Block2Data* _data2_,
                       GdkEventAny* event);
static gboolean ____lambda21__gtk_widget_delete_event (GtkWidget* _sender,
                                                GdkEventAny* event,
                                                gpointer self);
static void peek_ui_about_dialog_on_response (PeekUiAboutDialog* self,
                                       gint response_id);
static void _peek_ui_about_dialog_on_response_gtk_dialog_response (GtkDialog* _sender,
                                                            gint response_id,
                                                            gpointer self);
static void peek_ui_about_dialog_finalize (GObject * obj);
static GType peek_ui_about_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 Block2Data*
block2_data_ref (Block2Data* _data2_)
{
	g_atomic_int_inc (&_data2_->_ref_count_);
	return _data2_;
}

static void
block2_data_unref (void * _userdata_)
{
	Block2Data* _data2_;
	_data2_ = (Block2Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data2_->_ref_count_)) {
		_g_object_unref0 (_data2_->main_window);
		g_slice_free (Block2Data, _data2_);
	}
}

static gboolean
___lambda21_ (Block2Data* _data2_,
              GdkEventAny* event)
{
	gboolean result;
	g_return_val_if_fail (event != NULL, FALSE);
	_g_object_unref0 (peek_ui_about_dialog_instance);
	peek_ui_about_dialog_instance = NULL;
	gtk_window_set_keep_above (_data2_->main_window, TRUE);
	result = FALSE;
	return result;
}

static gboolean
____lambda21__gtk_widget_delete_event (GtkWidget* _sender,
                                       GdkEventAny* event,
                                       gpointer self)
{
	gboolean result;
	result = ___lambda21_ (self, event);
	return result;
}

GtkDialog*
peek_ui_about_dialog_present_single_instance (GtkWindow* main_window)
{
	Block2Data* _data2_;
	GtkWindow* _tmp0_;
	GtkDialog* _tmp1_;
	GtkDialog* _tmp6_;
	GtkDialog* _tmp7_;
	GtkDialog* _tmp8_;
	GtkDialog* _tmp9_;
	GtkDialog* result;
	g_return_val_if_fail (main_window != NULL, NULL);
	_data2_ = g_slice_new0 (Block2Data);
	_data2_->_ref_count_ = 1;
	_tmp0_ = _g_object_ref0 (main_window);
	_g_object_unref0 (_data2_->main_window);
	_data2_->main_window = _tmp0_;
	_tmp1_ = peek_ui_about_dialog_instance;
	if (_tmp1_ == NULL) {
		PeekUiAboutDialog* aboutDialog = NULL;
		PeekUiAboutDialog* _tmp2_;
		PeekUiAboutDialog* _tmp3_;
		GtkDialog* _tmp4_;
		GtkDialog* _tmp5_;
		_tmp2_ = peek_ui_about_dialog_new ();
		g_object_ref_sink (_tmp2_);
		aboutDialog = _tmp2_;
		_tmp3_ = aboutDialog;
		_tmp4_ = _g_object_ref0 ((GtkDialog*) _tmp3_);
		_g_object_unref0 (peek_ui_about_dialog_instance);
		peek_ui_about_dialog_instance = _tmp4_;
		_tmp5_ = peek_ui_about_dialog_instance;
		g_signal_connect_data ((GtkWidget*) _tmp5_, "delete-event", (GCallback) ____lambda21__gtk_widget_delete_event, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
		_g_object_unref0 (aboutDialog);
	}
	_tmp6_ = peek_ui_about_dialog_instance;
	gtk_window_set_transient_for ((GtkWindow*) _tmp6_, _data2_->main_window);
	gtk_window_set_keep_above (_data2_->main_window, FALSE);
	_tmp7_ = peek_ui_about_dialog_instance;
	gtk_window_present ((GtkWindow*) _tmp7_);
	_tmp8_ = peek_ui_about_dialog_instance;
	_tmp9_ = _g_object_ref0 (_tmp8_);
	result = _tmp9_;
	block2_data_unref (_data2_);
	_data2_ = NULL;
	return result;
}

static void
peek_ui_about_dialog_on_response (PeekUiAboutDialog* self,
                                  gint response_id)
{
	gboolean _tmp0_ = FALSE;
	g_return_if_fail (self != NULL);
	if (response_id == ((gint) GTK_RESPONSE_CANCEL)) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = response_id == ((gint) GTK_RESPONSE_DELETE_EVENT);
	}
	if (_tmp0_) {
		gtk_widget_hide_on_delete ((GtkWidget*) self);
	}
}

static void
_peek_ui_about_dialog_on_response_gtk_dialog_response (GtkDialog* _sender,
                                                       gint response_id,
                                                       gpointer self)
{
	peek_ui_about_dialog_on_response ((PeekUiAboutDialog*) self, response_id);
}

PeekUiAboutDialog*
peek_ui_about_dialog_construct (GType object_type)
{
	PeekUiAboutDialog * self = NULL;
	self = (PeekUiAboutDialog*) g_object_new (object_type, NULL);
	return self;
}

PeekUiAboutDialog*
peek_ui_about_dialog_new (void)
{
	return peek_ui_about_dialog_construct (PEEK_UI_TYPE_ABOUT_DIALOG);
}

static void
peek_ui_about_dialog_class_init (PeekUiAboutDialogClass * klass,
                                 gpointer klass_data)
{
	peek_ui_about_dialog_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = peek_ui_about_dialog_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/com/uploadedlobster/peek/about.ui");
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_response", G_CALLBACK(_peek_ui_about_dialog_on_response_gtk_dialog_response));
}

static void
peek_ui_about_dialog_instance_init (PeekUiAboutDialog * self,
                                    gpointer klass)
{
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
peek_ui_about_dialog_finalize (GObject * obj)
{
	PeekUiAboutDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PEEK_UI_TYPE_ABOUT_DIALOG, PeekUiAboutDialog);
	G_OBJECT_CLASS (peek_ui_about_dialog_parent_class)->finalize (obj);
}

static GType
peek_ui_about_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (PeekUiAboutDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) peek_ui_about_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PeekUiAboutDialog), 0, (GInstanceInitFunc) peek_ui_about_dialog_instance_init, NULL };
	GType peek_ui_about_dialog_type_id;
	peek_ui_about_dialog_type_id = g_type_register_static (gtk_about_dialog_get_type (), "PeekUiAboutDialog", &g_define_type_info, 0);
	return peek_ui_about_dialog_type_id;
}

GType
peek_ui_about_dialog_get_type (void)
{
	static volatile gsize peek_ui_about_dialog_type_id__once = 0;
	if (g_once_init_enter (&peek_ui_about_dialog_type_id__once)) {
		GType peek_ui_about_dialog_type_id;
		peek_ui_about_dialog_type_id = peek_ui_about_dialog_get_type_once ();
		g_once_init_leave (&peek_ui_about_dialog_type_id__once, peek_ui_about_dialog_type_id);
	}
	return peek_ui_about_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;
}

