/* folder-list-inbox-folder-entry.c generated by valac 0.56.3, the Vala compiler
 * generated from folder-list-inbox-folder-entry.vala, do not modify */

/* Copyright 2016 Software Freedom Conservancy Inc.
 *
 * This software is licensed under the GNU Lesser General Public License
 * (version 2.1 or later).  See the COPYING file in this distribution.
 */
/* A FolderEntry for inboxes in the Inboxes branch.*/

#include "geary-client-43.0.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "geary-engine.h"

enum  {
	FOLDER_LIST_INBOX_FOLDER_ENTRY_0_PROPERTY,
	FOLDER_LIST_INBOX_FOLDER_ENTRY_NUM_PROPERTIES
};
static GParamSpec* folder_list_inbox_folder_entry_properties[FOLDER_LIST_INBOX_FOLDER_ENTRY_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

struct _FolderListInboxFolderEntryPrivate {
	gchar* display_name;
};

static gint FolderListInboxFolderEntry_private_offset;
static gpointer folder_list_inbox_folder_entry_parent_class = NULL;

static void folder_list_inbox_folder_entry_on_information_changed (FolderListInboxFolderEntry* self,
                                                            GearyAccountInformation* config);
static void _folder_list_inbox_folder_entry_on_information_changed_geary_account_information_changed (GearyAccountInformation* _sender,
                                                                                               gpointer self);
static gchar* folder_list_inbox_folder_entry_real_get_sidebar_name (FolderListAbstractFolderEntry* base);
static void folder_list_inbox_folder_entry_finalize (GObject * obj);
static GType folder_list_inbox_folder_entry_get_type_once (void);

static inline gpointer
folder_list_inbox_folder_entry_get_instance_private (FolderListInboxFolderEntry* self)
{
	return G_STRUCT_MEMBER_P (self, FolderListInboxFolderEntry_private_offset);
}

static void
_folder_list_inbox_folder_entry_on_information_changed_geary_account_information_changed (GearyAccountInformation* _sender,
                                                                                          gpointer self)
{
	folder_list_inbox_folder_entry_on_information_changed ((FolderListInboxFolderEntry*) self, _sender);
}

FolderListInboxFolderEntry*
folder_list_inbox_folder_entry_construct (GType object_type,
                                          ApplicationFolderContext* context)
{
	FolderListInboxFolderEntry * self = NULL;
	GearyFolder* _tmp0_;
	GearyFolder* _tmp1_;
	GearyAccount* _tmp2_;
	GearyAccount* _tmp3_;
	GearyAccountInformation* _tmp4_;
	GearyAccountInformation* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	gchar* _tmp8_;
	GearyFolder* _tmp9_;
	GearyFolder* _tmp10_;
	GearyAccount* _tmp11_;
	GearyAccount* _tmp12_;
	GearyAccountInformation* _tmp13_;
	GearyAccountInformation* _tmp14_;
	g_return_val_if_fail (APPLICATION_IS_FOLDER_CONTEXT (context), NULL);
	self = (FolderListInboxFolderEntry*) folder_list_folder_entry_construct (object_type, context);
	_tmp0_ = application_folder_context_get_folder (context);
	_tmp1_ = _tmp0_;
	_tmp2_ = geary_folder_get_account (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = geary_account_get_information (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = geary_account_information_get_display_name (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = g_strdup (_tmp7_);
	_g_free0 (self->priv->display_name);
	self->priv->display_name = _tmp8_;
	_tmp9_ = application_folder_context_get_folder (context);
	_tmp10_ = _tmp9_;
	_tmp11_ = geary_folder_get_account (_tmp10_);
	_tmp12_ = _tmp11_;
	_tmp13_ = geary_account_get_information (_tmp12_);
	_tmp14_ = _tmp13_;
	g_signal_connect_object (_tmp14_, "changed", (GCallback) _folder_list_inbox_folder_entry_on_information_changed_geary_account_information_changed, self, 0);
	return self;
}

FolderListInboxFolderEntry*
folder_list_inbox_folder_entry_new (ApplicationFolderContext* context)
{
	return folder_list_inbox_folder_entry_construct (FOLDER_LIST_TYPE_INBOX_FOLDER_ENTRY, context);
}

static gchar*
folder_list_inbox_folder_entry_real_get_sidebar_name (FolderListAbstractFolderEntry* base)
{
	FolderListInboxFolderEntry * self;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, FOLDER_LIST_TYPE_INBOX_FOLDER_ENTRY, FolderListInboxFolderEntry);
	_tmp0_ = self->priv->display_name;
	_tmp1_ = g_strdup (_tmp0_);
	result = _tmp1_;
	return result;
}

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

GearyAccountInformation*
folder_list_inbox_folder_entry_get_account_information (FolderListInboxFolderEntry* self)
{
	GearyFolder* _tmp0_;
	GearyFolder* _tmp1_;
	GearyAccount* _tmp2_;
	GearyAccount* _tmp3_;
	GearyAccountInformation* _tmp4_;
	GearyAccountInformation* _tmp5_;
	GearyAccountInformation* _tmp6_;
	GearyAccountInformation* result;
	g_return_val_if_fail (FOLDER_LIST_IS_INBOX_FOLDER_ENTRY (self), NULL);
	_tmp0_ = folder_list_abstract_folder_entry_get_folder (G_TYPE_CHECK_INSTANCE_CAST (self, FOLDER_LIST_TYPE_ABSTRACT_FOLDER_ENTRY, FolderListAbstractFolderEntry));
	_tmp1_ = _tmp0_;
	_tmp2_ = geary_folder_get_account (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = geary_account_get_information (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = _g_object_ref0 (_tmp5_);
	result = _tmp6_;
	return result;
}

static void
folder_list_inbox_folder_entry_on_information_changed (FolderListInboxFolderEntry* self,
                                                       GearyAccountInformation* config)
{
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	g_return_if_fail (FOLDER_LIST_IS_INBOX_FOLDER_ENTRY (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (config, GEARY_TYPE_ACCOUNT_INFORMATION));
	_tmp0_ = self->priv->display_name;
	_tmp1_ = geary_account_information_get_display_name (config);
	_tmp2_ = _tmp1_;
	if (g_strcmp0 (_tmp0_, _tmp2_) != 0) {
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		gchar* _tmp5_;
		_tmp3_ = geary_account_information_get_display_name (config);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_strdup (_tmp4_);
		_g_free0 (self->priv->display_name);
		self->priv->display_name = _tmp5_;
		g_signal_emit_by_name (G_TYPE_CHECK_INSTANCE_CAST (self, SIDEBAR_TYPE_ENTRY, SidebarEntry), "entry-changed");
	}
}

static void
folder_list_inbox_folder_entry_class_init (FolderListInboxFolderEntryClass * klass,
                                           gpointer klass_data)
{
	folder_list_inbox_folder_entry_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FolderListInboxFolderEntry_private_offset);
	((FolderListAbstractFolderEntryClass *) klass)->get_sidebar_name = (gchar* (*) (FolderListAbstractFolderEntry*)) folder_list_inbox_folder_entry_real_get_sidebar_name;
	G_OBJECT_CLASS (klass)->finalize = folder_list_inbox_folder_entry_finalize;
}

static void
folder_list_inbox_folder_entry_instance_init (FolderListInboxFolderEntry * self,
                                              gpointer klass)
{
	gchar* _tmp0_;
	self->priv = folder_list_inbox_folder_entry_get_instance_private (self);
	_tmp0_ = g_strdup ("");
	self->priv->display_name = _tmp0_;
}

static void
folder_list_inbox_folder_entry_finalize (GObject * obj)
{
	FolderListInboxFolderEntry * self;
	GearyFolder* _tmp0_;
	GearyFolder* _tmp1_;
	GearyAccount* _tmp2_;
	GearyAccount* _tmp3_;
	GearyAccountInformation* _tmp4_;
	GearyAccountInformation* _tmp5_;
	guint _tmp6_;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FOLDER_LIST_TYPE_INBOX_FOLDER_ENTRY, FolderListInboxFolderEntry);
	_tmp0_ = folder_list_abstract_folder_entry_get_folder (G_TYPE_CHECK_INSTANCE_CAST (self, FOLDER_LIST_TYPE_ABSTRACT_FOLDER_ENTRY, FolderListAbstractFolderEntry));
	_tmp1_ = _tmp0_;
	_tmp2_ = geary_folder_get_account (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = geary_account_get_information (_tmp3_);
	_tmp5_ = _tmp4_;
	g_signal_parse_name ("changed", GEARY_TYPE_ACCOUNT_INFORMATION, &_tmp6_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp5_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp6_, 0, NULL, (GCallback) _folder_list_inbox_folder_entry_on_information_changed_geary_account_information_changed, self);
	_g_free0 (self->priv->display_name);
	G_OBJECT_CLASS (folder_list_inbox_folder_entry_parent_class)->finalize (obj);
}

static GType
folder_list_inbox_folder_entry_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FolderListInboxFolderEntryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) folder_list_inbox_folder_entry_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FolderListInboxFolderEntry), 0, (GInstanceInitFunc) folder_list_inbox_folder_entry_instance_init, NULL };
	GType folder_list_inbox_folder_entry_type_id;
	folder_list_inbox_folder_entry_type_id = g_type_register_static (FOLDER_LIST_TYPE_FOLDER_ENTRY, "FolderListInboxFolderEntry", &g_define_type_info, 0);
	FolderListInboxFolderEntry_private_offset = g_type_add_instance_private (folder_list_inbox_folder_entry_type_id, sizeof (FolderListInboxFolderEntryPrivate));
	return folder_list_inbox_folder_entry_type_id;
}

GType
folder_list_inbox_folder_entry_get_type (void)
{
	static volatile gsize folder_list_inbox_folder_entry_type_id__once = 0;
	if (g_once_init_enter (&folder_list_inbox_folder_entry_type_id__once)) {
		GType folder_list_inbox_folder_entry_type_id;
		folder_list_inbox_folder_entry_type_id = folder_list_inbox_folder_entry_get_type_once ();
		g_once_init_leave (&folder_list_inbox_folder_entry_type_id__once, folder_list_inbox_folder_entry_type_id);
	}
	return folder_list_inbox_folder_entry_type_id__once;
}

