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

/*
 * Seahorse
 *
 * 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/>.
 *
 * Author: Stef Walter <stefw@collabora.co.uk>
 */

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

#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block7Data Block7Data;

struct _Block7Data {
	int _ref_count_;
	GObject* object;
};



static Block7Data* block7_data_ref (Block7Data* _data7_);
static void block7_data_unref (void * _userdata_);
static void ___lambda9_ (Block7Data* _data7_);
static void ____lambda9__gtk_widget_destroy (GtkWidget* _sender, gpointer self);


GtkWindow* seahorse_viewable_create_viewer (SeahorseViewable* self, GtkWindow* parent) {
	g_return_val_if_fail (self != NULL, NULL);
	return SEAHORSE_VIEWABLE_GET_INTERFACE (self)->create_viewer (self, parent);
}


gboolean seahorse_viewable_can_view (GObject* object) {
	gboolean result = FALSE;
	GObject* _tmp0_ = NULL;
	g_return_val_if_fail (object != NULL, FALSE);
	_tmp0_ = object;
	result = G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, SEAHORSE_TYPE_VIEWABLE);
	return result;
}


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


static Block7Data* block7_data_ref (Block7Data* _data7_) {
	g_atomic_int_inc (&_data7_->_ref_count_);
	return _data7_;
}


static void block7_data_unref (void * _userdata_) {
	Block7Data* _data7_;
	_data7_ = (Block7Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data7_->_ref_count_)) {
		_g_object_unref0 (_data7_->object);
		g_slice_free (Block7Data, _data7_);
	}
}


static void ___lambda9_ (Block7Data* _data7_) {
	GObject* _tmp0_ = NULL;
	_tmp0_ = _data7_->object;
	g_object_set_data_full (_tmp0_, "viewable-window", NULL, NULL);
}


static void ____lambda9__gtk_widget_destroy (GtkWidget* _sender, gpointer self) {
	___lambda9_ (self);
}


gboolean seahorse_viewable_view (GObject* object, GtkWindow* parent) {
	gboolean result = FALSE;
	Block7Data* _data7_;
	GObject* _tmp0_ = NULL;
	GObject* _tmp1_ = NULL;
	GObject* _tmp2_ = NULL;
	gboolean _tmp3_ = FALSE;
	GtkWindow* window = NULL;
	GObject* _tmp4_ = NULL;
	gconstpointer _tmp5_ = NULL;
	GtkWindow* _tmp6_ = NULL;
	GtkWindow* _tmp7_ = NULL;
	GtkWindow* _tmp18_ = NULL;
	GtkWindow* _tmp19_ = NULL;
	g_return_val_if_fail (object != NULL, FALSE);
	_data7_ = g_slice_new0 (Block7Data);
	_data7_->_ref_count_ = 1;
	_tmp0_ = object;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (_data7_->object);
	_data7_->object = _tmp1_;
	_tmp2_ = _data7_->object;
	_tmp3_ = seahorse_viewable_can_view (_tmp2_);
	if (!_tmp3_) {
		result = FALSE;
		block7_data_unref (_data7_);
		_data7_ = NULL;
		return result;
	}
	window = NULL;
	_tmp4_ = _data7_->object;
	_tmp5_ = g_object_get_data (_tmp4_, "viewable-window");
	_tmp6_ = _g_object_ref0 ((GtkWindow*) _tmp5_);
	_g_object_unref0 (window);
	window = _tmp6_;
	_tmp7_ = window;
	if (_tmp7_ == NULL) {
		SeahorseViewable* viewable = NULL;
		GObject* _tmp8_ = NULL;
		SeahorseViewable* _tmp9_ = NULL;
		SeahorseViewable* _tmp10_ = NULL;
		GtkWindow* _tmp11_ = NULL;
		GtkWindow* _tmp12_ = NULL;
		GtkWindow* _tmp13_ = NULL;
		GObject* _tmp14_ = NULL;
		GtkWindow* _tmp15_ = NULL;
		GtkWindow* _tmp16_ = NULL;
		GtkWindow* _tmp17_ = NULL;
		_tmp8_ = _data7_->object;
		_tmp9_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, SEAHORSE_TYPE_VIEWABLE, SeahorseViewable));
		viewable = _tmp9_;
		_tmp10_ = viewable;
		_tmp11_ = parent;
		_tmp12_ = seahorse_viewable_create_viewer (_tmp10_, _tmp11_);
		_g_object_unref0 (window);
		window = _tmp12_;
		_tmp13_ = window;
		if (_tmp13_ == NULL) {
			result = FALSE;
			_g_object_unref0 (viewable);
			_g_object_unref0 (window);
			block7_data_unref (_data7_);
			_data7_ = NULL;
			return result;
		}
		_tmp14_ = _data7_->object;
		_tmp15_ = window;
		_tmp16_ = _g_object_ref0 (_tmp15_);
		g_object_set_data_full (_tmp14_, "viewable-window", _tmp16_, g_object_unref);
		_tmp17_ = window;
		g_signal_connect_data ((GtkWidget*) _tmp17_, "destroy", (GCallback) ____lambda9__gtk_widget_destroy, block7_data_ref (_data7_), (GClosureNotify) block7_data_unref, 0);
		_g_object_unref0 (viewable);
	}
	_tmp18_ = window;
	gtk_window_present (_tmp18_);
	_tmp19_ = window;
	gtk_widget_show ((GtkWidget*) _tmp19_);
	result = TRUE;
	_g_object_unref0 (window);
	block7_data_unref (_data7_);
	_data7_ = NULL;
	return result;
}


static void seahorse_viewable_base_init (SeahorseViewableIface * iface) {
	static gboolean initialized = FALSE;
	if (!initialized) {
		initialized = TRUE;
	}
}


GType seahorse_viewable_get_type (void) {
	static volatile gsize seahorse_viewable_type_id__volatile = 0;
	if (g_once_init_enter (&seahorse_viewable_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (SeahorseViewableIface), (GBaseInitFunc) seahorse_viewable_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
		GType seahorse_viewable_type_id;
		seahorse_viewable_type_id = g_type_register_static (G_TYPE_INTERFACE, "SeahorseViewable", &g_define_type_info, 0);
		g_type_interface_add_prerequisite (seahorse_viewable_type_id, G_TYPE_OBJECT);
		g_once_init_leave (&seahorse_viewable_type_id__volatile, seahorse_viewable_type_id);
	}
	return seahorse_viewable_type_id__volatile;
}



