/* EnginesRow.c generated by valac 0.56.19, the Vala compiler
 * generated from EnginesRow.vala, do not modify */

/*
* 2019-2020 elementary, Inc. (https://elementary.io)
*
* 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 <https://www.gnu.org/licenses/>.
*/

#include "keyboard.h"
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib-object.h>
#include <gtk/gtk.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

enum  {
	KEYBOARD_INPUT_METHOD_PAGE_ENGINES_ROW_0_PROPERTY,
	KEYBOARD_INPUT_METHOD_PAGE_ENGINES_ROW_SELECTED_PROPERTY,
	KEYBOARD_INPUT_METHOD_PAGE_ENGINES_ROW_ENGINE_NAME_PROPERTY,
	KEYBOARD_INPUT_METHOD_PAGE_ENGINES_ROW_NUM_PROPERTIES
};
static GParamSpec* keyboard_input_method_page_engines_row_properties[KEYBOARD_INPUT_METHOD_PAGE_ENGINES_ROW_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block6Data Block6Data;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _KeyboardInputMethodPageEnginesRowPrivate {
	gboolean _selected;
	gchar* _engine_name;
};

struct _Block6Data {
	int _ref_count_;
	KeyboardInputMethodPageEnginesRow* self;
	GtkImage* selection_icon;
};

static gint KeyboardInputMethodPageEnginesRow_private_offset;
static gpointer keyboard_input_method_page_engines_row_parent_class = NULL;

static GObject * keyboard_input_method_page_engines_row_constructor (GType type,
                                                              guint n_construct_properties,
                                                              GObjectConstructParam * construct_properties);
static Block6Data* block6_data_ref (Block6Data* _data6_);
static void block6_data_unref (void * _userdata_);
static void _keyboard_input_method_page_engines_row___lambda15_ (Block6Data* _data6_);
static void __keyboard_input_method_page_engines_row___lambda15__g_object_notify (GObject* _sender,
                                                                           GParamSpec* pspec,
                                                                           gpointer self);
static void keyboard_input_method_page_engines_row_finalize (GObject * obj);
static GType keyboard_input_method_page_engines_row_get_type_once (void);
static void _vala_keyboard_input_method_page_engines_row_get_property (GObject * object,
                                                                guint property_id,
                                                                GValue * value,
                                                                GParamSpec * pspec);
static void _vala_keyboard_input_method_page_engines_row_set_property (GObject * object,
                                                                guint property_id,
                                                                const GValue * value,
                                                                GParamSpec * pspec);

static inline gpointer
keyboard_input_method_page_engines_row_get_instance_private (KeyboardInputMethodPageEnginesRow* self)
{
	return G_STRUCT_MEMBER_P (self, KeyboardInputMethodPageEnginesRow_private_offset);
}

KeyboardInputMethodPageEnginesRow*
keyboard_input_method_page_engines_row_construct (GType object_type,
                                                  const gchar* engine_name)
{
	KeyboardInputMethodPageEnginesRow * self = NULL;
	g_return_val_if_fail (engine_name != NULL, NULL);
	self = (KeyboardInputMethodPageEnginesRow*) g_object_new (object_type, "engine-name", engine_name, NULL);
	return self;
}

KeyboardInputMethodPageEnginesRow*
keyboard_input_method_page_engines_row_new (const gchar* engine_name)
{
	return keyboard_input_method_page_engines_row_construct (KEYBOARD_INPUT_METHOD_PAGE_TYPE_ENGINES_ROW, engine_name);
}

gboolean
keyboard_input_method_page_engines_row_get_selected (KeyboardInputMethodPageEnginesRow* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_selected;
	return result;
}

void
keyboard_input_method_page_engines_row_set_selected (KeyboardInputMethodPageEnginesRow* self,
                                                     gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = keyboard_input_method_page_engines_row_get_selected (self);
	if (old_value != value) {
		self->priv->_selected = value;
		g_object_notify_by_pspec ((GObject *) self, keyboard_input_method_page_engines_row_properties[KEYBOARD_INPUT_METHOD_PAGE_ENGINES_ROW_SELECTED_PROPERTY]);
	}
}

const gchar*
keyboard_input_method_page_engines_row_get_engine_name (KeyboardInputMethodPageEnginesRow* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_engine_name;
	result = _tmp0_;
	return result;
}

static void
keyboard_input_method_page_engines_row_set_engine_name (KeyboardInputMethodPageEnginesRow* self,
                                                        const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = keyboard_input_method_page_engines_row_get_engine_name (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_engine_name);
		self->priv->_engine_name = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, keyboard_input_method_page_engines_row_properties[KEYBOARD_INPUT_METHOD_PAGE_ENGINES_ROW_ENGINE_NAME_PROPERTY]);
	}
}

static Block6Data*
block6_data_ref (Block6Data* _data6_)
{
	g_atomic_int_inc (&_data6_->_ref_count_);
	return _data6_;
}

static void
block6_data_unref (void * _userdata_)
{
	Block6Data* _data6_;
	_data6_ = (Block6Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data6_->_ref_count_)) {
		KeyboardInputMethodPageEnginesRow* self;
		self = _data6_->self;
		_g_object_unref0 (_data6_->selection_icon);
		_g_object_unref0 (self);
		g_slice_free (Block6Data, _data6_);
	}
}

static void
_keyboard_input_method_page_engines_row___lambda15_ (Block6Data* _data6_)
{
	KeyboardInputMethodPageEnginesRow* self;
	GtkImage* _tmp0_;
	gboolean _tmp1_;
	self = _data6_->self;
	_tmp0_ = _data6_->selection_icon;
	_tmp1_ = self->priv->_selected;
	gtk_widget_set_visible ((GtkWidget*) _tmp0_, _tmp1_);
}

static void
__keyboard_input_method_page_engines_row___lambda15__g_object_notify (GObject* _sender,
                                                                      GParamSpec* pspec,
                                                                      gpointer self)
{
	_keyboard_input_method_page_engines_row___lambda15_ (self);
}

static GObject *
keyboard_input_method_page_engines_row_constructor (GType type,
                                                    guint n_construct_properties,
                                                    GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	KeyboardInputMethodPageEnginesRow * self;
	Block6Data* _data6_;
	GtkLabel* label = NULL;
	const gchar* _tmp0_;
	GtkLabel* _tmp1_ = NULL;
	GtkImage* _tmp2_ = NULL;
	GtkBox* box = NULL;
	GtkBox* _tmp3_ = NULL;
	GtkBox* _tmp4_;
	GtkLabel* _tmp5_;
	GtkBox* _tmp6_;
	GtkImage* _tmp7_;
	GtkBox* _tmp8_;
	parent_class = G_OBJECT_CLASS (keyboard_input_method_page_engines_row_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, KEYBOARD_INPUT_METHOD_PAGE_TYPE_ENGINES_ROW, KeyboardInputMethodPageEnginesRow);
	_data6_ = g_slice_new0 (Block6Data);
	_data6_->_ref_count_ = 1;
	_data6_->self = g_object_ref (self);
	_tmp0_ = self->priv->_engine_name;
	_tmp1_ = (GtkLabel*) gtk_label_new (_tmp0_);
	gtk_widget_set_halign ((GtkWidget*) _tmp1_, GTK_ALIGN_START);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp1_, TRUE);
	g_object_ref_sink (_tmp1_);
	label = _tmp1_;
	_tmp2_ = (GtkImage*) gtk_image_new_from_icon_name ("object-select-symbolic");
	gtk_widget_set_visible ((GtkWidget*) _tmp2_, FALSE);
	g_object_ref_sink (_tmp2_);
	_data6_->selection_icon = _tmp2_;
	_tmp3_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp3_, 3);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp3_, 6);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp3_, 3);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp3_, 6);
	g_object_ref_sink (_tmp3_);
	box = _tmp3_;
	_tmp4_ = box;
	_tmp5_ = label;
	gtk_box_append (_tmp4_, (GtkWidget*) _tmp5_);
	_tmp6_ = box;
	_tmp7_ = _data6_->selection_icon;
	gtk_box_append (_tmp6_, (GtkWidget*) _tmp7_);
	_tmp8_ = box;
	gtk_list_box_row_set_child ((GtkListBoxRow*) self, (GtkWidget*) _tmp8_);
	g_signal_connect_data ((GObject*) self, "notify::selected", (GCallback) __keyboard_input_method_page_engines_row___lambda15__g_object_notify, block6_data_ref (_data6_), (GClosureNotify) block6_data_unref, 0);
	_g_object_unref0 (box);
	_g_object_unref0 (label);
	block6_data_unref (_data6_);
	_data6_ = NULL;
	return obj;
}

static void
keyboard_input_method_page_engines_row_class_init (KeyboardInputMethodPageEnginesRowClass * klass,
                                                   gpointer klass_data)
{
	keyboard_input_method_page_engines_row_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &KeyboardInputMethodPageEnginesRow_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_keyboard_input_method_page_engines_row_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_keyboard_input_method_page_engines_row_set_property;
	G_OBJECT_CLASS (klass)->constructor = keyboard_input_method_page_engines_row_constructor;
	G_OBJECT_CLASS (klass)->finalize = keyboard_input_method_page_engines_row_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), KEYBOARD_INPUT_METHOD_PAGE_ENGINES_ROW_SELECTED_PROPERTY, keyboard_input_method_page_engines_row_properties[KEYBOARD_INPUT_METHOD_PAGE_ENGINES_ROW_SELECTED_PROPERTY] = g_param_spec_boolean ("selected", "selected", "selected", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), KEYBOARD_INPUT_METHOD_PAGE_ENGINES_ROW_ENGINE_NAME_PROPERTY, keyboard_input_method_page_engines_row_properties[KEYBOARD_INPUT_METHOD_PAGE_ENGINES_ROW_ENGINE_NAME_PROPERTY] = g_param_spec_string ("engine-name", "engine-name", "engine-name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
keyboard_input_method_page_engines_row_instance_init (KeyboardInputMethodPageEnginesRow * self,
                                                      gpointer klass)
{
	self->priv = keyboard_input_method_page_engines_row_get_instance_private (self);
}

static void
keyboard_input_method_page_engines_row_finalize (GObject * obj)
{
	KeyboardInputMethodPageEnginesRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, KEYBOARD_INPUT_METHOD_PAGE_TYPE_ENGINES_ROW, KeyboardInputMethodPageEnginesRow);
	_g_free0 (self->priv->_engine_name);
	G_OBJECT_CLASS (keyboard_input_method_page_engines_row_parent_class)->finalize (obj);
}

static GType
keyboard_input_method_page_engines_row_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (KeyboardInputMethodPageEnginesRowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) keyboard_input_method_page_engines_row_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (KeyboardInputMethodPageEnginesRow), 0, (GInstanceInitFunc) keyboard_input_method_page_engines_row_instance_init, NULL };
	GType keyboard_input_method_page_engines_row_type_id;
	keyboard_input_method_page_engines_row_type_id = g_type_register_static (gtk_list_box_row_get_type (), "KeyboardInputMethodPageEnginesRow", &g_define_type_info, 0);
	KeyboardInputMethodPageEnginesRow_private_offset = g_type_add_instance_private (keyboard_input_method_page_engines_row_type_id, sizeof (KeyboardInputMethodPageEnginesRowPrivate));
	return keyboard_input_method_page_engines_row_type_id;
}

GType
keyboard_input_method_page_engines_row_get_type (void)
{
	static volatile gsize keyboard_input_method_page_engines_row_type_id__once = 0;
	if (g_once_init_enter (&keyboard_input_method_page_engines_row_type_id__once)) {
		GType keyboard_input_method_page_engines_row_type_id;
		keyboard_input_method_page_engines_row_type_id = keyboard_input_method_page_engines_row_get_type_once ();
		g_once_init_leave (&keyboard_input_method_page_engines_row_type_id__once, keyboard_input_method_page_engines_row_type_id);
	}
	return keyboard_input_method_page_engines_row_type_id__once;
}

static void
_vala_keyboard_input_method_page_engines_row_get_property (GObject * object,
                                                           guint property_id,
                                                           GValue * value,
                                                           GParamSpec * pspec)
{
	KeyboardInputMethodPageEnginesRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, KEYBOARD_INPUT_METHOD_PAGE_TYPE_ENGINES_ROW, KeyboardInputMethodPageEnginesRow);
	switch (property_id) {
		case KEYBOARD_INPUT_METHOD_PAGE_ENGINES_ROW_SELECTED_PROPERTY:
		g_value_set_boolean (value, keyboard_input_method_page_engines_row_get_selected (self));
		break;
		case KEYBOARD_INPUT_METHOD_PAGE_ENGINES_ROW_ENGINE_NAME_PROPERTY:
		g_value_set_string (value, keyboard_input_method_page_engines_row_get_engine_name (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_keyboard_input_method_page_engines_row_set_property (GObject * object,
                                                           guint property_id,
                                                           const GValue * value,
                                                           GParamSpec * pspec)
{
	KeyboardInputMethodPageEnginesRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, KEYBOARD_INPUT_METHOD_PAGE_TYPE_ENGINES_ROW, KeyboardInputMethodPageEnginesRow);
	switch (property_id) {
		case KEYBOARD_INPUT_METHOD_PAGE_ENGINES_ROW_SELECTED_PROPERTY:
		keyboard_input_method_page_engines_row_set_selected (self, g_value_get_boolean (value));
		break;
		case KEYBOARD_INPUT_METHOD_PAGE_ENGINES_ROW_ENGINE_NAME_PROPERTY:
		keyboard_input_method_page_engines_row_set_engine_name (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

