/* FollowButton.c generated by valac 0.30.0, the Vala compiler
 * generated from FollowButton.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 <glib/gi18n-lib.h>


#define TYPE_FOLLOW_BUTTON (follow_button_get_type ())
#define FOLLOW_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FOLLOW_BUTTON, FollowButton))
#define FOLLOW_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FOLLOW_BUTTON, FollowButtonClass))
#define IS_FOLLOW_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FOLLOW_BUTTON))
#define IS_FOLLOW_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FOLLOW_BUTTON))
#define FOLLOW_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FOLLOW_BUTTON, FollowButtonClass))

typedef struct _FollowButton FollowButton;
typedef struct _FollowButtonClass FollowButtonClass;
typedef struct _FollowButtonPrivate FollowButtonPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _FollowButton {
	GtkButton parent_instance;
	FollowButtonPrivate * priv;
};

struct _FollowButtonClass {
	GtkButtonClass parent_class;
};

struct _FollowButtonPrivate {
	gboolean _following;
	GtkStack* stack;
	GtkLabel* follow_label;
	GtkLabel* unfollow_label;
};


static gpointer follow_button_parent_class = NULL;

GType follow_button_get_type (void) G_GNUC_CONST;
#define FOLLOW_BUTTON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_FOLLOW_BUTTON, FollowButtonPrivate))
enum  {
	FOLLOW_BUTTON_DUMMY_PROPERTY,
	FOLLOW_BUTTON_FOLLOWING
};
FollowButton* follow_button_new (void);
FollowButton* follow_button_construct (GType object_type);
gboolean follow_button_get_following (FollowButton* self);
void follow_button_set_following (FollowButton* self, gboolean value);
static GObject * follow_button_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void follow_button_finalize (GObject* obj);
static void _vala_follow_button_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_follow_button_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);


FollowButton* follow_button_construct (GType object_type) {
	FollowButton * self = NULL;
	self = (FollowButton*) g_object_new (object_type, NULL);
	return self;
}


FollowButton* follow_button_new (void) {
	return follow_button_construct (TYPE_FOLLOW_BUTTON);
}


gboolean follow_button_get_following (FollowButton* self) {
	gboolean result;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (IS_FOLLOW_BUTTON (self), FALSE);
	_tmp0_ = self->priv->_following;
	result = _tmp0_;
	return result;
}


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


void follow_button_set_following (FollowButton* self, gboolean value) {
	GtkStyleContext* sc = NULL;
	GtkStyleContext* _tmp0_ = NULL;
	GtkStyleContext* _tmp1_ = NULL;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp11_ = FALSE;
	g_return_if_fail (IS_FOLLOW_BUTTON (self));
	_tmp0_ = gtk_widget_get_style_context (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
	_tmp1_ = _g_object_ref0 (_tmp0_);
	sc = _tmp1_;
	_tmp2_ = value;
	if (_tmp2_) {
		GtkStyleContext* _tmp3_ = NULL;
		GtkStyleContext* _tmp4_ = NULL;
		GtkStack* _tmp5_ = NULL;
		GtkLabel* _tmp6_ = NULL;
		_tmp3_ = sc;
		gtk_style_context_remove_class (_tmp3_, "suggested-action");
		_tmp4_ = sc;
		gtk_style_context_add_class (_tmp4_, "destructive-action");
		_tmp5_ = self->priv->stack;
		_tmp6_ = self->priv->unfollow_label;
		gtk_stack_set_visible_child (_tmp5_, G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, gtk_widget_get_type (), GtkWidget));
	} else {
		GtkStyleContext* _tmp7_ = NULL;
		GtkStyleContext* _tmp8_ = NULL;
		GtkStack* _tmp9_ = NULL;
		GtkLabel* _tmp10_ = NULL;
		_tmp7_ = sc;
		gtk_style_context_remove_class (_tmp7_, "destructive-action");
		_tmp8_ = sc;
		gtk_style_context_add_class (_tmp8_, "suggested-action");
		_tmp9_ = self->priv->stack;
		_tmp10_ = self->priv->follow_label;
		gtk_stack_set_visible_child (_tmp9_, G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, gtk_widget_get_type (), GtkWidget));
	}
	_tmp11_ = value;
	self->priv->_following = _tmp11_;
	_g_object_unref0 (sc);
	g_object_notify ((GObject *) self, "following");
}


static GObject * follow_button_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	FollowButton * self;
	GtkStack* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	GtkLabel* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	GtkLabel* _tmp4_ = NULL;
	GtkStack* _tmp5_ = NULL;
	GtkLabel* _tmp6_ = NULL;
	GtkStack* _tmp7_ = NULL;
	GtkLabel* _tmp8_ = NULL;
	GtkStack* _tmp9_ = NULL;
	parent_class = G_OBJECT_CLASS (follow_button_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_FOLLOW_BUTTON, FollowButton);
	_tmp0_ = (GtkStack*) gtk_stack_new ();
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->stack);
	self->priv->stack = _tmp0_;
	_tmp1_ = _ ("Follow");
	_tmp2_ = (GtkLabel*) gtk_label_new (_tmp1_);
	g_object_ref_sink (_tmp2_);
	_g_object_unref0 (self->priv->follow_label);
	self->priv->follow_label = _tmp2_;
	_tmp3_ = _ ("Unfollow");
	_tmp4_ = (GtkLabel*) gtk_label_new (_tmp3_);
	g_object_ref_sink (_tmp4_);
	_g_object_unref0 (self->priv->unfollow_label);
	self->priv->unfollow_label = _tmp4_;
	_tmp5_ = self->priv->stack;
	_tmp6_ = self->priv->follow_label;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, gtk_widget_get_type (), GtkWidget));
	_tmp7_ = self->priv->stack;
	_tmp8_ = self->priv->unfollow_label;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, gtk_widget_get_type (), GtkWidget));
	_tmp9_ = self->priv->stack;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, gtk_widget_get_type (), GtkWidget));
	return obj;
}


static void follow_button_class_init (FollowButtonClass * klass) {
	follow_button_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (FollowButtonPrivate));
	G_OBJECT_CLASS (klass)->get_property = _vala_follow_button_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_follow_button_set_property;
	G_OBJECT_CLASS (klass)->constructor = follow_button_constructor;
	G_OBJECT_CLASS (klass)->finalize = follow_button_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FOLLOW_BUTTON_FOLLOWING, g_param_spec_boolean ("following", "following", "following", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
}


static void follow_button_instance_init (FollowButton * self) {
	self->priv = FOLLOW_BUTTON_GET_PRIVATE (self);
}


static void follow_button_finalize (GObject* obj) {
	FollowButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_FOLLOW_BUTTON, FollowButton);
	_g_object_unref0 (self->priv->stack);
	_g_object_unref0 (self->priv->follow_label);
	_g_object_unref0 (self->priv->unfollow_label);
	G_OBJECT_CLASS (follow_button_parent_class)->finalize (obj);
}


GType follow_button_get_type (void) {
	static volatile gsize follow_button_type_id__volatile = 0;
	if (g_once_init_enter (&follow_button_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (FollowButtonClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) follow_button_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FollowButton), 0, (GInstanceInitFunc) follow_button_instance_init, NULL };
		GType follow_button_type_id;
		follow_button_type_id = g_type_register_static (gtk_button_get_type (), "FollowButton", &g_define_type_info, 0);
		g_once_init_leave (&follow_button_type_id__volatile, follow_button_type_id);
	}
	return follow_button_type_id__volatile;
}


static void _vala_follow_button_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	FollowButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_FOLLOW_BUTTON, FollowButton);
	switch (property_id) {
		case FOLLOW_BUTTON_FOLLOWING:
		g_value_set_boolean (value, follow_button_get_following (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_follow_button_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	FollowButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_FOLLOW_BUTTON, FollowButton);
	switch (property_id) {
		case FOLLOW_BUTTON_FOLLOWING:
		follow_button_set_following (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



