/* main_window_tools.c generated by valac 0.40.0.227-717ea, the Vala compiler
 * generated from main_window_tools.vala, do not modify */

/*
 * This file is part of GNOME LaTeX.
 *
 * Copyright © 2015 Sébastien Wilmet
 *
 * GNOME LaTeX is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * GNOME LaTeX is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with GNOME LaTeX.  If not, see <http://www.gnu.org/licenses/>.
 */


#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <glib/gi18n-lib.h>
#include "config.h"
#include <tepl/tepl.h>
#include <stdlib.h>
#include <string.h>
#include <gspell/gspell.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 gint MainWindowTools_private_offset;
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;
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 __lambda39_ (MainWindowTools* self);
static void ___lambda39__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
static void __lambda40_ (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 ___lambda40__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);
void main_window_tools_update_sensitivity (MainWindowTools* self);
void document_view_launch_spell_checker_dialog (DocumentView* self);
void document_view_save_spell_language_metadata (DocumentView* self);
void document_view_launch_spell_language_chooser_dialog (DocumentView* self);
void document_view_save_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, N_ ("_Tools")}, {"ToolsSpellCheckerDialog", NULL, N_ ("_Check Spelling…"), NULL, N_ ("Check the spelling of the current document"), (GCallback) _main_window_tools_on_spell_checker_dialog_gtk_action_callback}, {"ToolsSetSpellLanguage", NULL, N_ ("_Set Language…"), NULL, N_ ("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", N_ ("_Highlight Misspelled Words"), NULL, N_ ("Highlight misspelled words in the current document"), (GCallback) _main_window_tools_on_inline_spell_checker_gtk_action_callback}};

static inline gpointer
main_window_tools_get_instance_private (MainWindowTools* self)
{
	return G_STRUCT_MEMBER_P (self, MainWindowTools_private_offset);
}


static void
_main_window_tools_on_spell_checker_dialog_gtk_action_callback (GtkAction* action,
                                                                gpointer self)
{
#line 26 "main_window_tools.vala"
	main_window_tools_on_spell_checker_dialog ((MainWindowTools*) self, action);
#line 181 "main_window_tools.c"
}


static void
_main_window_tools_on_set_language_gtk_action_callback (GtkAction* action,
                                                        gpointer self)
{
#line 26 "main_window_tools.vala"
	main_window_tools_on_set_language ((MainWindowTools*) self, action);
#line 191 "main_window_tools.c"
}


static void
_main_window_tools_on_inline_spell_checker_gtk_action_callback (GtkAction* action,
                                                                gpointer self)
{
#line 36 "main_window_tools.vala"
	main_window_tools_on_inline_spell_checker ((MainWindowTools*) self, action);
#line 201 "main_window_tools.c"
}


static void
__lambda39_ (MainWindowTools* self)
{
#line 60 "main_window_tools.vala"
	main_window_tools_update_inline_spell_checker_action_state (self);
#line 210 "main_window_tools.c"
}


static void
___lambda39__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
#line 58 "main_window_tools.vala"
	__lambda39_ ((MainWindowTools*) self);
#line 221 "main_window_tools.c"
}


static void
__lambda40_ (MainWindowTools* self)
{
	MainWindow* _tmp0_;
	DocumentView* _tmp1_;
	DocumentView* _tmp2_;
#line 67 "main_window_tools.vala"
	_tmp0_ = self->priv->_main_window;
#line 67 "main_window_tools.vala"
	_tmp1_ = main_window_get_active_view (_tmp0_);
#line 67 "main_window_tools.vala"
	_tmp2_ = _tmp1_;
#line 67 "main_window_tools.vala"
	if (_tmp2_ != NULL) {
#line 239 "main_window_tools.c"
		MainWindow* _tmp3_;
		DocumentView* _tmp4_;
		DocumentView* _tmp5_;
#line 68 "main_window_tools.vala"
		_tmp3_ = self->priv->_main_window;
#line 68 "main_window_tools.vala"
		_tmp4_ = main_window_get_active_view (_tmp3_);
#line 68 "main_window_tools.vala"
		_tmp5_ = _tmp4_;
#line 68 "main_window_tools.vala"
		document_view_setup_inline_spell_checker (_tmp5_);
#line 251 "main_window_tools.c"
	}
#line 70 "main_window_tools.vala"
	main_window_tools_update_inline_spell_checker_action_state (self);
#line 255 "main_window_tools.c"
}


static void
___lambda40__g_settings_changed (GSettings* _sender,
                                 const gchar* key,
                                 gpointer self)
{
#line 65 "main_window_tools.vala"
	__lambda40_ ((MainWindowTools*) self);
#line 266 "main_window_tools.c"
}


MainWindowTools*
main_window_tools_construct (GType object_type,
                             MainWindow* main_window,
                             GtkUIManager* ui_manager)
{
	MainWindowTools* self = NULL;
	GtkActionGroup* _tmp0_;
	GtkActionGroup* _tmp1_;
	GtkActionGroup* _tmp2_;
	GtkActionGroup* _tmp3_;
	GtkActionGroup* _tmp4_;
	MainWindow* _tmp5_;
	GSettings* _tmp6_;
	GSettings* _tmp7_;
#line 46 "main_window_tools.vala"
	g_return_val_if_fail (main_window != NULL, NULL);
#line 46 "main_window_tools.vala"
	g_return_val_if_fail (ui_manager != NULL, NULL);
#line 46 "main_window_tools.vala"
	self = (MainWindowTools*) g_type_create_instance (object_type);
#line 48 "main_window_tools.vala"
	self->priv->_main_window = main_window;
#line 50 "main_window_tools.vala"
	_tmp0_ = gtk_action_group_new ("ToolsMenuActionGroup");
#line 50 "main_window_tools.vala"
	_g_object_unref0 (self->priv->_action_group);
#line 50 "main_window_tools.vala"
	self->priv->_action_group = _tmp0_;
#line 51 "main_window_tools.vala"
	_tmp1_ = self->priv->_action_group;
#line 51 "main_window_tools.vala"
	gtk_action_group_set_translation_domain (_tmp1_, GETTEXT_PACKAGE);
#line 52 "main_window_tools.vala"
	_tmp2_ = self->priv->_action_group;
#line 52 "main_window_tools.vala"
	gtk_action_group_add_actions (_tmp2_, MAIN_WINDOW_TOOLS__action_entries, (guint) G_N_ELEMENTS (MAIN_WINDOW_TOOLS__action_entries), self);
#line 53 "main_window_tools.vala"
	_tmp3_ = self->priv->_action_group;
#line 53 "main_window_tools.vala"
	gtk_action_group_add_toggle_actions (_tmp3_, MAIN_WINDOW_TOOLS__toggle_action_entries, (guint) G_N_ELEMENTS (MAIN_WINDOW_TOOLS__toggle_action_entries), self);
#line 55 "main_window_tools.vala"
	_tmp4_ = self->priv->_action_group;
#line 55 "main_window_tools.vala"
	gtk_ui_manager_insert_action_group (ui_manager, _tmp4_, 0);
#line 57 "main_window_tools.vala"
	main_window_tools_update_inline_spell_checker_action_state (self);
#line 58 "main_window_tools.vala"
	_tmp5_ = self->priv->_main_window;
#line 58 "main_window_tools.vala"
	g_signal_connect ((GObject*) _tmp5_, "notify::active-tab", (GCallback) ___lambda39__g_object_notify, self);
#line 63 "main_window_tools.vala"
	_tmp6_ = g_settings_new ("org.gnome.gnome-latex.preferences.editor");
#line 63 "main_window_tools.vala"
	_g_object_unref0 (self->priv->_editor_settings);
#line 63 "main_window_tools.vala"
	self->priv->_editor_settings = _tmp6_;
#line 65 "main_window_tools.vala"
	_tmp7_ = self->priv->_editor_settings;
#line 65 "main_window_tools.vala"
	g_signal_connect (_tmp7_, "changed::highlight-misspelled-words", (GCallback) ___lambda40__g_settings_changed, self);
#line 46 "main_window_tools.vala"
	return self;
#line 332 "main_window_tools.c"
}


MainWindowTools*
main_window_tools_new (MainWindow* main_window,
                       GtkUIManager* ui_manager)
{
#line 46 "main_window_tools.vala"
	return main_window_tools_construct (TYPE_MAIN_WINDOW_TOOLS, main_window, ui_manager);
#line 342 "main_window_tools.c"
}


static gpointer
_g_object_ref0 (gpointer self)
{
#line 79 "main_window_tools.vala"
	return self ? g_object_ref (self) : NULL;
#line 351 "main_window_tools.c"
}


static void
main_window_tools_update_inline_spell_checker_action_state (MainWindowTools* self)
{
	MainWindow* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentTab* _tmp2_;
	GtkToggleAction* spell_checking_action = NULL;
	GtkActionGroup* _tmp3_;
	GtkAction* _tmp4_;
	GtkToggleAction* _tmp5_;
	GspellTextView* gspell_view = NULL;
	MainWindow* _tmp6_;
	DocumentView* _tmp7_;
	DocumentView* _tmp8_;
	GspellTextView* _tmp9_;
	GspellTextView* _tmp10_;
	GtkToggleAction* _tmp11_;
	GspellTextView* _tmp12_;
	gboolean _tmp13_;
	gboolean _tmp14_;
#line 74 "main_window_tools.vala"
	g_return_if_fail (self != NULL);
#line 76 "main_window_tools.vala"
	_tmp0_ = self->priv->_main_window;
#line 76 "main_window_tools.vala"
	_tmp1_ = main_window_get_active_tab (_tmp0_);
#line 76 "main_window_tools.vala"
	_tmp2_ = _tmp1_;
#line 76 "main_window_tools.vala"
	if (_tmp2_ == NULL) {
#line 77 "main_window_tools.vala"
		return;
#line 387 "main_window_tools.c"
	}
#line 79 "main_window_tools.vala"
	_tmp3_ = self->priv->_action_group;
#line 79 "main_window_tools.vala"
	_tmp4_ = gtk_action_group_get_action (_tmp3_, "ToolsInlineSpellChecker");
#line 79 "main_window_tools.vala"
	_tmp5_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp4_, gtk_toggle_action_get_type ()) ? ((GtkToggleAction*) _tmp4_) : NULL);
#line 79 "main_window_tools.vala"
	spell_checking_action = _tmp5_;
#line 82 "main_window_tools.vala"
	_tmp6_ = self->priv->_main_window;
#line 82 "main_window_tools.vala"
	_tmp7_ = main_window_get_active_view (_tmp6_);
#line 82 "main_window_tools.vala"
	_tmp8_ = _tmp7_;
#line 82 "main_window_tools.vala"
	_tmp9_ = gspell_text_view_get_from_gtk_text_view (G_TYPE_CHECK_INSTANCE_TYPE (_tmp8_, gtk_text_view_get_type ()) ? ((GtkTextView*) _tmp8_) : NULL);
#line 82 "main_window_tools.vala"
	_tmp10_ = _g_object_ref0 (_tmp9_);
#line 82 "main_window_tools.vala"
	gspell_view = _tmp10_;
#line 84 "main_window_tools.vala"
	_tmp11_ = spell_checking_action;
#line 84 "main_window_tools.vala"
	_tmp12_ = gspell_view;
#line 84 "main_window_tools.vala"
	_tmp13_ = gspell_text_view_get_inline_spell_checking (_tmp12_);
#line 84 "main_window_tools.vala"
	_tmp14_ = _tmp13_;
#line 84 "main_window_tools.vala"
	gtk_toggle_action_set_active (_tmp11_, _tmp14_);
#line 74 "main_window_tools.vala"
	_g_object_unref0 (gspell_view);
#line 74 "main_window_tools.vala"
	_g_object_unref0 (spell_checking_action);
#line 423 "main_window_tools.c"
}


void
main_window_tools_update_sensitivity (MainWindowTools* self)
{
	gboolean sensitive = FALSE;
	MainWindow* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentTab* _tmp2_;
	gchar** action_names = NULL;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar** _tmp6_;
	gint action_names_length1;
	gint _action_names_size_;
	gchar** _tmp7_;
	gint _tmp7__length1;
#line 95 "main_window_tools.vala"
	g_return_if_fail (self != NULL);
#line 97 "main_window_tools.vala"
	_tmp0_ = self->priv->_main_window;
#line 97 "main_window_tools.vala"
	_tmp1_ = main_window_get_active_tab (_tmp0_);
#line 97 "main_window_tools.vala"
	_tmp2_ = _tmp1_;
#line 97 "main_window_tools.vala"
	sensitive = _tmp2_ != NULL;
#line 99 "main_window_tools.vala"
	_tmp3_ = g_strdup ("ToolsSpellCheckerDialog");
#line 99 "main_window_tools.vala"
	_tmp4_ = g_strdup ("ToolsSetSpellLanguage");
#line 99 "main_window_tools.vala"
	_tmp5_ = g_strdup ("ToolsInlineSpellChecker");
#line 99 "main_window_tools.vala"
	_tmp6_ = g_new0 (gchar*, 3 + 1);
#line 99 "main_window_tools.vala"
	_tmp6_[0] = _tmp3_;
#line 99 "main_window_tools.vala"
	_tmp6_[1] = _tmp4_;
#line 99 "main_window_tools.vala"
	_tmp6_[2] = _tmp5_;
#line 99 "main_window_tools.vala"
	action_names = _tmp6_;
#line 99 "main_window_tools.vala"
	action_names_length1 = 3;
#line 99 "main_window_tools.vala"
	_action_names_size_ = action_names_length1;
#line 106 "main_window_tools.vala"
	_tmp7_ = action_names;
#line 106 "main_window_tools.vala"
	_tmp7__length1 = action_names_length1;
#line 477 "main_window_tools.c"
	{
		gchar** action_name_collection = NULL;
		gint action_name_collection_length1 = 0;
		gint _action_name_collection_size_ = 0;
		gint action_name_it = 0;
#line 106 "main_window_tools.vala"
		action_name_collection = _tmp7_;
#line 106 "main_window_tools.vala"
		action_name_collection_length1 = _tmp7__length1;
#line 106 "main_window_tools.vala"
		for (action_name_it = 0; action_name_it < _tmp7__length1; action_name_it = action_name_it + 1) {
#line 489 "main_window_tools.c"
			gchar* _tmp8_;
			gchar* action_name = NULL;
#line 106 "main_window_tools.vala"
			_tmp8_ = g_strdup (action_name_collection[action_name_it]);
#line 106 "main_window_tools.vala"
			action_name = _tmp8_;
#line 496 "main_window_tools.c"
			{
				GtkAction* action = NULL;
				GtkActionGroup* _tmp9_;
				const gchar* _tmp10_;
				GtkAction* _tmp11_;
				GtkAction* _tmp12_;
				GtkAction* _tmp13_;
				gboolean _tmp14_;
#line 108 "main_window_tools.vala"
				_tmp9_ = self->priv->_action_group;
#line 108 "main_window_tools.vala"
				_tmp10_ = action_name;
#line 108 "main_window_tools.vala"
				_tmp11_ = gtk_action_group_get_action (_tmp9_, _tmp10_);
#line 108 "main_window_tools.vala"
				_tmp12_ = _g_object_ref0 (_tmp11_);
#line 108 "main_window_tools.vala"
				action = _tmp12_;
#line 109 "main_window_tools.vala"
				_tmp13_ = action;
#line 109 "main_window_tools.vala"
				_tmp14_ = sensitive;
#line 109 "main_window_tools.vala"
				gtk_action_set_sensitive (_tmp13_, _tmp14_);
#line 106 "main_window_tools.vala"
				_g_object_unref0 (action);
#line 106 "main_window_tools.vala"
				_g_free0 (action_name);
#line 525 "main_window_tools.c"
			}
		}
	}
#line 95 "main_window_tools.vala"
	action_names = (_vala_array_free (action_names, action_names_length1, (GDestroyNotify) g_free), NULL);
#line 531 "main_window_tools.c"
}


void
main_window_tools_on_spell_checker_dialog (MainWindowTools* self,
                                           GtkAction* action)
{
	DocumentView* view = NULL;
	MainWindow* _tmp0_;
	DocumentView* _tmp1_;
	DocumentView* _tmp2_;
	DocumentView* _tmp3_;
#line 115 "main_window_tools.vala"
	g_return_if_fail (self != NULL);
#line 115 "main_window_tools.vala"
	g_return_if_fail (action != NULL);
#line 117 "main_window_tools.vala"
	_tmp0_ = self->priv->_main_window;
#line 117 "main_window_tools.vala"
	_tmp1_ = main_window_get_active_view (_tmp0_);
#line 117 "main_window_tools.vala"
	_tmp2_ = _tmp1_;
#line 117 "main_window_tools.vala"
	_tmp3_ = _g_object_ref0 (_tmp2_);
#line 117 "main_window_tools.vala"
	view = _tmp3_;
#line 118 "main_window_tools.vala"
	g_return_if_fail (view != NULL);
#line 120 "main_window_tools.vala"
	document_view_launch_spell_checker_dialog (view);
#line 125 "main_window_tools.vala"
	document_view_save_spell_language_metadata (view);
#line 115 "main_window_tools.vala"
	_g_object_unref0 (view);
#line 566 "main_window_tools.c"
}


void
main_window_tools_on_set_language (MainWindowTools* self,
                                   GtkAction* action)
{
	DocumentView* view = NULL;
	MainWindow* _tmp0_;
	DocumentView* _tmp1_;
	DocumentView* _tmp2_;
	DocumentView* _tmp3_;
#line 128 "main_window_tools.vala"
	g_return_if_fail (self != NULL);
#line 128 "main_window_tools.vala"
	g_return_if_fail (action != NULL);
#line 130 "main_window_tools.vala"
	_tmp0_ = self->priv->_main_window;
#line 130 "main_window_tools.vala"
	_tmp1_ = main_window_get_active_view (_tmp0_);
#line 130 "main_window_tools.vala"
	_tmp2_ = _tmp1_;
#line 130 "main_window_tools.vala"
	_tmp3_ = _g_object_ref0 (_tmp2_);
#line 130 "main_window_tools.vala"
	view = _tmp3_;
#line 131 "main_window_tools.vala"
	g_return_if_fail (view != NULL);
#line 133 "main_window_tools.vala"
	document_view_launch_spell_language_chooser_dialog (view);
#line 134 "main_window_tools.vala"
	document_view_save_spell_language_metadata (view);
#line 128 "main_window_tools.vala"
	_g_object_unref0 (view);
#line 601 "main_window_tools.c"
}


void
main_window_tools_on_inline_spell_checker (MainWindowTools* self,
                                           GtkAction* action)
{
	DocumentView* view = NULL;
	MainWindow* _tmp0_;
	DocumentView* _tmp1_;
	DocumentView* _tmp2_;
	DocumentView* _tmp3_;
	DocumentView* _tmp4_;
	gboolean activate = FALSE;
	gboolean _tmp5_;
	gboolean _tmp6_;
	GspellTextView* gspell_view = NULL;
	DocumentView* _tmp7_;
	GspellTextView* _tmp8_;
	GspellTextView* _tmp9_;
	GspellTextView* _tmp10_;
	gboolean _tmp11_;
	gboolean _tmp12_;
	gboolean _tmp13_;
#line 137 "main_window_tools.vala"
	g_return_if_fail (self != NULL);
#line 137 "main_window_tools.vala"
	g_return_if_fail (action != NULL);
#line 139 "main_window_tools.vala"
	_tmp0_ = self->priv->_main_window;
#line 139 "main_window_tools.vala"
	_tmp1_ = main_window_get_active_view (_tmp0_);
#line 139 "main_window_tools.vala"
	_tmp2_ = _tmp1_;
#line 139 "main_window_tools.vala"
	_tmp3_ = _g_object_ref0 (_tmp2_);
#line 139 "main_window_tools.vala"
	view = _tmp3_;
#line 140 "main_window_tools.vala"
	_tmp4_ = view;
#line 140 "main_window_tools.vala"
	g_return_if_fail (_tmp4_ != NULL);
#line 142 "main_window_tools.vala"
	_tmp5_ = gtk_toggle_action_get_active (G_TYPE_CHECK_INSTANCE_TYPE (action, gtk_toggle_action_get_type ()) ? ((GtkToggleAction*) action) : NULL);
#line 142 "main_window_tools.vala"
	_tmp6_ = _tmp5_;
#line 142 "main_window_tools.vala"
	activate = _tmp6_;
#line 144 "main_window_tools.vala"
	_tmp7_ = view;
#line 144 "main_window_tools.vala"
	_tmp8_ = gspell_text_view_get_from_gtk_text_view (G_TYPE_CHECK_INSTANCE_TYPE (_tmp7_, gtk_text_view_get_type ()) ? ((GtkTextView*) _tmp7_) : NULL);
#line 144 "main_window_tools.vala"
	_tmp9_ = _g_object_ref0 (_tmp8_);
#line 144 "main_window_tools.vala"
	gspell_view = _tmp9_;
#line 150 "main_window_tools.vala"
	_tmp10_ = gspell_view;
#line 150 "main_window_tools.vala"
	_tmp11_ = gspell_text_view_get_inline_spell_checking (_tmp10_);
#line 150 "main_window_tools.vala"
	_tmp12_ = _tmp11_;
#line 150 "main_window_tools.vala"
	_tmp13_ = activate;
#line 150 "main_window_tools.vala"
	if (_tmp12_ != _tmp13_) {
#line 668 "main_window_tools.c"
		GspellTextView* _tmp14_;
		gboolean _tmp15_;
		DocumentView* _tmp16_;
		DocumentView* _tmp17_;
#line 152 "main_window_tools.vala"
		_tmp14_ = gspell_view;
#line 152 "main_window_tools.vala"
		_tmp15_ = activate;
#line 152 "main_window_tools.vala"
		gspell_text_view_set_inline_spell_checking (_tmp14_, _tmp15_);
#line 154 "main_window_tools.vala"
		main_window_tools_update_inline_spell_checker_action_state (self);
#line 156 "main_window_tools.vala"
		_tmp16_ = view;
#line 156 "main_window_tools.vala"
		document_view_save_inline_spell_metadata (_tmp16_);
#line 157 "main_window_tools.vala"
		_tmp17_ = view;
#line 157 "main_window_tools.vala"
		document_view_save_spell_language_metadata (_tmp17_);
#line 689 "main_window_tools.c"
	}
#line 137 "main_window_tools.vala"
	_g_object_unref0 (gspell_view);
#line 137 "main_window_tools.vala"
	_g_object_unref0 (view);
#line 695 "main_window_tools.c"
}


static void
value_main_window_tools_init (GValue* value)
{
#line 24 "main_window_tools.vala"
	value->data[0].v_pointer = NULL;
#line 704 "main_window_tools.c"
}


static void
value_main_window_tools_free_value (GValue* value)
{
#line 24 "main_window_tools.vala"
	if (value->data[0].v_pointer) {
#line 24 "main_window_tools.vala"
		main_window_tools_unref (value->data[0].v_pointer);
#line 715 "main_window_tools.c"
	}
}


static void
value_main_window_tools_copy_value (const GValue* src_value,
                                    GValue* dest_value)
{
#line 24 "main_window_tools.vala"
	if (src_value->data[0].v_pointer) {
#line 24 "main_window_tools.vala"
		dest_value->data[0].v_pointer = main_window_tools_ref (src_value->data[0].v_pointer);
#line 728 "main_window_tools.c"
	} else {
#line 24 "main_window_tools.vala"
		dest_value->data[0].v_pointer = NULL;
#line 732 "main_window_tools.c"
	}
}


static gpointer
value_main_window_tools_peek_pointer (const GValue* value)
{
#line 24 "main_window_tools.vala"
	return value->data[0].v_pointer;
#line 742 "main_window_tools.c"
}


static gchar*
value_main_window_tools_collect_value (GValue* value,
                                       guint n_collect_values,
                                       GTypeCValue* collect_values,
                                       guint collect_flags)
{
#line 24 "main_window_tools.vala"
	if (collect_values[0].v_pointer) {
#line 754 "main_window_tools.c"
		MainWindowTools * object;
		object = collect_values[0].v_pointer;
#line 24 "main_window_tools.vala"
		if (object->parent_instance.g_class == NULL) {
#line 24 "main_window_tools.vala"
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
#line 761 "main_window_tools.c"
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
#line 24 "main_window_tools.vala"
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
#line 765 "main_window_tools.c"
		}
#line 24 "main_window_tools.vala"
		value->data[0].v_pointer = main_window_tools_ref (object);
#line 769 "main_window_tools.c"
	} else {
#line 24 "main_window_tools.vala"
		value->data[0].v_pointer = NULL;
#line 773 "main_window_tools.c"
	}
#line 24 "main_window_tools.vala"
	return NULL;
#line 777 "main_window_tools.c"
}


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;
#line 24 "main_window_tools.vala"
	if (!object_p) {
#line 24 "main_window_tools.vala"
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
#line 793 "main_window_tools.c"
	}
#line 24 "main_window_tools.vala"
	if (!value->data[0].v_pointer) {
#line 24 "main_window_tools.vala"
		*object_p = NULL;
#line 799 "main_window_tools.c"
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
#line 24 "main_window_tools.vala"
		*object_p = value->data[0].v_pointer;
#line 803 "main_window_tools.c"
	} else {
#line 24 "main_window_tools.vala"
		*object_p = main_window_tools_ref (value->data[0].v_pointer);
#line 807 "main_window_tools.c"
	}
#line 24 "main_window_tools.vala"
	return NULL;
#line 811 "main_window_tools.c"
}


GParamSpec*
param_spec_main_window_tools (const gchar* name,
                              const gchar* nick,
                              const gchar* blurb,
                              GType object_type,
                              GParamFlags flags)
{
	ParamSpecMainWindowTools* spec;
#line 24 "main_window_tools.vala"
	g_return_val_if_fail (g_type_is_a (object_type, TYPE_MAIN_WINDOW_TOOLS), NULL);
#line 24 "main_window_tools.vala"
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
#line 24 "main_window_tools.vala"
	G_PARAM_SPEC (spec)->value_type = object_type;
#line 24 "main_window_tools.vala"
	return G_PARAM_SPEC (spec);
#line 831 "main_window_tools.c"
}


gpointer
value_get_main_window_tools (const GValue* value)
{
#line 24 "main_window_tools.vala"
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_MAIN_WINDOW_TOOLS), NULL);
#line 24 "main_window_tools.vala"
	return value->data[0].v_pointer;
#line 842 "main_window_tools.c"
}


void
value_set_main_window_tools (GValue* value,
                             gpointer v_object)
{
	MainWindowTools * old;
#line 24 "main_window_tools.vala"
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_MAIN_WINDOW_TOOLS));
#line 24 "main_window_tools.vala"
	old = value->data[0].v_pointer;
#line 24 "main_window_tools.vala"
	if (v_object) {
#line 24 "main_window_tools.vala"
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_MAIN_WINDOW_TOOLS));
#line 24 "main_window_tools.vala"
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
#line 24 "main_window_tools.vala"
		value->data[0].v_pointer = v_object;
#line 24 "main_window_tools.vala"
		main_window_tools_ref (value->data[0].v_pointer);
#line 865 "main_window_tools.c"
	} else {
#line 24 "main_window_tools.vala"
		value->data[0].v_pointer = NULL;
#line 869 "main_window_tools.c"
	}
#line 24 "main_window_tools.vala"
	if (old) {
#line 24 "main_window_tools.vala"
		main_window_tools_unref (old);
#line 875 "main_window_tools.c"
	}
}


void
value_take_main_window_tools (GValue* value,
                              gpointer v_object)
{
	MainWindowTools * old;
#line 24 "main_window_tools.vala"
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_MAIN_WINDOW_TOOLS));
#line 24 "main_window_tools.vala"
	old = value->data[0].v_pointer;
#line 24 "main_window_tools.vala"
	if (v_object) {
#line 24 "main_window_tools.vala"
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_MAIN_WINDOW_TOOLS));
#line 24 "main_window_tools.vala"
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
#line 24 "main_window_tools.vala"
		value->data[0].v_pointer = v_object;
#line 897 "main_window_tools.c"
	} else {
#line 24 "main_window_tools.vala"
		value->data[0].v_pointer = NULL;
#line 901 "main_window_tools.c"
	}
#line 24 "main_window_tools.vala"
	if (old) {
#line 24 "main_window_tools.vala"
		main_window_tools_unref (old);
#line 907 "main_window_tools.c"
	}
}


static void
main_window_tools_class_init (MainWindowToolsClass * klass)
{
#line 24 "main_window_tools.vala"
	main_window_tools_parent_class = g_type_class_peek_parent (klass);
#line 24 "main_window_tools.vala"
	((MainWindowToolsClass *) klass)->finalize = main_window_tools_finalize;
#line 24 "main_window_tools.vala"
	g_type_class_adjust_private_offset (klass, &MainWindowTools_private_offset);
#line 921 "main_window_tools.c"
}


static void
main_window_tools_instance_init (MainWindowTools * self)
{
#line 24 "main_window_tools.vala"
	self->priv = main_window_tools_get_instance_private (self);
#line 24 "main_window_tools.vala"
	self->ref_count = 1;
#line 932 "main_window_tools.c"
}


static void
main_window_tools_finalize (MainWindowTools * obj)
{
	MainWindowTools * self;
#line 24 "main_window_tools.vala"
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_MAIN_WINDOW_TOOLS, MainWindowTools);
#line 24 "main_window_tools.vala"
	g_signal_handlers_destroy (self);
#line 43 "main_window_tools.vala"
	_g_object_unref0 (self->priv->_action_group);
#line 44 "main_window_tools.vala"
	_g_object_unref0 (self->priv->_editor_settings);
#line 948 "main_window_tools.c"
}


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);
		MainWindowTools_private_offset = g_type_add_instance_private (main_window_tools_type_id, sizeof (MainWindowToolsPrivate));
		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;
#line 24 "main_window_tools.vala"
	g_atomic_int_inc (&self->ref_count);
#line 24 "main_window_tools.vala"
	return instance;
#line 978 "main_window_tools.c"
}


void
main_window_tools_unref (gpointer instance)
{
	MainWindowTools * self;
	self = instance;
#line 24 "main_window_tools.vala"
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
#line 24 "main_window_tools.vala"
		MAIN_WINDOW_TOOLS_GET_CLASS (self)->finalize (self);
#line 24 "main_window_tools.vala"
		g_type_free_instance ((GTypeInstance *) self);
#line 993 "main_window_tools.c"
	}
}


static void
_vala_array_destroy (gpointer array,
                     gint array_length,
                     GDestroyNotify destroy_func)
{
#line 27 "build_tools_preferences.vala"
	if ((array != NULL) && (destroy_func != NULL)) {
#line 1005 "main_window_tools.c"
		int i;
#line 27 "build_tools_preferences.vala"
		for (i = 0; i < array_length; i = i + 1) {
#line 27 "build_tools_preferences.vala"
			if (((gpointer*) array)[i] != NULL) {
#line 27 "build_tools_preferences.vala"
				destroy_func (((gpointer*) array)[i]);
#line 1013 "main_window_tools.c"
			}
		}
	}
}


static void
_vala_array_free (gpointer array,
                  gint array_length,
                  GDestroyNotify destroy_func)
{
#line 27 "build_tools_preferences.vala"
	_vala_array_destroy (array, array_length, destroy_func);
#line 27 "build_tools_preferences.vala"
	g_free (array);
#line 1029 "main_window_tools.c"
}



