/* dialogs.c generated by valac 0.39.1.3-7091, 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 __lambda19_ (Block12Data* _data12_, 
                  const gchar* path_str);
static void ___lambda19__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 inline 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
__lambda19_ (Block12Data* _data12_, 
             const gchar* path_str)
{
	GtkTreePath* path = NULL;
	GtkTreePath* _tmp0_;
	GtkTreeIter iter = {0};
	gboolean active = FALSE;
	GtkListStore* _tmp1_;
	GtkTreeIter _tmp2_ = {0};
	GtkListStore* _tmp3_;
	GtkTreeIter _tmp4_;
	GtkListStore* _tmp5_;
	GtkTreeIter _tmp6_;
	g_return_if_fail (path_str != NULL);
	_tmp0_ = gtk_tree_path_new_from_string (path_str);
	path = _tmp0_;
	_tmp1_ = _data12_->store;
	gtk_tree_model_get_iter ((GtkTreeModel*) _tmp1_, &_tmp2_, path);
	iter = _tmp2_;
	_tmp3_ = _data12_->store;
	_tmp4_ = iter;
	gtk_tree_model_get ((GtkTreeModel*) _tmp3_, &_tmp4_, DIALOGS_UNSAVED_DOC_COLUMN_SAVE, &active, -1, -1);
	_tmp5_ = _data12_->store;
	_tmp6_ = iter;
	gtk_list_store_set (_tmp5_, &_tmp6_, DIALOGS_UNSAVED_DOC_COLUMN_SAVE, !active, -1, -1);
	_gtk_tree_path_free0 (path);
}


static void
___lambda19__gtk_cell_renderer_toggle_toggled (GtkCellRendererToggle* _sender, 
                                               const gchar* path, 
                                               gpointer self)
{
	__lambda19_ (self, path);
}


static void
_g_object_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}


static inline void
_g_list_free__g_object_unref0_ (GList* self)
{
	g_list_free_full (self, (GDestroyNotify) _g_object_unref0_);
}


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



