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

/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 8 -*- */
/*
 * 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 <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <folks/folks.h>
#include <glib/gi18n-lib.h>
#include <libedataserver/libedataserver.h>
#include <folks/folks-eds.h>
#include <contacts-esd-setup.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>


#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 _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_list_free0(var) ((var == NULL) ? NULL : (var = (g_list_free (var), NULL)))

#define CONTACTS_TYPE_APP (contacts_app_get_type ())
#define CONTACTS_APP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONTACTS_TYPE_APP, ContactsApp))
#define CONTACTS_APP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONTACTS_TYPE_APP, ContactsAppClass))
#define CONTACTS_IS_APP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONTACTS_TYPE_APP))
#define CONTACTS_IS_APP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONTACTS_TYPE_APP))
#define CONTACTS_APP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONTACTS_TYPE_APP, ContactsAppClass))

typedef struct _ContactsApp ContactsApp;
typedef struct _ContactsAppClass ContactsAppClass;
typedef struct _ContactsAppPrivate ContactsAppPrivate;

#define CONTACTS_TYPE_STORE (contacts_store_get_type ())
#define CONTACTS_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONTACTS_TYPE_STORE, ContactsStore))
#define CONTACTS_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONTACTS_TYPE_STORE, ContactsStoreClass))
#define CONTACTS_IS_STORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONTACTS_TYPE_STORE))
#define CONTACTS_IS_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONTACTS_TYPE_STORE))
#define CONTACTS_STORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONTACTS_TYPE_STORE, ContactsStoreClass))

typedef struct _ContactsStore ContactsStore;
typedef struct _ContactsStoreClass ContactsStoreClass;

#define CONTACTS_TYPE_WINDOW (contacts_window_get_type ())
#define CONTACTS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONTACTS_TYPE_WINDOW, ContactsWindow))
#define CONTACTS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONTACTS_TYPE_WINDOW, ContactsWindowClass))
#define CONTACTS_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONTACTS_TYPE_WINDOW))
#define CONTACTS_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONTACTS_TYPE_WINDOW))
#define CONTACTS_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONTACTS_TYPE_WINDOW, ContactsWindowClass))

typedef struct _ContactsWindow ContactsWindow;
typedef struct _ContactsWindowClass ContactsWindowClass;
#define _g_free0(var) (var = (g_free (var), NULL))

struct _ContactsAccountsList {
	GtkFrame parent_instance;
	ContactsAccountsListPrivate * priv;
	FolksPersonaStore* selected_store;
};

struct _ContactsAccountsListClass {
	GtkFrameClass parent_class;
};

struct _ContactsAccountsListPrivate {
	GtkListBox* accounts_view;
	GtkListBoxRow* last_selected_row;
	GtkButton* add_account_button;
};

struct _ContactsApp {
	GtkApplication parent_instance;
	ContactsAppPrivate * priv;
	GSettings* settings;
	ContactsStore* contacts_store;
	ContactsWindow* window;
};

struct _ContactsAppClass {
	GtkApplicationClass parent_class;
};


static gpointer contacts_accounts_list_parent_class = NULL;
extern ContactsApp* contacts_app_app;

GType contacts_accounts_list_get_type (void) G_GNUC_CONST;
#define CONTACTS_ACCOUNTS_LIST_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CONTACTS_TYPE_ACCOUNTS_LIST, ContactsAccountsListPrivate))
enum  {
	CONTACTS_ACCOUNTS_LIST_DUMMY_PROPERTY
};
ContactsAccountsList* contacts_accounts_list_new (void);
ContactsAccountsList* contacts_accounts_list_construct (GType object_type);
static void contacts_accounts_list_update_header_func (ContactsAccountsList* self, GtkListBoxRow* row, GtkListBoxRow* before);
static void _contacts_accounts_list_update_header_func_gtk_list_box_update_header_func (GtkListBoxRow* row, GtkListBoxRow* before, gpointer self);
static void __lambda96_ (ContactsAccountsList* self);
static void ___lambda96__gtk_button_clicked (GtkButton* _sender, gpointer self);
static void contacts_accounts_list_row_selected (ContactsAccountsList* self, GtkListBoxRow* row);
static void _contacts_accounts_list_row_selected_gtk_list_box_row_selected (GtkListBox* _sender, GtkListBoxRow* row, gpointer self);
void contacts_accounts_list_update_contents (ContactsAccountsList* self, gboolean select_active);
FolksPersonaStore** contacts_app_get_eds_address_books (int* result_length1);
gchar* contacts_contact_format_persona_store_name (FolksPersonaStore* store);
GType contacts_app_get_type (void) G_GNUC_CONST;
GType contacts_store_get_type (void) G_GNUC_CONST;
GType contacts_window_get_type (void) G_GNUC_CONST;
FolksIndividualAggregator* contacts_store_get_aggregator (ContactsStore* self);
static void contacts_accounts_list_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 void _contacts_accounts_list_update_header_func_gtk_list_box_update_header_func (GtkListBoxRow* row, GtkListBoxRow* before, gpointer self) {
	contacts_accounts_list_update_header_func (self, row, before);
}


static void __lambda96_ (ContactsAccountsList* self) {
	GError * _inner_error_ = NULL;
	{
		g_spawn_command_line_async ("gnome-control-center online-accounts", &_inner_error_);
		if (_inner_error_ != NULL) {
			goto __catch30_g_error;
		}
	}
	goto __finally30;
	__catch30_g_error:
	{
		GError* e = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		_g_error_free0 (e);
	}
	__finally30:
	if (_inner_error_ != NULL) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
}


static void ___lambda96__gtk_button_clicked (GtkButton* _sender, gpointer self) {
	__lambda96_ (self);
}


static void _contacts_accounts_list_row_selected_gtk_list_box_row_selected (GtkListBox* _sender, GtkListBoxRow* row, gpointer self) {
	contacts_accounts_list_row_selected (self, row);
}


ContactsAccountsList* contacts_accounts_list_construct (GType object_type) {
	ContactsAccountsList * self = NULL;
	GtkListBox* _tmp0_ = NULL;
	GtkListBox* _tmp1_ = NULL;
	GtkListBox* _tmp2_ = NULL;
	GtkListBox* _tmp3_ = NULL;
	GtkScrolledWindow* scrolled = NULL;
	GtkScrolledWindow* _tmp4_ = NULL;
	GtkListBox* _tmp5_ = NULL;
	GtkToolbar* toolbar = NULL;
	GtkToolbar* _tmp6_ = NULL;
	GtkStyleContext* _tmp7_ = NULL;
	const gchar* _tmp8_ = NULL;
	GtkButton* _tmp9_ = NULL;
	GtkButton* _tmp10_ = NULL;
	GtkStyleContext* _tmp11_ = NULL;
	GtkButton* _tmp12_ = NULL;
	GtkWidget* _tmp13_ = NULL;
	GtkButton* _tmp14_ = NULL;
	GtkWidget* _tmp15_ = NULL;
	GtkButton* _tmp16_ = NULL;
	GtkWidget* _tmp17_ = NULL;
	GtkButton* _tmp18_ = NULL;
	GtkWidget* _tmp19_ = NULL;
	GtkButton* _tmp20_ = NULL;
	GtkSeparatorToolItem* spacer = NULL;
	GtkSeparatorToolItem* _tmp21_ = NULL;
	GtkSeparatorToolItem* _tmp22_ = NULL;
	GtkSeparatorToolItem* _tmp23_ = NULL;
	GtkSeparatorToolItem* _tmp24_ = NULL;
	GtkToolItem* item = NULL;
	GtkToolItem* _tmp25_ = NULL;
	GtkButton* _tmp26_ = NULL;
	GtkSeparatorToolItem* _tmp27_ = NULL;
	GtkSeparatorToolItem* _tmp28_ = NULL;
	GtkSeparatorToolItem* _tmp29_ = NULL;
	GtkSeparatorToolItem* _tmp30_ = NULL;
	GtkGrid* box = NULL;
	GtkGrid* _tmp31_ = NULL;
	GtkListBox* _tmp32_ = NULL;
	self = (ContactsAccountsList*) g_object_new (object_type, NULL);
	_g_object_unref0 (self->selected_store);
	self->selected_store = NULL;
	_tmp0_ = (GtkListBox*) gtk_list_box_new ();
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->accounts_view);
	self->priv->accounts_view = _tmp0_;
	_tmp1_ = self->priv->accounts_view;
	gtk_list_box_set_selection_mode (_tmp1_, GTK_SELECTION_BROWSE);
	_tmp2_ = self->priv->accounts_view;
	gtk_widget_set_size_request ((GtkWidget*) _tmp2_, 400, -1);
	_tmp3_ = self->priv->accounts_view;
	gtk_list_box_set_header_func (_tmp3_, _contacts_accounts_list_update_header_func_gtk_list_box_update_header_func, g_object_ref (self), g_object_unref);
	_tmp4_ = (GtkScrolledWindow*) gtk_scrolled_window_new (NULL, NULL);
	g_object_ref_sink (_tmp4_);
	scrolled = _tmp4_;
	gtk_widget_set_size_request ((GtkWidget*) scrolled, -1, 200);
	gtk_scrolled_window_set_policy (scrolled, GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_set_shadow_type (scrolled, GTK_SHADOW_NONE);
	_tmp5_ = self->priv->accounts_view;
	gtk_container_add ((GtkContainer*) scrolled, (GtkWidget*) _tmp5_);
	_tmp6_ = (GtkToolbar*) gtk_toolbar_new ();
	g_object_ref_sink (_tmp6_);
	toolbar = _tmp6_;
	_tmp7_ = gtk_widget_get_style_context ((GtkWidget*) toolbar);
	gtk_style_context_add_class (_tmp7_, GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
	_tmp8_ = _ ("Add an Online Account");
	_tmp9_ = (GtkButton*) gtk_button_new_with_label (_tmp8_);
	g_object_ref_sink (_tmp9_);
	_g_object_unref0 (self->priv->add_account_button);
	self->priv->add_account_button = _tmp9_;
	_tmp10_ = self->priv->add_account_button;
	_tmp11_ = gtk_widget_get_style_context ((GtkWidget*) _tmp10_);
	gtk_style_context_add_class (_tmp11_, GTK_STYLE_CLASS_RAISED);
	_tmp12_ = self->priv->add_account_button;
	_tmp13_ = gtk_bin_get_child ((GtkBin*) _tmp12_);
	gtk_widget_set_margin_left (_tmp13_, 6);
	_tmp14_ = self->priv->add_account_button;
	_tmp15_ = gtk_bin_get_child ((GtkBin*) _tmp14_);
	gtk_widget_set_margin_right (_tmp15_, 6);
	_tmp16_ = self->priv->add_account_button;
	_tmp17_ = gtk_bin_get_child ((GtkBin*) _tmp16_);
	gtk_widget_set_margin_top (_tmp17_, 3);
	_tmp18_ = self->priv->add_account_button;
	_tmp19_ = gtk_bin_get_child ((GtkBin*) _tmp18_);
	gtk_widget_set_margin_bottom (_tmp19_, 3);
	_tmp20_ = self->priv->add_account_button;
	g_signal_connect_object (_tmp20_, "clicked", (GCallback) ___lambda96__gtk_button_clicked, self, 0);
	_tmp21_ = (GtkSeparatorToolItem*) gtk_separator_tool_item_new ();
	g_object_ref_sink (_tmp21_);
	spacer = _tmp21_;
	_tmp22_ = spacer;
	gtk_separator_tool_item_set_draw (_tmp22_, FALSE);
	_tmp23_ = spacer;
	gtk_tool_item_set_expand ((GtkToolItem*) _tmp23_, TRUE);
	_tmp24_ = spacer;
	gtk_container_add ((GtkContainer*) toolbar, (GtkWidget*) _tmp24_);
	_tmp25_ = gtk_tool_item_new ();
	g_object_ref_sink (_tmp25_);
	item = _tmp25_;
	_tmp26_ = self->priv->add_account_button;
	gtk_container_add ((GtkContainer*) item, (GtkWidget*) _tmp26_);
	gtk_container_add ((GtkContainer*) toolbar, (GtkWidget*) item);
	_tmp27_ = (GtkSeparatorToolItem*) gtk_separator_tool_item_new ();
	g_object_ref_sink (_tmp27_);
	_g_object_unref0 (spacer);
	spacer = _tmp27_;
	_tmp28_ = spacer;
	gtk_separator_tool_item_set_draw (_tmp28_, FALSE);
	_tmp29_ = spacer;
	gtk_tool_item_set_expand ((GtkToolItem*) _tmp29_, TRUE);
	_tmp30_ = spacer;
	gtk_container_add ((GtkContainer*) toolbar, (GtkWidget*) _tmp30_);
	_tmp31_ = (GtkGrid*) gtk_grid_new ();
	g_object_ref_sink (_tmp31_);
	box = _tmp31_;
	gtk_orientable_set_orientation ((GtkOrientable*) box, GTK_ORIENTATION_VERTICAL);
	gtk_container_add ((GtkContainer*) box, (GtkWidget*) scrolled);
	gtk_container_add ((GtkContainer*) box, (GtkWidget*) toolbar);
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) box);
	gtk_widget_show_all ((GtkWidget*) self);
	_tmp32_ = self->priv->accounts_view;
	g_signal_connect_object (_tmp32_, "row-selected", (GCallback) _contacts_accounts_list_row_selected_gtk_list_box_row_selected, self, 0);
	_g_object_unref0 (box);
	_g_object_unref0 (item);
	_g_object_unref0 (spacer);
	_g_object_unref0 (toolbar);
	_g_object_unref0 (scrolled);
	return self;
}


ContactsAccountsList* contacts_accounts_list_new (void) {
	return contacts_accounts_list_construct (CONTACTS_TYPE_ACCOUNTS_LIST);
}


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


static void contacts_accounts_list_row_selected (ContactsAccountsList* self, GtkListBoxRow* row) {
	GtkListBoxRow* _tmp0_ = NULL;
	GtkWidget* row_data = NULL;
	GtkListBoxRow* _tmp1_ = NULL;
	GtkWidget* _tmp2_ = NULL;
	GtkWidget* _tmp3_ = NULL;
	GtkWidget* account_label = NULL;
	GtkWidget* _tmp4_ = NULL;
	GtkWidget* _tmp5_ = NULL;
	GtkWidget* _tmp6_ = NULL;
	GtkWidget* _tmp7_ = NULL;
	GtkListBoxRow* _tmp10_ = NULL;
	GtkListBoxRow* _tmp20_ = NULL;
	GtkListBoxRow* _tmp21_ = NULL;
	GtkWidget* _tmp22_ = NULL;
	gconstpointer _tmp23_ = NULL;
	FolksPersonaStore* _tmp24_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = row;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = row;
	_tmp2_ = gtk_bin_get_child (G_TYPE_CHECK_INSTANCE_TYPE (_tmp1_, GTK_TYPE_BIN) ? ((GtkBin*) _tmp1_) : NULL);
	_tmp3_ = _g_object_ref0 (_tmp2_);
	row_data = _tmp3_;
	_tmp4_ = row_data;
	_tmp5_ = gtk_grid_get_child_at (G_TYPE_CHECK_INSTANCE_TYPE (_tmp4_, GTK_TYPE_GRID) ? ((GtkGrid*) _tmp4_) : NULL, 1, 0);
	_tmp6_ = _g_object_ref0 (_tmp5_);
	account_label = _tmp6_;
	_tmp7_ = account_label;
	if (_tmp7_ != NULL) {
		GtkWidget* _tmp8_ = NULL;
		GtkStyleContext* _tmp9_ = NULL;
		_tmp8_ = account_label;
		_tmp9_ = gtk_widget_get_style_context (_tmp8_);
		gtk_style_context_remove_class (_tmp9_, "dim-label");
	}
	_tmp10_ = self->priv->last_selected_row;
	if (_tmp10_ != NULL) {
		GtkWidget* last_row_data = NULL;
		GtkListBoxRow* _tmp11_ = NULL;
		GtkWidget* _tmp12_ = NULL;
		GtkWidget* _tmp13_ = NULL;
		GtkWidget* last_account_label = NULL;
		GtkWidget* _tmp14_ = NULL;
		GtkWidget* _tmp15_ = NULL;
		GtkWidget* _tmp16_ = NULL;
		GtkWidget* _tmp17_ = NULL;
		_tmp11_ = self->priv->last_selected_row;
		_tmp12_ = gtk_bin_get_child (G_TYPE_CHECK_INSTANCE_TYPE (_tmp11_, GTK_TYPE_BIN) ? ((GtkBin*) _tmp11_) : NULL);
		_tmp13_ = _g_object_ref0 (_tmp12_);
		last_row_data = _tmp13_;
		_tmp14_ = last_row_data;
		_tmp15_ = gtk_grid_get_child_at (G_TYPE_CHECK_INSTANCE_TYPE (_tmp14_, GTK_TYPE_GRID) ? ((GtkGrid*) _tmp14_) : NULL, 1, 0);
		_tmp16_ = _g_object_ref0 (_tmp15_);
		last_account_label = _tmp16_;
		_tmp17_ = last_account_label;
		if (_tmp17_ != NULL) {
			GtkWidget* _tmp18_ = NULL;
			GtkStyleContext* _tmp19_ = NULL;
			_tmp18_ = last_account_label;
			_tmp19_ = gtk_widget_get_style_context (_tmp18_);
			gtk_style_context_add_class (_tmp19_, "dim-label");
		}
		_g_object_unref0 (last_account_label);
		_g_object_unref0 (last_row_data);
	}
	_tmp20_ = row;
	_tmp21_ = _g_object_ref0 (_tmp20_);
	_g_object_unref0 (self->priv->last_selected_row);
	self->priv->last_selected_row = _tmp21_;
	_tmp22_ = row_data;
	_tmp23_ = g_object_get_data ((GObject*) _tmp22_, "store");
	_tmp24_ = _g_object_ref0 ((FolksPersonaStore*) _tmp23_);
	_g_object_unref0 (self->selected_store);
	self->selected_store = _tmp24_;
	g_signal_emit_by_name (self, "account-selected");
	_g_object_unref0 (account_label);
	_g_object_unref0 (row_data);
}


static void contacts_accounts_list_update_header_func (ContactsAccountsList* self, GtkListBoxRow* row, GtkListBoxRow* before) {
	GtkListBoxRow* _tmp0_ = NULL;
	GtkWidget* _tmp1_ = NULL;
	GtkListBoxRow* _tmp5_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (row != NULL);
	_tmp0_ = row;
	_tmp1_ = gtk_list_box_row_get_header (_tmp0_);
	if (_tmp1_ == NULL) {
		GtkListBoxRow* _tmp2_ = NULL;
		GtkSeparator* _tmp3_ = NULL;
		GtkSeparator* _tmp4_ = NULL;
		_tmp2_ = row;
		_tmp3_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
		g_object_ref_sink (_tmp3_);
		_tmp4_ = _tmp3_;
		gtk_list_box_row_set_header (_tmp2_, (GtkWidget*) _tmp4_);
		_g_object_unref0 (_tmp4_);
		return;
	}
	_tmp5_ = row;
	gtk_list_box_row_set_header (_tmp5_, NULL);
}


void contacts_accounts_list_update_contents (ContactsAccountsList* self, gboolean select_active) {
	GtkListBox* _tmp0_ = NULL;
	GList* _tmp1_ = NULL;
	FolksPersonaStore* local_store = NULL;
	gint _tmp3_ = 0;
	FolksPersonaStore** _tmp4_ = NULL;
	GtkGrid* local_data = NULL;
	GtkGrid* _tmp60_ = NULL;
	GtkGrid* _tmp61_ = NULL;
	GtkGrid* _tmp62_ = NULL;
	FolksPersonaStore* _tmp63_ = NULL;
	FolksPersonaStore* _tmp64_ = NULL;
	GtkLabel* local_label = NULL;
	const gchar* _tmp65_ = NULL;
	GtkLabel* _tmp66_ = NULL;
	GtkGrid* _tmp67_ = NULL;
	GtkLabel* _tmp68_ = NULL;
	GtkListBox* _tmp69_ = NULL;
	GtkGrid* _tmp70_ = NULL;
	gboolean _tmp71_ = FALSE;
	gboolean _tmp72_ = FALSE;
	gboolean _tmp80_ = FALSE;
	GtkListBox* _tmp86_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->accounts_view;
	_tmp1_ = gtk_container_get_children ((GtkContainer*) _tmp0_);
	{
		GList* child_collection = NULL;
		GList* child_it = NULL;
		child_collection = _tmp1_;
		for (child_it = child_collection; child_it != NULL; child_it = child_it->next) {
			GtkWidget* child = NULL;
			child = (GtkWidget*) child_it->data;
			{
				GtkWidget* _tmp2_ = NULL;
				_tmp2_ = child;
				gtk_widget_destroy (_tmp2_);
			}
		}
		_g_list_free0 (child_collection);
	}
	local_store = NULL;
	_tmp4_ = contacts_app_get_eds_address_books (&_tmp3_);
	{
		FolksPersonaStore** persona_store_collection = NULL;
		gint persona_store_collection_length1 = 0;
		gint _persona_store_collection_size_ = 0;
		gint persona_store_it = 0;
		persona_store_collection = _tmp4_;
		persona_store_collection_length1 = _tmp3_;
		for (persona_store_it = 0; persona_store_it < _tmp3_; persona_store_it = persona_store_it + 1) {
			FolksPersonaStore* _tmp5_ = NULL;
			FolksPersonaStore* persona_store = NULL;
			_tmp5_ = _g_object_ref0 (persona_store_collection[persona_store_it]);
			persona_store = _tmp5_;
			{
				FolksPersonaStore* _tmp6_ = NULL;
				const gchar* _tmp7_ = NULL;
				const gchar* _tmp8_ = NULL;
				ESource* source = NULL;
				FolksPersonaStore* _tmp11_ = NULL;
				ESource* _tmp12_ = NULL;
				ESource* _tmp13_ = NULL;
				ESource* _tmp14_ = NULL;
				ESource* parent_source = NULL;
				ESourceRegistry* _tmp15_ = NULL;
				ESource* _tmp16_ = NULL;
				const gchar* _tmp17_ = NULL;
				const gchar* _tmp18_ = NULL;
				ESource* _tmp19_ = NULL;
				gchar* provider_name = NULL;
				FolksPersonaStore* _tmp20_ = NULL;
				gchar* _tmp21_ = NULL;
				GtkGrid* row_data = NULL;
				GtkGrid* _tmp22_ = NULL;
				GtkGrid* _tmp23_ = NULL;
				FolksPersonaStore* _tmp24_ = NULL;
				FolksPersonaStore* _tmp25_ = NULL;
				GtkGrid* _tmp26_ = NULL;
				GtkLabel* provider_label = NULL;
				const gchar* _tmp27_ = NULL;
				GtkLabel* _tmp28_ = NULL;
				GtkGrid* _tmp29_ = NULL;
				GtkLabel* _tmp30_ = NULL;
				gchar* account_name = NULL;
				ESource* _tmp31_ = NULL;
				const gchar* _tmp32_ = NULL;
				const gchar* _tmp33_ = NULL;
				gchar* _tmp34_ = NULL;
				GtkLabel* account_label = NULL;
				const gchar* _tmp35_ = NULL;
				GtkLabel* _tmp36_ = NULL;
				GtkLabel* _tmp37_ = NULL;
				GtkLabel* _tmp38_ = NULL;
				GtkLabel* _tmp39_ = NULL;
				GtkStyleContext* _tmp40_ = NULL;
				GtkGrid* _tmp41_ = NULL;
				GtkLabel* _tmp42_ = NULL;
				GtkListBox* _tmp43_ = NULL;
				GtkGrid* _tmp44_ = NULL;
				gboolean _tmp45_ = FALSE;
				gboolean _tmp46_ = FALSE;
				gboolean _tmp54_ = FALSE;
				_tmp6_ = persona_store;
				_tmp7_ = folks_persona_store_get_id (_tmp6_);
				_tmp8_ = _tmp7_;
				if (g_strcmp0 (_tmp8_, "system-address-book") == 0) {
					FolksPersonaStore* _tmp9_ = NULL;
					FolksPersonaStore* _tmp10_ = NULL;
					_tmp9_ = persona_store;
					_tmp10_ = _g_object_ref0 (_tmp9_);
					_g_object_unref0 (local_store);
					local_store = _tmp10_;
					_g_object_unref0 (persona_store);
					continue;
				}
				_tmp11_ = persona_store;
				_tmp12_ = edsf_persona_store_get_source (G_TYPE_CHECK_INSTANCE_TYPE (_tmp11_, EDSF_TYPE_PERSONA_STORE) ? ((EdsfPersonaStore*) _tmp11_) : NULL);
				_tmp13_ = _tmp12_;
				_tmp14_ = _g_object_ref0 (_tmp13_);
				source = _tmp14_;
				_tmp15_ = eds_source_registry;
				_tmp16_ = source;
				_tmp17_ = e_source_get_parent (_tmp16_);
				_tmp18_ = _tmp17_;
				_tmp19_ = e_source_registry_ref_source (_tmp15_, _tmp18_);
				parent_source = _tmp19_;
				_tmp20_ = persona_store;
				_tmp21_ = contacts_contact_format_persona_store_name (_tmp20_);
				provider_name = _tmp21_;
				_tmp22_ = (GtkGrid*) gtk_grid_new ();
				g_object_ref_sink (_tmp22_);
				row_data = _tmp22_;
				_tmp23_ = row_data;
				_tmp24_ = persona_store;
				_tmp25_ = _g_object_ref0 (_tmp24_);
				g_object_set_data_full ((GObject*) _tmp23_, "store", _tmp25_, g_object_unref);
				_tmp26_ = row_data;
				g_object_set ((GtkWidget*) _tmp26_, "margin", 12, NULL);
				_tmp27_ = provider_name;
				_tmp28_ = (GtkLabel*) gtk_label_new (_tmp27_);
				g_object_ref_sink (_tmp28_);
				provider_label = _tmp28_;
				_tmp29_ = row_data;
				_tmp30_ = provider_label;
				gtk_container_add ((GtkContainer*) _tmp29_, (GtkWidget*) _tmp30_);
				_tmp31_ = parent_source;
				_tmp32_ = e_source_get_display_name (_tmp31_);
				_tmp33_ = _tmp32_;
				_tmp34_ = g_strdup (_tmp33_);
				account_name = _tmp34_;
				_tmp35_ = account_name;
				_tmp36_ = (GtkLabel*) gtk_label_new (_tmp35_);
				g_object_ref_sink (_tmp36_);
				account_label = _tmp36_;
				_tmp37_ = account_label;
				gtk_widget_set_halign ((GtkWidget*) _tmp37_, GTK_ALIGN_END);
				_tmp38_ = account_label;
				gtk_widget_set_hexpand ((GtkWidget*) _tmp38_, TRUE);
				_tmp39_ = account_label;
				_tmp40_ = gtk_widget_get_style_context ((GtkWidget*) _tmp39_);
				gtk_style_context_add_class (_tmp40_, "dim-label");
				_tmp41_ = row_data;
				_tmp42_ = account_label;
				gtk_container_add ((GtkContainer*) _tmp41_, (GtkWidget*) _tmp42_);
				_tmp43_ = self->priv->accounts_view;
				_tmp44_ = row_data;
				gtk_container_add ((GtkContainer*) _tmp43_, (GtkWidget*) _tmp44_);
				_tmp46_ = select_active;
				if (_tmp46_) {
					FolksPersonaStore* _tmp47_ = NULL;
					ContactsApp* _tmp48_ = NULL;
					ContactsStore* _tmp49_ = NULL;
					FolksIndividualAggregator* _tmp50_ = NULL;
					FolksIndividualAggregator* _tmp51_ = NULL;
					FolksPersonaStore* _tmp52_ = NULL;
					FolksPersonaStore* _tmp53_ = NULL;
					_tmp47_ = persona_store;
					_tmp48_ = contacts_app_app;
					_tmp49_ = _tmp48_->contacts_store;
					_tmp50_ = contacts_store_get_aggregator (_tmp49_);
					_tmp51_ = _tmp50_;
					_tmp52_ = folks_individual_aggregator_get_primary_store (_tmp51_);
					_tmp53_ = _tmp52_;
					_tmp45_ = _tmp47_ == _tmp53_;
				} else {
					_tmp45_ = FALSE;
				}
				_tmp54_ = _tmp45_;
				if (_tmp54_) {
					GtkListBoxRow* row = NULL;
					GtkGrid* _tmp55_ = NULL;
					GtkWidget* _tmp56_ = NULL;
					GtkListBoxRow* _tmp57_ = NULL;
					GtkListBox* _tmp58_ = NULL;
					GtkListBoxRow* _tmp59_ = NULL;
					_tmp55_ = row_data;
					_tmp56_ = gtk_widget_get_parent ((GtkWidget*) _tmp55_);
					_tmp57_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp56_, GTK_TYPE_LIST_BOX_ROW) ? ((GtkListBoxRow*) _tmp56_) : NULL);
					row = _tmp57_;
					_tmp58_ = self->priv->accounts_view;
					_tmp59_ = row;
					gtk_list_box_select_row (_tmp58_, _tmp59_);
					_g_object_unref0 (row);
				}
				_g_object_unref0 (account_label);
				_g_free0 (account_name);
				_g_object_unref0 (provider_label);
				_g_object_unref0 (row_data);
				_g_free0 (provider_name);
				_g_object_unref0 (parent_source);
				_g_object_unref0 (source);
				_g_object_unref0 (persona_store);
			}
		}
		persona_store_collection = (_vala_array_free (persona_store_collection, persona_store_collection_length1, (GDestroyNotify) g_object_unref), NULL);
	}
	_tmp60_ = (GtkGrid*) gtk_grid_new ();
	g_object_ref_sink (_tmp60_);
	local_data = _tmp60_;
	_tmp61_ = local_data;
	g_object_set ((GtkWidget*) _tmp61_, "margin", 12, NULL);
	_tmp62_ = local_data;
	_tmp63_ = local_store;
	_tmp64_ = _g_object_ref0 (_tmp63_);
	g_object_set_data_full ((GObject*) _tmp62_, "store", _tmp64_, g_object_unref);
	_tmp65_ = _ ("Keep contacts on this computer only");
	_tmp66_ = (GtkLabel*) gtk_label_new (_tmp65_);
	g_object_ref_sink (_tmp66_);
	local_label = _tmp66_;
	_tmp67_ = local_data;
	_tmp68_ = local_label;
	gtk_container_add ((GtkContainer*) _tmp67_, (GtkWidget*) _tmp68_);
	_tmp69_ = self->priv->accounts_view;
	_tmp70_ = local_data;
	gtk_container_add ((GtkContainer*) _tmp69_, (GtkWidget*) _tmp70_);
	_tmp72_ = select_active;
	if (_tmp72_) {
		FolksPersonaStore* _tmp73_ = NULL;
		ContactsApp* _tmp74_ = NULL;
		ContactsStore* _tmp75_ = NULL;
		FolksIndividualAggregator* _tmp76_ = NULL;
		FolksIndividualAggregator* _tmp77_ = NULL;
		FolksPersonaStore* _tmp78_ = NULL;
		FolksPersonaStore* _tmp79_ = NULL;
		_tmp73_ = local_store;
		_tmp74_ = contacts_app_app;
		_tmp75_ = _tmp74_->contacts_store;
		_tmp76_ = contacts_store_get_aggregator (_tmp75_);
		_tmp77_ = _tmp76_;
		_tmp78_ = folks_individual_aggregator_get_primary_store (_tmp77_);
		_tmp79_ = _tmp78_;
		_tmp71_ = _tmp73_ == _tmp79_;
	} else {
		_tmp71_ = FALSE;
	}
	_tmp80_ = _tmp71_;
	if (_tmp80_) {
		GtkListBoxRow* row = NULL;
		GtkGrid* _tmp81_ = NULL;
		GtkWidget* _tmp82_ = NULL;
		GtkListBoxRow* _tmp83_ = NULL;
		GtkListBox* _tmp84_ = NULL;
		GtkListBoxRow* _tmp85_ = NULL;
		_tmp81_ = local_data;
		_tmp82_ = gtk_widget_get_parent ((GtkWidget*) _tmp81_);
		_tmp83_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp82_, GTK_TYPE_LIST_BOX_ROW) ? ((GtkListBoxRow*) _tmp82_) : NULL);
		row = _tmp83_;
		_tmp84_ = self->priv->accounts_view;
		_tmp85_ = row;
		gtk_list_box_select_row (_tmp84_, _tmp85_);
		_g_object_unref0 (row);
	}
	_tmp86_ = self->priv->accounts_view;
	gtk_widget_show_all ((GtkWidget*) _tmp86_);
	_g_object_unref0 (local_label);
	_g_object_unref0 (local_data);
	_g_object_unref0 (local_store);
}


static void contacts_accounts_list_class_init (ContactsAccountsListClass * klass) {
	contacts_accounts_list_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (ContactsAccountsListPrivate));
	G_OBJECT_CLASS (klass)->finalize = contacts_accounts_list_finalize;
	g_signal_new ("account_selected", CONTACTS_TYPE_ACCOUNTS_LIST, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}


static void contacts_accounts_list_instance_init (ContactsAccountsList * self) {
	self->priv = CONTACTS_ACCOUNTS_LIST_GET_PRIVATE (self);
}


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->accounts_view);
	_g_object_unref0 (self->priv->last_selected_row);
	_g_object_unref0 (self->priv->add_account_button);
	_g_object_unref0 (self->selected_store);
	G_OBJECT_CLASS (contacts_accounts_list_parent_class)->finalize (obj);
}


GType contacts_accounts_list_get_type (void) {
	static volatile gsize contacts_accounts_list_type_id__volatile = 0;
	if (g_once_init_enter (&contacts_accounts_list_type_id__volatile)) {
		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 (GTK_TYPE_FRAME, "ContactsAccountsList", &g_define_type_info, 0);
		g_once_init_leave (&contacts_accounts_list_type_id__volatile, contacts_accounts_list_type_id);
	}
	return contacts_accounts_list_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);
}



