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

/*
* Copyright (c) 2017 elementary, LLC. (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 2 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, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/

#include "keyboard.h"
#include <stdlib.h>
#include <string.h>
#include <glib.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  {
	ADVANCED_SETTINGS_PANEL_0_PROPERTY,
	ADVANCED_SETTINGS_PANEL_PANEL_NAME_PROPERTY,
	ADVANCED_SETTINGS_PANEL_INPUT_SOURCES_PROPERTY,
	ADVANCED_SETTINGS_PANEL_EXCLUSIONS_PROPERTY,
	ADVANCED_SETTINGS_PANEL_NUM_PROPERTIES
};
static GParamSpec* advanced_settings_panel_properties[ADVANCED_SETTINGS_PANEL_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

struct _AdvancedSettingsPanelPrivate {
	gchar* _panel_name;
	gchar** _input_sources;
	gint _input_sources_length1;
	gint __input_sources_size_;
	gchar** _exclusions;
	gint _exclusions_length1;
	gint __exclusions_size_;
};

static gint AdvancedSettingsPanel_private_offset;
static gpointer advanced_settings_panel_parent_class = NULL;

static gchar** _vala_array_dup3 (gchar** self,
                          gssize length);
static gchar** _vala_array_dup4 (gchar** self,
                          gssize length);
static GObject * advanced_settings_panel_constructor (GType type,
                                               guint n_construct_properties,
                                               GObjectConstructParam * construct_properties);
static void advanced_settings_panel_finalize (GObject * obj);
static GType advanced_settings_panel_get_type_once (void);
static void _vala_advanced_settings_panel_get_property (GObject * object,
                                                 guint property_id,
                                                 GValue * value,
                                                 GParamSpec * pspec);
static void _vala_advanced_settings_panel_set_property (GObject * object,
                                                 guint property_id,
                                                 const GValue * value,
                                                 GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static inline gpointer
advanced_settings_panel_get_instance_private (AdvancedSettingsPanel* self)
{
	return G_STRUCT_MEMBER_P (self, AdvancedSettingsPanel_private_offset);
}

AdvancedSettingsPanel*
advanced_settings_panel_construct (GType object_type,
                                   const gchar* name,
                                   gchar** input_sources,
                                   gint input_sources_length1,
                                   gchar** exclusions,
                                   gint exclusions_length1)
{
	AdvancedSettingsPanel * self = NULL;
	g_return_val_if_fail (name != NULL, NULL);
	self = (AdvancedSettingsPanel*) g_object_new (object_type, "panel-name", name, "input-sources", input_sources, "exclusions", exclusions, NULL);
	return self;
}

AdvancedSettingsPanel*
advanced_settings_panel_new (const gchar* name,
                             gchar** input_sources,
                             gint input_sources_length1,
                             gchar** exclusions,
                             gint exclusions_length1)
{
	return advanced_settings_panel_construct (TYPE_ADVANCED_SETTINGS_PANEL, name, input_sources, input_sources_length1, exclusions, exclusions_length1);
}

const gchar*
advanced_settings_panel_get_panel_name (AdvancedSettingsPanel* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_panel_name;
	result = _tmp0_;
	return result;
}

static void
advanced_settings_panel_set_panel_name (AdvancedSettingsPanel* self,
                                        const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = advanced_settings_panel_get_panel_name (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_panel_name);
		self->priv->_panel_name = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, advanced_settings_panel_properties[ADVANCED_SETTINGS_PANEL_PANEL_NAME_PROPERTY]);
	}
}

gchar**
advanced_settings_panel_get_input_sources (AdvancedSettingsPanel* self,
                                           gint* result_length1)
{
	gchar** result;
	gchar** _tmp0_;
	gint _tmp0__length1;
	gchar** _tmp1_;
	gint _tmp1__length1;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_input_sources;
	_tmp0__length1 = self->priv->_input_sources_length1;
	_tmp1_ = _tmp0_;
	_tmp1__length1 = _tmp0__length1;
	if (result_length1) {
		*result_length1 = _tmp1__length1;
	}
	result = _tmp1_;
	return result;
}

static gchar**
_vala_array_dup3 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

static void
advanced_settings_panel_set_input_sources (AdvancedSettingsPanel* self,
                                           gchar** value,
                                           gint value_length1)
{
	gchar** old_value;
	gint old_value_length;
	g_return_if_fail (self != NULL);
	old_value = advanced_settings_panel_get_input_sources (self, &old_value_length);
	if (old_value != value) {
		gchar** _tmp0_;
		gint _tmp0__length1;
		_tmp0_ = (value != NULL) ? _vala_array_dup3 (value, value_length1) : value;
		_tmp0__length1 = value_length1;
		self->priv->_input_sources = (_vala_array_free (self->priv->_input_sources, self->priv->_input_sources_length1, (GDestroyNotify) g_free), NULL);
		self->priv->_input_sources = _tmp0_;
		self->priv->_input_sources_length1 = _tmp0__length1;
		self->priv->__input_sources_size_ = self->priv->_input_sources_length1;
		g_object_notify_by_pspec ((GObject *) self, advanced_settings_panel_properties[ADVANCED_SETTINGS_PANEL_INPUT_SOURCES_PROPERTY]);
	}
}

gchar**
advanced_settings_panel_get_exclusions (AdvancedSettingsPanel* self,
                                        gint* result_length1)
{
	gchar** result;
	gchar** _tmp0_;
	gint _tmp0__length1;
	gchar** _tmp1_;
	gint _tmp1__length1;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_exclusions;
	_tmp0__length1 = self->priv->_exclusions_length1;
	_tmp1_ = _tmp0_;
	_tmp1__length1 = _tmp0__length1;
	if (result_length1) {
		*result_length1 = _tmp1__length1;
	}
	result = _tmp1_;
	return result;
}

static gchar**
_vala_array_dup4 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

static void
advanced_settings_panel_set_exclusions (AdvancedSettingsPanel* self,
                                        gchar** value,
                                        gint value_length1)
{
	gchar** old_value;
	gint old_value_length;
	g_return_if_fail (self != NULL);
	old_value = advanced_settings_panel_get_exclusions (self, &old_value_length);
	if (old_value != value) {
		gchar** _tmp0_;
		gint _tmp0__length1;
		_tmp0_ = (value != NULL) ? _vala_array_dup4 (value, value_length1) : value;
		_tmp0__length1 = value_length1;
		self->priv->_exclusions = (_vala_array_free (self->priv->_exclusions, self->priv->_exclusions_length1, (GDestroyNotify) g_free), NULL);
		self->priv->_exclusions = _tmp0_;
		self->priv->_exclusions_length1 = _tmp0__length1;
		self->priv->__exclusions_size_ = self->priv->_exclusions_length1;
		g_object_notify_by_pspec ((GObject *) self, advanced_settings_panel_properties[ADVANCED_SETTINGS_PANEL_EXCLUSIONS_PROPERTY]);
	}
}

static GObject *
advanced_settings_panel_constructor (GType type,
                                     guint n_construct_properties,
                                     GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	AdvancedSettingsPanel * self;
	parent_class = G_OBJECT_CLASS (advanced_settings_panel_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_ADVANCED_SETTINGS_PANEL, AdvancedSettingsPanel);
	gtk_grid_set_row_spacing ((GtkGrid*) self, 6);
	gtk_grid_set_column_spacing ((GtkGrid*) self, 12);
	return obj;
}

static void
advanced_settings_panel_class_init (AdvancedSettingsPanelClass * klass,
                                    gpointer klass_data)
{
	advanced_settings_panel_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &AdvancedSettingsPanel_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_advanced_settings_panel_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_advanced_settings_panel_set_property;
	G_OBJECT_CLASS (klass)->constructor = advanced_settings_panel_constructor;
	G_OBJECT_CLASS (klass)->finalize = advanced_settings_panel_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), ADVANCED_SETTINGS_PANEL_PANEL_NAME_PROPERTY, advanced_settings_panel_properties[ADVANCED_SETTINGS_PANEL_PANEL_NAME_PROPERTY] = g_param_spec_string ("panel-name", "panel-name", "panel-name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), ADVANCED_SETTINGS_PANEL_INPUT_SOURCES_PROPERTY, advanced_settings_panel_properties[ADVANCED_SETTINGS_PANEL_INPUT_SOURCES_PROPERTY] = g_param_spec_boxed ("input-sources", "input-sources", "input-sources", G_TYPE_STRV, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), ADVANCED_SETTINGS_PANEL_EXCLUSIONS_PROPERTY, advanced_settings_panel_properties[ADVANCED_SETTINGS_PANEL_EXCLUSIONS_PROPERTY] = g_param_spec_boxed ("exclusions", "exclusions", "exclusions", G_TYPE_STRV, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
advanced_settings_panel_instance_init (AdvancedSettingsPanel * self,
                                       gpointer klass)
{
	self->priv = advanced_settings_panel_get_instance_private (self);
}

static void
advanced_settings_panel_finalize (GObject * obj)
{
	AdvancedSettingsPanel * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_ADVANCED_SETTINGS_PANEL, AdvancedSettingsPanel);
	_g_free0 (self->priv->_panel_name);
	self->priv->_input_sources = (_vala_array_free (self->priv->_input_sources, self->priv->_input_sources_length1, (GDestroyNotify) g_free), NULL);
	self->priv->_exclusions = (_vala_array_free (self->priv->_exclusions, self->priv->_exclusions_length1, (GDestroyNotify) g_free), NULL);
	G_OBJECT_CLASS (advanced_settings_panel_parent_class)->finalize (obj);
}

static GType
advanced_settings_panel_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (AdvancedSettingsPanelClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) advanced_settings_panel_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (AdvancedSettingsPanel), 0, (GInstanceInitFunc) advanced_settings_panel_instance_init, NULL };
	GType advanced_settings_panel_type_id;
	advanced_settings_panel_type_id = g_type_register_static (gtk_grid_get_type (), "AdvancedSettingsPanel", &g_define_type_info, 0);
	AdvancedSettingsPanel_private_offset = g_type_add_instance_private (advanced_settings_panel_type_id, sizeof (AdvancedSettingsPanelPrivate));
	return advanced_settings_panel_type_id;
}

GType
advanced_settings_panel_get_type (void)
{
	static volatile gsize advanced_settings_panel_type_id__once = 0;
	if (g_once_init_enter (&advanced_settings_panel_type_id__once)) {
		GType advanced_settings_panel_type_id;
		advanced_settings_panel_type_id = advanced_settings_panel_get_type_once ();
		g_once_init_leave (&advanced_settings_panel_type_id__once, advanced_settings_panel_type_id);
	}
	return advanced_settings_panel_type_id__once;
}

static void
_vala_advanced_settings_panel_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec)
{
	AdvancedSettingsPanel * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_ADVANCED_SETTINGS_PANEL, AdvancedSettingsPanel);
	switch (property_id) {
		case ADVANCED_SETTINGS_PANEL_PANEL_NAME_PROPERTY:
		g_value_set_string (value, advanced_settings_panel_get_panel_name (self));
		break;
		case ADVANCED_SETTINGS_PANEL_INPUT_SOURCES_PROPERTY:
		{
			int length;
			g_value_set_boxed (value, advanced_settings_panel_get_input_sources (self, &length));
		}
		break;
		case ADVANCED_SETTINGS_PANEL_EXCLUSIONS_PROPERTY:
		{
			int length;
			g_value_set_boxed (value, advanced_settings_panel_get_exclusions (self, &length));
		}
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_advanced_settings_panel_set_property (GObject * object,
                                            guint property_id,
                                            const GValue * value,
                                            GParamSpec * pspec)
{
	AdvancedSettingsPanel * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_ADVANCED_SETTINGS_PANEL, AdvancedSettingsPanel);
	switch (property_id) {
		case ADVANCED_SETTINGS_PANEL_PANEL_NAME_PROPERTY:
		advanced_settings_panel_set_panel_name (self, g_value_get_string (value));
		break;
		case ADVANCED_SETTINGS_PANEL_INPUT_SOURCES_PROPERTY:
		{
			gpointer boxed;
			boxed = g_value_get_boxed (value);
			advanced_settings_panel_set_input_sources (self, boxed, (boxed == NULL) ? 0 : g_strv_length (boxed));
		}
		break;
		case ADVANCED_SETTINGS_PANEL_EXCLUSIONS_PROPERTY:
		{
			gpointer boxed;
			boxed = g_value_get_boxed (value);
			advanced_settings_panel_set_exclusions (self, boxed, (boxed == NULL) ? 0 : g_strv_length (boxed));
		}
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize 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,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

