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

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.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 G4_TYPE_NARROW_BAR (g4_narrow_bar_get_type ())
#define G4_NARROW_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G4_TYPE_NARROW_BAR, G4NarrowBar))
#define G4_NARROW_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), G4_TYPE_NARROW_BAR, G4NarrowBarClass))
#define G4_IS_NARROW_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G4_TYPE_NARROW_BAR))
#define G4_IS_NARROW_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), G4_TYPE_NARROW_BAR))
#define G4_NARROW_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), G4_TYPE_NARROW_BAR, G4NarrowBarClass))

typedef struct _G4NarrowBar G4NarrowBar;
typedef struct _G4NarrowBarClass G4NarrowBarClass;
typedef struct _G4NarrowBarPrivate G4NarrowBarPrivate;
enum  {
	G4_NARROW_BAR_0_PROPERTY,
	G4_NARROW_BAR_CHILD_PROPERTY,
	G4_NARROW_BAR_REVEAL_PROPERTY,
	G4_NARROW_BAR_NUM_PROPERTIES
};
static GParamSpec* g4_narrow_bar_properties[G4_NARROW_BAR_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _G4NarrowBar {
	GtkWidget parent_instance;
	G4NarrowBarPrivate * priv;
};

struct _G4NarrowBarClass {
	GtkWidgetClass parent_class;
};

struct _G4NarrowBarPrivate {
	GtkWidget* _child;
	gint _minimum_width;
	gboolean _reveal;
};

static gint G4NarrowBar_private_offset;
static gpointer g4_narrow_bar_parent_class = NULL;

VALA_EXTERN GType g4_narrow_bar_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (G4NarrowBar, g_object_unref)
static void g4_narrow_bar_real_measure (GtkWidget* base,
                                 GtkOrientation orientation,
                                 gint for_size,
                                 gint* minimum,
                                 gint* natural,
                                 gint* minimum_baseline,
                                 gint* natural_baseline);
static void g4_narrow_bar_real_size_allocate (GtkWidget* base,
                                       gint width,
                                       gint height,
                                       gint baseline);
VALA_EXTERN G4NarrowBar* g4_narrow_bar_new (void);
VALA_EXTERN G4NarrowBar* g4_narrow_bar_construct (GType object_type);
VALA_EXTERN GtkWidget* g4_narrow_bar_get_child (G4NarrowBar* self);
VALA_EXTERN void g4_narrow_bar_set_child (G4NarrowBar* self,
                              GtkWidget* value);
VALA_EXTERN gboolean g4_narrow_bar_get_reveal (G4NarrowBar* self);
VALA_EXTERN void g4_narrow_bar_set_reveal (G4NarrowBar* self,
                               gboolean value);
static void g4_narrow_bar_finalize (GObject * obj);
static GType g4_narrow_bar_get_type_once (void);
static void _vala_g4_narrow_bar_get_property (GObject * object,
                                       guint property_id,
                                       GValue * value,
                                       GParamSpec * pspec);
static void _vala_g4_narrow_bar_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
g4_narrow_bar_get_instance_private (G4NarrowBar* self)
{
	return G_STRUCT_MEMBER_P (self, G4NarrowBar_private_offset);
}

static void
g4_narrow_bar_real_measure (GtkWidget* base,
                            GtkOrientation orientation,
                            gint for_size,
                            gint* minimum,
                            gint* natural,
                            gint* minimum_baseline,
                            gint* natural_baseline)
{
	G4NarrowBar * self;
	gint _vala_minimum = 0;
	gint _vala_natural = 0;
	gint _vala_minimum_baseline = 0;
	gint _vala_natural_baseline = 0;
	GtkWidget* _tmp0_;
	self = (G4NarrowBar*) base;
	_tmp0_ = self->priv->_child;
	if (_tmp0_ != NULL) {
		GtkWidget* _tmp1_;
		gint _tmp2_ = 0;
		gint _tmp3_ = 0;
		gint _tmp4_ = 0;
		gint _tmp5_ = 0;
		_tmp1_ = self->priv->_child;
		gtk_widget_measure (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_widget_get_type (), GtkWidget), orientation, for_size, &_tmp2_, &_tmp3_, &_tmp4_, &_tmp5_);
		_vala_minimum = _tmp2_;
		_vala_natural = _tmp3_;
		_vala_minimum_baseline = _tmp4_;
		_vala_natural_baseline = _tmp5_;
	} else {
		_vala_natural_baseline = 0;
		_vala_minimum_baseline = _vala_natural_baseline;
		_vala_natural = _vala_minimum_baseline;
		_vala_minimum = _vala_natural;
	}
	if (orientation == GTK_ORIENTATION_HORIZONTAL) {
		self->priv->_minimum_width = _vala_minimum;
		_vala_minimum = self->priv->_minimum_width / 2;
	}
	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_narrow_bar_real_size_allocate (GtkWidget* base,
                                  gint width,
                                  gint height,
                                  gint baseline)
{
	G4NarrowBar * self;
	gboolean wide = FALSE;
	GtkWidget* _tmp16_;
	self = (G4NarrowBar*) base;
	wide = width >= self->priv->_minimum_width;
	if (self->priv->_reveal != wide) {
		gboolean _tmp0_ = FALSE;
		self->priv->_reveal = wide;
		g_object_notify ((GObject*) self, "reveal");
		if (wide) {
			GtkWidget* _tmp1_ = NULL;
			GtkWidget* _tmp2_;
			GtkWidget* _tmp3_ = NULL;
			_tmp2_ = self->priv->_child;
			_tmp1_ = _tmp2_;
			_tmp3_ = NULL;
			if (_tmp1_ != NULL) {
				GtkWidget* _tmp4_;
				GtkWidget* _tmp5_;
				_tmp4_ = gtk_widget_get_parent (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_widget_get_type (), GtkWidget));
				_tmp5_ = _tmp4_;
				_tmp3_ = _tmp5_;
			}
			_tmp0_ = _tmp3_ == NULL;
		} else {
			_tmp0_ = FALSE;
		}
		if (_tmp0_) {
			GtkWidget* _tmp6_ = NULL;
			GtkWidget* _tmp7_;
			_tmp7_ = self->priv->_child;
			_tmp6_ = _tmp7_;
			if (_tmp6_ != NULL) {
				gtk_widget_set_parent (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, gtk_widget_get_type (), GtkWidget), (GtkWidget*) self);
			}
		} else {
			gboolean _tmp8_ = FALSE;
			if (!wide) {
				GtkWidget* _tmp9_ = NULL;
				GtkWidget* _tmp10_;
				GtkWidget* _tmp11_ = NULL;
				_tmp10_ = self->priv->_child;
				_tmp9_ = _tmp10_;
				_tmp11_ = NULL;
				if (_tmp9_ != NULL) {
					GtkWidget* _tmp12_;
					GtkWidget* _tmp13_;
					_tmp12_ = gtk_widget_get_parent (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, gtk_widget_get_type (), GtkWidget));
					_tmp13_ = _tmp12_;
					_tmp11_ = _tmp13_;
				}
				_tmp8_ = _tmp11_ != NULL;
			} else {
				_tmp8_ = FALSE;
			}
			if (_tmp8_) {
				GtkWidget* _tmp14_ = NULL;
				GtkWidget* _tmp15_;
				_tmp15_ = self->priv->_child;
				_tmp14_ = _tmp15_;
				if (_tmp14_ != NULL) {
					gtk_widget_unparent (G_TYPE_CHECK_INSTANCE_CAST (_tmp14_, gtk_widget_get_type (), GtkWidget));
				}
			}
		}
	}
	_tmp16_ = self->priv->_child;
	if (_tmp16_ != NULL) {
		GtkAllocation allocation = {0};
		GtkWidget* _tmp17_;
		GtkAllocation _tmp18_;
		memset (&allocation, 0, sizeof (GtkAllocation));
		allocation.x = 0;
		allocation.y = 0;
		allocation.width = width;
		allocation.height = height;
		_tmp17_ = self->priv->_child;
		_tmp18_ = allocation;
		gtk_widget_size_allocate (G_TYPE_CHECK_INSTANCE_CAST (_tmp17_, gtk_widget_get_type (), GtkWidget), &_tmp18_, baseline);
	}
}

G4NarrowBar*
g4_narrow_bar_construct (GType object_type)
{
	G4NarrowBar * self = NULL;
	self = (G4NarrowBar*) g_object_new (object_type, NULL);
	return self;
}

G4NarrowBar*
g4_narrow_bar_new (void)
{
	return g4_narrow_bar_construct (G4_TYPE_NARROW_BAR);
}

GtkWidget*
g4_narrow_bar_get_child (G4NarrowBar* self)
{
	GtkWidget* result;
	GtkWidget* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_child;
	result = _tmp0_;
	return result;
}

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

void
g4_narrow_bar_set_child (G4NarrowBar* self,
                         GtkWidget* value)
{
	GtkWidget* _tmp0_ = NULL;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp3_ = NULL;
	GtkWidget* _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->_child;
	_tmp0_ = _tmp1_;
	if (_tmp0_ != NULL) {
		gtk_widget_unparent (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gtk_widget_get_type (), GtkWidget));
	}
	_tmp2_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_child);
	self->priv->_child = _tmp2_;
	_tmp4_ = self->priv->_child;
	_tmp3_ = _tmp4_;
	if (_tmp3_ != NULL) {
		gtk_widget_set_parent (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, gtk_widget_get_type (), GtkWidget), (GtkWidget*) self);
	}
	gtk_widget_queue_allocate ((GtkWidget*) self);
	g_object_notify_by_pspec ((GObject *) self, g4_narrow_bar_properties[G4_NARROW_BAR_CHILD_PROPERTY]);
}

gboolean
g4_narrow_bar_get_reveal (G4NarrowBar* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_reveal;
	return result;
}

void
g4_narrow_bar_set_reveal (G4NarrowBar* self,
                          gboolean value)
{
	g_return_if_fail (self != NULL);
	self->priv->_reveal = value;
	gtk_widget_queue_allocate ((GtkWidget*) self);
	g_object_notify_by_pspec ((GObject *) self, g4_narrow_bar_properties[G4_NARROW_BAR_REVEAL_PROPERTY]);
}

static void
g4_narrow_bar_class_init (G4NarrowBarClass * klass,
                          gpointer klass_data)
{
	g4_narrow_bar_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &G4NarrowBar_private_offset);
	((GtkWidgetClass *) klass)->measure = (void (*) (GtkWidget*, GtkOrientation, gint, gint*, gint*, gint*, gint*)) g4_narrow_bar_real_measure;
	((GtkWidgetClass *) klass)->size_allocate = (void (*) (GtkWidget*, gint, gint, gint)) g4_narrow_bar_real_size_allocate;
	G_OBJECT_CLASS (klass)->get_property = _vala_g4_narrow_bar_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_g4_narrow_bar_set_property;
	G_OBJECT_CLASS (klass)->finalize = g4_narrow_bar_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), G4_NARROW_BAR_CHILD_PROPERTY, g4_narrow_bar_properties[G4_NARROW_BAR_CHILD_PROPERTY] = g_param_spec_object ("child", "child", "child", gtk_widget_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), G4_NARROW_BAR_REVEAL_PROPERTY, g4_narrow_bar_properties[G4_NARROW_BAR_REVEAL_PROPERTY] = g_param_spec_boolean ("reveal", "reveal", "reveal", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
g4_narrow_bar_instance_init (G4NarrowBar * self,
                             gpointer klass)
{
	self->priv = g4_narrow_bar_get_instance_private (self);
	self->priv->_child = NULL;
	self->priv->_minimum_width = 0;
	self->priv->_reveal = TRUE;
}

static void
g4_narrow_bar_finalize (GObject * obj)
{
	G4NarrowBar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, G4_TYPE_NARROW_BAR, G4NarrowBar);
	_g_object_unref0 (self->priv->_child);
	G_OBJECT_CLASS (g4_narrow_bar_parent_class)->finalize (obj);
}

static GType
g4_narrow_bar_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (G4NarrowBarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) g4_narrow_bar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (G4NarrowBar), 0, (GInstanceInitFunc) g4_narrow_bar_instance_init, NULL };
	GType g4_narrow_bar_type_id;
	g4_narrow_bar_type_id = g_type_register_static (gtk_widget_get_type (), "G4NarrowBar", &g_define_type_info, 0);
	G4NarrowBar_private_offset = g_type_add_instance_private (g4_narrow_bar_type_id, sizeof (G4NarrowBarPrivate));
	return g4_narrow_bar_type_id;
}

GType
g4_narrow_bar_get_type (void)
{
	static volatile gsize g4_narrow_bar_type_id__once = 0;
	if (g_once_init_enter (&g4_narrow_bar_type_id__once)) {
		GType g4_narrow_bar_type_id;
		g4_narrow_bar_type_id = g4_narrow_bar_get_type_once ();
		g_once_init_leave (&g4_narrow_bar_type_id__once, g4_narrow_bar_type_id);
	}
	return g4_narrow_bar_type_id__once;
}

static void
_vala_g4_narrow_bar_get_property (GObject * object,
                                  guint property_id,
                                  GValue * value,
                                  GParamSpec * pspec)
{
	G4NarrowBar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, G4_TYPE_NARROW_BAR, G4NarrowBar);
	switch (property_id) {
		case G4_NARROW_BAR_CHILD_PROPERTY:
		g_value_set_object (value, g4_narrow_bar_get_child (self));
		break;
		case G4_NARROW_BAR_REVEAL_PROPERTY:
		g_value_set_boolean (value, g4_narrow_bar_get_reveal (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_g4_narrow_bar_set_property (GObject * object,
                                  guint property_id,
                                  const GValue * value,
                                  GParamSpec * pspec)
{
	G4NarrowBar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, G4_TYPE_NARROW_BAR, G4NarrowBar);
	switch (property_id) {
		case G4_NARROW_BAR_CHILD_PROPERTY:
		g4_narrow_bar_set_child (self, g_value_get_object (value));
		break;
		case G4_NARROW_BAR_REVEAL_PROPERTY:
		g4_narrow_bar_set_reveal (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;
}

