/* CloseProjectsConfirmationDialog.c generated by valac 0.56.19, the Vala compiler
 * generated from CloseProjectsConfirmationDialog.vala, do not modify */

/*
* Copyright 2024 elementary, Inc. (https://elementary.io)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 3 as published by the Free Software Foundation.
*
* 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 Lesser General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/

#include "codecore.h"
#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <granite.h>
#include <gio/gio.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  {
	SCRATCH_DIALOGS_CLOSE_PROJECTS_CONFIRMATION_DIALOG_0_PROPERTY,
	SCRATCH_DIALOGS_CLOSE_PROJECTS_CONFIRMATION_DIALOG_N_PARENTS_PROPERTY,
	SCRATCH_DIALOGS_CLOSE_PROJECTS_CONFIRMATION_DIALOG_N_CHILDREN_PROPERTY,
	SCRATCH_DIALOGS_CLOSE_PROJECTS_CONFIRMATION_DIALOG_NUM_PROPERTIES
};
static GParamSpec* scratch_dialogs_close_projects_confirmation_dialog_properties[SCRATCH_DIALOGS_CLOSE_PROJECTS_CONFIRMATION_DIALOG_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _ScratchDialogsCloseProjectsConfirmationDialogPrivate {
	guint _n_parents;
	guint _n_children;
};

static gint ScratchDialogsCloseProjectsConfirmationDialog_private_offset;
static gpointer scratch_dialogs_close_projects_confirmation_dialog_parent_class = NULL;

static GObject * scratch_dialogs_close_projects_confirmation_dialog_constructor (GType type,
                                                                          guint n_construct_properties,
                                                                          GObjectConstructParam * construct_properties);
static void scratch_dialogs_close_projects_confirmation_dialog_finalize (GObject * obj);
static GType scratch_dialogs_close_projects_confirmation_dialog_get_type_once (void);
static void _vala_scratch_dialogs_close_projects_confirmation_dialog_get_property (GObject * object,
                                                                            guint property_id,
                                                                            GValue * value,
                                                                            GParamSpec * pspec);
static void _vala_scratch_dialogs_close_projects_confirmation_dialog_set_property (GObject * object,
                                                                            guint property_id,
                                                                            const GValue * value,
                                                                            GParamSpec * pspec);

static inline gpointer
scratch_dialogs_close_projects_confirmation_dialog_get_instance_private (ScratchDialogsCloseProjectsConfirmationDialog* self)
{
	return G_STRUCT_MEMBER_P (self, ScratchDialogsCloseProjectsConfirmationDialog_private_offset);
}

ScratchDialogsCloseProjectsConfirmationDialog*
scratch_dialogs_close_projects_confirmation_dialog_construct (GType object_type,
                                                              ScratchMainWindow* parent,
                                                              guint n_parents,
                                                              guint n_children)
{
	ScratchDialogsCloseProjectsConfirmationDialog * self = NULL;
	g_return_val_if_fail (parent != NULL, NULL);
	self = (ScratchDialogsCloseProjectsConfirmationDialog*) g_object_new (object_type, "buttons", GTK_BUTTONS_NONE, "transient-for", parent, "n-parents", n_parents, "n-children", n_children, NULL);
	return self;
}

ScratchDialogsCloseProjectsConfirmationDialog*
scratch_dialogs_close_projects_confirmation_dialog_new (ScratchMainWindow* parent,
                                                        guint n_parents,
                                                        guint n_children)
{
	return scratch_dialogs_close_projects_confirmation_dialog_construct (SCRATCH_DIALOGS_TYPE_CLOSE_PROJECTS_CONFIRMATION_DIALOG, parent, n_parents, n_children);
}

guint
scratch_dialogs_close_projects_confirmation_dialog_get_n_parents (ScratchDialogsCloseProjectsConfirmationDialog* self)
{
	guint result;
	g_return_val_if_fail (self != NULL, 0U);
	result = self->priv->_n_parents;
	return result;
}

static void
scratch_dialogs_close_projects_confirmation_dialog_set_n_parents (ScratchDialogsCloseProjectsConfirmationDialog* self,
                                                                  guint value)
{
	guint old_value;
	g_return_if_fail (self != NULL);
	old_value = scratch_dialogs_close_projects_confirmation_dialog_get_n_parents (self);
	if (old_value != value) {
		self->priv->_n_parents = value;
		g_object_notify_by_pspec ((GObject *) self, scratch_dialogs_close_projects_confirmation_dialog_properties[SCRATCH_DIALOGS_CLOSE_PROJECTS_CONFIRMATION_DIALOG_N_PARENTS_PROPERTY]);
	}
}

guint
scratch_dialogs_close_projects_confirmation_dialog_get_n_children (ScratchDialogsCloseProjectsConfirmationDialog* self)
{
	guint result;
	g_return_val_if_fail (self != NULL, 0U);
	result = self->priv->_n_children;
	return result;
}

static void
scratch_dialogs_close_projects_confirmation_dialog_set_n_children (ScratchDialogsCloseProjectsConfirmationDialog* self,
                                                                   guint value)
{
	guint old_value;
	g_return_if_fail (self != NULL);
	old_value = scratch_dialogs_close_projects_confirmation_dialog_get_n_children (self);
	if (old_value != value) {
		self->priv->_n_children = value;
		g_object_notify_by_pspec ((GObject *) self, scratch_dialogs_close_projects_confirmation_dialog_properties[SCRATCH_DIALOGS_CLOSE_PROJECTS_CONFIRMATION_DIALOG_N_CHILDREN_PROPERTY]);
	}
}

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

static GObject *
scratch_dialogs_close_projects_confirmation_dialog_constructor (GType type,
                                                                guint n_construct_properties,
                                                                GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	ScratchDialogsCloseProjectsConfirmationDialog * self;
	GThemedIcon* _tmp0_;
	GThemedIcon* _tmp1_;
	gchar* button_label = NULL;
	gchar* _tmp2_;
	guint _tmp3_;
	GtkButton* ignore_button = NULL;
	const gchar* _tmp9_;
	GtkWidget* _tmp10_;
	GtkButton* _tmp11_;
	GtkButton* _tmp12_;
	GtkStyleContext* _tmp13_;
	parent_class = G_OBJECT_CLASS (scratch_dialogs_close_projects_confirmation_dialog_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SCRATCH_DIALOGS_TYPE_CLOSE_PROJECTS_CONFIRMATION_DIALOG, ScratchDialogsCloseProjectsConfirmationDialog);
	_tmp0_ = (GThemedIcon*) g_themed_icon_new ("dialog-warning");
	_tmp1_ = _tmp0_;
	granite_message_dialog_set_image_icon ((GraniteMessageDialog*) self, (GIcon*) _tmp1_);
	_g_object_unref0 (_tmp1_);
	_tmp2_ = g_strdup ("");
	button_label = _tmp2_;
	_tmp3_ = self->priv->_n_children;
	if (_tmp3_ > ((guint) 0)) {
		guint _tmp4_;
		guint _tmp5_;
		guint _tmp6_;
		gchar* _tmp7_;
		_tmp4_ = self->priv->_n_children;
		granite_message_dialog_set_primary_text ((GraniteMessageDialog*) self, ngettext ("This folder is the parent of an open project", "This folder is the parent of open projects", (gulong) _tmp4_));
		_tmp5_ = self->priv->_n_children;
		granite_message_dialog_set_secondary_text ((GraniteMessageDialog*) self, ngettext ("Opening this folder will close the child project", "Opening this folder will close all child projects", (gulong) _tmp5_));
		_tmp6_ = self->priv->_n_children;
		_tmp7_ = g_strdup (ngettext ("Close Child Project", "Close Child Projects", (gulong) _tmp6_));
		_g_free0 (button_label);
		button_label = _tmp7_;
	} else {
		gchar* _tmp8_;
		granite_message_dialog_set_primary_text ((GraniteMessageDialog*) self, _ ("This folder is a child of an open project"));
		granite_message_dialog_set_secondary_text ((GraniteMessageDialog*) self, _ ("Opening this folder will close the parent project"));
		_tmp8_ = g_strdup (_ ("Close Parent Project"));
		_g_free0 (button_label);
		button_label = _tmp8_;
	}
	gtk_dialog_add_button ((GtkDialog*) self, _ ("Don't Open"), (gint) GTK_RESPONSE_REJECT);
	_tmp9_ = button_label;
	_tmp10_ = gtk_dialog_add_button ((GtkDialog*) self, _tmp9_, (gint) GTK_RESPONSE_ACCEPT);
	_tmp11_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, gtk_button_get_type (), GtkButton));
	ignore_button = _tmp11_;
	_tmp12_ = ignore_button;
	_tmp13_ = gtk_widget_get_style_context ((GtkWidget*) _tmp12_);
	gtk_style_context_add_class (_tmp13_, GTK_STYLE_CLASS_DESTRUCTIVE_ACTION);
	_g_object_unref0 (ignore_button);
	_g_free0 (button_label);
	return obj;
}

static void
scratch_dialogs_close_projects_confirmation_dialog_class_init (ScratchDialogsCloseProjectsConfirmationDialogClass * klass,
                                                               gpointer klass_data)
{
	scratch_dialogs_close_projects_confirmation_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ScratchDialogsCloseProjectsConfirmationDialog_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_scratch_dialogs_close_projects_confirmation_dialog_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_scratch_dialogs_close_projects_confirmation_dialog_set_property;
	G_OBJECT_CLASS (klass)->constructor = scratch_dialogs_close_projects_confirmation_dialog_constructor;
	G_OBJECT_CLASS (klass)->finalize = scratch_dialogs_close_projects_confirmation_dialog_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), SCRATCH_DIALOGS_CLOSE_PROJECTS_CONFIRMATION_DIALOG_N_PARENTS_PROPERTY, scratch_dialogs_close_projects_confirmation_dialog_properties[SCRATCH_DIALOGS_CLOSE_PROJECTS_CONFIRMATION_DIALOG_N_PARENTS_PROPERTY] = g_param_spec_uint ("n-parents", "n-parents", "n-parents", 0, G_MAXUINT, 0U, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), SCRATCH_DIALOGS_CLOSE_PROJECTS_CONFIRMATION_DIALOG_N_CHILDREN_PROPERTY, scratch_dialogs_close_projects_confirmation_dialog_properties[SCRATCH_DIALOGS_CLOSE_PROJECTS_CONFIRMATION_DIALOG_N_CHILDREN_PROPERTY] = g_param_spec_uint ("n-children", "n-children", "n-children", 0, G_MAXUINT, 0U, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
scratch_dialogs_close_projects_confirmation_dialog_instance_init (ScratchDialogsCloseProjectsConfirmationDialog * self,
                                                                  gpointer klass)
{
	self->priv = scratch_dialogs_close_projects_confirmation_dialog_get_instance_private (self);
}

static void
scratch_dialogs_close_projects_confirmation_dialog_finalize (GObject * obj)
{
	ScratchDialogsCloseProjectsConfirmationDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SCRATCH_DIALOGS_TYPE_CLOSE_PROJECTS_CONFIRMATION_DIALOG, ScratchDialogsCloseProjectsConfirmationDialog);
	G_OBJECT_CLASS (scratch_dialogs_close_projects_confirmation_dialog_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
scratch_dialogs_close_projects_confirmation_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ScratchDialogsCloseProjectsConfirmationDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) scratch_dialogs_close_projects_confirmation_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ScratchDialogsCloseProjectsConfirmationDialog), 0, (GInstanceInitFunc) scratch_dialogs_close_projects_confirmation_dialog_instance_init, NULL };
	GType scratch_dialogs_close_projects_confirmation_dialog_type_id;
	scratch_dialogs_close_projects_confirmation_dialog_type_id = g_type_register_static (GRANITE_TYPE_MESSAGE_DIALOG, "ScratchDialogsCloseProjectsConfirmationDialog", &g_define_type_info, G_TYPE_FLAG_NONE);
	ScratchDialogsCloseProjectsConfirmationDialog_private_offset = g_type_add_instance_private (scratch_dialogs_close_projects_confirmation_dialog_type_id, sizeof (ScratchDialogsCloseProjectsConfirmationDialogPrivate));
	return scratch_dialogs_close_projects_confirmation_dialog_type_id;
}

GType
scratch_dialogs_close_projects_confirmation_dialog_get_type (void)
{
	static gsize scratch_dialogs_close_projects_confirmation_dialog_type_id__once = 0;
	if (g_once_init_enter (&scratch_dialogs_close_projects_confirmation_dialog_type_id__once)) {
		GType scratch_dialogs_close_projects_confirmation_dialog_type_id;
		scratch_dialogs_close_projects_confirmation_dialog_type_id = scratch_dialogs_close_projects_confirmation_dialog_get_type_once ();
		g_once_init_leave (&scratch_dialogs_close_projects_confirmation_dialog_type_id__once, scratch_dialogs_close_projects_confirmation_dialog_type_id);
	}
	return scratch_dialogs_close_projects_confirmation_dialog_type_id__once;
}

static void
_vala_scratch_dialogs_close_projects_confirmation_dialog_get_property (GObject * object,
                                                                       guint property_id,
                                                                       GValue * value,
                                                                       GParamSpec * pspec)
{
	ScratchDialogsCloseProjectsConfirmationDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SCRATCH_DIALOGS_TYPE_CLOSE_PROJECTS_CONFIRMATION_DIALOG, ScratchDialogsCloseProjectsConfirmationDialog);
	switch (property_id) {
		case SCRATCH_DIALOGS_CLOSE_PROJECTS_CONFIRMATION_DIALOG_N_PARENTS_PROPERTY:
		g_value_set_uint (value, scratch_dialogs_close_projects_confirmation_dialog_get_n_parents (self));
		break;
		case SCRATCH_DIALOGS_CLOSE_PROJECTS_CONFIRMATION_DIALOG_N_CHILDREN_PROPERTY:
		g_value_set_uint (value, scratch_dialogs_close_projects_confirmation_dialog_get_n_children (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_scratch_dialogs_close_projects_confirmation_dialog_set_property (GObject * object,
                                                                       guint property_id,
                                                                       const GValue * value,
                                                                       GParamSpec * pspec)
{
	ScratchDialogsCloseProjectsConfirmationDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SCRATCH_DIALOGS_TYPE_CLOSE_PROJECTS_CONFIRMATION_DIALOG, ScratchDialogsCloseProjectsConfirmationDialog);
	switch (property_id) {
		case SCRATCH_DIALOGS_CLOSE_PROJECTS_CONFIRMATION_DIALOG_N_PARENTS_PROPERTY:
		scratch_dialogs_close_projects_confirmation_dialog_set_n_parents (self, g_value_get_uint (value));
		break;
		case SCRATCH_DIALOGS_CLOSE_PROJECTS_CONFIRMATION_DIALOG_N_CHILDREN_PROPERTY:
		scratch_dialogs_close_projects_confirmation_dialog_set_n_children (self, g_value_get_uint (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

