/* contacts-types.c generated by valac 0.20.1.71-45f6, the Vala compiler
 * generated from contacts-types.vala, do not modify */

/* -*- Mode: vala; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 8 -*- */
/*
 * Copyright (C) 2011 Alexander Larsson <alexl@redhat.com>
 *
 * 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 2 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 <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <config.h>
#include <folks/folks.h>
#include <gee.h>
#include <gdk/gdk.h>


#define CONTACTS_TYPE_TYPESET (contacts_typeset_get_type ())
#define CONTACTS_TYPESET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONTACTS_TYPE_TYPESET, ContactsTypeSet))
#define CONTACTS_TYPESET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONTACTS_TYPE_TYPESET, ContactsTypeSetClass))
#define CONTACTS_IS_TYPESET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONTACTS_TYPE_TYPESET))
#define CONTACTS_IS_TYPESET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONTACTS_TYPE_TYPESET))
#define CONTACTS_TYPESET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONTACTS_TYPE_TYPESET, ContactsTypeSetClass))

typedef struct _ContactsTypeSet ContactsTypeSet;
typedef struct _ContactsTypeSetClass ContactsTypeSetClass;
typedef struct _ContactsTypeSetPrivate ContactsTypeSetPrivate;

#define CONTACTS_TYPESET_TYPE_DATA (contacts_typeset_data_get_type ())
#define CONTACTS_TYPESET_DATA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONTACTS_TYPESET_TYPE_DATA, ContactsTypeSetData))
#define CONTACTS_TYPESET_DATA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONTACTS_TYPESET_TYPE_DATA, ContactsTypeSetDataClass))
#define CONTACTS_TYPESET_IS_DATA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONTACTS_TYPESET_TYPE_DATA))
#define CONTACTS_TYPESET_IS_DATA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONTACTS_TYPESET_TYPE_DATA))
#define CONTACTS_TYPESET_DATA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONTACTS_TYPESET_TYPE_DATA, ContactsTypeSetDataClass))

typedef struct _ContactsTypeSetData ContactsTypeSetData;
typedef struct _ContactsTypeSetDataClass ContactsTypeSetDataClass;

#define CONTACTS_TYPESET_TYPE_INIT_DATA (contacts_typeset_init_data_get_type ())
typedef struct _ContactsTypeSetInitData ContactsTypeSetInitData;
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _ContactsTypeSetDataPrivate ContactsTypeSetDataPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_list_free0(var) ((var == NULL) ? NULL : (var = (g_list_free (var), NULL)))

#define CONTACTS_TYPE_TYPECOMBO (contacts_typecombo_get_type ())
#define CONTACTS_TYPECOMBO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONTACTS_TYPE_TYPECOMBO, ContactsTypeCombo))
#define CONTACTS_TYPECOMBO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONTACTS_TYPE_TYPECOMBO, ContactsTypeComboClass))
#define CONTACTS_IS_TYPECOMBO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONTACTS_TYPE_TYPECOMBO))
#define CONTACTS_IS_TYPECOMBO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONTACTS_TYPE_TYPECOMBO))
#define CONTACTS_TYPECOMBO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONTACTS_TYPE_TYPECOMBO, ContactsTypeComboClass))

typedef struct _ContactsTypeCombo ContactsTypeCombo;
typedef struct _ContactsTypeComboClass ContactsTypeComboClass;
typedef struct _ContactsTypeComboPrivate ContactsTypeComboPrivate;
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _ContactsTypeSet {
	GObject parent_instance;
	ContactsTypeSetPrivate * priv;
	GtkListStore* store;
};

struct _ContactsTypeSetClass {
	GObjectClass parent_class;
};

struct _ContactsTypeSetInitData {
	const gchar* display_name_u;
	const gchar* types[3];
};

struct _ContactsTypeSetPrivate {
	GHashTable* display_name_hash;
	GHashTable* vcard_lookup_hash;
	GHashTable* custom_hash;
	GtkTreeIter other_iter;
	GtkTreeIter custom_iter;
};

struct _ContactsTypeSetData {
	GObject parent_instance;
	ContactsTypeSetDataPrivate * priv;
	gchar* display_name;
	GList* init_data;
	GtkTreeIter iter;
	gboolean in_store;
};

struct _ContactsTypeSetDataClass {
	GObjectClass parent_class;
};

struct _ContactsTypeCombo {
	GtkGrid parent_instance;
	ContactsTypeComboPrivate * priv;
	gboolean modified;
};

struct _ContactsTypeComboClass {
	GtkGridClass parent_class;
};

struct _ContactsTypeComboPrivate {
	ContactsTypeSet* type_set;
	GtkComboBox* combo;
	GtkEntry* entry;
	GtkTreeIter last_active;
	gboolean custom_mode;
	gboolean in_manual_change;
};


static gpointer contacts_typeset_parent_class = NULL;
static ContactsTypeSetData* contacts_typeset_custom_dummy;
static ContactsTypeSetData* contacts_typeset_custom_dummy = NULL;
static ContactsTypeSetData* contacts_typeset_other_dummy;
static ContactsTypeSetData* contacts_typeset_other_dummy = NULL;
static ContactsTypeSet* contacts_typeset__general;
static ContactsTypeSet* contacts_typeset__general = NULL;
static ContactsTypeSet* contacts_typeset__email;
static ContactsTypeSet* contacts_typeset__email = NULL;
static ContactsTypeSet* contacts_typeset__phone;
static ContactsTypeSet* contacts_typeset__phone = NULL;
static gpointer contacts_typeset_data_parent_class = NULL;
static gpointer contacts_typecombo_parent_class = NULL;

GType contacts_typeset_get_type (void) G_GNUC_CONST;
static GType contacts_typeset_data_get_type (void) G_GNUC_CONST G_GNUC_UNUSED;
static GType contacts_typeset_init_data_get_type (void) G_GNUC_CONST G_GNUC_UNUSED;
static ContactsTypeSetInitData* contacts_typeset_init_data_dup (const ContactsTypeSetInitData* self);
static void contacts_typeset_init_data_free (ContactsTypeSetInitData* self);
#define CONTACTS_TYPESET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CONTACTS_TYPE_TYPESET, ContactsTypeSetPrivate))
enum  {
	CONTACTS_TYPESET_DUMMY_PROPERTY
};
static ContactsTypeSetData* contacts_typeset_data_new (void);
static ContactsTypeSetData* contacts_typeset_data_construct (GType object_type);
#define CONTACTS_TYPESET_X_GOOGLE_LABEL "x-google-label"
#define CONTACTS_TYPESET_MAX_TYPES 3
static ContactsTypeSet* contacts_typeset_new (void);
static ContactsTypeSet* contacts_typeset_construct (GType object_type);
static void _g_object_unref0_ (gpointer var);
static void _g_list_free0_ (gpointer var);
static void _g_free0_ (gpointer var);
static void contacts_typeset_add_data_to_store (ContactsTypeSet* self, ContactsTypeSetData* data, gboolean is_custom);
static void contacts_typeset_add_init_data (ContactsTypeSet* self, ContactsTypeSetInitData* init_data);
static void contacts_typeset_add_init_data_done (ContactsTypeSet* self, gchar** standard_untranslated, int standard_untranslated_length1);
void contacts_typeset_add_custom_label (ContactsTypeSet* self, const gchar* label, GtkTreeIter* iter);
static GtkTreeIter* _gtk_tree_iter_dup (GtkTreeIter* self);
static ContactsTypeSetData* contacts_typeset_lookup_data_by_string (ContactsTypeSet* self, const gchar* str);
static ContactsTypeSetData* contacts_typeset_lookup_data (ContactsTypeSet* self, FolksAbstractFieldDetails* detail);
void contacts_typeset_lookup_type (ContactsTypeSet* self, FolksAbstractFieldDetails* detail, GtkTreeIter* iter);
gpointer contacts_utils_get_first (GType t_type, GBoxedCopyFunc t_dup_func, GDestroyNotify t_destroy_func, GeeCollection* collection);
void contacts_typeset_lookup_type_by_string (ContactsTypeSet* self, const gchar* type, GtkTreeIter* iter);
void contacts_typeset_type_seen (ContactsTypeSet* self, FolksAbstractFieldDetails* detail);
gchar* contacts_typeset_format_type (ContactsTypeSet* self, FolksAbstractFieldDetails* detail);
void contacts_typeset_update_details (ContactsTypeSet* self, FolksAbstractFieldDetails* details, GtkTreeIter* iter);
gboolean contacts_typeset_is_custom (ContactsTypeSet* self, GtkTreeIter* iter);
ContactsTypeSet* contacts_typeset_get_general (void);
ContactsTypeSet* contacts_typeset_get_email (void);
ContactsTypeSet* contacts_typeset_get_phone (void);
enum  {
	CONTACTS_TYPESET_DATA_DUMMY_PROPERTY
};
static void contacts_typeset_data_finalize (GObject* obj);
static void contacts_typeset_finalize (GObject* obj);
static void _vala_contacts_typeset_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
GType contacts_typecombo_get_type (void) G_GNUC_CONST;
#define CONTACTS_TYPECOMBO_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CONTACTS_TYPE_TYPECOMBO, ContactsTypeComboPrivate))
enum  {
	CONTACTS_TYPECOMBO_DUMMY_PROPERTY
};
ContactsTypeCombo* contacts_typecombo_new (ContactsTypeSet* type_set);
ContactsTypeCombo* contacts_typecombo_construct (GType object_type, ContactsTypeSet* type_set);
static gboolean __lambda35_ (ContactsTypeCombo* self, GtkTreeModel* model, GtkTreeIter* iter);
static gboolean ___lambda35__gtk_tree_view_row_separator_func (GtkTreeModel* model, GtkTreeIter* iter, gpointer self);
static void contacts_typecombo_combo_changed (ContactsTypeCombo* self, GtkComboBox* combo);
static void _contacts_typecombo_combo_changed_gtk_combo_box_changed (GtkComboBox* _sender, gpointer self);
static gboolean contacts_typecombo_entry_focus_out_event (ContactsTypeCombo* self, GdkEventFocus* event);
static gboolean _contacts_typecombo_entry_focus_out_event_gtk_widget_focus_out_event (GtkWidget* _sender, GdkEventFocus* event, gpointer self);
static void contacts_typecombo_entry_activate (ContactsTypeCombo* self);
static void _contacts_typecombo_entry_activate_gtk_entry_activate (GtkEntry* _sender, gpointer self);
static gboolean contacts_typecombo_entry_key_release (ContactsTypeCombo* self, GdkEventKey* event);
static gboolean _contacts_typecombo_entry_key_release_gtk_widget_key_release_event (GtkWidget* _sender, GdkEventKey* event, gpointer self);
static void contacts_typecombo_finish_custom (ContactsTypeCombo* self);
static void contacts_typecombo_set_from_iter (ContactsTypeCombo* self, GtkTreeIter* iter);
void contacts_typecombo_set_active (ContactsTypeCombo* self, FolksAbstractFieldDetails* details);
void contacts_typecombo_set_to (ContactsTypeCombo* self, const gchar* type);
void contacts_typecombo_update_details (ContactsTypeCombo* self, FolksAbstractFieldDetails* details);
static void contacts_typecombo_finalize (GObject* obj);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);

static const ContactsTypeSetInitData CONTACTS_TYPESET_general_data[2] = {{"Home", {"HOME"}, 3}, {"Work", {"WORK"}, 3}};
static const ContactsTypeSetInitData CONTACTS_TYPESET_email_data[2] = {{"Personal", {"PERSONAL"}, 3}, {"Work", {"WORK"}, 3}};

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


static void _g_list_free0_ (gpointer var) {
	(var == NULL) ? NULL : (var = (g_list_free (var), NULL));
}


static void _g_free0_ (gpointer var) {
	(var == NULL) ? NULL : (var = (g_free (var), NULL));
}


static ContactsTypeSet* contacts_typeset_construct (GType object_type) {
	ContactsTypeSet * self = NULL;
	GHashFunc _tmp0_ = NULL;
	GEqualFunc _tmp1_ = NULL;
	GHashTable* _tmp2_ = NULL;
	GHashFunc _tmp3_ = NULL;
	GEqualFunc _tmp4_ = NULL;
	GHashTable* _tmp5_ = NULL;
	GHashFunc _tmp6_ = NULL;
	GEqualFunc _tmp7_ = NULL;
	GHashTable* _tmp8_ = NULL;
	GtkListStore* _tmp9_ = NULL;
	self = (ContactsTypeSet*) g_object_new (object_type, NULL);
	_tmp0_ = g_str_hash;
	_tmp1_ = g_str_equal;
	_tmp2_ = g_hash_table_new_full (_tmp0_, _tmp1_, NULL, _g_object_unref0_);
	_g_hash_table_unref0 (self->priv->display_name_hash);
	self->priv->display_name_hash = _tmp2_;
	_tmp3_ = g_str_hash;
	_tmp4_ = g_str_equal;
	_tmp5_ = g_hash_table_new_full (_tmp3_, _tmp4_, NULL, _g_list_free0_);
	_g_hash_table_unref0 (self->priv->vcard_lookup_hash);
	self->priv->vcard_lookup_hash = _tmp5_;
	_tmp6_ = g_str_hash;
	_tmp7_ = g_str_equal;
	_tmp8_ = g_hash_table_new_full (_tmp6_, _tmp7_, NULL, _g_free0_);
	_g_hash_table_unref0 (self->priv->custom_hash);
	self->priv->custom_hash = _tmp8_;
	_tmp9_ = gtk_list_store_new (2, G_TYPE_STRING, CONTACTS_TYPESET_TYPE_DATA);
	_g_object_unref0 (self->store);
	self->store = _tmp9_;
	return self;
}


static ContactsTypeSet* contacts_typeset_new (void) {
	return contacts_typeset_construct (CONTACTS_TYPE_TYPESET);
}


static void contacts_typeset_add_data_to_store (ContactsTypeSet* self, ContactsTypeSetData* data, gboolean is_custom) {
	ContactsTypeSetData* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	ContactsTypeSetData* _tmp2_ = NULL;
	gboolean _tmp3_ = FALSE;
	GtkListStore* _tmp11_ = NULL;
	ContactsTypeSetData* _tmp12_ = NULL;
	GtkTreeIter _tmp13_ = {0};
	ContactsTypeSetData* _tmp14_ = NULL;
	const gchar* _tmp15_ = NULL;
	ContactsTypeSetData* _tmp16_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (data != NULL);
	_tmp0_ = data;
	_tmp1_ = _tmp0_->in_store;
	if (_tmp1_) {
		return;
	}
	_tmp2_ = data;
	_tmp2_->in_store = TRUE;
	_tmp3_ = is_custom;
	if (_tmp3_) {
		GtkListStore* _tmp4_ = NULL;
		ContactsTypeSetData* _tmp5_ = NULL;
		GtkTreeIter _tmp6_ = {0};
		GtkTreeIter _tmp7_ = {0};
		_tmp4_ = self->store;
		_tmp5_ = data;
		_tmp6_ = self->priv->custom_iter;
		gtk_list_store_insert_before (_tmp4_, &_tmp7_, &_tmp6_);
		_tmp5_->iter = _tmp7_;
	} else {
		GtkListStore* _tmp8_ = NULL;
		ContactsTypeSetData* _tmp9_ = NULL;
		GtkTreeIter _tmp10_ = {0};
		_tmp8_ = self->store;
		_tmp9_ = data;
		gtk_list_store_append (_tmp8_, &_tmp10_);
		_tmp9_->iter = _tmp10_;
	}
	_tmp11_ = self->store;
	_tmp12_ = data;
	_tmp13_ = _tmp12_->iter;
	_tmp14_ = data;
	_tmp15_ = _tmp14_->display_name;
	_tmp16_ = data;
	gtk_list_store_set (_tmp11_, &_tmp13_, 0, _tmp15_, 1, _tmp16_, -1);
}


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


static void contacts_typeset_add_init_data (ContactsTypeSet* self, ContactsTypeSetInitData* init_data) {
	const gchar* dn = NULL;
	ContactsTypeSetInitData* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	ContactsTypeSetData* data = NULL;
	GHashTable* _tmp3_ = NULL;
	const gchar* _tmp4_ = NULL;
	gconstpointer _tmp5_ = NULL;
	ContactsTypeSetData* _tmp6_ = NULL;
	ContactsTypeSetData* _tmp7_ = NULL;
	ContactsTypeSetData* _tmp16_ = NULL;
	ContactsTypeSetInitData* _tmp17_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = init_data;
	_tmp1_ = (*_tmp0_).display_name_u;
	_tmp2_ = g_dgettext (GETTEXT_PACKAGE, _tmp1_);
	dn = _tmp2_;
	_tmp3_ = self->priv->display_name_hash;
	_tmp4_ = dn;
	_tmp5_ = g_hash_table_lookup (_tmp3_, _tmp4_);
	_tmp6_ = _g_object_ref0 ((ContactsTypeSetData*) _tmp5_);
	data = _tmp6_;
	_tmp7_ = data;
	if (_tmp7_ == NULL) {
		ContactsTypeSetData* _tmp8_ = NULL;
		ContactsTypeSetData* _tmp9_ = NULL;
		const gchar* _tmp10_ = NULL;
		gchar* _tmp11_ = NULL;
		GHashTable* _tmp12_ = NULL;
		const gchar* _tmp13_ = NULL;
		ContactsTypeSetData* _tmp14_ = NULL;
		ContactsTypeSetData* _tmp15_ = NULL;
		_tmp8_ = contacts_typeset_data_new ();
		_g_object_unref0 (data);
		data = _tmp8_;
		_tmp9_ = data;
		_tmp10_ = dn;
		_tmp11_ = g_strdup (_tmp10_);
		_g_free0 (_tmp9_->display_name);
		_tmp9_->display_name = _tmp11_;
		_tmp12_ = self->priv->display_name_hash;
		_tmp13_ = dn;
		_tmp14_ = data;
		_tmp15_ = _g_object_ref0 (_tmp14_);
		g_hash_table_insert (_tmp12_, _tmp13_, _tmp15_);
	}
	_tmp16_ = data;
	_tmp17_ = init_data;
	_tmp16_->init_data = g_list_append (_tmp16_->init_data, _tmp17_);
	{
		gint j = 0;
		j = 0;
		{
			gboolean _tmp18_ = FALSE;
			_tmp18_ = TRUE;
			while (TRUE) {
				gboolean _tmp19_ = FALSE;
				gboolean _tmp21_ = FALSE;
				gint _tmp22_ = 0;
				gboolean _tmp26_ = FALSE;
				const gchar* type = NULL;
				ContactsTypeSetInitData* _tmp27_ = NULL;
				gint _tmp28_ = 0;
				const gchar* _tmp29_ = NULL;
				GList* l = NULL;
				GHashTable* _tmp30_ = NULL;
				const gchar* _tmp31_ = NULL;
				gconstpointer _tmp32_ = NULL;
				GList* _tmp33_ = NULL;
				_tmp19_ = _tmp18_;
				if (!_tmp19_) {
					gint _tmp20_ = 0;
					_tmp20_ = j;
					j = _tmp20_ + 1;
				}
				_tmp18_ = FALSE;
				_tmp22_ = j;
				if (_tmp22_ < CONTACTS_TYPESET_MAX_TYPES) {
					ContactsTypeSetInitData* _tmp23_ = NULL;
					gint _tmp24_ = 0;
					const gchar* _tmp25_ = NULL;
					_tmp23_ = init_data;
					_tmp24_ = j;
					_tmp25_ = (*_tmp23_).types[_tmp24_];
					_tmp21_ = _tmp25_ != NULL;
				} else {
					_tmp21_ = FALSE;
				}
				_tmp26_ = _tmp21_;
				if (!_tmp26_) {
					break;
				}
				_tmp27_ = init_data;
				_tmp28_ = j;
				_tmp29_ = (*_tmp27_).types[_tmp28_];
				type = _tmp29_;
				_tmp30_ = self->priv->vcard_lookup_hash;
				_tmp31_ = type;
				_tmp32_ = g_hash_table_lookup (_tmp30_, _tmp31_);
				l = (GList*) _tmp32_;
				_tmp33_ = l;
				if (_tmp33_ != NULL) {
					ContactsTypeSetInitData* _tmp34_ = NULL;
					_tmp34_ = init_data;
					l = g_list_append (l, _tmp34_);
				} else {
					GList* l2 = NULL;
					ContactsTypeSetInitData* _tmp35_ = NULL;
					GHashTable* _tmp36_ = NULL;
					const gchar* _tmp37_ = NULL;
					GList* _tmp38_ = NULL;
					l2 = NULL;
					_tmp35_ = init_data;
					l2 = g_list_append (l2, _tmp35_);
					_tmp36_ = self->priv->vcard_lookup_hash;
					_tmp37_ = type;
					_tmp38_ = l2;
					l2 = NULL;
					g_hash_table_insert (_tmp36_, _tmp37_, _tmp38_);
					_g_list_free0 (l2);
				}
			}
		}
	}
	_g_object_unref0 (data);
}


static void contacts_typeset_add_init_data_done (ContactsTypeSet* self, gchar** standard_untranslated, int standard_untranslated_length1) {
	gchar** _tmp0_ = NULL;
	gint _tmp0__length1 = 0;
	GtkListStore* _tmp10_ = NULL;
	GtkTreeIter _tmp11_ = {0};
	GtkListStore* _tmp12_ = NULL;
	GtkTreeIter _tmp13_ = {0};
	const gchar* _tmp14_ = NULL;
	ContactsTypeSetData* _tmp15_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = standard_untranslated;
	_tmp0__length1 = standard_untranslated_length1;
	{
		gchar** untranslated_collection = NULL;
		gint untranslated_collection_length1 = 0;
		gint _untranslated_collection_size_ = 0;
		gint untranslated_it = 0;
		untranslated_collection = _tmp0_;
		untranslated_collection_length1 = _tmp0__length1;
		for (untranslated_it = 0; untranslated_it < _tmp0__length1; untranslated_it = untranslated_it + 1) {
			gchar* _tmp1_ = NULL;
			gchar* untranslated = NULL;
			_tmp1_ = g_strdup (untranslated_collection[untranslated_it]);
			untranslated = _tmp1_;
			{
				ContactsTypeSetData* data = NULL;
				GHashTable* _tmp2_ = NULL;
				const gchar* _tmp3_ = NULL;
				const gchar* _tmp4_ = NULL;
				gconstpointer _tmp5_ = NULL;
				ContactsTypeSetData* _tmp6_ = NULL;
				ContactsTypeSetData* _tmp7_ = NULL;
				_tmp2_ = self->priv->display_name_hash;
				_tmp3_ = untranslated;
				_tmp4_ = g_dgettext (GETTEXT_PACKAGE, _tmp3_);
				_tmp5_ = g_hash_table_lookup (_tmp2_, _tmp4_);
				_tmp6_ = _g_object_ref0 ((ContactsTypeSetData*) _tmp5_);
				data = _tmp6_;
				_tmp7_ = data;
				if (_tmp7_ != NULL) {
					ContactsTypeSetData* _tmp8_ = NULL;
					_tmp8_ = data;
					contacts_typeset_add_data_to_store (self, _tmp8_, FALSE);
				} else {
					const gchar* _tmp9_ = NULL;
					_tmp9_ = untranslated;
					g_error ("contacts-types.vala:109: Internal error: Can't find display name %s in" \
" TypeSet data", _tmp9_);
				}
				_g_object_unref0 (data);
				_g_free0 (untranslated);
			}
		}
	}
	_tmp10_ = self->store;
	gtk_list_store_append (_tmp10_, &_tmp11_);
	self->priv->other_iter = _tmp11_;
	_tmp12_ = self->store;
	_tmp13_ = self->priv->other_iter;
	_tmp14_ = _ ("Other");
	_tmp15_ = contacts_typeset_other_dummy;
	gtk_list_store_set (_tmp12_, &_tmp13_, 0, _tmp14_, 1, _tmp15_, -1);
}


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


static gpointer __gtk_tree_iter_dup0 (gpointer self) {
	return self ? _gtk_tree_iter_dup (self) : NULL;
}


void contacts_typeset_add_custom_label (ContactsTypeSet* self, const gchar* label, GtkTreeIter* iter) {
	GtkTreeIter _vala_iter = {0};
	ContactsTypeSetData* data = NULL;
	GHashTable* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	gconstpointer _tmp2_ = NULL;
	ContactsTypeSetData* _tmp3_ = NULL;
	ContactsTypeSetData* _tmp4_ = NULL;
	const gchar* _tmp8_ = NULL;
	const gchar* _tmp9_ = NULL;
	GtkTreeIter* iterp = NULL;
	GHashTable* _tmp11_ = NULL;
	const gchar* _tmp12_ = NULL;
	gconstpointer _tmp13_ = NULL;
	GtkTreeIter* _tmp14_ = NULL;
	GtkListStore* _tmp16_ = NULL;
	GtkTreeIter _tmp17_ = {0};
	GtkTreeIter _tmp18_ = {0};
	GtkListStore* _tmp19_ = NULL;
	GtkTreeIter _tmp20_ = {0};
	const gchar* _tmp21_ = NULL;
	GHashTable* _tmp22_ = NULL;
	const gchar* _tmp23_ = NULL;
	gchar* _tmp24_ = NULL;
	GtkTreeIter _tmp25_ = {0};
	GtkTreeIter* _tmp26_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (label != NULL);
	_tmp0_ = self->priv->display_name_hash;
	_tmp1_ = label;
	_tmp2_ = g_hash_table_lookup (_tmp0_, _tmp1_);
	_tmp3_ = _g_object_ref0 ((ContactsTypeSetData*) _tmp2_);
	data = _tmp3_;
	_tmp4_ = data;
	if (_tmp4_ != NULL) {
		ContactsTypeSetData* _tmp5_ = NULL;
		ContactsTypeSetData* _tmp6_ = NULL;
		GtkTreeIter _tmp7_ = {0};
		_tmp5_ = data;
		contacts_typeset_add_data_to_store (self, _tmp5_, TRUE);
		_tmp6_ = data;
		_tmp7_ = _tmp6_->iter;
		_vala_iter = _tmp7_;
		_g_object_unref0 (data);
		if (iter) {
			*iter = _vala_iter;
		}
		return;
	}
	_tmp8_ = label;
	_tmp9_ = _ ("Other");
	if (g_strcmp0 (_tmp8_, _tmp9_) == 0) {
		GtkTreeIter _tmp10_ = {0};
		_tmp10_ = self->priv->other_iter;
		_vala_iter = _tmp10_;
		_g_object_unref0 (data);
		if (iter) {
			*iter = _vala_iter;
		}
		return;
	}
	_tmp11_ = self->priv->custom_hash;
	_tmp12_ = label;
	_tmp13_ = g_hash_table_lookup (_tmp11_, _tmp12_);
	iterp = (GtkTreeIter*) _tmp13_;
	_tmp14_ = iterp;
	if (_tmp14_ != NULL) {
		GtkTreeIter* _tmp15_ = NULL;
		_tmp15_ = iterp;
		_vala_iter = *_tmp15_;
		_g_object_unref0 (data);
		if (iter) {
			*iter = _vala_iter;
		}
		return;
	}
	_tmp16_ = self->store;
	_tmp17_ = self->priv->custom_iter;
	gtk_list_store_insert_before (_tmp16_, &_tmp18_, &_tmp17_);
	_vala_iter = _tmp18_;
	_tmp19_ = self->store;
	_tmp20_ = _vala_iter;
	_tmp21_ = label;
	gtk_list_store_set (_tmp19_, &_tmp20_, 0, _tmp21_, 1, NULL, -1);
	_tmp22_ = self->priv->custom_hash;
	_tmp23_ = label;
	_tmp24_ = g_strdup (_tmp23_);
	_tmp25_ = _vala_iter;
	_tmp26_ = __gtk_tree_iter_dup0 (&_tmp25_);
	g_hash_table_insert (_tmp22_, _tmp24_, _tmp26_);
	_g_object_unref0 (data);
	if (iter) {
		*iter = _vala_iter;
	}
}


static ContactsTypeSetData* contacts_typeset_lookup_data_by_string (ContactsTypeSet* self, const gchar* str) {
	ContactsTypeSetData* result = NULL;
	GList* l = NULL;
	GHashTable* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	gconstpointer _tmp2_ = NULL;
	GList* _tmp3_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (str != NULL, NULL);
	_tmp0_ = self->priv->vcard_lookup_hash;
	_tmp1_ = str;
	_tmp2_ = g_hash_table_lookup (_tmp0_, _tmp1_);
	l = (GList*) _tmp2_;
	_tmp3_ = l;
	{
		GList* d_collection = NULL;
		GList* d_it = NULL;
		d_collection = _tmp3_;
		for (d_it = d_collection; d_it != NULL; d_it = d_it->next) {
			ContactsTypeSetInitData* d = NULL;
			d = d_it->data;
			{
				ContactsTypeSetInitData* _tmp4_ = NULL;
				const gchar* _tmp5_ = NULL;
				_tmp4_ = d;
				_tmp5_ = (*_tmp4_).types[1];
				if (_tmp5_ == NULL) {
					const gchar* dn = NULL;
					ContactsTypeSetInitData* _tmp6_ = NULL;
					const gchar* _tmp7_ = NULL;
					const gchar* _tmp8_ = NULL;
					GHashTable* _tmp9_ = NULL;
					const gchar* _tmp10_ = NULL;
					gconstpointer _tmp11_ = NULL;
					_tmp6_ = d;
					_tmp7_ = (*_tmp6_).display_name_u;
					_tmp8_ = g_dgettext (GETTEXT_PACKAGE, _tmp7_);
					dn = _tmp8_;
					_tmp9_ = self->priv->display_name_hash;
					_tmp10_ = dn;
					_tmp11_ = g_hash_table_lookup (_tmp9_, _tmp10_);
					result = (ContactsTypeSetData*) _tmp11_;
					return result;
				}
			}
		}
	}
	result = NULL;
	return result;
}


static ContactsTypeSetData* contacts_typeset_lookup_data (ContactsTypeSet* self, FolksAbstractFieldDetails* detail) {
	ContactsTypeSetData* result = NULL;
	GeeCollection* i = NULL;
	FolksAbstractFieldDetails* _tmp0_ = NULL;
	GeeCollection* _tmp1_ = NULL;
	gboolean _tmp2_ = FALSE;
	GeeCollection* _tmp3_ = NULL;
	gboolean _tmp7_ = FALSE;
	GeeArrayList* list = NULL;
	GeeArrayList* _tmp8_ = NULL;
	GList* l = NULL;
	GHashTable* _tmp22_ = NULL;
	GeeArrayList* _tmp23_ = NULL;
	gpointer _tmp24_ = NULL;
	gchar* _tmp25_ = NULL;
	gconstpointer _tmp26_ = NULL;
	GList* _tmp27_ = NULL;
	GList* _tmp28_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (detail != NULL, NULL);
	_tmp0_ = detail;
	_tmp1_ = folks_abstract_field_details_get_parameter_values (_tmp0_, "type");
	i = _tmp1_;
	_tmp3_ = i;
	if (_tmp3_ == NULL) {
		_tmp2_ = TRUE;
	} else {
		GeeCollection* _tmp4_ = NULL;
		gboolean _tmp5_ = FALSE;
		gboolean _tmp6_ = FALSE;
		_tmp4_ = i;
		_tmp5_ = gee_collection_get_is_empty (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp2_ = _tmp6_;
	}
	_tmp7_ = _tmp2_;
	if (_tmp7_) {
		result = NULL;
		_g_object_unref0 (i);
		return result;
	}
	_tmp8_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL);
	list = _tmp8_;
	{
		GeeIterator* _s_it = NULL;
		FolksAbstractFieldDetails* _tmp9_ = NULL;
		GeeCollection* _tmp10_ = NULL;
		GeeCollection* _tmp11_ = NULL;
		GeeIterator* _tmp12_ = NULL;
		GeeIterator* _tmp13_ = NULL;
		_tmp9_ = detail;
		_tmp10_ = folks_abstract_field_details_get_parameter_values (_tmp9_, "type");
		_tmp11_ = _tmp10_;
		_tmp12_ = gee_iterable_iterator ((GeeIterable*) _tmp11_);
		_tmp13_ = _tmp12_;
		_g_object_unref0 (_tmp11_);
		_s_it = _tmp13_;
		while (TRUE) {
			GeeIterator* _tmp14_ = NULL;
			gboolean _tmp15_ = FALSE;
			gchar* s = NULL;
			GeeIterator* _tmp16_ = NULL;
			gpointer _tmp17_ = NULL;
			GeeArrayList* _tmp18_ = NULL;
			const gchar* _tmp19_ = NULL;
			gchar* _tmp20_ = NULL;
			gchar* _tmp21_ = NULL;
			_tmp14_ = _s_it;
			_tmp15_ = gee_iterator_next (_tmp14_);
			if (!_tmp15_) {
				break;
			}
			_tmp16_ = _s_it;
			_tmp17_ = gee_iterator_get (_tmp16_);
			s = (gchar*) _tmp17_;
			_tmp18_ = list;
			_tmp19_ = s;
			_tmp20_ = g_utf8_strup (_tmp19_, (gssize) (-1));
			_tmp21_ = _tmp20_;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp18_, _tmp21_);
			_g_free0 (_tmp21_);
			_g_free0 (s);
		}
		_g_object_unref0 (_s_it);
	}
	_tmp22_ = self->priv->vcard_lookup_hash;
	_tmp23_ = list;
	_tmp24_ = gee_abstract_list_get ((GeeAbstractList*) _tmp23_, 0);
	_tmp25_ = (gchar*) _tmp24_;
	_tmp26_ = g_hash_table_lookup (_tmp22_, _tmp25_);
	_tmp27_ = (GList*) _tmp26_;
	_g_free0 (_tmp25_);
	l = _tmp27_;
	_tmp28_ = l;
	{
		GList* d_collection = NULL;
		GList* d_it = NULL;
		d_collection = _tmp28_;
		for (d_it = d_collection; d_it != NULL; d_it = d_it->next) {
			ContactsTypeSetInitData* d = NULL;
			d = d_it->data;
			{
				gboolean all_found = FALSE;
				gboolean _tmp43_ = FALSE;
				all_found = TRUE;
				{
					gint j = 0;
					j = 0;
					{
						gboolean _tmp29_ = FALSE;
						_tmp29_ = TRUE;
						while (TRUE) {
							gboolean _tmp30_ = FALSE;
							gboolean _tmp32_ = FALSE;
							gint _tmp33_ = 0;
							gboolean _tmp37_ = FALSE;
							GeeArrayList* _tmp38_ = NULL;
							ContactsTypeSetInitData* _tmp39_ = NULL;
							gint _tmp40_ = 0;
							const gchar* _tmp41_ = NULL;
							gboolean _tmp42_ = FALSE;
							_tmp30_ = _tmp29_;
							if (!_tmp30_) {
								gint _tmp31_ = 0;
								_tmp31_ = j;
								j = _tmp31_ + 1;
							}
							_tmp29_ = FALSE;
							_tmp33_ = j;
							if (_tmp33_ < CONTACTS_TYPESET_MAX_TYPES) {
								ContactsTypeSetInitData* _tmp34_ = NULL;
								gint _tmp35_ = 0;
								const gchar* _tmp36_ = NULL;
								_tmp34_ = d;
								_tmp35_ = j;
								_tmp36_ = (*_tmp34_).types[_tmp35_];
								_tmp32_ = _tmp36_ != NULL;
							} else {
								_tmp32_ = FALSE;
							}
							_tmp37_ = _tmp32_;
							if (!_tmp37_) {
								break;
							}
							_tmp38_ = list;
							_tmp39_ = d;
							_tmp40_ = j;
							_tmp41_ = (*_tmp39_).types[_tmp40_];
							_tmp42_ = gee_abstract_collection_contains ((GeeAbstractCollection*) _tmp38_, _tmp41_);
							if (!_tmp42_) {
								all_found = FALSE;
								break;
							}
						}
					}
				}
				_tmp43_ = all_found;
				if (_tmp43_) {
					const gchar* dn = NULL;
					ContactsTypeSetInitData* _tmp44_ = NULL;
					const gchar* _tmp45_ = NULL;
					const gchar* _tmp46_ = NULL;
					GHashTable* _tmp47_ = NULL;
					const gchar* _tmp48_ = NULL;
					gconstpointer _tmp49_ = NULL;
					_tmp44_ = d;
					_tmp45_ = (*_tmp44_).display_name_u;
					_tmp46_ = g_dgettext (GETTEXT_PACKAGE, _tmp45_);
					dn = _tmp46_;
					_tmp47_ = self->priv->display_name_hash;
					_tmp48_ = dn;
					_tmp49_ = g_hash_table_lookup (_tmp47_, _tmp48_);
					result = (ContactsTypeSetData*) _tmp49_;
					_g_object_unref0 (list);
					_g_object_unref0 (i);
					return result;
				}
			}
		}
	}
	result = NULL;
	_g_object_unref0 (list);
	_g_object_unref0 (i);
	return result;
}


void contacts_typeset_lookup_type (ContactsTypeSet* self, FolksAbstractFieldDetails* detail, GtkTreeIter* iter) {
	GtkTreeIter _vala_iter = {0};
	FolksAbstractFieldDetails* _tmp0_ = NULL;
	GeeMultiMap* _tmp1_ = NULL;
	GeeMultiMap* _tmp2_ = NULL;
	gboolean _tmp3_ = FALSE;
	ContactsTypeSetData* d = NULL;
	FolksAbstractFieldDetails* _tmp13_ = NULL;
	ContactsTypeSetData* _tmp14_ = NULL;
	ContactsTypeSetData* _tmp15_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (detail != NULL);
	_tmp0_ = detail;
	_tmp1_ = folks_abstract_field_details_get_parameters (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = gee_multi_map_contains (_tmp2_, CONTACTS_TYPESET_X_GOOGLE_LABEL);
	if (_tmp3_) {
		gchar* label = NULL;
		FolksAbstractFieldDetails* _tmp4_ = NULL;
		GeeMultiMap* _tmp5_ = NULL;
		GeeMultiMap* _tmp6_ = NULL;
		GeeCollection* _tmp7_ = NULL;
		GeeCollection* _tmp8_ = NULL;
		gpointer _tmp9_ = NULL;
		gchar* _tmp10_ = NULL;
		const gchar* _tmp11_ = NULL;
		GtkTreeIter _tmp12_ = {0};
		_tmp4_ = detail;
		_tmp5_ = folks_abstract_field_details_get_parameters (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp7_ = gee_multi_map_get (_tmp6_, CONTACTS_TYPESET_X_GOOGLE_LABEL);
		_tmp8_ = _tmp7_;
		_tmp9_ = contacts_utils_get_first (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, _tmp8_);
		_tmp10_ = (gchar*) _tmp9_;
		_g_object_unref0 (_tmp8_);
		label = _tmp10_;
		_tmp11_ = label;
		contacts_typeset_add_custom_label (self, _tmp11_, &_tmp12_);
		_vala_iter = _tmp12_;
		_g_free0 (label);
		if (iter) {
			*iter = _vala_iter;
		}
		return;
	}
	_tmp13_ = detail;
	_tmp14_ = contacts_typeset_lookup_data (self, _tmp13_);
	d = _tmp14_;
	_tmp15_ = d;
	if (_tmp15_ != NULL) {
		ContactsTypeSetData* _tmp16_ = NULL;
		ContactsTypeSetData* _tmp17_ = NULL;
		GtkTreeIter _tmp18_ = {0};
		_tmp16_ = d;
		contacts_typeset_add_data_to_store (self, _tmp16_, TRUE);
		_tmp17_ = d;
		_tmp18_ = _tmp17_->iter;
		_vala_iter = _tmp18_;
	} else {
		GtkTreeIter _tmp19_ = {0};
		_tmp19_ = self->priv->other_iter;
		_vala_iter = _tmp19_;
	}
	if (iter) {
		*iter = _vala_iter;
	}
}


void contacts_typeset_lookup_type_by_string (ContactsTypeSet* self, const gchar* type, GtkTreeIter* iter) {
	GtkTreeIter _vala_iter = {0};
	ContactsTypeSetData* d = NULL;
	const gchar* _tmp0_ = NULL;
	ContactsTypeSetData* _tmp1_ = NULL;
	ContactsTypeSetData* _tmp2_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (type != NULL);
	_tmp0_ = type;
	_tmp1_ = contacts_typeset_lookup_data_by_string (self, _tmp0_);
	d = _tmp1_;
	_tmp2_ = d;
	if (_tmp2_ != NULL) {
		ContactsTypeSetData* _tmp3_ = NULL;
		GtkTreeIter _tmp4_ = {0};
		_tmp3_ = d;
		_tmp4_ = _tmp3_->iter;
		_vala_iter = _tmp4_;
	} else {
		GtkTreeIter _tmp5_ = {0};
		_tmp5_ = self->priv->other_iter;
		_vala_iter = _tmp5_;
	}
	if (iter) {
		*iter = _vala_iter;
	}
}


void contacts_typeset_type_seen (ContactsTypeSet* self, FolksAbstractFieldDetails* detail) {
	FolksAbstractFieldDetails* _tmp0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (detail != NULL);
	_tmp0_ = detail;
	contacts_typeset_lookup_type (self, _tmp0_, NULL);
}


gchar* contacts_typeset_format_type (ContactsTypeSet* self, FolksAbstractFieldDetails* detail) {
	gchar* result = NULL;
	FolksAbstractFieldDetails* _tmp0_ = NULL;
	GeeMultiMap* _tmp1_ = NULL;
	GeeMultiMap* _tmp2_ = NULL;
	gboolean _tmp3_ = FALSE;
	ContactsTypeSetData* d = NULL;
	FolksAbstractFieldDetails* _tmp11_ = NULL;
	ContactsTypeSetData* _tmp12_ = NULL;
	ContactsTypeSetData* _tmp13_ = NULL;
	const gchar* _tmp17_ = NULL;
	gchar* _tmp18_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (detail != NULL, NULL);
	_tmp0_ = detail;
	_tmp1_ = folks_abstract_field_details_get_parameters (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = gee_multi_map_contains (_tmp2_, CONTACTS_TYPESET_X_GOOGLE_LABEL);
	if (_tmp3_) {
		FolksAbstractFieldDetails* _tmp4_ = NULL;
		GeeMultiMap* _tmp5_ = NULL;
		GeeMultiMap* _tmp6_ = NULL;
		GeeCollection* _tmp7_ = NULL;
		GeeCollection* _tmp8_ = NULL;
		gpointer _tmp9_ = NULL;
		gchar* _tmp10_ = NULL;
		_tmp4_ = detail;
		_tmp5_ = folks_abstract_field_details_get_parameters (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp7_ = gee_multi_map_get (_tmp6_, CONTACTS_TYPESET_X_GOOGLE_LABEL);
		_tmp8_ = _tmp7_;
		_tmp9_ = contacts_utils_get_first (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, _tmp8_);
		_tmp10_ = (gchar*) _tmp9_;
		_g_object_unref0 (_tmp8_);
		result = _tmp10_;
		return result;
	}
	_tmp11_ = detail;
	_tmp12_ = contacts_typeset_lookup_data (self, _tmp11_);
	d = _tmp12_;
	_tmp13_ = d;
	if (_tmp13_ != NULL) {
		ContactsTypeSetData* _tmp14_ = NULL;
		const gchar* _tmp15_ = NULL;
		gchar* _tmp16_ = NULL;
		_tmp14_ = d;
		_tmp15_ = _tmp14_->display_name;
		_tmp16_ = g_strdup (_tmp15_);
		result = _tmp16_;
		return result;
	}
	_tmp17_ = _ ("Other");
	_tmp18_ = g_strdup (_tmp17_);
	result = _tmp18_;
	return result;
}


void contacts_typeset_update_details (ContactsTypeSet* self, FolksAbstractFieldDetails* details, GtkTreeIter* iter) {
	GeeMultiMap* old_parameters = NULL;
	FolksAbstractFieldDetails* _tmp0_ = NULL;
	GeeMultiMap* _tmp1_ = NULL;
	GeeMultiMap* _tmp2_ = NULL;
	GeeMultiMap* _tmp3_ = NULL;
	FolksAbstractFieldDetails* _tmp4_ = NULL;
	GeeHashMultiMap* _tmp5_ = NULL;
	GeeHashMultiMap* _tmp6_ = NULL;
	gboolean has_pref = FALSE;
	ContactsTypeSetData* data = NULL;
	gchar* display_name = NULL;
	GtkListStore* _tmp46_ = NULL;
	GtkTreeIter _tmp47_ = {0};
	const gchar* _tmp48_ = NULL;
	ContactsTypeSetData* _tmp49_ = NULL;
	ContactsTypeSetData* _tmp50_ = NULL;
	ContactsTypeSetData* _tmp51_ = NULL;
	gboolean _tmp82_ = FALSE;
	g_return_if_fail (self != NULL);
	g_return_if_fail (details != NULL);
	g_return_if_fail (iter != NULL);
	_tmp0_ = details;
	_tmp1_ = folks_abstract_field_details_get_parameters (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	old_parameters = _tmp3_;
	_tmp4_ = details;
	_tmp5_ = gee_hash_multi_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_tmp6_ = _tmp5_;
	folks_abstract_field_details_set_parameters (_tmp4_, (GeeMultiMap*) _tmp6_);
	_g_object_unref0 (_tmp6_);
	has_pref = FALSE;
	{
		GeeIterator* _value_it = NULL;
		GeeMultiMap* _tmp7_ = NULL;
		GeeCollection* _tmp8_ = NULL;
		GeeCollection* _tmp9_ = NULL;
		GeeIterator* _tmp10_ = NULL;
		GeeIterator* _tmp11_ = NULL;
		_tmp7_ = old_parameters;
		_tmp8_ = gee_multi_map_get (_tmp7_, "type");
		_tmp9_ = _tmp8_;
		_tmp10_ = gee_iterable_iterator ((GeeIterable*) _tmp9_);
		_tmp11_ = _tmp10_;
		_g_object_unref0 (_tmp9_);
		_value_it = _tmp11_;
		while (TRUE) {
			GeeIterator* _tmp12_ = NULL;
			gboolean _tmp13_ = FALSE;
			gchar* value = NULL;
			GeeIterator* _tmp14_ = NULL;
			gpointer _tmp15_ = NULL;
			const gchar* _tmp16_ = NULL;
			gint _tmp17_ = 0;
			_tmp12_ = _value_it;
			_tmp13_ = gee_iterator_next (_tmp12_);
			if (!_tmp13_) {
				break;
			}
			_tmp14_ = _value_it;
			_tmp15_ = gee_iterator_get (_tmp14_);
			value = (gchar*) _tmp15_;
			_tmp16_ = value;
			_tmp17_ = g_ascii_strcasecmp (_tmp16_, "PREF");
			if (_tmp17_ == 0) {
				has_pref = TRUE;
				_g_free0 (value);
				break;
			}
			_g_free0 (value);
		}
		_g_object_unref0 (_value_it);
	}
	{
		GeeIterator* _param_it = NULL;
		GeeMultiMap* _tmp18_ = NULL;
		GeeSet* _tmp19_ = NULL;
		GeeSet* _tmp20_ = NULL;
		GeeIterator* _tmp21_ = NULL;
		GeeIterator* _tmp22_ = NULL;
		_tmp18_ = old_parameters;
		_tmp19_ = gee_multi_map_get_keys (_tmp18_);
		_tmp20_ = _tmp19_;
		_tmp21_ = gee_iterable_iterator ((GeeIterable*) _tmp20_);
		_tmp22_ = _tmp21_;
		_g_object_unref0 (_tmp20_);
		_param_it = _tmp22_;
		while (TRUE) {
			GeeIterator* _tmp23_ = NULL;
			gboolean _tmp24_ = FALSE;
			gchar* param = NULL;
			GeeIterator* _tmp25_ = NULL;
			gpointer _tmp26_ = NULL;
			gboolean _tmp27_ = FALSE;
			const gchar* _tmp28_ = NULL;
			gboolean _tmp30_ = FALSE;
			_tmp23_ = _param_it;
			_tmp24_ = gee_iterator_next (_tmp23_);
			if (!_tmp24_) {
				break;
			}
			_tmp25_ = _param_it;
			_tmp26_ = gee_iterator_get (_tmp25_);
			param = (gchar*) _tmp26_;
			_tmp28_ = param;
			if (g_strcmp0 (_tmp28_, "type") != 0) {
				const gchar* _tmp29_ = NULL;
				_tmp29_ = param;
				_tmp27_ = g_strcmp0 (_tmp29_, CONTACTS_TYPESET_X_GOOGLE_LABEL) != 0;
			} else {
				_tmp27_ = FALSE;
			}
			_tmp30_ = _tmp27_;
			if (_tmp30_) {
				{
					GeeIterator* _value_it = NULL;
					GeeMultiMap* _tmp31_ = NULL;
					const gchar* _tmp32_ = NULL;
					GeeCollection* _tmp33_ = NULL;
					GeeCollection* _tmp34_ = NULL;
					GeeIterator* _tmp35_ = NULL;
					GeeIterator* _tmp36_ = NULL;
					_tmp31_ = old_parameters;
					_tmp32_ = param;
					_tmp33_ = gee_multi_map_get (_tmp31_, _tmp32_);
					_tmp34_ = _tmp33_;
					_tmp35_ = gee_iterable_iterator ((GeeIterable*) _tmp34_);
					_tmp36_ = _tmp35_;
					_g_object_unref0 (_tmp34_);
					_value_it = _tmp36_;
					while (TRUE) {
						GeeIterator* _tmp37_ = NULL;
						gboolean _tmp38_ = FALSE;
						gchar* value = NULL;
						GeeIterator* _tmp39_ = NULL;
						gpointer _tmp40_ = NULL;
						FolksAbstractFieldDetails* _tmp41_ = NULL;
						GeeMultiMap* _tmp42_ = NULL;
						GeeMultiMap* _tmp43_ = NULL;
						const gchar* _tmp44_ = NULL;
						const gchar* _tmp45_ = NULL;
						_tmp37_ = _value_it;
						_tmp38_ = gee_iterator_next (_tmp37_);
						if (!_tmp38_) {
							break;
						}
						_tmp39_ = _value_it;
						_tmp40_ = gee_iterator_get (_tmp39_);
						value = (gchar*) _tmp40_;
						_tmp41_ = details;
						_tmp42_ = folks_abstract_field_details_get_parameters (_tmp41_);
						_tmp43_ = _tmp42_;
						_tmp44_ = param;
						_tmp45_ = value;
						gee_multi_map_set (_tmp43_, _tmp44_, _tmp45_);
						_g_free0 (value);
					}
					_g_object_unref0 (_value_it);
				}
			}
			_g_free0 (param);
		}
		_g_object_unref0 (_param_it);
	}
	_tmp46_ = self->store;
	_tmp47_ = *iter;
	gtk_tree_model_get ((GtkTreeModel*) _tmp46_, &_tmp47_, 0, &display_name, 1, &data, -1);
	_tmp48_ = display_name;
	_vala_assert (_tmp48_ != NULL, "display_name != null");
	_tmp49_ = data;
	_tmp50_ = contacts_typeset_custom_dummy;
	_vala_assert (_tmp49_ != _tmp50_, "data != custom_dummy");
	_tmp51_ = data;
	if (_tmp51_ == NULL) {
		FolksAbstractFieldDetails* _tmp52_ = NULL;
		GeeMultiMap* _tmp53_ = NULL;
		GeeMultiMap* _tmp54_ = NULL;
		FolksAbstractFieldDetails* _tmp55_ = NULL;
		GeeMultiMap* _tmp56_ = NULL;
		GeeMultiMap* _tmp57_ = NULL;
		const gchar* _tmp58_ = NULL;
		_tmp52_ = details;
		_tmp53_ = folks_abstract_field_details_get_parameters (_tmp52_);
		_tmp54_ = _tmp53_;
		gee_multi_map_set (_tmp54_, "type", "OTHER");
		_tmp55_ = details;
		_tmp56_ = folks_abstract_field_details_get_parameters (_tmp55_);
		_tmp57_ = _tmp56_;
		_tmp58_ = display_name;
		gee_multi_map_set (_tmp57_, CONTACTS_TYPESET_X_GOOGLE_LABEL, _tmp58_);
	} else {
		ContactsTypeSetData* _tmp59_ = NULL;
		ContactsTypeSetData* _tmp60_ = NULL;
		_tmp59_ = data;
		_tmp60_ = contacts_typeset_other_dummy;
		if (_tmp59_ == _tmp60_) {
			FolksAbstractFieldDetails* _tmp61_ = NULL;
			GeeMultiMap* _tmp62_ = NULL;
			GeeMultiMap* _tmp63_ = NULL;
			_tmp61_ = details;
			_tmp62_ = folks_abstract_field_details_get_parameters (_tmp61_);
			_tmp63_ = _tmp62_;
			gee_multi_map_set (_tmp63_, "type", "OTHER");
		} else {
			ContactsTypeSetInitData* init_data = NULL;
			ContactsTypeSetData* _tmp64_ = NULL;
			GList* _tmp65_ = NULL;
			gconstpointer _tmp66_ = NULL;
			_tmp64_ = data;
			_tmp65_ = _tmp64_->init_data;
			_tmp66_ = _tmp65_->data;
			init_data = _tmp66_;
			{
				gint j = 0;
				j = 0;
				{
					gboolean _tmp67_ = FALSE;
					_tmp67_ = TRUE;
					while (TRUE) {
						gboolean _tmp68_ = FALSE;
						gboolean _tmp70_ = FALSE;
						gint _tmp71_ = 0;
						gboolean _tmp75_ = FALSE;
						FolksAbstractFieldDetails* _tmp76_ = NULL;
						GeeMultiMap* _tmp77_ = NULL;
						GeeMultiMap* _tmp78_ = NULL;
						ContactsTypeSetInitData* _tmp79_ = NULL;
						gint _tmp80_ = 0;
						const gchar* _tmp81_ = NULL;
						_tmp68_ = _tmp67_;
						if (!_tmp68_) {
							gint _tmp69_ = 0;
							_tmp69_ = j;
							j = _tmp69_ + 1;
						}
						_tmp67_ = FALSE;
						_tmp71_ = j;
						if (_tmp71_ < CONTACTS_TYPESET_MAX_TYPES) {
							ContactsTypeSetInitData* _tmp72_ = NULL;
							gint _tmp73_ = 0;
							const gchar* _tmp74_ = NULL;
							_tmp72_ = init_data;
							_tmp73_ = j;
							_tmp74_ = (*_tmp72_).types[_tmp73_];
							_tmp70_ = _tmp74_ != NULL;
						} else {
							_tmp70_ = FALSE;
						}
						_tmp75_ = _tmp70_;
						if (!_tmp75_) {
							break;
						}
						_tmp76_ = details;
						_tmp77_ = folks_abstract_field_details_get_parameters (_tmp76_);
						_tmp78_ = _tmp77_;
						_tmp79_ = init_data;
						_tmp80_ = j;
						_tmp81_ = (*_tmp79_).types[_tmp80_];
						gee_multi_map_set (_tmp78_, "type", _tmp81_);
					}
				}
			}
		}
	}
	_tmp82_ = has_pref;
	if (_tmp82_) {
		FolksAbstractFieldDetails* _tmp83_ = NULL;
		GeeMultiMap* _tmp84_ = NULL;
		GeeMultiMap* _tmp85_ = NULL;
		_tmp83_ = details;
		_tmp84_ = folks_abstract_field_details_get_parameters (_tmp83_);
		_tmp85_ = _tmp84_;
		gee_multi_map_set (_tmp85_, "type", "PREF");
	}
	_g_free0 (display_name);
	_g_object_unref0 (data);
	_g_object_unref0 (old_parameters);
}


gboolean contacts_typeset_is_custom (ContactsTypeSet* self, GtkTreeIter* iter) {
	gboolean result = FALSE;
	ContactsTypeSetData* data = NULL;
	GtkListStore* _tmp0_ = NULL;
	GtkTreeIter _tmp1_ = {0};
	ContactsTypeSetData* _tmp2_ = NULL;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (iter != NULL, FALSE);
	_tmp0_ = self->store;
	_tmp1_ = *iter;
	gtk_tree_model_get ((GtkTreeModel*) _tmp0_, &_tmp1_, 1, &data, -1);
	_tmp2_ = contacts_typeset_custom_dummy;
	result = data == _tmp2_;
	_g_object_unref0 (data);
	return result;
}


ContactsTypeSet* contacts_typeset_get_general (void) {
	ContactsTypeSet* result;
	gchar** standard = NULL;
	gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	gchar** _tmp2_ = NULL;
	gint standard_length1 = 0;
	gint _standard_size_ = 0;
	ContactsTypeSet* _tmp3_ = NULL;
	ContactsTypeSet* _tmp13_ = NULL;
	_tmp0_ = g_strdup ("Work");
	_tmp1_ = g_strdup ("Home");
	_tmp2_ = g_new0 (gchar*, 2 + 1);
	_tmp2_[0] = _tmp0_;
	_tmp2_[1] = _tmp1_;
	standard = _tmp2_;
	standard_length1 = 2;
	_standard_size_ = standard_length1;
	_tmp3_ = contacts_typeset__general;
	if (_tmp3_ == NULL) {
		ContactsTypeSet* _tmp4_ = NULL;
		ContactsTypeSet* _tmp11_ = NULL;
		gchar** _tmp12_ = NULL;
		gint _tmp12__length1 = 0;
		_tmp4_ = contacts_typeset_new ();
		_g_object_unref0 (contacts_typeset__general);
		contacts_typeset__general = _tmp4_;
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp5_ = FALSE;
				_tmp5_ = TRUE;
				while (TRUE) {
					gboolean _tmp6_ = FALSE;
					gint _tmp8_ = 0;
					ContactsTypeSet* _tmp9_ = NULL;
					gint _tmp10_ = 0;
					_tmp6_ = _tmp5_;
					if (!_tmp6_) {
						gint _tmp7_ = 0;
						_tmp7_ = i;
						i = _tmp7_ + 1;
					}
					_tmp5_ = FALSE;
					_tmp8_ = i;
					if (!(_tmp8_ < G_N_ELEMENTS (CONTACTS_TYPESET_general_data))) {
						break;
					}
					_tmp9_ = contacts_typeset__general;
					_tmp10_ = i;
					contacts_typeset_add_init_data (_tmp9_, &CONTACTS_TYPESET_general_data[_tmp10_]);
				}
			}
		}
		_tmp11_ = contacts_typeset__general;
		_tmp12_ = standard;
		_tmp12__length1 = standard_length1;
		contacts_typeset_add_init_data_done (_tmp11_, _tmp12_, _tmp12__length1);
	}
	_tmp13_ = contacts_typeset__general;
	result = _tmp13_;
	standard = (_vala_array_free (standard, standard_length1, (GDestroyNotify) g_free), NULL);
	return result;
}


ContactsTypeSet* contacts_typeset_get_email (void) {
	ContactsTypeSet* result;
	gchar** standard = NULL;
	gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	gchar** _tmp2_ = NULL;
	gint standard_length1 = 0;
	gint _standard_size_ = 0;
	ContactsTypeSet* _tmp3_ = NULL;
	ContactsTypeSet* _tmp13_ = NULL;
	_tmp0_ = g_strdup ("Personal");
	_tmp1_ = g_strdup ("Work");
	_tmp2_ = g_new0 (gchar*, 2 + 1);
	_tmp2_[0] = _tmp0_;
	_tmp2_[1] = _tmp1_;
	standard = _tmp2_;
	standard_length1 = 2;
	_standard_size_ = standard_length1;
	_tmp3_ = contacts_typeset__email;
	if (_tmp3_ == NULL) {
		ContactsTypeSet* _tmp4_ = NULL;
		ContactsTypeSet* _tmp11_ = NULL;
		gchar** _tmp12_ = NULL;
		gint _tmp12__length1 = 0;
		_tmp4_ = contacts_typeset_new ();
		_g_object_unref0 (contacts_typeset__email);
		contacts_typeset__email = _tmp4_;
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp5_ = FALSE;
				_tmp5_ = TRUE;
				while (TRUE) {
					gboolean _tmp6_ = FALSE;
					gint _tmp8_ = 0;
					ContactsTypeSet* _tmp9_ = NULL;
					gint _tmp10_ = 0;
					_tmp6_ = _tmp5_;
					if (!_tmp6_) {
						gint _tmp7_ = 0;
						_tmp7_ = i;
						i = _tmp7_ + 1;
					}
					_tmp5_ = FALSE;
					_tmp8_ = i;
					if (!(_tmp8_ < G_N_ELEMENTS (CONTACTS_TYPESET_email_data))) {
						break;
					}
					_tmp9_ = contacts_typeset__email;
					_tmp10_ = i;
					contacts_typeset_add_init_data (_tmp9_, &CONTACTS_TYPESET_email_data[_tmp10_]);
				}
			}
		}
		_tmp11_ = contacts_typeset__email;
		_tmp12_ = standard;
		_tmp12__length1 = standard_length1;
		contacts_typeset_add_init_data_done (_tmp11_, _tmp12_, _tmp12__length1);
	}
	_tmp13_ = contacts_typeset__email;
	result = _tmp13_;
	standard = (_vala_array_free (standard, standard_length1, (GDestroyNotify) g_free), NULL);
	return result;
}


ContactsTypeSet* contacts_typeset_get_phone (void) {
	ContactsTypeSet* result;
	static const ContactsTypeSetInitData data[] = {{"Assistant", {"X-EVOLUTION-ASSISTANT"}, 3}, {"Work", {"WORK", "VOICE"}, 3}, {"Work Fax", {"WORK", "FAX"}, 3}, {"Callback", {"X-EVOLUTION-CALLBACK"}, 3}, {"Car", {"CAR"}, 3}, {"Company", {"X-EVOLUTION-COMPANY"}, 3}, {"Home", {"HOME", "VOICE"}, 3}, {"Home Fax", {"HOME", "FAX"}, 3}, {"ISDN", {"ISDN"}, 3}, {"Mobile", {"CELL"}, 3}, {"Other", {"VOICE"}, 3}, {"Fax", {"FAX"}, 3}, {"Pager", {"PAGER"}, 3}, {"Radio", {"X-EVOLUTION-RADIO"}, 3}, {"Telex", {"X-EVOLUTION-TELEX"}, 3}, {"TTY", {"X-EVOLUTION-TTYTDD"}, 3}};
	gchar** standard = NULL;
	gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	gchar** _tmp3_ = NULL;
	gint standard_length1 = 0;
	gint _standard_size_ = 0;
	ContactsTypeSet* _tmp4_ = NULL;
	ContactsTypeSet* _tmp20_ = NULL;
	_tmp0_ = g_strdup ("Mobile");
	_tmp1_ = g_strdup ("Work");
	_tmp2_ = g_strdup ("Home");
	_tmp3_ = g_new0 (gchar*, 3 + 1);
	_tmp3_[0] = _tmp0_;
	_tmp3_[1] = _tmp1_;
	_tmp3_[2] = _tmp2_;
	standard = _tmp3_;
	standard_length1 = 3;
	_standard_size_ = standard_length1;
	_tmp4_ = contacts_typeset__phone;
	if (_tmp4_ == NULL) {
		ContactsTypeSet* _tmp5_ = NULL;
		ContactsTypeSet* _tmp18_ = NULL;
		gchar** _tmp19_ = NULL;
		gint _tmp19__length1 = 0;
		_tmp5_ = contacts_typeset_new ();
		_g_object_unref0 (contacts_typeset__phone);
		contacts_typeset__phone = _tmp5_;
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp6_ = FALSE;
				_tmp6_ = TRUE;
				while (TRUE) {
					gboolean _tmp7_ = FALSE;
					gint _tmp9_ = 0;
					ContactsTypeSet* _tmp10_ = NULL;
					gint _tmp11_ = 0;
					_tmp7_ = _tmp6_;
					if (!_tmp7_) {
						gint _tmp8_ = 0;
						_tmp8_ = i;
						i = _tmp8_ + 1;
					}
					_tmp6_ = FALSE;
					_tmp9_ = i;
					if (!(_tmp9_ < G_N_ELEMENTS (data))) {
						break;
					}
					_tmp10_ = contacts_typeset__phone;
					_tmp11_ = i;
					contacts_typeset_add_init_data (_tmp10_, &data[_tmp11_]);
				}
			}
		}
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp12_ = FALSE;
				_tmp12_ = TRUE;
				while (TRUE) {
					gboolean _tmp13_ = FALSE;
					gint _tmp15_ = 0;
					ContactsTypeSet* _tmp16_ = NULL;
					gint _tmp17_ = 0;
					_tmp13_ = _tmp12_;
					if (!_tmp13_) {
						gint _tmp14_ = 0;
						_tmp14_ = i;
						i = _tmp14_ + 1;
					}
					_tmp12_ = FALSE;
					_tmp15_ = i;
					if (!(_tmp15_ < G_N_ELEMENTS (CONTACTS_TYPESET_general_data))) {
						break;
					}
					_tmp16_ = contacts_typeset__phone;
					_tmp17_ = i;
					contacts_typeset_add_init_data (_tmp16_, &CONTACTS_TYPESET_general_data[_tmp17_]);
				}
			}
		}
		_tmp18_ = contacts_typeset__phone;
		_tmp19_ = standard;
		_tmp19__length1 = standard_length1;
		contacts_typeset_add_init_data_done (_tmp18_, _tmp19_, _tmp19__length1);
	}
	_tmp20_ = contacts_typeset__phone;
	result = _tmp20_;
	standard = (_vala_array_free (standard, standard_length1, (GDestroyNotify) g_free), NULL);
	return result;
}


static ContactsTypeSetData* contacts_typeset_data_construct (GType object_type) {
	ContactsTypeSetData * self = NULL;
	self = (ContactsTypeSetData*) g_object_new (object_type, NULL);
	return self;
}


static ContactsTypeSetData* contacts_typeset_data_new (void) {
	return contacts_typeset_data_construct (CONTACTS_TYPESET_TYPE_DATA);
}


static void contacts_typeset_data_class_init (ContactsTypeSetDataClass * klass) {
	contacts_typeset_data_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = contacts_typeset_data_finalize;
}


static void contacts_typeset_data_instance_init (ContactsTypeSetData * self) {
}


static void contacts_typeset_data_finalize (GObject* obj) {
	ContactsTypeSetData * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CONTACTS_TYPESET_TYPE_DATA, ContactsTypeSetData);
	_g_free0 (self->display_name);
	_g_list_free0 (self->init_data);
	G_OBJECT_CLASS (contacts_typeset_data_parent_class)->finalize (obj);
}


static GType contacts_typeset_data_get_type (void) {
	static volatile gsize contacts_typeset_data_type_id__volatile = 0;
	if (g_once_init_enter (&contacts_typeset_data_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (ContactsTypeSetDataClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) contacts_typeset_data_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ContactsTypeSetData), 0, (GInstanceInitFunc) contacts_typeset_data_instance_init, NULL };
		GType contacts_typeset_data_type_id;
		contacts_typeset_data_type_id = g_type_register_static (G_TYPE_OBJECT, "ContactsTypeSetData", &g_define_type_info, 0);
		g_once_init_leave (&contacts_typeset_data_type_id__volatile, contacts_typeset_data_type_id);
	}
	return contacts_typeset_data_type_id__volatile;
}


static ContactsTypeSetInitData* contacts_typeset_init_data_dup (const ContactsTypeSetInitData* self) {
	ContactsTypeSetInitData* dup;
	dup = g_new0 (ContactsTypeSetInitData, 1);
	memcpy (dup, self, sizeof (ContactsTypeSetInitData));
	return dup;
}


static void contacts_typeset_init_data_free (ContactsTypeSetInitData* self) {
	g_free (self);
}


static GType contacts_typeset_init_data_get_type (void) {
	static volatile gsize contacts_typeset_init_data_type_id__volatile = 0;
	if (g_once_init_enter (&contacts_typeset_init_data_type_id__volatile)) {
		GType contacts_typeset_init_data_type_id;
		contacts_typeset_init_data_type_id = g_boxed_type_register_static ("ContactsTypeSetInitData", (GBoxedCopyFunc) contacts_typeset_init_data_dup, (GBoxedFreeFunc) contacts_typeset_init_data_free);
		g_once_init_leave (&contacts_typeset_init_data_type_id__volatile, contacts_typeset_init_data_type_id);
	}
	return contacts_typeset_init_data_type_id__volatile;
}


static void contacts_typeset_class_init (ContactsTypeSetClass * klass) {
	ContactsTypeSetData* _tmp0_ = NULL;
	ContactsTypeSetData* _tmp1_ = NULL;
	contacts_typeset_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (ContactsTypeSetPrivate));
	G_OBJECT_CLASS (klass)->get_property = _vala_contacts_typeset_get_property;
	G_OBJECT_CLASS (klass)->finalize = contacts_typeset_finalize;
	_tmp0_ = contacts_typeset_data_new ();
	contacts_typeset_custom_dummy = _tmp0_;
	_tmp1_ = contacts_typeset_data_new ();
	contacts_typeset_other_dummy = _tmp1_;
}


static void contacts_typeset_instance_init (ContactsTypeSet * self) {
	self->priv = CONTACTS_TYPESET_GET_PRIVATE (self);
}


static void contacts_typeset_finalize (GObject* obj) {
	ContactsTypeSet * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CONTACTS_TYPE_TYPESET, ContactsTypeSet);
	_g_hash_table_unref0 (self->priv->display_name_hash);
	_g_hash_table_unref0 (self->priv->vcard_lookup_hash);
	_g_hash_table_unref0 (self->priv->custom_hash);
	_g_object_unref0 (self->store);
	G_OBJECT_CLASS (contacts_typeset_parent_class)->finalize (obj);
}


GType contacts_typeset_get_type (void) {
	static volatile gsize contacts_typeset_type_id__volatile = 0;
	if (g_once_init_enter (&contacts_typeset_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (ContactsTypeSetClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) contacts_typeset_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ContactsTypeSet), 0, (GInstanceInitFunc) contacts_typeset_instance_init, NULL };
		GType contacts_typeset_type_id;
		contacts_typeset_type_id = g_type_register_static (G_TYPE_OBJECT, "ContactsTypeSet", &g_define_type_info, 0);
		g_once_init_leave (&contacts_typeset_type_id__volatile, contacts_typeset_type_id);
	}
	return contacts_typeset_type_id__volatile;
}


static void _vala_contacts_typeset_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	ContactsTypeSet * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, CONTACTS_TYPE_TYPESET, ContactsTypeSet);
	switch (property_id) {
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static gboolean __lambda35_ (ContactsTypeCombo* self, GtkTreeModel* model, GtkTreeIter* iter) {
	gboolean result = FALSE;
	gchar* s = NULL;
	GtkTreeModel* _tmp0_ = NULL;
	GtkTreeIter _tmp1_ = {0};
	g_return_val_if_fail (model != NULL, FALSE);
	g_return_val_if_fail (iter != NULL, FALSE);
	_tmp0_ = model;
	_tmp1_ = *iter;
	gtk_tree_model_get (_tmp0_, &_tmp1_, 0, &s, -1);
	result = s == NULL;
	_g_free0 (s);
	return result;
}


static gboolean ___lambda35__gtk_tree_view_row_separator_func (GtkTreeModel* model, GtkTreeIter* iter, gpointer self) {
	gboolean result;
	result = __lambda35_ (self, model, iter);
	return result;
}


static void _contacts_typecombo_combo_changed_gtk_combo_box_changed (GtkComboBox* _sender, gpointer self) {
	contacts_typecombo_combo_changed (self, _sender);
}


static gboolean _contacts_typecombo_entry_focus_out_event_gtk_widget_focus_out_event (GtkWidget* _sender, GdkEventFocus* event, gpointer self) {
	gboolean result;
	result = contacts_typecombo_entry_focus_out_event (self, event);
	return result;
}


static void _contacts_typecombo_entry_activate_gtk_entry_activate (GtkEntry* _sender, gpointer self) {
	contacts_typecombo_entry_activate (self);
}


static gboolean _contacts_typecombo_entry_key_release_gtk_widget_key_release_event (GtkWidget* _sender, GdkEventKey* event, gpointer self) {
	gboolean result;
	result = contacts_typecombo_entry_key_release (self, event);
	return result;
}


ContactsTypeCombo* contacts_typecombo_construct (GType object_type, ContactsTypeSet* type_set) {
	ContactsTypeCombo * self = NULL;
	ContactsTypeSet* _tmp0_ = NULL;
	ContactsTypeSet* _tmp1_ = NULL;
	ContactsTypeSet* _tmp2_ = NULL;
	GtkListStore* _tmp3_ = NULL;
	GtkComboBox* _tmp4_ = NULL;
	GtkComboBox* _tmp5_ = NULL;
	GtkComboBox* _tmp6_ = NULL;
	GtkComboBox* _tmp7_ = NULL;
	GtkCellRendererText* renderer = NULL;
	GtkCellRendererText* _tmp8_ = NULL;
	GtkComboBox* _tmp9_ = NULL;
	GtkComboBox* _tmp10_ = NULL;
	GtkComboBox* _tmp11_ = NULL;
	GtkEntry* _tmp12_ = NULL;
	GtkEntry* _tmp13_ = NULL;
	GtkStyleContext* _tmp14_ = NULL;
	GtkEntry* _tmp15_ = NULL;
	GtkEntry* _tmp16_ = NULL;
	GtkEntry* _tmp17_ = NULL;
	GtkEntry* _tmp18_ = NULL;
	GtkComboBox* _tmp19_ = NULL;
	GtkEntry* _tmp20_ = NULL;
	GtkComboBox* _tmp21_ = NULL;
	GtkComboBox* _tmp22_ = NULL;
	GtkEntry* _tmp23_ = NULL;
	GtkEntry* _tmp24_ = NULL;
	GtkEntry* _tmp25_ = NULL;
	g_return_val_if_fail (type_set != NULL, NULL);
	self = (ContactsTypeCombo*) g_object_new (object_type, NULL);
	_tmp0_ = type_set;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->type_set);
	self->priv->type_set = _tmp1_;
	_tmp2_ = type_set;
	_tmp3_ = _tmp2_->store;
	_tmp4_ = (GtkComboBox*) gtk_combo_box_new_with_model ((GtkTreeModel*) _tmp3_);
	g_object_ref_sink (_tmp4_);
	_g_object_unref0 (self->priv->combo);
	self->priv->combo = _tmp4_;
	_tmp5_ = self->priv->combo;
	gtk_widget_set_halign ((GtkWidget*) _tmp5_, GTK_ALIGN_FILL);
	_tmp6_ = self->priv->combo;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp6_, TRUE);
	_tmp7_ = self->priv->combo;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp7_);
	_tmp8_ = (GtkCellRendererText*) gtk_cell_renderer_text_new ();
	g_object_ref_sink (_tmp8_);
	renderer = _tmp8_;
	_tmp9_ = self->priv->combo;
	gtk_cell_layout_pack_start ((GtkCellLayout*) _tmp9_, (GtkCellRenderer*) renderer, TRUE);
	_tmp10_ = self->priv->combo;
	gtk_cell_layout_set_attributes ((GtkCellLayout*) _tmp10_, (GtkCellRenderer*) renderer, "text", 0, NULL);
	_tmp11_ = self->priv->combo;
	gtk_combo_box_set_row_separator_func (_tmp11_, ___lambda35__gtk_tree_view_row_separator_func, g_object_ref (self), g_object_unref);
	_tmp12_ = (GtkEntry*) gtk_entry_new ();
	g_object_ref_sink (_tmp12_);
	_g_object_unref0 (self->priv->entry);
	self->priv->entry = _tmp12_;
	_tmp13_ = self->priv->entry;
	_tmp14_ = gtk_widget_get_style_context ((GtkWidget*) _tmp13_);
	gtk_style_context_add_class (_tmp14_, "contacts-entry");
	_tmp15_ = self->priv->entry;
	gtk_widget_set_halign ((GtkWidget*) _tmp15_, GTK_ALIGN_FILL);
	_tmp16_ = self->priv->entry;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp16_, TRUE);
	_tmp17_ = self->priv->entry;
	gtk_entry_set_width_chars (_tmp17_, 4);
	_tmp18_ = self->priv->entry;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp18_);
	_tmp19_ = self->priv->combo;
	gtk_widget_set_no_show_all ((GtkWidget*) _tmp19_, TRUE);
	_tmp20_ = self->priv->entry;
	gtk_widget_set_no_show_all ((GtkWidget*) _tmp20_, TRUE);
	_tmp21_ = self->priv->combo;
	gtk_widget_show ((GtkWidget*) _tmp21_);
	_tmp22_ = self->priv->combo;
	g_signal_connect_object (_tmp22_, "changed", (GCallback) _contacts_typecombo_combo_changed_gtk_combo_box_changed, self, 0);
	_tmp23_ = self->priv->entry;
	g_signal_connect_object ((GtkWidget*) _tmp23_, "focus-out-event", (GCallback) _contacts_typecombo_entry_focus_out_event_gtk_widget_focus_out_event, self, 0);
	_tmp24_ = self->priv->entry;
	g_signal_connect_object (_tmp24_, "activate", (GCallback) _contacts_typecombo_entry_activate_gtk_entry_activate, self, 0);
	_tmp25_ = self->priv->entry;
	g_signal_connect_object ((GtkWidget*) _tmp25_, "key-release-event", (GCallback) _contacts_typecombo_entry_key_release_gtk_widget_key_release_event, self, 0);
	_g_object_unref0 (renderer);
	return self;
}


ContactsTypeCombo* contacts_typecombo_new (ContactsTypeSet* type_set) {
	return contacts_typecombo_construct (CONTACTS_TYPE_TYPECOMBO, type_set);
}


static void contacts_typecombo_finish_custom (ContactsTypeCombo* self) {
	gboolean _tmp0_ = FALSE;
	gchar* text = NULL;
	GtkEntry* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	const gchar* _tmp4_ = NULL;
	GtkComboBox* _tmp13_ = NULL;
	GtkEntry* _tmp14_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->custom_mode;
	if (!_tmp0_) {
		return;
	}
	self->priv->custom_mode = FALSE;
	_tmp1_ = self->priv->entry;
	_tmp2_ = gtk_entry_get_text (_tmp1_);
	_tmp3_ = g_strdup (_tmp2_);
	text = _tmp3_;
	_tmp4_ = text;
	if (g_strcmp0 (_tmp4_, "") != 0) {
		GtkTreeIter iter = {0};
		ContactsTypeSet* _tmp5_ = NULL;
		const gchar* _tmp6_ = NULL;
		GtkTreeIter _tmp7_ = {0};
		GtkTreeIter _tmp8_ = {0};
		GtkComboBox* _tmp9_ = NULL;
		GtkTreeIter _tmp10_ = {0};
		_tmp5_ = self->priv->type_set;
		_tmp6_ = text;
		contacts_typeset_add_custom_label (_tmp5_, _tmp6_, &_tmp7_);
		iter = _tmp7_;
		_tmp8_ = iter;
		self->priv->last_active = _tmp8_;
		_tmp9_ = self->priv->combo;
		_tmp10_ = iter;
		gtk_combo_box_set_active_iter (_tmp9_, &_tmp10_);
	} else {
		GtkComboBox* _tmp11_ = NULL;
		GtkTreeIter _tmp12_ = {0};
		_tmp11_ = self->priv->combo;
		_tmp12_ = self->priv->last_active;
		gtk_combo_box_set_active_iter (_tmp11_, &_tmp12_);
	}
	_tmp13_ = self->priv->combo;
	gtk_widget_show ((GtkWidget*) _tmp13_);
	_tmp14_ = self->priv->entry;
	gtk_widget_hide ((GtkWidget*) _tmp14_);
	_g_free0 (text);
}


static void contacts_typecombo_entry_activate (ContactsTypeCombo* self) {
	g_return_if_fail (self != NULL);
	contacts_typecombo_finish_custom (self);
}


static gboolean contacts_typecombo_entry_key_release (ContactsTypeCombo* self, GdkEventKey* event) {
	gboolean result = FALSE;
	GdkEventKey _tmp0_ = {0};
	guint _tmp1_ = 0U;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = *event;
	_tmp1_ = _tmp0_.keyval;
	if (_tmp1_ == ((guint) GDK_KEY_Escape)) {
		GtkEntry* _tmp2_ = NULL;
		_tmp2_ = self->priv->entry;
		gtk_entry_set_text (_tmp2_, "");
		contacts_typecombo_finish_custom (self);
	}
	result = TRUE;
	return result;
}


static gboolean contacts_typecombo_entry_focus_out_event (ContactsTypeCombo* self, GdkEventFocus* event) {
	gboolean result = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	contacts_typecombo_finish_custom (self);
	result = FALSE;
	return result;
}


static void contacts_typecombo_combo_changed (ContactsTypeCombo* self, GtkComboBox* combo) {
	gboolean _tmp0_ = FALSE;
	GtkTreeIter iter = {0};
	GtkComboBox* _tmp1_ = NULL;
	GtkTreeIter _tmp2_ = {0};
	gboolean _tmp3_ = FALSE;
	g_return_if_fail (self != NULL);
	g_return_if_fail (combo != NULL);
	_tmp0_ = self->priv->in_manual_change;
	if (_tmp0_) {
		return;
	}
	self->modified = TRUE;
	_tmp1_ = combo;
	_tmp3_ = gtk_combo_box_get_active_iter (_tmp1_, &_tmp2_);
	iter = _tmp2_;
	if (_tmp3_) {
		ContactsTypeSet* _tmp4_ = NULL;
		GtkTreeIter _tmp5_ = {0};
		gboolean _tmp6_ = FALSE;
		_tmp4_ = self->priv->type_set;
		_tmp5_ = iter;
		_tmp6_ = contacts_typeset_is_custom (_tmp4_, &_tmp5_);
		if (_tmp6_) {
			GtkEntry* _tmp7_ = NULL;
			GtkEntry* _tmp8_ = NULL;
			GtkComboBox* _tmp9_ = NULL;
			self->priv->custom_mode = TRUE;
			_tmp7_ = self->priv->entry;
			gtk_widget_show ((GtkWidget*) _tmp7_);
			_tmp8_ = self->priv->entry;
			gtk_widget_grab_focus ((GtkWidget*) _tmp8_);
			_tmp9_ = combo;
			gtk_widget_hide ((GtkWidget*) _tmp9_);
		} else {
			GtkTreeIter _tmp10_ = {0};
			_tmp10_ = iter;
			self->priv->last_active = _tmp10_;
			g_signal_emit_by_name (self, "changed");
		}
	}
}


static void contacts_typecombo_set_from_iter (ContactsTypeCombo* self, GtkTreeIter* iter) {
	GtkTreeIter _tmp0_ = {0};
	GtkComboBox* _tmp1_ = NULL;
	GtkTreeIter _tmp2_ = {0};
	g_return_if_fail (self != NULL);
	g_return_if_fail (iter != NULL);
	self->priv->in_manual_change = TRUE;
	_tmp0_ = *iter;
	self->priv->last_active = _tmp0_;
	_tmp1_ = self->priv->combo;
	_tmp2_ = *iter;
	gtk_combo_box_set_active_iter (_tmp1_, &_tmp2_);
	self->priv->in_manual_change = FALSE;
	self->modified = FALSE;
}


void contacts_typecombo_set_active (ContactsTypeCombo* self, FolksAbstractFieldDetails* details) {
	GtkTreeIter iter = {0};
	ContactsTypeSet* _tmp0_ = NULL;
	FolksAbstractFieldDetails* _tmp1_ = NULL;
	GtkTreeIter _tmp2_ = {0};
	GtkTreeIter _tmp3_ = {0};
	g_return_if_fail (self != NULL);
	g_return_if_fail (details != NULL);
	_tmp0_ = self->priv->type_set;
	_tmp1_ = details;
	contacts_typeset_lookup_type (_tmp0_, _tmp1_, &_tmp2_);
	iter = _tmp2_;
	_tmp3_ = iter;
	contacts_typecombo_set_from_iter (self, &_tmp3_);
}


void contacts_typecombo_set_to (ContactsTypeCombo* self, const gchar* type) {
	GtkTreeIter iter = {0};
	ContactsTypeSet* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	GtkTreeIter _tmp2_ = {0};
	GtkTreeIter _tmp3_ = {0};
	g_return_if_fail (self != NULL);
	g_return_if_fail (type != NULL);
	_tmp0_ = self->priv->type_set;
	_tmp1_ = type;
	contacts_typeset_lookup_type_by_string (_tmp0_, _tmp1_, &_tmp2_);
	iter = _tmp2_;
	_tmp3_ = iter;
	contacts_typecombo_set_from_iter (self, &_tmp3_);
}


void contacts_typecombo_update_details (ContactsTypeCombo* self, FolksAbstractFieldDetails* details) {
	GtkTreeIter iter = {0};
	GtkComboBox* _tmp0_ = NULL;
	GtkTreeIter _tmp1_ = {0};
	ContactsTypeSet* _tmp2_ = NULL;
	FolksAbstractFieldDetails* _tmp3_ = NULL;
	GtkTreeIter _tmp4_ = {0};
	g_return_if_fail (self != NULL);
	g_return_if_fail (details != NULL);
	_tmp0_ = self->priv->combo;
	gtk_combo_box_get_active_iter (_tmp0_, &_tmp1_);
	iter = _tmp1_;
	_tmp2_ = self->priv->type_set;
	_tmp3_ = details;
	_tmp4_ = iter;
	contacts_typeset_update_details (_tmp2_, _tmp3_, &_tmp4_);
}


static void contacts_typecombo_class_init (ContactsTypeComboClass * klass) {
	contacts_typecombo_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (ContactsTypeComboPrivate));
	G_OBJECT_CLASS (klass)->finalize = contacts_typecombo_finalize;
	g_signal_new ("changed", CONTACTS_TYPE_TYPECOMBO, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}


static void contacts_typecombo_instance_init (ContactsTypeCombo * self) {
	self->priv = CONTACTS_TYPECOMBO_GET_PRIVATE (self);
}


static void contacts_typecombo_finalize (GObject* obj) {
	ContactsTypeCombo * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CONTACTS_TYPE_TYPECOMBO, ContactsTypeCombo);
	_g_object_unref0 (self->priv->type_set);
	_g_object_unref0 (self->priv->combo);
	_g_object_unref0 (self->priv->entry);
	G_OBJECT_CLASS (contacts_typecombo_parent_class)->finalize (obj);
}


GType contacts_typecombo_get_type (void) {
	static volatile gsize contacts_typecombo_type_id__volatile = 0;
	if (g_once_init_enter (&contacts_typecombo_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (ContactsTypeComboClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) contacts_typecombo_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ContactsTypeCombo), 0, (GInstanceInitFunc) contacts_typecombo_instance_init, NULL };
		GType contacts_typecombo_type_id;
		contacts_typecombo_type_id = g_type_register_static (GTK_TYPE_GRID, "ContactsTypeCombo", &g_define_type_info, 0);
		g_once_init_leave (&contacts_typecombo_type_id__volatile, contacts_typecombo_type_id);
	}
	return contacts_typecombo_type_id__volatile;
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int 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, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}



