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

/*
 * This file is part of LaTeXila.
 *
 * Copyright © 2010-2011 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>
#include <glib/gi18n-lib.h>


#define TYPE_TAB_INFO_BAR (tab_info_bar_get_type ())
#define TAB_INFO_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TAB_INFO_BAR, TabInfoBar))
#define TAB_INFO_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TAB_INFO_BAR, TabInfoBarClass))
#define IS_TAB_INFO_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TAB_INFO_BAR))
#define IS_TAB_INFO_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TAB_INFO_BAR))
#define TAB_INFO_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TAB_INFO_BAR, TabInfoBarClass))

typedef struct _TabInfoBar TabInfoBar;
typedef struct _TabInfoBarClass TabInfoBarClass;
typedef struct _TabInfoBarPrivate TabInfoBarPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _TabInfoBar {
	GtkInfoBar parent_instance;
	TabInfoBarPrivate * priv;
};

struct _TabInfoBarClass {
	GtkInfoBarClass parent_class;
};


static gpointer tab_info_bar_parent_class = NULL;

GType tab_info_bar_get_type (void) G_GNUC_CONST;
enum  {
	TAB_INFO_BAR_DUMMY_PROPERTY
};
TabInfoBar* tab_info_bar_new (const gchar* primary_msg, const gchar* secondary_msg, GtkMessageType msg_type);
TabInfoBar* tab_info_bar_construct (GType object_type, const gchar* primary_msg, const gchar* secondary_msg, GtkMessageType msg_type);
void tab_info_bar_add_ok_button (TabInfoBar* self);
static void __lambda15_ (TabInfoBar* self, gint response_id);
static void ___lambda15__gtk_info_bar_response (GtkInfoBar* _sender, gint response_id, gpointer self);


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


TabInfoBar* tab_info_bar_construct (GType object_type, const gchar* primary_msg, const gchar* secondary_msg, GtkMessageType msg_type) {
	TabInfoBar * self = NULL;
	GtkBox* content_area = NULL;
	GtkContainer* _tmp0_ = NULL;
	GtkBox* _tmp1_ = NULL;
	gchar* icon_name = NULL;
	GtkMessageType _tmp2_ = 0;
	GtkImage* image = NULL;
	const gchar* _tmp7_ = NULL;
	GtkImage* _tmp8_ = NULL;
	GtkBox* _tmp9_ = NULL;
	GtkGrid* grid = NULL;
	GtkGrid* _tmp10_ = NULL;
	GtkBox* _tmp11_ = NULL;
	GtkLabel* primary_label = NULL;
	const gchar* _tmp12_ = NULL;
	gchar* _tmp13_ = NULL;
	gchar* _tmp14_ = NULL;
	gchar* _tmp15_ = NULL;
	gchar* _tmp16_ = NULL;
	GtkLabel* _tmp17_ = NULL;
	GtkLabel* _tmp18_ = NULL;
	GtkLabel* secondary_label = NULL;
	const gchar* _tmp19_ = NULL;
	gchar* _tmp20_ = NULL;
	gchar* _tmp21_ = NULL;
	gchar* _tmp22_ = NULL;
	gchar* _tmp23_ = NULL;
	GtkLabel* _tmp24_ = NULL;
	GtkLabel* _tmp25_ = NULL;
	GtkMessageType _tmp26_ = 0;
	g_return_val_if_fail (primary_msg != NULL, NULL);
	g_return_val_if_fail (secondary_msg != NULL, NULL);
	self = (TabInfoBar*) g_object_new (object_type, NULL);
	_tmp0_ = gtk_info_bar_get_content_area ((GtkInfoBar*) self);
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, gtk_box_get_type ()) ? ((GtkBox*) _tmp0_) : NULL);
	content_area = _tmp1_;
	_tmp2_ = msg_type;
	switch (_tmp2_) {
		case GTK_MESSAGE_ERROR:
		{
			gchar* _tmp3_ = NULL;
			_tmp3_ = g_strdup ("dialog-error");
			_g_free0 (icon_name);
			icon_name = _tmp3_;
			break;
		}
		case GTK_MESSAGE_QUESTION:
		{
			gchar* _tmp4_ = NULL;
			_tmp4_ = g_strdup ("dialog-question");
			_g_free0 (icon_name);
			icon_name = _tmp4_;
			break;
		}
		case GTK_MESSAGE_WARNING:
		{
			gchar* _tmp5_ = NULL;
			_tmp5_ = g_strdup ("dialog-warning");
			_g_free0 (icon_name);
			icon_name = _tmp5_;
			break;
		}
		default:
		case GTK_MESSAGE_INFO:
		{
			gchar* _tmp6_ = NULL;
			_tmp6_ = g_strdup ("dialog-information");
			_g_free0 (icon_name);
			icon_name = _tmp6_;
			break;
		}
	}
	_tmp7_ = icon_name;
	_tmp8_ = (GtkImage*) gtk_image_new_from_icon_name (_tmp7_, GTK_ICON_SIZE_DIALOG);
	g_object_ref_sink (_tmp8_);
	image = _tmp8_;
	gtk_widget_set_valign ((GtkWidget*) image, GTK_ALIGN_START);
	_tmp9_ = content_area;
	gtk_box_pack_start (_tmp9_, (GtkWidget*) image, FALSE, FALSE, (guint) 0);
	_tmp10_ = (GtkGrid*) gtk_grid_new ();
	g_object_ref_sink (_tmp10_);
	grid = _tmp10_;
	gtk_orientable_set_orientation ((GtkOrientable*) grid, GTK_ORIENTATION_VERTICAL);
	gtk_grid_set_row_spacing (grid, (guint) 10);
	_tmp11_ = content_area;
	gtk_box_pack_start (_tmp11_, (GtkWidget*) grid, TRUE, TRUE, (guint) 0);
	_tmp12_ = primary_msg;
	_tmp13_ = g_strconcat ("<b>", _tmp12_, NULL);
	_tmp14_ = _tmp13_;
	_tmp15_ = g_strconcat (_tmp14_, "</b>", NULL);
	_tmp16_ = _tmp15_;
	_tmp17_ = (GtkLabel*) gtk_label_new (_tmp16_);
	g_object_ref_sink (_tmp17_);
	_tmp18_ = _tmp17_;
	_g_free0 (_tmp16_);
	_g_free0 (_tmp14_);
	primary_label = _tmp18_;
	gtk_container_add ((GtkContainer*) grid, (GtkWidget*) primary_label);
	gtk_widget_set_halign ((GtkWidget*) primary_label, GTK_ALIGN_START);
	gtk_label_set_selectable (primary_label, TRUE);
	gtk_label_set_line_wrap (primary_label, TRUE);
	gtk_label_set_use_markup (primary_label, TRUE);
	_tmp19_ = secondary_msg;
	_tmp20_ = g_strconcat ("<small>", _tmp19_, NULL);
	_tmp21_ = _tmp20_;
	_tmp22_ = g_strconcat (_tmp21_, "</small>", NULL);
	_tmp23_ = _tmp22_;
	_tmp24_ = (GtkLabel*) gtk_label_new (_tmp23_);
	g_object_ref_sink (_tmp24_);
	_tmp25_ = _tmp24_;
	_g_free0 (_tmp23_);
	_g_free0 (_tmp21_);
	secondary_label = _tmp25_;
	gtk_container_add ((GtkContainer*) grid, (GtkWidget*) secondary_label);
	gtk_widget_set_halign ((GtkWidget*) secondary_label, GTK_ALIGN_START);
	gtk_label_set_selectable (secondary_label, TRUE);
	gtk_label_set_line_wrap (secondary_label, TRUE);
	gtk_label_set_use_markup (secondary_label, TRUE);
	_tmp26_ = msg_type;
	gtk_info_bar_set_message_type ((GtkInfoBar*) self, _tmp26_);
	gtk_widget_show_all ((GtkWidget*) self);
	_g_object_unref0 (secondary_label);
	_g_object_unref0 (primary_label);
	_g_object_unref0 (grid);
	_g_object_unref0 (image);
	_g_free0 (icon_name);
	_g_object_unref0 (content_area);
	return self;
}


TabInfoBar* tab_info_bar_new (const gchar* primary_msg, const gchar* secondary_msg, GtkMessageType msg_type) {
	return tab_info_bar_construct (TYPE_TAB_INFO_BAR, primary_msg, secondary_msg, msg_type);
}


static void __lambda15_ (TabInfoBar* self, gint response_id) {
	gint _tmp0_ = 0;
	_tmp0_ = response_id;
	if (_tmp0_ == ((gint) GTK_RESPONSE_OK)) {
		gtk_widget_destroy ((GtkWidget*) self);
	}
}


static void ___lambda15__gtk_info_bar_response (GtkInfoBar* _sender, gint response_id, gpointer self) {
	__lambda15_ ((TabInfoBar*) self, response_id);
}


void tab_info_bar_add_ok_button (TabInfoBar* self) {
	const gchar* _tmp0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = _ ("_OK");
	gtk_info_bar_add_button ((GtkInfoBar*) self, _tmp0_, (gint) GTK_RESPONSE_OK);
	g_signal_connect_object ((GtkInfoBar*) self, "response", (GCallback) ___lambda15__gtk_info_bar_response, self, 0);
}


static void tab_info_bar_class_init (TabInfoBarClass * klass) {
	tab_info_bar_parent_class = g_type_class_peek_parent (klass);
}


static void tab_info_bar_instance_init (TabInfoBar * self) {
}


GType tab_info_bar_get_type (void) {
	static volatile gsize tab_info_bar_type_id__volatile = 0;
	if (g_once_init_enter (&tab_info_bar_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (TabInfoBarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tab_info_bar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TabInfoBar), 0, (GInstanceInitFunc) tab_info_bar_instance_init, NULL };
		GType tab_info_bar_type_id;
		tab_info_bar_type_id = g_type_register_static (gtk_info_bar_get_type (), "TabInfoBar", &g_define_type_info, 0);
		g_once_init_leave (&tab_info_bar_type_id__volatile, tab_info_bar_type_id);
	}
	return tab_info_bar_type_id__volatile;
}



