/* dialogs.c generated by valac 0.48.10, the Vala compiler
 * generated from dialogs.vala, do not modify */

/*
 * This file is part of GNOME LaTeX.
 *
 * Copyright © 2010-2011 Sébastien Wilmet
 *
 * GNOME LaTeX 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.
 *
 * GNOME LaTeX 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 GNOME LaTeX.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <glib-object.h>
#include <gtk/gtk.h>
#include <gee.h>
#include <tepl/tepl.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.h>

typedef enum  {
	DIALOGS_UNSAVED_DOC_COLUMN_SAVE,
	DIALOGS_UNSAVED_DOC_COLUMN_NAME,
	DIALOGS_UNSAVED_DOC_COLUMN_DOC,
	DIALOGS_UNSAVED_DOC_COLUMN_N_COLUMNS
} DialogsUnsavedDocColumn;

#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 __vala_GtkTreePath_free0(var) ((var == NULL) ? NULL : (var = (_vala_GtkTreePath_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;

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;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MainWindow, g_object_unref)
GType document_get_type (void) G_GNUC_CONST;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Document, g_object_unref)
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 __lambda41_ (Block12Data* _data12_,
                  const gchar* path_str);
static void _vala_GtkTreePath_free (GtkTreePath* self);
static void ___lambda41__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;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DocumentTab, g_object_unref)
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);

G_GNUC_NO_INLINE static GType
dialogs_unsaved_doc_column_get_type_once (void)
{
	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);
	return dialogs_unsaved_doc_column_type_id;
}

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)) {
		GType dialogs_unsaved_doc_column_type_id;
		dialogs_unsaved_doc_column_type_id = dialogs_unsaved_doc_column_get_type_once ();
		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
_vala_GtkTreePath_free (GtkTreePath* self)
{
	g_boxed_free (gtk_tree_path_get_type (), self);
}

static void
__lambda41_ (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_;
	gboolean _tmp5_ = FALSE;
	GtkListStore* _tmp6_;
	GtkTreeIter _tmp7_;
	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, &_tmp5_, -1, -1);
	active = _tmp5_;
	_tmp6_ = _data12_->store;
	_tmp7_ = iter;
	gtk_list_store_set (_tmp6_, &_tmp7_, DIALOGS_UNSAVED_DOC_COLUMN_SAVE, !active, -1, -1);
	__vala_GtkTreePath_free0 (path);
}

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

