/* contacts-types.c generated by valac 0.36.4, 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;
enum  {
	CONTACTS_TYPECOMBO_CHANGED_SIGNAL,
	CONTACTS_TYPECOMBO_LAST_SIGNAL
};
static guint contacts_typecombo_signals[CONTACTS_TYPECOMBO_LAST_SIGNAL] = {0};
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (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;
};

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 __lambda24_ (ContactsTypeCombo* self, GtkTreeModel* model, GtkTreeIter* iter);
static gboolean ___lambda24__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] = {{N_ ("Home"), {"HOME"}, 3}, {N_ ("Work"), {"WORK"}, 3}};
static const ContactsTypeSetInitData CONTACTS_TYPESET_email_data[3] = {{N_ ("Personal"), {"PERSONAL"}, 3}, {N_ ("Home"), {"HOME"}, 3}, {N_ ("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_;
	GEqualFunc _tmp1_;
	GHashTable* _tmp2_;
	GHashFunc _tmp3_;
	GEqualFunc _tmp4_;
	GHashTable* _tmp5_;
	GHashFunc _tmp6_;
	GEqualFunc _tmp7_;
	GHashTable* _tmp8_;
	GtkListStore* _tmp9_;
	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_;
	gboolean _tmp1_;
	ContactsTypeSetData* _tmp2_;
	gboolean _tmp3_;
	GtkListStore* _tmp10_;
	ContactsTypeSetData* _tmp11_;
	GtkTreeIter _tmp12_;
	ContactsTypeSetData* _tmp13_;
	const gchar* _tmp14_;
	ContactsTypeSetData* _tmp15_;
	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_;
		ContactsTypeSetData* _tmp5_;
		GtkTreeIter _tmp6_ = {0};
		_tmp4_ = self->store;
		_tmp5_ = data;
		gtk_list_store_insert_before (_tmp4_, &_tmp6_, NULL);
		_tmp5_->iter = _tmp6_;
	} else {
		GtkListStore* _tmp7_;
		ContactsTypeSetData* _tmp8_;
		GtkTreeIter _tmp9_ = {0};
		_tmp7_ = self->store;
		_tmp8_ = data;
		gtk_list_store_append (_tmp7_, &_tmp9_);
		_tmp8_->iter = _tmp9_;
	}
	_tmp10_ = self->store;
	_tmp11_ = data;
	_tmp12_ = _tmp11_->iter;
	_tmp13_ = data;
	_tmp14_ = _tmp13_->display_name;
	_tmp15_ = data;
	gtk_list_store_set (_tmp10_, &_tmp12_, 0, _tmp14_, 1, _tmp15_, -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_;
	const gchar* _tmp1_;
	ContactsTypeSetData* data = NULL;
	GHashTable* _tmp2_;
	const gchar* _tmp3_;
	gconstpointer _tmp4_;
	ContactsTypeSetData* _tmp5_;
	ContactsTypeSetData* _tmp6_;
	ContactsTypeSetData* _tmp15_;
	ContactsTypeSetInitData* _tmp16_;
	g_return_if_fail (self != NULL);
	_tmp0_ = init_data;
	_tmp1_ = (*_tmp0_).display_name_u;
	dn = g_dgettext (GETTEXT_PACKAGE, _tmp1_);
	_tmp2_ = self->priv->display_name_hash;
	_tmp3_ = dn;
	_tmp4_ = g_hash_table_lookup (_tmp2_, _tmp3_);
	_tmp5_ = _g_object_ref0 ((ContactsTypeSetData*) _tmp4_);
	data = _tmp5_;
	_tmp6_ = data;
	if (_tmp6_ == NULL) {
		ContactsTypeSetData* _tmp7_;
		ContactsTypeSetData* _tmp8_;
		const gchar* _tmp9_;
		gchar* _tmp10_;
		GHashTable* _tmp11_;
		const gchar* _tmp12_;
		ContactsTypeSetData* _tmp13_;
		ContactsTypeSetData* _tmp14_;
		_tmp7_ = contacts_typeset_data_new ();
		_g_object_unref0 (data);
		data = _tmp7_;
		_tmp8_ = data;
		_tmp9_ = dn;
		_tmp10_ = g_strdup (_tmp9_);
		_g_free0 (_tmp8_->display_name);
		_tmp8_->display_name = _tmp10_;
		_tmp11_ = self->priv->display_name_hash;
		_tmp12_ = dn;
		_tmp13_ = data;
		_tmp14_ = _g_object_ref0 (_tmp13_);
		g_hash_table_insert (_tmp11_, _tmp12_, _tmp14_);
	}
	_tmp15_ = data;
	_tmp16_ = init_data;
	_tmp15_->init_data = g_list_append (_tmp15_->init_data, _tmp16_);
	{
		gint j = 0;
		j = 0;
		{
			gboolean _tmp17_ = FALSE;
			_tmp17_ = TRUE;
			while (TRUE) {
				gboolean _tmp19_ = FALSE;
				gint _tmp20_;
				const gchar* type = NULL;
				ContactsTypeSetInitData* _tmp24_;
				gint _tmp25_;
				const gchar* _tmp26_;
				GList* l = NULL;
				GHashTable* _tmp27_;
				const gchar* _tmp28_;
				gconstpointer _tmp29_;
				GList* _tmp30_;
				if (!_tmp17_) {
					gint _tmp18_;
					_tmp18_ = j;
					j = _tmp18_ + 1;
				}
				_tmp17_ = FALSE;
				_tmp20_ = j;
				if (_tmp20_ < CONTACTS_TYPESET_MAX_TYPES) {
					ContactsTypeSetInitData* _tmp21_;
					gint _tmp22_;
					const gchar* _tmp23_;
					_tmp21_ = init_data;
					_tmp22_ = j;
					_tmp23_ = (*_tmp21_).types[_tmp22_];
					_tmp19_ = _tmp23_ != NULL;
				} else {
					_tmp19_ = FALSE;
				}
				if (!_tmp19_) {
					break;
				}
				_tmp24_ = init_data;
				_tmp25_ = j;
				_tmp26_ = (*_tmp24_).types[_tmp25_];
				type = _tmp26_;
				_tmp27_ = self->priv->vcard_lookup_hash;
				_tmp28_ = type;
				_tmp29_ = g_hash_table_lookup (_tmp27_, _tmp28_);
				l = (GList*) _tmp29_;
				_tmp30_ = l;
				if (_tmp30_ != NULL) {
					ContactsTypeSetInitData* _tmp31_;
					_tmp31_ = init_data;
					l = g_list_append (l, _tmp31_);
				} else {
					GList* l2 = NULL;
					ContactsTypeSetInitData* _tmp32_;
					GHashTable* _tmp33_;
					const gchar* _tmp34_;
					GList* _tmp35_;
					l2 = NULL;
					_tmp32_ = init_data;
					l2 = g_list_append (l2, _tmp32_);
					_tmp33_ = self->priv->vcard_lookup_hash;
					_tmp34_ = type;
					_tmp35_ = l2;
					l2 = NULL;
					g_hash_table_insert (_tmp33_, _tmp34_, _tmp35_);
					_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_;
	gint _tmp0__length1;
	GtkListStore* _tmp9_;
	GtkTreeIter _tmp10_ = {0};
	GtkListStore* _tmp11_;
	GtkTreeIter _tmp12_;
	ContactsTypeSetData* _tmp13_;
	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_;
			gchar* untranslated = NULL;
			_tmp1_ = g_strdup (untranslated_collection[untranslated_it]);
			untranslated = _tmp1_;
			{
				ContactsTypeSetData* data = NULL;
				GHashTable* _tmp2_;
				const gchar* _tmp3_;
				gconstpointer _tmp4_;
				ContactsTypeSetData* _tmp5_;
				ContactsTypeSetData* _tmp6_;
				_tmp2_ = self->priv->display_name_hash;
				_tmp3_ = untranslated;
				_tmp4_ = g_hash_table_lookup (_tmp2_, g_dgettext (GETTEXT_PACKAGE, _tmp3_));
				_tmp5_ = _g_object_ref0 ((ContactsTypeSetData*) _tmp4_);
				data = _tmp5_;
				_tmp6_ = data;
				if (_tmp6_ != NULL) {
					ContactsTypeSetData* _tmp7_;
					_tmp7_ = data;
					contacts_typeset_add_data_to_store (self, _tmp7_, FALSE);
				} else {
					const gchar* _tmp8_;
					_tmp8_ = untranslated;
					g_error ("contacts-types.vala:108: Internal error: Can't find display name %s in" \
" TypeSet data", _tmp8_);
				}
				_g_object_unref0 (data);
				_g_free0 (untranslated);
			}
		}
	}
	_tmp9_ = self->store;
	gtk_list_store_append (_tmp9_, &_tmp10_);
	self->priv->other_iter = _tmp10_;
	_tmp11_ = self->store;
	_tmp12_ = self->priv->other_iter;
	_tmp13_ = contacts_typeset_other_dummy;
	gtk_list_store_set (_tmp11_, &_tmp12_, 0, _ ("Other"), 1, _tmp13_, -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_;
	const gchar* _tmp1_;
	gconstpointer _tmp2_;
	ContactsTypeSetData* _tmp3_;
	ContactsTypeSetData* _tmp4_;
	const gchar* _tmp8_;
	GtkTreeIter* iterp = NULL;
	GHashTable* _tmp10_;
	const gchar* _tmp11_;
	gconstpointer _tmp12_;
	GtkTreeIter* _tmp13_;
	GtkListStore* _tmp15_;
	GtkTreeIter _tmp16_ = {0};
	GtkListStore* _tmp17_;
	GtkTreeIter _tmp18_;
	const gchar* _tmp19_;
	GHashTable* _tmp20_;
	const gchar* _tmp21_;
	gchar* _tmp22_;
	GtkTreeIter _tmp23_;
	GtkTreeIter* _tmp24_;
	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_;
		ContactsTypeSetData* _tmp6_;
		GtkTreeIter _tmp7_;
		_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;
	if (g_strcmp0 (_tmp8_, _ ("Other")) == 0) {
		GtkTreeIter _tmp9_;
		_tmp9_ = self->priv->other_iter;
		_vala_iter = _tmp9_;
		_g_object_unref0 (data);
		if (iter) {
			*iter = _vala_iter;
		}
		return;
	}
	_tmp10_ = self->priv->custom_hash;
	_tmp11_ = label;
	_tmp12_ = g_hash_table_lookup (_tmp10_, _tmp11_);
	iterp = (GtkTreeIter*) _tmp12_;
	_tmp13_ = iterp;
	if (_tmp13_ != NULL) {
		GtkTreeIter* _tmp14_;
		_tmp14_ = iterp;
		_vala_iter = *_tmp14_;
		_g_object_unref0 (data);
		if (iter) {
			*iter = _vala_iter;
		}
		return;
	}
	_tmp15_ = self->store;
	gtk_list_store_insert_before (_tmp15_, &_tmp16_, NULL);
	_vala_iter = _tmp16_;
	_tmp17_ = self->store;
	_tmp18_ = _vala_iter;
	_tmp19_ = label;
	gtk_list_store_set (_tmp17_, &_tmp18_, 0, _tmp19_, 1, NULL, -1);
	_tmp20_ = self->priv->custom_hash;
	_tmp21_ = label;
	_tmp22_ = g_strdup (_tmp21_);
	_tmp23_ = _vala_iter;
	_tmp24_ = __gtk_tree_iter_dup0 (&_tmp23_);
	g_hash_table_insert (_tmp20_, _tmp22_, _tmp24_);
	_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_;
	const gchar* _tmp1_;
	gconstpointer _tmp2_;
	GList* _tmp3_;
	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_;
				const gchar* _tmp5_;
				_tmp4_ = d;
				_tmp5_ = (*_tmp4_).types[1];
				if (_tmp5_ == NULL) {
					const gchar* dn = NULL;
					ContactsTypeSetInitData* _tmp6_;
					const gchar* _tmp7_;
					GHashTable* _tmp8_;
					const gchar* _tmp9_;
					gconstpointer _tmp10_;
					_tmp6_ = d;
					_tmp7_ = (*_tmp6_).display_name_u;
					dn = g_dgettext (GETTEXT_PACKAGE, _tmp7_);
					_tmp8_ = self->priv->display_name_hash;
					_tmp9_ = dn;
					_tmp10_ = g_hash_table_lookup (_tmp8_, _tmp9_);
					result = (ContactsTypeSetData*) _tmp10_;
					return result;
				}
			}
		}
	}
	result = NULL;
	return result;
}


static ContactsTypeSetData* contacts_typeset_lookup_data (ContactsTypeSet* self, FolksAbstractFieldDetails* detail) {
	ContactsTypeSetData* result = NULL;
	GeeCollection* i = NULL;
	FolksAbstractFieldDetails* _tmp0_;
	GeeCollection* _tmp1_;
	gboolean _tmp2_ = FALSE;
	GeeCollection* _tmp3_;
	GeeArrayList* list = NULL;
	GeeArrayList* _tmp7_;
	GList* l = NULL;
	GHashTable* _tmp21_;
	GeeArrayList* _tmp22_;
	gpointer _tmp23_;
	gchar* _tmp24_;
	gconstpointer _tmp25_;
	GList* _tmp26_;
	GList* _tmp27_;
	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_;
		gboolean _tmp5_;
		gboolean _tmp6_;
		_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, (GDestroyNotify) g_free, NULL, NULL, NULL);
	list = _tmp7_;
	{
		GeeIterator* _s_it = NULL;
		FolksAbstractFieldDetails* _tmp8_;
		GeeCollection* _tmp9_;
		GeeCollection* _tmp10_;
		GeeIterator* _tmp11_;
		GeeIterator* _tmp12_;
		_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_;
			gboolean _tmp14_;
			gchar* s = NULL;
			GeeIterator* _tmp15_;
			gpointer _tmp16_;
			GeeArrayList* _tmp17_;
			const gchar* _tmp18_;
			gchar* _tmp19_;
			gchar* _tmp20_;
			_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_;
				all_found = TRUE;
				{
					gint j = 0;
					j = 0;
					{
						gboolean _tmp28_ = FALSE;
						_tmp28_ = TRUE;
						while (TRUE) {
							gboolean _tmp30_ = FALSE;
							gint _tmp31_;
							GeeArrayList* _tmp35_;
							ContactsTypeSetInitData* _tmp36_;
							gint _tmp37_;
							const gchar* _tmp38_;
							gboolean _tmp39_;
							if (!_tmp28_) {
								gint _tmp29_;
								_tmp29_ = j;
								j = _tmp29_ + 1;
							}
							_tmp28_ = FALSE;
							_tmp31_ = j;
							if (_tmp31_ < CONTACTS_TYPESET_MAX_TYPES) {
								ContactsTypeSetInitData* _tmp32_;
								gint _tmp33_;
								const gchar* _tmp34_;
								_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_;
					const gchar* _tmp42_;
					GHashTable* _tmp43_;
					const gchar* _tmp44_;
					gconstpointer _tmp45_;
					_tmp41_ = d;
					_tmp42_ = (*_tmp41_).display_name_u;
					dn = g_dgettext (GETTEXT_PACKAGE, _tmp42_);
					_tmp43_ = self->priv->display_name_hash;
					_tmp44_ = dn;
					_tmp45_ = g_hash_table_lookup (_tmp43_, _tmp44_);
					result = (ContactsTypeSetData*) _tmp45_;
					_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_;
	GeeMultiMap* _tmp1_;
	GeeMultiMap* _tmp2_;
	gboolean _tmp3_;
	ContactsTypeSetData* d = NULL;
	FolksAbstractFieldDetails* _tmp13_;
	ContactsTypeSetData* _tmp14_;
	ContactsTypeSetData* _tmp15_;
	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_;
		GeeMultiMap* _tmp5_;
		GeeMultiMap* _tmp6_;
		GeeCollection* _tmp7_;
		GeeCollection* _tmp8_;
		gpointer _tmp9_;
		gchar* _tmp10_;
		const gchar* _tmp11_;
		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, (GDestroyNotify) 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_;
		ContactsTypeSetData* _tmp17_;
		GtkTreeIter _tmp18_;
		_tmp16_ = d;
		contacts_typeset_add_data_to_store (self, _tmp16_, TRUE);
		_tmp17_ = d;
		_tmp18_ = _tmp17_->iter;
		_vala_iter = _tmp18_;
	} else {
		GtkTreeIter _tmp19_;
		_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_;
	ContactsTypeSetData* _tmp1_;
	ContactsTypeSetData* _tmp2_;
	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_;
		GtkTreeIter _tmp4_;
		_tmp3_ = d;
		_tmp4_ = _tmp3_->iter;
		_vala_iter = _tmp4_;
	} else {
		GtkTreeIter _tmp5_;
		_tmp5_ = self->priv->other_iter;
		_vala_iter = _tmp5_;
	}
	if (iter) {
		*iter = _vala_iter;
	}
}


void contacts_typeset_type_seen (ContactsTypeSet* self, FolksAbstractFieldDetails* detail) {
	FolksAbstractFieldDetails* _tmp0_;
	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_;
	GeeMultiMap* _tmp1_;
	GeeMultiMap* _tmp2_;
	gboolean _tmp3_;
	ContactsTypeSetData* d = NULL;
	FolksAbstractFieldDetails* _tmp11_;
	ContactsTypeSetData* _tmp12_;
	ContactsTypeSetData* _tmp13_;
	gchar* _tmp17_;
	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_;
		GeeMultiMap* _tmp5_;
		GeeMultiMap* _tmp6_;
		GeeCollection* _tmp7_;
		GeeCollection* _tmp8_;
		gpointer _tmp9_;
		gchar* _tmp10_;
		_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, (GDestroyNotify) 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_;
		const gchar* _tmp15_;
		gchar* _tmp16_;
		_tmp14_ = d;
		_tmp15_ = _tmp14_->display_name;
		_tmp16_ = g_strdup (_tmp15_);
		result = _tmp16_;
		return result;
	}
	_tmp17_ = g_strdup (_ ("Other"));
	result = _tmp17_;
	return result;
}


void contacts_typeset_update_details (ContactsTypeSet* self, FolksAbstractFieldDetails* details, GtkTreeIter* iter) {
	GeeMultiMap* old_parameters = NULL;
	FolksAbstractFieldDetails* _tmp0_;
	GeeMultiMap* _tmp1_;
	GeeMultiMap* _tmp2_;
	GeeMultiMap* _tmp3_;
	FolksAbstractFieldDetails* _tmp4_;
	GeeHashMultiMap* _tmp5_;
	GeeHashMultiMap* _tmp6_;
	gboolean has_pref = FALSE;
	ContactsTypeSetData* data = NULL;
	gchar* display_name = NULL;
	GtkListStore* _tmp45_;
	GtkTreeIter _tmp46_;
	const gchar* _tmp47_;
	ContactsTypeSetData* _tmp48_;
	ContactsTypeSetData* _tmp49_;
	ContactsTypeSetData* _tmp50_;
	gboolean _tmp79_;
	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, (GDestroyNotify) g_free, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) 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_;
		GeeCollection* _tmp8_;
		GeeCollection* _tmp9_;
		GeeIterator* _tmp10_;
		GeeIterator* _tmp11_;
		_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_;
			gboolean _tmp13_;
			gchar* value = NULL;
			GeeIterator* _tmp14_;
			gpointer _tmp15_;
			const gchar* _tmp16_;
			gint _tmp17_;
			_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_;
		GeeSet* _tmp19_;
		GeeSet* _tmp20_;
		GeeIterator* _tmp21_;
		GeeIterator* _tmp22_;
		_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_;
			gboolean _tmp24_;
			gchar* param = NULL;
			GeeIterator* _tmp25_;
			gpointer _tmp26_;
			gboolean _tmp27_ = FALSE;
			const gchar* _tmp28_;
			_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_;
				_tmp29_ = param;
				_tmp27_ = g_strcmp0 (_tmp29_, CONTACTS_TYPESET_X_GOOGLE_LABEL) != 0;
			} else {
				_tmp27_ = FALSE;
			}
			if (_tmp27_) {
				{
					GeeIterator* _value_it = NULL;
					GeeMultiMap* _tmp30_;
					const gchar* _tmp31_;
					GeeCollection* _tmp32_;
					GeeCollection* _tmp33_;
					GeeIterator* _tmp34_;
					GeeIterator* _tmp35_;
					_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_;
						gboolean _tmp37_;
						gchar* value = NULL;
						GeeIterator* _tmp38_;
						gpointer _tmp39_;
						FolksAbstractFieldDetails* _tmp40_;
						GeeMultiMap* _tmp41_;
						GeeMultiMap* _tmp42_;
						const gchar* _tmp43_;
						const gchar* _tmp44_;
						_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_;
		GeeMultiMap* _tmp52_;
		GeeMultiMap* _tmp53_;
		FolksAbstractFieldDetails* _tmp54_;
		GeeMultiMap* _tmp55_;
		GeeMultiMap* _tmp56_;
		const gchar* _tmp57_;
		_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_;
		ContactsTypeSetData* _tmp59_;
		_tmp58_ = data;
		_tmp59_ = contacts_typeset_other_dummy;
		if (_tmp58_ == _tmp59_) {
			FolksAbstractFieldDetails* _tmp60_;
			GeeMultiMap* _tmp61_;
			GeeMultiMap* _tmp62_;
			_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_;
			GList* _tmp64_;
			gconstpointer _tmp65_;
			_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_;
						FolksAbstractFieldDetails* _tmp73_;
						GeeMultiMap* _tmp74_;
						GeeMultiMap* _tmp75_;
						ContactsTypeSetInitData* _tmp76_;
						gint _tmp77_;
						const gchar* _tmp78_;
						if (!_tmp66_) {
							gint _tmp67_;
							_tmp67_ = j;
							j = _tmp67_ + 1;
						}
						_tmp66_ = FALSE;
						_tmp69_ = j;
						if (_tmp69_ < CONTACTS_TYPESET_MAX_TYPES) {
							ContactsTypeSetInitData* _tmp70_;
							gint _tmp71_;
							const gchar* _tmp72_;
							_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_;
		GeeMultiMap* _tmp81_;
		GeeMultiMap* _tmp82_;
		_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_;
	GtkTreeIter _tmp1_;
	ContactsTypeSetData* _tmp2_;
	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_;
	gchar* _tmp1_;
	gchar** _tmp2_;
	gint standard_length1;
	gint _standard_size_;
	ContactsTypeSet* _tmp3_;
	ContactsTypeSet* _tmp12_;
	_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_;
		ContactsTypeSet* _tmp10_;
		gchar** _tmp11_;
		gint _tmp11__length1;
		_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_;
					ContactsTypeSet* _tmp8_;
					gint _tmp9_;
					if (!_tmp5_) {
						gint _tmp6_;
						_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_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar** _tmp3_;
	gint standard_length1;
	gint _standard_size_;
	ContactsTypeSet* _tmp4_;
	ContactsTypeSet* _tmp13_;
	_tmp0_ = g_strdup ("Personal");
	_tmp1_ = g_strdup ("Home");
	_tmp2_ = g_strdup ("Work");
	_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__email;
	if (_tmp4_ == NULL) {
		ContactsTypeSet* _tmp5_;
		ContactsTypeSet* _tmp11_;
		gchar** _tmp12_;
		gint _tmp12__length1;
		_tmp5_ = contacts_typeset_new ();
		_g_object_unref0 (contacts_typeset__email);
		contacts_typeset__email = _tmp5_;
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp6_ = FALSE;
				_tmp6_ = TRUE;
				while (TRUE) {
					gint _tmp8_;
					ContactsTypeSet* _tmp9_;
					gint _tmp10_;
					if (!_tmp6_) {
						gint _tmp7_;
						_tmp7_ = i;
						i = _tmp7_ + 1;
					}
					_tmp6_ = 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[] = {{N_ ("Assistant"), {"X-EVOLUTION-ASSISTANT"}, 3}, {N_ ("Work"), {"WORK", "VOICE"}, 3}, {N_ ("Work Fax"), {"WORK", "FAX"}, 3}, {N_ ("Callback"), {"X-EVOLUTION-CALLBACK"}, 3}, {N_ ("Car"), {"CAR"}, 3}, {N_ ("Company"), {"X-EVOLUTION-COMPANY"}, 3}, {N_ ("Home"), {"HOME", "VOICE"}, 3}, {N_ ("Home Fax"), {"HOME", "FAX"}, 3}, {N_ ("ISDN"), {"ISDN"}, 3}, {N_ ("Mobile"), {"CELL"}, 3}, {N_ ("Other"), {"VOICE"}, 3}, {N_ ("Fax"), {"FAX"}, 3}, {N_ ("Pager"), {"PAGER"}, 3}, {N_ ("Radio"), {"X-EVOLUTION-RADIO"}, 3}, {N_ ("Telex"), {"X-EVOLUTION-TELEX"}, 3}, {N_ ("TTY"), {"X-EVOLUTION-TTYTDD"}, 3}};
	gchar** standard = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar** _tmp3_;
	gint standard_length1;
	gint _standard_size_;
	ContactsTypeSet* _tmp4_;
	ContactsTypeSet* _tmp18_;
	_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_;
		ContactsTypeSet* _tmp16_;
		gchar** _tmp17_;
		gint _tmp17__length1;
		_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_;
					ContactsTypeSet* _tmp9_;
					gint _tmp10_;
					if (!_tmp6_) {
						gint _tmp7_;
						_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_;
					ContactsTypeSet* _tmp14_;
					gint _tmp15_;
					if (!_tmp11_) {
						gint _tmp12_;
						_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_;
	ContactsTypeSetData* _tmp1_;
	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 __lambda24_ (ContactsTypeCombo* self, GtkTreeModel* model, GtkTreeIter* iter) {
	gboolean result = FALSE;
	gchar* s = NULL;
	GtkTreeModel* _tmp0_;
	GtkTreeIter _tmp1_;
	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 ___lambda24__gtk_tree_view_row_separator_func (GtkTreeModel* model, GtkTreeIter* iter, gpointer self) {
	gboolean result;
	result = __lambda24_ ((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_;
	ContactsTypeSet* _tmp1_;
	ContactsTypeSet* _tmp2_;
	GtkListStore* _tmp3_;
	GtkComboBox* _tmp4_;
	GtkComboBox* _tmp5_;
	GtkComboBox* _tmp6_;
	GtkComboBox* _tmp7_;
	GtkCellRendererText* renderer = NULL;
	GtkCellRendererText* _tmp8_;
	GtkComboBox* _tmp9_;
	GtkComboBox* _tmp10_;
	GtkComboBox* _tmp11_;
	GtkEntry* _tmp12_;
	GtkEntry* _tmp13_;
	GtkStyleContext* _tmp14_;
	GtkEntry* _tmp15_;
	GtkEntry* _tmp16_;
	GtkEntry* _tmp17_;
	GtkEntry* _tmp18_;
	GtkComboBox* _tmp19_;
	GtkEntry* _tmp20_;
	GtkComboBox* _tmp21_;
	GtkComboBox* _tmp22_;
	GtkEntry* _tmp23_;
	GtkEntry* _tmp24_;
	GtkEntry* _tmp25_;
	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_, ___lambda24__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_;
	gchar* text = NULL;
	GtkEntry* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	GtkComboBox* _tmp13_;
	GtkEntry* _tmp14_;
	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_;
		const gchar* _tmp6_;
		GtkTreeIter _tmp7_ = {0};
		GtkTreeIter _tmp8_;
		GtkComboBox* _tmp9_;
		GtkTreeIter _tmp10_;
		_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_;
		GtkTreeIter _tmp12_;
		_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_;
	guint _tmp1_;
	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_;
		_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_;
	GtkTreeIter iter = {0};
	GtkComboBox* _tmp1_;
	GtkTreeIter _tmp2_ = {0};
	gboolean _tmp3_;
	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_;
		GtkTreeIter _tmp5_;
		gboolean _tmp6_;
		_tmp4_ = self->priv->type_set;
		_tmp5_ = iter;
		_tmp6_ = contacts_typeset_is_custom (_tmp4_, &_tmp5_);
		if (_tmp6_) {
			GtkEntry* _tmp7_;
			GtkEntry* _tmp8_;
			GtkComboBox* _tmp9_;
			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_;
			_tmp10_ = iter;
			self->priv->last_active = _tmp10_;
			g_signal_emit (self, contacts_typecombo_signals[CONTACTS_TYPECOMBO_CHANGED_SIGNAL], 0);
		}
	}
}


static void contacts_typecombo_set_from_iter (ContactsTypeCombo* self, GtkTreeIter* iter) {
	GtkTreeIter _tmp0_;
	GtkComboBox* _tmp1_;
	GtkTreeIter _tmp2_;
	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_;
	FolksAbstractFieldDetails* _tmp1_;
	GtkTreeIter _tmp2_ = {0};
	GtkTreeIter _tmp3_;
	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_;
	const gchar* _tmp1_;
	GtkTreeIter _tmp2_ = {0};
	GtkTreeIter _tmp3_;
	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_;
	GtkTreeIter _tmp1_ = {0};
	ContactsTypeSet* _tmp2_;
	FolksAbstractFieldDetails* _tmp3_;
	GtkTreeIter _tmp4_;
	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;
	contacts_typecombo_signals[CONTACTS_TYPECOMBO_CHANGED_SIGNAL] = 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);
}



