/* Tag.c generated by valac 0.56.19, the Vala compiler
 * generated from Tag.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 <gee.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_TYPE_TAG (tuba_widgets_tag_get_type ())
#define TUBA_WIDGETS_TAG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUBA_WIDGETS_TYPE_TAG, TubaWidgetsTag))
#define TUBA_WIDGETS_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TUBA_WIDGETS_TYPE_TAG, TubaWidgetsTagClass))
#define TUBA_WIDGETS_IS_TAG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUBA_WIDGETS_TYPE_TAG))
#define TUBA_WIDGETS_IS_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TUBA_WIDGETS_TYPE_TAG))
#define TUBA_WIDGETS_TAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TUBA_WIDGETS_TYPE_TAG, TubaWidgetsTagClass))

typedef struct _TubaWidgetsTag TubaWidgetsTag;
typedef struct _TubaWidgetsTagClass TubaWidgetsTagClass;
typedef struct _TubaWidgetsTagPrivate TubaWidgetsTagPrivate;
enum  {
	TUBA_WIDGETS_TAG_0_PROPERTY,
	TUBA_WIDGETS_TAG_NAME_PROPERTY,
	TUBA_WIDGETS_TAG_NUM_PROPERTIES
};
static GParamSpec* tuba_widgets_tag_properties[TUBA_WIDGETS_TAG_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_TYPE_TAG (tuba_api_tag_get_type ())
#define TUBA_API_TAG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUBA_API_TYPE_TAG, TubaAPITag))
#define TUBA_API_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TUBA_API_TYPE_TAG, TubaAPITagClass))
#define TUBA_API_IS_TAG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUBA_API_TYPE_TAG))
#define TUBA_API_IS_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TUBA_API_TYPE_TAG))
#define TUBA_API_TAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TUBA_API_TYPE_TAG, TubaAPITagClass))

typedef struct _TubaAPITag TubaAPITag;
typedef struct _TubaAPITagClass TubaAPITagClass;

#define TUBA_API_TYPE_TAG_HISTORY (tuba_api_tag_history_get_type ())
#define TUBA_API_TAG_HISTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUBA_API_TYPE_TAG_HISTORY, TubaAPITagHistory))
#define TUBA_API_TAG_HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TUBA_API_TYPE_TAG_HISTORY, TubaAPITagHistoryClass))
#define TUBA_API_IS_TAG_HISTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUBA_API_TYPE_TAG_HISTORY))
#define TUBA_API_IS_TAG_HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TUBA_API_TYPE_TAG_HISTORY))
#define TUBA_API_TAG_HISTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TUBA_API_TYPE_TAG_HISTORY, TubaAPITagHistoryClass))

typedef struct _TubaAPITagHistory TubaAPITagHistory;
typedef struct _TubaAPITagHistoryClass TubaAPITagHistoryClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _TubaWidgetsTag {
	AdwActionRow parent_instance;
	TubaWidgetsTagPrivate * priv;
};

struct _TubaWidgetsTagClass {
	AdwActionRowClass parent_class;
};

struct _TubaWidgetsTagPrivate {
	gchar* _name;
};

static gint TubaWidgetsTag_private_offset;
static gpointer tuba_widgets_tag_parent_class = NULL;

VALA_EXTERN GType tuba_widgets_tag_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaWidgetsTag, 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_tag_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaAPITag, g_object_unref)
VALA_EXTERN TubaWidgetsTag* tuba_widgets_tag_new (TubaAPITag* tag);
VALA_EXTERN TubaWidgetsTag* tuba_widgets_tag_construct (GType object_type,
                                            TubaAPITag* tag);
VALA_EXTERN const gchar* tuba_api_tag_get_name (TubaAPITag* self);
VALA_EXTERN void tuba_widgets_tag_set_name (TubaWidgetsTag* self,
                                const gchar* value);
VALA_EXTERN GType tuba_api_tag_history_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaAPITagHistory, g_object_unref)
VALA_EXTERN GeeArrayList* tuba_api_tag_get_history (TubaAPITag* self);
VALA_EXTERN const gchar* tuba_api_tag_history_get_accounts (TubaAPITagHistory* self);
VALA_EXTERN const gchar* tuba_widgets_tag_get_name (TubaWidgetsTag* self);
static void tuba_widgets_tag_finalize (GObject * obj);
static GType tuba_widgets_tag_get_type_once (void);
static void _vala_tuba_widgets_tag_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec);
static void _vala_tuba_widgets_tag_set_property (GObject * object,
                                          guint property_id,
                                          const GValue * value,
                                          GParamSpec * pspec);

static inline gpointer
tuba_widgets_tag_get_instance_private (TubaWidgetsTag* self)
{
	return G_STRUCT_MEMBER_P (self, TubaWidgetsTag_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;
}

TubaWidgetsTag*
tuba_widgets_tag_construct (GType object_type,
                            TubaAPITag* tag)
{
	TubaWidgetsTag * self = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gboolean _tmp5_ = FALSE;
	GeeArrayList* _tmp6_;
	GeeArrayList* _tmp7_;
	g_return_val_if_fail (tag != NULL, NULL);
	self = (TubaWidgetsTag*) g_object_new (object_type, NULL);
	_tmp0_ = tuba_api_tag_get_name (tag);
	_tmp1_ = _tmp0_;
	_tmp2_ = string_to_string (_tmp1_);
	_tmp3_ = g_strconcat ("#", _tmp2_, NULL);
	_tmp4_ = _tmp3_;
	adw_preferences_row_set_title ((AdwPreferencesRow*) self, _tmp4_);
	tuba_widgets_tag_set_name (self, _tmp4_);
	_g_free0 (_tmp4_);
	gtk_list_box_row_set_activatable ((GtkListBoxRow*) self, TRUE);
	adw_preferences_row_set_use_markup ((AdwPreferencesRow*) self, FALSE);
	_tmp6_ = tuba_api_tag_get_history (tag);
	_tmp7_ = _tmp6_;
	if (_tmp7_ != NULL) {
		GeeArrayList* _tmp8_;
		GeeArrayList* _tmp9_;
		gint _tmp10_;
		gint _tmp11_;
		_tmp8_ = tuba_api_tag_get_history (tag);
		_tmp9_ = _tmp8_;
		_tmp10_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp9_);
		_tmp11_ = _tmp10_;
		_tmp5_ = _tmp11_ > 0;
	} else {
		_tmp5_ = FALSE;
	}
	if (_tmp5_) {
		TubaAPITagHistory* last_history_entry = NULL;
		GeeArrayList* _tmp12_;
		GeeArrayList* _tmp13_;
		gpointer _tmp14_;
		gint total_accounts = 0;
		TubaAPITagHistory* _tmp15_;
		const gchar* _tmp16_;
		const gchar* _tmp17_;
		gchar* subtitle = NULL;
		gchar* _tmp18_;
		GeeArrayList* _tmp19_;
		GeeArrayList* _tmp20_;
		gint _tmp21_;
		gint _tmp22_;
		const gchar* _tmp30_;
		_tmp12_ = tuba_api_tag_get_history (tag);
		_tmp13_ = _tmp12_;
		_tmp14_ = gee_abstract_list_get ((GeeAbstractList*) _tmp13_, 0);
		last_history_entry = (TubaAPITagHistory*) _tmp14_;
		_tmp15_ = last_history_entry;
		_tmp16_ = tuba_api_tag_history_get_accounts (_tmp15_);
		_tmp17_ = _tmp16_;
		total_accounts = atoi (_tmp17_);
		_tmp18_ = g_strdup_printf (ngettext ("%d person yesterday", "%d people yesterday", (gulong) total_accounts), total_accounts);
		subtitle = _tmp18_;
		_tmp19_ = tuba_api_tag_get_history (tag);
		_tmp20_ = _tmp19_;
		_tmp21_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp20_);
		_tmp22_ = _tmp21_;
		if (_tmp22_ > 1) {
			GeeArrayList* _tmp23_;
			GeeArrayList* _tmp24_;
			gpointer _tmp25_;
			TubaAPITagHistory* _tmp26_;
			const gchar* _tmp27_;
			const gchar* _tmp28_;
			gchar* _tmp29_;
			_tmp23_ = tuba_api_tag_get_history (tag);
			_tmp24_ = _tmp23_;
			_tmp25_ = gee_abstract_list_get ((GeeAbstractList*) _tmp24_, 1);
			_g_object_unref0 (last_history_entry);
			last_history_entry = (TubaAPITagHistory*) _tmp25_;
			_tmp26_ = last_history_entry;
			_tmp27_ = tuba_api_tag_history_get_accounts (_tmp26_);
			_tmp28_ = _tmp27_;
			total_accounts += atoi (_tmp28_);
			_tmp29_ = g_strdup_printf (ngettext ("%d person in the past 2 days", "%d people in the past 2 days", (gulong) total_accounts), total_accounts);
			_g_free0 (subtitle);
			subtitle = _tmp29_;
		}
		_tmp30_ = subtitle;
		adw_action_row_set_subtitle ((AdwActionRow*) self, _tmp30_);
		_g_free0 (subtitle);
		_g_object_unref0 (last_history_entry);
	}
	return self;
}

TubaWidgetsTag*
tuba_widgets_tag_new (TubaAPITag* tag)
{
	return tuba_widgets_tag_construct (TUBA_WIDGETS_TYPE_TAG, tag);
}

const gchar*
tuba_widgets_tag_get_name (TubaWidgetsTag* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_name;
	result = _tmp0_;
	return result;
}

void
tuba_widgets_tag_set_name (TubaWidgetsTag* self,
                           const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = tuba_widgets_tag_get_name (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_name);
		self->priv->_name = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, tuba_widgets_tag_properties[TUBA_WIDGETS_TAG_NAME_PROPERTY]);
	}
}

static void
tuba_widgets_tag_class_init (TubaWidgetsTagClass * klass,
                             gpointer klass_data)
{
	tuba_widgets_tag_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &TubaWidgetsTag_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_tuba_widgets_tag_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_tuba_widgets_tag_set_property;
	G_OBJECT_CLASS (klass)->finalize = tuba_widgets_tag_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), TUBA_WIDGETS_TAG_NAME_PROPERTY, tuba_widgets_tag_properties[TUBA_WIDGETS_TAG_NAME_PROPERTY] = g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
tuba_widgets_tag_instance_init (TubaWidgetsTag * self,
                                gpointer klass)
{
	self->priv = tuba_widgets_tag_get_instance_private (self);
}

static void
tuba_widgets_tag_finalize (GObject * obj)
{
	TubaWidgetsTag * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TUBA_WIDGETS_TYPE_TAG, TubaWidgetsTag);
	_g_free0 (self->priv->_name);
	G_OBJECT_CLASS (tuba_widgets_tag_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
tuba_widgets_tag_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TubaWidgetsTagClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tuba_widgets_tag_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TubaWidgetsTag), 0, (GInstanceInitFunc) tuba_widgets_tag_instance_init, NULL };
	GType tuba_widgets_tag_type_id;
	tuba_widgets_tag_type_id = g_type_register_static (adw_action_row_get_type (), "TubaWidgetsTag", &g_define_type_info, G_TYPE_FLAG_NONE);
	TubaWidgetsTag_private_offset = g_type_add_instance_private (tuba_widgets_tag_type_id, sizeof (TubaWidgetsTagPrivate));
	return tuba_widgets_tag_type_id;
}

GType
tuba_widgets_tag_get_type (void)
{
	static GType tuba_widgets_tag_type_id__once = 0;
	if (g_once_init_enter_pointer (&tuba_widgets_tag_type_id__once)) {
		GType tuba_widgets_tag_type_id;
		tuba_widgets_tag_type_id = tuba_widgets_tag_get_type_once ();
		g_once_init_leave_pointer (&tuba_widgets_tag_type_id__once, tuba_widgets_tag_type_id);
	}
	return tuba_widgets_tag_type_id__once;
}

static void
_vala_tuba_widgets_tag_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec)
{
	TubaWidgetsTag * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TUBA_WIDGETS_TYPE_TAG, TubaWidgetsTag);
	switch (property_id) {
		case TUBA_WIDGETS_TAG_NAME_PROPERTY:
		g_value_set_string (value, tuba_widgets_tag_get_name (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_tuba_widgets_tag_set_property (GObject * object,
                                     guint property_id,
                                     const GValue * value,
                                     GParamSpec * pspec)
{
	TubaWidgetsTag * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TUBA_WIDGETS_TYPE_TAG, TubaWidgetsTag);
	switch (property_id) {
		case TUBA_WIDGETS_TAG_NAME_PROPERTY:
		tuba_widgets_tag_set_name (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

