/* delete-dialog.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from delete-dialog.vala, do not modify */

/*
 * Seahorse
 *
 * Copyright (C) 2011 Collabora Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 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
 * Lesser 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, see <http://www.gnu.org/licenses/>.
 *
 * Author: Stef Walter <stefw@collabora.co.uk>
 */

#include "seahorse-common.h"
#include <gtk/gtk.h>
#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.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  {
	SEAHORSE_DELETE_DIALOG_0_PROPERTY,
	SEAHORSE_DELETE_DIALOG_CHECK_LABEL_PROPERTY,
	SEAHORSE_DELETE_DIALOG_CHECK_VALUE_PROPERTY,
	SEAHORSE_DELETE_DIALOG_CHECK_REQUIRE_PROPERTY,
	SEAHORSE_DELETE_DIALOG_NUM_PROPERTIES
};
static GParamSpec* seahorse_delete_dialog_properties[SEAHORSE_DELETE_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 _SeahorseDeleteDialogPrivate {
	GtkToggleButton* _check;
	gboolean _check_require;
};

static gint SeahorseDeleteDialog_private_offset;
static gpointer seahorse_delete_dialog_parent_class = NULL;

static void seahorse_delete_dialog_update_response_buttons (SeahorseDeleteDialog* self);
static GObject * seahorse_delete_dialog_constructor (GType type,
                                              guint n_construct_properties,
                                              GObjectConstructParam * construct_properties);
static void _seahorse_delete_dialog___lambda13_ (SeahorseDeleteDialog* self,
                                          GtkToggleButton* toggle);
static void __seahorse_delete_dialog___lambda13__gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                                     gpointer self);
static void seahorse_delete_dialog_finalize (GObject * obj);
static GType seahorse_delete_dialog_get_type_once (void);
static void _vala_seahorse_delete_dialog_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec);
static void _vala_seahorse_delete_dialog_set_property (GObject * object,
                                                guint property_id,
                                                const GValue * value,
                                                GParamSpec * pspec);

static inline gpointer
seahorse_delete_dialog_get_instance_private (SeahorseDeleteDialog* self)
{
	return G_STRUCT_MEMBER_P (self, SeahorseDeleteDialog_private_offset);
}

GtkDialog*
seahorse_delete_dialog_constructv (GType object_type,
                                   GtkWindow* parent,
                                   const gchar* format,
                                   va_list _vala_va_list)
{
	SeahorseDeleteDialog * self = NULL;
	va_list _tmp0_ = {0};
	gchar* _tmp1_;
	gchar* _tmp2_;
	g_return_val_if_fail (format != NULL, NULL);
	va_copy (_tmp0_, _vala_va_list);
	_tmp1_ = g_strdup_vprintf (format, _tmp0_);
	_tmp2_ = _tmp1_;
	self = (SeahorseDeleteDialog*) g_object_new (object_type, "message-type", GTK_MESSAGE_QUESTION, "transient-for", parent, "text", _tmp2_, NULL);
	_g_free0 (_tmp2_);
	va_end (_tmp0_);
	return (GtkDialog*) self;
}

GtkDialog*
seahorse_delete_dialog_new (GtkWindow* parent,
                            const gchar* format,
                            ...)
{
	va_list _vala_va_list_obj;
	va_start (_vala_va_list_obj, format);
	return seahorse_delete_dialog_constructv (SEAHORSE_TYPE_DELETE_DIALOG, parent, format, _vala_va_list_obj);
}

GtkDialog*
seahorse_delete_dialog_construct (GType object_type,
                                  GtkWindow* parent,
                                  const gchar* format,
                                  ...)
{
	va_list _vala_va_list_obj;
	va_start (_vala_va_list_obj, format);
	return seahorse_delete_dialog_constructv (object_type, parent, format, _vala_va_list_obj);
}

static void
seahorse_delete_dialog_update_response_buttons (SeahorseDeleteDialog* self)
{
	gboolean _tmp0_ = FALSE;
	g_return_if_fail (self != NULL);
	if (!self->priv->_check_require) {
		_tmp0_ = TRUE;
	} else {
		GtkToggleButton* _tmp1_;
		_tmp1_ = self->priv->_check;
		_tmp0_ = gtk_toggle_button_get_active (_tmp1_);
	}
	gtk_dialog_set_response_sensitive ((GtkDialog*) self, (gint) GTK_RESPONSE_OK, _tmp0_);
}

gboolean
seahorse_delete_dialog_prompt (GtkWindow* parent,
                               const gchar* text)
{
	GtkDialog* dialog = NULL;
	SeahorseDeleteDialog* _tmp0_;
	gint response = 0;
	gboolean result;
	g_return_val_if_fail (text != NULL, FALSE);
	_tmp0_ = (SeahorseDeleteDialog*) seahorse_delete_dialog_new (parent, "%s", text, NULL);
	g_object_ref_sink (_tmp0_);
	dialog = (GtkDialog*) _tmp0_;
	response = gtk_dialog_run (dialog);
	gtk_widget_destroy ((GtkWidget*) dialog);
	result = response == ((gint) GTK_RESPONSE_OK);
	_g_object_unref0 (dialog);
	return result;
}

const gchar*
seahorse_delete_dialog_get_check_label (SeahorseDeleteDialog* self)
{
	const gchar* result;
	GtkToggleButton* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_check;
	if (gtk_widget_get_visible ((GtkWidget*) _tmp0_)) {
		GtkToggleButton* _tmp1_;
		const gchar* _tmp2_;
		_tmp1_ = self->priv->_check;
		_tmp2_ = gtk_button_get_label ((GtkButton*) _tmp1_);
		result = _tmp2_;
		return result;
	}
	result = NULL;
	return result;
}

void
seahorse_delete_dialog_set_check_label (SeahorseDeleteDialog* self,
                                        const gchar* value)
{
	GtkToggleButton* _tmp2_;
	g_return_if_fail (self != NULL);
	if (value == NULL) {
		GtkToggleButton* _tmp0_;
		_tmp0_ = self->priv->_check;
		gtk_widget_hide ((GtkWidget*) _tmp0_);
		value = "";
	} else {
		GtkToggleButton* _tmp1_;
		_tmp1_ = self->priv->_check;
		gtk_widget_show ((GtkWidget*) _tmp1_);
	}
	_tmp2_ = self->priv->_check;
	gtk_button_set_label ((GtkButton*) _tmp2_, value);
	g_object_notify_by_pspec ((GObject *) self, seahorse_delete_dialog_properties[SEAHORSE_DELETE_DIALOG_CHECK_LABEL_PROPERTY]);
}

gboolean
seahorse_delete_dialog_get_check_value (SeahorseDeleteDialog* self)
{
	gboolean result;
	GtkToggleButton* _tmp0_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->_check;
	if (gtk_widget_get_visible ((GtkWidget*) _tmp0_)) {
		GtkToggleButton* _tmp1_;
		_tmp1_ = self->priv->_check;
		result = gtk_toggle_button_get_active (_tmp1_);
		return result;
	}
	result = FALSE;
	return result;
}

void
seahorse_delete_dialog_set_check_value (SeahorseDeleteDialog* self,
                                        gboolean value)
{
	GtkToggleButton* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_check;
	gtk_toggle_button_set_active (_tmp0_, value);
	g_object_notify_by_pspec ((GObject *) self, seahorse_delete_dialog_properties[SEAHORSE_DELETE_DIALOG_CHECK_VALUE_PROPERTY]);
}

gboolean
seahorse_delete_dialog_get_check_require (SeahorseDeleteDialog* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_check_require;
	return result;
}

void
seahorse_delete_dialog_set_check_require (SeahorseDeleteDialog* self,
                                          gboolean value)
{
	g_return_if_fail (self != NULL);
	self->priv->_check_require = value;
	seahorse_delete_dialog_update_response_buttons (self);
	g_object_notify_by_pspec ((GObject *) self, seahorse_delete_dialog_properties[SEAHORSE_DELETE_DIALOG_CHECK_REQUIRE_PROPERTY]);
}

static void
_seahorse_delete_dialog___lambda13_ (SeahorseDeleteDialog* self,
                                     GtkToggleButton* toggle)
{
	g_return_if_fail (toggle != NULL);
	seahorse_delete_dialog_update_response_buttons (self);
}

static void
__seahorse_delete_dialog___lambda13__gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                                gpointer self)
{
	_seahorse_delete_dialog___lambda13_ ((SeahorseDeleteDialog*) self, _sender);
}

static GObject *
seahorse_delete_dialog_constructor (GType type,
                                    guint n_construct_properties,
                                    GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	SeahorseDeleteDialog * self;
	GtkCheckButton* _tmp0_;
	GtkWidget* _tmp1_;
	GtkToggleButton* _tmp2_;
	GtkToggleButton* _tmp3_;
	GtkButton* cancel = NULL;
	GtkButton* _tmp4_;
	GtkButton* _tmp5_;
	GtkButton* _tmp6_;
	GtkButton* delet = NULL;
	GtkButton* _tmp7_;
	GtkButton* _tmp8_;
	GtkStyleContext* _tmp9_;
	GtkButton* _tmp10_;
	GtkButton* _tmp11_;
	parent_class = G_OBJECT_CLASS (seahorse_delete_dialog_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SEAHORSE_TYPE_DELETE_DIALOG, SeahorseDeleteDialog);
	gtk_window_set_modal ((GtkWindow*) self, TRUE);
	gtk_window_set_destroy_with_parent ((GtkWindow*) self, TRUE);
	_tmp0_ = (GtkCheckButton*) gtk_check_button_new ();
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->_check);
	self->priv->_check = (GtkToggleButton*) _tmp0_;
	_tmp1_ = gtk_message_dialog_get_message_area ((GtkMessageDialog*) self);
	_tmp2_ = self->priv->_check;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_container_get_type (), GtkContainer), (GtkWidget*) _tmp2_);
	_tmp3_ = self->priv->_check;
	g_signal_connect_object (_tmp3_, "toggled", (GCallback) __seahorse_delete_dialog___lambda13__gtk_toggle_button_toggled, self, 0);
	_tmp4_ = (GtkButton*) gtk_button_new_with_mnemonic (_ ("_Cancel"));
	g_object_ref_sink (_tmp4_);
	cancel = _tmp4_;
	_tmp5_ = cancel;
	gtk_dialog_add_action_widget ((GtkDialog*) self, (GtkWidget*) _tmp5_, (gint) GTK_RESPONSE_CANCEL);
	_tmp6_ = cancel;
	gtk_widget_show ((GtkWidget*) _tmp6_);
	_tmp7_ = (GtkButton*) gtk_button_new_with_mnemonic (_ ("_Delete"));
	g_object_ref_sink (_tmp7_);
	delet = _tmp7_;
	_tmp8_ = delet;
	_tmp9_ = gtk_widget_get_style_context ((GtkWidget*) _tmp8_);
	gtk_style_context_add_class (_tmp9_, "destructive-action");
	_tmp10_ = delet;
	gtk_dialog_add_action_widget ((GtkDialog*) self, (GtkWidget*) _tmp10_, (gint) GTK_RESPONSE_OK);
	_tmp11_ = delet;
	gtk_widget_show ((GtkWidget*) _tmp11_);
	_g_object_unref0 (delet);
	_g_object_unref0 (cancel);
	return obj;
}

static void
seahorse_delete_dialog_class_init (SeahorseDeleteDialogClass * klass,
                                   gpointer klass_data)
{
	seahorse_delete_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &SeahorseDeleteDialog_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_seahorse_delete_dialog_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_seahorse_delete_dialog_set_property;
	G_OBJECT_CLASS (klass)->constructor = seahorse_delete_dialog_constructor;
	G_OBJECT_CLASS (klass)->finalize = seahorse_delete_dialog_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), SEAHORSE_DELETE_DIALOG_CHECK_LABEL_PROPERTY, seahorse_delete_dialog_properties[SEAHORSE_DELETE_DIALOG_CHECK_LABEL_PROPERTY] = g_param_spec_string ("check-label", "check-label", "check-label", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), SEAHORSE_DELETE_DIALOG_CHECK_VALUE_PROPERTY, seahorse_delete_dialog_properties[SEAHORSE_DELETE_DIALOG_CHECK_VALUE_PROPERTY] = g_param_spec_boolean ("check-value", "check-value", "check-value", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), SEAHORSE_DELETE_DIALOG_CHECK_REQUIRE_PROPERTY, seahorse_delete_dialog_properties[SEAHORSE_DELETE_DIALOG_CHECK_REQUIRE_PROPERTY] = g_param_spec_boolean ("check-require", "check-require", "check-require", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
seahorse_delete_dialog_instance_init (SeahorseDeleteDialog * self,
                                      gpointer klass)
{
	self->priv = seahorse_delete_dialog_get_instance_private (self);
}

static void
seahorse_delete_dialog_finalize (GObject * obj)
{
	SeahorseDeleteDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SEAHORSE_TYPE_DELETE_DIALOG, SeahorseDeleteDialog);
	_g_object_unref0 (self->priv->_check);
	G_OBJECT_CLASS (seahorse_delete_dialog_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
seahorse_delete_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SeahorseDeleteDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) seahorse_delete_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SeahorseDeleteDialog), 0, (GInstanceInitFunc) seahorse_delete_dialog_instance_init, NULL };
	GType seahorse_delete_dialog_type_id;
	seahorse_delete_dialog_type_id = g_type_register_static (gtk_message_dialog_get_type (), "SeahorseDeleteDialog", &g_define_type_info, 0);
	SeahorseDeleteDialog_private_offset = g_type_add_instance_private (seahorse_delete_dialog_type_id, sizeof (SeahorseDeleteDialogPrivate));
	return seahorse_delete_dialog_type_id;
}

GType
seahorse_delete_dialog_get_type (void)
{
	static volatile gsize seahorse_delete_dialog_type_id__once = 0;
	if (g_once_init_enter (&seahorse_delete_dialog_type_id__once)) {
		GType seahorse_delete_dialog_type_id;
		seahorse_delete_dialog_type_id = seahorse_delete_dialog_get_type_once ();
		g_once_init_leave (&seahorse_delete_dialog_type_id__once, seahorse_delete_dialog_type_id);
	}
	return seahorse_delete_dialog_type_id__once;
}

static void
_vala_seahorse_delete_dialog_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec)
{
	SeahorseDeleteDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SEAHORSE_TYPE_DELETE_DIALOG, SeahorseDeleteDialog);
	switch (property_id) {
		case SEAHORSE_DELETE_DIALOG_CHECK_LABEL_PROPERTY:
		g_value_set_string (value, seahorse_delete_dialog_get_check_label (self));
		break;
		case SEAHORSE_DELETE_DIALOG_CHECK_VALUE_PROPERTY:
		g_value_set_boolean (value, seahorse_delete_dialog_get_check_value (self));
		break;
		case SEAHORSE_DELETE_DIALOG_CHECK_REQUIRE_PROPERTY:
		g_value_set_boolean (value, seahorse_delete_dialog_get_check_require (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_seahorse_delete_dialog_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec)
{
	SeahorseDeleteDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SEAHORSE_TYPE_DELETE_DIALOG, SeahorseDeleteDialog);
	switch (property_id) {
		case SEAHORSE_DELETE_DIALOG_CHECK_LABEL_PROPERTY:
		seahorse_delete_dialog_set_check_label (self, g_value_get_string (value));
		break;
		case SEAHORSE_DELETE_DIALOG_CHECK_VALUE_PROPERTY:
		seahorse_delete_dialog_set_check_value (self, g_value_get_boolean (value));
		break;
		case SEAHORSE_DELETE_DIALOG_CHECK_REQUIRE_PROPERTY:
		seahorse_delete_dialog_set_check_require (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

