/* contacts-list-pane.c generated by valac 0.20.1.71-45f6, the Vala compiler
 * generated from contacts-list-pane.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 <libgd/gd.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <glib/gi18n-lib.h>
#include <gee.h>


#define CONTACTS_TYPE_LIST_PANE (contacts_list_pane_get_type ())
#define CONTACTS_LIST_PANE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONTACTS_TYPE_LIST_PANE, ContactsListPane))
#define CONTACTS_LIST_PANE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONTACTS_TYPE_LIST_PANE, ContactsListPaneClass))
#define CONTACTS_IS_LIST_PANE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONTACTS_TYPE_LIST_PANE))
#define CONTACTS_IS_LIST_PANE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONTACTS_TYPE_LIST_PANE))
#define CONTACTS_LIST_PANE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONTACTS_TYPE_LIST_PANE, ContactsListPaneClass))

typedef struct _ContactsListPane ContactsListPane;
typedef struct _ContactsListPaneClass ContactsListPaneClass;
typedef struct _ContactsListPanePrivate ContactsListPanePrivate;

#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_VIEW (contacts_view_get_type ())
#define CONTACTS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONTACTS_TYPE_VIEW, ContactsView))
#define CONTACTS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONTACTS_TYPE_VIEW, ContactsViewClass))
#define CONTACTS_IS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONTACTS_TYPE_VIEW))
#define CONTACTS_IS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONTACTS_TYPE_VIEW))
#define CONTACTS_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONTACTS_TYPE_VIEW, ContactsViewClass))

typedef struct _ContactsView ContactsView;
typedef struct _ContactsViewClass ContactsViewClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_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_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 CONTACTS_VIEW_TYPE_SUBSET (contacts_view_subset_get_type ())
typedef struct _Block31Data Block31Data;

#define CONTACTS_VIEW_TYPE_TEXT_DISPLAY (contacts_view_text_display_get_type ())

#define CONTACTS_TYPE_CONTACT (contacts_contact_get_type ())
#define CONTACTS_CONTACT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONTACTS_TYPE_CONTACT, ContactsContact))
#define CONTACTS_CONTACT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONTACTS_TYPE_CONTACT, ContactsContactClass))
#define CONTACTS_IS_CONTACT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONTACTS_TYPE_CONTACT))
#define CONTACTS_IS_CONTACT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONTACTS_TYPE_CONTACT))
#define CONTACTS_CONTACT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONTACTS_TYPE_CONTACT, ContactsContactClass))

typedef struct _ContactsContact ContactsContact;
typedef struct _ContactsContactClass ContactsContactClass;

struct _ContactsListPane {
	GtkFrame parent_instance;
	ContactsListPanePrivate * priv;
	GtkSearchEntry* filter_entry;
};

struct _ContactsListPaneClass {
	GtkFrameClass parent_class;
};

struct _ContactsListPanePrivate {
	ContactsStore* contacts_store;
	ContactsView* contacts_view;
	GdRevealer* selection_revealer;
	guint filter_entry_changed_id;
	gboolean ignore_selection_change;
	gboolean search_visible;
};

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

struct _ContactsAppClass {
	GtkApplicationClass parent_class;
};

typedef enum  {
	CONTACTS_VIEW_SUBSET_MAIN,
	CONTACTS_VIEW_SUBSET_OTHER,
	CONTACTS_VIEW_SUBSET_ALL_SEPARATED,
	CONTACTS_VIEW_SUBSET_ALL
} ContactsViewSubset;

struct _Block31Data {
	int _ref_count_;
	ContactsListPane * self;
	GtkButton* link_selected_button;
	GtkButton* delete_selected_button;
};

typedef enum  {
	CONTACTS_VIEW_TEXT_DISPLAY_NONE,
	CONTACTS_VIEW_TEXT_DISPLAY_PRESENCE,
	CONTACTS_VIEW_TEXT_DISPLAY_STORES
} ContactsViewTextDisplay;


static gpointer contacts_list_pane_parent_class = NULL;
extern ContactsApp* contacts_app_app;

GType contacts_list_pane_get_type (void) G_GNUC_CONST;
GType contacts_store_get_type (void) G_GNUC_CONST;
GType contacts_view_get_type (void) G_GNUC_CONST;
#define CONTACTS_LIST_PANE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CONTACTS_TYPE_LIST_PANE, ContactsListPanePrivate))
enum  {
	CONTACTS_LIST_PANE_DUMMY_PROPERTY
};
void contacts_list_pane_refilter (ContactsListPane* self);
gboolean contacts_utils_string_is_empty (const gchar* str);
gchar* contacts_utils_canonicalize_for_search (const gchar* str);
void contacts_view_set_filter_values (ContactsView* self, gchar** values, int values_length1);
GType contacts_app_get_type (void) G_GNUC_CONST;
GType contacts_window_get_type (void) G_GNUC_CONST;
GType contacts_view_subset_get_type (void) G_GNUC_CONST;
void contacts_view_set_show_subset (ContactsView* self, ContactsViewSubset subset);
static gboolean contacts_list_pane_filter_entry_changed_timeout (ContactsListPane* self);
static void contacts_list_pane_filter_entry_changed (ContactsListPane* self, GtkEditable* editable);
static gboolean _contacts_list_pane_filter_entry_changed_timeout_gsource_func (gpointer self);
ContactsListPane* contacts_list_pane_new (ContactsStore* contacts_store);
ContactsListPane* contacts_list_pane_construct (GType object_type, ContactsStore* contacts_store);
static Block31Data* block31_data_ref (Block31Data* _data31_);
static void block31_data_unref (void * _userdata_);
GType contacts_view_text_display_get_type (void) G_GNUC_CONST;
ContactsView* contacts_view_new (ContactsStore* store, ContactsViewTextDisplay text_display);
ContactsView* contacts_view_construct (GType object_type, ContactsStore* store, ContactsViewTextDisplay text_display);
static void _contacts_list_pane_filter_entry_changed_gtk_editable_changed (GtkEditable* _sender, gpointer self);
GType contacts_contact_get_type (void) G_GNUC_CONST;
static void __lambda25_ (ContactsListPane* self, ContactsView* l, ContactsContact* contact);
static void ___lambda25__contacts_view_selection_changed (ContactsView* _sender, ContactsContact* contact, gpointer self);
static void __lambda26_ (Block31Data* _data31_, gint nr_contacts_marked);
static void ___lambda26__contacts_view_contacts_marked (ContactsView* _sender, gint contacts_marked, gpointer self);
static void __lambda27_ (ContactsListPane* self);
GeeLinkedList* contacts_view_get_marked_contacts (ContactsView* self);
static void ___lambda27__gtk_button_clicked (GtkButton* _sender, gpointer self);
static void __lambda28_ (ContactsListPane* self);
void contacts_contact_hide (ContactsContact* self);
static void ___lambda28__gtk_button_clicked (GtkButton* _sender, gpointer self);
void contacts_list_pane_select_contact (ContactsListPane* self, ContactsContact* contact, gboolean ignore_change);
void contacts_view_select_contact (ContactsView* self, ContactsContact* contact);
void contacts_list_pane_show_selection (ContactsListPane* self);
void contacts_view_show_selectors (ContactsView* self);
void contacts_list_pane_hide_selection (ContactsListPane* self);
void contacts_view_hide_selectors (ContactsView* self);
static void contacts_list_pane_real_get_preferred_width (GtkWidget* base, gint* minimum_width, gint* natural_width);
static void contacts_list_pane_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 gint _vala_array_length (gpointer array);


void contacts_list_pane_refilter (ContactsListPane* self) {
	gchar** values = NULL;
	gint values_length1 = 0;
	gint _values_size_ = 0;
	gchar* str = NULL;
	GtkSearchEntry* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	gboolean _tmp4_ = FALSE;
	ContactsView* _tmp10_ = NULL;
	gchar** _tmp11_ = NULL;
	gint _tmp11__length1 = 0;
	gint subset = 0;
	ContactsApp* _tmp12_ = NULL;
	GSettings* _tmp13_ = NULL;
	gint _tmp14_ = 0;
	gint _tmp15_ = 0;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->filter_entry;
	_tmp1_ = gtk_entry_get_text ((GtkEntry*) _tmp0_);
	_tmp2_ = g_strdup (_tmp1_);
	str = _tmp2_;
	_tmp3_ = str;
	_tmp4_ = contacts_utils_string_is_empty (_tmp3_);
	if (_tmp4_) {
		values = (_vala_array_free (values, values_length1, (GDestroyNotify) g_free), NULL);
		values = NULL;
		values_length1 = 0;
		_values_size_ = values_length1;
	} else {
		const gchar* _tmp5_ = NULL;
		gchar* _tmp6_ = NULL;
		const gchar* _tmp7_ = NULL;
		gchar** _tmp8_ = NULL;
		gchar** _tmp9_ = NULL;
		_tmp5_ = str;
		_tmp6_ = contacts_utils_canonicalize_for_search (_tmp5_);
		_g_free0 (str);
		str = _tmp6_;
		_tmp7_ = str;
		_tmp9_ = _tmp8_ = g_strsplit (_tmp7_, " ", 0);
		values = (_vala_array_free (values, values_length1, (GDestroyNotify) g_free), NULL);
		values = _tmp9_;
		values_length1 = _vala_array_length (_tmp8_);
		_values_size_ = values_length1;
	}
	_tmp10_ = self->priv->contacts_view;
	_tmp11_ = values;
	_tmp11__length1 = values_length1;
	contacts_view_set_filter_values (_tmp10_, _tmp11_, _tmp11__length1);
	_tmp12_ = contacts_app_app;
	_tmp13_ = _tmp12_->settings;
	_tmp14_ = g_settings_get_enum (_tmp13_, "view-subset");
	subset = _tmp14_;
	_tmp15_ = subset;
	if (_tmp15_ == ((gint) CONTACTS_VIEW_SUBSET_MAIN)) {
		gchar** _tmp16_ = NULL;
		gint _tmp16__length1 = 0;
		_tmp16_ = values;
		_tmp16__length1 = values_length1;
		if (_tmp16_ == NULL) {
			ContactsView* _tmp17_ = NULL;
			_tmp17_ = self->priv->contacts_view;
			contacts_view_set_show_subset (_tmp17_, CONTACTS_VIEW_SUBSET_MAIN);
		} else {
			ContactsView* _tmp18_ = NULL;
			_tmp18_ = self->priv->contacts_view;
			contacts_view_set_show_subset (_tmp18_, CONTACTS_VIEW_SUBSET_ALL_SEPARATED);
		}
	} else {
		ContactsView* _tmp19_ = NULL;
		_tmp19_ = self->priv->contacts_view;
		contacts_view_set_show_subset (_tmp19_, CONTACTS_VIEW_SUBSET_ALL);
	}
	_g_free0 (str);
	values = (_vala_array_free (values, values_length1, (GDestroyNotify) g_free), NULL);
}


static gboolean contacts_list_pane_filter_entry_changed_timeout (ContactsListPane* self) {
	gboolean result = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	self->priv->filter_entry_changed_id = (guint) 0;
	contacts_list_pane_refilter (self);
	result = FALSE;
	return result;
}


static gboolean _contacts_list_pane_filter_entry_changed_timeout_gsource_func (gpointer self) {
	gboolean result;
	result = contacts_list_pane_filter_entry_changed_timeout (self);
	return result;
}


static void contacts_list_pane_filter_entry_changed (ContactsListPane* self, GtkEditable* editable) {
	guint _tmp0_ = 0U;
	guint _tmp2_ = 0U;
	g_return_if_fail (self != NULL);
	g_return_if_fail (editable != NULL);
	_tmp0_ = self->priv->filter_entry_changed_id;
	if (_tmp0_ != ((guint) 0)) {
		guint _tmp1_ = 0U;
		_tmp1_ = self->priv->filter_entry_changed_id;
		g_source_remove (_tmp1_);
	}
	_tmp2_ = g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 300, _contacts_list_pane_filter_entry_changed_timeout_gsource_func, g_object_ref (self), g_object_unref);
	self->priv->filter_entry_changed_id = _tmp2_;
}


static Block31Data* block31_data_ref (Block31Data* _data31_) {
	g_atomic_int_inc (&_data31_->_ref_count_);
	return _data31_;
}


static void block31_data_unref (void * _userdata_) {
	Block31Data* _data31_;
	_data31_ = (Block31Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data31_->_ref_count_)) {
		ContactsListPane * self;
		self = _data31_->self;
		_g_object_unref0 (_data31_->delete_selected_button);
		_g_object_unref0 (_data31_->link_selected_button);
		_g_object_unref0 (self);
		g_slice_free (Block31Data, _data31_);
	}
}


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


static void _contacts_list_pane_filter_entry_changed_gtk_editable_changed (GtkEditable* _sender, gpointer self) {
	contacts_list_pane_filter_entry_changed (self, _sender);
}


static void __lambda25_ (ContactsListPane* self, ContactsView* l, ContactsContact* contact) {
	gboolean _tmp0_ = FALSE;
	g_return_if_fail (l != NULL);
	_tmp0_ = self->priv->ignore_selection_change;
	if (!_tmp0_) {
		ContactsContact* _tmp1_ = NULL;
		_tmp1_ = contact;
		g_signal_emit_by_name (self, "selection-changed", _tmp1_);
	}
}


static void ___lambda25__contacts_view_selection_changed (ContactsView* _sender, ContactsContact* contact, gpointer self) {
	__lambda25_ (self, _sender, contact);
}


static void __lambda26_ (Block31Data* _data31_, gint nr_contacts_marked) {
	ContactsListPane * self;
	gint _tmp0_ = 0;
	gint _tmp1_ = 0;
	self = _data31_->self;
	_tmp0_ = nr_contacts_marked;
	if (_tmp0_ > 0) {
		gtk_widget_set_sensitive ((GtkWidget*) _data31_->delete_selected_button, TRUE);
	} else {
		gtk_widget_set_sensitive ((GtkWidget*) _data31_->delete_selected_button, FALSE);
	}
	_tmp1_ = nr_contacts_marked;
	if (_tmp1_ > 1) {
		gtk_widget_set_sensitive ((GtkWidget*) _data31_->link_selected_button, TRUE);
	} else {
		gtk_widget_set_sensitive ((GtkWidget*) _data31_->link_selected_button, FALSE);
	}
}


static void ___lambda26__contacts_view_contacts_marked (ContactsView* _sender, gint contacts_marked, gpointer self) {
	__lambda26_ (self, contacts_marked);
}


static void __lambda27_ (ContactsListPane* self) {
	GeeLinkedList* marked_contacts = NULL;
	ContactsView* _tmp0_ = NULL;
	GeeLinkedList* _tmp1_ = NULL;
	_tmp0_ = self->priv->contacts_view;
	_tmp1_ = contacts_view_get_marked_contacts (_tmp0_);
	marked_contacts = _tmp1_;
	g_signal_emit_by_name (self, "link-contacts", marked_contacts);
	_g_object_unref0 (marked_contacts);
}


static void ___lambda27__gtk_button_clicked (GtkButton* _sender, gpointer self) {
	__lambda27_ (self);
}


static void __lambda28_ (ContactsListPane* self) {
	GeeLinkedList* marked_contacts = NULL;
	ContactsView* _tmp0_ = NULL;
	GeeLinkedList* _tmp1_ = NULL;
	GeeLinkedList* _tmp14_ = NULL;
	_tmp0_ = self->priv->contacts_view;
	_tmp1_ = contacts_view_get_marked_contacts (_tmp0_);
	marked_contacts = _tmp1_;
	{
		GeeLinkedList* _c_list = NULL;
		GeeLinkedList* _tmp2_ = NULL;
		GeeLinkedList* _tmp3_ = NULL;
		gint _c_size = 0;
		GeeLinkedList* _tmp4_ = NULL;
		gint _tmp5_ = 0;
		gint _tmp6_ = 0;
		gint _c_index = 0;
		_tmp2_ = marked_contacts;
		_tmp3_ = _g_object_ref0 (_tmp2_);
		_c_list = _tmp3_;
		_tmp4_ = _c_list;
		_tmp5_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp4_);
		_tmp6_ = _tmp5_;
		_c_size = _tmp6_;
		_c_index = -1;
		while (TRUE) {
			gint _tmp7_ = 0;
			gint _tmp8_ = 0;
			gint _tmp9_ = 0;
			ContactsContact* c = NULL;
			GeeLinkedList* _tmp10_ = NULL;
			gint _tmp11_ = 0;
			gpointer _tmp12_ = NULL;
			ContactsContact* _tmp13_ = NULL;
			_tmp7_ = _c_index;
			_c_index = _tmp7_ + 1;
			_tmp8_ = _c_index;
			_tmp9_ = _c_size;
			if (!(_tmp8_ < _tmp9_)) {
				break;
			}
			_tmp10_ = _c_list;
			_tmp11_ = _c_index;
			_tmp12_ = gee_abstract_list_get ((GeeAbstractList*) _tmp10_, _tmp11_);
			c = (ContactsContact*) _tmp12_;
			_tmp13_ = c;
			contacts_contact_hide (_tmp13_);
			_g_object_unref0 (c);
		}
		_g_object_unref0 (_c_list);
	}
	_tmp14_ = marked_contacts;
	g_signal_emit_by_name (self, "delete-contacts", _tmp14_);
	_g_object_unref0 (marked_contacts);
}


static void ___lambda28__gtk_button_clicked (GtkButton* _sender, gpointer self) {
	__lambda28_ (self);
}


ContactsListPane* contacts_list_pane_construct (GType object_type, ContactsStore* contacts_store) {
	ContactsListPane * self = NULL;
	Block31Data* _data31_;
	GtkStyleContext* _tmp0_ = NULL;
	ContactsStore* _tmp1_ = NULL;
	ContactsStore* _tmp2_ = NULL;
	ContactsStore* _tmp3_ = NULL;
	ContactsView* _tmp4_ = NULL;
	GtkToolbar* toolbar = NULL;
	GtkToolbar* _tmp5_ = NULL;
	GtkStyleContext* _tmp6_ = NULL;
	ContactsView* _tmp7_ = NULL;
	GtkSearchEntry* _tmp8_ = NULL;
	GtkSearchEntry* _tmp9_ = NULL;
	const gchar* _tmp10_ = NULL;
	GtkSearchEntry* _tmp11_ = NULL;
	GtkToolItem* search_entry_item = NULL;
	GtkToolItem* _tmp12_ = NULL;
	GtkSearchEntry* _tmp13_ = NULL;
	GtkScrolledWindow* scrolled = NULL;
	GtkScrolledWindow* _tmp14_ = NULL;
	GtkGrid* grid = NULL;
	GtkGrid* _tmp15_ = NULL;
	ContactsView* _tmp16_ = NULL;
	ContactsView* _tmp17_ = NULL;
	ContactsView* _tmp18_ = NULL;
	GdRevealer* _tmp19_ = NULL;
	GdMainToolbar* selection_toolbar = NULL;
	GdMainToolbar* _tmp20_ = NULL;
	GtkStyleContext* _tmp21_ = NULL;
	GtkStyleContext* _tmp22_ = NULL;
	const gchar* _tmp23_ = NULL;
	GtkWidget* _tmp24_ = NULL;
	GtkButton* _tmp25_ = NULL;
	const gchar* _tmp26_ = NULL;
	GtkWidget* _tmp27_ = NULL;
	GtkButton* _tmp28_ = NULL;
	GdRevealer* _tmp29_ = NULL;
	GdRevealer* _tmp30_ = NULL;
	ContactsView* _tmp31_ = NULL;
	g_return_val_if_fail (contacts_store != NULL, NULL);
	_data31_ = g_slice_new0 (Block31Data);
	_data31_->_ref_count_ = 1;
	self = (ContactsListPane*) g_object_new (object_type, NULL);
	_data31_->self = g_object_ref (self);
	_tmp0_ = gtk_widget_get_style_context ((GtkWidget*) self);
	gtk_style_context_add_class (_tmp0_, GTK_STYLE_CLASS_SIDEBAR);
	_tmp1_ = contacts_store;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_g_object_unref0 (self->priv->contacts_store);
	self->priv->contacts_store = _tmp2_;
	_tmp3_ = contacts_store;
	_tmp4_ = contacts_view_new (_tmp3_, CONTACTS_VIEW_TEXT_DISPLAY_PRESENCE);
	g_object_ref_sink (_tmp4_);
	_g_object_unref0 (self->priv->contacts_view);
	self->priv->contacts_view = _tmp4_;
	_tmp5_ = (GtkToolbar*) gtk_toolbar_new ();
	g_object_ref_sink (_tmp5_);
	toolbar = _tmp5_;
	_tmp6_ = gtk_widget_get_style_context ((GtkWidget*) toolbar);
	gtk_style_context_add_class (_tmp6_, GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
	gtk_toolbar_set_icon_size (toolbar, GTK_ICON_SIZE_MENU);
	gtk_widget_set_vexpand ((GtkWidget*) toolbar, FALSE);
	gtk_widget_set_hexpand ((GtkWidget*) toolbar, TRUE);
	_tmp7_ = self->priv->contacts_view;
	contacts_view_set_show_subset (_tmp7_, CONTACTS_VIEW_SUBSET_MAIN);
	_tmp8_ = (GtkSearchEntry*) gtk_search_entry_new ();
	g_object_ref_sink (_tmp8_);
	_g_object_unref0 (self->filter_entry);
	self->filter_entry = _tmp8_;
	_tmp9_ = self->filter_entry;
	_tmp10_ = _ ("Type to search");
	gtk_entry_set_placeholder_text ((GtkEntry*) _tmp9_, _tmp10_);
	_tmp11_ = self->filter_entry;
	g_signal_connect_object ((GtkEditable*) _tmp11_, "changed", (GCallback) _contacts_list_pane_filter_entry_changed_gtk_editable_changed, self, 0);
	_tmp12_ = gtk_tool_item_new ();
	g_object_ref_sink (_tmp12_);
	search_entry_item = _tmp12_;
	gtk_tool_item_set_is_important (search_entry_item, FALSE);
	gtk_tool_item_set_expand (search_entry_item, TRUE);
	_tmp13_ = self->filter_entry;
	gtk_container_add ((GtkContainer*) search_entry_item, (GtkWidget*) _tmp13_);
	gtk_container_add ((GtkContainer*) toolbar, (GtkWidget*) search_entry_item);
	gtk_widget_set_hexpand ((GtkWidget*) self, FALSE);
	_tmp14_ = (GtkScrolledWindow*) gtk_scrolled_window_new (NULL, NULL);
	g_object_ref_sink (_tmp14_);
	scrolled = _tmp14_;
	gtk_scrolled_window_set_policy (scrolled, GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
	gtk_widget_set_vexpand ((GtkWidget*) scrolled, TRUE);
	gtk_widget_set_hexpand ((GtkWidget*) scrolled, TRUE);
	gtk_scrolled_window_set_shadow_type (scrolled, GTK_SHADOW_NONE);
	_tmp15_ = (GtkGrid*) gtk_grid_new ();
	g_object_ref_sink (_tmp15_);
	grid = _tmp15_;
	gtk_orientable_set_orientation ((GtkOrientable*) grid, GTK_ORIENTATION_VERTICAL);
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) grid);
	_tmp16_ = self->priv->contacts_view;
	g_signal_connect_object (_tmp16_, "selection-changed", (GCallback) ___lambda25__contacts_view_selection_changed, self, 0);
	_tmp17_ = self->priv->contacts_view;
	gtk_widget_show_all ((GtkWidget*) _tmp17_);
	_tmp18_ = self->priv->contacts_view;
	gtk_container_add ((GtkContainer*) scrolled, (GtkWidget*) _tmp18_);
	gtk_widget_set_no_show_all ((GtkWidget*) scrolled, TRUE);
	gtk_widget_show ((GtkWidget*) scrolled);
	gtk_container_add ((GtkContainer*) grid, (GtkWidget*) toolbar);
	gtk_container_add ((GtkContainer*) grid, (GtkWidget*) scrolled);
	_tmp19_ = (GdRevealer*) gd_revealer_new ();
	g_object_ref_sink (_tmp19_);
	_g_object_unref0 (self->priv->selection_revealer);
	self->priv->selection_revealer = _tmp19_;
	_tmp20_ = (GdMainToolbar*) gd_main_toolbar_new ();
	g_object_ref_sink (_tmp20_);
	selection_toolbar = _tmp20_;
	_tmp21_ = gtk_widget_get_style_context ((GtkWidget*) selection_toolbar);
	gtk_style_context_add_class (_tmp21_, GTK_STYLE_CLASS_MENUBAR);
	_tmp22_ = gtk_widget_get_style_context ((GtkWidget*) selection_toolbar);
	gtk_style_context_add_class (_tmp22_, "contacts-selection-toolbar");
	_tmp23_ = _ ("Link");
	_tmp24_ = gd_main_toolbar_add_button (selection_toolbar, NULL, _tmp23_, TRUE);
	_tmp25_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp24_, GTK_TYPE_BUTTON) ? ((GtkButton*) _tmp24_) : NULL);
	_data31_->link_selected_button = _tmp25_;
	gtk_widget_set_size_request ((GtkWidget*) _data31_->link_selected_button, 70, -1);
	gtk_widget_set_sensitive ((GtkWidget*) _data31_->link_selected_button, FALSE);
	_tmp26_ = _ ("Delete");
	_tmp27_ = gd_main_toolbar_add_button (selection_toolbar, NULL, _tmp26_, FALSE);
	_tmp28_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp27_, GTK_TYPE_BUTTON) ? ((GtkButton*) _tmp27_) : NULL);
	_data31_->delete_selected_button = _tmp28_;
	gtk_widget_set_size_request ((GtkWidget*) _data31_->delete_selected_button, 70, -1);
	gtk_widget_set_sensitive ((GtkWidget*) _data31_->delete_selected_button, FALSE);
	_tmp29_ = self->priv->selection_revealer;
	gtk_container_add ((GtkContainer*) _tmp29_, (GtkWidget*) selection_toolbar);
	_tmp30_ = self->priv->selection_revealer;
	gtk_container_add ((GtkContainer*) grid, (GtkWidget*) _tmp30_);
	gtk_widget_show_all ((GtkWidget*) self);
	_tmp31_ = self->priv->contacts_view;
	g_signal_connect_data (_tmp31_, "contacts-marked", (GCallback) ___lambda26__contacts_view_contacts_marked, block31_data_ref (_data31_), (GClosureNotify) block31_data_unref, 0);
	g_signal_connect_object (_data31_->link_selected_button, "clicked", (GCallback) ___lambda27__gtk_button_clicked, self, 0);
	g_signal_connect_object (_data31_->delete_selected_button, "clicked", (GCallback) ___lambda28__gtk_button_clicked, self, 0);
	_g_object_unref0 (selection_toolbar);
	_g_object_unref0 (grid);
	_g_object_unref0 (scrolled);
	_g_object_unref0 (search_entry_item);
	_g_object_unref0 (toolbar);
	block31_data_unref (_data31_);
	_data31_ = NULL;
	return self;
}


ContactsListPane* contacts_list_pane_new (ContactsStore* contacts_store) {
	return contacts_list_pane_construct (CONTACTS_TYPE_LIST_PANE, contacts_store);
}


void contacts_list_pane_select_contact (ContactsListPane* self, ContactsContact* contact, gboolean ignore_change) {
	gboolean _tmp0_ = FALSE;
	ContactsView* _tmp1_ = NULL;
	ContactsContact* _tmp2_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = ignore_change;
	if (_tmp0_) {
		self->priv->ignore_selection_change = TRUE;
	}
	_tmp1_ = self->priv->contacts_view;
	_tmp2_ = contact;
	contacts_view_select_contact (_tmp1_, _tmp2_);
	self->priv->ignore_selection_change = FALSE;
}


void contacts_list_pane_show_selection (ContactsListPane* self) {
	ContactsView* _tmp0_ = NULL;
	GdRevealer* _tmp1_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->contacts_view;
	contacts_view_show_selectors (_tmp0_);
	_tmp1_ = self->priv->selection_revealer;
	gd_revealer_set_reveal_child (_tmp1_, TRUE);
}


void contacts_list_pane_hide_selection (ContactsListPane* self) {
	ContactsView* _tmp0_ = NULL;
	GdRevealer* _tmp1_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->contacts_view;
	contacts_view_hide_selectors (_tmp0_);
	_tmp1_ = self->priv->selection_revealer;
	gd_revealer_set_reveal_child (_tmp1_, FALSE);
}


static void contacts_list_pane_real_get_preferred_width (GtkWidget* base, gint* minimum_width, gint* natural_width) {
	ContactsListPane * self;
	gint _vala_minimum_width = 0;
	gint _vala_natural_width = 0;
	self = (ContactsListPane*) base;
	_vala_natural_width = 300;
	_vala_minimum_width = _vala_natural_width;
	if (minimum_width) {
		*minimum_width = _vala_minimum_width;
	}
	if (natural_width) {
		*natural_width = _vala_natural_width;
	}
}


static void contacts_list_pane_class_init (ContactsListPaneClass * klass) {
	contacts_list_pane_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (ContactsListPanePrivate));
	GTK_WIDGET_CLASS (klass)->get_preferred_width = contacts_list_pane_real_get_preferred_width;
	G_OBJECT_CLASS (klass)->finalize = contacts_list_pane_finalize;
	g_signal_new ("selection_changed", CONTACTS_TYPE_LIST_PANE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, CONTACTS_TYPE_CONTACT);
	g_signal_new ("link_contacts", CONTACTS_TYPE_LIST_PANE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GEE_TYPE_LINKED_LIST);
	g_signal_new ("delete_contacts", CONTACTS_TYPE_LIST_PANE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GEE_TYPE_LINKED_LIST);
}


static void contacts_list_pane_instance_init (ContactsListPane * self) {
	self->priv = CONTACTS_LIST_PANE_GET_PRIVATE (self);
}


static void contacts_list_pane_finalize (GObject* obj) {
	ContactsListPane * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CONTACTS_TYPE_LIST_PANE, ContactsListPane);
	_g_object_unref0 (self->priv->contacts_store);
	_g_object_unref0 (self->filter_entry);
	_g_object_unref0 (self->priv->contacts_view);
	_g_object_unref0 (self->priv->selection_revealer);
	G_OBJECT_CLASS (contacts_list_pane_parent_class)->finalize (obj);
}


GType contacts_list_pane_get_type (void) {
	static volatile gsize contacts_list_pane_type_id__volatile = 0;
	if (g_once_init_enter (&contacts_list_pane_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (ContactsListPaneClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) contacts_list_pane_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ContactsListPane), 0, (GInstanceInitFunc) contacts_list_pane_instance_init, NULL };
		GType contacts_list_pane_type_id;
		contacts_list_pane_type_id = g_type_register_static (GTK_TYPE_FRAME, "ContactsListPane", &g_define_type_info, 0);
		g_once_init_leave (&contacts_list_pane_type_id__volatile, contacts_list_pane_type_id);
	}
	return contacts_list_pane_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);
}


static gint _vala_array_length (gpointer array) {
	int length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}



