/* HistoryDialog.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from HistoryDialog.vala, do not modify */

/*-
 * Copyright 2018-2021 elementary, Inc. (https://elementary.io)
 *           2014 Marvin Beckers <beckersmarvin@gmail.com>
 *
 * 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.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Authored by: Marvin Beckers <beckersmarvin@gmail.com>
 */

#include <granite-7.h>
#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
#include <float.h>
#include <math.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define PANTHEON_CALCULATOR_TYPE_HISTORY_DIALOG (pantheon_calculator_history_dialog_get_type ())
#define PANTHEON_CALCULATOR_HISTORY_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PANTHEON_CALCULATOR_TYPE_HISTORY_DIALOG, PantheonCalculatorHistoryDialog))
#define PANTHEON_CALCULATOR_HISTORY_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANTHEON_CALCULATOR_TYPE_HISTORY_DIALOG, PantheonCalculatorHistoryDialogClass))
#define PANTHEON_CALCULATOR_IS_HISTORY_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PANTHEON_CALCULATOR_TYPE_HISTORY_DIALOG))
#define PANTHEON_CALCULATOR_IS_HISTORY_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANTHEON_CALCULATOR_TYPE_HISTORY_DIALOG))
#define PANTHEON_CALCULATOR_HISTORY_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANTHEON_CALCULATOR_TYPE_HISTORY_DIALOG, PantheonCalculatorHistoryDialogClass))

typedef struct _PantheonCalculatorHistoryDialog PantheonCalculatorHistoryDialog;
typedef struct _PantheonCalculatorHistoryDialogClass PantheonCalculatorHistoryDialogClass;
typedef struct _PantheonCalculatorHistoryDialogPrivate PantheonCalculatorHistoryDialogPrivate;

#define PANTHEON_CALCULATOR_MAIN_WINDOW_TYPE_HISTORY (pantheon_calculator_main_window_history_get_type ())
typedef struct _PantheonCalculatorMainWindowHistory PantheonCalculatorMainWindowHistory;
enum  {
	PANTHEON_CALCULATOR_HISTORY_DIALOG_0_PROPERTY,
	PANTHEON_CALCULATOR_HISTORY_DIALOG_HISTORY_PROPERTY,
	PANTHEON_CALCULATOR_HISTORY_DIALOG_NUM_PROPERTIES
};
static GParamSpec* pantheon_calculator_history_dialog_properties[PANTHEON_CALCULATOR_HISTORY_DIALOG_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	PANTHEON_CALCULATOR_HISTORY_DIALOG_CLEAR_HISTORY_SIGNAL,
	PANTHEON_CALCULATOR_HISTORY_DIALOG_ADDED_SIGNAL,
	PANTHEON_CALCULATOR_HISTORY_DIALOG_NUM_SIGNALS
};
static guint pantheon_calculator_history_dialog_signals[PANTHEON_CALCULATOR_HISTORY_DIALOG_NUM_SIGNALS] = {0};

struct _PantheonCalculatorHistoryDialog {
	GraniteDialog parent_instance;
	PantheonCalculatorHistoryDialogPrivate * priv;
};

struct _PantheonCalculatorHistoryDialogClass {
	GraniteDialogClass parent_class;
};

struct _PantheonCalculatorMainWindowHistory {
	gchar* exp;
	gchar* output;
};

struct _PantheonCalculatorHistoryDialogPrivate {
	GList* _history;
	GtkTreeView* view;
	GtkListStore* list_store;
	GtkCheckButton* expression_check_button;
	GtkCheckButton* result_check_button;
};

static gint PantheonCalculatorHistoryDialog_private_offset;
static gpointer pantheon_calculator_history_dialog_parent_class = NULL;

VALA_EXTERN GType pantheon_calculator_history_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PantheonCalculatorHistoryDialog, g_object_unref)
VALA_EXTERN GType pantheon_calculator_main_window_history_get_type (void) G_GNUC_CONST ;
VALA_EXTERN PantheonCalculatorMainWindowHistory* pantheon_calculator_main_window_history_dup (const PantheonCalculatorMainWindowHistory* self);
VALA_EXTERN void pantheon_calculator_main_window_history_free (PantheonCalculatorMainWindowHistory* self);
VALA_EXTERN void pantheon_calculator_main_window_history_copy (const PantheonCalculatorMainWindowHistory* self,
                                                   PantheonCalculatorMainWindowHistory* dest);
VALA_EXTERN void pantheon_calculator_main_window_history_destroy (PantheonCalculatorMainWindowHistory* self);
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (PantheonCalculatorMainWindowHistory, pantheon_calculator_main_window_history_destroy)
VALA_EXTERN PantheonCalculatorHistoryDialog* pantheon_calculator_history_dialog_new (GList* _history);
VALA_EXTERN PantheonCalculatorHistoryDialog* pantheon_calculator_history_dialog_construct (GType object_type,
                                                                               GList* _history);
VALA_EXTERN void pantheon_calculator_history_dialog_append (PantheonCalculatorHistoryDialog* self,
                                                PantheonCalculatorMainWindowHistory* entry);
static void pantheon_calculator_history_dialog_on_response (PantheonCalculatorHistoryDialog* self,
                                                     GtkDialog* source,
                                                     gint response_id);
VALA_EXTERN GList* pantheon_calculator_history_dialog_get_history (PantheonCalculatorHistoryDialog* self);
static void pantheon_calculator_history_dialog_set_history (PantheonCalculatorHistoryDialog* self,
                                                     GList* value);
static GObject * pantheon_calculator_history_dialog_constructor (GType type,
                                                          guint n_construct_properties,
                                                          GObjectConstructParam * construct_properties);
static void _pantheon_calculator_history_dialog_on_response_gtk_dialog_response (GtkDialog* _sender,
                                                                          gint response_id,
                                                                          gpointer self);
static void pantheon_calculator_history_dialog_finalize (GObject * obj);
static GType pantheon_calculator_history_dialog_get_type_once (void);
static void _vala_pantheon_calculator_history_dialog_get_property (GObject * object,
                                                            guint property_id,
                                                            GValue * value,
                                                            GParamSpec * pspec);
static void _vala_pantheon_calculator_history_dialog_set_property (GObject * object,
                                                            guint property_id,
                                                            const GValue * value,
                                                            GParamSpec * pspec);

static inline gpointer
pantheon_calculator_history_dialog_get_instance_private (PantheonCalculatorHistoryDialog* self)
{
	return G_STRUCT_MEMBER_P (self, PantheonCalculatorHistoryDialog_private_offset);
}

PantheonCalculatorHistoryDialog*
pantheon_calculator_history_dialog_construct (GType object_type,
                                              GList* _history)
{
	PantheonCalculatorHistoryDialog * self = NULL;
	self = (PantheonCalculatorHistoryDialog*) g_object_new (object_type, "history", _history, NULL);
	return self;
}

PantheonCalculatorHistoryDialog*
pantheon_calculator_history_dialog_new (GList* _history)
{
	return pantheon_calculator_history_dialog_construct (PANTHEON_CALCULATOR_TYPE_HISTORY_DIALOG, _history);
}

void
pantheon_calculator_history_dialog_append (PantheonCalculatorHistoryDialog* self,
                                           PantheonCalculatorMainWindowHistory* entry)
{
	GtkTreeIter iter = {0};
	GtkListStore* _tmp0_;
	GtkTreeIter _tmp1_ = {0};
	GtkListStore* _tmp2_;
	GtkTreeIter _tmp3_;
	PantheonCalculatorMainWindowHistory _tmp4_;
	const gchar* _tmp5_;
	PantheonCalculatorMainWindowHistory _tmp6_;
	const gchar* _tmp7_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (entry != NULL);
	_tmp0_ = self->priv->list_store;
	gtk_list_store_insert (_tmp0_, &_tmp1_, 0);
	iter = _tmp1_;
	_tmp2_ = self->priv->list_store;
	_tmp3_ = iter;
	_tmp4_ = *entry;
	_tmp5_ = _tmp4_.exp;
	_tmp6_ = *entry;
	_tmp7_ = _tmp6_.output;
	gtk_list_store_set (_tmp2_, &_tmp3_, 0, _tmp5_, 1, _tmp7_, -1);
}

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

static void
pantheon_calculator_history_dialog_on_response (PantheonCalculatorHistoryDialog* self,
                                                GtkDialog* source,
                                                gint response_id)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (source != NULL);
	if (response_id == 0) {
		GtkListStore* _tmp0_;
		_tmp0_ = self->priv->list_store;
		gtk_list_store_clear (_tmp0_);
		g_signal_emit (self, pantheon_calculator_history_dialog_signals[PANTHEON_CALCULATOR_HISTORY_DIALOG_CLEAR_HISTORY_SIGNAL], 0);
	} else {
		if (response_id == ((gint) GTK_RESPONSE_APPLY)) {
			GtkTreeSelection* selection = NULL;
			GtkTreeView* _tmp1_;
			GtkTreeSelection* _tmp2_;
			GtkTreeSelection* _tmp3_;
			GtkTreeIter iter = {0};
			GtkTreeSelection* _tmp4_;
			GtkTreeIter _tmp5_ = {0};
			gboolean _tmp6_;
			_tmp1_ = self->priv->view;
			_tmp2_ = gtk_tree_view_get_selection (_tmp1_);
			_tmp3_ = _g_object_ref0 (_tmp2_);
			selection = _tmp3_;
			_tmp4_ = selection;
			_tmp6_ = gtk_tree_selection_get_selected (_tmp4_, NULL, &_tmp5_);
			iter = _tmp5_;
			if (_tmp6_) {
				GValue val = {0};
				GValue _tmp7_ = {0};
				GtkCheckButton* _tmp8_;
				const gchar* _tmp16_;
				g_value_init (&_tmp7_, G_TYPE_STRING);
				val = _tmp7_;
				_tmp8_ = self->priv->result_check_button;
				if (gtk_check_button_get_active (_tmp8_)) {
					GtkListStore* _tmp9_;
					GtkTreeIter _tmp10_;
					GValue _tmp11_ = {0};
					_tmp9_ = self->priv->list_store;
					_tmp10_ = iter;
					gtk_tree_model_get_value ((GtkTreeModel*) _tmp9_, &_tmp10_, 1, &_tmp11_);
					G_IS_VALUE (&val) ? (g_value_unset (&val), NULL) : NULL;
					val = _tmp11_;
				} else {
					GtkCheckButton* _tmp12_;
					_tmp12_ = self->priv->expression_check_button;
					if (gtk_check_button_get_active (_tmp12_)) {
						GtkListStore* _tmp13_;
						GtkTreeIter _tmp14_;
						GValue _tmp15_ = {0};
						_tmp13_ = self->priv->list_store;
						_tmp14_ = iter;
						gtk_tree_model_get_value ((GtkTreeModel*) _tmp13_, &_tmp14_, 0, &_tmp15_);
						G_IS_VALUE (&val) ? (g_value_unset (&val), NULL) : NULL;
						val = _tmp15_;
					}
				}
				_tmp16_ = g_value_get_string (&val);
				g_signal_emit (self, pantheon_calculator_history_dialog_signals[PANTHEON_CALCULATOR_HISTORY_DIALOG_ADDED_SIGNAL], 0, _tmp16_);
				G_IS_VALUE (&val) ? (g_value_unset (&val), NULL) : NULL;
			}
			_g_object_unref0 (selection);
		}
	}
	gtk_widget_hide ((GtkWidget*) self);
	gtk_window_destroy ((GtkWindow*) self);
}

GList*
pantheon_calculator_history_dialog_get_history (PantheonCalculatorHistoryDialog* self)
{
	GList* result;
	GList* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_history;
	result = _tmp0_;
	return result;
}

static void
pantheon_calculator_history_dialog_set_history (PantheonCalculatorHistoryDialog* self,
                                                GList* value)
{
	GList* old_value;
	g_return_if_fail (self != NULL);
	old_value = pantheon_calculator_history_dialog_get_history (self);
	if (old_value != value) {
		self->priv->_history = value;
		g_object_notify_by_pspec ((GObject *) self, pantheon_calculator_history_dialog_properties[PANTHEON_CALCULATOR_HISTORY_DIALOG_HISTORY_PROPERTY]);
	}
}

static void
_pantheon_calculator_history_dialog_on_response_gtk_dialog_response (GtkDialog* _sender,
                                                                     gint response_id,
                                                                     gpointer self)
{
	pantheon_calculator_history_dialog_on_response ((PantheonCalculatorHistoryDialog*) self, _sender, response_id);
}

static GObject *
pantheon_calculator_history_dialog_constructor (GType type,
                                                guint n_construct_properties,
                                                GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	PantheonCalculatorHistoryDialog * self;
	GtkLabel* description_label = NULL;
	GtkLabel* _tmp0_ = NULL;
	GtkListStore* _tmp1_;
	GtkTreeIter iter = {0};
	GList* _tmp2_;
	GtkCellRendererText* cell = NULL;
	GtkCellRendererText* _tmp13_;
	GtkListStore* _tmp14_;
	GtkTreeView* _tmp15_ = NULL;
	GtkTreeView* _tmp16_;
	GtkTreeView* _tmp17_;
	GtkCellRendererText* _tmp18_;
	GtkTreeView* _tmp19_;
	GtkCellRendererText* _tmp20_;
	GtkTreeView* _tmp21_;
	GtkTreeViewColumn* _tmp22_;
	GtkTreeView* _tmp23_;
	GtkTreeViewColumn* _tmp24_;
	GtkScrolledWindow* scrolled = NULL;
	GtkTreeView* _tmp25_;
	GtkWidget* _tmp26_;
	GtkScrolledWindow* _tmp27_ = NULL;
	GtkFrame* frame = NULL;
	GtkScrolledWindow* _tmp28_;
	GtkWidget* _tmp29_;
	GtkFrame* _tmp30_ = NULL;
	GtkLabel* add_label = NULL;
	GtkLabel* _tmp31_ = NULL;
	GtkCheckButton* _tmp32_ = NULL;
	GtkCheckButton* _tmp33_;
	GtkCheckButton* _tmp34_;
	GtkCheckButton* _tmp35_ = NULL;
	GtkGrid* main_grid = NULL;
	GtkGrid* _tmp36_ = NULL;
	GtkGrid* _tmp37_;
	GtkLabel* _tmp38_;
	GtkGrid* _tmp39_;
	GtkFrame* _tmp40_;
	GtkGrid* _tmp41_;
	GtkLabel* _tmp42_;
	GtkGrid* _tmp43_;
	GtkCheckButton* _tmp44_;
	GtkGrid* _tmp45_;
	GtkCheckButton* _tmp46_;
	GtkBox* _tmp47_;
	GtkGrid* _tmp48_;
	GtkWidget* button_clear = NULL;
	GtkWidget* _tmp49_;
	GtkWidget* _tmp50_;
	GtkWidget* _tmp51_;
	GtkWidget* button_add = NULL;
	GtkWidget* _tmp52_;
	GtkWidget* _tmp53_;
	GtkWidget* _tmp54_;
	parent_class = G_OBJECT_CLASS (pantheon_calculator_history_dialog_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PANTHEON_CALCULATOR_TYPE_HISTORY_DIALOG, PantheonCalculatorHistoryDialog);
	gtk_window_set_deletable ((GtkWindow*) self, FALSE);
	gtk_window_set_title ((GtkWindow*) self, _ ("History"));
	g_object_set ((GtkWindow*) self, "default-width", 250, NULL);
	_tmp0_ = (GtkLabel*) gtk_label_new (_ ("Insert a previous expression or result into the current calculation."));
	gtk_label_set_xalign (_tmp0_, (gfloat) 0);
	gtk_widget_set_halign ((GtkWidget*) _tmp0_, GTK_ALIGN_START);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp0_, TRUE);
	gtk_label_set_justify (_tmp0_, GTK_JUSTIFY_LEFT);
	gtk_label_set_wrap (_tmp0_, TRUE);
	g_object_ref_sink (_tmp0_);
	description_label = _tmp0_;
	_tmp1_ = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING, -1);
	_g_object_unref0 (self->priv->list_store);
	self->priv->list_store = _tmp1_;
	_tmp2_ = self->priv->_history;
	{
		GList* h_collection = NULL;
		GList* h_it = NULL;
		h_collection = _tmp2_;
		for (h_it = h_collection; h_it != NULL; h_it = h_it->next) {
			PantheonCalculatorMainWindowHistory _tmp3_;
			PantheonCalculatorMainWindowHistory _tmp4_ = {0};
			PantheonCalculatorMainWindowHistory h = {0};
			_tmp3_ = *((PantheonCalculatorMainWindowHistory*) h_it->data);
			pantheon_calculator_main_window_history_copy (&_tmp3_, &_tmp4_);
			h = _tmp4_;
			{
				GtkListStore* _tmp5_;
				GtkTreeIter _tmp6_ = {0};
				GtkListStore* _tmp7_;
				GtkTreeIter _tmp8_;
				PantheonCalculatorMainWindowHistory _tmp9_;
				const gchar* _tmp10_;
				PantheonCalculatorMainWindowHistory _tmp11_;
				const gchar* _tmp12_;
				_tmp5_ = self->priv->list_store;
				gtk_list_store_insert (_tmp5_, &_tmp6_, 0);
				iter = _tmp6_;
				_tmp7_ = self->priv->list_store;
				_tmp8_ = iter;
				_tmp9_ = h;
				_tmp10_ = _tmp9_.exp;
				_tmp11_ = h;
				_tmp12_ = _tmp11_.output;
				gtk_list_store_set (_tmp7_, &_tmp8_, 0, _tmp10_, 1, _tmp12_, -1);
				pantheon_calculator_main_window_history_destroy (&h);
			}
		}
	}
	_tmp13_ = (GtkCellRendererText*) gtk_cell_renderer_text_new ();
	g_object_ref_sink (_tmp13_);
	cell = _tmp13_;
	_tmp14_ = self->priv->list_store;
	_tmp15_ = (GtkTreeView*) gtk_tree_view_new_with_model ((GtkTreeModel*) _tmp14_);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp15_, TRUE);
	gtk_widget_set_vexpand ((GtkWidget*) _tmp15_, TRUE);
	gtk_tree_view_set_headers_visible (_tmp15_, FALSE);
	g_object_ref_sink (_tmp15_);
	_g_object_unref0 (self->priv->view);
	self->priv->view = _tmp15_;
	_tmp16_ = self->priv->view;
	gtk_widget_add_css_class ((GtkWidget*) _tmp16_, GRANITE_STYLE_CLASS_H3_LABEL);
	_tmp17_ = self->priv->view;
	_tmp18_ = cell;
	gtk_tree_view_insert_column_with_attributes (_tmp17_, -1, NULL, (GtkCellRenderer*) _tmp18_, "text", 0, NULL);
	_tmp19_ = self->priv->view;
	_tmp20_ = cell;
	gtk_tree_view_insert_column_with_attributes (_tmp19_, -1, NULL, (GtkCellRenderer*) _tmp20_, "text", 1, NULL);
	_tmp21_ = self->priv->view;
	_tmp22_ = gtk_tree_view_get_column (_tmp21_, 1);
	gtk_tree_view_column_set_min_width (_tmp22_, 75);
	_tmp23_ = self->priv->view;
	_tmp24_ = gtk_tree_view_get_column (_tmp23_, 0);
	gtk_tree_view_column_set_min_width (_tmp24_, 200);
	_tmp25_ = self->priv->view;
	_tmp26_ = _g_object_ref0 ((GtkWidget*) _tmp25_);
	_tmp27_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	gtk_scrolled_window_set_min_content_height (_tmp27_, 125);
	gtk_scrolled_window_set_child (_tmp27_, _tmp26_);
	_g_object_unref0 (_tmp26_);
	g_object_ref_sink (_tmp27_);
	scrolled = _tmp27_;
	_tmp28_ = scrolled;
	_tmp29_ = _g_object_ref0 ((GtkWidget*) _tmp28_);
	_tmp30_ = (GtkFrame*) gtk_frame_new (NULL);
	gtk_frame_set_child (_tmp30_, _tmp29_);
	_g_object_unref0 (_tmp29_);
	g_object_ref_sink (_tmp30_);
	frame = _tmp30_;
	_tmp31_ = (GtkLabel*) gtk_label_new (_ ("Value to insert:"));
	gtk_widget_set_halign ((GtkWidget*) _tmp31_, GTK_ALIGN_END);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp31_, TRUE);
	g_object_ref_sink (_tmp31_);
	add_label = _tmp31_;
	_tmp32_ = (GtkCheckButton*) gtk_check_button_new_with_label (_ ("Result"));
	gtk_check_button_set_active (_tmp32_, TRUE);
	g_object_ref_sink (_tmp32_);
	_g_object_unref0 (self->priv->result_check_button);
	self->priv->result_check_button = _tmp32_;
	_tmp33_ = self->priv->result_check_button;
	_tmp34_ = _g_object_ref0 (_tmp33_);
	_tmp35_ = (GtkCheckButton*) gtk_check_button_new_with_label (_ ("Expression"));
	gtk_check_button_set_group (_tmp35_, _tmp34_);
	_g_object_unref0 (_tmp34_);
	g_object_ref_sink (_tmp35_);
	_g_object_unref0 (self->priv->expression_check_button);
	self->priv->expression_check_button = _tmp35_;
	_tmp36_ = (GtkGrid*) gtk_grid_new ();
	gtk_grid_set_column_spacing (_tmp36_, 12);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp36_, TRUE);
	gtk_widget_set_vexpand ((GtkWidget*) _tmp36_, TRUE);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp36_, 12);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp36_, 12);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp36_, 12);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp36_, 0);
	gtk_grid_set_row_spacing (_tmp36_, 12);
	g_object_ref_sink (_tmp36_);
	main_grid = _tmp36_;
	_tmp37_ = main_grid;
	_tmp38_ = description_label;
	gtk_grid_attach (_tmp37_, (GtkWidget*) _tmp38_, 0, 0, 3, 1);
	_tmp39_ = main_grid;
	_tmp40_ = frame;
	gtk_grid_attach (_tmp39_, (GtkWidget*) _tmp40_, 0, 1, 3, 1);
	_tmp41_ = main_grid;
	_tmp42_ = add_label;
	gtk_grid_attach (_tmp41_, (GtkWidget*) _tmp42_, 0, 2, 1, 1);
	_tmp43_ = main_grid;
	_tmp44_ = self->priv->result_check_button;
	gtk_grid_attach (_tmp43_, (GtkWidget*) _tmp44_, 2, 2, 1, 1);
	_tmp45_ = main_grid;
	_tmp46_ = self->priv->expression_check_button;
	gtk_grid_attach (_tmp45_, (GtkWidget*) _tmp46_, 1, 2, 1, 1);
	_tmp47_ = gtk_dialog_get_content_area ((GtkDialog*) self);
	_tmp48_ = main_grid;
	gtk_box_append (_tmp47_, (GtkWidget*) _tmp48_);
	_tmp49_ = granite_dialog_add_button ((GraniteDialog*) self, _ ("Clear History"), 0);
	_tmp50_ = _g_object_ref0 (_tmp49_);
	button_clear = _tmp50_;
	_tmp51_ = button_clear;
	gtk_widget_add_css_class (_tmp51_, GRANITE_STYLE_CLASS_DESTRUCTIVE_ACTION);
	granite_dialog_add_button ((GraniteDialog*) self, _ ("Close"), (gint) GTK_RESPONSE_CLOSE);
	_tmp52_ = granite_dialog_add_button ((GraniteDialog*) self, _ ("Insert"), (gint) GTK_RESPONSE_APPLY);
	_tmp53_ = _g_object_ref0 (_tmp52_);
	button_add = _tmp53_;
	_tmp54_ = button_add;
	gtk_widget_add_css_class (_tmp54_, GRANITE_STYLE_CLASS_SUGGESTED_ACTION);
	g_signal_connect_object ((GtkDialog*) self, "response", (GCallback) _pantheon_calculator_history_dialog_on_response_gtk_dialog_response, self, 0);
	_g_object_unref0 (button_add);
	_g_object_unref0 (button_clear);
	_g_object_unref0 (main_grid);
	_g_object_unref0 (add_label);
	_g_object_unref0 (frame);
	_g_object_unref0 (scrolled);
	_g_object_unref0 (cell);
	_g_object_unref0 (description_label);
	return obj;
}

static void
pantheon_calculator_history_dialog_class_init (PantheonCalculatorHistoryDialogClass * klass,
                                               gpointer klass_data)
{
	pantheon_calculator_history_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &PantheonCalculatorHistoryDialog_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_pantheon_calculator_history_dialog_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_pantheon_calculator_history_dialog_set_property;
	G_OBJECT_CLASS (klass)->constructor = pantheon_calculator_history_dialog_constructor;
	G_OBJECT_CLASS (klass)->finalize = pantheon_calculator_history_dialog_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), PANTHEON_CALCULATOR_HISTORY_DIALOG_HISTORY_PROPERTY, pantheon_calculator_history_dialog_properties[PANTHEON_CALCULATOR_HISTORY_DIALOG_HISTORY_PROPERTY] = g_param_spec_pointer ("history", "history", "history", G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	pantheon_calculator_history_dialog_signals[PANTHEON_CALCULATOR_HISTORY_DIALOG_CLEAR_HISTORY_SIGNAL] = g_signal_new ("clear-history", PANTHEON_CALCULATOR_TYPE_HISTORY_DIALOG, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	pantheon_calculator_history_dialog_signals[PANTHEON_CALCULATOR_HISTORY_DIALOG_ADDED_SIGNAL] = g_signal_new ("added", PANTHEON_CALCULATOR_TYPE_HISTORY_DIALOG, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
}

static void
pantheon_calculator_history_dialog_instance_init (PantheonCalculatorHistoryDialog * self,
                                                  gpointer klass)
{
	self->priv = pantheon_calculator_history_dialog_get_instance_private (self);
}

static void
pantheon_calculator_history_dialog_finalize (GObject * obj)
{
	PantheonCalculatorHistoryDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PANTHEON_CALCULATOR_TYPE_HISTORY_DIALOG, PantheonCalculatorHistoryDialog);
	_g_object_unref0 (self->priv->view);
	_g_object_unref0 (self->priv->list_store);
	_g_object_unref0 (self->priv->expression_check_button);
	_g_object_unref0 (self->priv->result_check_button);
	G_OBJECT_CLASS (pantheon_calculator_history_dialog_parent_class)->finalize (obj);
}

static GType
pantheon_calculator_history_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (PantheonCalculatorHistoryDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) pantheon_calculator_history_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PantheonCalculatorHistoryDialog), 0, (GInstanceInitFunc) pantheon_calculator_history_dialog_instance_init, NULL };
	GType pantheon_calculator_history_dialog_type_id;
	pantheon_calculator_history_dialog_type_id = g_type_register_static (GRANITE_TYPE_DIALOG, "PantheonCalculatorHistoryDialog", &g_define_type_info, 0);
	PantheonCalculatorHistoryDialog_private_offset = g_type_add_instance_private (pantheon_calculator_history_dialog_type_id, sizeof (PantheonCalculatorHistoryDialogPrivate));
	return pantheon_calculator_history_dialog_type_id;
}

GType
pantheon_calculator_history_dialog_get_type (void)
{
	static volatile gsize pantheon_calculator_history_dialog_type_id__once = 0;
	if (g_once_init_enter (&pantheon_calculator_history_dialog_type_id__once)) {
		GType pantheon_calculator_history_dialog_type_id;
		pantheon_calculator_history_dialog_type_id = pantheon_calculator_history_dialog_get_type_once ();
		g_once_init_leave (&pantheon_calculator_history_dialog_type_id__once, pantheon_calculator_history_dialog_type_id);
	}
	return pantheon_calculator_history_dialog_type_id__once;
}

static void
_vala_pantheon_calculator_history_dialog_get_property (GObject * object,
                                                       guint property_id,
                                                       GValue * value,
                                                       GParamSpec * pspec)
{
	PantheonCalculatorHistoryDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PANTHEON_CALCULATOR_TYPE_HISTORY_DIALOG, PantheonCalculatorHistoryDialog);
	switch (property_id) {
		case PANTHEON_CALCULATOR_HISTORY_DIALOG_HISTORY_PROPERTY:
		g_value_set_pointer (value, pantheon_calculator_history_dialog_get_history (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_pantheon_calculator_history_dialog_set_property (GObject * object,
                                                       guint property_id,
                                                       const GValue * value,
                                                       GParamSpec * pspec)
{
	PantheonCalculatorHistoryDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PANTHEON_CALCULATOR_TYPE_HISTORY_DIALOG, PantheonCalculatorHistoryDialog);
	switch (property_id) {
		case PANTHEON_CALCULATOR_HISTORY_DIALOG_HISTORY_PROPERTY:
		pantheon_calculator_history_dialog_set_history (self, g_value_get_pointer (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

