/* main_window.c generated by valac 0.17.3.8-fd35, the Vala compiler
 * generated from main_window.vala, do not modify */

/*
 * This file is part of LaTeXila.
 *
 * Copyright © 2010-2012 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 <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <gdk/gdk.h>
#include <glib/gi18n-lib.h>
#include <gee.h>
#include <gtksourceview/gtksource.h>
#include "config.h"
#include <float.h>
#include <math.h>
#include <gdk-pixbuf/gdk-pixbuf.h>


#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;
typedef struct _MainWindowPrivate MainWindowPrivate;

#define TYPE_DOCUMENTS_PANEL (documents_panel_get_type ())
#define DOCUMENTS_PANEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DOCUMENTS_PANEL, DocumentsPanel))
#define DOCUMENTS_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DOCUMENTS_PANEL, DocumentsPanelClass))
#define IS_DOCUMENTS_PANEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DOCUMENTS_PANEL))
#define IS_DOCUMENTS_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DOCUMENTS_PANEL))
#define DOCUMENTS_PANEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DOCUMENTS_PANEL, DocumentsPanelClass))

typedef struct _DocumentsPanel DocumentsPanel;
typedef struct _DocumentsPanelClass DocumentsPanelClass;

#define TYPE_CUSTOM_STATUSBAR (custom_statusbar_get_type ())
#define CUSTOM_STATUSBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CUSTOM_STATUSBAR, CustomStatusbar))
#define CUSTOM_STATUSBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CUSTOM_STATUSBAR, CustomStatusbarClass))
#define IS_CUSTOM_STATUSBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CUSTOM_STATUSBAR))
#define IS_CUSTOM_STATUSBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CUSTOM_STATUSBAR))
#define CUSTOM_STATUSBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CUSTOM_STATUSBAR, CustomStatusbarClass))

typedef struct _CustomStatusbar CustomStatusbar;
typedef struct _CustomStatusbarClass CustomStatusbarClass;

#define TYPE_GOTO_LINE (goto_line_get_type ())
#define GOTO_LINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GOTO_LINE, GotoLine))
#define GOTO_LINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GOTO_LINE, GotoLineClass))
#define IS_GOTO_LINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GOTO_LINE))
#define IS_GOTO_LINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GOTO_LINE))
#define GOTO_LINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GOTO_LINE, GotoLineClass))

typedef struct _GotoLine GotoLine;
typedef struct _GotoLineClass GotoLineClass;

#define TYPE_SEARCH_AND_REPLACE (search_and_replace_get_type ())
#define SEARCH_AND_REPLACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SEARCH_AND_REPLACE, SearchAndReplace))
#define SEARCH_AND_REPLACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SEARCH_AND_REPLACE, SearchAndReplaceClass))
#define IS_SEARCH_AND_REPLACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SEARCH_AND_REPLACE))
#define IS_SEARCH_AND_REPLACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SEARCH_AND_REPLACE))
#define SEARCH_AND_REPLACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SEARCH_AND_REPLACE, SearchAndReplaceClass))

typedef struct _SearchAndReplace SearchAndReplace;
typedef struct _SearchAndReplaceClass SearchAndReplaceClass;

#define TYPE_SIDE_PANEL (side_panel_get_type ())
#define SIDE_PANEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SIDE_PANEL, SidePanel))
#define SIDE_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SIDE_PANEL, SidePanelClass))
#define IS_SIDE_PANEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SIDE_PANEL))
#define IS_SIDE_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SIDE_PANEL))
#define SIDE_PANEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SIDE_PANEL, SidePanelClass))

typedef struct _SidePanel SidePanel;
typedef struct _SidePanelClass SidePanelClass;

#define TYPE_SYMBOLS_VIEW (symbols_view_get_type ())
#define SYMBOLS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SYMBOLS_VIEW, SymbolsView))
#define SYMBOLS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SYMBOLS_VIEW, SymbolsViewClass))
#define IS_SYMBOLS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SYMBOLS_VIEW))
#define IS_SYMBOLS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SYMBOLS_VIEW))
#define SYMBOLS_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SYMBOLS_VIEW, SymbolsViewClass))

typedef struct _SymbolsView SymbolsView;
typedef struct _SymbolsViewClass SymbolsViewClass;

#define TYPE_MAIN_WINDOW_BUILD_TOOLS (main_window_build_tools_get_type ())
#define MAIN_WINDOW_BUILD_TOOLS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MAIN_WINDOW_BUILD_TOOLS, MainWindowBuildTools))
#define MAIN_WINDOW_BUILD_TOOLS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MAIN_WINDOW_BUILD_TOOLS, MainWindowBuildToolsClass))
#define IS_MAIN_WINDOW_BUILD_TOOLS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MAIN_WINDOW_BUILD_TOOLS))
#define IS_MAIN_WINDOW_BUILD_TOOLS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MAIN_WINDOW_BUILD_TOOLS))
#define MAIN_WINDOW_BUILD_TOOLS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MAIN_WINDOW_BUILD_TOOLS, MainWindowBuildToolsClass))

typedef struct _MainWindowBuildTools MainWindowBuildTools;
typedef struct _MainWindowBuildToolsClass MainWindowBuildToolsClass;

#define TYPE_MAIN_WINDOW_STRUCTURE (main_window_structure_get_type ())
#define MAIN_WINDOW_STRUCTURE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MAIN_WINDOW_STRUCTURE, MainWindowStructure))
#define MAIN_WINDOW_STRUCTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MAIN_WINDOW_STRUCTURE, MainWindowStructureClass))
#define IS_MAIN_WINDOW_STRUCTURE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MAIN_WINDOW_STRUCTURE))
#define IS_MAIN_WINDOW_STRUCTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MAIN_WINDOW_STRUCTURE))
#define MAIN_WINDOW_STRUCTURE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MAIN_WINDOW_STRUCTURE, MainWindowStructureClass))

typedef struct _MainWindowStructure MainWindowStructure;
typedef struct _MainWindowStructureClass MainWindowStructureClass;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _main_window_build_tools_unref0(var) ((var == NULL) ? NULL : (var = (main_window_build_tools_unref (var), NULL)))
#define _main_window_structure_unref0(var) ((var == NULL) ? NULL : (var = (main_window_structure_unref (var), NULL)))

#define TYPE_FILE_BROWSER (file_browser_get_type ())
#define FILE_BROWSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FILE_BROWSER, FileBrowser))
#define FILE_BROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FILE_BROWSER, FileBrowserClass))
#define IS_FILE_BROWSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FILE_BROWSER))
#define IS_FILE_BROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FILE_BROWSER))
#define FILE_BROWSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FILE_BROWSER, FileBrowserClass))

typedef struct _FileBrowser FileBrowser;
typedef struct _FileBrowserClass FileBrowserClass;

#define TYPE_STRUCTURE (structure_get_type ())
#define STRUCTURE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_STRUCTURE, Structure))
#define STRUCTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_STRUCTURE, StructureClass))
#define IS_STRUCTURE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_STRUCTURE))
#define IS_STRUCTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_STRUCTURE))
#define STRUCTURE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_STRUCTURE, StructureClass))

typedef struct _Structure Structure;
typedef struct _StructureClass StructureClass;

#define TYPE_BUILD_VIEW (build_view_get_type ())
#define BUILD_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_BUILD_VIEW, BuildView))
#define BUILD_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_BUILD_VIEW, BuildViewClass))
#define IS_BUILD_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_BUILD_VIEW))
#define IS_BUILD_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_BUILD_VIEW))
#define BUILD_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_BUILD_VIEW, BuildViewClass))

typedef struct _BuildView BuildView;
typedef struct _BuildViewClass BuildViewClass;

#define TYPE_BOTTOM_PANEL (bottom_panel_get_type ())
#define BOTTOM_PANEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_BOTTOM_PANEL, BottomPanel))
#define BOTTOM_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_BOTTOM_PANEL, BottomPanelClass))
#define IS_BOTTOM_PANEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_BOTTOM_PANEL))
#define IS_BOTTOM_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_BOTTOM_PANEL))
#define BOTTOM_PANEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_BOTTOM_PANEL, BottomPanelClass))

typedef struct _BottomPanel BottomPanel;
typedef struct _BottomPanelClass BottomPanelClass;

#define TYPE_COMPLETION_PROVIDER (completion_provider_get_type ())
#define COMPLETION_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_COMPLETION_PROVIDER, CompletionProvider))
#define COMPLETION_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_COMPLETION_PROVIDER, CompletionProviderClass))
#define IS_COMPLETION_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_COMPLETION_PROVIDER))
#define IS_COMPLETION_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_COMPLETION_PROVIDER))
#define COMPLETION_PROVIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_COMPLETION_PROVIDER, CompletionProviderClass))

typedef struct _CompletionProvider CompletionProvider;
typedef struct _CompletionProviderClass CompletionProviderClass;

#define TYPE_LATEXILA (latexila_get_type ())
#define LATEXILA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_LATEXILA, Latexila))
#define LATEXILA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_LATEXILA, LatexilaClass))
#define IS_LATEXILA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_LATEXILA))
#define IS_LATEXILA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_LATEXILA))
#define LATEXILA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_LATEXILA, LatexilaClass))

typedef struct _Latexila Latexila;
typedef struct _LatexilaClass LatexilaClass;

#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;

#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 TYPE_DOCUMENT_VIEW (document_view_get_type ())
#define DOCUMENT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DOCUMENT_VIEW, DocumentView))
#define DOCUMENT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DOCUMENT_VIEW, DocumentViewClass))
#define IS_DOCUMENT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DOCUMENT_VIEW))
#define IS_DOCUMENT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DOCUMENT_VIEW))
#define DOCUMENT_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DOCUMENT_VIEW, DocumentViewClass))

typedef struct _DocumentView DocumentView;
typedef struct _DocumentViewClass DocumentViewClass;

#define TYPE_LATEX_MENU (latex_menu_get_type ())
#define LATEX_MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_LATEX_MENU, LatexMenu))
#define LATEX_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_LATEX_MENU, LatexMenuClass))
#define IS_LATEX_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_LATEX_MENU))
#define IS_LATEX_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_LATEX_MENU))
#define LATEX_MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_LATEX_MENU, LatexMenuClass))

typedef struct _LatexMenu LatexMenu;
typedef struct _LatexMenuClass LatexMenuClass;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _Block6Data Block6Data;
typedef struct _DocumentPrivate DocumentPrivate;

#define TYPE_TAB_INFO_BAR (tab_info_bar_get_type ())
#define TAB_INFO_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TAB_INFO_BAR, TabInfoBar))
#define TAB_INFO_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TAB_INFO_BAR, TabInfoBarClass))
#define IS_TAB_INFO_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TAB_INFO_BAR))
#define IS_TAB_INFO_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TAB_INFO_BAR))
#define TAB_INFO_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TAB_INFO_BAR, TabInfoBarClass))

typedef struct _TabInfoBar TabInfoBar;
typedef struct _TabInfoBarClass TabInfoBarClass;
typedef struct _Block7Data Block7Data;
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
#define _g_list_free0(var) ((var == NULL) ? NULL : (var = (g_list_free (var), NULL)))

#define TYPE_OPEN_TEMPLATE_DIALOG (open_template_dialog_get_type ())
#define OPEN_TEMPLATE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_OPEN_TEMPLATE_DIALOG, OpenTemplateDialog))
#define OPEN_TEMPLATE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_OPEN_TEMPLATE_DIALOG, OpenTemplateDialogClass))
#define IS_OPEN_TEMPLATE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_OPEN_TEMPLATE_DIALOG))
#define IS_OPEN_TEMPLATE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_OPEN_TEMPLATE_DIALOG))
#define OPEN_TEMPLATE_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_OPEN_TEMPLATE_DIALOG, OpenTemplateDialogClass))

typedef struct _OpenTemplateDialog OpenTemplateDialog;
typedef struct _OpenTemplateDialogClass OpenTemplateDialogClass;
#define _open_template_dialog_unref0(var) ((var == NULL) ? NULL : (var = (open_template_dialog_unref (var), NULL)))
#define __g_slist_free__g_object_unref0_0(var) ((var == NULL) ? NULL : (var = (_g_slist_free__g_object_unref0_ (var), NULL)))

#define TYPE_CREATE_TEMPLATE_DIALOG (create_template_dialog_get_type ())
#define CREATE_TEMPLATE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CREATE_TEMPLATE_DIALOG, CreateTemplateDialog))
#define CREATE_TEMPLATE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CREATE_TEMPLATE_DIALOG, CreateTemplateDialogClass))
#define IS_CREATE_TEMPLATE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CREATE_TEMPLATE_DIALOG))
#define IS_CREATE_TEMPLATE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CREATE_TEMPLATE_DIALOG))
#define CREATE_TEMPLATE_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CREATE_TEMPLATE_DIALOG, CreateTemplateDialogClass))

typedef struct _CreateTemplateDialog CreateTemplateDialog;
typedef struct _CreateTemplateDialogClass CreateTemplateDialogClass;

#define TYPE_DELETE_TEMPLATE_DIALOG (delete_template_dialog_get_type ())
#define DELETE_TEMPLATE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DELETE_TEMPLATE_DIALOG, DeleteTemplateDialog))
#define DELETE_TEMPLATE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DELETE_TEMPLATE_DIALOG, DeleteTemplateDialogClass))
#define IS_DELETE_TEMPLATE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DELETE_TEMPLATE_DIALOG))
#define IS_DELETE_TEMPLATE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DELETE_TEMPLATE_DIALOG))
#define DELETE_TEMPLATE_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DELETE_TEMPLATE_DIALOG, DeleteTemplateDialogClass))

typedef struct _DeleteTemplateDialog DeleteTemplateDialog;
typedef struct _DeleteTemplateDialogClass DeleteTemplateDialogClass;

struct _MainWindow {
	GtkWindow parent_instance;
	MainWindowPrivate * priv;
};

struct _MainWindowClass {
	GtkWindowClass parent_class;
};

struct _MainWindowPrivate {
	gchar* file_chooser_current_folder;
	DocumentsPanel* documents_panel;
	CustomStatusbar* statusbar;
	GotoLine* goto_line;
	SearchAndReplace* search_and_replace;
	GtkToolbar* _main_toolbar;
	GtkToolbar* _edit_toolbar;
	SidePanel* _side_panel;
	SymbolsView* _symbols;
	GtkPaned* main_hpaned;
	GtkPaned* vpaned;
	GtkUIManager* ui_manager;
	GtkActionGroup* action_group;
	GtkActionGroup* latex_action_group;
	GtkActionGroup* documents_list_action_group;
	guint documents_list_menu_ui_id;
	MainWindowBuildTools* _main_window_build_tools;
	MainWindowStructure* _main_window_structure;
	guint tip_message_cid;
};

struct _Block6Data {
	int _ref_count_;
	MainWindow * self;
	DocumentTab* tab;
	GtkInfoBar* infobar;
};

struct _Document {
	GtkSourceBuffer parent_instance;
	DocumentPrivate * priv;
	DocumentTab* tab;
	guint _unsaved_doc_num;
};

struct _DocumentClass {
	GtkSourceBufferClass parent_class;
};

struct _Block7Data {
	int _ref_count_;
	MainWindow * self;
	DocumentTab* tab;
};


static gpointer main_window_parent_class = NULL;

GType main_window_get_type (void) G_GNUC_CONST;
GType documents_panel_get_type (void) G_GNUC_CONST;
GType custom_statusbar_get_type (void) G_GNUC_CONST;
GType goto_line_get_type (void) G_GNUC_CONST;
GType search_and_replace_get_type (void) G_GNUC_CONST;
GType side_panel_get_type (void) G_GNUC_CONST;
GType symbols_view_get_type (void) G_GNUC_CONST;
gpointer main_window_build_tools_ref (gpointer instance);
void main_window_build_tools_unref (gpointer instance);
GParamSpec* param_spec_main_window_build_tools (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void value_set_main_window_build_tools (GValue* value, gpointer v_object);
void value_take_main_window_build_tools (GValue* value, gpointer v_object);
gpointer value_get_main_window_build_tools (const GValue* value);
GType main_window_build_tools_get_type (void) G_GNUC_CONST;
gpointer main_window_structure_ref (gpointer instance);
void main_window_structure_unref (gpointer instance);
GParamSpec* param_spec_main_window_structure (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void value_set_main_window_structure (GValue* value, gpointer v_object);
void value_take_main_window_structure (GValue* value, gpointer v_object);
gpointer value_get_main_window_structure (const GValue* value);
GType main_window_structure_get_type (void) G_GNUC_CONST;
#define MAIN_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_MAIN_WINDOW, MainWindowPrivate))
enum  {
	MAIN_WINDOW_DUMMY_PROPERTY,
	MAIN_WINDOW_ACTIVE_TAB,
	MAIN_WINDOW_ACTIVE_VIEW,
	MAIN_WINDOW_ACTIVE_DOCUMENT
};
void main_window_on_file_new (MainWindow* self);
static void _main_window_on_file_new_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_new_window (MainWindow* self);
static void _main_window_on_new_window_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_file_open (MainWindow* self);
static void _main_window_on_file_open_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_file_save (MainWindow* self);
static void _main_window_on_file_save_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_file_save_as (MainWindow* self);
static void _main_window_on_file_save_as_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_create_template (MainWindow* self);
static void _main_window_on_create_template_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_delete_template (MainWindow* self);
static void _main_window_on_delete_template_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_file_close (MainWindow* self);
static void _main_window_on_file_close_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_quit (MainWindow* self);
static void _main_window_on_quit_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_edit_undo (MainWindow* self);
static void _main_window_on_edit_undo_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_edit_redo (MainWindow* self);
static void _main_window_on_edit_redo_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_edit_cut (MainWindow* self);
static void _main_window_on_edit_cut_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_edit_copy (MainWindow* self);
static void _main_window_on_edit_copy_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_edit_paste (MainWindow* self);
static void _main_window_on_edit_paste_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_edit_delete (MainWindow* self);
static void _main_window_on_edit_delete_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_edit_select_all (MainWindow* self);
static void _main_window_on_edit_select_all_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_edit_comment (MainWindow* self);
static void _main_window_on_edit_comment_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_edit_uncomment (MainWindow* self);
static void _main_window_on_edit_uncomment_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_open_preferences (MainWindow* self);
static void _main_window_on_open_preferences_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_view_zoom_in (MainWindow* self);
static void _main_window_on_view_zoom_in_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_view_zoom_out (MainWindow* self);
static void _main_window_on_view_zoom_out_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_view_zoom_reset (MainWindow* self);
static void _main_window_on_view_zoom_reset_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_search_find (MainWindow* self);
static void _main_window_on_search_find_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_search_replace (MainWindow* self);
static void _main_window_on_search_replace_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_search_goto_line (MainWindow* self);
static void _main_window_on_search_goto_line_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_documents_save_all (MainWindow* self);
static void _main_window_on_documents_save_all_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_documents_close_all (MainWindow* self);
static void _main_window_on_documents_close_all_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_documents_previous (MainWindow* self);
static void _main_window_on_documents_previous_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_documents_next (MainWindow* self);
static void _main_window_on_documents_next_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_documents_move_to_new_window (MainWindow* self);
static void _main_window_on_documents_move_to_new_window_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_projects_new (MainWindow* self);
static void _main_window_on_projects_new_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_projects_config_current (MainWindow* self);
static void _main_window_on_projects_config_current_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_projects_manage (MainWindow* self);
static void _main_window_on_projects_manage_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_help_contents (MainWindow* self);
static void _main_window_on_help_contents_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_help_latex_reference (MainWindow* self);
static void _main_window_on_help_latex_reference_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_about_dialog (MainWindow* self);
static void _main_window_on_about_dialog_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_on_spell_checking (MainWindow* self, GtkAction* action);
static void _main_window_on_spell_checking_gtk_action_callback (GtkAction* action, gpointer self);
MainWindow* main_window_new (void);
MainWindow* main_window_construct (GType object_type);
static void main_window_initialize_menubar_and_toolbar (MainWindow* self);
DocumentsPanel* documents_panel_new (MainWindow* main_window);
DocumentsPanel* documents_panel_construct (GType object_type, MainWindow* main_window);
static void __lambda124_ (MainWindow* self, GdkEventButton* event);
static void ___lambda124__documents_panel_right_click (DocumentsPanel* _sender, GdkEventButton* event, gpointer self);
CustomStatusbar* custom_statusbar_new (void);
CustomStatusbar* custom_statusbar_construct (GType object_type);
GotoLine* goto_line_new (MainWindow* main_window);
GotoLine* goto_line_construct (GType object_type, MainWindow* main_window);
SearchAndReplace* search_and_replace_new (MainWindow* main_window);
SearchAndReplace* search_and_replace_construct (GType object_type, MainWindow* main_window);
FileBrowser* file_browser_new (MainWindow* main_window);
FileBrowser* file_browser_construct (GType object_type, MainWindow* main_window);
GType file_browser_get_type (void) G_GNUC_CONST;
SymbolsView* symbols_view_new (MainWindow* main_window);
SymbolsView* symbols_view_construct (GType object_type, MainWindow* main_window);
Structure* structure_new (MainWindow* main_window);
Structure* structure_construct (GType object_type, MainWindow* main_window);
GType structure_get_type (void) G_GNUC_CONST;
MainWindowStructure* main_window_structure_new (GtkUIManager* ui_manager, Structure* structure);
MainWindowStructure* main_window_structure_construct (GType object_type, GtkUIManager* ui_manager, Structure* structure);
BuildView* build_view_new (MainWindow* main_window);
BuildView* build_view_construct (GType object_type, MainWindow* main_window);
GType build_view_get_type (void) G_GNUC_CONST;
MainWindowBuildTools* main_window_build_tools_new (MainWindow* main_window, GtkUIManager* ui_manager, BuildView* build_view, FileBrowser* file_browser);
MainWindowBuildTools* main_window_build_tools_construct (GType object_type, MainWindow* main_window, GtkUIManager* ui_manager, BuildView* build_view, FileBrowser* file_browser);
BottomPanel* bottom_panel_new (BuildView* build_view, GtkToolbar* toolbar);
BottomPanel* bottom_panel_construct (GType object_type, BuildView* build_view, GtkToolbar* toolbar);
GType bottom_panel_get_type (void) G_GNUC_CONST;
SidePanel* side_panel_new (void);
SidePanel* side_panel_construct (GType object_type);
void side_panel_add_component (SidePanel* self, const gchar* name, const gchar* stock_id, GtkGrid* component);
void side_panel_restore_state (SidePanel* self);
static void main_window_setup_toolbar_open_button (MainWindow* self, GtkToolbar* toolbar);
static gboolean __lambda126_ (MainWindow* self);
static gboolean ___lambda126__gtk_widget_delete_event (GtkWidget* _sender, GdkEventAny* event, gpointer self);
static void __lambda127_ (MainWindow* self);
static void main_window_set_file_actions_sensitivity (MainWindow* self, gboolean sensitive);
static void main_window_set_documents_move_to_new_window_sensitivity (MainWindow* self, gboolean sensitive);
static void main_window_update_documents_list_menu (MainWindow* self);
static void ___lambda127__gtk_notebook_page_added (GtkNotebook* _sender, GtkWidget* child, guint page_num, gpointer self);
static void __lambda128_ (MainWindow* self);
void custom_statusbar_set_cursor_position (CustomStatusbar* self, gint line, gint col);
void search_and_replace_hide (SearchAndReplace* self);
static void main_window_my_set_title (MainWindow* self);
static void ___lambda128__gtk_notebook_page_removed (GtkNotebook* _sender, GtkWidget* child, guint page_num, gpointer self);
static void __lambda129_ (MainWindow* self, GtkWidget* pg, guint page_num);
static void main_window_set_undo_sensitivity (MainWindow* self);
static void main_window_set_redo_sensitivity (MainWindow* self);
static void main_window_update_next_prev_doc_sensitivity (MainWindow* self);
void main_window_build_tools_update_sensitivity (MainWindowBuildTools* self);
void main_window_update_config_project_sensitivity (MainWindow* self);
static void main_window_update_cursor_position_statusbar (MainWindow* self);
static void main_window_documents_list_menu_activate (MainWindow* self, GtkAction* action);
static void _main_window_documents_list_menu_activate_gtk_action_activate (GtkAction* _sender, gpointer self);
static void ___lambda129__gtk_notebook_switch_page (GtkNotebook* _sender, GtkWidget* page, guint page_num, gpointer self);
static void __lambda130_ (MainWindow* self);
static void ___lambda130__gtk_notebook_page_reordered (GtkNotebook* _sender, GtkWidget* child, guint page_num, gpointer self);
static void __lambda131_ (MainWindow* self);
GType completion_provider_get_type (void) G_GNUC_CONST;
CompletionProvider* completion_provider_get_default (void);
void completion_provider_hide_calltip_window (CompletionProvider* self);
static void ___lambda131__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self);
static gboolean __lambda132_ (MainWindow* self);
static gboolean ___lambda132__gtk_widget_focus_out_event (GtkWidget* _sender, GdkEventFocus* event, gpointer self);
static void __lambda133_ (MainWindow* self, GdkDragContext* dc, gint x, gint y, GtkSelectionData* selection_data, guint info, guint time);
GType latexila_get_type (void) G_GNUC_CONST;
Latexila* latexila_get_instance (void);
static void _vala_array_add6 (GFile*** array, int* length, int* size, GFile* value);
void latexila_open_documents (Latexila* self, GFile** files, int files_length1);
static void ___lambda133__gtk_widget_drag_data_received (GtkWidget* _sender, GdkDragContext* context, gint x, gint y, GtkSelectionData* selection_data, guint info, guint time_, gpointer self);
GtkWidget* search_and_replace_get_widget (SearchAndReplace* self);
static void main_window_show_or_hide_widgets (MainWindow* self);
GType document_get_type (void) G_GNUC_CONST;
GeeList* main_window_get_documents (MainWindow* self);
GType document_tab_get_type (void) G_GNUC_CONST;
Document* document_tab_get_document (DocumentTab* self);
GeeList* main_window_get_unsaved_documents (MainWindow* self);
gboolean document_get_modified (Document* self);
GType document_view_get_type (void) G_GNUC_CONST;
GeeList* main_window_get_views (MainWindow* self);
DocumentView* document_tab_get_view (DocumentTab* self);
static void main_window_configure_recent_chooser (MainWindow* self, GtkRecentChooser* recent_chooser);
LatexMenu* latex_menu_new (MainWindow* main_window);
LatexMenu* latex_menu_construct (GType object_type, MainWindow* main_window);
GType latex_menu_get_type (void) G_GNUC_CONST;
static void __lambda122_ (MainWindow* self, GtkAction* action, GtkWidget* p);
static void main_window_on_menu_item_select (MainWindow* self, GtkMenuItem* proxy);
static void _main_window_on_menu_item_select_gtk_menu_item_select (GtkMenuItem* _sender, gpointer self);
static void main_window_on_menu_item_deselect (MainWindow* self, GtkMenuItem* proxy);
static void _main_window_on_menu_item_deselect_gtk_menu_item_deselect (GtkMenuItem* _sender, gpointer self);
static void ___lambda122__gtk_ui_manager_connect_proxy (GtkUIManager* _sender, GtkAction* action, GtkWidget* proxy, gpointer self);
static void __lambda123_ (MainWindow* self, GtkAction* action, GtkWidget* p);
static void ___lambda123__gtk_ui_manager_disconnect_proxy (GtkUIManager* _sender, GtkAction* action, GtkWidget* proxy, gpointer self);
DocumentTab* main_window_open_document (MainWindow* self, GFile* location, gboolean jump_to);
static Block6Data* block6_data_ref (Block6Data* _data6_);
static void block6_data_unref (void * _userdata_);
GFile* document_get_location (Document* self);
void main_window_set_active_tab (MainWindow* self, DocumentTab* value);
DocumentTab* main_window_create_tab_from_location (MainWindow* self, GFile* location, gboolean jump_to);
void document_set_readonly (Document* self, gboolean value);
GType tab_info_bar_get_type (void) G_GNUC_CONST;
TabInfoBar* document_tab_add_message (DocumentTab* self, const gchar* primary_msg, const gchar* secondary_msg, GtkMessageType msg_type);
static void ______lambda68_ (Block6Data* _data6_, gint response_id);
static void _______lambda68__gtk_info_bar_response (GtkInfoBar* _sender, gint response_id, gpointer self);
DocumentTab* main_window_create_tab (MainWindow* self, gboolean jump_to);
DocumentTab* document_tab_new (void);
DocumentTab* document_tab_construct (GType object_type);
static DocumentTab* main_window_process_create_tab (MainWindow* self, DocumentTab* tab, gboolean jump_to);
DocumentTab* document_tab_new_from_location (GFile* location);
DocumentTab* document_tab_construct_from_location (GType object_type, GFile* location);
void main_window_create_tab_with_view (MainWindow* self, DocumentView* view);
DocumentTab* document_tab_new_with_view (DocumentView* view);
DocumentTab* document_tab_construct_with_view (GType object_type, DocumentView* view);
static Block7Data* block7_data_ref (Block7Data* _data7_);
static void block7_data_unref (void * _userdata_);
static void __lambda17_ (Block7Data* _data7_);
gboolean main_window_close_tab (MainWindow* self, DocumentTab* tab, gboolean force_close);
static void ___lambda17__document_tab_close_document (DocumentTab* _sender, gpointer self);
static void __lambda18_ (Block7Data* _data7_);
DocumentTab* main_window_get_active_tab (MainWindow* self);
static void ___lambda18__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self);
static void __lambda19_ (Block7Data* _data7_);
static void ___lambda19__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self);
static void __lambda20_ (Block7Data* _data7_);
static void main_window_selection_changed (MainWindow* self);
static void ___lambda20__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self);
static void __lambda21_ (Block7Data* _data7_);
static void main_window_sync_name (MainWindow* self, DocumentTab* tab);
static void ___lambda21__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self);
static void __lambda65_ (MainWindow* self);
static void ___lambda65__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self);
static void __lambda66_ (Block7Data* _data7_);
static void ___lambda66__gtk_text_buffer_modified_changed (GtkTextBuffer* _sender, gpointer self);
static void __lambda67_ (Block7Data* _data7_);
static void ___lambda67__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self);
static void _main_window_update_cursor_position_statusbar_document_cursor_moved (Document* _sender, gpointer self);
void documents_panel_add_tab (DocumentsPanel* self, DocumentTab* tab, gint position, gboolean jump_to);
const gchar* document_tab_get_label_text (DocumentTab* self);
gboolean main_window_save_document (MainWindow* self, Document* doc, gboolean force_save_as);
void documents_panel_remove_tab (DocumentsPanel* self, DocumentTab* tab);
DocumentTab* main_window_get_tab_from_location (MainWindow* self, GFile* location);
gchar* document_tab_get_name (DocumentTab* self);
gchar* document_tab_get_menu_tip (DocumentTab* self);
Document* main_window_get_active_document (MainWindow* self);
gchar* document_get_short_name_for_display (Document* self);
gchar* utils_str_middle_truncate (const gchar* str, guint max_length);
gchar* utils_get_dirname_for_display (GFile* location);
gboolean document_get_readonly (Document* self);
void document_save (Document* self, gboolean check_file_changed_on_disk, gboolean force);
void document_set_location (Document* self, GFile* value);
static gboolean main_window_close_all_documents (MainWindow* self);
void documents_panel_remove_all_tabs (DocumentsPanel* self);
void dialogs_close_several_unsaved_documents (MainWindow* window, GeeList* unsaved_docs);
void main_window_remove_all_tabs (MainWindow* self);
DocumentView* main_window_get_active_view (MainWindow* self);
static void __lambda121_ (MainWindow* self, GtkRecentChooser* chooser);
static void ___lambda121__gtk_recent_chooser_item_activated (GtkRecentChooser* _sender, gpointer self);
void main_window_save_state (MainWindow* self);
void main_window_structure_save_state (MainWindowStructure* self);
void main_window_build_tools_save_state (MainWindowBuildTools* self);
static void main_window_move_tab_to_new_window (MainWindow* self, DocumentTab* tab);
MainWindow* latexila_create_window (Latexila* self);
gint document_get_project_id (Document* self);
OpenTemplateDialog* open_template_dialog_new (MainWindow* main_window);
OpenTemplateDialog* open_template_dialog_construct (GType object_type, MainWindow* main_window);
gpointer open_template_dialog_ref (gpointer instance);
void open_template_dialog_unref (gpointer instance);
GParamSpec* param_spec_open_template_dialog (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void value_set_open_template_dialog (GValue* value, gpointer v_object);
void value_take_open_template_dialog (GValue* value, gpointer v_object);
gpointer value_get_open_template_dialog (const GValue* value);
GType open_template_dialog_get_type (void) G_GNUC_CONST;
static void _g_object_unref0_ (gpointer var);
static void _g_slist_free__g_object_unref0_ (GSList* self);
CreateTemplateDialog* create_template_dialog_new (MainWindow* parent);
CreateTemplateDialog* create_template_dialog_construct (GType object_type, MainWindow* parent);
GType create_template_dialog_get_type (void) G_GNUC_CONST;
DeleteTemplateDialog* delete_template_dialog_new (MainWindow* parent);
DeleteTemplateDialog* delete_template_dialog_construct (GType object_type, MainWindow* parent);
GType delete_template_dialog_get_type (void) G_GNUC_CONST;
static void _vala_array_add7 (gchar*** array, int* length, int* size, gchar* value);
void document_view_scroll_to_cursor (DocumentView* self, gdouble margin);
void document_view_cut_selection (DocumentView* self);
void document_view_copy_selection (DocumentView* self);
void document_view_my_paste_clipboard (DocumentView* self);
void document_view_delete_selection (DocumentView* self);
void document_view_my_select_all (DocumentView* self);
void document_comment_selected_lines (Document* self);
void document_uncomment_selected_lines (Document* self);
void document_view_activate_spell_checking (DocumentView* self);
void document_view_disable_spell_checking (DocumentView* self);
void preferences_dialog_show_me (MainWindow* parent);
void document_view_enlarge_font (DocumentView* self);
void document_view_shrink_font (DocumentView* self);
void document_view_set_font_from_settings (DocumentView* self);
void search_and_replace_show_search (SearchAndReplace* self);
void search_and_replace_show_search_and_replace (SearchAndReplace* self);
void goto_line_show (GotoLine* self);
void project_dialogs_new_project (MainWindow* main_window);
gboolean project_dialogs_configure_project (GtkWindow* main_window, gint project_id);
void project_dialogs_manage_projects (MainWindow* main_window);
DocumentTab* documents_panel_get_active_tab (DocumentsPanel* self);
static void main_window_finalize (GObject* obj);
static void _vala_main_window_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_main_window_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
static gint _vala_array_length (gpointer array);

static const GtkActionEntry MAIN_WINDOW_action_entries[43] = {{"File", NULL, "_File"}, {"FileNew", GTK_STOCK_NEW, NULL, NULL, "New file", (GCallback) _main_window_on_file_new_gtk_action_callback}, {"FileNewWindow", NULL, "New _Window", NULL, "Create a new window", (GCallback) _main_window_on_new_window_gtk_action_callback}, {"FileOpen", GTK_STOCK_OPEN, NULL, NULL, "Open a file", (GCallback) _main_window_on_file_open_gtk_action_callback}, {"FileSave", GTK_STOCK_SAVE, NULL, NULL, "Save the current file", (GCallback) _main_window_on_file_save_gtk_action_callback}, {"FileSaveAs", GTK_STOCK_SAVE_AS, NULL, NULL, "Save the current file with a different name", (GCallback) _main_window_on_file_save_as_gtk_action_callback}, {"FileCreateTemplate", NULL, "Create _Template From Document...", NULL, "Create a new template from the current document", (GCallback) _main_window_on_create_template_gtk_action_callback}, {"FileDeleteTemplate", NULL, "_Delete Template...", NULL, "Delete personal template(s)", (GCallback) _main_window_on_delete_template_gtk_action_callback}, {"FileClose", GTK_STOCK_CLOSE, NULL, NULL, "Close the current file", (GCallback) _main_window_on_file_close_gtk_action_callback}, {"FileQuit", GTK_STOCK_QUIT, NULL, NULL, "Quit the program", (GCallback) _main_window_on_quit_gtk_action_callback}, {"Edit", NULL, "_Edit"}, {"EditUndo", GTK_STOCK_UNDO, NULL, "<Control>Z", "Undo the last action", (GCallback) _main_window_on_edit_undo_gtk_action_callback}, {"EditRedo", GTK_STOCK_REDO, NULL, "<Shift><Control>Z", "Redo the last undone action", (GCallback) _main_window_on_edit_redo_gtk_action_callback}, {"EditCut", GTK_STOCK_CUT, NULL, NULL, "Cut the selection", (GCallback) _main_window_on_edit_cut_gtk_action_callback}, {"EditCopy", GTK_STOCK_COPY, NULL, NULL, "Copy the selection", (GCallback) _main_window_on_edit_copy_gtk_action_callback}, {"EditPaste", GTK_STOCK_PASTE, NULL, "", "Paste the clipboard", (GCallback) _main_window_on_edit_paste_gtk_action_callback}, {"EditDelete", GTK_STOCK_DELETE, NULL, NULL, "Delete the selected text", (GCallback) _main_window_on_edit_delete_gtk_action_callback}, {"EditSelectAll", GTK_STOCK_SELECT_ALL, NULL, "<Control>A", "Select the entire document", (GCallback) _main_window_on_edit_select_all_gtk_action_callback}, {"EditComment", NULL, "_Comment", "<Control>M", "Comment the selected lines (add the character \"%\")", (GCallback) _main_window_on_edit_comment_gtk_action_callback}, {"EditUncomment", NULL, "_Uncomment", "<Shift><Control>M", "Uncomment the selected lines (remove the character \"%\")", (GCallback) _main_window_on_edit_uncomment_gtk_action_callback}, {"EditPreferences", GTK_STOCK_PREFERENCES, NULL, NULL, "Configure the application", (GCallback) _main_window_on_open_preferences_gtk_action_callback}, {"View", NULL, "_View"}, {"ViewZoomIn", GTK_STOCK_ZOOM_IN, "Zoom _In", "<Control>plus", "Enlarge the font", (GCallback) _main_window_on_view_zoom_in_gtk_action_callback}, {"ViewZoomOut", GTK_STOCK_ZOOM_OUT, "Zoom _Out", "<Control>minus", "Shrink the font", (GCallback) _main_window_on_view_zoom_out_gtk_action_callback}, {"ViewZoomReset", GTK_STOCK_ZOOM_100, "_Reset Zoom", "<Control>0", "Reset the size of the font", (GCallback) _main_window_on_view_zoom_reset_gtk_action_callback}, {"Search", NULL, "_Search"}, {"SearchFind", GTK_STOCK_FIND, NULL, NULL, "Search for text", (GCallback) _main_window_on_search_find_gtk_action_callback}, {"SearchReplace", GTK_STOCK_FIND_AND_REPLACE, NULL, NULL, "Search for and replace text", (GCallback) _main_window_on_search_replace_gtk_action_callback}, {"SearchGoToLine", GTK_STOCK_JUMP_TO, "_Go to Line...", "<Control>G", "Go to a specific line", (GCallback) _main_window_on_search_goto_line_gtk_action_callback}, {"Documents", NULL, "_Documents"}, {"DocumentsSaveAll", GTK_STOCK_SAVE, "_Save All", "<Shift><Control>L", "Save all open files", (GCallback) _main_window_on_documents_save_all_gtk_action_callback}, {"DocumentsCloseAll", GTK_STOCK_CLOSE, "_Close All", "<Shift><Control>W", "Close all open files", (GCallback) _main_window_on_documents_close_all_gtk_action_callback}, {"DocumentsPrevious", GTK_STOCK_GO_BACK, "_Previous Document", "<Control><Alt>Page_Up", "Activate previous document", (GCallback) _main_window_on_documents_previous_gtk_action_callback}, {"DocumentsNext", GTK_STOCK_GO_FORWARD, "_Next Document", "<Control><Alt>Page_Down", "Activate next document", (GCallback) _main_window_on_documents_next_gtk_action_callback}, {"DocumentsMoveToNewWindow", NULL, "_Move to New Window", NULL, "Move the current document to a new window", (GCallback) _main_window_on_documents_move_to_new_window_gtk_action_callback}, {"Projects", NULL, "_Projects"}, {"ProjectsNew", GTK_STOCK_NEW, "_New Project", NULL, "Create a new project", (GCallback) _main_window_on_projects_new_gtk_action_callback}, {"ProjectsConfigCurrent", GTK_STOCK_PROPERTIES, "_Configure Current Project", NULL, "Change the main file of the current project", (GCallback) _main_window_on_projects_config_current_gtk_action_callback}, {"ProjectsManage", GTK_STOCK_PREFERENCES, "_Manage Projects", NULL, "Manage Projects", (GCallback) _main_window_on_projects_manage_gtk_action_callback}, {"Help", NULL, "_Help"}, {"HelpContents", GTK_STOCK_HELP, "_Contents", "<Release>F1", "Open the LaTeXila documentation", (GCallback) _main_window_on_help_contents_gtk_action_callback}, {"HelpLatexReference", NULL, "_LaTeX Reference", NULL, "The Kile LaTeX Reference", (GCallback) _main_window_on_help_latex_reference_gtk_action_callback}, {"HelpAbout", GTK_STOCK_ABOUT, NULL, NULL, "About LaTeXila", (GCallback) _main_window_on_about_dialog_gtk_action_callback}};
static const GtkToggleActionEntry MAIN_WINDOW_toggle_action_entries[5] = {{"EditSpellChecking", GTK_STOCK_SPELL_CHECK, NULL, "", "Activate or disable the spell checking", (GCallback) _main_window_on_spell_checking_gtk_action_callback}, {"ViewMainToolbar", NULL, "_Main Toolbar", NULL, "Show or hide the main toolbar", (GCallback) NULL}, {"ViewEditToolbar", NULL, "_Edit Toolbar", NULL, "Show or hide the edit toolbar", (GCallback) NULL}, {"ViewSidePanel", NULL, "_Side panel", "<Release>F12", "Show or hide the side panel", (GCallback) NULL}, {"ViewBottomPanel", NULL, "_Bottom panel", NULL, "Show or hide the bottom panel", (GCallback) NULL}};

static void _main_window_on_file_new_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_file_new (self);
}


static void _main_window_on_new_window_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_new_window (self);
}


static void _main_window_on_file_open_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_file_open (self);
}


static void _main_window_on_file_save_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_file_save (self);
}


static void _main_window_on_file_save_as_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_file_save_as (self);
}


static void _main_window_on_create_template_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_create_template (self);
}


static void _main_window_on_delete_template_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_delete_template (self);
}


static void _main_window_on_file_close_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_file_close (self);
}


static void _main_window_on_quit_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_quit (self);
}


static void _main_window_on_edit_undo_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_edit_undo (self);
}


static void _main_window_on_edit_redo_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_edit_redo (self);
}


static void _main_window_on_edit_cut_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_edit_cut (self);
}


static void _main_window_on_edit_copy_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_edit_copy (self);
}


static void _main_window_on_edit_paste_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_edit_paste (self);
}


static void _main_window_on_edit_delete_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_edit_delete (self);
}


static void _main_window_on_edit_select_all_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_edit_select_all (self);
}


static void _main_window_on_edit_comment_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_edit_comment (self);
}


static void _main_window_on_edit_uncomment_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_edit_uncomment (self);
}


static void _main_window_on_open_preferences_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_open_preferences (self);
}


static void _main_window_on_view_zoom_in_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_view_zoom_in (self);
}


static void _main_window_on_view_zoom_out_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_view_zoom_out (self);
}


static void _main_window_on_view_zoom_reset_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_view_zoom_reset (self);
}


static void _main_window_on_search_find_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_search_find (self);
}


static void _main_window_on_search_replace_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_search_replace (self);
}


static void _main_window_on_search_goto_line_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_search_goto_line (self);
}


static void _main_window_on_documents_save_all_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_documents_save_all (self);
}


static void _main_window_on_documents_close_all_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_documents_close_all (self);
}


static void _main_window_on_documents_previous_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_documents_previous (self);
}


static void _main_window_on_documents_next_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_documents_next (self);
}


static void _main_window_on_documents_move_to_new_window_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_documents_move_to_new_window (self);
}


static void _main_window_on_projects_new_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_projects_new (self);
}


static void _main_window_on_projects_config_current_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_projects_config_current (self);
}


static void _main_window_on_projects_manage_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_projects_manage (self);
}


static void _main_window_on_help_contents_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_help_contents (self);
}


static void _main_window_on_help_latex_reference_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_help_latex_reference (self);
}


static void _main_window_on_about_dialog_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_about_dialog (self);
}


static void _main_window_on_spell_checking_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_on_spell_checking (self, action);
}


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


static void __lambda124_ (MainWindow* self, GdkEventButton* event) {
	GtkUIManager* _tmp0_;
	GtkWidget* _tmp1_ = NULL;
	GtkMenu* _tmp2_;
	GtkMenu* popup_menu;
	GdkEventButton _tmp3_;
	guint _tmp4_;
	GdkEventButton _tmp5_;
	guint32 _tmp6_;
	g_return_if_fail (event != NULL);
	_tmp0_ = self->priv->ui_manager;
	_tmp1_ = gtk_ui_manager_get_widget (_tmp0_, "/NotebookPopup");
	_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp1_, GTK_TYPE_MENU) ? ((GtkMenu*) _tmp1_) : NULL);
	popup_menu = _tmp2_;
	_tmp3_ = *event;
	_tmp4_ = _tmp3_.button;
	_tmp5_ = *event;
	_tmp6_ = _tmp5_.time;
	gtk_menu_popup (popup_menu, NULL, NULL, NULL, NULL, _tmp4_, _tmp6_);
	_g_object_unref0 (popup_menu);
}


static void ___lambda124__documents_panel_right_click (DocumentsPanel* _sender, GdkEventButton* event, gpointer self) {
	__lambda124_ (self, event);
}


static gboolean __lambda126_ (MainWindow* self) {
	gboolean result = FALSE;
	main_window_on_quit (self);
	result = TRUE;
	return result;
}


static gboolean ___lambda126__gtk_widget_delete_event (GtkWidget* _sender, GdkEventAny* event, gpointer self) {
	gboolean result;
	result = __lambda126_ (self);
	return result;
}


static void __lambda127_ (MainWindow* self) {
	DocumentsPanel* _tmp0_;
	gint _tmp1_ = 0;
	gint nb_pages;
	gint _tmp2_;
	_tmp0_ = self->priv->documents_panel;
	_tmp1_ = gtk_notebook_get_n_pages ((GtkNotebook*) _tmp0_);
	nb_pages = _tmp1_;
	_tmp2_ = nb_pages;
	if (_tmp2_ == 1) {
		main_window_set_file_actions_sensitivity (self, TRUE);
	} else {
		gint _tmp3_;
		_tmp3_ = nb_pages;
		if (_tmp3_ == 2) {
			main_window_set_documents_move_to_new_window_sensitivity (self, TRUE);
		}
	}
	main_window_update_documents_list_menu (self);
}


static void ___lambda127__gtk_notebook_page_added (GtkNotebook* _sender, GtkWidget* child, guint page_num, gpointer self) {
	__lambda127_ (self);
}


static void __lambda128_ (MainWindow* self) {
	DocumentsPanel* _tmp0_;
	gint _tmp1_ = 0;
	gint nb_pages;
	gint _tmp2_;
	_tmp0_ = self->priv->documents_panel;
	_tmp1_ = gtk_notebook_get_n_pages ((GtkNotebook*) _tmp0_);
	nb_pages = _tmp1_;
	_tmp2_ = nb_pages;
	if (_tmp2_ == 0) {
		CustomStatusbar* _tmp3_;
		GotoLine* _tmp4_;
		SearchAndReplace* _tmp5_;
		_tmp3_ = self->priv->statusbar;
		custom_statusbar_set_cursor_position (_tmp3_, -1, -1);
		main_window_set_file_actions_sensitivity (self, FALSE);
		_tmp4_ = self->priv->goto_line;
		gtk_widget_hide ((GtkWidget*) _tmp4_);
		_tmp5_ = self->priv->search_and_replace;
		search_and_replace_hide (_tmp5_);
		g_object_notify ((GObject*) self, "active-tab");
		g_object_notify ((GObject*) self, "active-document");
		g_object_notify ((GObject*) self, "active-view");
	} else {
		gint _tmp6_;
		_tmp6_ = nb_pages;
		if (_tmp6_ == 1) {
			main_window_set_documents_move_to_new_window_sensitivity (self, FALSE);
		}
	}
	main_window_my_set_title (self);
	main_window_update_documents_list_menu (self);
}


static void ___lambda128__gtk_notebook_page_removed (GtkNotebook* _sender, GtkWidget* child, guint page_num, gpointer self) {
	__lambda128_ (self);
}


static void _main_window_documents_list_menu_activate_gtk_action_activate (GtkAction* _sender, gpointer self) {
	main_window_documents_list_menu_activate (self, _sender);
}


static void __lambda129_ (MainWindow* self, GtkWidget* pg, guint page_num) {
	MainWindowBuildTools* _tmp0_;
	guint _tmp1_;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_;
	gchar* _tmp4_ = NULL;
	gchar* _tmp5_;
	gchar* action_name;
	GtkActionGroup* _tmp6_;
	const gchar* _tmp7_;
	GtkAction* _tmp8_ = NULL;
	GtkRadioAction* _tmp9_;
	GtkRadioAction* action;
	GtkRadioAction* _tmp10_;
	g_return_if_fail (pg != NULL);
	main_window_set_undo_sensitivity (self);
	main_window_set_redo_sensitivity (self);
	main_window_update_next_prev_doc_sensitivity (self);
	_tmp0_ = self->priv->_main_window_build_tools;
	main_window_build_tools_update_sensitivity (_tmp0_);
	main_window_update_config_project_sensitivity (self);
	main_window_my_set_title (self);
	main_window_update_cursor_position_statusbar (self);
	_tmp1_ = page_num;
	_tmp2_ = g_strdup_printf ("%u", _tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = g_strconcat ("Tab_", _tmp3_, NULL);
	_tmp5_ = _tmp4_;
	_g_free0 (_tmp3_);
	action_name = _tmp5_;
	_tmp6_ = self->priv->documents_list_action_group;
	_tmp7_ = action_name;
	_tmp8_ = gtk_action_group_get_action (_tmp6_, _tmp7_);
	_tmp9_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, GTK_TYPE_RADIO_ACTION, GtkRadioAction));
	action = _tmp9_;
	_tmp10_ = action;
	if (_tmp10_ != NULL) {
		GtkRadioAction* _tmp11_;
		guint _tmp12_ = 0U;
		GtkRadioAction* _tmp13_;
		GtkRadioAction* _tmp14_;
		_tmp11_ = action;
		g_signal_parse_name ("activate", GTK_TYPE_ACTION, &_tmp12_, NULL, FALSE);
		g_signal_handlers_disconnect_matched ((GtkAction*) _tmp11_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp12_, 0, NULL, (GCallback) _main_window_documents_list_menu_activate_gtk_action_activate, self);
		_tmp13_ = action;
		gtk_toggle_action_set_active ((GtkToggleAction*) _tmp13_, TRUE);
		_tmp14_ = action;
		g_signal_connect_object ((GtkAction*) _tmp14_, "activate", (GCallback) _main_window_documents_list_menu_activate_gtk_action_activate, self, 0);
	}
	g_object_notify ((GObject*) self, "active-tab");
	g_object_notify ((GObject*) self, "active-document");
	g_object_notify ((GObject*) self, "active-view");
	_g_object_unref0 (action);
	_g_free0 (action_name);
}


static void ___lambda129__gtk_notebook_switch_page (GtkNotebook* _sender, GtkWidget* page, guint page_num, gpointer self) {
	__lambda129_ (self, page, page_num);
}


static void __lambda130_ (MainWindow* self) {
	main_window_update_next_prev_doc_sensitivity (self);
	main_window_update_documents_list_menu (self);
}


static void ___lambda130__gtk_notebook_page_reordered (GtkNotebook* _sender, GtkWidget* child, guint page_num, gpointer self) {
	__lambda130_ (self);
}


static void __lambda131_ (MainWindow* self) {
	CompletionProvider* _tmp0_ = NULL;
	CompletionProvider* provider;
	_tmp0_ = completion_provider_get_default ();
	provider = _tmp0_;
	completion_provider_hide_calltip_window (provider);
	_g_object_unref0 (provider);
}


static void ___lambda131__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) {
	__lambda131_ (self);
}


static gboolean __lambda132_ (MainWindow* self) {
	gboolean result = FALSE;
	CompletionProvider* _tmp0_ = NULL;
	CompletionProvider* provider;
	_tmp0_ = completion_provider_get_default ();
	provider = _tmp0_;
	completion_provider_hide_calltip_window (provider);
	result = FALSE;
	_g_object_unref0 (provider);
	return result;
}


static gboolean ___lambda132__gtk_widget_focus_out_event (GtkWidget* _sender, GdkEventFocus* event, gpointer self) {
	gboolean result;
	result = __lambda132_ (self);
	return result;
}


static void _vala_array_add6 (GFile*** array, int* length, int* size, GFile* value) {
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (GFile*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}


static void __lambda133_ (MainWindow* self, GdkDragContext* dc, gint x, gint y, GtkSelectionData* selection_data, guint info, guint time) {
	Latexila* _tmp0_ = NULL;
	Latexila* app;
	GFile** _tmp1_ = NULL;
	GFile** files;
	gint files_length1;
	gint _files_size_;
	GtkSelectionData* _tmp2_;
	gchar** _tmp3_;
	gchar** _tmp4_ = NULL;
	Latexila* _tmp12_;
	GFile** _tmp13_;
	gint _tmp13__length1;
	GdkDragContext* _tmp14_;
	guint _tmp15_;
	g_return_if_fail (dc != NULL);
	g_return_if_fail (selection_data != NULL);
	_tmp0_ = latexila_get_instance ();
	app = _tmp0_;
	_tmp1_ = g_new0 (GFile*, 0 + 1);
	files = _tmp1_;
	files_length1 = 0;
	_files_size_ = files_length1;
	_tmp2_ = selection_data;
	_tmp4_ = _tmp3_ = gtk_selection_data_get_uris (_tmp2_);
	{
		gchar** uri_collection = NULL;
		gint uri_collection_length1 = 0;
		gint _uri_collection_size_ = 0;
		gint uri_it = 0;
		uri_collection = _tmp4_;
		uri_collection_length1 = _vala_array_length (_tmp3_);
		for (uri_it = 0; uri_it < _vala_array_length (_tmp3_); uri_it = uri_it + 1) {
			gchar* _tmp5_;
			gchar* uri = NULL;
			_tmp5_ = g_strdup (uri_collection[uri_it]);
			uri = _tmp5_;
			{
				const gchar* _tmp6_;
				gint _tmp7_;
				gint _tmp8_;
				_tmp6_ = uri;
				_tmp7_ = strlen (_tmp6_);
				_tmp8_ = _tmp7_;
				if (0 < _tmp8_) {
					GFile** _tmp9_;
					gint _tmp9__length1;
					const gchar* _tmp10_;
					GFile* _tmp11_ = NULL;
					_tmp9_ = files;
					_tmp9__length1 = files_length1;
					_tmp10_ = uri;
					_tmp11_ = g_file_new_for_uri (_tmp10_);
					_vala_array_add6 (&files, &files_length1, &_files_size_, _tmp11_);
				}
				_g_free0 (uri);
			}
		}
		uri_collection = (_vala_array_free (uri_collection, uri_collection_length1, (GDestroyNotify) g_free), NULL);
	}
	_tmp12_ = app;
	_tmp13_ = files;
	_tmp13__length1 = files_length1;
	latexila_open_documents (_tmp12_, _tmp13_, _tmp13__length1);
	_tmp14_ = dc;
	_tmp15_ = time;
	gtk_drag_finish (_tmp14_, TRUE, TRUE, (guint32) _tmp15_);
	files = (_vala_array_free (files, files_length1, (GDestroyNotify) g_object_unref), NULL);
	_g_object_unref0 (app);
}


static void ___lambda133__gtk_widget_drag_data_received (GtkWidget* _sender, GdkDragContext* context, gint x, gint y, GtkSelectionData* selection_data, guint info, guint time_, gpointer self) {
	__lambda133_ (self, context, x, y, selection_data, info, time_);
}


MainWindow* main_window_construct (GType object_type) {
	MainWindow * self = NULL;
	GSettings* _tmp0_;
	GSettings* settings;
	gint w = 0;
	gint h = 0;
	GSettings* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	GSettings* _tmp4_;
	gint _tmp5_ = 0;
	GdkWindowState state;
	GdkWindowState _tmp6_;
	GdkWindowState _tmp7_;
	DocumentsPanel* _tmp8_;
	DocumentsPanel* _tmp9_;
	CustomStatusbar* _tmp10_;
	CustomStatusbar* _tmp11_;
	guint _tmp12_ = 0U;
	GotoLine* _tmp13_;
	SearchAndReplace* _tmp14_;
	FileBrowser* _tmp15_;
	FileBrowser* file_browser;
	SymbolsView* _tmp16_;
	Structure* _tmp17_;
	Structure* structure;
	GtkUIManager* _tmp18_;
	MainWindowStructure* _tmp19_;
	BuildView* _tmp20_;
	BuildView* build_view;
	GtkUIManager* _tmp21_;
	MainWindowBuildTools* _tmp22_;
	GtkUIManager* _tmp23_;
	GtkWidget* _tmp24_ = NULL;
	GtkToolbar* _tmp25_;
	GtkToolbar* build_toolbar;
	BottomPanel* _tmp26_;
	BottomPanel* bottom_panel;
	GtkActionGroup* _tmp27_;
	GtkAction* _tmp28_ = NULL;
	GtkToggleAction* _tmp29_;
	GtkToggleAction* action_bottom_panel;
	SidePanel* _tmp30_;
	SidePanel* _tmp31_;
	const gchar* _tmp32_ = NULL;
	SymbolsView* _tmp33_;
	SidePanel* _tmp34_;
	const gchar* _tmp35_ = NULL;
	SidePanel* _tmp36_;
	const gchar* _tmp37_ = NULL;
	SidePanel* _tmp38_;
	GtkUIManager* _tmp39_;
	GtkWidget* _tmp40_ = NULL;
	GtkWidget* _tmp41_;
	GtkWidget* menu;
	GtkUIManager* _tmp42_;
	GtkWidget* _tmp43_ = NULL;
	GtkToolbar* _tmp44_;
	GtkToolbar* _tmp45_;
	GtkToolbar* _tmp46_;
	GtkStyleContext* _tmp47_ = NULL;
	GtkStyleContext* _tmp48_;
	GtkStyleContext* main_toolbar_context;
	GtkToolbar* _tmp49_;
	GtkUIManager* _tmp50_;
	GtkWidget* _tmp51_ = NULL;
	GtkToolbar* _tmp52_;
	GtkToolbar* _tmp53_;
	DocumentsPanel* _tmp54_;
	DocumentsPanel* _tmp55_;
	DocumentsPanel* _tmp56_;
	DocumentsPanel* _tmp57_;
	GtkTargetEntry* _tmp58_ = NULL;
	GtkTargetEntry* _tmp59_;
	gint _tmp59__length1;
	GtkActionGroup* _tmp60_;
	GtkAction* _tmp61_ = NULL;
	GtkToggleAction* _tmp62_;
	GtkToggleAction* spell_checking_action;
	GSettings* _tmp63_;
	GSettings* editor_settings;
	GtkGrid* _tmp64_;
	GtkGrid* main_vgrid;
	GtkToolbar* _tmp65_;
	GtkToolbar* _tmp66_;
	GtkToolbar* _tmp67_;
	GtkPaned* _tmp68_;
	GtkPaned* _tmp69_;
	GSettings* _tmp70_;
	gint _tmp71_ = 0;
	GtkPaned* _tmp72_;
	GtkPaned* _tmp73_;
	GtkGrid* _tmp74_;
	GtkGrid* vgrid_source_view;
	DocumentsPanel* _tmp75_;
	GotoLine* _tmp76_;
	SearchAndReplace* _tmp77_;
	GtkWidget* _tmp78_ = NULL;
	GtkWidget* _tmp79_;
	DocumentsPanel* _tmp80_;
	GtkPaned* _tmp81_;
	GtkPaned* _tmp82_;
	GSettings* _tmp83_;
	gint _tmp84_ = 0;
	GtkPaned* _tmp85_;
	GtkPaned* _tmp86_;
	GtkPaned* _tmp87_;
	SidePanel* _tmp88_;
	GtkPaned* _tmp89_;
	GtkPaned* _tmp90_;
	SidePanel* _tmp91_;
	GtkPaned* _tmp92_;
	CustomStatusbar* _tmp93_;
	CustomStatusbar* _tmp94_;
	GtkSettings* _tmp95_ = NULL;
	GtkSettings* gtk_settings;
	self = (MainWindow*) g_object_new (object_type, NULL);
	gtk_window_set_title ((GtkWindow*) self, "LaTeXila");
	_tmp0_ = g_settings_new ("org.gnome.latexila.state.window");
	settings = _tmp0_;
	_tmp1_ = settings;
	g_settings_get (_tmp1_, "size", "(ii)", &w, &h);
	_tmp2_ = w;
	_tmp3_ = h;
	gtk_window_set_default_size ((GtkWindow*) self, _tmp2_, _tmp3_);
	_tmp4_ = settings;
	_tmp5_ = g_settings_get_int (_tmp4_, "state");
	state = (GdkWindowState) _tmp5_;
	_tmp6_ = state;
	if ((_tmp6_ & GDK_WINDOW_STATE_MAXIMIZED) == GDK_WINDOW_STATE_MAXIMIZED) {
		gtk_window_maximize ((GtkWindow*) self);
	} else {
		gtk_window_unmaximize ((GtkWindow*) self);
	}
	_tmp7_ = state;
	if ((_tmp7_ & GDK_WINDOW_STATE_STICKY) == GDK_WINDOW_STATE_STICKY) {
		gtk_window_stick ((GtkWindow*) self);
	} else {
		gtk_window_unstick ((GtkWindow*) self);
	}
	main_window_initialize_menubar_and_toolbar (self);
	_tmp8_ = documents_panel_new (self);
	g_object_ref_sink (_tmp8_);
	_g_object_unref0 (self->priv->documents_panel);
	self->priv->documents_panel = _tmp8_;
	_tmp9_ = self->priv->documents_panel;
	g_signal_connect_object (_tmp9_, "right-click", (GCallback) ___lambda124__documents_panel_right_click, self, 0);
	_tmp10_ = custom_statusbar_new ();
	g_object_ref_sink (_tmp10_);
	_g_object_unref0 (self->priv->statusbar);
	self->priv->statusbar = _tmp10_;
	_tmp11_ = self->priv->statusbar;
	_tmp12_ = gtk_statusbar_get_context_id ((GtkStatusbar*) _tmp11_, "tip_message");
	self->priv->tip_message_cid = _tmp12_;
	_tmp13_ = goto_line_new (self);
	g_object_ref_sink (_tmp13_);
	_g_object_unref0 (self->priv->goto_line);
	self->priv->goto_line = _tmp13_;
	_tmp14_ = search_and_replace_new (self);
	_g_object_unref0 (self->priv->search_and_replace);
	self->priv->search_and_replace = _tmp14_;
	_tmp15_ = file_browser_new (self);
	g_object_ref_sink (_tmp15_);
	file_browser = _tmp15_;
	_tmp16_ = symbols_view_new (self);
	g_object_ref_sink (_tmp16_);
	_g_object_unref0 (self->priv->_symbols);
	self->priv->_symbols = _tmp16_;
	_tmp17_ = structure_new (self);
	g_object_ref_sink (_tmp17_);
	structure = _tmp17_;
	_tmp18_ = self->priv->ui_manager;
	_tmp19_ = main_window_structure_new (_tmp18_, structure);
	_main_window_structure_unref0 (self->priv->_main_window_structure);
	self->priv->_main_window_structure = _tmp19_;
	_tmp20_ = build_view_new (self);
	g_object_ref_sink (_tmp20_);
	build_view = _tmp20_;
	_tmp21_ = self->priv->ui_manager;
	_tmp22_ = main_window_build_tools_new (self, _tmp21_, build_view, file_browser);
	_main_window_build_tools_unref0 (self->priv->_main_window_build_tools);
	self->priv->_main_window_build_tools = _tmp22_;
	_tmp23_ = self->priv->ui_manager;
	_tmp24_ = gtk_ui_manager_get_widget (_tmp23_, "/BuildToolbar");
	_tmp25_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp24_, GTK_TYPE_TOOLBAR) ? ((GtkToolbar*) _tmp24_) : NULL);
	build_toolbar = _tmp25_;
	gtk_toolbar_set_style (build_toolbar, GTK_TOOLBAR_ICONS);
	gtk_toolbar_set_icon_size (build_toolbar, GTK_ICON_SIZE_MENU);
	gtk_orientable_set_orientation ((GtkOrientable*) build_toolbar, GTK_ORIENTATION_VERTICAL);
	_tmp26_ = bottom_panel_new (build_view, build_toolbar);
	g_object_ref_sink (_tmp26_);
	bottom_panel = _tmp26_;
	_tmp27_ = self->priv->action_group;
	_tmp28_ = gtk_action_group_get_action (_tmp27_, "ViewBottomPanel");
	_tmp29_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp28_, GTK_TYPE_TOGGLE_ACTION) ? ((GtkToggleAction*) _tmp28_) : NULL);
	action_bottom_panel = _tmp29_;
	g_object_bind_property_with_closures ((GObject*) bottom_panel, "visible", (GObject*) action_bottom_panel, "active", G_BINDING_BIDIRECTIONAL, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, NULL)));
	_tmp30_ = side_panel_new ();
	g_object_ref_sink (_tmp30_);
	_g_object_unref0 (self->priv->_side_panel);
	self->priv->_side_panel = _tmp30_;
	_tmp31_ = self->priv->_side_panel;
	_tmp32_ = _ ("Symbols");
	_tmp33_ = self->priv->_symbols;
	side_panel_add_component (_tmp31_, _tmp32_, "symbol_greek", (GtkGrid*) _tmp33_);
	_tmp34_ = self->priv->_side_panel;
	_tmp35_ = _ ("File Browser");
	side_panel_add_component (_tmp34_, _tmp35_, GTK_STOCK_OPEN, (GtkGrid*) file_browser);
	_tmp36_ = self->priv->_side_panel;
	_tmp37_ = _ ("Structure");
	side_panel_add_component (_tmp36_, _tmp37_, GTK_STOCK_INDEX, (GtkGrid*) structure);
	_tmp38_ = self->priv->_side_panel;
	side_panel_restore_state (_tmp38_);
	_tmp39_ = self->priv->ui_manager;
	_tmp40_ = gtk_ui_manager_get_widget (_tmp39_, "/MainMenu");
	_tmp41_ = _g_object_ref0 (_tmp40_);
	menu = _tmp41_;
	_tmp42_ = self->priv->ui_manager;
	_tmp43_ = gtk_ui_manager_get_widget (_tmp42_, "/MainToolbar");
	_tmp44_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp43_, GTK_TYPE_TOOLBAR) ? ((GtkToolbar*) _tmp43_) : NULL);
	_g_object_unref0 (self->priv->_main_toolbar);
	self->priv->_main_toolbar = _tmp44_;
	_tmp45_ = self->priv->_main_toolbar;
	gtk_toolbar_set_style (_tmp45_, GTK_TOOLBAR_ICONS);
	_tmp46_ = self->priv->_main_toolbar;
	_tmp47_ = gtk_widget_get_style_context ((GtkWidget*) _tmp46_);
	_tmp48_ = _g_object_ref0 (_tmp47_);
	main_toolbar_context = _tmp48_;
	gtk_style_context_add_class (main_toolbar_context, GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
	_tmp49_ = self->priv->_main_toolbar;
	main_window_setup_toolbar_open_button (self, _tmp49_);
	_tmp50_ = self->priv->ui_manager;
	_tmp51_ = gtk_ui_manager_get_widget (_tmp50_, "/EditToolbar");
	_tmp52_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp51_, GTK_TYPE_TOOLBAR) ? ((GtkToolbar*) _tmp51_) : NULL);
	_g_object_unref0 (self->priv->_edit_toolbar);
	self->priv->_edit_toolbar = _tmp52_;
	_tmp53_ = self->priv->_edit_toolbar;
	gtk_toolbar_set_style (_tmp53_, GTK_TOOLBAR_ICONS);
	g_signal_connect_object ((GtkWidget*) self, "delete-event", (GCallback) ___lambda126__gtk_widget_delete_event, self, 0);
	_tmp54_ = self->priv->documents_panel;
	g_signal_connect_object ((GtkNotebook*) _tmp54_, "page-added", (GCallback) ___lambda127__gtk_notebook_page_added, self, 0);
	_tmp55_ = self->priv->documents_panel;
	g_signal_connect_object ((GtkNotebook*) _tmp55_, "page-removed", (GCallback) ___lambda128__gtk_notebook_page_removed, self, 0);
	_tmp56_ = self->priv->documents_panel;
	g_signal_connect_object ((GtkNotebook*) _tmp56_, "switch-page", (GCallback) ___lambda129__gtk_notebook_switch_page, self, 0);
	_tmp57_ = self->priv->documents_panel;
	g_signal_connect_object ((GtkNotebook*) _tmp57_, "page-reordered", (GCallback) ___lambda130__gtk_notebook_page_reordered, self, 0);
	g_signal_connect_object ((GObject*) self, "notify::active-tab", (GCallback) ___lambda131__g_object_notify, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "focus-out-event", (GCallback) ___lambda132__gtk_widget_focus_out_event, self, 0);
	main_window_set_file_actions_sensitivity (self, FALSE);
	main_window_set_documents_move_to_new_window_sensitivity (self, FALSE);
	_tmp58_ = g_new0 (GtkTargetEntry, 0);
	_tmp59_ = _tmp58_;
	_tmp59__length1 = 0;
	gtk_drag_dest_set ((GtkWidget*) self, GTK_DEST_DEFAULT_ALL, _tmp59_, 0, GDK_ACTION_COPY);
	_tmp59_ = (g_free (_tmp59_), NULL);
	gtk_drag_dest_add_uri_targets ((GtkWidget*) self);
	g_signal_connect_object ((GtkWidget*) self, "drag-data-received", (GCallback) ___lambda133__gtk_widget_drag_data_received, self, 0);
	_tmp60_ = self->priv->action_group;
	_tmp61_ = gtk_action_group_get_action (_tmp60_, "EditSpellChecking");
	_tmp62_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp61_, GTK_TYPE_TOGGLE_ACTION) ? ((GtkToggleAction*) _tmp61_) : NULL);
	spell_checking_action = _tmp62_;
	_tmp63_ = g_settings_new ("org.gnome.latexila.preferences.editor");
	editor_settings = _tmp63_;
	g_settings_bind (editor_settings, "spell-checking", (GObject*) spell_checking_action, "active", G_SETTINGS_BIND_DEFAULT);
	_tmp64_ = (GtkGrid*) gtk_grid_new ();
	g_object_ref_sink (_tmp64_);
	main_vgrid = _tmp64_;
	gtk_orientable_set_orientation ((GtkOrientable*) main_vgrid, GTK_ORIENTATION_VERTICAL);
	gtk_container_add ((GtkContainer*) main_vgrid, menu);
	_tmp65_ = self->priv->_main_toolbar;
	gtk_container_add ((GtkContainer*) main_vgrid, (GtkWidget*) _tmp65_);
	_tmp66_ = self->priv->_edit_toolbar;
	gtk_container_add ((GtkContainer*) main_vgrid, (GtkWidget*) _tmp66_);
	gtk_widget_show ((GtkWidget*) main_vgrid);
	gtk_widget_show_all (menu);
	_tmp67_ = self->priv->_main_toolbar;
	gtk_widget_show_all ((GtkWidget*) _tmp67_);
	_tmp68_ = (GtkPaned*) gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
	g_object_ref_sink (_tmp68_);
	_g_object_unref0 (self->priv->main_hpaned);
	self->priv->main_hpaned = _tmp68_;
	_tmp69_ = self->priv->main_hpaned;
	_tmp70_ = settings;
	_tmp71_ = g_settings_get_int (_tmp70_, "side-panel-size");
	gtk_paned_set_position (_tmp69_, _tmp71_);
	_tmp72_ = self->priv->main_hpaned;
	gtk_container_add ((GtkContainer*) main_vgrid, (GtkWidget*) _tmp72_);
	_tmp73_ = self->priv->main_hpaned;
	gtk_widget_show ((GtkWidget*) _tmp73_);
	_tmp74_ = (GtkGrid*) gtk_grid_new ();
	g_object_ref_sink (_tmp74_);
	vgrid_source_view = _tmp74_;
	gtk_orientable_set_orientation ((GtkOrientable*) vgrid_source_view, GTK_ORIENTATION_VERTICAL);
	gtk_grid_set_row_spacing (vgrid_source_view, (guint) 2);
	_tmp75_ = self->priv->documents_panel;
	gtk_container_add ((GtkContainer*) vgrid_source_view, (GtkWidget*) _tmp75_);
	_tmp76_ = self->priv->goto_line;
	gtk_container_add ((GtkContainer*) vgrid_source_view, (GtkWidget*) _tmp76_);
	_tmp77_ = self->priv->search_and_replace;
	_tmp78_ = search_and_replace_get_widget (_tmp77_);
	_tmp79_ = _tmp78_;
	gtk_container_add ((GtkContainer*) vgrid_source_view, _tmp79_);
	_g_object_unref0 (_tmp79_);
	gtk_widget_show ((GtkWidget*) vgrid_source_view);
	_tmp80_ = self->priv->documents_panel;
	gtk_widget_show_all ((GtkWidget*) _tmp80_);
	_tmp81_ = (GtkPaned*) gtk_paned_new (GTK_ORIENTATION_VERTICAL);
	g_object_ref_sink (_tmp81_);
	_g_object_unref0 (self->priv->vpaned);
	self->priv->vpaned = _tmp81_;
	_tmp82_ = self->priv->vpaned;
	_tmp83_ = settings;
	_tmp84_ = g_settings_get_int (_tmp83_, "vertical-paned-position");
	gtk_paned_set_position (_tmp82_, _tmp84_);
	_tmp85_ = self->priv->vpaned;
	gtk_paned_pack1 (_tmp85_, (GtkWidget*) vgrid_source_view, TRUE, TRUE);
	_tmp86_ = self->priv->vpaned;
	gtk_paned_pack2 (_tmp86_, (GtkWidget*) bottom_panel, FALSE, TRUE);
	_tmp87_ = self->priv->main_hpaned;
	_tmp88_ = self->priv->_side_panel;
	gtk_paned_add1 (_tmp87_, (GtkWidget*) _tmp88_);
	_tmp89_ = self->priv->main_hpaned;
	_tmp90_ = self->priv->vpaned;
	gtk_paned_add2 (_tmp89_, (GtkWidget*) _tmp90_);
	_tmp91_ = self->priv->_side_panel;
	gtk_widget_show ((GtkWidget*) _tmp91_);
	_tmp92_ = self->priv->vpaned;
	gtk_widget_show ((GtkWidget*) _tmp92_);
	_tmp93_ = self->priv->statusbar;
	gtk_container_add ((GtkContainer*) main_vgrid, (GtkWidget*) _tmp93_);
	_tmp94_ = self->priv->statusbar;
	gtk_widget_show_all ((GtkWidget*) _tmp94_);
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) main_vgrid);
	gtk_widget_show ((GtkWidget*) self);
	main_window_show_or_hide_widgets (self);
	_tmp95_ = gtk_widget_get_settings (menu);
	gtk_settings = _tmp95_;
	g_object_set (gtk_settings, "gtk-menu-images", TRUE, NULL);
	_g_object_unref0 (vgrid_source_view);
	_g_object_unref0 (main_vgrid);
	_g_object_unref0 (editor_settings);
	_g_object_unref0 (spell_checking_action);
	_g_object_unref0 (main_toolbar_context);
	_g_object_unref0 (menu);
	_g_object_unref0 (action_bottom_panel);
	_g_object_unref0 (bottom_panel);
	_g_object_unref0 (build_toolbar);
	_g_object_unref0 (build_view);
	_g_object_unref0 (structure);
	_g_object_unref0 (file_browser);
	_g_object_unref0 (settings);
	return self;
}


MainWindow* main_window_new (void) {
	return main_window_construct (TYPE_MAIN_WINDOW);
}


GeeList* main_window_get_documents (MainWindow* self) {
	GeeList* result = NULL;
	GeeLinkedList* _tmp0_;
	GeeList* all_documents;
	DocumentsPanel* _tmp1_;
	gint _tmp2_ = 0;
	gint nb_documents;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = gee_linked_list_new (TYPE_DOCUMENT, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL);
	all_documents = (GeeList*) _tmp0_;
	_tmp1_ = self->priv->documents_panel;
	_tmp2_ = gtk_notebook_get_n_pages ((GtkNotebook*) _tmp1_);
	nb_documents = _tmp2_;
	{
		gint i;
		i = 0;
		{
			gboolean _tmp3_;
			_tmp3_ = TRUE;
			while (TRUE) {
				gboolean _tmp4_;
				gint _tmp6_;
				gint _tmp7_;
				DocumentsPanel* _tmp8_;
				gint _tmp9_;
				GtkWidget* _tmp10_ = NULL;
				DocumentTab* _tmp11_;
				DocumentTab* tab;
				GeeList* _tmp12_;
				DocumentTab* _tmp13_;
				Document* _tmp14_;
				Document* _tmp15_;
				_tmp4_ = _tmp3_;
				if (!_tmp4_) {
					gint _tmp5_;
					_tmp5_ = i;
					i = _tmp5_ + 1;
				}
				_tmp3_ = FALSE;
				_tmp6_ = i;
				_tmp7_ = nb_documents;
				if (!(_tmp6_ < _tmp7_)) {
					break;
				}
				_tmp8_ = self->priv->documents_panel;
				_tmp9_ = i;
				_tmp10_ = gtk_notebook_get_nth_page ((GtkNotebook*) _tmp8_, _tmp9_);
				_tmp11_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp10_, TYPE_DOCUMENT_TAB) ? ((DocumentTab*) _tmp10_) : NULL);
				tab = _tmp11_;
				_tmp12_ = all_documents;
				_tmp13_ = tab;
				_tmp14_ = document_tab_get_document (_tmp13_);
				_tmp15_ = _tmp14_;
				gee_collection_add ((GeeCollection*) _tmp12_, _tmp15_);
				_g_object_unref0 (tab);
			}
		}
	}
	result = all_documents;
	return result;
}


GeeList* main_window_get_unsaved_documents (MainWindow* self) {
	GeeList* result = NULL;
	GeeLinkedList* _tmp0_;
	GeeList* unsaved_documents;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = gee_linked_list_new (TYPE_DOCUMENT, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL);
	unsaved_documents = (GeeList*) _tmp0_;
	{
		GeeList* _tmp1_ = NULL;
		GeeList* _doc_list;
		GeeList* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		gint _doc_size;
		gint _doc_index;
		_tmp1_ = main_window_get_documents (self);
		_doc_list = _tmp1_;
		_tmp2_ = _doc_list;
		_tmp3_ = gee_collection_get_size ((GeeCollection*) _tmp2_);
		_tmp4_ = _tmp3_;
		_doc_size = _tmp4_;
		_doc_index = -1;
		while (TRUE) {
			gint _tmp5_;
			gint _tmp6_;
			gint _tmp7_;
			GeeList* _tmp8_;
			gint _tmp9_;
			gpointer _tmp10_ = NULL;
			Document* doc;
			Document* _tmp11_;
			gboolean _tmp12_ = FALSE;
			_tmp5_ = _doc_index;
			_doc_index = _tmp5_ + 1;
			_tmp6_ = _doc_index;
			_tmp7_ = _doc_size;
			if (!(_tmp6_ < _tmp7_)) {
				break;
			}
			_tmp8_ = _doc_list;
			_tmp9_ = _doc_index;
			_tmp10_ = gee_list_get (_tmp8_, _tmp9_);
			doc = (Document*) _tmp10_;
			_tmp11_ = doc;
			_tmp12_ = document_get_modified (_tmp11_);
			if (_tmp12_) {
				GeeList* _tmp13_;
				Document* _tmp14_;
				_tmp13_ = unsaved_documents;
				_tmp14_ = doc;
				gee_collection_add ((GeeCollection*) _tmp13_, _tmp14_);
			}
			_g_object_unref0 (doc);
		}
		_g_object_unref0 (_doc_list);
	}
	result = unsaved_documents;
	return result;
}


GeeList* main_window_get_views (MainWindow* self) {
	GeeList* result = NULL;
	GeeLinkedList* _tmp0_;
	GeeList* all_views;
	DocumentsPanel* _tmp1_;
	gint _tmp2_ = 0;
	gint nb_documents;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = gee_linked_list_new (TYPE_DOCUMENT, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL);
	all_views = (GeeList*) _tmp0_;
	_tmp1_ = self->priv->documents_panel;
	_tmp2_ = gtk_notebook_get_n_pages ((GtkNotebook*) _tmp1_);
	nb_documents = _tmp2_;
	{
		gint i;
		i = 0;
		{
			gboolean _tmp3_;
			_tmp3_ = TRUE;
			while (TRUE) {
				gboolean _tmp4_;
				gint _tmp6_;
				gint _tmp7_;
				DocumentsPanel* _tmp8_;
				gint _tmp9_;
				GtkWidget* _tmp10_ = NULL;
				DocumentTab* _tmp11_;
				DocumentTab* tab;
				GeeList* _tmp12_;
				DocumentTab* _tmp13_;
				DocumentView* _tmp14_;
				DocumentView* _tmp15_;
				_tmp4_ = _tmp3_;
				if (!_tmp4_) {
					gint _tmp5_;
					_tmp5_ = i;
					i = _tmp5_ + 1;
				}
				_tmp3_ = FALSE;
				_tmp6_ = i;
				_tmp7_ = nb_documents;
				if (!(_tmp6_ < _tmp7_)) {
					break;
				}
				_tmp8_ = self->priv->documents_panel;
				_tmp9_ = i;
				_tmp10_ = gtk_notebook_get_nth_page ((GtkNotebook*) _tmp8_, _tmp9_);
				_tmp11_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp10_, TYPE_DOCUMENT_TAB) ? ((DocumentTab*) _tmp10_) : NULL);
				tab = _tmp11_;
				_tmp12_ = all_views;
				_tmp13_ = tab;
				_tmp14_ = document_tab_get_view (_tmp13_);
				_tmp15_ = _tmp14_;
				gee_collection_add ((GeeCollection*) _tmp12_, _tmp15_);
				_g_object_unref0 (tab);
			}
		}
	}
	result = all_views;
	return result;
}


static void _main_window_on_menu_item_select_gtk_menu_item_select (GtkMenuItem* _sender, gpointer self) {
	main_window_on_menu_item_select (self, _sender);
}


static void _main_window_on_menu_item_deselect_gtk_menu_item_deselect (GtkMenuItem* _sender, gpointer self) {
	main_window_on_menu_item_deselect (self, _sender);
}


static void __lambda122_ (MainWindow* self, GtkAction* action, GtkWidget* p) {
	GtkWidget* _tmp0_;
	g_return_if_fail (action != NULL);
	g_return_if_fail (p != NULL);
	_tmp0_ = p;
	if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, GTK_TYPE_MENU_ITEM)) {
		GtkWidget* _tmp1_;
		GtkMenuItem* _tmp2_;
		GtkMenuItem* proxy;
		GtkMenuItem* _tmp3_;
		GtkMenuItem* _tmp4_;
		_tmp1_ = p;
		_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp1_, GTK_TYPE_MENU_ITEM) ? ((GtkMenuItem*) _tmp1_) : NULL);
		proxy = _tmp2_;
		_tmp3_ = proxy;
		g_signal_connect_object (_tmp3_, "select", (GCallback) _main_window_on_menu_item_select_gtk_menu_item_select, self, 0);
		_tmp4_ = proxy;
		g_signal_connect_object (_tmp4_, "deselect", (GCallback) _main_window_on_menu_item_deselect_gtk_menu_item_deselect, self, 0);
		_g_object_unref0 (proxy);
	}
}


static void ___lambda122__gtk_ui_manager_connect_proxy (GtkUIManager* _sender, GtkAction* action, GtkWidget* proxy, gpointer self) {
	__lambda122_ (self, action, proxy);
}


static void __lambda123_ (MainWindow* self, GtkAction* action, GtkWidget* p) {
	GtkWidget* _tmp0_;
	g_return_if_fail (action != NULL);
	g_return_if_fail (p != NULL);
	_tmp0_ = p;
	if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, GTK_TYPE_MENU_ITEM)) {
		GtkWidget* _tmp1_;
		GtkMenuItem* _tmp2_;
		GtkMenuItem* proxy;
		GtkMenuItem* _tmp3_;
		guint _tmp4_ = 0U;
		GtkMenuItem* _tmp5_;
		guint _tmp6_ = 0U;
		_tmp1_ = p;
		_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp1_, GTK_TYPE_MENU_ITEM) ? ((GtkMenuItem*) _tmp1_) : NULL);
		proxy = _tmp2_;
		_tmp3_ = proxy;
		g_signal_parse_name ("select", GTK_TYPE_MENU_ITEM, &_tmp4_, NULL, FALSE);
		g_signal_handlers_disconnect_matched (_tmp3_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp4_, 0, NULL, (GCallback) _main_window_on_menu_item_select_gtk_menu_item_select, self);
		_tmp5_ = proxy;
		g_signal_parse_name ("deselect", GTK_TYPE_MENU_ITEM, &_tmp6_, NULL, FALSE);
		g_signal_handlers_disconnect_matched (_tmp5_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp6_, 0, NULL, (GCallback) _main_window_on_menu_item_deselect_gtk_menu_item_deselect, self);
		_g_object_unref0 (proxy);
	}
}


static void ___lambda123__gtk_ui_manager_disconnect_proxy (GtkUIManager* _sender, GtkAction* action, GtkWidget* proxy, gpointer self) {
	__lambda123_ (self, action, proxy);
}


static void main_window_initialize_menubar_and_toolbar (MainWindow* self) {
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	GtkRecentAction* _tmp2_;
	GtkAction* recent_action;
	GtkActionGroup* _tmp3_;
	GtkActionGroup* _tmp4_;
	GtkActionGroup* _tmp5_;
	GtkActionGroup* _tmp6_;
	GtkActionGroup* _tmp7_;
	LatexMenu* _tmp8_;
	GtkUIManager* _tmp9_;
	GtkUIManager* _tmp10_;
	GtkActionGroup* _tmp11_;
	GtkUIManager* _tmp12_;
	GtkActionGroup* _tmp13_;
	GtkUIManager* _tmp17_;
	GtkAccelGroup* _tmp18_ = NULL;
	GtkUIManager* _tmp19_;
	GtkUIManager* _tmp20_;
	GtkActionGroup* _tmp21_;
	GtkUIManager* _tmp22_;
	GtkActionGroup* _tmp23_;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = _ ("Open _Recent");
	_tmp1_ = _ ("Open recently used files");
	_tmp2_ = (GtkRecentAction*) gtk_recent_action_new ("FileOpenRecent", _tmp0_, _tmp1_, "");
	recent_action = (GtkAction*) _tmp2_;
	main_window_configure_recent_chooser (self, G_TYPE_CHECK_INSTANCE_CAST (recent_action, GTK_TYPE_RECENT_CHOOSER, GtkRecentChooser));
	_tmp3_ = gtk_action_group_new ("ActionGroup");
	_g_object_unref0 (self->priv->action_group);
	self->priv->action_group = _tmp3_;
	_tmp4_ = self->priv->action_group;
	gtk_action_group_set_translation_domain (_tmp4_, GETTEXT_PACKAGE);
	_tmp5_ = self->priv->action_group;
	gtk_action_group_add_actions (_tmp5_, MAIN_WINDOW_action_entries, G_N_ELEMENTS (MAIN_WINDOW_action_entries), self);
	_tmp6_ = self->priv->action_group;
	gtk_action_group_add_action (_tmp6_, recent_action);
	_tmp7_ = self->priv->action_group;
	gtk_action_group_add_toggle_actions (_tmp7_, MAIN_WINDOW_toggle_action_entries, G_N_ELEMENTS (MAIN_WINDOW_toggle_action_entries), self);
	_tmp8_ = latex_menu_new (self);
	_g_object_unref0 (self->priv->latex_action_group);
	self->priv->latex_action_group = (GtkActionGroup*) _tmp8_;
	_tmp9_ = gtk_ui_manager_new ();
	_g_object_unref0 (self->priv->ui_manager);
	self->priv->ui_manager = _tmp9_;
	_tmp10_ = self->priv->ui_manager;
	_tmp11_ = self->priv->action_group;
	gtk_ui_manager_insert_action_group (_tmp10_, _tmp11_, 0);
	_tmp12_ = self->priv->ui_manager;
	_tmp13_ = self->priv->latex_action_group;
	gtk_ui_manager_insert_action_group (_tmp12_, _tmp13_, 0);
	{
		gchar* _tmp14_ = NULL;
		gchar* path;
		GtkUIManager* _tmp15_;
		_tmp14_ = g_build_filename (DATA_DIR, "ui", "ui.xml", NULL);
		path = _tmp14_;
		_tmp15_ = self->priv->ui_manager;
		gtk_ui_manager_add_ui_from_file (_tmp15_, path, &_inner_error_);
		if (_inner_error_ != NULL) {
			_g_free0 (path);
			goto __catch15_g_error;
		}
		_g_free0 (path);
	}
	goto __finally15;
	__catch15_g_error:
	{
		GError* err = NULL;
		const gchar* _tmp16_;
		err = _inner_error_;
		_inner_error_ = NULL;
		_tmp16_ = err->message;
		g_error ("main_window.vala:555: %s", _tmp16_);
		_g_error_free0 (err);
	}
	__finally15:
	if (_inner_error_ != NULL) {
		_g_object_unref0 (recent_action);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
	_tmp17_ = self->priv->ui_manager;
	_tmp18_ = gtk_ui_manager_get_accel_group (_tmp17_);
	gtk_window_add_accel_group ((GtkWindow*) self, _tmp18_);
	_tmp19_ = self->priv->ui_manager;
	g_signal_connect_object (_tmp19_, "connect-proxy", (GCallback) ___lambda122__gtk_ui_manager_connect_proxy, self, 0);
	_tmp20_ = self->priv->ui_manager;
	g_signal_connect_object (_tmp20_, "disconnect-proxy", (GCallback) ___lambda123__gtk_ui_manager_disconnect_proxy, self, 0);
	_tmp21_ = gtk_action_group_new ("DocumentsListActions");
	_g_object_unref0 (self->priv->documents_list_action_group);
	self->priv->documents_list_action_group = _tmp21_;
	_tmp22_ = self->priv->ui_manager;
	_tmp23_ = self->priv->documents_list_action_group;
	gtk_ui_manager_insert_action_group (_tmp22_, _tmp23_, 0);
	_g_object_unref0 (recent_action);
}


static void main_window_on_menu_item_select (MainWindow* self, GtkMenuItem* proxy) {
	GtkMenuItem* _tmp0_;
	GtkAction* _tmp1_ = NULL;
	GtkAction* _tmp2_;
	GtkAction* action;
	GtkAction* _tmp3_;
	GtkAction* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (proxy != NULL);
	_tmp0_ = proxy;
	_tmp1_ = gtk_activatable_get_related_action ((GtkActivatable*) _tmp0_);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	action = _tmp2_;
	_tmp3_ = action;
	g_return_if_fail (_tmp3_ != NULL);
	_tmp4_ = action;
	_tmp5_ = gtk_action_get_tooltip (_tmp4_);
	_tmp6_ = _tmp5_;
	if (_tmp6_ != NULL) {
		CustomStatusbar* _tmp7_;
		guint _tmp8_;
		GtkAction* _tmp9_;
		const gchar* _tmp10_;
		const gchar* _tmp11_;
		_tmp7_ = self->priv->statusbar;
		_tmp8_ = self->priv->tip_message_cid;
		_tmp9_ = action;
		_tmp10_ = gtk_action_get_tooltip (_tmp9_);
		_tmp11_ = _tmp10_;
		gtk_statusbar_push ((GtkStatusbar*) _tmp7_, _tmp8_, _tmp11_);
	}
	_g_object_unref0 (action);
}


static void main_window_on_menu_item_deselect (MainWindow* self, GtkMenuItem* proxy) {
	CustomStatusbar* _tmp0_;
	guint _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (proxy != NULL);
	_tmp0_ = self->priv->statusbar;
	_tmp1_ = self->priv->tip_message_cid;
	gtk_statusbar_pop ((GtkStatusbar*) _tmp0_, _tmp1_);
}


static void main_window_show_or_hide_widgets (MainWindow* self) {
	GSettings* _tmp0_;
	GSettings* settings;
	GtkActionGroup* _tmp1_;
	GtkAction* _tmp2_ = NULL;
	GtkToggleAction* _tmp3_;
	GtkToggleAction* action;
	GtkToolbar* _tmp4_;
	GtkToggleAction* _tmp5_;
	GtkToggleAction* _tmp6_;
	gboolean _tmp7_ = FALSE;
	GtkActionGroup* _tmp8_;
	GtkAction* _tmp9_ = NULL;
	GtkToggleAction* _tmp10_;
	GtkToolbar* _tmp11_;
	GtkToggleAction* _tmp12_;
	GtkToggleAction* _tmp13_;
	gboolean _tmp14_ = FALSE;
	GtkActionGroup* _tmp15_;
	GtkAction* _tmp16_ = NULL;
	GtkToggleAction* _tmp17_;
	SidePanel* _tmp18_;
	GtkToggleAction* _tmp19_;
	GtkToggleAction* _tmp20_;
	gboolean _tmp21_ = FALSE;
	GtkActionGroup* _tmp22_;
	GtkAction* _tmp23_ = NULL;
	GtkToggleAction* _tmp24_;
	GtkToggleAction* _tmp25_;
	gboolean _tmp26_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_settings_new ("org.gnome.latexila.preferences.ui");
	settings = _tmp0_;
	_tmp1_ = self->priv->action_group;
	_tmp2_ = gtk_action_group_get_action (_tmp1_, "ViewMainToolbar");
	_tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp2_, GTK_TYPE_TOGGLE_ACTION) ? ((GtkToggleAction*) _tmp2_) : NULL);
	action = _tmp3_;
	_tmp4_ = self->priv->_main_toolbar;
	_tmp5_ = action;
	g_object_bind_property_with_closures ((GObject*) _tmp4_, "visible", (GObject*) _tmp5_, "active", G_BINDING_BIDIRECTIONAL, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, NULL)));
	_tmp6_ = action;
	_tmp7_ = g_settings_get_boolean (settings, "main-toolbar-visible");
	gtk_toggle_action_set_active (_tmp6_, _tmp7_);
	_tmp8_ = self->priv->action_group;
	_tmp9_ = gtk_action_group_get_action (_tmp8_, "ViewEditToolbar");
	_tmp10_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp9_, GTK_TYPE_TOGGLE_ACTION) ? ((GtkToggleAction*) _tmp9_) : NULL);
	_g_object_unref0 (action);
	action = _tmp10_;
	_tmp11_ = self->priv->_edit_toolbar;
	_tmp12_ = action;
	g_object_bind_property_with_closures ((GObject*) _tmp11_, "visible", (GObject*) _tmp12_, "active", G_BINDING_BIDIRECTIONAL, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, NULL)));
	_tmp13_ = action;
	_tmp14_ = g_settings_get_boolean (settings, "edit-toolbar-visible");
	gtk_toggle_action_set_active (_tmp13_, _tmp14_);
	_tmp15_ = self->priv->action_group;
	_tmp16_ = gtk_action_group_get_action (_tmp15_, "ViewSidePanel");
	_tmp17_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp16_, GTK_TYPE_TOGGLE_ACTION) ? ((GtkToggleAction*) _tmp16_) : NULL);
	_g_object_unref0 (action);
	action = _tmp17_;
	_tmp18_ = self->priv->_side_panel;
	_tmp19_ = action;
	g_object_bind_property_with_closures ((GObject*) _tmp18_, "visible", (GObject*) _tmp19_, "active", G_BINDING_BIDIRECTIONAL, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, NULL)));
	_tmp20_ = action;
	_tmp21_ = g_settings_get_boolean (settings, "side-panel-visible");
	gtk_toggle_action_set_active (_tmp20_, _tmp21_);
	_tmp22_ = self->priv->action_group;
	_tmp23_ = gtk_action_group_get_action (_tmp22_, "ViewBottomPanel");
	_tmp24_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp23_, GTK_TYPE_TOGGLE_ACTION) ? ((GtkToggleAction*) _tmp23_) : NULL);
	_g_object_unref0 (action);
	action = _tmp24_;
	_tmp25_ = action;
	_tmp26_ = g_settings_get_boolean (settings, "bottom-panel-visible");
	gtk_toggle_action_set_active (_tmp25_, _tmp26_);
	_g_object_unref0 (action);
	_g_object_unref0 (settings);
}


static Block6Data* block6_data_ref (Block6Data* _data6_) {
	g_atomic_int_inc (&_data6_->_ref_count_);
	return _data6_;
}


static void block6_data_unref (void * _userdata_) {
	Block6Data* _data6_;
	_data6_ = (Block6Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data6_->_ref_count_)) {
		MainWindow * self;
		self = _data6_->self;
		_g_object_unref0 (_data6_->infobar);
		_g_object_unref0 (_data6_->tab);
		_g_object_unref0 (self);
		g_slice_free (Block6Data, _data6_);
	}
}


static void ______lambda68_ (Block6Data* _data6_, gint response_id) {
	MainWindow * self;
	gint _tmp0_;
	GtkInfoBar* _tmp4_;
	DocumentTab* _tmp5_;
	DocumentView* _tmp6_;
	DocumentView* _tmp7_;
	self = _data6_->self;
	_tmp0_ = response_id;
	if (_tmp0_ == ((gint) GTK_RESPONSE_YES)) {
		DocumentTab* _tmp1_;
		Document* _tmp2_;
		Document* _tmp3_;
		_tmp1_ = _data6_->tab;
		_tmp2_ = document_tab_get_document (_tmp1_);
		_tmp3_ = _tmp2_;
		document_set_readonly (_tmp3_, FALSE);
	}
	_tmp4_ = _data6_->infobar;
	gtk_widget_destroy ((GtkWidget*) _tmp4_);
	_tmp5_ = _data6_->tab;
	_tmp6_ = document_tab_get_view (_tmp5_);
	_tmp7_ = _tmp6_;
	gtk_widget_grab_focus ((GtkWidget*) _tmp7_);
}


static void _______lambda68__gtk_info_bar_response (GtkInfoBar* _sender, gint response_id, gpointer self) {
	______lambda68_ (self, response_id);
}


DocumentTab* main_window_open_document (MainWindow* self, GFile* location, gboolean jump_to) {
	DocumentTab* result = NULL;
	Latexila* _tmp0_ = NULL;
	Latexila* _tmp1_;
	GList* _tmp2_ = NULL;
	GList* _tmp3_;
	GFile* _tmp60_;
	gboolean _tmp61_;
	DocumentTab* _tmp62_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (location != NULL, NULL);
	_tmp0_ = latexila_get_instance ();
	_tmp1_ = _tmp0_;
	_tmp2_ = gtk_application_get_windows ((GtkApplication*) _tmp1_);
	_tmp3_ = _tmp2_;
	_g_object_unref0 (_tmp1_);
	{
		GList* window_collection = NULL;
		GList* window_it = NULL;
		window_collection = _tmp3_;
		for (window_it = window_collection; window_it != NULL; window_it = window_it->next) {
			GtkWindow* _tmp4_;
			GtkWindow* window = NULL;
			_tmp4_ = _g_object_ref0 ((GtkWindow*) window_it->data);
			window = _tmp4_;
			{
				GtkWindow* _tmp5_;
				MainWindow* _tmp6_;
				MainWindow* w;
				_tmp5_ = window;
				_tmp6_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp5_, TYPE_MAIN_WINDOW) ? ((MainWindow*) _tmp5_) : NULL);
				w = _tmp6_;
				{
					MainWindow* _tmp7_;
					GeeList* _tmp8_ = NULL;
					GeeList* _doc_list;
					GeeList* _tmp9_;
					gint _tmp10_;
					gint _tmp11_;
					gint _doc_size;
					gint _doc_index;
					_tmp7_ = w;
					_tmp8_ = main_window_get_documents (_tmp7_);
					_doc_list = _tmp8_;
					_tmp9_ = _doc_list;
					_tmp10_ = gee_collection_get_size ((GeeCollection*) _tmp9_);
					_tmp11_ = _tmp10_;
					_doc_size = _tmp11_;
					_doc_index = -1;
					while (TRUE) {
						Block6Data* _data6_;
						gint _tmp12_;
						gint _tmp13_;
						gint _tmp14_;
						GeeList* _tmp15_;
						gint _tmp16_;
						gpointer _tmp17_ = NULL;
						Document* doc;
						gboolean _tmp18_ = FALSE;
						Document* _tmp19_;
						GFile* _tmp20_;
						GFile* _tmp21_;
						gboolean _tmp27_;
						MainWindow* _tmp28_;
						GFile* _tmp35_;
						gboolean _tmp36_;
						DocumentTab* _tmp37_ = NULL;
						DocumentTab* _tmp38_;
						Document* _tmp39_;
						Document* _tmp40_;
						const gchar* _tmp41_ = NULL;
						GFile* _tmp42_;
						gchar* _tmp43_ = NULL;
						gchar* _tmp44_;
						gchar* _tmp45_ = NULL;
						gchar* _tmp46_;
						gchar* primary_msg;
						const gchar* _tmp47_ = NULL;
						gchar* _tmp48_;
						gchar* secondary_msg;
						DocumentTab* _tmp49_;
						const gchar* _tmp50_;
						const gchar* _tmp51_;
						TabInfoBar* _tmp52_ = NULL;
						GtkInfoBar* _tmp53_;
						const gchar* _tmp54_ = NULL;
						GtkInfoBar* _tmp55_;
						const gchar* _tmp56_ = NULL;
						GtkInfoBar* _tmp57_;
						DocumentTab* _tmp58_;
						DocumentTab* _tmp59_;
						_data6_ = g_slice_new0 (Block6Data);
						_data6_->_ref_count_ = 1;
						_data6_->self = g_object_ref (self);
						_tmp12_ = _doc_index;
						_doc_index = _tmp12_ + 1;
						_tmp13_ = _doc_index;
						_tmp14_ = _doc_size;
						if (!(_tmp13_ < _tmp14_)) {
							block6_data_unref (_data6_);
							_data6_ = NULL;
							break;
						}
						_tmp15_ = _doc_list;
						_tmp16_ = _doc_index;
						_tmp17_ = gee_list_get (_tmp15_, _tmp16_);
						doc = (Document*) _tmp17_;
						_tmp19_ = doc;
						_tmp20_ = document_get_location (_tmp19_);
						_tmp21_ = _tmp20_;
						if (_tmp21_ == NULL) {
							_tmp18_ = TRUE;
						} else {
							GFile* _tmp22_;
							Document* _tmp23_;
							GFile* _tmp24_;
							GFile* _tmp25_;
							gboolean _tmp26_ = FALSE;
							_tmp22_ = location;
							_tmp23_ = doc;
							_tmp24_ = document_get_location (_tmp23_);
							_tmp25_ = _tmp24_;
							_tmp26_ = g_file_equal (_tmp22_, _tmp25_);
							_tmp18_ = !_tmp26_;
						}
						_tmp27_ = _tmp18_;
						if (_tmp27_) {
							_g_object_unref0 (doc);
							block6_data_unref (_data6_);
							_data6_ = NULL;
							continue;
						}
						_tmp28_ = w;
						if (self == _tmp28_) {
							gboolean _tmp29_;
							Document* _tmp32_;
							DocumentTab* _tmp33_;
							DocumentTab* _tmp34_;
							_tmp29_ = jump_to;
							if (_tmp29_) {
								Document* _tmp30_;
								DocumentTab* _tmp31_;
								_tmp30_ = doc;
								_tmp31_ = _tmp30_->tab;
								main_window_set_active_tab (self, _tmp31_);
							}
							_tmp32_ = doc;
							_tmp33_ = _tmp32_->tab;
							_tmp34_ = _g_object_ref0 (_tmp33_);
							result = _tmp34_;
							_g_object_unref0 (doc);
							block6_data_unref (_data6_);
							_data6_ = NULL;
							_g_object_unref0 (_doc_list);
							_g_object_unref0 (w);
							_g_object_unref0 (window);
							return result;
						}
						_tmp35_ = location;
						_tmp36_ = jump_to;
						_tmp37_ = main_window_create_tab_from_location (self, _tmp35_, _tmp36_);
						_data6_->tab = _tmp37_;
						_tmp38_ = _data6_->tab;
						_tmp39_ = document_tab_get_document (_tmp38_);
						_tmp40_ = _tmp39_;
						document_set_readonly (_tmp40_, TRUE);
						_tmp41_ = _ ("This file (%s) is already opened in another LaTeXila window.");
						_tmp42_ = location;
						_tmp43_ = g_file_get_parse_name (_tmp42_);
						_tmp44_ = _tmp43_;
						_tmp45_ = g_strdup_printf (_tmp41_, _tmp44_);
						_tmp46_ = _tmp45_;
						_g_free0 (_tmp44_);
						primary_msg = _tmp46_;
						_tmp47_ = _ ("LaTeXila opened this instance of the file in a non-editable way. Do yo" \
"u want to edit it anyway?");
						_tmp48_ = g_strdup (_tmp47_);
						secondary_msg = _tmp48_;
						_tmp49_ = _data6_->tab;
						_tmp50_ = primary_msg;
						_tmp51_ = secondary_msg;
						_tmp52_ = document_tab_add_message (_tmp49_, _tmp50_, _tmp51_, GTK_MESSAGE_WARNING);
						_data6_->infobar = (GtkInfoBar*) _tmp52_;
						_tmp53_ = _data6_->infobar;
						_tmp54_ = _ ("Edit Anyway");
						gtk_info_bar_add_button (_tmp53_, _tmp54_, (gint) GTK_RESPONSE_YES);
						_tmp55_ = _data6_->infobar;
						_tmp56_ = _ ("Don't Edit");
						gtk_info_bar_add_button (_tmp55_, _tmp56_, (gint) GTK_RESPONSE_NO);
						_tmp57_ = _data6_->infobar;
						g_signal_connect_data (_tmp57_, "response", (GCallback) _______lambda68__gtk_info_bar_response, block6_data_ref (_data6_), (GClosureNotify) block6_data_unref, 0);
						_tmp58_ = _data6_->tab;
						_tmp59_ = _g_object_ref0 (_tmp58_);
						result = _tmp59_;
						_g_free0 (secondary_msg);
						_g_free0 (primary_msg);
						_g_object_unref0 (doc);
						block6_data_unref (_data6_);
						_data6_ = NULL;
						_g_object_unref0 (_doc_list);
						_g_object_unref0 (w);
						_g_object_unref0 (window);
						return result;
					}
					_g_object_unref0 (_doc_list);
				}
				_g_object_unref0 (w);
				_g_object_unref0 (window);
			}
		}
	}
	_tmp60_ = location;
	_tmp61_ = jump_to;
	_tmp62_ = main_window_create_tab_from_location (self, _tmp60_, _tmp61_);
	result = _tmp62_;
	return result;
}


DocumentTab* main_window_create_tab (MainWindow* self, gboolean jump_to) {
	DocumentTab* result = NULL;
	DocumentTab* _tmp0_;
	DocumentTab* tab;
	gboolean _tmp1_;
	DocumentTab* _tmp2_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = document_tab_new ();
	g_object_ref_sink (_tmp0_);
	tab = _tmp0_;
	_tmp1_ = jump_to;
	_tmp2_ = main_window_process_create_tab (self, tab, _tmp1_);
	result = _tmp2_;
	_g_object_unref0 (tab);
	return result;
}


DocumentTab* main_window_create_tab_from_location (MainWindow* self, GFile* location, gboolean jump_to) {
	DocumentTab* result = NULL;
	GFile* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentTab* tab;
	gboolean _tmp2_;
	DocumentTab* _tmp3_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (location != NULL, NULL);
	_tmp0_ = location;
	_tmp1_ = document_tab_new_from_location (_tmp0_);
	g_object_ref_sink (_tmp1_);
	tab = _tmp1_;
	_tmp2_ = jump_to;
	_tmp3_ = main_window_process_create_tab (self, tab, _tmp2_);
	result = _tmp3_;
	_g_object_unref0 (tab);
	return result;
}


void main_window_create_tab_with_view (MainWindow* self, DocumentView* view) {
	DocumentView* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentTab* tab;
	DocumentTab* _tmp2_ = NULL;
	DocumentTab* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (view != NULL);
	_tmp0_ = view;
	_tmp1_ = document_tab_new_with_view (_tmp0_);
	g_object_ref_sink (_tmp1_);
	tab = _tmp1_;
	_tmp2_ = main_window_process_create_tab (self, tab, TRUE);
	_tmp3_ = _tmp2_;
	_g_object_unref0 (_tmp3_);
	_g_object_unref0 (tab);
}


static Block7Data* block7_data_ref (Block7Data* _data7_) {
	g_atomic_int_inc (&_data7_->_ref_count_);
	return _data7_;
}


static void block7_data_unref (void * _userdata_) {
	Block7Data* _data7_;
	_data7_ = (Block7Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data7_->_ref_count_)) {
		MainWindow * self;
		self = _data7_->self;
		_g_object_unref0 (_data7_->tab);
		_g_object_unref0 (self);
		g_slice_free (Block7Data, _data7_);
	}
}


static void __lambda17_ (Block7Data* _data7_) {
	MainWindow * self;
	DocumentTab* _tmp0_;
	self = _data7_->self;
	_tmp0_ = _data7_->tab;
	main_window_close_tab (self, _tmp0_, FALSE);
}


static void ___lambda17__document_tab_close_document (DocumentTab* _sender, gpointer self) {
	__lambda17_ (self);
}


static void __lambda18_ (Block7Data* _data7_) {
	MainWindow * self;
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentTab* _tmp2_;
	self = _data7_->self;
	_tmp0_ = _data7_->tab;
	_tmp1_ = main_window_get_active_tab (self);
	_tmp2_ = _tmp1_;
	if (_tmp0_ != _tmp2_) {
		return;
	}
	main_window_set_undo_sensitivity (self);
}


static void ___lambda18__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) {
	__lambda18_ (self);
}


static void __lambda19_ (Block7Data* _data7_) {
	MainWindow * self;
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentTab* _tmp2_;
	self = _data7_->self;
	_tmp0_ = _data7_->tab;
	_tmp1_ = main_window_get_active_tab (self);
	_tmp2_ = _tmp1_;
	if (_tmp0_ != _tmp2_) {
		return;
	}
	main_window_set_redo_sensitivity (self);
}


static void ___lambda19__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) {
	__lambda19_ (self);
}


static void __lambda20_ (Block7Data* _data7_) {
	MainWindow * self;
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentTab* _tmp2_;
	self = _data7_->self;
	_tmp0_ = _data7_->tab;
	_tmp1_ = main_window_get_active_tab (self);
	_tmp2_ = _tmp1_;
	if (_tmp0_ != _tmp2_) {
		return;
	}
	main_window_selection_changed (self);
}


static void ___lambda20__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) {
	__lambda20_ (self);
}


static void __lambda21_ (Block7Data* _data7_) {
	MainWindow * self;
	DocumentTab* _tmp0_;
	MainWindowBuildTools* _tmp1_;
	self = _data7_->self;
	_tmp0_ = _data7_->tab;
	main_window_sync_name (self, _tmp0_);
	_tmp1_ = self->priv->_main_window_build_tools;
	main_window_build_tools_update_sensitivity (_tmp1_);
}


static void ___lambda21__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) {
	__lambda21_ (self);
}


static void __lambda65_ (MainWindow* self) {
	MainWindowBuildTools* _tmp0_;
	_tmp0_ = self->priv->_main_window_build_tools;
	main_window_build_tools_update_sensitivity (_tmp0_);
}


static void ___lambda65__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) {
	__lambda65_ (self);
}


static void __lambda66_ (Block7Data* _data7_) {
	MainWindow * self;
	DocumentTab* _tmp0_;
	self = _data7_->self;
	_tmp0_ = _data7_->tab;
	main_window_sync_name (self, _tmp0_);
}


static void ___lambda66__gtk_text_buffer_modified_changed (GtkTextBuffer* _sender, gpointer self) {
	__lambda66_ (self);
}


static void __lambda67_ (Block7Data* _data7_) {
	MainWindow * self;
	DocumentTab* _tmp0_;
	self = _data7_->self;
	_tmp0_ = _data7_->tab;
	main_window_sync_name (self, _tmp0_);
}


static void ___lambda67__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) {
	__lambda67_ (self);
}


static void _main_window_update_cursor_position_statusbar_document_cursor_moved (Document* _sender, gpointer self) {
	main_window_update_cursor_position_statusbar (self);
}


static DocumentTab* main_window_process_create_tab (MainWindow* self, DocumentTab* tab, gboolean jump_to) {
	DocumentTab* result = NULL;
	Block7Data* _data7_;
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentTab* _tmp2_;
	DocumentTab* _tmp3_;
	DocumentTab* _tmp4_;
	Document* _tmp5_;
	Document* _tmp6_;
	DocumentTab* _tmp7_;
	Document* _tmp8_;
	Document* _tmp9_;
	DocumentTab* _tmp10_;
	Document* _tmp11_;
	Document* _tmp12_;
	DocumentTab* _tmp13_;
	Document* _tmp14_;
	Document* _tmp15_;
	DocumentTab* _tmp16_;
	Document* _tmp17_;
	Document* _tmp18_;
	DocumentTab* _tmp19_;
	Document* _tmp20_;
	Document* _tmp21_;
	DocumentTab* _tmp22_;
	Document* _tmp23_;
	Document* _tmp24_;
	DocumentTab* _tmp25_;
	Document* _tmp26_;
	Document* _tmp27_;
	DocumentTab* _tmp28_;
	DocumentsPanel* _tmp29_;
	DocumentTab* _tmp30_;
	gboolean _tmp31_;
	gboolean _tmp32_ = FALSE;
	DocumentTab* _tmp33_;
	DocumentTab* _tmp34_;
	g_return_val_if_fail (self != NULL, NULL);
	_data7_ = g_slice_new0 (Block7Data);
	_data7_->_ref_count_ = 1;
	_data7_->self = g_object_ref (self);
	_tmp0_ = tab;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_data7_->tab = _tmp1_;
	_tmp2_ = _data7_->tab;
	if (_tmp2_ == NULL) {
		result = NULL;
		block7_data_unref (_data7_);
		_data7_ = NULL;
		return result;
	}
	_tmp3_ = _data7_->tab;
	g_signal_connect_data (_tmp3_, "close-document", (GCallback) ___lambda17__document_tab_close_document, block7_data_ref (_data7_), (GClosureNotify) block7_data_unref, 0);
	_tmp4_ = _data7_->tab;
	_tmp5_ = document_tab_get_document (_tmp4_);
	_tmp6_ = _tmp5_;
	g_signal_connect_data ((GObject*) _tmp6_, "notify::can-undo", (GCallback) ___lambda18__g_object_notify, block7_data_ref (_data7_), (GClosureNotify) block7_data_unref, 0);
	_tmp7_ = _data7_->tab;
	_tmp8_ = document_tab_get_document (_tmp7_);
	_tmp9_ = _tmp8_;
	g_signal_connect_data ((GObject*) _tmp9_, "notify::can-redo", (GCallback) ___lambda19__g_object_notify, block7_data_ref (_data7_), (GClosureNotify) block7_data_unref, 0);
	_tmp10_ = _data7_->tab;
	_tmp11_ = document_tab_get_document (_tmp10_);
	_tmp12_ = _tmp11_;
	g_signal_connect_data ((GObject*) _tmp12_, "notify::has-selection", (GCallback) ___lambda20__g_object_notify, block7_data_ref (_data7_), (GClosureNotify) block7_data_unref, 0);
	_tmp13_ = _data7_->tab;
	_tmp14_ = document_tab_get_document (_tmp13_);
	_tmp15_ = _tmp14_;
	g_signal_connect_data ((GObject*) _tmp15_, "notify::location", (GCallback) ___lambda21__g_object_notify, block7_data_ref (_data7_), (GClosureNotify) block7_data_unref, 0);
	_tmp16_ = _data7_->tab;
	_tmp17_ = document_tab_get_document (_tmp16_);
	_tmp18_ = _tmp17_;
	g_signal_connect_object ((GObject*) _tmp18_, "notify::project-id", (GCallback) ___lambda65__g_object_notify, self, 0);
	_tmp19_ = _data7_->tab;
	_tmp20_ = document_tab_get_document (_tmp19_);
	_tmp21_ = _tmp20_;
	g_signal_connect_data ((GtkTextBuffer*) _tmp21_, "modified-changed", (GCallback) ___lambda66__gtk_text_buffer_modified_changed, block7_data_ref (_data7_), (GClosureNotify) block7_data_unref, 0);
	_tmp22_ = _data7_->tab;
	_tmp23_ = document_tab_get_document (_tmp22_);
	_tmp24_ = _tmp23_;
	g_signal_connect_data ((GObject*) _tmp24_, "notify::readonly", (GCallback) ___lambda67__g_object_notify, block7_data_ref (_data7_), (GClosureNotify) block7_data_unref, 0);
	_tmp25_ = _data7_->tab;
	_tmp26_ = document_tab_get_document (_tmp25_);
	_tmp27_ = _tmp26_;
	g_signal_connect_object (_tmp27_, "cursor-moved", (GCallback) _main_window_update_cursor_position_statusbar_document_cursor_moved, self, 0);
	_tmp28_ = _data7_->tab;
	gtk_widget_show ((GtkWidget*) _tmp28_);
	_tmp29_ = self->priv->documents_panel;
	_tmp30_ = _data7_->tab;
	_tmp31_ = jump_to;
	documents_panel_add_tab (_tmp29_, _tmp30_, -1, _tmp31_);
	main_window_set_undo_sensitivity (self);
	main_window_set_redo_sensitivity (self);
	main_window_selection_changed (self);
	_tmp32_ = gtk_widget_get_visible ((GtkWidget*) self);
	if (!_tmp32_) {
		gtk_window_present ((GtkWindow*) self);
	}
	_tmp33_ = _data7_->tab;
	_tmp34_ = _g_object_ref0 (_tmp33_);
	result = _tmp34_;
	block7_data_unref (_data7_);
	_data7_ = NULL;
	return result;
}


gboolean main_window_close_tab (MainWindow* self, DocumentTab* tab, gboolean force_close) {
	gboolean result = FALSE;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_;
	gboolean _tmp6_;
	DocumentsPanel* _tmp31_;
	DocumentTab* _tmp32_;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (tab != NULL, FALSE);
	_tmp1_ = force_close;
	if (!_tmp1_) {
		DocumentTab* _tmp2_;
		Document* _tmp3_;
		Document* _tmp4_;
		gboolean _tmp5_ = FALSE;
		_tmp2_ = tab;
		_tmp3_ = document_tab_get_document (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp5_ = document_get_modified (_tmp4_);
		_tmp0_ = _tmp5_;
	} else {
		_tmp0_ = FALSE;
	}
	_tmp6_ = _tmp0_;
	if (_tmp6_) {
		const gchar* _tmp7_ = NULL;
		DocumentTab* _tmp8_;
		const gchar* _tmp9_;
		const gchar* _tmp10_;
		GtkMessageDialog* _tmp11_;
		GtkDialog* dialog;
		GtkDialog* _tmp12_;
		const gchar* _tmp13_ = NULL;
		DocumentTab* _tmp14_;
		Document* _tmp15_;
		Document* _tmp16_;
		GFile* _tmp17_;
		GFile* _tmp18_;
		GtkDialog* _tmp30_;
		_tmp7_ = _ ("Save changes to document \"%s\" before closing?");
		_tmp8_ = tab;
		_tmp9_ = document_tab_get_label_text (_tmp8_);
		_tmp10_ = _tmp9_;
		_tmp11_ = (GtkMessageDialog*) gtk_message_dialog_new ((GtkWindow*) self, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, _tmp7_, _tmp10_);
		g_object_ref_sink (_tmp11_);
		dialog = (GtkDialog*) _tmp11_;
		_tmp12_ = dialog;
		_tmp13_ = _ ("Close without Saving");
		gtk_dialog_add_buttons (_tmp12_, _tmp13_, GTK_RESPONSE_CLOSE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
		_tmp14_ = tab;
		_tmp15_ = document_tab_get_document (_tmp14_);
		_tmp16_ = _tmp15_;
		_tmp17_ = document_get_location (_tmp16_);
		_tmp18_ = _tmp17_;
		if (_tmp18_ == NULL) {
			GtkDialog* _tmp19_;
			_tmp19_ = dialog;
			gtk_dialog_add_button (_tmp19_, GTK_STOCK_SAVE_AS, (gint) GTK_RESPONSE_ACCEPT);
		} else {
			GtkDialog* _tmp20_;
			_tmp20_ = dialog;
			gtk_dialog_add_button (_tmp20_, GTK_STOCK_SAVE, (gint) GTK_RESPONSE_ACCEPT);
		}
		while (TRUE) {
			GtkDialog* _tmp21_;
			gint _tmp22_ = 0;
			gint res;
			gint _tmp23_;
			_tmp21_ = dialog;
			_tmp22_ = gtk_dialog_run (_tmp21_);
			res = _tmp22_;
			_tmp23_ = res;
			if (_tmp23_ == ((gint) GTK_RESPONSE_CLOSE)) {
				break;
			} else {
				gint _tmp24_;
				_tmp24_ = res;
				if (_tmp24_ == ((gint) GTK_RESPONSE_ACCEPT)) {
					DocumentTab* _tmp25_;
					Document* _tmp26_;
					Document* _tmp27_;
					gboolean _tmp28_ = FALSE;
					_tmp25_ = tab;
					_tmp26_ = document_tab_get_document (_tmp25_);
					_tmp27_ = _tmp26_;
					_tmp28_ = main_window_save_document (self, _tmp27_, FALSE);
					if (_tmp28_) {
						break;
					}
					continue;
				} else {
					GtkDialog* _tmp29_;
					_tmp29_ = dialog;
					gtk_widget_destroy ((GtkWidget*) _tmp29_);
					result = FALSE;
					_g_object_unref0 (dialog);
					return result;
				}
			}
		}
		_tmp30_ = dialog;
		gtk_widget_destroy ((GtkWidget*) _tmp30_);
		_g_object_unref0 (dialog);
	}
	_tmp31_ = self->priv->documents_panel;
	_tmp32_ = tab;
	documents_panel_remove_tab (_tmp31_, _tmp32_);
	result = TRUE;
	return result;
}


DocumentTab* main_window_get_tab_from_location (MainWindow* self, GFile* location) {
	DocumentTab* result = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (location != NULL, NULL);
	{
		GeeList* _tmp0_ = NULL;
		GeeList* _doc_list;
		GeeList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _doc_size;
		gint _doc_index;
		_tmp0_ = main_window_get_documents (self);
		_doc_list = _tmp0_;
		_tmp1_ = _doc_list;
		_tmp2_ = gee_collection_get_size ((GeeCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_doc_size = _tmp3_;
		_doc_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			gint _tmp6_;
			GeeList* _tmp7_;
			gint _tmp8_;
			gpointer _tmp9_ = NULL;
			Document* doc;
			GFile* _tmp10_;
			Document* _tmp11_;
			GFile* _tmp12_;
			GFile* _tmp13_;
			gboolean _tmp14_ = FALSE;
			_tmp4_ = _doc_index;
			_doc_index = _tmp4_ + 1;
			_tmp5_ = _doc_index;
			_tmp6_ = _doc_size;
			if (!(_tmp5_ < _tmp6_)) {
				break;
			}
			_tmp7_ = _doc_list;
			_tmp8_ = _doc_index;
			_tmp9_ = gee_list_get (_tmp7_, _tmp8_);
			doc = (Document*) _tmp9_;
			_tmp10_ = location;
			_tmp11_ = doc;
			_tmp12_ = document_get_location (_tmp11_);
			_tmp13_ = _tmp12_;
			_tmp14_ = g_file_equal (_tmp10_, _tmp13_);
			if (_tmp14_) {
				Document* _tmp15_;
				DocumentTab* _tmp16_;
				DocumentTab* _tmp17_;
				_tmp15_ = doc;
				_tmp16_ = _tmp15_->tab;
				_tmp17_ = _g_object_ref0 (_tmp16_);
				result = _tmp17_;
				_g_object_unref0 (doc);
				_g_object_unref0 (_doc_list);
				return result;
			}
			_g_object_unref0 (doc);
		}
		_g_object_unref0 (_doc_list);
	}
	result = NULL;
	return result;
}


static gchar* string_replace (const gchar* self, const gchar* old, const gchar* replacement) {
	gchar* result = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	{
		const gchar* _tmp0_;
		gchar* _tmp1_ = NULL;
		gchar* _tmp2_;
		GRegex* _tmp3_;
		GRegex* _tmp4_;
		GRegex* regex;
		GRegex* _tmp5_;
		const gchar* _tmp6_;
		gchar* _tmp7_ = NULL;
		gchar* _tmp8_;
		_tmp0_ = old;
		_tmp1_ = g_regex_escape_string (_tmp0_, -1);
		_tmp2_ = _tmp1_;
		_tmp3_ = g_regex_new (_tmp2_, 0, 0, &_inner_error_);
		_tmp4_ = _tmp3_;
		_g_free0 (_tmp2_);
		regex = _tmp4_;
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == G_REGEX_ERROR) {
				goto __catch16_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return NULL;
		}
		_tmp5_ = regex;
		_tmp6_ = replacement;
		_tmp7_ = g_regex_replace_literal (_tmp5_, self, (gssize) (-1), 0, _tmp6_, 0, &_inner_error_);
		_tmp8_ = _tmp7_;
		if (_inner_error_ != NULL) {
			_g_regex_unref0 (regex);
			if (_inner_error_->domain == G_REGEX_ERROR) {
				goto __catch16_g_regex_error;
			}
			_g_regex_unref0 (regex);
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return NULL;
		}
		result = _tmp8_;
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally16;
	__catch16_g_regex_error:
	{
		GError* e = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		g_assert_not_reached ();
		_g_error_free0 (e);
	}
	__finally16:
	if (_inner_error_ != NULL) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return NULL;
	}
}


static void main_window_sync_name (MainWindow* self, DocumentTab* tab) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentTab* _tmp2_;
	DocumentsPanel* _tmp3_;
	DocumentTab* _tmp4_;
	gint _tmp5_ = 0;
	gint page_num;
	gchar* _tmp6_ = NULL;
	gchar* _tmp7_;
	gchar* _tmp8_ = NULL;
	gchar* _tmp9_;
	gchar* action_name;
	GtkActionGroup* _tmp10_;
	GtkAction* _tmp11_ = NULL;
	GtkAction* _tmp12_;
	GtkAction* action;
	DocumentTab* _tmp13_;
	gchar* _tmp14_ = NULL;
	gchar* _tmp15_;
	gchar* _tmp16_ = NULL;
	gchar* _tmp17_;
	DocumentTab* _tmp18_;
	gchar* _tmp19_ = NULL;
	gchar* _tmp20_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (tab != NULL);
	_tmp0_ = tab;
	_tmp1_ = main_window_get_active_tab (self);
	_tmp2_ = _tmp1_;
	if (_tmp0_ == _tmp2_) {
		main_window_my_set_title (self);
	}
	_tmp3_ = self->priv->documents_panel;
	_tmp4_ = tab;
	_tmp5_ = gtk_notebook_page_num ((GtkNotebook*) _tmp3_, (GtkWidget*) _tmp4_);
	page_num = _tmp5_;
	_tmp6_ = g_strdup_printf ("%i", page_num);
	_tmp7_ = _tmp6_;
	_tmp8_ = g_strconcat ("Tab_", _tmp7_, NULL);
	_tmp9_ = _tmp8_;
	_g_free0 (_tmp7_);
	action_name = _tmp9_;
	_tmp10_ = self->priv->documents_list_action_group;
	_tmp11_ = gtk_action_group_get_action (_tmp10_, action_name);
	_tmp12_ = _g_object_ref0 (_tmp11_);
	action = _tmp12_;
	g_return_if_fail (action != NULL);
	_tmp13_ = tab;
	_tmp14_ = document_tab_get_name (_tmp13_);
	_tmp15_ = _tmp14_;
	_tmp16_ = string_replace (_tmp15_, "_", "__");
	_tmp17_ = _tmp16_;
	gtk_action_set_label (action, _tmp17_);
	_g_free0 (_tmp17_);
	_g_free0 (_tmp15_);
	_tmp18_ = tab;
	_tmp19_ = document_tab_get_menu_tip (_tmp18_);
	_tmp20_ = _tmp19_;
	gtk_action_set_tooltip (action, _tmp20_);
	_g_free0 (_tmp20_);
	_g_object_unref0 (action);
	_g_free0 (action_name);
}


static void main_window_my_set_title (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	guint max_title_length;
	gchar* title;
	gchar* dirname;
	Document* _tmp2_;
	Document* _tmp3_;
	GFile* _tmp4_;
	GFile* _tmp5_;
	GFile* _tmp6_;
	GFile* loc;
	GFile* _tmp7_;
	const gchar* _tmp31_ = NULL;
	Document* _tmp32_;
	Document* _tmp33_;
	gboolean _tmp34_ = FALSE;
	gchar* _tmp35_ = NULL;
	Document* _tmp36_;
	Document* _tmp37_;
	gboolean _tmp38_;
	gboolean _tmp39_;
	gchar* _tmp45_ = NULL;
	const gchar* _tmp46_;
	const gchar* _tmp52_;
	const gchar* _tmp53_;
	gchar* _tmp54_;
	gchar* _tmp55_;
	const gchar* _tmp56_;
	gchar* _tmp57_;
	gchar* _tmp58_;
	const gchar* _tmp59_;
	gchar* _tmp60_;
	gchar* _tmp61_;
	gchar* _tmp62_;
	gchar* _tmp63_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	if (_tmp1_ == NULL) {
		gtk_window_set_title ((GtkWindow*) self, "LaTeXila");
		return;
	}
	max_title_length = (guint) 100;
	title = NULL;
	dirname = NULL;
	_tmp2_ = main_window_get_active_document (self);
	_tmp3_ = _tmp2_;
	_tmp4_ = document_get_location (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = _g_object_ref0 (_tmp5_);
	loc = _tmp6_;
	_tmp7_ = loc;
	if (_tmp7_ == NULL) {
		Document* _tmp8_;
		Document* _tmp9_;
		gchar* _tmp10_ = NULL;
		_tmp8_ = main_window_get_active_document (self);
		_tmp9_ = _tmp8_;
		_tmp10_ = document_get_short_name_for_display (_tmp9_);
		_g_free0 (title);
		title = _tmp10_;
	} else {
		GFile* _tmp11_;
		gchar* _tmp12_ = NULL;
		gchar* basename;
		const gchar* _tmp13_;
		gint _tmp14_;
		gint _tmp15_;
		guint _tmp16_;
		_tmp11_ = loc;
		_tmp12_ = g_file_get_basename (_tmp11_);
		basename = _tmp12_;
		_tmp13_ = basename;
		_tmp14_ = strlen (_tmp13_);
		_tmp15_ = _tmp14_;
		_tmp16_ = max_title_length;
		if (((guint) _tmp15_) > _tmp16_) {
			const gchar* _tmp17_;
			guint _tmp18_;
			gchar* _tmp19_ = NULL;
			_tmp17_ = basename;
			_tmp18_ = max_title_length;
			_tmp19_ = utils_str_middle_truncate (_tmp17_, _tmp18_);
			_g_free0 (title);
			title = _tmp19_;
		} else {
			const gchar* _tmp20_;
			gchar* _tmp21_;
			GFile* _tmp22_;
			gchar* _tmp23_ = NULL;
			gchar* _tmp24_;
			guint _tmp25_;
			const gchar* _tmp26_;
			gint _tmp27_;
			gint _tmp28_;
			glong _tmp29_ = 0L;
			gchar* _tmp30_ = NULL;
			_tmp20_ = basename;
			_tmp21_ = g_strdup (_tmp20_);
			_g_free0 (title);
			title = _tmp21_;
			_tmp22_ = loc;
			_tmp23_ = utils_get_dirname_for_display (_tmp22_);
			_tmp24_ = _tmp23_;
			_tmp25_ = max_title_length;
			_tmp26_ = basename;
			_tmp27_ = strlen (_tmp26_);
			_tmp28_ = _tmp27_;
			_tmp29_ = MAX ((glong) 20, (glong) (_tmp25_ - _tmp28_));
			_tmp30_ = utils_str_middle_truncate (_tmp24_, (guint) _tmp29_);
			_g_free0 (dirname);
			dirname = _tmp30_;
			_g_free0 (_tmp24_);
		}
		_g_free0 (basename);
	}
	_tmp32_ = main_window_get_active_document (self);
	_tmp33_ = _tmp32_;
	_tmp34_ = document_get_modified (_tmp33_);
	if (_tmp34_) {
		_tmp31_ = "*";
	} else {
		_tmp31_ = "";
	}
	_tmp36_ = main_window_get_active_document (self);
	_tmp37_ = _tmp36_;
	_tmp38_ = document_get_readonly (_tmp37_);
	_tmp39_ = _tmp38_;
	if (_tmp39_) {
		const gchar* _tmp40_ = NULL;
		gchar* _tmp41_;
		gchar* _tmp42_;
		gchar* _tmp43_;
		_tmp40_ = _ ("Read-Only");
		_tmp41_ = g_strconcat (" [", _tmp40_, NULL);
		_tmp42_ = _tmp41_;
		_tmp43_ = g_strconcat (_tmp42_, "]", NULL);
		_g_free0 (_tmp35_);
		_tmp35_ = _tmp43_;
		_g_free0 (_tmp42_);
	} else {
		gchar* _tmp44_;
		_tmp44_ = g_strdup ("");
		_g_free0 (_tmp35_);
		_tmp35_ = _tmp44_;
	}
	_tmp46_ = dirname;
	if (_tmp46_ != NULL) {
		const gchar* _tmp47_;
		gchar* _tmp48_;
		gchar* _tmp49_;
		gchar* _tmp50_;
		_tmp47_ = dirname;
		_tmp48_ = g_strconcat (" (", _tmp47_, NULL);
		_tmp49_ = _tmp48_;
		_tmp50_ = g_strconcat (_tmp49_, ")", NULL);
		_g_free0 (_tmp45_);
		_tmp45_ = _tmp50_;
		_g_free0 (_tmp49_);
	} else {
		gchar* _tmp51_;
		_tmp51_ = g_strdup ("");
		_g_free0 (_tmp45_);
		_tmp45_ = _tmp51_;
	}
	_tmp52_ = _tmp31_;
	_tmp53_ = title;
	_tmp54_ = g_strconcat (_tmp52_, _tmp53_, NULL);
	_tmp55_ = _tmp54_;
	_tmp56_ = _tmp35_;
	_tmp57_ = g_strconcat (_tmp55_, _tmp56_, NULL);
	_tmp58_ = _tmp57_;
	_tmp59_ = _tmp45_;
	_tmp60_ = g_strconcat (_tmp58_, _tmp59_, NULL);
	_tmp61_ = _tmp60_;
	_tmp62_ = g_strconcat (_tmp61_, " - LaTeXila", NULL);
	_tmp63_ = _tmp62_;
	gtk_window_set_title ((GtkWindow*) self, _tmp63_);
	_g_free0 (_tmp63_);
	_g_free0 (_tmp61_);
	_g_free0 (_tmp58_);
	_g_free0 (_tmp55_);
	_g_free0 (_tmp45_);
	_g_free0 (_tmp35_);
	_g_object_unref0 (loc);
	_g_free0 (dirname);
	_g_free0 (title);
}


gboolean main_window_save_document (MainWindow* self, Document* doc, gboolean force_save_as) {
	gboolean result = FALSE;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_;
	gboolean _tmp5_;
	const gchar* _tmp7_ = NULL;
	GtkFileChooserDialog* _tmp8_;
	GtkFileChooserDialog* file_chooser;
	Document* _tmp9_;
	GFile* _tmp10_;
	GFile* _tmp11_;
	const gchar* _tmp24_;
	Document* _tmp27_;
	GFile* _tmp28_;
	GFile* _tmp29_;
	GtkFileChooserDialog* _tmp62_;
	gchar* _tmp63_ = NULL;
	GtkFileChooserDialog* _tmp64_;
	Document* _tmp65_;
	GFile* _tmp66_;
	GFile* _tmp67_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (doc != NULL, FALSE);
	_tmp1_ = force_save_as;
	if (!_tmp1_) {
		Document* _tmp2_;
		GFile* _tmp3_;
		GFile* _tmp4_;
		_tmp2_ = doc;
		_tmp3_ = document_get_location (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_ != NULL;
	} else {
		_tmp0_ = FALSE;
	}
	_tmp5_ = _tmp0_;
	if (_tmp5_) {
		Document* _tmp6_;
		_tmp6_ = doc;
		document_save (_tmp6_, TRUE, FALSE);
		result = TRUE;
		return result;
	}
	_tmp7_ = _ ("Save File");
	_tmp8_ = (GtkFileChooserDialog*) gtk_file_chooser_dialog_new (_tmp7_, (GtkWindow*) self, GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL, NULL);
	g_object_ref_sink (_tmp8_);
	file_chooser = _tmp8_;
	_tmp9_ = doc;
	_tmp10_ = document_get_location (_tmp9_);
	_tmp11_ = _tmp10_;
	if (_tmp11_ == NULL) {
		GtkFileChooserDialog* _tmp12_;
		Document* _tmp13_;
		DocumentTab* _tmp14_;
		const gchar* _tmp15_;
		const gchar* _tmp16_;
		gchar* _tmp17_;
		gchar* _tmp18_;
		_tmp12_ = file_chooser;
		_tmp13_ = doc;
		_tmp14_ = _tmp13_->tab;
		_tmp15_ = document_tab_get_label_text (_tmp14_);
		_tmp16_ = _tmp15_;
		_tmp17_ = g_strconcat (_tmp16_, ".tex", NULL);
		_tmp18_ = _tmp17_;
		gtk_file_chooser_set_current_name ((GtkFileChooser*) _tmp12_, _tmp18_);
		_g_free0 (_tmp18_);
	} else {
		GtkFileChooserDialog* _tmp19_;
		Document* _tmp20_;
		DocumentTab* _tmp21_;
		const gchar* _tmp22_;
		const gchar* _tmp23_;
		_tmp19_ = file_chooser;
		_tmp20_ = doc;
		_tmp21_ = _tmp20_->tab;
		_tmp22_ = document_tab_get_label_text (_tmp21_);
		_tmp23_ = _tmp22_;
		gtk_file_chooser_set_current_name ((GtkFileChooser*) _tmp19_, _tmp23_);
	}
	_tmp24_ = self->priv->file_chooser_current_folder;
	if (_tmp24_ != NULL) {
		GtkFileChooserDialog* _tmp25_;
		const gchar* _tmp26_;
		_tmp25_ = file_chooser;
		_tmp26_ = self->priv->file_chooser_current_folder;
		gtk_file_chooser_set_current_folder ((GtkFileChooser*) _tmp25_, _tmp26_);
	}
	_tmp27_ = doc;
	_tmp28_ = document_get_location (_tmp27_);
	_tmp29_ = _tmp28_;
	if (_tmp29_ != NULL) {
		{
			GtkFileChooserDialog* _tmp30_;
			Document* _tmp31_;
			GFile* _tmp32_;
			GFile* _tmp33_;
			_tmp30_ = file_chooser;
			_tmp31_ = doc;
			_tmp32_ = document_get_location (_tmp31_);
			_tmp33_ = _tmp32_;
			gtk_file_chooser_set_file ((GtkFileChooser*) _tmp30_, _tmp33_, &_inner_error_);
			if (_inner_error_ != NULL) {
				goto __catch17_g_error;
			}
		}
		goto __finally17;
		__catch17_g_error:
		{
			GError* e = NULL;
			e = _inner_error_;
			_inner_error_ = NULL;
			_g_error_free0 (e);
		}
		__finally17:
		if (_inner_error_ != NULL) {
			_g_object_unref0 (file_chooser);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return FALSE;
		}
	}
	while (TRUE) {
		GtkFileChooserDialog* _tmp34_;
		gint _tmp35_ = 0;
		GtkFileChooserDialog* _tmp36_;
		GFile* _tmp37_ = NULL;
		GFile* _tmp38_;
		GFile* file;
		GFile* _tmp39_;
		gboolean _tmp40_ = FALSE;
		Document* _tmp60_;
		GFile* _tmp61_;
		_tmp34_ = file_chooser;
		_tmp35_ = gtk_dialog_run ((GtkDialog*) _tmp34_);
		if (!(_tmp35_ == ((gint) GTK_RESPONSE_ACCEPT))) {
			break;
		}
		_tmp36_ = file_chooser;
		_tmp37_ = gtk_file_chooser_get_file ((GtkFileChooser*) _tmp36_);
		_tmp38_ = _g_object_ref0 (_tmp37_);
		file = _tmp38_;
		_tmp39_ = file;
		_tmp40_ = g_file_query_exists (_tmp39_, NULL);
		if (_tmp40_) {
			const gchar* _tmp41_ = NULL;
			GFile* _tmp42_;
			gchar* _tmp43_ = NULL;
			gchar* _tmp44_;
			GtkMessageDialog* _tmp45_;
			GtkMessageDialog* _tmp46_;
			GtkMessageDialog* confirmation;
			GtkMessageDialog* _tmp47_;
			const gchar* _tmp48_ = NULL;
			GtkButton* _tmp49_;
			GtkButton* button_replace;
			GtkImage* _tmp50_;
			GtkImage* icon;
			GtkButton* _tmp51_;
			GtkImage* _tmp52_;
			GtkMessageDialog* _tmp53_;
			GtkButton* _tmp54_;
			GtkButton* _tmp55_;
			GtkMessageDialog* _tmp56_;
			gint _tmp57_ = 0;
			gint response;
			GtkMessageDialog* _tmp58_;
			gint _tmp59_;
			_tmp41_ = _ ("A file named \"%s\" already exists. Do you want to replace it?");
			_tmp42_ = file;
			_tmp43_ = g_file_get_basename (_tmp42_);
			_tmp44_ = _tmp43_;
			_tmp45_ = (GtkMessageDialog*) gtk_message_dialog_new ((GtkWindow*) self, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, _tmp41_, _tmp44_);
			g_object_ref_sink (_tmp45_);
			_tmp46_ = _tmp45_;
			_g_free0 (_tmp44_);
			confirmation = _tmp46_;
			_tmp47_ = confirmation;
			gtk_dialog_add_button ((GtkDialog*) _tmp47_, GTK_STOCK_CANCEL, (gint) GTK_RESPONSE_CANCEL);
			_tmp48_ = _ ("Replace");
			_tmp49_ = (GtkButton*) gtk_button_new_with_label (_tmp48_);
			g_object_ref_sink (_tmp49_);
			button_replace = _tmp49_;
			_tmp50_ = (GtkImage*) gtk_image_new_from_stock (GTK_STOCK_SAVE_AS, GTK_ICON_SIZE_BUTTON);
			g_object_ref_sink (_tmp50_);
			icon = _tmp50_;
			_tmp51_ = button_replace;
			_tmp52_ = icon;
			gtk_button_set_image (_tmp51_, (GtkWidget*) _tmp52_);
			_tmp53_ = confirmation;
			_tmp54_ = button_replace;
			gtk_dialog_add_action_widget ((GtkDialog*) _tmp53_, (GtkWidget*) _tmp54_, (gint) GTK_RESPONSE_YES);
			_tmp55_ = button_replace;
			gtk_widget_show ((GtkWidget*) _tmp55_);
			_tmp56_ = confirmation;
			_tmp57_ = gtk_dialog_run ((GtkDialog*) _tmp56_);
			response = _tmp57_;
			_tmp58_ = confirmation;
			gtk_widget_destroy ((GtkWidget*) _tmp58_);
			_tmp59_ = response;
			if (_tmp59_ != ((gint) GTK_RESPONSE_YES)) {
				_g_object_unref0 (icon);
				_g_object_unref0 (button_replace);
				_g_object_unref0 (confirmation);
				_g_object_unref0 (file);
				continue;
			}
			_g_object_unref0 (icon);
			_g_object_unref0 (button_replace);
			_g_object_unref0 (confirmation);
		}
		_tmp60_ = doc;
		_tmp61_ = file;
		document_set_location (_tmp60_, _tmp61_);
		_g_object_unref0 (file);
		break;
	}
	_tmp62_ = file_chooser;
	_tmp63_ = gtk_file_chooser_get_current_folder ((GtkFileChooser*) _tmp62_);
	_g_free0 (self->priv->file_chooser_current_folder);
	self->priv->file_chooser_current_folder = _tmp63_;
	_tmp64_ = file_chooser;
	gtk_widget_destroy ((GtkWidget*) _tmp64_);
	_tmp65_ = doc;
	_tmp66_ = document_get_location (_tmp65_);
	_tmp67_ = _tmp66_;
	if (_tmp67_ != NULL) {
		Document* _tmp68_;
		_tmp68_ = doc;
		document_save (_tmp68_, FALSE, TRUE);
		result = TRUE;
		_g_object_unref0 (file_chooser);
		return result;
	}
	result = FALSE;
	_g_object_unref0 (file_chooser);
	return result;
}


static gboolean main_window_close_all_documents (MainWindow* self) {
	gboolean result = FALSE;
	GeeList* _tmp0_ = NULL;
	GeeList* unsaved_documents;
	GeeList* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = main_window_get_unsaved_documents (self);
	unsaved_documents = _tmp0_;
	_tmp1_ = unsaved_documents;
	_tmp2_ = gee_collection_get_size ((GeeCollection*) _tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_ == 0) {
		DocumentsPanel* _tmp4_;
		_tmp4_ = self->priv->documents_panel;
		documents_panel_remove_all_tabs (_tmp4_);
		result = TRUE;
		_g_object_unref0 (unsaved_documents);
		return result;
	} else {
		GeeList* _tmp5_;
		gint _tmp6_;
		gint _tmp7_;
		_tmp5_ = unsaved_documents;
		_tmp6_ = gee_collection_get_size ((GeeCollection*) _tmp5_);
		_tmp7_ = _tmp6_;
		if (_tmp7_ == 1) {
			GeeList* _tmp8_;
			gpointer _tmp9_ = NULL;
			Document* doc;
			Document* _tmp10_;
			DocumentTab* _tmp11_;
			Document* _tmp12_;
			DocumentTab* _tmp13_;
			gboolean _tmp14_ = FALSE;
			_tmp8_ = unsaved_documents;
			_tmp9_ = gee_list_first (_tmp8_);
			doc = (Document*) _tmp9_;
			_tmp10_ = doc;
			_tmp11_ = _tmp10_->tab;
			main_window_set_active_tab (self, _tmp11_);
			_tmp12_ = doc;
			_tmp13_ = _tmp12_->tab;
			_tmp14_ = main_window_close_tab (self, _tmp13_, FALSE);
			if (_tmp14_) {
				DocumentsPanel* _tmp15_;
				_tmp15_ = self->priv->documents_panel;
				documents_panel_remove_all_tabs (_tmp15_);
				result = TRUE;
				_g_object_unref0 (doc);
				_g_object_unref0 (unsaved_documents);
				return result;
			}
			_g_object_unref0 (doc);
		} else {
			GeeList* _tmp16_;
			DocumentsPanel* _tmp17_;
			gint _tmp18_ = 0;
			_tmp16_ = unsaved_documents;
			dialogs_close_several_unsaved_documents (self, _tmp16_);
			_tmp17_ = self->priv->documents_panel;
			_tmp18_ = gtk_notebook_get_n_pages ((GtkNotebook*) _tmp17_);
			if (_tmp18_ == 0) {
				result = TRUE;
				_g_object_unref0 (unsaved_documents);
				return result;
			}
		}
	}
	result = FALSE;
	_g_object_unref0 (unsaved_documents);
	return result;
}


void main_window_remove_all_tabs (MainWindow* self) {
	DocumentsPanel* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->documents_panel;
	documents_panel_remove_all_tabs (_tmp0_);
}


static void main_window_update_cursor_position_statusbar (MainWindow* self) {
	GtkTextIter iter = {0};
	Document* _tmp0_;
	Document* _tmp1_;
	Document* _tmp2_;
	Document* _tmp3_;
	GtkTextMark* _tmp4_ = NULL;
	GtkTextIter _tmp5_ = {0};
	gint _tmp6_ = 0;
	gint row;
	DocumentView* _tmp7_;
	DocumentView* _tmp8_;
	GtkTextIter _tmp9_;
	guint _tmp10_ = 0U;
	gint col;
	CustomStatusbar* _tmp11_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_document (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = main_window_get_active_document (self);
	_tmp3_ = _tmp2_;
	_tmp4_ = gtk_text_buffer_get_insert ((GtkTextBuffer*) _tmp3_);
	gtk_text_buffer_get_iter_at_mark ((GtkTextBuffer*) _tmp1_, &_tmp5_, _tmp4_);
	iter = _tmp5_;
	_tmp6_ = gtk_text_iter_get_line (&iter);
	row = (gint) _tmp6_;
	_tmp7_ = main_window_get_active_view (self);
	_tmp8_ = _tmp7_;
	_tmp9_ = iter;
	_tmp10_ = gtk_source_view_get_visual_column ((GtkSourceView*) _tmp8_, &_tmp9_);
	col = (gint) _tmp10_;
	_tmp11_ = self->priv->statusbar;
	custom_statusbar_set_cursor_position (_tmp11_, row + 1, col + 1);
}


static void main_window_setup_toolbar_open_button (MainWindow* self, GtkToolbar* toolbar) {
	GtkRecentManager* _tmp0_ = NULL;
	GtkRecentManager* _tmp1_;
	GtkRecentManager* recent_manager;
	GtkRecentChooserMenu* _tmp2_;
	GtkWidget* toolbar_recent_menu;
	GtkMenuToolButton* _tmp3_;
	GtkMenuToolButton* open_button;
	const gchar* _tmp4_ = NULL;
	const gchar* _tmp5_ = NULL;
	GtkActionGroup* _tmp6_;
	GtkAction* _tmp7_ = NULL;
	GtkAction* _tmp8_;
	GtkAction* action;
	GtkToolbar* _tmp9_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (toolbar != NULL);
	_tmp0_ = gtk_recent_manager_get_default ();
	_tmp1_ = _g_object_ref0 (_tmp0_);
	recent_manager = _tmp1_;
	_tmp2_ = (GtkRecentChooserMenu*) gtk_recent_chooser_menu_new_for_manager (recent_manager);
	g_object_ref_sink (_tmp2_);
	toolbar_recent_menu = (GtkWidget*) _tmp2_;
	main_window_configure_recent_chooser (self, G_TYPE_CHECK_INSTANCE_CAST (toolbar_recent_menu, GTK_TYPE_RECENT_CHOOSER, GtkRecentChooser));
	_tmp3_ = (GtkMenuToolButton*) gtk_menu_tool_button_new_from_stock (GTK_STOCK_OPEN);
	g_object_ref_sink (_tmp3_);
	open_button = _tmp3_;
	gtk_menu_tool_button_set_menu (open_button, toolbar_recent_menu);
	_tmp4_ = _ ("Open a file");
	gtk_tool_item_set_tooltip_text ((GtkToolItem*) open_button, _tmp4_);
	_tmp5_ = _ ("Open a recently used file");
	gtk_menu_tool_button_set_arrow_tooltip_text (open_button, _tmp5_);
	_tmp6_ = self->priv->action_group;
	_tmp7_ = gtk_action_group_get_action (_tmp6_, "FileOpen");
	_tmp8_ = _g_object_ref0 (_tmp7_);
	action = _tmp8_;
	gtk_activatable_set_related_action ((GtkActivatable*) open_button, action);
	_tmp9_ = toolbar;
	gtk_toolbar_insert (_tmp9_, (GtkToolItem*) open_button, 1);
	_g_object_unref0 (action);
	_g_object_unref0 (open_button);
	_g_object_unref0 (toolbar_recent_menu);
	_g_object_unref0 (recent_manager);
}


static void __lambda121_ (MainWindow* self, GtkRecentChooser* chooser) {
	GtkRecentChooser* _tmp0_;
	const gchar* _tmp1_ = NULL;
	gchar* _tmp2_;
	gchar* uri;
	GFile* _tmp3_ = NULL;
	GFile* _tmp4_;
	DocumentTab* _tmp5_ = NULL;
	DocumentTab* _tmp6_;
	g_return_if_fail (chooser != NULL);
	_tmp0_ = chooser;
	_tmp1_ = gtk_recent_chooser_get_current_uri (_tmp0_);
	_tmp2_ = g_strdup (_tmp1_);
	uri = _tmp2_;
	_tmp3_ = g_file_new_for_uri (uri);
	_tmp4_ = _tmp3_;
	_tmp5_ = main_window_open_document (self, _tmp4_, TRUE);
	_tmp6_ = _tmp5_;
	_g_object_unref0 (_tmp6_);
	_g_object_unref0 (_tmp4_);
	_g_free0 (uri);
}


static void ___lambda121__gtk_recent_chooser_item_activated (GtkRecentChooser* _sender, gpointer self) {
	__lambda121_ (self, _sender);
}


static void main_window_configure_recent_chooser (MainWindow* self, GtkRecentChooser* recent_chooser) {
	GtkRecentChooser* _tmp0_;
	GtkRecentChooser* _tmp1_;
	GtkRecentFilter* _tmp2_;
	GtkRecentFilter* filter;
	GtkRecentChooser* _tmp3_;
	GtkRecentChooser* _tmp4_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (recent_chooser != NULL);
	_tmp0_ = recent_chooser;
	gtk_recent_chooser_set_local_only (_tmp0_, FALSE);
	_tmp1_ = recent_chooser;
	gtk_recent_chooser_set_sort_type (_tmp1_, GTK_RECENT_SORT_MRU);
	_tmp2_ = gtk_recent_filter_new ();
	g_object_ref_sink (_tmp2_);
	filter = _tmp2_;
	gtk_recent_filter_add_application (filter, APP_NAME);
	_tmp3_ = recent_chooser;
	gtk_recent_chooser_set_filter (_tmp3_, filter);
	_tmp4_ = recent_chooser;
	g_signal_connect_object (_tmp4_, "item-activated", (GCallback) ___lambda121__gtk_recent_chooser_item_activated, self, 0);
	_g_object_unref0 (filter);
}


void main_window_save_state (MainWindow* self) {
	GSettings* _tmp0_;
	GSettings* settings_window;
	GdkWindow* _tmp1_ = NULL;
	GdkWindowState _tmp2_ = 0;
	GdkWindowState state;
	GSettings* _tmp3_;
	GdkWindowState _tmp4_;
	gint w = 0;
	gint h = 0;
	gint _tmp5_ = 0;
	gint _tmp6_ = 0;
	GdkWindowState _tmp7_;
	GSettings* _tmp10_;
	gint _tmp11_;
	gint _tmp12_;
	GSettings* _tmp13_;
	GtkPaned* _tmp14_;
	gint _tmp15_ = 0;
	GSettings* _tmp16_;
	GtkPaned* _tmp17_;
	gint _tmp18_ = 0;
	MainWindowStructure* _tmp19_;
	GSettings* _tmp20_;
	GSettings* settings_ui;
	GtkActionGroup* _tmp21_;
	GtkAction* _tmp22_ = NULL;
	GtkToggleAction* _tmp23_;
	GtkToggleAction* action;
	GtkToggleAction* _tmp24_;
	gboolean _tmp25_;
	gboolean _tmp26_;
	GtkActionGroup* _tmp27_;
	GtkAction* _tmp28_ = NULL;
	GtkToggleAction* _tmp29_;
	GtkToggleAction* _tmp30_;
	gboolean _tmp31_;
	gboolean _tmp32_;
	GtkActionGroup* _tmp33_;
	GtkAction* _tmp34_ = NULL;
	GtkToggleAction* _tmp35_;
	GtkToggleAction* _tmp36_;
	gboolean _tmp37_;
	gboolean _tmp38_;
	GtkActionGroup* _tmp39_;
	GtkAction* _tmp40_ = NULL;
	GtkToggleAction* _tmp41_;
	GtkToggleAction* _tmp42_;
	gboolean _tmp43_;
	gboolean _tmp44_;
	MainWindowBuildTools* _tmp45_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_settings_new ("org.gnome.latexila.state.window");
	settings_window = _tmp0_;
	_tmp1_ = gtk_widget_get_window ((GtkWidget*) self);
	_tmp2_ = gdk_window_get_state (_tmp1_);
	state = _tmp2_;
	_tmp3_ = settings_window;
	_tmp4_ = state;
	g_settings_set_int (_tmp3_, "state", (gint) _tmp4_);
	gtk_window_get_size ((GtkWindow*) self, &_tmp5_, &_tmp6_);
	w = _tmp5_;
	h = _tmp6_;
	_tmp7_ = state;
	if ((_tmp7_ & GDK_WINDOW_STATE_MAXIMIZED) == GDK_WINDOW_STATE_MAXIMIZED) {
		gint _tmp8_;
		gint _tmp9_;
		_tmp8_ = w;
		w = _tmp8_ - 100;
		_tmp9_ = h;
		h = _tmp9_ - 100;
	}
	_tmp10_ = settings_window;
	_tmp11_ = w;
	_tmp12_ = h;
	g_settings_set (_tmp10_, "size", "(ii)", _tmp11_, _tmp12_);
	_tmp13_ = settings_window;
	_tmp14_ = self->priv->main_hpaned;
	_tmp15_ = gtk_paned_get_position (_tmp14_);
	g_settings_set_int (_tmp13_, "side-panel-size", _tmp15_);
	_tmp16_ = settings_window;
	_tmp17_ = self->priv->vpaned;
	_tmp18_ = gtk_paned_get_position (_tmp17_);
	g_settings_set_int (_tmp16_, "vertical-paned-position", _tmp18_);
	_tmp19_ = self->priv->_main_window_structure;
	main_window_structure_save_state (_tmp19_);
	_tmp20_ = g_settings_new ("org.gnome.latexila.preferences.ui");
	settings_ui = _tmp20_;
	_tmp21_ = self->priv->action_group;
	_tmp22_ = gtk_action_group_get_action (_tmp21_, "ViewMainToolbar");
	_tmp23_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp22_, GTK_TYPE_TOGGLE_ACTION, GtkToggleAction));
	action = _tmp23_;
	_tmp24_ = action;
	_tmp25_ = gtk_toggle_action_get_active (_tmp24_);
	_tmp26_ = _tmp25_;
	g_settings_set_boolean (settings_ui, "main-toolbar-visible", _tmp26_);
	_tmp27_ = self->priv->action_group;
	_tmp28_ = gtk_action_group_get_action (_tmp27_, "ViewEditToolbar");
	_tmp29_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp28_, GTK_TYPE_TOGGLE_ACTION, GtkToggleAction));
	_g_object_unref0 (action);
	action = _tmp29_;
	_tmp30_ = action;
	_tmp31_ = gtk_toggle_action_get_active (_tmp30_);
	_tmp32_ = _tmp31_;
	g_settings_set_boolean (settings_ui, "edit-toolbar-visible", _tmp32_);
	_tmp33_ = self->priv->action_group;
	_tmp34_ = gtk_action_group_get_action (_tmp33_, "ViewSidePanel");
	_tmp35_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp34_, GTK_TYPE_TOGGLE_ACTION, GtkToggleAction));
	_g_object_unref0 (action);
	action = _tmp35_;
	_tmp36_ = action;
	_tmp37_ = gtk_toggle_action_get_active (_tmp36_);
	_tmp38_ = _tmp37_;
	g_settings_set_boolean (settings_ui, "side-panel-visible", _tmp38_);
	_tmp39_ = self->priv->action_group;
	_tmp40_ = gtk_action_group_get_action (_tmp39_, "ViewBottomPanel");
	_tmp41_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp40_, GTK_TYPE_TOGGLE_ACTION, GtkToggleAction));
	_g_object_unref0 (action);
	action = _tmp41_;
	_tmp42_ = action;
	_tmp43_ = gtk_toggle_action_get_active (_tmp42_);
	_tmp44_ = _tmp43_;
	g_settings_set_boolean (settings_ui, "bottom-panel-visible", _tmp44_);
	_tmp45_ = self->priv->_main_window_build_tools;
	main_window_build_tools_save_state (_tmp45_);
	_g_object_unref0 (action);
	_g_object_unref0 (settings_ui);
	_g_object_unref0 (settings_window);
}


static void main_window_move_tab_to_new_window (MainWindow* self, DocumentTab* tab) {
	Latexila* _tmp0_ = NULL;
	Latexila* _tmp1_;
	MainWindow* _tmp2_ = NULL;
	MainWindow* _tmp3_;
	MainWindow* new_window;
	DocumentTab* _tmp4_;
	DocumentView* _tmp5_;
	DocumentView* _tmp6_;
	DocumentView* _tmp7_;
	DocumentView* view;
	DocumentsPanel* _tmp8_;
	DocumentTab* _tmp9_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (tab != NULL);
	_tmp0_ = latexila_get_instance ();
	_tmp1_ = _tmp0_;
	_tmp2_ = latexila_create_window (_tmp1_);
	_tmp3_ = _tmp2_;
	_g_object_unref0 (_tmp1_);
	new_window = _tmp3_;
	_tmp4_ = tab;
	_tmp5_ = document_tab_get_view (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = _g_object_ref0 (_tmp6_);
	view = _tmp7_;
	_tmp8_ = self->priv->documents_panel;
	_tmp9_ = tab;
	documents_panel_remove_tab (_tmp8_, _tmp9_);
	main_window_create_tab_with_view (new_window, view);
	_g_object_unref0 (view);
	_g_object_unref0 (new_window);
}


static void main_window_update_documents_list_menu (MainWindow* self) {
	GtkActionGroup* _tmp0_;
	guint _tmp1_;
	GtkActionGroup* _tmp4_;
	GList* _tmp5_ = NULL;
	DocumentsPanel* _tmp11_;
	gint _tmp12_ = 0;
	gint n;
	guint _tmp13_ = 0U;
	gint _tmp14_;
	guint _tmp17_;
	guint id;
	GSList* group;
	guint _tmp67_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->documents_list_action_group;
	g_return_if_fail (_tmp0_ != NULL);
	_tmp1_ = self->priv->documents_list_menu_ui_id;
	if (_tmp1_ != ((guint) 0)) {
		GtkUIManager* _tmp2_;
		guint _tmp3_;
		_tmp2_ = self->priv->ui_manager;
		_tmp3_ = self->priv->documents_list_menu_ui_id;
		gtk_ui_manager_remove_ui (_tmp2_, _tmp3_);
	}
	_tmp4_ = self->priv->documents_list_action_group;
	_tmp5_ = gtk_action_group_list_actions (_tmp4_);
	{
		GList* action_collection = NULL;
		GList* action_it = NULL;
		action_collection = _tmp5_;
		for (action_it = action_collection; action_it != NULL; action_it = action_it->next) {
			GtkAction* _tmp6_;
			GtkAction* action = NULL;
			_tmp6_ = _g_object_ref0 ((GtkAction*) action_it->data);
			action = _tmp6_;
			{
				GtkAction* _tmp7_;
				guint _tmp8_ = 0U;
				GtkActionGroup* _tmp9_;
				GtkAction* _tmp10_;
				_tmp7_ = action;
				g_signal_parse_name ("activate", GTK_TYPE_ACTION, &_tmp8_, NULL, FALSE);
				g_signal_handlers_disconnect_matched (_tmp7_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp8_, 0, NULL, (GCallback) _main_window_documents_list_menu_activate_gtk_action_activate, self);
				_tmp9_ = self->priv->documents_list_action_group;
				_tmp10_ = action;
				gtk_action_group_remove_action (_tmp9_, _tmp10_);
				_g_object_unref0 (action);
			}
		}
		_g_list_free0 (action_collection);
	}
	_tmp11_ = self->priv->documents_panel;
	_tmp12_ = gtk_notebook_get_n_pages ((GtkNotebook*) _tmp11_);
	n = _tmp12_;
	_tmp14_ = n;
	if (_tmp14_ > 0) {
		GtkUIManager* _tmp15_;
		guint _tmp16_ = 0U;
		_tmp15_ = self->priv->ui_manager;
		_tmp16_ = gtk_ui_manager_new_merge_id (_tmp15_);
		_tmp13_ = _tmp16_;
	} else {
		_tmp13_ = (guint) 0;
	}
	_tmp17_ = _tmp13_;
	id = _tmp17_;
	group = NULL;
	{
		gint i;
		i = 0;
		{
			gboolean _tmp18_;
			_tmp18_ = TRUE;
			while (TRUE) {
				gboolean _tmp19_;
				gint _tmp21_;
				gint _tmp22_;
				DocumentsPanel* _tmp23_;
				gint _tmp24_;
				GtkWidget* _tmp25_ = NULL;
				DocumentTab* _tmp26_;
				DocumentTab* tab;
				gint _tmp27_;
				gchar* _tmp28_ = NULL;
				gchar* _tmp29_;
				gchar* _tmp30_ = NULL;
				gchar* _tmp31_;
				gchar* action_name;
				DocumentTab* _tmp32_;
				gchar* _tmp33_ = NULL;
				gchar* _tmp34_;
				gchar* _tmp35_ = NULL;
				gchar* _tmp36_;
				gchar* name;
				DocumentTab* _tmp37_;
				gchar* _tmp38_ = NULL;
				gchar* tip;
				gchar* _tmp39_ = NULL;
				gint _tmp40_;
				const gchar* _tmp43_;
				gchar* _tmp44_;
				gchar* accel;
				const gchar* _tmp45_;
				const gchar* _tmp46_;
				const gchar* _tmp47_;
				gint _tmp48_;
				GtkRadioAction* _tmp49_;
				GtkRadioAction* action;
				GSList* _tmp50_;
				GtkRadioAction* _tmp53_;
				GSList* _tmp54_ = NULL;
				GtkActionGroup* _tmp55_;
				GtkRadioAction* _tmp56_;
				const gchar* _tmp57_;
				GtkRadioAction* _tmp58_;
				GtkUIManager* _tmp59_;
				guint _tmp60_;
				const gchar* _tmp61_;
				const gchar* _tmp62_;
				DocumentTab* _tmp63_;
				DocumentTab* _tmp64_;
				DocumentTab* _tmp65_;
				_tmp19_ = _tmp18_;
				if (!_tmp19_) {
					gint _tmp20_;
					_tmp20_ = i;
					i = _tmp20_ + 1;
				}
				_tmp18_ = FALSE;
				_tmp21_ = i;
				_tmp22_ = n;
				if (!(_tmp21_ < _tmp22_)) {
					break;
				}
				_tmp23_ = self->priv->documents_panel;
				_tmp24_ = i;
				_tmp25_ = gtk_notebook_get_nth_page ((GtkNotebook*) _tmp23_, _tmp24_);
				_tmp26_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp25_, TYPE_DOCUMENT_TAB, DocumentTab));
				tab = _tmp26_;
				_tmp27_ = i;
				_tmp28_ = g_strdup_printf ("%i", _tmp27_);
				_tmp29_ = _tmp28_;
				_tmp30_ = g_strconcat ("Tab_", _tmp29_, NULL);
				_tmp31_ = _tmp30_;
				_g_free0 (_tmp29_);
				action_name = _tmp31_;
				_tmp32_ = tab;
				_tmp33_ = document_tab_get_name (_tmp32_);
				_tmp34_ = _tmp33_;
				_tmp35_ = string_replace (_tmp34_, "_", "__");
				_tmp36_ = _tmp35_;
				_g_free0 (_tmp34_);
				name = _tmp36_;
				_tmp37_ = tab;
				_tmp38_ = document_tab_get_menu_tip (_tmp37_);
				tip = _tmp38_;
				_tmp40_ = i;
				if (_tmp40_ < 10) {
					gint _tmp41_;
					gchar* _tmp42_ = NULL;
					_tmp41_ = i;
					_tmp42_ = g_strdup_printf ("<alt>%d", (_tmp41_ + 1) % 10);
					_g_free0 (_tmp39_);
					_tmp39_ = _tmp42_;
				} else {
					_g_free0 (_tmp39_);
					_tmp39_ = NULL;
				}
				_tmp43_ = _tmp39_;
				_tmp44_ = g_strdup (_tmp43_);
				accel = _tmp44_;
				_tmp45_ = action_name;
				_tmp46_ = name;
				_tmp47_ = tip;
				_tmp48_ = i;
				_tmp49_ = gtk_radio_action_new (_tmp45_, _tmp46_, _tmp47_, NULL, _tmp48_);
				action = _tmp49_;
				_tmp50_ = group;
				if (_tmp50_ != NULL) {
					GtkRadioAction* _tmp51_;
					GSList* _tmp52_;
					_tmp51_ = action;
					_tmp52_ = group;
					gtk_radio_action_set_group (_tmp51_, _tmp52_);
				}
				_tmp53_ = action;
				_tmp54_ = gtk_radio_action_get_group (_tmp53_);
				group = _tmp54_;
				_tmp55_ = self->priv->documents_list_action_group;
				_tmp56_ = action;
				_tmp57_ = accel;
				gtk_action_group_add_action_with_accel (_tmp55_, (GtkAction*) _tmp56_, _tmp57_);
				_tmp58_ = action;
				g_signal_connect_object ((GtkAction*) _tmp58_, "activate", (GCallback) _main_window_documents_list_menu_activate_gtk_action_activate, self, 0);
				_tmp59_ = self->priv->ui_manager;
				_tmp60_ = id;
				_tmp61_ = action_name;
				_tmp62_ = action_name;
				gtk_ui_manager_add_ui (_tmp59_, _tmp60_, "/MainMenu/DocumentsMenu/DocumentsListPlaceholder", _tmp61_, _tmp62_, GTK_UI_MANAGER_MENUITEM, FALSE);
				_tmp63_ = tab;
				_tmp64_ = main_window_get_active_tab (self);
				_tmp65_ = _tmp64_;
				if (_tmp63_ == _tmp65_) {
					GtkRadioAction* _tmp66_;
					_tmp66_ = action;
					gtk_toggle_action_set_active ((GtkToggleAction*) _tmp66_, TRUE);
				}
				_g_object_unref0 (action);
				_g_free0 (accel);
				_g_free0 (_tmp39_);
				_g_free0 (tip);
				_g_free0 (name);
				_g_free0 (action_name);
				_g_object_unref0 (tab);
			}
		}
	}
	_tmp67_ = id;
	self->priv->documents_list_menu_ui_id = _tmp67_;
}


static void main_window_documents_list_menu_activate (MainWindow* self, GtkAction* action) {
	GtkAction* _tmp0_;
	GtkRadioAction* _tmp1_;
	GtkRadioAction* radio_action;
	GtkRadioAction* _tmp2_;
	gboolean _tmp3_ = FALSE;
	DocumentsPanel* _tmp4_;
	GtkRadioAction* _tmp5_;
	gint _tmp6_ = 0;
	g_return_if_fail (self != NULL);
	g_return_if_fail (action != NULL);
	_tmp0_ = action;
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GTK_TYPE_RADIO_ACTION, GtkRadioAction));
	radio_action = _tmp1_;
	_tmp2_ = radio_action;
	_tmp3_ = gtk_toggle_action_get_active ((GtkToggleAction*) _tmp2_);
	if (!_tmp3_) {
		_g_object_unref0 (radio_action);
		return;
	}
	_tmp4_ = self->priv->documents_panel;
	_tmp5_ = radio_action;
	_tmp6_ = gtk_radio_action_get_current_value (_tmp5_);
	gtk_notebook_set_current_page ((GtkNotebook*) _tmp4_, _tmp6_);
	_g_object_unref0 (radio_action);
}


/*****************************
     *    ACTIONS SENSITIVITY    *
     *****************************/
static void main_window_set_file_actions_sensitivity (MainWindow* self, gboolean sensitive) {
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	gchar** _tmp24_ = NULL;
	gchar** file_actions;
	gint file_actions_length1;
	gint _file_actions_size_;
	gchar** _tmp25_;
	gint _tmp25__length1;
	GtkActionGroup* _tmp33_;
	gboolean _tmp34_;
	MainWindowBuildTools* _tmp35_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup ("FileSave");
	_tmp1_ = g_strdup ("FileSaveAs");
	_tmp2_ = g_strdup ("FileClose");
	_tmp3_ = g_strdup ("EditUndo");
	_tmp4_ = g_strdup ("EditRedo");
	_tmp5_ = g_strdup ("EditCut");
	_tmp6_ = g_strdup ("EditCopy");
	_tmp7_ = g_strdup ("EditPaste");
	_tmp8_ = g_strdup ("EditDelete");
	_tmp9_ = g_strdup ("EditSelectAll");
	_tmp10_ = g_strdup ("EditComment");
	_tmp11_ = g_strdup ("EditUncomment");
	_tmp12_ = g_strdup ("ViewZoomIn");
	_tmp13_ = g_strdup ("ViewZoomOut");
	_tmp14_ = g_strdup ("ViewZoomReset");
	_tmp15_ = g_strdup ("DocumentsSaveAll");
	_tmp16_ = g_strdup ("DocumentsCloseAll");
	_tmp17_ = g_strdup ("DocumentsPrevious");
	_tmp18_ = g_strdup ("DocumentsNext");
	_tmp19_ = g_strdup ("SearchFind");
	_tmp20_ = g_strdup ("SearchReplace");
	_tmp21_ = g_strdup ("SearchGoToLine");
	_tmp22_ = g_strdup ("ProjectsConfigCurrent");
	_tmp23_ = g_strdup ("FileCreateTemplate");
	_tmp24_ = g_new0 (gchar*, 24 + 1);
	_tmp24_[0] = _tmp0_;
	_tmp24_[1] = _tmp1_;
	_tmp24_[2] = _tmp2_;
	_tmp24_[3] = _tmp3_;
	_tmp24_[4] = _tmp4_;
	_tmp24_[5] = _tmp5_;
	_tmp24_[6] = _tmp6_;
	_tmp24_[7] = _tmp7_;
	_tmp24_[8] = _tmp8_;
	_tmp24_[9] = _tmp9_;
	_tmp24_[10] = _tmp10_;
	_tmp24_[11] = _tmp11_;
	_tmp24_[12] = _tmp12_;
	_tmp24_[13] = _tmp13_;
	_tmp24_[14] = _tmp14_;
	_tmp24_[15] = _tmp15_;
	_tmp24_[16] = _tmp16_;
	_tmp24_[17] = _tmp17_;
	_tmp24_[18] = _tmp18_;
	_tmp24_[19] = _tmp19_;
	_tmp24_[20] = _tmp20_;
	_tmp24_[21] = _tmp21_;
	_tmp24_[22] = _tmp22_;
	_tmp24_[23] = _tmp23_;
	file_actions = _tmp24_;
	file_actions_length1 = 24;
	_file_actions_size_ = file_actions_length1;
	_tmp25_ = file_actions;
	_tmp25__length1 = file_actions_length1;
	{
		gchar** file_action_collection = NULL;
		gint file_action_collection_length1 = 0;
		gint _file_action_collection_size_ = 0;
		gint file_action_it = 0;
		file_action_collection = _tmp25_;
		file_action_collection_length1 = _tmp25__length1;
		for (file_action_it = 0; file_action_it < _tmp25__length1; file_action_it = file_action_it + 1) {
			gchar* _tmp26_;
			gchar* file_action = NULL;
			_tmp26_ = g_strdup (file_action_collection[file_action_it]);
			file_action = _tmp26_;
			{
				GtkActionGroup* _tmp27_;
				const gchar* _tmp28_;
				GtkAction* _tmp29_ = NULL;
				GtkAction* _tmp30_;
				GtkAction* action;
				GtkAction* _tmp31_;
				gboolean _tmp32_;
				_tmp27_ = self->priv->action_group;
				_tmp28_ = file_action;
				_tmp29_ = gtk_action_group_get_action (_tmp27_, _tmp28_);
				_tmp30_ = _g_object_ref0 (_tmp29_);
				action = _tmp30_;
				_tmp31_ = action;
				_tmp32_ = sensitive;
				gtk_action_set_sensitive (_tmp31_, _tmp32_);
				_g_object_unref0 (action);
				_g_free0 (file_action);
			}
		}
	}
	_tmp33_ = self->priv->latex_action_group;
	_tmp34_ = sensitive;
	gtk_action_group_set_sensitive (_tmp33_, _tmp34_);
	_tmp35_ = self->priv->_main_window_build_tools;
	main_window_build_tools_update_sensitivity (_tmp35_);
	file_actions = (_vala_array_free (file_actions, file_actions_length1, (GDestroyNotify) g_free), NULL);
}


static void main_window_set_undo_sensitivity (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	if (_tmp1_ != NULL) {
		GtkActionGroup* _tmp2_;
		GtkAction* _tmp3_ = NULL;
		GtkAction* _tmp4_;
		GtkAction* action;
		GtkAction* _tmp5_;
		Document* _tmp6_;
		Document* _tmp7_;
		gboolean _tmp8_ = FALSE;
		gboolean _tmp9_;
		_tmp2_ = self->priv->action_group;
		_tmp3_ = gtk_action_group_get_action (_tmp2_, "EditUndo");
		_tmp4_ = _g_object_ref0 (_tmp3_);
		action = _tmp4_;
		_tmp5_ = action;
		_tmp6_ = main_window_get_active_document (self);
		_tmp7_ = _tmp6_;
		g_object_get ((GtkSourceBuffer*) _tmp7_, "can-undo", &_tmp8_, NULL);
		_tmp9_ = _tmp8_;
		gtk_action_set_sensitive (_tmp5_, _tmp9_);
		_g_object_unref0 (action);
	}
}


static void main_window_set_redo_sensitivity (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	GtkActionGroup* _tmp2_;
	GtkAction* _tmp3_ = NULL;
	GtkAction* _tmp4_;
	GtkAction* action;
	GtkAction* _tmp5_;
	Document* _tmp6_;
	Document* _tmp7_;
	gboolean _tmp8_ = FALSE;
	gboolean _tmp9_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	if (_tmp1_ == NULL) {
		return;
	}
	_tmp2_ = self->priv->action_group;
	_tmp3_ = gtk_action_group_get_action (_tmp2_, "EditRedo");
	_tmp4_ = _g_object_ref0 (_tmp3_);
	action = _tmp4_;
	_tmp5_ = action;
	_tmp6_ = main_window_get_active_document (self);
	_tmp7_ = _tmp6_;
	g_object_get ((GtkSourceBuffer*) _tmp7_, "can-redo", &_tmp8_, NULL);
	_tmp9_ = _tmp8_;
	gtk_action_set_sensitive (_tmp5_, _tmp9_);
	_g_object_unref0 (action);
}


static void main_window_set_documents_move_to_new_window_sensitivity (MainWindow* self, gboolean sensitive) {
	GtkActionGroup* _tmp0_;
	GtkAction* _tmp1_ = NULL;
	GtkAction* _tmp2_;
	GtkAction* action;
	gboolean _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->action_group;
	_tmp1_ = gtk_action_group_get_action (_tmp0_, "DocumentsMoveToNewWindow");
	_tmp2_ = _g_object_ref0 (_tmp1_);
	action = _tmp2_;
	_tmp3_ = sensitive;
	gtk_action_set_sensitive (action, _tmp3_);
	_g_object_unref0 (action);
}


static void main_window_update_next_prev_doc_sensitivity (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	GtkActionGroup* _tmp2_;
	GtkAction* _tmp3_ = NULL;
	GtkAction* _tmp4_;
	GtkAction* action_previous;
	GtkActionGroup* _tmp5_;
	GtkAction* _tmp6_ = NULL;
	GtkAction* _tmp7_;
	GtkAction* action_next;
	DocumentsPanel* _tmp8_;
	DocumentTab* _tmp9_;
	DocumentTab* _tmp10_;
	gint _tmp11_ = 0;
	gint current_page;
	GtkAction* _tmp12_;
	gint _tmp13_;
	DocumentsPanel* _tmp14_;
	gint _tmp15_ = 0;
	gint nb_pages;
	GtkAction* _tmp16_;
	gint _tmp17_;
	gint _tmp18_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	if (_tmp1_ == NULL) {
		return;
	}
	_tmp2_ = self->priv->action_group;
	_tmp3_ = gtk_action_group_get_action (_tmp2_, "DocumentsPrevious");
	_tmp4_ = _g_object_ref0 (_tmp3_);
	action_previous = _tmp4_;
	_tmp5_ = self->priv->action_group;
	_tmp6_ = gtk_action_group_get_action (_tmp5_, "DocumentsNext");
	_tmp7_ = _g_object_ref0 (_tmp6_);
	action_next = _tmp7_;
	_tmp8_ = self->priv->documents_panel;
	_tmp9_ = main_window_get_active_tab (self);
	_tmp10_ = _tmp9_;
	_tmp11_ = gtk_notebook_page_num ((GtkNotebook*) _tmp8_, (GtkWidget*) _tmp10_);
	current_page = _tmp11_;
	_tmp12_ = action_previous;
	_tmp13_ = current_page;
	gtk_action_set_sensitive (_tmp12_, _tmp13_ > 0);
	_tmp14_ = self->priv->documents_panel;
	_tmp15_ = gtk_notebook_get_n_pages ((GtkNotebook*) _tmp14_);
	nb_pages = _tmp15_;
	_tmp16_ = action_next;
	_tmp17_ = current_page;
	_tmp18_ = nb_pages;
	gtk_action_set_sensitive (_tmp16_, _tmp17_ < (_tmp18_ - 1));
	_g_object_unref0 (action_next);
	_g_object_unref0 (action_previous);
}


void main_window_update_config_project_sensitivity (MainWindow* self) {
	GtkActionGroup* _tmp0_;
	GtkAction* _tmp1_ = NULL;
	GtkAction* _tmp2_;
	GtkAction* action;
	gboolean _tmp3_ = FALSE;
	DocumentTab* _tmp4_;
	DocumentTab* _tmp5_;
	GtkAction* _tmp10_;
	gboolean _tmp11_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->action_group;
	_tmp1_ = gtk_action_group_get_action (_tmp0_, "ProjectsConfigCurrent");
	_tmp2_ = _g_object_ref0 (_tmp1_);
	action = _tmp2_;
	_tmp4_ = main_window_get_active_tab (self);
	_tmp5_ = _tmp4_;
	if (_tmp5_ != NULL) {
		Document* _tmp6_;
		Document* _tmp7_;
		gint _tmp8_;
		gint _tmp9_;
		_tmp6_ = main_window_get_active_document (self);
		_tmp7_ = _tmp6_;
		_tmp8_ = document_get_project_id (_tmp7_);
		_tmp9_ = _tmp8_;
		_tmp3_ = _tmp9_ != (-1);
	} else {
		_tmp3_ = FALSE;
	}
	_tmp10_ = action;
	_tmp11_ = _tmp3_;
	gtk_action_set_sensitive (_tmp10_, _tmp11_);
	_g_object_unref0 (action);
}


static void main_window_selection_changed (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	if (_tmp1_ != NULL) {
		Document* _tmp2_;
		Document* _tmp3_;
		gboolean _tmp4_;
		gboolean _tmp5_;
		gboolean has_selection;
		gchar* _tmp6_;
		gchar* _tmp7_;
		gchar* _tmp8_;
		gchar** _tmp9_ = NULL;
		gchar** selection_actions;
		gint selection_actions_length1;
		gint _selection_actions_size_;
		gchar** _tmp10_;
		gint _tmp10__length1;
		_tmp2_ = main_window_get_active_document (self);
		_tmp3_ = _tmp2_;
		_tmp4_ = gtk_text_buffer_get_has_selection ((GtkTextBuffer*) _tmp3_);
		_tmp5_ = _tmp4_;
		has_selection = _tmp5_;
		_tmp6_ = g_strdup ("EditCut");
		_tmp7_ = g_strdup ("EditCopy");
		_tmp8_ = g_strdup ("EditDelete");
		_tmp9_ = g_new0 (gchar*, 3 + 1);
		_tmp9_[0] = _tmp6_;
		_tmp9_[1] = _tmp7_;
		_tmp9_[2] = _tmp8_;
		selection_actions = _tmp9_;
		selection_actions_length1 = 3;
		_selection_actions_size_ = selection_actions_length1;
		_tmp10_ = selection_actions;
		_tmp10__length1 = selection_actions_length1;
		{
			gchar** selection_action_collection = NULL;
			gint selection_action_collection_length1 = 0;
			gint _selection_action_collection_size_ = 0;
			gint selection_action_it = 0;
			selection_action_collection = _tmp10_;
			selection_action_collection_length1 = _tmp10__length1;
			for (selection_action_it = 0; selection_action_it < _tmp10__length1; selection_action_it = selection_action_it + 1) {
				gchar* _tmp11_;
				gchar* selection_action = NULL;
				_tmp11_ = g_strdup (selection_action_collection[selection_action_it]);
				selection_action = _tmp11_;
				{
					GtkActionGroup* _tmp12_;
					const gchar* _tmp13_;
					GtkAction* _tmp14_ = NULL;
					GtkAction* _tmp15_;
					GtkAction* action;
					GtkAction* _tmp16_;
					gboolean _tmp17_;
					_tmp12_ = self->priv->action_group;
					_tmp13_ = selection_action;
					_tmp14_ = gtk_action_group_get_action (_tmp12_, _tmp13_);
					_tmp15_ = _g_object_ref0 (_tmp14_);
					action = _tmp15_;
					_tmp16_ = action;
					_tmp17_ = has_selection;
					gtk_action_set_sensitive (_tmp16_, _tmp17_);
					_g_object_unref0 (action);
					_g_free0 (selection_action);
				}
			}
		}
		selection_actions = (_vala_array_free (selection_actions, selection_actions_length1, (GDestroyNotify) g_free), NULL);
	}
}


/*******************
     *    CALLBACKS
     ******************/
void main_window_on_file_new (MainWindow* self) {
	OpenTemplateDialog* _tmp0_;
	OpenTemplateDialog* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = open_template_dialog_new (self);
	_tmp1_ = _tmp0_;
	_open_template_dialog_unref0 (_tmp1_);
}


void main_window_on_new_window (MainWindow* self) {
	Latexila* _tmp0_ = NULL;
	Latexila* _tmp1_;
	MainWindow* _tmp2_ = NULL;
	MainWindow* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = latexila_get_instance ();
	_tmp1_ = _tmp0_;
	_tmp2_ = latexila_create_window (_tmp1_);
	_tmp3_ = _tmp2_;
	_g_object_unref0 (_tmp3_);
	_g_object_unref0 (_tmp1_);
}


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


static void _g_slist_free__g_object_unref0_ (GSList* self) {
	g_slist_foreach (self, (GFunc) _g_object_unref0_, NULL);
	g_slist_free (self);
}


void main_window_on_file_open (MainWindow* self) {
	const gchar* _tmp0_ = NULL;
	GtkFileChooserDialog* _tmp1_;
	GtkFileChooserDialog* file_chooser;
	const gchar* _tmp2_;
	GtkFileChooserDialog* _tmp5_;
	GtkFileFilter* _tmp6_;
	GtkFileFilter* latex_filter;
	GtkFileFilter* _tmp7_;
	const gchar* _tmp8_ = NULL;
	GtkFileFilter* _tmp9_;
	GtkFileFilter* _tmp10_;
	GtkFileChooserDialog* _tmp11_;
	GtkFileFilter* _tmp12_;
	GtkFileFilter* _tmp13_;
	GtkFileFilter* all_files_filter;
	GtkFileFilter* _tmp14_;
	const gchar* _tmp15_ = NULL;
	GtkFileFilter* _tmp16_;
	GtkFileChooserDialog* _tmp17_;
	GtkFileFilter* _tmp18_;
	GSList* files_to_open;
	GtkFileChooserDialog* _tmp19_;
	gint _tmp20_ = 0;
	GtkFileChooserDialog* _tmp23_;
	gchar* _tmp24_ = NULL;
	GtkFileChooserDialog* _tmp25_;
	gboolean jump_to;
	GSList* _tmp26_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _ ("Open Files");
	_tmp1_ = (GtkFileChooserDialog*) gtk_file_chooser_dialog_new (_tmp0_, (GtkWindow*) self, GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL, NULL);
	g_object_ref_sink (_tmp1_);
	file_chooser = _tmp1_;
	_tmp2_ = self->priv->file_chooser_current_folder;
	if (_tmp2_ != NULL) {
		GtkFileChooserDialog* _tmp3_;
		const gchar* _tmp4_;
		_tmp3_ = file_chooser;
		_tmp4_ = self->priv->file_chooser_current_folder;
		gtk_file_chooser_set_current_folder ((GtkFileChooser*) _tmp3_, _tmp4_);
	}
	_tmp5_ = file_chooser;
	gtk_file_chooser_set_select_multiple ((GtkFileChooser*) _tmp5_, TRUE);
	_tmp6_ = gtk_file_filter_new ();
	g_object_ref_sink (_tmp6_);
	latex_filter = _tmp6_;
	_tmp7_ = latex_filter;
	_tmp8_ = _ ("All LaTeX Files");
	gtk_file_filter_set_name (_tmp7_, _tmp8_);
	_tmp9_ = latex_filter;
	gtk_file_filter_add_pattern (_tmp9_, "*.tex");
	_tmp10_ = latex_filter;
	gtk_file_filter_add_pattern (_tmp10_, "*.bib");
	_tmp11_ = file_chooser;
	_tmp12_ = latex_filter;
	gtk_file_chooser_add_filter ((GtkFileChooser*) _tmp11_, _tmp12_);
	_tmp13_ = gtk_file_filter_new ();
	g_object_ref_sink (_tmp13_);
	all_files_filter = _tmp13_;
	_tmp14_ = all_files_filter;
	_tmp15_ = _ ("All Files");
	gtk_file_filter_set_name (_tmp14_, _tmp15_);
	_tmp16_ = all_files_filter;
	gtk_file_filter_add_pattern (_tmp16_, "*");
	_tmp17_ = file_chooser;
	_tmp18_ = all_files_filter;
	gtk_file_chooser_add_filter ((GtkFileChooser*) _tmp17_, _tmp18_);
	files_to_open = NULL;
	_tmp19_ = file_chooser;
	_tmp20_ = gtk_dialog_run ((GtkDialog*) _tmp19_);
	if (_tmp20_ == ((gint) GTK_RESPONSE_ACCEPT)) {
		GtkFileChooserDialog* _tmp21_;
		GSList* _tmp22_ = NULL;
		_tmp21_ = file_chooser;
		_tmp22_ = gtk_file_chooser_get_files ((GtkFileChooser*) _tmp21_);
		__g_slist_free__g_object_unref0_0 (files_to_open);
		files_to_open = _tmp22_;
	}
	_tmp23_ = file_chooser;
	_tmp24_ = gtk_file_chooser_get_current_folder ((GtkFileChooser*) _tmp23_);
	_g_free0 (self->priv->file_chooser_current_folder);
	self->priv->file_chooser_current_folder = _tmp24_;
	_tmp25_ = file_chooser;
	gtk_widget_destroy ((GtkWidget*) _tmp25_);
	jump_to = TRUE;
	_tmp26_ = files_to_open;
	{
		GSList* file_collection = NULL;
		GSList* file_it = NULL;
		file_collection = _tmp26_;
		for (file_it = file_collection; file_it != NULL; file_it = file_it->next) {
			GFile* _tmp27_;
			GFile* file = NULL;
			_tmp27_ = _g_object_ref0 ((GFile*) file_it->data);
			file = _tmp27_;
			{
				GFile* _tmp28_;
				gboolean _tmp29_;
				DocumentTab* _tmp30_ = NULL;
				DocumentTab* _tmp31_;
				_tmp28_ = file;
				_tmp29_ = jump_to;
				_tmp30_ = main_window_open_document (self, _tmp28_, _tmp29_);
				_tmp31_ = _tmp30_;
				_g_object_unref0 (_tmp31_);
				jump_to = FALSE;
				_g_object_unref0 (file);
			}
		}
	}
	__g_slist_free__g_object_unref0_0 (files_to_open);
	_g_object_unref0 (all_files_filter);
	_g_object_unref0 (latex_filter);
	_g_object_unref0 (file_chooser);
}


void main_window_on_file_save (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	Document* _tmp2_;
	Document* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	g_return_if_fail (_tmp1_ != NULL);
	_tmp2_ = main_window_get_active_document (self);
	_tmp3_ = _tmp2_;
	main_window_save_document (self, _tmp3_, FALSE);
}


void main_window_on_file_save_as (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	Document* _tmp2_;
	Document* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	g_return_if_fail (_tmp1_ != NULL);
	_tmp2_ = main_window_get_active_document (self);
	_tmp3_ = _tmp2_;
	main_window_save_document (self, _tmp3_, TRUE);
}


void main_window_on_create_template (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	CreateTemplateDialog* _tmp2_;
	CreateTemplateDialog* dialog;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	g_return_if_fail (_tmp1_ != NULL);
	_tmp2_ = create_template_dialog_new (self);
	g_object_ref_sink (_tmp2_);
	dialog = _tmp2_;
	gtk_widget_destroy ((GtkWidget*) dialog);
	_g_object_unref0 (dialog);
}


void main_window_on_delete_template (MainWindow* self) {
	DeleteTemplateDialog* _tmp0_;
	DeleteTemplateDialog* dialog;
	g_return_if_fail (self != NULL);
	_tmp0_ = delete_template_dialog_new (self);
	g_object_ref_sink (_tmp0_);
	dialog = _tmp0_;
	gtk_widget_destroy ((GtkWidget*) dialog);
	_g_object_unref0 (dialog);
}


void main_window_on_file_close (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentTab* _tmp2_;
	DocumentTab* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	g_return_if_fail (_tmp1_ != NULL);
	_tmp2_ = main_window_get_active_tab (self);
	_tmp3_ = _tmp2_;
	main_window_close_tab (self, _tmp3_, FALSE);
}


static void _vala_array_add7 (gchar*** array, int* length, int* size, gchar* value) {
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}


void main_window_on_quit (MainWindow* self) {
	gchar** _tmp0_ = NULL;
	gchar** list_uris;
	gint list_uris_length1;
	gint _list_uris_size_;
	GSettings* _tmp19_;
	GSettings* settings;
	GSettings* _tmp20_;
	gchar** _tmp21_;
	gint _tmp21__length1;
	gboolean _tmp22_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_new0 (gchar*, 0 + 1);
	list_uris = _tmp0_;
	list_uris_length1 = 0;
	_list_uris_size_ = list_uris_length1;
	{
		GeeList* _tmp1_ = NULL;
		GeeList* _doc_list;
		GeeList* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		gint _doc_size;
		gint _doc_index;
		_tmp1_ = main_window_get_documents (self);
		_doc_list = _tmp1_;
		_tmp2_ = _doc_list;
		_tmp3_ = gee_collection_get_size ((GeeCollection*) _tmp2_);
		_tmp4_ = _tmp3_;
		_doc_size = _tmp4_;
		_doc_index = -1;
		while (TRUE) {
			gint _tmp5_;
			gint _tmp6_;
			gint _tmp7_;
			GeeList* _tmp8_;
			gint _tmp9_;
			gpointer _tmp10_ = NULL;
			Document* doc;
			Document* _tmp11_;
			GFile* _tmp12_;
			GFile* _tmp13_;
			_tmp5_ = _doc_index;
			_doc_index = _tmp5_ + 1;
			_tmp6_ = _doc_index;
			_tmp7_ = _doc_size;
			if (!(_tmp6_ < _tmp7_)) {
				break;
			}
			_tmp8_ = _doc_list;
			_tmp9_ = _doc_index;
			_tmp10_ = gee_list_get (_tmp8_, _tmp9_);
			doc = (Document*) _tmp10_;
			_tmp11_ = doc;
			_tmp12_ = document_get_location (_tmp11_);
			_tmp13_ = _tmp12_;
			if (_tmp13_ != NULL) {
				gchar** _tmp14_;
				gint _tmp14__length1;
				Document* _tmp15_;
				GFile* _tmp16_;
				GFile* _tmp17_;
				gchar* _tmp18_ = NULL;
				_tmp14_ = list_uris;
				_tmp14__length1 = list_uris_length1;
				_tmp15_ = doc;
				_tmp16_ = document_get_location (_tmp15_);
				_tmp17_ = _tmp16_;
				_tmp18_ = g_file_get_uri (_tmp17_);
				_vala_array_add7 (&list_uris, &list_uris_length1, &_list_uris_size_, _tmp18_);
			}
			_g_object_unref0 (doc);
		}
		_g_object_unref0 (_doc_list);
	}
	_tmp19_ = g_settings_new ("org.gnome.latexila.state.window");
	settings = _tmp19_;
	_tmp20_ = settings;
	_tmp21_ = list_uris;
	_tmp21__length1 = list_uris_length1;
	g_settings_set_strv (_tmp20_, "documents", _tmp21_);
	_tmp22_ = main_window_close_all_documents (self);
	if (_tmp22_) {
		main_window_save_state (self);
		gtk_widget_destroy ((GtkWidget*) self);
	}
	_g_object_unref0 (settings);
	list_uris = (_vala_array_free (list_uris, list_uris_length1, (GDestroyNotify) g_free), NULL);
}


void main_window_on_edit_undo (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	Document* _tmp2_;
	Document* _tmp3_;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	g_return_if_fail (_tmp1_ != NULL);
	_tmp2_ = main_window_get_active_document (self);
	_tmp3_ = _tmp2_;
	g_object_get ((GtkSourceBuffer*) _tmp3_, "can-undo", &_tmp4_, NULL);
	_tmp5_ = _tmp4_;
	if (_tmp5_) {
		Document* _tmp6_;
		Document* _tmp7_;
		DocumentView* _tmp8_;
		DocumentView* _tmp9_;
		DocumentView* _tmp10_;
		DocumentView* _tmp11_;
		_tmp6_ = main_window_get_active_document (self);
		_tmp7_ = _tmp6_;
		gtk_source_buffer_undo ((GtkSourceBuffer*) _tmp7_);
		_tmp8_ = main_window_get_active_view (self);
		_tmp9_ = _tmp8_;
		document_view_scroll_to_cursor (_tmp9_, 0.25);
		_tmp10_ = main_window_get_active_view (self);
		_tmp11_ = _tmp10_;
		gtk_widget_grab_focus ((GtkWidget*) _tmp11_);
	}
}


void main_window_on_edit_redo (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	Document* _tmp2_;
	Document* _tmp3_;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	g_return_if_fail (_tmp1_ != NULL);
	_tmp2_ = main_window_get_active_document (self);
	_tmp3_ = _tmp2_;
	g_object_get ((GtkSourceBuffer*) _tmp3_, "can-redo", &_tmp4_, NULL);
	_tmp5_ = _tmp4_;
	if (_tmp5_) {
		Document* _tmp6_;
		Document* _tmp7_;
		DocumentView* _tmp8_;
		DocumentView* _tmp9_;
		DocumentView* _tmp10_;
		DocumentView* _tmp11_;
		_tmp6_ = main_window_get_active_document (self);
		_tmp7_ = _tmp6_;
		gtk_source_buffer_redo ((GtkSourceBuffer*) _tmp7_);
		_tmp8_ = main_window_get_active_view (self);
		_tmp9_ = _tmp8_;
		document_view_scroll_to_cursor (_tmp9_, 0.25);
		_tmp10_ = main_window_get_active_view (self);
		_tmp11_ = _tmp10_;
		gtk_widget_grab_focus ((GtkWidget*) _tmp11_);
	}
}


void main_window_on_edit_cut (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentView* _tmp2_;
	DocumentView* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	g_return_if_fail (_tmp1_ != NULL);
	_tmp2_ = main_window_get_active_view (self);
	_tmp3_ = _tmp2_;
	document_view_cut_selection (_tmp3_);
}


void main_window_on_edit_copy (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentView* _tmp2_;
	DocumentView* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	g_return_if_fail (_tmp1_ != NULL);
	_tmp2_ = main_window_get_active_view (self);
	_tmp3_ = _tmp2_;
	document_view_copy_selection (_tmp3_);
}


void main_window_on_edit_paste (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentView* _tmp2_;
	DocumentView* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	g_return_if_fail (_tmp1_ != NULL);
	_tmp2_ = main_window_get_active_view (self);
	_tmp3_ = _tmp2_;
	document_view_my_paste_clipboard (_tmp3_);
}


void main_window_on_edit_delete (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentView* _tmp2_;
	DocumentView* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	g_return_if_fail (_tmp1_ != NULL);
	_tmp2_ = main_window_get_active_view (self);
	_tmp3_ = _tmp2_;
	document_view_delete_selection (_tmp3_);
}


void main_window_on_edit_select_all (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentView* _tmp2_;
	DocumentView* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	g_return_if_fail (_tmp1_ != NULL);
	_tmp2_ = main_window_get_active_view (self);
	_tmp3_ = _tmp2_;
	document_view_my_select_all (_tmp3_);
}


void main_window_on_edit_comment (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	Document* _tmp2_;
	Document* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	g_return_if_fail (_tmp1_ != NULL);
	_tmp2_ = main_window_get_active_document (self);
	_tmp3_ = _tmp2_;
	document_comment_selected_lines (_tmp3_);
}


void main_window_on_edit_uncomment (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	Document* _tmp2_;
	Document* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	g_return_if_fail (_tmp1_ != NULL);
	_tmp2_ = main_window_get_active_document (self);
	_tmp3_ = _tmp2_;
	document_uncomment_selected_lines (_tmp3_);
}


void main_window_on_spell_checking (MainWindow* self, GtkAction* action) {
	GtkAction* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	gboolean activate;
	g_return_if_fail (self != NULL);
	g_return_if_fail (action != NULL);
	_tmp0_ = action;
	_tmp1_ = gtk_toggle_action_get_active (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, GTK_TYPE_TOGGLE_ACTION) ? ((GtkToggleAction*) _tmp0_) : NULL);
	_tmp2_ = _tmp1_;
	activate = _tmp2_;
	{
		GeeList* _tmp3_ = NULL;
		GeeList* _view_list;
		GeeList* _tmp4_;
		gint _tmp5_;
		gint _tmp6_;
		gint _view_size;
		gint _view_index;
		_tmp3_ = main_window_get_views (self);
		_view_list = _tmp3_;
		_tmp4_ = _view_list;
		_tmp5_ = gee_collection_get_size ((GeeCollection*) _tmp4_);
		_tmp6_ = _tmp5_;
		_view_size = _tmp6_;
		_view_index = -1;
		while (TRUE) {
			gint _tmp7_;
			gint _tmp8_;
			gint _tmp9_;
			GeeList* _tmp10_;
			gint _tmp11_;
			gpointer _tmp12_ = NULL;
			DocumentView* view;
			gboolean _tmp13_;
			_tmp7_ = _view_index;
			_view_index = _tmp7_ + 1;
			_tmp8_ = _view_index;
			_tmp9_ = _view_size;
			if (!(_tmp8_ < _tmp9_)) {
				break;
			}
			_tmp10_ = _view_list;
			_tmp11_ = _view_index;
			_tmp12_ = gee_list_get (_tmp10_, _tmp11_);
			view = (DocumentView*) _tmp12_;
			_tmp13_ = activate;
			if (_tmp13_) {
				DocumentView* _tmp14_;
				_tmp14_ = view;
				document_view_activate_spell_checking (_tmp14_);
			} else {
				DocumentView* _tmp15_;
				_tmp15_ = view;
				document_view_disable_spell_checking (_tmp15_);
			}
			_g_object_unref0 (view);
		}
		_g_object_unref0 (_view_list);
	}
}


void main_window_on_open_preferences (MainWindow* self) {
	g_return_if_fail (self != NULL);
	preferences_dialog_show_me (self);
}


void main_window_on_view_zoom_in (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentView* _tmp2_;
	DocumentView* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	g_return_if_fail (_tmp1_ != NULL);
	_tmp2_ = main_window_get_active_view (self);
	_tmp3_ = _tmp2_;
	document_view_enlarge_font (_tmp3_);
}


void main_window_on_view_zoom_out (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentView* _tmp2_;
	DocumentView* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	g_return_if_fail (_tmp1_ != NULL);
	_tmp2_ = main_window_get_active_view (self);
	_tmp3_ = _tmp2_;
	document_view_shrink_font (_tmp3_);
}


void main_window_on_view_zoom_reset (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentView* _tmp2_;
	DocumentView* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	g_return_if_fail (_tmp1_ != NULL);
	_tmp2_ = main_window_get_active_view (self);
	_tmp3_ = _tmp2_;
	document_view_set_font_from_settings (_tmp3_);
}


void main_window_on_search_find (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	SearchAndReplace* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	g_return_if_fail (_tmp1_ != NULL);
	_tmp2_ = self->priv->search_and_replace;
	search_and_replace_show_search (_tmp2_);
}


void main_window_on_search_replace (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	SearchAndReplace* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	g_return_if_fail (_tmp1_ != NULL);
	_tmp2_ = self->priv->search_and_replace;
	search_and_replace_show_search_and_replace (_tmp2_);
}


void main_window_on_search_goto_line (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	GotoLine* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	g_return_if_fail (_tmp1_ != NULL);
	_tmp2_ = self->priv->goto_line;
	goto_line_show (_tmp2_);
}


void main_window_on_documents_save_all (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	g_return_if_fail (_tmp1_ != NULL);
	{
		GeeList* _tmp2_ = NULL;
		GeeList* _doc_list;
		GeeList* _tmp3_;
		gint _tmp4_;
		gint _tmp5_;
		gint _doc_size;
		gint _doc_index;
		_tmp2_ = main_window_get_unsaved_documents (self);
		_doc_list = _tmp2_;
		_tmp3_ = _doc_list;
		_tmp4_ = gee_collection_get_size ((GeeCollection*) _tmp3_);
		_tmp5_ = _tmp4_;
		_doc_size = _tmp5_;
		_doc_index = -1;
		while (TRUE) {
			gint _tmp6_;
			gint _tmp7_;
			gint _tmp8_;
			GeeList* _tmp9_;
			gint _tmp10_;
			gpointer _tmp11_ = NULL;
			Document* doc;
			Document* _tmp12_;
			_tmp6_ = _doc_index;
			_doc_index = _tmp6_ + 1;
			_tmp7_ = _doc_index;
			_tmp8_ = _doc_size;
			if (!(_tmp7_ < _tmp8_)) {
				break;
			}
			_tmp9_ = _doc_list;
			_tmp10_ = _doc_index;
			_tmp11_ = gee_list_get (_tmp9_, _tmp10_);
			doc = (Document*) _tmp11_;
			_tmp12_ = doc;
			document_save (_tmp12_, TRUE, FALSE);
			_g_object_unref0 (doc);
		}
		_g_object_unref0 (_doc_list);
	}
}


void main_window_on_documents_close_all (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	g_return_if_fail (_tmp1_ != NULL);
	main_window_close_all_documents (self);
}


void main_window_on_documents_previous (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentsPanel* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	g_return_if_fail (_tmp1_ != NULL);
	_tmp2_ = self->priv->documents_panel;
	gtk_notebook_prev_page ((GtkNotebook*) _tmp2_);
}


void main_window_on_documents_next (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentsPanel* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	g_return_if_fail (_tmp1_ != NULL);
	_tmp2_ = self->priv->documents_panel;
	gtk_notebook_next_page ((GtkNotebook*) _tmp2_);
}


void main_window_on_documents_move_to_new_window (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentTab* _tmp2_;
	DocumentTab* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	g_return_if_fail (_tmp1_ != NULL);
	_tmp2_ = main_window_get_active_tab (self);
	_tmp3_ = _tmp2_;
	main_window_move_tab_to_new_window (self, _tmp3_);
}


void main_window_on_projects_new (MainWindow* self) {
	g_return_if_fail (self != NULL);
	project_dialogs_new_project (self);
}


void main_window_on_projects_config_current (MainWindow* self) {
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	Document* _tmp2_;
	Document* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	Document* _tmp6_;
	Document* _tmp7_;
	gint _tmp8_;
	gint _tmp9_;
	g_return_if_fail (self != NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	g_return_if_fail (_tmp1_ != NULL);
	_tmp2_ = main_window_get_active_document (self);
	_tmp3_ = _tmp2_;
	_tmp4_ = document_get_project_id (_tmp3_);
	_tmp5_ = _tmp4_;
	g_return_if_fail (_tmp5_ != (-1));
	_tmp6_ = main_window_get_active_document (self);
	_tmp7_ = _tmp6_;
	_tmp8_ = document_get_project_id (_tmp7_);
	_tmp9_ = _tmp8_;
	project_dialogs_configure_project ((GtkWindow*) self, _tmp9_);
}


void main_window_on_projects_manage (MainWindow* self) {
	g_return_if_fail (self != NULL);
	project_dialogs_manage_projects (self);
}


void main_window_on_help_contents (MainWindow* self) {
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	{
		GdkScreen* _tmp0_ = NULL;
		_tmp0_ = gtk_window_get_screen ((GtkWindow*) self);
		gtk_show_uri (_tmp0_, "ghelp:latexila", (guint32) GDK_CURRENT_TIME, &_inner_error_);
		if (_inner_error_ != NULL) {
			goto __catch18_g_error;
		}
	}
	goto __finally18;
	__catch18_g_error:
	{
		GError* e = NULL;
		GError* _tmp1_;
		const gchar* _tmp2_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp1_ = e;
		_tmp2_ = _tmp1_->message;
		g_warning ("main_window.vala:1535: Impossible to open the documentation: %s", _tmp2_);
		_g_error_free0 (e);
	}
	__finally18:
	if (_inner_error_ != NULL) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
}


void main_window_on_help_latex_reference (MainWindow* self) {
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	{
		gchar* _tmp0_ = NULL;
		gchar* _tmp1_;
		gchar* _tmp2_ = NULL;
		gchar* _tmp3_;
		gchar* uri;
		GdkScreen* _tmp4_ = NULL;
		const gchar* _tmp5_;
		_tmp0_ = g_build_filename (DATA_DIR, "latexhelp.html", NULL, NULL);
		_tmp1_ = _tmp0_;
		_tmp2_ = g_filename_to_uri (_tmp1_, NULL, &_inner_error_);
		_tmp3_ = _tmp2_;
		_g_free0 (_tmp1_);
		uri = _tmp3_;
		if (_inner_error_ != NULL) {
			goto __catch19_g_error;
		}
		_tmp4_ = gtk_window_get_screen ((GtkWindow*) self);
		_tmp5_ = uri;
		gtk_show_uri (_tmp4_, _tmp5_, (guint32) GDK_CURRENT_TIME, &_inner_error_);
		if (_inner_error_ != NULL) {
			_g_free0 (uri);
			goto __catch19_g_error;
		}
		_g_free0 (uri);
	}
	goto __finally19;
	__catch19_g_error:
	{
		GError* e = NULL;
		GError* _tmp6_;
		const gchar* _tmp7_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp6_ = e;
		_tmp7_ = _tmp6_->message;
		g_warning ("main_window.vala:1549: Impossible to open the LaTeX reference: %s", _tmp7_);
		_g_error_free0 (e);
	}
	__finally19:
	if (_inner_error_ != NULL) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
}


void main_window_on_about_dialog (MainWindow* self) {
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_;
	gchar* comments;
	gchar* _tmp2_;
	gchar* copyright;
	gchar* _tmp3_;
	gchar* website;
	gchar* _tmp4_;
	gchar** _tmp5_ = NULL;
	gchar** authors;
	gint authors_length1;
	gint _authors_size_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar** _tmp11_ = NULL;
	gchar** artists;
	gint artists_length1;
	gint _artists_size_;
	GdkPixbuf* logo;
	const gchar* _tmp16_ = NULL;
	const gchar* _tmp17_ = NULL;
	GdkPixbuf* _tmp18_;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = _ ("LaTeXila is an Integrated LaTeX Environment for the GNOME Desktop");
	_tmp1_ = g_strdup (_tmp0_);
	comments = _tmp1_;
	_tmp2_ = g_strdup ("Copyright (C) 2009-2012 Sébastien Wilmet");
	copyright = _tmp2_;
	_tmp3_ = g_strdup ("http://projects.gnome.org/latexila/");
	website = _tmp3_;
	_tmp4_ = g_strdup ("Sébastien Wilmet <sebastien.wilmet@gmail.com>");
	_tmp5_ = g_new0 (gchar*, 2 + 1);
	_tmp5_[0] = _tmp4_;
	_tmp5_[1] = NULL;
	authors = _tmp5_;
	authors_length1 = 2;
	_authors_size_ = authors_length1;
	_tmp6_ = g_strdup ("Ann Melnichuk <melnichu@qtp.ufl.edu>");
	_tmp7_ = g_strdup ("Eric Forgeot <e.forgeot@laposte.net>");
	_tmp8_ = g_strdup ("Sébastien Wilmet <sebastien.wilmet@gmail.com>");
	_tmp9_ = g_strdup ("The Kile Team http://kile.sourceforge.net/");
	_tmp10_ = g_strdup ("Gedit LaTeX Plugin http://live.gnome.org/Gedit/LaTeXPlugin");
	_tmp11_ = g_new0 (gchar*, 6 + 1);
	_tmp11_[0] = _tmp6_;
	_tmp11_[1] = _tmp7_;
	_tmp11_[2] = _tmp8_;
	_tmp11_[3] = _tmp9_;
	_tmp11_[4] = _tmp10_;
	_tmp11_[5] = NULL;
	artists = _tmp11_;
	artists_length1 = 6;
	_artists_size_ = artists_length1;
	logo = NULL;
	{
		GdkPixbuf* _tmp12_;
		GdkPixbuf* _tmp13_;
		_tmp12_ = gdk_pixbuf_new_from_file (DATA_DIR "/images/app/logo.png", &_inner_error_);
		_tmp13_ = _tmp12_;
		if (_inner_error_ != NULL) {
			goto __catch20_g_error;
		}
		_g_object_unref0 (logo);
		logo = _tmp13_;
	}
	goto __finally20;
	__catch20_g_error:
	{
		GError* e = NULL;
		GError* _tmp14_;
		const gchar* _tmp15_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp14_ = e;
		_tmp15_ = _tmp14_->message;
		g_warning ("main_window.vala:1584: Logo: %s", _tmp15_);
		_g_error_free0 (e);
	}
	__finally20:
	if (_inner_error_ != NULL) {
		_g_object_unref0 (logo);
		artists = (_vala_array_free (artists, artists_length1, (GDestroyNotify) g_free), NULL);
		authors = (_vala_array_free (authors, authors_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (website);
		_g_free0 (copyright);
		_g_free0 (comments);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
	_tmp16_ = _ ("About LaTeXila");
	_tmp17_ = _ ("translator-credits");
	_tmp18_ = logo;
	gtk_show_about_dialog ((GtkWindow*) self, "program-name", "LaTeXila", "version", APP_VERSION, "authors", authors, "artists", artists, "comments", comments, "copyright", copyright, "license-type", GTK_LICENSE_GPL_3_0, "title", _tmp16_, "translator-credits", _tmp17_, "website", website, "logo", _tmp18_, NULL, NULL);
	_g_object_unref0 (logo);
	artists = (_vala_array_free (artists, artists_length1, (GDestroyNotify) g_free), NULL);
	authors = (_vala_array_free (authors, authors_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (website);
	_g_free0 (copyright);
	_g_free0 (comments);
}


DocumentTab* main_window_get_active_tab (MainWindow* self) {
	DocumentTab* result;
	gboolean _tmp0_ = FALSE;
	DocumentsPanel* _tmp1_;
	gboolean _tmp4_;
	DocumentsPanel* _tmp5_;
	DocumentTab* _tmp6_;
	DocumentTab* _tmp7_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp1_ = self->priv->documents_panel;
	if (_tmp1_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		DocumentsPanel* _tmp2_;
		gint _tmp3_ = 0;
		_tmp2_ = self->priv->documents_panel;
		_tmp3_ = gtk_notebook_get_n_pages ((GtkNotebook*) _tmp2_);
		_tmp0_ = _tmp3_ == 0;
	}
	_tmp4_ = _tmp0_;
	if (_tmp4_) {
		result = NULL;
		return result;
	}
	_tmp5_ = self->priv->documents_panel;
	_tmp6_ = documents_panel_get_active_tab (_tmp5_);
	_tmp7_ = _tmp6_;
	result = _tmp7_;
	return result;
}


void main_window_set_active_tab (MainWindow* self, DocumentTab* value) {
	DocumentsPanel* _tmp0_;
	DocumentTab* _tmp1_;
	gint _tmp2_ = 0;
	gint n;
	gint _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->documents_panel;
	_tmp1_ = value;
	_tmp2_ = gtk_notebook_page_num ((GtkNotebook*) _tmp0_, (GtkWidget*) _tmp1_);
	n = _tmp2_;
	_tmp3_ = n;
	if (_tmp3_ != (-1)) {
		DocumentsPanel* _tmp4_;
		gint _tmp5_;
		_tmp4_ = self->priv->documents_panel;
		_tmp5_ = n;
		gtk_notebook_set_current_page ((GtkNotebook*) _tmp4_, _tmp5_);
	}
	g_object_notify ((GObject *) self, "active-tab");
}


DocumentView* main_window_get_active_view (MainWindow* self) {
	DocumentView* result;
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentTab* _tmp2_;
	DocumentTab* _tmp3_;
	DocumentView* _tmp4_;
	DocumentView* _tmp5_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	if (_tmp1_ == NULL) {
		result = NULL;
		return result;
	}
	_tmp2_ = main_window_get_active_tab (self);
	_tmp3_ = _tmp2_;
	_tmp4_ = document_tab_get_view (_tmp3_);
	_tmp5_ = _tmp4_;
	result = _tmp5_;
	return result;
}


Document* main_window_get_active_document (MainWindow* self) {
	Document* result;
	DocumentTab* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentTab* _tmp2_;
	DocumentTab* _tmp3_;
	Document* _tmp4_;
	Document* _tmp5_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = main_window_get_active_tab (self);
	_tmp1_ = _tmp0_;
	if (_tmp1_ == NULL) {
		result = NULL;
		return result;
	}
	_tmp2_ = main_window_get_active_tab (self);
	_tmp3_ = _tmp2_;
	_tmp4_ = document_tab_get_document (_tmp3_);
	_tmp5_ = _tmp4_;
	result = _tmp5_;
	return result;
}


static void main_window_class_init (MainWindowClass * klass) {
	main_window_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (MainWindowPrivate));
	G_OBJECT_CLASS (klass)->get_property = _vala_main_window_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_main_window_set_property;
	G_OBJECT_CLASS (klass)->finalize = main_window_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), MAIN_WINDOW_ACTIVE_TAB, g_param_spec_object ("active-tab", "active-tab", "active-tab", TYPE_DOCUMENT_TAB, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), MAIN_WINDOW_ACTIVE_VIEW, g_param_spec_object ("active-view", "active-view", "active-view", TYPE_DOCUMENT_VIEW, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), MAIN_WINDOW_ACTIVE_DOCUMENT, g_param_spec_object ("active-document", "active-document", "active-document", TYPE_DOCUMENT, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
}


static void main_window_instance_init (MainWindow * self) {
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_;
	self->priv = MAIN_WINDOW_GET_PRIVATE (self);
	_tmp0_ = g_get_home_dir ();
	_tmp1_ = g_strdup (_tmp0_);
	self->priv->file_chooser_current_folder = _tmp1_;
}


static void main_window_finalize (GObject* obj) {
	MainWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_MAIN_WINDOW, MainWindow);
	_g_free0 (self->priv->file_chooser_current_folder);
	_g_object_unref0 (self->priv->documents_panel);
	_g_object_unref0 (self->priv->statusbar);
	_g_object_unref0 (self->priv->goto_line);
	_g_object_unref0 (self->priv->search_and_replace);
	_g_object_unref0 (self->priv->_main_toolbar);
	_g_object_unref0 (self->priv->_edit_toolbar);
	_g_object_unref0 (self->priv->_side_panel);
	_g_object_unref0 (self->priv->_symbols);
	_g_object_unref0 (self->priv->main_hpaned);
	_g_object_unref0 (self->priv->vpaned);
	_g_object_unref0 (self->priv->ui_manager);
	_g_object_unref0 (self->priv->action_group);
	_g_object_unref0 (self->priv->latex_action_group);
	_g_object_unref0 (self->priv->documents_list_action_group);
	_main_window_build_tools_unref0 (self->priv->_main_window_build_tools);
	_main_window_structure_unref0 (self->priv->_main_window_structure);
	G_OBJECT_CLASS (main_window_parent_class)->finalize (obj);
}


GType main_window_get_type (void) {
	static volatile gsize main_window_type_id__volatile = 0;
	if (g_once_init_enter (&main_window_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (MainWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) main_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MainWindow), 0, (GInstanceInitFunc) main_window_instance_init, NULL };
		GType main_window_type_id;
		main_window_type_id = g_type_register_static (GTK_TYPE_WINDOW, "MainWindow", &g_define_type_info, 0);
		g_once_init_leave (&main_window_type_id__volatile, main_window_type_id);
	}
	return main_window_type_id__volatile;
}


static void _vala_main_window_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	MainWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_MAIN_WINDOW, MainWindow);
	switch (property_id) {
		case MAIN_WINDOW_ACTIVE_TAB:
		g_value_set_object (value, main_window_get_active_tab (self));
		break;
		case MAIN_WINDOW_ACTIVE_VIEW:
		g_value_set_object (value, main_window_get_active_view (self));
		break;
		case MAIN_WINDOW_ACTIVE_DOCUMENT:
		g_value_set_object (value, main_window_get_active_document (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_main_window_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	MainWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_MAIN_WINDOW, MainWindow);
	switch (property_id) {
		case MAIN_WINDOW_ACTIVE_TAB:
		main_window_set_active_tab (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}


static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}


static gint _vala_array_length (gpointer array) {
	int length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}



