/* main_window_file.c generated by valac 0.18.0.1-c1117, the Vala compiler
 * generated from main_window_file.vala, do not modify */

/*
 * This file is part of LaTeXila.
 *
 * Copyright © 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/>.
 *
 * Author: Sébastien Wilmet
 */

#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include "config.h"
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <gtksourceview/gtksource.h>
#include <gobject/gvaluecollector.h>


#define TYPE_MAIN_WINDOW_FILE (main_window_file_get_type ())
#define MAIN_WINDOW_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MAIN_WINDOW_FILE, MainWindowFile))
#define MAIN_WINDOW_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MAIN_WINDOW_FILE, MainWindowFileClass))
#define IS_MAIN_WINDOW_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MAIN_WINDOW_FILE))
#define IS_MAIN_WINDOW_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MAIN_WINDOW_FILE))
#define MAIN_WINDOW_FILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MAIN_WINDOW_FILE, MainWindowFileClass))

typedef struct _MainWindowFile MainWindowFile;
typedef struct _MainWindowFileClass MainWindowFileClass;
typedef struct _MainWindowFilePrivate MainWindowFilePrivate;

#define TYPE_MAIN_WINDOW (main_window_get_type ())
#define MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MAIN_WINDOW, MainWindow))
#define MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MAIN_WINDOW, MainWindowClass))
#define IS_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MAIN_WINDOW))
#define IS_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MAIN_WINDOW))
#define MAIN_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MAIN_WINDOW, MainWindowClass))

typedef struct _MainWindow MainWindow;
typedef struct _MainWindowClass MainWindowClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define TYPE_DOCUMENT_TAB (document_tab_get_type ())
#define DOCUMENT_TAB(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DOCUMENT_TAB, DocumentTab))
#define DOCUMENT_TAB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DOCUMENT_TAB, DocumentTabClass))
#define IS_DOCUMENT_TAB(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DOCUMENT_TAB))
#define IS_DOCUMENT_TAB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DOCUMENT_TAB))
#define DOCUMENT_TAB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DOCUMENT_TAB, DocumentTabClass))

typedef struct _DocumentTab DocumentTab;
typedef struct _DocumentTabClass DocumentTabClass;
#define _g_free0(var) (var = (g_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 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;
typedef struct _MainWindowPrivate MainWindowPrivate;
#define __g_slist_free__g_object_unref0_0(var) ((var == NULL) ? NULL : (var = (_g_slist_free__g_object_unref0_ (var), NULL)))

#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_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;
typedef struct _ParamSpecMainWindowFile ParamSpecMainWindowFile;

struct _MainWindowFile {
	GTypeInstance parent_instance;
	volatile int ref_count;
	MainWindowFilePrivate * priv;
};

struct _MainWindowFileClass {
	GTypeClass parent_class;
	void (*finalize) (MainWindowFile *self);
};

struct _MainWindowFilePrivate {
	MainWindow* _main_window;
	GtkActionGroup* _action_group;
};

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

struct _MainWindowClass {
	GtkWindowClass parent_class;
};

struct _ParamSpecMainWindowFile {
	GParamSpec parent_instance;
};


static gpointer main_window_file_parent_class = NULL;

gpointer main_window_file_ref (gpointer instance);
void main_window_file_unref (gpointer instance);
GParamSpec* param_spec_main_window_file (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void value_set_main_window_file (GValue* value, gpointer v_object);
void value_take_main_window_file (GValue* value, gpointer v_object);
gpointer value_get_main_window_file (const GValue* value);
GType main_window_file_get_type (void) G_GNUC_CONST;
GType main_window_get_type (void) G_GNUC_CONST;
#define MAIN_WINDOW_FILE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_MAIN_WINDOW_FILE, MainWindowFilePrivate))
enum  {
	MAIN_WINDOW_FILE_DUMMY_PROPERTY
};
void main_window_file_on_file_new (MainWindowFile* self);
static void _main_window_file_on_file_new_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_file_on_new_window (MainWindowFile* self);
static void _main_window_file_on_new_window_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_file_on_file_open (MainWindowFile* self);
static void _main_window_file_on_file_open_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_file_on_file_save (MainWindowFile* self);
static void _main_window_file_on_file_save_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_file_on_file_save_as (MainWindowFile* self);
static void _main_window_file_on_file_save_as_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_file_on_create_template (MainWindowFile* self);
static void _main_window_file_on_create_template_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_file_on_delete_template (MainWindowFile* self);
static void _main_window_file_on_delete_template_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_file_on_file_close (MainWindowFile* self);
static void _main_window_file_on_file_close_gtk_action_callback (GtkAction* action, gpointer self);
MainWindowFile* main_window_file_new (MainWindow* main_window, GtkUIManager* ui_manager);
MainWindowFile* main_window_file_construct (GType object_type, MainWindow* main_window, GtkUIManager* ui_manager);
static void main_window_file_configure_recent_chooser (MainWindowFile* self, GtkRecentChooser* recent_chooser);
GtkToolItem* main_window_file_get_toolbar_open_button (MainWindowFile* self);
static void __lambda113_ (MainWindowFile* self, GtkRecentChooser* chooser);
GType document_tab_get_type (void) G_GNUC_CONST;
DocumentTab* main_window_open_document (MainWindow* self, GFile* location, gboolean jump_to);
static void ___lambda113__gtk_recent_chooser_item_activated (GtkRecentChooser* _sender, gpointer self);
void main_window_file_update_sensitivity (MainWindowFile* self, gboolean sensitive);
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;
GType latexila_get_type (void) G_GNUC_CONST;
Latexila* latexila_get_instance (void);
MainWindow* latexila_create_window (Latexila* self);
static void _g_object_unref0_ (gpointer var);
static void _g_slist_free__g_object_unref0_ (GSList* self);
DocumentTab* main_window_get_active_tab (MainWindow* self);
GType document_get_type (void) G_GNUC_CONST;
gboolean main_window_save_document (MainWindow* self, Document* doc, gboolean force_save_as);
Document* main_window_get_active_document (MainWindow* 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;
gboolean main_window_close_tab (MainWindow* self, DocumentTab* tab, gboolean force_close);
static void main_window_file_finalize (MainWindowFile* obj);
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 const GtkActionEntry MAIN_WINDOW_FILE__action_entries[9] = {{"File", NULL, "_File"}, {"FileNew", GTK_STOCK_NEW, NULL, NULL, "New file", (GCallback) _main_window_file_on_file_new_gtk_action_callback}, {"FileNewWindow", NULL, "New _Window", NULL, "Create a new window", (GCallback) _main_window_file_on_new_window_gtk_action_callback}, {"FileOpen", GTK_STOCK_OPEN, NULL, NULL, "Open a file", (GCallback) _main_window_file_on_file_open_gtk_action_callback}, {"FileSave", GTK_STOCK_SAVE, NULL, NULL, "Save the current file", (GCallback) _main_window_file_on_file_save_gtk_action_callback}, {"FileSaveAs", GTK_STOCK_SAVE_AS, NULL, NULL, "Save the current file with a different name", (GCallback) _main_window_file_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_file_on_create_template_gtk_action_callback}, {"FileDeleteTemplate", NULL, "_Delete Template...", NULL, "Delete personal template(s)", (GCallback) _main_window_file_on_delete_template_gtk_action_callback}, {"FileClose", GTK_STOCK_CLOSE, NULL, NULL, "Close the current file", (GCallback) _main_window_file_on_file_close_gtk_action_callback}};

static void _main_window_file_on_file_new_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_file_on_file_new (self);
}


static void _main_window_file_on_new_window_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_file_on_new_window (self);
}


static void _main_window_file_on_file_open_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_file_on_file_open (self);
}


static void _main_window_file_on_file_save_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_file_on_file_save (self);
}


static void _main_window_file_on_file_save_as_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_file_on_file_save_as (self);
}


static void _main_window_file_on_create_template_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_file_on_create_template (self);
}


static void _main_window_file_on_delete_template_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_file_on_delete_template (self);
}


static void _main_window_file_on_file_close_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_file_on_file_close (self);
}


MainWindowFile* main_window_file_construct (GType object_type, MainWindow* main_window, GtkUIManager* ui_manager) {
	MainWindowFile* self = NULL;
	MainWindow* _tmp0_;
	GtkActionGroup* _tmp1_;
	GtkActionGroup* _tmp2_;
	GtkActionGroup* _tmp3_;
	const gchar* _tmp4_ = NULL;
	const gchar* _tmp5_ = NULL;
	GtkRecentAction* _tmp6_;
	GtkAction* recent_action;
	GtkActionGroup* _tmp7_;
	GtkUIManager* _tmp8_;
	GtkActionGroup* _tmp9_;
	g_return_val_if_fail (main_window != NULL, NULL);
	g_return_val_if_fail (ui_manager != NULL, NULL);
	self = (MainWindowFile*) g_type_create_instance (object_type);
	_tmp0_ = main_window;
	self->priv->_main_window = _tmp0_;
	_tmp1_ = gtk_action_group_new ("FileMenuActionGroup");
	_g_object_unref0 (self->priv->_action_group);
	self->priv->_action_group = _tmp1_;
	_tmp2_ = self->priv->_action_group;
	gtk_action_group_set_translation_domain (_tmp2_, GETTEXT_PACKAGE);
	_tmp3_ = self->priv->_action_group;
	gtk_action_group_add_actions (_tmp3_, MAIN_WINDOW_FILE__action_entries, G_N_ELEMENTS (MAIN_WINDOW_FILE__action_entries), self);
	_tmp4_ = _ ("Open _Recent");
	_tmp5_ = _ ("Open recently used files");
	_tmp6_ = (GtkRecentAction*) gtk_recent_action_new ("FileOpenRecent", _tmp4_, _tmp5_, "");
	recent_action = (GtkAction*) _tmp6_;
	main_window_file_configure_recent_chooser (self, G_TYPE_CHECK_INSTANCE_TYPE (recent_action, GTK_TYPE_RECENT_CHOOSER) ? ((GtkRecentChooser*) recent_action) : NULL);
	_tmp7_ = self->priv->_action_group;
	gtk_action_group_add_action (_tmp7_, recent_action);
	_tmp8_ = ui_manager;
	_tmp9_ = self->priv->_action_group;
	gtk_ui_manager_insert_action_group (_tmp8_, _tmp9_, 0);
	_g_object_unref0 (recent_action);
	return self;
}


MainWindowFile* main_window_file_new (MainWindow* main_window, GtkUIManager* ui_manager) {
	return main_window_file_construct (TYPE_MAIN_WINDOW_FILE, main_window, ui_manager);
}


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


GtkToolItem* main_window_file_get_toolbar_open_button (MainWindowFile* self) {
	GtkToolItem* result = NULL;
	GtkRecentManager* _tmp0_ = NULL;
	GtkRecentManager* _tmp1_;
	GtkRecentManager* recent_manager;
	GtkRecentChooserMenu* _tmp2_;
	GtkWidget* recent_menu;
	GtkMenuToolButton* _tmp3_;
	GtkMenuToolButton* open_button;
	const gchar* _tmp4_ = NULL;
	const gchar* _tmp5_ = NULL;
	GtkActionGroup* _tmp6_;
	GtkAction* _tmp7_ = NULL;
	GtkAction* _tmp8_;
	GtkAction* action;
	g_return_val_if_fail (self != NULL, 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_);
	recent_menu = (GtkWidget*) _tmp2_;
	main_window_file_configure_recent_chooser (self, G_TYPE_CHECK_INSTANCE_TYPE (recent_menu, GTK_TYPE_RECENT_CHOOSER) ? ((GtkRecentChooser*) recent_menu) : NULL);
	_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, 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);
	result = (GtkToolItem*) open_button;
	_g_object_unref0 (action);
	_g_object_unref0 (recent_menu);
	_g_object_unref0 (recent_manager);
	return result;
}


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


static void ___lambda113__gtk_recent_chooser_item_activated (GtkRecentChooser* _sender, gpointer self) {
	__lambda113_ (self, _sender);
}


static void main_window_file_configure_recent_chooser (MainWindowFile* 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, PACKAGE_NAME);
	_tmp3_ = recent_chooser;
	gtk_recent_chooser_set_filter (_tmp3_, filter);
	_tmp4_ = recent_chooser;
	g_signal_connect (_tmp4_, "item-activated", (GCallback) ___lambda113__gtk_recent_chooser_item_activated, self);
	_g_object_unref0 (filter);
}


void main_window_file_update_sensitivity (MainWindowFile* self, gboolean sensitive) {
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar** _tmp4_ = NULL;
	gchar** action_names;
	gint action_names_length1;
	gint _action_names_size_;
	gchar** _tmp5_;
	gint _tmp5__length1;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup ("FileSave");
	_tmp1_ = g_strdup ("FileSaveAs");
	_tmp2_ = g_strdup ("FileClose");
	_tmp3_ = g_strdup ("FileCreateTemplate");
	_tmp4_ = g_new0 (gchar*, 4 + 1);
	_tmp4_[0] = _tmp0_;
	_tmp4_[1] = _tmp1_;
	_tmp4_[2] = _tmp2_;
	_tmp4_[3] = _tmp3_;
	action_names = _tmp4_;
	action_names_length1 = 4;
	_action_names_size_ = action_names_length1;
	_tmp5_ = action_names;
	_tmp5__length1 = action_names_length1;
	{
		gchar** action_name_collection = NULL;
		gint action_name_collection_length1 = 0;
		gint _action_name_collection_size_ = 0;
		gint action_name_it = 0;
		action_name_collection = _tmp5_;
		action_name_collection_length1 = _tmp5__length1;
		for (action_name_it = 0; action_name_it < _tmp5__length1; action_name_it = action_name_it + 1) {
			gchar* _tmp6_;
			gchar* action_name = NULL;
			_tmp6_ = g_strdup (action_name_collection[action_name_it]);
			action_name = _tmp6_;
			{
				GtkActionGroup* _tmp7_;
				const gchar* _tmp8_;
				GtkAction* _tmp9_ = NULL;
				GtkAction* _tmp10_;
				GtkAction* action;
				GtkAction* _tmp11_;
				gboolean _tmp12_;
				_tmp7_ = self->priv->_action_group;
				_tmp8_ = action_name;
				_tmp9_ = gtk_action_group_get_action (_tmp7_, _tmp8_);
				_tmp10_ = _g_object_ref0 (_tmp9_);
				action = _tmp10_;
				_tmp11_ = action;
				_tmp12_ = sensitive;
				gtk_action_set_sensitive (_tmp11_, _tmp12_);
				_g_object_unref0 (action);
				_g_free0 (action_name);
			}
		}
	}
	action_names = (_vala_array_free (action_names, action_names_length1, (GDestroyNotify) g_free), NULL);
}


void main_window_file_on_file_new (MainWindowFile* self) {
	MainWindow* _tmp0_;
	OpenTemplateDialog* _tmp1_;
	OpenTemplateDialog* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_main_window;
	_tmp1_ = open_template_dialog_new (_tmp0_);
	_tmp2_ = _tmp1_;
	_open_template_dialog_unref0 (_tmp2_);
}


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


void main_window_file_on_file_save_as (MainWindowFile* self) {
	MainWindow* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentTab* _tmp2_;
	MainWindow* _tmp3_;
	MainWindow* _tmp4_;
	Document* _tmp5_;
	Document* _tmp6_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_main_window;
	_tmp1_ = main_window_get_active_tab (_tmp0_);
	_tmp2_ = _tmp1_;
	g_return_if_fail (_tmp2_ != NULL);
	_tmp3_ = self->priv->_main_window;
	_tmp4_ = self->priv->_main_window;
	_tmp5_ = main_window_get_active_document (_tmp4_);
	_tmp6_ = _tmp5_;
	main_window_save_document (_tmp3_, _tmp6_, TRUE);
}


void main_window_file_on_create_template (MainWindowFile* self) {
	MainWindow* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentTab* _tmp2_;
	MainWindow* _tmp3_;
	CreateTemplateDialog* _tmp4_;
	CreateTemplateDialog* dialog;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_main_window;
	_tmp1_ = main_window_get_active_tab (_tmp0_);
	_tmp2_ = _tmp1_;
	g_return_if_fail (_tmp2_ != NULL);
	_tmp3_ = self->priv->_main_window;
	_tmp4_ = create_template_dialog_new (_tmp3_);
	g_object_ref_sink (_tmp4_);
	dialog = _tmp4_;
	gtk_widget_destroy ((GtkWidget*) dialog);
	_g_object_unref0 (dialog);
}


void main_window_file_on_delete_template (MainWindowFile* self) {
	MainWindow* _tmp0_;
	DeleteTemplateDialog* _tmp1_;
	DeleteTemplateDialog* dialog;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_main_window;
	_tmp1_ = delete_template_dialog_new (_tmp0_);
	g_object_ref_sink (_tmp1_);
	dialog = _tmp1_;
	gtk_widget_destroy ((GtkWidget*) dialog);
	_g_object_unref0 (dialog);
}


void main_window_file_on_file_close (MainWindowFile* self) {
	MainWindow* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentTab* _tmp2_;
	MainWindow* _tmp3_;
	MainWindow* _tmp4_;
	DocumentTab* _tmp5_;
	DocumentTab* _tmp6_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_main_window;
	_tmp1_ = main_window_get_active_tab (_tmp0_);
	_tmp2_ = _tmp1_;
	g_return_if_fail (_tmp2_ != NULL);
	_tmp3_ = self->priv->_main_window;
	_tmp4_ = self->priv->_main_window;
	_tmp5_ = main_window_get_active_tab (_tmp4_);
	_tmp6_ = _tmp5_;
	main_window_close_tab (_tmp3_, _tmp6_, FALSE);
}


static void value_main_window_file_init (GValue* value) {
	value->data[0].v_pointer = NULL;
}


static void value_main_window_file_free_value (GValue* value) {
	if (value->data[0].v_pointer) {
		main_window_file_unref (value->data[0].v_pointer);
	}
}


static void value_main_window_file_copy_value (const GValue* src_value, GValue* dest_value) {
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = main_window_file_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}


static gpointer value_main_window_file_peek_pointer (const GValue* value) {
	return value->data[0].v_pointer;
}


static gchar* value_main_window_file_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	if (collect_values[0].v_pointer) {
		MainWindowFile* object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = main_window_file_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}


static gchar* value_main_window_file_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	MainWindowFile** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = main_window_file_ref (value->data[0].v_pointer);
	}
	return NULL;
}


GParamSpec* param_spec_main_window_file (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
	ParamSpecMainWindowFile* spec;
	g_return_val_if_fail (g_type_is_a (object_type, TYPE_MAIN_WINDOW_FILE), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}


gpointer value_get_main_window_file (const GValue* value) {
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_MAIN_WINDOW_FILE), NULL);
	return value->data[0].v_pointer;
}


void value_set_main_window_file (GValue* value, gpointer v_object) {
	MainWindowFile* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_MAIN_WINDOW_FILE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_MAIN_WINDOW_FILE));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		main_window_file_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		main_window_file_unref (old);
	}
}


void value_take_main_window_file (GValue* value, gpointer v_object) {
	MainWindowFile* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_MAIN_WINDOW_FILE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_MAIN_WINDOW_FILE));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		main_window_file_unref (old);
	}
}


static void main_window_file_class_init (MainWindowFileClass * klass) {
	main_window_file_parent_class = g_type_class_peek_parent (klass);
	MAIN_WINDOW_FILE_CLASS (klass)->finalize = main_window_file_finalize;
	g_type_class_add_private (klass, sizeof (MainWindowFilePrivate));
}


static void main_window_file_instance_init (MainWindowFile * self) {
	self->priv = MAIN_WINDOW_FILE_GET_PRIVATE (self);
	self->ref_count = 1;
}


static void main_window_file_finalize (MainWindowFile* obj) {
	MainWindowFile * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_MAIN_WINDOW_FILE, MainWindowFile);
	_g_object_unref0 (self->priv->_action_group);
}


GType main_window_file_get_type (void) {
	static volatile gsize main_window_file_type_id__volatile = 0;
	if (g_once_init_enter (&main_window_file_type_id__volatile)) {
		static const GTypeValueTable g_define_type_value_table = { value_main_window_file_init, value_main_window_file_free_value, value_main_window_file_copy_value, value_main_window_file_peek_pointer, "p", value_main_window_file_collect_value, "p", value_main_window_file_lcopy_value };
		static const GTypeInfo g_define_type_info = { sizeof (MainWindowFileClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) main_window_file_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MainWindowFile), 0, (GInstanceInitFunc) main_window_file_instance_init, &g_define_type_value_table };
		static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
		GType main_window_file_type_id;
		main_window_file_type_id = g_type_register_fundamental (g_type_fundamental_next (), "MainWindowFile", &g_define_type_info, &g_define_type_fundamental_info, 0);
		g_once_init_leave (&main_window_file_type_id__volatile, main_window_file_type_id);
	}
	return main_window_file_type_id__volatile;
}


gpointer main_window_file_ref (gpointer instance) {
	MainWindowFile* self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}


void main_window_file_unref (gpointer instance) {
	MainWindowFile* self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		MAIN_WINDOW_FILE_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}


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);
}



