/* BadgeRadioToolButton.c generated by valac 0.26.2, the Vala compiler
 * generated from BadgeRadioToolButton.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 <atk/atk.h>
#include <cairo.h>
#include <float.h>
#include <math.h>


#define TYPE_BADGE_RADIO_TOOL_BUTTON (badge_radio_tool_button_get_type ())
#define BADGE_RADIO_TOOL_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_BADGE_RADIO_TOOL_BUTTON, BadgeRadioToolButton))
#define BADGE_RADIO_TOOL_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_BADGE_RADIO_TOOL_BUTTON, BadgeRadioToolButtonClass))
#define IS_BADGE_RADIO_TOOL_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_BADGE_RADIO_TOOL_BUTTON))
#define IS_BADGE_RADIO_TOOL_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_BADGE_RADIO_TOOL_BUTTON))
#define BADGE_RADIO_TOOL_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_BADGE_RADIO_TOOL_BUTTON, BadgeRadioToolButtonClass))

typedef struct _BadgeRadioToolButton BadgeRadioToolButton;
typedef struct _BadgeRadioToolButtonClass BadgeRadioToolButtonClass;
typedef struct _BadgeRadioToolButtonPrivate BadgeRadioToolButtonPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _BadgeRadioToolButton {
	GtkRadioButton parent_instance;
	BadgeRadioToolButtonPrivate * priv;
};

struct _BadgeRadioToolButtonClass {
	GtkRadioButtonClass parent_class;
};

struct _BadgeRadioToolButtonPrivate {
	gboolean _show_badge;
};


static gpointer badge_radio_tool_button_parent_class = NULL;

GType badge_radio_tool_button_get_type (void) G_GNUC_CONST;
#define BADGE_RADIO_TOOL_BUTTON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_BADGE_RADIO_TOOL_BUTTON, BadgeRadioToolButtonPrivate))
enum  {
	BADGE_RADIO_TOOL_BUTTON_DUMMY_PROPERTY,
	BADGE_RADIO_TOOL_BUTTON_SHOW_BADGE
};
#define BADGE_RADIO_TOOL_BUTTON_BADGE_SIZE 10
BadgeRadioToolButton* badge_radio_tool_button_new (GtkRadioButton* group, const gchar* icon_name, const gchar* text);
BadgeRadioToolButton* badge_radio_tool_button_construct (GType object_type, GtkRadioButton* group, const gchar* icon_name, const gchar* text);
static gboolean badge_radio_tool_button_real_draw (GtkWidget* base, cairo_t* c);
gboolean badge_radio_tool_button_get_show_badge (BadgeRadioToolButton* self);
void badge_radio_tool_button_set_show_badge (BadgeRadioToolButton* self, gboolean value);
static void badge_radio_tool_button_finalize (GObject* obj);
static void _vala_badge_radio_tool_button_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_badge_radio_tool_button_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);


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


BadgeRadioToolButton* badge_radio_tool_button_construct (GType object_type, GtkRadioButton* group, const gchar* icon_name, const gchar* text) {
	BadgeRadioToolButton * self = NULL;
	GtkRadioButton* _tmp0_ = NULL;
	GtkStyleContext* _tmp1_ = NULL;
	GtkImage* i = NULL;
	const gchar* _tmp2_ = NULL;
	GtkImage* _tmp3_ = NULL;
	GtkImage* _tmp4_ = NULL;
	const gchar* _tmp5_ = NULL;
	g_return_val_if_fail (GTK_IS_RADIO_BUTTON (group), NULL);
	g_return_val_if_fail (icon_name != NULL, NULL);
	g_return_val_if_fail (text != NULL, NULL);
	_tmp0_ = group;
	self = (BadgeRadioToolButton*) g_object_new (object_type, "group", _tmp0_, NULL);
	_tmp1_ = gtk_widget_get_style_context (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
	gtk_style_context_add_class (_tmp1_, "image-button");
	_tmp2_ = icon_name;
	_tmp3_ = (GtkImage*) gtk_image_new_from_icon_name (_tmp2_, GTK_ICON_SIZE_BUTTON);
	g_object_ref_sink (_tmp3_);
	i = _tmp3_;
	_tmp4_ = i;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, gtk_widget_get_type (), GtkWidget));
	gtk_toggle_button_set_mode (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_toggle_button_get_type (), GtkToggleButton), FALSE);
	gtk_button_set_focus_on_click (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_button_get_type (), GtkButton), FALSE);
	_tmp5_ = text;
	if (g_strcmp0 (_tmp5_, "") != 0) {
		const gchar* _tmp6_ = NULL;
		AtkObject* accessible = NULL;
		AtkObject* _tmp7_ = NULL;
		AtkObject* _tmp8_ = NULL;
		AtkObject* _tmp9_ = NULL;
		const gchar* _tmp10_ = NULL;
		_tmp6_ = text;
		gtk_widget_set_tooltip_text (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), _tmp6_);
		_tmp7_ = gtk_widget_get_accessible (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
		_tmp8_ = _g_object_ref0 (_tmp7_);
		accessible = _tmp8_;
		_tmp9_ = accessible;
		_tmp10_ = text;
		atk_object_set_name (_tmp9_, _tmp10_);
		_g_object_unref0 (accessible);
	}
	_g_object_unref0 (i);
	return self;
}


BadgeRadioToolButton* badge_radio_tool_button_new (GtkRadioButton* group, const gchar* icon_name, const gchar* text) {
	return badge_radio_tool_button_construct (TYPE_BADGE_RADIO_TOOL_BUTTON, group, icon_name, text);
}


static gboolean badge_radio_tool_button_real_draw (GtkWidget* base, cairo_t* c) {
	BadgeRadioToolButton * self;
	gboolean result = FALSE;
	GtkStyleContext* context = NULL;
	GtkStyleContext* _tmp0_ = NULL;
	GtkStyleContext* _tmp1_ = NULL;
	cairo_t* _tmp2_ = NULL;
	gboolean _tmp3_ = FALSE;
	gint width = 0;
	gint _tmp4_ = 0;
	GtkStyleContext* _tmp5_ = NULL;
	GtkStyleContext* _tmp6_ = NULL;
	GtkStyleContext* _tmp7_ = NULL;
	cairo_t* _tmp8_ = NULL;
	gint _tmp9_ = 0;
	GtkStyleContext* _tmp10_ = NULL;
	cairo_t* _tmp11_ = NULL;
	gint _tmp12_ = 0;
	GtkStyleContext* _tmp13_ = NULL;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_BADGE_RADIO_TOOL_BUTTON, BadgeRadioToolButton);
	g_return_val_if_fail (c != NULL, FALSE);
	_tmp0_ = gtk_widget_get_style_context (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
	_tmp1_ = _g_object_ref0 (_tmp0_);
	context = _tmp1_;
	_tmp2_ = c;
	GTK_WIDGET_CLASS (badge_radio_tool_button_parent_class)->draw (G_TYPE_CHECK_INSTANCE_CAST (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_radio_button_get_type (), GtkRadioButton), gtk_widget_get_type (), GtkWidget), _tmp2_);
	_tmp3_ = self->priv->_show_badge;
	if (!_tmp3_) {
		result = FALSE;
		_g_object_unref0 (context);
		return result;
	}
	_tmp4_ = gtk_widget_get_allocated_width (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
	width = _tmp4_;
	_tmp5_ = context;
	gtk_style_context_save (_tmp5_);
	_tmp6_ = context;
	gtk_style_context_add_class (_tmp6_, "badge");
	_tmp7_ = context;
	_tmp8_ = c;
	_tmp9_ = width;
	gtk_render_background (_tmp7_, _tmp8_, (gdouble) (_tmp9_ - BADGE_RADIO_TOOL_BUTTON_BADGE_SIZE), (gdouble) 0, (gdouble) BADGE_RADIO_TOOL_BUTTON_BADGE_SIZE, (gdouble) BADGE_RADIO_TOOL_BUTTON_BADGE_SIZE);
	_tmp10_ = context;
	_tmp11_ = c;
	_tmp12_ = width;
	gtk_render_frame (_tmp10_, _tmp11_, (gdouble) (_tmp12_ - BADGE_RADIO_TOOL_BUTTON_BADGE_SIZE), (gdouble) 0, (gdouble) BADGE_RADIO_TOOL_BUTTON_BADGE_SIZE, (gdouble) BADGE_RADIO_TOOL_BUTTON_BADGE_SIZE);
	_tmp13_ = context;
	gtk_style_context_restore (_tmp13_);
	result = FALSE;
	_g_object_unref0 (context);
	return result;
}


gboolean badge_radio_tool_button_get_show_badge (BadgeRadioToolButton* self) {
	gboolean result;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (IS_BADGE_RADIO_TOOL_BUTTON (self), FALSE);
	_tmp0_ = self->priv->_show_badge;
	result = _tmp0_;
	return result;
}


void badge_radio_tool_button_set_show_badge (BadgeRadioToolButton* self, gboolean value) {
	gboolean _tmp0_ = FALSE;
	g_return_if_fail (IS_BADGE_RADIO_TOOL_BUTTON (self));
	_tmp0_ = value;
	self->priv->_show_badge = _tmp0_;
	g_object_notify ((GObject *) self, "show-badge");
}


static void badge_radio_tool_button_class_init (BadgeRadioToolButtonClass * klass) {
	badge_radio_tool_button_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (BadgeRadioToolButtonPrivate));
	((GtkWidgetClass *) klass)->draw = badge_radio_tool_button_real_draw;
	G_OBJECT_CLASS (klass)->get_property = _vala_badge_radio_tool_button_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_badge_radio_tool_button_set_property;
	G_OBJECT_CLASS (klass)->finalize = badge_radio_tool_button_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), BADGE_RADIO_TOOL_BUTTON_SHOW_BADGE, g_param_spec_boolean ("show-badge", "show-badge", "show-badge", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
}


static void badge_radio_tool_button_instance_init (BadgeRadioToolButton * self) {
	self->priv = BADGE_RADIO_TOOL_BUTTON_GET_PRIVATE (self);
	self->priv->_show_badge = FALSE;
}


static void badge_radio_tool_button_finalize (GObject* obj) {
	BadgeRadioToolButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_BADGE_RADIO_TOOL_BUTTON, BadgeRadioToolButton);
	G_OBJECT_CLASS (badge_radio_tool_button_parent_class)->finalize (obj);
}


GType badge_radio_tool_button_get_type (void) {
	static volatile gsize badge_radio_tool_button_type_id__volatile = 0;
	if (g_once_init_enter (&badge_radio_tool_button_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (BadgeRadioToolButtonClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) badge_radio_tool_button_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BadgeRadioToolButton), 0, (GInstanceInitFunc) badge_radio_tool_button_instance_init, NULL };
		GType badge_radio_tool_button_type_id;
		badge_radio_tool_button_type_id = g_type_register_static (gtk_radio_button_get_type (), "BadgeRadioToolButton", &g_define_type_info, 0);
		g_once_init_leave (&badge_radio_tool_button_type_id__volatile, badge_radio_tool_button_type_id);
	}
	return badge_radio_tool_button_type_id__volatile;
}


static void _vala_badge_radio_tool_button_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	BadgeRadioToolButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_BADGE_RADIO_TOOL_BUTTON, BadgeRadioToolButton);
	switch (property_id) {
		case BADGE_RADIO_TOOL_BUTTON_SHOW_BADGE:
		g_value_set_boolean (value, badge_radio_tool_button_get_show_badge (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_badge_radio_tool_button_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	BadgeRadioToolButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_BADGE_RADIO_TOOL_BUTTON, BadgeRadioToolButton);
	switch (property_id) {
		case BADGE_RADIO_TOOL_BUTTON_SHOW_BADGE:
		badge_radio_tool_button_set_show_badge (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



