/* main_window_edit.c generated by valac 0.18.0.1-c1117, the Vala compiler
 * generated from main_window_edit.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 <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <gtksourceview/gtksource.h>
#include <float.h>
#include <math.h>
#include <gee.h>
#include <gobject/gvaluecollector.h>


#define TYPE_MAIN_WINDOW_EDIT (main_window_edit_get_type ())
#define MAIN_WINDOW_EDIT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MAIN_WINDOW_EDIT, MainWindowEdit))
#define MAIN_WINDOW_EDIT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MAIN_WINDOW_EDIT, MainWindowEditClass))
#define IS_MAIN_WINDOW_EDIT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MAIN_WINDOW_EDIT))
#define IS_MAIN_WINDOW_EDIT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MAIN_WINDOW_EDIT))
#define MAIN_WINDOW_EDIT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MAIN_WINDOW_EDIT, MainWindowEditClass))

typedef struct _MainWindowEdit MainWindowEdit;
typedef struct _MainWindowEditClass MainWindowEditClass;
typedef struct _MainWindowEditPrivate MainWindowEditPrivate;

#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_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_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;
typedef struct _ParamSpecMainWindowEdit ParamSpecMainWindowEdit;

struct _MainWindowEdit {
	GTypeInstance parent_instance;
	volatile int ref_count;
	MainWindowEditPrivate * priv;
};

struct _MainWindowEditClass {
	GTypeClass parent_class;
	void (*finalize) (MainWindowEdit *self);
};

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

struct _ParamSpecMainWindowEdit {
	GParamSpec parent_instance;
};


static gpointer main_window_edit_parent_class = NULL;

gpointer main_window_edit_ref (gpointer instance);
void main_window_edit_unref (gpointer instance);
GParamSpec* param_spec_main_window_edit (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void value_set_main_window_edit (GValue* value, gpointer v_object);
void value_take_main_window_edit (GValue* value, gpointer v_object);
gpointer value_get_main_window_edit (const GValue* value);
GType main_window_edit_get_type (void) G_GNUC_CONST;
GType main_window_get_type (void) G_GNUC_CONST;
#define MAIN_WINDOW_EDIT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_MAIN_WINDOW_EDIT, MainWindowEditPrivate))
enum  {
	MAIN_WINDOW_EDIT_DUMMY_PROPERTY
};
void main_window_edit_on_undo (MainWindowEdit* self);
static void _main_window_edit_on_undo_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_edit_on_redo (MainWindowEdit* self);
static void _main_window_edit_on_redo_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_edit_on_cut (MainWindowEdit* self);
static void _main_window_edit_on_cut_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_edit_on_copy (MainWindowEdit* self);
static void _main_window_edit_on_copy_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_edit_on_paste (MainWindowEdit* self);
static void _main_window_edit_on_paste_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_edit_on_delete (MainWindowEdit* self);
static void _main_window_edit_on_delete_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_edit_on_select_all (MainWindowEdit* self);
static void _main_window_edit_on_select_all_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_edit_on_comment (MainWindowEdit* self);
static void _main_window_edit_on_comment_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_edit_on_uncomment (MainWindowEdit* self);
static void _main_window_edit_on_uncomment_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_edit_on_open_preferences (MainWindowEdit* self);
static void _main_window_edit_on_open_preferences_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_edit_on_spell_checking (MainWindowEdit* self, GtkAction* action);
static void _main_window_edit_on_spell_checking_gtk_action_callback (GtkAction* action, gpointer self);
MainWindowEdit* main_window_edit_new (MainWindow* main_window, GtkUIManager* ui_manager);
MainWindowEdit* main_window_edit_construct (GType object_type, MainWindow* main_window, GtkUIManager* ui_manager);
void main_window_edit_update_sensitivity (MainWindowEdit* self);
GType document_tab_get_type (void) G_GNUC_CONST;
DocumentTab* main_window_get_active_tab (MainWindow* self);
static void main_window_edit_set_edit_actions_sensitivity (MainWindowEdit* self, gboolean sensitive);
static void main_window_edit_set_has_selection_sensitivity (MainWindowEdit* self);
static void main_window_edit_set_undo_sensitivity (MainWindowEdit* self);
static void main_window_edit_set_redo_sensitivity (MainWindowEdit* self);
GType document_get_type (void) G_GNUC_CONST;
Document* main_window_get_active_document (MainWindow* self);
GType document_view_get_type (void) G_GNUC_CONST;
DocumentView* main_window_get_active_view (MainWindow* self);
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);
GeeList* main_window_get_views (MainWindow* self);
void document_view_activate_spell_checking (DocumentView* self);
void document_view_disable_spell_checking (DocumentView* self);
void preferences_dialog_show_me (MainWindow* parent);
static void main_window_edit_finalize (MainWindowEdit* 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_EDIT__action_entries[11] = {{"Edit", NULL, "_Edit"}, {"EditUndo", GTK_STOCK_UNDO, NULL, "<Control>Z", "Undo the last action", (GCallback) _main_window_edit_on_undo_gtk_action_callback}, {"EditRedo", GTK_STOCK_REDO, NULL, "<Shift><Control>Z", "Redo the last undone action", (GCallback) _main_window_edit_on_redo_gtk_action_callback}, {"EditCut", GTK_STOCK_CUT, NULL, NULL, "Cut the selection", (GCallback) _main_window_edit_on_cut_gtk_action_callback}, {"EditCopy", GTK_STOCK_COPY, NULL, NULL, "Copy the selection", (GCallback) _main_window_edit_on_copy_gtk_action_callback}, {"EditPaste", GTK_STOCK_PASTE, NULL, "", "Paste the clipboard", (GCallback) _main_window_edit_on_paste_gtk_action_callback}, {"EditDelete", GTK_STOCK_DELETE, NULL, NULL, "Delete the selected text", (GCallback) _main_window_edit_on_delete_gtk_action_callback}, {"EditSelectAll", GTK_STOCK_SELECT_ALL, NULL, "<Control>A", "Select the entire document", (GCallback) _main_window_edit_on_select_all_gtk_action_callback}, {"EditComment", NULL, "_Comment", "<Control>M", "Comment the selected lines (add the character \"%\")", (GCallback) _main_window_edit_on_comment_gtk_action_callback}, {"EditUncomment", NULL, "_Uncomment", "<Shift><Control>M", "Uncomment the selected lines (remove the character \"%\")", (GCallback) _main_window_edit_on_uncomment_gtk_action_callback}, {"EditPreferences", GTK_STOCK_PREFERENCES, NULL, NULL, "Configure the application", (GCallback) _main_window_edit_on_open_preferences_gtk_action_callback}};
static const GtkToggleActionEntry MAIN_WINDOW_EDIT__toggle_action_entries[1] = {{"EditSpellChecking", GTK_STOCK_SPELL_CHECK, NULL, "", "Activate or disable the spell checking", (GCallback) _main_window_edit_on_spell_checking_gtk_action_callback}};

static void _main_window_edit_on_undo_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_edit_on_undo (self);
}


static void _main_window_edit_on_redo_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_edit_on_redo (self);
}


static void _main_window_edit_on_cut_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_edit_on_cut (self);
}


static void _main_window_edit_on_copy_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_edit_on_copy (self);
}


static void _main_window_edit_on_paste_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_edit_on_paste (self);
}


static void _main_window_edit_on_delete_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_edit_on_delete (self);
}


static void _main_window_edit_on_select_all_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_edit_on_select_all (self);
}


static void _main_window_edit_on_comment_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_edit_on_comment (self);
}


static void _main_window_edit_on_uncomment_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_edit_on_uncomment (self);
}


static void _main_window_edit_on_open_preferences_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_edit_on_open_preferences (self);
}


static void _main_window_edit_on_spell_checking_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_edit_on_spell_checking (self, action);
}


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


MainWindowEdit* main_window_edit_construct (GType object_type, MainWindow* main_window, GtkUIManager* ui_manager) {
	MainWindowEdit* self = NULL;
	MainWindow* _tmp0_;
	GtkActionGroup* _tmp1_;
	GtkActionGroup* _tmp2_;
	GtkActionGroup* _tmp3_;
	GtkActionGroup* _tmp4_;
	GtkUIManager* _tmp5_;
	GtkActionGroup* _tmp6_;
	GtkActionGroup* _tmp7_;
	GtkAction* _tmp8_ = NULL;
	GtkToggleAction* _tmp9_;
	GtkToggleAction* spell_checking_action;
	GSettings* _tmp10_;
	GSettings* editor_settings;
	g_return_val_if_fail (main_window != NULL, NULL);
	g_return_val_if_fail (ui_manager != NULL, NULL);
	self = (MainWindowEdit*) g_type_create_instance (object_type);
	_tmp0_ = main_window;
	self->priv->_main_window = _tmp0_;
	_tmp1_ = gtk_action_group_new ("EditMenuActionGroup");
	_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_EDIT__action_entries, G_N_ELEMENTS (MAIN_WINDOW_EDIT__action_entries), self);
	_tmp4_ = self->priv->_action_group;
	gtk_action_group_add_toggle_actions (_tmp4_, MAIN_WINDOW_EDIT__toggle_action_entries, G_N_ELEMENTS (MAIN_WINDOW_EDIT__toggle_action_entries), self);
	_tmp5_ = ui_manager;
	_tmp6_ = self->priv->_action_group;
	gtk_ui_manager_insert_action_group (_tmp5_, _tmp6_, 0);
	_tmp7_ = self->priv->_action_group;
	_tmp8_ = gtk_action_group_get_action (_tmp7_, "EditSpellChecking");
	_tmp9_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp8_, GTK_TYPE_TOGGLE_ACTION) ? ((GtkToggleAction*) _tmp8_) : NULL);
	spell_checking_action = _tmp9_;
	_tmp10_ = g_settings_new ("org.gnome.latexila.preferences.editor");
	editor_settings = _tmp10_;
	g_settings_bind (editor_settings, "spell-checking", (GObject*) spell_checking_action, "active", G_SETTINGS_BIND_DEFAULT);
	_g_object_unref0 (editor_settings);
	_g_object_unref0 (spell_checking_action);
	return self;
}


MainWindowEdit* main_window_edit_new (MainWindow* main_window, GtkUIManager* ui_manager) {
	return main_window_edit_construct (TYPE_MAIN_WINDOW_EDIT, main_window, ui_manager);
}


void main_window_edit_update_sensitivity (MainWindowEdit* self) {
	MainWindow* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentTab* _tmp2_;
	gboolean sensitive;
	gboolean _tmp3_;
	gboolean _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_main_window;
	_tmp1_ = main_window_get_active_tab (_tmp0_);
	_tmp2_ = _tmp1_;
	sensitive = _tmp2_ != NULL;
	_tmp3_ = sensitive;
	main_window_edit_set_edit_actions_sensitivity (self, _tmp3_);
	_tmp4_ = sensitive;
	if (_tmp4_) {
		main_window_edit_set_has_selection_sensitivity (self);
		main_window_edit_set_undo_sensitivity (self);
		main_window_edit_set_redo_sensitivity (self);
	}
}


static void main_window_edit_set_edit_actions_sensitivity (MainWindowEdit* self, gboolean sensitive) {
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar** _tmp9_ = NULL;
	gchar** action_names;
	gint action_names_length1;
	gint _action_names_size_;
	gchar** _tmp10_;
	gint _tmp10__length1;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup ("EditUndo");
	_tmp1_ = g_strdup ("EditRedo");
	_tmp2_ = g_strdup ("EditCut");
	_tmp3_ = g_strdup ("EditCopy");
	_tmp4_ = g_strdup ("EditPaste");
	_tmp5_ = g_strdup ("EditDelete");
	_tmp6_ = g_strdup ("EditSelectAll");
	_tmp7_ = g_strdup ("EditComment");
	_tmp8_ = g_strdup ("EditUncomment");
	_tmp9_ = g_new0 (gchar*, 9 + 1);
	_tmp9_[0] = _tmp0_;
	_tmp9_[1] = _tmp1_;
	_tmp9_[2] = _tmp2_;
	_tmp9_[3] = _tmp3_;
	_tmp9_[4] = _tmp4_;
	_tmp9_[5] = _tmp5_;
	_tmp9_[6] = _tmp6_;
	_tmp9_[7] = _tmp7_;
	_tmp9_[8] = _tmp8_;
	action_names = _tmp9_;
	action_names_length1 = 9;
	_action_names_size_ = action_names_length1;
	_tmp10_ = action_names;
	_tmp10__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 = _tmp10_;
		action_name_collection_length1 = _tmp10__length1;
		for (action_name_it = 0; action_name_it < _tmp10__length1; action_name_it = action_name_it + 1) {
			gchar* _tmp11_;
			gchar* action_name = NULL;
			_tmp11_ = g_strdup (action_name_collection[action_name_it]);
			action_name = _tmp11_;
			{
				GtkActionGroup* _tmp12_;
				const gchar* _tmp13_;
				GtkAction* _tmp14_ = NULL;
				GtkAction* _tmp15_;
				GtkAction* action;
				GtkAction* _tmp16_;
				gboolean _tmp17_;
				_tmp12_ = self->priv->_action_group;
				_tmp13_ = action_name;
				_tmp14_ = gtk_action_group_get_action (_tmp12_, _tmp13_);
				_tmp15_ = _g_object_ref0 (_tmp14_);
				action = _tmp15_;
				_tmp16_ = action;
				_tmp17_ = sensitive;
				gtk_action_set_sensitive (_tmp16_, _tmp17_);
				_g_object_unref0 (action);
				_g_free0 (action_name);
			}
		}
	}
	action_names = (_vala_array_free (action_names, action_names_length1, (GDestroyNotify) g_free), NULL);
}


static void main_window_edit_set_has_selection_sensitivity (MainWindowEdit* self) {
	gboolean has_selection;
	MainWindow* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentTab* _tmp2_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar** _tmp11_ = NULL;
	gchar** action_names;
	gint action_names_length1;
	gint _action_names_size_;
	gchar** _tmp12_;
	gint _tmp12__length1;
	g_return_if_fail (self != NULL);
	has_selection = FALSE;
	_tmp0_ = self->priv->_main_window;
	_tmp1_ = main_window_get_active_tab (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ != NULL) {
		MainWindow* _tmp3_;
		Document* _tmp4_;
		Document* _tmp5_;
		gboolean _tmp6_;
		gboolean _tmp7_;
		_tmp3_ = self->priv->_main_window;
		_tmp4_ = main_window_get_active_document (_tmp3_);
		_tmp5_ = _tmp4_;
		_tmp6_ = gtk_text_buffer_get_has_selection ((GtkTextBuffer*) _tmp5_);
		_tmp7_ = _tmp6_;
		has_selection = _tmp7_;
	}
	_tmp8_ = g_strdup ("EditCut");
	_tmp9_ = g_strdup ("EditCopy");
	_tmp10_ = g_strdup ("EditDelete");
	_tmp11_ = g_new0 (gchar*, 3 + 1);
	_tmp11_[0] = _tmp8_;
	_tmp11_[1] = _tmp9_;
	_tmp11_[2] = _tmp10_;
	action_names = _tmp11_;
	action_names_length1 = 3;
	_action_names_size_ = action_names_length1;
	_tmp12_ = action_names;
	_tmp12__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 = _tmp12_;
		action_name_collection_length1 = _tmp12__length1;
		for (action_name_it = 0; action_name_it < _tmp12__length1; action_name_it = action_name_it + 1) {
			gchar* _tmp13_;
			gchar* action_name = NULL;
			_tmp13_ = g_strdup (action_name_collection[action_name_it]);
			action_name = _tmp13_;
			{
				GtkActionGroup* _tmp14_;
				const gchar* _tmp15_;
				GtkAction* _tmp16_ = NULL;
				GtkAction* _tmp17_;
				GtkAction* action;
				GtkAction* _tmp18_;
				gboolean _tmp19_;
				_tmp14_ = self->priv->_action_group;
				_tmp15_ = action_name;
				_tmp16_ = gtk_action_group_get_action (_tmp14_, _tmp15_);
				_tmp17_ = _g_object_ref0 (_tmp16_);
				action = _tmp17_;
				_tmp18_ = action;
				_tmp19_ = has_selection;
				gtk_action_set_sensitive (_tmp18_, _tmp19_);
				_g_object_unref0 (action);
				_g_free0 (action_name);
			}
		}
	}
	action_names = (_vala_array_free (action_names, action_names_length1, (GDestroyNotify) g_free), NULL);
}


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


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


void main_window_edit_on_undo (MainWindowEdit* self) {
	MainWindow* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentTab* _tmp2_;
	MainWindow* _tmp3_;
	Document* _tmp4_;
	Document* _tmp5_;
	gboolean _tmp6_ = FALSE;
	gboolean _tmp7_;
	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_ = main_window_get_active_document (_tmp3_);
	_tmp5_ = _tmp4_;
	g_object_get ((GtkSourceBuffer*) _tmp5_, "can-undo", &_tmp6_, NULL);
	_tmp7_ = _tmp6_;
	if (_tmp7_) {
		MainWindow* _tmp8_;
		Document* _tmp9_;
		Document* _tmp10_;
		MainWindow* _tmp11_;
		DocumentView* _tmp12_;
		DocumentView* _tmp13_;
		MainWindow* _tmp14_;
		DocumentView* _tmp15_;
		DocumentView* _tmp16_;
		_tmp8_ = self->priv->_main_window;
		_tmp9_ = main_window_get_active_document (_tmp8_);
		_tmp10_ = _tmp9_;
		gtk_source_buffer_undo ((GtkSourceBuffer*) _tmp10_);
		_tmp11_ = self->priv->_main_window;
		_tmp12_ = main_window_get_active_view (_tmp11_);
		_tmp13_ = _tmp12_;
		document_view_scroll_to_cursor (_tmp13_, 0.25);
		_tmp14_ = self->priv->_main_window;
		_tmp15_ = main_window_get_active_view (_tmp14_);
		_tmp16_ = _tmp15_;
		gtk_widget_grab_focus ((GtkWidget*) _tmp16_);
	}
}


void main_window_edit_on_redo (MainWindowEdit* self) {
	MainWindow* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentTab* _tmp2_;
	MainWindow* _tmp3_;
	Document* _tmp4_;
	Document* _tmp5_;
	gboolean _tmp6_ = FALSE;
	gboolean _tmp7_;
	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_ = main_window_get_active_document (_tmp3_);
	_tmp5_ = _tmp4_;
	g_object_get ((GtkSourceBuffer*) _tmp5_, "can-redo", &_tmp6_, NULL);
	_tmp7_ = _tmp6_;
	if (_tmp7_) {
		MainWindow* _tmp8_;
		Document* _tmp9_;
		Document* _tmp10_;
		MainWindow* _tmp11_;
		DocumentView* _tmp12_;
		DocumentView* _tmp13_;
		MainWindow* _tmp14_;
		DocumentView* _tmp15_;
		DocumentView* _tmp16_;
		_tmp8_ = self->priv->_main_window;
		_tmp9_ = main_window_get_active_document (_tmp8_);
		_tmp10_ = _tmp9_;
		gtk_source_buffer_redo ((GtkSourceBuffer*) _tmp10_);
		_tmp11_ = self->priv->_main_window;
		_tmp12_ = main_window_get_active_view (_tmp11_);
		_tmp13_ = _tmp12_;
		document_view_scroll_to_cursor (_tmp13_, 0.25);
		_tmp14_ = self->priv->_main_window;
		_tmp15_ = main_window_get_active_view (_tmp14_);
		_tmp16_ = _tmp15_;
		gtk_widget_grab_focus ((GtkWidget*) _tmp16_);
	}
}


void main_window_edit_on_cut (MainWindowEdit* self) {
	MainWindow* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentTab* _tmp2_;
	MainWindow* _tmp3_;
	DocumentView* _tmp4_;
	DocumentView* _tmp5_;
	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_ = main_window_get_active_view (_tmp3_);
	_tmp5_ = _tmp4_;
	document_view_cut_selection (_tmp5_);
}


void main_window_edit_on_copy (MainWindowEdit* self) {
	MainWindow* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentTab* _tmp2_;
	MainWindow* _tmp3_;
	DocumentView* _tmp4_;
	DocumentView* _tmp5_;
	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_ = main_window_get_active_view (_tmp3_);
	_tmp5_ = _tmp4_;
	document_view_copy_selection (_tmp5_);
}


void main_window_edit_on_paste (MainWindowEdit* self) {
	MainWindow* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentTab* _tmp2_;
	MainWindow* _tmp3_;
	DocumentView* _tmp4_;
	DocumentView* _tmp5_;
	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_ = main_window_get_active_view (_tmp3_);
	_tmp5_ = _tmp4_;
	document_view_my_paste_clipboard (_tmp5_);
}


void main_window_edit_on_delete (MainWindowEdit* self) {
	MainWindow* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentTab* _tmp2_;
	MainWindow* _tmp3_;
	DocumentView* _tmp4_;
	DocumentView* _tmp5_;
	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_ = main_window_get_active_view (_tmp3_);
	_tmp5_ = _tmp4_;
	document_view_delete_selection (_tmp5_);
}


void main_window_edit_on_select_all (MainWindowEdit* self) {
	MainWindow* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentTab* _tmp2_;
	MainWindow* _tmp3_;
	DocumentView* _tmp4_;
	DocumentView* _tmp5_;
	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_ = main_window_get_active_view (_tmp3_);
	_tmp5_ = _tmp4_;
	document_view_my_select_all (_tmp5_);
}


void main_window_edit_on_comment (MainWindowEdit* self) {
	MainWindow* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentTab* _tmp2_;
	MainWindow* _tmp3_;
	Document* _tmp4_;
	Document* _tmp5_;
	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_ = main_window_get_active_document (_tmp3_);
	_tmp5_ = _tmp4_;
	document_comment_selected_lines (_tmp5_);
}


void main_window_edit_on_uncomment (MainWindowEdit* self) {
	MainWindow* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentTab* _tmp2_;
	MainWindow* _tmp3_;
	Document* _tmp4_;
	Document* _tmp5_;
	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_ = main_window_get_active_document (_tmp3_);
	_tmp5_ = _tmp4_;
	document_uncomment_selected_lines (_tmp5_);
}


void main_window_edit_on_spell_checking (MainWindowEdit* 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_;
	{
		MainWindow* _tmp3_;
		GeeList* _tmp4_ = NULL;
		GeeList* _view_list;
		GeeList* _tmp5_;
		gint _tmp6_;
		gint _tmp7_;
		gint _view_size;
		gint _view_index;
		_tmp3_ = self->priv->_main_window;
		_tmp4_ = main_window_get_views (_tmp3_);
		_view_list = _tmp4_;
		_tmp5_ = _view_list;
		_tmp6_ = gee_collection_get_size ((GeeCollection*) _tmp5_);
		_tmp7_ = _tmp6_;
		_view_size = _tmp7_;
		_view_index = -1;
		while (TRUE) {
			gint _tmp8_;
			gint _tmp9_;
			gint _tmp10_;
			GeeList* _tmp11_;
			gint _tmp12_;
			gpointer _tmp13_ = NULL;
			DocumentView* view;
			gboolean _tmp14_;
			_tmp8_ = _view_index;
			_view_index = _tmp8_ + 1;
			_tmp9_ = _view_index;
			_tmp10_ = _view_size;
			if (!(_tmp9_ < _tmp10_)) {
				break;
			}
			_tmp11_ = _view_list;
			_tmp12_ = _view_index;
			_tmp13_ = gee_list_get (_tmp11_, _tmp12_);
			view = (DocumentView*) _tmp13_;
			_tmp14_ = activate;
			if (_tmp14_) {
				DocumentView* _tmp15_;
				_tmp15_ = view;
				document_view_activate_spell_checking (_tmp15_);
			} else {
				DocumentView* _tmp16_;
				_tmp16_ = view;
				document_view_disable_spell_checking (_tmp16_);
			}
			_g_object_unref0 (view);
		}
		_g_object_unref0 (_view_list);
	}
}


void main_window_edit_on_open_preferences (MainWindowEdit* self) {
	MainWindow* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_main_window;
	preferences_dialog_show_me (_tmp0_);
}


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


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


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


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


static gchar* value_main_window_edit_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	if (collect_values[0].v_pointer) {
		MainWindowEdit* 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_edit_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}


static gchar* value_main_window_edit_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	MainWindowEdit** 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_edit_ref (value->data[0].v_pointer);
	}
	return NULL;
}


GParamSpec* param_spec_main_window_edit (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
	ParamSpecMainWindowEdit* spec;
	g_return_val_if_fail (g_type_is_a (object_type, TYPE_MAIN_WINDOW_EDIT), 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_edit (const GValue* value) {
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_MAIN_WINDOW_EDIT), NULL);
	return value->data[0].v_pointer;
}


void value_set_main_window_edit (GValue* value, gpointer v_object) {
	MainWindowEdit* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_MAIN_WINDOW_EDIT));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_MAIN_WINDOW_EDIT));
		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_edit_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		main_window_edit_unref (old);
	}
}


void value_take_main_window_edit (GValue* value, gpointer v_object) {
	MainWindowEdit* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_MAIN_WINDOW_EDIT));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_MAIN_WINDOW_EDIT));
		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_edit_unref (old);
	}
}


static void main_window_edit_class_init (MainWindowEditClass * klass) {
	main_window_edit_parent_class = g_type_class_peek_parent (klass);
	MAIN_WINDOW_EDIT_CLASS (klass)->finalize = main_window_edit_finalize;
	g_type_class_add_private (klass, sizeof (MainWindowEditPrivate));
}


static void main_window_edit_instance_init (MainWindowEdit * self) {
	self->priv = MAIN_WINDOW_EDIT_GET_PRIVATE (self);
	self->ref_count = 1;
}


static void main_window_edit_finalize (MainWindowEdit* obj) {
	MainWindowEdit * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_MAIN_WINDOW_EDIT, MainWindowEdit);
	_g_object_unref0 (self->priv->_action_group);
}


GType main_window_edit_get_type (void) {
	static volatile gsize main_window_edit_type_id__volatile = 0;
	if (g_once_init_enter (&main_window_edit_type_id__volatile)) {
		static const GTypeValueTable g_define_type_value_table = { value_main_window_edit_init, value_main_window_edit_free_value, value_main_window_edit_copy_value, value_main_window_edit_peek_pointer, "p", value_main_window_edit_collect_value, "p", value_main_window_edit_lcopy_value };
		static const GTypeInfo g_define_type_info = { sizeof (MainWindowEditClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) main_window_edit_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MainWindowEdit), 0, (GInstanceInitFunc) main_window_edit_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_edit_type_id;
		main_window_edit_type_id = g_type_register_fundamental (g_type_fundamental_next (), "MainWindowEdit", &g_define_type_info, &g_define_type_fundamental_info, 0);
		g_once_init_leave (&main_window_edit_type_id__volatile, main_window_edit_type_id);
	}
	return main_window_edit_type_id__volatile;
}


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


void main_window_edit_unref (gpointer instance) {
	MainWindowEdit* self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		MAIN_WINDOW_EDIT_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);
}



