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

#include <pango/pango.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <float.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <graphene-gobject.h>
#include <gsk/gsk.h>
#include <gdk/gdk.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

typedef enum  {
	G4_ELLIPSIZE_MODE_NONE = PANGO_ELLIPSIZE_NONE,
	G4_ELLIPSIZE_MODE_START = PANGO_ELLIPSIZE_START,
	G4_ELLIPSIZE_MODE_MIDDLE = PANGO_ELLIPSIZE_MIDDLE,
	G4_ELLIPSIZE_MODE_END = PANGO_ELLIPSIZE_END,
	G4_ELLIPSIZE_MODE_MARQUEE
} G4EllipsizeMode;

#define G4_TYPE_ELLIPSIZE_MODE (g4_ellipsize_mode_get_type ())

#define G4_TYPE_STABLE_LABEL (g4_stable_label_get_type ())
#define G4_STABLE_LABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G4_TYPE_STABLE_LABEL, G4StableLabel))
#define G4_STABLE_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), G4_TYPE_STABLE_LABEL, G4StableLabelClass))
#define G4_IS_STABLE_LABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G4_TYPE_STABLE_LABEL))
#define G4_IS_STABLE_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), G4_TYPE_STABLE_LABEL))
#define G4_STABLE_LABEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), G4_TYPE_STABLE_LABEL, G4StableLabelClass))

typedef struct _G4StableLabel G4StableLabel;
typedef struct _G4StableLabelClass G4StableLabelClass;
typedef struct _G4StableLabelPrivate G4StableLabelPrivate;
enum  {
	G4_STABLE_LABEL_0_PROPERTY,
	G4_STABLE_LABEL_ELLIPSIZE_PROPERTY,
	G4_STABLE_LABEL_LABEL_PROPERTY,
	G4_STABLE_LABEL_MARQUEE_PROPERTY,
	G4_STABLE_LABEL_NUM_PROPERTIES
};
static GParamSpec* g4_stable_label_properties[G4_STABLE_LABEL_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef void (*G4VoidFunc) (gpointer user_data);

struct _G4StableLabel {
	GtkWidget parent_instance;
	G4StableLabelPrivate * priv;
};

struct _G4StableLabelClass {
	GtkWidgetClass parent_class;
};

struct _G4StableLabelPrivate {
	G4EllipsizeMode _ellipsize;
	GtkLabel* _label;
	gfloat _label_offset;
	gint _label_width;
	guint _pixels_per_second;
	guint _tick_handler;
	gboolean _tick_moving;
	gint64 _tick_start_time;
	guint _timer_id;
};

static gint G4StableLabel_private_offset;
static gpointer g4_stable_label_parent_class = NULL;
static gfloat g4_stable_label_SPACE;
static gfloat g4_stable_label_SPACE = 40.f;
static guint g4_stable_label_TICK_WAIT;
static guint g4_stable_label_TICK_WAIT = (guint) 3000;

VALA_EXTERN GType g4_ellipsize_mode_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType g4_stable_label_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (G4StableLabel, g_object_unref)
static void g4_stable_label_real_measure (GtkWidget* base,
                                   GtkOrientation orientation,
                                   gint for_size,
                                   gint* minimum,
                                   gint* natural,
                                   gint* minimum_baseline,
                                   gint* natural_baseline);
VALA_EXTERN gboolean g4_stable_label_get_marquee (G4StableLabel* self);
static void g4_stable_label_real_size_allocate (GtkWidget* base,
                                         gint width,
                                         gint height,
                                         gint baseline);
static void g4_stable_label_update_tick_delayed (G4StableLabel* self);
static void g4_stable_label_real_snapshot (GtkWidget* base,
                                    GtkSnapshot* snapshot);
VALA_EXTERN void g4_color_from_uint (guint color,
                         GdkRGBA* result);
static gboolean g4_stable_label_on_tick_callback (G4StableLabel* self,
                                           GtkWidget* widget,
                                           GdkFrameClock* clock);
static void g4_stable_label_stop_tick (G4StableLabel* self);
static void g4_stable_label_update_tick (G4StableLabel* self);
static gboolean _g4_stable_label_on_tick_callback_gtk_tick_callback (GtkWidget* widget,
                                                              GdkFrameClock* frame_clock,
                                                              gpointer self);
VALA_EXTERN guint g4_run_timeout_once (guint interval,
                           G4VoidFunc func,
                           gpointer func_target,
                           GDestroyNotify func_target_destroy_notify);
static void ___lambda54_ (G4StableLabel* self);
static void ____lambda54__g4_void_func (gpointer self);
VALA_EXTERN G4StableLabel* g4_stable_label_new (void);
VALA_EXTERN G4StableLabel* g4_stable_label_construct (GType object_type);
VALA_EXTERN G4EllipsizeMode g4_stable_label_get_ellipsize (G4StableLabel* self);
VALA_EXTERN void g4_stable_label_set_ellipsize (G4StableLabel* self,
                                    G4EllipsizeMode value);
VALA_EXTERN const gchar* g4_stable_label_get_label (G4StableLabel* self);
VALA_EXTERN void g4_stable_label_set_label (G4StableLabel* self,
                                const gchar* value);
VALA_EXTERN void g4_stable_label_set_marquee (G4StableLabel* self,
                                  gboolean value);
static GObject * g4_stable_label_constructor (GType type,
                                       guint n_construct_properties,
                                       GObjectConstructParam * construct_properties);
static void g4_stable_label_finalize (GObject * obj);
static GType g4_stable_label_get_type_once (void);
static void _vala_g4_stable_label_get_property (GObject * object,
                                         guint property_id,
                                         GValue * value,
                                         GParamSpec * pspec);
static void _vala_g4_stable_label_set_property (GObject * object,
                                         guint property_id,
                                         const GValue * value,
                                         GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static GType
g4_ellipsize_mode_get_type_once (void)
{
	static const GEnumValue values[] = {{G4_ELLIPSIZE_MODE_NONE, "G4_ELLIPSIZE_MODE_NONE", "none"}, {G4_ELLIPSIZE_MODE_START, "G4_ELLIPSIZE_MODE_START", "start"}, {G4_ELLIPSIZE_MODE_MIDDLE, "G4_ELLIPSIZE_MODE_MIDDLE", "middle"}, {G4_ELLIPSIZE_MODE_END, "G4_ELLIPSIZE_MODE_END", "end"}, {G4_ELLIPSIZE_MODE_MARQUEE, "G4_ELLIPSIZE_MODE_MARQUEE", "marquee"}, {0, NULL, NULL}};
	GType g4_ellipsize_mode_type_id;
	g4_ellipsize_mode_type_id = g_enum_register_static ("G4EllipsizeMode", values);
	return g4_ellipsize_mode_type_id;
}

GType
g4_ellipsize_mode_get_type (void)
{
	static volatile gsize g4_ellipsize_mode_type_id__once = 0;
	if (g_once_init_enter (&g4_ellipsize_mode_type_id__once)) {
		GType g4_ellipsize_mode_type_id;
		g4_ellipsize_mode_type_id = g4_ellipsize_mode_get_type_once ();
		g_once_init_leave (&g4_ellipsize_mode_type_id__once, g4_ellipsize_mode_type_id);
	}
	return g4_ellipsize_mode_type_id__once;
}

static inline gpointer
g4_stable_label_get_instance_private (G4StableLabel* self)
{
	return G_STRUCT_MEMBER_P (self, G4StableLabel_private_offset);
}

static void
g4_stable_label_real_measure (GtkWidget* base,
                              GtkOrientation orientation,
                              gint for_size,
                              gint* minimum,
                              gint* natural,
                              gint* minimum_baseline,
                              gint* natural_baseline)
{
	G4StableLabel * self;
	gint _vala_minimum = 0;
	gint _vala_natural = 0;
	gint _vala_minimum_baseline = 0;
	gint _vala_natural_baseline = 0;
	self = (G4StableLabel*) base;
	if (orientation == GTK_ORIENTATION_VERTICAL) {
		gchar* text = NULL;
		GtkLabel* _tmp0_;
		const gchar* _tmp1_;
		const gchar* _tmp2_;
		gchar* _tmp3_;
		GtkLabel* _tmp4_;
		GtkLabel* _tmp5_;
		gint _tmp6_ = 0;
		gint _tmp7_ = 0;
		gint _tmp8_ = 0;
		gint _tmp9_ = 0;
		GtkLabel* _tmp10_;
		const gchar* _tmp11_;
		_tmp0_ = self->priv->_label;
		_tmp1_ = gtk_label_get_label (_tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = g_strdup (_tmp2_);
		text = _tmp3_;
		_tmp4_ = self->priv->_label;
		gtk_label_set_label (_tmp4_, "A中");
		_tmp5_ = self->priv->_label;
		gtk_widget_measure ((GtkWidget*) _tmp5_, orientation, for_size, &_tmp6_, &_tmp7_, &_tmp8_, &_tmp9_);
		_vala_minimum = _tmp6_;
		_vala_natural = _tmp7_;
		_vala_minimum_baseline = _tmp8_;
		_vala_natural_baseline = _tmp9_;
		_tmp10_ = self->priv->_label;
		_tmp11_ = text;
		gtk_label_set_label (_tmp10_, _tmp11_);
		_g_free0 (text);
	} else {
		GtkLabel* _tmp12_;
		gint _tmp13_ = 0;
		gint _tmp14_ = 0;
		gint _tmp15_ = 0;
		gint _tmp16_ = 0;
		gboolean _tmp17_;
		gboolean _tmp18_;
		_tmp12_ = self->priv->_label;
		gtk_widget_measure ((GtkWidget*) _tmp12_, orientation, for_size, &_tmp13_, &_tmp14_, &_tmp15_, &_tmp16_);
		_vala_minimum = _tmp13_;
		_vala_natural = _tmp14_;
		_vala_minimum_baseline = _tmp15_;
		_vala_natural_baseline = _tmp16_;
		self->priv->_label_width = _vala_natural;
		_tmp17_ = g4_stable_label_get_marquee (self);
		_tmp18_ = _tmp17_;
		if (_tmp18_) {
			_vala_minimum = 0;
		}
	}
	if (minimum) {
		*minimum = _vala_minimum;
	}
	if (natural) {
		*natural = _vala_natural;
	}
	if (minimum_baseline) {
		*minimum_baseline = _vala_minimum_baseline;
	}
	if (natural_baseline) {
		*natural_baseline = _vala_natural_baseline;
	}
}

static void
g4_stable_label_real_size_allocate (GtkWidget* base,
                                    gint width,
                                    gint height,
                                    gint baseline)
{
	G4StableLabel * self;
	GtkAllocation allocation = {0};
	GtkLabel* _tmp0_;
	GtkAllocation _tmp1_;
	self = (G4StableLabel*) base;
	memset (&allocation, 0, sizeof (GtkAllocation));
	allocation.x = 0;
	allocation.y = 0;
	allocation.width = width;
	allocation.height = height;
	_tmp0_ = self->priv->_label;
	_tmp1_ = allocation;
	gtk_widget_size_allocate ((GtkWidget*) _tmp0_, &_tmp1_, baseline);
	g4_stable_label_update_tick_delayed (self);
}

static void
g4_stable_label_real_snapshot (GtkWidget* base,
                               GtkSnapshot* snapshot)
{
	G4StableLabel * self;
	gint width = 0;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_;
	gboolean _tmp2_;
	gboolean overflow = FALSE;
	self = (G4StableLabel*) base;
	g_return_if_fail (snapshot != NULL);
	width = gtk_widget_get_width ((GtkWidget*) self);
	_tmp1_ = g4_stable_label_get_marquee (self);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		_tmp0_ = width < self->priv->_label_width;
	} else {
		_tmp0_ = FALSE;
	}
	overflow = _tmp0_;
	if (overflow) {
		gint height = 0;
		gfloat total_width = 0.0F;
		gfloat mask_width = 0.0F;
		gfloat _tmp3_ = 0.0F;
		gfloat left_mask = 0.0F;
		graphene_rect_t rect = {0};
		GskColorStop* stops = NULL;
		GdkRGBA _tmp5_ = {0};
		GskColorStop _tmp6_ = {0};
		GdkRGBA _tmp7_ = {0};
		GskColorStop _tmp8_ = {0};
		GskColorStop* _tmp9_;
		gint stops_length1;
		gint _stops_size_;
		graphene_rect_t _tmp10_;
		graphene_point_t _tmp11_ = {0};
		graphene_point_t _tmp12_ = {0};
		GskColorStop* _tmp13_;
		gint _tmp13__length1;
		graphene_rect_t _tmp14_;
		graphene_point_t _tmp15_ = {0};
		graphene_point_t _tmp16_ = {0};
		GskColorStop* _tmp17_;
		gint _tmp17__length1;
		graphene_rect_t bounds = {0};
		graphene_rect_t _tmp18_;
		graphene_point_t point = {0};
		height = gtk_widget_get_height ((GtkWidget*) self);
		total_width = self->priv->_label_width + g4_stable_label_SPACE;
		mask_width = MIN (width * 0.1f, height * 1.25f);
		if (self->priv->_label_offset < mask_width) {
			_tmp3_ = self->priv->_label_offset;
		} else {
			gfloat _tmp4_ = 0.0F;
			if ((self->priv->_label_offset + mask_width) > total_width) {
				_tmp4_ = (gfloat) 0;
			} else {
				_tmp4_ = mask_width;
			}
			_tmp3_ = _tmp4_;
		}
		left_mask = _tmp3_;
		memset (&rect, 0, sizeof (graphene_rect_t));
		graphene_rect_init (&rect, (gfloat) 0, (gfloat) 0, left_mask, (gfloat) height);
		g4_color_from_uint (0xff000000U, &_tmp5_);
		memset (&_tmp6_, 0, sizeof (GskColorStop));
		_tmp6_.offset = (gfloat) 0;
		_tmp6_.color = _tmp5_;
		g4_color_from_uint (0x00000000U, &_tmp7_);
		memset (&_tmp8_, 0, sizeof (GskColorStop));
		_tmp8_.offset = (gfloat) 1;
		_tmp8_.color = _tmp7_;
		_tmp9_ = g_new0 (GskColorStop, 2);
		_tmp9_[0] = _tmp6_;
		_tmp9_[1] = _tmp8_;
		stops = _tmp9_;
		stops_length1 = 2;
		_stops_size_ = stops_length1;
		gtk_snapshot_push_mask (snapshot, GSK_MASK_MODE_INVERTED_ALPHA);
		_tmp10_ = rect;
		graphene_rect_get_top_left (&rect, &_tmp11_);
		graphene_rect_get_top_right (&rect, &_tmp12_);
		_tmp13_ = stops;
		_tmp13__length1 = stops_length1;
		gtk_snapshot_append_linear_gradient (snapshot, &_tmp10_, &_tmp11_, &_tmp12_, _tmp13_, (gsize) _tmp13__length1);
		graphene_rect_init (&rect, width - mask_width, (gfloat) 0, mask_width, (gfloat) height);
		_tmp14_ = rect;
		graphene_rect_get_top_right (&rect, &_tmp15_);
		graphene_rect_get_top_left (&rect, &_tmp16_);
		_tmp17_ = stops;
		_tmp17__length1 = stops_length1;
		gtk_snapshot_append_linear_gradient (snapshot, &_tmp14_, &_tmp15_, &_tmp16_, _tmp17_, (gsize) _tmp17__length1);
		gtk_snapshot_pop (snapshot);
		memset (&bounds, 0, sizeof (graphene_rect_t));
		graphene_rect_init (&bounds, (gfloat) 0, (gfloat) 0, (gfloat) width, (gfloat) height);
		_tmp18_ = bounds;
		gtk_snapshot_push_clip (snapshot, &_tmp18_);
		memset (&point, 0, sizeof (graphene_point_t));
		graphene_point_init (&point, (gfloat) 0, (gfloat) 0);
		if (self->priv->_label_offset < ((gfloat) self->priv->_label_width)) {
			graphene_point_t _tmp19_;
			graphene_point_t _tmp20_;
			graphene_point_t _tmp21_;
			point.x = -self->priv->_label_offset;
			_tmp19_ = point;
			gtk_snapshot_translate (snapshot, &_tmp19_);
			GTK_WIDGET_CLASS (g4_stable_label_parent_class)->snapshot (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), snapshot);
			_tmp20_ = point;
			point.x = -_tmp20_.x;
			_tmp21_ = point;
			gtk_snapshot_translate (snapshot, &_tmp21_);
		}
		if (self->priv->_label_offset >= (total_width - width)) {
			graphene_point_t _tmp22_;
			graphene_point_t _tmp23_;
			graphene_point_t _tmp24_;
			point.x = (-self->priv->_label_offset) + total_width;
			_tmp22_ = point;
			gtk_snapshot_translate (snapshot, &_tmp22_);
			GTK_WIDGET_CLASS (g4_stable_label_parent_class)->snapshot (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), snapshot);
			_tmp23_ = point;
			point.x = -_tmp23_.x;
			_tmp24_ = point;
			gtk_snapshot_translate (snapshot, &_tmp24_);
		}
		gtk_snapshot_pop (snapshot);
		gtk_snapshot_pop (snapshot);
		stops = (g_free (stops), NULL);
	} else {
		GTK_WIDGET_CLASS (g4_stable_label_parent_class)->snapshot (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), snapshot);
	}
}

static gboolean
g4_stable_label_on_tick_callback (G4StableLabel* self,
                                  GtkWidget* widget,
                                  GdkFrameClock* clock)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (widget != NULL, FALSE);
	g_return_val_if_fail (clock != NULL, FALSE);
	if (self->priv->_tick_moving) {
		gint64 now = 0LL;
		gfloat elapsed = 0.0F;
		now = g_get_monotonic_time ();
		elapsed = (now - self->priv->_tick_start_time) / 1e6f;
		self->priv->_label_offset = elapsed * self->priv->_pixels_per_second;
		if (self->priv->_label_offset > (self->priv->_label_width + g4_stable_label_SPACE)) {
			g4_stable_label_stop_tick (self);
			g4_stable_label_update_tick_delayed (self);
		}
		gtk_widget_queue_draw ((GtkWidget*) self);
	}
	result = TRUE;
	return result;
}

static void
g4_stable_label_stop_tick (G4StableLabel* self)
{
	g_return_if_fail (self != NULL);
	if (self->priv->_tick_handler != ((guint) 0)) {
		gtk_widget_remove_tick_callback ((GtkWidget*) self, self->priv->_tick_handler);
		self->priv->_tick_handler = (guint) 0;
	}
	if (self->priv->_timer_id != ((guint) 0)) {
		g_source_remove (self->priv->_timer_id);
		self->priv->_timer_id = (guint) 0;
	}
	self->priv->_label_offset = (gfloat) 0;
	self->priv->_tick_moving = FALSE;
}

static gboolean
_g4_stable_label_on_tick_callback_gtk_tick_callback (GtkWidget* widget,
                                                     GdkFrameClock* frame_clock,
                                                     gpointer self)
{
	gboolean result;
	result = g4_stable_label_on_tick_callback ((G4StableLabel*) self, widget, frame_clock);
	return result;
}

static void
g4_stable_label_update_tick (G4StableLabel* self)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_;
	gboolean _tmp2_;
	gboolean need_tick = FALSE;
	gboolean _tmp3_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp1_ = g4_stable_label_get_marquee (self);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		_tmp0_ = gtk_widget_get_width ((GtkWidget*) self) < self->priv->_label_width;
	} else {
		_tmp0_ = FALSE;
	}
	need_tick = _tmp0_;
	if (need_tick) {
		_tmp3_ = self->priv->_tick_handler == ((guint) 0);
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		self->priv->_tick_handler = gtk_widget_add_tick_callback ((GtkWidget*) self, _g4_stable_label_on_tick_callback_gtk_tick_callback, g_object_ref (self), g_object_unref);
		self->priv->_tick_moving = self->priv->_tick_handler != ((guint) 0);
		self->priv->_tick_start_time = g_get_monotonic_time ();
	} else {
		gboolean _tmp4_ = FALSE;
		if (!need_tick) {
			_tmp4_ = self->priv->_tick_handler != ((guint) 0);
		} else {
			_tmp4_ = FALSE;
		}
		if (_tmp4_) {
			g4_stable_label_stop_tick (self);
		}
	}
}

static void
___lambda54_ (G4StableLabel* self)
{
	self->priv->_timer_id = (guint) 0;
	g4_stable_label_update_tick (self);
}

static void
____lambda54__g4_void_func (gpointer self)
{
	___lambda54_ ((G4StableLabel*) self);
}

static void
g4_stable_label_update_tick_delayed (G4StableLabel* self)
{
	g_return_if_fail (self != NULL);
	if (self->priv->_timer_id == ((guint) 0)) {
		self->priv->_timer_id = g4_run_timeout_once (g4_stable_label_TICK_WAIT, ____lambda54__g4_void_func, g_object_ref (self), g_object_unref);
	}
}

G4StableLabel*
g4_stable_label_construct (GType object_type)
{
	G4StableLabel * self = NULL;
	self = (G4StableLabel*) g_object_new (object_type, NULL);
	return self;
}

G4StableLabel*
g4_stable_label_new (void)
{
	return g4_stable_label_construct (G4_TYPE_STABLE_LABEL);
}

G4EllipsizeMode
g4_stable_label_get_ellipsize (G4StableLabel* self)
{
	G4EllipsizeMode result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_ellipsize;
	return result;
}

void
g4_stable_label_set_ellipsize (G4StableLabel* self,
                               G4EllipsizeMode value)
{
	PangoEllipsizeMode _tmp0_ = 0;
	GtkLabel* _tmp1_;
	g_return_if_fail (self != NULL);
	self->priv->_ellipsize = value;
	if (value == G4_ELLIPSIZE_MODE_MARQUEE) {
		_tmp0_ = PANGO_ELLIPSIZE_NONE;
	} else {
		_tmp0_ = (PangoEllipsizeMode) value;
	}
	_tmp1_ = self->priv->_label;
	gtk_label_set_ellipsize (_tmp1_, _tmp0_);
	g4_stable_label_stop_tick (self);
	g_object_notify_by_pspec ((GObject *) self, g4_stable_label_properties[G4_STABLE_LABEL_ELLIPSIZE_PROPERTY]);
}

const gchar*
g4_stable_label_get_label (G4StableLabel* self)
{
	const gchar* result;
	GtkLabel* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_label;
	_tmp1_ = gtk_label_get_label (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

void
g4_stable_label_set_label (G4StableLabel* self,
                           const gchar* value)
{
	GtkLabel* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_label;
	gtk_label_set_label (_tmp0_, value);
	g4_stable_label_stop_tick (self);
	g_object_notify_by_pspec ((GObject *) self, g4_stable_label_properties[G4_STABLE_LABEL_LABEL_PROPERTY]);
}

gboolean
g4_stable_label_get_marquee (G4StableLabel* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_ellipsize == G4_ELLIPSIZE_MODE_MARQUEE;
	return result;
}

void
g4_stable_label_set_marquee (G4StableLabel* self,
                             gboolean value)
{
	G4EllipsizeMode _tmp0_ = 0;
	g_return_if_fail (self != NULL);
	if (value) {
		_tmp0_ = G4_ELLIPSIZE_MODE_MARQUEE;
	} else {
		_tmp0_ = G4_ELLIPSIZE_MODE_NONE;
	}
	g4_stable_label_set_ellipsize (self, _tmp0_);
	g_object_notify_by_pspec ((GObject *) self, g4_stable_label_properties[G4_STABLE_LABEL_MARQUEE_PROPERTY]);
}

static GObject *
g4_stable_label_constructor (GType type,
                             guint n_construct_properties,
                             GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	G4StableLabel * self;
	GtkLabel* _tmp0_;
	GtkLabel* _tmp1_;
	parent_class = G_OBJECT_CLASS (g4_stable_label_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, G4_TYPE_STABLE_LABEL, G4StableLabel);
	_tmp0_ = self->priv->_label;
	gtk_label_set_xalign (_tmp0_, (gfloat) 0);
	_tmp1_ = self->priv->_label;
	gtk_widget_set_parent ((GtkWidget*) _tmp1_, (GtkWidget*) self);
	return obj;
}

static void
g4_stable_label_class_init (G4StableLabelClass * klass,
                            gpointer klass_data)
{
	g4_stable_label_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &G4StableLabel_private_offset);
	((GtkWidgetClass *) klass)->measure = (void (*) (GtkWidget*, GtkOrientation, gint, gint*, gint*, gint*, gint*)) g4_stable_label_real_measure;
	((GtkWidgetClass *) klass)->size_allocate = (void (*) (GtkWidget*, gint, gint, gint)) g4_stable_label_real_size_allocate;
	((GtkWidgetClass *) klass)->snapshot = (void (*) (GtkWidget*, GtkSnapshot*)) g4_stable_label_real_snapshot;
	G_OBJECT_CLASS (klass)->get_property = _vala_g4_stable_label_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_g4_stable_label_set_property;
	G_OBJECT_CLASS (klass)->constructor = g4_stable_label_constructor;
	G_OBJECT_CLASS (klass)->finalize = g4_stable_label_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), G4_STABLE_LABEL_ELLIPSIZE_PROPERTY, g4_stable_label_properties[G4_STABLE_LABEL_ELLIPSIZE_PROPERTY] = g_param_spec_enum ("ellipsize", "ellipsize", "ellipsize", G4_TYPE_ELLIPSIZE_MODE, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), G4_STABLE_LABEL_LABEL_PROPERTY, g4_stable_label_properties[G4_STABLE_LABEL_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), G4_STABLE_LABEL_MARQUEE_PROPERTY, g4_stable_label_properties[G4_STABLE_LABEL_MARQUEE_PROPERTY] = g_param_spec_boolean ("marquee", "marquee", "marquee", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
g4_stable_label_instance_init (G4StableLabel * self,
                               gpointer klass)
{
	GtkLabel* _tmp0_;
	self->priv = g4_stable_label_get_instance_private (self);
	self->priv->_ellipsize = G4_ELLIPSIZE_MODE_NONE;
	_tmp0_ = (GtkLabel*) gtk_label_new (NULL);
	g_object_ref_sink (_tmp0_);
	self->priv->_label = _tmp0_;
	self->priv->_label_offset = (gfloat) 0;
	self->priv->_label_width = 0;
	self->priv->_pixels_per_second = (guint) 24;
	self->priv->_tick_handler = (guint) 0;
	self->priv->_tick_moving = FALSE;
	self->priv->_tick_start_time = (gint64) 0;
	self->priv->_timer_id = (guint) 0;
}

static void
g4_stable_label_finalize (GObject * obj)
{
	G4StableLabel * self;
	GtkLabel* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, G4_TYPE_STABLE_LABEL, G4StableLabel);
	_tmp0_ = self->priv->_label;
	gtk_widget_unparent ((GtkWidget*) _tmp0_);
	_g_object_unref0 (self->priv->_label);
	G_OBJECT_CLASS (g4_stable_label_parent_class)->finalize (obj);
}

static GType
g4_stable_label_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (G4StableLabelClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) g4_stable_label_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (G4StableLabel), 0, (GInstanceInitFunc) g4_stable_label_instance_init, NULL };
	GType g4_stable_label_type_id;
	g4_stable_label_type_id = g_type_register_static (gtk_widget_get_type (), "G4StableLabel", &g_define_type_info, 0);
	G4StableLabel_private_offset = g_type_add_instance_private (g4_stable_label_type_id, sizeof (G4StableLabelPrivate));
	return g4_stable_label_type_id;
}

GType
g4_stable_label_get_type (void)
{
	static volatile gsize g4_stable_label_type_id__once = 0;
	if (g_once_init_enter (&g4_stable_label_type_id__once)) {
		GType g4_stable_label_type_id;
		g4_stable_label_type_id = g4_stable_label_get_type_once ();
		g_once_init_leave (&g4_stable_label_type_id__once, g4_stable_label_type_id);
	}
	return g4_stable_label_type_id__once;
}

static void
_vala_g4_stable_label_get_property (GObject * object,
                                    guint property_id,
                                    GValue * value,
                                    GParamSpec * pspec)
{
	G4StableLabel * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, G4_TYPE_STABLE_LABEL, G4StableLabel);
	switch (property_id) {
		case G4_STABLE_LABEL_ELLIPSIZE_PROPERTY:
		g_value_set_enum (value, g4_stable_label_get_ellipsize (self));
		break;
		case G4_STABLE_LABEL_LABEL_PROPERTY:
		g_value_set_string (value, g4_stable_label_get_label (self));
		break;
		case G4_STABLE_LABEL_MARQUEE_PROPERTY:
		g_value_set_boolean (value, g4_stable_label_get_marquee (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_g4_stable_label_set_property (GObject * object,
                                    guint property_id,
                                    const GValue * value,
                                    GParamSpec * pspec)
{
	G4StableLabel * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, G4_TYPE_STABLE_LABEL, G4StableLabel);
	switch (property_id) {
		case G4_STABLE_LABEL_ELLIPSIZE_PROPERTY:
		g4_stable_label_set_ellipsize (self, g_value_get_enum (value));
		break;
		case G4_STABLE_LABEL_LABEL_PROPERTY:
		g4_stable_label_set_label (self, g_value_get_string (value));
		break;
		case G4_STABLE_LABEL_MARQUEE_PROPERTY:
		g4_stable_label_set_marquee (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

