/* contacts-accounts-list.c generated by valac 0.56.3, the Vala compiler
 * generated from contacts-accounts-list.vala, do not modify */

/*
 * Copyright (C) 2011 Erick Pérez Castellanos <erick.red@gmail.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 <adwaita.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <glib.h>
#include "contacts.h"
#include <folks/folks.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <libedataserver/libedataserver.h>
#include <folks/folks-eds.h>
#include <config.h>

#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define CONTACTS_TYPE_ACCOUNTS_LIST (contacts_accounts_list_get_type ())
#define CONTACTS_ACCOUNTS_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONTACTS_TYPE_ACCOUNTS_LIST, ContactsAccountsList))
#define CONTACTS_ACCOUNTS_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONTACTS_TYPE_ACCOUNTS_LIST, ContactsAccountsListClass))
#define CONTACTS_IS_ACCOUNTS_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONTACTS_TYPE_ACCOUNTS_LIST))
#define CONTACTS_IS_ACCOUNTS_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONTACTS_TYPE_ACCOUNTS_LIST))
#define CONTACTS_ACCOUNTS_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONTACTS_TYPE_ACCOUNTS_LIST, ContactsAccountsListClass))

typedef struct _ContactsAccountsList ContactsAccountsList;
typedef struct _ContactsAccountsListClass ContactsAccountsListClass;
typedef struct _ContactsAccountsListPrivate ContactsAccountsListPrivate;

#define CONTACTS_ACCOUNTS_LIST_TYPE_ADDRESSBOOK_ROW (contacts_accounts_list_addressbook_row_get_type ())
#define CONTACTS_ACCOUNTS_LIST_ADDRESSBOOK_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONTACTS_ACCOUNTS_LIST_TYPE_ADDRESSBOOK_ROW, ContactsAccountsListAddressbookRow))
#define CONTACTS_ACCOUNTS_LIST_ADDRESSBOOK_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONTACTS_ACCOUNTS_LIST_TYPE_ADDRESSBOOK_ROW, ContactsAccountsListAddressbookRowClass))
#define CONTACTS_ACCOUNTS_LIST_IS_ADDRESSBOOK_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONTACTS_ACCOUNTS_LIST_TYPE_ADDRESSBOOK_ROW))
#define CONTACTS_ACCOUNTS_LIST_IS_ADDRESSBOOK_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONTACTS_ACCOUNTS_LIST_TYPE_ADDRESSBOOK_ROW))
#define CONTACTS_ACCOUNTS_LIST_ADDRESSBOOK_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONTACTS_ACCOUNTS_LIST_TYPE_ADDRESSBOOK_ROW, ContactsAccountsListAddressbookRowClass))

typedef struct _ContactsAccountsListAddressbookRow ContactsAccountsListAddressbookRow;
typedef struct _ContactsAccountsListAddressbookRowClass ContactsAccountsListAddressbookRowClass;
enum  {
	CONTACTS_ACCOUNTS_LIST_0_PROPERTY,
	CONTACTS_ACCOUNTS_LIST_SELECTED_STORE_PROPERTY,
	CONTACTS_ACCOUNTS_LIST_NUM_PROPERTIES
};
static GParamSpec* contacts_accounts_list_properties[CONTACTS_ACCOUNTS_LIST_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_ptr_array_unref0(var) ((var == NULL) ? NULL : (var = (g_ptr_array_unref (var), NULL)))
typedef struct _ContactsAccountsListAddressbookRowPrivate ContactsAccountsListAddressbookRowPrivate;
enum  {
	CONTACTS_ACCOUNTS_LIST_ADDRESSBOOK_ROW_0_PROPERTY,
	CONTACTS_ACCOUNTS_LIST_ADDRESSBOOK_ROW_PERSONA_STORE_PROPERTY,
	CONTACTS_ACCOUNTS_LIST_ADDRESSBOOK_ROW_SELECTED_PROPERTY,
	CONTACTS_ACCOUNTS_LIST_ADDRESSBOOK_ROW_NUM_PROPERTIES
};
static GParamSpec* contacts_accounts_list_addressbook_row_properties[CONTACTS_ACCOUNTS_LIST_ADDRESSBOOK_ROW_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

struct _ContactsAccountsList {
	AdwPreferencesGroup parent_instance;
	ContactsAccountsListPrivate * priv;
};

struct _ContactsAccountsListClass {
	AdwPreferencesGroupClass parent_class;
};

struct _ContactsAccountsListPrivate {
	GtkSingleSelection* selection;
	GPtrArray* rows;
};

struct _ContactsAccountsListAddressbookRow {
	AdwActionRow parent_instance;
	ContactsAccountsListAddressbookRowPrivate * priv;
};

struct _ContactsAccountsListAddressbookRowClass {
	AdwActionRowClass parent_class;
};

struct _ContactsAccountsListAddressbookRowPrivate {
	FolksPersonaStore* _persona_store;
	gboolean _selected;
};

static gint ContactsAccountsList_private_offset;
static gpointer contacts_accounts_list_parent_class = NULL;
static gint ContactsAccountsListAddressbookRow_private_offset;
static gpointer contacts_accounts_list_addressbook_row_parent_class = NULL;

VALA_EXTERN GType contacts_accounts_list_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ContactsAccountsList, g_object_unref)
static GType contacts_accounts_list_addressbook_row_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ContactsAccountsListAddressbookRow, g_object_unref)
static void _g_object_unref0_ (gpointer var);
VALA_EXTERN ContactsAccountsList* contacts_accounts_list_new (ContactsStore* contacts_store);
VALA_EXTERN ContactsAccountsList* contacts_accounts_list_construct (GType object_type,
                                                        ContactsStore* contacts_store);
static gboolean __lambda4_ (ContactsAccountsList* self,
                     GObject* item);
static gboolean ___lambda4__gtk_custom_filter_func (GObject* item,
                                             gpointer self);
static void contacts_accounts_list_on_model_items_changed (ContactsAccountsList* self,
                                                    GListModel* model,
                                                    guint pos,
                                                    guint removed,
                                                    guint added);
static void _contacts_accounts_list_on_model_items_changed_g_list_model_items_changed (GListModel* _sender,
                                                                                guint position,
                                                                                guint removed,
                                                                                guint added,
                                                                                gpointer self);
static void __lambda6_ (ContactsAccountsList* self,
                 GtkSelectionModel* sel,
                 guint pos,
                 guint n_items);
static void contacts_accounts_list_addressbook_row_set_selected (ContactsAccountsListAddressbookRow* self,
                                                          gboolean value);
static void ___lambda6__gtk_selection_model_selection_changed (GtkSelectionModel* _sender,
                                                        guint position,
                                                        guint n_items,
                                                        gpointer self);
static ContactsAccountsListAddressbookRow* contacts_accounts_list_addressbook_row_new (FolksPersonaStore* persona_store);
static ContactsAccountsListAddressbookRow* contacts_accounts_list_addressbook_row_construct (GType object_type,
                                                                                      FolksPersonaStore* persona_store);
static void _____lambda5_ (ContactsAccountsList* self,
                    AdwActionRow* row);
static void ______lambda5__adw_action_row_activated (AdwActionRow* _sender,
                                              gpointer self);
VALA_EXTERN FolksPersonaStore* contacts_accounts_list_get_selected_store (ContactsAccountsList* self);
static FolksPersonaStore* contacts_accounts_list_addressbook_row_get_persona_store (ContactsAccountsListAddressbookRow* self);
static void contacts_accounts_list_addressbook_row_set_persona_store (ContactsAccountsListAddressbookRow* self,
                                                               FolksPersonaStore* value);
static gboolean contacts_accounts_list_addressbook_row_get_selected (ContactsAccountsListAddressbookRow* self);
static GObject * contacts_accounts_list_addressbook_row_constructor (GType type,
                                                              guint n_construct_properties,
                                                              GObjectConstructParam * construct_properties);
static void contacts_accounts_list_addressbook_row_finalize (GObject * obj);
static GType contacts_accounts_list_addressbook_row_get_type_once (void);
static void _vala_contacts_accounts_list_addressbook_row_get_property (GObject * object,
                                                                guint property_id,
                                                                GValue * value,
                                                                GParamSpec * pspec);
static void _vala_contacts_accounts_list_addressbook_row_set_property (GObject * object,
                                                                guint property_id,
                                                                const GValue * value,
                                                                GParamSpec * pspec);
static void contacts_accounts_list_finalize (GObject * obj);
static GType contacts_accounts_list_get_type_once (void);
static void _vala_contacts_accounts_list_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec);

static inline gpointer
contacts_accounts_list_get_instance_private (ContactsAccountsList* self)
{
	return G_STRUCT_MEMBER_P (self, ContactsAccountsList_private_offset);
}

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

static gboolean
__lambda4_ (ContactsAccountsList* self,
            GObject* item)
{
	FolksPersonaStore* store = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gboolean result;
	g_return_val_if_fail (item != NULL, FALSE);
	store = G_TYPE_CHECK_INSTANCE_CAST (item, FOLKS_TYPE_PERSONA_STORE, FolksPersonaStore);
	_tmp0_ = folks_persona_store_get_type_id (store);
	_tmp1_ = _tmp0_;
	result = g_strcmp0 (_tmp1_, "eds") == 0;
	return result;
}

static gboolean
___lambda4__gtk_custom_filter_func (GObject* item,
                                    gpointer self)
{
	gboolean result;
	result = __lambda4_ ((ContactsAccountsList*) self, item);
	return result;
}

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

static void
_contacts_accounts_list_on_model_items_changed_g_list_model_items_changed (GListModel* _sender,
                                                                           guint position,
                                                                           guint removed,
                                                                           guint added,
                                                                           gpointer self)
{
	contacts_accounts_list_on_model_items_changed ((ContactsAccountsList*) self, _sender, position, removed, added);
}

static void
__lambda6_ (ContactsAccountsList* self,
            GtkSelectionModel* sel,
            guint pos,
            guint n_items)
{
	g_return_if_fail (sel != NULL);
	{
		guint i = 0U;
		i = pos;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GPtrArray* _tmp2_;
				gconstpointer _tmp3_;
				GtkSingleSelection* _tmp4_;
				if (!_tmp0_) {
					guint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				if (!(i < (pos + n_items))) {
					break;
				}
				_tmp2_ = self->priv->rows;
				_tmp3_ = g_ptr_array_index (_tmp2_, i);
				_tmp4_ = self->priv->selection;
				contacts_accounts_list_addressbook_row_set_selected ((ContactsAccountsListAddressbookRow*) _tmp3_, gtk_selection_model_is_selected ((GtkSelectionModel*) _tmp4_, i));
			}
		}
	}
	g_object_notify ((GObject*) self, "selected-store");
}

static void
___lambda6__gtk_selection_model_selection_changed (GtkSelectionModel* _sender,
                                                   guint position,
                                                   guint n_items,
                                                   gpointer self)
{
	__lambda6_ ((ContactsAccountsList*) self, _sender, position, n_items);
}

ContactsAccountsList*
contacts_accounts_list_construct (GType object_type,
                                  ContactsStore* contacts_store)
{
	ContactsAccountsList * self = NULL;
	GtkCustomFilter* filter = NULL;
	GtkCustomFilter* _tmp0_;
	GtkFilterListModel* model = NULL;
	GListModel* _tmp1_;
	GListModel* _tmp2_;
	GListModel* _tmp3_;
	GtkCustomFilter* _tmp4_;
	GtkFilterListModel* _tmp5_;
	GtkFilterListModel* _tmp6_;
	GtkFilterListModel* _tmp7_;
	GtkFilterListModel* _tmp8_;
	GtkSingleSelection* _tmp9_;
	GtkSingleSelection* _tmp10_;
	GtkSingleSelection* _tmp11_;
	GtkFilterListModel* _tmp12_;
	GtkSingleSelection* _tmp13_;
	g_return_val_if_fail (contacts_store != NULL, NULL);
	self = (ContactsAccountsList*) g_object_new (object_type, NULL);
	_tmp0_ = gtk_custom_filter_new (___lambda4__gtk_custom_filter_func, g_object_ref (self), g_object_unref);
	filter = _tmp0_;
	_tmp1_ = contacts_store_get_address_books (contacts_store);
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	_tmp4_ = filter;
	filter = NULL;
	_tmp5_ = gtk_filter_list_model_new (_tmp3_, (GtkFilter*) _tmp4_);
	model = _tmp5_;
	_tmp6_ = model;
	g_signal_connect_object ((GListModel*) _tmp6_, "items-changed", (GCallback) _contacts_accounts_list_on_model_items_changed_g_list_model_items_changed, self, 0);
	_tmp7_ = model;
	_tmp8_ = model;
	contacts_accounts_list_on_model_items_changed (self, (GListModel*) _tmp7_, (guint) 0, (guint) 0, g_list_model_get_n_items ((GListModel*) _tmp8_));
	_tmp9_ = gtk_single_selection_new (NULL);
	_g_object_unref0 (self->priv->selection);
	self->priv->selection = _tmp9_;
	_tmp10_ = self->priv->selection;
	gtk_single_selection_set_autoselect (_tmp10_, FALSE);
	_tmp11_ = self->priv->selection;
	_tmp12_ = model;
	gtk_single_selection_set_model (_tmp11_, (GListModel*) _tmp12_);
	_tmp13_ = self->priv->selection;
	g_signal_connect_object ((GtkSelectionModel*) _tmp13_, "selection-changed", (GCallback) ___lambda6__gtk_selection_model_selection_changed, self, 0);
	{
		guint i = 0U;
		i = (guint) 0;
		{
			gboolean _tmp14_ = FALSE;
			_tmp14_ = TRUE;
			while (TRUE) {
				GtkFilterListModel* _tmp16_;
				FolksPersonaStore* persona_store = NULL;
				GtkFilterListModel* _tmp17_;
				GObject* _tmp18_;
				FolksPersonaStore* _tmp19_;
				FolksIndividualAggregator* _tmp20_;
				FolksIndividualAggregator* _tmp21_;
				FolksPersonaStore* _tmp22_;
				FolksPersonaStore* _tmp23_;
				if (!_tmp14_) {
					guint _tmp15_;
					_tmp15_ = i;
					i = _tmp15_ + 1;
				}
				_tmp14_ = FALSE;
				_tmp16_ = model;
				if (!(i < g_list_model_get_n_items ((GListModel*) _tmp16_))) {
					break;
				}
				_tmp17_ = model;
				_tmp18_ = g_list_model_get_item ((GListModel*) _tmp17_, i);
				persona_store = G_TYPE_CHECK_INSTANCE_CAST (_tmp18_, FOLKS_TYPE_PERSONA_STORE, FolksPersonaStore);
				_tmp19_ = persona_store;
				_tmp20_ = contacts_store_get_aggregator (contacts_store);
				_tmp21_ = _tmp20_;
				_tmp22_ = folks_individual_aggregator_get_primary_store (_tmp21_);
				_tmp23_ = _tmp22_;
				if (_tmp19_ == _tmp23_) {
					GtkSingleSelection* _tmp24_;
					_tmp24_ = self->priv->selection;
					gtk_single_selection_set_selected (_tmp24_, i);
				}
				_g_object_unref0 (persona_store);
			}
		}
	}
	_g_object_unref0 (model);
	_g_object_unref0 (filter);
	return self;
}

ContactsAccountsList*
contacts_accounts_list_new (ContactsStore* contacts_store)
{
	return contacts_accounts_list_construct (CONTACTS_TYPE_ACCOUNTS_LIST, contacts_store);
}

static void
_____lambda5_ (ContactsAccountsList* self,
               AdwActionRow* row)
{
	GtkSingleSelection* _tmp0_;
	g_return_if_fail (row != NULL);
	_tmp0_ = self->priv->selection;
	gtk_single_selection_set_selected (_tmp0_, (guint) gtk_list_box_row_get_index ((GtkListBoxRow*) row));
}

static void
______lambda5__adw_action_row_activated (AdwActionRow* _sender,
                                         gpointer self)
{
	_____lambda5_ ((ContactsAccountsList*) self, _sender);
}

static void
contacts_accounts_list_on_model_items_changed (ContactsAccountsList* self,
                                               GListModel* model,
                                               guint pos,
                                               guint removed,
                                               guint added)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (model != NULL);
	{
		guint i = 0U;
		i = pos;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GPtrArray* _tmp2_;
				gconstpointer _tmp3_;
				GPtrArray* _tmp4_;
				if (!_tmp0_) {
					guint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				if (!(i < (pos + removed))) {
					break;
				}
				_tmp2_ = self->priv->rows;
				_tmp3_ = g_ptr_array_index (_tmp2_, i);
				adw_preferences_group_remove ((AdwPreferencesGroup*) self, (GtkWidget*) ((ContactsAccountsListAddressbookRow*) _tmp3_));
				_tmp4_ = self->priv->rows;
				g_ptr_array_remove_index (_tmp4_, i);
			}
		}
	}
	{
		guint i = 0U;
		i = pos;
		{
			gboolean _tmp5_ = FALSE;
			_tmp5_ = TRUE;
			while (TRUE) {
				FolksPersonaStore* persona_store = NULL;
				GObject* _tmp7_;
				ContactsAccountsListAddressbookRow* row = NULL;
				FolksPersonaStore* _tmp8_;
				ContactsAccountsListAddressbookRow* _tmp9_;
				ContactsAccountsListAddressbookRow* _tmp10_;
				GPtrArray* _tmp11_;
				ContactsAccountsListAddressbookRow* _tmp12_;
				ContactsAccountsListAddressbookRow* _tmp13_;
				ContactsAccountsListAddressbookRow* _tmp14_;
				if (!_tmp5_) {
					guint _tmp6_;
					_tmp6_ = i;
					i = _tmp6_ + 1;
				}
				_tmp5_ = FALSE;
				if (!(i < (pos + added))) {
					break;
				}
				_tmp7_ = g_list_model_get_item (model, i);
				persona_store = G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, FOLKS_TYPE_PERSONA_STORE, FolksPersonaStore);
				_tmp8_ = persona_store;
				_tmp9_ = contacts_accounts_list_addressbook_row_new (_tmp8_);
				g_object_ref_sink (_tmp9_);
				row = _tmp9_;
				_tmp10_ = row;
				adw_preferences_group_add ((AdwPreferencesGroup*) self, (GtkWidget*) _tmp10_);
				_tmp11_ = self->priv->rows;
				_tmp12_ = row;
				_tmp13_ = _g_object_ref0 (_tmp12_);
				g_ptr_array_add (_tmp11_, _tmp13_);
				_tmp14_ = row;
				g_signal_connect_object ((AdwActionRow*) _tmp14_, "activated", (GCallback) ______lambda5__adw_action_row_activated, self, 0);
				_g_object_unref0 (row);
				_g_object_unref0 (persona_store);
			}
		}
	}
}

FolksPersonaStore*
contacts_accounts_list_get_selected_store (ContactsAccountsList* self)
{
	FolksPersonaStore* result;
	GtkSingleSelection* _tmp0_;
	GObject* _tmp1_;
	GObject* _tmp2_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->selection;
	_tmp1_ = gtk_single_selection_get_selected_item (_tmp0_);
	_tmp2_ = _tmp1_;
	result = G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, FOLKS_TYPE_PERSONA_STORE, FolksPersonaStore);
	return result;
}

static inline gpointer
contacts_accounts_list_addressbook_row_get_instance_private (ContactsAccountsListAddressbookRow* self)
{
	return G_STRUCT_MEMBER_P (self, ContactsAccountsListAddressbookRow_private_offset);
}

static ContactsAccountsListAddressbookRow*
contacts_accounts_list_addressbook_row_construct (GType object_type,
                                                  FolksPersonaStore* persona_store)
{
	ContactsAccountsListAddressbookRow * self = NULL;
	g_return_val_if_fail (persona_store != NULL, NULL);
	self = (ContactsAccountsListAddressbookRow*) g_object_new (object_type, "persona-store", persona_store, NULL);
	return self;
}

static ContactsAccountsListAddressbookRow*
contacts_accounts_list_addressbook_row_new (FolksPersonaStore* persona_store)
{
	return contacts_accounts_list_addressbook_row_construct (CONTACTS_ACCOUNTS_LIST_TYPE_ADDRESSBOOK_ROW, persona_store);
}

static FolksPersonaStore*
contacts_accounts_list_addressbook_row_get_persona_store (ContactsAccountsListAddressbookRow* self)
{
	FolksPersonaStore* result;
	FolksPersonaStore* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_persona_store;
	result = _tmp0_;
	return result;
}

static void
contacts_accounts_list_addressbook_row_set_persona_store (ContactsAccountsListAddressbookRow* self,
                                                          FolksPersonaStore* value)
{
	FolksPersonaStore* old_value;
	g_return_if_fail (self != NULL);
	old_value = contacts_accounts_list_addressbook_row_get_persona_store (self);
	if (old_value != value) {
		FolksPersonaStore* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_persona_store);
		self->priv->_persona_store = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, contacts_accounts_list_addressbook_row_properties[CONTACTS_ACCOUNTS_LIST_ADDRESSBOOK_ROW_PERSONA_STORE_PROPERTY]);
	}
}

static gboolean
contacts_accounts_list_addressbook_row_get_selected (ContactsAccountsListAddressbookRow* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_selected;
	return result;
}

static void
contacts_accounts_list_addressbook_row_set_selected (ContactsAccountsListAddressbookRow* self,
                                                     gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = contacts_accounts_list_addressbook_row_get_selected (self);
	if (old_value != value) {
		self->priv->_selected = value;
		g_object_notify_by_pspec ((GObject *) self, contacts_accounts_list_addressbook_row_properties[CONTACTS_ACCOUNTS_LIST_ADDRESSBOOK_ROW_SELECTED_PROPERTY]);
	}
}

static GObject *
contacts_accounts_list_addressbook_row_constructor (GType type,
                                                    guint n_construct_properties,
                                                    GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	ContactsAccountsListAddressbookRow * self;
	ESource* source = NULL;
	FolksPersonaStore* _tmp0_;
	ESource* _tmp1_;
	ESource* _tmp2_;
	ESource* _tmp3_;
	ESource* parent_source = NULL;
	ESourceRegistry* _tmp4_;
	ESource* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	ESource* _tmp8_;
	FolksPersonaStore* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* source_account_id = NULL;
	gchar* _tmp12_;
	ESource* _tmp13_;
	GtkImage* provider_image = NULL;
	gboolean _tmp21_ = FALSE;
	FolksPersonaStore* _tmp22_;
	const gchar* _tmp23_;
	const gchar* _tmp24_;
	GtkImage* _tmp29_;
	GtkImage* _tmp30_;
	FolksPersonaStore* _tmp31_;
	gchar* _tmp32_;
	gchar* _tmp33_;
	ESource* _tmp34_;
	const gchar* _tmp35_;
	const gchar* _tmp36_;
	GtkImage* checkmark = NULL;
	GtkImage* _tmp37_;
	GtkImage* _tmp38_;
	GtkImage* _tmp39_;
	GtkImage* _tmp40_;
	parent_class = G_OBJECT_CLASS (contacts_accounts_list_addressbook_row_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CONTACTS_ACCOUNTS_LIST_TYPE_ADDRESSBOOK_ROW, ContactsAccountsListAddressbookRow);
	_tmp0_ = self->priv->_persona_store;
	_tmp1_ = edsf_persona_store_get_source (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, EDSF_TYPE_PERSONA_STORE, EdsfPersonaStore));
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	source = _tmp3_;
	_tmp4_ = contacts_eds_source_registry;
	_tmp5_ = source;
	_tmp6_ = e_source_get_parent (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = e_source_registry_ref_source (_tmp4_, _tmp7_);
	parent_source = _tmp8_;
	_tmp9_ = self->priv->_persona_store;
	_tmp10_ = contacts_utils_format_persona_store_name (_tmp9_);
	_tmp11_ = _tmp10_;
	g_debug ("contacts-accounts-list.vala:101: Contact store \"%s\"", _tmp11_);
	_g_free0 (_tmp11_);
	_tmp12_ = g_strdup ("");
	source_account_id = _tmp12_;
	_tmp13_ = parent_source;
	if (e_source_has_extension (_tmp13_, E_SOURCE_EXTENSION_GOA)) {
		ESourceGoa* goa_source_ext = NULL;
		ESource* _tmp14_;
		ESourceExtension* _tmp15_;
		ESourceGoa* _tmp16_;
		ESourceGoa* _tmp17_;
		const gchar* _tmp18_;
		const gchar* _tmp19_;
		gchar* _tmp20_;
		_tmp14_ = parent_source;
		_tmp15_ = e_source_get_extension (_tmp14_, E_SOURCE_EXTENSION_GOA);
		_tmp16_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp15_, e_source_goa_get_type ()) ? ((ESourceGoa*) _tmp15_) : NULL);
		goa_source_ext = _tmp16_;
		_tmp17_ = goa_source_ext;
		_tmp18_ = e_source_goa_get_account_id (_tmp17_);
		_tmp19_ = _tmp18_;
		_tmp20_ = g_strdup (_tmp19_);
		_g_free0 (source_account_id);
		source_account_id = _tmp20_;
		_g_object_unref0 (goa_source_ext);
	}
	_tmp22_ = self->priv->_persona_store;
	_tmp23_ = folks_persona_store_get_id (_tmp22_);
	_tmp24_ = _tmp23_;
	if (g_strcmp0 (_tmp24_, "system-address-book") != 0) {
		const gchar* _tmp25_;
		_tmp25_ = source_account_id;
		_tmp21_ = g_strcmp0 (_tmp25_, "") != 0;
	} else {
		_tmp21_ = FALSE;
	}
	if (_tmp21_) {
		const gchar* _tmp26_;
		GtkImage* _tmp27_;
		_tmp26_ = source_account_id;
		_tmp27_ = contacts_get_icon_for_goa_account (_tmp26_);
		_g_object_unref0 (provider_image);
		provider_image = _tmp27_;
	} else {
		GtkImage* _tmp28_;
		_tmp28_ = (GtkImage*) gtk_image_new_from_icon_name (APP_ID);
		g_object_ref_sink (_tmp28_);
		_g_object_unref0 (provider_image);
		provider_image = _tmp28_;
	}
	_tmp29_ = provider_image;
	gtk_image_set_icon_size (_tmp29_, GTK_ICON_SIZE_LARGE);
	_tmp30_ = provider_image;
	adw_action_row_add_prefix ((AdwActionRow*) self, (GtkWidget*) _tmp30_);
	_tmp31_ = self->priv->_persona_store;
	_tmp32_ = contacts_utils_format_persona_store_name (_tmp31_);
	_tmp33_ = _tmp32_;
	adw_preferences_row_set_title ((AdwPreferencesRow*) self, _tmp33_);
	_g_free0 (_tmp33_);
	_tmp34_ = parent_source;
	_tmp35_ = e_source_get_display_name (_tmp34_);
	_tmp36_ = _tmp35_;
	adw_action_row_set_subtitle ((AdwActionRow*) self, _tmp36_);
	_tmp37_ = (GtkImage*) gtk_image_new_from_icon_name ("object-select-symbolic");
	g_object_ref_sink (_tmp37_);
	checkmark = _tmp37_;
	_tmp38_ = checkmark;
	g_object_bind_property_with_closures ((GObject*) self, "selected", (GObject*) _tmp38_, "visible", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp39_ = checkmark;
	adw_action_row_add_suffix ((AdwActionRow*) self, (GtkWidget*) _tmp39_);
	_tmp40_ = checkmark;
	adw_action_row_set_activatable_widget ((AdwActionRow*) self, (GtkWidget*) _tmp40_);
	_g_object_unref0 (checkmark);
	_g_object_unref0 (provider_image);
	_g_free0 (source_account_id);
	_g_object_unref0 (parent_source);
	_g_object_unref0 (source);
	return obj;
}

static void
contacts_accounts_list_addressbook_row_class_init (ContactsAccountsListAddressbookRowClass * klass,
                                                   gpointer klass_data)
{
	contacts_accounts_list_addressbook_row_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ContactsAccountsListAddressbookRow_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_contacts_accounts_list_addressbook_row_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_contacts_accounts_list_addressbook_row_set_property;
	G_OBJECT_CLASS (klass)->constructor = contacts_accounts_list_addressbook_row_constructor;
	G_OBJECT_CLASS (klass)->finalize = contacts_accounts_list_addressbook_row_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), CONTACTS_ACCOUNTS_LIST_ADDRESSBOOK_ROW_PERSONA_STORE_PROPERTY, contacts_accounts_list_addressbook_row_properties[CONTACTS_ACCOUNTS_LIST_ADDRESSBOOK_ROW_PERSONA_STORE_PROPERTY] = g_param_spec_object ("persona-store", "persona-store", "persona-store", FOLKS_TYPE_PERSONA_STORE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CONTACTS_ACCOUNTS_LIST_ADDRESSBOOK_ROW_SELECTED_PROPERTY, contacts_accounts_list_addressbook_row_properties[CONTACTS_ACCOUNTS_LIST_ADDRESSBOOK_ROW_SELECTED_PROPERTY] = g_param_spec_boolean ("selected", "selected", "selected", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
contacts_accounts_list_addressbook_row_instance_init (ContactsAccountsListAddressbookRow * self,
                                                      gpointer klass)
{
	self->priv = contacts_accounts_list_addressbook_row_get_instance_private (self);
	self->priv->_selected = FALSE;
}

static void
contacts_accounts_list_addressbook_row_finalize (GObject * obj)
{
	ContactsAccountsListAddressbookRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CONTACTS_ACCOUNTS_LIST_TYPE_ADDRESSBOOK_ROW, ContactsAccountsListAddressbookRow);
	_g_object_unref0 (self->priv->_persona_store);
	G_OBJECT_CLASS (contacts_accounts_list_addressbook_row_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
contacts_accounts_list_addressbook_row_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ContactsAccountsListAddressbookRowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) contacts_accounts_list_addressbook_row_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ContactsAccountsListAddressbookRow), 0, (GInstanceInitFunc) contacts_accounts_list_addressbook_row_instance_init, NULL };
	GType contacts_accounts_list_addressbook_row_type_id;
	contacts_accounts_list_addressbook_row_type_id = g_type_register_static (adw_action_row_get_type (), "ContactsAccountsListAddressbookRow", &g_define_type_info, 0);
	ContactsAccountsListAddressbookRow_private_offset = g_type_add_instance_private (contacts_accounts_list_addressbook_row_type_id, sizeof (ContactsAccountsListAddressbookRowPrivate));
	return contacts_accounts_list_addressbook_row_type_id;
}

static GType
contacts_accounts_list_addressbook_row_get_type (void)
{
	static volatile gsize contacts_accounts_list_addressbook_row_type_id__once = 0;
	if (g_once_init_enter (&contacts_accounts_list_addressbook_row_type_id__once)) {
		GType contacts_accounts_list_addressbook_row_type_id;
		contacts_accounts_list_addressbook_row_type_id = contacts_accounts_list_addressbook_row_get_type_once ();
		g_once_init_leave (&contacts_accounts_list_addressbook_row_type_id__once, contacts_accounts_list_addressbook_row_type_id);
	}
	return contacts_accounts_list_addressbook_row_type_id__once;
}

static void
_vala_contacts_accounts_list_addressbook_row_get_property (GObject * object,
                                                           guint property_id,
                                                           GValue * value,
                                                           GParamSpec * pspec)
{
	ContactsAccountsListAddressbookRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, CONTACTS_ACCOUNTS_LIST_TYPE_ADDRESSBOOK_ROW, ContactsAccountsListAddressbookRow);
	switch (property_id) {
		case CONTACTS_ACCOUNTS_LIST_ADDRESSBOOK_ROW_PERSONA_STORE_PROPERTY:
		g_value_set_object (value, contacts_accounts_list_addressbook_row_get_persona_store (self));
		break;
		case CONTACTS_ACCOUNTS_LIST_ADDRESSBOOK_ROW_SELECTED_PROPERTY:
		g_value_set_boolean (value, contacts_accounts_list_addressbook_row_get_selected (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_contacts_accounts_list_addressbook_row_set_property (GObject * object,
                                                           guint property_id,
                                                           const GValue * value,
                                                           GParamSpec * pspec)
{
	ContactsAccountsListAddressbookRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, CONTACTS_ACCOUNTS_LIST_TYPE_ADDRESSBOOK_ROW, ContactsAccountsListAddressbookRow);
	switch (property_id) {
		case CONTACTS_ACCOUNTS_LIST_ADDRESSBOOK_ROW_PERSONA_STORE_PROPERTY:
		contacts_accounts_list_addressbook_row_set_persona_store (self, g_value_get_object (value));
		break;
		case CONTACTS_ACCOUNTS_LIST_ADDRESSBOOK_ROW_SELECTED_PROPERTY:
		contacts_accounts_list_addressbook_row_set_selected (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
contacts_accounts_list_class_init (ContactsAccountsListClass * klass,
                                   gpointer klass_data)
{
	contacts_accounts_list_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ContactsAccountsList_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_contacts_accounts_list_get_property;
	G_OBJECT_CLASS (klass)->finalize = contacts_accounts_list_finalize;
	/** The selected PersonaStore (or null if none) */
	g_object_class_install_property (G_OBJECT_CLASS (klass), CONTACTS_ACCOUNTS_LIST_SELECTED_STORE_PROPERTY, contacts_accounts_list_properties[CONTACTS_ACCOUNTS_LIST_SELECTED_STORE_PROPERTY] = g_param_spec_object ("selected-store", "selected-store", "selected-store", FOLKS_TYPE_PERSONA_STORE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
contacts_accounts_list_instance_init (ContactsAccountsList * self,
                                      gpointer klass)
{
	GPtrArray* _tmp0_;
	self->priv = contacts_accounts_list_get_instance_private (self);
	_tmp0_ = g_ptr_array_new_full ((guint) 0, _g_object_unref0_);
	self->priv->rows = _tmp0_;
}

static void
contacts_accounts_list_finalize (GObject * obj)
{
	ContactsAccountsList * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CONTACTS_TYPE_ACCOUNTS_LIST, ContactsAccountsList);
	_g_object_unref0 (self->priv->selection);
	_g_ptr_array_unref0 (self->priv->rows);
	G_OBJECT_CLASS (contacts_accounts_list_parent_class)->finalize (obj);
}

/**
 * The AccountsList widget provides a way to list all the known address books
 * for a user, as well as providing a means of selecting a "primary" address
 * book, ie the address book that will be used to write the details of a
 * contact to.
 *
 * Internally, each "address book" is a {@link Folks.PersonaStore}.
 */
 G_GNUC_NO_INLINE static GType
contacts_accounts_list_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ContactsAccountsListClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) contacts_accounts_list_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ContactsAccountsList), 0, (GInstanceInitFunc) contacts_accounts_list_instance_init, NULL };
	GType contacts_accounts_list_type_id;
	contacts_accounts_list_type_id = g_type_register_static (adw_preferences_group_get_type (), "ContactsAccountsList", &g_define_type_info, 0);
	ContactsAccountsList_private_offset = g_type_add_instance_private (contacts_accounts_list_type_id, sizeof (ContactsAccountsListPrivate));
	return contacts_accounts_list_type_id;
}

GType
contacts_accounts_list_get_type (void)
{
	static volatile gsize contacts_accounts_list_type_id__once = 0;
	if (g_once_init_enter (&contacts_accounts_list_type_id__once)) {
		GType contacts_accounts_list_type_id;
		contacts_accounts_list_type_id = contacts_accounts_list_get_type_once ();
		g_once_init_leave (&contacts_accounts_list_type_id__once, contacts_accounts_list_type_id);
	}
	return contacts_accounts_list_type_id__once;
}

static void
_vala_contacts_accounts_list_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec)
{
	ContactsAccountsList * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, CONTACTS_TYPE_ACCOUNTS_LIST, ContactsAccountsList);
	switch (property_id) {
		case CONTACTS_ACCOUNTS_LIST_SELECTED_STORE_PROPERTY:
		g_value_set_object (value, contacts_accounts_list_get_selected_store (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

