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



