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

/*
 * Copyright (c) 2015-2021 elementary LLC (https://elementary.io)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Library General Public License as published by
 * the Free Software Foundation, either version 2.1 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 Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "network.h"
#include <NetworkManager.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
#include <glib-object.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  {
	NETWORK_WIDGET_NM_INTERFACE_0_PROPERTY,
	NETWORK_WIDGET_NM_INTERFACE_DEVICE_PROPERTY,
	NETWORK_WIDGET_NM_INTERFACE_STATE_PROPERTY,
	NETWORK_WIDGET_NM_INTERFACE_DISPLAY_TITLE_PROPERTY,
	NETWORK_WIDGET_NM_INTERFACE_SEP_PROPERTY,
	NETWORK_WIDGET_NM_INTERFACE_NUM_PROPERTIES
};
static GParamSpec* network_widget_nm_interface_properties[NETWORK_WIDGET_NM_INTERFACE_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _NetworkWidgetNMInterfacePrivate {
	NMDevice* _device;
	NetworkState _state;
	gchar* _display_title;
	GtkSeparator* _sep;
};

static gint NetworkWidgetNMInterface_private_offset;
static gpointer network_widget_nm_interface_parent_class = NULL;

static GObject * network_widget_nm_interface_constructor (GType type,
                                                   guint n_construct_properties,
                                                   GObjectConstructParam * construct_properties);
static void network_widget_nm_interface_finalize (GObject * obj);
static GType network_widget_nm_interface_get_type_once (void);
static void _vala_network_widget_nm_interface_get_property (GObject * object,
                                                     guint property_id,
                                                     GValue * value,
                                                     GParamSpec * pspec);
static void _vala_network_widget_nm_interface_set_property (GObject * object,
                                                     guint property_id,
                                                     const GValue * value,
                                                     GParamSpec * pspec);

static inline gpointer
network_widget_nm_interface_get_instance_private (NetworkWidgetNMInterface* self)
{
	return G_STRUCT_MEMBER_P (self, NetworkWidgetNMInterface_private_offset);
}

NetworkWidgetNMInterface*
network_widget_nm_interface_construct (GType object_type)
{
	NetworkWidgetNMInterface * self = NULL;
	self = (NetworkWidgetNMInterface*) g_object_new (object_type, NULL);
	return self;
}

NMDevice*
network_widget_nm_interface_get_device (NetworkWidgetNMInterface* self)
{
	NMDevice* result;
	NMDevice* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_device;
	result = _tmp0_;
	return result;
}

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

void
network_widget_nm_interface_set_device (NetworkWidgetNMInterface* self,
                                        NMDevice* value)
{
	NMDevice* old_value;
	g_return_if_fail (self != NULL);
	old_value = network_widget_nm_interface_get_device (self);
	if (old_value != value) {
		NMDevice* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_device);
		self->priv->_device = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, network_widget_nm_interface_properties[NETWORK_WIDGET_NM_INTERFACE_DEVICE_PROPERTY]);
	}
}

NetworkState
network_widget_nm_interface_get_state (NetworkWidgetNMInterface* self)
{
	NetworkState result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_state;
	return result;
}

void
network_widget_nm_interface_set_state (NetworkWidgetNMInterface* self,
                                       NetworkState value)
{
	NetworkState old_value;
	g_return_if_fail (self != NULL);
	old_value = network_widget_nm_interface_get_state (self);
	if (old_value != value) {
		self->priv->_state = value;
		g_object_notify_by_pspec ((GObject *) self, network_widget_nm_interface_properties[NETWORK_WIDGET_NM_INTERFACE_STATE_PROPERTY]);
	}
}

const gchar*
network_widget_nm_interface_get_display_title (NetworkWidgetNMInterface* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_display_title;
	result = _tmp0_;
	return result;
}

void
network_widget_nm_interface_set_display_title (NetworkWidgetNMInterface* self,
                                               const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = network_widget_nm_interface_get_display_title (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_display_title);
		self->priv->_display_title = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, network_widget_nm_interface_properties[NETWORK_WIDGET_NM_INTERFACE_DISPLAY_TITLE_PROPERTY]);
	}
}

GtkSeparator*
network_widget_nm_interface_get_sep (NetworkWidgetNMInterface* self)
{
	GtkSeparator* result;
	GtkSeparator* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_sep;
	result = _tmp0_;
	return result;
}

static void
network_widget_nm_interface_set_sep (NetworkWidgetNMInterface* self,
                                     GtkSeparator* value)
{
	GtkSeparator* old_value;
	g_return_if_fail (self != NULL);
	old_value = network_widget_nm_interface_get_sep (self);
	if (old_value != value) {
		GtkSeparator* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_sep);
		self->priv->_sep = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, network_widget_nm_interface_properties[NETWORK_WIDGET_NM_INTERFACE_SEP_PROPERTY]);
	}
}

static GObject *
network_widget_nm_interface_constructor (GType type,
                                         guint n_construct_properties,
                                         GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	NetworkWidgetNMInterface * self;
	GtkSeparator* _tmp0_ = NULL;
	GtkSeparator* _tmp1_;
	parent_class = G_OBJECT_CLASS (network_widget_nm_interface_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, NETWORK_TYPE_WIDGET_NM_INTERFACE, NetworkWidgetNMInterface);
	_tmp0_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp0_, 3);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp0_, 3);
	g_object_ref_sink (_tmp0_);
	_tmp1_ = _tmp0_;
	network_widget_nm_interface_set_sep (self, _tmp1_);
	_g_object_unref0 (_tmp1_);
	return obj;
}

static void
network_widget_nm_interface_class_init (NetworkWidgetNMInterfaceClass * klass,
                                        gpointer klass_data)
{
	network_widget_nm_interface_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &NetworkWidgetNMInterface_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_network_widget_nm_interface_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_network_widget_nm_interface_set_property;
	G_OBJECT_CLASS (klass)->constructor = network_widget_nm_interface_constructor;
	G_OBJECT_CLASS (klass)->finalize = network_widget_nm_interface_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), NETWORK_WIDGET_NM_INTERFACE_DEVICE_PROPERTY, network_widget_nm_interface_properties[NETWORK_WIDGET_NM_INTERFACE_DEVICE_PROPERTY] = g_param_spec_object ("device", "device", "device", nm_device_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), NETWORK_WIDGET_NM_INTERFACE_STATE_PROPERTY, network_widget_nm_interface_properties[NETWORK_WIDGET_NM_INTERFACE_STATE_PROPERTY] = g_param_spec_enum ("state", "state", "state", NETWORK_TYPE_STATE, NETWORK_STATE_DISCONNECTED, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), NETWORK_WIDGET_NM_INTERFACE_DISPLAY_TITLE_PROPERTY, network_widget_nm_interface_properties[NETWORK_WIDGET_NM_INTERFACE_DISPLAY_TITLE_PROPERTY] = g_param_spec_string ("display-title", "display-title", "display-title", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), NETWORK_WIDGET_NM_INTERFACE_SEP_PROPERTY, network_widget_nm_interface_properties[NETWORK_WIDGET_NM_INTERFACE_SEP_PROPERTY] = g_param_spec_object ("sep", "sep", "sep", gtk_separator_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
network_widget_nm_interface_instance_init (NetworkWidgetNMInterface * self,
                                           gpointer klass)
{
	gchar* _tmp0_;
	self->priv = network_widget_nm_interface_get_instance_private (self);
	self->priv->_state = NETWORK_STATE_DISCONNECTED;
	_tmp0_ = g_strdup (_ ("Unknown device"));
	self->priv->_display_title = _tmp0_;
}

static void
network_widget_nm_interface_finalize (GObject * obj)
{
	NetworkWidgetNMInterface * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, NETWORK_TYPE_WIDGET_NM_INTERFACE, NetworkWidgetNMInterface);
	_g_object_unref0 (self->priv->_device);
	_g_free0 (self->priv->_display_title);
	_g_object_unref0 (self->priv->_sep);
	G_OBJECT_CLASS (network_widget_nm_interface_parent_class)->finalize (obj);
}

static GType
network_widget_nm_interface_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (NetworkWidgetNMInterfaceClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) network_widget_nm_interface_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (NetworkWidgetNMInterface), 0, (GInstanceInitFunc) network_widget_nm_interface_instance_init, NULL };
	GType network_widget_nm_interface_type_id;
	network_widget_nm_interface_type_id = g_type_register_static (gtk_box_get_type (), "NetworkWidgetNMInterface", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	NetworkWidgetNMInterface_private_offset = g_type_add_instance_private (network_widget_nm_interface_type_id, sizeof (NetworkWidgetNMInterfacePrivate));
	return network_widget_nm_interface_type_id;
}

GType
network_widget_nm_interface_get_type (void)
{
	static volatile gsize network_widget_nm_interface_type_id__once = 0;
	if (g_once_init_enter (&network_widget_nm_interface_type_id__once)) {
		GType network_widget_nm_interface_type_id;
		network_widget_nm_interface_type_id = network_widget_nm_interface_get_type_once ();
		g_once_init_leave (&network_widget_nm_interface_type_id__once, network_widget_nm_interface_type_id);
	}
	return network_widget_nm_interface_type_id__once;
}

static void
_vala_network_widget_nm_interface_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec)
{
	NetworkWidgetNMInterface * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, NETWORK_TYPE_WIDGET_NM_INTERFACE, NetworkWidgetNMInterface);
	switch (property_id) {
		case NETWORK_WIDGET_NM_INTERFACE_DEVICE_PROPERTY:
		g_value_set_object (value, network_widget_nm_interface_get_device (self));
		break;
		case NETWORK_WIDGET_NM_INTERFACE_STATE_PROPERTY:
		g_value_set_enum (value, network_widget_nm_interface_get_state (self));
		break;
		case NETWORK_WIDGET_NM_INTERFACE_DISPLAY_TITLE_PROPERTY:
		g_value_set_string (value, network_widget_nm_interface_get_display_title (self));
		break;
		case NETWORK_WIDGET_NM_INTERFACE_SEP_PROPERTY:
		g_value_set_object (value, network_widget_nm_interface_get_sep (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_network_widget_nm_interface_set_property (GObject * object,
                                                guint property_id,
                                                const GValue * value,
                                                GParamSpec * pspec)
{
	NetworkWidgetNMInterface * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, NETWORK_TYPE_WIDGET_NM_INTERFACE, NetworkWidgetNMInterface);
	switch (property_id) {
		case NETWORK_WIDGET_NM_INTERFACE_DEVICE_PROPERTY:
		network_widget_nm_interface_set_device (self, g_value_get_object (value));
		break;
		case NETWORK_WIDGET_NM_INTERFACE_STATE_PROPERTY:
		network_widget_nm_interface_set_state (self, g_value_get_enum (value));
		break;
		case NETWORK_WIDGET_NM_INTERFACE_DISPLAY_TITLE_PROPERTY:
		network_widget_nm_interface_set_display_title (self, g_value_get_string (value));
		break;
		case NETWORK_WIDGET_NM_INTERFACE_SEP_PROPERTY:
		network_widget_nm_interface_set_sep (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

