/* Avatar.c generated by valac 0.52.4, the Vala compiler
 * generated from Avatar.vala, do not modify */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <handy.h>

#define TOOTLE_WIDGETS_TYPE_AVATAR (tootle_widgets_avatar_get_type ())
#define TOOTLE_WIDGETS_AVATAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_WIDGETS_TYPE_AVATAR, TootleWidgetsAvatar))
#define TOOTLE_WIDGETS_AVATAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_WIDGETS_TYPE_AVATAR, TootleWidgetsAvatarClass))
#define TOOTLE_WIDGETS_IS_AVATAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_WIDGETS_TYPE_AVATAR))
#define TOOTLE_WIDGETS_IS_AVATAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_WIDGETS_TYPE_AVATAR))
#define TOOTLE_WIDGETS_AVATAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_WIDGETS_TYPE_AVATAR, TootleWidgetsAvatarClass))

typedef struct _TootleWidgetsAvatar TootleWidgetsAvatar;
typedef struct _TootleWidgetsAvatarClass TootleWidgetsAvatarClass;
typedef struct _TootleWidgetsAvatarPrivate TootleWidgetsAvatarPrivate;

#define TOOTLE_CACHE_TYPE_REFERENCE (tootle_cache_reference_get_type ())
typedef struct _TootleCacheReference TootleCacheReference;

#define TOOTLE_TYPE_ENTITY (tootle_entity_get_type ())
#define TOOTLE_ENTITY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_TYPE_ENTITY, TootleEntity))
#define TOOTLE_ENTITY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_TYPE_ENTITY, TootleEntityClass))
#define TOOTLE_IS_ENTITY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_TYPE_ENTITY))
#define TOOTLE_IS_ENTITY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_TYPE_ENTITY))
#define TOOTLE_ENTITY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_TYPE_ENTITY, TootleEntityClass))

typedef struct _TootleEntity TootleEntity;
typedef struct _TootleEntityClass TootleEntityClass;

#define TOOTLE_API_TYPE_ACCOUNT (tootle_api_account_get_type ())
#define TOOTLE_API_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_API_TYPE_ACCOUNT, TootleAPIAccount))
#define TOOTLE_API_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_API_TYPE_ACCOUNT, TootleAPIAccountClass))
#define TOOTLE_API_IS_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_API_TYPE_ACCOUNT))
#define TOOTLE_API_IS_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_API_TYPE_ACCOUNT))
#define TOOTLE_API_ACCOUNT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_API_TYPE_ACCOUNT, TootleAPIAccountClass))

typedef struct _TootleAPIAccount TootleAPIAccount;
typedef struct _TootleAPIAccountClass TootleAPIAccountClass;
enum  {
	TOOTLE_WIDGETS_AVATAR_0_PROPERTY,
	TOOTLE_WIDGETS_AVATAR_SIZE_PROPERTY,
	TOOTLE_WIDGETS_AVATAR_ACCOUNT_PROPERTY,
	TOOTLE_WIDGETS_AVATAR_NUM_PROPERTIES
};
static GParamSpec* tootle_widgets_avatar_properties[TOOTLE_WIDGETS_AVATAR_NUM_PROPERTIES];

#define TOOTLE_TYPE_CACHE (tootle_cache_get_type ())
#define TOOTLE_CACHE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_TYPE_CACHE, TootleCache))
#define TOOTLE_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_TYPE_CACHE, TootleCacheClass))
#define TOOTLE_IS_CACHE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_TYPE_CACHE))
#define TOOTLE_IS_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_TYPE_CACHE))
#define TOOTLE_CACHE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_TYPE_CACHE, TootleCacheClass))

typedef struct _TootleCache TootleCache;
typedef struct _TootleCacheClass TootleCacheClass;
#define _tootle_cache_reference_free0(var) ((var == NULL) ? NULL : (var = (tootle_cache_reference_free (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef void (*TootleCacheCachedResultCallback) (TootleCacheReference* _result_, gpointer user_data);

struct _TootleWidgetsAvatar {
	GtkBin parent_instance;
	TootleWidgetsAvatarPrivate * priv;
};

struct _TootleWidgetsAvatarClass {
	GtkBinClass parent_class;
};

struct _TootleCacheReference {
	gchar* key;
	GdkPixbuf* data;
	gboolean loading;
};

struct _TootleWidgetsAvatarPrivate {
	TootleCacheReference* cached;
	HdyAvatar* avatar;
	TootleAPIAccount* _account;
};

static gint TootleWidgetsAvatar_private_offset;
static gpointer tootle_widgets_avatar_parent_class = NULL;
extern TootleCache* tootle_cache;

GType tootle_widgets_avatar_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleWidgetsAvatar, g_object_unref)
GType tootle_cache_reference_get_type (void) G_GNUC_CONST ;
TootleCacheReference* tootle_cache_reference_dup (const TootleCacheReference* self);
void tootle_cache_reference_free (TootleCacheReference* self);
void tootle_cache_reference_copy (const TootleCacheReference* self,
                                  TootleCacheReference* dest);
void tootle_cache_reference_destroy (TootleCacheReference* self);
GType tootle_entity_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleEntity, g_object_unref)
GType tootle_api_account_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleAPIAccount, g_object_unref)
static void tootle_widgets_avatar_on_invalidated (TootleWidgetsAvatar* self);
static void _tootle_widgets_avatar_on_invalidated_g_object_notify (GObject* _sender,
                                                            GParamSpec* pspec,
                                                            gpointer self);
GType tootle_cache_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleCache, g_object_unref)
void tootle_cache_unload (TootleCache* self,
                          TootleCacheReference** r);
TootleAPIAccount* tootle_widgets_avatar_get_account (TootleWidgetsAvatar* self);
void tootle_cache_load (TootleCache* self,
                        const gchar* url,
                        TootleCacheCachedResultCallback cb,
                        gpointer cb_target,
                        GDestroyNotify cb_target_destroy_notify);
const gchar* tootle_api_account_get_avatar (TootleAPIAccount* self);
static void tootle_widgets_avatar_on_cache_result (TootleWidgetsAvatar* self,
                                            TootleCacheReference* _result_);
static void _tootle_widgets_avatar_on_cache_result_tootle_cache_cached_result_callback (TootleCacheReference* _result_,
                                                                                 gpointer self);
const gchar* tootle_api_account_get_display_name (TootleAPIAccount* self);
static GdkPixbuf* tootle_widgets_avatar_avatar_set_pixbuf (TootleWidgetsAvatar* self,
                                                    gint size);
static GdkPixbuf* _tootle_widgets_avatar_avatar_set_pixbuf_hdy_avatar_image_load_func (gint size,
                                                                                gpointer self);
TootleWidgetsAvatar* tootle_widgets_avatar_new (void);
TootleWidgetsAvatar* tootle_widgets_avatar_construct (GType object_type);
gint tootle_widgets_avatar_get_size (TootleWidgetsAvatar* self);
void tootle_widgets_avatar_set_size (TootleWidgetsAvatar* self,
                                     gint value);
void tootle_widgets_avatar_set_account (TootleWidgetsAvatar* self,
                                        TootleAPIAccount* value);
static GObject * tootle_widgets_avatar_constructor (GType type,
                                             guint n_construct_properties,
                                             GObjectConstructParam * construct_properties);
static void _tootle_widgets_avatar___lambda28_ (TootleWidgetsAvatar* self);
static void __tootle_widgets_avatar___lambda28__gtk_widget_destroy (GtkWidget* _sender,
                                                             gpointer self);
static void tootle_widgets_avatar_finalize (GObject * obj);
static GType tootle_widgets_avatar_get_type_once (void);
static void _vala_tootle_widgets_avatar_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec);
static void _vala_tootle_widgets_avatar_set_property (GObject * object,
                                               guint property_id,
                                               const GValue * value,
                                               GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
tootle_widgets_avatar_get_instance_private (TootleWidgetsAvatar* self)
{
	return G_STRUCT_MEMBER_P (self, TootleWidgetsAvatar_private_offset);
}

static void
_tootle_widgets_avatar_on_invalidated_g_object_notify (GObject* _sender,
                                                       GParamSpec* pspec,
                                                       gpointer self)
{
	tootle_widgets_avatar_on_invalidated ((TootleWidgetsAvatar*) self);
}

static void
_tootle_widgets_avatar_on_cache_result_tootle_cache_cached_result_callback (TootleCacheReference* _result_,
                                                                            gpointer self)
{
	tootle_widgets_avatar_on_cache_result ((TootleWidgetsAvatar*) self, _result_);
}

static void
tootle_widgets_avatar_on_invalidated (TootleWidgetsAvatar* self)
{
	TootleCacheReference* _tmp0_;
	TootleAPIAccount* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->cached;
	if (_tmp0_ != NULL) {
		TootleCache* _tmp1_;
		_tmp1_ = tootle_cache;
		tootle_cache_unload (_tmp1_, &self->priv->cached);
	}
	_tmp2_ = self->priv->_account;
	if (_tmp2_ != NULL) {
		TootleCache* _tmp3_;
		TootleAPIAccount* _tmp4_;
		const gchar* _tmp5_;
		const gchar* _tmp6_;
		_tmp3_ = tootle_cache;
		_tmp4_ = self->priv->_account;
		_tmp5_ = tootle_api_account_get_avatar (_tmp4_);
		_tmp6_ = _tmp5_;
		tootle_cache_load (_tmp3_, _tmp6_, _tootle_widgets_avatar_on_cache_result_tootle_cache_cached_result_callback, g_object_ref (self), g_object_unref);
	} else {
		tootle_widgets_avatar_on_cache_result (self, NULL);
	}
}

static gpointer
_tootle_cache_reference_dup0 (gpointer self)
{
	return self ? tootle_cache_reference_dup (self) : NULL;
}

static GdkPixbuf*
_tootle_widgets_avatar_avatar_set_pixbuf_hdy_avatar_image_load_func (gint size,
                                                                     gpointer self)
{
	GdkPixbuf* result;
	result = tootle_widgets_avatar_avatar_set_pixbuf ((TootleWidgetsAvatar*) self, size);
	return result;
}

static void
tootle_widgets_avatar_on_cache_result (TootleWidgetsAvatar* self,
                                       TootleCacheReference* _result_)
{
	TootleCacheReference* _tmp0_;
	TootleAPIAccount* _tmp1_;
	HdyAvatar* _tmp10_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _tootle_cache_reference_dup0 (_result_);
	_tootle_cache_reference_free0 (self->priv->cached);
	self->priv->cached = _tmp0_;
	_tmp1_ = self->priv->_account;
	if (_tmp1_ == NULL) {
		HdyAvatar* _tmp2_;
		HdyAvatar* _tmp3_;
		_tmp2_ = self->priv->avatar;
		hdy_avatar_set_text (_tmp2_, "abc");
		_tmp3_ = self->priv->avatar;
		hdy_avatar_set_show_initials (_tmp3_, FALSE);
	} else {
		TootleCacheReference* _tmp4_;
		_tmp4_ = self->priv->cached;
		if (_tmp4_ != NULL) {
			HdyAvatar* _tmp5_;
			TootleAPIAccount* _tmp6_;
			const gchar* _tmp7_;
			const gchar* _tmp8_;
			HdyAvatar* _tmp9_;
			_tmp5_ = self->priv->avatar;
			_tmp6_ = self->priv->_account;
			_tmp7_ = tootle_api_account_get_display_name (_tmp6_);
			_tmp8_ = _tmp7_;
			hdy_avatar_set_text (_tmp5_, _tmp8_);
			_tmp9_ = self->priv->avatar;
			hdy_avatar_set_show_initials (_tmp9_, TRUE);
		}
	}
	_tmp10_ = self->priv->avatar;
	hdy_avatar_set_image_load_func (_tmp10_, _tootle_widgets_avatar_avatar_set_pixbuf_hdy_avatar_image_load_func, g_object_ref (self), g_object_unref);
}

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

static GdkPixbuf*
tootle_widgets_avatar_avatar_set_pixbuf (TootleWidgetsAvatar* self,
                                         gint size)
{
	gboolean _tmp0_ = FALSE;
	TootleCacheReference* _tmp1_;
	GdkPixbuf* result = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp1_ = self->priv->cached;
	if (_tmp1_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		TootleCacheReference* _tmp2_;
		GdkPixbuf* _tmp3_;
		_tmp2_ = self->priv->cached;
		_tmp3_ = (*_tmp2_).data;
		_tmp0_ = _tmp3_ == NULL;
	}
	if (_tmp0_) {
		result = NULL;
		return result;
	} else {
		GdkPixbuf* pb = NULL;
		TootleCacheReference* _tmp4_;
		GdkPixbuf* _tmp5_;
		GdkPixbuf* _tmp6_;
		GdkPixbuf* _tmp7_;
		gint _tmp8_;
		gint _tmp9_;
		_tmp4_ = self->priv->cached;
		_tmp5_ = (*_tmp4_).data;
		_tmp6_ = _g_object_ref0 (_tmp5_);
		pb = _tmp6_;
		_tmp7_ = pb;
		_tmp8_ = gdk_pixbuf_get_width (_tmp7_);
		_tmp9_ = _tmp8_;
		if (_tmp9_ != size) {
			GdkPixbuf* _tmp10_;
			GdkPixbuf* _tmp11_;
			_tmp10_ = pb;
			_tmp11_ = gdk_pixbuf_scale_simple (_tmp10_, size, size, GDK_INTERP_BILINEAR);
			result = _tmp11_;
			_g_object_unref0 (pb);
			return result;
		} else {
			result = pb;
			return result;
		}
		_g_object_unref0 (pb);
	}
}

TootleWidgetsAvatar*
tootle_widgets_avatar_construct (GType object_type)
{
	TootleWidgetsAvatar * self = NULL;
	self = (TootleWidgetsAvatar*) g_object_new (object_type, NULL);
	return self;
}

TootleWidgetsAvatar*
tootle_widgets_avatar_new (void)
{
	return tootle_widgets_avatar_construct (TOOTLE_WIDGETS_TYPE_AVATAR);
}

gint
tootle_widgets_avatar_get_size (TootleWidgetsAvatar* self)
{
	gint result;
	HdyAvatar* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->avatar;
	_tmp1_ = hdy_avatar_get_size (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

void
tootle_widgets_avatar_set_size (TootleWidgetsAvatar* self,
                                gint value)
{
	HdyAvatar* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->avatar;
	hdy_avatar_set_size (_tmp0_, value);
	g_object_notify_by_pspec ((GObject *) self, tootle_widgets_avatar_properties[TOOTLE_WIDGETS_AVATAR_SIZE_PROPERTY]);
}

TootleAPIAccount*
tootle_widgets_avatar_get_account (TootleWidgetsAvatar* self)
{
	TootleAPIAccount* result;
	TootleAPIAccount* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_account;
	result = _tmp0_;
	return result;
}

void
tootle_widgets_avatar_set_account (TootleWidgetsAvatar* self,
                                   TootleAPIAccount* value)
{
	TootleAPIAccount* old_value;
	g_return_if_fail (self != NULL);
	old_value = tootle_widgets_avatar_get_account (self);
	if (old_value != value) {
		TootleAPIAccount* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_account);
		self->priv->_account = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, tootle_widgets_avatar_properties[TOOTLE_WIDGETS_AVATAR_ACCOUNT_PROPERTY]);
	}
}

static void
_tootle_widgets_avatar___lambda28_ (TootleWidgetsAvatar* self)
{
	HdyAvatar* _tmp0_;
	_tmp0_ = self->priv->avatar;
	hdy_avatar_set_image_load_func (_tmp0_, NULL, NULL, NULL);
}

static void
__tootle_widgets_avatar___lambda28__gtk_widget_destroy (GtkWidget* _sender,
                                                        gpointer self)
{
	_tootle_widgets_avatar___lambda28_ ((TootleWidgetsAvatar*) self);
}

static GObject *
tootle_widgets_avatar_constructor (GType type,
                                   guint n_construct_properties,
                                   GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	TootleWidgetsAvatar * self;
	HdyAvatar* _tmp0_;
	HdyAvatar* _tmp1_;
	HdyAvatar* _tmp2_;
	parent_class = G_OBJECT_CLASS (tootle_widgets_avatar_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TOOTLE_WIDGETS_TYPE_AVATAR, TootleWidgetsAvatar);
	_tmp0_ = (HdyAvatar*) hdy_avatar_new (48, NULL, TRUE);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->avatar);
	self->priv->avatar = _tmp0_;
	_tmp1_ = self->priv->avatar;
	g_signal_connect_object ((GtkWidget*) _tmp1_, "destroy", (GCallback) __tootle_widgets_avatar___lambda28__gtk_widget_destroy, self, 0);
	_tmp2_ = self->priv->avatar;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp2_);
	gtk_widget_show_all ((GtkWidget*) self);
	g_signal_connect_object ((GObject*) self, "notify::account", (GCallback) _tootle_widgets_avatar_on_invalidated_g_object_notify, self, 0);
	tootle_widgets_avatar_on_invalidated (self);
	return obj;
}

static void
tootle_widgets_avatar_class_init (TootleWidgetsAvatarClass * klass,
                                  gpointer klass_data)
{
	tootle_widgets_avatar_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &TootleWidgetsAvatar_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_tootle_widgets_avatar_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_tootle_widgets_avatar_set_property;
	G_OBJECT_CLASS (klass)->constructor = tootle_widgets_avatar_constructor;
	G_OBJECT_CLASS (klass)->finalize = tootle_widgets_avatar_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), TOOTLE_WIDGETS_AVATAR_SIZE_PROPERTY, tootle_widgets_avatar_properties[TOOTLE_WIDGETS_AVATAR_SIZE_PROPERTY] = g_param_spec_int ("size", "size", "size", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), TOOTLE_WIDGETS_AVATAR_ACCOUNT_PROPERTY, tootle_widgets_avatar_properties[TOOTLE_WIDGETS_AVATAR_ACCOUNT_PROPERTY] = g_param_spec_object ("account", "account", "account", TOOTLE_API_TYPE_ACCOUNT, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
tootle_widgets_avatar_instance_init (TootleWidgetsAvatar * self,
                                     gpointer klass)
{
	self->priv = tootle_widgets_avatar_get_instance_private (self);
}

static void
tootle_widgets_avatar_finalize (GObject * obj)
{
	TootleWidgetsAvatar * self;
	guint _tmp0_;
	GQuark _tmp1_;
	TootleCache* _tmp2_;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TOOTLE_WIDGETS_TYPE_AVATAR, TootleWidgetsAvatar);
	g_signal_parse_name ("notify::account", G_TYPE_OBJECT, &_tmp0_, &_tmp1_, TRUE);
	g_signal_handlers_disconnect_matched ((GObject*) self, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DETAIL | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp0_, _tmp1_, NULL, (GCallback) _tootle_widgets_avatar_on_invalidated_g_object_notify, self);
	_tmp2_ = tootle_cache;
	tootle_cache_unload (_tmp2_, &self->priv->cached);
	_tootle_cache_reference_free0 (self->priv->cached);
	_g_object_unref0 (self->priv->avatar);
	_g_object_unref0 (self->priv->_account);
	G_OBJECT_CLASS (tootle_widgets_avatar_parent_class)->finalize (obj);
}

static GType
tootle_widgets_avatar_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TootleWidgetsAvatarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tootle_widgets_avatar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TootleWidgetsAvatar), 0, (GInstanceInitFunc) tootle_widgets_avatar_instance_init, NULL };
	GType tootle_widgets_avatar_type_id;
	tootle_widgets_avatar_type_id = g_type_register_static (gtk_bin_get_type (), "TootleWidgetsAvatar", &g_define_type_info, 0);
	TootleWidgetsAvatar_private_offset = g_type_add_instance_private (tootle_widgets_avatar_type_id, sizeof (TootleWidgetsAvatarPrivate));
	return tootle_widgets_avatar_type_id;
}

GType
tootle_widgets_avatar_get_type (void)
{
	static volatile gsize tootle_widgets_avatar_type_id__volatile = 0;
	if (g_once_init_enter (&tootle_widgets_avatar_type_id__volatile)) {
		GType tootle_widgets_avatar_type_id;
		tootle_widgets_avatar_type_id = tootle_widgets_avatar_get_type_once ();
		g_once_init_leave (&tootle_widgets_avatar_type_id__volatile, tootle_widgets_avatar_type_id);
	}
	return tootle_widgets_avatar_type_id__volatile;
}

static void
_vala_tootle_widgets_avatar_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec)
{
	TootleWidgetsAvatar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TOOTLE_WIDGETS_TYPE_AVATAR, TootleWidgetsAvatar);
	switch (property_id) {
		case TOOTLE_WIDGETS_AVATAR_SIZE_PROPERTY:
		g_value_set_int (value, tootle_widgets_avatar_get_size (self));
		break;
		case TOOTLE_WIDGETS_AVATAR_ACCOUNT_PROPERTY:
		g_value_set_object (value, tootle_widgets_avatar_get_account (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_tootle_widgets_avatar_set_property (GObject * object,
                                          guint property_id,
                                          const GValue * value,
                                          GParamSpec * pspec)
{
	TootleWidgetsAvatar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TOOTLE_WIDGETS_TYPE_AVATAR, TootleWidgetsAvatar);
	switch (property_id) {
		case TOOTLE_WIDGETS_AVATAR_SIZE_PROPERTY:
		tootle_widgets_avatar_set_size (self, g_value_get_int (value));
		break;
		case TOOTLE_WIDGETS_AVATAR_ACCOUNT_PROPERTY:
		tootle_widgets_avatar_set_account (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

