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

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

#define TOOTLE_WIDGETS_TYPE_ADAPTIVE_BUTTON (tootle_widgets_adaptive_button_get_type ())
#define TOOTLE_WIDGETS_ADAPTIVE_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_WIDGETS_TYPE_ADAPTIVE_BUTTON, TootleWidgetsAdaptiveButton))
#define TOOTLE_WIDGETS_ADAPTIVE_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_WIDGETS_TYPE_ADAPTIVE_BUTTON, TootleWidgetsAdaptiveButtonClass))
#define TOOTLE_WIDGETS_IS_ADAPTIVE_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_WIDGETS_TYPE_ADAPTIVE_BUTTON))
#define TOOTLE_WIDGETS_IS_ADAPTIVE_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_WIDGETS_TYPE_ADAPTIVE_BUTTON))
#define TOOTLE_WIDGETS_ADAPTIVE_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_WIDGETS_TYPE_ADAPTIVE_BUTTON, TootleWidgetsAdaptiveButtonClass))

typedef struct _TootleWidgetsAdaptiveButton TootleWidgetsAdaptiveButton;
typedef struct _TootleWidgetsAdaptiveButtonClass TootleWidgetsAdaptiveButtonClass;
typedef struct _TootleWidgetsAdaptiveButtonPrivate TootleWidgetsAdaptiveButtonPrivate;
enum  {
	TOOTLE_WIDGETS_ADAPTIVE_BUTTON_0_PROPERTY,
	TOOTLE_WIDGETS_ADAPTIVE_BUTTON_LABEL_PROPERTY,
	TOOTLE_WIDGETS_ADAPTIVE_BUTTON_ICON_NAME_PROPERTY,
	TOOTLE_WIDGETS_ADAPTIVE_BUTTON_NUM_PROPERTIES
};
static GParamSpec* tootle_widgets_adaptive_button_properties[TOOTLE_WIDGETS_ADAPTIVE_BUTTON_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	TOOTLE_WIDGETS_ADAPTIVE_BUTTON_CLICKED_SIGNAL,
	TOOTLE_WIDGETS_ADAPTIVE_BUTTON_NUM_SIGNALS
};
static guint tootle_widgets_adaptive_button_signals[TOOTLE_WIDGETS_ADAPTIVE_BUTTON_NUM_SIGNALS] = {0};

struct _TootleWidgetsAdaptiveButton {
	GtkBox parent_instance;
	TootleWidgetsAdaptiveButtonPrivate * priv;
};

struct _TootleWidgetsAdaptiveButtonClass {
	GtkBoxClass parent_class;
};

struct _TootleWidgetsAdaptiveButtonPrivate {
	gchar* _label;
	gchar* _icon_name;
	GtkButton* full;
	GtkButton* mini;
	GtkImage* image1;
	GtkImage* image2;
};

static gint TootleWidgetsAdaptiveButton_private_offset;
static gpointer tootle_widgets_adaptive_button_parent_class = NULL;

GType tootle_widgets_adaptive_button_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleWidgetsAdaptiveButton, g_object_unref)
TootleWidgetsAdaptiveButton* tootle_widgets_adaptive_button_new (void);
TootleWidgetsAdaptiveButton* tootle_widgets_adaptive_button_construct (GType object_type);
const gchar* tootle_widgets_adaptive_button_get_label (TootleWidgetsAdaptiveButton* self);
void tootle_widgets_adaptive_button_set_label (TootleWidgetsAdaptiveButton* self,
                                               const gchar* value);
const gchar* tootle_widgets_adaptive_button_get_icon_name (TootleWidgetsAdaptiveButton* self);
void tootle_widgets_adaptive_button_set_icon_name (TootleWidgetsAdaptiveButton* self,
                                                   const gchar* value);
static GObject * tootle_widgets_adaptive_button_constructor (GType type,
                                                      guint n_construct_properties,
                                                      GObjectConstructParam * construct_properties);
static void _tootle_widgets_adaptive_button_____lambda76_ (TootleWidgetsAdaptiveButton* self);
static void __tootle_widgets_adaptive_button_____lambda76__gtk_button_clicked (GtkButton* _sender,
                                                                        gpointer self);
static void tootle_widgets_adaptive_button_finalize (GObject * obj);
static GType tootle_widgets_adaptive_button_get_type_once (void);
static void _vala_tootle_widgets_adaptive_button_get_property (GObject * object,
                                                        guint property_id,
                                                        GValue * value,
                                                        GParamSpec * pspec);
static void _vala_tootle_widgets_adaptive_button_set_property (GObject * object,
                                                        guint property_id,
                                                        const GValue * value,
                                                        GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gint array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gint array_length,
                       GDestroyNotify destroy_func);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
tootle_widgets_adaptive_button_get_instance_private (TootleWidgetsAdaptiveButton* self)
{
	return G_STRUCT_MEMBER_P (self, TootleWidgetsAdaptiveButton_private_offset);
}

TootleWidgetsAdaptiveButton*
tootle_widgets_adaptive_button_construct (GType object_type)
{
	TootleWidgetsAdaptiveButton * self = NULL;
	self = (TootleWidgetsAdaptiveButton*) g_object_new (object_type, NULL);
	return self;
}

TootleWidgetsAdaptiveButton*
tootle_widgets_adaptive_button_new (void)
{
	return tootle_widgets_adaptive_button_construct (TOOTLE_WIDGETS_TYPE_ADAPTIVE_BUTTON);
}

const gchar*
tootle_widgets_adaptive_button_get_label (TootleWidgetsAdaptiveButton* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_label;
	result = _tmp0_;
	return result;
}

void
tootle_widgets_adaptive_button_set_label (TootleWidgetsAdaptiveButton* self,
                                          const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = tootle_widgets_adaptive_button_get_label (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_label);
		self->priv->_label = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, tootle_widgets_adaptive_button_properties[TOOTLE_WIDGETS_ADAPTIVE_BUTTON_LABEL_PROPERTY]);
	}
}

const gchar*
tootle_widgets_adaptive_button_get_icon_name (TootleWidgetsAdaptiveButton* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_icon_name;
	result = _tmp0_;
	return result;
}

void
tootle_widgets_adaptive_button_set_icon_name (TootleWidgetsAdaptiveButton* self,
                                              const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = tootle_widgets_adaptive_button_get_icon_name (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_icon_name);
		self->priv->_icon_name = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, tootle_widgets_adaptive_button_properties[TOOTLE_WIDGETS_ADAPTIVE_BUTTON_ICON_NAME_PROPERTY]);
	}
}

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

static void
_tootle_widgets_adaptive_button_____lambda76_ (TootleWidgetsAdaptiveButton* self)
{
	g_signal_emit (self, tootle_widgets_adaptive_button_signals[TOOTLE_WIDGETS_ADAPTIVE_BUTTON_CLICKED_SIGNAL], 0);
}

static void
__tootle_widgets_adaptive_button_____lambda76__gtk_button_clicked (GtkButton* _sender,
                                                                   gpointer self)
{
	_tootle_widgets_adaptive_button_____lambda76_ ((TootleWidgetsAdaptiveButton*) self);
}

static GObject *
tootle_widgets_adaptive_button_constructor (GType type,
                                            guint n_construct_properties,
                                            GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	TootleWidgetsAdaptiveButton * self;
	GtkButton** butts = NULL;
	GtkButton* _tmp0_;
	GtkButton* _tmp1_;
	GtkButton* _tmp2_;
	GtkButton* _tmp3_;
	GtkButton** _tmp4_;
	gint butts_length1;
	gint _butts_size_;
	GtkButton* _tmp5_;
	GtkButton** _tmp6_;
	gint _tmp6__length1;
	GtkImage* _tmp10_;
	GtkImage* _tmp11_;
	GtkImage* _tmp12_;
	GtkImage* _tmp13_;
	GtkImage** _tmp14_;
	parent_class = G_OBJECT_CLASS (tootle_widgets_adaptive_button_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TOOTLE_WIDGETS_TYPE_ADAPTIVE_BUTTON, TootleWidgetsAdaptiveButton);
	_tmp0_ = self->priv->full;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_tmp2_ = self->priv->mini;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	_tmp4_ = g_new0 (GtkButton*, 2 + 1);
	_tmp4_[0] = _tmp1_;
	_tmp4_[1] = _tmp3_;
	butts = _tmp4_;
	butts_length1 = 2;
	_butts_size_ = butts_length1;
	_tmp5_ = self->priv->full;
	g_object_bind_property_with_closures ((GObject*) self, "label", (GObject*) _tmp5_, "label", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp6_ = butts;
	_tmp6__length1 = butts_length1;
	{
		GtkButton** butt_collection = NULL;
		gint butt_collection_length1 = 0;
		gint _butt_collection_size_ = 0;
		gint butt_it = 0;
		butt_collection = _tmp6_;
		butt_collection_length1 = _tmp6__length1;
		for (butt_it = 0; butt_it < butt_collection_length1; butt_it = butt_it + 1) {
			GtkButton* _tmp7_;
			GtkButton* butt = NULL;
			_tmp7_ = _g_object_ref0 (butt_collection[butt_it]);
			butt = _tmp7_;
			{
				GtkButton* _tmp8_;
				GtkButton* _tmp9_;
				_tmp8_ = butt;
				g_object_bind_property_with_closures ((GObject*) self, "tooltip_text", (GObject*) _tmp8_, "tooltip_text", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
				_tmp9_ = butt;
				g_signal_connect_object (_tmp9_, "clicked", (GCallback) __tootle_widgets_adaptive_button_____lambda76__gtk_button_clicked, self, 0);
				_g_object_unref0 (butt);
			}
		}
	}
	_tmp10_ = self->priv->image1;
	_tmp11_ = _g_object_ref0 (_tmp10_);
	_tmp12_ = self->priv->image2;
	_tmp13_ = _g_object_ref0 (_tmp12_);
	_tmp14_ = g_new0 (GtkImage*, 2 + 1);
	_tmp14_[0] = _tmp11_;
	_tmp14_[1] = _tmp13_;
	{
		GtkImage** img_collection = NULL;
		gint img_collection_length1 = 0;
		gint _img_collection_size_ = 0;
		gint img_it = 0;
		img_collection = _tmp14_;
		img_collection_length1 = 2;
		for (img_it = 0; img_it < img_collection_length1; img_it = img_it + 1) {
			GtkImage* _tmp15_;
			GtkImage* img = NULL;
			_tmp15_ = _g_object_ref0 (img_collection[img_it]);
			img = _tmp15_;
			{
				GtkImage* _tmp16_;
				_tmp16_ = img;
				g_object_bind_property_with_closures ((GObject*) self, "icon_name", (GObject*) _tmp16_, "icon_name", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
				_g_object_unref0 (img);
			}
		}
		img_collection = (_vala_array_free (img_collection, img_collection_length1, (GDestroyNotify) g_object_unref), NULL);
	}
	butts = (_vala_array_free (butts, butts_length1, (GDestroyNotify) g_object_unref), NULL);
	return obj;
}

static void
tootle_widgets_adaptive_button_class_init (TootleWidgetsAdaptiveButtonClass * klass,
                                           gpointer klass_data)
{
	tootle_widgets_adaptive_button_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &TootleWidgetsAdaptiveButton_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_tootle_widgets_adaptive_button_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_tootle_widgets_adaptive_button_set_property;
	G_OBJECT_CLASS (klass)->constructor = tootle_widgets_adaptive_button_constructor;
	G_OBJECT_CLASS (klass)->finalize = tootle_widgets_adaptive_button_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), TOOTLE_WIDGETS_ADAPTIVE_BUTTON_LABEL_PROPERTY, tootle_widgets_adaptive_button_properties[TOOTLE_WIDGETS_ADAPTIVE_BUTTON_LABEL_PROPERTY] = g_param_spec_string ("label", "label", "label", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), TOOTLE_WIDGETS_ADAPTIVE_BUTTON_ICON_NAME_PROPERTY, tootle_widgets_adaptive_button_properties[TOOTLE_WIDGETS_ADAPTIVE_BUTTON_ICON_NAME_PROPERTY] = g_param_spec_string ("icon-name", "icon-name", "icon-name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/com/github/bleakgrey/tootle/ui/widgets/adaptive_button.ui");
	tootle_widgets_adaptive_button_signals[TOOTLE_WIDGETS_ADAPTIVE_BUTTON_CLICKED_SIGNAL] = g_signal_new ("clicked", TOOTLE_WIDGETS_TYPE_ADAPTIVE_BUTTON, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "full", FALSE, TootleWidgetsAdaptiveButton_private_offset + G_STRUCT_OFFSET (TootleWidgetsAdaptiveButtonPrivate, full));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "mini", FALSE, TootleWidgetsAdaptiveButton_private_offset + G_STRUCT_OFFSET (TootleWidgetsAdaptiveButtonPrivate, mini));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "image1", FALSE, TootleWidgetsAdaptiveButton_private_offset + G_STRUCT_OFFSET (TootleWidgetsAdaptiveButtonPrivate, image1));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "image2", FALSE, TootleWidgetsAdaptiveButton_private_offset + G_STRUCT_OFFSET (TootleWidgetsAdaptiveButtonPrivate, image2));
}

static void
tootle_widgets_adaptive_button_instance_init (TootleWidgetsAdaptiveButton * self,
                                              gpointer klass)
{
	gchar* _tmp0_;
	self->priv = tootle_widgets_adaptive_button_get_instance_private (self);
	_tmp0_ = g_strdup ("image-loading-symbolic");
	self->priv->_icon_name = _tmp0_;
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
tootle_widgets_adaptive_button_finalize (GObject * obj)
{
	TootleWidgetsAdaptiveButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TOOTLE_WIDGETS_TYPE_ADAPTIVE_BUTTON, TootleWidgetsAdaptiveButton);
	_g_free0 (self->priv->_label);
	_g_free0 (self->priv->_icon_name);
	G_OBJECT_CLASS (tootle_widgets_adaptive_button_parent_class)->finalize (obj);
}

static GType
tootle_widgets_adaptive_button_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TootleWidgetsAdaptiveButtonClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tootle_widgets_adaptive_button_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TootleWidgetsAdaptiveButton), 0, (GInstanceInitFunc) tootle_widgets_adaptive_button_instance_init, NULL };
	GType tootle_widgets_adaptive_button_type_id;
	tootle_widgets_adaptive_button_type_id = g_type_register_static (gtk_box_get_type (), "TootleWidgetsAdaptiveButton", &g_define_type_info, 0);
	TootleWidgetsAdaptiveButton_private_offset = g_type_add_instance_private (tootle_widgets_adaptive_button_type_id, sizeof (TootleWidgetsAdaptiveButtonPrivate));
	return tootle_widgets_adaptive_button_type_id;
}

GType
tootle_widgets_adaptive_button_get_type (void)
{
	static volatile gsize tootle_widgets_adaptive_button_type_id__volatile = 0;
	if (g_once_init_enter (&tootle_widgets_adaptive_button_type_id__volatile)) {
		GType tootle_widgets_adaptive_button_type_id;
		tootle_widgets_adaptive_button_type_id = tootle_widgets_adaptive_button_get_type_once ();
		g_once_init_leave (&tootle_widgets_adaptive_button_type_id__volatile, tootle_widgets_adaptive_button_type_id);
	}
	return tootle_widgets_adaptive_button_type_id__volatile;
}

static void
_vala_tootle_widgets_adaptive_button_get_property (GObject * object,
                                                   guint property_id,
                                                   GValue * value,
                                                   GParamSpec * pspec)
{
	TootleWidgetsAdaptiveButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TOOTLE_WIDGETS_TYPE_ADAPTIVE_BUTTON, TootleWidgetsAdaptiveButton);
	switch (property_id) {
		case TOOTLE_WIDGETS_ADAPTIVE_BUTTON_LABEL_PROPERTY:
		g_value_set_string (value, tootle_widgets_adaptive_button_get_label (self));
		break;
		case TOOTLE_WIDGETS_ADAPTIVE_BUTTON_ICON_NAME_PROPERTY:
		g_value_set_string (value, tootle_widgets_adaptive_button_get_icon_name (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_tootle_widgets_adaptive_button_set_property (GObject * object,
                                                   guint property_id,
                                                   const GValue * value,
                                                   GParamSpec * pspec)
{
	TootleWidgetsAdaptiveButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TOOTLE_WIDGETS_TYPE_ADAPTIVE_BUTTON, TootleWidgetsAdaptiveButton);
	switch (property_id) {
		case TOOTLE_WIDGETS_ADAPTIVE_BUTTON_LABEL_PROPERTY:
		tootle_widgets_adaptive_button_set_label (self, g_value_get_string (value));
		break;
		case TOOTLE_WIDGETS_ADAPTIVE_BUTTON_ICON_NAME_PROPERTY:
		tootle_widgets_adaptive_button_set_icon_name (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_array_destroy (gpointer array,
                     gint array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gint i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gint array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

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;
}

