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

/* process-user-tag.vala
 *
 * Copyright (C) 2024 Markus Göllnitz
 *
 * 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 <http://www.gnu.org/licenses/>.
 *
 * Authors: Markus Göllnitz <camelcasenick@bewares.it>
 */

#include <adwaita.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.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
#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 USAGE_TYPE_PROCESS_USER_TAG (usage_process_user_tag_get_type ())
#define USAGE_PROCESS_USER_TAG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), USAGE_TYPE_PROCESS_USER_TAG, UsageProcessUserTag))
#define USAGE_PROCESS_USER_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), USAGE_TYPE_PROCESS_USER_TAG, UsageProcessUserTagClass))
#define USAGE_IS_PROCESS_USER_TAG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), USAGE_TYPE_PROCESS_USER_TAG))
#define USAGE_IS_PROCESS_USER_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), USAGE_TYPE_PROCESS_USER_TAG))
#define USAGE_PROCESS_USER_TAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), USAGE_TYPE_PROCESS_USER_TAG, UsageProcessUserTagClass))

typedef struct _UsageProcessUserTag UsageProcessUserTag;
typedef struct _UsageProcessUserTagClass UsageProcessUserTagClass;
typedef struct _UsageProcessUserTagPrivate UsageProcessUserTagPrivate;
enum  {
	USAGE_PROCESS_USER_TAG_0_PROPERTY,
	USAGE_PROCESS_USER_TAG_USER_TYPE_PROPERTY,
	USAGE_PROCESS_USER_TAG_LABEL_PROPERTY,
	USAGE_PROCESS_USER_TAG_NUM_PROPERTIES
};
static GParamSpec* usage_process_user_tag_properties[USAGE_PROCESS_USER_TAG_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)))

struct _UsageProcessUserTag {
	AdwBin parent_instance;
	UsageProcessUserTagPrivate * priv;
};

struct _UsageProcessUserTagClass {
	AdwBinClass parent_class;
	const gchar* (*get_label) (UsageProcessUserTag* self);
	void (*set_label) (UsageProcessUserTag* self, const gchar* value);
};

struct _UsageProcessUserTagPrivate {
	gchar* _user_type;
	GtkLabel* inner_label;
};

static gint UsageProcessUserTag_private_offset;
static gpointer usage_process_user_tag_parent_class = NULL;

VALA_EXTERN GType usage_process_user_tag_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (UsageProcessUserTag, g_object_unref)
VALA_EXTERN const gchar* usage_process_user_tag_get_label (UsageProcessUserTag* self);
VALA_EXTERN void usage_process_user_tag_set_label (UsageProcessUserTag* self,
                                       const gchar* value);
VALA_EXTERN UsageProcessUserTag* usage_process_user_tag_new (void);
VALA_EXTERN UsageProcessUserTag* usage_process_user_tag_construct (GType object_type);
VALA_EXTERN const gchar* usage_process_user_tag_get_user_type (UsageProcessUserTag* self);
VALA_EXTERN void usage_process_user_tag_set_user_type (UsageProcessUserTag* self,
                                           const gchar* value);
static GObject * usage_process_user_tag_constructor (GType type,
                                              guint n_construct_properties,
                                              GObjectConstructParam * construct_properties);
static void usage_process_user_tag_finalize (GObject * obj);
static GType usage_process_user_tag_get_type_once (void);
static void _vala_usage_process_user_tag_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec);
static void _vala_usage_process_user_tag_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
usage_process_user_tag_get_instance_private (UsageProcessUserTag* self)
{
	return G_STRUCT_MEMBER_P (self, UsageProcessUserTag_private_offset);
}

UsageProcessUserTag*
usage_process_user_tag_construct (GType object_type)
{
	UsageProcessUserTag * self = NULL;
	self = (UsageProcessUserTag*) g_object_new (object_type, NULL);
	return self;
}

UsageProcessUserTag*
usage_process_user_tag_new (void)
{
	return usage_process_user_tag_construct (USAGE_TYPE_PROCESS_USER_TAG);
}

const gchar*
usage_process_user_tag_get_user_type (UsageProcessUserTag* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_user_type;
	result = _tmp0_;
	return result;
}

void
usage_process_user_tag_set_user_type (UsageProcessUserTag* self,
                                      const gchar* value)
{
	const gchar* _tmp0_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_user_type;
	if (_tmp0_ != NULL) {
		const gchar* _tmp1_;
		_tmp1_ = self->priv->_user_type;
		gtk_widget_remove_css_class ((GtkWidget*) self, _tmp1_);
	}
	_tmp2_ = g_strdup (value);
	_g_free0 (self->priv->_user_type);
	self->priv->_user_type = _tmp2_;
	_tmp3_ = self->priv->_user_type;
	if (_tmp3_ != NULL) {
		const gchar* _tmp4_;
		_tmp4_ = self->priv->_user_type;
		gtk_widget_add_css_class ((GtkWidget*) self, _tmp4_);
	}
	g_object_notify_by_pspec ((GObject *) self, usage_process_user_tag_properties[USAGE_PROCESS_USER_TAG_USER_TYPE_PROPERTY]);
}

const gchar*
usage_process_user_tag_get_label (UsageProcessUserTag* self)
{
	UsageProcessUserTagClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = USAGE_PROCESS_USER_TAG_GET_CLASS (self);
	if (_klass_->get_label) {
		return _klass_->get_label (self);
	}
	return NULL;
}

static const gchar*
usage_process_user_tag_real_get_label (UsageProcessUserTag* base)
{
	const gchar* result;
	UsageProcessUserTag* self;
	GtkLabel* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	self = base;
	_tmp0_ = self->priv->inner_label;
	_tmp1_ = gtk_label_get_label (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

void
usage_process_user_tag_set_label (UsageProcessUserTag* self,
                                  const gchar* value)
{
	UsageProcessUserTagClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = USAGE_PROCESS_USER_TAG_GET_CLASS (self);
	if (_klass_->set_label) {
		_klass_->set_label (self, value);
	}
}

static void
usage_process_user_tag_real_set_label (UsageProcessUserTag* base,
                                       const gchar* value)
{
	UsageProcessUserTag* self;
	GtkLabel* _tmp0_;
	self = base;
	_tmp0_ = self->priv->inner_label;
	gtk_label_set_label (_tmp0_, value);
	g_object_notify_by_pspec ((GObject *) self, usage_process_user_tag_properties[USAGE_PROCESS_USER_TAG_LABEL_PROPERTY]);
}

static GObject *
usage_process_user_tag_constructor (GType type,
                                    guint n_construct_properties,
                                    GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	UsageProcessUserTag * self;
	GtkLabel* _tmp0_;
	GtkLabel* _tmp1_;
	parent_class = G_OBJECT_CLASS (usage_process_user_tag_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, USAGE_TYPE_PROCESS_USER_TAG, UsageProcessUserTag);
	_tmp0_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->inner_label);
	self->priv->inner_label = _tmp0_;
	_tmp1_ = self->priv->inner_label;
	adw_bin_set_child ((AdwBin*) self, (GtkWidget*) _tmp1_);
	gtk_widget_add_css_class ((GtkWidget*) self, "tag");
	return obj;
}

static void
usage_process_user_tag_class_init (UsageProcessUserTagClass * klass,
                                   gpointer klass_data)
{
	usage_process_user_tag_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &UsageProcessUserTag_private_offset);
	USAGE_PROCESS_USER_TAG_CLASS (klass)->get_label = (const gchar* (*) (UsageProcessUserTag*)) usage_process_user_tag_real_get_label;
	USAGE_PROCESS_USER_TAG_CLASS (klass)->set_label = (void (*) (UsageProcessUserTag*, const gchar*)) usage_process_user_tag_real_set_label;
	G_OBJECT_CLASS (klass)->get_property = _vala_usage_process_user_tag_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_usage_process_user_tag_set_property;
	G_OBJECT_CLASS (klass)->constructor = usage_process_user_tag_constructor;
	G_OBJECT_CLASS (klass)->finalize = usage_process_user_tag_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), USAGE_PROCESS_USER_TAG_USER_TYPE_PROPERTY, usage_process_user_tag_properties[USAGE_PROCESS_USER_TAG_USER_TYPE_PROPERTY] = g_param_spec_string ("user-type", "user-type", "user-type", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), USAGE_PROCESS_USER_TAG_LABEL_PROPERTY, usage_process_user_tag_properties[USAGE_PROCESS_USER_TAG_LABEL_PROPERTY] = g_param_spec_string ("label", "label", "label", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
usage_process_user_tag_instance_init (UsageProcessUserTag * self,
                                      gpointer klass)
{
	gchar* _tmp0_;
	self->priv = usage_process_user_tag_get_instance_private (self);
	_tmp0_ = g_strdup ("default");
	self->priv->_user_type = _tmp0_;
}

static void
usage_process_user_tag_finalize (GObject * obj)
{
	UsageProcessUserTag * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, USAGE_TYPE_PROCESS_USER_TAG, UsageProcessUserTag);
	_g_free0 (self->priv->_user_type);
	_g_object_unref0 (self->priv->inner_label);
	G_OBJECT_CLASS (usage_process_user_tag_parent_class)->finalize (obj);
}

static GType
usage_process_user_tag_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (UsageProcessUserTagClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) usage_process_user_tag_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UsageProcessUserTag), 0, (GInstanceInitFunc) usage_process_user_tag_instance_init, NULL };
	GType usage_process_user_tag_type_id;
	usage_process_user_tag_type_id = g_type_register_static (adw_bin_get_type (), "UsageProcessUserTag", &g_define_type_info, 0);
	UsageProcessUserTag_private_offset = g_type_add_instance_private (usage_process_user_tag_type_id, sizeof (UsageProcessUserTagPrivate));
	return usage_process_user_tag_type_id;
}

GType
usage_process_user_tag_get_type (void)
{
	static volatile gsize usage_process_user_tag_type_id__once = 0;
	if (g_once_init_enter (&usage_process_user_tag_type_id__once)) {
		GType usage_process_user_tag_type_id;
		usage_process_user_tag_type_id = usage_process_user_tag_get_type_once ();
		g_once_init_leave (&usage_process_user_tag_type_id__once, usage_process_user_tag_type_id);
	}
	return usage_process_user_tag_type_id__once;
}

static void
_vala_usage_process_user_tag_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec)
{
	UsageProcessUserTag * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, USAGE_TYPE_PROCESS_USER_TAG, UsageProcessUserTag);
	switch (property_id) {
		case USAGE_PROCESS_USER_TAG_USER_TYPE_PROPERTY:
		g_value_set_string (value, usage_process_user_tag_get_user_type (self));
		break;
		case USAGE_PROCESS_USER_TAG_LABEL_PROPERTY:
		g_value_set_string (value, usage_process_user_tag_get_label (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_usage_process_user_tag_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec)
{
	UsageProcessUserTag * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, USAGE_TYPE_PROCESS_USER_TAG, UsageProcessUserTag);
	switch (property_id) {
		case USAGE_PROCESS_USER_TAG_USER_TYPE_PROPERTY:
		usage_process_user_tag_set_user_type (self, g_value_get_string (value));
		break;
		case USAGE_PROCESS_USER_TAG_LABEL_PROPERTY:
		usage_process_user_tag_set_label (self, g_value_get_string (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;
}

