/* spell-check-popover.c generated by valac 0.56.3, the Vala compiler
 * generated from spell-check-popover.vala, do not modify */

/* Copyright 2016 Software Freedom Conservancy Inc.
 *
 * This software is licensed under the GNU Lesser General Public License
 * (version 2.1 or later).  See the COPYING file in this distribution.
 */

#include "geary-client-43.0.h"
#include <gtk/gtk.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib-object.h>
#include <glib/gi18n-lib.h>
#include <pango/pango.h>
#include <float.h>
#include <math.h>
#include <gobject/gvaluecollector.h>

typedef enum  {
	SPELL_CHECK_POPOVER_SPELL_CHECK_STATUS_INACTIVE,
	SPELL_CHECK_POPOVER_SPELL_CHECK_STATUS_ACTIVE
} SpellCheckPopoverSpellCheckStatus;

#define SPELL_CHECK_POPOVER_TYPE_SPELL_CHECK_STATUS (spell_check_popover_spell_check_status_get_type ())
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))

#define SPELL_CHECK_POPOVER_TYPE_SPELL_CHECK_LANG_ROW (spell_check_popover_spell_check_lang_row_get_type ())
#define SPELL_CHECK_POPOVER_SPELL_CHECK_LANG_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPELL_CHECK_POPOVER_TYPE_SPELL_CHECK_LANG_ROW, SpellCheckPopoverSpellCheckLangRow))
#define SPELL_CHECK_POPOVER_SPELL_CHECK_LANG_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SPELL_CHECK_POPOVER_TYPE_SPELL_CHECK_LANG_ROW, SpellCheckPopoverSpellCheckLangRowClass))
#define SPELL_CHECK_POPOVER_IS_SPELL_CHECK_LANG_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SPELL_CHECK_POPOVER_TYPE_SPELL_CHECK_LANG_ROW))
#define SPELL_CHECK_POPOVER_IS_SPELL_CHECK_LANG_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SPELL_CHECK_POPOVER_TYPE_SPELL_CHECK_LANG_ROW))
#define SPELL_CHECK_POPOVER_SPELL_CHECK_LANG_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SPELL_CHECK_POPOVER_TYPE_SPELL_CHECK_LANG_ROW, SpellCheckPopoverSpellCheckLangRowClass))

typedef struct _SpellCheckPopoverSpellCheckLangRow SpellCheckPopoverSpellCheckLangRow;
typedef struct _SpellCheckPopoverSpellCheckLangRowClass SpellCheckPopoverSpellCheckLangRowClass;
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block77Data Block77Data;
#define _spell_check_popover_unref0(var) ((var == NULL) ? NULL : (var = (spell_check_popover_unref (var), NULL)))
typedef struct _Block78Data Block78Data;
typedef struct _SpellCheckPopoverSpellCheckLangRowPrivate SpellCheckPopoverSpellCheckLangRowPrivate;
enum  {
	SPELL_CHECK_POPOVER_SPELL_CHECK_LANG_ROW_0_PROPERTY,
	SPELL_CHECK_POPOVER_SPELL_CHECK_LANG_ROW_LANG_CODE_PROPERTY,
	SPELL_CHECK_POPOVER_SPELL_CHECK_LANG_ROW_NUM_PROPERTIES
};
static GParamSpec* spell_check_popover_spell_check_lang_row_properties[SPELL_CHECK_POPOVER_SPELL_CHECK_LANG_ROW_NUM_PROPERTIES];
enum  {
	SPELL_CHECK_POPOVER_SPELL_CHECK_LANG_ROW_ENABLED_CHANGED_SIGNAL,
	SPELL_CHECK_POPOVER_SPELL_CHECK_LANG_ROW_VISIBILITY_CHANGED_SIGNAL,
	SPELL_CHECK_POPOVER_SPELL_CHECK_LANG_ROW_NUM_SIGNALS
};
static guint spell_check_popover_spell_check_lang_row_signals[SPELL_CHECK_POPOVER_SPELL_CHECK_LANG_ROW_NUM_SIGNALS] = {0};
typedef struct _ParamSpecSpellCheckPopover ParamSpecSpellCheckPopover;
enum  {
	SPELL_CHECK_POPOVER_SELECTION_CHANGED_SIGNAL,
	SPELL_CHECK_POPOVER_NUM_SIGNALS
};
static guint spell_check_popover_signals[SPELL_CHECK_POPOVER_NUM_SIGNALS] = {0};

struct _SpellCheckPopoverPrivate {
	GtkPopover* popover;
	GHashTable* selected_rows;
	gboolean is_expanded;
	GtkListBox* langs_list;
	GtkSearchEntry* search_box;
	GtkScrolledWindow* view;
	GtkBox* content;
	ApplicationConfiguration* config;
};

struct _Block77Data {
	int _ref_count_;
	SpellCheckPopover* self;
	gchar** active_langs;
	gint active_langs_length1;
	gint _active_langs_size_;
};

struct _Block78Data {
	int _ref_count_;
	GHashTable* self;
	GFunc func;
	gpointer func_target;
};

struct _SpellCheckPopoverSpellCheckLangRow {
	GtkListBoxRow parent_instance;
	SpellCheckPopoverSpellCheckLangRowPrivate * priv;
};

struct _SpellCheckPopoverSpellCheckLangRowClass {
	GtkListBoxRowClass parent_class;
};

struct _SpellCheckPopoverSpellCheckLangRowPrivate {
	gchar* _lang_code;
	gchar* lang_name;
	gchar* country_name;
	gboolean is_lang_visible;
	GtkImage* active_image;
	GtkButton* visibility_button;
	SpellCheckPopoverSpellCheckStatus lang_active;
};

struct _ParamSpecSpellCheckPopover {
	GParamSpec parent_instance;
};

static gint SpellCheckPopover_private_offset;
static gpointer spell_check_popover_parent_class = NULL;
static gint SpellCheckPopoverSpellCheckLangRow_private_offset;
static gpointer spell_check_popover_spell_check_lang_row_parent_class = NULL;

static GType spell_check_popover_spell_check_status_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static void g_cclosure_user_marshal_VOID__BOXED_INT (GClosure * closure,
                                              GValue * return_value,
                                              guint n_param_values,
                                              const GValue * param_values,
                                              gpointer invocation_hint,
                                              gpointer marshal_data);
static void _g_free0_ (gpointer var);
static void spell_check_popover_setup_popover (SpellCheckPopover* self);
static void spell_check_popover_header_function (SpellCheckPopover* self,
                                          GtkListBoxRow* row,
                                          GtkListBoxRow* before);
static gboolean spell_check_popover_filter_function (SpellCheckPopover* self,
                                              GtkListBoxRow* row);
static GType spell_check_popover_spell_check_lang_row_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static gboolean spell_check_popover_spell_check_lang_row_is_row_visible (SpellCheckPopoverSpellCheckLangRow* self,
                                                                  gboolean is_expanded);
static gboolean spell_check_popover_spell_check_lang_row_match_filter (SpellCheckPopoverSpellCheckLangRow* self,
                                                                const gchar* filter);
static void spell_check_popover_on_search_box_changed (SpellCheckPopover* self);
static void _spell_check_popover_on_search_box_changed_gtk_editable_changed (GtkEditable* _sender,
                                                                      gpointer self);
static void spell_check_popover_on_search_box_grab_focus (SpellCheckPopover* self);
static void _spell_check_popover_on_search_box_grab_focus_gtk_widget_grab_focus (GtkWidget* _sender,
                                                                          gpointer self);
static gboolean _vala_string_array_contains (gchar* * stack,
                                      gssize stack_length,
                                      const gchar* needle);
static SpellCheckPopoverSpellCheckLangRow* spell_check_popover_spell_check_lang_row_new (const gchar* lang_code,
                                                                                  gboolean is_active,
                                                                                  gboolean is_visible);
static SpellCheckPopoverSpellCheckLangRow* spell_check_popover_spell_check_lang_row_construct (GType object_type,
                                                                                        const gchar* lang_code,
                                                                                        gboolean is_active,
                                                                                        gboolean is_visible);
static gboolean spell_check_popover_spell_check_lang_row_is_lang_active (SpellCheckPopoverSpellCheckLangRow* self);
static void spell_check_popover_on_row_enabled_changed (SpellCheckPopover* self,
                                                 SpellCheckPopoverSpellCheckLangRow* row,
                                                 gboolean is_active);
static void _spell_check_popover_on_row_enabled_changed_spell_check_popover_spell_check_lang_row_enabled_changed (SpellCheckPopoverSpellCheckLangRow* _sender,
                                                                                                           gboolean is_enabled,
                                                                                                           gpointer self);
static void spell_check_popover_on_row_visibility_changed (SpellCheckPopover* self,
                                                    SpellCheckPopoverSpellCheckLangRow* row,
                                                    gboolean is_visible);
static void _spell_check_popover_on_row_visibility_changed_spell_check_popover_spell_check_lang_row_visibility_changed (SpellCheckPopoverSpellCheckLangRow* _sender,
                                                                                                                 gboolean is_visible,
                                                                                                                 gpointer self);
static void spell_check_popover_on_row_activated (SpellCheckPopover* self,
                                           GtkListBoxRow* row);
static void _spell_check_popover_on_row_activated_gtk_list_box_row_activated (GtkListBox* _sender,
                                                                       GtkListBoxRow* row,
                                                                       gpointer self);
static gboolean _spell_check_popover_filter_function_gtk_list_box_filter_func (GtkListBoxRow* row,
                                                                        gpointer self);
static void _spell_check_popover_header_function_gtk_list_box_update_header_func (GtkListBoxRow* row,
                                                                           GtkListBoxRow* before,
                                                                           gpointer self);
static void spell_check_popover_on_shown (SpellCheckPopover* self);
static void _spell_check_popover_on_shown_gtk_widget_show (GtkWidget* _sender,
                                                    gpointer self);
static void spell_check_popover_spell_check_lang_row_handle_activation (SpellCheckPopoverSpellCheckLangRow* self,
                                                                 SpellCheckPopover* spell_check_popover);
static void spell_check_popover_set_expanded (SpellCheckPopover* self,
                                       gboolean expanded);
static Block77Data* block77_data_ref (Block77Data* _data77_);
static void block77_data_unref (void * _userdata_);
static const gchar* spell_check_popover_spell_check_lang_row_get_lang_code (SpellCheckPopoverSpellCheckLangRow* self);
static Block78Data* block78_data_ref (Block78Data* _data78_);
static void block78_data_unref (void * _userdata_);
static void ___lambda0__gh_func (gconstpointer key,
                          gconstpointer value,
                          gpointer self);
static void __lambda25_ (Block77Data* _data77_,
                  const gchar* lang);
static void _vala_array_add15 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
static void ___lambda25__gfunc (gconstpointer data,
                         gpointer self);
static void _vala_array_add16 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
static void _vala_array_add17 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
static gchar** _vala_array_dup6 (gchar** self,
                          gssize length);
static void spell_check_popover_spell_check_lang_row_set_lang_code (SpellCheckPopoverSpellCheckLangRow* self,
                                                             const gchar* value);
static void spell_check_popover_spell_check_lang_row_on_visibility_clicked (SpellCheckPopoverSpellCheckLangRow* self);
static void _spell_check_popover_spell_check_lang_row_on_visibility_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                                         gpointer self);
static void spell_check_popover_spell_check_lang_row_update_images (SpellCheckPopoverSpellCheckLangRow* self);
static void spell_check_popover_spell_check_lang_row_set_lang_active (SpellCheckPopoverSpellCheckLangRow* self,
                                                               SpellCheckPopoverSpellCheckStatus active);
static void spell_check_popover_spell_check_lang_row_set_lang_visible (SpellCheckPopoverSpellCheckLangRow* self,
                                                                gboolean is_visible);
static void spell_check_popover_spell_check_lang_row_finalize (GObject * obj);
static GType spell_check_popover_spell_check_lang_row_get_type_once (void);
static void _vala_spell_check_popover_spell_check_lang_row_get_property (GObject * object,
                                                                  guint property_id,
                                                                  GValue * value,
                                                                  GParamSpec * pspec);
static void _vala_spell_check_popover_spell_check_lang_row_set_property (GObject * object,
                                                                  guint property_id,
                                                                  const GValue * value,
                                                                  GParamSpec * pspec);
static void spell_check_popover_finalize (SpellCheckPopover * obj);
static GType spell_check_popover_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static inline gpointer
spell_check_popover_get_instance_private (SpellCheckPopover* self)
{
	return G_STRUCT_MEMBER_P (self, SpellCheckPopover_private_offset);
}

static GType
spell_check_popover_spell_check_status_get_type_once (void)
{
	static const GEnumValue values[] = {{SPELL_CHECK_POPOVER_SPELL_CHECK_STATUS_INACTIVE, "SPELL_CHECK_POPOVER_SPELL_CHECK_STATUS_INACTIVE", "inactive"}, {SPELL_CHECK_POPOVER_SPELL_CHECK_STATUS_ACTIVE, "SPELL_CHECK_POPOVER_SPELL_CHECK_STATUS_ACTIVE", "active"}, {0, NULL, NULL}};
	GType spell_check_popover_spell_check_status_type_id;
	spell_check_popover_spell_check_status_type_id = g_enum_register_static ("SpellCheckPopoverSpellCheckStatus", values);
	return spell_check_popover_spell_check_status_type_id;
}

static GType
spell_check_popover_spell_check_status_get_type (void)
{
	static volatile gsize spell_check_popover_spell_check_status_type_id__once = 0;
	if (g_once_init_enter (&spell_check_popover_spell_check_status_type_id__once)) {
		GType spell_check_popover_spell_check_status_type_id;
		spell_check_popover_spell_check_status_type_id = spell_check_popover_spell_check_status_get_type_once ();
		g_once_init_leave (&spell_check_popover_spell_check_status_type_id__once, spell_check_popover_spell_check_status_type_id);
	}
	return spell_check_popover_spell_check_status_type_id__once;
}

static void
g_cclosure_user_marshal_VOID__BOXED_INT (GClosure * closure,
                                         GValue * return_value,
                                         guint n_param_values,
                                         const GValue * param_values,
                                         gpointer invocation_hint,
                                         gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__BOXED_INT) (gpointer data1, gpointer arg_1, gint arg_2, gpointer data2);
	register GMarshalFunc_VOID__BOXED_INT callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__BOXED_INT) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_boxed (param_values + 1), g_value_get_int (param_values + 2), data2);
}

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

static void
_g_free0_ (gpointer var)
{
	var = (g_free (var), NULL);
}

SpellCheckPopover*
spell_check_popover_construct (GType object_type,
                               GtkMenuButton* button,
                               ApplicationConfiguration* config)
{
	SpellCheckPopover* self = NULL;
	GtkPopover* _tmp0_;
	GtkPopover* _tmp1_;
	ApplicationConfiguration* _tmp2_;
	GHashFunc _tmp3_;
	GEqualFunc _tmp4_;
	GHashTable* _tmp5_;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (button, gtk_menu_button_get_type ()), NULL);
	g_return_val_if_fail (APPLICATION_IS_CONFIGURATION (config), NULL);
	self = (SpellCheckPopover*) g_type_create_instance (object_type);
	_tmp0_ = (GtkPopover*) gtk_popover_new (G_TYPE_CHECK_INSTANCE_CAST (button, gtk_widget_get_type (), GtkWidget));
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->popover);
	self->priv->popover = _tmp0_;
	_tmp1_ = self->priv->popover;
	gtk_menu_button_set_popover (button, _tmp1_);
	_tmp2_ = _g_object_ref0 (config);
	_g_object_unref0 (self->priv->config);
	self->priv->config = _tmp2_;
	_tmp3_ = g_str_hash;
	_tmp4_ = g_str_equal;
	_tmp5_ = g_hash_table_new_full (_tmp3_, _tmp4_, NULL, _g_free0_);
	_g_hash_table_unref0 (self->priv->selected_rows);
	self->priv->selected_rows = _tmp5_;
	spell_check_popover_setup_popover (self);
	return self;
}

SpellCheckPopover*
spell_check_popover_new (GtkMenuButton* button,
                         ApplicationConfiguration* config)
{
	return spell_check_popover_construct (TYPE_SPELL_CHECK_POPOVER, button, config);
}

static void
spell_check_popover_header_function (SpellCheckPopover* self,
                                     GtkListBoxRow* row,
                                     GtkListBoxRow* before)
{
	g_return_if_fail (IS_SPELL_CHECK_POPOVER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (row, gtk_list_box_row_get_type ()));
	g_return_if_fail ((before == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (before, gtk_list_box_row_get_type ()));
	if (before != NULL) {
		GtkWidget* _tmp0_;
		_tmp0_ = gtk_list_box_row_get_header (row);
		if (_tmp0_ == NULL) {
			GtkSeparator* _tmp1_;
			GtkSeparator* _tmp2_;
			_tmp1_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
			g_object_ref_sink (_tmp1_);
			_tmp2_ = _tmp1_;
			gtk_list_box_row_set_header (row, G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, gtk_widget_get_type (), GtkWidget));
			_g_object_unref0 (_tmp2_);
		}
	}
}

static gboolean
spell_check_popover_filter_function (SpellCheckPopover* self,
                                     GtkListBoxRow* row)
{
	gchar* text = NULL;
	GtkSearchEntry* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	SpellCheckPopoverSpellCheckLangRow* r = NULL;
	SpellCheckPopoverSpellCheckLangRow* _tmp3_;
	gboolean _tmp4_ = FALSE;
	SpellCheckPopoverSpellCheckLangRow* _tmp5_;
	gboolean result;
	g_return_val_if_fail (IS_SPELL_CHECK_POPOVER (self), FALSE);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (row, gtk_list_box_row_get_type ()), FALSE);
	_tmp0_ = self->priv->search_box;
	_tmp1_ = gtk_entry_get_text (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gtk_entry_get_type (), GtkEntry));
	_tmp2_ = g_strdup (_tmp1_);
	text = _tmp2_;
	_tmp3_ = _g_object_ref0 (SPELL_CHECK_POPOVER_IS_SPELL_CHECK_LANG_ROW (row) ? ((SpellCheckPopoverSpellCheckLangRow*) row) : NULL);
	r = _tmp3_;
	_tmp5_ = r;
	if (spell_check_popover_spell_check_lang_row_is_row_visible (_tmp5_, self->priv->is_expanded)) {
		SpellCheckPopoverSpellCheckLangRow* _tmp6_;
		const gchar* _tmp7_;
		_tmp6_ = r;
		_tmp7_ = text;
		_tmp4_ = spell_check_popover_spell_check_lang_row_match_filter (_tmp6_, _tmp7_);
	} else {
		_tmp4_ = FALSE;
	}
	result = _tmp4_;
	_g_object_unref0 (r);
	_g_free0 (text);
	return result;
}

static void
_spell_check_popover_on_search_box_changed_gtk_editable_changed (GtkEditable* _sender,
                                                                 gpointer self)
{
	spell_check_popover_on_search_box_changed ((SpellCheckPopover*) self);
}

static void
_spell_check_popover_on_search_box_grab_focus_gtk_widget_grab_focus (GtkWidget* _sender,
                                                                     gpointer self)
{
	spell_check_popover_on_search_box_grab_focus ((SpellCheckPopover*) self);
}

static gboolean
_vala_string_array_contains (gchar* * stack,
                             gssize stack_length,
                             const gchar* needle)
{
	gssize i;
	for (i = 0; i < stack_length; i++) {
		if (g_strcmp0 (stack[i], needle) == 0) {
			return TRUE;
		}
	}
	return FALSE;
}

static void
_spell_check_popover_on_row_enabled_changed_spell_check_popover_spell_check_lang_row_enabled_changed (SpellCheckPopoverSpellCheckLangRow* _sender,
                                                                                                      gboolean is_enabled,
                                                                                                      gpointer self)
{
	spell_check_popover_on_row_enabled_changed ((SpellCheckPopover*) self, _sender, is_enabled);
}

static void
_spell_check_popover_on_row_visibility_changed_spell_check_popover_spell_check_lang_row_visibility_changed (SpellCheckPopoverSpellCheckLangRow* _sender,
                                                                                                            gboolean is_visible,
                                                                                                            gpointer self)
{
	spell_check_popover_on_row_visibility_changed ((SpellCheckPopover*) self, _sender, is_visible);
}

static void
_spell_check_popover_on_row_activated_gtk_list_box_row_activated (GtkListBox* _sender,
                                                                  GtkListBoxRow* row,
                                                                  gpointer self)
{
	spell_check_popover_on_row_activated ((SpellCheckPopover*) self, row);
}

static gboolean
_spell_check_popover_filter_function_gtk_list_box_filter_func (GtkListBoxRow* row,
                                                               gpointer self)
{
	gboolean result;
	result = spell_check_popover_filter_function ((SpellCheckPopover*) self, row);
	return result;
}

static void
_spell_check_popover_header_function_gtk_list_box_update_header_func (GtkListBoxRow* row,
                                                                      GtkListBoxRow* before,
                                                                      gpointer self)
{
	spell_check_popover_header_function ((SpellCheckPopover*) self, row, before);
}

static void
_spell_check_popover_on_shown_gtk_widget_show (GtkWidget* _sender,
                                               gpointer self)
{
	spell_check_popover_on_shown ((SpellCheckPopover*) self);
}

static void
spell_check_popover_setup_popover (SpellCheckPopover* self)
{
	gchar** languages = NULL;
	gint _tmp0_ = 0;
	gchar** _tmp1_;
	gint languages_length1;
	gint _languages_size_;
	gchar** enabled_langs = NULL;
	ApplicationConfiguration* _tmp2_;
	gint _tmp3_ = 0;
	gchar** _tmp4_;
	gint enabled_langs_length1;
	gint _enabled_langs_size_;
	gchar** visible_langs = NULL;
	ApplicationConfiguration* _tmp5_;
	gint _tmp6_ = 0;
	gchar** _tmp7_;
	gint visible_langs_length1;
	gint _visible_langs_size_;
	GtkBox* _tmp8_;
	GtkSearchEntry* _tmp9_;
	GtkSearchEntry* _tmp10_;
	GtkSearchEntry* _tmp11_;
	GtkSearchEntry* _tmp12_;
	GtkBox* _tmp13_;
	GtkSearchEntry* _tmp14_;
	GtkScrolledWindow* _tmp15_;
	GtkScrolledWindow* _tmp16_;
	GtkScrolledWindow* _tmp17_;
	GtkListBox* _tmp18_;
	GtkListBox* _tmp19_;
	gchar** _tmp20_;
	gint _tmp20__length1;
	GtkListBox* _tmp36_;
	GtkScrolledWindow* _tmp37_;
	GtkListBox* _tmp38_;
	GtkBox* _tmp39_;
	GtkScrolledWindow* _tmp40_;
	GtkListBox* _tmp41_;
	GtkListBox* _tmp42_;
	GtkPopover* _tmp43_;
	GtkBox* _tmp44_;
	GtkBox* _tmp45_;
	GtkScrolledWindow* _tmp46_;
	GtkBox* _tmp47_;
	GtkBox* _tmp48_;
	GtkBox* _tmp49_;
	GtkBox* _tmp50_;
	GtkPopover* _tmp51_;
	GtkPopover* _tmp52_;
	g_return_if_fail (IS_SPELL_CHECK_POPOVER (self));
	_tmp1_ = util_i18n_get_available_dictionaries (&_tmp0_);
	languages = _tmp1_;
	languages_length1 = _tmp0_;
	_languages_size_ = languages_length1;
	_tmp2_ = self->priv->config;
	_tmp4_ = application_configuration_get_spell_check_languages (_tmp2_, &_tmp3_);
	enabled_langs = _tmp4_;
	enabled_langs_length1 = _tmp3_;
	_enabled_langs_size_ = enabled_langs_length1;
	_tmp5_ = self->priv->config;
	_tmp7_ = application_configuration_get_spell_check_visible_languages (_tmp5_, &_tmp6_);
	visible_langs = _tmp7_;
	visible_langs_length1 = _tmp6_;
	_visible_langs_size_ = visible_langs_length1;
	_tmp8_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
	g_object_ref_sink (_tmp8_);
	_g_object_unref0 (self->priv->content);
	self->priv->content = _tmp8_;
	_tmp9_ = (GtkSearchEntry*) gtk_search_entry_new ();
	g_object_ref_sink (_tmp9_);
	_g_object_unref0 (self->priv->search_box);
	self->priv->search_box = _tmp9_;
	_tmp10_ = self->priv->search_box;
	gtk_entry_set_placeholder_text (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, gtk_entry_get_type (), GtkEntry), _ ("Search for more languages"));
	_tmp11_ = self->priv->search_box;
	g_signal_connect (G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, gtk_editable_get_type (), GtkEditable), "changed", (GCallback) _spell_check_popover_on_search_box_changed_gtk_editable_changed, self);
	_tmp12_ = self->priv->search_box;
	g_signal_connect (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, gtk_widget_get_type (), GtkWidget), "grab-focus", (GCallback) _spell_check_popover_on_search_box_grab_focus_gtk_widget_grab_focus, self);
	_tmp13_ = self->priv->content;
	_tmp14_ = self->priv->search_box;
	gtk_box_pack_start (_tmp13_, G_TYPE_CHECK_INSTANCE_CAST (_tmp14_, gtk_widget_get_type (), GtkWidget), FALSE, TRUE, (guint) 0);
	_tmp15_ = (GtkScrolledWindow*) gtk_scrolled_window_new (NULL, NULL);
	g_object_ref_sink (_tmp15_);
	_g_object_unref0 (self->priv->view);
	self->priv->view = _tmp15_;
	_tmp16_ = self->priv->view;
	gtk_scrolled_window_set_shadow_type (_tmp16_, GTK_SHADOW_IN);
	_tmp17_ = self->priv->view;
	gtk_scrolled_window_set_policy (_tmp17_, GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
	_tmp18_ = (GtkListBox*) gtk_list_box_new ();
	g_object_ref_sink (_tmp18_);
	_g_object_unref0 (self->priv->langs_list);
	self->priv->langs_list = _tmp18_;
	_tmp19_ = self->priv->langs_list;
	gtk_list_box_set_selection_mode (_tmp19_, GTK_SELECTION_NONE);
	_tmp20_ = languages;
	_tmp20__length1 = languages_length1;
	{
		gchar** lang_collection = NULL;
		gint lang_collection_length1 = 0;
		gint _lang_collection_size_ = 0;
		gint lang_it = 0;
		lang_collection = _tmp20_;
		lang_collection_length1 = _tmp20__length1;
		for (lang_it = 0; lang_it < lang_collection_length1; lang_it = lang_it + 1) {
			gchar* _tmp21_;
			gchar* lang = NULL;
			_tmp21_ = g_strdup (lang_collection[lang_it]);
			lang = _tmp21_;
			{
				SpellCheckPopoverSpellCheckLangRow* row = NULL;
				const gchar* _tmp22_;
				const gchar* _tmp23_;
				gchar** _tmp24_;
				gint _tmp24__length1;
				const gchar* _tmp25_;
				gchar** _tmp26_;
				gint _tmp26__length1;
				SpellCheckPopoverSpellCheckLangRow* _tmp27_;
				GtkListBox* _tmp28_;
				SpellCheckPopoverSpellCheckLangRow* _tmp29_;
				SpellCheckPopoverSpellCheckLangRow* _tmp30_;
				SpellCheckPopoverSpellCheckLangRow* _tmp34_;
				SpellCheckPopoverSpellCheckLangRow* _tmp35_;
				_tmp22_ = lang;
				_tmp23_ = lang;
				_tmp24_ = enabled_langs;
				_tmp24__length1 = enabled_langs_length1;
				_tmp25_ = lang;
				_tmp26_ = visible_langs;
				_tmp26__length1 = visible_langs_length1;
				_tmp27_ = spell_check_popover_spell_check_lang_row_new (_tmp22_, _vala_string_array_contains (_tmp24_, _tmp24__length1, _tmp23_), _vala_string_array_contains (_tmp26_, _tmp26__length1, _tmp25_));
				g_object_ref_sink (_tmp27_);
				row = _tmp27_;
				_tmp28_ = self->priv->langs_list;
				_tmp29_ = row;
				gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp28_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp29_, gtk_widget_get_type (), GtkWidget));
				_tmp30_ = row;
				if (spell_check_popover_spell_check_lang_row_is_lang_active (_tmp30_)) {
					GHashTable* _tmp31_;
					const gchar* _tmp32_;
					gchar* _tmp33_;
					_tmp31_ = self->priv->selected_rows;
					_tmp32_ = lang;
					_tmp33_ = g_strdup (_tmp32_);
					g_hash_table_add (_tmp31_, _tmp33_);
				}
				_tmp34_ = row;
				g_signal_connect (_tmp34_, "enabled-changed", (GCallback) _spell_check_popover_on_row_enabled_changed_spell_check_popover_spell_check_lang_row_enabled_changed, self);
				_tmp35_ = row;
				g_signal_connect (_tmp35_, "visibility-changed", (GCallback) _spell_check_popover_on_row_visibility_changed_spell_check_popover_spell_check_lang_row_visibility_changed, self);
				_g_object_unref0 (row);
				_g_free0 (lang);
			}
		}
	}
	_tmp36_ = self->priv->langs_list;
	g_signal_connect (_tmp36_, "row-activated", (GCallback) _spell_check_popover_on_row_activated_gtk_list_box_row_activated, self);
	_tmp37_ = self->priv->view;
	_tmp38_ = self->priv->langs_list;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp37_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp38_, gtk_widget_get_type (), GtkWidget));
	_tmp39_ = self->priv->content;
	_tmp40_ = self->priv->view;
	gtk_box_pack_start (_tmp39_, G_TYPE_CHECK_INSTANCE_CAST (_tmp40_, gtk_widget_get_type (), GtkWidget), TRUE, TRUE, (guint) 0);
	_tmp41_ = self->priv->langs_list;
	gtk_list_box_set_filter_func (_tmp41_, _spell_check_popover_filter_function_gtk_list_box_filter_func, spell_check_popover_ref (self), spell_check_popover_unref);
	_tmp42_ = self->priv->langs_list;
	gtk_list_box_set_header_func (_tmp42_, _spell_check_popover_header_function_gtk_list_box_update_header_func, spell_check_popover_ref (self), spell_check_popover_unref);
	_tmp43_ = self->priv->popover;
	_tmp44_ = self->priv->content;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp43_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp44_, gtk_widget_get_type (), GtkWidget));
	_tmp45_ = self->priv->content;
	_tmp46_ = self->priv->view;
	gtk_container_set_focus_child (G_TYPE_CHECK_INSTANCE_CAST (_tmp45_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp46_, gtk_widget_get_type (), GtkWidget));
	_tmp47_ = self->priv->content;
	gtk_widget_set_margin_start (G_TYPE_CHECK_INSTANCE_CAST (_tmp47_, gtk_widget_get_type (), GtkWidget), 6);
	_tmp48_ = self->priv->content;
	gtk_widget_set_margin_end (G_TYPE_CHECK_INSTANCE_CAST (_tmp48_, gtk_widget_get_type (), GtkWidget), 6);
	_tmp49_ = self->priv->content;
	gtk_widget_set_margin_top (G_TYPE_CHECK_INSTANCE_CAST (_tmp49_, gtk_widget_get_type (), GtkWidget), 6);
	_tmp50_ = self->priv->content;
	gtk_widget_set_margin_bottom (G_TYPE_CHECK_INSTANCE_CAST (_tmp50_, gtk_widget_get_type (), GtkWidget), 6);
	_tmp51_ = self->priv->popover;
	g_signal_connect (G_TYPE_CHECK_INSTANCE_CAST (_tmp51_, gtk_widget_get_type (), GtkWidget), "show", (GCallback) _spell_check_popover_on_shown_gtk_widget_show, self);
	_tmp52_ = self->priv->popover;
	gtk_widget_set_size_request (G_TYPE_CHECK_INSTANCE_CAST (_tmp52_, gtk_widget_get_type (), GtkWidget), 360, 350);
	visible_langs = (_vala_array_free (visible_langs, visible_langs_length1, (GDestroyNotify) g_free), NULL);
	enabled_langs = (_vala_array_free (enabled_langs, enabled_langs_length1, (GDestroyNotify) g_free), NULL);
	languages = (_vala_array_free (languages, languages_length1, (GDestroyNotify) g_free), NULL);
}

static void
spell_check_popover_on_row_activated (SpellCheckPopover* self,
                                      GtkListBoxRow* row)
{
	SpellCheckPopoverSpellCheckLangRow* r = NULL;
	SpellCheckPopoverSpellCheckLangRow* _tmp0_;
	GtkListBox* _tmp1_;
	g_return_if_fail (IS_SPELL_CHECK_POPOVER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (row, gtk_list_box_row_get_type ()));
	_tmp0_ = _g_object_ref0 (SPELL_CHECK_POPOVER_IS_SPELL_CHECK_LANG_ROW (row) ? ((SpellCheckPopoverSpellCheckLangRow*) row) : NULL);
	r = _tmp0_;
	spell_check_popover_spell_check_lang_row_handle_activation (r, self);
	_tmp1_ = self->priv->langs_list;
	gtk_list_box_invalidate_filter (_tmp1_);
	_g_object_unref0 (r);
}

static void
spell_check_popover_on_search_box_changed (SpellCheckPopover* self)
{
	GtkListBox* _tmp0_;
	g_return_if_fail (IS_SPELL_CHECK_POPOVER (self));
	_tmp0_ = self->priv->langs_list;
	gtk_list_box_invalidate_filter (_tmp0_);
}

static void
spell_check_popover_on_search_box_grab_focus (SpellCheckPopover* self)
{
	g_return_if_fail (IS_SPELL_CHECK_POPOVER (self));
	spell_check_popover_set_expanded (self, TRUE);
}

static void
spell_check_popover_set_expanded (SpellCheckPopover* self,
                                  gboolean expanded)
{
	GtkListBox* _tmp0_;
	g_return_if_fail (IS_SPELL_CHECK_POPOVER (self));
	self->priv->is_expanded = expanded;
	_tmp0_ = self->priv->langs_list;
	gtk_list_box_invalidate_filter (_tmp0_);
}

static void
spell_check_popover_on_shown (SpellCheckPopover* self)
{
	GtkSearchEntry* _tmp0_;
	GtkBox* _tmp1_;
	GtkScrolledWindow* _tmp2_;
	GtkListBox* _tmp3_;
	GtkPopover* _tmp4_;
	g_return_if_fail (IS_SPELL_CHECK_POPOVER (self));
	_tmp0_ = self->priv->search_box;
	gtk_entry_set_text (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gtk_entry_get_type (), GtkEntry), "");
	_tmp1_ = self->priv->content;
	_tmp2_ = self->priv->view;
	gtk_container_set_focus_child (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, gtk_widget_get_type (), GtkWidget));
	self->priv->is_expanded = FALSE;
	_tmp3_ = self->priv->langs_list;
	gtk_list_box_invalidate_filter (_tmp3_);
	_tmp4_ = self->priv->popover;
	gtk_widget_show_all (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, gtk_widget_get_type (), GtkWidget));
}

static Block77Data*
block77_data_ref (Block77Data* _data77_)
{
	g_atomic_int_inc (&_data77_->_ref_count_);
	return _data77_;
}

static void
block77_data_unref (void * _userdata_)
{
	Block77Data* _data77_;
	_data77_ = (Block77Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data77_->_ref_count_)) {
		SpellCheckPopover* self;
		self = _data77_->self;
		_data77_->active_langs = (_vala_array_free (_data77_->active_langs, _data77_->active_langs_length1, (GDestroyNotify) g_free), NULL);
		_spell_check_popover_unref0 (self);
		g_slice_free (Block77Data, _data77_);
	}
}

static Block78Data*
block78_data_ref (Block78Data* _data78_)
{
	g_atomic_int_inc (&_data78_->_ref_count_);
	return _data78_;
}

static void
block78_data_unref (void * _userdata_)
{
	Block78Data* _data78_;
	_data78_ = (Block78Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data78_->_ref_count_)) {
		GHashTable* self;
		self = _data78_->self;
		_g_hash_table_unref0 (self);
		g_slice_free (Block78Data, _data78_);
	}
}

static void
__lambda0_ (Block78Data* _data78_,
            gconstpointer k,
            gconstpointer v)
{
	GHashTable* self;
	self = _data78_->self;
	_data78_->func (v, _data78_->func_target);
}

static void
___lambda0__gh_func (gconstpointer key,
                     gconstpointer value,
                     gpointer self)
{
	__lambda0_ (self, key, value);
}

static void
_vala_g_hash_set_foreach (GHashTable* self,
                          GFunc func,
                          gpointer func_target)
{
	Block78Data* _data78_;
	g_return_if_fail (self != NULL);
	_data78_ = g_slice_new0 (Block78Data);
	_data78_->_ref_count_ = 1;
	_data78_->self = g_hash_table_ref (self);
	_data78_->func = func;
	_data78_->func_target = func_target;
	g_hash_table_foreach ((GHashTable*) self, ___lambda0__gh_func, _data78_);
	block78_data_unref (_data78_);
	_data78_ = NULL;
}

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

static void
__lambda25_ (Block77Data* _data77_,
             const gchar* lang)
{
	SpellCheckPopover* self;
	gchar* _tmp0_;
	self = _data77_->self;
	g_return_if_fail (lang != NULL);
	_tmp0_ = g_strdup (lang);
	_vala_array_add15 (&_data77_->active_langs, &_data77_->active_langs_length1, &_data77_->_active_langs_size_, _tmp0_);
}

static void
___lambda25__gfunc (gconstpointer data,
                    gpointer self)
{
	__lambda25_ (self, (const gchar*) data);
}

static void
spell_check_popover_on_row_enabled_changed (SpellCheckPopover* self,
                                            SpellCheckPopoverSpellCheckLangRow* row,
                                            gboolean is_active)
{
	Block77Data* _data77_;
	gchar* lang = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar** _tmp8_;
	GHashTable* _tmp9_;
	g_return_if_fail (IS_SPELL_CHECK_POPOVER (self));
	g_return_if_fail (SPELL_CHECK_POPOVER_IS_SPELL_CHECK_LANG_ROW (row));
	_data77_ = g_slice_new0 (Block77Data);
	_data77_->_ref_count_ = 1;
	_data77_->self = spell_check_popover_ref (self);
	_tmp0_ = spell_check_popover_spell_check_lang_row_get_lang_code (row);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_strdup (_tmp1_);
	lang = _tmp2_;
	if (is_active) {
		GHashTable* _tmp3_;
		const gchar* _tmp4_;
		gchar* _tmp5_;
		_tmp3_ = self->priv->selected_rows;
		_tmp4_ = lang;
		_tmp5_ = g_strdup (_tmp4_);
		g_hash_table_add (_tmp3_, _tmp5_);
	} else {
		GHashTable* _tmp6_;
		const gchar* _tmp7_;
		_tmp6_ = self->priv->selected_rows;
		_tmp7_ = lang;
		g_hash_table_remove (_tmp6_, _tmp7_);
	}
	_tmp8_ = g_new0 (gchar*, 0 + 1);
	_data77_->active_langs = _tmp8_;
	_data77_->active_langs_length1 = 0;
	_data77_->_active_langs_size_ = _data77_->active_langs_length1;
	_tmp9_ = self->priv->selected_rows;
	_vala_g_hash_set_foreach (_tmp9_, ___lambda25__gfunc, _data77_);
	g_signal_emit (self, spell_check_popover_signals[SPELL_CHECK_POPOVER_SELECTION_CHANGED_SIGNAL], 0, _data77_->active_langs, (gint) _data77_->active_langs_length1);
	_g_free0 (lang);
	block77_data_unref (_data77_);
	_data77_ = NULL;
}

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

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

static gchar**
_vala_array_dup6 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

static void
spell_check_popover_on_row_visibility_changed (SpellCheckPopover* self,
                                               SpellCheckPopoverSpellCheckLangRow* row,
                                               gboolean is_visible)
{
	GtkListBox* _tmp0_;
	gchar** visible_langs = NULL;
	ApplicationConfiguration* _tmp1_;
	gint _tmp2_ = 0;
	gchar** _tmp3_;
	gint visible_langs_length1;
	gint _visible_langs_size_;
	gchar* lang = NULL;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	ApplicationConfiguration* _tmp20_;
	gchar** _tmp21_;
	gint _tmp21__length1;
	g_return_if_fail (IS_SPELL_CHECK_POPOVER (self));
	g_return_if_fail (SPELL_CHECK_POPOVER_IS_SPELL_CHECK_LANG_ROW (row));
	_tmp0_ = self->priv->langs_list;
	gtk_list_box_invalidate_filter (_tmp0_);
	_tmp1_ = self->priv->config;
	_tmp3_ = application_configuration_get_spell_check_visible_languages (_tmp1_, &_tmp2_);
	visible_langs = _tmp3_;
	visible_langs_length1 = _tmp2_;
	_visible_langs_size_ = visible_langs_length1;
	_tmp4_ = spell_check_popover_spell_check_lang_row_get_lang_code (row);
	_tmp5_ = _tmp4_;
	_tmp6_ = g_strdup (_tmp5_);
	lang = _tmp6_;
	if (is_visible) {
		const gchar* _tmp7_;
		gchar** _tmp8_;
		gint _tmp8__length1;
		_tmp7_ = lang;
		_tmp8_ = visible_langs;
		_tmp8__length1 = visible_langs_length1;
		if (!_vala_string_array_contains (_tmp8_, _tmp8__length1, _tmp7_)) {
			const gchar* _tmp9_;
			gchar* _tmp10_;
			_tmp9_ = lang;
			_tmp10_ = g_strdup (_tmp9_);
			_vala_array_add16 (&visible_langs, &visible_langs_length1, &_visible_langs_size_, _tmp10_);
		}
	} else {
		gchar** new_langs = NULL;
		gchar** _tmp11_;
		gint new_langs_length1;
		gint _new_langs_size_;
		gchar** _tmp12_;
		gint _tmp12__length1;
		gchar** _tmp18_;
		gint _tmp18__length1;
		gchar** _tmp19_;
		gint _tmp19__length1;
		_tmp11_ = g_new0 (gchar*, 0 + 1);
		new_langs = _tmp11_;
		new_langs_length1 = 0;
		_new_langs_size_ = new_langs_length1;
		_tmp12_ = visible_langs;
		_tmp12__length1 = visible_langs_length1;
		{
			gchar** lang_code_collection = NULL;
			gint lang_code_collection_length1 = 0;
			gint _lang_code_collection_size_ = 0;
			gint lang_code_it = 0;
			lang_code_collection = _tmp12_;
			lang_code_collection_length1 = _tmp12__length1;
			for (lang_code_it = 0; lang_code_it < lang_code_collection_length1; lang_code_it = lang_code_it + 1) {
				gchar* _tmp13_;
				gchar* lang_code = NULL;
				_tmp13_ = g_strdup (lang_code_collection[lang_code_it]);
				lang_code = _tmp13_;
				{
					const gchar* _tmp14_;
					const gchar* _tmp15_;
					_tmp14_ = lang;
					_tmp15_ = lang_code;
					if (g_strcmp0 (_tmp14_, _tmp15_) != 0) {
						const gchar* _tmp16_;
						gchar* _tmp17_;
						_tmp16_ = lang_code;
						_tmp17_ = g_strdup (_tmp16_);
						_vala_array_add17 (&new_langs, &new_langs_length1, &_new_langs_size_, _tmp17_);
					}
					_g_free0 (lang_code);
				}
			}
		}
		_tmp18_ = new_langs;
		_tmp18__length1 = new_langs_length1;
		_tmp19_ = (_tmp18_ != NULL) ? _vala_array_dup6 (_tmp18_, _tmp18__length1) : _tmp18_;
		_tmp19__length1 = _tmp18__length1;
		visible_langs = (_vala_array_free (visible_langs, visible_langs_length1, (GDestroyNotify) g_free), NULL);
		visible_langs = _tmp19_;
		visible_langs_length1 = _tmp19__length1;
		_visible_langs_size_ = visible_langs_length1;
		new_langs = (_vala_array_free (new_langs, new_langs_length1, (GDestroyNotify) g_free), NULL);
	}
	_tmp20_ = self->priv->config;
	_tmp21_ = visible_langs;
	_tmp21__length1 = visible_langs_length1;
	application_configuration_set_spell_check_visible_languages (_tmp20_, _tmp21_, (gint) _tmp21__length1);
	_g_free0 (lang);
	visible_langs = (_vala_array_free (visible_langs, visible_langs_length1, (GDestroyNotify) g_free), NULL);
}

static inline gpointer
spell_check_popover_spell_check_lang_row_get_instance_private (SpellCheckPopoverSpellCheckLangRow* self)
{
	return G_STRUCT_MEMBER_P (self, SpellCheckPopoverSpellCheckLangRow_private_offset);
}

static const gchar*
spell_check_popover_spell_check_lang_row_get_lang_code (SpellCheckPopoverSpellCheckLangRow* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (SPELL_CHECK_POPOVER_IS_SPELL_CHECK_LANG_ROW (self), NULL);
	_tmp0_ = self->priv->_lang_code;
	result = _tmp0_;
	return result;
}

static void
spell_check_popover_spell_check_lang_row_set_lang_code (SpellCheckPopoverSpellCheckLangRow* self,
                                                        const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (SPELL_CHECK_POPOVER_IS_SPELL_CHECK_LANG_ROW (self));
	old_value = spell_check_popover_spell_check_lang_row_get_lang_code (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_lang_code);
		self->priv->_lang_code = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, spell_check_popover_spell_check_lang_row_properties[SPELL_CHECK_POPOVER_SPELL_CHECK_LANG_ROW_LANG_CODE_PROPERTY]);
	}
}

static void
_spell_check_popover_spell_check_lang_row_on_visibility_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                                    gpointer self)
{
	spell_check_popover_spell_check_lang_row_on_visibility_clicked ((SpellCheckPopoverSpellCheckLangRow*) self);
}

static SpellCheckPopoverSpellCheckLangRow*
spell_check_popover_spell_check_lang_row_construct (GType object_type,
                                                    const gchar* lang_code,
                                                    gboolean is_active,
                                                    gboolean is_visible)
{
	SpellCheckPopoverSpellCheckLangRow * self = NULL;
	SpellCheckPopoverSpellCheckStatus _tmp0_ = 0;
	gboolean _tmp1_ = FALSE;
	GtkBox* box = NULL;
	GtkBox* _tmp2_;
	GtkBox* _tmp3_;
	GtkBox* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* label_text = NULL;
	const gchar* _tmp7_;
	gchar* _tmp8_;
	GtkLabel* label = NULL;
	const gchar* _tmp9_;
	GtkLabel* _tmp10_;
	GtkLabel* _tmp11_;
	const gchar* _tmp12_;
	GtkLabel* _tmp13_;
	GtkLabel* _tmp14_;
	GtkLabel* _tmp15_;
	const gchar* _tmp16_;
	GtkIconSize sz = 0;
	GtkImage* _tmp35_;
	GtkButton* _tmp36_;
	GtkButton* _tmp37_;
	GtkBox* _tmp38_;
	GtkImage* _tmp39_;
	GtkBox* _tmp40_;
	GtkButton* _tmp41_;
	GtkButton* _tmp42_;
	GtkButton* _tmp43_;
	GtkButton* _tmp44_;
	GtkBox* _tmp45_;
	g_return_val_if_fail (lang_code != NULL, NULL);
	self = (SpellCheckPopoverSpellCheckLangRow*) g_object_new (object_type, NULL);
	spell_check_popover_spell_check_lang_row_set_lang_code (self, lang_code);
	if (is_active) {
		_tmp0_ = SPELL_CHECK_POPOVER_SPELL_CHECK_STATUS_ACTIVE;
	} else {
		_tmp0_ = SPELL_CHECK_POPOVER_SPELL_CHECK_STATUS_INACTIVE;
	}
	self->priv->lang_active = _tmp0_;
	if (is_active) {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = is_visible;
	}
	self->priv->is_lang_visible = _tmp1_;
	_tmp2_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	g_object_ref_sink (_tmp2_);
	box = _tmp2_;
	_tmp3_ = box;
	g_object_set (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, gtk_widget_get_type (), GtkWidget), "margin", 6, NULL);
	_tmp4_ = box;
	gtk_widget_set_margin_start (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, gtk_widget_get_type (), GtkWidget), 12);
	_tmp5_ = util_i18n_language_name_from_locale (lang_code);
	_g_free0 (self->priv->lang_name);
	self->priv->lang_name = _tmp5_;
	_tmp6_ = util_i18n_country_name_from_locale (lang_code);
	_g_free0 (self->priv->country_name);
	self->priv->country_name = _tmp6_;
	_tmp7_ = self->priv->lang_name;
	_tmp8_ = g_strdup (_tmp7_);
	label_text = _tmp8_;
	_tmp9_ = label_text;
	_tmp10_ = (GtkLabel*) gtk_label_new (_tmp9_);
	g_object_ref_sink (_tmp10_);
	label = _tmp10_;
	_tmp11_ = label;
	_tmp12_ = label_text;
	gtk_widget_set_tooltip_text (G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, gtk_widget_get_type (), GtkWidget), _tmp12_);
	_tmp13_ = label;
	gtk_widget_set_halign (G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, gtk_widget_get_type (), GtkWidget), GTK_ALIGN_START);
	_tmp14_ = label;
	gtk_label_set_ellipsize (_tmp14_, PANGO_ELLIPSIZE_END);
	_tmp15_ = label;
	gtk_label_set_xalign (_tmp15_, (gfloat) 0);
	_tmp16_ = self->priv->country_name;
	if (_tmp16_ != NULL) {
		GtkBox* label_box = NULL;
		GtkBox* _tmp17_;
		GtkLabel* country_label = NULL;
		const gchar* _tmp18_;
		GtkLabel* _tmp19_;
		GtkLabel* _tmp20_;
		const gchar* _tmp21_;
		GtkLabel* _tmp22_;
		GtkLabel* _tmp23_;
		GtkLabel* _tmp24_;
		GtkLabel* _tmp25_;
		GtkStyleContext* _tmp26_;
		GtkBox* _tmp27_;
		GtkLabel* _tmp28_;
		GtkBox* _tmp29_;
		GtkLabel* _tmp30_;
		GtkBox* _tmp31_;
		GtkBox* _tmp32_;
		_tmp17_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
		g_object_ref_sink (_tmp17_);
		label_box = _tmp17_;
		_tmp18_ = self->priv->country_name;
		_tmp19_ = (GtkLabel*) gtk_label_new (_tmp18_);
		g_object_ref_sink (_tmp19_);
		country_label = _tmp19_;
		_tmp20_ = country_label;
		_tmp21_ = self->priv->country_name;
		gtk_widget_set_tooltip_text (G_TYPE_CHECK_INSTANCE_CAST (_tmp20_, gtk_widget_get_type (), GtkWidget), _tmp21_);
		_tmp22_ = country_label;
		gtk_widget_set_halign (G_TYPE_CHECK_INSTANCE_CAST (_tmp22_, gtk_widget_get_type (), GtkWidget), GTK_ALIGN_START);
		_tmp23_ = country_label;
		gtk_label_set_ellipsize (_tmp23_, PANGO_ELLIPSIZE_END);
		_tmp24_ = country_label;
		gtk_label_set_xalign (_tmp24_, (gfloat) 0);
		_tmp25_ = country_label;
		_tmp26_ = gtk_widget_get_style_context (G_TYPE_CHECK_INSTANCE_CAST (_tmp25_, gtk_widget_get_type (), GtkWidget));
		gtk_style_context_add_class (_tmp26_, "dim-label");
		_tmp27_ = label_box;
		_tmp28_ = label;
		gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp27_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp28_, gtk_widget_get_type (), GtkWidget));
		_tmp29_ = label_box;
		_tmp30_ = country_label;
		gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp29_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp30_, gtk_widget_get_type (), GtkWidget));
		_tmp31_ = box;
		_tmp32_ = label_box;
		gtk_box_pack_start (_tmp31_, G_TYPE_CHECK_INSTANCE_CAST (_tmp32_, gtk_widget_get_type (), GtkWidget), FALSE, FALSE, (guint) 0);
		_g_object_unref0 (country_label);
		_g_object_unref0 (label_box);
	} else {
		GtkBox* _tmp33_;
		GtkLabel* _tmp34_;
		_tmp33_ = box;
		_tmp34_ = label;
		gtk_box_pack_start (_tmp33_, G_TYPE_CHECK_INSTANCE_CAST (_tmp34_, gtk_widget_get_type (), GtkWidget), FALSE, FALSE, (guint) 0);
	}
	sz = GTK_ICON_SIZE_SMALL_TOOLBAR;
	_tmp35_ = (GtkImage*) gtk_image_new_from_icon_name ("object-select-symbolic", (GtkIconSize) sz);
	g_object_ref_sink (_tmp35_);
	_g_object_unref0 (self->priv->active_image);
	self->priv->active_image = _tmp35_;
	_tmp36_ = (GtkButton*) gtk_button_new ();
	g_object_ref_sink (_tmp36_);
	_g_object_unref0 (self->priv->visibility_button);
	self->priv->visibility_button = _tmp36_;
	_tmp37_ = self->priv->visibility_button;
	gtk_button_set_relief (_tmp37_, GTK_RELIEF_NONE);
	_tmp38_ = box;
	_tmp39_ = self->priv->active_image;
	gtk_box_pack_start (_tmp38_, G_TYPE_CHECK_INSTANCE_CAST (_tmp39_, gtk_widget_get_type (), GtkWidget), FALSE, FALSE, (guint) 6);
	_tmp40_ = box;
	_tmp41_ = self->priv->visibility_button;
	gtk_box_pack_start (_tmp40_, G_TYPE_CHECK_INSTANCE_CAST (_tmp41_, gtk_widget_get_type (), GtkWidget), TRUE, TRUE, (guint) 0);
	_tmp42_ = self->priv->visibility_button;
	gtk_widget_set_halign (G_TYPE_CHECK_INSTANCE_CAST (_tmp42_, gtk_widget_get_type (), GtkWidget), GTK_ALIGN_END);
	_tmp43_ = self->priv->visibility_button;
	gtk_widget_set_valign (G_TYPE_CHECK_INSTANCE_CAST (_tmp43_, gtk_widget_get_type (), GtkWidget), GTK_ALIGN_CENTER);
	_tmp44_ = self->priv->visibility_button;
	g_signal_connect_object (_tmp44_, "clicked", (GCallback) _spell_check_popover_spell_check_lang_row_on_visibility_clicked_gtk_button_clicked, self, 0);
	spell_check_popover_spell_check_lang_row_update_images (self);
	_tmp45_ = box;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp45_, gtk_widget_get_type (), GtkWidget));
	_g_object_unref0 (label);
	_g_free0 (label_text);
	_g_object_unref0 (box);
	return self;
}

static SpellCheckPopoverSpellCheckLangRow*
spell_check_popover_spell_check_lang_row_new (const gchar* lang_code,
                                              gboolean is_active,
                                              gboolean is_visible)
{
	return spell_check_popover_spell_check_lang_row_construct (SPELL_CHECK_POPOVER_TYPE_SPELL_CHECK_LANG_ROW, lang_code, is_active, is_visible);
}

static gboolean
spell_check_popover_spell_check_lang_row_is_lang_active (SpellCheckPopoverSpellCheckLangRow* self)
{
	gboolean result;
	g_return_val_if_fail (SPELL_CHECK_POPOVER_IS_SPELL_CHECK_LANG_ROW (self), FALSE);
	result = self->priv->lang_active == SPELL_CHECK_POPOVER_SPELL_CHECK_STATUS_ACTIVE;
	return result;
}

static void
spell_check_popover_spell_check_lang_row_update_images (SpellCheckPopoverSpellCheckLangRow* self)
{
	GtkIconSize sz = 0;
	g_return_if_fail (SPELL_CHECK_POPOVER_IS_SPELL_CHECK_LANG_ROW (self));
	sz = GTK_ICON_SIZE_SMALL_TOOLBAR;
	switch (self->priv->lang_active) {
		case SPELL_CHECK_POPOVER_SPELL_CHECK_STATUS_ACTIVE:
		{
			GtkImage* _tmp0_;
			_tmp0_ = self->priv->active_image;
			gtk_image_set_from_icon_name (_tmp0_, "object-select-symbolic", (GtkIconSize) sz);
			break;
		}
		case SPELL_CHECK_POPOVER_SPELL_CHECK_STATUS_INACTIVE:
		{
			GtkImage* _tmp1_;
			_tmp1_ = self->priv->active_image;
			gtk_image_clear (_tmp1_);
			break;
		}
		default:
		break;
	}
	if (self->priv->is_lang_visible) {
		GtkButton* _tmp2_;
		GtkImage* _tmp3_;
		GtkImage* _tmp4_;
		GtkButton* _tmp5_;
		_tmp2_ = self->priv->visibility_button;
		_tmp3_ = (GtkImage*) gtk_image_new_from_icon_name ("list-remove-symbolic", (GtkIconSize) sz);
		g_object_ref_sink (_tmp3_);
		_tmp4_ = _tmp3_;
		gtk_button_set_image (_tmp2_, G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, gtk_widget_get_type (), GtkWidget));
		_g_object_unref0 (_tmp4_);
		_tmp5_ = self->priv->visibility_button;
		gtk_widget_set_tooltip_text (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, gtk_widget_get_type (), GtkWidget), _ ("Remove this language from the preferred list"));
	} else {
		GtkButton* _tmp6_;
		GtkImage* _tmp7_;
		GtkImage* _tmp8_;
		GtkButton* _tmp9_;
		_tmp6_ = self->priv->visibility_button;
		_tmp7_ = (GtkImage*) gtk_image_new_from_icon_name ("list-add-symbolic", (GtkIconSize) sz);
		g_object_ref_sink (_tmp7_);
		_tmp8_ = _tmp7_;
		gtk_button_set_image (_tmp6_, G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, gtk_widget_get_type (), GtkWidget));
		_g_object_unref0 (_tmp8_);
		_tmp9_ = self->priv->visibility_button;
		gtk_widget_set_tooltip_text (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, gtk_widget_get_type (), GtkWidget), _ ("Add this language to the preferred list"));
	}
}

static gboolean
string_contains (const gchar* self,
                 const gchar* needle)
{
	gchar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (needle != NULL, FALSE);
	_tmp0_ = strstr ((gchar*) self, (gchar*) needle);
	result = _tmp0_ != NULL;
	return result;
}

static gboolean
spell_check_popover_spell_check_lang_row_match_filter (SpellCheckPopoverSpellCheckLangRow* self,
                                                       const gchar* filter)
{
	gchar* filter_down = NULL;
	gchar* _tmp0_;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	const gchar* _tmp3_;
	gboolean result;
	g_return_val_if_fail (SPELL_CHECK_POPOVER_IS_SPELL_CHECK_LANG_ROW (self), FALSE);
	g_return_val_if_fail (filter != NULL, FALSE);
	_tmp0_ = g_utf8_strdown (filter, (gssize) -1);
	filter_down = _tmp0_;
	_tmp3_ = self->priv->lang_name;
	if (_tmp3_ != NULL) {
		const gchar* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp6_;
		const gchar* _tmp7_;
		_tmp4_ = self->priv->lang_name;
		_tmp5_ = g_utf8_strdown (_tmp4_, (gssize) -1);
		_tmp6_ = _tmp5_;
		_tmp7_ = filter_down;
		_tmp2_ = string_contains (_tmp6_, _tmp7_);
		_g_free0 (_tmp6_);
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		_tmp1_ = TRUE;
	} else {
		gboolean _tmp8_ = FALSE;
		const gchar* _tmp9_;
		_tmp9_ = self->priv->country_name;
		if (_tmp9_ != NULL) {
			const gchar* _tmp10_;
			gchar* _tmp11_;
			gchar* _tmp12_;
			const gchar* _tmp13_;
			_tmp10_ = self->priv->country_name;
			_tmp11_ = g_utf8_strdown (_tmp10_, (gssize) -1);
			_tmp12_ = _tmp11_;
			_tmp13_ = filter_down;
			_tmp8_ = string_contains (_tmp12_, _tmp13_);
			_g_free0 (_tmp12_);
		} else {
			_tmp8_ = FALSE;
		}
		_tmp1_ = _tmp8_;
	}
	result = _tmp1_;
	_g_free0 (filter_down);
	return result;
}

static void
spell_check_popover_spell_check_lang_row_set_lang_active (SpellCheckPopoverSpellCheckLangRow* self,
                                                          SpellCheckPopoverSpellCheckStatus active)
{
	g_return_if_fail (SPELL_CHECK_POPOVER_IS_SPELL_CHECK_LANG_ROW (self));
	self->priv->lang_active = active;
	switch (active) {
		case SPELL_CHECK_POPOVER_SPELL_CHECK_STATUS_ACTIVE:
		{
			if (!self->priv->is_lang_visible) {
				spell_check_popover_spell_check_lang_row_set_lang_visible (self, TRUE);
			}
			break;
		}
		case SPELL_CHECK_POPOVER_SPELL_CHECK_STATUS_INACTIVE:
		{
			break;
		}
		default:
		break;
	}
	spell_check_popover_spell_check_lang_row_update_images (self);
	g_signal_emit (self, spell_check_popover_spell_check_lang_row_signals[SPELL_CHECK_POPOVER_SPELL_CHECK_LANG_ROW_ENABLED_CHANGED_SIGNAL], 0, active == SPELL_CHECK_POPOVER_SPELL_CHECK_STATUS_ACTIVE);
}

static void
spell_check_popover_spell_check_lang_row_set_lang_visible (SpellCheckPopoverSpellCheckLangRow* self,
                                                           gboolean is_visible)
{
	gboolean _tmp0_ = FALSE;
	g_return_if_fail (SPELL_CHECK_POPOVER_IS_SPELL_CHECK_LANG_ROW (self));
	self->priv->is_lang_visible = is_visible;
	spell_check_popover_spell_check_lang_row_update_images (self);
	if (!self->priv->is_lang_visible) {
		_tmp0_ = self->priv->lang_active == SPELL_CHECK_POPOVER_SPELL_CHECK_STATUS_ACTIVE;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		spell_check_popover_spell_check_lang_row_set_lang_active (self, SPELL_CHECK_POPOVER_SPELL_CHECK_STATUS_INACTIVE);
	}
	g_signal_emit (self, spell_check_popover_spell_check_lang_row_signals[SPELL_CHECK_POPOVER_SPELL_CHECK_LANG_ROW_VISIBILITY_CHANGED_SIGNAL], 0, is_visible);
}

static void
spell_check_popover_spell_check_lang_row_handle_activation (SpellCheckPopoverSpellCheckLangRow* self,
                                                            SpellCheckPopover* spell_check_popover)
{
	gboolean _tmp0_;
	gboolean _tmp1_;
	g_return_if_fail (SPELL_CHECK_POPOVER_IS_SPELL_CHECK_LANG_ROW (self));
	g_return_if_fail (IS_SPELL_CHECK_POPOVER (spell_check_popover));
	_tmp0_ = gtk_widget_get_visible (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
	_tmp1_ = _tmp0_;
	if (!_tmp1_) {
		return;
	}
	switch (self->priv->lang_active) {
		case SPELL_CHECK_POPOVER_SPELL_CHECK_STATUS_ACTIVE:
		{
			spell_check_popover_spell_check_lang_row_set_lang_active (self, SPELL_CHECK_POPOVER_SPELL_CHECK_STATUS_INACTIVE);
			break;
		}
		case SPELL_CHECK_POPOVER_SPELL_CHECK_STATUS_INACTIVE:
		{
			spell_check_popover_spell_check_lang_row_set_lang_active (self, SPELL_CHECK_POPOVER_SPELL_CHECK_STATUS_ACTIVE);
			break;
		}
		default:
		break;
	}
}

static gboolean
spell_check_popover_spell_check_lang_row_is_row_visible (SpellCheckPopoverSpellCheckLangRow* self,
                                                         gboolean is_expanded)
{
	gboolean _tmp0_ = FALSE;
	gboolean result;
	g_return_val_if_fail (SPELL_CHECK_POPOVER_IS_SPELL_CHECK_LANG_ROW (self), FALSE);
	if (self->priv->is_lang_visible) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = is_expanded;
	}
	result = _tmp0_;
	return result;
}

static void
spell_check_popover_spell_check_lang_row_on_visibility_clicked (SpellCheckPopoverSpellCheckLangRow* self)
{
	g_return_if_fail (SPELL_CHECK_POPOVER_IS_SPELL_CHECK_LANG_ROW (self));
	spell_check_popover_spell_check_lang_row_set_lang_visible (self, !self->priv->is_lang_visible);
}

static void
spell_check_popover_spell_check_lang_row_class_init (SpellCheckPopoverSpellCheckLangRowClass * klass,
                                                     gpointer klass_data)
{
	spell_check_popover_spell_check_lang_row_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &SpellCheckPopoverSpellCheckLangRow_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_spell_check_popover_spell_check_lang_row_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_spell_check_popover_spell_check_lang_row_set_property;
	G_OBJECT_CLASS (klass)->finalize = spell_check_popover_spell_check_lang_row_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), SPELL_CHECK_POPOVER_SPELL_CHECK_LANG_ROW_LANG_CODE_PROPERTY, spell_check_popover_spell_check_lang_row_properties[SPELL_CHECK_POPOVER_SPELL_CHECK_LANG_ROW_LANG_CODE_PROPERTY] = g_param_spec_string ("lang-code", "lang-code", "lang-code", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/**
	         * Emitted when the language has been enabled or disabled.
	         */
	spell_check_popover_spell_check_lang_row_signals[SPELL_CHECK_POPOVER_SPELL_CHECK_LANG_ROW_ENABLED_CHANGED_SIGNAL] = g_signal_new ("enabled-changed", SPELL_CHECK_POPOVER_TYPE_SPELL_CHECK_LANG_ROW, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
	/**
	         * @brief Signal when the visibility has changed.
	         */
	spell_check_popover_spell_check_lang_row_signals[SPELL_CHECK_POPOVER_SPELL_CHECK_LANG_ROW_VISIBILITY_CHANGED_SIGNAL] = g_signal_new ("visibility-changed", SPELL_CHECK_POPOVER_TYPE_SPELL_CHECK_LANG_ROW, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
}

static void
spell_check_popover_spell_check_lang_row_instance_init (SpellCheckPopoverSpellCheckLangRow * self,
                                                        gpointer klass)
{
	self->priv = spell_check_popover_spell_check_lang_row_get_instance_private (self);
	self->priv->lang_active = SPELL_CHECK_POPOVER_SPELL_CHECK_STATUS_INACTIVE;
}

static void
spell_check_popover_spell_check_lang_row_finalize (GObject * obj)
{
	SpellCheckPopoverSpellCheckLangRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SPELL_CHECK_POPOVER_TYPE_SPELL_CHECK_LANG_ROW, SpellCheckPopoverSpellCheckLangRow);
	_g_free0 (self->priv->_lang_code);
	_g_free0 (self->priv->lang_name);
	_g_free0 (self->priv->country_name);
	_g_object_unref0 (self->priv->active_image);
	_g_object_unref0 (self->priv->visibility_button);
	G_OBJECT_CLASS (spell_check_popover_spell_check_lang_row_parent_class)->finalize (obj);
}

static GType
spell_check_popover_spell_check_lang_row_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SpellCheckPopoverSpellCheckLangRowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) spell_check_popover_spell_check_lang_row_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SpellCheckPopoverSpellCheckLangRow), 0, (GInstanceInitFunc) spell_check_popover_spell_check_lang_row_instance_init, NULL };
	GType spell_check_popover_spell_check_lang_row_type_id;
	spell_check_popover_spell_check_lang_row_type_id = g_type_register_static (gtk_list_box_row_get_type (), "SpellCheckPopoverSpellCheckLangRow", &g_define_type_info, 0);
	SpellCheckPopoverSpellCheckLangRow_private_offset = g_type_add_instance_private (spell_check_popover_spell_check_lang_row_type_id, sizeof (SpellCheckPopoverSpellCheckLangRowPrivate));
	return spell_check_popover_spell_check_lang_row_type_id;
}

static GType
spell_check_popover_spell_check_lang_row_get_type (void)
{
	static volatile gsize spell_check_popover_spell_check_lang_row_type_id__once = 0;
	if (g_once_init_enter (&spell_check_popover_spell_check_lang_row_type_id__once)) {
		GType spell_check_popover_spell_check_lang_row_type_id;
		spell_check_popover_spell_check_lang_row_type_id = spell_check_popover_spell_check_lang_row_get_type_once ();
		g_once_init_leave (&spell_check_popover_spell_check_lang_row_type_id__once, spell_check_popover_spell_check_lang_row_type_id);
	}
	return spell_check_popover_spell_check_lang_row_type_id__once;
}

static void
_vala_spell_check_popover_spell_check_lang_row_get_property (GObject * object,
                                                             guint property_id,
                                                             GValue * value,
                                                             GParamSpec * pspec)
{
	SpellCheckPopoverSpellCheckLangRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SPELL_CHECK_POPOVER_TYPE_SPELL_CHECK_LANG_ROW, SpellCheckPopoverSpellCheckLangRow);
	switch (property_id) {
		case SPELL_CHECK_POPOVER_SPELL_CHECK_LANG_ROW_LANG_CODE_PROPERTY:
		g_value_set_string (value, spell_check_popover_spell_check_lang_row_get_lang_code (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_spell_check_popover_spell_check_lang_row_set_property (GObject * object,
                                                             guint property_id,
                                                             const GValue * value,
                                                             GParamSpec * pspec)
{
	SpellCheckPopoverSpellCheckLangRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SPELL_CHECK_POPOVER_TYPE_SPELL_CHECK_LANG_ROW, SpellCheckPopoverSpellCheckLangRow);
	switch (property_id) {
		case SPELL_CHECK_POPOVER_SPELL_CHECK_LANG_ROW_LANG_CODE_PROPERTY:
		spell_check_popover_spell_check_lang_row_set_lang_code (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

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

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

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

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

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

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

void
value_set_spell_check_popover (GValue* value,
                               gpointer v_object)
{
	SpellCheckPopover * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_SPELL_CHECK_POPOVER));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_SPELL_CHECK_POPOVER));
		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;
		spell_check_popover_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		spell_check_popover_unref (old);
	}
}

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

static void
spell_check_popover_class_init (SpellCheckPopoverClass * klass,
                                gpointer klass_data)
{
	spell_check_popover_parent_class = g_type_class_peek_parent (klass);
	((SpellCheckPopoverClass *) klass)->finalize = spell_check_popover_finalize;
	g_type_class_adjust_private_offset (klass, &SpellCheckPopover_private_offset);
	/**
	     * This signal is emitted then the selection of rows changes.
	     *
	     * @param active_langs The new set of active dictionaries after the
	     *                     selection has changed.
	     */
	spell_check_popover_signals[SPELL_CHECK_POPOVER_SELECTION_CHANGED_SIGNAL] = g_signal_new ("selection-changed", TYPE_SPELL_CHECK_POPOVER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__BOXED_INT, G_TYPE_NONE, 2, G_TYPE_STRV, G_TYPE_INT);
}

static void
spell_check_popover_instance_init (SpellCheckPopover * self,
                                   gpointer klass)
{
	self->priv = spell_check_popover_get_instance_private (self);
	self->priv->popover = NULL;
	self->priv->is_expanded = FALSE;
	self->ref_count = 1;
}

static void
spell_check_popover_finalize (SpellCheckPopover * obj)
{
	SpellCheckPopover * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_SPELL_CHECK_POPOVER, SpellCheckPopover);
	g_signal_handlers_destroy (self);
	_g_object_unref0 (self->priv->popover);
	_g_hash_table_unref0 (self->priv->selected_rows);
	_g_object_unref0 (self->priv->langs_list);
	_g_object_unref0 (self->priv->search_box);
	_g_object_unref0 (self->priv->view);
	_g_object_unref0 (self->priv->content);
	_g_object_unref0 (self->priv->config);
}

static GType
spell_check_popover_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { value_spell_check_popover_init, value_spell_check_popover_free_value, value_spell_check_popover_copy_value, value_spell_check_popover_peek_pointer, "p", value_spell_check_popover_collect_value, "p", value_spell_check_popover_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (SpellCheckPopoverClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) spell_check_popover_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SpellCheckPopover), 0, (GInstanceInitFunc) spell_check_popover_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 spell_check_popover_type_id;
	spell_check_popover_type_id = g_type_register_fundamental (g_type_fundamental_next (), "SpellCheckPopover", &g_define_type_info, &g_define_type_fundamental_info, 0);
	SpellCheckPopover_private_offset = g_type_add_instance_private (spell_check_popover_type_id, sizeof (SpellCheckPopoverPrivate));
	return spell_check_popover_type_id;
}

GType
spell_check_popover_get_type (void)
{
	static volatile gsize spell_check_popover_type_id__once = 0;
	if (g_once_init_enter (&spell_check_popover_type_id__once)) {
		GType spell_check_popover_type_id;
		spell_check_popover_type_id = spell_check_popover_get_type_once ();
		g_once_init_leave (&spell_check_popover_type_id__once, spell_check_popover_type_id);
	}
	return spell_check_popover_type_id__once;
}

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

void
spell_check_popover_unref (gpointer instance)
{
	SpellCheckPopover * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		SPELL_CHECK_POPOVER_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize 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,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

