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

/*
 * Copyright (C) 2013 Garima Joshi
 *
 * 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 <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include "libcalculator.h"
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include <gdk/gdk.h>


#define TYPE_MATH_FUNCTION_POPOVER (math_function_popover_get_type ())
#define MATH_FUNCTION_POPOVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MATH_FUNCTION_POPOVER, MathFunctionPopover))
#define MATH_FUNCTION_POPOVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MATH_FUNCTION_POPOVER, MathFunctionPopoverClass))
#define IS_MATH_FUNCTION_POPOVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MATH_FUNCTION_POPOVER))
#define IS_MATH_FUNCTION_POPOVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MATH_FUNCTION_POPOVER))
#define MATH_FUNCTION_POPOVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MATH_FUNCTION_POPOVER, MathFunctionPopoverClass))

typedef struct _MathFunctionPopover MathFunctionPopover;
typedef struct _MathFunctionPopoverClass MathFunctionPopoverClass;
typedef struct _MathFunctionPopoverPrivate MathFunctionPopoverPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block1Data Block1Data;
#define _g_free0(var) (var = (g_free (var), NULL))

struct _MathFunctionPopover {
	GtkPopover parent_instance;
	MathFunctionPopoverPrivate * priv;
};

struct _MathFunctionPopoverClass {
	GtkPopoverClass parent_class;
};

struct _MathFunctionPopoverPrivate {
	MathEquation* equation;
	GtkListBox* function_list;
	GtkEntry* function_name_entry;
	gboolean function_name_entry_placeholder_reseted;
	GtkButton* add_function_button;
	GtkSpinButton* add_arguments_button;
};

struct _Block1Data {
	int _ref_count_;
	MathFunctionPopover* self;
	GtkListBoxRow* row;
	MathFunction* function;
};


static gpointer math_function_popover_parent_class = NULL;
static gchar** math_function_popover_FUNCTION_ARGS;
static gint math_function_popover_FUNCTION_ARGS_length1;
static gchar** math_function_popover_FUNCTION_ARGS = NULL;
static gint math_function_popover_FUNCTION_ARGS_length1 = 0;
static gint _math_function_popover_FUNCTION_ARGS_size_ = 0;

GType math_function_popover_get_type (void) G_GNUC_CONST;
#define MATH_FUNCTION_POPOVER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_MATH_FUNCTION_POPOVER, MathFunctionPopoverPrivate))
enum  {
	MATH_FUNCTION_POPOVER_DUMMY_PROPERTY
};
MathFunctionPopover* math_function_popover_new (MathEquation* equation);
MathFunctionPopover* math_function_popover_construct (GType object_type, MathEquation* equation);
static GtkListBoxRow* math_function_popover_make_function_row (MathFunctionPopover* self, MathFunction* function);
static gint math_function_popover_function_list_sort (MathFunctionPopover* self, GtkListBoxRow* row1, GtkListBoxRow* row2);
static gint _math_function_popover_function_list_sort_gtk_list_box_sort_func (GtkListBoxRow* row1, GtkListBoxRow* row2, gpointer self);
static void __lambda16_ (MathFunctionPopover* self, MathFunction* function);
static void ___lambda16__function_manager_function_added (FunctionManager* _sender, MathFunction* function, gpointer self);
static void __lambda17_ (MathFunctionPopover* self, MathFunction* function);
static GtkListBoxRow* math_function_popover_find_row_for_function (MathFunctionPopover* self, MathFunction* function);
static void ___lambda17__function_manager_function_edited (FunctionManager* _sender, MathFunction* new_function, gpointer self);
static void __lambda19_ (MathFunctionPopover* self, MathFunction* function);
static void ___lambda19__function_manager_function_deleted (FunctionManager* _sender, MathFunction* function, gpointer self);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
static void __lambda18_ (Block1Data* _data1_, GtkWidget* child);
static void ___lambda18__gtk_callback (GtkWidget* widget, gpointer self);
static void math_function_popover_insert_function_cb (MathFunctionPopover* self, GtkListBoxRow* row);
static void _math_function_popover_insert_function_cb_gtk_list_box_row_activated (GtkListBox* _sender, GtkListBoxRow* row, gpointer self);
static gboolean math_function_popover_function_name_mouse_click_cb (MathFunctionPopover* self, GtkWidget* widget, GdkEventButton* event);
static gboolean _math_function_popover_function_name_mouse_click_cb_gtk_widget_button_press_event (GtkWidget* _sender, GdkEventButton* event, gpointer self);
static gboolean math_function_popover_function_name_key_press_cb (MathFunctionPopover* self, GtkWidget* widget, GdkEventKey* event);
static gboolean _math_function_popover_function_name_key_press_cb_gtk_widget_key_press_event (GtkWidget* _sender, GdkEventKey* event, gpointer self);
static void math_function_popover_function_name_changed_cb (MathFunctionPopover* self);
static void _math_function_popover_function_name_changed_cb_gtk_editable_changed (GtkEditable* _sender, gpointer self);
static void math_function_popover_add_function_cb (MathFunctionPopover* self, GtkWidget* widget);
static void _math_function_popover_add_function_cb_gtk_button_clicked (GtkButton* _sender, gpointer self);
static void math_function_popover_save_function_cb (MathFunctionPopover* self, GtkWidget* widget);
static void math_function_popover_delete_function_cb (MathFunctionPopover* self, GtkWidget* widget);
static void _math_function_popover_save_function_cb_gtk_button_clicked (GtkButton* _sender, gpointer self);
static void _math_function_popover_delete_function_cb_gtk_button_clicked (GtkButton* _sender, gpointer self);
static void math_function_popover_finalize (GObject * obj);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);


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


static gint _math_function_popover_function_list_sort_gtk_list_box_sort_func (GtkListBoxRow* row1, GtkListBoxRow* row2, gpointer self) {
	gint result;
	result = math_function_popover_function_list_sort ((MathFunctionPopover*) self, row1, row2);
	return result;
}


static void __lambda16_ (MathFunctionPopover* self, MathFunction* function) {
	GtkListBox* _tmp0_;
	MathFunction* _tmp1_;
	GtkListBoxRow* _tmp2_;
	GtkListBoxRow* _tmp3_;
	g_return_if_fail (function != NULL);
	_tmp0_ = self->priv->function_list;
	_tmp1_ = function;
	_tmp2_ = math_function_popover_make_function_row (self, _tmp1_);
	_tmp3_ = _tmp2_;
	gtk_container_add ((GtkContainer*) _tmp0_, (GtkWidget*) _tmp3_);
	_g_object_unref0 (_tmp3_);
}


static void ___lambda16__function_manager_function_added (FunctionManager* _sender, MathFunction* function, gpointer self) {
	__lambda16_ ((MathFunctionPopover*) self, function);
}


static void __lambda17_ (MathFunctionPopover* self, MathFunction* function) {
	GtkListBox* _tmp0_;
	MathFunction* _tmp1_;
	GtkListBoxRow* _tmp2_;
	GtkListBoxRow* _tmp3_;
	GtkListBox* _tmp4_;
	MathFunction* _tmp5_;
	GtkListBoxRow* _tmp6_;
	GtkListBoxRow* _tmp7_;
	g_return_if_fail (function != NULL);
	_tmp0_ = self->priv->function_list;
	_tmp1_ = function;
	_tmp2_ = math_function_popover_find_row_for_function (self, _tmp1_);
	_tmp3_ = _tmp2_;
	gtk_container_remove ((GtkContainer*) _tmp0_, (GtkWidget*) _tmp3_);
	_g_object_unref0 (_tmp3_);
	_tmp4_ = self->priv->function_list;
	_tmp5_ = function;
	_tmp6_ = math_function_popover_make_function_row (self, _tmp5_);
	_tmp7_ = _tmp6_;
	gtk_container_add ((GtkContainer*) _tmp4_, (GtkWidget*) _tmp7_);
	_g_object_unref0 (_tmp7_);
}


static void ___lambda17__function_manager_function_edited (FunctionManager* _sender, MathFunction* new_function, gpointer self) {
	__lambda17_ ((MathFunctionPopover*) self, new_function);
}


static void __lambda19_ (MathFunctionPopover* self, MathFunction* function) {
	GtkListBox* _tmp0_;
	MathFunction* _tmp1_;
	GtkListBoxRow* _tmp2_;
	GtkListBoxRow* _tmp3_;
	g_return_if_fail (function != NULL);
	_tmp0_ = self->priv->function_list;
	_tmp1_ = function;
	_tmp2_ = math_function_popover_find_row_for_function (self, _tmp1_);
	_tmp3_ = _tmp2_;
	gtk_container_remove ((GtkContainer*) _tmp0_, (GtkWidget*) _tmp3_);
	_g_object_unref0 (_tmp3_);
}


static void ___lambda19__function_manager_function_deleted (FunctionManager* _sender, MathFunction* function, gpointer self) {
	__lambda19_ ((MathFunctionPopover*) self, function);
}


MathFunctionPopover* math_function_popover_construct (GType object_type, MathEquation* equation) {
	MathFunctionPopover * self = NULL;
	MathEquation* _tmp0_;
	MathEquation* _tmp1_;
	FunctionManager* function_manager = NULL;
	FunctionManager* _tmp2_;
	gchar** names = NULL;
	FunctionManager* _tmp3_;
	gint _tmp4_;
	gchar** _tmp5_;
	gint names_length1;
	gint _names_size_;
	GtkListBox* _tmp20_;
	FunctionManager* _tmp21_;
	FunctionManager* _tmp22_;
	FunctionManager* _tmp23_;
	GtkSpinButton* _tmp24_;
	GtkSpinButton* _tmp25_;
	g_return_val_if_fail (equation != NULL, NULL);
	self = (MathFunctionPopover*) g_object_new (object_type, NULL);
	_tmp0_ = equation;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->equation);
	self->priv->equation = _tmp1_;
	_tmp2_ = function_manager_get_default_function_manager ();
	function_manager = _tmp2_;
	_tmp3_ = function_manager;
	_tmp5_ = function_manager_get_names (_tmp3_, &_tmp4_);
	names = _tmp5_;
	names_length1 = _tmp4_;
	_names_size_ = names_length1;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp6_ = FALSE;
			_tmp6_ = TRUE;
			while (TRUE) {
				gchar** _tmp8_;
				gint _tmp8__length1;
				gint _tmp9_;
				const gchar* _tmp10_;
				MathFunction* function = NULL;
				FunctionManager* _tmp11_;
				gchar** _tmp12_;
				gint _tmp12__length1;
				gint _tmp13_;
				const gchar* _tmp14_;
				MathFunction* _tmp15_;
				GtkListBox* _tmp16_;
				MathFunction* _tmp17_;
				GtkListBoxRow* _tmp18_;
				GtkListBoxRow* _tmp19_;
				if (!_tmp6_) {
					gint _tmp7_;
					_tmp7_ = i;
					i = _tmp7_ + 1;
				}
				_tmp6_ = FALSE;
				_tmp8_ = names;
				_tmp8__length1 = names_length1;
				_tmp9_ = i;
				_tmp10_ = _tmp8_[_tmp9_];
				if (!(_tmp10_ != NULL)) {
					break;
				}
				_tmp11_ = function_manager;
				_tmp12_ = names;
				_tmp12__length1 = names_length1;
				_tmp13_ = i;
				_tmp14_ = _tmp12_[_tmp13_];
				_tmp15_ = function_manager_get (_tmp11_, _tmp14_);
				function = _tmp15_;
				_tmp16_ = self->priv->function_list;
				_tmp17_ = function;
				_tmp18_ = math_function_popover_make_function_row (self, _tmp17_);
				_tmp19_ = _tmp18_;
				gtk_container_add ((GtkContainer*) _tmp16_, (GtkWidget*) _tmp19_);
				_g_object_unref0 (_tmp19_);
				_g_object_unref0 (function);
			}
		}
	}
	_tmp20_ = self->priv->function_list;
	gtk_list_box_set_sort_func (_tmp20_, _math_function_popover_function_list_sort_gtk_list_box_sort_func, g_object_ref (self), g_object_unref);
	_tmp21_ = function_manager;
	g_signal_connect_object (_tmp21_, "function-added", (GCallback) ___lambda16__function_manager_function_added, self, 0);
	_tmp22_ = function_manager;
	g_signal_connect_object (_tmp22_, "function-edited", (GCallback) ___lambda17__function_manager_function_edited, self, 0);
	_tmp23_ = function_manager;
	g_signal_connect_object (_tmp23_, "function-deleted", (GCallback) ___lambda19__function_manager_function_deleted, self, 0);
	_tmp24_ = self->priv->add_arguments_button;
	gtk_spin_button_set_range (_tmp24_, (gdouble) 1, (gdouble) 10);
	_tmp25_ = self->priv->add_arguments_button;
	gtk_spin_button_set_increments (_tmp25_, (gdouble) 1, (gdouble) 1);
	names = (_vala_array_free (names, names_length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (function_manager);
	return self;
}


MathFunctionPopover* math_function_popover_new (MathEquation* equation) {
	return math_function_popover_construct (TYPE_MATH_FUNCTION_POPOVER, equation);
}


static Block1Data* block1_data_ref (Block1Data* _data1_) {
	g_atomic_int_inc (&_data1_->_ref_count_);
	return _data1_;
}


static void block1_data_unref (void * _userdata_) {
	Block1Data* _data1_;
	_data1_ = (Block1Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		MathFunctionPopover* self;
		self = _data1_->self;
		_g_object_unref0 (_data1_->function);
		_g_object_unref0 (self);
		g_slice_free (Block1Data, _data1_);
	}
}


static void __lambda18_ (Block1Data* _data1_, GtkWidget* child) {
	MathFunctionPopover* self;
	MathFunction* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	GtkWidget* _tmp3_;
	gconstpointer _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	self = _data1_->self;
	g_return_if_fail (child != NULL);
	_tmp0_ = _data1_->function;
	_tmp1_ = math_function_get_name (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = child;
	_tmp4_ = g_object_get_data ((GObject*) _tmp3_, "function");
	_tmp5_ = math_function_get_name ((MathFunction*) _tmp4_);
	_tmp6_ = _tmp5_;
	if (g_strcmp0 (_tmp2_, _tmp6_) == 0) {
		GtkWidget* _tmp7_;
		_tmp7_ = child;
		_data1_->row = G_TYPE_CHECK_INSTANCE_TYPE (_tmp7_, gtk_list_box_row_get_type ()) ? ((GtkListBoxRow*) _tmp7_) : NULL;
	}
}


static void ___lambda18__gtk_callback (GtkWidget* widget, gpointer self) {
	__lambda18_ (self, widget);
}


static GtkListBoxRow* math_function_popover_find_row_for_function (MathFunctionPopover* self, MathFunction* function) {
	GtkListBoxRow* result = NULL;
	Block1Data* _data1_;
	MathFunction* _tmp0_;
	MathFunction* _tmp1_;
	GtkListBox* _tmp2_;
	GtkListBoxRow* _tmp3_;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (function != NULL, NULL);
	_data1_ = g_slice_new0 (Block1Data);
	_data1_->_ref_count_ = 1;
	_data1_->self = g_object_ref (self);
	_tmp0_ = function;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (_data1_->function);
	_data1_->function = _tmp1_;
	_data1_->row = NULL;
	_tmp2_ = self->priv->function_list;
	gtk_container_foreach ((GtkContainer*) _tmp2_, ___lambda18__gtk_callback, _data1_);
	_tmp3_ = _g_object_ref0 (_data1_->row);
	result = _tmp3_;
	block1_data_unref (_data1_);
	_data1_ = NULL;
	return result;
}


static void math_function_popover_insert_function_cb (MathFunctionPopover* self, GtkListBoxRow* row) {
	MathFunction* function = NULL;
	GtkListBoxRow* _tmp0_;
	gconstpointer _tmp1_;
	MathFunction* _tmp2_;
	MathEquation* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	GtkTextIter end = {0};
	MathEquation* _tmp8_;
	MathEquation* _tmp9_;
	GtkTextMark* _tmp10_;
	GtkTextIter _tmp11_ = {0};
	MathEquation* _tmp12_;
	GtkTextIter _tmp13_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (row != NULL);
	_tmp0_ = row;
	_tmp1_ = g_object_get_data ((GObject*) _tmp0_, "function");
	_tmp2_ = _g_object_ref0 ((MathFunction*) _tmp1_);
	function = _tmp2_;
	_tmp3_ = self->priv->equation;
	_tmp4_ = math_function_get_name (function);
	_tmp5_ = _tmp4_;
	_tmp6_ = g_strconcat (_tmp5_, "()", NULL);
	_tmp7_ = _tmp6_;
	math_equation_insert (_tmp3_, _tmp7_);
	_g_free0 (_tmp7_);
	_tmp8_ = self->priv->equation;
	_tmp9_ = self->priv->equation;
	_tmp10_ = gtk_text_buffer_get_insert ((GtkTextBuffer*) _tmp9_);
	gtk_text_buffer_get_iter_at_mark ((GtkTextBuffer*) _tmp8_, &_tmp11_, _tmp10_);
	end = _tmp11_;
	gtk_text_iter_backward_chars (&end, 1);
	_tmp12_ = self->priv->equation;
	_tmp13_ = end;
	gtk_text_buffer_place_cursor ((GtkTextBuffer*) _tmp12_, &_tmp13_);
	_g_object_unref0 (function);
}


static void _math_function_popover_insert_function_cb_gtk_list_box_row_activated (GtkListBox* _sender, GtkListBoxRow* row, gpointer self) {
	math_function_popover_insert_function_cb ((MathFunctionPopover*) self, row);
}


static gboolean math_function_popover_function_name_mouse_click_cb (MathFunctionPopover* self, GtkWidget* widget, GdkEventButton* event) {
	gboolean result = FALSE;
	gboolean _tmp0_;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (widget != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = self->priv->function_name_entry_placeholder_reseted;
	if (!_tmp0_) {
		GtkEntry* _tmp1_;
		self->priv->function_name_entry_placeholder_reseted = TRUE;
		_tmp1_ = self->priv->function_name_entry;
		gtk_entry_set_text (_tmp1_, "");
	}
	result = FALSE;
	return result;
}


static gboolean _math_function_popover_function_name_mouse_click_cb_gtk_widget_button_press_event (GtkWidget* _sender, GdkEventButton* event, gpointer self) {
	gboolean result;
	result = math_function_popover_function_name_mouse_click_cb ((MathFunctionPopover*) self, _sender, event);
	return result;
}


static gboolean math_function_popover_function_name_key_press_cb (MathFunctionPopover* self, GtkWidget* widget, GdkEventKey* event) {
	gboolean result = FALSE;
	gboolean _tmp0_ = FALSE;
	GdkEventKey* _tmp1_;
	guint _tmp2_;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (widget != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	self->priv->function_name_entry_placeholder_reseted = TRUE;
	_tmp1_ = event;
	_tmp2_ = _tmp1_->keyval;
	if (_tmp2_ == ((guint) GDK_KEY_space)) {
		_tmp0_ = TRUE;
	} else {
		GdkEventKey* _tmp3_;
		guint _tmp4_;
		_tmp3_ = event;
		_tmp4_ = _tmp3_->keyval;
		_tmp0_ = _tmp4_ == ((guint) GDK_KEY_KP_Space);
	}
	if (_tmp0_) {
		GdkEventKey* _tmp5_;
		_tmp5_ = event;
		_tmp5_->keyval = (guint) GDK_KEY_underscore;
	}
	result = FALSE;
	return result;
}


static gboolean _math_function_popover_function_name_key_press_cb_gtk_widget_key_press_event (GtkWidget* _sender, GdkEventKey* event, gpointer self) {
	gboolean result;
	result = math_function_popover_function_name_key_press_cb ((MathFunctionPopover*) self, _sender, event);
	return result;
}


static void math_function_popover_function_name_changed_cb (MathFunctionPopover* self) {
	GtkButton* _tmp0_;
	GtkEntry* _tmp1_;
	const gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->add_function_button;
	_tmp1_ = self->priv->function_name_entry;
	_tmp2_ = gtk_entry_get_text (_tmp1_);
	gtk_widget_set_sensitive ((GtkWidget*) _tmp0_, g_strcmp0 (_tmp2_, "") != 0);
}


static void _math_function_popover_function_name_changed_cb_gtk_editable_changed (GtkEditable* _sender, gpointer self) {
	math_function_popover_function_name_changed_cb ((MathFunctionPopover*) self);
}


static gchar* _vala_g_strjoinv (const gchar* separator, gchar** str_array, int str_array_length1) {
	gchar* result = NULL;
	const gchar* _tmp0_;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	gchar** _tmp3_;
	gint _tmp3__length1;
	_tmp0_ = separator;
	if (_tmp0_ == NULL) {
		separator = "";
	}
	_tmp3_ = str_array;
	_tmp3__length1 = str_array_length1;
	if (_tmp3_ != NULL) {
		_tmp2_ = TRUE;
	} else {
		gchar** _tmp4_;
		gint _tmp4__length1;
		_tmp4_ = str_array;
		_tmp4__length1 = str_array_length1;
		_tmp2_ = _tmp4__length1 > 0;
	}
	if (_tmp2_) {
		_tmp1_ = TRUE;
	} else {
		gboolean _tmp5_ = FALSE;
		gchar** _tmp6_;
		gint _tmp6__length1;
		_tmp6_ = str_array;
		_tmp6__length1 = str_array_length1;
		if (_tmp6__length1 == -1) {
			gchar** _tmp7_;
			gint _tmp7__length1;
			const gchar* _tmp8_;
			_tmp7_ = str_array;
			_tmp7__length1 = str_array_length1;
			_tmp8_ = _tmp7_[0];
			_tmp5_ = _tmp8_ != NULL;
		} else {
			_tmp5_ = FALSE;
		}
		_tmp1_ = _tmp5_;
	}
	if (_tmp1_) {
		gint i = 0;
		gsize len = 0UL;
		gint _tmp31_;
		gint _tmp33_;
		gint _tmp34_;
		gsize _tmp35_;
		const gchar* _tmp36_;
		gint _tmp37_;
		gint _tmp38_;
		gint _tmp39_;
		const gchar* res = NULL;
		gsize _tmp40_;
		void* _tmp41_;
		void* ptr = NULL;
		const gchar* _tmp42_;
		gchar** _tmp43_;
		gint _tmp43__length1;
		const gchar* _tmp44_;
		void* _tmp45_;
		const gchar* _tmp62_;
		len = (gsize) 1;
		{
			gboolean _tmp9_ = FALSE;
			i = 0;
			_tmp9_ = TRUE;
			while (TRUE) {
				gboolean _tmp11_ = FALSE;
				gboolean _tmp12_ = FALSE;
				gchar** _tmp13_;
				gint _tmp13__length1;
				gint _tmp21_ = 0;
				gchar** _tmp22_;
				gint _tmp22__length1;
				gint _tmp23_;
				const gchar* _tmp24_;
				gsize _tmp30_;
				if (!_tmp9_) {
					gint _tmp10_;
					_tmp10_ = i;
					i = _tmp10_ + 1;
				}
				_tmp9_ = FALSE;
				_tmp13_ = str_array;
				_tmp13__length1 = str_array_length1;
				if (_tmp13__length1 != -1) {
					gint _tmp14_;
					gchar** _tmp15_;
					gint _tmp15__length1;
					_tmp14_ = i;
					_tmp15_ = str_array;
					_tmp15__length1 = str_array_length1;
					_tmp12_ = _tmp14_ < _tmp15__length1;
				} else {
					_tmp12_ = FALSE;
				}
				if (_tmp12_) {
					_tmp11_ = TRUE;
				} else {
					gboolean _tmp16_ = FALSE;
					gchar** _tmp17_;
					gint _tmp17__length1;
					_tmp17_ = str_array;
					_tmp17__length1 = str_array_length1;
					if (_tmp17__length1 == -1) {
						gchar** _tmp18_;
						gint _tmp18__length1;
						gint _tmp19_;
						const gchar* _tmp20_;
						_tmp18_ = str_array;
						_tmp18__length1 = str_array_length1;
						_tmp19_ = i;
						_tmp20_ = _tmp18_[_tmp19_];
						_tmp16_ = _tmp20_ != NULL;
					} else {
						_tmp16_ = FALSE;
					}
					_tmp11_ = _tmp16_;
				}
				if (!_tmp11_) {
					break;
				}
				_tmp22_ = str_array;
				_tmp22__length1 = str_array_length1;
				_tmp23_ = i;
				_tmp24_ = _tmp22_[_tmp23_];
				if (_tmp24_ != NULL) {
					gchar** _tmp25_;
					gint _tmp25__length1;
					gint _tmp26_;
					const gchar* _tmp27_;
					gint _tmp28_;
					gint _tmp29_;
					_tmp25_ = str_array;
					_tmp25__length1 = str_array_length1;
					_tmp26_ = i;
					_tmp27_ = _tmp25_[_tmp26_];
					_tmp28_ = strlen ((const gchar*) _tmp27_);
					_tmp29_ = _tmp28_;
					_tmp21_ = _tmp29_;
				} else {
					_tmp21_ = 0;
				}
				_tmp30_ = len;
				len = _tmp30_ + _tmp21_;
			}
		}
		_tmp31_ = i;
		if (_tmp31_ == 0) {
			gchar* _tmp32_;
			_tmp32_ = g_strdup ("");
			result = _tmp32_;
			return result;
		}
		_tmp33_ = i;
		str_array_length1 = _tmp33_;
		_tmp34_ = str_array_length1;
		_tmp35_ = len;
		_tmp36_ = separator;
		_tmp37_ = strlen ((const gchar*) _tmp36_);
		_tmp38_ = _tmp37_;
		_tmp39_ = i;
		len = _tmp35_ + (_tmp38_ * (_tmp39_ - 1));
		_tmp40_ = len;
		_tmp41_ = g_malloc (_tmp40_);
		res = _tmp41_;
		_tmp42_ = res;
		_tmp43_ = str_array;
		_tmp43__length1 = str_array_length1;
		_tmp44_ = _tmp43_[0];
		_tmp45_ = g_stpcpy ((void*) _tmp42_, (const gchar*) _tmp44_);
		ptr = _tmp45_;
		{
			gboolean _tmp46_ = FALSE;
			i = 1;
			_tmp46_ = TRUE;
			while (TRUE) {
				gint _tmp48_;
				gchar** _tmp49_;
				gint _tmp49__length1;
				void* _tmp50_;
				const gchar* _tmp51_;
				void* _tmp52_;
				const gchar* _tmp53_ = NULL;
				gchar** _tmp54_;
				gint _tmp54__length1;
				gint _tmp55_;
				const gchar* _tmp56_;
				void* _tmp60_;
				void* _tmp61_;
				if (!_tmp46_) {
					gint _tmp47_;
					_tmp47_ = i;
					i = _tmp47_ + 1;
				}
				_tmp46_ = FALSE;
				_tmp48_ = i;
				_tmp49_ = str_array;
				_tmp49__length1 = str_array_length1;
				if (!(_tmp48_ < _tmp49__length1)) {
					break;
				}
				_tmp50_ = ptr;
				_tmp51_ = separator;
				_tmp52_ = g_stpcpy (_tmp50_, (const gchar*) _tmp51_);
				ptr = _tmp52_;
				_tmp54_ = str_array;
				_tmp54__length1 = str_array_length1;
				_tmp55_ = i;
				_tmp56_ = _tmp54_[_tmp55_];
				if (_tmp56_ != NULL) {
					gchar** _tmp57_;
					gint _tmp57__length1;
					gint _tmp58_;
					const gchar* _tmp59_;
					_tmp57_ = str_array;
					_tmp57__length1 = str_array_length1;
					_tmp58_ = i;
					_tmp59_ = _tmp57_[_tmp58_];
					_tmp53_ = (const gchar*) _tmp59_;
				} else {
					_tmp53_ = "";
				}
				_tmp60_ = ptr;
				_tmp61_ = g_stpcpy (_tmp60_, _tmp53_);
				ptr = _tmp61_;
			}
		}
		_tmp62_ = res;
		res = NULL;
		result = (gchar*) _tmp62_;
		return result;
	} else {
		gchar* _tmp63_;
		_tmp63_ = g_strdup ("");
		result = _tmp63_;
		return result;
	}
}


static void math_function_popover_add_function_cb (MathFunctionPopover* self, GtkWidget* widget) {
	gchar* name = NULL;
	GtkEntry* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	gint arguments = 0;
	GtkSpinButton* _tmp5_;
	gint _tmp6_;
	gchar* formatted_args = NULL;
	gchar* _tmp7_;
	gint _tmp8_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	MathEquation* _tmp17_;
	MathEquation* _tmp18_;
	const gchar* _tmp19_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (widget != NULL);
	_tmp0_ = self->priv->function_name_entry;
	_tmp1_ = gtk_entry_get_text (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strdup (_tmp2_);
	name = _tmp3_;
	_tmp4_ = name;
	if (g_strcmp0 (_tmp4_, "") == 0) {
		_g_free0 (name);
		return;
	}
	_tmp5_ = self->priv->add_arguments_button;
	_tmp6_ = gtk_spin_button_get_value_as_int (_tmp5_);
	arguments = _tmp6_;
	_tmp7_ = g_strdup ("");
	formatted_args = _tmp7_;
	_tmp8_ = arguments;
	if (_tmp8_ > 0) {
		gchar** _tmp9_;
		gint _tmp9__length1;
		gint _tmp10_;
		gchar* _tmp11_;
		_tmp9_ = math_function_popover_FUNCTION_ARGS;
		_tmp9__length1 = math_function_popover_FUNCTION_ARGS_length1;
		_tmp10_ = arguments;
		_tmp11_ = _vala_g_strjoinv ("; ", _tmp9_ + 0, _tmp10_ - 0);
		_g_free0 (formatted_args);
		formatted_args = _tmp11_;
	}
	_tmp12_ = name;
	_tmp13_ = formatted_args;
	_tmp14_ = g_strdup_printf ("(%s)=", _tmp13_);
	_tmp15_ = _tmp14_;
	_tmp16_ = g_strconcat (_tmp12_, _tmp15_, NULL);
	_g_free0 (name);
	name = _tmp16_;
	_g_free0 (_tmp15_);
	_tmp17_ = self->priv->equation;
	math_equation_clear (_tmp17_);
	_tmp18_ = self->priv->equation;
	_tmp19_ = name;
	math_equation_insert (_tmp18_, _tmp19_);
	_g_free0 (formatted_args);
	_g_free0 (name);
}


static void _math_function_popover_add_function_cb_gtk_button_clicked (GtkButton* _sender, gpointer self) {
	math_function_popover_add_function_cb ((MathFunctionPopover*) self, _sender);
}


static void math_function_popover_save_function_cb (MathFunctionPopover* self, GtkWidget* widget) {
	MathFunction* function = NULL;
	GtkWidget* _tmp0_;
	gconstpointer _tmp1_;
	MathFunction* _tmp2_;
	gchar* function_to_edit = NULL;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gchar** _tmp5_;
	gint _tmp5__length1;
	gchar** _tmp6_;
	gint _tmp6__length1;
	gchar* _tmp7_;
	gchar* _tmp8_;
	const gchar* _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	MathEquation* _tmp15_;
	MathEquation* _tmp16_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (widget != NULL);
	_tmp0_ = widget;
	_tmp1_ = g_object_get_data ((GObject*) _tmp0_, "function");
	_tmp2_ = _g_object_ref0 ((MathFunction*) _tmp1_);
	function = _tmp2_;
	_tmp3_ = math_function_get_name (function);
	_tmp4_ = _tmp3_;
	_tmp5_ = math_function_get_arguments (function, &_tmp5__length1);
	_tmp6_ = _tmp5_;
	_tmp6__length1 = _tmp5__length1;
	_tmp7_ = _vala_g_strjoinv (";", _tmp6_, _tmp6__length1);
	_tmp8_ = _tmp7_;
	_tmp9_ = math_function_get_expression (function);
	_tmp10_ = _tmp9_;
	_tmp11_ = math_function_get_description (function);
	_tmp12_ = _tmp11_;
	_tmp13_ = g_strdup_printf ("%s(%s)=%s@%s", _tmp4_, _tmp8_, _tmp10_, _tmp12_);
	_tmp14_ = _tmp13_;
	_g_free0 (_tmp8_);
	function_to_edit = _tmp14_;
	_tmp15_ = self->priv->equation;
	math_equation_clear (_tmp15_);
	_tmp16_ = self->priv->equation;
	math_equation_insert (_tmp16_, function_to_edit);
	_g_free0 (function_to_edit);
	_g_object_unref0 (function);
}


static void math_function_popover_delete_function_cb (MathFunctionPopover* self, GtkWidget* widget) {
	MathFunction* function = NULL;
	GtkWidget* _tmp0_;
	gconstpointer _tmp1_;
	MathFunction* _tmp2_;
	FunctionManager* function_manager = NULL;
	FunctionManager* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (widget != NULL);
	_tmp0_ = widget;
	_tmp1_ = g_object_get_data ((GObject*) _tmp0_, "function");
	_tmp2_ = _g_object_ref0 ((MathFunction*) _tmp1_);
	function = _tmp2_;
	_tmp3_ = function_manager_get_default_function_manager ();
	function_manager = _tmp3_;
	_tmp4_ = math_function_get_name (function);
	_tmp5_ = _tmp4_;
	function_manager_delete (function_manager, _tmp5_);
	_g_object_unref0 (function_manager);
	_g_object_unref0 (function);
}


static void _math_function_popover_save_function_cb_gtk_button_clicked (GtkButton* _sender, gpointer self) {
	math_function_popover_save_function_cb ((MathFunctionPopover*) self, _sender);
}


static void _math_function_popover_delete_function_cb_gtk_button_clicked (GtkButton* _sender, gpointer self) {
	math_function_popover_delete_function_cb ((MathFunctionPopover*) self, _sender);
}


static GtkListBoxRow* math_function_popover_make_function_row (MathFunctionPopover* self, MathFunction* function) {
	GtkListBoxRow* result = NULL;
	GtkListBoxRow* row = NULL;
	GtkListBoxRow* _tmp0_;
	GtkListBoxRow* _tmp1_;
	GtkStyleContext* _tmp2_;
	GtkListBoxRow* _tmp3_;
	MathFunction* _tmp4_;
	MathFunction* _tmp5_;
	GtkListBoxRow* _tmp6_;
	MathFunction* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	GtkBox* hbox = NULL;
	GtkBox* _tmp12_;
	gchar* expression = NULL;
	gchar* _tmp13_;
	MathFunction* _tmp14_;
	gboolean _tmp15_;
	GtkLabel* label = NULL;
	MathFunction* _tmp22_;
	const gchar* _tmp23_;
	const gchar* _tmp24_;
	const gchar* _tmp25_;
	gchar* _tmp26_;
	gchar* _tmp27_;
	GtkLabel* _tmp28_;
	GtkLabel* _tmp29_;
	GtkLabel* _tmp30_;
	GtkLabel* _tmp31_;
	GtkBox* _tmp32_;
	GtkLabel* _tmp33_;
	MathFunction* _tmp34_;
	gboolean _tmp35_;
	GtkListBoxRow* _tmp54_;
	GtkBox* _tmp55_;
	GtkListBoxRow* _tmp56_;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (function != NULL, NULL);
	_tmp0_ = (GtkListBoxRow*) gtk_list_box_row_new ();
	g_object_ref_sink (_tmp0_);
	row = _tmp0_;
	_tmp1_ = row;
	_tmp2_ = gtk_widget_get_style_context ((GtkWidget*) _tmp1_);
	gtk_style_context_add_class (_tmp2_, "popover-row");
	_tmp3_ = row;
	_tmp4_ = function;
	_tmp5_ = _g_object_ref0 (_tmp4_);
	g_object_set_data_full ((GObject*) _tmp3_, "function", _tmp5_, g_object_unref);
	_tmp6_ = row;
	_tmp7_ = function;
	_tmp8_ = math_function_get_description (_tmp7_);
	_tmp9_ = _tmp8_;
	_tmp10_ = g_strdup_printf ("%s", _tmp9_);
	_tmp11_ = _tmp10_;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp6_, _tmp11_);
	_g_free0 (_tmp11_);
	_tmp12_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	g_object_ref_sink (_tmp12_);
	hbox = _tmp12_;
	_tmp13_ = g_strdup ("(x)");
	expression = _tmp13_;
	_tmp14_ = function;
	_tmp15_ = math_function_is_custom_function (_tmp14_);
	if (_tmp15_) {
		MathFunction* _tmp16_;
		gchar** _tmp17_;
		gint _tmp17__length1;
		gchar** _tmp18_;
		gint _tmp18__length1;
		gchar* _tmp19_;
		gchar* _tmp20_;
		gchar* _tmp21_;
		_tmp16_ = function;
		_tmp17_ = math_function_get_arguments (_tmp16_, &_tmp17__length1);
		_tmp18_ = _tmp17_;
		_tmp18__length1 = _tmp17__length1;
		_tmp19_ = _vala_g_strjoinv (";", _tmp18_, _tmp18__length1);
		_tmp20_ = _tmp19_;
		_tmp21_ = g_strdup_printf ("(%s)", _tmp20_);
		_g_free0 (expression);
		expression = _tmp21_;
		_g_free0 (_tmp20_);
	}
	_tmp22_ = function;
	_tmp23_ = math_function_get_name (_tmp22_);
	_tmp24_ = _tmp23_;
	_tmp25_ = expression;
	_tmp26_ = g_strdup_printf ("<b>%s</b>%s", _tmp24_, _tmp25_);
	_tmp27_ = _tmp26_;
	_tmp28_ = (GtkLabel*) gtk_label_new (_tmp27_);
	g_object_ref_sink (_tmp28_);
	_tmp29_ = _tmp28_;
	_g_free0 (_tmp27_);
	label = _tmp29_;
	_tmp30_ = label;
	gtk_label_set_use_markup (_tmp30_, TRUE);
	_tmp31_ = label;
	gtk_widget_set_halign ((GtkWidget*) _tmp31_, GTK_ALIGN_START);
	_tmp32_ = hbox;
	_tmp33_ = label;
	gtk_box_pack_start (_tmp32_, (GtkWidget*) _tmp33_, TRUE, TRUE, (guint) 0);
	_tmp34_ = function;
	_tmp35_ = math_function_is_custom_function (_tmp34_);
	if (_tmp35_) {
		GtkButton* button = NULL;
		GtkButton* _tmp36_;
		GtkButton* _tmp37_;
		GtkStyleContext* _tmp38_;
		GtkButton* _tmp39_;
		MathFunction* _tmp40_;
		MathFunction* _tmp41_;
		GtkButton* _tmp42_;
		GtkBox* _tmp43_;
		GtkButton* _tmp44_;
		GtkButton* _tmp45_;
		GtkButton* _tmp46_;
		GtkStyleContext* _tmp47_;
		GtkButton* _tmp48_;
		MathFunction* _tmp49_;
		MathFunction* _tmp50_;
		GtkButton* _tmp51_;
		GtkBox* _tmp52_;
		GtkButton* _tmp53_;
		_tmp36_ = (GtkButton*) gtk_button_new_from_icon_name ("edit-symbolic", GTK_ICON_SIZE_BUTTON);
		g_object_ref_sink (_tmp36_);
		button = _tmp36_;
		_tmp37_ = button;
		_tmp38_ = gtk_widget_get_style_context ((GtkWidget*) _tmp37_);
		gtk_style_context_add_class (_tmp38_, "flat");
		_tmp39_ = button;
		_tmp40_ = function;
		_tmp41_ = _g_object_ref0 (_tmp40_);
		g_object_set_data_full ((GObject*) _tmp39_, "function", _tmp41_, g_object_unref);
		_tmp42_ = button;
		g_signal_connect_object (_tmp42_, "clicked", (GCallback) _math_function_popover_save_function_cb_gtk_button_clicked, self, 0);
		_tmp43_ = hbox;
		_tmp44_ = button;
		gtk_box_pack_start (_tmp43_, (GtkWidget*) _tmp44_, FALSE, TRUE, (guint) 0);
		_tmp45_ = (GtkButton*) gtk_button_new_from_icon_name ("list-remove-symbolic", GTK_ICON_SIZE_BUTTON);
		g_object_ref_sink (_tmp45_);
		_g_object_unref0 (button);
		button = _tmp45_;
		_tmp46_ = button;
		_tmp47_ = gtk_widget_get_style_context ((GtkWidget*) _tmp46_);
		gtk_style_context_add_class (_tmp47_, "flat");
		_tmp48_ = button;
		_tmp49_ = function;
		_tmp50_ = _g_object_ref0 (_tmp49_);
		g_object_set_data_full ((GObject*) _tmp48_, "function", _tmp50_, g_object_unref);
		_tmp51_ = button;
		g_signal_connect_object (_tmp51_, "clicked", (GCallback) _math_function_popover_delete_function_cb_gtk_button_clicked, self, 0);
		_tmp52_ = hbox;
		_tmp53_ = button;
		gtk_box_pack_start (_tmp52_, (GtkWidget*) _tmp53_, FALSE, TRUE, (guint) 0);
		_g_object_unref0 (button);
	}
	_tmp54_ = row;
	_tmp55_ = hbox;
	gtk_container_add ((GtkContainer*) _tmp54_, (GtkWidget*) _tmp55_);
	_tmp56_ = row;
	gtk_widget_show_all ((GtkWidget*) _tmp56_);
	result = row;
	_g_object_unref0 (label);
	_g_free0 (expression);
	_g_object_unref0 (hbox);
	return result;
}


static gint math_function_popover_function_list_sort (MathFunctionPopover* self, GtkListBoxRow* row1, GtkListBoxRow* row2) {
	gint result = 0;
	MathFunction* function1 = NULL;
	GtkListBoxRow* _tmp0_;
	gconstpointer _tmp1_;
	MathFunction* _tmp2_;
	MathFunction* function2 = NULL;
	GtkListBoxRow* _tmp3_;
	gconstpointer _tmp4_;
	MathFunction* _tmp5_;
	GCompareFunc _tmp6_;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	const gchar* _tmp10_;
	gint _tmp11_;
	g_return_val_if_fail (self != NULL, 0);
	g_return_val_if_fail (row1 != NULL, 0);
	g_return_val_if_fail (row2 != NULL, 0);
	_tmp0_ = row1;
	_tmp1_ = g_object_get_data ((GObject*) _tmp0_, "function");
	_tmp2_ = _g_object_ref0 ((MathFunction*) _tmp1_);
	function1 = _tmp2_;
	_tmp3_ = row2;
	_tmp4_ = g_object_get_data ((GObject*) _tmp3_, "function");
	_tmp5_ = _g_object_ref0 ((MathFunction*) _tmp4_);
	function2 = _tmp5_;
	_tmp6_ = g_strcmp0;
	_tmp7_ = math_function_get_name (function1);
	_tmp8_ = _tmp7_;
	_tmp9_ = math_function_get_name (function2);
	_tmp10_ = _tmp9_;
	_tmp11_ = _tmp6_ (_tmp8_, _tmp10_);
	result = _tmp11_;
	_g_object_unref0 (function2);
	_g_object_unref0 (function1);
	return result;
}


static void math_function_popover_class_init (MathFunctionPopoverClass * klass) {
	gint MathFunctionPopover_private_offset;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar** _tmp10_;
	math_function_popover_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (MathFunctionPopoverPrivate));
	G_OBJECT_CLASS (klass)->finalize = math_function_popover_finalize;
	MathFunctionPopover_private_offset = g_type_class_get_instance_private_offset (klass);
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/calculator/math-function-popover.ui");
	_tmp0_ = g_strdup ("x");
	_tmp1_ = g_strdup ("y");
	_tmp2_ = g_strdup ("z");
	_tmp3_ = g_strdup ("u");
	_tmp4_ = g_strdup ("v");
	_tmp5_ = g_strdup ("w");
	_tmp6_ = g_strdup ("a");
	_tmp7_ = g_strdup ("b");
	_tmp8_ = g_strdup ("c");
	_tmp9_ = g_strdup ("d");
	_tmp10_ = g_new0 (gchar*, 10 + 1);
	_tmp10_[0] = _tmp0_;
	_tmp10_[1] = _tmp1_;
	_tmp10_[2] = _tmp2_;
	_tmp10_[3] = _tmp3_;
	_tmp10_[4] = _tmp4_;
	_tmp10_[5] = _tmp5_;
	_tmp10_[6] = _tmp6_;
	_tmp10_[7] = _tmp7_;
	_tmp10_[8] = _tmp8_;
	_tmp10_[9] = _tmp9_;
	math_function_popover_FUNCTION_ARGS = _tmp10_;
	math_function_popover_FUNCTION_ARGS_length1 = 10;
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "function_list", FALSE, MathFunctionPopover_private_offset + G_STRUCT_OFFSET (MathFunctionPopoverPrivate, function_list));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "function_name_entry", FALSE, MathFunctionPopover_private_offset + G_STRUCT_OFFSET (MathFunctionPopoverPrivate, function_name_entry));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "add_function_button", FALSE, MathFunctionPopover_private_offset + G_STRUCT_OFFSET (MathFunctionPopoverPrivate, add_function_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "add_arguments_button", FALSE, MathFunctionPopover_private_offset + G_STRUCT_OFFSET (MathFunctionPopoverPrivate, add_arguments_button));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "insert_function_cb", G_CALLBACK(_math_function_popover_insert_function_cb_gtk_list_box_row_activated));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "function_name_mouse_click_cb", G_CALLBACK(_math_function_popover_function_name_mouse_click_cb_gtk_widget_button_press_event));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "function_name_key_press_cb", G_CALLBACK(_math_function_popover_function_name_key_press_cb_gtk_widget_key_press_event));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "function_name_changed_cb", G_CALLBACK(_math_function_popover_function_name_changed_cb_gtk_editable_changed));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "add_function_cb", G_CALLBACK(_math_function_popover_add_function_cb_gtk_button_clicked));
}


static void math_function_popover_instance_init (MathFunctionPopover * self) {
	self->priv = MATH_FUNCTION_POPOVER_GET_PRIVATE (self);
	self->priv->function_name_entry_placeholder_reseted = FALSE;
	gtk_widget_init_template (GTK_WIDGET (self));
}


static void math_function_popover_finalize (GObject * obj) {
	MathFunctionPopover * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_MATH_FUNCTION_POPOVER, MathFunctionPopover);
	_g_object_unref0 (self->priv->equation);
	_g_object_unref0 (self->priv->function_list);
	_g_object_unref0 (self->priv->function_name_entry);
	_g_object_unref0 (self->priv->add_function_button);
	_g_object_unref0 (self->priv->add_arguments_button);
	G_OBJECT_CLASS (math_function_popover_parent_class)->finalize (obj);
}


GType math_function_popover_get_type (void) {
	static volatile gsize math_function_popover_type_id__volatile = 0;
	if (g_once_init_enter (&math_function_popover_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (MathFunctionPopoverClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) math_function_popover_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MathFunctionPopover), 0, (GInstanceInitFunc) math_function_popover_instance_init, NULL };
		GType math_function_popover_type_id;
		math_function_popover_type_id = g_type_register_static (gtk_popover_get_type (), "MathFunctionPopover", &g_define_type_info, 0);
		g_once_init_leave (&math_function_popover_type_id__volatile, math_function_popover_type_id);
	}
	return math_function_popover_type_id__volatile;
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int 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, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}



