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

/*
 * Copyright (C) 2008-2012 Robert Ancell
 *
 * 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 <adwaita.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <glib.h>
#include "calculator.h"
#include <stdlib.h>
#include <string.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 TYPE_BASIC_BUTTON_PANEL (basic_button_panel_get_type ())
#define BASIC_BUTTON_PANEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_BASIC_BUTTON_PANEL, BasicButtonPanel))
#define BASIC_BUTTON_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_BASIC_BUTTON_PANEL, BasicButtonPanelClass))
#define IS_BASIC_BUTTON_PANEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_BASIC_BUTTON_PANEL))
#define IS_BASIC_BUTTON_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_BASIC_BUTTON_PANEL))
#define BASIC_BUTTON_PANEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_BASIC_BUTTON_PANEL, BasicButtonPanelClass))

typedef struct _BasicButtonPanel BasicButtonPanel;
typedef struct _BasicButtonPanelClass BasicButtonPanelClass;
typedef struct _BasicButtonPanelPrivate BasicButtonPanelPrivate;
enum  {
	BASIC_BUTTON_PANEL_0_PROPERTY,
	BASIC_BUTTON_PANEL_NUM_PROPERTIES
};
static GParamSpec* basic_button_panel_properties[BASIC_BUTTON_PANEL_NUM_PROPERTIES];

#define TYPE_MATH_BUTTONS (math_buttons_get_type ())
#define MATH_BUTTONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MATH_BUTTONS, MathButtons))
#define MATH_BUTTONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MATH_BUTTONS, MathButtonsClass))
#define IS_MATH_BUTTONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MATH_BUTTONS))
#define IS_MATH_BUTTONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MATH_BUTTONS))
#define MATH_BUTTONS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MATH_BUTTONS, MathButtonsClass))

typedef struct _MathButtons MathButtons;
typedef struct _MathButtonsClass MathButtonsClass;
#define _g_free0(var) (var = (g_free (var), NULL))

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

typedef struct _MathPopover MathPopover;
typedef struct _MathPopoverClass MathPopoverClass;

#define TYPE_MATH_VARIABLE_POPOVER (math_variable_popover_get_type ())
#define MATH_VARIABLE_POPOVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MATH_VARIABLE_POPOVER, MathVariablePopover))
#define MATH_VARIABLE_POPOVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MATH_VARIABLE_POPOVER, MathVariablePopoverClass))
#define IS_MATH_VARIABLE_POPOVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MATH_VARIABLE_POPOVER))
#define IS_MATH_VARIABLE_POPOVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MATH_VARIABLE_POPOVER))
#define MATH_VARIABLE_POPOVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MATH_VARIABLE_POPOVER, MathVariablePopoverClass))

typedef struct _MathVariablePopover MathVariablePopover;
typedef struct _MathVariablePopoverClass MathVariablePopoverClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

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

struct _BasicButtonPanel {
	AdwBin parent_instance;
	BasicButtonPanelPrivate * priv;
};

struct _BasicButtonPanelClass {
	AdwBinClass parent_class;
};

struct _BasicButtonPanelPrivate {
	GtkWidget* basic;
	GtkButton* calc_numeric_point_button;
	GtkMenuButton* calc_memory_button;
	GtkMenuButton* calc_function_button;
};

static gint BasicButtonPanel_private_offset;
static gpointer basic_button_panel_parent_class = NULL;

VALA_EXTERN GType basic_button_panel_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BasicButtonPanel, g_object_unref)
VALA_EXTERN GType math_buttons_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MathButtons, g_object_unref)
VALA_EXTERN BasicButtonPanel* basic_button_panel_new (MathButtons* buttons);
VALA_EXTERN BasicButtonPanel* basic_button_panel_construct (GType object_type,
                                                MathButtons* buttons);
VALA_EXTERN MathEquation* math_buttons_get_equation (MathButtons* self);
VALA_EXTERN MathVariablePopover* math_variable_popover_new (MathEquation* equation);
VALA_EXTERN MathVariablePopover* math_variable_popover_construct (GType object_type,
                                                      MathEquation* equation);
VALA_EXTERN GType math_popover_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MathPopover, g_object_unref)
VALA_EXTERN GType math_variable_popover_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MathVariablePopover, g_object_unref)
VALA_EXTERN MathFunctionPopover* math_function_popover_new (MathEquation* equation);
VALA_EXTERN MathFunctionPopover* math_function_popover_construct (GType object_type,
                                                      MathEquation* equation);
VALA_EXTERN GType math_function_popover_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MathFunctionPopover, g_object_unref)
static void basic_button_panel_finalize (GObject * obj);
static GType basic_button_panel_get_type_once (void);

static inline gpointer
basic_button_panel_get_instance_private (BasicButtonPanel* self)
{
	return G_STRUCT_MEMBER_P (self, BasicButtonPanel_private_offset);
}

static gchar*
g_unichar_to_string (gunichar self)
{
	gchar* str = NULL;
	gchar* _tmp0_;
	gchar* result;
	_tmp0_ = g_new0 (gchar, 7);
	str = (gchar*) _tmp0_;
	g_unichar_to_utf8 (self, str);
	result = str;
	return result;
}

BasicButtonPanel*
basic_button_panel_construct (GType object_type,
                              MathButtons* buttons)
{
	BasicButtonPanel * self = NULL;
	GtkWidget* _tmp0_;
	GtkButton* _tmp1_;
	MathEquation* _tmp2_;
	MathEquation* _tmp3_;
	Serializer* _tmp4_;
	Serializer* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	GtkMenuButton* _tmp8_;
	MathEquation* _tmp9_;
	MathEquation* _tmp10_;
	MathVariablePopover* _tmp11_;
	MathVariablePopover* _tmp12_;
	GtkMenuButton* _tmp13_;
	MathEquation* _tmp14_;
	MathEquation* _tmp15_;
	MathFunctionPopover* _tmp16_;
	MathFunctionPopover* _tmp17_;
	g_return_val_if_fail (buttons != NULL, NULL);
	self = (BasicButtonPanel*) g_object_new (object_type, NULL);
	_tmp0_ = self->priv->basic;
	gtk_widget_set_direction (_tmp0_, GTK_TEXT_DIR_LTR);
	_tmp1_ = self->priv->calc_numeric_point_button;
	_tmp2_ = math_buttons_get_equation (buttons);
	_tmp3_ = _tmp2_;
	_tmp4_ = math_equation_get_serializer (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = g_unichar_to_string (serializer_get_radix (_tmp5_));
	_tmp7_ = _tmp6_;
	gtk_button_set_label (_tmp1_, _tmp7_);
	_g_free0 (_tmp7_);
	_tmp8_ = self->priv->calc_memory_button;
	_tmp9_ = math_buttons_get_equation (buttons);
	_tmp10_ = _tmp9_;
	_tmp11_ = math_variable_popover_new (_tmp10_);
	g_object_ref_sink (_tmp11_);
	_tmp12_ = _tmp11_;
	gtk_menu_button_set_popover (_tmp8_, (GtkPopover*) _tmp12_);
	_g_object_unref0 (_tmp12_);
	_tmp13_ = self->priv->calc_function_button;
	_tmp14_ = math_buttons_get_equation (buttons);
	_tmp15_ = _tmp14_;
	_tmp16_ = math_function_popover_new (_tmp15_);
	g_object_ref_sink (_tmp16_);
	_tmp17_ = _tmp16_;
	gtk_menu_button_set_popover (_tmp13_, (GtkPopover*) _tmp17_);
	_g_object_unref0 (_tmp17_);
	return self;
}

BasicButtonPanel*
basic_button_panel_new (MathButtons* buttons)
{
	return basic_button_panel_construct (TYPE_BASIC_BUTTON_PANEL, buttons);
}

static void
basic_button_panel_class_init (BasicButtonPanelClass * klass,
                               gpointer klass_data)
{
	basic_button_panel_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BasicButtonPanel_private_offset);
	G_OBJECT_CLASS (klass)->finalize = basic_button_panel_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/calculator/buttons-basic.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "basic", FALSE, BasicButtonPanel_private_offset + G_STRUCT_OFFSET (BasicButtonPanelPrivate, basic));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "calc_numeric_point_button", FALSE, BasicButtonPanel_private_offset + G_STRUCT_OFFSET (BasicButtonPanelPrivate, calc_numeric_point_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "calc_memory_button", FALSE, BasicButtonPanel_private_offset + G_STRUCT_OFFSET (BasicButtonPanelPrivate, calc_memory_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "calc_function_button", FALSE, BasicButtonPanel_private_offset + G_STRUCT_OFFSET (BasicButtonPanelPrivate, calc_function_button));
}

static void
basic_button_panel_instance_init (BasicButtonPanel * self,
                                  gpointer klass)
{
	self->priv = basic_button_panel_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
basic_button_panel_finalize (GObject * obj)
{
	BasicButtonPanel * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_BASIC_BUTTON_PANEL, BasicButtonPanel);
	G_OBJECT_CLASS (basic_button_panel_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
basic_button_panel_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BasicButtonPanelClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) basic_button_panel_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BasicButtonPanel), 0, (GInstanceInitFunc) basic_button_panel_instance_init, NULL };
	GType basic_button_panel_type_id;
	basic_button_panel_type_id = g_type_register_static (adw_bin_get_type (), "BasicButtonPanel", &g_define_type_info, 0);
	BasicButtonPanel_private_offset = g_type_add_instance_private (basic_button_panel_type_id, sizeof (BasicButtonPanelPrivate));
	return basic_button_panel_type_id;
}

GType
basic_button_panel_get_type (void)
{
	static gsize basic_button_panel_type_id__once = 0;
	if (g_once_init_enter (&basic_button_panel_type_id__once)) {
		GType basic_button_panel_type_id;
		basic_button_panel_type_id = basic_button_panel_get_type_once ();
		g_once_init_leave (&basic_button_panel_type_id__once, basic_button_panel_type_id);
	}
	return basic_button_panel_type_id__once;
}

