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

/*
 * Copyright (C) 2010 Michal Hruby <michal.mhr@gmail.com>
 *
 * This program 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 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA.
 *
 * Authored by Michal Hruby <michal.mhr@gmail.com>
 *
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <float.h>
#include <math.h>
#include <pango/pango.h>
#include <cairo-gobject.h>
#include <string.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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define UI_WIDGETS_TYPE_WRAP_LABEL (ui_widgets_wrap_label_get_type ())
#define UI_WIDGETS_WRAP_LABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UI_WIDGETS_TYPE_WRAP_LABEL, UIWidgetsWrapLabel))
#define UI_WIDGETS_WRAP_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UI_WIDGETS_TYPE_WRAP_LABEL, UIWidgetsWrapLabelClass))
#define UI_WIDGETS_IS_WRAP_LABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UI_WIDGETS_TYPE_WRAP_LABEL))
#define UI_WIDGETS_IS_WRAP_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UI_WIDGETS_TYPE_WRAP_LABEL))
#define UI_WIDGETS_WRAP_LABEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UI_WIDGETS_TYPE_WRAP_LABEL, UIWidgetsWrapLabelClass))

typedef struct _UIWidgetsWrapLabel UIWidgetsWrapLabel;
typedef struct _UIWidgetsWrapLabelClass UIWidgetsWrapLabelClass;
typedef struct _UIWidgetsWrapLabelPrivate UIWidgetsWrapLabelPrivate;
enum  {
	UI_WIDGETS_WRAP_LABEL_0_PROPERTY,
	UI_WIDGETS_WRAP_LABEL_WRAP_PROPERTY,
	UI_WIDGETS_WRAP_LABEL_NUM_PROPERTIES
};
static GParamSpec* ui_widgets_wrap_label_properties[UI_WIDGETS_WRAP_LABEL_NUM_PROPERTIES];

struct _UIWidgetsWrapLabel {
	GtkLabel parent_instance;
	UIWidgetsWrapLabelPrivate * priv;
};

struct _UIWidgetsWrapLabelClass {
	GtkLabelClass parent_class;
};

struct _UIWidgetsWrapLabelPrivate {
	gfloat orig_yalign;
	gboolean _wrap;
};

static gint UIWidgetsWrapLabel_private_offset;
static gpointer ui_widgets_wrap_label_parent_class = NULL;

VALA_EXTERN GType ui_widgets_wrap_label_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (UIWidgetsWrapLabel, g_object_unref)
VALA_EXTERN UIWidgetsWrapLabel* ui_widgets_wrap_label_new (void);
VALA_EXTERN UIWidgetsWrapLabel* ui_widgets_wrap_label_construct (GType object_type);
static void ui_widgets_wrap_label_real_size_allocate (GtkWidget* base,
                                               GtkAllocation* allocation);
static void ui_widgets_wrap_label_real_get_preferred_width (GtkWidget* base,
                                                     gint* min_width,
                                                     gint* nat_width);
VALA_EXTERN gboolean ui_widgets_wrap_label_get_wrap (UIWidgetsWrapLabel* self);
VALA_EXTERN void ui_widgets_wrap_label_set_wrap (UIWidgetsWrapLabel* self,
                                     gboolean value);
static GObject * ui_widgets_wrap_label_constructor (GType type,
                                             guint n_construct_properties,
                                             GObjectConstructParam * construct_properties);
static void ui_widgets_wrap_label_finalize (GObject * obj);
static GType ui_widgets_wrap_label_get_type_once (void);
static void _vala_ui_widgets_wrap_label_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec);
static void _vala_ui_widgets_wrap_label_set_property (GObject * object,
                                               guint property_id,
                                               const GValue * value,
                                               GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
ui_widgets_wrap_label_get_instance_private (UIWidgetsWrapLabel* self)
{
	return G_STRUCT_MEMBER_P (self, UIWidgetsWrapLabel_private_offset);
}

UIWidgetsWrapLabel*
ui_widgets_wrap_label_construct (GType object_type)
{
	UIWidgetsWrapLabel * self = NULL;
#line 46 "tile-view/wrap-label.vala"
	self = (UIWidgetsWrapLabel*) g_object_new (object_type, "xalign", 0.0f, "wrap", FALSE, NULL);
#line 44 "tile-view/wrap-label.vala"
	return self;
#line 129 "wrap-label.c"
}

UIWidgetsWrapLabel*
ui_widgets_wrap_label_new (void)
{
#line 44 "tile-view/wrap-label.vala"
	return ui_widgets_wrap_label_construct (UI_WIDGETS_TYPE_WRAP_LABEL);
#line 137 "wrap-label.c"
}

static void
ui_widgets_wrap_label_real_size_allocate (GtkWidget* base,
                                          GtkAllocation* allocation)
{
	UIWidgetsWrapLabel * self;
	PangoLayout* layout = NULL;
	PangoLayout* _tmp0_;
	GtkAllocation _tmp1_;
	gint lw = 0;
	gint lh = 0;
	gint _tmp2_ = 0;
	gint _tmp3_ = 0;
	GtkAllocation _tmp4_;
#line 53 "tile-view/wrap-label.vala"
	self = (UIWidgetsWrapLabel*) base;
#line 53 "tile-view/wrap-label.vala"
	g_return_if_fail (allocation != NULL);
#line 55 "tile-view/wrap-label.vala"
	_tmp0_ = gtk_label_get_layout ((GtkLabel*) self);
#line 55 "tile-view/wrap-label.vala"
	layout = _tmp0_;
#line 56 "tile-view/wrap-label.vala"
	_tmp1_ = *allocation;
#line 56 "tile-view/wrap-label.vala"
	pango_layout_set_width (layout, _tmp1_.width * PANGO_SCALE);
#line 59 "tile-view/wrap-label.vala"
	pango_layout_get_pixel_size (layout, &_tmp2_, &_tmp3_);
#line 59 "tile-view/wrap-label.vala"
	lw = _tmp2_;
#line 59 "tile-view/wrap-label.vala"
	lh = _tmp3_;
#line 61 "tile-view/wrap-label.vala"
	g_object_set ((GtkWidget*) self, "height-request", lh, NULL);
#line 63 "tile-view/wrap-label.vala"
	_tmp4_ = *allocation;
#line 63 "tile-view/wrap-label.vala"
	GTK_WIDGET_CLASS (ui_widgets_wrap_label_parent_class)->size_allocate ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_label_get_type (), GtkLabel), &_tmp4_);
#line 177 "wrap-label.c"
}

static void
ui_widgets_wrap_label_real_get_preferred_width (GtkWidget* base,
                                                gint* min_width,
                                                gint* nat_width)
{
	UIWidgetsWrapLabel * self;
	gint _vala_min_width = 0;
	gint _vala_nat_width = 0;
	gint _tmp0_ = 0;
	gint _tmp1_ = 0;
#line 66 "tile-view/wrap-label.vala"
	self = (UIWidgetsWrapLabel*) base;
#line 68 "tile-view/wrap-label.vala"
	GTK_WIDGET_CLASS (ui_widgets_wrap_label_parent_class)->get_preferred_width ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_label_get_type (), GtkLabel), &_tmp0_, &_tmp1_);
#line 68 "tile-view/wrap-label.vala"
	_vala_min_width = _tmp0_;
#line 68 "tile-view/wrap-label.vala"
	_vala_nat_width = _tmp1_;
#line 69 "tile-view/wrap-label.vala"
	_vala_nat_width = 30;
#line 69 "tile-view/wrap-label.vala"
	_vala_min_width = _vala_nat_width;
#line 70 "tile-view/wrap-label.vala"
	if (self->priv->_wrap) {
#line 71 "tile-view/wrap-label.vala"
		_vala_nat_width = 1;
#line 71 "tile-view/wrap-label.vala"
		_vala_min_width = _vala_nat_width;
#line 208 "wrap-label.c"
	}
#line 66 "tile-view/wrap-label.vala"
	if (min_width) {
#line 66 "tile-view/wrap-label.vala"
		*min_width = _vala_min_width;
#line 214 "wrap-label.c"
	}
#line 66 "tile-view/wrap-label.vala"
	if (nat_width) {
#line 66 "tile-view/wrap-label.vala"
		*nat_width = _vala_nat_width;
#line 220 "wrap-label.c"
	}
}

gboolean
ui_widgets_wrap_label_get_wrap (UIWidgetsWrapLabel* self)
{
	gboolean result;
#line 29 "tile-view/wrap-label.vala"
	g_return_val_if_fail (self != NULL, FALSE);
#line 31 "tile-view/wrap-label.vala"
	result = self->priv->_wrap;
#line 31 "tile-view/wrap-label.vala"
	return result;
#line 234 "wrap-label.c"
}

void
ui_widgets_wrap_label_set_wrap (UIWidgetsWrapLabel* self,
                                gboolean value)
{
	gint _tmp0_ = 0;
	PangoEllipsizeMode _tmp1_ = 0;
	gfloat _tmp4_ = 0.0F;
#line 33 "tile-view/wrap-label.vala"
	g_return_if_fail (self != NULL);
#line 35 "tile-view/wrap-label.vala"
	self->priv->_wrap = value;
#line 36 "tile-view/wrap-label.vala"
	if (self->priv->_wrap) {
#line 36 "tile-view/wrap-label.vala"
		_tmp0_ = -1;
#line 252 "wrap-label.c"
	} else {
#line 36 "tile-view/wrap-label.vala"
		_tmp0_ = 10;
#line 256 "wrap-label.c"
	}
#line 36 "tile-view/wrap-label.vala"
	gtk_label_set_max_width_chars ((GtkLabel*) self, _tmp0_);
#line 37 "tile-view/wrap-label.vala"
	if (self->priv->_wrap) {
#line 37 "tile-view/wrap-label.vala"
		_tmp1_ = PANGO_ELLIPSIZE_NONE;
#line 264 "wrap-label.c"
	} else {
#line 38 "tile-view/wrap-label.vala"
		_tmp1_ = PANGO_ELLIPSIZE_END;
#line 268 "wrap-label.c"
	}
#line 37 "tile-view/wrap-label.vala"
	gtk_label_set_ellipsize ((GtkLabel*) self, _tmp1_);
#line 39 "tile-view/wrap-label.vala"
	if (!self->priv->_wrap) {
#line 274 "wrap-label.c"
		gfloat _tmp2_;
		gfloat _tmp3_;
#line 39 "tile-view/wrap-label.vala"
		g_object_get (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_misc_get_type (), GtkMisc), "yalign", &_tmp2_, NULL);
#line 39 "tile-view/wrap-label.vala"
		_tmp3_ = _tmp2_;
#line 39 "tile-view/wrap-label.vala"
		self->priv->orig_yalign = _tmp3_;
#line 283 "wrap-label.c"
	}
#line 40 "tile-view/wrap-label.vala"
	if (self->priv->_wrap) {
#line 40 "tile-view/wrap-label.vala"
		_tmp4_ = 0.0f;
#line 289 "wrap-label.c"
	} else {
#line 40 "tile-view/wrap-label.vala"
		_tmp4_ = self->priv->orig_yalign;
#line 293 "wrap-label.c"
	}
#line 40 "tile-view/wrap-label.vala"
	g_object_set (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_misc_get_type (), GtkMisc), "yalign", _tmp4_, NULL);
#line 41 "tile-view/wrap-label.vala"
	gtk_widget_queue_resize ((GtkWidget*) self);
#line 33 "tile-view/wrap-label.vala"
	g_object_notify_by_pspec ((GObject *) self, ui_widgets_wrap_label_properties[UI_WIDGETS_WRAP_LABEL_WRAP_PROPERTY]);
#line 301 "wrap-label.c"
}

static GObject *
ui_widgets_wrap_label_constructor (GType type,
                                   guint n_construct_properties,
                                   GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	UIWidgetsWrapLabel * self;
#line 49 "tile-view/wrap-label.vala"
	parent_class = G_OBJECT_CLASS (ui_widgets_wrap_label_parent_class);
#line 49 "tile-view/wrap-label.vala"
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
#line 49 "tile-view/wrap-label.vala"
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, UI_WIDGETS_TYPE_WRAP_LABEL, UIWidgetsWrapLabel);
#line 49 "tile-view/wrap-label.vala"
	return obj;
#line 320 "wrap-label.c"
}

static void
ui_widgets_wrap_label_class_init (UIWidgetsWrapLabelClass * klass,
                                  gpointer klass_data)
{
#line 24 "tile-view/wrap-label.vala"
	ui_widgets_wrap_label_parent_class = g_type_class_peek_parent (klass);
#line 24 "tile-view/wrap-label.vala"
	g_type_class_adjust_private_offset (klass, &UIWidgetsWrapLabel_private_offset);
#line 24 "tile-view/wrap-label.vala"
	((GtkWidgetClass *) klass)->size_allocate = (void (*) (GtkWidget*, GtkAllocation*)) ui_widgets_wrap_label_real_size_allocate;
#line 24 "tile-view/wrap-label.vala"
	((GtkWidgetClass *) klass)->get_preferred_width = (void (*) (GtkWidget*, gint*, gint*)) ui_widgets_wrap_label_real_get_preferred_width;
#line 24 "tile-view/wrap-label.vala"
	G_OBJECT_CLASS (klass)->get_property = _vala_ui_widgets_wrap_label_get_property;
#line 24 "tile-view/wrap-label.vala"
	G_OBJECT_CLASS (klass)->set_property = _vala_ui_widgets_wrap_label_set_property;
#line 24 "tile-view/wrap-label.vala"
	G_OBJECT_CLASS (klass)->constructor = ui_widgets_wrap_label_constructor;
#line 24 "tile-view/wrap-label.vala"
	G_OBJECT_CLASS (klass)->finalize = ui_widgets_wrap_label_finalize;
#line 24 "tile-view/wrap-label.vala"
	g_object_class_install_property (G_OBJECT_CLASS (klass), UI_WIDGETS_WRAP_LABEL_WRAP_PROPERTY, ui_widgets_wrap_label_properties[UI_WIDGETS_WRAP_LABEL_WRAP_PROPERTY] = g_param_spec_boolean ("wrap", "wrap", "wrap", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
#line 345 "wrap-label.c"
}

static void
ui_widgets_wrap_label_instance_init (UIWidgetsWrapLabel * self,
                                     gpointer klass)
{
#line 24 "tile-view/wrap-label.vala"
	self->priv = ui_widgets_wrap_label_get_instance_private (self);
#line 26 "tile-view/wrap-label.vala"
	self->priv->orig_yalign = 0.5f;
#line 27 "tile-view/wrap-label.vala"
	self->priv->_wrap = FALSE;
#line 358 "wrap-label.c"
}

static void
ui_widgets_wrap_label_finalize (GObject * obj)
{
	UIWidgetsWrapLabel * self;
#line 24 "tile-view/wrap-label.vala"
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, UI_WIDGETS_TYPE_WRAP_LABEL, UIWidgetsWrapLabel);
#line 24 "tile-view/wrap-label.vala"
	G_OBJECT_CLASS (ui_widgets_wrap_label_parent_class)->finalize (obj);
#line 369 "wrap-label.c"
}

static GType
ui_widgets_wrap_label_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (UIWidgetsWrapLabelClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ui_widgets_wrap_label_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UIWidgetsWrapLabel), 0, (GInstanceInitFunc) ui_widgets_wrap_label_instance_init, NULL };
	GType ui_widgets_wrap_label_type_id;
	ui_widgets_wrap_label_type_id = g_type_register_static (gtk_label_get_type (), "UIWidgetsWrapLabel", &g_define_type_info, 0);
	UIWidgetsWrapLabel_private_offset = g_type_add_instance_private (ui_widgets_wrap_label_type_id, sizeof (UIWidgetsWrapLabelPrivate));
	return ui_widgets_wrap_label_type_id;
}

GType
ui_widgets_wrap_label_get_type (void)
{
	static volatile gsize ui_widgets_wrap_label_type_id__once = 0;
	if (g_once_init_enter (&ui_widgets_wrap_label_type_id__once)) {
		GType ui_widgets_wrap_label_type_id;
		ui_widgets_wrap_label_type_id = ui_widgets_wrap_label_get_type_once ();
		g_once_init_leave (&ui_widgets_wrap_label_type_id__once, ui_widgets_wrap_label_type_id);
	}
	return ui_widgets_wrap_label_type_id__once;
}

static void
_vala_ui_widgets_wrap_label_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec)
{
	UIWidgetsWrapLabel * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, UI_WIDGETS_TYPE_WRAP_LABEL, UIWidgetsWrapLabel);
#line 24 "tile-view/wrap-label.vala"
	switch (property_id) {
#line 24 "tile-view/wrap-label.vala"
		case UI_WIDGETS_WRAP_LABEL_WRAP_PROPERTY:
#line 24 "tile-view/wrap-label.vala"
		g_value_set_boolean (value, ui_widgets_wrap_label_get_wrap (self));
#line 24 "tile-view/wrap-label.vala"
		break;
#line 410 "wrap-label.c"
		default:
#line 24 "tile-view/wrap-label.vala"
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
#line 24 "tile-view/wrap-label.vala"
		break;
#line 416 "wrap-label.c"
	}
}

static void
_vala_ui_widgets_wrap_label_set_property (GObject * object,
                                          guint property_id,
                                          const GValue * value,
                                          GParamSpec * pspec)
{
	UIWidgetsWrapLabel * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, UI_WIDGETS_TYPE_WRAP_LABEL, UIWidgetsWrapLabel);
#line 24 "tile-view/wrap-label.vala"
	switch (property_id) {
#line 24 "tile-view/wrap-label.vala"
		case UI_WIDGETS_WRAP_LABEL_WRAP_PROPERTY:
#line 24 "tile-view/wrap-label.vala"
		ui_widgets_wrap_label_set_wrap (self, g_value_get_boolean (value));
#line 24 "tile-view/wrap-label.vala"
		break;
#line 436 "wrap-label.c"
		default:
#line 24 "tile-view/wrap-label.vala"
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
#line 24 "tile-view/wrap-label.vala"
		break;
#line 442 "wrap-label.c"
	}
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
#line 24 "controller.vala"
	if (mem && byte_size != 0) {
#line 24 "controller.vala"
		new_mem = g_malloc (byte_size);
#line 24 "controller.vala"
		memcpy (new_mem, mem, byte_size);
#line 457 "wrap-label.c"
	} else {
#line 24 "controller.vala"
		new_mem = NULL;
#line 461 "wrap-label.c"
	}
#line 24 "controller.vala"
	return new_mem;
#line 465 "wrap-label.c"
}

