/* math-function-popup.c generated by valac 0.34.4, the Vala compiler
 * generated from math-function-popup.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 <gdk/gdk.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>


#define TYPE_MATH_FUNCTION_POPUP (math_function_popup_get_type ())
#define MATH_FUNCTION_POPUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MATH_FUNCTION_POPUP, MathFunctionPopup))
#define MATH_FUNCTION_POPUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MATH_FUNCTION_POPUP, MathFunctionPopupClass))
#define IS_MATH_FUNCTION_POPUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MATH_FUNCTION_POPUP))
#define IS_MATH_FUNCTION_POPUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MATH_FUNCTION_POPUP))
#define MATH_FUNCTION_POPUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MATH_FUNCTION_POPUP, MathFunctionPopupClass))

typedef struct _MathFunctionPopup MathFunctionPopup;
typedef struct _MathFunctionPopupClass MathFunctionPopupClass;
typedef struct _MathFunctionPopupPrivate MathFunctionPopupPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _MathFunctionPopup {
	GtkWindow parent_instance;
	MathFunctionPopupPrivate * priv;
};

struct _MathFunctionPopupClass {
	GtkWindowClass parent_class;
};

struct _MathFunctionPopupPrivate {
	MathEquation* equation;
	GtkScrolledWindow* scrolled_window;
	GtkBox* vbox;
	GtkEntry* function_name_entry;
	gboolean function_name_entry_placeholder_reseted;
	GtkButton* add_function_button;
	GtkSpinButton* add_arguments_button;
};


static gpointer math_function_popup_parent_class = NULL;

GType math_function_popup_get_type (void) G_GNUC_CONST;
#define MATH_FUNCTION_POPUP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_MATH_FUNCTION_POPUP, MathFunctionPopupPrivate))
enum  {
	MATH_FUNCTION_POPUP_DUMMY_PROPERTY
};
MathFunctionPopup* math_function_popup_new (MathEquation* equation);
MathFunctionPopup* math_function_popup_construct (GType object_type, MathEquation* equation);
static gboolean __lambda20_ (MathFunctionPopup* self, GdkEventFocus* event);
static gboolean ___lambda20__gtk_widget_focus_out_event (GtkWidget* _sender, GdkEventFocus* event, gpointer self);
static GtkBox* math_function_popup_make_function_entry (MathFunctionPopup* self, const gchar* name, const gchar* expression, MathFunction* math_function, gboolean writable);
static gboolean math_function_popup_function_name_key_press_cb (MathFunctionPopup* self, GtkWidget* widget, GdkEventKey* event);
static gboolean _math_function_popup_function_name_key_press_cb_gtk_widget_key_press_event (GtkWidget* _sender, GdkEventKey* event, gpointer self);
static gboolean math_function_popup_function_name_mouse_click_cb (MathFunctionPopup* self, GtkWidget* widget, GdkEventButton* event);
static gboolean _math_function_popup_function_name_mouse_click_cb_gtk_widget_button_press_event (GtkWidget* _sender, GdkEventButton* event, gpointer self);
static void math_function_popup_function_name_changed_cb (MathFunctionPopup* self);
static void _math_function_popup_function_name_changed_cb_gtk_editable_changed (GtkEditable* _sender, gpointer self);
static void math_function_popup_add_function_cb (MathFunctionPopup* self, GtkWidget* widget);
static void _math_function_popup_add_function_cb_gtk_entry_activate (GtkEntry* _sender, gpointer self);
static void _math_function_popup_add_function_cb_gtk_button_clicked (GtkButton* _sender, gpointer self);
static void math_function_popup_insert_function_cb (MathFunctionPopup* self, GtkWidget* widget);
static void math_function_popup_save_function_cb (MathFunctionPopup* self, GtkWidget* widget);
static void math_function_popup_delete_function_cb (MathFunctionPopup* self, GtkWidget* widget);
static void _math_function_popup_insert_function_cb_gtk_button_clicked (GtkButton* _sender, gpointer self);
static void _math_function_popup_save_function_cb_gtk_button_clicked (GtkButton* _sender, gpointer self);
static void _math_function_popup_delete_function_cb_gtk_button_clicked (GtkButton* _sender, gpointer self);
static void math_function_popup_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 gboolean __lambda20_ (MathFunctionPopup* self, GdkEventFocus* event) {
	gboolean result = FALSE;
	g_return_val_if_fail (event != NULL, FALSE);
	gtk_widget_destroy ((GtkWidget*) self);
	result = FALSE;
	return result;
}


static gboolean ___lambda20__gtk_widget_focus_out_event (GtkWidget* _sender, GdkEventFocus* event, gpointer self) {
	gboolean result;
	result = __lambda20_ ((MathFunctionPopup*) self, event);
	return result;
}


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


static gboolean _math_function_popup_function_name_key_press_cb_gtk_widget_key_press_event (GtkWidget* _sender, GdkEventKey* event, gpointer self) {
	gboolean result;
	result = math_function_popup_function_name_key_press_cb ((MathFunctionPopup*) self, _sender, event);
	return result;
}


static gboolean _math_function_popup_function_name_mouse_click_cb_gtk_widget_button_press_event (GtkWidget* _sender, GdkEventButton* event, gpointer self) {
	gboolean result;
	result = math_function_popup_function_name_mouse_click_cb ((MathFunctionPopup*) self, _sender, event);
	return result;
}


static void _math_function_popup_function_name_changed_cb_gtk_editable_changed (GtkEditable* _sender, gpointer self) {
	math_function_popup_function_name_changed_cb ((MathFunctionPopup*) self);
}


static void _math_function_popup_add_function_cb_gtk_entry_activate (GtkEntry* _sender, gpointer self) {
	math_function_popup_add_function_cb ((MathFunctionPopup*) self, _sender);
}


static void _math_function_popup_add_function_cb_gtk_button_clicked (GtkButton* _sender, gpointer self) {
	math_function_popup_add_function_cb ((MathFunctionPopup*) self, _sender);
}


MathFunctionPopup* math_function_popup_construct (GType object_type, MathEquation* equation) {
	MathFunctionPopup * self = NULL;
	MathEquation* _tmp0_ = NULL;
	MathEquation* _tmp1_ = NULL;
	GtkScrolledWindow* _tmp2_ = NULL;
	GtkScrolledWindow* _tmp3_ = NULL;
	GtkScrolledWindow* _tmp4_ = NULL;
	GtkScrolledWindow* _tmp5_ = NULL;
	GtkBox* _tmp6_ = NULL;
	GtkBox* _tmp7_ = NULL;
	GtkScrolledWindow* _tmp8_ = NULL;
	GtkBox* _tmp9_ = NULL;
	GtkBox* _tmp10_ = NULL;
	FunctionManager* function_manager = NULL;
	FunctionManager* _tmp11_ = NULL;
	gchar** names = NULL;
	FunctionManager* _tmp12_ = NULL;
	gint _tmp13_ = 0;
	gchar** _tmp14_ = NULL;
	gint names_length1 = 0;
	gint _names_size_ = 0;
	GtkBox* entry = NULL;
	GtkBox* _tmp45_ = NULL;
	GtkBox* _tmp46_ = NULL;
	GtkEntry* _tmp47_ = NULL;
	GtkEntry* _tmp48_ = NULL;
	GtkEntry* _tmp49_ = NULL;
	GtkEntry* _tmp50_ = NULL;
	GtkEntry* _tmp51_ = NULL;
	GtkEntry* _tmp52_ = NULL;
	GtkEntry* _tmp53_ = NULL;
	GtkBox* _tmp54_ = NULL;
	GtkEntry* _tmp55_ = NULL;
	GtkEntry* _tmp56_ = NULL;
	GtkBox* _tmp57_ = NULL;
	GtkBox* _tmp58_ = NULL;
	GtkBox* _tmp59_ = NULL;
	GtkBox* _tmp60_ = NULL;
	GtkSpinButton* _tmp61_ = NULL;
	GtkSpinButton* _tmp62_ = NULL;
	GtkBox* _tmp63_ = NULL;
	GtkSpinButton* _tmp64_ = NULL;
	GtkSpinButton* _tmp65_ = NULL;
	GtkButton* _tmp66_ = NULL;
	GtkButton* _tmp67_ = NULL;
	GtkButton* _tmp68_ = NULL;
	GtkImage* image = NULL;
	GtkImage* _tmp69_ = NULL;
	GtkButton* _tmp70_ = NULL;
	GtkBox* _tmp71_ = NULL;
	GtkButton* _tmp72_ = NULL;
	GtkButton* _tmp73_ = NULL;
	GtkBox* _tmp74_ = NULL;
	GtkBox* _tmp75_ = NULL;
	g_return_val_if_fail (equation != NULL, NULL);
	self = (MathFunctionPopup*) g_object_new (object_type, NULL);
	_tmp0_ = equation;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->equation);
	self->priv->equation = _tmp1_;
	gtk_window_set_decorated ((GtkWindow*) self, FALSE);
	gtk_window_set_skip_taskbar_hint ((GtkWindow*) self, TRUE);
	gtk_container_set_border_width ((GtkContainer*) self, (guint) 6);
	gtk_window_set_default_size ((GtkWindow*) self, 200, 260);
	g_signal_connect_object ((GtkWidget*) self, "focus-out-event", (GCallback) ___lambda20__gtk_widget_focus_out_event, self, 0);
	_tmp2_ = (GtkScrolledWindow*) gtk_scrolled_window_new (NULL, NULL);
	g_object_ref_sink (_tmp2_);
	_g_object_unref0 (self->priv->scrolled_window);
	self->priv->scrolled_window = _tmp2_;
	_tmp3_ = self->priv->scrolled_window;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp3_);
	_tmp4_ = self->priv->scrolled_window;
	gtk_scrolled_window_set_policy (_tmp4_, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	_tmp5_ = self->priv->scrolled_window;
	gtk_widget_show ((GtkWidget*) _tmp5_);
	_tmp6_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
	g_object_ref_sink (_tmp6_);
	_g_object_unref0 (self->priv->vbox);
	self->priv->vbox = _tmp6_;
	_tmp7_ = self->priv->vbox;
	gtk_box_set_homogeneous (_tmp7_, TRUE);
	_tmp8_ = self->priv->scrolled_window;
	_tmp9_ = self->priv->vbox;
	gtk_scrolled_window_add_with_viewport (_tmp8_, (GtkWidget*) _tmp9_);
	_tmp10_ = self->priv->vbox;
	gtk_widget_show ((GtkWidget*) _tmp10_);
	_tmp11_ = function_manager_get_default_function_manager ();
	function_manager = _tmp11_;
	_tmp12_ = function_manager;
	_tmp14_ = function_manager_get_names (_tmp12_, &_tmp13_);
	names = _tmp14_;
	names_length1 = _tmp13_;
	_names_size_ = names_length1;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp15_ = FALSE;
			_tmp15_ = TRUE;
			while (TRUE) {
				gchar** _tmp17_ = NULL;
				gint _tmp17__length1 = 0;
				gint _tmp18_ = 0;
				const gchar* _tmp19_ = NULL;
				MathFunction* math_function = NULL;
				FunctionManager* _tmp20_ = NULL;
				gchar** _tmp21_ = NULL;
				gint _tmp21__length1 = 0;
				gint _tmp22_ = 0;
				const gchar* _tmp23_ = NULL;
				MathFunction* _tmp24_ = NULL;
				gboolean is_custom = FALSE;
				MathFunction* _tmp25_ = NULL;
				gboolean _tmp26_ = FALSE;
				gchar* expression = NULL;
				gchar* _tmp27_ = NULL;
				gboolean _tmp28_ = FALSE;
				GtkBox* entry = NULL;
				gchar** _tmp35_ = NULL;
				gint _tmp35__length1 = 0;
				gint _tmp36_ = 0;
				const gchar* _tmp37_ = NULL;
				const gchar* _tmp38_ = NULL;
				MathFunction* _tmp39_ = NULL;
				gboolean _tmp40_ = FALSE;
				GtkBox* _tmp41_ = NULL;
				GtkBox* _tmp42_ = NULL;
				GtkBox* _tmp43_ = NULL;
				GtkBox* _tmp44_ = NULL;
				if (!_tmp15_) {
					gint _tmp16_ = 0;
					_tmp16_ = i;
					i = _tmp16_ + 1;
				}
				_tmp15_ = FALSE;
				_tmp17_ = names;
				_tmp17__length1 = names_length1;
				_tmp18_ = i;
				_tmp19_ = _tmp17_[_tmp18_];
				if (!(_tmp19_ != NULL)) {
					break;
				}
				_tmp20_ = function_manager;
				_tmp21_ = names;
				_tmp21__length1 = names_length1;
				_tmp22_ = i;
				_tmp23_ = _tmp21_[_tmp22_];
				_tmp24_ = function_manager_get (_tmp20_, _tmp23_);
				math_function = _tmp24_;
				_tmp25_ = math_function;
				_tmp26_ = math_function_is_custom_function (_tmp25_);
				is_custom = _tmp26_;
				_tmp27_ = g_strdup ("(x)");
				expression = _tmp27_;
				_tmp28_ = is_custom;
				if (_tmp28_) {
					MathFunction* _tmp29_ = NULL;
					gchar** _tmp30_ = NULL;
					gint _tmp30__length1 = 0;
					gchar** _tmp31_ = NULL;
					gint _tmp31__length1 = 0;
					gchar* _tmp32_ = NULL;
					gchar* _tmp33_ = NULL;
					gchar* _tmp34_ = NULL;
					_tmp29_ = math_function;
					_tmp30_ = math_function_get_arguments (_tmp29_, &_tmp30__length1);
					_tmp31_ = _tmp30_;
					_tmp31__length1 = _tmp30__length1;
					_tmp32_ = _vala_g_strjoinv (";", _tmp31_, _tmp31__length1);
					_tmp33_ = _tmp32_;
					_tmp34_ = g_strdup_printf ("(%s)", _tmp33_);
					_g_free0 (expression);
					expression = _tmp34_;
					_g_free0 (_tmp33_);
				}
				_tmp35_ = names;
				_tmp35__length1 = names_length1;
				_tmp36_ = i;
				_tmp37_ = _tmp35_[_tmp36_];
				_tmp38_ = expression;
				_tmp39_ = math_function;
				_tmp40_ = is_custom;
				_tmp41_ = math_function_popup_make_function_entry (self, _tmp37_, _tmp38_, _tmp39_, _tmp40_);
				entry = _tmp41_;
				_tmp42_ = entry;
				gtk_widget_show ((GtkWidget*) _tmp42_);
				_tmp43_ = self->priv->vbox;
				_tmp44_ = entry;
				gtk_box_pack_end (_tmp43_, (GtkWidget*) _tmp44_, FALSE, TRUE, (guint) 0);
				_g_object_unref0 (entry);
				_g_free0 (expression);
				_g_object_unref0 (math_function);
			}
		}
	}
	_tmp45_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	g_object_ref_sink (_tmp45_);
	entry = _tmp45_;
	_tmp46_ = entry;
	gtk_widget_show ((GtkWidget*) _tmp46_);
	_tmp47_ = (GtkEntry*) gtk_entry_new ();
	g_object_ref_sink (_tmp47_);
	_g_object_unref0 (self->priv->function_name_entry);
	self->priv->function_name_entry = _tmp47_;
	_tmp48_ = self->priv->function_name_entry;
	gtk_entry_set_text (_tmp48_, "Type function name here");
	_tmp49_ = self->priv->function_name_entry;
	g_signal_connect_object ((GtkWidget*) _tmp49_, "key-press-event", (GCallback) _math_function_popup_function_name_key_press_cb_gtk_widget_key_press_event, self, 0);
	_tmp50_ = self->priv->function_name_entry;
	g_signal_connect_object ((GtkWidget*) _tmp50_, "button-press-event", (GCallback) _math_function_popup_function_name_mouse_click_cb_gtk_widget_button_press_event, self, 0);
	_tmp51_ = self->priv->function_name_entry;
	g_signal_connect_object ((GtkEditable*) _tmp51_, "changed", (GCallback) _math_function_popup_function_name_changed_cb_gtk_editable_changed, self, 0);
	_tmp52_ = self->priv->function_name_entry;
	gtk_widget_set_margin_right ((GtkWidget*) _tmp52_, 5);
	_tmp53_ = self->priv->function_name_entry;
	g_signal_connect_object (_tmp53_, "activate", (GCallback) _math_function_popup_add_function_cb_gtk_entry_activate, self, 0);
	_tmp54_ = entry;
	_tmp55_ = self->priv->function_name_entry;
	gtk_box_pack_start (_tmp54_, (GtkWidget*) _tmp55_, TRUE, TRUE, (guint) 0);
	_tmp56_ = self->priv->function_name_entry;
	gtk_widget_show ((GtkWidget*) _tmp56_);
	_tmp57_ = self->priv->vbox;
	_tmp58_ = entry;
	gtk_box_pack_start (_tmp57_, (GtkWidget*) _tmp58_, FALSE, TRUE, (guint) 0);
	_tmp59_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	g_object_ref_sink (_tmp59_);
	_g_object_unref0 (entry);
	entry = _tmp59_;
	_tmp60_ = entry;
	gtk_widget_show ((GtkWidget*) _tmp60_);
	_tmp61_ = (GtkSpinButton*) gtk_spin_button_new_with_range ((gdouble) 1, (gdouble) 10, (gdouble) 1);
	g_object_ref_sink (_tmp61_);
	_g_object_unref0 (self->priv->add_arguments_button);
	self->priv->add_arguments_button = _tmp61_;
	_tmp62_ = self->priv->add_arguments_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp62_, "Select no. of arguments");
	_tmp63_ = entry;
	_tmp64_ = self->priv->add_arguments_button;
	gtk_box_pack_start (_tmp63_, (GtkWidget*) _tmp64_, FALSE, TRUE, (guint) 0);
	_tmp65_ = self->priv->add_arguments_button;
	gtk_widget_show ((GtkWidget*) _tmp65_);
	_tmp66_ = (GtkButton*) gtk_button_new ();
	g_object_ref_sink (_tmp66_);
	_g_object_unref0 (self->priv->add_function_button);
	self->priv->add_function_button = _tmp66_;
	_tmp67_ = self->priv->add_function_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp67_, FALSE);
	_tmp68_ = self->priv->add_function_button;
	g_signal_connect_object (_tmp68_, "clicked", (GCallback) _math_function_popup_add_function_cb_gtk_button_clicked, self, 0);
	_tmp69_ = (GtkImage*) gtk_image_new_from_icon_name ("list-add-symbolic", GTK_ICON_SIZE_BUTTON);
	g_object_ref_sink (_tmp69_);
	image = _tmp69_;
	_tmp70_ = self->priv->add_function_button;
	gtk_container_add ((GtkContainer*) _tmp70_, (GtkWidget*) image);
	_tmp71_ = entry;
	_tmp72_ = self->priv->add_function_button;
	gtk_box_pack_end (_tmp71_, (GtkWidget*) _tmp72_, FALSE, TRUE, (guint) 0);
	gtk_widget_show ((GtkWidget*) image);
	_tmp73_ = self->priv->add_function_button;
	gtk_widget_show ((GtkWidget*) _tmp73_);
	_tmp74_ = self->priv->vbox;
	_tmp75_ = entry;
	gtk_box_pack_end (_tmp74_, (GtkWidget*) _tmp75_, FALSE, TRUE, (guint) 0);
	_g_object_unref0 (image);
	_g_object_unref0 (entry);
	names = (_vala_array_free (names, names_length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (function_manager);
	return self;
}


MathFunctionPopup* math_function_popup_new (MathEquation* equation) {
	return math_function_popup_construct (TYPE_MATH_FUNCTION_POPUP, equation);
}


static void math_function_popup_insert_function_cb (MathFunctionPopup* self, GtkWidget* widget) {
	gchar* name = NULL;
	GtkWidget* _tmp0_ = NULL;
	gconstpointer _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	gchar* _tmp4_ = NULL;
	MathEquation* _tmp5_ = NULL;
	const gchar* _tmp6_ = NULL;
	GtkTextIter end = {0};
	MathEquation* _tmp7_ = NULL;
	MathEquation* _tmp8_ = NULL;
	GtkTextMark* _tmp9_ = NULL;
	GtkTextIter _tmp10_ = {0};
	MathEquation* _tmp11_ = NULL;
	GtkTextIter _tmp12_ = {0};
	GtkWidget* _tmp13_ = NULL;
	GtkWidget* _tmp14_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (widget != NULL);
	_tmp0_ = widget;
	_tmp1_ = g_object_get_data ((GObject*) _tmp0_, "function_name");
	_tmp2_ = g_strdup ((const gchar*) _tmp1_);
	name = _tmp2_;
	_tmp3_ = name;
	_tmp4_ = g_strconcat (_tmp3_, "()", NULL);
	_g_free0 (name);
	name = _tmp4_;
	_tmp5_ = self->priv->equation;
	_tmp6_ = name;
	math_equation_insert (_tmp5_, _tmp6_);
	_tmp7_ = self->priv->equation;
	_tmp8_ = self->priv->equation;
	_tmp9_ = gtk_text_buffer_get_insert ((GtkTextBuffer*) _tmp8_);
	gtk_text_buffer_get_iter_at_mark ((GtkTextBuffer*) _tmp7_, &_tmp10_, _tmp9_);
	end = _tmp10_;
	gtk_text_iter_backward_chars (&end, 1);
	_tmp11_ = self->priv->equation;
	_tmp12_ = end;
	gtk_text_buffer_place_cursor ((GtkTextBuffer*) _tmp11_, &_tmp12_);
	_tmp13_ = widget;
	_tmp14_ = gtk_widget_get_toplevel (_tmp13_);
	gtk_widget_destroy (_tmp14_);
	_g_free0 (name);
}


static gboolean math_function_popup_function_name_mouse_click_cb (MathFunctionPopup* self, GtkWidget* widget, GdkEventButton* event) {
	gboolean result = FALSE;
	gboolean _tmp0_ = FALSE;
	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_ = NULL;
		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_popup_function_name_key_press_cb (MathFunctionPopup* self, GtkWidget* widget, GdkEventKey* event) {
	gboolean result = FALSE;
	gboolean _tmp0_ = FALSE;
	GdkEventKey* _tmp1_ = NULL;
	guint _tmp2_ = 0U;
	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_ = NULL;
		guint _tmp4_ = 0U;
		_tmp3_ = event;
		_tmp4_ = _tmp3_->keyval;
		_tmp0_ = _tmp4_ == ((guint) GDK_KEY_KP_Space);
	}
	if (_tmp0_) {
		GdkEventKey* _tmp5_ = NULL;
		_tmp5_ = event;
		_tmp5_->keyval = (guint) GDK_KEY_underscore;
	}
	result = FALSE;
	return result;
}


static void math_function_popup_function_name_changed_cb (MathFunctionPopup* self) {
	GtkButton* _tmp0_ = NULL;
	GtkEntry* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	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 glong string_strnlen (gchar* str, glong maxlen) {
	glong result = 0L;
	gchar* end = NULL;
	gchar* _tmp0_ = NULL;
	glong _tmp1_ = 0L;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	_tmp0_ = str;
	_tmp1_ = maxlen;
	_tmp2_ = memchr (_tmp0_, 0, (gsize) _tmp1_);
	end = _tmp2_;
	_tmp3_ = end;
	if (_tmp3_ == NULL) {
		glong _tmp4_ = 0L;
		_tmp4_ = maxlen;
		result = _tmp4_;
		return result;
	} else {
		gchar* _tmp5_ = NULL;
		gchar* _tmp6_ = NULL;
		_tmp5_ = end;
		_tmp6_ = str;
		result = (glong) (_tmp5_ - _tmp6_);
		return result;
	}
}


static gchar* string_substring (const gchar* self, glong offset, glong len) {
	gchar* result = NULL;
	glong string_length = 0L;
	gboolean _tmp0_ = FALSE;
	glong _tmp1_ = 0L;
	glong _tmp8_ = 0L;
	glong _tmp14_ = 0L;
	glong _tmp17_ = 0L;
	glong _tmp18_ = 0L;
	glong _tmp19_ = 0L;
	glong _tmp20_ = 0L;
	glong _tmp21_ = 0L;
	gchar* _tmp22_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp1_ = offset;
	if (_tmp1_ >= ((glong) 0)) {
		glong _tmp2_ = 0L;
		_tmp2_ = len;
		_tmp0_ = _tmp2_ >= ((glong) 0);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		glong _tmp3_ = 0L;
		glong _tmp4_ = 0L;
		glong _tmp5_ = 0L;
		_tmp3_ = offset;
		_tmp4_ = len;
		_tmp5_ = string_strnlen ((gchar*) self, _tmp3_ + _tmp4_);
		string_length = _tmp5_;
	} else {
		gint _tmp6_ = 0;
		gint _tmp7_ = 0;
		_tmp6_ = strlen (self);
		_tmp7_ = _tmp6_;
		string_length = (glong) _tmp7_;
	}
	_tmp8_ = offset;
	if (_tmp8_ < ((glong) 0)) {
		glong _tmp9_ = 0L;
		glong _tmp10_ = 0L;
		glong _tmp11_ = 0L;
		_tmp9_ = string_length;
		_tmp10_ = offset;
		offset = _tmp9_ + _tmp10_;
		_tmp11_ = offset;
		g_return_val_if_fail (_tmp11_ >= ((glong) 0), NULL);
	} else {
		glong _tmp12_ = 0L;
		glong _tmp13_ = 0L;
		_tmp12_ = offset;
		_tmp13_ = string_length;
		g_return_val_if_fail (_tmp12_ <= _tmp13_, NULL);
	}
	_tmp14_ = len;
	if (_tmp14_ < ((glong) 0)) {
		glong _tmp15_ = 0L;
		glong _tmp16_ = 0L;
		_tmp15_ = string_length;
		_tmp16_ = offset;
		len = _tmp15_ - _tmp16_;
	}
	_tmp17_ = offset;
	_tmp18_ = len;
	_tmp19_ = string_length;
	g_return_val_if_fail ((_tmp17_ + _tmp18_) <= _tmp19_, NULL);
	_tmp20_ = offset;
	_tmp21_ = len;
	_tmp22_ = g_strndup (((gchar*) self) + _tmp20_, (gsize) _tmp21_);
	result = _tmp22_;
	return result;
}


static void math_function_popup_add_function_cb (MathFunctionPopup* self, GtkWidget* widget) {
	gchar* name = NULL;
	GtkEntry* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	gint arguments = 0;
	GtkSpinButton* _tmp4_ = NULL;
	gint _tmp5_ = 0;
	const gchar* _tmp6_ = NULL;
	gchar* _tmp7_ = NULL;
	gint _tmp8_ = 0;
	const gchar* _tmp24_ = NULL;
	gchar* _tmp25_ = NULL;
	MathEquation* _tmp26_ = NULL;
	MathEquation* _tmp27_ = NULL;
	const gchar* _tmp28_ = NULL;
	GtkWidget* _tmp29_ = NULL;
	GtkWidget* _tmp30_ = NULL;
	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_ = g_strdup (_tmp1_);
	name = _tmp2_;
	_tmp3_ = name;
	if (g_strcmp0 (_tmp3_, "") == 0) {
		_g_free0 (name);
		return;
	}
	_tmp4_ = self->priv->add_arguments_button;
	_tmp5_ = gtk_spin_button_get_value_as_int (_tmp4_);
	arguments = _tmp5_;
	_tmp6_ = name;
	_tmp7_ = g_strconcat (_tmp6_, "(", NULL);
	_g_free0 (name);
	name = _tmp7_;
	_tmp8_ = arguments;
	if (_tmp8_ > 0) {
		gchar* s = NULL;
		gchar* _tmp9_ = NULL;
		_tmp9_ = g_strdup ("xyzuvwabcd");
		s = _tmp9_;
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp10_ = FALSE;
				_tmp10_ = TRUE;
				while (TRUE) {
					gint _tmp12_ = 0;
					gint _tmp13_ = 0;
					const gchar* _tmp14_ = NULL;
					const gchar* _tmp15_ = NULL;
					gint _tmp16_ = 0;
					gchar* _tmp17_ = NULL;
					gchar* _tmp18_ = NULL;
					gchar* _tmp19_ = NULL;
					gint _tmp20_ = 0;
					gint _tmp21_ = 0;
					if (!_tmp10_) {
						gint _tmp11_ = 0;
						_tmp11_ = i;
						i = _tmp11_ + 1;
					}
					_tmp10_ = FALSE;
					_tmp12_ = i;
					_tmp13_ = arguments;
					if (!(_tmp12_ < _tmp13_)) {
						break;
					}
					_tmp14_ = name;
					_tmp15_ = s;
					_tmp16_ = i;
					_tmp17_ = string_substring (_tmp15_, (glong) _tmp16_, (glong) 1);
					_tmp18_ = _tmp17_;
					_tmp19_ = g_strconcat (_tmp14_, _tmp18_, NULL);
					_g_free0 (name);
					name = _tmp19_;
					_g_free0 (_tmp18_);
					_tmp20_ = i;
					_tmp21_ = arguments;
					if (_tmp20_ < (_tmp21_ - 1)) {
						const gchar* _tmp22_ = NULL;
						gchar* _tmp23_ = NULL;
						_tmp22_ = name;
						_tmp23_ = g_strconcat (_tmp22_, "; ", NULL);
						_g_free0 (name);
						name = _tmp23_;
					}
				}
			}
		}
		_g_free0 (s);
	}
	_tmp24_ = name;
	_tmp25_ = g_strconcat (_tmp24_, ")=", NULL);
	_g_free0 (name);
	name = _tmp25_;
	_tmp26_ = self->priv->equation;
	math_equation_clear (_tmp26_);
	_tmp27_ = self->priv->equation;
	_tmp28_ = name;
	math_equation_insert (_tmp27_, _tmp28_);
	_tmp29_ = widget;
	_tmp30_ = gtk_widget_get_toplevel (_tmp29_);
	gtk_widget_destroy (_tmp30_);
	_g_free0 (name);
}


static void math_function_popup_save_function_cb (MathFunctionPopup* self, GtkWidget* widget) {
	gchar* name = NULL;
	GtkWidget* _tmp0_ = NULL;
	gconstpointer _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	FunctionManager* function_manager = NULL;
	FunctionManager* _tmp3_ = NULL;
	MathFunction* function = NULL;
	MathFunction* _tmp4_ = NULL;
	gchar* function_to_edit = NULL;
	const gchar* _tmp5_ = NULL;
	const gchar* _tmp6_ = NULL;
	gchar** _tmp7_ = NULL;
	gint _tmp7__length1 = 0;
	gchar** _tmp8_ = NULL;
	gint _tmp8__length1 = 0;
	gchar* _tmp9_ = NULL;
	gchar* _tmp10_ = NULL;
	const gchar* _tmp11_ = NULL;
	const gchar* _tmp12_ = NULL;
	const gchar* _tmp13_ = NULL;
	const gchar* _tmp14_ = NULL;
	gchar* _tmp15_ = NULL;
	gchar* _tmp16_ = NULL;
	MathEquation* _tmp17_ = NULL;
	MathEquation* _tmp18_ = NULL;
	GtkWidget* _tmp19_ = NULL;
	GtkWidget* _tmp20_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (widget != NULL);
	_tmp0_ = widget;
	_tmp1_ = g_object_get_data ((GObject*) _tmp0_, "function_name");
	_tmp2_ = g_strdup ((const gchar*) _tmp1_);
	name = _tmp2_;
	_tmp3_ = function_manager_get_default_function_manager ();
	function_manager = _tmp3_;
	_tmp4_ = function_manager_get (function_manager, name);
	function = _tmp4_;
	_tmp5_ = math_function_get_name (function);
	_tmp6_ = _tmp5_;
	_tmp7_ = math_function_get_arguments (function, &_tmp7__length1);
	_tmp8_ = _tmp7_;
	_tmp8__length1 = _tmp7__length1;
	_tmp9_ = _vala_g_strjoinv (";", _tmp8_, _tmp8__length1);
	_tmp10_ = _tmp9_;
	_tmp11_ = math_function_get_expression (function);
	_tmp12_ = _tmp11_;
	_tmp13_ = math_function_get_description (function);
	_tmp14_ = _tmp13_;
	_tmp15_ = g_strdup_printf ("%s(%s)=%s@%s", _tmp6_, _tmp10_, _tmp12_, _tmp14_);
	_tmp16_ = _tmp15_;
	_g_free0 (_tmp10_);
	function_to_edit = _tmp16_;
	_tmp17_ = self->priv->equation;
	math_equation_clear (_tmp17_);
	_tmp18_ = self->priv->equation;
	math_equation_insert (_tmp18_, function_to_edit);
	_tmp19_ = widget;
	_tmp20_ = gtk_widget_get_toplevel (_tmp19_);
	gtk_widget_destroy (_tmp20_);
	_g_free0 (function_to_edit);
	_g_object_unref0 (function);
	_g_object_unref0 (function_manager);
	_g_free0 (name);
}


static void math_function_popup_delete_function_cb (MathFunctionPopup* self, GtkWidget* widget) {
	gchar* name = NULL;
	GtkWidget* _tmp0_ = NULL;
	gconstpointer _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	FunctionManager* function_manager = NULL;
	FunctionManager* _tmp3_ = NULL;
	GtkWidget* _tmp4_ = NULL;
	GtkWidget* _tmp5_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (widget != NULL);
	_tmp0_ = widget;
	_tmp1_ = g_object_get_data ((GObject*) _tmp0_, "function_name");
	_tmp2_ = g_strdup ((const gchar*) _tmp1_);
	name = _tmp2_;
	_tmp3_ = function_manager_get_default_function_manager ();
	function_manager = _tmp3_;
	function_manager_delete (function_manager, name);
	_tmp4_ = widget;
	_tmp5_ = gtk_widget_get_toplevel (_tmp4_);
	gtk_widget_destroy (_tmp5_);
	_g_object_unref0 (function_manager);
	_g_free0 (name);
}


static void _math_function_popup_insert_function_cb_gtk_button_clicked (GtkButton* _sender, gpointer self) {
	math_function_popup_insert_function_cb ((MathFunctionPopup*) self, _sender);
}


static void _math_function_popup_save_function_cb_gtk_button_clicked (GtkButton* _sender, gpointer self) {
	math_function_popup_save_function_cb ((MathFunctionPopup*) self, _sender);
}


static void _math_function_popup_delete_function_cb_gtk_button_clicked (GtkButton* _sender, gpointer self) {
	math_function_popup_delete_function_cb ((MathFunctionPopup*) self, _sender);
}


static GtkBox* math_function_popup_make_function_entry (MathFunctionPopup* self, const gchar* name, const gchar* expression, MathFunction* math_function, gboolean writable) {
	GtkBox* result = NULL;
	GtkBox* hbox = NULL;
	GtkBox* _tmp0_ = NULL;
	gchar* text = NULL;
	const gchar* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	GtkButton* button = NULL;
	GtkButton* _tmp4_ = NULL;
	GtkButton* _tmp5_ = NULL;
	const gchar* _tmp6_ = NULL;
	gchar* _tmp7_ = NULL;
	gchar* function_details = NULL;
	MathFunction* _tmp8_ = NULL;
	const gchar* _tmp9_ = NULL;
	const gchar* _tmp10_ = NULL;
	gchar* _tmp11_ = NULL;
	GtkButton* _tmp12_ = NULL;
	const gchar* _tmp13_ = NULL;
	GtkButton* _tmp14_ = NULL;
	GtkButton* _tmp15_ = NULL;
	GtkBox* _tmp16_ = NULL;
	GtkButton* _tmp17_ = NULL;
	GtkButton* _tmp18_ = NULL;
	GtkLabel* label = NULL;
	const gchar* _tmp19_ = NULL;
	GtkLabel* _tmp20_ = NULL;
	GtkLabel* _tmp21_ = NULL;
	GtkLabel* _tmp22_ = NULL;
	GtkButton* _tmp23_ = NULL;
	GtkLabel* _tmp24_ = NULL;
	GtkLabel* _tmp25_ = NULL;
	gboolean _tmp26_ = FALSE;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (expression != NULL, NULL);
	g_return_val_if_fail (math_function != NULL, NULL);
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	g_object_ref_sink (_tmp0_);
	hbox = _tmp0_;
	_tmp1_ = name;
	_tmp2_ = expression;
	_tmp3_ = g_strdup_printf ("<b>%s</b>%s", _tmp1_, _tmp2_);
	text = _tmp3_;
	_tmp4_ = (GtkButton*) gtk_button_new ();
	g_object_ref_sink (_tmp4_);
	button = _tmp4_;
	_tmp5_ = button;
	_tmp6_ = name;
	_tmp7_ = g_strdup (_tmp6_);
	g_object_set_data_full ((GObject*) _tmp5_, "function_name", _tmp7_, g_free);
	_tmp8_ = math_function;
	_tmp9_ = math_function_get_description (_tmp8_);
	_tmp10_ = _tmp9_;
	_tmp11_ = g_strdup_printf ("%s", _tmp10_);
	function_details = _tmp11_;
	_tmp12_ = button;
	_tmp13_ = function_details;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp12_, _tmp13_);
	_tmp14_ = button;
	g_signal_connect_object (_tmp14_, "clicked", (GCallback) _math_function_popup_insert_function_cb_gtk_button_clicked, self, 0);
	_tmp15_ = button;
	gtk_button_set_relief (_tmp15_, GTK_RELIEF_NONE);
	_tmp16_ = hbox;
	_tmp17_ = button;
	gtk_box_pack_start (_tmp16_, (GtkWidget*) _tmp17_, TRUE, TRUE, (guint) 0);
	_tmp18_ = button;
	gtk_widget_show ((GtkWidget*) _tmp18_);
	_tmp19_ = text;
	_tmp20_ = (GtkLabel*) gtk_label_new (_tmp19_);
	g_object_ref_sink (_tmp20_);
	label = _tmp20_;
	_tmp21_ = label;
	gtk_label_set_use_markup (_tmp21_, TRUE);
	_tmp22_ = label;
	gtk_misc_set_alignment ((GtkMisc*) _tmp22_, 0.0f, 0.5f);
	_tmp23_ = button;
	_tmp24_ = label;
	gtk_container_add ((GtkContainer*) _tmp23_, (GtkWidget*) _tmp24_);
	_tmp25_ = label;
	gtk_widget_show ((GtkWidget*) _tmp25_);
	_tmp26_ = writable;
	if (_tmp26_) {
		GtkButton* _tmp27_ = NULL;
		GtkButton* _tmp28_ = NULL;
		const gchar* _tmp29_ = NULL;
		gchar* _tmp30_ = NULL;
		GtkImage* image = NULL;
		GtkImage* _tmp31_ = NULL;
		GtkButton* _tmp32_ = NULL;
		GtkImage* _tmp33_ = NULL;
		GtkBox* _tmp34_ = NULL;
		GtkButton* _tmp35_ = NULL;
		GtkButton* _tmp36_ = NULL;
		GtkImage* _tmp37_ = NULL;
		GtkButton* _tmp38_ = NULL;
		GtkButton* _tmp39_ = NULL;
		GtkButton* _tmp40_ = NULL;
		const gchar* _tmp41_ = NULL;
		gchar* _tmp42_ = NULL;
		GtkImage* _tmp43_ = NULL;
		GtkButton* _tmp44_ = NULL;
		GtkImage* _tmp45_ = NULL;
		GtkBox* _tmp46_ = NULL;
		GtkButton* _tmp47_ = NULL;
		GtkButton* _tmp48_ = NULL;
		GtkImage* _tmp49_ = NULL;
		GtkButton* _tmp50_ = NULL;
		_tmp27_ = (GtkButton*) gtk_button_new ();
		g_object_ref_sink (_tmp27_);
		_g_object_unref0 (button);
		button = _tmp27_;
		_tmp28_ = button;
		_tmp29_ = name;
		_tmp30_ = g_strdup (_tmp29_);
		g_object_set_data_full ((GObject*) _tmp28_, "function_name", _tmp30_, g_free);
		_tmp31_ = (GtkImage*) gtk_image_new_from_icon_name ("accessories-text-editor-symbolic", GTK_ICON_SIZE_BUTTON);
		g_object_ref_sink (_tmp31_);
		image = _tmp31_;
		_tmp32_ = button;
		_tmp33_ = image;
		gtk_container_add ((GtkContainer*) _tmp32_, (GtkWidget*) _tmp33_);
		_tmp34_ = hbox;
		_tmp35_ = button;
		gtk_box_pack_start (_tmp34_, (GtkWidget*) _tmp35_, FALSE, TRUE, (guint) 0);
		_tmp36_ = button;
		g_signal_connect_object (_tmp36_, "clicked", (GCallback) _math_function_popup_save_function_cb_gtk_button_clicked, self, 0);
		_tmp37_ = image;
		gtk_widget_show ((GtkWidget*) _tmp37_);
		_tmp38_ = button;
		gtk_widget_show ((GtkWidget*) _tmp38_);
		_tmp39_ = (GtkButton*) gtk_button_new ();
		g_object_ref_sink (_tmp39_);
		_g_object_unref0 (button);
		button = _tmp39_;
		_tmp40_ = button;
		_tmp41_ = name;
		_tmp42_ = g_strdup (_tmp41_);
		g_object_set_data_full ((GObject*) _tmp40_, "function_name", _tmp42_, g_free);
		_tmp43_ = (GtkImage*) gtk_image_new_from_icon_name ("edit-delete-symbolic", GTK_ICON_SIZE_BUTTON);
		g_object_ref_sink (_tmp43_);
		_g_object_unref0 (image);
		image = _tmp43_;
		_tmp44_ = button;
		_tmp45_ = image;
		gtk_container_add ((GtkContainer*) _tmp44_, (GtkWidget*) _tmp45_);
		_tmp46_ = hbox;
		_tmp47_ = button;
		gtk_box_pack_start (_tmp46_, (GtkWidget*) _tmp47_, FALSE, TRUE, (guint) 0);
		_tmp48_ = button;
		g_signal_connect_object (_tmp48_, "clicked", (GCallback) _math_function_popup_delete_function_cb_gtk_button_clicked, self, 0);
		_tmp49_ = image;
		gtk_widget_show ((GtkWidget*) _tmp49_);
		_tmp50_ = button;
		gtk_widget_show ((GtkWidget*) _tmp50_);
		_g_object_unref0 (image);
	}
	result = hbox;
	_g_object_unref0 (label);
	_g_free0 (function_details);
	_g_object_unref0 (button);
	_g_free0 (text);
	return result;
}


static void math_function_popup_class_init (MathFunctionPopupClass * klass) {
	math_function_popup_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (MathFunctionPopupPrivate));
	G_OBJECT_CLASS (klass)->finalize = math_function_popup_finalize;
}


static void math_function_popup_instance_init (MathFunctionPopup * self) {
	self->priv = MATH_FUNCTION_POPUP_GET_PRIVATE (self);
	self->priv->function_name_entry_placeholder_reseted = FALSE;
}


static void math_function_popup_finalize (GObject* obj) {
	MathFunctionPopup * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_MATH_FUNCTION_POPUP, MathFunctionPopup);
	_g_object_unref0 (self->priv->equation);
	_g_object_unref0 (self->priv->scrolled_window);
	_g_object_unref0 (self->priv->vbox);
	_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_popup_parent_class)->finalize (obj);
}


GType math_function_popup_get_type (void) {
	static volatile gsize math_function_popup_type_id__volatile = 0;
	if (g_once_init_enter (&math_function_popup_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (MathFunctionPopupClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) math_function_popup_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MathFunctionPopup), 0, (GInstanceInitFunc) math_function_popup_instance_init, NULL };
		GType math_function_popup_type_id;
		math_function_popup_type_id = g_type_register_static (gtk_window_get_type (), "MathFunctionPopup", &g_define_type_info, 0);
		g_once_init_leave (&math_function_popup_type_id__volatile, math_function_popup_type_id);
	}
	return math_function_popup_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);
}



