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

/* Copyright (c) 2005 VMware, Inc.*/
/* This is a translation of http://git.gnome.org/browse/meld/tree/meld/ui/wraplabel.py,*/
/* which in turn is a translation of WrapLabel from libview.*/
/* Permission is hereby granted, free of charge, to any person obtaining a copy*/
/* of this software and associated documentation files (the "Software"), to deal*/
/* in the Software without restriction, including without limitation the rights*/
/* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell*/
/* copies of the Software, and to permit persons to whom the Software is*/
/* furnished to do so, subject to the following conditions:*/
/**/
/* The above copyright notice and this permission notice shall be included in*/
/* all copies or substantial portions of the Software.*/
/**/
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*/
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,*/
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE*/
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*/
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,*/
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE*/
/* SOFTWARE.*/
/* Python translation from wrapLabel.{cc|h} by Gian Mario Tagliaretti*/
/* Vala translation from wraplabel.py by Zbigniew Jędrzejewski-Szmek*/

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


#define TYPE_WRAP_LABEL (wrap_label_get_type ())
#define WRAP_LABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_WRAP_LABEL, WrapLabel))
#define WRAP_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_WRAP_LABEL, WrapLabelClass))
#define IS_WRAP_LABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_WRAP_LABEL))
#define IS_WRAP_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_WRAP_LABEL))
#define WRAP_LABEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_WRAP_LABEL, WrapLabelClass))

typedef struct _WrapLabel WrapLabel;
typedef struct _WrapLabelClass WrapLabelClass;
typedef struct _WrapLabelPrivate WrapLabelPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _WrapLabel {
	GtkLabel parent_instance;
	WrapLabelPrivate * priv;
};

struct _WrapLabelClass {
	GtkLabelClass parent_class;
};

struct _WrapLabelPrivate {
	gint _wrap_width;
};


static gpointer wrap_label_parent_class = NULL;

GType wrap_label_get_type (void) G_GNUC_CONST;
#define WRAP_LABEL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_WRAP_LABEL, WrapLabelPrivate))
enum  {
	WRAP_LABEL_DUMMY_PROPERTY
};
WrapLabel* wrap_label_new (const gchar* text);
WrapLabel* wrap_label_construct (GType object_type, const gchar* text);
void wrap_label_set_text (WrapLabel* self, const gchar* str);
static void wrap_label_real_size_request (GtkWidget* base, GtkRequisition* requisition);
static void wrap_label_real_size_allocate (GtkWidget* base, GdkRectangle* allocation);
static void _wrap_label_set_wrap_width (WrapLabel* self, gint width);
void wrap_label_set_markup (WrapLabel* self, const gchar* str);
static void wrap_label_finalize (GObject* obj);


static gpointer _g_object_ref0 (gpointer self) {
#line 32 "/home/lennart/projects/systemd/src/wraplabel.vala"
	return self ? g_object_ref (self) : NULL;
#line 85 "wraplabel.c"
}


WrapLabel* wrap_label_construct (GType object_type, const gchar* text) {
	WrapLabel * self = NULL;
	PangoLayout* _tmp0_ = NULL;
	PangoLayout* _tmp1_;
	PangoLayout* layout;
	PangoLayout* _tmp2_;
	const gchar* _tmp3_;
#line 30 "/home/lennart/projects/systemd/src/wraplabel.vala"
	self = (WrapLabel*) g_object_new (object_type, NULL);
#line 31 "/home/lennart/projects/systemd/src/wraplabel.vala"
	self->priv->_wrap_width = 0;
#line 32 "/home/lennart/projects/systemd/src/wraplabel.vala"
	_tmp0_ = gtk_label_get_layout ((GtkLabel*) self);
#line 32 "/home/lennart/projects/systemd/src/wraplabel.vala"
	_tmp1_ = _g_object_ref0 (_tmp0_);
#line 32 "/home/lennart/projects/systemd/src/wraplabel.vala"
	layout = _tmp1_;
#line 33 "/home/lennart/projects/systemd/src/wraplabel.vala"
	_tmp2_ = layout;
#line 33 "/home/lennart/projects/systemd/src/wraplabel.vala"
	pango_layout_set_wrap (_tmp2_, PANGO_WRAP_WORD_CHAR);
#line 34 "/home/lennart/projects/systemd/src/wraplabel.vala"
	_tmp3_ = text;
#line 34 "/home/lennart/projects/systemd/src/wraplabel.vala"
	if (_tmp3_ != NULL) {
#line 114 "wraplabel.c"
		const gchar* _tmp4_;
#line 35 "/home/lennart/projects/systemd/src/wraplabel.vala"
		_tmp4_ = text;
#line 35 "/home/lennart/projects/systemd/src/wraplabel.vala"
		wrap_label_set_text (self, _tmp4_);
#line 120 "wraplabel.c"
	}
#line 36 "/home/lennart/projects/systemd/src/wraplabel.vala"
	gtk_misc_set_alignment ((GtkMisc*) self, (gfloat) 0, (gfloat) 0);
#line 30 "/home/lennart/projects/systemd/src/wraplabel.vala"
	_g_object_unref0 (layout);
#line 30 "/home/lennart/projects/systemd/src/wraplabel.vala"
	return self;
#line 128 "wraplabel.c"
}


WrapLabel* wrap_label_new (const gchar* text) {
#line 30 "/home/lennart/projects/systemd/src/wraplabel.vala"
	return wrap_label_construct (TYPE_WRAP_LABEL, text);
#line 135 "wraplabel.c"
}


static void wrap_label_real_size_request (GtkWidget* base, GtkRequisition* requisition) {
	WrapLabel * self;
	GtkRequisition _vala_requisition = {0};
	gint width = 0;
	gint height = 0;
	PangoLayout* _tmp0_ = NULL;
	PangoLayout* _tmp1_;
	PangoLayout* layout;
	gint _tmp2_ = 0;
	gint _tmp3_ = 0;
#line 39 "/home/lennart/projects/systemd/src/wraplabel.vala"
	self = (WrapLabel*) base;
#line 41 "/home/lennart/projects/systemd/src/wraplabel.vala"
	_tmp0_ = gtk_label_get_layout ((GtkLabel*) self);
#line 41 "/home/lennart/projects/systemd/src/wraplabel.vala"
	_tmp1_ = _g_object_ref0 (_tmp0_);
#line 41 "/home/lennart/projects/systemd/src/wraplabel.vala"
	layout = _tmp1_;
#line 42 "/home/lennart/projects/systemd/src/wraplabel.vala"
	pango_layout_get_pixel_size (layout, &_tmp2_, &_tmp3_);
#line 42 "/home/lennart/projects/systemd/src/wraplabel.vala"
	width = _tmp2_;
#line 42 "/home/lennart/projects/systemd/src/wraplabel.vala"
	height = _tmp3_;
#line 43 "/home/lennart/projects/systemd/src/wraplabel.vala"
	_vala_requisition.width = 0;
#line 44 "/home/lennart/projects/systemd/src/wraplabel.vala"
	_vala_requisition.height = height;
#line 39 "/home/lennart/projects/systemd/src/wraplabel.vala"
	_g_object_unref0 (layout);
#line 39 "/home/lennart/projects/systemd/src/wraplabel.vala"
	if (requisition) {
#line 39 "/home/lennart/projects/systemd/src/wraplabel.vala"
		*requisition = _vala_requisition;
#line 173 "wraplabel.c"
	}
}


static void wrap_label_real_size_allocate (GtkWidget* base, GdkRectangle* allocation) {
	WrapLabel * self;
	GdkRectangle _tmp0_;
	GdkRectangle _tmp1_;
	gint _tmp2_;
#line 47 "/home/lennart/projects/systemd/src/wraplabel.vala"
	self = (WrapLabel*) base;
#line 47 "/home/lennart/projects/systemd/src/wraplabel.vala"
	g_return_if_fail (allocation != NULL);
#line 48 "/home/lennart/projects/systemd/src/wraplabel.vala"
	_tmp0_ = *allocation;
#line 48 "/home/lennart/projects/systemd/src/wraplabel.vala"
	GTK_WIDGET_CLASS (wrap_label_parent_class)->size_allocate ((GtkWidget*) GTK_LABEL (self), &_tmp0_);
#line 49 "/home/lennart/projects/systemd/src/wraplabel.vala"
	_tmp1_ = *allocation;
#line 49 "/home/lennart/projects/systemd/src/wraplabel.vala"
	_tmp2_ = _tmp1_.width;
#line 49 "/home/lennart/projects/systemd/src/wraplabel.vala"
	_wrap_label_set_wrap_width (self, _tmp2_);
#line 197 "wraplabel.c"
}


void wrap_label_set_text (WrapLabel* self, const gchar* str) {
	const gchar* _tmp0_;
	gint _tmp1_;
#line 52 "/home/lennart/projects/systemd/src/wraplabel.vala"
	g_return_if_fail (self != NULL);
#line 52 "/home/lennart/projects/systemd/src/wraplabel.vala"
	g_return_if_fail (str != NULL);
#line 53 "/home/lennart/projects/systemd/src/wraplabel.vala"
	_tmp0_ = str;
#line 53 "/home/lennart/projects/systemd/src/wraplabel.vala"
	gtk_label_set_text (GTK_LABEL (self), _tmp0_);
#line 54 "/home/lennart/projects/systemd/src/wraplabel.vala"
	_tmp1_ = self->priv->_wrap_width;
#line 54 "/home/lennart/projects/systemd/src/wraplabel.vala"
	_wrap_label_set_wrap_width (self, _tmp1_);
#line 216 "wraplabel.c"
}


void wrap_label_set_markup (WrapLabel* self, const gchar* str) {
	const gchar* _tmp0_;
	gint _tmp1_;
#line 57 "/home/lennart/projects/systemd/src/wraplabel.vala"
	g_return_if_fail (self != NULL);
#line 57 "/home/lennart/projects/systemd/src/wraplabel.vala"
	g_return_if_fail (str != NULL);
#line 58 "/home/lennart/projects/systemd/src/wraplabel.vala"
	_tmp0_ = str;
#line 58 "/home/lennart/projects/systemd/src/wraplabel.vala"
	gtk_label_set_markup (GTK_LABEL (self), _tmp0_);
#line 59 "/home/lennart/projects/systemd/src/wraplabel.vala"
	_tmp1_ = self->priv->_wrap_width;
#line 59 "/home/lennart/projects/systemd/src/wraplabel.vala"
	_wrap_label_set_wrap_width (self, _tmp1_);
#line 235 "wraplabel.c"
}


static void _wrap_label_set_wrap_width (WrapLabel* self, gint width) {
	gint _tmp0_;
	PangoLayout* _tmp1_ = NULL;
	PangoLayout* _tmp2_;
	PangoLayout* layout;
	PangoLayout* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
#line 62 "/home/lennart/projects/systemd/src/wraplabel.vala"
	g_return_if_fail (self != NULL);
#line 63 "/home/lennart/projects/systemd/src/wraplabel.vala"
	_tmp0_ = width;
#line 63 "/home/lennart/projects/systemd/src/wraplabel.vala"
	if (_tmp0_ == 0) {
#line 64 "/home/lennart/projects/systemd/src/wraplabel.vala"
		return;
#line 256 "wraplabel.c"
	}
#line 66 "/home/lennart/projects/systemd/src/wraplabel.vala"
	_tmp1_ = gtk_label_get_layout ((GtkLabel*) self);
#line 66 "/home/lennart/projects/systemd/src/wraplabel.vala"
	_tmp2_ = _g_object_ref0 (_tmp1_);
#line 66 "/home/lennart/projects/systemd/src/wraplabel.vala"
	layout = _tmp2_;
#line 67 "/home/lennart/projects/systemd/src/wraplabel.vala"
	_tmp3_ = layout;
#line 67 "/home/lennart/projects/systemd/src/wraplabel.vala"
	_tmp4_ = width;
#line 67 "/home/lennart/projects/systemd/src/wraplabel.vala"
	pango_layout_set_width (_tmp3_, _tmp4_ * PANGO_SCALE);
#line 68 "/home/lennart/projects/systemd/src/wraplabel.vala"
	_tmp5_ = self->priv->_wrap_width;
#line 68 "/home/lennart/projects/systemd/src/wraplabel.vala"
	_tmp6_ = width;
#line 68 "/home/lennart/projects/systemd/src/wraplabel.vala"
	if (_tmp5_ != _tmp6_) {
#line 276 "wraplabel.c"
		gint _tmp7_;
#line 69 "/home/lennart/projects/systemd/src/wraplabel.vala"
		_tmp7_ = width;
#line 69 "/home/lennart/projects/systemd/src/wraplabel.vala"
		self->priv->_wrap_width = _tmp7_;
#line 70 "/home/lennart/projects/systemd/src/wraplabel.vala"
		gtk_widget_queue_resize ((GtkWidget*) self);
#line 284 "wraplabel.c"
	}
#line 62 "/home/lennart/projects/systemd/src/wraplabel.vala"
	_g_object_unref0 (layout);
#line 288 "wraplabel.c"
}


static void wrap_label_class_init (WrapLabelClass * klass) {
#line 27 "/home/lennart/projects/systemd/src/wraplabel.vala"
	wrap_label_parent_class = g_type_class_peek_parent (klass);
#line 27 "/home/lennart/projects/systemd/src/wraplabel.vala"
	g_type_class_add_private (klass, sizeof (WrapLabelPrivate));
#line 27 "/home/lennart/projects/systemd/src/wraplabel.vala"
	GTK_WIDGET_CLASS (klass)->size_request = wrap_label_real_size_request;
#line 27 "/home/lennart/projects/systemd/src/wraplabel.vala"
	GTK_WIDGET_CLASS (klass)->size_allocate = wrap_label_real_size_allocate;
#line 27 "/home/lennart/projects/systemd/src/wraplabel.vala"
	G_OBJECT_CLASS (klass)->finalize = wrap_label_finalize;
#line 303 "wraplabel.c"
}


static void wrap_label_instance_init (WrapLabel * self) {
#line 27 "/home/lennart/projects/systemd/src/wraplabel.vala"
	self->priv = WRAP_LABEL_GET_PRIVATE (self);
#line 310 "wraplabel.c"
}


static void wrap_label_finalize (GObject* obj) {
	WrapLabel * self;
#line 27 "/home/lennart/projects/systemd/src/wraplabel.vala"
	self = WRAP_LABEL (obj);
#line 27 "/home/lennart/projects/systemd/src/wraplabel.vala"
	G_OBJECT_CLASS (wrap_label_parent_class)->finalize (obj);
#line 320 "wraplabel.c"
}


GType wrap_label_get_type (void) {
	static volatile gsize wrap_label_type_id__volatile = 0;
	if (g_once_init_enter (&wrap_label_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (WrapLabelClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) wrap_label_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WrapLabel), 0, (GInstanceInitFunc) wrap_label_instance_init, NULL };
		GType wrap_label_type_id;
		wrap_label_type_id = g_type_register_static (GTK_TYPE_LABEL, "WrapLabel", &g_define_type_info, 0);
		g_once_init_leave (&wrap_label_type_id__volatile, wrap_label_type_id);
	}
	return wrap_label_type_id__volatile;
}



