/* HeaderLabel.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from HeaderLabel.vala, do not modify */

/*
 * Copyright 2017-2022 elementary, Inc. (https://elementary.io)
 * SPDX-License-Identifier: LGPL-2.1-or-later
 */

#include "granite-7.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <pango/pango.h>
#include <float.h>
#include <math.h>
#include <glib-object.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	GRANITE_HEADER_LABEL_0_PROPERTY,
	GRANITE_HEADER_LABEL_LABEL_PROPERTY,
	GRANITE_HEADER_LABEL_MNEMONIC_WIDGET_PROPERTY,
	GRANITE_HEADER_LABEL_SIZE_PROPERTY,
	GRANITE_HEADER_LABEL_ELLIPSIZE_PROPERTY,
	GRANITE_HEADER_LABEL_SECONDARY_TEXT_PROPERTY,
	GRANITE_HEADER_LABEL_NUM_PROPERTIES
};
static GParamSpec* granite_header_label_properties[GRANITE_HEADER_LABEL_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)))

struct _GraniteHeaderLabelPrivate {
	gchar* _label;
	GtkWidget* _mnemonic_widget;
	GraniteHeaderLabelSize _size;
	PangoEllipsizeMode _ellipsize;
	GtkLabel* secondary_label;
};

static gint GraniteHeaderLabel_private_offset;
static gpointer granite_header_label_parent_class = NULL;

static void granite_header_label_update_accessible_description (GraniteHeaderLabel* self,
                                                         const gchar* description);
static void granite_header_label_update_size (GraniteHeaderLabel* self);
static GObject * granite_header_label_constructor (GType type,
                                            guint n_construct_properties,
                                            GObjectConstructParam * construct_properties);
static void _granite_header_label___lambda13_ (GraniteHeaderLabel* self);
static void __granite_header_label___lambda13__g_object_notify (GObject* _sender,
                                                         GParamSpec* pspec,
                                                         gpointer self);
static void _granite_header_label_update_size_g_object_notify (GObject* _sender,
                                                        GParamSpec* pspec,
                                                        gpointer self);
static void granite_header_label_finalize (GObject * obj);
static GType granite_header_label_get_type_once (void);
static void _vala_granite_header_label_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec);
static void _vala_granite_header_label_set_property (GObject * object,
                                              guint property_id,
                                              const GValue * value,
                                              GParamSpec * pspec);

static inline gpointer
granite_header_label_get_instance_private (GraniteHeaderLabel* self)
{
	return G_STRUCT_MEMBER_P (self, GraniteHeaderLabel_private_offset);
}

gchar*
granite_header_label_size_to_string (GraniteHeaderLabelSize self)
{
	gchar* result;
	switch (self) {
		case GRANITE_HEADER_LABEL_SIZE_H1:
		{
			gchar* _tmp0_;
			_tmp0_ = g_strdup ("title-1");
			result = _tmp0_;
			return result;
		}
		case GRANITE_HEADER_LABEL_SIZE_H2:
		{
			gchar* _tmp1_;
			_tmp1_ = g_strdup ("title-2");
			result = _tmp1_;
			return result;
		}
		case GRANITE_HEADER_LABEL_SIZE_H3:
		{
			gchar* _tmp2_;
			_tmp2_ = g_strdup ("title-3");
			result = _tmp2_;
			return result;
		}
		case GRANITE_HEADER_LABEL_SIZE_H4:
		{
			gchar* _tmp3_;
			_tmp3_ = g_strdup ("title-4");
			result = _tmp3_;
			return result;
		}
		default:
		{
			gchar* _tmp4_;
			_tmp4_ = g_strdup ("");
			result = _tmp4_;
			return result;
		}
	}
}

static GType
granite_header_label_size_get_type_once (void)
{
	static const GEnumValue values[] = {{GRANITE_HEADER_LABEL_SIZE_H1, "GRANITE_HEADER_LABEL_SIZE_H1", "h1"}, {GRANITE_HEADER_LABEL_SIZE_H2, "GRANITE_HEADER_LABEL_SIZE_H2", "h2"}, {GRANITE_HEADER_LABEL_SIZE_H3, "GRANITE_HEADER_LABEL_SIZE_H3", "h3"}, {GRANITE_HEADER_LABEL_SIZE_H4, "GRANITE_HEADER_LABEL_SIZE_H4", "h4"}, {0, NULL, NULL}};
	GType granite_header_label_size_type_id;
	granite_header_label_size_type_id = g_enum_register_static ("GraniteHeaderLabelSize", values);
	return granite_header_label_size_type_id;
}

GType
granite_header_label_size_get_type (void)
{
	static volatile gsize granite_header_label_size_type_id__once = 0;
	if (g_once_init_enter (&granite_header_label_size_type_id__once)) {
		GType granite_header_label_size_type_id;
		granite_header_label_size_type_id = granite_header_label_size_get_type_once ();
		g_once_init_leave (&granite_header_label_size_type_id__once, granite_header_label_size_type_id);
	}
	return granite_header_label_size_type_id__once;
}

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

void
granite_header_label_set_label (GraniteHeaderLabel* self,
                                const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = granite_header_label_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, granite_header_label_properties[GRANITE_HEADER_LABEL_LABEL_PROPERTY]);
	}
}

GtkWidget*
granite_header_label_get_mnemonic_widget (GraniteHeaderLabel* self)
{
	GtkWidget* result;
	GtkWidget* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_mnemonic_widget;
	result = _tmp0_;
	return result;
}

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

void
granite_header_label_set_mnemonic_widget (GraniteHeaderLabel* self,
                                          GtkWidget* value)
{
	GtkWidget* old_value;
	g_return_if_fail (self != NULL);
	old_value = granite_header_label_get_mnemonic_widget (self);
	if (old_value != value) {
		GtkWidget* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_mnemonic_widget);
		self->priv->_mnemonic_widget = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, granite_header_label_properties[GRANITE_HEADER_LABEL_MNEMONIC_WIDGET_PROPERTY]);
	}
}

GraniteHeaderLabelSize
granite_header_label_get_size (GraniteHeaderLabel* self)
{
	GraniteHeaderLabelSize result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_size;
	return result;
}

void
granite_header_label_set_size (GraniteHeaderLabel* self,
                               GraniteHeaderLabelSize value)
{
	GraniteHeaderLabelSize old_value;
	g_return_if_fail (self != NULL);
	old_value = granite_header_label_get_size (self);
	if (old_value != value) {
		self->priv->_size = value;
		g_object_notify_by_pspec ((GObject *) self, granite_header_label_properties[GRANITE_HEADER_LABEL_SIZE_PROPERTY]);
	}
}

PangoEllipsizeMode
granite_header_label_get_ellipsize (GraniteHeaderLabel* self)
{
	PangoEllipsizeMode result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_ellipsize;
	return result;
}

void
granite_header_label_set_ellipsize (GraniteHeaderLabel* self,
                                    PangoEllipsizeMode value)
{
	PangoEllipsizeMode old_value;
	g_return_if_fail (self != NULL);
	old_value = granite_header_label_get_ellipsize (self);
	if (old_value != value) {
		self->priv->_ellipsize = value;
		g_object_notify_by_pspec ((GObject *) self, granite_header_label_properties[GRANITE_HEADER_LABEL_ELLIPSIZE_PROPERTY]);
	}
}

const gchar*
granite_header_label_get_secondary_text (GraniteHeaderLabel* self)
{
	const gchar* result;
	const gchar* _tmp0_ = NULL;
	GtkLabel* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp1_ = self->priv->secondary_label;
	if (_tmp1_ != NULL) {
		GtkLabel* _tmp2_;
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		_tmp2_ = self->priv->secondary_label;
		_tmp3_ = gtk_label_get_label (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_;
	} else {
		_tmp0_ = NULL;
	}
	result = _tmp0_;
	return result;
}

void
granite_header_label_set_secondary_text (GraniteHeaderLabel* self,
                                         const gchar* value)
{
	GtkLabel* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->secondary_label;
	if (_tmp0_ != NULL) {
		gboolean _tmp1_ = FALSE;
		if (value == NULL) {
			_tmp1_ = TRUE;
		} else {
			_tmp1_ = g_strcmp0 (value, "") == 0;
		}
		if (_tmp1_) {
			GtkLabel* _tmp2_;
			_tmp2_ = self->priv->secondary_label;
			gtk_widget_unparent ((GtkWidget*) _tmp2_);
			_g_object_unref0 (self->priv->secondary_label);
			self->priv->secondary_label = NULL;
		} else {
			GtkLabel* _tmp3_;
			_tmp3_ = self->priv->secondary_label;
			gtk_label_set_label (_tmp3_, value);
		}
	} else {
		if (value != NULL) {
			GtkLabel* _tmp4_ = NULL;
			GtkLabel* _tmp5_;
			GtkLabel* _tmp6_;
			GtkLabel* _tmp7_;
			_tmp4_ = (GtkLabel*) gtk_label_new (value);
			gtk_label_set_use_markup (_tmp4_, TRUE);
			gtk_label_set_wrap (_tmp4_, TRUE);
			gtk_label_set_xalign (_tmp4_, (gfloat) 0);
			g_object_ref_sink (_tmp4_);
			_g_object_unref0 (self->priv->secondary_label);
			self->priv->secondary_label = _tmp4_;
			_tmp5_ = self->priv->secondary_label;
			gtk_widget_add_css_class ((GtkWidget*) _tmp5_, "subtitle");
			_tmp6_ = self->priv->secondary_label;
			g_object_bind_property_with_closures ((GObject*) self, "ellipsize", (GObject*) _tmp6_, "ellipsize", 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)));
			_tmp7_ = self->priv->secondary_label;
			gtk_widget_set_parent ((GtkWidget*) _tmp7_, (GtkWidget*) self);
		}
	}
	granite_header_label_update_accessible_description (self, value);
	g_object_notify_by_pspec ((GObject *) self, granite_header_label_properties[GRANITE_HEADER_LABEL_SECONDARY_TEXT_PROPERTY]);
}

/**
     * Create a new HeaderLabel
     */
GraniteHeaderLabel*
granite_header_label_construct (GType object_type,
                                const gchar* label)
{
	GraniteHeaderLabel * self = NULL;
	g_return_val_if_fail (label != NULL, NULL);
	self = (GraniteHeaderLabel*) g_object_new (object_type, "label", label, NULL);
	return self;
}

GraniteHeaderLabel*
granite_header_label_new (const gchar* label)
{
	return granite_header_label_construct (GRANITE_TYPE_HEADER_LABEL, label);
}

static void
granite_header_label_update_size (GraniteHeaderLabel* self)
{
	GEnumClass* enum_class = NULL;
	GTypeClass* _tmp0_;
	GEnumClass* _tmp1_;
	GEnumValue* _tmp2_;
	gint _tmp2__length1;
	GraniteHeaderLabelSize _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gboolean _tmp12_;
	GraniteHeaderLabelSize _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_type_class_peek (GRANITE_HEADER_LABEL_TYPE_SIZE);
	enum_class = (GEnumClass*) _tmp0_;
	_tmp1_ = enum_class;
	_tmp2_ = _tmp1_->values;
	_tmp2__length1 = _tmp1_->n_values;
	{
		GEnumValue* val_collection = NULL;
		gint val_collection_length1 = 0;
		gint _val_collection_size_ = 0;
		gint val_it = 0;
		val_collection = _tmp2_;
		val_collection_length1 = _tmp2__length1;
		for (val_it = 0; val_it < val_collection_length1; val_it = val_it + 1) {
			GEnumValue val = {0};
			val = val_collection[val_it];
			{
				gchar* css_class = NULL;
				GEnumValue _tmp3_;
				gchar* _tmp4_;
				gboolean _tmp5_ = FALSE;
				const gchar* _tmp6_;
				_tmp3_ = val;
				_tmp4_ = granite_header_label_size_to_string ((GraniteHeaderLabelSize) _tmp3_.value);
				css_class = _tmp4_;
				_tmp6_ = css_class;
				if (g_strcmp0 (_tmp6_, "") != 0) {
					const gchar* _tmp7_;
					_tmp7_ = css_class;
					_tmp5_ = gtk_widget_has_css_class ((GtkWidget*) self, _tmp7_);
				} else {
					_tmp5_ = FALSE;
				}
				if (_tmp5_) {
					const gchar* _tmp8_;
					_tmp8_ = css_class;
					gtk_widget_remove_css_class ((GtkWidget*) self, _tmp8_);
				}
				_g_free0 (css_class);
			}
		}
	}
	_tmp9_ = self->priv->_size;
	_tmp10_ = granite_header_label_size_to_string (_tmp9_);
	_tmp11_ = _tmp10_;
	_tmp12_ = g_strcmp0 (_tmp11_, "") == 0;
	_g_free0 (_tmp11_);
	if (_tmp12_) {
		return;
	}
	_tmp13_ = self->priv->_size;
	_tmp14_ = granite_header_label_size_to_string (_tmp13_);
	_tmp15_ = _tmp14_;
	gtk_widget_add_css_class ((GtkWidget*) self, _tmp15_);
	_g_free0 (_tmp15_);
}

static void
granite_header_label_update_accessible_description (GraniteHeaderLabel* self,
                                                    const gchar* description)
{
	GtkWidget* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_mnemonic_widget;
	if (_tmp0_ != NULL) {
		GtkWidget* _tmp1_;
		_tmp1_ = self->priv->_mnemonic_widget;
		gtk_accessible_update_property ((GtkAccessible*) _tmp1_, GTK_ACCESSIBLE_PROPERTY_DESCRIPTION, description, -1, -1);
	}
}

static void
_granite_header_label___lambda13_ (GraniteHeaderLabel* self)
{
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	_tmp0_ = granite_header_label_get_secondary_text (self);
	_tmp1_ = _tmp0_;
	granite_header_label_update_accessible_description (self, _tmp1_);
}

static void
__granite_header_label___lambda13__g_object_notify (GObject* _sender,
                                                    GParamSpec* pspec,
                                                    gpointer self)
{
	_granite_header_label___lambda13_ ((GraniteHeaderLabel*) self);
}

static void
_granite_header_label_update_size_g_object_notify (GObject* _sender,
                                                   GParamSpec* pspec,
                                                   gpointer self)
{
	granite_header_label_update_size ((GraniteHeaderLabel*) self);
}

static GObject *
granite_header_label_constructor (GType type,
                                  guint n_construct_properties,
                                  GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GraniteHeaderLabel * self;
	GtkLabel* label_widget = NULL;
	const gchar* _tmp0_;
	GtkLabel* _tmp1_ = NULL;
	GtkLabel* _tmp2_;
	GtkLabel* _tmp3_;
	GtkLayoutManager* _tmp4_;
	GtkLabel* _tmp5_;
	GtkLabel* _tmp6_;
	GtkLabel* _tmp7_;
	parent_class = G_OBJECT_CLASS (granite_header_label_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRANITE_TYPE_HEADER_LABEL, GraniteHeaderLabel);
	_tmp0_ = self->priv->_label;
	_tmp1_ = (GtkLabel*) gtk_label_new (_tmp0_);
	gtk_label_set_wrap (_tmp1_, TRUE);
	gtk_label_set_xalign (_tmp1_, (gfloat) 0);
	g_object_ref_sink (_tmp1_);
	label_widget = _tmp1_;
	_tmp2_ = label_widget;
	gtk_widget_add_css_class ((GtkWidget*) _tmp2_, "heading");
	_tmp3_ = label_widget;
	gtk_widget_set_parent ((GtkWidget*) _tmp3_, (GtkWidget*) self);
	_tmp4_ = gtk_widget_get_layout_manager ((GtkWidget*) self);
	gtk_orientable_set_orientation ((GtkOrientable*) G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, gtk_box_layout_get_type (), GtkBoxLayout), GTK_ORIENTATION_VERTICAL);
	_tmp5_ = label_widget;
	g_object_bind_property_with_closures ((GObject*) self, "label", (GObject*) _tmp5_, "label", G_BINDING_DEFAULT, (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_ = label_widget;
	g_object_bind_property_with_closures ((GObject*) self, "mnemonic-widget", (GObject*) _tmp6_, "mnemonic-widget", G_BINDING_DEFAULT, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp7_ = label_widget;
	g_object_bind_property_with_closures ((GObject*) self, "ellipsize", (GObject*) _tmp7_, "ellipsize", 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_signal_connect_object ((GObject*) self, "notify::mnemonic-widget", (GCallback) __granite_header_label___lambda13__g_object_notify, self, 0);
	granite_header_label_update_size (self);
	g_signal_connect_object ((GObject*) self, "notify::size", (GCallback) _granite_header_label_update_size_g_object_notify, self, 0);
	_g_object_unref0 (label_widget);
	return obj;
}

static void
granite_header_label_base_init (GraniteHeaderLabelClass * klass)
{
	gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (klass), "header");
}

static void
granite_header_label_class_init (GraniteHeaderLabelClass * klass,
                                 gpointer klass_data)
{
	granite_header_label_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GraniteHeaderLabel_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_granite_header_label_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_granite_header_label_set_property;
	G_OBJECT_CLASS (klass)->constructor = granite_header_label_constructor;
	G_OBJECT_CLASS (klass)->finalize = granite_header_label_finalize;
	/**
	     * The primary header label string
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRANITE_HEADER_LABEL_LABEL_PROPERTY, granite_header_label_properties[GRANITE_HEADER_LABEL_LABEL_PROPERTY] = g_param_spec_string ("label", "label", "label", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	/**
	     * The widget to be activated when the labels mnemonic key is pressed. Also sets #this as screenreader label.
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRANITE_HEADER_LABEL_MNEMONIC_WIDGET_PROPERTY, granite_header_label_properties[GRANITE_HEADER_LABEL_MNEMONIC_WIDGET_PROPERTY] = g_param_spec_object ("mnemonic-widget", "mnemonic-widget", "mnemonic-widget", gtk_widget_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * The size of #this
	     * Only use one {@link Size.H1} per page. It represents the main heading/subject for the whole page
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRANITE_HEADER_LABEL_SIZE_PROPERTY, granite_header_label_properties[GRANITE_HEADER_LABEL_SIZE_PROPERTY] = g_param_spec_enum ("size", "size", "size", GRANITE_HEADER_LABEL_TYPE_SIZE, GRANITE_HEADER_LABEL_SIZE_H4, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * The preferred place to ellipsize the string, if the label does not have enough room to display the entire string.
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRANITE_HEADER_LABEL_ELLIPSIZE_PROPERTY, granite_header_label_properties[GRANITE_HEADER_LABEL_ELLIPSIZE_PROPERTY] = g_param_spec_enum ("ellipsize", "ellipsize", "ellipsize", pango_ellipsize_mode_get_type (), PANGO_ELLIPSIZE_NONE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Optional secondary label string displayed below the header
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRANITE_HEADER_LABEL_SECONDARY_TEXT_PROPERTY, granite_header_label_properties[GRANITE_HEADER_LABEL_SECONDARY_TEXT_PROPERTY] = g_param_spec_string ("secondary-text", "secondary-text", "secondary-text", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	gtk_widget_class_set_layout_manager_type (GTK_WIDGET_CLASS (klass), gtk_box_layout_get_type ());
}

static void
granite_header_label_instance_init (GraniteHeaderLabel * self,
                                    gpointer klass)
{
	self->priv = granite_header_label_get_instance_private (self);
	self->priv->_size = GRANITE_HEADER_LABEL_SIZE_H4;
	self->priv->_ellipsize = PANGO_ELLIPSIZE_NONE;
	self->priv->secondary_label = NULL;
}

static void
granite_header_label_finalize (GObject * obj)
{
	GraniteHeaderLabel * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRANITE_TYPE_HEADER_LABEL, GraniteHeaderLabel);
	while (TRUE) {
		GtkWidget* _tmp0_;
		GtkWidget* _tmp1_;
		_tmp0_ = gtk_widget_get_first_child ((GtkWidget*) self);
		if (!(_tmp0_ != NULL)) {
			break;
		}
		_tmp1_ = gtk_widget_get_first_child ((GtkWidget*) self);
		gtk_widget_unparent (_tmp1_);
	}
	_g_free0 (self->priv->_label);
	_g_object_unref0 (self->priv->_mnemonic_widget);
	_g_object_unref0 (self->priv->secondary_label);
	G_OBJECT_CLASS (granite_header_label_parent_class)->finalize (obj);
}

/**
 * HeaderLabel contains a start-aligned {@link Gtk.Label} with the "heading" style class.
 * Optionally it can contain a secondary {@link Gtk.Label} to provide additional context
 */
static GType
granite_header_label_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GraniteHeaderLabelClass), (GBaseInitFunc) granite_header_label_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) granite_header_label_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GraniteHeaderLabel), 0, (GInstanceInitFunc) granite_header_label_instance_init, NULL };
	GType granite_header_label_type_id;
	granite_header_label_type_id = g_type_register_static (gtk_widget_get_type (), "GraniteHeaderLabel", &g_define_type_info, 0);
	GraniteHeaderLabel_private_offset = g_type_add_instance_private (granite_header_label_type_id, sizeof (GraniteHeaderLabelPrivate));
	return granite_header_label_type_id;
}

GType
granite_header_label_get_type (void)
{
	static volatile gsize granite_header_label_type_id__once = 0;
	if (g_once_init_enter (&granite_header_label_type_id__once)) {
		GType granite_header_label_type_id;
		granite_header_label_type_id = granite_header_label_get_type_once ();
		g_once_init_leave (&granite_header_label_type_id__once, granite_header_label_type_id);
	}
	return granite_header_label_type_id__once;
}

static void
_vala_granite_header_label_get_property (GObject * object,
                                         guint property_id,
                                         GValue * value,
                                         GParamSpec * pspec)
{
	GraniteHeaderLabel * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRANITE_TYPE_HEADER_LABEL, GraniteHeaderLabel);
	switch (property_id) {
		case GRANITE_HEADER_LABEL_LABEL_PROPERTY:
		g_value_set_string (value, granite_header_label_get_label (self));
		break;
		case GRANITE_HEADER_LABEL_MNEMONIC_WIDGET_PROPERTY:
		g_value_set_object (value, granite_header_label_get_mnemonic_widget (self));
		break;
		case GRANITE_HEADER_LABEL_SIZE_PROPERTY:
		g_value_set_enum (value, granite_header_label_get_size (self));
		break;
		case GRANITE_HEADER_LABEL_ELLIPSIZE_PROPERTY:
		g_value_set_enum (value, granite_header_label_get_ellipsize (self));
		break;
		case GRANITE_HEADER_LABEL_SECONDARY_TEXT_PROPERTY:
		g_value_set_string (value, granite_header_label_get_secondary_text (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_granite_header_label_set_property (GObject * object,
                                         guint property_id,
                                         const GValue * value,
                                         GParamSpec * pspec)
{
	GraniteHeaderLabel * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRANITE_TYPE_HEADER_LABEL, GraniteHeaderLabel);
	switch (property_id) {
		case GRANITE_HEADER_LABEL_LABEL_PROPERTY:
		granite_header_label_set_label (self, g_value_get_string (value));
		break;
		case GRANITE_HEADER_LABEL_MNEMONIC_WIDGET_PROPERTY:
		granite_header_label_set_mnemonic_widget (self, g_value_get_object (value));
		break;
		case GRANITE_HEADER_LABEL_SIZE_PROPERTY:
		granite_header_label_set_size (self, g_value_get_enum (value));
		break;
		case GRANITE_HEADER_LABEL_ELLIPSIZE_PROPERTY:
		granite_header_label_set_ellipsize (self, g_value_get_enum (value));
		break;
		case GRANITE_HEADER_LABEL_SECONDARY_TEXT_PROPERTY:
		granite_header_label_set_secondary_text (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

