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

/*
 * Seahorse
 *
 * Copyright (C) 2009 Stefan Walter
 *
 * 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/>.
 */

#include "seahorse-gkr.h"
#include <gtk/gtk.h>
#include <glib.h>
#include <gio/gio.h>
#include <glib-object.h>
#include <gdk/gdk.h>
#include <gobject/gvaluecollector.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 _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _SeahorseGkrParamSpecDialog SeahorseGkrParamSpecDialog;

struct _SeahorseGkrParamSpecDialog {
	GParamSpec parent_instance;
};

static gpointer seahorse_gkr_dialog_parent_class = NULL;

static void seahorse_gkr_dialog_update_wait_cursor (GtkWidget* widget);
static void __lambda14_ (void* data);
static void ___lambda14__gdestroy_notify (void* data);
static void _seahorse_gkr_dialog_update_wait_cursor_gtk_widget_realize (GtkWidget* _sender,
                                                                 gpointer self);
static void seahorse_gkr_dialog_finalize (SeahorseGkrDialog * obj);
static GType seahorse_gkr_dialog_get_type_once (void);

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

static void
seahorse_gkr_dialog_update_wait_cursor (GtkWidget* widget)
{
	GCancellable* cancellable = NULL;
	gconstpointer _tmp0_;
	GCancellable* _tmp1_;
	GCancellable* _tmp2_;
	GdkCursor* cursor = NULL;
	gconstpointer _tmp4_;
	GdkCursor* _tmp5_;
	GdkCursor* _tmp6_;
	GdkWindow* _tmp11_;
	GdkCursor* _tmp12_;
	g_return_if_fail (widget != NULL);
	_tmp0_ = g_object_get_data ((GObject*) widget, "gkr-request");
	_tmp1_ = _g_object_ref0 ((GCancellable*) _tmp0_);
	cancellable = _tmp1_;
	_tmp2_ = cancellable;
	if (_tmp2_ == NULL) {
		GdkWindow* _tmp3_;
		_tmp3_ = gtk_widget_get_window (widget);
		gdk_window_set_cursor (_tmp3_, NULL);
		_g_object_unref0 (cancellable);
		return;
	}
	_tmp4_ = g_object_get_data ((GObject*) widget, "wait-cursor");
	_tmp5_ = _g_object_ref0 ((GdkCursor*) _tmp4_);
	cursor = _tmp5_;
	_tmp6_ = cursor;
	if (_tmp6_ == NULL) {
		GdkDisplay* _tmp7_;
		GdkCursor* _tmp8_;
		GdkCursor* _tmp9_;
		GdkCursor* _tmp10_;
		_tmp7_ = gdk_display_get_default ();
		_tmp8_ = gdk_cursor_new_from_name (_tmp7_, "wait");
		_g_object_unref0 (cursor);
		cursor = _tmp8_;
		_tmp9_ = cursor;
		_tmp10_ = _g_object_ref0 (_tmp9_);
		g_object_set_data_full ((GObject*) widget, "wait-cursor", _tmp10_, g_object_unref);
	}
	_tmp11_ = gtk_widget_get_window (widget);
	_tmp12_ = cursor;
	gdk_window_set_cursor (_tmp11_, _tmp12_);
	_g_object_unref0 (cursor);
	_g_object_unref0 (cancellable);
}

static void
__lambda14_ (void* data)
{
	GCancellable* c = NULL;
	GCancellable* _tmp0_;
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (data, g_cancellable_get_type (), GCancellable));
	c = _tmp0_;
	g_cancellable_cancel (c);
	g_object_unref ((GObject*) c);
	_g_object_unref0 (c);
}

static void
___lambda14__gdestroy_notify (void* data)
{
	__lambda14_ (data);
}

static void
_seahorse_gkr_dialog_update_wait_cursor_gtk_widget_realize (GtkWidget* _sender,
                                                            gpointer self)
{
	seahorse_gkr_dialog_update_wait_cursor (_sender);
}

GCancellable*
seahorse_gkr_dialog_begin_request (GtkWidget* dialog)
{
	GCancellable* cancellable = NULL;
	GCancellable* _tmp0_;
	GCancellable* _tmp1_;
	GObject* _tmp2_;
	GCancellable* result;
	g_return_val_if_fail (dialog != NULL, NULL);
	seahorse_gkr_dialog_complete_request (dialog, TRUE);
	_tmp0_ = g_cancellable_new ();
	cancellable = _tmp0_;
	_tmp1_ = cancellable;
	_tmp2_ = g_object_ref ((GObject*) _tmp1_);
	g_object_set_data_full ((GObject*) dialog, "gkr-request", _tmp2_, ___lambda14__gdestroy_notify);
	if (gtk_widget_get_realized (dialog)) {
		seahorse_gkr_dialog_update_wait_cursor (dialog);
	} else {
		g_signal_connect (dialog, "realize", (GCallback) _seahorse_gkr_dialog_update_wait_cursor_gtk_widget_realize, NULL);
	}
	gtk_widget_set_sensitive (dialog, FALSE);
	result = cancellable;
	return result;
}

void
seahorse_gkr_dialog_complete_request (GtkWidget* dialog,
                                      gboolean cancel)
{
	GCancellable* cancellable = NULL;
	gpointer _tmp0_;
	gboolean _tmp1_ = FALSE;
	GCancellable* _tmp2_;
	g_return_if_fail (dialog != NULL);
	_tmp0_ = g_object_steal_data ((GObject*) dialog, "gkr-request");
	cancellable = (GCancellable*) _tmp0_;
	_tmp2_ = cancellable;
	if (_tmp2_ != NULL) {
		_tmp1_ = cancel;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		GCancellable* _tmp3_;
		_tmp3_ = cancellable;
		g_cancellable_cancel (_tmp3_);
	}
	if (gtk_widget_get_realized (dialog)) {
		seahorse_gkr_dialog_update_wait_cursor (dialog);
	}
	gtk_widget_set_sensitive (dialog, TRUE);
	_g_object_unref0 (cancellable);
}

SeahorseGkrDialog*
seahorse_gkr_dialog_construct (GType object_type)
{
	SeahorseGkrDialog* self = NULL;
	self = (SeahorseGkrDialog*) g_type_create_instance (object_type);
	return self;
}

SeahorseGkrDialog*
seahorse_gkr_dialog_new (void)
{
	return seahorse_gkr_dialog_construct (SEAHORSE_GKR_TYPE_DIALOG);
}

static void
seahorse_gkr_value_dialog_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
seahorse_gkr_value_dialog_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		seahorse_gkr_dialog_unref (value->data[0].v_pointer);
	}
}

static void
seahorse_gkr_value_dialog_copy_value (const GValue* src_value,
                                      GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = seahorse_gkr_dialog_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
seahorse_gkr_value_dialog_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
seahorse_gkr_value_dialog_collect_value (GValue* value,
                                         guint n_collect_values,
                                         GTypeCValue* collect_values,
                                         guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		SeahorseGkrDialog * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = seahorse_gkr_dialog_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
seahorse_gkr_value_dialog_lcopy_value (const GValue* value,
                                       guint n_collect_values,
                                       GTypeCValue* collect_values,
                                       guint collect_flags)
{
	SeahorseGkrDialog ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = seahorse_gkr_dialog_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
seahorse_gkr_param_spec_dialog (const gchar* name,
                                const gchar* nick,
                                const gchar* blurb,
                                GType object_type,
                                GParamFlags flags)
{
	SeahorseGkrParamSpecDialog* spec;
	g_return_val_if_fail (g_type_is_a (object_type, SEAHORSE_GKR_TYPE_DIALOG), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
seahorse_gkr_value_get_dialog (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, SEAHORSE_GKR_TYPE_DIALOG), NULL);
	return value->data[0].v_pointer;
}

void
seahorse_gkr_value_set_dialog (GValue* value,
                               gpointer v_object)
{
	SeahorseGkrDialog * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, SEAHORSE_GKR_TYPE_DIALOG));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, SEAHORSE_GKR_TYPE_DIALOG));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		seahorse_gkr_dialog_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		seahorse_gkr_dialog_unref (old);
	}
}

void
seahorse_gkr_value_take_dialog (GValue* value,
                                gpointer v_object)
{
	SeahorseGkrDialog * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, SEAHORSE_GKR_TYPE_DIALOG));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, SEAHORSE_GKR_TYPE_DIALOG));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		seahorse_gkr_dialog_unref (old);
	}
}

static void
seahorse_gkr_dialog_class_init (SeahorseGkrDialogClass * klass,
                                gpointer klass_data)
{
	seahorse_gkr_dialog_parent_class = g_type_class_peek_parent (klass);
	((SeahorseGkrDialogClass *) klass)->finalize = seahorse_gkr_dialog_finalize;
}

static void
seahorse_gkr_dialog_instance_init (SeahorseGkrDialog * self,
                                   gpointer klass)
{
	self->ref_count = 1;
}

static void
seahorse_gkr_dialog_finalize (SeahorseGkrDialog * obj)
{
	SeahorseGkrDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SEAHORSE_GKR_TYPE_DIALOG, SeahorseGkrDialog);
	g_signal_handlers_destroy (self);
}

 G_GNUC_NO_INLINE static GType
seahorse_gkr_dialog_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { seahorse_gkr_value_dialog_init, seahorse_gkr_value_dialog_free_value, seahorse_gkr_value_dialog_copy_value, seahorse_gkr_value_dialog_peek_pointer, "p", seahorse_gkr_value_dialog_collect_value, "p", seahorse_gkr_value_dialog_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (SeahorseGkrDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) seahorse_gkr_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SeahorseGkrDialog), 0, (GInstanceInitFunc) seahorse_gkr_dialog_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType seahorse_gkr_dialog_type_id;
	seahorse_gkr_dialog_type_id = g_type_register_fundamental (g_type_fundamental_next (), "SeahorseGkrDialog", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return seahorse_gkr_dialog_type_id;
}

GType
seahorse_gkr_dialog_get_type (void)
{
	static volatile gsize seahorse_gkr_dialog_type_id__once = 0;
	if (g_once_init_enter (&seahorse_gkr_dialog_type_id__once)) {
		GType seahorse_gkr_dialog_type_id;
		seahorse_gkr_dialog_type_id = seahorse_gkr_dialog_get_type_once ();
		g_once_init_leave (&seahorse_gkr_dialog_type_id__once, seahorse_gkr_dialog_type_id);
	}
	return seahorse_gkr_dialog_type_id__once;
}

gpointer
seahorse_gkr_dialog_ref (gpointer instance)
{
	SeahorseGkrDialog * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
seahorse_gkr_dialog_unref (gpointer instance)
{
	SeahorseGkrDialog * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		SEAHORSE_GKR_DIALOG_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

