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

/*
 *  pamac-vala
 *
 *  Copyright (C) 2018-2022 Guillaume Benoit <guillaume@manjaro.org>
 *
 *  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
 *  (at your option) 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 get of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "pamac-gtk.h"
#include <gtk/gtk.h>
#include <glib-object.h>
#include <pamac.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.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

enum  {
	PAMAC_DATABASE_GTK_0_PROPERTY,
	PAMAC_DATABASE_GTK_WINDOW_PROPERTY,
	PAMAC_DATABASE_GTK_NUM_PROPERTIES
};
static GParamSpec* pamac_database_gtk_properties[PAMAC_DATABASE_GTK_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block13Data Block13Data;

struct _PamacDatabaseGtkPrivate {
	GtkWindow* _window;
};

struct _Block13Data {
	int _ref_count_;
	PamacDatabaseGtk* self;
	GtkDialog* dialog;
};

static gint PamacDatabaseGtk_private_offset;
static gpointer pamac_database_gtk_parent_class = NULL;

static GObject * pamac_database_gtk_constructor (GType type,
                                          guint n_construct_properties,
                                          GObjectConstructParam * construct_properties);
static void _pamac_database_gtk___lambda25_ (PamacDatabaseGtk* self,
                                      const gchar* message);
static Block13Data* block13_data_ref (Block13Data* _data13_);
static void block13_data_unref (void * _userdata_);
static void __lambda26_ (Block13Data* _data13_);
static void ___lambda26__gtk_dialog_response (GtkDialog* _sender,
                                       gint response_id,
                                       gpointer self);
static void __pamac_database_gtk___lambda25__pamac_database_emit_warning (PamacDatabase* _sender,
                                                                   const gchar* message,
                                                                   gpointer self);
static void pamac_database_gtk_finalize (GObject * obj);
static GType pamac_database_gtk_get_type_once (void);
static void _vala_pamac_database_gtk_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec);
static void _vala_pamac_database_gtk_set_property (GObject * object,
                                            guint property_id,
                                            const GValue * value,
                                            GParamSpec * pspec);

static inline gpointer
pamac_database_gtk_get_instance_private (PamacDatabaseGtk* self)
{
	return G_STRUCT_MEMBER_P (self, PamacDatabaseGtk_private_offset);
}

PamacDatabaseGtk*
pamac_database_gtk_construct (GType object_type,
                              PamacConfig* config)
{
	PamacDatabaseGtk * self = NULL;
	g_return_val_if_fail (config != NULL, NULL);
	self = (PamacDatabaseGtk*) g_object_new (object_type, "config", config, NULL);
	return self;
}

PamacDatabaseGtk*
pamac_database_gtk_new (PamacConfig* config)
{
	return pamac_database_gtk_construct (PAMAC_TYPE_DATABASE_GTK, config);
}

GtkWindow*
pamac_database_gtk_get_window (PamacDatabaseGtk* self)
{
	GtkWindow* result;
	GtkWindow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_window;
	result = _tmp0_;
	return result;
}

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

void
pamac_database_gtk_set_window (PamacDatabaseGtk* self,
                               GtkWindow* value)
{
	GtkWindow* old_value;
	g_return_if_fail (self != NULL);
	old_value = pamac_database_gtk_get_window (self);
	if (old_value != value) {
		GtkWindow* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_window);
		self->priv->_window = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, pamac_database_gtk_properties[PAMAC_DATABASE_GTK_WINDOW_PROPERTY]);
	}
}

static Block13Data*
block13_data_ref (Block13Data* _data13_)
{
	g_atomic_int_inc (&_data13_->_ref_count_);
	return _data13_;
}

static void
block13_data_unref (void * _userdata_)
{
	Block13Data* _data13_;
	_data13_ = (Block13Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data13_->_ref_count_)) {
		PamacDatabaseGtk* self;
		self = _data13_->self;
		_g_object_unref0 (_data13_->dialog);
		_g_object_unref0 (self);
		g_slice_free (Block13Data, _data13_);
	}
}

static void
__lambda26_ (Block13Data* _data13_)
{
	PamacDatabaseGtk* self;
	GtkDialog* _tmp0_;
	self = _data13_->self;
	_tmp0_ = _data13_->dialog;
	gtk_widget_destroy ((GtkWidget*) _tmp0_);
}

static void
___lambda26__gtk_dialog_response (GtkDialog* _sender,
                                  gint response_id,
                                  gpointer self)
{
	__lambda26_ (self);
}

static void
_pamac_database_gtk___lambda25_ (PamacDatabaseGtk* self,
                                 const gchar* message)
{
	Block13Data* _data13_;
	gint _tmp0_;
	gint _tmp1_;
	GtkDialogFlags flags = 0U;
	gint use_header_bar = 0;
	GtkSettings* _tmp2_;
	gint _tmp3_ = 0;
	GtkWindow* _tmp4_;
	GtkDialog* _tmp5_;
	GtkDialog* _tmp6_;
	GtkDialog* _tmp7_;
	GtkDialog* _tmp8_;
	GtkDialog* _tmp9_;
	GtkDialog* _tmp10_;
	GtkDialog* _tmp11_;
	GtkWidget* widget = NULL;
	GtkDialog* _tmp12_;
	GtkWidget* _tmp13_;
	GtkWidget* _tmp14_;
	GtkScrolledWindow* scrolledwindow = NULL;
	GtkScrolledWindow* _tmp15_;
	GtkScrolledWindow* _tmp16_;
	GtkLabel* label = NULL;
	GtkLabel* _tmp17_;
	GtkLabel* _tmp18_;
	GtkLabel* _tmp19_;
	GtkLabel* _tmp20_;
	GtkLabel* _tmp21_;
	GtkLabel* _tmp22_;
	GtkLabel* _tmp23_;
	GtkScrolledWindow* _tmp24_;
	GtkLabel* _tmp25_;
	GtkScrolledWindow* _tmp26_;
	GtkScrolledWindow* _tmp27_;
	GtkBox* box = NULL;
	GtkDialog* _tmp28_;
	GtkBox* _tmp29_;
	GtkBox* _tmp30_;
	GtkScrolledWindow* _tmp31_;
	GtkBox* _tmp32_;
	GtkDialog* _tmp33_;
	GtkDialog* _tmp34_;
	GtkDialog* _tmp35_;
	GtkDialog* _tmp36_;
	g_return_if_fail (message != NULL);
	_data13_ = g_slice_new0 (Block13Data);
	_data13_->_ref_count_ = 1;
	_data13_->self = g_object_ref (self);
	_tmp0_ = strlen (message);
	_tmp1_ = _tmp0_;
	if (_tmp1_ == 0) {
		block13_data_unref (_data13_);
		_data13_ = NULL;
		return;
	}
	flags = GTK_DIALOG_MODAL;
	_tmp2_ = gtk_settings_get_default ();
	g_object_get ((GObject*) _tmp2_, "gtk-dialogs-use-header", &_tmp3_, NULL);
	use_header_bar = _tmp3_;
	if (use_header_bar == 1) {
		flags |= GTK_DIALOG_USE_HEADER_BAR;
	}
	_tmp4_ = self->priv->_window;
	_tmp5_ = (GtkDialog*) gtk_dialog_new_with_buttons (g_dgettext (NULL, "Error"), _tmp4_, flags, NULL);
	g_object_ref_sink (_tmp5_);
	_data13_->dialog = _tmp5_;
	_tmp6_ = _data13_->dialog;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp6_, 3);
	_tmp7_ = _data13_->dialog;
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp7_, 3);
	_tmp8_ = _data13_->dialog;
	gtk_widget_set_margin_start ((GtkWidget*) _tmp8_, 3);
	_tmp9_ = _data13_->dialog;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp9_, 3);
	_tmp10_ = _data13_->dialog;
	gtk_window_set_icon_name ((GtkWindow*) _tmp10_, "system-software-install");
	_tmp11_ = _data13_->dialog;
	gtk_window_set_deletable ((GtkWindow*) _tmp11_, FALSE);
	_tmp12_ = _data13_->dialog;
	_tmp13_ = gtk_dialog_add_button (_tmp12_, g_dgettext (NULL, "_Close"), (gint) GTK_RESPONSE_CLOSE);
	widget = _tmp13_;
	_tmp14_ = widget;
	gtk_widget_grab_default (_tmp14_);
	_tmp15_ = (GtkScrolledWindow*) gtk_scrolled_window_new (NULL, NULL);
	g_object_ref_sink (_tmp15_);
	scrolledwindow = _tmp15_;
	_tmp16_ = scrolledwindow;
	gtk_widget_set_visible ((GtkWidget*) _tmp16_, TRUE);
	_tmp17_ = (GtkLabel*) gtk_label_new (message);
	g_object_ref_sink (_tmp17_);
	label = _tmp17_;
	_tmp18_ = label;
	gtk_widget_set_visible ((GtkWidget*) _tmp18_, TRUE);
	_tmp19_ = label;
	gtk_label_set_selectable (_tmp19_, TRUE);
	_tmp20_ = label;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp20_, 12);
	_tmp21_ = label;
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp21_, 12);
	_tmp22_ = label;
	gtk_widget_set_margin_start ((GtkWidget*) _tmp22_, 12);
	_tmp23_ = label;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp23_, 12);
	_tmp24_ = scrolledwindow;
	_tmp25_ = label;
	gtk_container_add ((GtkContainer*) _tmp24_, (GtkWidget*) _tmp25_);
	_tmp26_ = scrolledwindow;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp26_, TRUE);
	_tmp27_ = scrolledwindow;
	gtk_widget_set_vexpand ((GtkWidget*) _tmp27_, TRUE);
	_tmp28_ = _data13_->dialog;
	_tmp29_ = gtk_dialog_get_content_area (_tmp28_);
	box = _tmp29_;
	_tmp30_ = box;
	_tmp31_ = scrolledwindow;
	gtk_container_add ((GtkContainer*) _tmp30_, (GtkWidget*) _tmp31_);
	_tmp32_ = box;
	gtk_box_set_spacing (_tmp32_, 6);
	_tmp33_ = _data13_->dialog;
	g_object_set ((GtkWindow*) _tmp33_, "default-width", 600, NULL);
	_tmp34_ = _data13_->dialog;
	g_object_set ((GtkWindow*) _tmp34_, "default-height", 300, NULL);
	_tmp35_ = _data13_->dialog;
	g_signal_connect_data (_tmp35_, "response", (GCallback) ___lambda26__gtk_dialog_response, block13_data_ref (_data13_), (GClosureNotify) block13_data_unref, 0);
	_tmp36_ = _data13_->dialog;
	gtk_widget_show ((GtkWidget*) _tmp36_);
	_g_object_unref0 (label);
	_g_object_unref0 (scrolledwindow);
	block13_data_unref (_data13_);
	_data13_ = NULL;
}

static void
__pamac_database_gtk___lambda25__pamac_database_emit_warning (PamacDatabase* _sender,
                                                              const gchar* message,
                                                              gpointer self)
{
	_pamac_database_gtk___lambda25_ ((PamacDatabaseGtk*) self, message);
}

static GObject *
pamac_database_gtk_constructor (GType type,
                                guint n_construct_properties,
                                GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	PamacDatabaseGtk * self;
	parent_class = G_OBJECT_CLASS (pamac_database_gtk_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PAMAC_TYPE_DATABASE_GTK, PamacDatabaseGtk);
	g_signal_connect_object ((PamacDatabase*) self, "emit-warning", (GCallback) __pamac_database_gtk___lambda25__pamac_database_emit_warning, self, 0);
	return obj;
}

static void
pamac_database_gtk_class_init (PamacDatabaseGtkClass * klass,
                               gpointer klass_data)
{
	pamac_database_gtk_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &PamacDatabaseGtk_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_pamac_database_gtk_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_pamac_database_gtk_set_property;
	G_OBJECT_CLASS (klass)->constructor = pamac_database_gtk_constructor;
	G_OBJECT_CLASS (klass)->finalize = pamac_database_gtk_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), PAMAC_DATABASE_GTK_WINDOW_PROPERTY, pamac_database_gtk_properties[PAMAC_DATABASE_GTK_WINDOW_PROPERTY] = g_param_spec_object ("window", "window", "window", gtk_window_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
pamac_database_gtk_instance_init (PamacDatabaseGtk * self,
                                  gpointer klass)
{
	self->priv = pamac_database_gtk_get_instance_private (self);
}

static void
pamac_database_gtk_finalize (GObject * obj)
{
	PamacDatabaseGtk * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PAMAC_TYPE_DATABASE_GTK, PamacDatabaseGtk);
	_g_object_unref0 (self->priv->_window);
	G_OBJECT_CLASS (pamac_database_gtk_parent_class)->finalize (obj);
}

static GType
pamac_database_gtk_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (PamacDatabaseGtkClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) pamac_database_gtk_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PamacDatabaseGtk), 0, (GInstanceInitFunc) pamac_database_gtk_instance_init, NULL };
	GType pamac_database_gtk_type_id;
	pamac_database_gtk_type_id = g_type_register_static (PAMAC_TYPE_DATABASE, "PamacDatabaseGtk", &g_define_type_info, 0);
	PamacDatabaseGtk_private_offset = g_type_add_instance_private (pamac_database_gtk_type_id, sizeof (PamacDatabaseGtkPrivate));
	return pamac_database_gtk_type_id;
}

GType
pamac_database_gtk_get_type (void)
{
	static volatile gsize pamac_database_gtk_type_id__once = 0;
	if (g_once_init_enter (&pamac_database_gtk_type_id__once)) {
		GType pamac_database_gtk_type_id;
		pamac_database_gtk_type_id = pamac_database_gtk_get_type_once ();
		g_once_init_leave (&pamac_database_gtk_type_id__once, pamac_database_gtk_type_id);
	}
	return pamac_database_gtk_type_id__once;
}

static void
_vala_pamac_database_gtk_get_property (GObject * object,
                                       guint property_id,
                                       GValue * value,
                                       GParamSpec * pspec)
{
	PamacDatabaseGtk * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PAMAC_TYPE_DATABASE_GTK, PamacDatabaseGtk);
	switch (property_id) {
		case PAMAC_DATABASE_GTK_WINDOW_PROPERTY:
		g_value_set_object (value, pamac_database_gtk_get_window (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_pamac_database_gtk_set_property (GObject * object,
                                       guint property_id,
                                       const GValue * value,
                                       GParamSpec * pspec)
{
	PamacDatabaseGtk * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PAMAC_TYPE_DATABASE_GTK, PamacDatabaseGtk);
	switch (property_id) {
		case PAMAC_DATABASE_GTK_WINDOW_PROPERTY:
		pamac_database_gtk_set_window (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

