/* dialogs.c generated by valac 0.36.5, 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))
#define _gtk_tree_path_free0(var) ((var == NULL) ? NULL : (var = (gtk_tree_path_free (var), NULL)))

#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;
typedef struct _DocumentPrivate DocumentPrivate;
#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;
};

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_);
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);
GType document_tab_get_type (void) G_GNUC_CONST;
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* _tmp65_;
	GtkListStore* _tmp66_;
	GtkCellRendererToggle* renderer1 = NULL;
	GtkCellRendererToggle* _tmp67_;
	GtkCellRendererToggle* _tmp68_;
	GtkTreeViewColumn* column = NULL;
	GtkCellRendererToggle* _tmp69_;
	GtkTreeViewColumn* _tmp70_;
	GtkTreeView* _tmp71_;
	GtkTreeViewColumn* _tmp72_;
	GtkCellRendererText* renderer2 = NULL;
	GtkCellRendererText* _tmp73_;
	GtkCellRendererText* _tmp74_;
	GtkTreeViewColumn* _tmp75_;
	GtkTreeView* _tmp76_;
	GtkTreeViewColumn* _tmp77_;
	GtkScrolledWindow* sw = NULL;
	GtkTreeView* _tmp78_;
	GtkScrolledWindow* _tmp79_;
	GtkScrolledWindow* _tmp80_;
	GtkScrolledWindow* _tmp81_;
	GtkGrid* _tmp82_;
	GtkScrolledWindow* _tmp83_;
	GtkLabel* secondary_label = NULL;
	GtkLabel* _tmp84_;
	GtkLabel* _tmp85_;
	GtkLabel* _tmp86_;
	GtkLabel* _tmp87_;
	GtkGrid* _tmp88_;
	GtkLabel* _tmp89_;
	GtkGrid* _tmp90_;
	gint resp = 0;
	GtkDialog* _tmp91_;
	gint _tmp92_;
	gint _tmp93_;
	GtkDialog* _tmp134_;
	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_;
			TeplFile* _tmp62_;
			const gchar* _tmp63_;
			Document* _tmp64_;
			_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_ = tepl_buffer_get_file ((TeplBuffer*) _tmp61_);
			_tmp63_ = tepl_file_get_short_name (_tmp62_);
			_tmp64_ = doc;
			gtk_list_store_set (_tmp59_, &_tmp60_, DIALOGS_UNSAVED_DOC_COLUMN_SAVE, TRUE, DIALOGS_UNSAVED_DOC_COLUMN_NAME, _tmp63_, DIALOGS_UNSAVED_DOC_COLUMN_DOC, _tmp64_, -1, -1);
			_g_object_unref0 (doc);
		}
		_g_object_unref0 (_doc_list);
	}
	_tmp65_ = treeview;
	_tmp66_ = _data12_->store;
	gtk_tree_view_set_model (_tmp65_, (GtkTreeModel*) _tmp66_);
	_tmp67_ = (GtkCellRendererToggle*) gtk_cell_renderer_toggle_new ();
	g_object_ref_sink (_tmp67_);
	renderer1 = _tmp67_;
	_tmp68_ = renderer1;
	g_signal_connect_data (_tmp68_, "toggled", (GCallback) ___lambda23__gtk_cell_renderer_toggle_toggled, block12_data_ref (_data12_), (GClosureNotify) block12_data_unref, 0);
	_tmp69_ = renderer1;
	_tmp70_ = gtk_tree_view_column_new_with_attributes ("Save?", (GtkCellRenderer*) _tmp69_, "active", DIALOGS_UNSAVED_DOC_COLUMN_SAVE, NULL, NULL);
	g_object_ref_sink (_tmp70_);
	column = _tmp70_;
	_tmp71_ = treeview;
	_tmp72_ = column;
	gtk_tree_view_append_column (_tmp71_, _tmp72_);
	_tmp73_ = (GtkCellRendererText*) gtk_cell_renderer_text_new ();
	g_object_ref_sink (_tmp73_);
	renderer2 = _tmp73_;
	_tmp74_ = renderer2;
	_tmp75_ = gtk_tree_view_column_new_with_attributes ("Name", (GtkCellRenderer*) _tmp74_, "text", DIALOGS_UNSAVED_DOC_COLUMN_NAME, NULL, NULL);
	g_object_ref_sink (_tmp75_);
	_g_object_unref0 (column);
	column = _tmp75_;
	_tmp76_ = treeview;
	_tmp77_ = column;
	gtk_tree_view_append_column (_tmp76_, _tmp77_);
	_tmp78_ = treeview;
	_tmp79_ = utils_add_scrollbar ((GtkWidget*) _tmp78_);
	sw = _tmp79_;
	_tmp80_ = sw;
	gtk_scrolled_window_set_shadow_type (_tmp80_, GTK_SHADOW_IN);
	_tmp81_ = sw;
	g_object_set ((GtkWidget*) _tmp81_, "expand", TRUE, NULL);
	_tmp82_ = grid;
	_tmp83_ = sw;
	gtk_grid_attach (_tmp82_, (GtkWidget*) _tmp83_, 1, 2, 1, 1);
	_tmp84_ = (GtkLabel*) gtk_label_new (_ ("If you don't save, all your changes will be permanently lost."));
	g_object_ref_sink (_tmp84_);
	secondary_label = _tmp84_;
	_tmp85_ = secondary_label;
	gtk_label_set_line_wrap (_tmp85_, TRUE);
	_tmp86_ = secondary_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp86_, GTK_ALIGN_START);
	_tmp87_ = secondary_label;
	gtk_label_set_selectable (_tmp87_, TRUE);
	_tmp88_ = grid;
	_tmp89_ = secondary_label;
	gtk_grid_attach (_tmp88_, (GtkWidget*) _tmp89_, 1, 3, 1, 1);
	_tmp90_ = grid;
	gtk_widget_show_all ((GtkWidget*) _tmp90_);
	_tmp91_ = dialog;
	_tmp92_ = gtk_dialog_run (_tmp91_);
	resp = _tmp92_;
	_tmp93_ = resp;
	if (_tmp93_ == ((gint) GTK_RESPONSE_CLOSE)) {
		MainWindow* _tmp94_;
		_tmp94_ = window;
		main_window_remove_all_tabs (_tmp94_);
	} else {
		gint _tmp95_;
		_tmp95_ = resp;
		if (_tmp95_ == ((gint) GTK_RESPONSE_ACCEPT)) {
			GList* selected_docs = NULL;
			GtkTreeIter iter = {0};
			gboolean valid = FALSE;
			GtkListStore* _tmp112_;
			GtkTreeIter _tmp113_ = {0};
			gboolean _tmp114_;
			GList* _tmp126_;
			{
				GeeList* _doc_list = NULL;
				MainWindow* _tmp96_;
				GeeList* _tmp97_;
				gint _doc_size = 0;
				GeeList* _tmp98_;
				gint _tmp99_;
				gint _tmp100_;
				gint _doc_index = 0;
				_tmp96_ = window;
				_tmp97_ = main_window_get_documents (_tmp96_);
				_doc_list = _tmp97_;
				_tmp98_ = _doc_list;
				_tmp99_ = gee_collection_get_size ((GeeCollection*) _tmp98_);
				_tmp100_ = _tmp99_;
				_doc_size = _tmp100_;
				_doc_index = -1;
				while (TRUE) {
					gint _tmp101_;
					gint _tmp102_;
					gint _tmp103_;
					Document* doc = NULL;
					GeeList* _tmp104_;
					gint _tmp105_;
					gpointer _tmp106_;
					Document* _tmp107_;
					gboolean _tmp108_;
					_tmp101_ = _doc_index;
					_doc_index = _tmp101_ + 1;
					_tmp102_ = _doc_index;
					_tmp103_ = _doc_size;
					if (!(_tmp102_ < _tmp103_)) {
						break;
					}
					_tmp104_ = _doc_list;
					_tmp105_ = _doc_index;
					_tmp106_ = gee_list_get (_tmp104_, _tmp105_);
					doc = (Document*) _tmp106_;
					_tmp107_ = doc;
					_tmp108_ = gtk_text_buffer_get_modified ((GtkTextBuffer*) _tmp107_);
					if (!_tmp108_) {
						MainWindow* _tmp109_;
						Document* _tmp110_;
						DocumentTab* _tmp111_;
						_tmp109_ = window;
						_tmp110_ = doc;
						_tmp111_ = _tmp110_->tab;
						main_window_close_tab (_tmp109_, _tmp111_, FALSE);
					}
					_g_object_unref0 (doc);
				}
				_g_object_unref0 (_doc_list);
			}
			selected_docs = NULL;
			_tmp112_ = _data12_->store;
			_tmp114_ = gtk_tree_model_get_iter_first ((GtkTreeModel*) _tmp112_, &_tmp113_);
			iter = _tmp113_;
			valid = _tmp114_;
			while (TRUE) {
				gboolean _tmp115_;
				gboolean selected = FALSE;
				Document* doc = NULL;
				GtkListStore* _tmp116_;
				GtkTreeIter _tmp117_;
				gboolean _tmp118_;
				GtkListStore* _tmp124_;
				gboolean _tmp125_;
				_tmp115_ = valid;
				if (!_tmp115_) {
					break;
				}
				_tmp116_ = _data12_->store;
				_tmp117_ = iter;
				gtk_tree_model_get ((GtkTreeModel*) _tmp116_, &_tmp117_, DIALOGS_UNSAVED_DOC_COLUMN_SAVE, &selected, DIALOGS_UNSAVED_DOC_COLUMN_DOC, &doc, -1, -1);
				_tmp118_ = selected;
				if (_tmp118_) {
					Document* _tmp119_;
					Document* _tmp120_;
					_tmp119_ = doc;
					_tmp120_ = _g_object_ref0 (_tmp119_);
					selected_docs = g_list_prepend (selected_docs, _tmp120_);
				} else {
					MainWindow* _tmp121_;
					Document* _tmp122_;
					DocumentTab* _tmp123_;
					_tmp121_ = window;
					_tmp122_ = doc;
					_tmp123_ = _tmp122_->tab;
					main_window_close_tab (_tmp121_, _tmp123_, TRUE);
				}
				_tmp124_ = _data12_->store;
				_tmp125_ = gtk_tree_model_iter_next ((GtkTreeModel*) _tmp124_, &iter);
				valid = _tmp125_;
				_g_object_unref0 (doc);
			}
			selected_docs = g_list_reverse (selected_docs);
			_tmp126_ = selected_docs;
			{
				GList* doc_collection = NULL;
				GList* doc_it = NULL;
				doc_collection = _tmp126_;
				for (doc_it = doc_collection; doc_it != NULL; doc_it = doc_it->next) {
					Document* _tmp127_;
					Document* doc = NULL;
					_tmp127_ = _g_object_ref0 ((Document*) doc_it->data);
					doc = _tmp127_;
					{
						MainWindow* _tmp128_;
						Document* _tmp129_;
						gboolean _tmp130_;
						_tmp128_ = window;
						_tmp129_ = doc;
						_tmp130_ = main_window_save_document (_tmp128_, _tmp129_, FALSE);
						if (_tmp130_) {
							MainWindow* _tmp131_;
							Document* _tmp132_;
							DocumentTab* _tmp133_;
							_tmp131_ = window;
							_tmp132_ = doc;
							_tmp133_ = _tmp132_->tab;
							main_window_close_tab (_tmp131_, _tmp133_, TRUE);
						}
						_g_object_unref0 (doc);
					}
				}
			}
			__g_list_free__g_object_unref0_0 (selected_docs);
		}
	}
	_tmp134_ = dialog;
	gtk_widget_destroy ((GtkWidget*) _tmp134_);
	_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;
}



