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

/*
 * Seahorse
 *
 * Copyright (C) 2004,2005 Stefan Walter
 * Copyright (C) 2011 Collabora Ltd.
 * Copyright (C) 2012 Stefan Walter
 *
 * 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 2 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 copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 */

#include <glib.h>
#include <glib-object.h>
#include "seahorse-common.h"
#include <gtk/gtk.h>
#include <gio/gio.h>

typedef struct _Block2Data Block2Data;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL)))
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))

struct _Block2Data {
	int _ref_count_;
	GMainLoop* loop;
	GAsyncResult* _result_;
};



static Block2Data* block2_data_ref (Block2Data* _data2_);
static void block2_data_unref (void * _userdata_);
static void ____lambda6_ (Block2Data* _data2_, GObject* obj, GAsyncResult* res);
static void _____lambda6__gasync_ready_callback (GObject* source_object, GAsyncResult* res, gpointer self);


SeahorseDeleter* seahorse_deletable_create_deleter (SeahorseDeletable* self) {
#line 24 "/data/src/seahorse/common/deletable.vala"
	g_return_val_if_fail (self != NULL, NULL);
#line 24 "/data/src/seahorse/common/deletable.vala"
	return SEAHORSE_DELETABLE_GET_INTERFACE (self)->create_deleter (self);
#line 55 "deletable.c"
}


gboolean seahorse_deletable_can_delete (GObject* obj) {
	gboolean result = FALSE;
	GObject* _tmp0_ = NULL;
#line 27 "/data/src/seahorse/common/deletable.vala"
	g_return_val_if_fail (obj != NULL, FALSE);
#line 28 "/data/src/seahorse/common/deletable.vala"
	_tmp0_ = obj;
#line 28 "/data/src/seahorse/common/deletable.vala"
	if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, SEAHORSE_TYPE_DELETABLE)) {
#line 68 "deletable.c"
		GObject* _tmp1_ = NULL;
		gboolean _tmp2_ = FALSE;
		gboolean _tmp3_ = FALSE;
#line 29 "/data/src/seahorse/common/deletable.vala"
		_tmp1_ = obj;
#line 29 "/data/src/seahorse/common/deletable.vala"
		_tmp2_ = seahorse_deletable_get_deletable (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, SEAHORSE_TYPE_DELETABLE, SeahorseDeletable));
#line 29 "/data/src/seahorse/common/deletable.vala"
		_tmp3_ = _tmp2_;
#line 29 "/data/src/seahorse/common/deletable.vala"
		result = _tmp3_;
#line 29 "/data/src/seahorse/common/deletable.vala"
		return result;
#line 82 "deletable.c"
	}
#line 30 "/data/src/seahorse/common/deletable.vala"
	result = FALSE;
#line 30 "/data/src/seahorse/common/deletable.vala"
	return result;
#line 88 "deletable.c"
}


static Block2Data* block2_data_ref (Block2Data* _data2_) {
#line 33 "/data/src/seahorse/common/deletable.vala"
	g_atomic_int_inc (&_data2_->_ref_count_);
#line 33 "/data/src/seahorse/common/deletable.vala"
	return _data2_;
#line 97 "deletable.c"
}


static void block2_data_unref (void * _userdata_) {
	Block2Data* _data2_;
	_data2_ = (Block2Data*) _userdata_;
#line 33 "/data/src/seahorse/common/deletable.vala"
	if (g_atomic_int_dec_and_test (&_data2_->_ref_count_)) {
#line 33 "/data/src/seahorse/common/deletable.vala"
		_g_object_unref0 (_data2_->_result_);
#line 33 "/data/src/seahorse/common/deletable.vala"
		_g_main_loop_unref0 (_data2_->loop);
#line 33 "/data/src/seahorse/common/deletable.vala"
		g_slice_free (Block2Data, _data2_);
#line 112 "deletable.c"
	}
}


static gpointer _g_object_ref0 (gpointer self) {
#line 42 "/data/src/seahorse/common/deletable.vala"
	return self ? g_object_ref (self) : NULL;
#line 120 "deletable.c"
}


static void ____lambda6_ (Block2Data* _data2_, GObject* obj, GAsyncResult* res) {
	GAsyncResult* _tmp0_ = NULL;
	GAsyncResult* _tmp1_ = NULL;
	GMainLoop* _tmp2_ = NULL;
#line 69 "/data/src/seahorse/common/deletable.vala"
	g_return_if_fail (res != NULL);
#line 70 "/data/src/seahorse/common/deletable.vala"
	_tmp0_ = res;
#line 70 "/data/src/seahorse/common/deletable.vala"
	_tmp1_ = _g_object_ref0 (_tmp0_);
#line 70 "/data/src/seahorse/common/deletable.vala"
	_g_object_unref0 (_data2_->_result_);
#line 70 "/data/src/seahorse/common/deletable.vala"
	_data2_->_result_ = _tmp1_;
#line 71 "/data/src/seahorse/common/deletable.vala"
	_tmp2_ = _data2_->loop;
#line 71 "/data/src/seahorse/common/deletable.vala"
	g_main_loop_quit (_tmp2_);
#line 142 "deletable.c"
}


static void _____lambda6__gasync_ready_callback (GObject* source_object, GAsyncResult* res, gpointer self) {
#line 69 "/data/src/seahorse/common/deletable.vala"
	____lambda6_ (self, source_object, res);
#line 69 "/data/src/seahorse/common/deletable.vala"
	block2_data_unref (self);
#line 151 "deletable.c"
}


gint seahorse_deletable_delete_with_prompt_wait (GList* objects, GtkWindow* parent, GError** error) {
	gint result = 0;
	Block2Data* _data2_;
	GMainLoop* _tmp0_ = NULL;
	gint count = 0;
	GHashTable* pending = NULL;
	GHashFunc _tmp1_ = NULL;
	GEqualFunc _tmp2_ = NULL;
	GHashTable* _tmp3_ = NULL;
	GList* _tmp4_ = NULL;
	GList* _tmp8_ = NULL;
	GError * _inner_error_ = NULL;
#line 33 "/data/src/seahorse/common/deletable.vala"
	_data2_ = g_slice_new0 (Block2Data);
#line 33 "/data/src/seahorse/common/deletable.vala"
	_data2_->_ref_count_ = 1;
#line 36 "/data/src/seahorse/common/deletable.vala"
	_tmp0_ = g_main_loop_new (NULL, FALSE);
#line 36 "/data/src/seahorse/common/deletable.vala"
	_data2_->loop = _tmp0_;
#line 37 "/data/src/seahorse/common/deletable.vala"
	_data2_->_result_ = NULL;
#line 38 "/data/src/seahorse/common/deletable.vala"
	count = 0;
#line 41 "/data/src/seahorse/common/deletable.vala"
	_tmp1_ = g_direct_hash;
#line 41 "/data/src/seahorse/common/deletable.vala"
	_tmp2_ = g_direct_equal;
#line 41 "/data/src/seahorse/common/deletable.vala"
	_tmp3_ = g_hash_table_new_full (_tmp1_, _tmp2_, NULL, NULL);
#line 41 "/data/src/seahorse/common/deletable.vala"
	pending = _tmp3_;
#line 42 "/data/src/seahorse/common/deletable.vala"
	_tmp4_ = objects;
#line 189 "deletable.c"
	{
		GList* obj_collection = NULL;
		GList* obj_it = NULL;
#line 42 "/data/src/seahorse/common/deletable.vala"
		obj_collection = _tmp4_;
#line 42 "/data/src/seahorse/common/deletable.vala"
		for (obj_it = obj_collection; obj_it != NULL; obj_it = obj_it->next) {
#line 197 "deletable.c"
			GObject* _tmp5_ = NULL;
			GObject* obj = NULL;
#line 42 "/data/src/seahorse/common/deletable.vala"
			_tmp5_ = _g_object_ref0 ((GObject*) obj_it->data);
#line 42 "/data/src/seahorse/common/deletable.vala"
			obj = _tmp5_;
#line 204 "deletable.c"
			{
				GHashTable* _tmp6_ = NULL;
				GObject* _tmp7_ = NULL;
#line 43 "/data/src/seahorse/common/deletable.vala"
				_tmp6_ = pending;
#line 43 "/data/src/seahorse/common/deletable.vala"
				_tmp7_ = obj;
#line 43 "/data/src/seahorse/common/deletable.vala"
				g_hash_table_add (_tmp6_, _tmp7_);
#line 42 "/data/src/seahorse/common/deletable.vala"
				_g_object_unref0 (obj);
#line 216 "deletable.c"
			}
		}
	}
#line 45 "/data/src/seahorse/common/deletable.vala"
	_tmp8_ = objects;
#line 222 "deletable.c"
	{
		GList* obj_collection = NULL;
		GList* obj_it = NULL;
#line 45 "/data/src/seahorse/common/deletable.vala"
		obj_collection = _tmp8_;
#line 45 "/data/src/seahorse/common/deletable.vala"
		for (obj_it = obj_collection; obj_it != NULL; obj_it = obj_it->next) {
#line 230 "deletable.c"
			GObject* _tmp9_ = NULL;
			GObject* obj = NULL;
#line 45 "/data/src/seahorse/common/deletable.vala"
			_tmp9_ = _g_object_ref0 ((GObject*) obj_it->data);
#line 45 "/data/src/seahorse/common/deletable.vala"
			obj = _tmp9_;
#line 237 "deletable.c"
			{
				GHashTable* _tmp10_ = NULL;
				GObject* _tmp11_ = NULL;
				gconstpointer _tmp12_ = NULL;
				GObject* _tmp13_ = NULL;
				gboolean _tmp14_ = FALSE;
				SeahorseDeleter* deleter = NULL;
				GObject* _tmp17_ = NULL;
				SeahorseDeleter* _tmp18_ = NULL;
				GList* _tmp19_ = NULL;
				gboolean ret = FALSE;
				SeahorseDeleter* _tmp28_ = NULL;
				GtkWindow* _tmp29_ = NULL;
				gboolean _tmp30_ = FALSE;
				gboolean _tmp31_ = FALSE;
				SeahorseDeleter* _tmp32_ = NULL;
				GMainLoop* _tmp33_ = NULL;
				gboolean _tmp34_ = FALSE;
				SeahorseDeleter* _tmp35_ = NULL;
				GAsyncResult* _tmp36_ = NULL;
				gboolean _tmp37_ = FALSE;
#line 46 "/data/src/seahorse/common/deletable.vala"
				_tmp10_ = pending;
#line 46 "/data/src/seahorse/common/deletable.vala"
				_tmp11_ = obj;
#line 46 "/data/src/seahorse/common/deletable.vala"
				_tmp12_ = g_hash_table_lookup (_tmp10_, _tmp11_);
#line 46 "/data/src/seahorse/common/deletable.vala"
				if (((GObject*) _tmp12_) == NULL) {
#line 47 "/data/src/seahorse/common/deletable.vala"
					_g_object_unref0 (obj);
#line 47 "/data/src/seahorse/common/deletable.vala"
					continue;
#line 271 "deletable.c"
				}
#line 49 "/data/src/seahorse/common/deletable.vala"
				_tmp13_ = obj;
#line 49 "/data/src/seahorse/common/deletable.vala"
				_tmp14_ = seahorse_deletable_can_delete (_tmp13_);
#line 49 "/data/src/seahorse/common/deletable.vala"
				if (!_tmp14_) {
#line 279 "deletable.c"
					GHashTable* _tmp15_ = NULL;
					GObject* _tmp16_ = NULL;
#line 50 "/data/src/seahorse/common/deletable.vala"
					_tmp15_ = pending;
#line 50 "/data/src/seahorse/common/deletable.vala"
					_tmp16_ = obj;
#line 50 "/data/src/seahorse/common/deletable.vala"
					g_hash_table_remove (_tmp15_, _tmp16_);
#line 51 "/data/src/seahorse/common/deletable.vala"
					_g_object_unref0 (obj);
#line 51 "/data/src/seahorse/common/deletable.vala"
					continue;
#line 292 "deletable.c"
				}
#line 54 "/data/src/seahorse/common/deletable.vala"
				_tmp17_ = obj;
#line 54 "/data/src/seahorse/common/deletable.vala"
				_tmp18_ = seahorse_deletable_create_deleter (G_TYPE_CHECK_INSTANCE_CAST (_tmp17_, SEAHORSE_TYPE_DELETABLE, SeahorseDeletable));
#line 54 "/data/src/seahorse/common/deletable.vala"
				deleter = _tmp18_;
#line 57 "/data/src/seahorse/common/deletable.vala"
				_tmp19_ = objects;
#line 302 "deletable.c"
				{
					GList* x_collection = NULL;
					GList* x_it = NULL;
#line 57 "/data/src/seahorse/common/deletable.vala"
					x_collection = _tmp19_;
#line 57 "/data/src/seahorse/common/deletable.vala"
					for (x_it = x_collection; x_it != NULL; x_it = x_it->next) {
#line 310 "deletable.c"
						GObject* _tmp20_ = NULL;
						GObject* x = NULL;
#line 57 "/data/src/seahorse/common/deletable.vala"
						_tmp20_ = _g_object_ref0 ((GObject*) x_it->data);
#line 57 "/data/src/seahorse/common/deletable.vala"
						x = _tmp20_;
#line 317 "deletable.c"
						{
							GObject* _tmp21_ = NULL;
							GObject* _tmp22_ = NULL;
							GHashTable* _tmp23_ = NULL;
							GObject* _tmp24_ = NULL;
							gconstpointer _tmp25_ = NULL;
#line 58 "/data/src/seahorse/common/deletable.vala"
							_tmp21_ = x;
#line 58 "/data/src/seahorse/common/deletable.vala"
							_tmp22_ = obj;
#line 58 "/data/src/seahorse/common/deletable.vala"
							if (_tmp21_ == _tmp22_) {
#line 59 "/data/src/seahorse/common/deletable.vala"
								_g_object_unref0 (x);
#line 59 "/data/src/seahorse/common/deletable.vala"
								continue;
#line 334 "deletable.c"
							}
#line 60 "/data/src/seahorse/common/deletable.vala"
							_tmp23_ = pending;
#line 60 "/data/src/seahorse/common/deletable.vala"
							_tmp24_ = x;
#line 60 "/data/src/seahorse/common/deletable.vala"
							_tmp25_ = g_hash_table_lookup (_tmp23_, _tmp24_);
#line 60 "/data/src/seahorse/common/deletable.vala"
							if (((GObject*) _tmp25_) != NULL) {
#line 344 "deletable.c"
								SeahorseDeleter* _tmp26_ = NULL;
								GObject* _tmp27_ = NULL;
#line 61 "/data/src/seahorse/common/deletable.vala"
								_tmp26_ = deleter;
#line 61 "/data/src/seahorse/common/deletable.vala"
								_tmp27_ = x;
#line 61 "/data/src/seahorse/common/deletable.vala"
								seahorse_deleter_add_object (_tmp26_, _tmp27_);
#line 353 "deletable.c"
							}
#line 57 "/data/src/seahorse/common/deletable.vala"
							_g_object_unref0 (x);
#line 357 "deletable.c"
						}
					}
				}
#line 65 "/data/src/seahorse/common/deletable.vala"
				_tmp28_ = deleter;
#line 65 "/data/src/seahorse/common/deletable.vala"
				_tmp29_ = parent;
#line 65 "/data/src/seahorse/common/deletable.vala"
				_tmp30_ = seahorse_deleter_prompt (_tmp28_, _tmp29_);
#line 65 "/data/src/seahorse/common/deletable.vala"
				ret = _tmp30_;
#line 66 "/data/src/seahorse/common/deletable.vala"
				_tmp31_ = ret;
#line 66 "/data/src/seahorse/common/deletable.vala"
				if (!_tmp31_) {
#line 67 "/data/src/seahorse/common/deletable.vala"
					_g_object_unref0 (deleter);
#line 67 "/data/src/seahorse/common/deletable.vala"
					_g_object_unref0 (obj);
#line 67 "/data/src/seahorse/common/deletable.vala"
					break;
#line 379 "deletable.c"
				}
#line 69 "/data/src/seahorse/common/deletable.vala"
				_tmp32_ = deleter;
#line 69 "/data/src/seahorse/common/deletable.vala"
				seahorse_deleter_delete (_tmp32_, NULL, _____lambda6__gasync_ready_callback, block2_data_ref (_data2_));
#line 74 "/data/src/seahorse/common/deletable.vala"
				_tmp33_ = _data2_->loop;
#line 74 "/data/src/seahorse/common/deletable.vala"
				g_main_loop_run (_tmp33_);
#line 76 "/data/src/seahorse/common/deletable.vala"
				_tmp35_ = deleter;
#line 76 "/data/src/seahorse/common/deletable.vala"
				_tmp36_ = _data2_->_result_;
#line 76 "/data/src/seahorse/common/deletable.vala"
				_tmp37_ = seahorse_deleter_delete_finish (_tmp35_, _tmp36_, &_inner_error_);
#line 76 "/data/src/seahorse/common/deletable.vala"
				_tmp34_ = _tmp37_;
#line 76 "/data/src/seahorse/common/deletable.vala"
				if (_inner_error_ != NULL) {
#line 76 "/data/src/seahorse/common/deletable.vala"
					g_propagate_error (error, _inner_error_);
#line 76 "/data/src/seahorse/common/deletable.vala"
					_g_object_unref0 (deleter);
#line 76 "/data/src/seahorse/common/deletable.vala"
					_g_object_unref0 (obj);
#line 76 "/data/src/seahorse/common/deletable.vala"
					_g_hash_table_unref0 (pending);
#line 76 "/data/src/seahorse/common/deletable.vala"
					block2_data_unref (_data2_);
#line 76 "/data/src/seahorse/common/deletable.vala"
					_data2_ = NULL;
#line 76 "/data/src/seahorse/common/deletable.vala"
					return 0;
#line 413 "deletable.c"
				}
#line 76 "/data/src/seahorse/common/deletable.vala"
				if (_tmp34_) {
#line 417 "deletable.c"
					SeahorseDeleter* _tmp38_ = NULL;
					GList* _tmp39_ = NULL;
#line 77 "/data/src/seahorse/common/deletable.vala"
					_tmp38_ = deleter;
#line 77 "/data/src/seahorse/common/deletable.vala"
					_tmp39_ = seahorse_deleter_get_objects (_tmp38_);
#line 424 "deletable.c"
					{
						GList* x_collection = NULL;
						GList* x_it = NULL;
#line 77 "/data/src/seahorse/common/deletable.vala"
						x_collection = _tmp39_;
#line 77 "/data/src/seahorse/common/deletable.vala"
						for (x_it = x_collection; x_it != NULL; x_it = x_it->next) {
#line 432 "deletable.c"
							GObject* x = NULL;
#line 77 "/data/src/seahorse/common/deletable.vala"
							x = (GObject*) x_it->data;
#line 436 "deletable.c"
							{
								GHashTable* _tmp40_ = NULL;
								GObject* _tmp41_ = NULL;
								gint _tmp42_ = 0;
#line 78 "/data/src/seahorse/common/deletable.vala"
								_tmp40_ = pending;
#line 78 "/data/src/seahorse/common/deletable.vala"
								_tmp41_ = x;
#line 78 "/data/src/seahorse/common/deletable.vala"
								g_hash_table_remove (_tmp40_, _tmp41_);
#line 79 "/data/src/seahorse/common/deletable.vala"
								_tmp42_ = count;
#line 79 "/data/src/seahorse/common/deletable.vala"
								count = _tmp42_ + 1;
#line 451 "deletable.c"
							}
						}
					}
				} else {
#line 82 "/data/src/seahorse/common/deletable.vala"
					_g_object_unref0 (deleter);
#line 82 "/data/src/seahorse/common/deletable.vala"
					_g_object_unref0 (obj);
#line 82 "/data/src/seahorse/common/deletable.vala"
					break;
#line 462 "deletable.c"
				}
#line 45 "/data/src/seahorse/common/deletable.vala"
				_g_object_unref0 (deleter);
#line 45 "/data/src/seahorse/common/deletable.vala"
				_g_object_unref0 (obj);
#line 468 "deletable.c"
			}
		}
	}
#line 86 "/data/src/seahorse/common/deletable.vala"
	result = count;
#line 86 "/data/src/seahorse/common/deletable.vala"
	_g_hash_table_unref0 (pending);
#line 86 "/data/src/seahorse/common/deletable.vala"
	block2_data_unref (_data2_);
#line 86 "/data/src/seahorse/common/deletable.vala"
	_data2_ = NULL;
#line 86 "/data/src/seahorse/common/deletable.vala"
	return result;
#line 482 "deletable.c"
}


gboolean seahorse_deletable_get_deletable (SeahorseDeletable* self) {
#line 25 "/data/src/seahorse/common/deletable.vala"
	g_return_val_if_fail (self != NULL, FALSE);
#line 25 "/data/src/seahorse/common/deletable.vala"
	return SEAHORSE_DELETABLE_GET_INTERFACE (self)->get_deletable (self);
#line 491 "deletable.c"
}


static void seahorse_deletable_base_init (SeahorseDeletableIface * iface) {
#line 23 "/data/src/seahorse/common/deletable.vala"
	static gboolean initialized = FALSE;
#line 23 "/data/src/seahorse/common/deletable.vala"
	if (!initialized) {
#line 23 "/data/src/seahorse/common/deletable.vala"
		initialized = TRUE;
#line 23 "/data/src/seahorse/common/deletable.vala"
		g_object_interface_install_property (iface, g_param_spec_boolean ("deletable", "deletable", "deletable", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
#line 504 "deletable.c"
	}
}


GType seahorse_deletable_get_type (void) {
	static volatile gsize seahorse_deletable_type_id__volatile = 0;
	if (g_once_init_enter (&seahorse_deletable_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (SeahorseDeletableIface), (GBaseInitFunc) seahorse_deletable_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
		GType seahorse_deletable_type_id;
		seahorse_deletable_type_id = g_type_register_static (G_TYPE_INTERFACE, "SeahorseDeletable", &g_define_type_info, 0);
		g_type_interface_add_prerequisite (seahorse_deletable_type_id, G_TYPE_OBJECT);
		g_once_init_leave (&seahorse_deletable_type_id__volatile, seahorse_deletable_type_id);
	}
	return seahorse_deletable_type_id__volatile;
}



