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

/*
Copyright (C) 2014 2015 Johan Mattsson

This library is free software; you can redistribute it and/or modify 
it under the terms of the GNU Lesser General Public License as 
published by the Free Software Foundation; either version 3 of the 
License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but 
WITHOUT ANY WARRANTY; without even the implied warranty of 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
Lesser General Public License for more details.
*/

#include "birdfont.h"
#include <glib.h>
#include <cairo-gobject.h>
#include <float.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <gee.h>
#include <glib-object.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

enum  {
	BIRD_FONT_TABLE_LAYOUT_0_PROPERTY,
	BIRD_FONT_TABLE_LAYOUT_NUM_PROPERTIES
};
static GParamSpec* bird_font_table_layout_properties[BIRD_FONT_TABLE_LAYOUT_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_source_unref0(var) ((var == NULL) ? NULL : (var = (g_source_unref (var), NULL)))

struct _BirdFontTableLayoutPrivate {
	gboolean ignore_input;
};

static gint BirdFontTableLayout_private_offset;
static gpointer bird_font_table_layout_parent_class = NULL;

static void bird_font_table_layout_real_draw (BirdFontFontDisplay* base,
                                       BirdFontWidgetAllocation* allocation,
                                       cairo_t* cr);
static void bird_font_table_layout_layout (BirdFontTableLayout* self);
static void bird_font_table_layout_real_key_press (BirdFontFontDisplay* base,
                                            guint keyval);
static void bird_font_table_layout_focus_previous (BirdFontTableLayout* self);
static void bird_font_table_layout_focus_next (BirdFontTableLayout* self);
static void bird_font_table_layout_real_button_press (BirdFontFontDisplay* base,
                                               guint button,
                                               gdouble x,
                                               gdouble y);
static void bird_font_table_layout_real_button_release (BirdFontFontDisplay* base,
                                                 gint button,
                                                 gdouble x,
                                                 gdouble y);
static void bird_font_table_layout_real_motion_notify (BirdFontFontDisplay* base,
                                                gdouble x,
                                                gdouble y);
static gchar* bird_font_table_layout_real_get_label (BirdFontFontDisplay* base);
static gchar* bird_font_table_layout_real_get_name (BirdFontFontDisplay* base);
static gboolean bird_font_table_layout_real_has_scrollbar (BirdFontFontDisplay* base);
static void bird_font_table_layout_real_scroll_wheel (BirdFontFontDisplay* base,
                                               gdouble x,
                                               gdouble y,
                                               gdouble pixeldelta,
                                               gdouble dy);
static void bird_font_table_layout_real_selected_canvas (BirdFontFontDisplay* base);
static gboolean __lambda121_ (BirdFontTableLayout* self);
static gboolean ___lambda121__gsource_func (gpointer self);
static void bird_font_table_layout_real_update_scrollbar (BirdFontFontDisplay* base);
static void bird_font_table_layout_real_scroll_to (BirdFontFontDisplay* base,
                                            gdouble percent);
static gboolean bird_font_table_layout_real_needs_modifier (BirdFontFontDisplay* base);
static void bird_font_table_layout_real_double_click (BirdFontFontDisplay* base,
                                               guint button,
                                               gdouble x,
                                               gdouble y);
static void bird_font_table_layout_finalize (GObject * obj);
static GType bird_font_table_layout_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
bird_font_table_layout_get_instance_private (BirdFontTableLayout* self)
{
	return G_STRUCT_MEMBER_P (self, BirdFontTableLayout_private_offset);
}

BirdFontTableLayout*
bird_font_table_layout_construct (GType object_type)
{
	BirdFontTableLayout * self = NULL;
	self = (BirdFontTableLayout*) bird_font_font_display_construct (object_type);
	return self;
}

BirdFontTableLayout*
bird_font_table_layout_new (void)
{
	return bird_font_table_layout_construct (BIRD_FONT_TYPE_TABLE_LAYOUT);
}

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

static void
bird_font_table_layout_real_draw (BirdFontFontDisplay* base,
                                  BirdFontWidgetAllocation* allocation,
                                  cairo_t* cr)
{
	BirdFontTableLayout * self;
	BirdFontWidgetAllocation* _tmp0_;
	self = (BirdFontTableLayout*) base;
	g_return_if_fail (allocation != NULL);
	g_return_if_fail (cr != NULL);
	_tmp0_ = _g_object_ref0 (allocation);
	_g_object_unref0 (self->allocation);
	self->allocation = _tmp0_;
	bird_font_table_layout_layout (self);
	cairo_save (cr);
	cairo_rectangle (cr, (gdouble) 0, (gdouble) 0, (gdouble) allocation->width, (gdouble) allocation->height);
	cairo_set_line_width (cr, (gdouble) 0);
	bird_font_theme_color (cr, "Default Background");
	cairo_fill (cr);
	cairo_stroke (cr);
	cairo_restore (cr);
	{
		GeeArrayList* _w_list = NULL;
		GeeArrayList* _tmp1_;
		gint _w_size = 0;
		GeeArrayList* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		gint _w_index = 0;
		_tmp1_ = self->widgets;
		_w_list = _tmp1_;
		_tmp2_ = _w_list;
		_tmp3_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp2_);
		_tmp4_ = _tmp3_;
		_w_size = _tmp4_;
		_w_index = -1;
		while (TRUE) {
			gint _tmp5_;
			gint _tmp6_;
			BirdFontWidget* w = NULL;
			GeeArrayList* _tmp7_;
			gpointer _tmp8_;
			BirdFontWidget* _tmp9_;
			_w_index = _w_index + 1;
			_tmp5_ = _w_index;
			_tmp6_ = _w_size;
			if (!(_tmp5_ < _tmp6_)) {
				break;
			}
			_tmp7_ = _w_list;
			_tmp8_ = gee_abstract_list_get ((GeeAbstractList*) _tmp7_, _w_index);
			w = (BirdFontWidget*) _tmp8_;
			_tmp9_ = w;
			if (bird_font_widget_is_on_screen (_tmp9_)) {
				BirdFontWidget* _tmp10_;
				_tmp10_ = w;
				if (BIRD_FONT_IS_TEXT (_tmp10_)) {
					BirdFontWidget* _tmp11_;
					cairo_save (cr);
					bird_font_theme_color (cr, "Foreground 1");
					_tmp11_ = w;
					bird_font_widget_draw (_tmp11_, cr);
					cairo_restore (cr);
				} else {
					BirdFontWidget* _tmp12_;
					_tmp12_ = w;
					bird_font_widget_draw (_tmp12_, cr);
				}
			}
			_g_object_unref0 (w);
		}
	}
}

static void
bird_font_table_layout_layout (BirdFontTableLayout* self)
{
	gdouble y = 0.0;
	g_return_if_fail (self != NULL);
	y = -self->scroll;
	{
		GeeArrayList* _w_list = NULL;
		GeeArrayList* _tmp0_;
		gint _w_size = 0;
		GeeArrayList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _w_index = 0;
		_tmp0_ = self->widgets;
		_w_list = _tmp0_;
		_tmp1_ = _w_list;
		_tmp2_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_w_size = _tmp3_;
		_w_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			BirdFontWidget* w = NULL;
			GeeArrayList* _tmp6_;
			gpointer _tmp7_;
			BirdFontWidget* _tmp8_;
			BirdFontWidget* _tmp9_;
			BirdFontWidget* _tmp10_;
			BirdFontWidgetAllocation* _tmp11_;
			BirdFontWidgetAllocation* _tmp12_;
			BirdFontWidget* _tmp13_;
			BirdFontWidget* _tmp15_;
			BirdFontWidget* _tmp16_;
			_w_index = _w_index + 1;
			_tmp4_ = _w_index;
			_tmp5_ = _w_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _w_list;
			_tmp7_ = gee_abstract_list_get ((GeeAbstractList*) _tmp6_, _w_index);
			w = (BirdFontWidget*) _tmp7_;
			_tmp8_ = w;
			_tmp8_->widget_x = (gdouble) 17;
			_tmp9_ = w;
			_tmp9_->widget_y = y;
			_tmp10_ = w;
			_tmp11_ = self->allocation;
			_tmp12_ = _g_object_ref0 (_tmp11_);
			_g_object_unref0 (_tmp10_->allocation);
			_tmp10_->allocation = _tmp12_;
			_tmp13_ = w;
			if (BIRD_FONT_IS_TEXT_AREA (_tmp13_)) {
				BirdFontWidget* _tmp14_;
				_tmp14_ = w;
				bird_font_widget_layout ((BirdFontWidget*) G_TYPE_CHECK_INSTANCE_CAST (_tmp14_, BIRD_FONT_TYPE_TEXT_AREA, BirdFontTextArea));
			}
			_tmp15_ = w;
			_tmp16_ = w;
			y += bird_font_widget_get_height (_tmp15_) + _tmp16_->margin_bottom;
			_g_object_unref0 (w);
		}
	}
	self->content_height = y + self->scroll;
	bird_font_font_display_update_scrollbar ((BirdFontFontDisplay*) self);
}

void
bird_font_table_layout_scroll_event (BirdFontTableLayout* self,
                                     gdouble p)
{
	g_return_if_fail (self != NULL);
	self->scroll = self->scroll + p;
	bird_font_table_layout_layout (self);
	bird_font_glyph_canvas_redraw ();
}

static void
bird_font_table_layout_real_key_press (BirdFontFontDisplay* base,
                                       guint keyval)
{
	BirdFontTableLayout * self;
	BirdFontWidget* focus = NULL;
	self = (BirdFontTableLayout*) base;
	if (keyval == ((guint) BIRD_FONT_KEY_SHIFT_TAB)) {
		bird_font_table_layout_focus_previous (self);
	} else {
		if (keyval == ((guint) BIRD_FONT_KEY_TAB)) {
			bird_font_table_layout_focus_next (self);
		} else {
			BirdFontWidget* _tmp0_;
			_tmp0_ = self->keyboard_focus;
			if (_tmp0_ != NULL) {
				BirdFontWidget* _tmp1_;
				BirdFontWidget* _tmp2_;
				BirdFontWidget* _tmp3_;
				_tmp1_ = self->keyboard_focus;
				_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, BIRD_FONT_TYPE_WIDGET, BirdFontWidget));
				_g_object_unref0 (focus);
				focus = _tmp2_;
				_tmp3_ = focus;
				bird_font_widget_key_press (_tmp3_, keyval);
			}
		}
	}
	bird_font_glyph_canvas_redraw ();
	_g_object_unref0 (focus);
}

static void
bird_font_table_layout_focus_previous (BirdFontTableLayout* self)
{
	gint _tmp0_;
	GeeArrayList* _tmp1_;
	gpointer _tmp2_;
	BirdFontWidget* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->focus_index;
	self->focus_index = _tmp0_ - 1;
	if (self->focus_index < 0) {
		self->focus_index = 0;
	}
	_tmp1_ = self->focus_ring;
	_tmp2_ = gee_abstract_list_get ((GeeAbstractList*) _tmp1_, self->focus_index);
	_tmp3_ = (BirdFontWidget*) _tmp2_;
	bird_font_table_layout_set_focus (self, _tmp3_);
	_g_object_unref0 (_tmp3_);
}

static void
bird_font_table_layout_focus_next (BirdFontTableLayout* self)
{
	gint _tmp0_;
	GeeArrayList* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	GeeArrayList* _tmp7_;
	gpointer _tmp8_;
	BirdFontWidget* _tmp9_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->focus_index;
	self->focus_index = _tmp0_ + 1;
	_tmp1_ = self->focus_ring;
	_tmp2_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp1_);
	_tmp3_ = _tmp2_;
	if (self->focus_index >= _tmp3_) {
		GeeArrayList* _tmp4_;
		gint _tmp5_;
		gint _tmp6_;
		_tmp4_ = self->focus_ring;
		_tmp5_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp4_);
		_tmp6_ = _tmp5_;
		self->focus_index = _tmp6_ - 1;
	}
	_tmp7_ = self->focus_ring;
	_tmp8_ = gee_abstract_list_get ((GeeAbstractList*) _tmp7_, self->focus_index);
	_tmp9_ = (BirdFontWidget*) _tmp8_;
	bird_font_table_layout_set_focus (self, _tmp9_);
	_g_object_unref0 (_tmp9_);
}

static void
bird_font_table_layout_real_button_press (BirdFontFontDisplay* base,
                                          guint button,
                                          gdouble x,
                                          gdouble y)
{
	BirdFontTableLayout * self;
	BirdFontWidget* t = NULL;
	BirdFontWidget* old = NULL;
	BirdFontCheckBox* c = NULL;
	self = (BirdFontTableLayout*) base;
	if (self->priv->ignore_input) {
		bird_font_printd ("Ignoring extra clicks.");
		_g_object_unref0 (c);
		_g_object_unref0 (old);
		_g_object_unref0 (t);
		return;
	}
	{
		GeeArrayList* _w_list = NULL;
		GeeArrayList* _tmp0_;
		gint _w_size = 0;
		GeeArrayList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _w_index = 0;
		_tmp0_ = self->widgets;
		_w_list = _tmp0_;
		_tmp1_ = _w_list;
		_tmp2_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_w_size = _tmp3_;
		_w_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			BirdFontWidget* w = NULL;
			GeeArrayList* _tmp6_;
			gpointer _tmp7_;
			BirdFontWidget* _tmp8_;
			_w_index = _w_index + 1;
			_tmp4_ = _w_index;
			_tmp5_ = _w_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _w_list;
			_tmp7_ = gee_abstract_list_get ((GeeAbstractList*) _tmp6_, _w_index);
			w = (BirdFontWidget*) _tmp7_;
			_tmp8_ = w;
			if (bird_font_widget_is_over (_tmp8_, x, y)) {
				BirdFontWidget* _tmp9_;
				_tmp9_ = w;
				if (BIRD_FONT_IS_TEXT_AREA (_tmp9_)) {
					BirdFontWidget* _tmp10_;
					BirdFontWidget* _tmp11_;
					gboolean _tmp12_ = FALSE;
					BirdFontWidget* _tmp13_;
					BirdFontWidget* _tmp19_;
					BirdFontWidget* _tmp20_;
					_tmp10_ = w;
					_tmp11_ = _g_object_ref0 ((BirdFontWidget*) G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, BIRD_FONT_TYPE_TEXT_AREA, BirdFontTextArea));
					_g_object_unref0 (t);
					t = _tmp11_;
					_tmp13_ = self->keyboard_focus;
					if (_tmp13_ != NULL) {
						BirdFontWidget* _tmp14_;
						BirdFontWidget* _tmp15_;
						_tmp14_ = self->keyboard_focus;
						_tmp15_ = t;
						_tmp12_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp14_, BIRD_FONT_TYPE_WIDGET, BirdFontWidget) != _tmp15_;
					} else {
						_tmp12_ = FALSE;
					}
					if (_tmp12_) {
						BirdFontWidget* _tmp16_;
						BirdFontWidget* _tmp17_;
						BirdFontWidget* _tmp18_;
						_tmp16_ = self->keyboard_focus;
						_tmp17_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp16_, BIRD_FONT_TYPE_WIDGET, BirdFontWidget));
						_g_object_unref0 (old);
						old = _tmp17_;
						_tmp18_ = old;
						bird_font_widget_focus (_tmp18_, FALSE);
					}
					_tmp19_ = t;
					bird_font_table_layout_set_focus (self, _tmp19_);
					_tmp20_ = t;
					bird_font_widget_button_press (_tmp20_, button, x, y);
				} else {
					BirdFontWidget* _tmp21_;
					_tmp21_ = w;
					if (BIRD_FONT_IS_CHECK_BOX (_tmp21_)) {
						BirdFontWidget* _tmp22_;
						BirdFontCheckBox* _tmp23_;
						BirdFontCheckBox* _tmp24_;
						BirdFontCheckBox* _tmp25_;
						_tmp22_ = w;
						_tmp23_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp22_, BIRD_FONT_TYPE_CHECK_BOX, BirdFontCheckBox));
						_g_object_unref0 (c);
						c = _tmp23_;
						_tmp24_ = c;
						_tmp25_ = c;
						bird_font_check_box_set_checked (_tmp24_, !_tmp25_->checked);
					} else {
						BirdFontWidget* _tmp26_;
						_tmp26_ = w;
						bird_font_widget_button_press (_tmp26_, button, x, y);
					}
				}
			}
			_g_object_unref0 (w);
		}
	}
	bird_font_glyph_canvas_redraw ();
	_g_object_unref0 (c);
	_g_object_unref0 (old);
	_g_object_unref0 (t);
}

void
bird_font_table_layout_set_focus (BirdFontTableLayout* self,
                                  BirdFontWidget* w)
{
	BirdFontWidget* old = NULL;
	gboolean _tmp0_ = FALSE;
	BirdFontWidget* _tmp1_;
	BirdFontWidget* _tmp6_;
	GeeArrayList* _tmp7_;
	GeeArrayList* _tmp8_;
	gint _tmp9_;
	gint _tmp10_;
	gint _tmp11_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (w != NULL);
	_tmp1_ = self->keyboard_focus;
	if (_tmp1_ != NULL) {
		BirdFontWidget* _tmp2_;
		_tmp2_ = self->keyboard_focus;
		_tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, BIRD_FONT_TYPE_WIDGET, BirdFontWidget) != w;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		BirdFontWidget* _tmp3_;
		BirdFontWidget* _tmp4_;
		BirdFontWidget* _tmp5_;
		_tmp3_ = self->keyboard_focus;
		_tmp4_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, BIRD_FONT_TYPE_WIDGET, BirdFontWidget));
		_g_object_unref0 (old);
		old = _tmp4_;
		_tmp5_ = old;
		bird_font_widget_focus (_tmp5_, FALSE);
	}
	_tmp6_ = _g_object_ref0 (w);
	_g_object_unref0 (self->keyboard_focus);
	self->keyboard_focus = _tmp6_;
	bird_font_widget_focus (w, TRUE);
	_tmp7_ = self->focus_ring;
	self->focus_index = gee_abstract_list_index_of ((GeeAbstractList*) _tmp7_, w);
	_tmp8_ = self->focus_ring;
	_tmp9_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp8_);
	_tmp10_ = _tmp9_;
	_tmp11_ = self->focus_index;
	if (!((0 <= _tmp11_) && (_tmp11_ < _tmp10_))) {
		self->focus_index = 0;
	}
	bird_font_font_display_update_scrollbar ((BirdFontFontDisplay*) self);
	bird_font_glyph_canvas_redraw ();
	_g_object_unref0 (old);
}

static void
bird_font_table_layout_real_button_release (BirdFontFontDisplay* base,
                                            gint button,
                                            gdouble x,
                                            gdouble y)
{
	BirdFontTableLayout * self;
	BirdFontWidget* t = NULL;
	BirdFontWidget* _tmp0_;
	self = (BirdFontTableLayout*) base;
	if (self->priv->ignore_input) {
		bird_font_printd ("Ignoring extra clicks.");
		_g_object_unref0 (t);
		return;
	}
	_tmp0_ = self->keyboard_focus;
	if (_tmp0_ != NULL) {
		BirdFontWidget* _tmp1_;
		BirdFontWidget* _tmp2_;
		BirdFontWidget* _tmp3_;
		BirdFontWidget* _tmp4_;
		_tmp1_ = self->keyboard_focus;
		_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, BIRD_FONT_TYPE_WIDGET, BirdFontWidget));
		_g_object_unref0 (t);
		t = _tmp2_;
		_tmp3_ = t;
		bird_font_table_layout_set_focus (self, _tmp3_);
		_tmp4_ = t;
		bird_font_widget_button_release (_tmp4_, (guint) button, x, y);
	}
	{
		GeeArrayList* _w_list = NULL;
		GeeArrayList* _tmp5_;
		gint _w_size = 0;
		GeeArrayList* _tmp6_;
		gint _tmp7_;
		gint _tmp8_;
		gint _w_index = 0;
		_tmp5_ = self->widgets;
		_w_list = _tmp5_;
		_tmp6_ = _w_list;
		_tmp7_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp6_);
		_tmp8_ = _tmp7_;
		_w_size = _tmp8_;
		_w_index = -1;
		while (TRUE) {
			gint _tmp9_;
			gint _tmp10_;
			BirdFontWidget* w = NULL;
			GeeArrayList* _tmp11_;
			gpointer _tmp12_;
			BirdFontWidget* _tmp13_;
			_w_index = _w_index + 1;
			_tmp9_ = _w_index;
			_tmp10_ = _w_size;
			if (!(_tmp9_ < _tmp10_)) {
				break;
			}
			_tmp11_ = _w_list;
			_tmp12_ = gee_abstract_list_get ((GeeAbstractList*) _tmp11_, _w_index);
			w = (BirdFontWidget*) _tmp12_;
			_tmp13_ = w;
			if (bird_font_widget_is_over (_tmp13_, x, y)) {
				BirdFontWidget* _tmp14_;
				_tmp14_ = w;
				bird_font_widget_button_release (_tmp14_, (guint) button, x, y);
			}
			_g_object_unref0 (w);
		}
	}
	bird_font_glyph_canvas_redraw ();
	_g_object_unref0 (t);
}

static void
bird_font_table_layout_real_motion_notify (BirdFontFontDisplay* base,
                                           gdouble x,
                                           gdouble y)
{
	BirdFontTableLayout * self;
	BirdFontWidget* t = NULL;
	BirdFontWidget* _tmp0_;
	self = (BirdFontTableLayout*) base;
	_tmp0_ = self->keyboard_focus;
	if (_tmp0_ != NULL) {
		BirdFontWidget* _tmp1_;
		BirdFontWidget* _tmp2_;
		BirdFontWidget* _tmp3_;
		_tmp1_ = self->keyboard_focus;
		_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, BIRD_FONT_TYPE_WIDGET, BirdFontWidget));
		_g_object_unref0 (t);
		t = _tmp2_;
		_tmp3_ = t;
		if (bird_font_widget_motion (_tmp3_, x, y)) {
			bird_font_glyph_canvas_redraw ();
		}
	}
	_g_object_unref0 (t);
}

static gchar*
bird_font_table_layout_real_get_label (BirdFontFontDisplay* base)
{
	BirdFontTableLayout * self;
	gchar* _tmp0_;
	gchar* result;
	self = (BirdFontTableLayout*) base;
	_tmp0_ = bird_font_t_ ("Name and Description");
	result = _tmp0_;
	return result;
}

static gchar*
bird_font_table_layout_real_get_name (BirdFontFontDisplay* base)
{
	BirdFontTableLayout * self;
	gchar* _tmp0_;
	gchar* result;
	self = (BirdFontTableLayout*) base;
	_tmp0_ = g_strdup ("Description");
	result = _tmp0_;
	return result;
}

static gboolean
bird_font_table_layout_real_has_scrollbar (BirdFontFontDisplay* base)
{
	BirdFontTableLayout * self;
	gboolean result;
	self = (BirdFontTableLayout*) base;
	result = TRUE;
	return result;
}

static void
bird_font_table_layout_real_scroll_wheel (BirdFontFontDisplay* base,
                                          gdouble x,
                                          gdouble y,
                                          gdouble pixeldelta,
                                          gdouble dy)
{
	BirdFontTableLayout * self;
	BirdFontWidgetAllocation* _tmp0_;
	self = (BirdFontTableLayout*) base;
	self->scroll = self->scroll - dy;
	_tmp0_ = self->allocation;
	if ((self->scroll + _tmp0_->height) >= self->content_height) {
		BirdFontWidgetAllocation* _tmp1_;
		_tmp1_ = self->allocation;
		self->scroll = self->content_height - _tmp1_->height;
		if (self->scroll < ((gdouble) 0)) {
			self->scroll = (gdouble) 0;
		}
	}
	if (self->scroll < ((gdouble) 0)) {
		self->scroll = (gdouble) 0;
	}
	bird_font_font_display_update_scrollbar ((BirdFontFontDisplay*) self);
	bird_font_glyph_canvas_redraw ();
}

static gboolean
__lambda121_ (BirdFontTableLayout* self)
{
	gboolean result;
	self->priv->ignore_input = FALSE;
	result = FALSE;
	return result;
}

static gboolean
___lambda121__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda121_ ((BirdFontTableLayout*) self);
	return result;
}

static void
bird_font_table_layout_real_selected_canvas (BirdFontFontDisplay* base)
{
	BirdFontTableLayout * self;
	GSource* input_delay = NULL;
	GSource* _tmp0_;
	self = (BirdFontTableLayout*) base;
	self->priv->ignore_input = TRUE;
	_tmp0_ = g_timeout_source_new ((guint) 250);
	input_delay = _tmp0_;
	g_source_set_callback (input_delay, ___lambda121__gsource_func, g_object_ref (self), g_object_unref);
	g_source_attach (input_delay, NULL);
	bird_font_key_bindings_set_require_modifier (TRUE);
	bird_font_font_display_update_scrollbar ((BirdFontFontDisplay*) self);
	bird_font_glyph_canvas_redraw ();
	_g_source_unref0 (input_delay);
}

static void
bird_font_table_layout_real_update_scrollbar (BirdFontFontDisplay* base)
{
	BirdFontTableLayout * self;
	gdouble h = 0.0;
	BirdFontWidgetAllocation* _tmp0_;
	BirdFontWidgetAllocation* _tmp1_;
	self = (BirdFontTableLayout*) base;
	_tmp0_ = self->allocation;
	h = self->content_height - _tmp0_->height;
	_tmp1_ = self->allocation;
	bird_font_main_window_set_scrollbar_size (_tmp1_->height / self->content_height);
	bird_font_main_window_set_scrollbar_position (self->scroll / h);
}

static void
bird_font_table_layout_real_scroll_to (BirdFontFontDisplay* base,
                                       gdouble percent)
{
	BirdFontTableLayout * self;
	gdouble h = 0.0;
	BirdFontWidgetAllocation* _tmp0_;
	self = (BirdFontTableLayout*) base;
	_tmp0_ = self->allocation;
	h = self->content_height - _tmp0_->height;
	self->scroll = percent * h;
	bird_font_glyph_canvas_redraw ();
}

static gboolean
bird_font_table_layout_real_needs_modifier (BirdFontFontDisplay* base)
{
	BirdFontTableLayout * self;
	gboolean result;
	self = (BirdFontTableLayout*) base;
	result = TRUE;
	return result;
}

static void
bird_font_table_layout_real_double_click (BirdFontFontDisplay* base,
                                          guint button,
                                          gdouble x,
                                          gdouble y)
{
	BirdFontTableLayout * self;
	BirdFontWidget* t = NULL;
	BirdFontWidget* _tmp0_;
	self = (BirdFontTableLayout*) base;
	if (self->priv->ignore_input) {
		bird_font_printd ("Ignoring extra clicks.");
		_g_object_unref0 (t);
		return;
	}
	_tmp0_ = self->keyboard_focus;
	if (_tmp0_ != NULL) {
		BirdFontWidget* _tmp1_;
		BirdFontWidget* _tmp2_;
		BirdFontWidget* _tmp3_;
		BirdFontWidget* _tmp4_;
		_tmp1_ = self->keyboard_focus;
		_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, BIRD_FONT_TYPE_WIDGET, BirdFontWidget));
		_g_object_unref0 (t);
		t = _tmp2_;
		_tmp3_ = t;
		bird_font_table_layout_set_focus (self, _tmp3_);
		_tmp4_ = t;
		bird_font_widget_double_click (_tmp4_, button, x, y);
	}
	{
		GeeArrayList* _w_list = NULL;
		GeeArrayList* _tmp5_;
		gint _w_size = 0;
		GeeArrayList* _tmp6_;
		gint _tmp7_;
		gint _tmp8_;
		gint _w_index = 0;
		_tmp5_ = self->widgets;
		_w_list = _tmp5_;
		_tmp6_ = _w_list;
		_tmp7_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp6_);
		_tmp8_ = _tmp7_;
		_w_size = _tmp8_;
		_w_index = -1;
		while (TRUE) {
			gint _tmp9_;
			gint _tmp10_;
			BirdFontWidget* w = NULL;
			GeeArrayList* _tmp11_;
			gpointer _tmp12_;
			BirdFontWidget* _tmp13_;
			_w_index = _w_index + 1;
			_tmp9_ = _w_index;
			_tmp10_ = _w_size;
			if (!(_tmp9_ < _tmp10_)) {
				break;
			}
			_tmp11_ = _w_list;
			_tmp12_ = gee_abstract_list_get ((GeeAbstractList*) _tmp11_, _w_index);
			w = (BirdFontWidget*) _tmp12_;
			_tmp13_ = w;
			if (bird_font_widget_is_over (_tmp13_, x, y)) {
				BirdFontWidget* _tmp14_;
				_tmp14_ = w;
				bird_font_widget_double_click (_tmp14_, button, x, y);
			}
			_g_object_unref0 (w);
		}
	}
	bird_font_glyph_canvas_redraw ();
	_g_object_unref0 (t);
}

static void
bird_font_table_layout_class_init (BirdFontTableLayoutClass * klass,
                                   gpointer klass_data)
{
	bird_font_table_layout_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BirdFontTableLayout_private_offset);
	((BirdFontFontDisplayClass *) klass)->draw = (void (*) (BirdFontFontDisplay*, BirdFontWidgetAllocation*, cairo_t*)) bird_font_table_layout_real_draw;
	((BirdFontFontDisplayClass *) klass)->key_press = (void (*) (BirdFontFontDisplay*, guint)) bird_font_table_layout_real_key_press;
	((BirdFontFontDisplayClass *) klass)->button_press = (void (*) (BirdFontFontDisplay*, guint, gdouble, gdouble)) bird_font_table_layout_real_button_press;
	((BirdFontFontDisplayClass *) klass)->button_release = (void (*) (BirdFontFontDisplay*, gint, gdouble, gdouble)) bird_font_table_layout_real_button_release;
	((BirdFontFontDisplayClass *) klass)->motion_notify = (void (*) (BirdFontFontDisplay*, gdouble, gdouble)) bird_font_table_layout_real_motion_notify;
	((BirdFontFontDisplayClass *) klass)->get_label = (gchar* (*) (BirdFontFontDisplay*)) bird_font_table_layout_real_get_label;
	((BirdFontFontDisplayClass *) klass)->get_name = (gchar* (*) (BirdFontFontDisplay*)) bird_font_table_layout_real_get_name;
	((BirdFontFontDisplayClass *) klass)->has_scrollbar = (gboolean (*) (BirdFontFontDisplay*)) bird_font_table_layout_real_has_scrollbar;
	((BirdFontFontDisplayClass *) klass)->scroll_wheel = (void (*) (BirdFontFontDisplay*, gdouble, gdouble, gdouble, gdouble)) bird_font_table_layout_real_scroll_wheel;
	((BirdFontFontDisplayClass *) klass)->selected_canvas = (void (*) (BirdFontFontDisplay*)) bird_font_table_layout_real_selected_canvas;
	((BirdFontFontDisplayClass *) klass)->update_scrollbar = (void (*) (BirdFontFontDisplay*)) bird_font_table_layout_real_update_scrollbar;
	((BirdFontFontDisplayClass *) klass)->scroll_to = (void (*) (BirdFontFontDisplay*, gdouble)) bird_font_table_layout_real_scroll_to;
	((BirdFontFontDisplayClass *) klass)->needs_modifier = (gboolean (*) (BirdFontFontDisplay*)) bird_font_table_layout_real_needs_modifier;
	((BirdFontFontDisplayClass *) klass)->double_click = (void (*) (BirdFontFontDisplay*, guint, gdouble, gdouble)) bird_font_table_layout_real_double_click;
	G_OBJECT_CLASS (klass)->finalize = bird_font_table_layout_finalize;
}

static void
bird_font_table_layout_instance_init (BirdFontTableLayout * self,
                                      gpointer klass)
{
	BirdFontWidgetAllocation* _tmp0_;
	GeeArrayList* _tmp1_;
	GeeArrayList* _tmp2_;
	self->priv = bird_font_table_layout_get_instance_private (self);
	self->scroll = (gdouble) 0;
	self->content_height = (gdouble) 1;
	_tmp0_ = bird_font_widget_allocation_new ();
	self->allocation = _tmp0_;
	_tmp1_ = gee_array_list_new (BIRD_FONT_TYPE_WIDGET, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	self->widgets = _tmp1_;
	_tmp2_ = gee_array_list_new (BIRD_FONT_TYPE_WIDGET, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	self->focus_ring = _tmp2_;
	self->focus_index = 0;
	self->priv->ignore_input = TRUE;
	self->keyboard_focus = NULL;
}

static void
bird_font_table_layout_finalize (GObject * obj)
{
	BirdFontTableLayout * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BIRD_FONT_TYPE_TABLE_LAYOUT, BirdFontTableLayout);
	_g_object_unref0 (self->allocation);
	_g_object_unref0 (self->widgets);
	_g_object_unref0 (self->focus_ring);
	_g_object_unref0 (self->keyboard_focus);
	G_OBJECT_CLASS (bird_font_table_layout_parent_class)->finalize (obj);
}

static GType
bird_font_table_layout_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontTableLayoutClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_table_layout_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontTableLayout), 0, (GInstanceInitFunc) bird_font_table_layout_instance_init, NULL };
	GType bird_font_table_layout_type_id;
	bird_font_table_layout_type_id = g_type_register_static (BIRD_FONT_TYPE_FONT_DISPLAY, "BirdFontTableLayout", &g_define_type_info, 0);
	BirdFontTableLayout_private_offset = g_type_add_instance_private (bird_font_table_layout_type_id, sizeof (BirdFontTableLayoutPrivate));
	return bird_font_table_layout_type_id;
}

GType
bird_font_table_layout_get_type (void)
{
	static volatile gsize bird_font_table_layout_type_id__once = 0;
	if (g_once_init_enter (&bird_font_table_layout_type_id__once)) {
		GType bird_font_table_layout_type_id;
		bird_font_table_layout_type_id = bird_font_table_layout_get_type_once ();
		g_once_init_leave (&bird_font_table_layout_type_id__once, bird_font_table_layout_type_id);
	}
	return bird_font_table_layout_type_id__once;
}

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

