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

#include <adwaita.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <glib/gi18n-lib.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 TUBA_WIDGETS_ADMIN_TYPE_IP_BLOCK (tuba_widgets_admin_ip_block_get_type ())
#define TUBA_WIDGETS_ADMIN_IP_BLOCK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUBA_WIDGETS_ADMIN_TYPE_IP_BLOCK, TubaWidgetsAdminIPBlock))
#define TUBA_WIDGETS_ADMIN_IP_BLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TUBA_WIDGETS_ADMIN_TYPE_IP_BLOCK, TubaWidgetsAdminIPBlockClass))
#define TUBA_WIDGETS_ADMIN_IS_IP_BLOCK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUBA_WIDGETS_ADMIN_TYPE_IP_BLOCK))
#define TUBA_WIDGETS_ADMIN_IS_IP_BLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TUBA_WIDGETS_ADMIN_TYPE_IP_BLOCK))
#define TUBA_WIDGETS_ADMIN_IP_BLOCK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TUBA_WIDGETS_ADMIN_TYPE_IP_BLOCK, TubaWidgetsAdminIPBlockClass))

typedef struct _TubaWidgetsAdminIPBlock TubaWidgetsAdminIPBlock;
typedef struct _TubaWidgetsAdminIPBlockClass TubaWidgetsAdminIPBlockClass;
typedef struct _TubaWidgetsAdminIPBlockPrivate TubaWidgetsAdminIPBlockPrivate;
enum  {
	TUBA_WIDGETS_ADMIN_IP_BLOCK_0_PROPERTY,
	TUBA_WIDGETS_ADMIN_IP_BLOCK_NUM_PROPERTIES
};
static GParamSpec* tuba_widgets_admin_ip_block_properties[TUBA_WIDGETS_ADMIN_IP_BLOCK_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

#define TUBA_TYPE_ENTITY (tuba_entity_get_type ())
#define TUBA_ENTITY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUBA_TYPE_ENTITY, TubaEntity))
#define TUBA_ENTITY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TUBA_TYPE_ENTITY, TubaEntityClass))
#define TUBA_IS_ENTITY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUBA_TYPE_ENTITY))
#define TUBA_IS_ENTITY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TUBA_TYPE_ENTITY))
#define TUBA_ENTITY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TUBA_TYPE_ENTITY, TubaEntityClass))

typedef struct _TubaEntity TubaEntity;
typedef struct _TubaEntityClass TubaEntityClass;

#define TUBA_API_ADMIN_TYPE_IP_BLOCK (tuba_api_admin_ip_block_get_type ())
#define TUBA_API_ADMIN_IP_BLOCK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUBA_API_ADMIN_TYPE_IP_BLOCK, TubaAPIAdminIPBlock))
#define TUBA_API_ADMIN_IP_BLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TUBA_API_ADMIN_TYPE_IP_BLOCK, TubaAPIAdminIPBlockClass))
#define TUBA_API_ADMIN_IS_IP_BLOCK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUBA_API_ADMIN_TYPE_IP_BLOCK))
#define TUBA_API_ADMIN_IS_IP_BLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TUBA_API_ADMIN_TYPE_IP_BLOCK))
#define TUBA_API_ADMIN_IP_BLOCK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TUBA_API_ADMIN_TYPE_IP_BLOCK, TubaAPIAdminIPBlockClass))

typedef struct _TubaAPIAdminIPBlock TubaAPIAdminIPBlock;
typedef struct _TubaAPIAdminIPBlockClass TubaAPIAdminIPBlockClass;
typedef enum  {
	TUBA_API_ADMIN_IP_BLOCK_SEVERITY_NO_ACCESS,
	TUBA_API_ADMIN_IP_BLOCK_SEVERITY_SIGN_UP_BLOCK,
	TUBA_API_ADMIN_IP_BLOCK_SEVERITY_SIGN_UP_REQUIRES_APPROVAL
} TubaAPIAdminIPBlockSeverity;

#define TUBA_API_ADMIN_IP_BLOCK_TYPE_SEVERITY (tuba_api_admin_ip_block_severity_get_type ())
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	TUBA_WIDGETS_ADMIN_IP_BLOCK_REMOVED_SIGNAL,
	TUBA_WIDGETS_ADMIN_IP_BLOCK_NUM_SIGNALS
};
static guint tuba_widgets_admin_ip_block_signals[TUBA_WIDGETS_ADMIN_IP_BLOCK_NUM_SIGNALS] = {0};

struct _TubaWidgetsAdminIPBlock {
	AdwActionRow parent_instance;
	TubaWidgetsAdminIPBlockPrivate * priv;
};

struct _TubaWidgetsAdminIPBlockClass {
	AdwActionRowClass parent_class;
};

struct _TubaWidgetsAdminIPBlockPrivate {
	gchar* ip_block_id;
};

static gint TubaWidgetsAdminIPBlock_private_offset;
static gpointer tuba_widgets_admin_ip_block_parent_class = NULL;

VALA_EXTERN GType tuba_widgets_admin_ip_block_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaWidgetsAdminIPBlock, g_object_unref)
VALA_EXTERN GType tuba_entity_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaEntity, g_object_unref)
VALA_EXTERN GType tuba_api_admin_ip_block_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaAPIAdminIPBlock, g_object_unref)
VALA_EXTERN TubaWidgetsAdminIPBlock* tuba_widgets_admin_ip_block_new (TubaAPIAdminIPBlock* ip_block);
VALA_EXTERN TubaWidgetsAdminIPBlock* tuba_widgets_admin_ip_block_construct (GType object_type,
                                                                TubaAPIAdminIPBlock* ip_block);
VALA_EXTERN const gchar* tuba_api_admin_ip_block_get_id (TubaAPIAdminIPBlock* self);
VALA_EXTERN const gchar* tuba_api_admin_ip_block_get_ip (TubaAPIAdminIPBlock* self);
VALA_EXTERN GType tuba_api_admin_ip_block_severity_get_type (void) G_GNUC_CONST ;
VALA_EXTERN TubaAPIAdminIPBlockSeverity tuba_api_admin_ip_block_severity_from_string (const gchar* severity);
VALA_EXTERN const gchar* tuba_api_admin_ip_block_get_severity (TubaAPIAdminIPBlock* self);
VALA_EXTERN gchar* tuba_api_admin_ip_block_severity_to_string (TubaAPIAdminIPBlockSeverity self);
VALA_EXTERN const gchar* tuba_api_admin_ip_block_get_comment (TubaAPIAdminIPBlock* self);
VALA_EXTERN void tuba_widgets_admin_ip_block_on_remove (TubaWidgetsAdminIPBlock* self);
static void _tuba_widgets_admin_ip_block_on_remove_gtk_button_clicked (GtkButton* _sender,
                                                                gpointer self);
static void tuba_widgets_admin_ip_block_finalize (GObject * obj);
static GType tuba_widgets_admin_ip_block_get_type_once (void);
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
tuba_widgets_admin_ip_block_get_instance_private (TubaWidgetsAdminIPBlock* self)
{
	return G_STRUCT_MEMBER_P (self, TubaWidgetsAdminIPBlock_private_offset);
}

static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

static void
_tuba_widgets_admin_ip_block_on_remove_gtk_button_clicked (GtkButton* _sender,
                                                           gpointer self)
{
	tuba_widgets_admin_ip_block_on_remove ((TubaWidgetsAdminIPBlock*) self);
}

TubaWidgetsAdminIPBlock*
tuba_widgets_admin_ip_block_construct (GType object_type,
                                       TubaAPIAdminIPBlock* ip_block)
{
	TubaWidgetsAdminIPBlock * self = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gchar* sub = NULL;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	const gchar* _tmp17_;
	GtkButton* delete_button = NULL;
	gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	gchar** _tmp21_;
	gchar* _tmp22_;
	GtkButton* _tmp23_ = NULL;
	g_return_val_if_fail (ip_block != NULL, NULL);
	self = (TubaWidgetsAdminIPBlock*) g_object_new (object_type, NULL);
	_tmp0_ = tuba_api_admin_ip_block_get_id (ip_block);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_strdup (_tmp1_);
	_g_free0 (self->priv->ip_block_id);
	self->priv->ip_block_id = _tmp2_;
	_tmp3_ = tuba_api_admin_ip_block_get_ip (ip_block);
	_tmp4_ = _tmp3_;
	adw_preferences_row_set_title ((AdwPreferencesRow*) self, _tmp4_);
	_tmp5_ = tuba_api_admin_ip_block_get_severity (ip_block);
	_tmp6_ = _tmp5_;
	_tmp7_ = tuba_api_admin_ip_block_severity_to_string (tuba_api_admin_ip_block_severity_from_string (_tmp6_));
	sub = _tmp7_;
	_tmp8_ = tuba_api_admin_ip_block_get_comment (ip_block);
	_tmp9_ = _tmp8_;
	if (g_strcmp0 (_tmp9_, "") != 0) {
		const gchar* _tmp10_;
		const gchar* _tmp11_;
		const gchar* _tmp12_;
		const gchar* _tmp13_;
		gchar* _tmp14_;
		gchar* _tmp15_;
		gchar* _tmp16_;
		_tmp10_ = sub;
		_tmp11_ = tuba_api_admin_ip_block_get_comment (ip_block);
		_tmp12_ = _tmp11_;
		_tmp13_ = string_to_string (_tmp12_);
		_tmp14_ = g_strconcat (" · ", _tmp13_, NULL);
		_tmp15_ = _tmp14_;
		_tmp16_ = g_strconcat (_tmp10_, _tmp15_, NULL);
		_g_free0 (sub);
		sub = _tmp16_;
		_g_free0 (_tmp15_);
	}
	_tmp17_ = sub;
	adw_action_row_set_subtitle ((AdwActionRow*) self, _tmp17_);
	_tmp18_ = g_strdup ("circular");
	_tmp19_ = g_strdup ("flat");
	_tmp20_ = g_strdup ("error");
	_tmp21_ = g_new0 (gchar*, 3 + 1);
	_tmp21_[0] = _tmp18_;
	_tmp21_[1] = _tmp19_;
	_tmp21_[2] = _tmp20_;
	_tmp22_ = g_strdup (_ ("Delete"));
	_tmp23_ = (GtkButton*) gtk_button_new_from_icon_name ("user-trash-symbolic");
	gtk_widget_set_css_classes ((GtkWidget*) _tmp23_, _tmp21_);
	_tmp21_ = (_vala_array_free (_tmp21_, 3, (GDestroyNotify) g_free), NULL);
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp23_, _tmp22_);
	_g_free0 (_tmp22_);
	gtk_widget_set_valign ((GtkWidget*) _tmp23_, GTK_ALIGN_CENTER);
	g_object_ref_sink (_tmp23_);
	delete_button = _tmp23_;
	g_signal_connect_object (delete_button, "clicked", (GCallback) _tuba_widgets_admin_ip_block_on_remove_gtk_button_clicked, self, 0);
	adw_action_row_add_suffix ((AdwActionRow*) self, (GtkWidget*) delete_button);
	_g_object_unref0 (delete_button);
	_g_free0 (sub);
	return self;
}

TubaWidgetsAdminIPBlock*
tuba_widgets_admin_ip_block_new (TubaAPIAdminIPBlock* ip_block)
{
	return tuba_widgets_admin_ip_block_construct (TUBA_WIDGETS_ADMIN_TYPE_IP_BLOCK, ip_block);
}

void
tuba_widgets_admin_ip_block_on_remove (TubaWidgetsAdminIPBlock* self)
{
	const gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->ip_block_id;
	g_signal_emit (self, tuba_widgets_admin_ip_block_signals[TUBA_WIDGETS_ADMIN_IP_BLOCK_REMOVED_SIGNAL], 0, _tmp0_);
}

static void
tuba_widgets_admin_ip_block_class_init (TubaWidgetsAdminIPBlockClass * klass,
                                        gpointer klass_data)
{
	tuba_widgets_admin_ip_block_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &TubaWidgetsAdminIPBlock_private_offset);
	G_OBJECT_CLASS (klass)->finalize = tuba_widgets_admin_ip_block_finalize;
	tuba_widgets_admin_ip_block_signals[TUBA_WIDGETS_ADMIN_IP_BLOCK_REMOVED_SIGNAL] = g_signal_new ("removed", TUBA_WIDGETS_ADMIN_TYPE_IP_BLOCK, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
}

static void
tuba_widgets_admin_ip_block_instance_init (TubaWidgetsAdminIPBlock * self,
                                           gpointer klass)
{
	self->priv = tuba_widgets_admin_ip_block_get_instance_private (self);
}

static void
tuba_widgets_admin_ip_block_finalize (GObject * obj)
{
	TubaWidgetsAdminIPBlock * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TUBA_WIDGETS_ADMIN_TYPE_IP_BLOCK, TubaWidgetsAdminIPBlock);
	g_debug ("IPBlock.vala:5: Destroying IPBlock");
	_g_free0 (self->priv->ip_block_id);
	G_OBJECT_CLASS (tuba_widgets_admin_ip_block_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
tuba_widgets_admin_ip_block_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TubaWidgetsAdminIPBlockClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tuba_widgets_admin_ip_block_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TubaWidgetsAdminIPBlock), 0, (GInstanceInitFunc) tuba_widgets_admin_ip_block_instance_init, NULL };
	GType tuba_widgets_admin_ip_block_type_id;
	tuba_widgets_admin_ip_block_type_id = g_type_register_static (adw_action_row_get_type (), "TubaWidgetsAdminIPBlock", &g_define_type_info, G_TYPE_FLAG_NONE);
	TubaWidgetsAdminIPBlock_private_offset = g_type_add_instance_private (tuba_widgets_admin_ip_block_type_id, sizeof (TubaWidgetsAdminIPBlockPrivate));
	return tuba_widgets_admin_ip_block_type_id;
}

GType
tuba_widgets_admin_ip_block_get_type (void)
{
	static GType tuba_widgets_admin_ip_block_type_id__once = 0;
	if (g_once_init_enter_pointer (&tuba_widgets_admin_ip_block_type_id__once)) {
		GType tuba_widgets_admin_ip_block_type_id;
		tuba_widgets_admin_ip_block_type_id = tuba_widgets_admin_ip_block_get_type_once ();
		g_once_init_leave_pointer (&tuba_widgets_admin_ip_block_type_id__once, tuba_widgets_admin_ip_block_type_id);
	}
	return tuba_widgets_admin_ip_block_type_id__once;
}

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);
}

