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

#include <glib-object.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <float.h>
#include <math.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 PROTON_PLUS_WIDGETS_TYPE_SCROLL_CONTROLLER (proton_plus_widgets_scroll_controller_get_type ())
#define PROTON_PLUS_WIDGETS_SCROLL_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PROTON_PLUS_WIDGETS_TYPE_SCROLL_CONTROLLER, ProtonPlusWidgetsScrollController))
#define PROTON_PLUS_WIDGETS_SCROLL_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PROTON_PLUS_WIDGETS_TYPE_SCROLL_CONTROLLER, ProtonPlusWidgetsScrollControllerClass))
#define PROTON_PLUS_WIDGETS_IS_SCROLL_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PROTON_PLUS_WIDGETS_TYPE_SCROLL_CONTROLLER))
#define PROTON_PLUS_WIDGETS_IS_SCROLL_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PROTON_PLUS_WIDGETS_TYPE_SCROLL_CONTROLLER))
#define PROTON_PLUS_WIDGETS_SCROLL_CONTROLLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PROTON_PLUS_WIDGETS_TYPE_SCROLL_CONTROLLER, ProtonPlusWidgetsScrollControllerClass))

typedef struct _ProtonPlusWidgetsScrollController ProtonPlusWidgetsScrollController;
typedef struct _ProtonPlusWidgetsScrollControllerClass ProtonPlusWidgetsScrollControllerClass;
typedef struct _ProtonPlusWidgetsScrollControllerPrivate ProtonPlusWidgetsScrollControllerPrivate;
enum  {
	PROTON_PLUS_WIDGETS_SCROLL_CONTROLLER_0_PROPERTY,
	PROTON_PLUS_WIDGETS_SCROLL_CONTROLLER_NUM_PROPERTIES
};
static GParamSpec* proton_plus_widgets_scroll_controller_properties[PROTON_PLUS_WIDGETS_SCROLL_CONTROLLER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _ProtonPlusWidgetsScrollController {
	GObject parent_instance;
	ProtonPlusWidgetsScrollControllerPrivate * priv;
};

struct _ProtonPlusWidgetsScrollControllerClass {
	GObjectClass parent_class;
};

struct _ProtonPlusWidgetsScrollControllerPrivate {
	GtkAdjustment* vadjustment;
	gdouble saved_pos;
};

static gint ProtonPlusWidgetsScrollController_private_offset;
static gpointer proton_plus_widgets_scroll_controller_parent_class = NULL;

VALA_EXTERN GType proton_plus_widgets_scroll_controller_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ProtonPlusWidgetsScrollController, g_object_unref)
VALA_EXTERN ProtonPlusWidgetsScrollController* proton_plus_widgets_scroll_controller_new (GtkScrolledWindow* window);
VALA_EXTERN ProtonPlusWidgetsScrollController* proton_plus_widgets_scroll_controller_construct (GType object_type,
                                                                                    GtkScrolledWindow* window);
VALA_EXTERN void proton_plus_widgets_scroll_controller_save (ProtonPlusWidgetsScrollController* self);
VALA_EXTERN void proton_plus_widgets_scroll_controller_restore (ProtonPlusWidgetsScrollController* self,
                                                    gint delay_ms);
static gboolean __lambda21_ (ProtonPlusWidgetsScrollController* self);
static gboolean ___lambda21__gsource_func (gpointer self);
static void proton_plus_widgets_scroll_controller_finalize (GObject * obj);
static GType proton_plus_widgets_scroll_controller_get_type_once (void);

static inline gpointer
proton_plus_widgets_scroll_controller_get_instance_private (ProtonPlusWidgetsScrollController* self)
{
	return G_STRUCT_MEMBER_P (self, ProtonPlusWidgetsScrollController_private_offset);
}

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

ProtonPlusWidgetsScrollController*
proton_plus_widgets_scroll_controller_construct (GType object_type,
                                                 GtkScrolledWindow* window)
{
	ProtonPlusWidgetsScrollController * self = NULL;
	GtkAdjustment* _tmp0_;
	GtkAdjustment* _tmp1_;
	GtkAdjustment* _tmp2_;
	g_return_val_if_fail (window != NULL, NULL);
	self = (ProtonPlusWidgetsScrollController*) g_object_new (object_type, NULL);
	_tmp0_ = gtk_scrolled_window_get_vadjustment (window);
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->vadjustment);
	self->priv->vadjustment = _tmp1_;
	_tmp2_ = self->priv->vadjustment;
	if (_tmp2_ == NULL) {
		g_warning ("scroll-controller.vala:10: ScrollController: vadjustment is null – win" \
"dow not realized?");
	}
	return self;
}

ProtonPlusWidgetsScrollController*
proton_plus_widgets_scroll_controller_new (GtkScrolledWindow* window)
{
	return proton_plus_widgets_scroll_controller_construct (PROTON_PLUS_WIDGETS_TYPE_SCROLL_CONTROLLER, window);
}

void
proton_plus_widgets_scroll_controller_save (ProtonPlusWidgetsScrollController* self)
{
	GtkAdjustment* _tmp0_;
	GtkAdjustment* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->vadjustment;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = self->priv->vadjustment;
	self->priv->saved_pos = gtk_adjustment_get_value (_tmp1_);
}

static gboolean
__lambda21_ (ProtonPlusWidgetsScrollController* self)
{
	GtkAdjustment* _tmp0_;
	gboolean result;
	_tmp0_ = self->priv->vadjustment;
	gtk_adjustment_set_value (_tmp0_, self->priv->saved_pos);
	result = FALSE;
	return result;
}

static gboolean
___lambda21__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda21_ ((ProtonPlusWidgetsScrollController*) self);
	return result;
}

void
proton_plus_widgets_scroll_controller_restore (ProtonPlusWidgetsScrollController* self,
                                               gint delay_ms)
{
	GtkAdjustment* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->vadjustment;
	if (_tmp0_ == NULL) {
		return;
	}
	g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) delay_ms, ___lambda21__gsource_func, g_object_ref (self), g_object_unref);
}

static void
proton_plus_widgets_scroll_controller_class_init (ProtonPlusWidgetsScrollControllerClass * klass,
                                                  gpointer klass_data)
{
	proton_plus_widgets_scroll_controller_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ProtonPlusWidgetsScrollController_private_offset);
	G_OBJECT_CLASS (klass)->finalize = proton_plus_widgets_scroll_controller_finalize;
}

static void
proton_plus_widgets_scroll_controller_instance_init (ProtonPlusWidgetsScrollController * self,
                                                     gpointer klass)
{
	self->priv = proton_plus_widgets_scroll_controller_get_instance_private (self);
	self->priv->saved_pos = (gdouble) 0;
}

static void
proton_plus_widgets_scroll_controller_finalize (GObject * obj)
{
	ProtonPlusWidgetsScrollController * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PROTON_PLUS_WIDGETS_TYPE_SCROLL_CONTROLLER, ProtonPlusWidgetsScrollController);
	_g_object_unref0 (self->priv->vadjustment);
	G_OBJECT_CLASS (proton_plus_widgets_scroll_controller_parent_class)->finalize (obj);
}

static GType
proton_plus_widgets_scroll_controller_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusWidgetsScrollControllerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_widgets_scroll_controller_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusWidgetsScrollController), 0, (GInstanceInitFunc) proton_plus_widgets_scroll_controller_instance_init, NULL };
	GType proton_plus_widgets_scroll_controller_type_id;
	proton_plus_widgets_scroll_controller_type_id = g_type_register_static (G_TYPE_OBJECT, "ProtonPlusWidgetsScrollController", &g_define_type_info, 0);
	ProtonPlusWidgetsScrollController_private_offset = g_type_add_instance_private (proton_plus_widgets_scroll_controller_type_id, sizeof (ProtonPlusWidgetsScrollControllerPrivate));
	return proton_plus_widgets_scroll_controller_type_id;
}

GType
proton_plus_widgets_scroll_controller_get_type (void)
{
	static volatile gsize proton_plus_widgets_scroll_controller_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_widgets_scroll_controller_type_id__once)) {
		GType proton_plus_widgets_scroll_controller_type_id;
		proton_plus_widgets_scroll_controller_type_id = proton_plus_widgets_scroll_controller_get_type_once ();
		g_once_init_leave (&proton_plus_widgets_scroll_controller_type_id__once, proton_plus_widgets_scroll_controller_type_id);
	}
	return proton_plus_widgets_scroll_controller_type_id__once;
}

