/* dialogs.c generated by valac 0.36.3, 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 <gee.h>
#include <tepl/tepl.h>
#include <glib/gi18n-lib.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 _Block12Data Block12Data;
#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 _Block12Data {
	int _ref_count_;
	GtkListStore* store;
};

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

struct _DocumentClass {
	TeplBufferClass 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, GeeList* unsaved_docs);
static Block12Data* block12_data_ref (Block12Data* _data12_);
static void block12_data_unref (void * _userdata_);
GType document_tab_get_type (void) G_GNUC_CONST;
const gchar* document_tab_get_label_text (DocumentTab* self);
static void __lambda23_ (Block12Data* _data12_, const gchar* path_str);
static void ___lambda23__gtk_cell_renderer_toggle_toggled (GtkCellRendererToggle* _sender, const gchar* path, gpointer self);
GtkScrolledWindow* utils_add_scrollbar (GtkWidget* child);
void main_window_remove_all_tabs (MainWindow* self);
GeeList* main_window_get_documents (MainWindow* self);
gboolean main_window_close_tab (MainWindow* self, DocumentTab* tab, gboolean force_close);
gboolean main_window_save_document (MainWindow* self, Document* doc, gboolean force_save_as);
static void _g_object_unref0_ (gpointer var);
static void _g_list_free__g_object_unref0_ (GList* self);


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 Block12Data* block12_data_ref (Block12Data* _data12_) {
	g_atomic_int_inc (&_data12_->_ref_count_);
	return _data12_;
}


static void block12_data_unref (void * _userdata_) {
	Block12Data* _data12_;
	_data12_ = (Block12Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data12_->_ref_count_)) {
		_g_object_unref0 (_data12_->store);
		g_slice_free (Block12Data, _data12_);
	}
}


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


static void __lambda23_ (Block12Data* _data12_, const gchar* path_str) {
	GtkTreePath* path = NULL;
	const gchar* _tmp0_;
	GtkTreePath* _tmp1_;
	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_ = _data12_->store;
	gtk_tree_model_get_iter ((GtkTreeModel*) _tmp2_, &_tmp3_, path);
	iter = _tmp3_;
	_tmp4_ = _data12_->store;
	_tmp5_ = iter;
	gtk_tree_model_get ((GtkTreeModel*) _tmp4_, &_tmp5_, DIALOGS_UNSAVED_DOC_COLUMN_SAVE, &active, -1, -1);
	_tmp6_ = _data12_->store;
	_tmp7_ = iter;
	gtk_list_store_set (_tmp6_, &_tmp7_, DIALOGS_UNSAVED_DOC_COLUMN_SAVE, !active, -1, -1);
	_gtk_tree_path_free0 (path);
}


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



