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

/* This file is part of GNOME Boxes. License: LGPLv2+*/

#include <handy.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <glib.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 BOXES_TYPE_DEVICE_LIST_ROW (boxes_device_list_row_get_type ())
#define BOXES_DEVICE_LIST_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_DEVICE_LIST_ROW, BoxesDeviceListRow))
#define BOXES_DEVICE_LIST_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_DEVICE_LIST_ROW, BoxesDeviceListRowClass))
#define BOXES_IS_DEVICE_LIST_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_DEVICE_LIST_ROW))
#define BOXES_IS_DEVICE_LIST_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_DEVICE_LIST_ROW))
#define BOXES_DEVICE_LIST_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_DEVICE_LIST_ROW, BoxesDeviceListRowClass))

typedef struct _BoxesDeviceListRow BoxesDeviceListRow;
typedef struct _BoxesDeviceListRowClass BoxesDeviceListRowClass;
typedef struct _BoxesDeviceListRowPrivate BoxesDeviceListRowPrivate;
enum  {
	BOXES_DEVICE_LIST_ROW_0_PROPERTY,
	BOXES_DEVICE_LIST_ROW_NUM_PROPERTIES
};
static GParamSpec* boxes_device_list_row_properties[BOXES_DEVICE_LIST_ROW_NUM_PROPERTIES];

#define BOXES_TYPE_USB_DEVICE (boxes_usb_device_get_type ())
#define BOXES_USB_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_USB_DEVICE, BoxesUsbDevice))
#define BOXES_USB_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_USB_DEVICE, BoxesUsbDeviceClass))
#define BOXES_IS_USB_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_USB_DEVICE))
#define BOXES_IS_USB_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_USB_DEVICE))
#define BOXES_USB_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_USB_DEVICE, BoxesUsbDeviceClass))

typedef struct _BoxesUsbDevice BoxesUsbDevice;
typedef struct _BoxesUsbDeviceClass BoxesUsbDeviceClass;
typedef struct _BoxesUsbDevicePrivate BoxesUsbDevicePrivate;
enum  {
	BOXES_USB_DEVICE_0_PROPERTY,
	BOXES_USB_DEVICE_ACTIVE_PROPERTY,
	BOXES_USB_DEVICE_NUM_PROPERTIES
};
static GParamSpec* boxes_usb_device_properties[BOXES_USB_DEVICE_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

struct _BoxesDeviceListRow {
	HdyActionRow parent_instance;
	BoxesDeviceListRowPrivate * priv;
};

struct _BoxesDeviceListRowClass {
	HdyActionRowClass parent_class;
};

struct _BoxesDeviceListRowPrivate {
	GtkSwitch* toggle;
};

struct _BoxesUsbDevice {
	GObject parent_instance;
	BoxesUsbDevicePrivate * priv;
	gchar* title;
};

struct _BoxesUsbDeviceClass {
	GObjectClass parent_class;
};

struct _BoxesUsbDevicePrivate {
	gboolean _active;
};

static gint BoxesDeviceListRow_private_offset;
static gpointer boxes_device_list_row_parent_class = NULL;
static gint BoxesUsbDevice_private_offset;
static gpointer boxes_usb_device_parent_class = NULL;

VALA_EXTERN GType boxes_device_list_row_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesDeviceListRow, g_object_unref)
VALA_EXTERN GType boxes_usb_device_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesUsbDevice, g_object_unref)
VALA_EXTERN BoxesDeviceListRow* boxes_device_list_row_new (BoxesUsbDevice* device);
VALA_EXTERN BoxesDeviceListRow* boxes_device_list_row_construct (GType object_type,
                                                     BoxesUsbDevice* device);
VALA_EXTERN gboolean boxes_usb_device_get_active (BoxesUsbDevice* self);
static void boxes_device_list_row_finalize (GObject * obj);
static GType boxes_device_list_row_get_type_once (void);
VALA_EXTERN BoxesUsbDevice* boxes_usb_device_new (void);
VALA_EXTERN BoxesUsbDevice* boxes_usb_device_construct (GType object_type);
VALA_EXTERN void boxes_usb_device_set_active (BoxesUsbDevice* self,
                                  gboolean value);
static void boxes_usb_device_finalize (GObject * obj);
static GType boxes_usb_device_get_type_once (void);
static void _vala_boxes_usb_device_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec);
static void _vala_boxes_usb_device_set_property (GObject * object,
                                          guint property_id,
                                          const GValue * value,
                                          GParamSpec * pspec);

static inline gpointer
boxes_device_list_row_get_instance_private (BoxesDeviceListRow* self)
{
	return G_STRUCT_MEMBER_P (self, BoxesDeviceListRow_private_offset);
}

BoxesDeviceListRow*
boxes_device_list_row_construct (GType object_type,
                                 BoxesUsbDevice* device)
{
	BoxesDeviceListRow * self = NULL;
	const gchar* _tmp0_;
	GtkSwitch* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	GtkSwitch* _tmp4_;
	g_return_val_if_fail (device != NULL, NULL);
	self = (BoxesDeviceListRow*) g_object_new (object_type, NULL);
	_tmp0_ = device->title;
	hdy_preferences_row_set_title ((HdyPreferencesRow*) self, _tmp0_);
	_tmp1_ = self->priv->toggle;
	_tmp2_ = boxes_usb_device_get_active (device);
	_tmp3_ = _tmp2_;
	gtk_switch_set_active (_tmp1_, _tmp3_);
	_tmp4_ = self->priv->toggle;
	g_object_bind_property_with_closures ((GObject*) device, "active", (GObject*) _tmp4_, "active", G_BINDING_BIDIRECTIONAL, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	return self;
}

BoxesDeviceListRow*
boxes_device_list_row_new (BoxesUsbDevice* device)
{
	return boxes_device_list_row_construct (BOXES_TYPE_DEVICE_LIST_ROW, device);
}

static void
boxes_device_list_row_class_init (BoxesDeviceListRowClass * klass,
                                  gpointer klass_data)
{
	boxes_device_list_row_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BoxesDeviceListRow_private_offset);
	G_OBJECT_CLASS (klass)->finalize = boxes_device_list_row_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Boxes/ui/preferences/device-list-row.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "toggle", FALSE, BoxesDeviceListRow_private_offset + G_STRUCT_OFFSET (BoxesDeviceListRowPrivate, toggle));
}

static void
boxes_device_list_row_instance_init (BoxesDeviceListRow * self,
                                     gpointer klass)
{
	self->priv = boxes_device_list_row_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
boxes_device_list_row_finalize (GObject * obj)
{
	BoxesDeviceListRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BOXES_TYPE_DEVICE_LIST_ROW, BoxesDeviceListRow);
	G_OBJECT_CLASS (boxes_device_list_row_parent_class)->finalize (obj);
}

static GType
boxes_device_list_row_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BoxesDeviceListRowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) boxes_device_list_row_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BoxesDeviceListRow), 0, (GInstanceInitFunc) boxes_device_list_row_instance_init, NULL };
	GType boxes_device_list_row_type_id;
	boxes_device_list_row_type_id = g_type_register_static (hdy_action_row_get_type (), "BoxesDeviceListRow", &g_define_type_info, 0);
	BoxesDeviceListRow_private_offset = g_type_add_instance_private (boxes_device_list_row_type_id, sizeof (BoxesDeviceListRowPrivate));
	return boxes_device_list_row_type_id;
}

GType
boxes_device_list_row_get_type (void)
{
	static volatile gsize boxes_device_list_row_type_id__once = 0;
	if (g_once_init_enter (&boxes_device_list_row_type_id__once)) {
		GType boxes_device_list_row_type_id;
		boxes_device_list_row_type_id = boxes_device_list_row_get_type_once ();
		g_once_init_leave (&boxes_device_list_row_type_id__once, boxes_device_list_row_type_id);
	}
	return boxes_device_list_row_type_id__once;
}

static inline gpointer
boxes_usb_device_get_instance_private (BoxesUsbDevice* self)
{
	return G_STRUCT_MEMBER_P (self, BoxesUsbDevice_private_offset);
}

BoxesUsbDevice*
boxes_usb_device_construct (GType object_type)
{
	BoxesUsbDevice * self = NULL;
	self = (BoxesUsbDevice*) g_object_new (object_type, NULL);
	return self;
}

BoxesUsbDevice*
boxes_usb_device_new (void)
{
	return boxes_usb_device_construct (BOXES_TYPE_USB_DEVICE);
}

gboolean
boxes_usb_device_get_active (BoxesUsbDevice* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_active;
	return result;
}

void
boxes_usb_device_set_active (BoxesUsbDevice* self,
                             gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = boxes_usb_device_get_active (self);
	if (old_value != value) {
		self->priv->_active = value;
		g_object_notify_by_pspec ((GObject *) self, boxes_usb_device_properties[BOXES_USB_DEVICE_ACTIVE_PROPERTY]);
	}
}

static void
boxes_usb_device_class_init (BoxesUsbDeviceClass * klass,
                             gpointer klass_data)
{
	boxes_usb_device_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BoxesUsbDevice_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_boxes_usb_device_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_boxes_usb_device_set_property;
	G_OBJECT_CLASS (klass)->finalize = boxes_usb_device_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), BOXES_USB_DEVICE_ACTIVE_PROPERTY, boxes_usb_device_properties[BOXES_USB_DEVICE_ACTIVE_PROPERTY] = g_param_spec_boolean ("active", "active", "active", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
boxes_usb_device_instance_init (BoxesUsbDevice * self,
                                gpointer klass)
{
	self->priv = boxes_usb_device_get_instance_private (self);
}

static void
boxes_usb_device_finalize (GObject * obj)
{
	BoxesUsbDevice * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BOXES_TYPE_USB_DEVICE, BoxesUsbDevice);
	_g_free0 (self->title);
	G_OBJECT_CLASS (boxes_usb_device_parent_class)->finalize (obj);
}

static GType
boxes_usb_device_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BoxesUsbDeviceClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) boxes_usb_device_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BoxesUsbDevice), 0, (GInstanceInitFunc) boxes_usb_device_instance_init, NULL };
	GType boxes_usb_device_type_id;
	boxes_usb_device_type_id = g_type_register_static (G_TYPE_OBJECT, "BoxesUsbDevice", &g_define_type_info, 0);
	BoxesUsbDevice_private_offset = g_type_add_instance_private (boxes_usb_device_type_id, sizeof (BoxesUsbDevicePrivate));
	return boxes_usb_device_type_id;
}

GType
boxes_usb_device_get_type (void)
{
	static volatile gsize boxes_usb_device_type_id__once = 0;
	if (g_once_init_enter (&boxes_usb_device_type_id__once)) {
		GType boxes_usb_device_type_id;
		boxes_usb_device_type_id = boxes_usb_device_get_type_once ();
		g_once_init_leave (&boxes_usb_device_type_id__once, boxes_usb_device_type_id);
	}
	return boxes_usb_device_type_id__once;
}

static void
_vala_boxes_usb_device_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec)
{
	BoxesUsbDevice * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, BOXES_TYPE_USB_DEVICE, BoxesUsbDevice);
	switch (property_id) {
		case BOXES_USB_DEVICE_ACTIVE_PROPERTY:
		g_value_set_boolean (value, boxes_usb_device_get_active (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_boxes_usb_device_set_property (GObject * object,
                                     guint property_id,
                                     const GValue * value,
                                     GParamSpec * pspec)
{
	BoxesUsbDevice * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, BOXES_TYPE_USB_DEVICE, BoxesUsbDevice);
	switch (property_id) {
		case BOXES_USB_DEVICE_ACTIVE_PROPERTY:
		boxes_usb_device_set_active (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

