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

/*
 * This file is part of LaTeXila.
 *
 * Copyright © 2015 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 <gio/gio.h>
#include "config.h"
#include <gtksourceview/gtksource.h>
#include <stdlib.h>
#include <string.h>
#include <gobject/gvaluecollector.h>


#define TYPE_MAIN_WINDOW_TOOLS (main_window_tools_get_type ())
#define MAIN_WINDOW_TOOLS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MAIN_WINDOW_TOOLS, MainWindowTools))
#define MAIN_WINDOW_TOOLS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MAIN_WINDOW_TOOLS, MainWindowToolsClass))
#define IS_MAIN_WINDOW_TOOLS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MAIN_WINDOW_TOOLS))
#define IS_MAIN_WINDOW_TOOLS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MAIN_WINDOW_TOOLS))
#define MAIN_WINDOW_TOOLS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MAIN_WINDOW_TOOLS, MainWindowToolsClass))

typedef struct _MainWindowTools MainWindowTools;
typedef struct _MainWindowToolsClass MainWindowToolsClass;
typedef struct _MainWindowToolsPrivate MainWindowToolsPrivate;

#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_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_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))
typedef struct _ParamSpecMainWindowTools ParamSpecMainWindowTools;

struct _MainWindowTools {
	GTypeInstance parent_instance;
	volatile int ref_count;
	MainWindowToolsPrivate * priv;
};

struct _MainWindowToolsClass {
	GTypeClass parent_class;
	void (*finalize) (MainWindowTools *self);
};

struct _MainWindowToolsPrivate {
	MainWindow* _main_window;
	GtkActionGroup* _action_group;
	GSettings* _editor_settings;
};

struct _ParamSpecMainWindowTools {
	GParamSpec parent_instance;
};


static gpointer main_window_tools_parent_class = NULL;

gpointer main_window_tools_ref (gpointer instance);
void main_window_tools_unref (gpointer instance);
GParamSpec* param_spec_main_window_tools (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void value_set_main_window_tools (GValue* value, gpointer v_object);
void value_take_main_window_tools (GValue* value, gpointer v_object);
gpointer value_get_main_window_tools (const GValue* value);
GType main_window_tools_get_type (void) G_GNUC_CONST;
GType main_window_get_type (void) G_GNUC_CONST;
#define MAIN_WINDOW_TOOLS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_MAIN_WINDOW_TOOLS, MainWindowToolsPrivate))
enum  {
	MAIN_WINDOW_TOOLS_DUMMY_PROPERTY
};
void main_window_tools_on_spell_checker_dialog (MainWindowTools* self, GtkAction* action);
static void _main_window_tools_on_spell_checker_dialog_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_tools_on_set_language (MainWindowTools* self, GtkAction* action);
static void _main_window_tools_on_set_language_gtk_action_callback (GtkAction* action, gpointer self);
void main_window_tools_on_inline_spell_checker (MainWindowTools* self, GtkAction* action);
static void _main_window_tools_on_inline_spell_checker_gtk_action_callback (GtkAction* action, gpointer self);
MainWindowTools* main_window_tools_new (MainWindow* main_window, GtkUIManager* ui_manager);
MainWindowTools* main_window_tools_construct (GType object_type, MainWindow* main_window, GtkUIManager* ui_manager);
static void main_window_tools_update_inline_spell_checker_action_state (MainWindowTools* self);
static void __lambda80_ (MainWindowTools* self);
static void ___lambda80__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self);
static void __lambda81_ (MainWindowTools* self);
GType document_view_get_type (void) G_GNUC_CONST;
DocumentView* main_window_get_active_view (MainWindow* self);
void document_view_setup_inline_spell_checker (DocumentView* self);
static void ___lambda81__g_settings_changed (GSettings* _sender, const gchar* key, gpointer self);
GType document_tab_get_type (void) G_GNUC_CONST;
DocumentTab* main_window_get_active_tab (MainWindow* self);
gboolean document_view_get_highlight_misspelled_words (DocumentView* self);
void main_window_tools_update_sensitivity (MainWindowTools* self);
void document_view_launch_spell_checker_dialog (DocumentView* self);
void document_view_set_spell_language_metadata (DocumentView* self);
void document_view_launch_spell_language_chooser_dialog (DocumentView* self);
void document_view_set_highlight_misspelled_words (DocumentView* self, gboolean value);
void document_view_set_inline_spell_metadata (DocumentView* self);
static void main_window_tools_finalize (MainWindowTools* 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_TOOLS__action_entries[3] = {{"Tools", NULL, "_Tools"}, {"ToolsSpellCheckerDialog", NULL, "_Check Spelling…", NULL, "Check the spelling of the current document", (GCallback) _main_window_tools_on_spell_checker_dialog_gtk_action_callback}, {"ToolsSetSpellLanguage", NULL, "_Set Language…", NULL, "Set the language used for the spell checking for the current document", (GCallback) _main_window_tools_on_set_language_gtk_action_callback}};
static const GtkToggleActionEntry MAIN_WINDOW_TOOLS__toggle_action_entries[1] = {{"ToolsInlineSpellChecker", "tools-check-spelling", "_Highlight Misspelled Words", NULL, "Highlight misspelled words in the current document", (GCallback) _main_window_tools_on_inline_spell_checker_gtk_action_callback}};

static void _main_window_tools_on_spell_checker_dialog_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_tools_on_spell_checker_dialog ((MainWindowTools*) self, action);
}


static void _main_window_tools_on_set_language_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_tools_on_set_language ((MainWindowTools*) self, action);
}


static void _main_window_tools_on_inline_spell_checker_gtk_action_callback (GtkAction* action, gpointer self) {
	main_window_tools_on_inline_spell_checker ((MainWindowTools*) self, action);
}


static void __lambda80_ (MainWindowTools* self) {
	main_window_tools_update_inline_spell_checker_action_state (self);
}


static void ___lambda80__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) {
	__lambda80_ ((MainWindowTools*) self);
}


static void __lambda81_ (MainWindowTools* self) {
	MainWindow* _tmp0_ = NULL;
	DocumentView* _tmp1_ = NULL;
	DocumentView* _tmp2_ = NULL;
	_tmp0_ = self->priv->_main_window;
	_tmp1_ = main_window_get_active_view (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ != NULL) {
		MainWindow* _tmp3_ = NULL;
		DocumentView* _tmp4_ = NULL;
		DocumentView* _tmp5_ = NULL;
		_tmp3_ = self->priv->_main_window;
		_tmp4_ = main_window_get_active_view (_tmp3_);
		_tmp5_ = _tmp4_;
		document_view_setup_inline_spell_checker (_tmp5_);
	}
	main_window_tools_update_inline_spell_checker_action_state (self);
}


static void ___lambda81__g_settings_changed (GSettings* _sender, const gchar* key, gpointer self) {
	__lambda81_ ((MainWindowTools*) self);
}


MainWindowTools* main_window_tools_construct (GType object_type, MainWindow* main_window, GtkUIManager* ui_manager) {
	MainWindowTools* self = NULL;
	MainWindow* _tmp0_ = NULL;
	GtkActionGroup* _tmp1_ = NULL;
	GtkActionGroup* _tmp2_ = NULL;
	GtkActionGroup* _tmp3_ = NULL;
	GtkActionGroup* _tmp4_ = NULL;
	GtkUIManager* _tmp5_ = NULL;
	GtkActionGroup* _tmp6_ = NULL;
	MainWindow* _tmp7_ = NULL;
	GSettings* _tmp8_ = NULL;
	GSettings* _tmp9_ = NULL;
	g_return_val_if_fail (main_window != NULL, NULL);
	g_return_val_if_fail (ui_manager != NULL, NULL);
	self = (MainWindowTools*) g_type_create_instance (object_type);
	_tmp0_ = main_window;
	self->priv->_main_window = _tmp0_;
	_tmp1_ = gtk_action_group_new ("ToolsMenuActionGroup");
	_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_TOOLS__action_entries, G_N_ELEMENTS (MAIN_WINDOW_TOOLS__action_entries), self);
	_tmp4_ = self->priv->_action_group;
	gtk_action_group_add_toggle_actions (_tmp4_, MAIN_WINDOW_TOOLS__toggle_action_entries, G_N_ELEMENTS (MAIN_WINDOW_TOOLS__toggle_action_entries), self);
	_tmp5_ = ui_manager;
	_tmp6_ = self->priv->_action_group;
	gtk_ui_manager_insert_action_group (_tmp5_, _tmp6_, 0);
	main_window_tools_update_inline_spell_checker_action_state (self);
	_tmp7_ = self->priv->_main_window;
	g_signal_connect ((GObject*) _tmp7_, "notify::active-tab", (GCallback) ___lambda80__g_object_notify, self);
	_tmp8_ = g_settings_new ("org.gnome.latexila.preferences.editor");
	_g_object_unref0 (self->priv->_editor_settings);
	self->priv->_editor_settings = _tmp8_;
	_tmp9_ = self->priv->_editor_settings;
	g_signal_connect (_tmp9_, "changed::highlight-misspelled-words", (GCallback) ___lambda81__g_settings_changed, self);
	return self;
}


MainWindowTools* main_window_tools_new (MainWindow* main_window, GtkUIManager* ui_manager) {
	return main_window_tools_construct (TYPE_MAIN_WINDOW_TOOLS, main_window, ui_manager);
}


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


static void main_window_tools_update_inline_spell_checker_action_state (MainWindowTools* self) {
	MainWindow* _tmp0_ = NULL;
	DocumentTab* _tmp1_ = NULL;
	DocumentTab* _tmp2_ = NULL;
	GtkToggleAction* spell_checking_action = NULL;
	GtkActionGroup* _tmp3_ = NULL;
	GtkAction* _tmp4_ = NULL;
	GtkToggleAction* _tmp5_ = NULL;
	GtkToggleAction* _tmp6_ = NULL;
	MainWindow* _tmp7_ = NULL;
	DocumentView* _tmp8_ = NULL;
	DocumentView* _tmp9_ = NULL;
	gboolean _tmp10_ = FALSE;
	gboolean _tmp11_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_main_window;
	_tmp1_ = main_window_get_active_tab (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ == NULL) {
		return;
	}
	_tmp3_ = self->priv->_action_group;
	_tmp4_ = gtk_action_group_get_action (_tmp3_, "ToolsInlineSpellChecker");
	_tmp5_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp4_, gtk_toggle_action_get_type ()) ? ((GtkToggleAction*) _tmp4_) : NULL);
	spell_checking_action = _tmp5_;
	_tmp6_ = spell_checking_action;
	_tmp7_ = self->priv->_main_window;
	_tmp8_ = main_window_get_active_view (_tmp7_);
	_tmp9_ = _tmp8_;
	_tmp10_ = document_view_get_highlight_misspelled_words (_tmp9_);
	_tmp11_ = _tmp10_;
	gtk_toggle_action_set_active (_tmp6_, _tmp11_);
	_g_object_unref0 (spell_checking_action);
}


void main_window_tools_update_sensitivity (MainWindowTools* self) {
	gboolean sensitive = FALSE;
	MainWindow* _tmp0_ = NULL;
	DocumentTab* _tmp1_ = NULL;
	DocumentTab* _tmp2_ = NULL;
	gchar** action_names = NULL;
	gchar* _tmp3_ = NULL;
	gchar* _tmp4_ = NULL;
	gchar* _tmp5_ = NULL;
	gchar** _tmp6_ = NULL;
	gint action_names_length1 = 0;
	gint _action_names_size_ = 0;
	gchar** _tmp7_ = NULL;
	gint _tmp7__length1 = 0;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_main_window;
	_tmp1_ = main_window_get_active_tab (_tmp0_);
	_tmp2_ = _tmp1_;
	sensitive = _tmp2_ != NULL;
	_tmp3_ = g_strdup ("ToolsSpellCheckerDialog");
	_tmp4_ = g_strdup ("ToolsSetSpellLanguage");
	_tmp5_ = g_strdup ("ToolsInlineSpellChecker");
	_tmp6_ = g_new0 (gchar*, 3 + 1);
	_tmp6_[0] = _tmp3_;
	_tmp6_[1] = _tmp4_;
	_tmp6_[2] = _tmp5_;
	action_names = _tmp6_;
	action_names_length1 = 3;
	_action_names_size_ = action_names_length1;
	_tmp7_ = action_names;
	_tmp7__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 = _tmp7_;
		action_name_collection_length1 = _tmp7__length1;
		for (action_name_it = 0; action_name_it < _tmp7__length1; action_name_it = action_name_it + 1) {
			gchar* _tmp8_ = NULL;
			gchar* action_name = NULL;
			_tmp8_ = g_strdup (action_name_collection[action_name_it]);
			action_name = _tmp8_;
			{
				GtkAction* action = NULL;
				GtkActionGroup* _tmp9_ = NULL;
				const gchar* _tmp10_ = NULL;
				GtkAction* _tmp11_ = NULL;
				GtkAction* _tmp12_ = NULL;
				GtkAction* _tmp13_ = NULL;
				gboolean _tmp14_ = FALSE;
				_tmp9_ = self->priv->_action_group;
				_tmp10_ = action_name;
				_tmp11_ = gtk_action_group_get_action (_tmp9_, _tmp10_);
				_tmp12_ = _g_object_ref0 (_tmp11_);
				action = _tmp12_;
				_tmp13_ = action;
				_tmp14_ = sensitive;
				gtk_action_set_sensitive (_tmp13_, _tmp14_);
				_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_tools_on_spell_checker_dialog (MainWindowTools* self, GtkAction* action) {
	DocumentView* view = NULL;
	MainWindow* _tmp0_ = NULL;
	DocumentView* _tmp1_ = NULL;
	DocumentView* _tmp2_ = NULL;
	DocumentView* _tmp3_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (action != NULL);
	_tmp0_ = self->priv->_main_window;
	_tmp1_ = main_window_get_active_view (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	view = _tmp3_;
	g_return_if_fail (view != NULL);
	document_view_launch_spell_checker_dialog (view);
	document_view_set_spell_language_metadata (view);
	_g_object_unref0 (view);
}


void main_window_tools_on_set_language (MainWindowTools* self, GtkAction* action) {
	DocumentView* view = NULL;
	MainWindow* _tmp0_ = NULL;
	DocumentView* _tmp1_ = NULL;
	DocumentView* _tmp2_ = NULL;
	DocumentView* _tmp3_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (action != NULL);
	_tmp0_ = self->priv->_main_window;
	_tmp1_ = main_window_get_active_view (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	view = _tmp3_;
	g_return_if_fail (view != NULL);
	document_view_launch_spell_language_chooser_dialog (view);
	document_view_set_spell_language_metadata (view);
	_g_object_unref0 (view);
}


void main_window_tools_on_inline_spell_checker (MainWindowTools* self, GtkAction* action) {
	DocumentView* view = NULL;
	MainWindow* _tmp0_ = NULL;
	DocumentView* _tmp1_ = NULL;
	DocumentView* _tmp2_ = NULL;
	DocumentView* _tmp3_ = NULL;
	DocumentView* _tmp4_ = NULL;
	gboolean activate = FALSE;
	GtkAction* _tmp5_ = NULL;
	gboolean _tmp6_ = FALSE;
	gboolean _tmp7_ = FALSE;
	DocumentView* _tmp8_ = NULL;
	gboolean _tmp9_ = FALSE;
	gboolean _tmp10_ = FALSE;
	gboolean _tmp11_ = FALSE;
	g_return_if_fail (self != NULL);
	g_return_if_fail (action != NULL);
	_tmp0_ = self->priv->_main_window;
	_tmp1_ = main_window_get_active_view (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	view = _tmp3_;
	_tmp4_ = view;
	g_return_if_fail (_tmp4_ != NULL);
	_tmp5_ = action;
	_tmp6_ = gtk_toggle_action_get_active (G_TYPE_CHECK_INSTANCE_TYPE (_tmp5_, gtk_toggle_action_get_type ()) ? ((GtkToggleAction*) _tmp5_) : NULL);
	_tmp7_ = _tmp6_;
	activate = _tmp7_;
	_tmp8_ = view;
	_tmp9_ = document_view_get_highlight_misspelled_words (_tmp8_);
	_tmp10_ = _tmp9_;
	_tmp11_ = activate;
	if (_tmp10_ != _tmp11_) {
		DocumentView* _tmp12_ = NULL;
		gboolean _tmp13_ = FALSE;
		DocumentView* _tmp14_ = NULL;
		DocumentView* _tmp15_ = NULL;
		_tmp12_ = view;
		_tmp13_ = activate;
		document_view_set_highlight_misspelled_words (_tmp12_, _tmp13_);
		main_window_tools_update_inline_spell_checker_action_state (self);
		_tmp14_ = view;
		document_view_set_inline_spell_metadata (_tmp14_);
		_tmp15_ = view;
		document_view_set_spell_language_metadata (_tmp15_);
	}
	_g_object_unref0 (view);
}


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


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


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


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


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


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


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


void value_set_main_window_tools (GValue* value, gpointer v_object) {
	MainWindowTools* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_MAIN_WINDOW_TOOLS));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_MAIN_WINDOW_TOOLS));
		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_tools_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		main_window_tools_unref (old);
	}
}


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


static void main_window_tools_class_init (MainWindowToolsClass * klass) {
	main_window_tools_parent_class = g_type_class_peek_parent (klass);
	((MainWindowToolsClass *) klass)->finalize = main_window_tools_finalize;
	g_type_class_add_private (klass, sizeof (MainWindowToolsPrivate));
}


static void main_window_tools_instance_init (MainWindowTools * self) {
	self->priv = MAIN_WINDOW_TOOLS_GET_PRIVATE (self);
	self->ref_count = 1;
}


static void main_window_tools_finalize (MainWindowTools* obj) {
	MainWindowTools * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_MAIN_WINDOW_TOOLS, MainWindowTools);
	g_signal_handlers_destroy (self);
	_g_object_unref0 (self->priv->_action_group);
	_g_object_unref0 (self->priv->_editor_settings);
}


GType main_window_tools_get_type (void) {
	static volatile gsize main_window_tools_type_id__volatile = 0;
	if (g_once_init_enter (&main_window_tools_type_id__volatile)) {
		static const GTypeValueTable g_define_type_value_table = { value_main_window_tools_init, value_main_window_tools_free_value, value_main_window_tools_copy_value, value_main_window_tools_peek_pointer, "p", value_main_window_tools_collect_value, "p", value_main_window_tools_lcopy_value };
		static const GTypeInfo g_define_type_info = { sizeof (MainWindowToolsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) main_window_tools_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MainWindowTools), 0, (GInstanceInitFunc) main_window_tools_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_tools_type_id;
		main_window_tools_type_id = g_type_register_fundamental (g_type_fundamental_next (), "MainWindowTools", &g_define_type_info, &g_define_type_fundamental_info, 0);
		g_once_init_leave (&main_window_tools_type_id__volatile, main_window_tools_type_id);
	}
	return main_window_tools_type_id__volatile;
}


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


void main_window_tools_unref (gpointer instance) {
	MainWindowTools* self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		MAIN_WINDOW_TOOLS_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);
}



