/* wrap-label.c generated by valac 0.11.6, the Vala compiler
 * generated from wrap-label.vala, do not modify */


#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <float.h>
#include <math.h>
#include <gdk/gdk.h>
#include <pango/pango.h>


#define DOCK_MANAGER_TYPE_WRAP_LABEL (dock_manager_wrap_label_get_type ())
#define DOCK_MANAGER_WRAP_LABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DOCK_MANAGER_TYPE_WRAP_LABEL, DockManagerWrapLabel))
#define DOCK_MANAGER_WRAP_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DOCK_MANAGER_TYPE_WRAP_LABEL, DockManagerWrapLabelClass))
#define DOCK_MANAGER_IS_WRAP_LABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DOCK_MANAGER_TYPE_WRAP_LABEL))
#define DOCK_MANAGER_IS_WRAP_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DOCK_MANAGER_TYPE_WRAP_LABEL))
#define DOCK_MANAGER_WRAP_LABEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DOCK_MANAGER_TYPE_WRAP_LABEL, DockManagerWrapLabelClass))

typedef struct _DockManagerWrapLabel DockManagerWrapLabel;
typedef struct _DockManagerWrapLabelClass DockManagerWrapLabelClass;
typedef struct _DockManagerWrapLabelPrivate DockManagerWrapLabelPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _DockManagerWrapLabel {
	GtkLabel parent_instance;
	DockManagerWrapLabelPrivate * priv;
};

struct _DockManagerWrapLabelClass {
	GtkLabelClass parent_class;
};

struct _DockManagerWrapLabelPrivate {
	gfloat orig_yalign;
	gboolean _wrap;
};


static gpointer dock_manager_wrap_label_parent_class = NULL;

GType dock_manager_wrap_label_get_type (void) G_GNUC_CONST;
#define DOCK_MANAGER_WRAP_LABEL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DOCK_MANAGER_TYPE_WRAP_LABEL, DockManagerWrapLabelPrivate))
enum  {
	DOCK_MANAGER_WRAP_LABEL_DUMMY_PROPERTY,
	DOCK_MANAGER_WRAP_LABEL_WRAP
};
DockManagerWrapLabel* dock_manager_wrap_label_new (void);
DockManagerWrapLabel* dock_manager_wrap_label_construct (GType object_type);
static void dock_manager_wrap_label_real_size_allocate (GtkWidget* base, GdkRectangle* allocation);
static void dock_manager_wrap_label_real_size_request (GtkWidget* base, GtkRequisition* req);
gboolean dock_manager_wrap_label_get_wrap (DockManagerWrapLabel* self);
void dock_manager_wrap_label_set_wrap (DockManagerWrapLabel* self, gboolean value);
static GObject * dock_manager_wrap_label_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void dock_manager_wrap_label_finalize (GObject* obj);
static void _vala_dock_manager_wrap_label_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_dock_manager_wrap_label_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);


DockManagerWrapLabel* dock_manager_wrap_label_construct (GType object_type) {
	DockManagerWrapLabel * self = NULL;
	self = (DockManagerWrapLabel*) g_object_new (object_type, "xalign", 0.0f, "wrap", FALSE, NULL);
	return self;
}


DockManagerWrapLabel* dock_manager_wrap_label_new (void) {
	return dock_manager_wrap_label_construct (DOCK_MANAGER_TYPE_WRAP_LABEL);
}


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


static void dock_manager_wrap_label_real_size_allocate (GtkWidget* base, GdkRectangle* allocation) {
	DockManagerWrapLabel * self;
	PangoLayout* _tmp0_ = NULL;
	PangoLayout* _tmp1_;
	PangoLayout* layout;
	gint lw = 0;
	gint lh = 0;
	gint _tmp2_;
	gint _tmp3_;
	self = (DockManagerWrapLabel*) base;
	_tmp0_ = gtk_label_get_layout ((GtkLabel*) self);
	_tmp1_ = _g_object_ref0 (_tmp0_);
	layout = _tmp1_;
	pango_layout_set_width (layout, (*allocation).width * PANGO_SCALE);
	pango_layout_get_pixel_size (layout, &_tmp2_, &_tmp3_);
	lw = _tmp2_;
	lh = _tmp3_;
	g_object_set ((GtkWidget*) self, "height-request", lh, NULL);
	GTK_WIDGET_CLASS (dock_manager_wrap_label_parent_class)->size_allocate ((GtkWidget*) GTK_LABEL (self), allocation);
	_g_object_unref0 (layout);
}


static void dock_manager_wrap_label_real_size_request (GtkWidget* base, GtkRequisition* req) {
	DockManagerWrapLabel * self;
	GtkRequisition _req = {0};
	GtkRequisition _tmp0_ = {0};
	self = (DockManagerWrapLabel*) base;
	GTK_WIDGET_CLASS (dock_manager_wrap_label_parent_class)->size_request ((GtkWidget*) GTK_LABEL (self), &_tmp0_);
	_req = _tmp0_;
	if (self->priv->_wrap) {
		_req.width = 1;
	}
	if (req) {
		*req = _req;
	}
}


gboolean dock_manager_wrap_label_get_wrap (DockManagerWrapLabel* self) {
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_wrap;
	return result;
}


void dock_manager_wrap_label_set_wrap (DockManagerWrapLabel* self, gboolean value) {
	gint _tmp0_ = 0;
	PangoEllipsizeMode _tmp1_ = 0;
	gfloat _tmp3_ = 0.0F;
	g_return_if_fail (self != NULL);
	self->priv->_wrap = value;
	if (self->priv->_wrap) {
		_tmp0_ = -1;
	} else {
		_tmp0_ = 10;
	}
	gtk_label_set_max_width_chars ((GtkLabel*) self, _tmp0_);
	if (self->priv->_wrap) {
		_tmp1_ = PANGO_ELLIPSIZE_NONE;
	} else {
		_tmp1_ = PANGO_ELLIPSIZE_END;
	}
	gtk_label_set_ellipsize ((GtkLabel*) self, _tmp1_);
	if (!self->priv->_wrap) {
		gfloat _tmp2_;
		self->priv->orig_yalign = (g_object_get ((GtkMisc*) self, "yalign", &_tmp2_, NULL), _tmp2_);
	}
	if (self->priv->_wrap) {
		_tmp3_ = 0.0f;
	} else {
		_tmp3_ = self->priv->orig_yalign;
	}
	g_object_set ((GtkMisc*) self, "yalign", _tmp3_, NULL);
	gtk_widget_queue_resize ((GtkWidget*) self);
	g_object_notify ((GObject *) self, "wrap");
}


static GObject * dock_manager_wrap_label_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	DockManagerWrapLabel * self;
	parent_class = G_OBJECT_CLASS (dock_manager_wrap_label_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = DOCK_MANAGER_WRAP_LABEL (obj);
	return obj;
}


static void dock_manager_wrap_label_class_init (DockManagerWrapLabelClass * klass) {
	dock_manager_wrap_label_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (DockManagerWrapLabelPrivate));
	GTK_WIDGET_CLASS (klass)->size_allocate = dock_manager_wrap_label_real_size_allocate;
	GTK_WIDGET_CLASS (klass)->size_request = dock_manager_wrap_label_real_size_request;
	G_OBJECT_CLASS (klass)->get_property = _vala_dock_manager_wrap_label_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_dock_manager_wrap_label_set_property;
	G_OBJECT_CLASS (klass)->constructor = dock_manager_wrap_label_constructor;
	G_OBJECT_CLASS (klass)->finalize = dock_manager_wrap_label_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DOCK_MANAGER_WRAP_LABEL_WRAP, g_param_spec_boolean ("wrap", "wrap", "wrap", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
}


static void dock_manager_wrap_label_instance_init (DockManagerWrapLabel * self) {
	self->priv = DOCK_MANAGER_WRAP_LABEL_GET_PRIVATE (self);
	self->priv->orig_yalign = 0.5f;
	self->priv->_wrap = FALSE;
}


static void dock_manager_wrap_label_finalize (GObject* obj) {
	DockManagerWrapLabel * self;
	self = DOCK_MANAGER_WRAP_LABEL (obj);
	G_OBJECT_CLASS (dock_manager_wrap_label_parent_class)->finalize (obj);
}


GType dock_manager_wrap_label_get_type (void) {
	static volatile gsize dock_manager_wrap_label_type_id__volatile = 0;
	if (g_once_init_enter (&dock_manager_wrap_label_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (DockManagerWrapLabelClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dock_manager_wrap_label_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DockManagerWrapLabel), 0, (GInstanceInitFunc) dock_manager_wrap_label_instance_init, NULL };
		GType dock_manager_wrap_label_type_id;
		dock_manager_wrap_label_type_id = g_type_register_static (GTK_TYPE_LABEL, "DockManagerWrapLabel", &g_define_type_info, 0);
		g_once_init_leave (&dock_manager_wrap_label_type_id__volatile, dock_manager_wrap_label_type_id);
	}
	return dock_manager_wrap_label_type_id__volatile;
}


static void _vala_dock_manager_wrap_label_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	DockManagerWrapLabel * self;
	self = DOCK_MANAGER_WRAP_LABEL (object);
	switch (property_id) {
		case DOCK_MANAGER_WRAP_LABEL_WRAP:
		g_value_set_boolean (value, dock_manager_wrap_label_get_wrap (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_dock_manager_wrap_label_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	DockManagerWrapLabel * self;
	self = DOCK_MANAGER_WRAP_LABEL (object);
	switch (property_id) {
		case DOCK_MANAGER_WRAP_LABEL_WRAP:
		dock_manager_wrap_label_set_wrap (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



