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

/* -*- Mode: vala; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * Copyright © 2020 Andrii Kuteiko
 *
 * This file is part of GNOME Sudoku.
 *
 * GNOME Sudoku 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.
 *
 * GNOME Sudoku 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 GNOME Sudoku. If not, see <http://www.gnu.org/licenses/>.
 */

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

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

#define TYPE_SUDOKU_MAIN_MENU (sudoku_main_menu_get_type ())
#define SUDOKU_MAIN_MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SUDOKU_MAIN_MENU, SudokuMainMenu))
#define SUDOKU_MAIN_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SUDOKU_MAIN_MENU, SudokuMainMenuClass))
#define IS_SUDOKU_MAIN_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SUDOKU_MAIN_MENU))
#define IS_SUDOKU_MAIN_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SUDOKU_MAIN_MENU))
#define SUDOKU_MAIN_MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SUDOKU_MAIN_MENU, SudokuMainMenuClass))

typedef struct _SudokuMainMenu SudokuMainMenu;
typedef struct _SudokuMainMenuClass SudokuMainMenuClass;
typedef struct _SudokuMainMenuPrivate SudokuMainMenuPrivate;
enum  {
	SUDOKU_MAIN_MENU_0_PROPERTY,
	SUDOKU_MAIN_MENU_NUM_PROPERTIES
};
static GParamSpec* sudoku_main_menu_properties[SUDOKU_MAIN_MENU_NUM_PROPERTIES];

#define TYPE_SUDOKU_MAIN_MENU_ITEM (sudoku_main_menu_item_get_type ())
#define SUDOKU_MAIN_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SUDOKU_MAIN_MENU_ITEM, SudokuMainMenuItem))
#define SUDOKU_MAIN_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SUDOKU_MAIN_MENU_ITEM, SudokuMainMenuItemClass))
#define IS_SUDOKU_MAIN_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SUDOKU_MAIN_MENU_ITEM))
#define IS_SUDOKU_MAIN_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SUDOKU_MAIN_MENU_ITEM))
#define SUDOKU_MAIN_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SUDOKU_MAIN_MENU_ITEM, SudokuMainMenuItemClass))

typedef struct _SudokuMainMenuItem SudokuMainMenuItem;
typedef struct _SudokuMainMenuItemClass SudokuMainMenuItemClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _SudokuMainMenuItemPrivate SudokuMainMenuItemPrivate;
enum  {
	SUDOKU_MAIN_MENU_ITEM_0_PROPERTY,
	SUDOKU_MAIN_MENU_ITEM_LABEL_PROPERTY,
	SUDOKU_MAIN_MENU_ITEM_HAS_SEPARATOR_PROPERTY,
	SUDOKU_MAIN_MENU_ITEM_NUM_PROPERTIES
};
static GParamSpec* sudoku_main_menu_item_properties[SUDOKU_MAIN_MENU_ITEM_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

struct _SudokuMainMenu {
	GtkListBox parent_instance;
	SudokuMainMenuPrivate * priv;
};

struct _SudokuMainMenuClass {
	GtkListBoxClass parent_class;
};

struct _SudokuMainMenuItem {
	GtkListBoxRow parent_instance;
	SudokuMainMenuItemPrivate * priv;
};

struct _SudokuMainMenuItemClass {
	GtkListBoxRowClass parent_class;
};

struct _SudokuMainMenuItemPrivate {
	gchar* _label;
	gboolean _has_separator;
};

static gpointer sudoku_main_menu_parent_class = NULL;
static gint SudokuMainMenuItem_private_offset;
static gpointer sudoku_main_menu_item_parent_class = NULL;

VALA_EXTERN GType sudoku_main_menu_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SudokuMainMenu, g_object_unref)
VALA_EXTERN SudokuMainMenu* sudoku_main_menu_new (void);
VALA_EXTERN SudokuMainMenu* sudoku_main_menu_construct (GType object_type);
static GObject * sudoku_main_menu_constructor (GType type,
                                        guint n_construct_properties,
                                        GObjectConstructParam * construct_properties);
static void _sudoku_main_menu___lambda28_ (SudokuMainMenu* self,
                                    GtkListBoxRow* row);
VALA_EXTERN GType sudoku_main_menu_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SudokuMainMenuItem, g_object_unref)
VALA_EXTERN gboolean sudoku_main_menu_item_get_has_separator (SudokuMainMenuItem* self);
static void __sudoku_main_menu___lambda28__gtk_list_box_update_header_func (GtkListBoxRow* row,
                                                                     GtkListBoxRow* before,
                                                                     gpointer self);
static GType sudoku_main_menu_get_type_once (void);
VALA_EXTERN SudokuMainMenuItem* sudoku_main_menu_item_new (void);
VALA_EXTERN SudokuMainMenuItem* sudoku_main_menu_item_construct (GType object_type);
VALA_EXTERN const gchar* sudoku_main_menu_item_get_label (SudokuMainMenuItem* self);
VALA_EXTERN void sudoku_main_menu_item_set_label (SudokuMainMenuItem* self,
                                      const gchar* value);
VALA_EXTERN void sudoku_main_menu_item_set_has_separator (SudokuMainMenuItem* self,
                                              gboolean value);
static GObject * sudoku_main_menu_item_constructor (GType type,
                                             guint n_construct_properties,
                                             GObjectConstructParam * construct_properties);
static void sudoku_main_menu_item_finalize (GObject * obj);
static GType sudoku_main_menu_item_get_type_once (void);
static void _vala_sudoku_main_menu_item_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec);
static void _vala_sudoku_main_menu_item_set_property (GObject * object,
                                               guint property_id,
                                               const GValue * value,
                                               GParamSpec * pspec);

SudokuMainMenu*
sudoku_main_menu_construct (GType object_type)
{
	SudokuMainMenu * self = NULL;
	self = (SudokuMainMenu*) g_object_new (object_type, NULL);
	return self;
}

SudokuMainMenu*
sudoku_main_menu_new (void)
{
	return sudoku_main_menu_construct (TYPE_SUDOKU_MAIN_MENU);
}

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

static void
_sudoku_main_menu___lambda28_ (SudokuMainMenu* self,
                               GtkListBoxRow* row)
{
	SudokuMainMenuItem* mi = NULL;
	SudokuMainMenuItem* _tmp0_;
	gboolean _tmp1_ = FALSE;
	SudokuMainMenuItem* _tmp2_;
	g_return_if_fail (row != NULL);
	_tmp0_ = _g_object_ref0 (IS_SUDOKU_MAIN_MENU_ITEM (row) ? ((SudokuMainMenuItem*) row) : NULL);
	mi = _tmp0_;
	_tmp2_ = mi;
	if (_tmp2_ != NULL) {
		SudokuMainMenuItem* _tmp3_;
		gboolean _tmp4_;
		gboolean _tmp5_;
		_tmp3_ = mi;
		_tmp4_ = sudoku_main_menu_item_get_has_separator (_tmp3_);
		_tmp5_ = _tmp4_;
		_tmp1_ = _tmp5_;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		GtkSeparator* separator = NULL;
		GtkSeparator* _tmp6_;
		SudokuMainMenuItem* _tmp7_;
		GtkSeparator* _tmp8_;
		_tmp6_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
		g_object_ref_sink (_tmp6_);
		separator = _tmp6_;
		_tmp7_ = mi;
		_tmp8_ = separator;
		gtk_list_box_row_set_header ((GtkListBoxRow*) _tmp7_, (GtkWidget*) _tmp8_);
		_g_object_unref0 (separator);
	}
	_g_object_unref0 (mi);
}

static void
__sudoku_main_menu___lambda28__gtk_list_box_update_header_func (GtkListBoxRow* row,
                                                                GtkListBoxRow* before,
                                                                gpointer self)
{
	_sudoku_main_menu___lambda28_ ((SudokuMainMenu*) self, row);
}

static GObject *
sudoku_main_menu_constructor (GType type,
                              guint n_construct_properties,
                              GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	SudokuMainMenu * self;
	parent_class = G_OBJECT_CLASS (sudoku_main_menu_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_SUDOKU_MAIN_MENU, SudokuMainMenu);
	gtk_widget_set_visible ((GtkWidget*) self, TRUE);
	gtk_widget_set_can_focus ((GtkWidget*) self, FALSE);
	gtk_list_box_set_header_func ((GtkListBox*) self, __sudoku_main_menu___lambda28__gtk_list_box_update_header_func, g_object_ref (self), g_object_unref);
	return obj;
}

static void
sudoku_main_menu_class_init (SudokuMainMenuClass * klass,
                             gpointer klass_data)
{
	sudoku_main_menu_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->constructor = sudoku_main_menu_constructor;
}

static void
sudoku_main_menu_instance_init (SudokuMainMenu * self,
                                gpointer klass)
{
}

static GType
sudoku_main_menu_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SudokuMainMenuClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) sudoku_main_menu_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SudokuMainMenu), 0, (GInstanceInitFunc) sudoku_main_menu_instance_init, NULL };
	GType sudoku_main_menu_type_id;
	sudoku_main_menu_type_id = g_type_register_static (gtk_list_box_get_type (), "SudokuMainMenu", &g_define_type_info, 0);
	return sudoku_main_menu_type_id;
}

GType
sudoku_main_menu_get_type (void)
{
	static volatile gsize sudoku_main_menu_type_id__once = 0;
	if (g_once_init_enter (&sudoku_main_menu_type_id__once)) {
		GType sudoku_main_menu_type_id;
		sudoku_main_menu_type_id = sudoku_main_menu_get_type_once ();
		g_once_init_leave (&sudoku_main_menu_type_id__once, sudoku_main_menu_type_id);
	}
	return sudoku_main_menu_type_id__once;
}

static inline gpointer
sudoku_main_menu_item_get_instance_private (SudokuMainMenuItem* self)
{
	return G_STRUCT_MEMBER_P (self, SudokuMainMenuItem_private_offset);
}

SudokuMainMenuItem*
sudoku_main_menu_item_construct (GType object_type)
{
	SudokuMainMenuItem * self = NULL;
	self = (SudokuMainMenuItem*) g_object_new (object_type, NULL);
	return self;
}

SudokuMainMenuItem*
sudoku_main_menu_item_new (void)
{
	return sudoku_main_menu_item_construct (TYPE_SUDOKU_MAIN_MENU_ITEM);
}

const gchar*
sudoku_main_menu_item_get_label (SudokuMainMenuItem* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_label;
	result = _tmp0_;
	return result;
}

void
sudoku_main_menu_item_set_label (SudokuMainMenuItem* self,
                                 const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = sudoku_main_menu_item_get_label (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_label);
		self->priv->_label = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, sudoku_main_menu_item_properties[SUDOKU_MAIN_MENU_ITEM_LABEL_PROPERTY]);
	}
}

gboolean
sudoku_main_menu_item_get_has_separator (SudokuMainMenuItem* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_has_separator;
	return result;
}

void
sudoku_main_menu_item_set_has_separator (SudokuMainMenuItem* self,
                                         gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = sudoku_main_menu_item_get_has_separator (self);
	if (old_value != value) {
		self->priv->_has_separator = value;
		g_object_notify_by_pspec ((GObject *) self, sudoku_main_menu_item_properties[SUDOKU_MAIN_MENU_ITEM_HAS_SEPARATOR_PROPERTY]);
	}
}

static GObject *
sudoku_main_menu_item_constructor (GType type,
                                   guint n_construct_properties,
                                   GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	SudokuMainMenuItem * self;
	GtkLabel* label_widget = NULL;
	const gchar* _tmp0_;
	GtkLabel* _tmp1_;
	GtkLabel* _tmp2_;
	GtkLabel* _tmp3_;
	GtkLabel* _tmp4_;
	GtkLabel* _tmp5_;
	parent_class = G_OBJECT_CLASS (sudoku_main_menu_item_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_SUDOKU_MAIN_MENU_ITEM, SudokuMainMenuItem);
	gtk_widget_set_visible ((GtkWidget*) self, TRUE);
	gtk_widget_set_can_focus ((GtkWidget*) self, TRUE);
	_tmp0_ = self->priv->_label;
	_tmp1_ = (GtkLabel*) gtk_label_new (_tmp0_);
	g_object_ref_sink (_tmp1_);
	label_widget = _tmp1_;
	_tmp2_ = label_widget;
	gtk_widget_set_visible ((GtkWidget*) _tmp2_, TRUE);
	_tmp3_ = label_widget;
	gtk_widget_set_can_focus ((GtkWidget*) _tmp3_, FALSE);
	_tmp4_ = label_widget;
	gtk_label_set_use_underline (_tmp4_, TRUE);
	_tmp5_ = label_widget;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp5_);
	_g_object_unref0 (label_widget);
	return obj;
}

static void
sudoku_main_menu_item_class_init (SudokuMainMenuItemClass * klass,
                                  gpointer klass_data)
{
	sudoku_main_menu_item_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &SudokuMainMenuItem_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_sudoku_main_menu_item_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_sudoku_main_menu_item_set_property;
	G_OBJECT_CLASS (klass)->constructor = sudoku_main_menu_item_constructor;
	G_OBJECT_CLASS (klass)->finalize = sudoku_main_menu_item_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), SUDOKU_MAIN_MENU_ITEM_LABEL_PROPERTY, sudoku_main_menu_item_properties[SUDOKU_MAIN_MENU_ITEM_LABEL_PROPERTY] = g_param_spec_string ("label", "label", "label", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), SUDOKU_MAIN_MENU_ITEM_HAS_SEPARATOR_PROPERTY, sudoku_main_menu_item_properties[SUDOKU_MAIN_MENU_ITEM_HAS_SEPARATOR_PROPERTY] = g_param_spec_boolean ("has-separator", "has-separator", "has-separator", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
}

static void
sudoku_main_menu_item_instance_init (SudokuMainMenuItem * self,
                                     gpointer klass)
{
	self->priv = sudoku_main_menu_item_get_instance_private (self);
}

static void
sudoku_main_menu_item_finalize (GObject * obj)
{
	SudokuMainMenuItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_SUDOKU_MAIN_MENU_ITEM, SudokuMainMenuItem);
	_g_free0 (self->priv->_label);
	G_OBJECT_CLASS (sudoku_main_menu_item_parent_class)->finalize (obj);
}

static GType
sudoku_main_menu_item_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SudokuMainMenuItemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) sudoku_main_menu_item_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SudokuMainMenuItem), 0, (GInstanceInitFunc) sudoku_main_menu_item_instance_init, NULL };
	GType sudoku_main_menu_item_type_id;
	sudoku_main_menu_item_type_id = g_type_register_static (gtk_list_box_row_get_type (), "SudokuMainMenuItem", &g_define_type_info, 0);
	SudokuMainMenuItem_private_offset = g_type_add_instance_private (sudoku_main_menu_item_type_id, sizeof (SudokuMainMenuItemPrivate));
	return sudoku_main_menu_item_type_id;
}

GType
sudoku_main_menu_item_get_type (void)
{
	static volatile gsize sudoku_main_menu_item_type_id__once = 0;
	if (g_once_init_enter (&sudoku_main_menu_item_type_id__once)) {
		GType sudoku_main_menu_item_type_id;
		sudoku_main_menu_item_type_id = sudoku_main_menu_item_get_type_once ();
		g_once_init_leave (&sudoku_main_menu_item_type_id__once, sudoku_main_menu_item_type_id);
	}
	return sudoku_main_menu_item_type_id__once;
}

static void
_vala_sudoku_main_menu_item_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec)
{
	SudokuMainMenuItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_SUDOKU_MAIN_MENU_ITEM, SudokuMainMenuItem);
	switch (property_id) {
		case SUDOKU_MAIN_MENU_ITEM_LABEL_PROPERTY:
		g_value_set_string (value, sudoku_main_menu_item_get_label (self));
		break;
		case SUDOKU_MAIN_MENU_ITEM_HAS_SEPARATOR_PROPERTY:
		g_value_set_boolean (value, sudoku_main_menu_item_get_has_separator (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_sudoku_main_menu_item_set_property (GObject * object,
                                          guint property_id,
                                          const GValue * value,
                                          GParamSpec * pspec)
{
	SudokuMainMenuItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_SUDOKU_MAIN_MENU_ITEM, SudokuMainMenuItem);
	switch (property_id) {
		case SUDOKU_MAIN_MENU_ITEM_LABEL_PROPERTY:
		sudoku_main_menu_item_set_label (self, g_value_get_string (value));
		break;
		case SUDOKU_MAIN_MENU_ITEM_HAS_SEPARATOR_PROPERTY:
		sudoku_main_menu_item_set_has_separator (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

