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

/*  This file is part of corebird, a Gtk+ linux Twitter client.
 *  Copyright (C) 2013 Timm Bäder
 *
 *  corebird 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 3 of the License, or
 *  (at your option) any later version.
 *
 *  corebird 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 corebird.  If not, see <http://www.gnu.org/licenses/>.
 */

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


#define TYPE_DM_PLACEHOLDER_BOX (dm_placeholder_box_get_type ())
#define DM_PLACEHOLDER_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DM_PLACEHOLDER_BOX, DMPlaceholderBox))
#define DM_PLACEHOLDER_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DM_PLACEHOLDER_BOX, DMPlaceholderBoxClass))
#define IS_DM_PLACEHOLDER_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DM_PLACEHOLDER_BOX))
#define IS_DM_PLACEHOLDER_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DM_PLACEHOLDER_BOX))
#define DM_PLACEHOLDER_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DM_PLACEHOLDER_BOX, DMPlaceholderBoxClass))

typedef struct _DMPlaceholderBox DMPlaceholderBox;
typedef struct _DMPlaceholderBoxClass DMPlaceholderBoxClass;
typedef struct _DMPlaceholderBoxPrivate DMPlaceholderBoxPrivate;

#define TYPE_AVATAR_WIDGET (avatar_widget_get_type ())
#define AVATAR_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_AVATAR_WIDGET, AvatarWidget))
#define AVATAR_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_AVATAR_WIDGET, AvatarWidgetClass))
#define IS_AVATAR_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_AVATAR_WIDGET))
#define IS_AVATAR_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_AVATAR_WIDGET))
#define AVATAR_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_AVATAR_WIDGET, AvatarWidgetClass))

typedef struct _AvatarWidget AvatarWidget;
typedef struct _AvatarWidgetClass AvatarWidgetClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

#define TYPE_TWITTER (twitter_get_type ())
#define TWITTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TWITTER, Twitter))
#define TWITTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TWITTER, TwitterClass))
#define IS_TWITTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TWITTER))
#define IS_TWITTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TWITTER))
#define TWITTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TWITTER, TwitterClass))

typedef struct _Twitter Twitter;
typedef struct _TwitterClass TwitterClass;

struct _DMPlaceholderBox {
	GtkBox parent_instance;
	DMPlaceholderBoxPrivate * priv;
	gchar* avatar_url;
};

struct _DMPlaceholderBoxClass {
	GtkBoxClass parent_class;
};

struct _DMPlaceholderBoxPrivate {
	AvatarWidget* avatar_image;
	GtkLabel* name_label;
	GtkLabel* screen_name_label;
};

typedef void (*TwitterAvatarDownloadedFunc) (GdkPixbuf* avatar, void* user_data);

static gpointer dm_placeholder_box_parent_class = NULL;

GType dm_placeholder_box_get_type (void) G_GNUC_CONST;
GType avatar_widget_get_type (void) G_GNUC_CONST;
#define DM_PLACEHOLDER_BOX_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_DM_PLACEHOLDER_BOX, DMPlaceholderBoxPrivate))
enum  {
	DM_PLACEHOLDER_BOX_DUMMY_PROPERTY,
	DM_PLACEHOLDER_BOX_NAME,
	DM_PLACEHOLDER_BOX_SCREEN_NAME
};
void dm_placeholder_box_load_avatar (DMPlaceholderBox* self);
GType twitter_get_type (void) G_GNUC_CONST;
Twitter* twitter_get (void);
GdkPixbuf* twitter_get_avatar (Twitter* self, const gchar* url, TwitterAvatarDownloadedFunc func, void* func_target, GDestroyNotify func_target_destroy_notify);
static void __lambda118_ (DMPlaceholderBox* self, GdkPixbuf* a);
static void ___lambda118__twitter_avatar_downloaded_func (GdkPixbuf* avatar, gpointer self);
DMPlaceholderBox* dm_placeholder_box_new (void);
DMPlaceholderBox* dm_placeholder_box_construct (GType object_type);
void dm_placeholder_box_set_name (DMPlaceholderBox* self, const gchar* value);
void dm_placeholder_box_set_screen_name (DMPlaceholderBox* self, const gchar* value);
static void dm_placeholder_box_finalize (GObject* obj);
static void _vala_dm_placeholder_box_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);


static void __lambda118_ (DMPlaceholderBox* self, GdkPixbuf* a) {
	AvatarWidget* _tmp0_ = NULL;
	GdkPixbuf* _tmp1_ = NULL;
	g_return_if_fail (GDK_IS_PIXBUF (a));
	_tmp0_ = self->priv->avatar_image;
	_tmp1_ = a;
	g_object_set (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gtk_image_get_type (), GtkImage), "pixbuf", _tmp1_, NULL);
}


static void ___lambda118__twitter_avatar_downloaded_func (GdkPixbuf* avatar, gpointer self) {
	__lambda118_ ((DMPlaceholderBox*) self, avatar);
}


void dm_placeholder_box_load_avatar (DMPlaceholderBox* self) {
	AvatarWidget* _tmp0_ = NULL;
	Twitter* _tmp1_ = NULL;
	Twitter* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	GdkPixbuf* _tmp4_ = NULL;
	GdkPixbuf* _tmp5_ = NULL;
	g_return_if_fail (IS_DM_PLACEHOLDER_BOX (self));
	_tmp0_ = self->priv->avatar_image;
	_tmp1_ = twitter_get ();
	_tmp2_ = _tmp1_;
	_tmp3_ = self->avatar_url;
	_tmp4_ = twitter_get_avatar (_tmp2_, _tmp3_, ___lambda118__twitter_avatar_downloaded_func, g_object_ref (self), g_object_unref);
	_tmp5_ = _tmp4_;
	g_object_set (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gtk_image_get_type (), GtkImage), "pixbuf", _tmp5_, NULL);
	_g_object_unref0 (_tmp5_);
	_g_object_unref0 (_tmp2_);
}


DMPlaceholderBox* dm_placeholder_box_construct (GType object_type) {
	DMPlaceholderBox * self = NULL;
	self = (DMPlaceholderBox*) g_object_new (object_type, NULL);
	return self;
}


DMPlaceholderBox* dm_placeholder_box_new (void) {
	return dm_placeholder_box_construct (TYPE_DM_PLACEHOLDER_BOX);
}


void dm_placeholder_box_set_name (DMPlaceholderBox* self, const gchar* value) {
	GtkLabel* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	g_return_if_fail (IS_DM_PLACEHOLDER_BOX (self));
	_tmp0_ = self->priv->name_label;
	_tmp1_ = value;
	gtk_label_set_label (_tmp0_, _tmp1_);
	g_object_notify ((GObject *) self, "name");
}


void dm_placeholder_box_set_screen_name (DMPlaceholderBox* self, const gchar* value) {
	GtkLabel* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	g_return_if_fail (IS_DM_PLACEHOLDER_BOX (self));
	_tmp0_ = self->priv->screen_name_label;
	_tmp1_ = value;
	_tmp2_ = g_strconcat ("@", _tmp1_, NULL);
	_tmp3_ = _tmp2_;
	gtk_label_set_label (_tmp0_, _tmp3_);
	_g_free0 (_tmp3_);
	g_object_notify ((GObject *) self, "screen-name");
}


static void dm_placeholder_box_class_init (DMPlaceholderBoxClass * klass) {
	gint DMPlaceholderBox_private_offset;
	dm_placeholder_box_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (DMPlaceholderBoxPrivate));
	G_OBJECT_CLASS (klass)->set_property = _vala_dm_placeholder_box_set_property;
	G_OBJECT_CLASS (klass)->finalize = dm_placeholder_box_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DM_PLACEHOLDER_BOX_NAME, g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DM_PLACEHOLDER_BOX_SCREEN_NAME, g_param_spec_string ("screen-name", "screen-name", "screen-name", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE));
	DMPlaceholderBox_private_offset = g_type_class_get_instance_private_offset (klass);
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/baedert/corebird/ui/dm-placeholder-box.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "avatar_image", FALSE, DMPlaceholderBox_private_offset + G_STRUCT_OFFSET (DMPlaceholderBoxPrivate, avatar_image));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "name_label", FALSE, DMPlaceholderBox_private_offset + G_STRUCT_OFFSET (DMPlaceholderBoxPrivate, name_label));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "screen_name_label", FALSE, DMPlaceholderBox_private_offset + G_STRUCT_OFFSET (DMPlaceholderBoxPrivate, screen_name_label));
}


static void dm_placeholder_box_instance_init (DMPlaceholderBox * self) {
	self->priv = DM_PLACEHOLDER_BOX_GET_PRIVATE (self);
	g_type_ensure (TYPE_AVATAR_WIDGET);
	gtk_widget_init_template (GTK_WIDGET (self));
}


static void dm_placeholder_box_finalize (GObject* obj) {
	DMPlaceholderBox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_DM_PLACEHOLDER_BOX, DMPlaceholderBox);
	_g_object_unref0 (self->priv->avatar_image);
	_g_object_unref0 (self->priv->name_label);
	_g_object_unref0 (self->priv->screen_name_label);
	_g_free0 (self->avatar_url);
	G_OBJECT_CLASS (dm_placeholder_box_parent_class)->finalize (obj);
}


GType dm_placeholder_box_get_type (void) {
	static volatile gsize dm_placeholder_box_type_id__volatile = 0;
	if (g_once_init_enter (&dm_placeholder_box_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (DMPlaceholderBoxClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dm_placeholder_box_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DMPlaceholderBox), 0, (GInstanceInitFunc) dm_placeholder_box_instance_init, NULL };
		GType dm_placeholder_box_type_id;
		dm_placeholder_box_type_id = g_type_register_static (gtk_box_get_type (), "DMPlaceholderBox", &g_define_type_info, 0);
		g_once_init_leave (&dm_placeholder_box_type_id__volatile, dm_placeholder_box_type_id);
	}
	return dm_placeholder_box_type_id__volatile;
}


static void _vala_dm_placeholder_box_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	DMPlaceholderBox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_DM_PLACEHOLDER_BOX, DMPlaceholderBox);
	switch (property_id) {
		case DM_PLACEHOLDER_BOX_NAME:
		dm_placeholder_box_set_name (self, g_value_get_string (value));
		break;
		case DM_PLACEHOLDER_BOX_SCREEN_NAME:
		dm_placeholder_box_set_screen_name (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



