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

#include <gtksourceview/gtksource.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <adwaita.h>
#include <gee.h>
#include <gdk/gdk.h>
#include <float.h>
#include <math.h>
#include <string.h>
#include <cairo-gobject.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 TUBA_WIDGETS_TYPE_SANDWICH_SOURCE_VIEW (tuba_widgets_sandwich_source_view_get_type ())
#define TUBA_WIDGETS_SANDWICH_SOURCE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUBA_WIDGETS_TYPE_SANDWICH_SOURCE_VIEW, TubaWidgetsSandwichSourceView))
#define TUBA_WIDGETS_SANDWICH_SOURCE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TUBA_WIDGETS_TYPE_SANDWICH_SOURCE_VIEW, TubaWidgetsSandwichSourceViewClass))
#define TUBA_WIDGETS_IS_SANDWICH_SOURCE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUBA_WIDGETS_TYPE_SANDWICH_SOURCE_VIEW))
#define TUBA_WIDGETS_IS_SANDWICH_SOURCE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TUBA_WIDGETS_TYPE_SANDWICH_SOURCE_VIEW))
#define TUBA_WIDGETS_SANDWICH_SOURCE_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TUBA_WIDGETS_TYPE_SANDWICH_SOURCE_VIEW, TubaWidgetsSandwichSourceViewClass))

typedef struct _TubaWidgetsSandwichSourceView TubaWidgetsSandwichSourceView;
typedef struct _TubaWidgetsSandwichSourceViewClass TubaWidgetsSandwichSourceViewClass;
typedef struct _TubaWidgetsSandwichSourceViewPrivate TubaWidgetsSandwichSourceViewPrivate;
enum  {
	TUBA_WIDGETS_SANDWICH_SOURCE_VIEW_0_PROPERTY,
	TUBA_WIDGETS_SANDWICH_SOURCE_VIEW_NUM_PROPERTIES
};
static GParamSpec* tuba_widgets_sandwich_source_view_properties[TUBA_WIDGETS_SANDWICH_SOURCE_VIEW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _TubaWidgetsSandwichSourceView {
	GtkSourceView parent_instance;
	TubaWidgetsSandwichSourceViewPrivate * priv;
};

struct _TubaWidgetsSandwichSourceViewClass {
	GtkSourceViewClass parent_class;
	void (*add_top_child) (TubaWidgetsSandwichSourceView* self, GtkWidget* new_top_child);
	void (*add_bottom_child) (TubaWidgetsSandwichSourceView* self, GtkWidget* new_bottom_child, gboolean append);
	void (*remove_bottom_child) (TubaWidgetsSandwichSourceView* self, GtkWidget* old_bottom_child);
	void (*clear_child_widget) (TubaWidgetsSandwichSourceView* self, GtkWidget* widget);
	void (*setup_child_widget) (TubaWidgetsSandwichSourceView* self, GtkWidget* wdgt);
};

struct _TubaWidgetsSandwichSourceViewPrivate {
	GtkWidget* top_child;
	GtkWidget* bottom_child;
	AdwTimedAnimation* scroll_animation;
	GtkEventController** top_controllers;
	gint top_controllers_length1;
	gint _top_controllers_size_;
	GeeHashMap* bottom_controllers_new;
	GtkBox* bottom_child_box;
};

static gint TubaWidgetsSandwichSourceView_private_offset;
static gpointer tuba_widgets_sandwich_source_view_parent_class = NULL;

VALA_EXTERN GType tuba_widgets_sandwich_source_view_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaWidgetsSandwichSourceView, g_object_unref)
VALA_EXTERN void tuba_widgets_sandwich_source_view_add_top_child (TubaWidgetsSandwichSourceView* self,
                                                      GtkWidget* new_top_child);
VALA_EXTERN void tuba_widgets_sandwich_source_view_add_bottom_child (TubaWidgetsSandwichSourceView* self,
                                                         GtkWidget* new_bottom_child,
                                                         gboolean append);
VALA_EXTERN void tuba_widgets_sandwich_source_view_remove_bottom_child (TubaWidgetsSandwichSourceView* self,
                                                            GtkWidget* old_bottom_child);
VALA_EXTERN void tuba_widgets_sandwich_source_view_clear_child_widget (TubaWidgetsSandwichSourceView* self,
                                                           GtkWidget* widget);
VALA_EXTERN void tuba_widgets_sandwich_source_view_setup_child_widget (TubaWidgetsSandwichSourceView* self,
                                                           GtkWidget* wdgt);
static void tuba_widgets_sandwich_source_view_real_dispose (GObject* base);
static void tuba_widgets_sandwich_source_view_remove_bottom_all (TubaWidgetsSandwichSourceView* self);
static void tuba_widgets_sandwich_source_view_focus_on_view (TubaWidgetsSandwichSourceView* self);
VALA_EXTERN gboolean tuba_widgets_sandwich_source_view_is_bottom_child (TubaWidgetsSandwichSourceView* self,
                                                            GtkWidget* child);
VALA_EXTERN gboolean tuba_widgets_sandwich_source_view_has_bottom_child (TubaWidgetsSandwichSourceView* self,
                                                             GtkWidget* child);
static void tuba_widgets_sandwich_source_view_real_add_top_child (TubaWidgetsSandwichSourceView* self,
                                                           GtkWidget* new_top_child);
static void tuba_widgets_sandwich_source_view_scroll_to_top_widget (TubaWidgetsSandwichSourceView* self);
static void _tuba_widgets_sandwich_source_view_scroll_to_top_widget_gtk_event_controller_focus_enter (GtkEventControllerFocus* _sender,
                                                                                               gpointer self);
static void tuba_widgets_sandwich_source_view_on_focus_leave (TubaWidgetsSandwichSourceView* self);
static void _tuba_widgets_sandwich_source_view_on_focus_leave_gtk_event_controller_focus_leave (GtkEventControllerFocus* _sender,
                                                                                         gpointer self);
static void _vala_array_add146 (GtkEventController** * array,
                         gint* length,
                         gint* size,
                         GtkEventController* value);
static void tuba_widgets_sandwich_source_view_real_add_bottom_child (TubaWidgetsSandwichSourceView* self,
                                                              GtkWidget* new_bottom_child,
                                                              gboolean append);
static void tuba_widgets_sandwich_source_view_scroll_to_bottom_widget (TubaWidgetsSandwichSourceView* self);
static void _tuba_widgets_sandwich_source_view_scroll_to_bottom_widget_gtk_event_controller_focus_enter (GtkEventControllerFocus* _sender,
                                                                                                  gpointer self);
static void tuba_widgets_sandwich_source_view_real_remove_bottom_child (TubaWidgetsSandwichSourceView* self,
                                                                 GtkWidget* old_bottom_child);
static void tuba_widgets_sandwich_source_view_real_clear_child_widget (TubaWidgetsSandwichSourceView* self,
                                                                GtkWidget* widget);
VALA_EXTERN void tuba_widgets_sandwich_source_view_scroll_to_widget (TubaWidgetsSandwichSourceView* self,
                                                         gboolean bottom);
static void tuba_widgets_sandwich_source_view_real_setup_child_widget (TubaWidgetsSandwichSourceView* self,
                                                                GtkWidget* wdgt);
static void tuba_widgets_sandwich_source_view_on_click_gesture_pressed (TubaWidgetsSandwichSourceView* self,
                                                                 GtkGestureClick* gesture,
                                                                 gint n_press,
                                                                 gdouble x,
                                                                 gdouble y);
static void _tuba_widgets_sandwich_source_view_on_click_gesture_pressed_gtk_gesture_click_pressed (GtkGestureClick* _sender,
                                                                                            gint n_press,
                                                                                            gdouble x,
                                                                                            gdouble y,
                                                                                            gpointer self);
static void _tuba_widgets_sandwich_source_view_on_click_gesture_pressed_gtk_gesture_click_released (GtkGestureClick* _sender,
                                                                                             gint n_press,
                                                                                             gdouble x,
                                                                                             gdouble y,
                                                                                             gpointer self);
static void _vala_array_add147 (GtkEventController** * array,
                         gint* length,
                         gint* size,
                         GtkEventController* value);
static void tuba_widgets_sandwich_source_view_on_map (TubaWidgetsSandwichSourceView* self);
static void tuba_widgets_sandwich_source_view_realloc (TubaWidgetsSandwichSourceView* self);
static void _tuba_widgets_sandwich_source_view_realloc_g_object_notify (GObject* _sender,
                                                                 GParamSpec* pspec,
                                                                 gpointer self);
static void tuba_widgets_sandwich_source_view_real_size_allocate (GtkWidget* base,
                                                           gint width,
                                                           gint height,
                                                           gint baseline);
static void tuba_widgets_sandwich_source_view_real_measure (GtkWidget* base,
                                                     GtkOrientation orientation,
                                                     gint for_size,
                                                     gint* minimum,
                                                     gint* natural,
                                                     gint* minimum_baseline,
                                                     gint* natural_baseline);
static void tuba_widgets_sandwich_source_view_real_snapshot (GtkWidget* base,
                                                      GtkSnapshot* snapshot);
VALA_EXTERN void tuba_widgets_sandwich_source_view_scroll_animated (TubaWidgetsSandwichSourceView* self,
                                                        gboolean end);
VALA_EXTERN TubaWidgetsSandwichSourceView* tuba_widgets_sandwich_source_view_new (void);
VALA_EXTERN TubaWidgetsSandwichSourceView* tuba_widgets_sandwich_source_view_construct (GType object_type);
static GObject * tuba_widgets_sandwich_source_view_constructor (GType type,
                                                         guint n_construct_properties,
                                                         GObjectConstructParam * construct_properties);
static void _tuba_widgets_sandwich_source_view_on_map_gtk_widget_map (GtkWidget* _sender,
                                                               gpointer self);
static void _tuba_widgets_sandwich_source_view_focus_on_view_gtk_text_view_move_cursor (GtkTextView* _sender,
                                                                                 GtkMovementStep step,
                                                                                 gint count,
                                                                                 gboolean extend_selection,
                                                                                 gpointer self);
static void _tuba_widgets_sandwich_source_view_focus_on_view_gtk_text_buffer_changed (GtkTextBuffer* _sender,
                                                                               gpointer self);
static void tuba_widgets_sandwich_source_view_finalize (GObject * obj);
static GType tuba_widgets_sandwich_source_view_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static inline gpointer
tuba_widgets_sandwich_source_view_get_instance_private (TubaWidgetsSandwichSourceView* self)
{
	return G_STRUCT_MEMBER_P (self, TubaWidgetsSandwichSourceView_private_offset);
}

static void
tuba_widgets_sandwich_source_view_real_dispose (GObject* base)
{
	TubaWidgetsSandwichSourceView * self;
	GtkWidget* _tmp0_;
	self = (TubaWidgetsSandwichSourceView*) base;
	tuba_widgets_sandwich_source_view_add_top_child (self, NULL);
	tuba_widgets_sandwich_source_view_remove_bottom_all (self);
	_tmp0_ = self->priv->bottom_child;
	gtk_widget_unparent (_tmp0_);
	G_OBJECT_CLASS (tuba_widgets_sandwich_source_view_parent_class)->dispose ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_source_view_get_type (), GtkSourceView));
}

static void
tuba_widgets_sandwich_source_view_focus_on_view (TubaWidgetsSandwichSourceView* self)
{
	gboolean _tmp0_;
	gboolean _tmp1_;
	g_return_if_fail (self != NULL);
	g_object_get ((GtkWidget*) self, "has-focus", &_tmp0_, NULL);
	_tmp1_ = _tmp0_;
	if (!_tmp1_) {
		gtk_widget_grab_focus ((GtkWidget*) self);
	}
}

gboolean
tuba_widgets_sandwich_source_view_is_bottom_child (TubaWidgetsSandwichSourceView* self,
                                                   GtkWidget* child)
{
	GtkWidget* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->bottom_child;
	result = child == _tmp0_;
	return result;
}

gboolean
tuba_widgets_sandwich_source_view_has_bottom_child (TubaWidgetsSandwichSourceView* self,
                                                    GtkWidget* child)
{
	gboolean _tmp0_ = FALSE;
	GeeHashMap* _tmp1_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (child != NULL, FALSE);
	_tmp1_ = self->priv->bottom_controllers_new;
	if (_tmp1_ != NULL) {
		GeeHashMap* _tmp2_;
		_tmp2_ = self->priv->bottom_controllers_new;
		_tmp0_ = gee_abstract_map_has_key ((GeeAbstractMap*) _tmp2_, child);
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

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

static void
_tuba_widgets_sandwich_source_view_scroll_to_top_widget_gtk_event_controller_focus_enter (GtkEventControllerFocus* _sender,
                                                                                          gpointer self)
{
	tuba_widgets_sandwich_source_view_scroll_to_top_widget ((TubaWidgetsSandwichSourceView*) self);
}

static void
_tuba_widgets_sandwich_source_view_on_focus_leave_gtk_event_controller_focus_leave (GtkEventControllerFocus* _sender,
                                                                                    gpointer self)
{
	tuba_widgets_sandwich_source_view_on_focus_leave ((TubaWidgetsSandwichSourceView*) self);
}

static void
_vala_array_add146 (GtkEventController** * array,
                    gint* length,
                    gint* size,
                    GtkEventController* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (GtkEventController*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
tuba_widgets_sandwich_source_view_real_add_top_child (TubaWidgetsSandwichSourceView* self,
                                                      GtkWidget* new_top_child)
{
	GtkWidget* _tmp2_;
	GtkWidget* _tmp4_;
	GtkEventControllerFocus* focus_controller = NULL;
	GtkEventControllerFocus* _tmp5_;
	GtkEventControllerFocus* _tmp6_;
	GtkEventControllerFocus* _tmp7_;
	GtkWidget* _tmp8_;
	GtkEventControllerFocus* _tmp9_;
	GtkEventController* _tmp10_;
	GtkEventControllerFocus* _tmp11_;
	GtkEventController* _tmp12_;
	GtkWidget* _tmp13_;
	GtkWidget* _tmp14_;
	if (new_top_child == NULL) {
		GtkWidget* _tmp0_;
		_tmp0_ = self->priv->top_child;
		if (_tmp0_ != NULL) {
			GtkWidget* _tmp1_;
			_tmp1_ = self->priv->top_child;
			tuba_widgets_sandwich_source_view_clear_child_widget (self, _tmp1_);
			_g_object_unref0 (self->priv->top_child);
			self->priv->top_child = NULL;
		}
		return;
	}
	_tmp2_ = self->priv->top_child;
	if (_tmp2_ != NULL) {
		GtkWidget* _tmp3_;
		_tmp3_ = self->priv->top_child;
		tuba_widgets_sandwich_source_view_clear_child_widget (self, _tmp3_);
	}
	_tmp4_ = _g_object_ref0 (new_top_child);
	_g_object_unref0 (self->priv->top_child);
	self->priv->top_child = _tmp4_;
	_tmp5_ = (GtkEventControllerFocus*) gtk_event_controller_focus_new ();
	focus_controller = _tmp5_;
	_tmp6_ = focus_controller;
	g_signal_connect_object (_tmp6_, "enter", (GCallback) _tuba_widgets_sandwich_source_view_scroll_to_top_widget_gtk_event_controller_focus_enter, self, 0);
	_tmp7_ = focus_controller;
	g_signal_connect_object (_tmp7_, "leave", (GCallback) _tuba_widgets_sandwich_source_view_on_focus_leave_gtk_event_controller_focus_leave, self, 0);
	_tmp8_ = self->priv->top_child;
	_tmp9_ = focus_controller;
	_tmp10_ = _g_object_ref0 ((GtkEventController*) _tmp9_);
	gtk_widget_add_controller (_tmp8_, _tmp10_);
	_tmp11_ = focus_controller;
	_tmp12_ = _g_object_ref0 ((GtkEventController*) _tmp11_);
	_vala_array_add146 (&self->priv->top_controllers, &self->priv->top_controllers_length1, &self->priv->_top_controllers_size_, _tmp12_);
	_tmp13_ = self->priv->top_child;
	gtk_widget_set_parent (_tmp13_, (GtkWidget*) self);
	_tmp14_ = self->priv->top_child;
	tuba_widgets_sandwich_source_view_setup_child_widget (self, _tmp14_);
	_g_object_unref0 (focus_controller);
}

void
tuba_widgets_sandwich_source_view_add_top_child (TubaWidgetsSandwichSourceView* self,
                                                 GtkWidget* new_top_child)
{
	TubaWidgetsSandwichSourceViewClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = TUBA_WIDGETS_SANDWICH_SOURCE_VIEW_GET_CLASS (self);
	if (_klass_->add_top_child) {
		_klass_->add_top_child (self, new_top_child);
	}
}

static void
_tuba_widgets_sandwich_source_view_scroll_to_bottom_widget_gtk_event_controller_focus_enter (GtkEventControllerFocus* _sender,
                                                                                             gpointer self)
{
	tuba_widgets_sandwich_source_view_scroll_to_bottom_widget ((TubaWidgetsSandwichSourceView*) self);
}

static void
tuba_widgets_sandwich_source_view_real_add_bottom_child (TubaWidgetsSandwichSourceView* self,
                                                         GtkWidget* new_bottom_child,
                                                         gboolean append)
{
	GtkBox* _tmp0_;
	GeeHashMap* _tmp1_;
	GeeArrayList* _tmp2_;
	GeeArrayList* _tmp3_;
	GtkEventControllerFocus* focus_controller = NULL;
	GtkEventControllerFocus* _tmp4_;
	GtkEventControllerFocus* _tmp5_;
	GtkEventControllerFocus* _tmp6_;
	GtkEventControllerFocus* _tmp7_;
	GtkEventController* _tmp8_;
	GeeHashMap* _tmp9_;
	gpointer _tmp10_;
	GeeArrayList* _tmp11_;
	GtkEventControllerFocus* _tmp12_;
	g_return_if_fail (new_bottom_child != NULL);
	_tmp0_ = self->priv->bottom_child_box;
	gtk_widget_set_visible ((GtkWidget*) _tmp0_, TRUE);
	if (tuba_widgets_sandwich_source_view_has_bottom_child (self, new_bottom_child)) {
		return;
	}
	_tmp1_ = self->priv->bottom_controllers_new;
	_tmp2_ = gee_array_list_new (gtk_event_controller_get_type (), (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	_tmp3_ = _tmp2_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp1_, new_bottom_child, _tmp3_);
	_g_object_unref0 (_tmp3_);
	_tmp4_ = (GtkEventControllerFocus*) gtk_event_controller_focus_new ();
	focus_controller = _tmp4_;
	_tmp5_ = focus_controller;
	g_signal_connect_object (_tmp5_, "enter", (GCallback) _tuba_widgets_sandwich_source_view_scroll_to_bottom_widget_gtk_event_controller_focus_enter, self, 0);
	_tmp6_ = focus_controller;
	g_signal_connect_object (_tmp6_, "leave", (GCallback) _tuba_widgets_sandwich_source_view_on_focus_leave_gtk_event_controller_focus_leave, self, 0);
	_tmp7_ = focus_controller;
	_tmp8_ = _g_object_ref0 ((GtkEventController*) _tmp7_);
	gtk_widget_add_controller (new_bottom_child, _tmp8_);
	_tmp9_ = self->priv->bottom_controllers_new;
	_tmp10_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp9_, new_bottom_child);
	_tmp11_ = (GeeArrayList*) _tmp10_;
	_tmp12_ = focus_controller;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp11_, (GtkEventController*) _tmp12_);
	_g_object_unref0 (_tmp11_);
	if (append) {
		GtkBox* _tmp13_;
		_tmp13_ = self->priv->bottom_child_box;
		gtk_box_append (_tmp13_, new_bottom_child);
	} else {
		GtkBox* _tmp14_;
		_tmp14_ = self->priv->bottom_child_box;
		gtk_box_prepend (_tmp14_, new_bottom_child);
	}
	tuba_widgets_sandwich_source_view_setup_child_widget (self, new_bottom_child);
	_g_object_unref0 (focus_controller);
}

void
tuba_widgets_sandwich_source_view_add_bottom_child (TubaWidgetsSandwichSourceView* self,
                                                    GtkWidget* new_bottom_child,
                                                    gboolean append)
{
	TubaWidgetsSandwichSourceViewClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = TUBA_WIDGETS_SANDWICH_SOURCE_VIEW_GET_CLASS (self);
	if (_klass_->add_bottom_child) {
		_klass_->add_bottom_child (self, new_bottom_child, append);
	}
}

static void
tuba_widgets_sandwich_source_view_real_remove_bottom_child (TubaWidgetsSandwichSourceView* self,
                                                            GtkWidget* old_bottom_child)
{
	GtkBox* _tmp0_;
	GtkBox* _tmp1_;
	GtkWidget* _tmp2_;
	g_return_if_fail (old_bottom_child != NULL);
	_tmp0_ = self->priv->bottom_child_box;
	gtk_box_remove (_tmp0_, old_bottom_child);
	tuba_widgets_sandwich_source_view_clear_child_widget (self, old_bottom_child);
	_tmp1_ = self->priv->bottom_child_box;
	_tmp2_ = gtk_widget_get_first_child ((GtkWidget*) _tmp1_);
	if (_tmp2_ == NULL) {
		GtkBox* _tmp3_;
		_tmp3_ = self->priv->bottom_child_box;
		gtk_widget_set_visible ((GtkWidget*) _tmp3_, FALSE);
	}
}

void
tuba_widgets_sandwich_source_view_remove_bottom_child (TubaWidgetsSandwichSourceView* self,
                                                       GtkWidget* old_bottom_child)
{
	TubaWidgetsSandwichSourceViewClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = TUBA_WIDGETS_SANDWICH_SOURCE_VIEW_GET_CLASS (self);
	if (_klass_->remove_bottom_child) {
		_klass_->remove_bottom_child (self, old_bottom_child);
	}
}

static void
tuba_widgets_sandwich_source_view_remove_bottom_all (TubaWidgetsSandwichSourceView* self)
{
	GeeHashMap* _tmp0_;
	GeeSet* _tmp1_;
	GeeSet* _tmp2_;
	GeeSet* _tmp3_;
	gint _tmp4_ = 0;
	gpointer* _tmp5_;
	GtkWidget** _tmp6_;
	gint _tmp6__length1;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->bottom_controllers_new;
	_tmp1_ = gee_abstract_map_get_keys ((GeeAbstractMap*) _tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_;
	_tmp5_ = gee_collection_to_array ((GeeCollection*) _tmp3_, &_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp6__length1 = _tmp4_;
	_g_object_unref0 (_tmp3_);
	{
		GtkWidget** widg_collection = NULL;
		gint widg_collection_length1 = 0;
		gint _widg_collection_size_ = 0;
		gint widg_it = 0;
		widg_collection = _tmp6_;
		widg_collection_length1 = _tmp6__length1;
		for (widg_it = 0; widg_it < widg_collection_length1; widg_it = widg_it + 1) {
			GtkWidget* _tmp7_;
			GtkWidget* widg = NULL;
			_tmp7_ = _g_object_ref0 (widg_collection[widg_it]);
			widg = _tmp7_;
			{
				GtkWidget* _tmp8_;
				_tmp8_ = widg;
				tuba_widgets_sandwich_source_view_remove_bottom_child (self, _tmp8_);
				_g_object_unref0 (widg);
			}
		}
		widg_collection = (_vala_array_free (widg_collection, widg_collection_length1, (GDestroyNotify) g_object_unref), NULL);
	}
}

static void
tuba_widgets_sandwich_source_view_real_clear_child_widget (TubaWidgetsSandwichSourceView* self,
                                                           GtkWidget* widget)
{
	GeeHashMap* _tmp0_;
	g_return_if_fail (widget != NULL);
	_tmp0_ = self->priv->bottom_controllers_new;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, widget)) {
		GeeArrayList* controllers = NULL;
		GeeHashMap* _tmp1_;
		gpointer _tmp2_;
		GeeArrayList* _tmp12_;
		GeeHashMap* _tmp13_;
		_tmp1_ = self->priv->bottom_controllers_new;
		_tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp1_, widget);
		controllers = (GeeArrayList*) _tmp2_;
		{
			GeeArrayList* _controller_list = NULL;
			GeeArrayList* _tmp3_;
			gint _controller_size = 0;
			GeeArrayList* _tmp4_;
			gint _tmp5_;
			gint _tmp6_;
			gint _controller_index = 0;
			_tmp3_ = controllers;
			_controller_list = _tmp3_;
			_tmp4_ = _controller_list;
			_tmp5_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp4_);
			_tmp6_ = _tmp5_;
			_controller_size = _tmp6_;
			_controller_index = -1;
			while (TRUE) {
				gint _tmp7_;
				gint _tmp8_;
				GtkEventController* controller = NULL;
				GeeArrayList* _tmp9_;
				gpointer _tmp10_;
				GtkEventController* _tmp11_;
				_controller_index = _controller_index + 1;
				_tmp7_ = _controller_index;
				_tmp8_ = _controller_size;
				if (!(_tmp7_ < _tmp8_)) {
					break;
				}
				_tmp9_ = _controller_list;
				_tmp10_ = gee_abstract_list_get ((GeeAbstractList*) _tmp9_, _controller_index);
				controller = (GtkEventController*) _tmp10_;
				_tmp11_ = controller;
				gtk_widget_remove_controller (widget, _tmp11_);
				_g_object_unref0 (controller);
			}
		}
		_tmp12_ = controllers;
		gee_abstract_collection_clear ((GeeAbstractCollection*) _tmp12_);
		_tmp13_ = self->priv->bottom_controllers_new;
		gee_abstract_map_unset ((GeeAbstractMap*) _tmp13_, widget, NULL);
		_g_object_unref0 (controllers);
	} else {
		GtkEventController** _tmp14_;
		gint _tmp14__length1;
		GtkEventController** _tmp17_;
		_tmp14_ = self->priv->top_controllers;
		_tmp14__length1 = self->priv->top_controllers_length1;
		{
			GtkEventController** controller_collection = NULL;
			gint controller_collection_length1 = 0;
			gint _controller_collection_size_ = 0;
			gint controller_it = 0;
			controller_collection = _tmp14_;
			controller_collection_length1 = _tmp14__length1;
			for (controller_it = 0; controller_it < controller_collection_length1; controller_it = controller_it + 1) {
				GtkEventController* _tmp15_;
				GtkEventController* controller = NULL;
				_tmp15_ = _g_object_ref0 (controller_collection[controller_it]);
				controller = _tmp15_;
				{
					GtkEventController* _tmp16_;
					_tmp16_ = controller;
					gtk_widget_remove_controller (widget, _tmp16_);
					_g_object_unref0 (controller);
				}
			}
		}
		_tmp17_ = g_new0 (GtkEventController*, 0 + 1);
		self->priv->top_controllers = (_vala_array_free (self->priv->top_controllers, self->priv->top_controllers_length1, (GDestroyNotify) g_object_unref), NULL);
		self->priv->top_controllers = _tmp17_;
		self->priv->top_controllers_length1 = 0;
		self->priv->_top_controllers_size_ = self->priv->top_controllers_length1;
	}
	gtk_widget_unparent (widget);
}

void
tuba_widgets_sandwich_source_view_clear_child_widget (TubaWidgetsSandwichSourceView* self,
                                                      GtkWidget* widget)
{
	TubaWidgetsSandwichSourceViewClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = TUBA_WIDGETS_SANDWICH_SOURCE_VIEW_GET_CLASS (self);
	if (_klass_->clear_child_widget) {
		_klass_->clear_child_widget (self, widget);
	}
}

static void
tuba_widgets_sandwich_source_view_scroll_to_top_widget (TubaWidgetsSandwichSourceView* self)
{
	g_return_if_fail (self != NULL);
	tuba_widgets_sandwich_source_view_scroll_to_widget (self, FALSE);
	gtk_text_view_set_editable ((GtkTextView*) self, FALSE);
}

static void
tuba_widgets_sandwich_source_view_scroll_to_bottom_widget (TubaWidgetsSandwichSourceView* self)
{
	g_return_if_fail (self != NULL);
	tuba_widgets_sandwich_source_view_scroll_to_widget (self, TRUE);
	gtk_text_view_set_editable ((GtkTextView*) self, FALSE);
}

static void
tuba_widgets_sandwich_source_view_on_focus_leave (TubaWidgetsSandwichSourceView* self)
{
	g_return_if_fail (self != NULL);
	gtk_text_view_set_editable ((GtkTextView*) self, TRUE);
}

static void
_tuba_widgets_sandwich_source_view_on_click_gesture_pressed_gtk_gesture_click_pressed (GtkGestureClick* _sender,
                                                                                       gint n_press,
                                                                                       gdouble x,
                                                                                       gdouble y,
                                                                                       gpointer self)
{
	tuba_widgets_sandwich_source_view_on_click_gesture_pressed ((TubaWidgetsSandwichSourceView*) self, _sender, n_press, x, y);
}

static void
_tuba_widgets_sandwich_source_view_on_click_gesture_pressed_gtk_gesture_click_released (GtkGestureClick* _sender,
                                                                                        gint n_press,
                                                                                        gdouble x,
                                                                                        gdouble y,
                                                                                        gpointer self)
{
	tuba_widgets_sandwich_source_view_on_click_gesture_pressed ((TubaWidgetsSandwichSourceView*) self, _sender, n_press, x, y);
}

static void
_vala_array_add147 (GtkEventController** * array,
                    gint* length,
                    gint* size,
                    GtkEventController* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (GtkEventController*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
tuba_widgets_sandwich_source_view_real_setup_child_widget (TubaWidgetsSandwichSourceView* self,
                                                           GtkWidget* wdgt)
{
	GdkCursor* _tmp0_;
	GdkCursor* _tmp1_;
	GtkGestureClick* click_gesture = NULL;
	GtkGestureClick* _tmp2_ = NULL;
	GtkGestureClick* _tmp3_;
	GtkGestureClick* _tmp4_;
	GtkGestureClick* _tmp5_;
	GtkEventController* _tmp6_;
	GeeHashMap* _tmp7_;
	g_return_if_fail (wdgt != NULL);
	_tmp0_ = gdk_cursor_new_from_name ("default", NULL);
	_tmp1_ = _tmp0_;
	gtk_widget_set_cursor (wdgt, _tmp1_);
	_g_object_unref0 (_tmp1_);
	_tmp2_ = (GtkGestureClick*) gtk_gesture_click_new ();
	gtk_gesture_single_set_button ((GtkGestureSingle*) _tmp2_, (guint) 3);
	gtk_event_controller_set_propagation_phase ((GtkEventController*) _tmp2_, GTK_PHASE_BUBBLE);
	click_gesture = _tmp2_;
	_tmp3_ = click_gesture;
	g_signal_connect_object (_tmp3_, "pressed", (GCallback) _tuba_widgets_sandwich_source_view_on_click_gesture_pressed_gtk_gesture_click_pressed, self, 0);
	_tmp4_ = click_gesture;
	g_signal_connect_object (_tmp4_, "released", (GCallback) _tuba_widgets_sandwich_source_view_on_click_gesture_pressed_gtk_gesture_click_released, self, 0);
	_tmp5_ = click_gesture;
	_tmp6_ = _g_object_ref0 ((GtkEventController*) _tmp5_);
	gtk_widget_add_controller (wdgt, _tmp6_);
	_tmp7_ = self->priv->bottom_controllers_new;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp7_, wdgt)) {
		GeeHashMap* _tmp8_;
		gpointer _tmp9_;
		GeeArrayList* _tmp10_;
		GtkGestureClick* _tmp11_;
		_tmp8_ = self->priv->bottom_controllers_new;
		_tmp9_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp8_, wdgt);
		_tmp10_ = (GeeArrayList*) _tmp9_;
		_tmp11_ = click_gesture;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp10_, (GtkEventController*) _tmp11_);
		_g_object_unref0 (_tmp10_);
	} else {
		GtkGestureClick* _tmp12_;
		GtkEventController* _tmp13_;
		_tmp12_ = click_gesture;
		_tmp13_ = _g_object_ref0 ((GtkEventController*) _tmp12_);
		_vala_array_add147 (&self->priv->top_controllers, &self->priv->top_controllers_length1, &self->priv->_top_controllers_size_, _tmp13_);
	}
	gtk_widget_queue_resize ((GtkWidget*) self);
	_g_object_unref0 (click_gesture);
}

void
tuba_widgets_sandwich_source_view_setup_child_widget (TubaWidgetsSandwichSourceView* self,
                                                      GtkWidget* wdgt)
{
	TubaWidgetsSandwichSourceViewClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = TUBA_WIDGETS_SANDWICH_SOURCE_VIEW_GET_CLASS (self);
	if (_klass_->setup_child_widget) {
		_klass_->setup_child_widget (self, wdgt);
	}
}

static void
tuba_widgets_sandwich_source_view_on_click_gesture_pressed (TubaWidgetsSandwichSourceView* self,
                                                            GtkGestureClick* gesture,
                                                            gint n_press,
                                                            gdouble x,
                                                            gdouble y)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (gesture != NULL);
	gtk_gesture_set_state ((GtkGesture*) gesture, GTK_EVENT_SEQUENCE_CLAIMED);
}

static void
_tuba_widgets_sandwich_source_view_realloc_g_object_notify (GObject* _sender,
                                                            GParamSpec* pspec,
                                                            gpointer self)
{
	tuba_widgets_sandwich_source_view_realloc ((TubaWidgetsSandwichSourceView*) self);
}

static void
tuba_widgets_sandwich_source_view_on_map (TubaWidgetsSandwichSourceView* self)
{
	GtkAdjustment* _tmp0_;
	GtkAdjustment* _tmp1_;
	GtkAdjustment* _tmp2_;
	GtkAdjustment* _tmp3_;
	gboolean _tmp4_ = FALSE;
	AdwTimedAnimation* _tmp5_;
	GtkAdjustment* _tmp10_;
	GtkAdjustment* _tmp11_;
	AdwPropertyAnimationTarget* _tmp12_;
	AdwTimedAnimation* _tmp13_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = gtk_scrollable_get_vadjustment ((GtkScrollable*) self);
	_tmp1_ = _tmp0_;
	g_signal_connect_object ((GObject*) _tmp1_, "notify::upper", (GCallback) _tuba_widgets_sandwich_source_view_realloc_g_object_notify, self, 0);
	_tmp2_ = gtk_scrollable_get_vadjustment ((GtkScrollable*) self);
	_tmp3_ = _tmp2_;
	g_signal_connect_object ((GObject*) _tmp3_, "notify::value", (GCallback) _tuba_widgets_sandwich_source_view_realloc_g_object_notify, self, 0);
	_tmp5_ = self->priv->scroll_animation;
	if (_tmp5_ != NULL) {
		AdwTimedAnimation* _tmp6_;
		AdwAnimationState _tmp7_;
		AdwAnimationState _tmp8_;
		_tmp6_ = self->priv->scroll_animation;
		_tmp7_ = adw_animation_get_state ((AdwAnimation*) _tmp6_);
		_tmp8_ = _tmp7_;
		_tmp4_ = _tmp8_ == ADW_ANIMATION_PLAYING;
	} else {
		_tmp4_ = FALSE;
	}
	if (_tmp4_) {
		AdwTimedAnimation* _tmp9_;
		_tmp9_ = self->priv->scroll_animation;
		adw_animation_skip ((AdwAnimation*) _tmp9_);
	}
	_tmp10_ = gtk_scrollable_get_vadjustment ((GtkScrollable*) self);
	_tmp11_ = _tmp10_;
	_tmp12_ = (AdwPropertyAnimationTarget*) adw_property_animation_target_new ((GObject*) _tmp11_, "value");
	_tmp13_ = (AdwTimedAnimation*) adw_timed_animation_new ((GtkWidget*) self, (gdouble) 0, (gdouble) 1, (guint) 500, (AdwAnimationTarget*) _tmp12_);
	adw_timed_animation_set_easing (_tmp13_, ADW_EASE_IN_OUT_QUART);
	_g_object_unref0 (self->priv->scroll_animation);
	self->priv->scroll_animation = _tmp13_;
}

static void
tuba_widgets_sandwich_source_view_realloc (TubaWidgetsSandwichSourceView* self)
{
	g_return_if_fail (self != NULL);
	gtk_widget_queue_allocate ((GtkWidget*) self);
}

static void
tuba_widgets_sandwich_source_view_real_size_allocate (GtkWidget* base,
                                                      gint width,
                                                      gint height,
                                                      gint baseline)
{
	TubaWidgetsSandwichSourceView * self;
	gdouble yoff = 0.0;
	gint top_child_height = 0;
	gint bottom_child_height = 0;
	GtkWidget* _tmp0_;
	gboolean _tmp5_ = FALSE;
	GtkWidget* _tmp6_;
	gdouble _tmp14_ = 0.0;
	GtkWidget* _tmp15_;
	gboolean _tmp18_ = FALSE;
	GtkWidget* _tmp19_;
	self = (TubaWidgetsSandwichSourceView*) base;
	yoff = (gdouble) 0;
	top_child_height = 0;
	bottom_child_height = 0;
	_tmp0_ = self->priv->top_child;
	if (_tmp0_ != NULL) {
		GtkWidget* _tmp1_;
		gint _tmp2_ = 0;
		gint _tmp3_;
		gint _tmp4_;
		_tmp1_ = self->priv->top_child;
		gtk_widget_measure (_tmp1_, GTK_ORIENTATION_VERTICAL, width, &_tmp2_, NULL, NULL, NULL);
		top_child_height = _tmp2_;
		_tmp3_ = gtk_text_view_get_top_margin ((GtkTextView*) self);
		_tmp4_ = _tmp3_;
		if (top_child_height != _tmp4_) {
			gtk_text_view_set_top_margin ((GtkTextView*) self, top_child_height);
		}
	} else {
		gtk_text_view_set_top_margin ((GtkTextView*) self, 0);
	}
	_tmp6_ = self->priv->bottom_child;
	if (_tmp6_ != NULL) {
		GtkWidget* _tmp7_;
		gboolean _tmp8_;
		gboolean _tmp9_;
		_tmp7_ = self->priv->bottom_child;
		_tmp8_ = gtk_widget_get_visible (_tmp7_);
		_tmp9_ = _tmp8_;
		_tmp5_ = _tmp9_;
	} else {
		_tmp5_ = FALSE;
	}
	if (_tmp5_) {
		GtkWidget* _tmp10_;
		gint _tmp11_ = 0;
		gint _tmp12_;
		gint _tmp13_;
		_tmp10_ = self->priv->bottom_child;
		gtk_widget_measure (_tmp10_, GTK_ORIENTATION_VERTICAL, width, &_tmp11_, NULL, NULL, NULL);
		bottom_child_height = _tmp11_;
		_tmp12_ = gtk_text_view_get_bottom_margin ((GtkTextView*) self);
		_tmp13_ = _tmp12_;
		if (bottom_child_height != _tmp13_) {
			gtk_text_view_set_bottom_margin ((GtkTextView*) self, bottom_child_height);
		}
	} else {
		gtk_text_view_set_bottom_margin ((GtkTextView*) self, 0);
	}
	GTK_WIDGET_CLASS (tuba_widgets_sandwich_source_view_parent_class)->size_allocate ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_source_view_get_type (), GtkSourceView), width, height, baseline);
	gtk_text_view_get_visible_offset ((GtkTextView*) self, NULL, &_tmp14_);
	yoff = _tmp14_;
	_tmp15_ = self->priv->top_child;
	if (_tmp15_ != NULL) {
		GtkWidget* _tmp16_;
		GtkAllocation _tmp17_ = {0};
		_tmp16_ = self->priv->top_child;
		memset (&_tmp17_, 0, sizeof (GtkAllocation));
		_tmp17_.height = top_child_height;
		_tmp17_.width = width;
		_tmp17_.x = 0;
		_tmp17_.y = (gint) ((-yoff) - top_child_height);
		gtk_widget_size_allocate (_tmp16_, &_tmp17_, baseline);
	}
	_tmp19_ = self->priv->bottom_child;
	if (_tmp19_ != NULL) {
		GtkWidget* _tmp20_;
		gboolean _tmp21_;
		gboolean _tmp22_;
		_tmp20_ = self->priv->bottom_child;
		_tmp21_ = gtk_widget_get_visible (_tmp20_);
		_tmp22_ = _tmp21_;
		_tmp18_ = _tmp22_;
	} else {
		_tmp18_ = FALSE;
	}
	if (_tmp18_) {
		GtkWidget* _tmp23_;
		GtkAdjustment* _tmp24_;
		GtkAdjustment* _tmp25_;
		gdouble _tmp26_;
		gdouble _tmp27_;
		gint _tmp28_;
		gint _tmp29_;
		GtkAllocation _tmp30_ = {0};
		_tmp23_ = self->priv->bottom_child;
		_tmp24_ = gtk_scrollable_get_vadjustment ((GtkScrollable*) self);
		_tmp25_ = _tmp24_;
		_tmp26_ = gtk_adjustment_get_upper (_tmp25_);
		_tmp27_ = _tmp26_;
		_tmp28_ = gtk_text_view_get_top_margin ((GtkTextView*) self);
		_tmp29_ = _tmp28_;
		memset (&_tmp30_, 0, sizeof (GtkAllocation));
		_tmp30_.height = bottom_child_height;
		_tmp30_.width = width;
		_tmp30_.x = 0;
		_tmp30_.y = (gint) (((_tmp27_ - yoff) - bottom_child_height) - _tmp29_);
		gtk_widget_size_allocate (_tmp23_, &_tmp30_, baseline);
	}
}

static void
tuba_widgets_sandwich_source_view_real_measure (GtkWidget* base,
                                                GtkOrientation orientation,
                                                gint for_size,
                                                gint* minimum,
                                                gint* natural,
                                                gint* minimum_baseline,
                                                gint* natural_baseline)
{
	TubaWidgetsSandwichSourceView * self;
	gint _vala_minimum = 0;
	gint _vala_natural = 0;
	gint _vala_minimum_baseline = 0;
	gint _vala_natural_baseline = 0;
	gint _tmp0_ = 0;
	gint _tmp1_ = 0;
	self = (TubaWidgetsSandwichSourceView*) base;
	GTK_WIDGET_CLASS (tuba_widgets_sandwich_source_view_parent_class)->measure ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_source_view_get_type (), GtkSourceView), orientation, for_size, &_tmp0_, &_tmp1_, NULL, NULL);
	_vala_minimum = _tmp0_;
	_vala_natural = _tmp1_;
	_vala_natural_baseline = -1;
	_vala_minimum_baseline = _vala_natural_baseline;
	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
tuba_widgets_sandwich_source_view_real_snapshot (GtkWidget* base,
                                                 GtkSnapshot* snapshot)
{
	TubaWidgetsSandwichSourceView * self;
	GtkWidget* _tmp0_;
	gboolean _tmp2_ = FALSE;
	GtkWidget* _tmp3_;
	self = (TubaWidgetsSandwichSourceView*) base;
	g_return_if_fail (snapshot != NULL);
	GTK_WIDGET_CLASS (tuba_widgets_sandwich_source_view_parent_class)->snapshot ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_source_view_get_type (), GtkSourceView), snapshot);
	_tmp0_ = self->priv->top_child;
	if (_tmp0_ != NULL) {
		GtkWidget* _tmp1_;
		_tmp1_ = self->priv->top_child;
		gtk_widget_snapshot_child ((GtkWidget*) self, _tmp1_, snapshot);
	}
	_tmp3_ = self->priv->bottom_child;
	if (_tmp3_ != NULL) {
		GtkWidget* _tmp4_;
		gboolean _tmp5_;
		gboolean _tmp6_;
		_tmp4_ = self->priv->bottom_child;
		_tmp5_ = gtk_widget_get_visible (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp2_ = _tmp6_;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		GtkWidget* _tmp7_;
		_tmp7_ = self->priv->bottom_child;
		gtk_widget_snapshot_child ((GtkWidget*) self, _tmp7_, snapshot);
	}
}

void
tuba_widgets_sandwich_source_view_scroll_to_widget (TubaWidgetsSandwichSourceView* self,
                                                    gboolean bottom)
{
	AdwTimedAnimation* _tmp0_;
	gdouble y_val = 0.0;
	GtkAdjustment* _tmp1_;
	GtkAdjustment* _tmp2_;
	gdouble _tmp3_;
	gdouble _tmp4_;
	gboolean _tmp5_ = FALSE;
	gboolean _tmp6_ = FALSE;
	AdwTimedAnimation* _tmp20_;
	AdwAnimationState _tmp21_;
	AdwAnimationState _tmp22_;
	gdouble _tmp24_ = 0.0;
	gdouble scroll_to_value = 0.0;
	AdwTimedAnimation* _tmp31_;
	AdwTimedAnimation* _tmp32_;
	AdwTimedAnimation* _tmp33_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->scroll_animation;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = gtk_scrollable_get_vadjustment ((GtkScrollable*) self);
	_tmp2_ = _tmp1_;
	_tmp3_ = gtk_adjustment_get_value (_tmp2_);
	_tmp4_ = _tmp3_;
	y_val = _tmp4_;
	if (!bottom) {
		gint _tmp7_;
		gint _tmp8_;
		_tmp7_ = gtk_text_view_get_top_margin ((GtkTextView*) self);
		_tmp8_ = _tmp7_;
		_tmp6_ = y_val < ((gdouble) MIN (_tmp8_, 100));
	} else {
		_tmp6_ = FALSE;
	}
	if (_tmp6_) {
		_tmp5_ = TRUE;
	} else {
		gboolean _tmp9_ = FALSE;
		if (bottom) {
			GtkAdjustment* _tmp10_;
			GtkAdjustment* _tmp11_;
			gdouble _tmp12_;
			gdouble _tmp13_;
			GtkAdjustment* _tmp14_;
			GtkAdjustment* _tmp15_;
			gdouble _tmp16_;
			gdouble _tmp17_;
			gint _tmp18_;
			gint _tmp19_;
			_tmp10_ = gtk_scrollable_get_vadjustment ((GtkScrollable*) self);
			_tmp11_ = _tmp10_;
			_tmp12_ = gtk_adjustment_get_upper (_tmp11_);
			_tmp13_ = _tmp12_;
			_tmp14_ = gtk_scrollable_get_vadjustment ((GtkScrollable*) self);
			_tmp15_ = _tmp14_;
			_tmp16_ = gtk_adjustment_get_page_size (_tmp15_);
			_tmp17_ = _tmp16_;
			_tmp18_ = gtk_text_view_get_bottom_margin ((GtkTextView*) self);
			_tmp19_ = _tmp18_;
			_tmp9_ = y_val > ((_tmp13_ - _tmp17_) - _tmp19_);
		} else {
			_tmp9_ = FALSE;
		}
		_tmp5_ = _tmp9_;
	}
	if (_tmp5_) {
		return;
	}
	_tmp20_ = self->priv->scroll_animation;
	_tmp21_ = adw_animation_get_state ((AdwAnimation*) _tmp20_);
	_tmp22_ = _tmp21_;
	if (_tmp22_ == ADW_ANIMATION_PLAYING) {
		AdwTimedAnimation* _tmp23_;
		_tmp23_ = self->priv->scroll_animation;
		adw_animation_pause ((AdwAnimation*) _tmp23_);
	}
	if (bottom) {
		GtkAdjustment* _tmp25_;
		GtkAdjustment* _tmp26_;
		gdouble _tmp27_;
		gdouble _tmp28_;
		gint _tmp29_;
		gint _tmp30_;
		_tmp25_ = gtk_scrollable_get_vadjustment ((GtkScrollable*) self);
		_tmp26_ = _tmp25_;
		_tmp27_ = gtk_adjustment_get_upper (_tmp26_);
		_tmp28_ = _tmp27_;
		_tmp29_ = gtk_text_view_get_bottom_margin ((GtkTextView*) self);
		_tmp30_ = _tmp29_;
		_tmp24_ = _tmp28_ - _tmp30_;
	} else {
		_tmp24_ = (gdouble) 0;
	}
	scroll_to_value = _tmp24_;
	_tmp31_ = self->priv->scroll_animation;
	adw_timed_animation_set_value_from (_tmp31_, y_val);
	_tmp32_ = self->priv->scroll_animation;
	adw_timed_animation_set_value_to (_tmp32_, scroll_to_value);
	_tmp33_ = self->priv->scroll_animation;
	adw_animation_play ((AdwAnimation*) _tmp33_);
}

void
tuba_widgets_sandwich_source_view_scroll_animated (TubaWidgetsSandwichSourceView* self,
                                                   gboolean end)
{
	AdwTimedAnimation* _tmp0_;
	AdwTimedAnimation* _tmp1_;
	AdwAnimationState _tmp2_;
	AdwAnimationState _tmp3_;
	AdwTimedAnimation* _tmp5_;
	GtkAdjustment* _tmp6_;
	GtkAdjustment* _tmp7_;
	gdouble _tmp8_;
	gdouble _tmp9_;
	gdouble _tmp10_ = 0.0;
	AdwTimedAnimation* _tmp15_;
	AdwTimedAnimation* _tmp16_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->scroll_animation;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = self->priv->scroll_animation;
	_tmp2_ = adw_animation_get_state ((AdwAnimation*) _tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_ == ADW_ANIMATION_PLAYING) {
		AdwTimedAnimation* _tmp4_;
		_tmp4_ = self->priv->scroll_animation;
		adw_animation_pause ((AdwAnimation*) _tmp4_);
	}
	_tmp5_ = self->priv->scroll_animation;
	_tmp6_ = gtk_scrollable_get_vadjustment ((GtkScrollable*) self);
	_tmp7_ = _tmp6_;
	_tmp8_ = gtk_adjustment_get_value (_tmp7_);
	_tmp9_ = _tmp8_;
	adw_timed_animation_set_value_from (_tmp5_, _tmp9_);
	if (end) {
		GtkAdjustment* _tmp11_;
		GtkAdjustment* _tmp12_;
		gdouble _tmp13_;
		gdouble _tmp14_;
		_tmp11_ = gtk_scrollable_get_vadjustment ((GtkScrollable*) self);
		_tmp12_ = _tmp11_;
		_tmp13_ = gtk_adjustment_get_upper (_tmp12_);
		_tmp14_ = _tmp13_;
		_tmp10_ = _tmp14_;
	} else {
		_tmp10_ = (gdouble) 0;
	}
	_tmp15_ = self->priv->scroll_animation;
	adw_timed_animation_set_value_to (_tmp15_, _tmp10_);
	_tmp16_ = self->priv->scroll_animation;
	adw_animation_play ((AdwAnimation*) _tmp16_);
}

TubaWidgetsSandwichSourceView*
tuba_widgets_sandwich_source_view_construct (GType object_type)
{
	TubaWidgetsSandwichSourceView * self = NULL;
	self = (TubaWidgetsSandwichSourceView*) g_object_new (object_type, NULL);
	return self;
}

TubaWidgetsSandwichSourceView*
tuba_widgets_sandwich_source_view_new (void)
{
	return tuba_widgets_sandwich_source_view_construct (TUBA_WIDGETS_TYPE_SANDWICH_SOURCE_VIEW);
}

static void
_tuba_widgets_sandwich_source_view_on_map_gtk_widget_map (GtkWidget* _sender,
                                                          gpointer self)
{
	tuba_widgets_sandwich_source_view_on_map ((TubaWidgetsSandwichSourceView*) self);
}

static void
_tuba_widgets_sandwich_source_view_focus_on_view_gtk_text_view_move_cursor (GtkTextView* _sender,
                                                                            GtkMovementStep step,
                                                                            gint count,
                                                                            gboolean extend_selection,
                                                                            gpointer self)
{
	tuba_widgets_sandwich_source_view_focus_on_view ((TubaWidgetsSandwichSourceView*) self);
}

static void
_tuba_widgets_sandwich_source_view_focus_on_view_gtk_text_buffer_changed (GtkTextBuffer* _sender,
                                                                          gpointer self)
{
	tuba_widgets_sandwich_source_view_focus_on_view ((TubaWidgetsSandwichSourceView*) self);
}

static GObject *
tuba_widgets_sandwich_source_view_constructor (GType type,
                                               guint n_construct_properties,
                                               GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	TubaWidgetsSandwichSourceView * self;
	GeeHashMap* _tmp0_;
	GtkBox* _tmp1_ = NULL;
	GtkBox* _tmp2_;
	GtkWidget* _tmp3_;
	GtkWidget* _tmp4_;
	GtkTextBuffer* _tmp5_;
	GtkTextBuffer* _tmp6_;
	parent_class = G_OBJECT_CLASS (tuba_widgets_sandwich_source_view_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TUBA_WIDGETS_TYPE_SANDWICH_SOURCE_VIEW, TubaWidgetsSandwichSourceView);
	_tmp0_ = gee_hash_map_new (gtk_widget_get_type (), (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, GEE_TYPE_ARRAY_LIST, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->bottom_controllers_new);
	self->priv->bottom_controllers_new = _tmp0_;
	_tmp1_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_widget_set_visible ((GtkWidget*) _tmp1_, FALSE);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp1_, 28);
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->priv->bottom_child_box);
	self->priv->bottom_child_box = _tmp1_;
	_tmp2_ = self->priv->bottom_child_box;
	_tmp3_ = _g_object_ref0 ((GtkWidget*) _tmp2_);
	_g_object_unref0 (self->priv->bottom_child);
	self->priv->bottom_child = _tmp3_;
	_tmp4_ = self->priv->bottom_child;
	gtk_widget_set_parent (_tmp4_, (GtkWidget*) self);
	gtk_text_view_set_accepts_tab ((GtkTextView*) self, FALSE);
	gtk_text_view_set_wrap_mode ((GtkTextView*) self, GTK_WRAP_WORD_CHAR);
	g_signal_connect_object ((GtkWidget*) self, "map", (GCallback) _tuba_widgets_sandwich_source_view_on_map_gtk_widget_map, self, 0);
	g_signal_connect_object ((GtkTextView*) self, "move-cursor", (GCallback) _tuba_widgets_sandwich_source_view_focus_on_view_gtk_text_view_move_cursor, self, 0);
	_tmp5_ = gtk_text_view_get_buffer ((GtkTextView*) self);
	_tmp6_ = _tmp5_;
	g_signal_connect_object (_tmp6_, "changed", (GCallback) _tuba_widgets_sandwich_source_view_focus_on_view_gtk_text_buffer_changed, self, 0);
	return obj;
}

static void
tuba_widgets_sandwich_source_view_class_init (TubaWidgetsSandwichSourceViewClass * klass,
                                              gpointer klass_data)
{
	tuba_widgets_sandwich_source_view_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &TubaWidgetsSandwichSourceView_private_offset);
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) tuba_widgets_sandwich_source_view_real_dispose;
	((TubaWidgetsSandwichSourceViewClass *) klass)->add_top_child = (void (*) (TubaWidgetsSandwichSourceView*, GtkWidget*)) tuba_widgets_sandwich_source_view_real_add_top_child;
	((TubaWidgetsSandwichSourceViewClass *) klass)->add_bottom_child = (void (*) (TubaWidgetsSandwichSourceView*, GtkWidget*, gboolean)) tuba_widgets_sandwich_source_view_real_add_bottom_child;
	((TubaWidgetsSandwichSourceViewClass *) klass)->remove_bottom_child = (void (*) (TubaWidgetsSandwichSourceView*, GtkWidget*)) tuba_widgets_sandwich_source_view_real_remove_bottom_child;
	((TubaWidgetsSandwichSourceViewClass *) klass)->clear_child_widget = (void (*) (TubaWidgetsSandwichSourceView*, GtkWidget*)) tuba_widgets_sandwich_source_view_real_clear_child_widget;
	((TubaWidgetsSandwichSourceViewClass *) klass)->setup_child_widget = (void (*) (TubaWidgetsSandwichSourceView*, GtkWidget*)) tuba_widgets_sandwich_source_view_real_setup_child_widget;
	((GtkWidgetClass *) klass)->size_allocate = (void (*) (GtkWidget*, gint, gint, gint)) tuba_widgets_sandwich_source_view_real_size_allocate;
	((GtkWidgetClass *) klass)->measure = (void (*) (GtkWidget*, GtkOrientation, gint, gint*, gint*, gint*, gint*)) tuba_widgets_sandwich_source_view_real_measure;
	((GtkWidgetClass *) klass)->snapshot = (void (*) (GtkWidget*, GtkSnapshot*)) tuba_widgets_sandwich_source_view_real_snapshot;
	G_OBJECT_CLASS (klass)->constructor = tuba_widgets_sandwich_source_view_constructor;
	G_OBJECT_CLASS (klass)->finalize = tuba_widgets_sandwich_source_view_finalize;
}

static void
tuba_widgets_sandwich_source_view_instance_init (TubaWidgetsSandwichSourceView * self,
                                                 gpointer klass)
{
	GtkEventController** _tmp0_;
	self->priv = tuba_widgets_sandwich_source_view_get_instance_private (self);
	self->priv->top_child = NULL;
	self->priv->bottom_child = NULL;
	_tmp0_ = g_new0 (GtkEventController*, 0 + 1);
	self->priv->top_controllers = _tmp0_;
	self->priv->top_controllers_length1 = 0;
	self->priv->_top_controllers_size_ = self->priv->top_controllers_length1;
	self->priv->bottom_controllers_new = NULL;
}

static void
tuba_widgets_sandwich_source_view_finalize (GObject * obj)
{
	TubaWidgetsSandwichSourceView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TUBA_WIDGETS_TYPE_SANDWICH_SOURCE_VIEW, TubaWidgetsSandwichSourceView);
	g_debug ("SandwichSourceView.vala:10: Destroying SandwichSourceView");
	_g_object_unref0 (self->priv->top_child);
	_g_object_unref0 (self->priv->bottom_child);
	_g_object_unref0 (self->priv->scroll_animation);
	self->priv->top_controllers = (_vala_array_free (self->priv->top_controllers, self->priv->top_controllers_length1, (GDestroyNotify) g_object_unref), NULL);
	_g_object_unref0 (self->priv->bottom_controllers_new);
	_g_object_unref0 (self->priv->bottom_child_box);
	G_OBJECT_CLASS (tuba_widgets_sandwich_source_view_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
tuba_widgets_sandwich_source_view_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TubaWidgetsSandwichSourceViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tuba_widgets_sandwich_source_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TubaWidgetsSandwichSourceView), 0, (GInstanceInitFunc) tuba_widgets_sandwich_source_view_instance_init, NULL };
	GType tuba_widgets_sandwich_source_view_type_id;
	tuba_widgets_sandwich_source_view_type_id = g_type_register_static (gtk_source_view_get_type (), "TubaWidgetsSandwichSourceView", &g_define_type_info, G_TYPE_FLAG_NONE);
	TubaWidgetsSandwichSourceView_private_offset = g_type_add_instance_private (tuba_widgets_sandwich_source_view_type_id, sizeof (TubaWidgetsSandwichSourceViewPrivate));
	return tuba_widgets_sandwich_source_view_type_id;
}

GType
tuba_widgets_sandwich_source_view_get_type (void)
{
	static GType tuba_widgets_sandwich_source_view_type_id__once = 0;
	if (g_once_init_enter_pointer (&tuba_widgets_sandwich_source_view_type_id__once)) {
		GType tuba_widgets_sandwich_source_view_type_id;
		tuba_widgets_sandwich_source_view_type_id = tuba_widgets_sandwich_source_view_get_type_once ();
		g_once_init_leave_pointer (&tuba_widgets_sandwich_source_view_type_id__once, tuba_widgets_sandwich_source_view_type_id);
	}
	return tuba_widgets_sandwich_source_view_type_id__once;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

