/* dialogs.c generated by valac 0.16.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 _Block9Data Block9Data;
#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 _Block9Data {
	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 Block9Data* block9_data_ref (Block9Data* _data9_);
static void block9_data_unref (void * _userdata_);
GType document_tab_get_type (void) G_GNUC_CONST;
const gchar* document_tab_get_label_text (DocumentTab* self);
static void __lambda78_ (Block9Data* _data9_, const gchar* path_str);
static void ___lambda78__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);
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 Block9Data* block9_data_ref (Block9Data* _data9_) {
	g_atomic_int_inc (&_data9_->_ref_count_);
	return _data9_;
}


static void block9_data_unref (void * _userdata_) {
	Block9Data* _data9_;
	_data9_ = (Block9Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data9_->_ref_count_)) {
		_g_object_unref0 (_data9_->store);
		g_slice_free (Block9Data, _data9_);
	}
}


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


static void __lambda78_ (Block9Data* _data9_, 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_ = _data9_->store;
	gtk_tree_model_get_iter ((GtkTreeModel*) _tmp2_, &_tmp3_, path);
	iter = _tmp3_;
	_tmp4_ = _data9_->store;
	_tmp5_ = iter;
	gtk_tree_model_get ((GtkTreeModel*) _tmp4_, &_tmp5_, DIALOGS_UNSAVED_DOC_COLUMN_SAVE, &active, -1, -1);
	_tmp6_ = _data9_->store;
	_tmp7_ = iter;
	gtk_list_store_set (_tmp6_, &_tmp7_, DIALOGS_UNSAVED_DOC_COLUMN_SAVE, !active, -1, -1);
	_gtk_tree_path_free0 (path);
}


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



