/* dialogs.c generated by valac 0.15.1, the Vala compiler
 * generated from dialogs.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 <gtksourceview/gtksourceview.h>
#include <glib/gi18n-lib.h>
#include <float.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>


#define DIALOGS_TYPE_UNSAVED_DOC_COLUMN (dialogs_unsaved_doc_column_get_type ())

#define TYPE_MAIN_WINDOW (main_window_get_type ())
#define MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MAIN_WINDOW, MainWindow))
#define MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MAIN_WINDOW, MainWindowClass))
#define IS_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MAIN_WINDOW))
#define IS_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MAIN_WINDOW))
#define MAIN_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MAIN_WINDOW, MainWindowClass))

typedef struct _MainWindow MainWindow;
typedef struct _MainWindowClass MainWindowClass;

#define TYPE_DOCUMENT (document_get_type ())
#define DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DOCUMENT, Document))
#define DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DOCUMENT, DocumentClass))
#define IS_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DOCUMENT))
#define IS_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DOCUMENT))
#define DOCUMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DOCUMENT, DocumentClass))

typedef struct _Document Document;
typedef struct _DocumentClass DocumentClass;
typedef struct _Block8Data Block8Data;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _DocumentPrivate DocumentPrivate;

#define TYPE_DOCUMENT_TAB (document_tab_get_type ())
#define DOCUMENT_TAB(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DOCUMENT_TAB, DocumentTab))
#define DOCUMENT_TAB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DOCUMENT_TAB, DocumentTabClass))
#define IS_DOCUMENT_TAB(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DOCUMENT_TAB))
#define IS_DOCUMENT_TAB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DOCUMENT_TAB))
#define DOCUMENT_TAB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DOCUMENT_TAB, DocumentTabClass))

typedef struct _DocumentTab DocumentTab;
typedef struct _DocumentTabClass DocumentTabClass;
#define _gtk_tree_path_free0(var) ((var == NULL) ? NULL : (var = (gtk_tree_path_free (var), NULL)))
#define __g_list_free__g_object_unref0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__g_object_unref0_ (var), NULL)))

typedef enum  {
	DIALOGS_UNSAVED_DOC_COLUMN_SAVE,
	DIALOGS_UNSAVED_DOC_COLUMN_NAME,
	DIALOGS_UNSAVED_DOC_COLUMN_DOC,
	DIALOGS_UNSAVED_DOC_COLUMN_N_COLUMNS
} DialogsUnsavedDocColumn;

struct _Block8Data {
	int _ref_count_;
	GtkListStore* store;
};

struct _Document {
	GtkSourceBuffer parent_instance;
	DocumentPrivate * priv;
	DocumentTab* tab;
	guint _unsaved_doc_num;
};

struct _DocumentClass {
	GtkSourceBufferClass parent_class;
};



GType dialogs_unsaved_doc_column_get_type (void) G_GNUC_CONST;
GType main_window_get_type (void) G_GNUC_CONST;
GType document_get_type (void) G_GNUC_CONST;
void dialogs_close_several_unsaved_documents (MainWindow* window, GList* unsaved_docs);
static Block8Data* block8_data_ref (Block8Data* _data8_);
static void block8_data_unref (Block8Data* _data8_);
GType document_tab_get_type (void) G_GNUC_CONST;
const gchar* document_tab_get_label_text (DocumentTab* self);
static void __lambda71_ (Block8Data* _data8_, const gchar* path_str);
static void ___lambda71__gtk_cell_renderer_toggle_toggled (GtkCellRendererToggle* _sender, const gchar* path, gpointer self);
GtkWidget* utils_add_scrollbar (GtkWidget* child);
void main_window_remove_all_tabs (MainWindow* self);
GList* main_window_get_documents (MainWindow* self);
gboolean document_get_modified (Document* self);
gboolean main_window_close_tab (MainWindow* self, DocumentTab* tab, gboolean force_close);
static void _g_object_unref0_ (gpointer var);
static void _g_list_free__g_object_unref0_ (GList* self);
gboolean main_window_save_document (MainWindow* self, Document* doc, gboolean force_save_as);


GType dialogs_unsaved_doc_column_get_type (void) {
	static volatile gsize dialogs_unsaved_doc_column_type_id__volatile = 0;
	if (g_once_init_enter (&dialogs_unsaved_doc_column_type_id__volatile)) {
		static const GEnumValue values[] = {{DIALOGS_UNSAVED_DOC_COLUMN_SAVE, "DIALOGS_UNSAVED_DOC_COLUMN_SAVE", "save"}, {DIALOGS_UNSAVED_DOC_COLUMN_NAME, "DIALOGS_UNSAVED_DOC_COLUMN_NAME", "name"}, {DIALOGS_UNSAVED_DOC_COLUMN_DOC, "DIALOGS_UNSAVED_DOC_COLUMN_DOC", "doc"}, {DIALOGS_UNSAVED_DOC_COLUMN_N_COLUMNS, "DIALOGS_UNSAVED_DOC_COLUMN_N_COLUMNS", "n-columns"}, {0, NULL, NULL}};
		GType dialogs_unsaved_doc_column_type_id;
		dialogs_unsaved_doc_column_type_id = g_enum_register_static ("DialogsUnsavedDocColumn", values);
		g_once_init_leave (&dialogs_unsaved_doc_column_type_id__volatile, dialogs_unsaved_doc_column_type_id);
	}
	return dialogs_unsaved_doc_column_type_id__volatile;
}


static Block8Data* block8_data_ref (Block8Data* _data8_) {
	g_atomic_int_inc (&_data8_->_ref_count_);
	return _data8_;
}


static void block8_data_unref (Block8Data* _data8_) {
	if (g_atomic_int_dec_and_test (&_data8_->_ref_count_)) {
		_g_object_unref0 (_data8_->store);
		g_slice_free (Block8Data, _data8_);
	}
}


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


static void __lambda71_ (Block8Data* _data8_, const gchar* path_str) {
	const gchar* _tmp0_;
	GtkTreePath* _tmp1_;
	GtkTreePath* path;
	GtkTreeIter iter = {0};
	gboolean active = FALSE;
	GtkListStore* _tmp2_;
	GtkTreeIter _tmp3_ = {0};
	GtkListStore* _tmp4_;
	GtkTreeIter _tmp5_;
	GtkListStore* _tmp6_;
	GtkTreeIter _tmp7_;
	g_return_if_fail (path_str != NULL);
	_tmp0_ = path_str;
	_tmp1_ = gtk_tree_path_new_from_string (_tmp0_);
	path = _tmp1_;
	_tmp2_ = _data8_->store;
	gtk_tree_model_get_iter ((GtkTreeModel*) _tmp2_, &_tmp3_, path);
	iter = _tmp3_;
	_tmp4_ = _data8_->store;
	_tmp5_ = iter;
	gtk_tree_model_get ((GtkTreeModel*) _tmp4_, &_tmp5_, DIALOGS_UNSAVED_DOC_COLUMN_SAVE, &active, -1, -1);
	_tmp6_ = _data8_->store;
	_tmp7_ = iter;
	gtk_list_store_set (_tmp6_, &_tmp7_, DIALOGS_UNSAVED_DOC_COLUMN_SAVE, !active, -1, -1);
	_gtk_tree_path_free0 (path);
}


static void ___lambda71__gtk_cell_renderer_toggle_toggled (GtkCellRendererToggle* _sender, const gchar* path, gpointer self) {
	__lambda71_ (self, path);
}


static void _g_object_unref0_ (gpointer var) {
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}


static void _g_list_free__g_object_unref0_ (GList* self) {
	g_list_foreach (self, (GFunc) _g_object_unref0_, NULL);
	g_list_free (self);
}


void dialogs_close_several_unsaved_documents (MainWindow* window, GList* unsaved_docs) {
	Block8Data* _data8_;
	GList* _tmp0_;
	guint _tmp1_ = 0U;
	MainWindow* _tmp2_;
	const gchar* _tmp3_ = NULL;
	GtkDialog* _tmp4_;
	GtkDialog* _tmp5_;
	GtkDialog* dialog;
	GtkDialog* _tmp6_;
	GtkHBox* _tmp7_;
	GtkHBox* _tmp8_;
	GtkHBox* hbox;
	GtkHBox* _tmp9_;
	GtkDialog* _tmp10_;
	GtkWidget* _tmp11_ = NULL;
	GtkVBox* _tmp12_;
	GtkVBox* content_area;
	GtkVBox* _tmp13_;
	GtkHBox* _tmp14_;
	GtkImage* _tmp15_;
	GtkImage* _tmp16_;
	GtkImage* image;
	GtkImage* _tmp17_;
	GtkHBox* _tmp18_;
	GtkImage* _tmp19_;
	GtkVBox* _tmp20_;
	GtkVBox* _tmp21_;
	GtkVBox* vbox;
	GtkHBox* _tmp22_;
	GtkVBox* _tmp23_;
	GtkLabel* _tmp24_;
	GtkLabel* _tmp25_;
	GtkLabel* primary_label;
	GtkLabel* _tmp26_;
	GtkLabel* _tmp27_;
	GtkLabel* _tmp28_;
	GtkLabel* _tmp29_;
	GtkLabel* _tmp30_;
	const gchar* _tmp31_ = NULL;
	GList* _tmp32_;
	guint _tmp33_ = 0U;
	gchar* _tmp34_ = NULL;
	gchar* _tmp35_;
	gchar* _tmp36_;
	gchar* _tmp37_;
	gchar* _tmp38_;
	gchar* _tmp39_;
	GtkVBox* _tmp40_;
	GtkLabel* _tmp41_;
	GtkVBox* _tmp42_;
	GtkVBox* _tmp43_;
	GtkVBox* vbox2;
	GtkVBox* _tmp44_;
	GtkVBox* _tmp45_;
	const gchar* _tmp46_ = NULL;
	GtkLabel* _tmp47_;
	GtkLabel* _tmp48_;
	GtkLabel* select_label;
	GtkLabel* _tmp49_;
	GtkLabel* _tmp50_;
	GtkVBox* _tmp51_;
	GtkLabel* _tmp52_;
	GtkTreeView* _tmp53_;
	GtkTreeView* _tmp54_;
	GtkTreeView* treeview;
	GtkTreeView* _tmp55_;
	GtkTreeView* _tmp56_;
	GtkTreeView* _tmp57_;
	GtkListStore* _tmp58_;
	GList* _tmp59_;
	GtkTreeView* _tmp70_;
	GtkListStore* _tmp71_;
	GtkCellRendererToggle* _tmp72_;
	GtkCellRendererToggle* _tmp73_;
	GtkCellRendererToggle* renderer1;
	GtkCellRendererToggle* _tmp74_;
	GtkCellRendererToggle* _tmp75_;
	GtkTreeViewColumn* _tmp76_;
	GtkTreeViewColumn* _tmp77_;
	GtkTreeViewColumn* column;
	GtkTreeView* _tmp78_;
	GtkTreeViewColumn* _tmp79_;
	GtkCellRendererText* _tmp80_;
	GtkCellRendererText* _tmp81_;
	GtkCellRendererText* renderer2;
	GtkCellRendererText* _tmp82_;
	GtkTreeViewColumn* _tmp83_;
	GtkTreeViewColumn* _tmp84_;
	GtkTreeView* _tmp85_;
	GtkTreeViewColumn* _tmp86_;
	GtkTreeView* _tmp87_;
	GtkWidget* _tmp88_ = NULL;
	GtkScrolledWindow* sw;
	GtkScrolledWindow* _tmp89_;
	GtkVBox* _tmp90_;
	GtkScrolledWindow* _tmp91_;
	const gchar* _tmp92_ = NULL;
	GtkLabel* _tmp93_;
	GtkLabel* _tmp94_;
	GtkLabel* secondary_label;
	GtkLabel* _tmp95_;
	GtkLabel* _tmp96_;
	GtkLabel* _tmp97_;
	GtkVBox* _tmp98_;
	GtkLabel* _tmp99_;
	GtkHBox* _tmp100_;
	GtkDialog* _tmp101_;
	gint _tmp102_ = 0;
	gint resp;
	gint _tmp103_;
	GtkDialog* _tmp136_;
	g_return_if_fail (window != NULL);
	_data8_ = g_slice_new0 (Block8Data);
	_data8_->_ref_count_ = 1;
	_tmp0_ = unsaved_docs;
	_tmp1_ = g_list_length (_tmp0_);
	g_return_if_fail (_tmp1_ >= ((guint) 2));
	_tmp2_ = window;
	_tmp3_ = _ ("Close without Saving");
	_tmp4_ = (GtkDialog*) gtk_dialog_new_with_buttons (NULL, (GtkWindow*) _tmp2_, GTK_DIALOG_DESTROY_WITH_PARENT, _tmp3_, GTK_RESPONSE_CLOSE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL, NULL);
	_tmp5_ = g_object_ref_sink (_tmp4_);
	dialog = _tmp5_;
	_tmp6_ = dialog;
	gtk_dialog_set_has_separator (_tmp6_, FALSE);
	_tmp7_ = (GtkHBox*) gtk_hbox_new (FALSE, 12);
	_tmp8_ = g_object_ref_sink (_tmp7_);
	hbox = _tmp8_;
	_tmp9_ = hbox;
	gtk_container_set_border_width ((GtkContainer*) _tmp9_, (guint) 5);
	_tmp10_ = dialog;
	_tmp11_ = gtk_dialog_get_content_area (_tmp10_);
	_tmp12_ = _g_object_ref0 (GTK_VBOX (_tmp11_));
	content_area = _tmp12_;
	_tmp13_ = content_area;
	_tmp14_ = hbox;
	gtk_box_pack_start ((GtkBox*) _tmp13_, (GtkWidget*) _tmp14_, TRUE, TRUE, (guint) 0);
	_tmp15_ = (GtkImage*) gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
	_tmp16_ = g_object_ref_sink (_tmp15_);
	image = _tmp16_;
	_tmp17_ = image;
	gtk_misc_set_alignment ((GtkMisc*) _tmp17_, (gfloat) 0.5, (gfloat) 0.0);
	_tmp18_ = hbox;
	_tmp19_ = image;
	gtk_box_pack_start ((GtkBox*) _tmp18_, (GtkWidget*) _tmp19_, FALSE, FALSE, (guint) 0);
	_tmp20_ = (GtkVBox*) gtk_vbox_new (FALSE, 12);
	_tmp21_ = g_object_ref_sink (_tmp20_);
	vbox = _tmp21_;
	_tmp22_ = hbox;
	_tmp23_ = vbox;
	gtk_box_pack_start ((GtkBox*) _tmp22_, (GtkWidget*) _tmp23_, TRUE, TRUE, (guint) 0);
	_tmp24_ = (GtkLabel*) gtk_label_new (NULL);
	_tmp25_ = g_object_ref_sink (_tmp24_);
	primary_label = _tmp25_;
	_tmp26_ = primary_label;
	gtk_label_set_line_wrap (_tmp26_, TRUE);
	_tmp27_ = primary_label;
	gtk_label_set_use_markup (_tmp27_, TRUE);
	_tmp28_ = primary_label;
	gtk_misc_set_alignment ((GtkMisc*) _tmp28_, (gfloat) 0.0, (gfloat) 0.5);
	_tmp29_ = primary_label;
	gtk_label_set_selectable (_tmp29_, TRUE);
	_tmp30_ = primary_label;
	_tmp31_ = _ ("There are %d documents with unsaved changes. Save changes before closi" \
"ng?");
	_tmp32_ = unsaved_docs;
	_tmp33_ = g_list_length (_tmp32_);
	_tmp34_ = g_strdup_printf (_tmp31_, _tmp33_);
	_tmp35_ = _tmp34_;
	_tmp36_ = g_strconcat ("<span weight=\"bold\" size=\"larger\">", _tmp35_, NULL);
	_tmp37_ = _tmp36_;
	_tmp38_ = g_strconcat (_tmp37_, "</span>", NULL);
	_tmp39_ = _tmp38_;
	gtk_label_set_markup (_tmp30_, _tmp39_);
	_g_free0 (_tmp39_);
	_g_free0 (_tmp37_);
	_g_free0 (_tmp35_);
	_tmp40_ = vbox;
	_tmp41_ = primary_label;
	gtk_box_pack_start ((GtkBox*) _tmp40_, (GtkWidget*) _tmp41_, FALSE, FALSE, (guint) 0);
	_tmp42_ = (GtkVBox*) gtk_vbox_new (FALSE, 8);
	_tmp43_ = g_object_ref_sink (_tmp42_);
	vbox2 = _tmp43_;
	_tmp44_ = vbox;
	_tmp45_ = vbox2;
	gtk_box_pack_start ((GtkBox*) _tmp44_, (GtkWidget*) _tmp45_, FALSE, FALSE, (guint) 0);
	_tmp46_ = _ ("Select the documents you want to save:");
	_tmp47_ = (GtkLabel*) gtk_label_new (_tmp46_);
	_tmp48_ = g_object_ref_sink (_tmp47_);
	select_label = _tmp48_;
	_tmp49_ = select_label;
	gtk_label_set_line_wrap (_tmp49_, TRUE);
	_tmp50_ = select_label;
	gtk_misc_set_alignment ((GtkMisc*) _tmp50_, (gfloat) 0.0, (gfloat) 0.5);
	_tmp51_ = vbox2;
	_tmp52_ = select_label;
	gtk_box_pack_start ((GtkBox*) _tmp51_, (GtkWidget*) _tmp52_, FALSE, FALSE, (guint) 0);
	_tmp53_ = (GtkTreeView*) gtk_tree_view_new ();
	_tmp54_ = g_object_ref_sink (_tmp53_);
	treeview = _tmp54_;
	_tmp55_ = treeview;
	gtk_widget_set_size_request ((GtkWidget*) _tmp55_, 260, 120);
	_tmp56_ = treeview;
	gtk_tree_view_set_headers_visible (_tmp56_, FALSE);
	_tmp57_ = treeview;
	gtk_tree_view_set_enable_search (_tmp57_, FALSE);
	_tmp58_ = gtk_list_store_new ((gint) DIALOGS_UNSAVED_DOC_COLUMN_N_COLUMNS, G_TYPE_BOOLEAN, G_TYPE_STRING, TYPE_DOCUMENT);
	_data8_->store = _tmp58_;
	_tmp59_ = unsaved_docs;
	{
		GList* doc_collection = NULL;
		GList* doc_it = NULL;
		doc_collection = _tmp59_;
		for (doc_it = doc_collection; doc_it != NULL; doc_it = doc_it->next) {
			Document* _tmp60_;
			Document* doc = NULL;
			_tmp60_ = _g_object_ref0 ((Document*) doc_it->data);
			doc = _tmp60_;
			{
				GtkTreeIter iter = {0};
				GtkListStore* _tmp61_;
				GtkTreeIter _tmp62_ = {0};
				GtkListStore* _tmp63_;
				GtkTreeIter _tmp64_;
				Document* _tmp65_;
				DocumentTab* _tmp66_;
				const gchar* _tmp67_;
				const gchar* _tmp68_;
				Document* _tmp69_;
				_tmp61_ = _data8_->store;
				gtk_list_store_append (_tmp61_, &_tmp62_);
				iter = _tmp62_;
				_tmp63_ = _data8_->store;
				_tmp64_ = iter;
				_tmp65_ = doc;
				_tmp66_ = _tmp65_->tab;
				_tmp67_ = document_tab_get_label_text (_tmp66_);
				_tmp68_ = _tmp67_;
				_tmp69_ = doc;
				gtk_list_store_set (_tmp63_, &_tmp64_, DIALOGS_UNSAVED_DOC_COLUMN_SAVE, TRUE, DIALOGS_UNSAVED_DOC_COLUMN_NAME, _tmp68_, DIALOGS_UNSAVED_DOC_COLUMN_DOC, _tmp69_, -1, -1);
				_g_object_unref0 (doc);
			}
		}
	}
	_tmp70_ = treeview;
	_tmp71_ = _data8_->store;
	gtk_tree_view_set_model (_tmp70_, (GtkTreeModel*) _tmp71_);
	_tmp72_ = (GtkCellRendererToggle*) gtk_cell_renderer_toggle_new ();
	_tmp73_ = g_object_ref_sink (_tmp72_);
	renderer1 = _tmp73_;
	_tmp74_ = renderer1;
	g_signal_connect_data (_tmp74_, "toggled", (GCallback) ___lambda71__gtk_cell_renderer_toggle_toggled, block8_data_ref (_data8_), (GClosureNotify) block8_data_unref, 0);
	_tmp75_ = renderer1;
	_tmp76_ = gtk_tree_view_column_new_with_attributes ("Save?", (GtkCellRenderer*) _tmp75_, "active", DIALOGS_UNSAVED_DOC_COLUMN_SAVE, NULL, NULL);
	_tmp77_ = g_object_ref_sink (_tmp76_);
	column = _tmp77_;
	_tmp78_ = treeview;
	_tmp79_ = column;
	gtk_tree_view_append_column (_tmp78_, _tmp79_);
	_tmp80_ = (GtkCellRendererText*) gtk_cell_renderer_text_new ();
	_tmp81_ = g_object_ref_sink (_tmp80_);
	renderer2 = _tmp81_;
	_tmp82_ = renderer2;
	_tmp83_ = gtk_tree_view_column_new_with_attributes ("Name", (GtkCellRenderer*) _tmp82_, "text", DIALOGS_UNSAVED_DOC_COLUMN_NAME, NULL, NULL);
	_tmp84_ = g_object_ref_sink (_tmp83_);
	_g_object_unref0 (column);
	column = _tmp84_;
	_tmp85_ = treeview;
	_tmp86_ = column;
	gtk_tree_view_append_column (_tmp85_, _tmp86_);
	_tmp87_ = treeview;
	_tmp88_ = utils_add_scrollbar ((GtkWidget*) _tmp87_);
	sw = GTK_SCROLLED_WINDOW (_tmp88_);
	_tmp89_ = sw;
	gtk_scrolled_window_set_shadow_type (_tmp89_, GTK_SHADOW_IN);
	_tmp90_ = vbox2;
	_tmp91_ = sw;
	gtk_box_pack_start ((GtkBox*) _tmp90_, (GtkWidget*) _tmp91_, TRUE, TRUE, (guint) 0);
	_tmp92_ = _ ("If you don't save, all your changes will be permanently lost.");
	_tmp93_ = (GtkLabel*) gtk_label_new (_tmp92_);
	_tmp94_ = g_object_ref_sink (_tmp93_);
	secondary_label = _tmp94_;
	_tmp95_ = secondary_label;
	gtk_label_set_line_wrap (_tmp95_, TRUE);
	_tmp96_ = secondary_label;
	gtk_misc_set_alignment ((GtkMisc*) _tmp96_, (gfloat) 0.0, (gfloat) 0.5);
	_tmp97_ = secondary_label;
	gtk_label_set_selectable (_tmp97_, TRUE);
	_tmp98_ = vbox2;
	_tmp99_ = secondary_label;
	gtk_box_pack_start ((GtkBox*) _tmp98_, (GtkWidget*) _tmp99_, FALSE, FALSE, (guint) 0);
	_tmp100_ = hbox;
	gtk_widget_show_all ((GtkWidget*) _tmp100_);
	_tmp101_ = dialog;
	_tmp102_ = gtk_dialog_run (_tmp101_);
	resp = _tmp102_;
	_tmp103_ = resp;
	if (_tmp103_ == ((gint) GTK_RESPONSE_CLOSE)) {
		MainWindow* _tmp104_;
		_tmp104_ = window;
		main_window_remove_all_tabs (_tmp104_);
	} else {
		gint _tmp105_;
		_tmp105_ = resp;
		if (_tmp105_ == ((gint) GTK_RESPONSE_ACCEPT)) {
			MainWindow* _tmp106_;
			GList* _tmp107_ = NULL;
			GList* selected_docs;
			GtkTreeIter iter = {0};
			GtkListStore* _tmp114_;
			GtkTreeIter _tmp115_ = {0};
			gboolean _tmp116_ = FALSE;
			gboolean valid;
			GList* _tmp128_;
			_tmp106_ = window;
			_tmp107_ = main_window_get_documents (_tmp106_);
			{
				GList* doc_collection = NULL;
				GList* doc_it = NULL;
				doc_collection = _tmp107_;
				for (doc_it = doc_collection; doc_it != NULL; doc_it = doc_it->next) {
					Document* _tmp108_;
					Document* doc = NULL;
					_tmp108_ = _g_object_ref0 ((Document*) doc_it->data);
					doc = _tmp108_;
					{
						Document* _tmp109_;
						gboolean _tmp110_ = FALSE;
						_tmp109_ = doc;
						_tmp110_ = document_get_modified (_tmp109_);
						if (!_tmp110_) {
							MainWindow* _tmp111_;
							Document* _tmp112_;
							DocumentTab* _tmp113_;
							_tmp111_ = window;
							_tmp112_ = doc;
							_tmp113_ = _tmp112_->tab;
							main_window_close_tab (_tmp111_, _tmp113_, FALSE);
						}
						_g_object_unref0 (doc);
					}
				}
				__g_list_free__g_object_unref0_0 (doc_collection);
			}
			selected_docs = NULL;
			_tmp114_ = _data8_->store;
			_tmp116_ = gtk_tree_model_get_iter_first ((GtkTreeModel*) _tmp114_, &_tmp115_);
			iter = _tmp115_;
			valid = _tmp116_;
			while (TRUE) {
				gboolean _tmp117_;
				gboolean selected = FALSE;
				Document* doc = NULL;
				GtkListStore* _tmp118_;
				GtkTreeIter _tmp119_;
				gboolean _tmp120_;
				GtkListStore* _tmp126_;
				gboolean _tmp127_ = FALSE;
				_tmp117_ = valid;
				if (!_tmp117_) {
					break;
				}
				_tmp118_ = _data8_->store;
				_tmp119_ = iter;
				gtk_tree_model_get ((GtkTreeModel*) _tmp118_, &_tmp119_, DIALOGS_UNSAVED_DOC_COLUMN_SAVE, &selected, DIALOGS_UNSAVED_DOC_COLUMN_DOC, &doc, -1, -1);
				_tmp120_ = selected;
				if (_tmp120_) {
					Document* _tmp121_;
					Document* _tmp122_;
					_tmp121_ = doc;
					_tmp122_ = _g_object_ref0 (_tmp121_);
					selected_docs = g_list_prepend (selected_docs, _tmp122_);
				} else {
					MainWindow* _tmp123_;
					Document* _tmp124_;
					DocumentTab* _tmp125_;
					_tmp123_ = window;
					_tmp124_ = doc;
					_tmp125_ = _tmp124_->tab;
					main_window_close_tab (_tmp123_, _tmp125_, TRUE);
				}
				_tmp126_ = _data8_->store;
				_tmp127_ = gtk_tree_model_iter_next ((GtkTreeModel*) _tmp126_, &iter);
				valid = _tmp127_;
				_g_object_unref0 (doc);
			}
			selected_docs = g_list_reverse (selected_docs);
			_tmp128_ = selected_docs;
			{
				GList* doc_collection = NULL;
				GList* doc_it = NULL;
				doc_collection = _tmp128_;
				for (doc_it = doc_collection; doc_it != NULL; doc_it = doc_it->next) {
					Document* _tmp129_;
					Document* doc = NULL;
					_tmp129_ = _g_object_ref0 ((Document*) doc_it->data);
					doc = _tmp129_;
					{
						MainWindow* _tmp130_;
						Document* _tmp131_;
						gboolean _tmp132_ = FALSE;
						_tmp130_ = window;
						_tmp131_ = doc;
						_tmp132_ = main_window_save_document (_tmp130_, _tmp131_, FALSE);
						if (_tmp132_) {
							MainWindow* _tmp133_;
							Document* _tmp134_;
							DocumentTab* _tmp135_;
							_tmp133_ = window;
							_tmp134_ = doc;
							_tmp135_ = _tmp134_->tab;
							main_window_close_tab (_tmp133_, _tmp135_, TRUE);
						}
						_g_object_unref0 (doc);
					}
				}
			}
			__g_list_free__g_object_unref0_0 (selected_docs);
		}
	}
	_tmp136_ = dialog;
	gtk_object_destroy ((GtkObject*) _tmp136_);
	_g_object_unref0 (secondary_label);
	_g_object_unref0 (sw);
	_g_object_unref0 (renderer2);
	_g_object_unref0 (column);
	_g_object_unref0 (renderer1);
	_g_object_unref0 (treeview);
	_g_object_unref0 (select_label);
	_g_object_unref0 (vbox2);
	_g_object_unref0 (primary_label);
	_g_object_unref0 (vbox);
	_g_object_unref0 (image);
	_g_object_unref0 (content_area);
	_g_object_unref0 (hbox);
	_g_object_unref0 (dialog);
	block8_data_unref (_data8_);
	_data8_ = NULL;
}



