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

/*
* Copyright 2019-2020 elementary, Inc. (https://elementary.io)
*
* This program 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.
*
* This program 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 this program.  If not, see <https://www.gnu.org/licenses/>.
*/

#include "keyboard.h"
#include <gtk/gtk.h>
#include <glib.h>
#include <glib-object.h>
#include <glib/gi18n-lib.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <adwaita.h>
#include <granite-7.h>
#include <float.h>
#include <math.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	KEYBOARD_INPUT_METHOD_PAGE_INSTALL_ENGINE_DIALOG_0_PROPERTY,
	KEYBOARD_INPUT_METHOD_PAGE_INSTALL_ENGINE_DIALOG_NUM_PROPERTIES
};
static GParamSpec* keyboard_input_method_page_install_engine_dialog_properties[KEYBOARD_INPUT_METHOD_PAGE_INSTALL_ENGINE_DIALOG_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) ((var == NULL) ? NULL : (var = (g_free (var), NULL)))
typedef struct _Block7Data Block7Data;

struct _KeyboardInputMethodPageInstallEngineDialogPrivate {
	GtkListBox* listbox;
	KeyboardInputMethodPageInstallList* engines_filter;
};

struct _Block7Data {
	int _ref_count_;
	KeyboardInputMethodPageInstallEngineDialog* self;
	GtkLabel* language_title;
	GtkScrolledWindow* scrolled;
	GtkBox* engine_list_box;
	AdwLeaflet* leaflet;
	GtkWidget* install_button;
};

static gint KeyboardInputMethodPageInstallEngineDialog_private_offset;
static gpointer keyboard_input_method_page_install_engine_dialog_parent_class = NULL;

static gboolean keyboard_input_method_page_install_engine_dialog_filter_function (GtkListBoxRow* row,
                                                                           KeyboardInputMethodPageInstallEngineDialog* self);
static gboolean _keyboard_input_method_page_install_list_equal (const KeyboardInputMethodPageInstallList * s1,
                                                         const KeyboardInputMethodPageInstallList * s2);
static gint keyboard_input_method_page_install_engine_dialog_sort_function (GtkListBoxRow* row1,
                                                                     GtkListBoxRow* row2,
                                                                     KeyboardInputMethodPageInstallEngineDialog* self);
static GObject * keyboard_input_method_page_install_engine_dialog_constructor (GType type,
                                                                        guint n_construct_properties,
                                                                        GObjectConstructParam * construct_properties);
static Block7Data* block7_data_ref (Block7Data* _data7_);
static void block7_data_unref (void * _userdata_);
static gboolean _keyboard_input_method_page_install_engine_dialog_filter_function_gtk_list_box_filter_func (GtkListBoxRow* row,
                                                                                                     gpointer self);
static gint _keyboard_input_method_page_install_engine_dialog_sort_function_gtk_list_box_sort_func (GtkListBoxRow* row1,
                                                                                             GtkListBoxRow* row2,
                                                                                             gpointer self);
static void _keyboard_input_method_page_install_engine_dialog___lambda16_ (Block7Data* _data7_,
                                                                    GtkListBoxRow* row);
static KeyboardInputMethodPageInstallList* _keyboard_input_method_page_install_list_dup (KeyboardInputMethodPageInstallList* self);
static void __keyboard_input_method_page_install_engine_dialog___lambda16__gtk_list_box_row_activated (GtkListBox* _sender,
                                                                                                GtkListBoxRow* row,
                                                                                                gpointer self);
static void _keyboard_input_method_page_install_engine_dialog___lambda17_ (Block7Data* _data7_);
static void __keyboard_input_method_page_install_engine_dialog___lambda17__gtk_button_clicked (GtkButton* _sender,
                                                                                        gpointer self);
static void _keyboard_input_method_page_install_engine_dialog___lambda18_ (Block7Data* _data7_);
static void __keyboard_input_method_page_install_engine_dialog___lambda18__gtk_list_box_selected_rows_changed (GtkListBox* _sender,
                                                                                                        gpointer self);
static void keyboard_input_method_page_install_engine_dialog_finalize (GObject * obj);
static GType keyboard_input_method_page_install_engine_dialog_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
keyboard_input_method_page_install_engine_dialog_get_instance_private (KeyboardInputMethodPageInstallEngineDialog* self)
{
	return G_STRUCT_MEMBER_P (self, KeyboardInputMethodPageInstallEngineDialog_private_offset);
}

KeyboardInputMethodPageInstallEngineDialog*
keyboard_input_method_page_install_engine_dialog_construct (GType object_type,
                                                            GtkWindow* parent)
{
	KeyboardInputMethodPageInstallEngineDialog * self = NULL;
	GThemedIcon* _tmp0_;
	GThemedIcon* _tmp1_;
	g_return_val_if_fail (parent != NULL, NULL);
	_tmp0_ = (GThemedIcon*) g_themed_icon_new ("extension");
	_tmp1_ = _tmp0_;
	self = (KeyboardInputMethodPageInstallEngineDialog*) g_object_new (object_type, "primary-text", _ ("Choose an engine to install"), "secondary-text", _ ("Select an engine from the list to install and use."), "image-icon", _tmp1_, "transient-for", parent, "buttons", GTK_BUTTONS_CANCEL, NULL);
	_g_object_unref0 (_tmp1_);
	return self;
}

KeyboardInputMethodPageInstallEngineDialog*
keyboard_input_method_page_install_engine_dialog_new (GtkWindow* parent)
{
	return keyboard_input_method_page_install_engine_dialog_construct (KEYBOARD_INPUT_METHOD_PAGE_TYPE_INSTALL_ENGINE_DIALOG, parent);
}

gchar*
keyboard_input_method_page_install_engine_dialog_get_selected_engine_name (KeyboardInputMethodPageInstallEngineDialog* self)
{
	GtkListBox* _tmp0_;
	GtkListBoxRow* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->listbox;
	_tmp1_ = gtk_list_box_get_selected_row (_tmp0_);
	_tmp2_ = keyboard_input_method_page_engines_row_get_engine_name (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, KEYBOARD_INPUT_METHOD_PAGE_TYPE_ENGINES_ROW, KeyboardInputMethodPageEnginesRow));
	_tmp3_ = _tmp2_;
	_tmp4_ = g_strdup (_tmp3_);
	result = _tmp4_;
	return result;
}

static gboolean
_keyboard_input_method_page_install_list_equal (const KeyboardInputMethodPageInstallList * s1,
                                                const KeyboardInputMethodPageInstallList * s2)
{
	if (s1 == s2) {
		return TRUE;
	}
	if (s1 == NULL) {
		return FALSE;
	}
	if (s2 == NULL) {
		return FALSE;
	}
	return (*s1) == (*s2);
}

static gboolean
keyboard_input_method_page_install_engine_dialog_filter_function (GtkListBoxRow* row,
                                                                  KeyboardInputMethodPageInstallEngineDialog* self)
{
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	KeyboardInputMethodPageInstallList _tmp2_;
	KeyboardInputMethodPageInstallList* _tmp3_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (row != NULL, FALSE);
	_tmp0_ = keyboard_input_method_page_engines_row_get_engine_name (G_TYPE_CHECK_INSTANCE_CAST (row, KEYBOARD_INPUT_METHOD_PAGE_TYPE_ENGINES_ROW, KeyboardInputMethodPageEnginesRow));
	_tmp1_ = _tmp0_;
	_tmp2_ = keyboard_input_method_page_install_list_get_language_from_engine_name (_tmp1_);
	_tmp3_ = self->priv->engines_filter;
	if (_keyboard_input_method_page_install_list_equal (&_tmp2_, _tmp3_) == TRUE) {
		result = TRUE;
		return result;
	}
	result = FALSE;
	return result;
}

static gint
keyboard_input_method_page_install_engine_dialog_sort_function (GtkListBoxRow* row1,
                                                                GtkListBoxRow* row2,
                                                                KeyboardInputMethodPageInstallEngineDialog* self)
{
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (row1 != NULL, -1);
	g_return_val_if_fail (row2 != NULL, -1);
	_tmp0_ = keyboard_input_method_page_engines_row_get_engine_name (G_TYPE_CHECK_INSTANCE_CAST (row1, KEYBOARD_INPUT_METHOD_PAGE_TYPE_ENGINES_ROW, KeyboardInputMethodPageEnginesRow));
	_tmp1_ = _tmp0_;
	_tmp2_ = keyboard_input_method_page_engines_row_get_engine_name (G_TYPE_CHECK_INSTANCE_CAST (row1, KEYBOARD_INPUT_METHOD_PAGE_TYPE_ENGINES_ROW, KeyboardInputMethodPageEnginesRow));
	_tmp3_ = _tmp2_;
	result = g_utf8_collate (_tmp1_, _tmp3_);
	return result;
}

static Block7Data*
block7_data_ref (Block7Data* _data7_)
{
	g_atomic_int_inc (&_data7_->_ref_count_);
	return _data7_;
}

static void
block7_data_unref (void * _userdata_)
{
	Block7Data* _data7_;
	_data7_ = (Block7Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data7_->_ref_count_)) {
		KeyboardInputMethodPageInstallEngineDialog* self;
		self = _data7_->self;
		_g_object_unref0 (_data7_->install_button);
		_g_object_unref0 (_data7_->leaflet);
		_g_object_unref0 (_data7_->engine_list_box);
		_g_object_unref0 (_data7_->scrolled);
		_g_object_unref0 (_data7_->language_title);
		_g_object_unref0 (self);
		g_slice_free (Block7Data, _data7_);
	}
}

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

static gboolean
_keyboard_input_method_page_install_engine_dialog_filter_function_gtk_list_box_filter_func (GtkListBoxRow* row,
                                                                                            gpointer self)
{
	gboolean result;
	result = keyboard_input_method_page_install_engine_dialog_filter_function (row, (KeyboardInputMethodPageInstallEngineDialog*) self);
	return result;
}

static gint
_keyboard_input_method_page_install_engine_dialog_sort_function_gtk_list_box_sort_func (GtkListBoxRow* row1,
                                                                                        GtkListBoxRow* row2,
                                                                                        gpointer self)
{
	gint result;
	result = keyboard_input_method_page_install_engine_dialog_sort_function (row1, row2, (KeyboardInputMethodPageInstallEngineDialog*) self);
	return result;
}

static KeyboardInputMethodPageInstallList*
_keyboard_input_method_page_install_list_dup (KeyboardInputMethodPageInstallList* self)
{
	KeyboardInputMethodPageInstallList* dup;
	dup = g_new0 (KeyboardInputMethodPageInstallList, 1);
	memcpy (dup, self, sizeof (KeyboardInputMethodPageInstallList));
	return dup;
}

static gpointer
__keyboard_input_method_page_install_list_dup0 (gpointer self)
{
	return self ? _keyboard_input_method_page_install_list_dup (self) : NULL;
}

static void
_keyboard_input_method_page_install_engine_dialog___lambda16_ (Block7Data* _data7_,
                                                               GtkListBoxRow* row)
{
	KeyboardInputMethodPageInstallEngineDialog* self;
	AdwLeaflet* _tmp0_;
	GtkBox* _tmp1_;
	GtkLabel* _tmp2_;
	KeyboardInputMethodPageInstallList _tmp3_;
	KeyboardInputMethodPageInstallList _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	KeyboardInputMethodPageInstallList _tmp7_;
	KeyboardInputMethodPageInstallList _tmp8_;
	KeyboardInputMethodPageInstallList* _tmp9_;
	GtkListBox* _tmp10_;
	GtkAdjustment* adjustment = NULL;
	GtkScrolledWindow* _tmp11_;
	GtkAdjustment* _tmp12_;
	GtkAdjustment* _tmp13_;
	GtkAdjustment* _tmp14_;
	GtkAdjustment* _tmp15_;
	gdouble _tmp16_;
	gdouble _tmp17_;
	self = _data7_->self;
	g_return_if_fail (row != NULL);
	_tmp0_ = _data7_->leaflet;
	_tmp1_ = _data7_->engine_list_box;
	adw_leaflet_set_visible_child (_tmp0_, (GtkWidget*) _tmp1_);
	_tmp2_ = _data7_->language_title;
	_tmp3_ = keyboard_input_method_page_languages_row_get_language (G_TYPE_CHECK_INSTANCE_CAST (row, KEYBOARD_INPUT_METHOD_PAGE_TYPE_LANGUAGES_ROW, KeyboardInputMethodPageLanguagesRow));
	_tmp4_ = _tmp3_;
	_tmp5_ = keyboard_input_method_page_install_list_get_name (_tmp4_);
	_tmp6_ = _tmp5_;
	gtk_label_set_label (_tmp2_, _tmp6_);
	_g_free0 (_tmp6_);
	_tmp7_ = keyboard_input_method_page_languages_row_get_language (G_TYPE_CHECK_INSTANCE_CAST (row, KEYBOARD_INPUT_METHOD_PAGE_TYPE_LANGUAGES_ROW, KeyboardInputMethodPageLanguagesRow));
	_tmp8_ = _tmp7_;
	_tmp9_ = __keyboard_input_method_page_install_list_dup0 (&_tmp8_);
	_g_free0 (self->priv->engines_filter);
	self->priv->engines_filter = _tmp9_;
	_tmp10_ = self->priv->listbox;
	gtk_list_box_invalidate_filter (_tmp10_);
	_tmp11_ = _data7_->scrolled;
	_tmp12_ = gtk_scrolled_window_get_vadjustment (_tmp11_);
	_tmp13_ = _g_object_ref0 (_tmp12_);
	adjustment = _tmp13_;
	_tmp14_ = adjustment;
	_tmp15_ = adjustment;
	_tmp16_ = gtk_adjustment_get_lower (_tmp15_);
	_tmp17_ = _tmp16_;
	gtk_adjustment_set_value (_tmp14_, _tmp17_);
	_g_object_unref0 (adjustment);
}

static void
__keyboard_input_method_page_install_engine_dialog___lambda16__gtk_list_box_row_activated (GtkListBox* _sender,
                                                                                           GtkListBoxRow* row,
                                                                                           gpointer self)
{
	_keyboard_input_method_page_install_engine_dialog___lambda16_ (self, row);
}

static void
_keyboard_input_method_page_install_engine_dialog___lambda17_ (Block7Data* _data7_)
{
	KeyboardInputMethodPageInstallEngineDialog* self;
	AdwLeaflet* _tmp0_;
	GtkWidget* _tmp1_;
	self = _data7_->self;
	_tmp0_ = _data7_->leaflet;
	adw_leaflet_navigate (_tmp0_, ADW_NAVIGATION_DIRECTION_BACK);
	_tmp1_ = _data7_->install_button;
	gtk_widget_set_sensitive (_tmp1_, FALSE);
}

static void
__keyboard_input_method_page_install_engine_dialog___lambda17__gtk_button_clicked (GtkButton* _sender,
                                                                                   gpointer self)
{
	_keyboard_input_method_page_install_engine_dialog___lambda17_ (self);
}

static void
_keyboard_input_method_page_install_engine_dialog___lambda18_ (Block7Data* _data7_)
{
	KeyboardInputMethodPageInstallEngineDialog* self;
	GtkWidget* child = NULL;
	GtkListBox* _tmp0_;
	GtkWidget* _tmp1_;
	GtkListBox* _tmp7_;
	GtkListBoxRow* _tmp8_;
	GtkWidget* _tmp9_;
	self = _data7_->self;
	_tmp0_ = self->priv->listbox;
	_tmp1_ = gtk_widget_get_first_child ((GtkWidget*) _tmp0_);
	child = _tmp1_;
	while (TRUE) {
		GtkWidget* _tmp2_;
		GtkWidget* _tmp3_;
		GtkWidget* _tmp5_;
		GtkWidget* _tmp6_;
		_tmp2_ = child;
		if (!(_tmp2_ != NULL)) {
			break;
		}
		_tmp3_ = child;
		if (KEYBOARD_INPUT_METHOD_PAGE_IS_ENGINES_ROW (_tmp3_)) {
			GtkWidget* _tmp4_;
			_tmp4_ = child;
			keyboard_input_method_page_engines_row_set_selected (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, KEYBOARD_INPUT_METHOD_PAGE_TYPE_ENGINES_ROW, KeyboardInputMethodPageEnginesRow), FALSE);
		}
		_tmp5_ = child;
		_tmp6_ = gtk_widget_get_next_sibling (_tmp5_);
		child = _tmp6_;
	}
	_tmp7_ = self->priv->listbox;
	_tmp8_ = gtk_list_box_get_selected_row (_tmp7_);
	keyboard_input_method_page_engines_row_set_selected (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, KEYBOARD_INPUT_METHOD_PAGE_TYPE_ENGINES_ROW, KeyboardInputMethodPageEnginesRow), TRUE);
	_tmp9_ = _data7_->install_button;
	gtk_widget_set_sensitive (_tmp9_, TRUE);
}

static void
__keyboard_input_method_page_install_engine_dialog___lambda18__gtk_list_box_selected_rows_changed (GtkListBox* _sender,
                                                                                                   gpointer self)
{
	_keyboard_input_method_page_install_engine_dialog___lambda18_ (self);
}

static GObject *
keyboard_input_method_page_install_engine_dialog_constructor (GType type,
                                                              guint n_construct_properties,
                                                              GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	KeyboardInputMethodPageInstallEngineDialog * self;
	Block7Data* _data7_;
	GtkListBox* languages_list = NULL;
	GtkListBox* _tmp0_ = NULL;
	gint _tmp1_ = 0;
	KeyboardInputMethodPageInstallList* _tmp2_;
	GtkButton* back_button = NULL;
	GtkButton* _tmp6_ = NULL;
	GtkButton* _tmp7_;
	GtkLabel* _tmp8_;
	GtkCenterBox* language_header = NULL;
	GtkButton* _tmp9_;
	GtkWidget* _tmp10_;
	GtkLabel* _tmp11_;
	GtkWidget* _tmp12_;
	GtkCenterBox* _tmp13_ = NULL;
	GtkListBox* _tmp14_ = NULL;
	GtkListBox* _tmp15_;
	GtkListBox* _tmp16_;
	gint _tmp17_ = 0;
	KeyboardInputMethodPageInstallList* _tmp18_;
	GtkListBox* _tmp26_;
	GtkWidget* _tmp27_;
	GtkScrolledWindow* _tmp28_ = NULL;
	GtkBox* _tmp29_;
	GtkBox* _tmp30_;
	GtkBox* _tmp31_;
	GtkCenterBox* _tmp32_;
	GtkBox* _tmp33_;
	GtkSeparator* _tmp34_;
	GtkSeparator* _tmp35_;
	GtkBox* _tmp36_;
	GtkScrolledWindow* _tmp37_;
	AdwLeaflet* _tmp38_ = NULL;
	AdwLeaflet* _tmp39_;
	GtkListBox* _tmp40_;
	AdwLeaflet* _tmp41_;
	GtkBox* _tmp42_;
	GtkFrame* frame = NULL;
	AdwLeaflet* _tmp43_;
	GtkWidget* _tmp44_;
	GtkFrame* _tmp45_ = NULL;
	GtkBox* _tmp46_;
	GtkBox* _tmp47_;
	GtkFrame* _tmp48_;
	GtkWidget* _tmp49_;
	GtkWidget* _tmp50_;
	GtkWidget* _tmp51_;
	GtkWidget* _tmp52_;
	GtkListBox* _tmp53_;
	GtkButton* _tmp54_;
	GtkListBox* _tmp55_;
	parent_class = G_OBJECT_CLASS (keyboard_input_method_page_install_engine_dialog_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, KEYBOARD_INPUT_METHOD_PAGE_TYPE_INSTALL_ENGINE_DIALOG, KeyboardInputMethodPageInstallEngineDialog);
	_data7_ = g_slice_new0 (Block7Data);
	_data7_->_ref_count_ = 1;
	_data7_->self = g_object_ref (self);
	_tmp0_ = (GtkListBox*) gtk_list_box_new ();
	gtk_list_box_set_activate_on_single_click (_tmp0_, TRUE);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp0_, TRUE);
	gtk_widget_set_vexpand ((GtkWidget*) _tmp0_, TRUE);
	gtk_list_box_set_selection_mode (_tmp0_, GTK_SELECTION_NONE);
	g_object_ref_sink (_tmp0_);
	languages_list = _tmp0_;
	_tmp2_ = keyboard_input_method_page_install_list_get_all (&_tmp1_);
	{
		KeyboardInputMethodPageInstallList* language_collection = NULL;
		gint language_collection_length1 = 0;
		gint _language_collection_size_ = 0;
		gint language_it = 0;
		language_collection = _tmp2_;
		language_collection_length1 = _tmp1_;
		for (language_it = 0; language_it < language_collection_length1; language_it = language_it + 1) {
			KeyboardInputMethodPageInstallList language = 0;
			language = language_collection[language_it];
			{
				KeyboardInputMethodPageLanguagesRow* lang = NULL;
				KeyboardInputMethodPageLanguagesRow* _tmp3_;
				GtkListBox* _tmp4_;
				KeyboardInputMethodPageLanguagesRow* _tmp5_;
				_tmp3_ = keyboard_input_method_page_languages_row_new (language);
				g_object_ref_sink (_tmp3_);
				lang = _tmp3_;
				_tmp4_ = languages_list;
				_tmp5_ = lang;
				gtk_list_box_append (_tmp4_, (GtkWidget*) _tmp5_);
				_g_object_unref0 (lang);
			}
		}
		language_collection = (g_free (language_collection), NULL);
	}
	_tmp6_ = (GtkButton*) gtk_button_new_with_label (_ ("Languages"));
	gtk_widget_set_halign ((GtkWidget*) _tmp6_, GTK_ALIGN_START);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp6_, 6);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp6_, 12);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp6_, 6);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp6_, 6);
	g_object_ref_sink (_tmp6_);
	back_button = _tmp6_;
	_tmp7_ = back_button;
	gtk_widget_add_css_class ((GtkWidget*) _tmp7_, GRANITE_STYLE_CLASS_BACK_BUTTON);
	_tmp8_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp8_);
	_data7_->language_title = _tmp8_;
	_tmp9_ = back_button;
	_tmp10_ = _g_object_ref0 ((GtkWidget*) _tmp9_);
	_tmp11_ = _data7_->language_title;
	_tmp12_ = _g_object_ref0 ((GtkWidget*) _tmp11_);
	_tmp13_ = (GtkCenterBox*) gtk_center_box_new ();
	gtk_center_box_set_start_widget (_tmp13_, _tmp10_);
	_g_object_unref0 (_tmp10_);
	gtk_center_box_set_center_widget (_tmp13_, _tmp12_);
	_g_object_unref0 (_tmp12_);
	g_object_ref_sink (_tmp13_);
	language_header = _tmp13_;
	_tmp14_ = (GtkListBox*) gtk_list_box_new ();
	gtk_widget_set_hexpand ((GtkWidget*) _tmp14_, TRUE);
	gtk_widget_set_vexpand ((GtkWidget*) _tmp14_, TRUE);
	g_object_ref_sink (_tmp14_);
	_g_object_unref0 (self->priv->listbox);
	self->priv->listbox = _tmp14_;
	_tmp15_ = self->priv->listbox;
	gtk_list_box_set_filter_func (_tmp15_, _keyboard_input_method_page_install_engine_dialog_filter_function_gtk_list_box_filter_func, g_object_ref (self), g_object_unref);
	_tmp16_ = self->priv->listbox;
	gtk_list_box_set_sort_func (_tmp16_, _keyboard_input_method_page_install_engine_dialog_sort_function_gtk_list_box_sort_func, g_object_ref (self), g_object_unref);
	_tmp18_ = keyboard_input_method_page_install_list_get_all (&_tmp17_);
	{
		KeyboardInputMethodPageInstallList* language_collection = NULL;
		gint language_collection_length1 = 0;
		gint _language_collection_size_ = 0;
		gint language_it = 0;
		language_collection = _tmp18_;
		language_collection_length1 = _tmp17_;
		for (language_it = 0; language_it < language_collection_length1; language_it = language_it + 1) {
			KeyboardInputMethodPageInstallList language = 0;
			language = language_collection[language_it];
			{
				gint _tmp19_ = 0;
				gchar** _tmp20_;
				_tmp20_ = keyboard_input_method_page_install_list_get_components (language, &_tmp19_);
				{
					gchar** engine_collection = NULL;
					gint engine_collection_length1 = 0;
					gint _engine_collection_size_ = 0;
					gint engine_it = 0;
					engine_collection = _tmp20_;
					engine_collection_length1 = _tmp19_;
					for (engine_it = 0; engine_it < engine_collection_length1; engine_it = engine_it + 1) {
						gchar* _tmp21_;
						gchar* engine = NULL;
						_tmp21_ = g_strdup (engine_collection[engine_it]);
						engine = _tmp21_;
						{
							GtkListBox* _tmp22_;
							const gchar* _tmp23_;
							KeyboardInputMethodPageEnginesRow* _tmp24_;
							KeyboardInputMethodPageEnginesRow* _tmp25_;
							_tmp22_ = self->priv->listbox;
							_tmp23_ = engine;
							_tmp24_ = keyboard_input_method_page_engines_row_new (_tmp23_);
							g_object_ref_sink (_tmp24_);
							_tmp25_ = _tmp24_;
							gtk_list_box_append (_tmp22_, (GtkWidget*) _tmp25_);
							_g_object_unref0 (_tmp25_);
							_g_free0 (engine);
						}
					}
					engine_collection = (_vala_array_free (engine_collection, engine_collection_length1, (GDestroyNotify) g_free), NULL);
				}
			}
		}
		language_collection = (g_free (language_collection), NULL);
	}
	_tmp26_ = self->priv->listbox;
	_tmp27_ = _g_object_ref0 ((GtkWidget*) _tmp26_);
	_tmp28_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	gtk_scrolled_window_set_child (_tmp28_, _tmp27_);
	_g_object_unref0 (_tmp27_);
	g_object_ref_sink (_tmp28_);
	_data7_->scrolled = _tmp28_;
	_tmp29_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp29_);
	_data7_->engine_list_box = _tmp29_;
	_tmp30_ = _data7_->engine_list_box;
	gtk_widget_add_css_class ((GtkWidget*) _tmp30_, GRANITE_STYLE_CLASS_VIEW);
	_tmp31_ = _data7_->engine_list_box;
	_tmp32_ = language_header;
	gtk_box_append (_tmp31_, (GtkWidget*) _tmp32_);
	_tmp33_ = _data7_->engine_list_box;
	_tmp34_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	g_object_ref_sink (_tmp34_);
	_tmp35_ = _tmp34_;
	gtk_box_append (_tmp33_, (GtkWidget*) _tmp35_);
	_g_object_unref0 (_tmp35_);
	_tmp36_ = _data7_->engine_list_box;
	_tmp37_ = _data7_->scrolled;
	gtk_box_append (_tmp36_, (GtkWidget*) _tmp37_);
	_tmp38_ = (AdwLeaflet*) adw_leaflet_new ();
	adw_leaflet_set_can_unfold (_tmp38_, FALSE);
	adw_leaflet_set_can_navigate_back (_tmp38_, TRUE);
	g_object_ref_sink (_tmp38_);
	_data7_->leaflet = _tmp38_;
	_tmp39_ = _data7_->leaflet;
	_tmp40_ = languages_list;
	adw_leaflet_append (_tmp39_, (GtkWidget*) _tmp40_);
	_tmp41_ = _data7_->leaflet;
	_tmp42_ = _data7_->engine_list_box;
	adw_leaflet_append (_tmp41_, (GtkWidget*) _tmp42_);
	_tmp43_ = _data7_->leaflet;
	_tmp44_ = _g_object_ref0 ((GtkWidget*) _tmp43_);
	_tmp45_ = (GtkFrame*) gtk_frame_new (NULL);
	gtk_frame_set_child (_tmp45_, _tmp44_);
	_g_object_unref0 (_tmp44_);
	g_object_ref_sink (_tmp45_);
	frame = _tmp45_;
	_tmp46_ = granite_message_dialog_get_custom_bin ((GraniteMessageDialog*) self);
	_tmp47_ = _tmp46_;
	_tmp48_ = frame;
	gtk_box_append (_tmp47_, (GtkWidget*) _tmp48_);
	g_object_set ((GtkWindow*) self, "default-height", 300, NULL);
	_tmp49_ = granite_dialog_add_button ((GraniteDialog*) self, _ ("Install"), (gint) GTK_RESPONSE_OK);
	_tmp50_ = _g_object_ref0 (_tmp49_);
	_data7_->install_button = _tmp50_;
	_tmp51_ = _data7_->install_button;
	gtk_widget_set_sensitive (_tmp51_, FALSE);
	_tmp52_ = _data7_->install_button;
	gtk_widget_add_css_class (_tmp52_, GRANITE_STYLE_CLASS_SUGGESTED_ACTION);
	_tmp53_ = languages_list;
	g_signal_connect_data (_tmp53_, "row-activated", (GCallback) __keyboard_input_method_page_install_engine_dialog___lambda16__gtk_list_box_row_activated, block7_data_ref (_data7_), (GClosureNotify) block7_data_unref, 0);
	_tmp54_ = back_button;
	g_signal_connect_data (_tmp54_, "clicked", (GCallback) __keyboard_input_method_page_install_engine_dialog___lambda17__gtk_button_clicked, block7_data_ref (_data7_), (GClosureNotify) block7_data_unref, 0);
	_tmp55_ = self->priv->listbox;
	g_signal_connect_data (_tmp55_, "selected-rows-changed", (GCallback) __keyboard_input_method_page_install_engine_dialog___lambda18__gtk_list_box_selected_rows_changed, block7_data_ref (_data7_), (GClosureNotify) block7_data_unref, 0);
	_g_object_unref0 (frame);
	_g_object_unref0 (language_header);
	_g_object_unref0 (back_button);
	_g_object_unref0 (languages_list);
	block7_data_unref (_data7_);
	_data7_ = NULL;
	return obj;
}

static void
keyboard_input_method_page_install_engine_dialog_class_init (KeyboardInputMethodPageInstallEngineDialogClass * klass,
                                                             gpointer klass_data)
{
	keyboard_input_method_page_install_engine_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &KeyboardInputMethodPageInstallEngineDialog_private_offset);
	G_OBJECT_CLASS (klass)->constructor = keyboard_input_method_page_install_engine_dialog_constructor;
	G_OBJECT_CLASS (klass)->finalize = keyboard_input_method_page_install_engine_dialog_finalize;
}

static void
keyboard_input_method_page_install_engine_dialog_instance_init (KeyboardInputMethodPageInstallEngineDialog * self,
                                                                gpointer klass)
{
	self->priv = keyboard_input_method_page_install_engine_dialog_get_instance_private (self);
}

static void
keyboard_input_method_page_install_engine_dialog_finalize (GObject * obj)
{
	KeyboardInputMethodPageInstallEngineDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, KEYBOARD_INPUT_METHOD_PAGE_TYPE_INSTALL_ENGINE_DIALOG, KeyboardInputMethodPageInstallEngineDialog);
	_g_object_unref0 (self->priv->listbox);
	_g_free0 (self->priv->engines_filter);
	G_OBJECT_CLASS (keyboard_input_method_page_install_engine_dialog_parent_class)->finalize (obj);
}

static GType
keyboard_input_method_page_install_engine_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (KeyboardInputMethodPageInstallEngineDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) keyboard_input_method_page_install_engine_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (KeyboardInputMethodPageInstallEngineDialog), 0, (GInstanceInitFunc) keyboard_input_method_page_install_engine_dialog_instance_init, NULL };
	GType keyboard_input_method_page_install_engine_dialog_type_id;
	keyboard_input_method_page_install_engine_dialog_type_id = g_type_register_static (GRANITE_TYPE_MESSAGE_DIALOG, "KeyboardInputMethodPageInstallEngineDialog", &g_define_type_info, 0);
	KeyboardInputMethodPageInstallEngineDialog_private_offset = g_type_add_instance_private (keyboard_input_method_page_install_engine_dialog_type_id, sizeof (KeyboardInputMethodPageInstallEngineDialogPrivate));
	return keyboard_input_method_page_install_engine_dialog_type_id;
}

GType
keyboard_input_method_page_install_engine_dialog_get_type (void)
{
	static volatile gsize keyboard_input_method_page_install_engine_dialog_type_id__once = 0;
	if (g_once_init_enter (&keyboard_input_method_page_install_engine_dialog_type_id__once)) {
		GType keyboard_input_method_page_install_engine_dialog_type_id;
		keyboard_input_method_page_install_engine_dialog_type_id = keyboard_input_method_page_install_engine_dialog_get_type_once ();
		g_once_init_leave (&keyboard_input_method_page_install_engine_dialog_type_id__once, keyboard_input_method_page_install_engine_dialog_type_id);
	}
	return keyboard_input_method_page_install_engine_dialog_type_id__once;
}

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

