/* tab_info_bar.c generated by valac 0.12.1, 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 <float.h>
#include <math.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 _lambda22_ (gint response_id, TabInfoBar* self);
static void __lambda22__gtk_info_bar_response (GtkInfoBar* _sender, gint response_id, gpointer self);
void tab_info_bar_add_stock_button_with_text (TabInfoBar* self, const gchar* text, const gchar* stock_id, gint response_id);


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;
	GtkWidget* _tmp0_ = NULL;
	GtkHBox* _tmp1_;
	GtkHBox* content_area;
	gchar* stock_id = NULL;
	GtkImage* _tmp6_ = NULL;
	GtkImage* image;
	GtkVBox* _tmp7_ = NULL;
	GtkVBox* vbox;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	GtkLabel* _tmp12_ = NULL;
	GtkLabel* _tmp13_;
	GtkLabel* primary_label;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	GtkLabel* _tmp18_ = NULL;
	GtkLabel* _tmp19_;
	GtkLabel* secondary_label;
	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 (GTK_HBOX (_tmp0_));
	content_area = _tmp1_;
	switch (msg_type) {
		case GTK_MESSAGE_ERROR:
		{
			gchar* _tmp2_;
			_tmp2_ = g_strdup (GTK_STOCK_DIALOG_ERROR);
			_g_free0 (stock_id);
			stock_id = _tmp2_;
			break;
		}
		case GTK_MESSAGE_QUESTION:
		{
			gchar* _tmp3_;
			_tmp3_ = g_strdup (GTK_STOCK_DIALOG_QUESTION);
			_g_free0 (stock_id);
			stock_id = _tmp3_;
			break;
		}
		case GTK_MESSAGE_WARNING:
		{
			gchar* _tmp4_;
			_tmp4_ = g_strdup (GTK_STOCK_DIALOG_WARNING);
			_g_free0 (stock_id);
			stock_id = _tmp4_;
			break;
		}
		default:
		case GTK_MESSAGE_INFO:
		{
			gchar* _tmp5_;
			_tmp5_ = g_strdup (GTK_STOCK_DIALOG_INFO);
			_g_free0 (stock_id);
			stock_id = _tmp5_;
			break;
		}
	}
	_tmp6_ = (GtkImage*) gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_DIALOG);
	image = g_object_ref_sink (_tmp6_);
	gtk_misc_set_alignment ((GtkMisc*) image, (gfloat) 0.5, (gfloat) 0.0);
	gtk_box_pack_start ((GtkBox*) content_area, (GtkWidget*) image, FALSE, FALSE, (guint) 0);
	_tmp7_ = (GtkVBox*) gtk_vbox_new (FALSE, 10);
	vbox = g_object_ref_sink (_tmp7_);
	gtk_box_pack_start ((GtkBox*) content_area, (GtkWidget*) vbox, TRUE, TRUE, (guint) 0);
	_tmp8_ = g_strconcat ("<b>", primary_msg, NULL);
	_tmp9_ = _tmp8_;
	_tmp10_ = g_strconcat (_tmp9_, "</b>", NULL);
	_tmp11_ = _tmp10_;
	_tmp12_ = (GtkLabel*) gtk_label_new (_tmp11_);
	_tmp13_ = g_object_ref_sink (_tmp12_);
	_g_free0 (_tmp11_);
	_g_free0 (_tmp9_);
	primary_label = _tmp13_;
	gtk_box_pack_start ((GtkBox*) vbox, (GtkWidget*) primary_label, FALSE, FALSE, (guint) 0);
	gtk_misc_set_alignment ((GtkMisc*) primary_label, (gfloat) 0.0, (gfloat) 0.5);
	gtk_label_set_selectable (primary_label, TRUE);
	gtk_label_set_line_wrap (primary_label, TRUE);
	gtk_label_set_use_markup (primary_label, TRUE);
	_tmp14_ = g_strconcat ("<small>", secondary_msg, NULL);
	_tmp15_ = _tmp14_;
	_tmp16_ = g_strconcat (_tmp15_, "</small>", NULL);
	_tmp17_ = _tmp16_;
	_tmp18_ = (GtkLabel*) gtk_label_new (_tmp17_);
	_tmp19_ = g_object_ref_sink (_tmp18_);
	_g_free0 (_tmp17_);
	_g_free0 (_tmp15_);
	secondary_label = _tmp19_;
	gtk_box_pack_start ((GtkBox*) vbox, (GtkWidget*) secondary_label, FALSE, FALSE, (guint) 0);
	gtk_misc_set_alignment ((GtkMisc*) secondary_label, (gfloat) 0.0, (gfloat) 0.5);
	gtk_label_set_selectable (secondary_label, TRUE);
	gtk_label_set_line_wrap (secondary_label, TRUE);
	gtk_label_set_use_markup (secondary_label, TRUE);
	gtk_info_bar_set_message_type ((GtkInfoBar*) self, msg_type);
	gtk_widget_show_all ((GtkWidget*) self);
	_g_object_unref0 (secondary_label);
	_g_object_unref0 (primary_label);
	_g_object_unref0 (vbox);
	_g_object_unref0 (image);
	_g_free0 (stock_id);
	_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 _lambda22_ (gint response_id, TabInfoBar* self) {
	if (response_id == GTK_RESPONSE_OK) {
		gtk_object_destroy ((GtkObject*) self);
	}
}


static void __lambda22__gtk_info_bar_response (GtkInfoBar* _sender, gint response_id, gpointer self) {
	_lambda22_ (response_id, self);
}


void tab_info_bar_add_ok_button (TabInfoBar* self) {
	g_return_if_fail (self != NULL);
	gtk_info_bar_add_button ((GtkInfoBar*) self, GTK_STOCK_OK, (gint) GTK_RESPONSE_OK);
	g_signal_connect_object ((GtkInfoBar*) self, "response", (GCallback) __lambda22__gtk_info_bar_response, self, 0);
}


void tab_info_bar_add_stock_button_with_text (TabInfoBar* self, const gchar* text, const gchar* stock_id, gint response_id) {
	GtkWidget* _tmp0_ = NULL;
	GtkButton* _tmp1_;
	GtkButton* button;
	GtkImage* _tmp2_ = NULL;
	GtkImage* image;
	g_return_if_fail (self != NULL);
	g_return_if_fail (text != NULL);
	g_return_if_fail (stock_id != NULL);
	_tmp0_ = gtk_info_bar_add_button ((GtkInfoBar*) self, text, response_id);
	_tmp1_ = _g_object_ref0 (GTK_BUTTON (_tmp0_));
	button = _tmp1_;
	_tmp2_ = (GtkImage*) gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON);
	image = g_object_ref_sink (_tmp2_);
	gtk_button_set_image (button, (GtkWidget*) image);
	_g_object_unref0 (image);
	_g_object_unref0 (button);
}


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_TYPE_INFO_BAR, "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;
}



