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

/*
 * Copyright 2024 elementary, Inc. (https://elementary.io)
 * SPDX-License-Identifier: GPL-3.0-or-later
 *
 * Authored by: Leonhard Kargl <leo.kargl@proton.me>
 */

#include "system.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <glib-object.h>
#include <float.h>
#include <math.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  {
	ABOUT_DRIVER_ROW_0_PROPERTY,
	ABOUT_DRIVER_ROW_DEVICE_PROPERTY,
	ABOUT_DRIVER_ROW_DRIVER_NAME_PROPERTY,
	ABOUT_DRIVER_ROW_INSTALLED_PROPERTY,
	ABOUT_DRIVER_ROW_INSTALL_BUTTON_PROPERTY,
	ABOUT_DRIVER_ROW_NUM_PROPERTIES
};
static GParamSpec* about_driver_row_properties[ABOUT_DRIVER_ROW_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	ABOUT_DRIVER_ROW_INSTALL_SIGNAL,
	ABOUT_DRIVER_ROW_NUM_SIGNALS
};
static guint about_driver_row_signals[ABOUT_DRIVER_ROW_NUM_SIGNALS] = {0};

struct _AboutDriverRowPrivate {
	gchar* _device;
	gchar* _driver_name;
	gboolean _installed;
	GtkCheckButton* _install_button;
};

static gint AboutDriverRow_private_offset;
static gpointer about_driver_row_parent_class = NULL;

static GObject * about_driver_row_constructor (GType type,
                                        guint n_construct_properties,
                                        GObjectConstructParam * construct_properties);
static void _about_driver_row___lambda34_ (AboutDriverRow* self);
static void __about_driver_row___lambda34__gtk_check_button_toggled (GtkCheckButton* _sender,
                                                              gpointer self);
static void about_driver_row_finalize (GObject * obj);
static GType about_driver_row_get_type_once (void);
static void _vala_about_driver_row_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec);
static void _vala_about_driver_row_set_property (GObject * object,
                                          guint property_id,
                                          const GValue * value,
                                          GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
about_driver_row_get_instance_private (AboutDriverRow* self)
{
	return G_STRUCT_MEMBER_P (self, AboutDriverRow_private_offset);
}

AboutDriverRow*
about_driver_row_construct (GType object_type,
                            const gchar* device,
                            const gchar* driver_name,
                            gboolean installed)
{
	AboutDriverRow * self = NULL;
	g_return_val_if_fail (device != NULL, NULL);
	g_return_val_if_fail (driver_name != NULL, NULL);
	self = (AboutDriverRow*) g_object_new (object_type, "device", device, "driver-name", driver_name, "installed", installed, NULL);
	return self;
}

AboutDriverRow*
about_driver_row_new (const gchar* device,
                      const gchar* driver_name,
                      gboolean installed)
{
	return about_driver_row_construct (ABOUT_TYPE_DRIVER_ROW, device, driver_name, installed);
}

const gchar*
about_driver_row_get_device (AboutDriverRow* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_device;
	result = _tmp0_;
	return result;
}

static void
about_driver_row_set_device (AboutDriverRow* self,
                             const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = about_driver_row_get_device (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_device);
		self->priv->_device = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, about_driver_row_properties[ABOUT_DRIVER_ROW_DEVICE_PROPERTY]);
	}
}

const gchar*
about_driver_row_get_driver_name (AboutDriverRow* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_driver_name;
	result = _tmp0_;
	return result;
}

static void
about_driver_row_set_driver_name (AboutDriverRow* self,
                                  const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = about_driver_row_get_driver_name (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_driver_name);
		self->priv->_driver_name = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, about_driver_row_properties[ABOUT_DRIVER_ROW_DRIVER_NAME_PROPERTY]);
	}
}

gboolean
about_driver_row_get_installed (AboutDriverRow* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_installed;
	return result;
}

static void
about_driver_row_set_installed (AboutDriverRow* self,
                                gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = about_driver_row_get_installed (self);
	if (old_value != value) {
		self->priv->_installed = value;
		g_object_notify_by_pspec ((GObject *) self, about_driver_row_properties[ABOUT_DRIVER_ROW_INSTALLED_PROPERTY]);
	}
}

GtkCheckButton*
about_driver_row_get_install_button (AboutDriverRow* self)
{
	GtkCheckButton* result;
	GtkCheckButton* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_install_button;
	result = _tmp0_;
	return result;
}

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

static void
about_driver_row_set_install_button (AboutDriverRow* self,
                                     GtkCheckButton* value)
{
	GtkCheckButton* old_value;
	g_return_if_fail (self != NULL);
	old_value = about_driver_row_get_install_button (self);
	if (old_value != value) {
		GtkCheckButton* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_install_button);
		self->priv->_install_button = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, about_driver_row_properties[ABOUT_DRIVER_ROW_INSTALL_BUTTON_PROPERTY]);
	}
}

static void
_about_driver_row___lambda34_ (AboutDriverRow* self)
{
	GtkCheckButton* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	_tmp0_ = self->priv->_install_button;
	_tmp1_ = gtk_check_button_get_active (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		g_signal_emit (self, about_driver_row_signals[ABOUT_DRIVER_ROW_INSTALL_SIGNAL], 0);
	}
}

static void
__about_driver_row___lambda34__gtk_check_button_toggled (GtkCheckButton* _sender,
                                                         gpointer self)
{
	_about_driver_row___lambda34_ ((AboutDriverRow*) self);
}

static GObject *
about_driver_row_constructor (GType type,
                              guint n_construct_properties,
                              GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	AboutDriverRow * self;
	GtkImage* icon = NULL;
	GtkImage* _tmp0_ = NULL;
	GtkLabel* label = NULL;
	const gchar* _tmp1_;
	GtkLabel* _tmp2_ = NULL;
	gboolean _tmp3_;
	GtkCheckButton* _tmp4_ = NULL;
	GtkCheckButton* _tmp5_;
	GtkBox* box = NULL;
	GtkBox* _tmp6_;
	GtkBox* _tmp7_;
	GtkImage* _tmp8_;
	GtkBox* _tmp9_;
	GtkLabel* _tmp10_;
	GtkBox* _tmp11_;
	GtkCheckButton* _tmp12_;
	GtkBox* _tmp13_;
	GtkCheckButton* _tmp14_;
	parent_class = G_OBJECT_CLASS (about_driver_row_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, ABOUT_TYPE_DRIVER_ROW, AboutDriverRow);
	_tmp0_ = (GtkImage*) gtk_image_new_from_icon_name ("application-x-firmware");
	gtk_image_set_pixel_size (_tmp0_, 32);
	g_object_ref_sink (_tmp0_);
	icon = _tmp0_;
	_tmp1_ = self->priv->_driver_name;
	_tmp2_ = (GtkLabel*) gtk_label_new (_tmp1_);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp2_, TRUE);
	gtk_label_set_xalign (_tmp2_, (gfloat) 0);
	g_object_ref_sink (_tmp2_);
	label = _tmp2_;
	_tmp3_ = self->priv->_installed;
	_tmp4_ = (GtkCheckButton*) gtk_check_button_new ();
	gtk_check_button_set_active (_tmp4_, _tmp3_);
	gtk_widget_set_valign ((GtkWidget*) _tmp4_, GTK_ALIGN_CENTER);
	g_object_ref_sink (_tmp4_);
	_tmp5_ = _tmp4_;
	about_driver_row_set_install_button (self, _tmp5_);
	_g_object_unref0 (_tmp5_);
	_tmp6_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	g_object_ref_sink (_tmp6_);
	box = _tmp6_;
	_tmp7_ = box;
	_tmp8_ = icon;
	gtk_box_append (_tmp7_, (GtkWidget*) _tmp8_);
	_tmp9_ = box;
	_tmp10_ = label;
	gtk_box_append (_tmp9_, (GtkWidget*) _tmp10_);
	_tmp11_ = box;
	_tmp12_ = self->priv->_install_button;
	gtk_box_append (_tmp11_, (GtkWidget*) _tmp12_);
	_tmp13_ = box;
	gtk_list_box_row_set_child ((GtkListBoxRow*) self, (GtkWidget*) _tmp13_);
	_tmp14_ = self->priv->_install_button;
	g_signal_connect_object (_tmp14_, "toggled", (GCallback) __about_driver_row___lambda34__gtk_check_button_toggled, self, 0);
	_g_object_unref0 (box);
	_g_object_unref0 (label);
	_g_object_unref0 (icon);
	return obj;
}

static void
about_driver_row_class_init (AboutDriverRowClass * klass,
                             gpointer klass_data)
{
	about_driver_row_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &AboutDriverRow_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_about_driver_row_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_about_driver_row_set_property;
	G_OBJECT_CLASS (klass)->constructor = about_driver_row_constructor;
	G_OBJECT_CLASS (klass)->finalize = about_driver_row_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), ABOUT_DRIVER_ROW_DEVICE_PROPERTY, about_driver_row_properties[ABOUT_DRIVER_ROW_DEVICE_PROPERTY] = g_param_spec_string ("device", "device", "device", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), ABOUT_DRIVER_ROW_DRIVER_NAME_PROPERTY, about_driver_row_properties[ABOUT_DRIVER_ROW_DRIVER_NAME_PROPERTY] = g_param_spec_string ("driver-name", "driver-name", "driver-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), ABOUT_DRIVER_ROW_INSTALLED_PROPERTY, about_driver_row_properties[ABOUT_DRIVER_ROW_INSTALLED_PROPERTY] = g_param_spec_boolean ("installed", "installed", "installed", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), ABOUT_DRIVER_ROW_INSTALL_BUTTON_PROPERTY, about_driver_row_properties[ABOUT_DRIVER_ROW_INSTALL_BUTTON_PROPERTY] = g_param_spec_object ("install-button", "install-button", "install-button", gtk_check_button_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	about_driver_row_signals[ABOUT_DRIVER_ROW_INSTALL_SIGNAL] = g_signal_new ("install", ABOUT_TYPE_DRIVER_ROW, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
about_driver_row_instance_init (AboutDriverRow * self,
                                gpointer klass)
{
	self->priv = about_driver_row_get_instance_private (self);
}

static void
about_driver_row_finalize (GObject * obj)
{
	AboutDriverRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, ABOUT_TYPE_DRIVER_ROW, AboutDriverRow);
	_g_free0 (self->priv->_device);
	_g_free0 (self->priv->_driver_name);
	_g_object_unref0 (self->priv->_install_button);
	G_OBJECT_CLASS (about_driver_row_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
about_driver_row_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (AboutDriverRowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) about_driver_row_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (AboutDriverRow), 0, (GInstanceInitFunc) about_driver_row_instance_init, NULL };
	GType about_driver_row_type_id;
	about_driver_row_type_id = g_type_register_static (gtk_list_box_row_get_type (), "AboutDriverRow", &g_define_type_info, 0);
	AboutDriverRow_private_offset = g_type_add_instance_private (about_driver_row_type_id, sizeof (AboutDriverRowPrivate));
	return about_driver_row_type_id;
}

GType
about_driver_row_get_type (void)
{
	static volatile gsize about_driver_row_type_id__once = 0;
	if (g_once_init_enter (&about_driver_row_type_id__once)) {
		GType about_driver_row_type_id;
		about_driver_row_type_id = about_driver_row_get_type_once ();
		g_once_init_leave (&about_driver_row_type_id__once, about_driver_row_type_id);
	}
	return about_driver_row_type_id__once;
}

static void
_vala_about_driver_row_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec)
{
	AboutDriverRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, ABOUT_TYPE_DRIVER_ROW, AboutDriverRow);
	switch (property_id) {
		case ABOUT_DRIVER_ROW_DEVICE_PROPERTY:
		g_value_set_string (value, about_driver_row_get_device (self));
		break;
		case ABOUT_DRIVER_ROW_DRIVER_NAME_PROPERTY:
		g_value_set_string (value, about_driver_row_get_driver_name (self));
		break;
		case ABOUT_DRIVER_ROW_INSTALLED_PROPERTY:
		g_value_set_boolean (value, about_driver_row_get_installed (self));
		break;
		case ABOUT_DRIVER_ROW_INSTALL_BUTTON_PROPERTY:
		g_value_set_object (value, about_driver_row_get_install_button (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_about_driver_row_set_property (GObject * object,
                                     guint property_id,
                                     const GValue * value,
                                     GParamSpec * pspec)
{
	AboutDriverRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, ABOUT_TYPE_DRIVER_ROW, AboutDriverRow);
	switch (property_id) {
		case ABOUT_DRIVER_ROW_DEVICE_PROPERTY:
		about_driver_row_set_device (self, g_value_get_string (value));
		break;
		case ABOUT_DRIVER_ROW_DRIVER_NAME_PROPERTY:
		about_driver_row_set_driver_name (self, g_value_get_string (value));
		break;
		case ABOUT_DRIVER_ROW_INSTALLED_PROPERTY:
		about_driver_row_set_installed (self, g_value_get_boolean (value));
		break;
		case ABOUT_DRIVER_ROW_INSTALL_BUTTON_PROPERTY:
		about_driver_row_set_install_button (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

