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



