/* error_entry.c generated by valac 0.30.0.2-88328, the Vala compiler
 * generated from error_entry.vala, do not modify */

/*
 * This file is part of LaTeXila.
 *
 * Copyright © 2012, 2013 Sébastien Wilmet
 *
 * LaTeXila 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 3 of the License, or
 * (at your option) any later version.
 *
 * LaTeXila 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 LaTeXila.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>


#define TYPE_ERROR_ENTRY (error_entry_get_type ())
#define ERROR_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ERROR_ENTRY, ErrorEntry))
#define ERROR_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ERROR_ENTRY, ErrorEntryClass))
#define IS_ERROR_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ERROR_ENTRY))
#define IS_ERROR_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ERROR_ENTRY))
#define ERROR_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ERROR_ENTRY, ErrorEntryClass))

typedef struct _ErrorEntry ErrorEntry;
typedef struct _ErrorEntryClass ErrorEntryClass;
typedef struct _ErrorEntryPrivate ErrorEntryPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _ErrorEntry {
	GObject parent_instance;
	ErrorEntryPrivate * priv;
};

struct _ErrorEntryClass {
	GObjectClass parent_class;
};


static gpointer error_entry_parent_class = NULL;
static GtkCssProvider* error_entry__provider;
static GtkCssProvider* error_entry__provider = NULL;

GType error_entry_get_type (void) G_GNUC_CONST;
enum  {
	ERROR_ENTRY_DUMMY_PROPERTY
};
static void error_entry_init_provider (void);
void error_entry_add_error (GtkWidget* widget);
void error_entry_remove_error (GtkWidget* widget);
ErrorEntry* error_entry_new (void);
ErrorEntry* error_entry_construct (GType object_type);
static void error_entry_finalize (GObject* obj);


static void error_entry_init_provider (void) {
	GtkCssProvider* _tmp0_ = NULL;
	gchar* style = NULL;
	gchar* _tmp1_ = NULL;
	GtkCssProvider* _tmp2_ = NULL;
	GError * _inner_error_ = NULL;
	_tmp0_ = error_entry__provider;
	if (_tmp0_ != NULL) {
		return;
	}
	_tmp1_ = g_strdup ("\n" \
"        GtkEntry {\n" \
"            color: white;\n" \
"            background-image: none;\n" \
"            background-color: rgb (237, 54, 54);\n" \
"        }\n" \
"        ");
	style = _tmp1_;
	_tmp2_ = gtk_css_provider_new ();
	_g_object_unref0 (error_entry__provider);
	error_entry__provider = _tmp2_;
	{
		GtkCssProvider* _tmp3_ = NULL;
		const gchar* _tmp4_ = NULL;
		_tmp3_ = error_entry__provider;
		_tmp4_ = style;
		gtk_css_provider_load_from_data (_tmp3_, _tmp4_, (gssize) -1, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch18_g_error;
		}
	}
	goto __finally18;
	__catch18_g_error:
	{
		GError* e = NULL;
		GError* _tmp5_ = NULL;
		const gchar* _tmp6_ = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp5_ = e;
		_tmp6_ = _tmp5_->message;
		g_warning ("error_entry.vala:49: Impossible to load CSS style for the error entry:" \
" %s", _tmp6_);
		_g_error_free0 (e);
	}
	__finally18:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_free0 (style);
		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);
		g_clear_error (&_inner_error_);
		return;
	}
	_g_free0 (style);
}


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


void error_entry_add_error (GtkWidget* widget) {
	GtkStyleContext* context = NULL;
	GtkWidget* _tmp0_ = NULL;
	GtkStyleContext* _tmp1_ = NULL;
	GtkStyleContext* _tmp2_ = NULL;
	GtkCssProvider* _tmp3_ = NULL;
	g_return_if_fail (widget != NULL);
	_tmp0_ = widget;
	_tmp1_ = gtk_widget_get_style_context (_tmp0_);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	context = _tmp2_;
	error_entry_init_provider ();
	_tmp3_ = error_entry__provider;
	if (_tmp3_ != NULL) {
		GtkStyleContext* _tmp4_ = NULL;
		GtkCssProvider* _tmp5_ = NULL;
		_tmp4_ = context;
		_tmp5_ = error_entry__provider;
		gtk_style_context_add_provider (_tmp4_, (GtkStyleProvider*) _tmp5_, (guint) GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
	}
	_g_object_unref0 (context);
}


void error_entry_remove_error (GtkWidget* widget) {
	GtkStyleContext* context = NULL;
	GtkWidget* _tmp0_ = NULL;
	GtkStyleContext* _tmp1_ = NULL;
	GtkStyleContext* _tmp2_ = NULL;
	GtkCssProvider* _tmp3_ = NULL;
	g_return_if_fail (widget != NULL);
	_tmp0_ = widget;
	_tmp1_ = gtk_widget_get_style_context (_tmp0_);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	context = _tmp2_;
	error_entry_init_provider ();
	_tmp3_ = error_entry__provider;
	if (_tmp3_ != NULL) {
		GtkStyleContext* _tmp4_ = NULL;
		GtkCssProvider* _tmp5_ = NULL;
		_tmp4_ = context;
		_tmp5_ = error_entry__provider;
		gtk_style_context_remove_provider (_tmp4_, (GtkStyleProvider*) _tmp5_);
	}
	_g_object_unref0 (context);
}


ErrorEntry* error_entry_construct (GType object_type) {
	ErrorEntry * self = NULL;
	self = (ErrorEntry*) g_object_new (object_type, NULL);
	return self;
}


ErrorEntry* error_entry_new (void) {
	return error_entry_construct (TYPE_ERROR_ENTRY);
}


static void error_entry_class_init (ErrorEntryClass * klass) {
	error_entry_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = error_entry_finalize;
}


static void error_entry_instance_init (ErrorEntry * self) {
}


static void error_entry_finalize (GObject* obj) {
	ErrorEntry * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_ERROR_ENTRY, ErrorEntry);
	G_OBJECT_CLASS (error_entry_parent_class)->finalize (obj);
}


GType error_entry_get_type (void) {
	static volatile gsize error_entry_type_id__volatile = 0;
	if (g_once_init_enter (&error_entry_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (ErrorEntryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) error_entry_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ErrorEntry), 0, (GInstanceInitFunc) error_entry_instance_init, NULL };
		GType error_entry_type_id;
		error_entry_type_id = g_type_register_static (G_TYPE_OBJECT, "ErrorEntry", &g_define_type_info, 0);
		g_once_init_leave (&error_entry_type_id__volatile, error_entry_type_id);
	}
	return error_entry_type_id__volatile;
}



