/* PlugsSearch.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from PlugsSearch.vala, do not modify */

/*
* Copyright (c) 2015-2017 elementary LLC (https://elementary.io)
*
* 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 2.1 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, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* Authored by: Kay van der Zander <kay20@hotmail.com>
*/

#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gee.h>
#include <gio/gio.h>
#include "switchboard.h"
#include <gobject/gvaluecollector.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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define SWITCHBOARD_TYPE_SEARCH_ENTRY (switchboard_search_entry_get_type ())
typedef struct _SwitchboardSearchEntry SwitchboardSearchEntry;
#define _g_free0(var) (var = (g_free (var), NULL))

#define SWITCHBOARD_TYPE_PLUGS_SEARCH (switchboard_plugs_search_get_type ())
#define SWITCHBOARD_PLUGS_SEARCH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWITCHBOARD_TYPE_PLUGS_SEARCH, SwitchboardPlugsSearch))
#define SWITCHBOARD_PLUGS_SEARCH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWITCHBOARD_TYPE_PLUGS_SEARCH, SwitchboardPlugsSearchClass))
#define SWITCHBOARD_IS_PLUGS_SEARCH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWITCHBOARD_TYPE_PLUGS_SEARCH))
#define SWITCHBOARD_IS_PLUGS_SEARCH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWITCHBOARD_TYPE_PLUGS_SEARCH))
#define SWITCHBOARD_PLUGS_SEARCH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWITCHBOARD_TYPE_PLUGS_SEARCH, SwitchboardPlugsSearchClass))

typedef struct _SwitchboardPlugsSearch SwitchboardPlugsSearch;
typedef struct _SwitchboardPlugsSearchClass SwitchboardPlugsSearchClass;
typedef struct _SwitchboardPlugsSearchPrivate SwitchboardPlugsSearchPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _switchboard_plugs_search_unref0(var) ((var == NULL) ? NULL : (var = (switchboard_plugs_search_unref (var), NULL)))
typedef struct _SwitchboardPlugsSearchCacheSearchEntriesData SwitchboardPlugsSearchCacheSearchEntriesData;
typedef struct _SwitchboardParamSpecPlugsSearch SwitchboardParamSpecPlugsSearch;

struct _SwitchboardSearchEntry {
	gchar* plug_name;
	gchar* ui_elements;
	gchar* open_window;
};

struct _SwitchboardPlugsSearch {
	GTypeInstance parent_instance;
	volatile int ref_count;
	SwitchboardPlugsSearchPrivate * priv;
	GeeArrayList* search_entries;
};

struct _SwitchboardPlugsSearchClass {
	GTypeClass parent_class;
	void (*finalize) (SwitchboardPlugsSearch *self);
};

struct _SwitchboardPlugsSearchPrivate {
	gboolean _ready;
};

struct _SwitchboardPlugsSearchCacheSearchEntriesData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	SwitchboardPlugsSearch* self;
	SwitchboardPlugsManager* plugsmanager;
	SwitchboardPlugsManager* _tmp0_;
	GeeIterator* _plug_it;
	SwitchboardPlugsManager* _tmp1_;
	GeeCollection* _tmp2_;
	GeeCollection* _tmp3_;
	GeeIterator* _tmp4_;
	GeeIterator* _tmp5_;
	GeeIterator* _tmp6_;
	SwitchboardPlug* plug;
	GeeIterator* _tmp7_;
	gpointer _tmp8_;
	GeeTreeMap* tmp_entries;
	SwitchboardPlug* _tmp9_;
	GeeTreeMap* _tmp10_;
	GeeIterator* _entry_it;
	GeeTreeMap* _tmp11_;
	GeeSet* _tmp12_;
	GeeSet* _tmp13_;
	GeeSet* _tmp14_;
	GeeIterator* _tmp15_;
	GeeIterator* _tmp16_;
	GeeIterator* _tmp17_;
	GeeMapEntry* entry;
	GeeIterator* _tmp18_;
	gpointer _tmp19_;
	gchar** tmp;
	GeeMapEntry* _tmp20_;
	gconstpointer _tmp21_;
	gconstpointer _tmp22_;
	gchar** _tmp23_;
	gchar** _tmp24_;
	gint tmp_length1;
	gint _tmp_size_;
	SwitchboardSearchEntry tmp_entry;
	gchar** _tmp25_;
	gint _tmp25__length1;
	const gchar* _tmp26_;
	gchar* _tmp27_;
	gchar* ui_elements_name;
	GeeMapEntry* _tmp28_;
	gconstpointer _tmp29_;
	gconstpointer _tmp30_;
	gchar* _tmp31_;
	const gchar* _tmp32_;
	gchar* _tmp33_;
	GeeMapEntry* _tmp34_;
	gconstpointer _tmp35_;
	gconstpointer _tmp36_;
	gchar* _tmp37_;
	GeeArrayList* _tmp38_;
	SwitchboardSearchEntry _tmp39_;
	SwitchboardSearchEntry _tmp40_;
	const gchar* _tmp41_;
	SwitchboardSearchEntry _tmp42_;
	const gchar* _tmp43_;
	SwitchboardSearchEntry _tmp44_;
	const gchar* _tmp45_;
};

struct _SwitchboardParamSpecPlugsSearch {
	GParamSpec parent_instance;
};

static gint SwitchboardPlugsSearch_private_offset;
static gpointer switchboard_plugs_search_parent_class = NULL;

VALA_EXTERN GType switchboard_search_entry_get_type (void) G_GNUC_CONST ;
VALA_EXTERN SwitchboardSearchEntry* switchboard_search_entry_dup (const SwitchboardSearchEntry* self);
VALA_EXTERN void switchboard_search_entry_free (SwitchboardSearchEntry* self);
VALA_EXTERN void switchboard_search_entry_copy (const SwitchboardSearchEntry* self,
                                    SwitchboardSearchEntry* dest);
VALA_EXTERN void switchboard_search_entry_destroy (SwitchboardSearchEntry* self);
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (SwitchboardSearchEntry, switchboard_search_entry_destroy)
VALA_EXTERN gpointer switchboard_plugs_search_ref (gpointer instance);
VALA_EXTERN void switchboard_plugs_search_unref (gpointer instance);
VALA_EXTERN GParamSpec* switchboard_param_spec_plugs_search (const gchar* name,
                                                 const gchar* nick,
                                                 const gchar* blurb,
                                                 GType object_type,
                                                 GParamFlags flags);
VALA_EXTERN void switchboard_value_set_plugs_search (GValue* value,
                                         gpointer v_object);
VALA_EXTERN void switchboard_value_take_plugs_search (GValue* value,
                                          gpointer v_object);
VALA_EXTERN gpointer switchboard_value_get_plugs_search (const GValue* value);
VALA_EXTERN GType switchboard_plugs_search_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SwitchboardPlugsSearch, switchboard_plugs_search_unref)
VALA_EXTERN SwitchboardPlugsSearch* switchboard_plugs_search_new (void);
VALA_EXTERN SwitchboardPlugsSearch* switchboard_plugs_search_construct (GType object_type);
static void switchboard_plugs_search_set_ready (SwitchboardPlugsSearch* self,
                                         gboolean value);
VALA_EXTERN void switchboard_plugs_search_cache_search_entries (SwitchboardPlugsSearch* self,
                                                    GAsyncReadyCallback _callback_,
                                                    gpointer _user_data_);
VALA_EXTERN void switchboard_plugs_search_cache_search_entries_finish (SwitchboardPlugsSearch* self,
                                                           GAsyncResult* _res_);
static void __lambda4_ (SwitchboardPlugsSearch* self,
                 GObject* obj,
                 GAsyncResult* res);
static void ___lambda4__gasync_ready_callback (GObject* source_object,
                                        GAsyncResult* res,
                                        gpointer self);
static void switchboard_plugs_search_cache_search_entries_data_free (gpointer _data);
static gboolean switchboard_plugs_search_cache_search_entries_co (SwitchboardPlugsSearchCacheSearchEntriesData* _data_);
static void switchboard_plugs_search_cache_search_entries_ready (GObject* source_object,
                                                          GAsyncResult* _res_,
                                                          gpointer _user_data_);
VALA_EXTERN gboolean switchboard_plugs_search_get_ready (SwitchboardPlugsSearch* self);
static void switchboard_plugs_search_finalize (SwitchboardPlugsSearch * obj);
static GType switchboard_plugs_search_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 gssize _vala_array_length (gpointer array);

void
switchboard_search_entry_copy (const SwitchboardSearchEntry* self,
                               SwitchboardSearchEntry* dest)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	_tmp0_ = (*self).plug_name;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 ((*dest).plug_name);
	(*dest).plug_name = _tmp1_;
	_tmp2_ = (*self).ui_elements;
	_tmp3_ = g_strdup (_tmp2_);
	_g_free0 ((*dest).ui_elements);
	(*dest).ui_elements = _tmp3_;
	_tmp4_ = (*self).open_window;
	_tmp5_ = g_strdup (_tmp4_);
	_g_free0 ((*dest).open_window);
	(*dest).open_window = _tmp5_;
}

void
switchboard_search_entry_destroy (SwitchboardSearchEntry* self)
{
	_g_free0 ((*self).plug_name);
	_g_free0 ((*self).ui_elements);
	_g_free0 ((*self).open_window);
}

SwitchboardSearchEntry*
switchboard_search_entry_dup (const SwitchboardSearchEntry* self)
{
	SwitchboardSearchEntry* dup;
	dup = g_new0 (SwitchboardSearchEntry, 1);
	switchboard_search_entry_copy (self, dup);
	return dup;
}

void
switchboard_search_entry_free (SwitchboardSearchEntry* self)
{
	switchboard_search_entry_destroy (self);
	g_free (self);
}

static GType
switchboard_search_entry_get_type_once (void)
{
	GType switchboard_search_entry_type_id;
	switchboard_search_entry_type_id = g_boxed_type_register_static ("SwitchboardSearchEntry", (GBoxedCopyFunc) switchboard_search_entry_dup, (GBoxedFreeFunc) switchboard_search_entry_free);
	return switchboard_search_entry_type_id;
}

GType
switchboard_search_entry_get_type (void)
{
	static volatile gsize switchboard_search_entry_type_id__once = 0;
	if (g_once_init_enter (&switchboard_search_entry_type_id__once)) {
		GType switchboard_search_entry_type_id;
		switchboard_search_entry_type_id = switchboard_search_entry_get_type_once ();
		g_once_init_leave (&switchboard_search_entry_type_id__once, switchboard_search_entry_type_id);
	}
	return switchboard_search_entry_type_id__once;
}

static inline gpointer
switchboard_plugs_search_get_instance_private (SwitchboardPlugsSearch* self)
{
	return G_STRUCT_MEMBER_P (self, SwitchboardPlugsSearch_private_offset);
}

static void
__lambda4_ (SwitchboardPlugsSearch* self,
            GObject* obj,
            GAsyncResult* res)
{
	g_return_if_fail (res != NULL);
	switchboard_plugs_search_cache_search_entries_finish (self, res);
	switchboard_plugs_search_set_ready (self, TRUE);
}

static void
___lambda4__gasync_ready_callback (GObject* source_object,
                                   GAsyncResult* res,
                                   gpointer self)
{
	__lambda4_ ((SwitchboardPlugsSearch*) self, source_object, res);
	switchboard_plugs_search_unref (self);
}

SwitchboardPlugsSearch*
switchboard_plugs_search_construct (GType object_type)
{
	SwitchboardPlugsSearch* self = NULL;
	GeeArrayList* _tmp0_;
	self = (SwitchboardPlugsSearch*) g_type_create_instance (object_type);
	switchboard_plugs_search_set_ready (self, FALSE);
	_tmp0_ = gee_array_list_new (SWITCHBOARD_TYPE_SEARCH_ENTRY, (GBoxedCopyFunc) switchboard_search_entry_dup, (GDestroyNotify) switchboard_search_entry_free, NULL, NULL, NULL);
	_g_object_unref0 (self->search_entries);
	self->search_entries = _tmp0_;
	switchboard_plugs_search_cache_search_entries (self, ___lambda4__gasync_ready_callback, switchboard_plugs_search_ref (self));
	return self;
}

SwitchboardPlugsSearch*
switchboard_plugs_search_new (void)
{
	return switchboard_plugs_search_construct (SWITCHBOARD_TYPE_PLUGS_SEARCH);
}

static void
switchboard_plugs_search_cache_search_entries_data_free (gpointer _data)
{
	SwitchboardPlugsSearchCacheSearchEntriesData* _data_;
	_data_ = _data;
	_switchboard_plugs_search_unref0 (_data_->self);
	g_slice_free (SwitchboardPlugsSearchCacheSearchEntriesData, _data_);
}

static gpointer
_switchboard_plugs_search_ref0 (gpointer self)
{
	return self ? switchboard_plugs_search_ref (self) : NULL;
}

void
switchboard_plugs_search_cache_search_entries (SwitchboardPlugsSearch* self,
                                               GAsyncReadyCallback _callback_,
                                               gpointer _user_data_)
{
	SwitchboardPlugsSearchCacheSearchEntriesData* _data_;
	SwitchboardPlugsSearch* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (SwitchboardPlugsSearchCacheSearchEntriesData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, switchboard_plugs_search_cache_search_entries_data_free);
	_tmp0_ = _switchboard_plugs_search_ref0 (self);
	_data_->self = _tmp0_;
	switchboard_plugs_search_cache_search_entries_co (_data_);
}

void
switchboard_plugs_search_cache_search_entries_finish (SwitchboardPlugsSearch* self,
                                                      GAsyncResult* _res_)
{
	SwitchboardPlugsSearchCacheSearchEntriesData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
switchboard_plugs_search_cache_search_entries_ready (GObject* source_object,
                                                     GAsyncResult* _res_,
                                                     gpointer _user_data_)
{
	SwitchboardPlugsSearchCacheSearchEntriesData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	switchboard_plugs_search_cache_search_entries_co (_data_);
}

static gboolean
switchboard_plugs_search_cache_search_entries_co (SwitchboardPlugsSearchCacheSearchEntriesData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = switchboard_plugs_manager_get_default ();
	_data_->plugsmanager = _data_->_tmp0_;
	{
		_data_->_tmp1_ = _data_->plugsmanager;
		_data_->_tmp2_ = switchboard_plugs_manager_get_plugs (_data_->_tmp1_);
		_data_->_tmp3_ = _data_->_tmp2_;
		_data_->_tmp4_ = gee_iterable_iterator ((GeeIterable*) _data_->_tmp3_);
		_data_->_tmp5_ = _data_->_tmp4_;
		_g_object_unref0 (_data_->_tmp3_);
		_data_->_plug_it = _data_->_tmp5_;
		while (TRUE) {
			_data_->_tmp6_ = _data_->_plug_it;
			if (!gee_iterator_next (_data_->_tmp6_)) {
				break;
			}
			_data_->_tmp7_ = _data_->_plug_it;
			_data_->_tmp8_ = gee_iterator_get (_data_->_tmp7_);
			_data_->plug = (SwitchboardPlug*) _data_->_tmp8_;
			_data_->_tmp9_ = _data_->plug;
			_data_->_state_ = 1;
			switchboard_plug_search (_data_->_tmp9_, "", switchboard_plugs_search_cache_search_entries_ready, _data_);
			return FALSE;
			_state_1:
			_data_->_tmp10_ = switchboard_plug_search_finish (_data_->_tmp9_, _data_->_res_);
			_data_->tmp_entries = _data_->_tmp10_;
			{
				_data_->_tmp11_ = _data_->tmp_entries;
				_data_->_tmp12_ = gee_abstract_map_get_entries ((GeeAbstractMap*) _data_->_tmp11_);
				_data_->_tmp13_ = _data_->_tmp12_;
				_data_->_tmp14_ = _data_->_tmp13_;
				_data_->_tmp15_ = gee_iterable_iterator ((GeeIterable*) _data_->_tmp14_);
				_data_->_tmp16_ = _data_->_tmp15_;
				_g_object_unref0 (_data_->_tmp14_);
				_data_->_entry_it = _data_->_tmp16_;
				while (TRUE) {
					_data_->_tmp17_ = _data_->_entry_it;
					if (!gee_iterator_next (_data_->_tmp17_)) {
						break;
					}
					_data_->_tmp18_ = _data_->_entry_it;
					_data_->_tmp19_ = gee_iterator_get (_data_->_tmp18_);
					_data_->entry = (GeeMapEntry*) _data_->_tmp19_;
					_data_->_tmp20_ = _data_->entry;
					_data_->_tmp21_ = gee_map_entry_get_key (_data_->_tmp20_);
					_data_->_tmp22_ = _data_->_tmp21_;
					_data_->_tmp24_ = _data_->_tmp23_ = g_strsplit ((const gchar*) _data_->_tmp22_, " → ", 0);
					_data_->tmp = _data_->_tmp24_;
					_data_->tmp_length1 = _vala_array_length (_data_->_tmp23_);
					_data_->_tmp_size_ = _data_->tmp_length1;
					memset (&_data_->tmp_entry, 0, sizeof (SwitchboardSearchEntry));
					_data_->_tmp25_ = _data_->tmp;
					_data_->_tmp25__length1 = _data_->tmp_length1;
					_data_->_tmp26_ = _data_->_tmp25_[0];
					_data_->_tmp27_ = g_strdup (_data_->_tmp26_);
					_g_free0 (_data_->tmp_entry.plug_name);
					_data_->tmp_entry.plug_name = _data_->_tmp27_;
					_data_->_tmp28_ = _data_->entry;
					_data_->_tmp29_ = gee_map_entry_get_key (_data_->_tmp28_);
					_data_->_tmp30_ = _data_->_tmp29_;
					_data_->_tmp31_ = g_strdup ((const gchar*) _data_->_tmp30_);
					_data_->ui_elements_name = _data_->_tmp31_;
					_data_->_tmp32_ = _data_->ui_elements_name;
					_data_->_tmp33_ = g_strdup (_data_->_tmp32_);
					_g_free0 (_data_->tmp_entry.ui_elements);
					_data_->tmp_entry.ui_elements = _data_->_tmp33_;
					_data_->_tmp34_ = _data_->entry;
					_data_->_tmp35_ = gee_map_entry_get_value (_data_->_tmp34_);
					_data_->_tmp36_ = _data_->_tmp35_;
					_data_->_tmp37_ = g_strdup ((const gchar*) _data_->_tmp36_);
					_g_free0 (_data_->tmp_entry.open_window);
					_data_->tmp_entry.open_window = _data_->_tmp37_;
					_data_->_tmp38_ = _data_->self->search_entries;
					_data_->_tmp39_ = _data_->tmp_entry;
					gee_abstract_collection_add ((GeeAbstractCollection*) _data_->_tmp38_, &_data_->_tmp39_);
					_data_->_tmp40_ = _data_->tmp_entry;
					_data_->_tmp41_ = _data_->_tmp40_.open_window;
					g_debug ("PlugsSearch.vala:57: plugsSearch: add open window: %s ", _data_->_tmp41_);
					_data_->_tmp42_ = _data_->tmp_entry;
					_data_->_tmp43_ = _data_->_tmp42_.ui_elements;
					g_debug ("PlugsSearch.vala:58: plugsSearch: add ui elements: %s ", _data_->_tmp43_);
					_data_->_tmp44_ = _data_->tmp_entry;
					_data_->_tmp45_ = _data_->_tmp44_.plug_name;
					g_debug ("PlugsSearch.vala:59: plugsSearch: add plug name: %s ", _data_->_tmp45_);
					_g_free0 (_data_->ui_elements_name);
					switchboard_search_entry_destroy (&_data_->tmp_entry);
					_data_->tmp = (_vala_array_free (_data_->tmp, _data_->tmp_length1, (GDestroyNotify) g_free), NULL);
					_g_object_unref0 (_data_->entry);
				}
				_g_object_unref0 (_data_->_entry_it);
			}
			_g_object_unref0 (_data_->tmp_entries);
			_g_object_unref0 (_data_->plug);
		}
		_g_object_unref0 (_data_->_plug_it);
	}
	_g_object_unref0 (_data_->plugsmanager);
	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;
}

gboolean
switchboard_plugs_search_get_ready (SwitchboardPlugsSearch* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_ready;
	return result;
}

static void
switchboard_plugs_search_set_ready (SwitchboardPlugsSearch* self,
                                    gboolean value)
{
	g_return_if_fail (self != NULL);
	self->priv->_ready = value;
}

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

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

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

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

static gchar*
switchboard_value_plugs_search_collect_value (GValue* value,
                                              guint n_collect_values,
                                              GTypeCValue* collect_values,
                                              guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		SwitchboardPlugsSearch * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = switchboard_plugs_search_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
switchboard_value_plugs_search_lcopy_value (const GValue* value,
                                            guint n_collect_values,
                                            GTypeCValue* collect_values,
                                            guint collect_flags)
{
	SwitchboardPlugsSearch ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = switchboard_plugs_search_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
switchboard_param_spec_plugs_search (const gchar* name,
                                     const gchar* nick,
                                     const gchar* blurb,
                                     GType object_type,
                                     GParamFlags flags)
{
	SwitchboardParamSpecPlugsSearch* spec;
	g_return_val_if_fail (g_type_is_a (object_type, SWITCHBOARD_TYPE_PLUGS_SEARCH), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
switchboard_value_get_plugs_search (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, SWITCHBOARD_TYPE_PLUGS_SEARCH), NULL);
	return value->data[0].v_pointer;
}

void
switchboard_value_set_plugs_search (GValue* value,
                                    gpointer v_object)
{
	SwitchboardPlugsSearch * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, SWITCHBOARD_TYPE_PLUGS_SEARCH));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, SWITCHBOARD_TYPE_PLUGS_SEARCH));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		switchboard_plugs_search_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		switchboard_plugs_search_unref (old);
	}
}

void
switchboard_value_take_plugs_search (GValue* value,
                                     gpointer v_object)
{
	SwitchboardPlugsSearch * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, SWITCHBOARD_TYPE_PLUGS_SEARCH));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, SWITCHBOARD_TYPE_PLUGS_SEARCH));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		switchboard_plugs_search_unref (old);
	}
}

static void
switchboard_plugs_search_class_init (SwitchboardPlugsSearchClass * klass,
                                     gpointer klass_data)
{
	switchboard_plugs_search_parent_class = g_type_class_peek_parent (klass);
	((SwitchboardPlugsSearchClass *) klass)->finalize = switchboard_plugs_search_finalize;
	g_type_class_adjust_private_offset (klass, &SwitchboardPlugsSearch_private_offset);
}

static void
switchboard_plugs_search_instance_init (SwitchboardPlugsSearch * self,
                                        gpointer klass)
{
	self->priv = switchboard_plugs_search_get_instance_private (self);
	self->ref_count = 1;
}

static void
switchboard_plugs_search_finalize (SwitchboardPlugsSearch * obj)
{
	SwitchboardPlugsSearch * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SWITCHBOARD_TYPE_PLUGS_SEARCH, SwitchboardPlugsSearch);
	g_signal_handlers_destroy (self);
	_g_object_unref0 (self->search_entries);
}

static GType
switchboard_plugs_search_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { switchboard_value_plugs_search_init, switchboard_value_plugs_search_free_value, switchboard_value_plugs_search_copy_value, switchboard_value_plugs_search_peek_pointer, "p", switchboard_value_plugs_search_collect_value, "p", switchboard_value_plugs_search_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (SwitchboardPlugsSearchClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) switchboard_plugs_search_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SwitchboardPlugsSearch), 0, (GInstanceInitFunc) switchboard_plugs_search_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType switchboard_plugs_search_type_id;
	switchboard_plugs_search_type_id = g_type_register_fundamental (g_type_fundamental_next (), "SwitchboardPlugsSearch", &g_define_type_info, &g_define_type_fundamental_info, 0);
	SwitchboardPlugsSearch_private_offset = g_type_add_instance_private (switchboard_plugs_search_type_id, sizeof (SwitchboardPlugsSearchPrivate));
	return switchboard_plugs_search_type_id;
}

GType
switchboard_plugs_search_get_type (void)
{
	static volatile gsize switchboard_plugs_search_type_id__once = 0;
	if (g_once_init_enter (&switchboard_plugs_search_type_id__once)) {
		GType switchboard_plugs_search_type_id;
		switchboard_plugs_search_type_id = switchboard_plugs_search_get_type_once ();
		g_once_init_leave (&switchboard_plugs_search_type_id__once, switchboard_plugs_search_type_id);
	}
	return switchboard_plugs_search_type_id__once;
}

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

void
switchboard_plugs_search_unref (gpointer instance)
{
	SwitchboardPlugsSearch * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		SWITCHBOARD_PLUGS_SEARCH_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

