/* Plug.c generated by valac 0.56.18-dirty, 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 "io.elementary.settings.locale.h"
#include <switchboard.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gio/gio.h>
#include <gee.h>
#include <glib-object.h>
#include <glib/gi18n-lib.h>
#include <gmodule.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  {
	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_free0(var) (var = (g_free (var), NULL))
typedef struct _SwitchboardPlugLocalePlugSearchData SwitchboardPlugLocalePlugSearchData;

struct _SwitchboardPlugLocalePlugPrivate {
	SwitchboardPlugLocaleWidgetsLocaleView* view;
};

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_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 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.settings.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;
	SwitchboardPlugLocaleWidgetsLocaleView* _tmp0_;
	SwitchboardPlugLocaleWidgetsLocaleView* _tmp2_;
	GtkWidget* _tmp3_;
	GtkWidget* result;
	self = (SwitchboardPlugLocalePlug*) base;
	_tmp0_ = self->priv->view;
	if (_tmp0_ == NULL) {
		SwitchboardPlugLocaleWidgetsLocaleView* _tmp1_;
		switchboard_plug_locale_utils_init ();
		_tmp1_ = switchboard_plug_locale_widgets_locale_view_new ();
		g_object_ref_sink (_tmp1_);
		_g_object_unref0 (self->priv->view);
		self->priv->view = _tmp1_;
	}
	_tmp2_ = self->priv->view;
	_tmp3_ = _g_object_ref0 ((GtkWidget*) _tmp2_);
	result = _tmp3_;
	return result;
}

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

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->view);
	G_OBJECT_CLASS (switchboard_plug_locale_plug_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE 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 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:72: Activating Locale plug");
	_tmp0_ = switchboard_plug_locale_plug_new ();
	plug = _tmp0_;
	result = (SwitchboardPlug*) plug;
	return result;
}

