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

/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 2 -*-
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 * SPDX-FileCopyrightText: Michael Terry
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <pango/pango.h>
#include <stdlib.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 TYPE_TOOLTIP_BOX (tooltip_box_get_type ())
#define TOOLTIP_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TOOLTIP_BOX, TooltipBox))
#define TOOLTIP_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TOOLTIP_BOX, TooltipBoxClass))
#define IS_TOOLTIP_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TOOLTIP_BOX))
#define IS_TOOLTIP_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TOOLTIP_BOX))
#define TOOLTIP_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TOOLTIP_BOX, TooltipBoxClass))

typedef struct _TooltipBox TooltipBox;
typedef struct _TooltipBoxClass TooltipBoxClass;
typedef struct _TooltipBoxPrivate TooltipBoxPrivate;
enum  {
	TOOLTIP_BOX_0_PROPERTY,
	TOOLTIP_BOX_LABEL_PROPERTY,
	TOOLTIP_BOX_NUM_PROPERTIES
};
static GParamSpec* tooltip_box_properties[TOOLTIP_BOX_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _TooltipBox {
	GtkBox parent_instance;
	TooltipBoxPrivate * priv;
};

struct _TooltipBoxClass {
	GtkBoxClass parent_class;
};

struct _TooltipBoxPrivate {
	GtkLabel* _label;
};

static gint TooltipBox_private_offset;
static gpointer tooltip_box_parent_class = NULL;

VALA_EXTERN GType tooltip_box_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TooltipBox, g_object_unref)
static gboolean tooltip_box_on_query_tooltip (TooltipBox* self,
                                       gint x,
                                       gint y,
                                       gboolean keyboard_mode,
                                       GtkTooltip* tooltip);
VALA_EXTERN GtkLabel* tooltip_box_get_label (TooltipBox* self);
VALA_EXTERN TooltipBox* tooltip_box_new (void);
VALA_EXTERN TooltipBox* tooltip_box_construct (GType object_type);
VALA_EXTERN void tooltip_box_set_label (TooltipBox* self,
                            GtkLabel* value);
static GObject * tooltip_box_constructor (GType type,
                                   guint n_construct_properties,
                                   GObjectConstructParam * construct_properties);
static gboolean _tooltip_box_on_query_tooltip_gtk_widget_query_tooltip (GtkWidget* _sender,
                                                                 gint x,
                                                                 gint y,
                                                                 gboolean keyboard_tooltip,
                                                                 GtkTooltip* tooltip,
                                                                 gpointer self);
static void tooltip_box_finalize (GObject * obj);
static GType tooltip_box_get_type_once (void);
static void _vala_tooltip_box_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec);
static void _vala_tooltip_box_set_property (GObject * object,
                                     guint property_id,
                                     const GValue * value,
                                     GParamSpec * pspec);

static inline gpointer
tooltip_box_get_instance_private (TooltipBox* self)
{
	return G_STRUCT_MEMBER_P (self, TooltipBox_private_offset);
}

static gboolean
tooltip_box_on_query_tooltip (TooltipBox* self,
                              gint x,
                              gint y,
                              gboolean keyboard_mode,
                              GtkTooltip* tooltip)
{
	gboolean _tmp0_ = FALSE;
	GtkLabel* _tmp1_;
	GtkLabel* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (tooltip != NULL, FALSE);
	_tmp1_ = self->priv->_label;
	if (_tmp1_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		GtkLabel* _tmp2_;
		PangoLayout* _tmp3_;
		_tmp2_ = self->priv->_label;
		_tmp3_ = gtk_label_get_layout (_tmp2_);
		_tmp0_ = !pango_layout_is_ellipsized (_tmp3_);
	}
	if (_tmp0_) {
		result = FALSE;
		return result;
	}
	_tmp4_ = self->priv->_label;
	_tmp5_ = gtk_label_get_label (_tmp4_);
	_tmp6_ = _tmp5_;
	gtk_tooltip_set_text (tooltip, _tmp6_);
	result = TRUE;
	return result;
}

TooltipBox*
tooltip_box_construct (GType object_type)
{
	TooltipBox * self = NULL;
	self = (TooltipBox*) g_object_new (object_type, NULL);
	return self;
}

TooltipBox*
tooltip_box_new (void)
{
	return tooltip_box_construct (TYPE_TOOLTIP_BOX);
}

GtkLabel*
tooltip_box_get_label (TooltipBox* self)
{
	GtkLabel* result;
	GtkLabel* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_label;
	result = _tmp0_;
	return result;
}

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

void
tooltip_box_set_label (TooltipBox* self,
                       GtkLabel* value)
{
	GtkLabel* old_value;
	g_return_if_fail (self != NULL);
	old_value = tooltip_box_get_label (self);
	if (old_value != value) {
		GtkLabel* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_label);
		self->priv->_label = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, tooltip_box_properties[TOOLTIP_BOX_LABEL_PROPERTY]);
	}
}

static gboolean
_tooltip_box_on_query_tooltip_gtk_widget_query_tooltip (GtkWidget* _sender,
                                                        gint x,
                                                        gint y,
                                                        gboolean keyboard_tooltip,
                                                        GtkTooltip* tooltip,
                                                        gpointer self)
{
	gboolean result;
	result = tooltip_box_on_query_tooltip ((TooltipBox*) self, x, y, keyboard_tooltip, tooltip);
	return result;
}

static GObject *
tooltip_box_constructor (GType type,
                         guint n_construct_properties,
                         GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	TooltipBox * self;
	parent_class = G_OBJECT_CLASS (tooltip_box_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_TOOLTIP_BOX, TooltipBox);
	gtk_widget_set_has_tooltip ((GtkWidget*) self, TRUE);
	g_signal_connect_object ((GtkWidget*) self, "query-tooltip", (GCallback) _tooltip_box_on_query_tooltip_gtk_widget_query_tooltip, self, 0);
	return obj;
}

static void
tooltip_box_class_init (TooltipBoxClass * klass,
                        gpointer klass_data)
{
	tooltip_box_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &TooltipBox_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_tooltip_box_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_tooltip_box_set_property;
	G_OBJECT_CLASS (klass)->constructor = tooltip_box_constructor;
	G_OBJECT_CLASS (klass)->finalize = tooltip_box_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), TOOLTIP_BOX_LABEL_PROPERTY, tooltip_box_properties[TOOLTIP_BOX_LABEL_PROPERTY] = g_param_spec_object ("label", "label", "label", gtk_label_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
tooltip_box_instance_init (TooltipBox * self,
                           gpointer klass)
{
	self->priv = tooltip_box_get_instance_private (self);
}

static void
tooltip_box_finalize (GObject * obj)
{
	TooltipBox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_TOOLTIP_BOX, TooltipBox);
	_g_object_unref0 (self->priv->_label);
	G_OBJECT_CLASS (tooltip_box_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
tooltip_box_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TooltipBoxClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tooltip_box_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TooltipBox), 0, (GInstanceInitFunc) tooltip_box_instance_init, NULL };
	GType tooltip_box_type_id;
	tooltip_box_type_id = g_type_register_static (gtk_box_get_type (), "TooltipBox", &g_define_type_info, 0);
	TooltipBox_private_offset = g_type_add_instance_private (tooltip_box_type_id, sizeof (TooltipBoxPrivate));
	return tooltip_box_type_id;
}

GType
tooltip_box_get_type (void)
{
	static gsize tooltip_box_type_id__once = 0;
	if (g_once_init_enter (&tooltip_box_type_id__once)) {
		GType tooltip_box_type_id;
		tooltip_box_type_id = tooltip_box_get_type_once ();
		g_once_init_leave (&tooltip_box_type_id__once, tooltip_box_type_id);
	}
	return tooltip_box_type_id__once;
}

static void
_vala_tooltip_box_get_property (GObject * object,
                                guint property_id,
                                GValue * value,
                                GParamSpec * pspec)
{
	TooltipBox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TOOLTIP_BOX, TooltipBox);
	switch (property_id) {
		case TOOLTIP_BOX_LABEL_PROPERTY:
		g_value_set_object (value, tooltip_box_get_label (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_tooltip_box_set_property (GObject * object,
                                guint property_id,
                                const GValue * value,
                                GParamSpec * pspec)
{
	TooltipBox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_TOOLTIP_BOX, TooltipBox);
	switch (property_id) {
		case TOOLTIP_BOX_LABEL_PROPERTY:
		tooltip_box_set_label (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

