/* math-popover.c generated by valac 0.56.0, the Vala compiler
 * generated from math-popover.vala, do not modify */

/*
 * Copyright (C) 2021 Robert Roth
 *
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
 * license.
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include "calculator.h"
#include <gio/gio.h>

#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define TYPE_MATH_POPOVER (math_popover_get_type ())
#define MATH_POPOVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MATH_POPOVER, MathPopover))
#define MATH_POPOVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MATH_POPOVER, MathPopoverClass))
#define IS_MATH_POPOVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MATH_POPOVER))
#define IS_MATH_POPOVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MATH_POPOVER))
#define MATH_POPOVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MATH_POPOVER, MathPopoverClass))

typedef struct _MathPopover MathPopover;
typedef struct _MathPopoverClass MathPopoverClass;
typedef struct _MathPopoverPrivate MathPopoverPrivate;
enum  {
	MATH_POPOVER_0_PROPERTY,
	MATH_POPOVER_T_TYPE,
	MATH_POPOVER_T_DUP_FUNC,
	MATH_POPOVER_T_DESTROY_FUNC,
	MATH_POPOVER_NUM_PROPERTIES
};
static GParamSpec* math_popover_properties[MATH_POPOVER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block3Data Block3Data;
#define _g_free0(var) (var = (g_free (var), NULL))
enum  {
	MATH_POPOVER_ITEM_EDITED_SIGNAL,
	MATH_POPOVER_ITEM_DELETED_SIGNAL,
	MATH_POPOVER_NUM_SIGNALS
};
static guint math_popover_signals[MATH_POPOVER_NUM_SIGNALS] = {0};

struct _MathPopover {
	GtkPopover parent_instance;
	MathPopoverPrivate * priv;
	MathEquation* equation;
	GListStore* model;
};

struct _MathPopoverClass {
	GtkPopoverClass parent_class;
	gint (*get_item_index) (MathPopover* self, gconstpointer item);
	gboolean (*is_deletable) (MathPopover* self, gconstpointer item);
	gboolean (*is_editable) (MathPopover* self, gconstpointer item);
	gchar* (*get_item_text) (MathPopover* self, gconstpointer item);
};

struct _MathPopoverPrivate {
	GType t_type;
	GBoxedCopyFunc t_dup_func;
	GDestroyNotify t_destroy_func;
	GCompareDataFunc compare_func;
	gpointer compare_func_target;
	GDestroyNotify compare_func_target_destroy_notify;
};

struct _Block3Data {
	int _ref_count_;
	MathPopover* self;
	GCompareDataFunc compare_func;
	gpointer compare_func_target;
};

static gint MathPopover_private_offset;
static gpointer math_popover_parent_class = NULL;

VALA_EXTERN GType math_popover_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MathPopover, g_object_unref)
VALA_EXTERN gint math_popover_get_item_index (MathPopover* self,
                                  gconstpointer item);
VALA_EXTERN gboolean math_popover_is_deletable (MathPopover* self,
                                    gconstpointer item);
VALA_EXTERN gboolean math_popover_is_editable (MathPopover* self,
                                   gconstpointer item);
VALA_EXTERN gchar* math_popover_get_item_text (MathPopover* self,
                                   gconstpointer item);
VALA_EXTERN MathPopover* math_popover_construct (GType object_type,
                                     GType t_type,
                                     GBoxedCopyFunc t_dup_func,
                                     GDestroyNotify t_destroy_func,
                                     MathEquation* equation,
                                     GListStore* model,
                                     GCompareDataFunc compare_func,
                                     gpointer compare_func_target);
static Block3Data* block3_data_ref (Block3Data* _data3_);
static void block3_data_unref (void * _userdata_);
static gint __lambda19_ (Block3Data* _data3_,
                  gconstpointer a,
                  gconstpointer b);
static gint ___lambda19__gcompare_data_func (gconstpointer a,
                                      gconstpointer b,
                                      gpointer self);
VALA_EXTERN void math_popover_item_added_cb (MathPopover* self,
                                 gconstpointer item);
static gint __lambda20_ (MathPopover* self,
                  GObject* a,
                  GObject* b);
static gint ___lambda20__gcompare_data_func (gconstpointer a,
                                      gconstpointer b,
                                      gpointer self);
VALA_EXTERN void math_popover_item_edited_cb (MathPopover* self,
                                  gconstpointer item);
VALA_EXTERN void math_popover_item_deleted_cb (MathPopover* self,
                                   gconstpointer item);
static gint math_popover_real_get_item_index (MathPopover* self,
                                       gconstpointer item);
static gboolean math_popover_real_is_deletable (MathPopover* self,
                                         gconstpointer item);
static gboolean math_popover_real_is_editable (MathPopover* self,
                                        gconstpointer item);
static gchar* math_popover_real_get_item_text (MathPopover* self,
                                        gconstpointer item);
VALA_EXTERN GtkWidget* math_popover_make_item_row (MathPopover* self,
                                       gconstpointer item);
static void math_popover_save_function_cb (MathPopover* self,
                                    GtkWidget* widget);
static void _math_popover_save_function_cb_gtk_button_clicked (GtkButton* _sender,
                                                        gpointer self);
static void math_popover_delete_function_cb (MathPopover* self,
                                      GtkWidget* widget);
static void _math_popover_delete_function_cb_gtk_button_clicked (GtkButton* _sender,
                                                          gpointer self);
static void math_popover_finalize (GObject * obj);
static GType math_popover_get_type_once (void);
static void _vala_math_popover_get_property (GObject * object,
                                      guint property_id,
                                      GValue * value,
                                      GParamSpec * pspec);
static void _vala_math_popover_set_property (GObject * object,
                                      guint property_id,
                                      const GValue * value,
                                      GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
math_popover_get_instance_private (MathPopover* self)
{
	return G_STRUCT_MEMBER_P (self, MathPopover_private_offset);
}

static Block3Data*
block3_data_ref (Block3Data* _data3_)
{
	g_atomic_int_inc (&_data3_->_ref_count_);
	return _data3_;
}

static void
block3_data_unref (void * _userdata_)
{
	Block3Data* _data3_;
	_data3_ = (Block3Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data3_->_ref_count_)) {
		MathPopover* self;
		self = _data3_->self;
		_g_object_unref0 (self);
		g_slice_free (Block3Data, _data3_);
	}
}

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

static gint
__lambda19_ (Block3Data* _data3_,
             gconstpointer a,
             gconstpointer b)
{
	MathPopover* self;
	gint result;
	self = _data3_->self;
	result = _data3_->compare_func (a, b, _data3_->compare_func_target);
	return result;
}

static gint
___lambda19__gcompare_data_func (gconstpointer a,
                                 gconstpointer b,
                                 gpointer self)
{
	gint result;
	result = __lambda19_ (self, a, b);
	return result;
}

MathPopover*
math_popover_construct (GType object_type,
                        GType t_type,
                        GBoxedCopyFunc t_dup_func,
                        GDestroyNotify t_destroy_func,
                        MathEquation* equation,
                        GListStore* model,
                        GCompareDataFunc compare_func,
                        gpointer compare_func_target)
{
	MathPopover * self = NULL;
	Block3Data* _data3_;
	MathEquation* _tmp0_;
	GListStore* _tmp1_;
	g_return_val_if_fail (equation != NULL, NULL);
	g_return_val_if_fail (model != NULL, NULL);
	_data3_ = g_slice_new0 (Block3Data);
	_data3_->_ref_count_ = 1;
	_data3_->compare_func = compare_func;
	_data3_->compare_func_target = compare_func_target;
	self = (MathPopover*) g_object_new (object_type, "t-type", t_type, "t-dup-func", t_dup_func, "t-destroy-func", t_destroy_func, NULL);
	_data3_->self = g_object_ref (self);
	self->priv->t_type = t_type;
	self->priv->t_dup_func = t_dup_func;
	self->priv->t_destroy_func = t_destroy_func;
	_tmp0_ = _g_object_ref0 (equation);
	_g_object_unref0 (self->equation);
	self->equation = _tmp0_;
	_tmp1_ = _g_object_ref0 (model);
	_g_object_unref0 (self->model);
	self->model = _tmp1_;
	(self->priv->compare_func_target_destroy_notify == NULL) ? NULL : (self->priv->compare_func_target_destroy_notify (self->priv->compare_func_target), NULL);
	self->priv->compare_func = NULL;
	self->priv->compare_func_target = NULL;
	self->priv->compare_func_target_destroy_notify = NULL;
	self->priv->compare_func = ___lambda19__gcompare_data_func;
	self->priv->compare_func_target = block3_data_ref (_data3_);
	self->priv->compare_func_target_destroy_notify = block3_data_unref;
	block3_data_unref (_data3_);
	_data3_ = NULL;
	return self;
}

static gint
__lambda20_ (MathPopover* self,
             GObject* a,
             GObject* b)
{
	GCompareDataFunc _tmp0_;
	gpointer _tmp0__target;
	gint result;
	g_return_val_if_fail (a != NULL, 0);
	g_return_val_if_fail (b != NULL, 0);
	_tmp0_ = self->priv->compare_func;
	_tmp0__target = self->priv->compare_func_target;
	result = _tmp0_ (a, b, _tmp0__target);
	return result;
}

static gint
___lambda20__gcompare_data_func (gconstpointer a,
                                 gconstpointer b,
                                 gpointer self)
{
	gint result;
	result = __lambda20_ ((MathPopover*) self, (GObject*) a, (GObject*) b);
	return result;
}

void
math_popover_item_added_cb (MathPopover* self,
                            gconstpointer item)
{
	GListStore* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->model;
	g_list_store_insert_sorted (_tmp0_, G_TYPE_CHECK_INSTANCE_TYPE (item, G_TYPE_OBJECT) ? ((GObject*) item) : NULL, ___lambda20__gcompare_data_func, self);
}

void
math_popover_item_edited_cb (MathPopover* self,
                             gconstpointer item)
{
	g_return_if_fail (self != NULL);
	math_popover_item_deleted_cb (self, item);
	math_popover_item_added_cb (self, item);
}

void
math_popover_item_deleted_cb (MathPopover* self,
                              gconstpointer item)
{
	gint position = 0;
	g_return_if_fail (self != NULL);
	position = math_popover_get_item_index (self, item);
	if (position >= 0) {
		GListStore* _tmp0_;
		_tmp0_ = self->model;
		g_list_store_remove (_tmp0_, (guint) position);
	}
}

static gint
math_popover_real_get_item_index (MathPopover* self,
                                  gconstpointer item)
{
	gint _tmp0_ = 0;
	g_critical ("Type `%s' does not implement abstract method `math_popover_get_item_index'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return _tmp0_;
}

gint
math_popover_get_item_index (MathPopover* self,
                             gconstpointer item)
{
	MathPopoverClass* _klass_;
	g_return_val_if_fail (self != NULL, 0);
	_klass_ = MATH_POPOVER_GET_CLASS (self);
	if (_klass_->get_item_index) {
		return _klass_->get_item_index (self, item);
	}
	return -1;
}

static gboolean
math_popover_real_is_deletable (MathPopover* self,
                                gconstpointer item)
{
	gboolean _tmp0_ = FALSE;
	g_critical ("Type `%s' does not implement abstract method `math_popover_is_deletable'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return _tmp0_;
}

gboolean
math_popover_is_deletable (MathPopover* self,
                           gconstpointer item)
{
	MathPopoverClass* _klass_;
	g_return_val_if_fail (self != NULL, FALSE);
	_klass_ = MATH_POPOVER_GET_CLASS (self);
	if (_klass_->is_deletable) {
		return _klass_->is_deletable (self, item);
	}
	return FALSE;
}

static gboolean
math_popover_real_is_editable (MathPopover* self,
                               gconstpointer item)
{
	gboolean _tmp0_ = FALSE;
	g_critical ("Type `%s' does not implement abstract method `math_popover_is_editable'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return _tmp0_;
}

gboolean
math_popover_is_editable (MathPopover* self,
                          gconstpointer item)
{
	MathPopoverClass* _klass_;
	g_return_val_if_fail (self != NULL, FALSE);
	_klass_ = MATH_POPOVER_GET_CLASS (self);
	if (_klass_->is_editable) {
		return _klass_->is_editable (self, item);
	}
	return FALSE;
}

static gchar*
math_popover_real_get_item_text (MathPopover* self,
                                 gconstpointer item)
{
	g_critical ("Type `%s' does not implement abstract method `math_popover_get_item_text'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return NULL;
}

gchar*
math_popover_get_item_text (MathPopover* self,
                            gconstpointer item)
{
	MathPopoverClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = MATH_POPOVER_GET_CLASS (self);
	if (_klass_->get_item_text) {
		return _klass_->get_item_text (self, item);
	}
	return NULL;
}

static void
_math_popover_save_function_cb_gtk_button_clicked (GtkButton* _sender,
                                                   gpointer self)
{
	math_popover_save_function_cb ((MathPopover*) self, _sender);
}

static void
_math_popover_delete_function_cb_gtk_button_clicked (GtkButton* _sender,
                                                     gpointer self)
{
	math_popover_delete_function_cb ((MathPopover*) self, _sender);
}

GtkWidget*
math_popover_make_item_row (MathPopover* self,
                            gconstpointer item)
{
	GtkBox* hbox = NULL;
	GtkBox* _tmp0_;
	GtkLabel* label = NULL;
	gchar* _tmp1_;
	gchar* _tmp2_;
	GtkLabel* _tmp3_;
	GtkLabel* _tmp4_;
	GtkLabel* _tmp5_;
	GtkLabel* _tmp6_;
	GtkLabel* _tmp7_;
	GtkBox* _tmp8_;
	GtkLabel* _tmp9_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	g_object_ref_sink (_tmp0_);
	hbox = _tmp0_;
	_tmp1_ = math_popover_get_item_text (self, item);
	_tmp2_ = _tmp1_;
	_tmp3_ = (GtkLabel*) gtk_label_new (_tmp2_);
	g_object_ref_sink (_tmp3_);
	_tmp4_ = _tmp3_;
	_g_free0 (_tmp2_);
	label = _tmp4_;
	_tmp5_ = label;
	gtk_widget_set_margin_start ((GtkWidget*) _tmp5_, 6);
	_tmp6_ = label;
	gtk_label_set_use_markup (_tmp6_, TRUE);
	_tmp7_ = label;
	gtk_widget_set_halign ((GtkWidget*) _tmp7_, GTK_ALIGN_START);
	_tmp8_ = hbox;
	_tmp9_ = label;
	gtk_box_append (_tmp8_, (GtkWidget*) _tmp9_);
	if (math_popover_is_editable (self, item)) {
		GtkButton* button = NULL;
		GtkButton* _tmp10_;
		GtkButton* _tmp11_;
		GtkStyleContext* _tmp12_;
		GtkButton* _tmp13_;
		GObject* _tmp14_;
		GtkButton* _tmp15_;
		GtkBox* _tmp16_;
		GtkButton* _tmp17_;
		_tmp10_ = (GtkButton*) gtk_button_new_from_icon_name ("document-edit-symbolic");
		g_object_ref_sink (_tmp10_);
		button = _tmp10_;
		_tmp11_ = button;
		_tmp12_ = gtk_widget_get_style_context ((GtkWidget*) _tmp11_);
		gtk_style_context_add_class (_tmp12_, "flat");
		_tmp13_ = button;
		_tmp14_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (item, G_TYPE_OBJECT) ? ((GObject*) item) : NULL);
		g_object_set_data_full ((GObject*) _tmp13_, "object", _tmp14_, g_object_unref);
		_tmp15_ = button;
		g_signal_connect_object (_tmp15_, "clicked", (GCallback) _math_popover_save_function_cb_gtk_button_clicked, self, 0);
		_tmp16_ = hbox;
		_tmp17_ = button;
		gtk_box_append (_tmp16_, (GtkWidget*) _tmp17_);
		_g_object_unref0 (button);
	}
	if (math_popover_is_deletable (self, item)) {
		GtkButton* button = NULL;
		GtkButton* _tmp18_;
		GtkButton* _tmp19_;
		GtkStyleContext* _tmp20_;
		GtkButton* _tmp21_;
		GObject* _tmp22_;
		GtkButton* _tmp23_;
		GtkBox* _tmp24_;
		GtkButton* _tmp25_;
		_tmp18_ = (GtkButton*) gtk_button_new_from_icon_name ("list-remove-symbolic");
		g_object_ref_sink (_tmp18_);
		button = _tmp18_;
		_tmp19_ = button;
		_tmp20_ = gtk_widget_get_style_context ((GtkWidget*) _tmp19_);
		gtk_style_context_add_class (_tmp20_, "flat");
		_tmp21_ = button;
		_tmp22_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (item, G_TYPE_OBJECT) ? ((GObject*) item) : NULL);
		g_object_set_data_full ((GObject*) _tmp21_, "object", _tmp22_, g_object_unref);
		_tmp23_ = button;
		g_signal_connect_object (_tmp23_, "clicked", (GCallback) _math_popover_delete_function_cb_gtk_button_clicked, self, 0);
		_tmp24_ = hbox;
		_tmp25_ = button;
		gtk_box_append (_tmp24_, (GtkWidget*) _tmp25_);
		_g_object_unref0 (button);
	}
	result = (GtkWidget*) hbox;
	_g_object_unref0 (label);
	return result;
}

static void
math_popover_save_function_cb (MathPopover* self,
                               GtkWidget* widget)
{
	gconstpointer _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (widget != NULL);
	_tmp0_ = g_object_get_data ((GObject*) widget, "object");
	g_signal_emit (self, math_popover_signals[MATH_POPOVER_ITEM_EDITED_SIGNAL], 0, (gconstpointer) ((GObject*) _tmp0_));
}

static void
math_popover_delete_function_cb (MathPopover* self,
                                 GtkWidget* widget)
{
	gconstpointer _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (widget != NULL);
	_tmp0_ = g_object_get_data ((GObject*) widget, "object");
	g_signal_emit (self, math_popover_signals[MATH_POPOVER_ITEM_DELETED_SIGNAL], 0, (gconstpointer) ((GObject*) _tmp0_));
}

static void
math_popover_class_init (MathPopoverClass * klass,
                         gpointer klass_data)
{
	math_popover_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &MathPopover_private_offset);
	((MathPopoverClass *) klass)->get_item_index = (gint (*) (MathPopover*, gconstpointer)) math_popover_real_get_item_index;
	((MathPopoverClass *) klass)->is_deletable = (gboolean (*) (MathPopover*, gconstpointer)) math_popover_real_is_deletable;
	((MathPopoverClass *) klass)->is_editable = (gboolean (*) (MathPopover*, gconstpointer)) math_popover_real_is_editable;
	((MathPopoverClass *) klass)->get_item_text = (gchar* (*) (MathPopover*, gconstpointer)) math_popover_real_get_item_text;
	G_OBJECT_CLASS (klass)->get_property = _vala_math_popover_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_math_popover_set_property;
	G_OBJECT_CLASS (klass)->finalize = math_popover_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), MATH_POPOVER_T_TYPE, g_param_spec_gtype ("t-type", "type", "type", G_TYPE_NONE, G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), MATH_POPOVER_T_DUP_FUNC, g_param_spec_pointer ("t-dup-func", "dup func", "dup func", G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), MATH_POPOVER_T_DESTROY_FUNC, g_param_spec_pointer ("t-destroy-func", "destroy func", "destroy func", G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
	math_popover_signals[MATH_POPOVER_ITEM_EDITED_SIGNAL] = g_signal_new ("item-edited", TYPE_MATH_POPOVER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);
	math_popover_signals[MATH_POPOVER_ITEM_DELETED_SIGNAL] = g_signal_new ("item-deleted", TYPE_MATH_POPOVER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);
}

static void
math_popover_instance_init (MathPopover * self,
                            gpointer klass)
{
	self->priv = math_popover_get_instance_private (self);
}

static void
math_popover_finalize (GObject * obj)
{
	MathPopover * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_MATH_POPOVER, MathPopover);
	_g_object_unref0 (self->equation);
	_g_object_unref0 (self->model);
	(self->priv->compare_func_target_destroy_notify == NULL) ? NULL : (self->priv->compare_func_target_destroy_notify (self->priv->compare_func_target), NULL);
	self->priv->compare_func = NULL;
	self->priv->compare_func_target = NULL;
	self->priv->compare_func_target_destroy_notify = NULL;
	G_OBJECT_CLASS (math_popover_parent_class)->finalize (obj);
}

static GType
math_popover_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (MathPopoverClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) math_popover_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MathPopover), 0, (GInstanceInitFunc) math_popover_instance_init, NULL };
	GType math_popover_type_id;
	math_popover_type_id = g_type_register_static (gtk_popover_get_type (), "MathPopover", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	MathPopover_private_offset = g_type_add_instance_private (math_popover_type_id, sizeof (MathPopoverPrivate));
	return math_popover_type_id;
}

GType
math_popover_get_type (void)
{
	static volatile gsize math_popover_type_id__once = 0;
	if (g_once_init_enter (&math_popover_type_id__once)) {
		GType math_popover_type_id;
		math_popover_type_id = math_popover_get_type_once ();
		g_once_init_leave (&math_popover_type_id__once, math_popover_type_id);
	}
	return math_popover_type_id__once;
}

static void
_vala_math_popover_get_property (GObject * object,
                                 guint property_id,
                                 GValue * value,
                                 GParamSpec * pspec)
{
	MathPopover * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_MATH_POPOVER, MathPopover);
	switch (property_id) {
		case MATH_POPOVER_T_TYPE:
		g_value_set_gtype (value, self->priv->t_type);
		break;
		case MATH_POPOVER_T_DUP_FUNC:
		g_value_set_pointer (value, self->priv->t_dup_func);
		break;
		case MATH_POPOVER_T_DESTROY_FUNC:
		g_value_set_pointer (value, self->priv->t_destroy_func);
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_math_popover_set_property (GObject * object,
                                 guint property_id,
                                 const GValue * value,
                                 GParamSpec * pspec)
{
	MathPopover * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_MATH_POPOVER, MathPopover);
	switch (property_id) {
		case MATH_POPOVER_T_TYPE:
		self->priv->t_type = g_value_get_gtype (value);
		break;
		case MATH_POPOVER_T_DUP_FUNC:
		self->priv->t_dup_func = g_value_get_pointer (value);
		break;
		case MATH_POPOVER_T_DESTROY_FUNC:
		self->priv->t_destroy_func = g_value_get_pointer (value);
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

