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

/* Copyright 2011-2015 Switchboard Locale Plug Developers
*
* This program is free software: you can redistribute it
* and/or modify it under the terms of the GNU Lesser 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 http://www.gnu.org/licenses/.
*/

#include "locale-plug.h"
#include <gtk/gtk.h>
#include <gee.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <switchboard.h>
#include <gio/gio.h>
#include <glib/gi18n-lib.h>
#include <gmodule.h>

enum  {
	SWITCHBOARD_PLUG_LOCALE_PLUG_0_PROPERTY,
	SWITCHBOARD_PLUG_LOCALE_PLUG_NUM_PROPERTIES
};
static GParamSpec* switchboard_plug_locale_plug_properties[SWITCHBOARD_PLUG_LOCALE_PLUG_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_thread_unref0(var) ((var == NULL) ? NULL : (var = (g_thread_unref (var), NULL)))
typedef struct _SwitchboardPlugLocalePlugReloadData SwitchboardPlugLocalePlugReloadData;
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _SwitchboardPlugLocalePlugSearchData SwitchboardPlugLocalePlugSearchData;

struct _SwitchboardPlugLocalePlugPrivate {
	GtkGrid* grid;
	SwitchboardPlugLocaleWidgetsLocaleView* view;
	SwitchboardPlugLocaleInstallerUbuntuInstaller* installer;
	SwitchboardPlugLocaleProgressDialog* progress_dialog;
	GeeArrayList* langs;
};

struct _SwitchboardPlugLocalePlugReloadData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	SwitchboardPlugLocalePlug* self;
	GThread* _tmp0_;
	GThread* _tmp1_;
	SwitchboardPlugLocaleInstallerUbuntuInstaller* _tmp2_;
};

struct _SwitchboardPlugLocalePlugSearchData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	SwitchboardPlugLocalePlug* self;
	gchar* search;
	GeeTreeMap* result;
	GeeTreeMap* search_results;
	GCompareFunc _tmp0_;
	GEqualFunc _tmp1_;
	GeeTreeMap* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
};

static gint SwitchboardPlugLocalePlug_private_offset;
static gpointer switchboard_plug_locale_plug_parent_class = NULL;

static GtkWidget* switchboard_plug_locale_plug_real_get_widget (SwitchboardPlug* base);
static void switchboard_plug_locale_plug_setup_ui (SwitchboardPlugLocalePlug* self);
static void switchboard_plug_locale_plug_setup_info (SwitchboardPlugLocalePlug* self);
static void switchboard_plug_locale_plug_reload_data_free (gpointer _data);
static void switchboard_plug_locale_plug_reload (SwitchboardPlugLocalePlug* self,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_);
static void switchboard_plug_locale_plug_reload_finish (SwitchboardPlugLocalePlug* self,
                                                 GAsyncResult* _res_);
static gboolean switchboard_plug_locale_plug_reload_co (SwitchboardPlugLocalePlugReloadData* _data_);
static void* __lambda30_ (SwitchboardPlugLocalePlug* self);
static gboolean __lambda31_ (SwitchboardPlugLocalePlug* self);
static gboolean ___lambda31__gsource_func (gpointer self);
static gpointer ___lambda30__gthread_func (gpointer self);
static void switchboard_plug_locale_plug_reload_ready (GObject* source_object,
                                                GAsyncResult* _res_,
                                                gpointer _user_data_);
static void __lambda32_ (SwitchboardPlugLocalePlug* self,
                  const gchar* langcode);
static void ___lambda32__switchboard_plug_locale_installer_ubuntu_installer_install_finished (SwitchboardPlugLocaleInstallerUbuntuInstaller* _sender,
                                                                                       const gchar* langcode,
                                                                                       gpointer self);
static void __lambda33_ (SwitchboardPlugLocalePlug* self,
                  const gchar* langcode);
static void ___lambda33__switchboard_plug_locale_installer_ubuntu_installer_remove_finished (SwitchboardPlugLocaleInstallerUbuntuInstaller* _sender,
                                                                                      const gchar* langcode,
                                                                                      gpointer self);
static void switchboard_plug_locale_plug_on_check_missing_finished (SwitchboardPlugLocalePlug* self,
                                                             gchar** missing,
                                                             gint missing_length1);
static void _switchboard_plug_locale_plug_on_check_missing_finished_switchboard_plug_locale_installer_ubuntu_installer_check_missing_finished (SwitchboardPlugLocaleInstallerUbuntuInstaller* _sender,
                                                                                                                                        gchar** missing,
                                                                                                                                        gint missing_length1,
                                                                                                                                        gpointer self);
static void switchboard_plug_locale_plug_on_progress_changed (SwitchboardPlugLocalePlug* self,
                                                       gint progress);
static void _switchboard_plug_locale_plug_on_progress_changed_switchboard_plug_locale_installer_ubuntu_installer_progress_changed (SwitchboardPlugLocaleInstallerUbuntuInstaller* _sender,
                                                                                                                            gint progress,
                                                                                                                            gpointer self);
static void switchboard_plug_locale_plug_real_shown (SwitchboardPlug* base);
static void switchboard_plug_locale_plug_real_hidden (SwitchboardPlug* base);
static void switchboard_plug_locale_plug_real_search_callback (SwitchboardPlug* base,
                                                        const gchar* location);
static void switchboard_plug_locale_plug_real_search_data_free (gpointer _data);
static void switchboard_plug_locale_plug_real_search (SwitchboardPlug* base,
                                               const gchar* search,
                                               GAsyncReadyCallback _callback_,
                                               gpointer _user_data_);
static gboolean switchboard_plug_locale_plug_real_search_co (SwitchboardPlugLocalePlugSearchData* _data_);
static void __lambda29_ (SwitchboardPlugLocalePlug* self);
static void ___lambda29__gtk_info_bar_response (GtkInfoBar* _sender,
                                         gint response_id,
                                         gpointer self);
static void switchboard_plug_locale_plug_finalize (GObject * obj);
static GType switchboard_plug_locale_plug_get_type_once (void);

static inline gpointer
switchboard_plug_locale_plug_get_instance_private (SwitchboardPlugLocalePlug* self)
{
	return G_STRUCT_MEMBER_P (self, SwitchboardPlugLocalePlug_private_offset);
}

SwitchboardPlugLocalePlug*
switchboard_plug_locale_plug_construct (GType object_type)
{
	SwitchboardPlugLocalePlug * self = NULL;
	GeeTreeMap* settings = NULL;
	GeeTreeMap* _tmp0_;
	bindtextdomain (CONSTANTS_GETTEXT_PACKAGE, CONSTANTS_LOCALEDIR);
	bind_textdomain_codeset (CONSTANTS_GETTEXT_PACKAGE, "UTF-8");
	_tmp0_ = gee_tree_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL, NULL, NULL, NULL);
	settings = _tmp0_;
	gee_abstract_map_set ((GeeAbstractMap*) settings, "language", NULL);
	self = (SwitchboardPlugLocalePlug*) g_object_new (object_type, "category", SWITCHBOARD_PLUG_CATEGORY_PERSONAL, "code-name", "io.elementary.switchboard.locale", "display-name", _ ("Language & Region"), "description", _ ("Manage languages, and configure region and format"), "icon", "preferences-desktop-locale", "supported-settings", settings, NULL);
	_g_object_unref0 (settings);
	return self;
}

SwitchboardPlugLocalePlug*
switchboard_plug_locale_plug_new (void)
{
	return switchboard_plug_locale_plug_construct (SWITCHBOARD_PLUG_LOCALE_TYPE_PLUG);
}

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

static GtkWidget*
switchboard_plug_locale_plug_real_get_widget (SwitchboardPlug* base)
{
	SwitchboardPlugLocalePlug * self;
	GtkGrid* _tmp0_;
	GtkGrid* _tmp3_;
	GtkWidget* _tmp4_;
	GtkWidget* result;
	self = (SwitchboardPlugLocalePlug*) base;
	_tmp0_ = self->priv->grid;
	if (_tmp0_ == NULL) {
		SwitchboardPlugLocaleInstallerUbuntuInstaller* _tmp1_;
		SwitchboardPlugLocaleInstallerUbuntuInstaller* _tmp2_;
		switchboard_plug_locale_utils_init ();
		_tmp1_ = switchboard_plug_locale_installer_ubuntu_installer_get_default ();
		_tmp2_ = _g_object_ref0 (_tmp1_);
		_g_object_unref0 (self->priv->installer);
		self->priv->installer = _tmp2_;
		switchboard_plug_locale_plug_setup_ui (self);
		switchboard_plug_locale_plug_setup_info (self);
	}
	_tmp3_ = self->priv->grid;
	_tmp4_ = _g_object_ref0 ((GtkWidget*) _tmp3_);
	result = _tmp4_;
	return result;
}

static void
switchboard_plug_locale_plug_reload_data_free (gpointer _data)
{
	SwitchboardPlugLocalePlugReloadData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (SwitchboardPlugLocalePlugReloadData, _data_);
}

static void
switchboard_plug_locale_plug_reload (SwitchboardPlugLocalePlug* self,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_)
{
	SwitchboardPlugLocalePlugReloadData* _data_;
	SwitchboardPlugLocalePlug* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (SwitchboardPlugLocalePlugReloadData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, switchboard_plug_locale_plug_reload_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	switchboard_plug_locale_plug_reload_co (_data_);
}

static void
switchboard_plug_locale_plug_reload_finish (SwitchboardPlugLocalePlug* self,
                                            GAsyncResult* _res_)
{
	SwitchboardPlugLocalePlugReloadData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static gboolean
__lambda31_ (SwitchboardPlugLocalePlug* self)
{
	SwitchboardPlugLocaleWidgetsLocaleView* _tmp0_;
	SwitchboardPlugLocaleWidgetsLanguageListBox* _tmp1_;
	GeeArrayList* _tmp2_;
	SwitchboardPlugLocaleWidgetsLocaleView* _tmp3_;
	SwitchboardPlugLocaleWidgetsLocaleSetting* _tmp4_;
	GeeArrayList* _tmp5_;
	gboolean result;
	_tmp0_ = self->priv->view;
	_tmp1_ = _tmp0_->list_box;
	_tmp2_ = self->priv->langs;
	switchboard_plug_locale_widgets_language_list_box_reload_languages (_tmp1_, _tmp2_);
	_tmp3_ = self->priv->view;
	_tmp4_ = _tmp3_->locale_setting;
	_tmp5_ = self->priv->langs;
	switchboard_plug_locale_widgets_locale_setting_reload_formats (_tmp4_, _tmp5_);
	result = FALSE;
	return result;
}

static gboolean
___lambda31__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda31_ ((SwitchboardPlugLocalePlug*) self);
	return result;
}

static void*
__lambda30_ (SwitchboardPlugLocalePlug* self)
{
	GeeArrayList* _tmp0_;
	void* result;
	_tmp0_ = switchboard_plug_locale_utils_get_installed_languages ();
	_g_object_unref0 (self->priv->langs);
	self->priv->langs = _tmp0_;
	g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, ___lambda31__gsource_func, g_object_ref (self), g_object_unref);
	result = NULL;
	return result;
}

static gpointer
___lambda30__gthread_func (gpointer self)
{
	gpointer result;
	result = __lambda30_ ((SwitchboardPlugLocalePlug*) self);
	g_object_unref (self);
	return result;
}

static void
switchboard_plug_locale_plug_reload_ready (GObject* source_object,
                                           GAsyncResult* _res_,
                                           gpointer _user_data_)
{
	SwitchboardPlugLocalePlugReloadData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	switchboard_plug_locale_plug_reload_co (_data_);
}

static gboolean
switchboard_plug_locale_plug_reload_co (SwitchboardPlugLocalePlugReloadData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = g_thread_new ("load-lang-data", ___lambda30__gthread_func, g_object_ref (_data_->self));
	_data_->_tmp1_ = _data_->_tmp0_;
	_g_thread_unref0 (_data_->_tmp1_);
	_data_->_tmp2_ = _data_->self->priv->installer;
	_data_->_state_ = 1;
	switchboard_plug_locale_installer_ubuntu_installer_check_missing_languages (_data_->_tmp2_, switchboard_plug_locale_plug_reload_ready, _data_);
	return FALSE;
	_state_1:
	switchboard_plug_locale_installer_ubuntu_installer_check_missing_languages_finish (_data_->_tmp2_, _data_->_res_);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
__lambda32_ (SwitchboardPlugLocalePlug* self,
             const gchar* langcode)
{
	g_return_if_fail (langcode != NULL);
	switchboard_plug_locale_plug_reload (self, NULL, NULL);
}

static void
___lambda32__switchboard_plug_locale_installer_ubuntu_installer_install_finished (SwitchboardPlugLocaleInstallerUbuntuInstaller* _sender,
                                                                                  const gchar* langcode,
                                                                                  gpointer self)
{
	__lambda32_ ((SwitchboardPlugLocalePlug*) self, langcode);
}

static void
__lambda33_ (SwitchboardPlugLocalePlug* self,
             const gchar* langcode)
{
	g_return_if_fail (langcode != NULL);
	switchboard_plug_locale_plug_reload (self, NULL, NULL);
}

static void
___lambda33__switchboard_plug_locale_installer_ubuntu_installer_remove_finished (SwitchboardPlugLocaleInstallerUbuntuInstaller* _sender,
                                                                                 const gchar* langcode,
                                                                                 gpointer self)
{
	__lambda33_ ((SwitchboardPlugLocalePlug*) self, langcode);
}

static void
_switchboard_plug_locale_plug_on_check_missing_finished_switchboard_plug_locale_installer_ubuntu_installer_check_missing_finished (SwitchboardPlugLocaleInstallerUbuntuInstaller* _sender,
                                                                                                                                   gchar** missing,
                                                                                                                                   gint missing_length1,
                                                                                                                                   gpointer self)
{
	switchboard_plug_locale_plug_on_check_missing_finished ((SwitchboardPlugLocalePlug*) self, missing, missing_length1);
}

static void
_switchboard_plug_locale_plug_on_progress_changed_switchboard_plug_locale_installer_ubuntu_installer_progress_changed (SwitchboardPlugLocaleInstallerUbuntuInstaller* _sender,
                                                                                                                       gint progress,
                                                                                                                       gpointer self)
{
	switchboard_plug_locale_plug_on_progress_changed ((SwitchboardPlugLocalePlug*) self, progress);
}

static void
switchboard_plug_locale_plug_setup_info (SwitchboardPlugLocalePlug* self)
{
	SwitchboardPlugLocaleLocaleManager* lm = NULL;
	SwitchboardPlugLocaleLocaleManager* _tmp0_;
	SwitchboardPlugLocaleLocaleManager* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	SwitchboardPlugLocaleInstallerUbuntuInstaller* _tmp5_;
	SwitchboardPlugLocaleInstallerUbuntuInstaller* _tmp6_;
	SwitchboardPlugLocaleInstallerUbuntuInstaller* _tmp7_;
	SwitchboardPlugLocaleInstallerUbuntuInstaller* _tmp8_;
	g_return_if_fail (self != NULL);
	_tmp0_ = switchboard_plug_locale_locale_manager_get_default ();
	lm = _tmp0_;
	_tmp1_ = lm;
	_tmp2_ = switchboard_plug_locale_locale_manager_get_is_connected (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_) {
		GtkInfoBar* _tmp4_;
		switchboard_plug_locale_plug_reload (self, NULL, NULL);
		_tmp4_ = self->infobar;
		gtk_info_bar_set_revealed (_tmp4_, FALSE);
	}
	_tmp5_ = self->priv->installer;
	g_signal_connect_object (_tmp5_, "install-finished", (GCallback) ___lambda32__switchboard_plug_locale_installer_ubuntu_installer_install_finished, self, 0);
	_tmp6_ = self->priv->installer;
	g_signal_connect_object (_tmp6_, "remove-finished", (GCallback) ___lambda33__switchboard_plug_locale_installer_ubuntu_installer_remove_finished, self, 0);
	_tmp7_ = self->priv->installer;
	g_signal_connect_object (_tmp7_, "check-missing-finished", (GCallback) _switchboard_plug_locale_plug_on_check_missing_finished_switchboard_plug_locale_installer_ubuntu_installer_check_missing_finished, self, 0);
	_tmp8_ = self->priv->installer;
	g_signal_connect_object (_tmp8_, "progress-changed", (GCallback) _switchboard_plug_locale_plug_on_progress_changed_switchboard_plug_locale_installer_ubuntu_installer_progress_changed, self, 0);
}

static void
switchboard_plug_locale_plug_real_shown (SwitchboardPlug* base)
{
	SwitchboardPlugLocalePlug * self;
	self = (SwitchboardPlugLocalePlug*) base;
}

static void
switchboard_plug_locale_plug_real_hidden (SwitchboardPlug* base)
{
	SwitchboardPlugLocalePlug * self;
	self = (SwitchboardPlugLocalePlug*) base;
}

static void
switchboard_plug_locale_plug_real_search_callback (SwitchboardPlug* base,
                                                   const gchar* location)
{
	SwitchboardPlugLocalePlug * self;
	self = (SwitchboardPlugLocalePlug*) base;
	g_return_if_fail (location != NULL);
}

static void
switchboard_plug_locale_plug_real_search_data_free (gpointer _data)
{
	SwitchboardPlugLocalePlugSearchData* _data_;
	_data_ = _data;
	_g_free0 (_data_->search);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (SwitchboardPlugLocalePlugSearchData, _data_);
}

static void
switchboard_plug_locale_plug_real_search (SwitchboardPlug* base,
                                          const gchar* search,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_)
{
	SwitchboardPlugLocalePlug * self;
	SwitchboardPlugLocalePlugSearchData* _data_;
	SwitchboardPlugLocalePlug* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (search != NULL);
	self = (SwitchboardPlugLocalePlug*) base;
	_data_ = g_slice_new0 (SwitchboardPlugLocalePlugSearchData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, switchboard_plug_locale_plug_real_search_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (search);
	_g_free0 (_data_->search);
	_data_->search = _tmp1_;
	switchboard_plug_locale_plug_real_search_co (_data_);
}

static GeeTreeMap*
switchboard_plug_locale_plug_search_finish (SwitchboardPlug* base,
                                            GAsyncResult* _res_)
{
	GeeTreeMap* result;
	SwitchboardPlugLocalePlugSearchData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static gboolean
switchboard_plug_locale_plug_real_search_co (SwitchboardPlugLocalePlugSearchData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = ((GCompareFunc) g_strcmp0);
	_data_->_tmp1_ = g_str_equal;
	_data_->_tmp2_ = gee_tree_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, (GCompareDataFunc) _data_->_tmp0_, NULL, NULL, (GeeEqualDataFunc) _data_->_tmp1_, NULL, NULL);
	_data_->search_results = _data_->_tmp2_;
	_data_->_tmp3_ = switchboard_plug_get_display_name ((SwitchboardPlug*) _data_->self);
	_data_->_tmp4_ = _data_->_tmp3_;
	_data_->_tmp5_ = g_strdup_printf ("%s → %s", _data_->_tmp4_, _ ("Region"));
	_data_->_tmp6_ = _data_->_tmp5_;
	gee_abstract_map_set ((GeeAbstractMap*) _data_->search_results, _data_->_tmp6_, "");
	_g_free0 (_data_->_tmp6_);
	_data_->_tmp7_ = switchboard_plug_get_display_name ((SwitchboardPlug*) _data_->self);
	_data_->_tmp8_ = _data_->_tmp7_;
	_data_->_tmp9_ = g_strdup_printf ("%s → %s", _data_->_tmp8_, _ ("Formats"));
	_data_->_tmp10_ = _data_->_tmp9_;
	gee_abstract_map_set ((GeeAbstractMap*) _data_->search_results, _data_->_tmp10_, "");
	_g_free0 (_data_->_tmp10_);
	_data_->_tmp11_ = switchboard_plug_get_display_name ((SwitchboardPlug*) _data_->self);
	_data_->_tmp12_ = _data_->_tmp11_;
	_data_->_tmp13_ = g_strdup_printf ("%s → %s", _data_->_tmp12_, _ ("Temperature"));
	_data_->_tmp14_ = _data_->_tmp13_;
	gee_abstract_map_set ((GeeAbstractMap*) _data_->search_results, _data_->_tmp14_, "");
	_g_free0 (_data_->_tmp14_);
	_data_->result = _data_->search_results;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
__lambda29_ (SwitchboardPlugLocalePlug* self)
{
	GtkInfoBar* _tmp0_;
	SwitchboardPlugLocaleInstallerUbuntuInstaller* _tmp1_;
	_tmp0_ = self->missing_lang_infobar;
	gtk_info_bar_set_revealed (_tmp0_, FALSE);
	_tmp1_ = self->priv->installer;
	switchboard_plug_locale_installer_ubuntu_installer_install_missing_languages (_tmp1_);
}

static void
___lambda29__gtk_info_bar_response (GtkInfoBar* _sender,
                                    gint response_id,
                                    gpointer self)
{
	__lambda29_ ((SwitchboardPlugLocalePlug*) self);
}

static void
switchboard_plug_locale_plug_setup_ui (SwitchboardPlugLocalePlug* self)
{
	GtkLabel* label = NULL;
	GtkLabel* _tmp0_;
	GtkInfoBar* _tmp1_;
	GtkInfoBar* _tmp2_;
	GtkInfoBar* _tmp3_;
	GtkInfoBar* _tmp4_;
	GtkContainer* _tmp5_;
	GtkLabel* missing_label = NULL;
	GtkLabel* _tmp6_;
	GtkInfoBar* _tmp7_;
	GtkInfoBar* _tmp8_;
	GtkInfoBar* _tmp9_;
	GtkInfoBar* _tmp10_;
	GtkInfoBar* _tmp11_;
	GtkContainer* _tmp12_;
	SwitchboardPlugLocaleWidgetsLocaleView* _tmp13_;
	GtkGrid* _tmp14_;
	GtkGrid* _tmp15_;
	GtkGrid* _tmp16_;
	GtkInfoBar* _tmp17_;
	GtkGrid* _tmp18_;
	GtkInfoBar* _tmp19_;
	GtkGrid* _tmp20_;
	SwitchboardPlugLocaleWidgetsLocaleView* _tmp21_;
	GtkGrid* _tmp22_;
	GtkInfoBar* _tmp23_;
	g_return_if_fail (self != NULL);
	_tmp0_ = (GtkLabel*) gtk_label_new (_ ("Some changes will not take effect until you log out"));
	g_object_ref_sink (_tmp0_);
	label = _tmp0_;
	_tmp1_ = (GtkInfoBar*) gtk_info_bar_new ();
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->infobar);
	self->infobar = _tmp1_;
	_tmp2_ = self->infobar;
	gtk_info_bar_set_message_type (_tmp2_, GTK_MESSAGE_WARNING);
	_tmp3_ = self->infobar;
	gtk_info_bar_set_revealed (_tmp3_, FALSE);
	_tmp4_ = self->infobar;
	_tmp5_ = gtk_info_bar_get_content_area (_tmp4_);
	gtk_container_add (_tmp5_, (GtkWidget*) label);
	_tmp6_ = (GtkLabel*) gtk_label_new (_ ("Language support is not installed completely"));
	g_object_ref_sink (_tmp6_);
	missing_label = _tmp6_;
	_tmp7_ = (GtkInfoBar*) gtk_info_bar_new ();
	g_object_ref_sink (_tmp7_);
	_g_object_unref0 (self->missing_lang_infobar);
	self->missing_lang_infobar = _tmp7_;
	_tmp8_ = self->missing_lang_infobar;
	gtk_info_bar_set_message_type (_tmp8_, GTK_MESSAGE_WARNING);
	_tmp9_ = self->missing_lang_infobar;
	gtk_info_bar_set_revealed (_tmp9_, FALSE);
	_tmp10_ = self->missing_lang_infobar;
	gtk_info_bar_add_button (_tmp10_, _ ("Complete Installation"), 0);
	_tmp11_ = self->missing_lang_infobar;
	_tmp12_ = gtk_info_bar_get_content_area (_tmp11_);
	gtk_container_add (_tmp12_, (GtkWidget*) missing_label);
	_tmp13_ = switchboard_plug_locale_widgets_locale_view_new (self);
	g_object_ref_sink (_tmp13_);
	_g_object_unref0 (self->priv->view);
	self->priv->view = _tmp13_;
	_tmp14_ = (GtkGrid*) gtk_grid_new ();
	g_object_ref_sink (_tmp14_);
	_g_object_unref0 (self->priv->grid);
	self->priv->grid = _tmp14_;
	_tmp15_ = self->priv->grid;
	gtk_orientable_set_orientation ((GtkOrientable*) _tmp15_, GTK_ORIENTATION_VERTICAL);
	_tmp16_ = self->priv->grid;
	_tmp17_ = self->infobar;
	gtk_container_add ((GtkContainer*) _tmp16_, (GtkWidget*) _tmp17_);
	_tmp18_ = self->priv->grid;
	_tmp19_ = self->missing_lang_infobar;
	gtk_container_add ((GtkContainer*) _tmp18_, (GtkWidget*) _tmp19_);
	_tmp20_ = self->priv->grid;
	_tmp21_ = self->priv->view;
	gtk_container_add ((GtkContainer*) _tmp20_, (GtkWidget*) _tmp21_);
	_tmp22_ = self->priv->grid;
	gtk_widget_show ((GtkWidget*) _tmp22_);
	_tmp23_ = self->missing_lang_infobar;
	g_signal_connect_object (_tmp23_, "response", (GCallback) ___lambda29__gtk_info_bar_response, self, 0);
	_g_object_unref0 (missing_label);
	_g_object_unref0 (label);
}

static void
switchboard_plug_locale_plug_on_check_missing_finished (SwitchboardPlugLocalePlug* self,
                                                        gchar** missing,
                                                        gint missing_length1)
{
	g_return_if_fail (self != NULL);
	if (missing_length1 > 0) {
		GtkInfoBar* _tmp0_;
		GtkInfoBar* _tmp1_;
		_tmp0_ = self->missing_lang_infobar;
		gtk_widget_show_all ((GtkWidget*) _tmp0_);
		_tmp1_ = self->missing_lang_infobar;
		gtk_info_bar_set_revealed (_tmp1_, TRUE);
	} else {
		GtkInfoBar* _tmp2_;
		_tmp2_ = self->missing_lang_infobar;
		gtk_info_bar_set_revealed (_tmp2_, FALSE);
	}
}

static void
switchboard_plug_locale_plug_on_progress_changed (SwitchboardPlugLocalePlug* self,
                                                  gint progress)
{
	SwitchboardPlugLocaleProgressDialog* _tmp0_;
	SwitchboardPlugLocaleProgressDialog* _tmp2_;
	SwitchboardPlugLocaleProgressDialog* _tmp3_;
	SwitchboardPlugLocaleProgressDialog* _tmp4_;
	GtkGrid* _tmp5_;
	GtkWidget* _tmp6_;
	SwitchboardPlugLocaleProgressDialog* _tmp7_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->progress_dialog;
	if (_tmp0_ != NULL) {
		SwitchboardPlugLocaleProgressDialog* _tmp1_;
		_tmp1_ = self->priv->progress_dialog;
		switchboard_plug_locale_progress_dialog_set_progress (_tmp1_, progress);
		return;
	}
	_tmp2_ = switchboard_plug_locale_progress_dialog_new ();
	g_object_ref_sink (_tmp2_);
	_g_object_unref0 (self->priv->progress_dialog);
	self->priv->progress_dialog = _tmp2_;
	_tmp3_ = self->priv->progress_dialog;
	switchboard_plug_locale_progress_dialog_set_progress (_tmp3_, progress);
	_tmp4_ = self->priv->progress_dialog;
	_tmp5_ = self->priv->grid;
	_tmp6_ = gtk_widget_get_toplevel ((GtkWidget*) _tmp5_);
	gtk_window_set_transient_for ((GtkWindow*) _tmp4_, G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, gtk_window_get_type (), GtkWindow));
	_tmp7_ = self->priv->progress_dialog;
	gtk_dialog_run ((GtkDialog*) _tmp7_);
	_g_object_unref0 (self->priv->progress_dialog);
	self->priv->progress_dialog = NULL;
}

static void
switchboard_plug_locale_plug_class_init (SwitchboardPlugLocalePlugClass * klass,
                                         gpointer klass_data)
{
	switchboard_plug_locale_plug_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &SwitchboardPlugLocalePlug_private_offset);
	((SwitchboardPlugClass *) klass)->get_widget = (GtkWidget* (*) (SwitchboardPlug*)) switchboard_plug_locale_plug_real_get_widget;
	((SwitchboardPlugClass *) klass)->shown = (void (*) (SwitchboardPlug*)) switchboard_plug_locale_plug_real_shown;
	((SwitchboardPlugClass *) klass)->hidden = (void (*) (SwitchboardPlug*)) switchboard_plug_locale_plug_real_hidden;
	((SwitchboardPlugClass *) klass)->search_callback = (void (*) (SwitchboardPlug*, const gchar*)) switchboard_plug_locale_plug_real_search_callback;
	((SwitchboardPlugClass *) klass)->search = (void (*) (SwitchboardPlug*, const gchar*, GAsyncReadyCallback, gpointer)) switchboard_plug_locale_plug_real_search;
	((SwitchboardPlugClass *) klass)->search_finish = (GeeTreeMap* (*) (SwitchboardPlug*, GAsyncResult*)) switchboard_plug_locale_plug_search_finish;
	G_OBJECT_CLASS (klass)->finalize = switchboard_plug_locale_plug_finalize;
}

static void
switchboard_plug_locale_plug_instance_init (SwitchboardPlugLocalePlug * self,
                                            gpointer klass)
{
	self->priv = switchboard_plug_locale_plug_get_instance_private (self);
	self->priv->progress_dialog = NULL;
}

static void
switchboard_plug_locale_plug_finalize (GObject * obj)
{
	SwitchboardPlugLocalePlug * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SWITCHBOARD_PLUG_LOCALE_TYPE_PLUG, SwitchboardPlugLocalePlug);
	_g_object_unref0 (self->priv->grid);
	_g_object_unref0 (self->priv->view);
	_g_object_unref0 (self->infobar);
	_g_object_unref0 (self->permission_infobar);
	_g_object_unref0 (self->missing_lang_infobar);
	_g_object_unref0 (self->priv->installer);
	_g_object_unref0 (self->priv->progress_dialog);
	_g_object_unref0 (self->priv->langs);
	G_OBJECT_CLASS (switchboard_plug_locale_plug_parent_class)->finalize (obj);
}

static GType
switchboard_plug_locale_plug_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SwitchboardPlugLocalePlugClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) switchboard_plug_locale_plug_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SwitchboardPlugLocalePlug), 0, (GInstanceInitFunc) switchboard_plug_locale_plug_instance_init, NULL };
	GType switchboard_plug_locale_plug_type_id;
	switchboard_plug_locale_plug_type_id = g_type_register_static (SWITCHBOARD_TYPE_PLUG, "SwitchboardPlugLocalePlug", &g_define_type_info, 0);
	SwitchboardPlugLocalePlug_private_offset = g_type_add_instance_private (switchboard_plug_locale_plug_type_id, sizeof (SwitchboardPlugLocalePlugPrivate));
	return switchboard_plug_locale_plug_type_id;
}

GType
switchboard_plug_locale_plug_get_type (void)
{
	static volatile gsize switchboard_plug_locale_plug_type_id__once = 0;
	if (g_once_init_enter (&switchboard_plug_locale_plug_type_id__once)) {
		GType switchboard_plug_locale_plug_type_id;
		switchboard_plug_locale_plug_type_id = switchboard_plug_locale_plug_get_type_once ();
		g_once_init_leave (&switchboard_plug_locale_plug_type_id__once, switchboard_plug_locale_plug_type_id);
	}
	return switchboard_plug_locale_plug_type_id__once;
}

SwitchboardPlug*
get_plug (GModule* module)
{
	SwitchboardPlugLocalePlug* plug = NULL;
	SwitchboardPlugLocalePlug* _tmp0_;
	SwitchboardPlug* result;
	g_return_val_if_fail (module != NULL, NULL);
	g_debug ("Plug.vala:176: Activating Locale plug");
	_tmp0_ = switchboard_plug_locale_plug_new ();
	plug = _tmp0_;
	result = (SwitchboardPlug*) plug;
	return result;
}

