/* contacts-types.c generated by valac 0.26.2, 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 __lambda33_ (ContactsTypeCombo* self, GtkTreeModel* model, GtkTreeIter* iter);
static gboolean ___lambda33__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, -1);
	_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 _tmp20_ = FALSE;
				gint _tmp21_ = 0;
				const gchar* type = NULL;
				ContactsTypeSetInitData* _tmp25_ = NULL;
				gint _tmp26_ = 0;
				const gchar* _tmp27_ = NULL;
				GList* l = NULL;
				GHashTable* _tmp28_ = NULL;
				const gchar* _tmp29_ = NULL;
				gconstpointer _tmp30_ = NULL;
				GList* _tmp31_ = NULL;
				if (!_tmp18_) {
					gint _tmp19_ = 0;
					_tmp19_ = j;
					j = _tmp19_ + 1;
				}
				_tmp18_ = FALSE;
				_tmp21_ = j;
				if (_tmp21_ < CONTACTS_TYPESET_MAX_TYPES) {
					ContactsTypeSetInitData* _tmp22_ = NULL;
					gint _tmp23_ = 0;
					const gchar* _tmp24_ = NULL;
					_tmp22_ = init_data;
					_tmp23_ = j;
					_tmp24_ = (*_tmp22_).types[_tmp23_];
					_tmp20_ = _tmp24_ != NULL;
				} else {
					_tmp20_ = FALSE;
				}
				if (!_tmp20_) {
					break;
				}
				_tmp25_ = init_data;
				_tmp26_ = j;
				_tmp27_ = (*_tmp25_).types[_tmp26_];
				type = _tmp27_;
				_tmp28_ = self->priv->vcard_lookup_hash;
				_tmp29_ = type;
				_tmp30_ = g_hash_table_lookup (_tmp28_, _tmp29_);
				l = (GList*) _tmp30_;
				_tmp31_ = l;
				if (_tmp31_ != NULL) {
					ContactsTypeSetInitData* _tmp32_ = NULL;
					_tmp32_ = init_data;
					l = g_list_append (l, _tmp32_);
				} else {
					GList* l2 = NULL;
					ContactsTypeSetInitData* _tmp33_ = NULL;
					GHashTable* _tmp34_ = NULL;
					const gchar* _tmp35_ = NULL;
					GList* _tmp36_ = NULL;
					l2 = NULL;
					_tmp33_ = init_data;
					l2 = g_list_append (l2, _tmp33_);
					_tmp34_ = self->priv->vcard_lookup_hash;
					_tmp35_ = type;
					_tmp36_ = l2;
					l2 = NULL;
					g_hash_table_insert (_tmp34_, _tmp35_, _tmp36_);
					_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;
	GeeArrayList* list = NULL;
	GeeArrayList* _tmp7_ = NULL;
	GList* l = NULL;
	GHashTable* _tmp21_ = NULL;
	GeeArrayList* _tmp22_ = NULL;
	gpointer _tmp23_ = NULL;
	gchar* _tmp24_ = NULL;
	gconstpointer _tmp25_ = NULL;
	GList* _tmp26_ = NULL;
	GList* _tmp27_ = 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_;
	}
	if (_tmp2_) {
		result = NULL;
		_g_object_unref0 (i);
		return result;
	}
	_tmp7_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL);
	list = _tmp7_;
	{
		GeeIterator* _s_it = NULL;
		FolksAbstractFieldDetails* _tmp8_ = NULL;
		GeeCollection* _tmp9_ = NULL;
		GeeCollection* _tmp10_ = NULL;
		GeeIterator* _tmp11_ = NULL;
		GeeIterator* _tmp12_ = NULL;
		_tmp8_ = detail;
		_tmp9_ = folks_abstract_field_details_get_parameter_values (_tmp8_, "type");
		_tmp10_ = _tmp9_;
		_tmp11_ = gee_iterable_iterator ((GeeIterable*) _tmp10_);
		_tmp12_ = _tmp11_;
		_g_object_unref0 (_tmp10_);
		_s_it = _tmp12_;
		while (TRUE) {
			GeeIterator* _tmp13_ = NULL;
			gboolean _tmp14_ = FALSE;
			gchar* s = NULL;
			GeeIterator* _tmp15_ = NULL;
			gpointer _tmp16_ = NULL;
			GeeArrayList* _tmp17_ = NULL;
			const gchar* _tmp18_ = NULL;
			gchar* _tmp19_ = NULL;
			gchar* _tmp20_ = NULL;
			_tmp13_ = _s_it;
			_tmp14_ = gee_iterator_next (_tmp13_);
			if (!_tmp14_) {
				break;
			}
			_tmp15_ = _s_it;
			_tmp16_ = gee_iterator_get (_tmp15_);
			s = (gchar*) _tmp16_;
			_tmp17_ = list;
			_tmp18_ = s;
			_tmp19_ = g_utf8_strup (_tmp18_, (gssize) (-1));
			_tmp20_ = _tmp19_;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp17_, _tmp20_);
			_g_free0 (_tmp20_);
			_g_free0 (s);
		}
		_g_object_unref0 (_s_it);
	}
	_tmp21_ = self->priv->vcard_lookup_hash;
	_tmp22_ = list;
	_tmp23_ = gee_abstract_list_get ((GeeAbstractList*) _tmp22_, 0);
	_tmp24_ = (gchar*) _tmp23_;
	_tmp25_ = g_hash_table_lookup (_tmp21_, _tmp24_);
	_tmp26_ = (GList*) _tmp25_;
	_g_free0 (_tmp24_);
	l = _tmp26_;
	_tmp27_ = l;
	{
		GList* d_collection = NULL;
		GList* d_it = NULL;
		d_collection = _tmp27_;
		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 _tmp40_ = FALSE;
				all_found = TRUE;
				{
					gint j = 0;
					j = 0;
					{
						gboolean _tmp28_ = FALSE;
						_tmp28_ = TRUE;
						while (TRUE) {
							gboolean _tmp30_ = FALSE;
							gint _tmp31_ = 0;
							GeeArrayList* _tmp35_ = NULL;
							ContactsTypeSetInitData* _tmp36_ = NULL;
							gint _tmp37_ = 0;
							const gchar* _tmp38_ = NULL;
							gboolean _tmp39_ = FALSE;
							if (!_tmp28_) {
								gint _tmp29_ = 0;
								_tmp29_ = j;
								j = _tmp29_ + 1;
							}
							_tmp28_ = FALSE;
							_tmp31_ = j;
							if (_tmp31_ < CONTACTS_TYPESET_MAX_TYPES) {
								ContactsTypeSetInitData* _tmp32_ = NULL;
								gint _tmp33_ = 0;
								const gchar* _tmp34_ = NULL;
								_tmp32_ = d;
								_tmp33_ = j;
								_tmp34_ = (*_tmp32_).types[_tmp33_];
								_tmp30_ = _tmp34_ != NULL;
							} else {
								_tmp30_ = FALSE;
							}
							if (!_tmp30_) {
								break;
							}
							_tmp35_ = list;
							_tmp36_ = d;
							_tmp37_ = j;
							_tmp38_ = (*_tmp36_).types[_tmp37_];
							_tmp39_ = gee_abstract_collection_contains ((GeeAbstractCollection*) _tmp35_, _tmp38_);
							if (!_tmp39_) {
								all_found = FALSE;
								break;
							}
						}
					}
				}
				_tmp40_ = all_found;
				if (_tmp40_) {
					const gchar* dn = NULL;
					ContactsTypeSetInitData* _tmp41_ = NULL;
					const gchar* _tmp42_ = NULL;
					const gchar* _tmp43_ = NULL;
					GHashTable* _tmp44_ = NULL;
					const gchar* _tmp45_ = NULL;
					gconstpointer _tmp46_ = NULL;
					_tmp41_ = d;
					_tmp42_ = (*_tmp41_).display_name_u;
					_tmp43_ = g_dgettext (GETTEXT_PACKAGE, _tmp42_);
					dn = _tmp43_;
					_tmp44_ = self->priv->display_name_hash;
					_tmp45_ = dn;
					_tmp46_ = g_hash_table_lookup (_tmp44_, _tmp45_);
					result = (ContactsTypeSetData*) _tmp46_;
					_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* _tmp45_ = NULL;
	GtkTreeIter _tmp46_ = {0};
	const gchar* _tmp47_ = NULL;
	ContactsTypeSetData* _tmp48_ = NULL;
	ContactsTypeSetData* _tmp49_ = NULL;
	ContactsTypeSetData* _tmp50_ = NULL;
	gboolean _tmp79_ = 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;
			_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;
			}
			if (_tmp27_) {
				{
					GeeIterator* _value_it = NULL;
					GeeMultiMap* _tmp30_ = NULL;
					const gchar* _tmp31_ = NULL;
					GeeCollection* _tmp32_ = NULL;
					GeeCollection* _tmp33_ = NULL;
					GeeIterator* _tmp34_ = NULL;
					GeeIterator* _tmp35_ = NULL;
					_tmp30_ = old_parameters;
					_tmp31_ = param;
					_tmp32_ = gee_multi_map_get (_tmp30_, _tmp31_);
					_tmp33_ = _tmp32_;
					_tmp34_ = gee_iterable_iterator ((GeeIterable*) _tmp33_);
					_tmp35_ = _tmp34_;
					_g_object_unref0 (_tmp33_);
					_value_it = _tmp35_;
					while (TRUE) {
						GeeIterator* _tmp36_ = NULL;
						gboolean _tmp37_ = FALSE;
						gchar* value = NULL;
						GeeIterator* _tmp38_ = NULL;
						gpointer _tmp39_ = NULL;
						FolksAbstractFieldDetails* _tmp40_ = NULL;
						GeeMultiMap* _tmp41_ = NULL;
						GeeMultiMap* _tmp42_ = NULL;
						const gchar* _tmp43_ = NULL;
						const gchar* _tmp44_ = NULL;
						_tmp36_ = _value_it;
						_tmp37_ = gee_iterator_next (_tmp36_);
						if (!_tmp37_) {
							break;
						}
						_tmp38_ = _value_it;
						_tmp39_ = gee_iterator_get (_tmp38_);
						value = (gchar*) _tmp39_;
						_tmp40_ = details;
						_tmp41_ = folks_abstract_field_details_get_parameters (_tmp40_);
						_tmp42_ = _tmp41_;
						_tmp43_ = param;
						_tmp44_ = value;
						gee_multi_map_set (_tmp42_, _tmp43_, _tmp44_);
						_g_free0 (value);
					}
					_g_object_unref0 (_value_it);
				}
			}
			_g_free0 (param);
		}
		_g_object_unref0 (_param_it);
	}
	_tmp45_ = self->store;
	_tmp46_ = *iter;
	gtk_tree_model_get ((GtkTreeModel*) _tmp45_, &_tmp46_, 0, &display_name, 1, &data, -1);
	_tmp47_ = display_name;
	_vala_assert (_tmp47_ != NULL, "display_name != null");
	_tmp48_ = data;
	_tmp49_ = contacts_typeset_custom_dummy;
	_vala_assert (_tmp48_ != _tmp49_, "data != custom_dummy");
	_tmp50_ = data;
	if (_tmp50_ == NULL) {
		FolksAbstractFieldDetails* _tmp51_ = NULL;
		GeeMultiMap* _tmp52_ = NULL;
		GeeMultiMap* _tmp53_ = NULL;
		FolksAbstractFieldDetails* _tmp54_ = NULL;
		GeeMultiMap* _tmp55_ = NULL;
		GeeMultiMap* _tmp56_ = NULL;
		const gchar* _tmp57_ = NULL;
		_tmp51_ = details;
		_tmp52_ = folks_abstract_field_details_get_parameters (_tmp51_);
		_tmp53_ = _tmp52_;
		gee_multi_map_set (_tmp53_, "type", "OTHER");
		_tmp54_ = details;
		_tmp55_ = folks_abstract_field_details_get_parameters (_tmp54_);
		_tmp56_ = _tmp55_;
		_tmp57_ = display_name;
		gee_multi_map_set (_tmp56_, CONTACTS_TYPESET_X_GOOGLE_LABEL, _tmp57_);
	} else {
		ContactsTypeSetData* _tmp58_ = NULL;
		ContactsTypeSetData* _tmp59_ = NULL;
		_tmp58_ = data;
		_tmp59_ = contacts_typeset_other_dummy;
		if (_tmp58_ == _tmp59_) {
			FolksAbstractFieldDetails* _tmp60_ = NULL;
			GeeMultiMap* _tmp61_ = NULL;
			GeeMultiMap* _tmp62_ = NULL;
			_tmp60_ = details;
			_tmp61_ = folks_abstract_field_details_get_parameters (_tmp60_);
			_tmp62_ = _tmp61_;
			gee_multi_map_set (_tmp62_, "type", "OTHER");
		} else {
			ContactsTypeSetInitData* init_data = NULL;
			ContactsTypeSetData* _tmp63_ = NULL;
			GList* _tmp64_ = NULL;
			gconstpointer _tmp65_ = NULL;
			_tmp63_ = data;
			_tmp64_ = _tmp63_->init_data;
			_tmp65_ = _tmp64_->data;
			init_data = _tmp65_;
			{
				gint j = 0;
				j = 0;
				{
					gboolean _tmp66_ = FALSE;
					_tmp66_ = TRUE;
					while (TRUE) {
						gboolean _tmp68_ = FALSE;
						gint _tmp69_ = 0;
						FolksAbstractFieldDetails* _tmp73_ = NULL;
						GeeMultiMap* _tmp74_ = NULL;
						GeeMultiMap* _tmp75_ = NULL;
						ContactsTypeSetInitData* _tmp76_ = NULL;
						gint _tmp77_ = 0;
						const gchar* _tmp78_ = NULL;
						if (!_tmp66_) {
							gint _tmp67_ = 0;
							_tmp67_ = j;
							j = _tmp67_ + 1;
						}
						_tmp66_ = FALSE;
						_tmp69_ = j;
						if (_tmp69_ < CONTACTS_TYPESET_MAX_TYPES) {
							ContactsTypeSetInitData* _tmp70_ = NULL;
							gint _tmp71_ = 0;
							const gchar* _tmp72_ = NULL;
							_tmp70_ = init_data;
							_tmp71_ = j;
							_tmp72_ = (*_tmp70_).types[_tmp71_];
							_tmp68_ = _tmp72_ != NULL;
						} else {
							_tmp68_ = FALSE;
						}
						if (!_tmp68_) {
							break;
						}
						_tmp73_ = details;
						_tmp74_ = folks_abstract_field_details_get_parameters (_tmp73_);
						_tmp75_ = _tmp74_;
						_tmp76_ = init_data;
						_tmp77_ = j;
						_tmp78_ = (*_tmp76_).types[_tmp77_];
						gee_multi_map_set (_tmp75_, "type", _tmp78_);
					}
				}
			}
		}
	}
	_tmp79_ = has_pref;
	if (_tmp79_) {
		FolksAbstractFieldDetails* _tmp80_ = NULL;
		GeeMultiMap* _tmp81_ = NULL;
		GeeMultiMap* _tmp82_ = NULL;
		_tmp80_ = details;
		_tmp81_ = folks_abstract_field_details_get_parameters (_tmp80_);
		_tmp82_ = _tmp81_;
		gee_multi_map_set (_tmp82_, "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* _tmp12_ = 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* _tmp10_ = NULL;
		gchar** _tmp11_ = NULL;
		gint _tmp11__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) {
					gint _tmp7_ = 0;
					ContactsTypeSet* _tmp8_ = NULL;
					gint _tmp9_ = 0;
					if (!_tmp5_) {
						gint _tmp6_ = 0;
						_tmp6_ = i;
						i = _tmp6_ + 1;
					}
					_tmp5_ = FALSE;
					_tmp7_ = i;
					if (!(_tmp7_ < G_N_ELEMENTS (CONTACTS_TYPESET_general_data))) {
						break;
					}
					_tmp8_ = contacts_typeset__general;
					_tmp9_ = i;
					contacts_typeset_add_init_data (_tmp8_, &CONTACTS_TYPESET_general_data[_tmp9_]);
				}
			}
		}
		_tmp10_ = contacts_typeset__general;
		_tmp11_ = standard;
		_tmp11__length1 = standard_length1;
		contacts_typeset_add_init_data_done (_tmp10_, _tmp11_, _tmp11__length1);
	}
	_tmp12_ = contacts_typeset__general;
	result = _tmp12_;
	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* _tmp12_ = 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* _tmp10_ = NULL;
		gchar** _tmp11_ = NULL;
		gint _tmp11__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) {
					gint _tmp7_ = 0;
					ContactsTypeSet* _tmp8_ = NULL;
					gint _tmp9_ = 0;
					if (!_tmp5_) {
						gint _tmp6_ = 0;
						_tmp6_ = i;
						i = _tmp6_ + 1;
					}
					_tmp5_ = FALSE;
					_tmp7_ = i;
					if (!(_tmp7_ < G_N_ELEMENTS (CONTACTS_TYPESET_email_data))) {
						break;
					}
					_tmp8_ = contacts_typeset__email;
					_tmp9_ = i;
					contacts_typeset_add_init_data (_tmp8_, &CONTACTS_TYPESET_email_data[_tmp9_]);
				}
			}
		}
		_tmp10_ = contacts_typeset__email;
		_tmp11_ = standard;
		_tmp11__length1 = standard_length1;
		contacts_typeset_add_init_data_done (_tmp10_, _tmp11_, _tmp11__length1);
	}
	_tmp12_ = contacts_typeset__email;
	result = _tmp12_;
	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* _tmp18_ = 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* _tmp16_ = NULL;
		gchar** _tmp17_ = NULL;
		gint _tmp17__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) {
					gint _tmp8_ = 0;
					ContactsTypeSet* _tmp9_ = NULL;
					gint _tmp10_ = 0;
					if (!_tmp6_) {
						gint _tmp7_ = 0;
						_tmp7_ = i;
						i = _tmp7_ + 1;
					}
					_tmp6_ = FALSE;
					_tmp8_ = i;
					if (!(_tmp8_ < G_N_ELEMENTS (data))) {
						break;
					}
					_tmp9_ = contacts_typeset__phone;
					_tmp10_ = i;
					contacts_typeset_add_init_data (_tmp9_, &data[_tmp10_]);
				}
			}
		}
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp11_ = FALSE;
				_tmp11_ = TRUE;
				while (TRUE) {
					gint _tmp13_ = 0;
					ContactsTypeSet* _tmp14_ = NULL;
					gint _tmp15_ = 0;
					if (!_tmp11_) {
						gint _tmp12_ = 0;
						_tmp12_ = i;
						i = _tmp12_ + 1;
					}
					_tmp11_ = FALSE;
					_tmp13_ = i;
					if (!(_tmp13_ < G_N_ELEMENTS (CONTACTS_TYPESET_general_data))) {
						break;
					}
					_tmp14_ = contacts_typeset__phone;
					_tmp15_ = i;
					contacts_typeset_add_init_data (_tmp14_, &CONTACTS_TYPESET_general_data[_tmp15_]);
				}
			}
		}
		_tmp16_ = contacts_typeset__phone;
		_tmp17_ = standard;
		_tmp17__length1 = standard_length1;
		contacts_typeset_add_init_data_done (_tmp16_, _tmp17_, _tmp17__length1);
	}
	_tmp18_ = contacts_typeset__phone;
	result = _tmp18_;
	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 __lambda33_ (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 ___lambda33__gtk_tree_view_row_separator_func (GtkTreeModel* model, GtkTreeIter* iter, gpointer self) {
	gboolean result;
	result = __lambda33_ ((ContactsTypeCombo*) self, model, iter);
	return result;
}


static void _contacts_typecombo_combo_changed_gtk_combo_box_changed (GtkComboBox* _sender, gpointer self) {
	contacts_typecombo_combo_changed ((ContactsTypeCombo*) 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 ((ContactsTypeCombo*) self, event);
	return result;
}


static void _contacts_typecombo_entry_activate_gtk_entry_activate (GtkEntry* _sender, gpointer self) {
	contacts_typecombo_entry_activate ((ContactsTypeCombo*) 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 ((ContactsTypeCombo*) 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_, ___lambda33__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_ = NULL;
	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_grid_get_type (), "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);
}



