/* util.c generated by valac 0.20.1.64-fa28c, the Vala compiler
 * generated from util.vala, do not modify */

/*
 * Seahorse
 *
 * Copyright (C) 2003 Jacob Perkins
 * Copyright (C) 2004-2005 Stefan Walter
 * Copyright (C) 2011 Collabora Ltd.
 *
 * 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, write to the
 * Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#include <glib.h>
#include <glib-object.h>
#include "seahorse-internal.h"
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <glib/gi18n-lib.h>
#include <config.h>

#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))





static gpointer _g_object_ref0 (gpointer self) {
#line 40 "/data/projects/seahorse/common/util.vala"
	return self ? g_object_ref (self) : NULL;
#line 49 "util.c"
}


void seahorse_util_show_error (GtkWidget* parent, const gchar* heading, const gchar* message) {
	GtkWindow* window = NULL;
	const gchar* _tmp0_ = NULL;
	GtkWidget* _tmp1_ = NULL;
	GtkMessageDialog* dialog = NULL;
	GtkWindow* _tmp8_ = NULL;
	GtkMessageDialog* _tmp9_ = NULL;
	const gchar* _tmp10_ = NULL;
	GtkMessageDialog* _tmp16_ = NULL;
	GtkMessageDialog* _tmp17_ = NULL;
#line 31 "/data/projects/seahorse/common/util.vala"
	window = NULL;
#line 33 "/data/projects/seahorse/common/util.vala"
	_tmp0_ = message;
#line 33 "/data/projects/seahorse/common/util.vala"
	if (_tmp0_ == NULL) {
#line 34 "/data/projects/seahorse/common/util.vala"
		message = "";
#line 71 "util.c"
	}
#line 36 "/data/projects/seahorse/common/util.vala"
	_tmp1_ = parent;
#line 36 "/data/projects/seahorse/common/util.vala"
	if (_tmp1_ != NULL) {
#line 77 "util.c"
		GtkWidget* _tmp2_ = NULL;
		GtkWidget* _tmp5_ = NULL;
#line 37 "/data/projects/seahorse/common/util.vala"
		_tmp2_ = parent;
#line 37 "/data/projects/seahorse/common/util.vala"
		if (!G_TYPE_CHECK_INSTANCE_TYPE (_tmp2_, GTK_TYPE_WINDOW)) {
#line 84 "util.c"
			GtkWidget* _tmp3_ = NULL;
			GtkWidget* _tmp4_ = NULL;
#line 38 "/data/projects/seahorse/common/util.vala"
			_tmp3_ = parent;
#line 38 "/data/projects/seahorse/common/util.vala"
			_tmp4_ = gtk_widget_get_toplevel (_tmp3_);
#line 38 "/data/projects/seahorse/common/util.vala"
			parent = _tmp4_;
#line 93 "util.c"
		}
#line 39 "/data/projects/seahorse/common/util.vala"
		_tmp5_ = parent;
#line 39 "/data/projects/seahorse/common/util.vala"
		if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp5_, GTK_TYPE_WINDOW)) {
#line 99 "util.c"
			GtkWidget* _tmp6_ = NULL;
			GtkWindow* _tmp7_ = NULL;
#line 40 "/data/projects/seahorse/common/util.vala"
			_tmp6_ = parent;
#line 40 "/data/projects/seahorse/common/util.vala"
			_tmp7_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, GTK_TYPE_WINDOW, GtkWindow));
#line 40 "/data/projects/seahorse/common/util.vala"
			_g_object_unref0 (window);
#line 40 "/data/projects/seahorse/common/util.vala"
			window = _tmp7_;
#line 110 "util.c"
		}
	}
#line 43 "/data/projects/seahorse/common/util.vala"
	_tmp8_ = window;
#line 43 "/data/projects/seahorse/common/util.vala"
	_tmp9_ = (GtkMessageDialog*) gtk_message_dialog_new (_tmp8_, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "");
#line 43 "/data/projects/seahorse/common/util.vala"
	g_object_ref_sink (_tmp9_);
#line 43 "/data/projects/seahorse/common/util.vala"
	dialog = _tmp9_;
#line 46 "/data/projects/seahorse/common/util.vala"
	_tmp10_ = heading;
#line 46 "/data/projects/seahorse/common/util.vala"
	if (_tmp10_ == NULL) {
#line 125 "util.c"
		GtkMessageDialog* _tmp11_ = NULL;
		const gchar* _tmp12_ = NULL;
#line 47 "/data/projects/seahorse/common/util.vala"
		_tmp11_ = dialog;
#line 47 "/data/projects/seahorse/common/util.vala"
		_tmp12_ = message;
#line 47 "/data/projects/seahorse/common/util.vala"
		g_object_set ((GObject*) _tmp11_, "text", _tmp12_, NULL);
#line 134 "util.c"
	} else {
		GtkMessageDialog* _tmp13_ = NULL;
		const gchar* _tmp14_ = NULL;
		const gchar* _tmp15_ = NULL;
#line 49 "/data/projects/seahorse/common/util.vala"
		_tmp13_ = dialog;
#line 49 "/data/projects/seahorse/common/util.vala"
		_tmp14_ = heading;
#line 49 "/data/projects/seahorse/common/util.vala"
		_tmp15_ = message;
#line 49 "/data/projects/seahorse/common/util.vala"
		g_object_set ((GObject*) _tmp13_, "text", _tmp14_, "secondary-text", _tmp15_, NULL);
#line 147 "util.c"
	}
#line 51 "/data/projects/seahorse/common/util.vala"
	_tmp16_ = dialog;
#line 51 "/data/projects/seahorse/common/util.vala"
	gtk_dialog_run ((GtkDialog*) _tmp16_);
#line 52 "/data/projects/seahorse/common/util.vala"
	_tmp17_ = dialog;
#line 52 "/data/projects/seahorse/common/util.vala"
	gtk_widget_destroy ((GtkWidget*) _tmp17_);
#line 28 "/data/projects/seahorse/common/util.vala"
	_g_object_unref0 (dialog);
#line 28 "/data/projects/seahorse/common/util.vala"
	_g_object_unref0 (window);
#line 161 "util.c"
}


gchar* seahorse_util_get_display_date_string (glong time) {
	gchar* result = NULL;
	glong _tmp0_ = 0L;
	GDate created_date = {0};
	glong _tmp2_ = 0L;
	gchar* buffer = NULL;
	gchar* _tmp3_ = NULL;
	gint buffer_length1 = 0;
	gint _buffer_size_ = 0;
	gchar* _tmp4_ = NULL;
	gint _tmp4__length1 = 0;
	const gchar* _tmp5_ = NULL;
	gchar* _tmp6_ = NULL;
	gint _tmp6__length1 = 0;
	gchar* _tmp7_ = NULL;
#line 57 "/data/projects/seahorse/common/util.vala"
	_tmp0_ = time;
#line 57 "/data/projects/seahorse/common/util.vala"
	if (_tmp0_ == ((glong) 0)) {
#line 184 "util.c"
		gchar* _tmp1_ = NULL;
#line 58 "/data/projects/seahorse/common/util.vala"
		_tmp1_ = g_strdup ("");
#line 58 "/data/projects/seahorse/common/util.vala"
		result = _tmp1_;
#line 58 "/data/projects/seahorse/common/util.vala"
		return result;
#line 192 "util.c"
	}
#line 59 "/data/projects/seahorse/common/util.vala"
	memset (&created_date, 0, sizeof (GDate));
#line 60 "/data/projects/seahorse/common/util.vala"
	_tmp2_ = time;
#line 60 "/data/projects/seahorse/common/util.vala"
	g_date_set_time_t (&created_date, (time_t) _tmp2_);
#line 61 "/data/projects/seahorse/common/util.vala"
	_tmp3_ = g_new0 (gchar, 128);
#line 61 "/data/projects/seahorse/common/util.vala"
	buffer = _tmp3_;
#line 61 "/data/projects/seahorse/common/util.vala"
	buffer_length1 = 128;
#line 61 "/data/projects/seahorse/common/util.vala"
	_buffer_size_ = buffer_length1;
#line 62 "/data/projects/seahorse/common/util.vala"
	_tmp4_ = buffer;
#line 62 "/data/projects/seahorse/common/util.vala"
	_tmp4__length1 = buffer_length1;
#line 62 "/data/projects/seahorse/common/util.vala"
	_tmp5_ = _ ("%Y-%m-%d");
#line 62 "/data/projects/seahorse/common/util.vala"
	g_date_strftime (_tmp4_, _tmp4__length1, _tmp5_, &created_date);
#line 63 "/data/projects/seahorse/common/util.vala"
	_tmp6_ = buffer;
#line 63 "/data/projects/seahorse/common/util.vala"
	_tmp6__length1 = buffer_length1;
#line 63 "/data/projects/seahorse/common/util.vala"
	_tmp7_ = g_strdup ((const gchar*) _tmp6_);
#line 63 "/data/projects/seahorse/common/util.vala"
	result = _tmp7_;
#line 63 "/data/projects/seahorse/common/util.vala"
	buffer = (g_free (buffer), NULL);
#line 63 "/data/projects/seahorse/common/util.vala"
	return result;
#line 228 "util.c"
}


GtkBuilder* seahorse_util_load_built_contents (GtkContainer* frame, const gchar* name) {
	GtkBuilder* result = NULL;
	GtkBuilder* builder = NULL;
	GtkBuilder* _tmp0_ = NULL;
	gchar* path = NULL;
	const gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	gchar* _tmp4_ = NULL;
	gchar* _tmp5_ = NULL;
	gboolean _tmp6_ = FALSE;
	GtkContainer* _tmp7_ = NULL;
	gboolean _tmp9_ = FALSE;
	GError * _inner_error_ = NULL;
#line 66 "/data/projects/seahorse/common/util.vala"
	g_return_val_if_fail (name != NULL, NULL);
#line 68 "/data/projects/seahorse/common/util.vala"
	_tmp0_ = gtk_builder_new ();
#line 68 "/data/projects/seahorse/common/util.vala"
	builder = _tmp0_;
#line 69 "/data/projects/seahorse/common/util.vala"
	_tmp1_ = name;
#line 69 "/data/projects/seahorse/common/util.vala"
	_tmp2_ = g_strdup_printf ("seahorse-%s.xml", _tmp1_);
#line 69 "/data/projects/seahorse/common/util.vala"
	_tmp3_ = _tmp2_;
#line 69 "/data/projects/seahorse/common/util.vala"
	_tmp4_ = g_build_filename (UIDIR, _tmp3_, NULL);
#line 69 "/data/projects/seahorse/common/util.vala"
	_tmp5_ = _tmp4_;
#line 69 "/data/projects/seahorse/common/util.vala"
	_g_free0 (_tmp3_);
#line 69 "/data/projects/seahorse/common/util.vala"
	path = _tmp5_;
#line 71 "/data/projects/seahorse/common/util.vala"
	_tmp7_ = frame;
#line 71 "/data/projects/seahorse/common/util.vala"
	if (_tmp7_ != NULL) {
#line 270 "util.c"
		GtkContainer* _tmp8_ = NULL;
#line 71 "/data/projects/seahorse/common/util.vala"
		_tmp8_ = frame;
#line 71 "/data/projects/seahorse/common/util.vala"
		_tmp6_ = G_TYPE_CHECK_INSTANCE_TYPE (_tmp8_, GTK_TYPE_DIALOG);
#line 276 "util.c"
	} else {
#line 71 "/data/projects/seahorse/common/util.vala"
		_tmp6_ = FALSE;
#line 280 "util.c"
	}
#line 71 "/data/projects/seahorse/common/util.vala"
	_tmp9_ = _tmp6_;
#line 71 "/data/projects/seahorse/common/util.vala"
	if (_tmp9_) {
#line 286 "util.c"
		GtkContainer* _tmp10_ = NULL;
		GtkBox* _tmp11_ = NULL;
#line 72 "/data/projects/seahorse/common/util.vala"
		_tmp10_ = frame;
#line 72 "/data/projects/seahorse/common/util.vala"
		_tmp11_ = (GtkBox*) gtk_dialog_get_content_area (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, GTK_TYPE_DIALOG, GtkDialog));
#line 72 "/data/projects/seahorse/common/util.vala"
		frame = (GtkContainer*) _tmp11_;
#line 295 "util.c"
	}
	{
		GtkBuilder* _tmp12_ = NULL;
		const gchar* _tmp13_ = NULL;
		GObject* obj = NULL;
		GtkBuilder* _tmp14_ = NULL;
		const gchar* _tmp15_ = NULL;
		GObject* _tmp16_ = NULL;
		GObject* _tmp17_ = NULL;
		GObject* _tmp18_ = NULL;
#line 75 "/data/projects/seahorse/common/util.vala"
		_tmp12_ = builder;
#line 75 "/data/projects/seahorse/common/util.vala"
		_tmp13_ = path;
#line 75 "/data/projects/seahorse/common/util.vala"
		gtk_builder_add_from_file (_tmp12_, _tmp13_, &_inner_error_);
#line 75 "/data/projects/seahorse/common/util.vala"
		if (_inner_error_ != NULL) {
#line 314 "util.c"
			goto __catch7_g_error;
		}
#line 76 "/data/projects/seahorse/common/util.vala"
		_tmp14_ = builder;
#line 76 "/data/projects/seahorse/common/util.vala"
		_tmp15_ = name;
#line 76 "/data/projects/seahorse/common/util.vala"
		_tmp16_ = gtk_builder_get_object (_tmp14_, _tmp15_);
#line 76 "/data/projects/seahorse/common/util.vala"
		_tmp17_ = _g_object_ref0 (_tmp16_);
#line 76 "/data/projects/seahorse/common/util.vala"
		obj = _tmp17_;
#line 77 "/data/projects/seahorse/common/util.vala"
		_tmp18_ = obj;
#line 77 "/data/projects/seahorse/common/util.vala"
		if (_tmp18_ == NULL) {
#line 331 "util.c"
			const gchar* _tmp19_ = NULL;
			const gchar* _tmp20_ = NULL;
#line 78 "/data/projects/seahorse/common/util.vala"
			_tmp19_ = name;
#line 78 "/data/projects/seahorse/common/util.vala"
			_tmp20_ = path;
#line 78 "/data/projects/seahorse/common/util.vala"
			g_critical ("util.vala:78: Couldn't find object named %s in %s", _tmp19_, _tmp20_);
#line 340 "util.c"
		} else {
			GtkContainer* _tmp21_ = NULL;
#line 79 "/data/projects/seahorse/common/util.vala"
			_tmp21_ = frame;
#line 79 "/data/projects/seahorse/common/util.vala"
			if (_tmp21_ != NULL) {
#line 347 "util.c"
				GtkWidget* widget = NULL;
				GObject* _tmp22_ = NULL;
				GtkWidget* _tmp23_ = NULL;
				GtkContainer* _tmp24_ = NULL;
				GtkWidget* _tmp25_ = NULL;
				GtkWidget* _tmp26_ = NULL;
#line 80 "/data/projects/seahorse/common/util.vala"
				_tmp22_ = obj;
#line 80 "/data/projects/seahorse/common/util.vala"
				_tmp23_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp22_, GTK_TYPE_WIDGET, GtkWidget));
#line 80 "/data/projects/seahorse/common/util.vala"
				widget = _tmp23_;
#line 81 "/data/projects/seahorse/common/util.vala"
				_tmp24_ = frame;
#line 81 "/data/projects/seahorse/common/util.vala"
				_tmp25_ = widget;
#line 81 "/data/projects/seahorse/common/util.vala"
				gtk_container_add (_tmp24_, _tmp25_);
#line 82 "/data/projects/seahorse/common/util.vala"
				_tmp26_ = widget;
#line 82 "/data/projects/seahorse/common/util.vala"
				gtk_widget_show (_tmp26_);
#line 79 "/data/projects/seahorse/common/util.vala"
				_g_object_unref0 (widget);
#line 372 "util.c"
			}
		}
#line 74 "/data/projects/seahorse/common/util.vala"
		_g_object_unref0 (obj);
#line 377 "util.c"
	}
	goto __finally7;
	__catch7_g_error:
	{
		GError* err = NULL;
		const gchar* _tmp27_ = NULL;
		GError* _tmp28_ = NULL;
		const gchar* _tmp29_ = NULL;
#line 74 "/data/projects/seahorse/common/util.vala"
		err = _inner_error_;
#line 74 "/data/projects/seahorse/common/util.vala"
		_inner_error_ = NULL;
#line 85 "/data/projects/seahorse/common/util.vala"
		_tmp27_ = path;
#line 85 "/data/projects/seahorse/common/util.vala"
		_tmp28_ = err;
#line 85 "/data/projects/seahorse/common/util.vala"
		_tmp29_ = _tmp28_->message;
#line 85 "/data/projects/seahorse/common/util.vala"
		g_critical ("util.vala:85: Couldn't load %s: %s", _tmp27_, _tmp29_);
#line 74 "/data/projects/seahorse/common/util.vala"
		_g_error_free0 (err);
#line 400 "util.c"
	}
	__finally7:
#line 74 "/data/projects/seahorse/common/util.vala"
	if (_inner_error_ != NULL) {
#line 74 "/data/projects/seahorse/common/util.vala"
		_g_free0 (path);
#line 74 "/data/projects/seahorse/common/util.vala"
		_g_object_unref0 (builder);
#line 74 "/data/projects/seahorse/common/util.vala"
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
#line 74 "/data/projects/seahorse/common/util.vala"
		g_clear_error (&_inner_error_);
#line 74 "/data/projects/seahorse/common/util.vala"
		return NULL;
#line 415 "util.c"
	}
#line 88 "/data/projects/seahorse/common/util.vala"
	result = builder;
#line 88 "/data/projects/seahorse/common/util.vala"
	_g_free0 (path);
#line 88 "/data/projects/seahorse/common/util.vala"
	return result;
#line 423 "util.c"
}



