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

/*
* Copyright 2019-2024 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 <glib.h>
#include <ibus.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <granite-7.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_ADD_ENGINE_DIALOG_0_PROPERTY,
	KEYBOARD_INPUT_METHOD_PAGE_ADD_ENGINE_DIALOG_ENGINES_PROPERTY,
	KEYBOARD_INPUT_METHOD_PAGE_ADD_ENGINE_DIALOG_NUM_PROPERTIES
};
static GParamSpec* keyboard_input_method_page_add_engine_dialog_properties[KEYBOARD_INPUT_METHOD_PAGE_ADD_ENGINE_DIALOG_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block4Data Block4Data;
typedef struct _Block5Data Block5Data;
enum  {
	KEYBOARD_INPUT_METHOD_PAGE_ADD_ENGINE_DIALOG_ADD_ENGINE_SIGNAL,
	KEYBOARD_INPUT_METHOD_PAGE_ADD_ENGINE_DIALOG_NUM_SIGNALS
};
static guint keyboard_input_method_page_add_engine_dialog_signals[KEYBOARD_INPUT_METHOD_PAGE_ADD_ENGINE_DIALOG_NUM_SIGNALS] = {0};

struct _KeyboardInputMethodPageAddEngineDialogPrivate {
	GList* _engines;
	GtkSearchEntry* search_entry;
	GListStore* liststore;
	GtkListBox* listbox;
};

struct _Block4Data {
	int _ref_count_;
	KeyboardInputMethodPageAddEngineDialog* self;
	KeyboardInputMethodPageUbuntuInstaller* installer;
	KeyboardInputMethodPageInstallEngineDialog* install_dialog;
};

struct _Block5Data {
	int _ref_count_;
	Block4Data * _data4_;
	KeyboardInputMethodPageProgressDialog* progress_dialog;
};

static gint KeyboardInputMethodPageAddEngineDialog_private_offset;
static gpointer keyboard_input_method_page_add_engine_dialog_parent_class = NULL;

static void keyboard_input_method_page_add_engine_dialog_trigger_add_engine (KeyboardInputMethodPageAddEngineDialog* self,
                                                                      GtkListBoxRow* row);
static void keyboard_input_method_page_add_engine_dialog_update_engines_list (KeyboardInputMethodPageAddEngineDialog* self);
VALA_EXTERN gchar* keyboard_input_method_page_utils_gettext_engine_longname (IBusEngineDesc* engine);
static gint __lambda11_ (KeyboardInputMethodPageAddEngineDialog* self,
                  GObject* a,
                  GObject* b);
static gint ___lambda11__gcompare_data_func (gconstpointer a,
                                      gconstpointer b,
                                      gpointer self);
static void _g_object_unref0_ (gpointer var);
static inline void _g_list_free__g_object_unref0_ (GList* self);
static GObject * keyboard_input_method_page_add_engine_dialog_constructor (GType type,
                                                                    guint n_construct_properties,
                                                                    GObjectConstructParam * construct_properties);
static void _keyboard_input_method_page_add_engine_dialog_trigger_add_engine_gtk_list_box_row_activated (GtkListBox* _sender,
                                                                                                  GtkListBoxRow* row,
                                                                                                  gpointer self);
static gboolean _keyboard_input_method_page_add_engine_dialog___lambda12_ (KeyboardInputMethodPageAddEngineDialog* self,
                                                                    GtkListBoxRow* list_box_row);
static gboolean __keyboard_input_method_page_add_engine_dialog___lambda12__gtk_list_box_filter_func (GtkListBoxRow* row,
                                                                                              gpointer self);
static void _keyboard_input_method_page_add_engine_dialog___lambda13_ (KeyboardInputMethodPageAddEngineDialog* self);
static void __keyboard_input_method_page_add_engine_dialog___lambda13__gtk_search_entry_search_changed (GtkSearchEntry* _sender,
                                                                                                 gpointer self);
static void _keyboard_input_method_page_add_engine_dialog___lambda14_ (KeyboardInputMethodPageAddEngineDialog* self,
                                                                gint response_id);
static Block4Data* block4_data_ref (Block4Data* _data4_);
static void block4_data_unref (void * _userdata_);
static void ___lambda19_ (Block4Data* _data4_,
                   gint response_id);
static Block5Data* block5_data_ref (Block5Data* _data5_);
static void block5_data_unref (void * _userdata_);
static void ___lambda21_ (Block5Data* _data5_,
                   gint p);
static void ____lambda21__keyboard_input_method_page_ubuntu_installer_progress_changed (KeyboardInputMethodPageUbuntuInstaller* _sender,
                                                                                 gint progress,
                                                                                 gpointer self);
static void ____lambda19__gtk_dialog_response (GtkDialog* _sender,
                                        gint response_id,
                                        gpointer self);
static void __keyboard_input_method_page_add_engine_dialog___lambda14__gtk_dialog_response (GtkDialog* _sender,
                                                                                     gint response_id,
                                                                                     gpointer self);
static void keyboard_input_method_page_add_engine_dialog_finalize (GObject * obj);
static GType keyboard_input_method_page_add_engine_dialog_get_type_once (void);
static void _vala_keyboard_input_method_page_add_engine_dialog_get_property (GObject * object,
                                                                      guint property_id,
                                                                      GValue * value,
                                                                      GParamSpec * pspec);
static void _vala_keyboard_input_method_page_add_engine_dialog_set_property (GObject * object,
                                                                      guint property_id,
                                                                      const GValue * value,
                                                                      GParamSpec * pspec);

static inline gpointer
keyboard_input_method_page_add_engine_dialog_get_instance_private (KeyboardInputMethodPageAddEngineDialog* self)
{
	return G_STRUCT_MEMBER_P (self, KeyboardInputMethodPageAddEngineDialog_private_offset);
}

KeyboardInputMethodPageAddEngineDialog*
keyboard_input_method_page_add_engine_dialog_construct (GType object_type,
                                                        GList* engines)
{
	KeyboardInputMethodPageAddEngineDialog * self = NULL;
	self = (KeyboardInputMethodPageAddEngineDialog*) g_object_new (object_type, "engines", engines, NULL);
	return self;
}

KeyboardInputMethodPageAddEngineDialog*
keyboard_input_method_page_add_engine_dialog_new (GList* engines)
{
	return keyboard_input_method_page_add_engine_dialog_construct (KEYBOARD_INPUT_METHOD_PAGE_TYPE_ADD_ENGINE_DIALOG, engines);
}

static void
keyboard_input_method_page_add_engine_dialog_trigger_add_engine (KeyboardInputMethodPageAddEngineDialog* self,
                                                                 GtkListBoxRow* row)
{
	gint index = 0;
	GListStore* _tmp0_;
	GObject* _tmp1_;
	KeyboardInputMethodPageAddEnginesList* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (row != NULL);
	index = gtk_list_box_row_get_index (row);
	_tmp0_ = self->priv->liststore;
	_tmp1_ = g_list_model_get_item ((GListModel*) _tmp0_, (guint) index);
	_tmp2_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, KEYBOARD_INPUT_METHOD_PAGE_TYPE_ADD_ENGINES_LIST, KeyboardInputMethodPageAddEnginesList);
	_tmp3_ = keyboard_input_method_page_add_engines_list_get_engine_id (_tmp2_);
	_tmp4_ = _tmp3_;
	g_signal_emit (self, keyboard_input_method_page_add_engine_dialog_signals[KEYBOARD_INPUT_METHOD_PAGE_ADD_ENGINE_DIALOG_ADD_ENGINE_SIGNAL], 0, _tmp4_);
	_g_object_unref0 (_tmp2_);
	g_signal_emit_by_name ((GtkDialog*) self, "close");
}

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

static gint
__lambda11_ (KeyboardInputMethodPageAddEngineDialog* self,
             GObject* a,
             GObject* b)
{
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint result;
	g_return_val_if_fail (a != NULL, -1);
	g_return_val_if_fail (b != NULL, -1);
	_tmp0_ = keyboard_input_method_page_add_engines_list_get_engine_full_name (G_TYPE_CHECK_INSTANCE_CAST (a, KEYBOARD_INPUT_METHOD_PAGE_TYPE_ADD_ENGINES_LIST, KeyboardInputMethodPageAddEnginesList));
	_tmp1_ = _tmp0_;
	_tmp2_ = keyboard_input_method_page_add_engines_list_get_engine_full_name (G_TYPE_CHECK_INSTANCE_CAST (b, KEYBOARD_INPUT_METHOD_PAGE_TYPE_ADD_ENGINES_LIST, KeyboardInputMethodPageAddEnginesList));
	_tmp3_ = _tmp2_;
	result = g_utf8_collate (_tmp1_, _tmp3_);
	return result;
}

static gint
___lambda11__gcompare_data_func (gconstpointer a,
                                 gconstpointer b,
                                 gpointer self)
{
	gint result;
	result = __lambda11_ ((KeyboardInputMethodPageAddEngineDialog*) self, (GObject*) a, (GObject*) b);
	return result;
}

static void
_g_object_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}

static inline void
_g_list_free__g_object_unref0_ (GList* self)
{
	g_list_free_full (self, (GDestroyNotify) _g_object_unref0_);
}

static void
keyboard_input_method_page_add_engine_dialog_update_engines_list (KeyboardInputMethodPageAddEngineDialog* self)
{
	GList* engine_lists = NULL;
	GList* _tmp0_;
	GList* _tmp17_;
	GListStore* _tmp21_;
	GtkListBox* _tmp37_;
	GtkListBox* _tmp38_;
	GtkListBoxRow* _tmp39_;
	GtkSearchEntry* _tmp40_;
	g_return_if_fail (self != NULL);
	engine_lists = NULL;
	_tmp0_ = self->priv->_engines;
	{
		GList* engine_collection = NULL;
		GList* engine_it = NULL;
		engine_collection = _tmp0_;
		for (engine_it = engine_collection; engine_it != NULL; engine_it = engine_it->next) {
			IBusEngineDesc* _tmp1_;
			IBusEngineDesc* engine = NULL;
			_tmp1_ = _g_object_ref0 ((IBusEngineDesc*) engine_it->data);
			engine = _tmp1_;
			{
				gchar* full_name = NULL;
				IBusEngineDesc* _tmp2_;
				const gchar* _tmp3_;
				const gchar* _tmp4_;
				gchar* _tmp5_;
				gchar* _tmp6_;
				IBusEngineDesc* _tmp7_;
				gchar* _tmp8_;
				gchar* _tmp9_;
				gchar* _tmp10_;
				gchar* _tmp11_;
				IBusEngineDesc* _tmp12_;
				const gchar* _tmp13_;
				const gchar* _tmp14_;
				const gchar* _tmp15_;
				KeyboardInputMethodPageAddEnginesList* _tmp16_;
				_tmp2_ = engine;
				_tmp3_ = ibus_engine_desc_get_language (_tmp2_);
				_tmp4_ = _tmp3_;
				_tmp5_ = ibus_get_language_name (_tmp4_);
				_tmp6_ = _tmp5_;
				_tmp7_ = engine;
				_tmp8_ = keyboard_input_method_page_utils_gettext_engine_longname (_tmp7_);
				_tmp9_ = _tmp8_;
				_tmp10_ = g_strdup_printf ("%s - %s", _tmp6_, _tmp9_);
				_tmp11_ = _tmp10_;
				_g_free0 (_tmp9_);
				_g_free0 (_tmp6_);
				full_name = _tmp11_;
				_tmp12_ = engine;
				_tmp13_ = ibus_engine_desc_get_name (_tmp12_);
				_tmp14_ = _tmp13_;
				_tmp15_ = full_name;
				_tmp16_ = keyboard_input_method_page_add_engines_list_new (_tmp14_, _tmp15_);
				engine_lists = g_list_append (engine_lists, _tmp16_);
				_g_free0 (full_name);
				_g_object_unref0 (engine);
			}
		}
	}
	_tmp17_ = engine_lists;
	{
		GList* engine_list_collection = NULL;
		GList* engine_list_it = NULL;
		engine_list_collection = _tmp17_;
		for (engine_list_it = engine_list_collection; engine_list_it != NULL; engine_list_it = engine_list_it->next) {
			KeyboardInputMethodPageAddEnginesList* _tmp18_;
			KeyboardInputMethodPageAddEnginesList* engine_list = NULL;
			_tmp18_ = _g_object_ref0 ((KeyboardInputMethodPageAddEnginesList*) engine_list_it->data);
			engine_list = _tmp18_;
			{
				GListStore* _tmp19_;
				KeyboardInputMethodPageAddEnginesList* _tmp20_;
				_tmp19_ = self->priv->liststore;
				_tmp20_ = engine_list;
				g_list_store_append (_tmp19_, (GObject*) _tmp20_);
				_g_object_unref0 (engine_list);
			}
		}
	}
	_tmp21_ = self->priv->liststore;
	g_list_store_sort (_tmp21_, ___lambda11__gcompare_data_func, self);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp22_ = FALSE;
			_tmp22_ = TRUE;
			while (TRUE) {
				GListStore* _tmp24_;
				GtkLabel* label = NULL;
				GListStore* _tmp25_;
				GObject* _tmp26_;
				KeyboardInputMethodPageAddEnginesList* _tmp27_;
				const gchar* _tmp28_;
				const gchar* _tmp29_;
				GtkLabel* _tmp30_ = NULL;
				GtkLabel* _tmp31_;
				GtkListBoxRow* listboxrow = NULL;
				GtkLabel* _tmp32_;
				GtkWidget* _tmp33_;
				GtkListBoxRow* _tmp34_ = NULL;
				GtkListBox* _tmp35_;
				GtkListBoxRow* _tmp36_;
				if (!_tmp22_) {
					gint _tmp23_;
					_tmp23_ = i;
					i = _tmp23_ + 1;
				}
				_tmp22_ = FALSE;
				_tmp24_ = self->priv->liststore;
				if (!(((guint) i) < g_list_model_get_n_items ((GListModel*) _tmp24_))) {
					break;
				}
				_tmp25_ = self->priv->liststore;
				_tmp26_ = g_list_model_get_item ((GListModel*) _tmp25_, (guint) i);
				_tmp27_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp26_, KEYBOARD_INPUT_METHOD_PAGE_TYPE_ADD_ENGINES_LIST, KeyboardInputMethodPageAddEnginesList);
				_tmp28_ = keyboard_input_method_page_add_engines_list_get_engine_full_name (_tmp27_);
				_tmp29_ = _tmp28_;
				_tmp30_ = (GtkLabel*) gtk_label_new (_tmp29_);
				gtk_widget_set_halign ((GtkWidget*) _tmp30_, GTK_ALIGN_START);
				gtk_widget_set_margin_top ((GtkWidget*) _tmp30_, 6);
				gtk_widget_set_margin_end ((GtkWidget*) _tmp30_, 12);
				gtk_widget_set_margin_bottom ((GtkWidget*) _tmp30_, 6);
				gtk_widget_set_margin_start ((GtkWidget*) _tmp30_, 12);
				g_object_ref_sink (_tmp30_);
				_tmp31_ = _tmp30_;
				_g_object_unref0 (_tmp27_);
				label = _tmp31_;
				_tmp32_ = label;
				_tmp33_ = _g_object_ref0 ((GtkWidget*) _tmp32_);
				_tmp34_ = (GtkListBoxRow*) gtk_list_box_row_new ();
				gtk_list_box_row_set_child (_tmp34_, _tmp33_);
				_g_object_unref0 (_tmp33_);
				g_object_ref_sink (_tmp34_);
				listboxrow = _tmp34_;
				_tmp35_ = self->priv->listbox;
				_tmp36_ = listboxrow;
				gtk_list_box_append (_tmp35_, (GtkWidget*) _tmp36_);
				_g_object_unref0 (listboxrow);
				_g_object_unref0 (label);
			}
		}
	}
	_tmp37_ = self->priv->listbox;
	_tmp38_ = self->priv->listbox;
	_tmp39_ = gtk_list_box_get_row_at_index (_tmp38_, 0);
	gtk_list_box_select_row (_tmp37_, _tmp39_);
	_tmp40_ = self->priv->search_entry;
	gtk_widget_grab_focus ((GtkWidget*) _tmp40_);
	(engine_lists == NULL) ? NULL : (engine_lists = (_g_list_free__g_object_unref0_ (engine_lists), NULL));
}

GList*
keyboard_input_method_page_add_engine_dialog_get_engines (KeyboardInputMethodPageAddEngineDialog* self)
{
	GList* result;
	GList* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_engines;
	result = _tmp0_;
	return result;
}

static void
keyboard_input_method_page_add_engine_dialog_set_engines (KeyboardInputMethodPageAddEngineDialog* self,
                                                          GList* value)
{
	GList* old_value;
	g_return_if_fail (self != NULL);
	old_value = keyboard_input_method_page_add_engine_dialog_get_engines (self);
	if (old_value != value) {
		self->priv->_engines = value;
		g_object_notify_by_pspec ((GObject *) self, keyboard_input_method_page_add_engine_dialog_properties[KEYBOARD_INPUT_METHOD_PAGE_ADD_ENGINE_DIALOG_ENGINES_PROPERTY]);
	}
}

static void
_keyboard_input_method_page_add_engine_dialog_trigger_add_engine_gtk_list_box_row_activated (GtkListBox* _sender,
                                                                                             GtkListBoxRow* row,
                                                                                             gpointer self)
{
	keyboard_input_method_page_add_engine_dialog_trigger_add_engine ((KeyboardInputMethodPageAddEngineDialog*) self, row);
}

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
_keyboard_input_method_page_add_engine_dialog___lambda12_ (KeyboardInputMethodPageAddEngineDialog* self,
                                                           GtkListBoxRow* list_box_row)
{
	KeyboardInputMethodPageAddEnginesList* item = NULL;
	GListStore* _tmp0_;
	GObject* _tmp1_;
	KeyboardInputMethodPageAddEnginesList* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	GtkSearchEntry* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gboolean _tmp12_;
	gboolean result;
	g_return_val_if_fail (list_box_row != NULL, FALSE);
	_tmp0_ = self->priv->liststore;
	_tmp1_ = g_list_model_get_item ((GListModel*) _tmp0_, (guint) gtk_list_box_row_get_index (list_box_row));
	item = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, KEYBOARD_INPUT_METHOD_PAGE_TYPE_ADD_ENGINES_LIST, KeyboardInputMethodPageAddEnginesList);
	_tmp2_ = item;
	_tmp3_ = keyboard_input_method_page_add_engines_list_get_engine_full_name (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = g_utf8_strdown (_tmp4_, (gssize) -1);
	_tmp6_ = _tmp5_;
	_tmp7_ = self->priv->search_entry;
	_tmp8_ = gtk_editable_get_text ((GtkEditable*) _tmp7_);
	_tmp9_ = _tmp8_;
	_tmp10_ = g_utf8_strdown (_tmp9_, (gssize) -1);
	_tmp11_ = _tmp10_;
	_tmp12_ = string_contains (_tmp6_, _tmp11_);
	_g_free0 (_tmp11_);
	_g_free0 (_tmp6_);
	result = _tmp12_;
	_g_object_unref0 (item);
	return result;
}

static gboolean
__keyboard_input_method_page_add_engine_dialog___lambda12__gtk_list_box_filter_func (GtkListBoxRow* row,
                                                                                     gpointer self)
{
	gboolean result;
	result = _keyboard_input_method_page_add_engine_dialog___lambda12_ ((KeyboardInputMethodPageAddEngineDialog*) self, row);
	return result;
}

static void
_keyboard_input_method_page_add_engine_dialog___lambda13_ (KeyboardInputMethodPageAddEngineDialog* self)
{
	GtkListBox* _tmp0_;
	_tmp0_ = self->priv->listbox;
	gtk_list_box_invalidate_filter (_tmp0_);
}

static void
__keyboard_input_method_page_add_engine_dialog___lambda13__gtk_search_entry_search_changed (GtkSearchEntry* _sender,
                                                                                            gpointer self)
{
	_keyboard_input_method_page_add_engine_dialog___lambda13_ ((KeyboardInputMethodPageAddEngineDialog*) self);
}

static Block4Data*
block4_data_ref (Block4Data* _data4_)
{
	g_atomic_int_inc (&_data4_->_ref_count_);
	return _data4_;
}

static void
block4_data_unref (void * _userdata_)
{
	Block4Data* _data4_;
	_data4_ = (Block4Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data4_->_ref_count_)) {
		KeyboardInputMethodPageAddEngineDialog* self;
		self = _data4_->self;
		_g_object_unref0 (_data4_->install_dialog);
		_g_object_unref0 (_data4_->installer);
		_g_object_unref0 (self);
		g_slice_free (Block4Data, _data4_);
	}
}

static Block5Data*
block5_data_ref (Block5Data* _data5_)
{
	g_atomic_int_inc (&_data5_->_ref_count_);
	return _data5_;
}

static void
block5_data_unref (void * _userdata_)
{
	Block5Data* _data5_;
	_data5_ = (Block5Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data5_->_ref_count_)) {
		KeyboardInputMethodPageAddEngineDialog* self;
		self = _data5_->_data4_->self;
		_g_object_unref0 (_data5_->progress_dialog);
		block4_data_unref (_data5_->_data4_);
		_data5_->_data4_ = NULL;
		g_slice_free (Block5Data, _data5_);
	}
}

static void
___lambda21_ (Block5Data* _data5_,
              gint p)
{
	Block4Data* _data4_;
	KeyboardInputMethodPageAddEngineDialog* self;
	KeyboardInputMethodPageProgressDialog* _tmp0_;
	_data4_ = _data5_->_data4_;
	self = _data4_->self;
	_tmp0_ = _data5_->progress_dialog;
	keyboard_input_method_page_progress_dialog_set_progress (_tmp0_, p);
}

static void
____lambda21__keyboard_input_method_page_ubuntu_installer_progress_changed (KeyboardInputMethodPageUbuntuInstaller* _sender,
                                                                            gint progress,
                                                                            gpointer self)
{
	___lambda21_ (self, progress);
}

static void
___lambda19_ (Block4Data* _data4_,
              gint response_id)
{
	KeyboardInputMethodPageAddEngineDialog* self;
	self = _data4_->self;
	if (response_id == ((gint) GTK_RESPONSE_OK)) {
		Block5Data* _data5_;
		gchar* engine_to_install = NULL;
		KeyboardInputMethodPageInstallEngineDialog* _tmp0_;
		gchar* _tmp1_;
		KeyboardInputMethodPageInstallEngineDialog* _tmp2_;
		KeyboardInputMethodPageUbuntuInstaller* _tmp3_;
		const gchar* _tmp4_;
		GtkRoot* _tmp5_;
		GtkWindow* _tmp6_;
		KeyboardInputMethodPageProgressDialog* _tmp7_ = NULL;
		KeyboardInputMethodPageUbuntuInstaller* _tmp8_;
		KeyboardInputMethodPageProgressDialog* _tmp9_;
		_data5_ = g_slice_new0 (Block5Data);
		_data5_->_ref_count_ = 1;
		_data5_->_data4_ = block4_data_ref (_data4_);
		_tmp0_ = _data4_->install_dialog;
		_tmp1_ = keyboard_input_method_page_install_engine_dialog_get_selected_engine_name (_tmp0_);
		engine_to_install = _tmp1_;
		_tmp2_ = _data4_->install_dialog;
		gtk_window_destroy ((GtkWindow*) _tmp2_);
		_tmp3_ = _data4_->installer;
		_tmp4_ = engine_to_install;
		keyboard_input_method_page_ubuntu_installer_install (_tmp3_, _tmp4_);
		_tmp5_ = gtk_widget_get_root ((GtkWidget*) self);
		_tmp6_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, gtk_window_get_type (), GtkWindow));
		_tmp7_ = keyboard_input_method_page_progress_dialog_new ();
		gtk_window_set_transient_for ((GtkWindow*) _tmp7_, _tmp6_);
		_g_object_unref0 (_tmp6_);
		g_object_ref_sink (_tmp7_);
		_data5_->progress_dialog = _tmp7_;
		_tmp8_ = _data4_->installer;
		g_signal_connect_data (_tmp8_, "progress-changed", (GCallback) ____lambda21__keyboard_input_method_page_ubuntu_installer_progress_changed, block5_data_ref (_data5_), (GClosureNotify) block5_data_unref, 0);
		_tmp9_ = _data5_->progress_dialog;
		gtk_window_present ((GtkWindow*) _tmp9_);
		_g_free0 (engine_to_install);
		block5_data_unref (_data5_);
		_data5_ = NULL;
	} else {
		KeyboardInputMethodPageInstallEngineDialog* _tmp10_;
		_tmp10_ = _data4_->install_dialog;
		gtk_window_destroy ((GtkWindow*) _tmp10_);
	}
}

static void
____lambda19__gtk_dialog_response (GtkDialog* _sender,
                                   gint response_id,
                                   gpointer self)
{
	___lambda19_ (self, response_id);
}

static void
_keyboard_input_method_page_add_engine_dialog___lambda14_ (KeyboardInputMethodPageAddEngineDialog* self,
                                                           gint response_id)
{
	if (response_id == ((gint) GTK_RESPONSE_OK)) {
		Block4Data* _data4_;
		KeyboardInputMethodPageUbuntuInstaller* _tmp0_;
		KeyboardInputMethodPageUbuntuInstaller* _tmp1_;
		KeyboardInputMethodPageInstallEngineDialog* _tmp2_ = NULL;
		KeyboardInputMethodPageInstallEngineDialog* _tmp3_;
		KeyboardInputMethodPageInstallEngineDialog* _tmp4_;
		_data4_ = g_slice_new0 (Block4Data);
		_data4_->_ref_count_ = 1;
		_data4_->self = g_object_ref (self);
		_tmp0_ = keyboard_input_method_page_ubuntu_installer_get_default ();
		_tmp1_ = _g_object_ref0 (_tmp0_);
		_data4_->installer = _tmp1_;
		_tmp2_ = keyboard_input_method_page_install_engine_dialog_new ((GtkWindow*) self);
		gtk_window_set_modal ((GtkWindow*) _tmp2_, TRUE);
		g_object_ref_sink (_tmp2_);
		_data4_->install_dialog = _tmp2_;
		_tmp3_ = _data4_->install_dialog;
		g_signal_connect_data ((GtkDialog*) _tmp3_, "response", (GCallback) ____lambda19__gtk_dialog_response, block4_data_ref (_data4_), (GClosureNotify) block4_data_unref, 0);
		_tmp4_ = _data4_->install_dialog;
		gtk_window_present ((GtkWindow*) _tmp4_);
		block4_data_unref (_data4_);
		_data4_ = NULL;
	} else {
		if (response_id == ((gint) GTK_RESPONSE_ACCEPT)) {
			GtkListBox* _tmp5_;
			GtkListBoxRow* _tmp6_;
			_tmp5_ = self->priv->listbox;
			_tmp6_ = gtk_list_box_get_selected_row (_tmp5_);
			keyboard_input_method_page_add_engine_dialog_trigger_add_engine (self, _tmp6_);
			g_signal_emit_by_name ((GtkDialog*) self, "close");
		} else {
			g_signal_emit_by_name ((GtkDialog*) self, "close");
		}
	}
}

static void
__keyboard_input_method_page_add_engine_dialog___lambda14__gtk_dialog_response (GtkDialog* _sender,
                                                                                gint response_id,
                                                                                gpointer self)
{
	_keyboard_input_method_page_add_engine_dialog___lambda14_ ((KeyboardInputMethodPageAddEngineDialog*) self, response_id);
}

static GObject *
keyboard_input_method_page_add_engine_dialog_constructor (GType type,
                                                          guint n_construct_properties,
                                                          GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	KeyboardInputMethodPageAddEngineDialog * self;
	gchar* _tmp0_;
	GtkSearchEntry* _tmp1_ = NULL;
	GListStore* _tmp2_;
	GtkListBox* _tmp3_ = NULL;
	GtkScrolledWindow* scrolled = NULL;
	GtkListBox* _tmp4_;
	GtkWidget* _tmp5_;
	GtkScrolledWindow* _tmp6_ = NULL;
	GtkBox* frame_box = NULL;
	GtkBox* _tmp7_;
	GtkBox* _tmp8_;
	GtkSearchEntry* _tmp9_;
	GtkBox* _tmp10_;
	GtkScrolledWindow* _tmp11_;
	GtkFrame* frame = NULL;
	GtkBox* _tmp12_;
	GtkWidget* _tmp13_;
	GtkFrame* _tmp14_ = NULL;
	GtkFrame* _tmp15_;
	GtkBox* _tmp16_;
	GtkFrame* _tmp17_;
	GtkWidget* install_button = NULL;
	GtkWidget* _tmp18_;
	GtkWidget* _tmp19_;
	GtkWidget* cancel_button = NULL;
	GtkWidget* _tmp20_;
	GtkWidget* _tmp21_;
	GtkWidget* add_button = NULL;
	GtkWidget* _tmp22_;
	GtkWidget* _tmp23_;
	GtkWidget* _tmp24_;
	GtkListBox* _tmp25_;
	GtkListBox* _tmp26_;
	GtkSearchEntry* _tmp27_;
	parent_class = G_OBJECT_CLASS (keyboard_input_method_page_add_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_ADD_ENGINE_DIALOG, KeyboardInputMethodPageAddEngineDialog);
	g_object_set ((GtkWindow*) self, "default-height", 450, NULL);
	g_object_set ((GtkWindow*) self, "default-width", 750, NULL);
	_tmp0_ = g_strdup (_ ("Search engine"));
	_tmp1_ = (GtkSearchEntry*) gtk_search_entry_new ();
	gtk_widget_set_margin_top ((GtkWidget*) _tmp1_, 12);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp1_, 12);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp1_, 6);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp1_, 12);
	g_object_set (_tmp1_, "placeholder-text", _tmp0_, NULL);
	_g_free0 (_tmp0_);
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->priv->search_entry);
	self->priv->search_entry = _tmp1_;
	_tmp2_ = g_list_store_new (G_TYPE_OBJECT);
	_g_object_unref0 (self->priv->liststore);
	self->priv->liststore = _tmp2_;
	_tmp3_ = (GtkListBox*) gtk_list_box_new ();
	gtk_list_box_set_activate_on_single_click (_tmp3_, FALSE);
	g_object_ref_sink (_tmp3_);
	_g_object_unref0 (self->priv->listbox);
	self->priv->listbox = _tmp3_;
	_tmp4_ = self->priv->listbox;
	_tmp5_ = _g_object_ref0 ((GtkWidget*) _tmp4_);
	_tmp6_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	gtk_scrolled_window_set_child (_tmp6_, _tmp5_);
	_g_object_unref0 (_tmp5_);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp6_, TRUE);
	gtk_widget_set_vexpand ((GtkWidget*) _tmp6_, TRUE);
	g_object_set ((GtkWidget*) _tmp6_, "height-request", 300, NULL);
	g_object_set ((GtkWidget*) _tmp6_, "width-request", 500, NULL);
	g_object_ref_sink (_tmp6_);
	scrolled = _tmp6_;
	_tmp7_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp7_);
	frame_box = _tmp7_;
	_tmp8_ = frame_box;
	_tmp9_ = self->priv->search_entry;
	gtk_box_append (_tmp8_, (GtkWidget*) _tmp9_);
	_tmp10_ = frame_box;
	_tmp11_ = scrolled;
	gtk_box_append (_tmp10_, (GtkWidget*) _tmp11_);
	_tmp12_ = frame_box;
	_tmp13_ = _g_object_ref0 ((GtkWidget*) _tmp12_);
	_tmp14_ = (GtkFrame*) gtk_frame_new (NULL);
	gtk_frame_set_child (_tmp14_, _tmp13_);
	_g_object_unref0 (_tmp13_);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp14_, 10);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp14_, 10);
	g_object_ref_sink (_tmp14_);
	frame = _tmp14_;
	_tmp15_ = frame;
	gtk_widget_add_css_class ((GtkWidget*) _tmp15_, GRANITE_STYLE_CLASS_VIEW);
	_tmp16_ = gtk_dialog_get_content_area ((GtkDialog*) self);
	_tmp17_ = frame;
	gtk_box_append (_tmp16_, (GtkWidget*) _tmp17_);
	_tmp18_ = granite_dialog_add_button ((GraniteDialog*) self, _ ("Install Unlisted Engines…"), (gint) GTK_RESPONSE_OK);
	_tmp19_ = _g_object_ref0 (_tmp18_);
	install_button = _tmp19_;
	_tmp20_ = granite_dialog_add_button ((GraniteDialog*) self, _ ("Cancel"), (gint) GTK_RESPONSE_CANCEL);
	_tmp21_ = _g_object_ref0 (_tmp20_);
	cancel_button = _tmp21_;
	_tmp22_ = granite_dialog_add_button ((GraniteDialog*) self, _ ("Add Engine"), (gint) GTK_RESPONSE_ACCEPT);
	_tmp23_ = _g_object_ref0 (_tmp22_);
	add_button = _tmp23_;
	_tmp24_ = add_button;
	gtk_widget_add_css_class (_tmp24_, GRANITE_STYLE_CLASS_SUGGESTED_ACTION);
	_tmp25_ = self->priv->listbox;
	g_signal_connect_object (_tmp25_, "row-activated", (GCallback) _keyboard_input_method_page_add_engine_dialog_trigger_add_engine_gtk_list_box_row_activated, self, 0);
	_tmp26_ = self->priv->listbox;
	gtk_list_box_set_filter_func (_tmp26_, __keyboard_input_method_page_add_engine_dialog___lambda12__gtk_list_box_filter_func, g_object_ref (self), g_object_unref);
	_tmp27_ = self->priv->search_entry;
	g_signal_connect_object (_tmp27_, "search-changed", (GCallback) __keyboard_input_method_page_add_engine_dialog___lambda13__gtk_search_entry_search_changed, self, 0);
	g_signal_connect_object ((GtkDialog*) self, "response", (GCallback) __keyboard_input_method_page_add_engine_dialog___lambda14__gtk_dialog_response, self, 0);
	keyboard_input_method_page_add_engine_dialog_update_engines_list (self);
	_g_object_unref0 (add_button);
	_g_object_unref0 (cancel_button);
	_g_object_unref0 (install_button);
	_g_object_unref0 (frame);
	_g_object_unref0 (frame_box);
	_g_object_unref0 (scrolled);
	return obj;
}

static void
keyboard_input_method_page_add_engine_dialog_class_init (KeyboardInputMethodPageAddEngineDialogClass * klass,
                                                         gpointer klass_data)
{
	keyboard_input_method_page_add_engine_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &KeyboardInputMethodPageAddEngineDialog_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_keyboard_input_method_page_add_engine_dialog_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_keyboard_input_method_page_add_engine_dialog_set_property;
	G_OBJECT_CLASS (klass)->constructor = keyboard_input_method_page_add_engine_dialog_constructor;
	G_OBJECT_CLASS (klass)->finalize = keyboard_input_method_page_add_engine_dialog_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), KEYBOARD_INPUT_METHOD_PAGE_ADD_ENGINE_DIALOG_ENGINES_PROPERTY, keyboard_input_method_page_add_engine_dialog_properties[KEYBOARD_INPUT_METHOD_PAGE_ADD_ENGINE_DIALOG_ENGINES_PROPERTY] = g_param_spec_pointer ("engines", "engines", "engines", G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	keyboard_input_method_page_add_engine_dialog_signals[KEYBOARD_INPUT_METHOD_PAGE_ADD_ENGINE_DIALOG_ADD_ENGINE_SIGNAL] = g_signal_new ("add-engine", KEYBOARD_INPUT_METHOD_PAGE_TYPE_ADD_ENGINE_DIALOG, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
}

static void
keyboard_input_method_page_add_engine_dialog_instance_init (KeyboardInputMethodPageAddEngineDialog * self,
                                                            gpointer klass)
{
	self->priv = keyboard_input_method_page_add_engine_dialog_get_instance_private (self);
}

static void
keyboard_input_method_page_add_engine_dialog_finalize (GObject * obj)
{
	KeyboardInputMethodPageAddEngineDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, KEYBOARD_INPUT_METHOD_PAGE_TYPE_ADD_ENGINE_DIALOG, KeyboardInputMethodPageAddEngineDialog);
	_g_object_unref0 (self->priv->search_entry);
	_g_object_unref0 (self->priv->liststore);
	_g_object_unref0 (self->priv->listbox);
	G_OBJECT_CLASS (keyboard_input_method_page_add_engine_dialog_parent_class)->finalize (obj);
}

static GType
keyboard_input_method_page_add_engine_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (KeyboardInputMethodPageAddEngineDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) keyboard_input_method_page_add_engine_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (KeyboardInputMethodPageAddEngineDialog), 0, (GInstanceInitFunc) keyboard_input_method_page_add_engine_dialog_instance_init, NULL };
	GType keyboard_input_method_page_add_engine_dialog_type_id;
	keyboard_input_method_page_add_engine_dialog_type_id = g_type_register_static (GRANITE_TYPE_DIALOG, "KeyboardInputMethodPageAddEngineDialog", &g_define_type_info, 0);
	KeyboardInputMethodPageAddEngineDialog_private_offset = g_type_add_instance_private (keyboard_input_method_page_add_engine_dialog_type_id, sizeof (KeyboardInputMethodPageAddEngineDialogPrivate));
	return keyboard_input_method_page_add_engine_dialog_type_id;
}

GType
keyboard_input_method_page_add_engine_dialog_get_type (void)
{
	static volatile gsize keyboard_input_method_page_add_engine_dialog_type_id__once = 0;
	if (g_once_init_enter (&keyboard_input_method_page_add_engine_dialog_type_id__once)) {
		GType keyboard_input_method_page_add_engine_dialog_type_id;
		keyboard_input_method_page_add_engine_dialog_type_id = keyboard_input_method_page_add_engine_dialog_get_type_once ();
		g_once_init_leave (&keyboard_input_method_page_add_engine_dialog_type_id__once, keyboard_input_method_page_add_engine_dialog_type_id);
	}
	return keyboard_input_method_page_add_engine_dialog_type_id__once;
}

static void
_vala_keyboard_input_method_page_add_engine_dialog_get_property (GObject * object,
                                                                 guint property_id,
                                                                 GValue * value,
                                                                 GParamSpec * pspec)
{
	KeyboardInputMethodPageAddEngineDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, KEYBOARD_INPUT_METHOD_PAGE_TYPE_ADD_ENGINE_DIALOG, KeyboardInputMethodPageAddEngineDialog);
	switch (property_id) {
		case KEYBOARD_INPUT_METHOD_PAGE_ADD_ENGINE_DIALOG_ENGINES_PROPERTY:
		g_value_set_pointer (value, keyboard_input_method_page_add_engine_dialog_get_engines (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_keyboard_input_method_page_add_engine_dialog_set_property (GObject * object,
                                                                 guint property_id,
                                                                 const GValue * value,
                                                                 GParamSpec * pspec)
{
	KeyboardInputMethodPageAddEngineDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, KEYBOARD_INPUT_METHOD_PAGE_TYPE_ADD_ENGINE_DIALOG, KeyboardInputMethodPageAddEngineDialog);
	switch (property_id) {
		case KEYBOARD_INPUT_METHOD_PAGE_ADD_ENGINE_DIALOG_ENGINES_PROPERTY:
		keyboard_input_method_page_add_engine_dialog_set_engines (self, g_value_get_pointer (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

