/* downloadable-entry.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from downloadable-entry.vala, do not modify */

#include <handy.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <osinfo/osinfo.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gio/gio.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_ASSISTANT_MEDIA_ENTRY (boxes_assistant_media_entry_get_type ())
#define BOXES_ASSISTANT_MEDIA_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_ASSISTANT_MEDIA_ENTRY, BoxesAssistantMediaEntry))
#define BOXES_ASSISTANT_MEDIA_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_ASSISTANT_MEDIA_ENTRY, BoxesAssistantMediaEntryClass))
#define BOXES_IS_ASSISTANT_MEDIA_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_ASSISTANT_MEDIA_ENTRY))
#define BOXES_IS_ASSISTANT_MEDIA_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_ASSISTANT_MEDIA_ENTRY))
#define BOXES_ASSISTANT_MEDIA_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_ASSISTANT_MEDIA_ENTRY, BoxesAssistantMediaEntryClass))

typedef struct _BoxesAssistantMediaEntry BoxesAssistantMediaEntry;
typedef struct _BoxesAssistantMediaEntryClass BoxesAssistantMediaEntryClass;
typedef struct _BoxesAssistantMediaEntryPrivate BoxesAssistantMediaEntryPrivate;

#define BOXES_TYPE_INSTALLER_MEDIA (boxes_installer_media_get_type ())
#define BOXES_INSTALLER_MEDIA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_INSTALLER_MEDIA, BoxesInstallerMedia))
#define BOXES_INSTALLER_MEDIA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_INSTALLER_MEDIA, BoxesInstallerMediaClass))
#define BOXES_IS_INSTALLER_MEDIA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_INSTALLER_MEDIA))
#define BOXES_IS_INSTALLER_MEDIA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_INSTALLER_MEDIA))
#define BOXES_INSTALLER_MEDIA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_INSTALLER_MEDIA, BoxesInstallerMediaClass))

typedef struct _BoxesInstallerMedia BoxesInstallerMedia;
typedef struct _BoxesInstallerMediaClass BoxesInstallerMediaClass;

#define BOXES_TYPE_ASSISTANT_DOWNLOADABLE_ENTRY (boxes_assistant_downloadable_entry_get_type ())
#define BOXES_ASSISTANT_DOWNLOADABLE_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_ASSISTANT_DOWNLOADABLE_ENTRY, BoxesAssistantDownloadableEntry))
#define BOXES_ASSISTANT_DOWNLOADABLE_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_ASSISTANT_DOWNLOADABLE_ENTRY, BoxesAssistantDownloadableEntryClass))
#define BOXES_IS_ASSISTANT_DOWNLOADABLE_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_ASSISTANT_DOWNLOADABLE_ENTRY))
#define BOXES_IS_ASSISTANT_DOWNLOADABLE_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_ASSISTANT_DOWNLOADABLE_ENTRY))
#define BOXES_ASSISTANT_DOWNLOADABLE_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_ASSISTANT_DOWNLOADABLE_ENTRY, BoxesAssistantDownloadableEntryClass))

typedef struct _BoxesAssistantDownloadableEntry BoxesAssistantDownloadableEntry;
typedef struct _BoxesAssistantDownloadableEntryClass BoxesAssistantDownloadableEntryClass;
typedef struct _BoxesAssistantDownloadableEntryPrivate BoxesAssistantDownloadableEntryPrivate;
enum  {
	BOXES_ASSISTANT_DOWNLOADABLE_ENTRY_0_PROPERTY,
	BOXES_ASSISTANT_DOWNLOADABLE_ENTRY_NUM_PROPERTIES
};
static GParamSpec* boxes_assistant_downloadable_entry_properties[BOXES_ASSISTANT_DOWNLOADABLE_ENTRY_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _BoxesAssistantMediaEntry {
	HdyActionRow parent_instance;
	BoxesAssistantMediaEntryPrivate * priv;
	BoxesInstallerMedia* media;
	GtkImage* media_image;
};

struct _BoxesAssistantMediaEntryClass {
	HdyActionRowClass parent_class;
};

struct _BoxesAssistantDownloadableEntry {
	BoxesAssistantMediaEntry parent_instance;
	BoxesAssistantDownloadableEntryPrivate * priv;
	OsinfoOs* os;
	gchar* url;
};

struct _BoxesAssistantDownloadableEntryClass {
	BoxesAssistantMediaEntryClass parent_class;
};

static gpointer boxes_assistant_downloadable_entry_parent_class = NULL;

VALA_EXTERN GType boxes_assistant_media_entry_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesAssistantMediaEntry, g_object_unref)
VALA_EXTERN GType boxes_installer_media_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesInstallerMedia, g_object_unref)
VALA_EXTERN GType boxes_assistant_downloadable_entry_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesAssistantDownloadableEntry, g_object_unref)
VALA_EXTERN BoxesAssistantDownloadableEntry* boxes_assistant_downloadable_entry_new_from_osinfo (OsinfoMedia* media);
VALA_EXTERN BoxesAssistantDownloadableEntry* boxes_assistant_downloadable_entry_construct_from_osinfo (GType object_type,
                                                                                           OsinfoMedia* media);
VALA_EXTERN BoxesAssistantMediaEntry* boxes_assistant_media_entry_new (void);
VALA_EXTERN BoxesAssistantMediaEntry* boxes_assistant_media_entry_construct (GType object_type);
VALA_EXTERN gchar* boxes_serialize_os_title (OsinfoMedia* media);
VALA_EXTERN void boxes_downloader_fetch_os_logo (GtkImage* image,
                                     OsinfoOs* os,
                                     gint size,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_);
VALA_EXTERN void boxes_downloader_fetch_os_logo_finish (GAsyncResult* _res_);
VALA_EXTERN BoxesAssistantDownloadableEntry* boxes_assistant_downloadable_entry_new (void);
VALA_EXTERN BoxesAssistantDownloadableEntry* boxes_assistant_downloadable_entry_construct (GType object_type);
static void boxes_assistant_downloadable_entry_finalize (GObject * obj);
static GType boxes_assistant_downloadable_entry_get_type_once (void);

BoxesAssistantDownloadableEntry*
boxes_assistant_downloadable_entry_construct_from_osinfo (GType object_type,
                                                          OsinfoMedia* media)
{
	BoxesAssistantDownloadableEntry * self = NULL;
	OsinfoOs* _tmp0_;
	OsinfoOs* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_ = NULL;
	gconstpointer _tmp5_;
	gchar* _tmp6_;
	const gchar* _tmp8_ = NULL;
	gconstpointer _tmp9_;
	gchar* _tmp15_ = NULL;
	gchar* _tmp16_;
	gchar* _tmp17_;
	GtkImage* _tmp21_;
	OsinfoOs* _tmp22_;
	g_return_val_if_fail (media != NULL, NULL);
	self = (BoxesAssistantDownloadableEntry*) boxes_assistant_media_entry_construct (object_type);
	g_object_get (media, "os", &_tmp0_, NULL);
	_tmp1_ = _tmp0_;
	_g_object_unref0 (self->os);
	self->os = _tmp1_;
	g_object_get (media, "url", &_tmp2_, NULL);
	_tmp3_ = _tmp2_;
	_g_free0 (self->url);
	self->url = _tmp3_;
	_tmp5_ = g_object_get_data ((GObject*) media, "title");
	_tmp6_ = g_strdup ((const gchar*) _tmp5_);
	_tmp4_ = _tmp6_;
	if (_tmp4_ == NULL) {
		gchar* _tmp7_;
		_tmp7_ = boxes_serialize_os_title (media);
		_g_free0 (_tmp4_);
		_tmp4_ = _tmp7_;
	}
	hdy_preferences_row_set_title ((HdyPreferencesRow*) self, _tmp4_);
	_tmp9_ = g_object_get_data ((GObject*) media, "subtitle");
	_tmp8_ = (const gchar*) _tmp9_;
	if (_tmp8_ == NULL) {
		OsinfoOs* _tmp10_;
		OsinfoOs* _tmp11_;
		OsinfoOs* _tmp12_;
		const gchar* _tmp13_;
		const gchar* _tmp14_;
		g_object_get (media, "os", &_tmp10_, NULL);
		_tmp11_ = _tmp10_;
		_tmp12_ = _tmp11_;
		_tmp13_ = osinfo_product_get_vendor ((OsinfoProduct*) _tmp12_);
		_tmp14_ = _tmp13_;
		_tmp8_ = _tmp14_;
		_g_object_unref0 (_tmp12_);
	}
	hdy_action_row_set_subtitle ((HdyActionRow*) self, _tmp8_);
	g_object_get (media, "url", &_tmp16_, NULL);
	_tmp17_ = _tmp16_;
	_tmp15_ = _tmp17_;
	if (_tmp15_ == NULL) {
		const gchar* _tmp18_;
		const gchar* _tmp19_;
		gchar* _tmp20_;
		_tmp18_ = hdy_preferences_row_get_title ((HdyPreferencesRow*) self);
		_tmp19_ = _tmp18_;
		_tmp20_ = g_strdup (_tmp19_);
		_g_free0 (_tmp15_);
		_tmp15_ = _tmp20_;
	}
	gtk_widget_set_tooltip_text ((GtkWidget*) self, _tmp15_);
	_tmp21_ = ((BoxesAssistantMediaEntry*) self)->media_image;
	_tmp22_ = self->os;
	boxes_downloader_fetch_os_logo (_tmp21_, _tmp22_, 64, NULL, NULL);
	_g_free0 (_tmp15_);
	_g_free0 (_tmp4_);
	return self;
}

BoxesAssistantDownloadableEntry*
boxes_assistant_downloadable_entry_new_from_osinfo (OsinfoMedia* media)
{
	return boxes_assistant_downloadable_entry_construct_from_osinfo (BOXES_TYPE_ASSISTANT_DOWNLOADABLE_ENTRY, media);
}

BoxesAssistantDownloadableEntry*
boxes_assistant_downloadable_entry_construct (GType object_type)
{
	BoxesAssistantDownloadableEntry * self = NULL;
	self = (BoxesAssistantDownloadableEntry*) boxes_assistant_media_entry_construct (object_type);
	return self;
}

BoxesAssistantDownloadableEntry*
boxes_assistant_downloadable_entry_new (void)
{
	return boxes_assistant_downloadable_entry_construct (BOXES_TYPE_ASSISTANT_DOWNLOADABLE_ENTRY);
}

static void
boxes_assistant_downloadable_entry_class_init (BoxesAssistantDownloadableEntryClass * klass,
                                               gpointer klass_data)
{
	boxes_assistant_downloadable_entry_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = boxes_assistant_downloadable_entry_finalize;
}

static void
boxes_assistant_downloadable_entry_instance_init (BoxesAssistantDownloadableEntry * self,
                                                  gpointer klass)
{
}

static void
boxes_assistant_downloadable_entry_finalize (GObject * obj)
{
	BoxesAssistantDownloadableEntry * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BOXES_TYPE_ASSISTANT_DOWNLOADABLE_ENTRY, BoxesAssistantDownloadableEntry);
	_g_object_unref0 (self->os);
	_g_free0 (self->url);
	G_OBJECT_CLASS (boxes_assistant_downloadable_entry_parent_class)->finalize (obj);
}

static GType
boxes_assistant_downloadable_entry_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BoxesAssistantDownloadableEntryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) boxes_assistant_downloadable_entry_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BoxesAssistantDownloadableEntry), 0, (GInstanceInitFunc) boxes_assistant_downloadable_entry_instance_init, NULL };
	GType boxes_assistant_downloadable_entry_type_id;
	boxes_assistant_downloadable_entry_type_id = g_type_register_static (BOXES_TYPE_ASSISTANT_MEDIA_ENTRY, "BoxesAssistantDownloadableEntry", &g_define_type_info, 0);
	return boxes_assistant_downloadable_entry_type_id;
}

GType
boxes_assistant_downloadable_entry_get_type (void)
{
	static volatile gsize boxes_assistant_downloadable_entry_type_id__once = 0;
	if (g_once_init_enter (&boxes_assistant_downloadable_entry_type_id__once)) {
		GType boxes_assistant_downloadable_entry_type_id;
		boxes_assistant_downloadable_entry_type_id = boxes_assistant_downloadable_entry_get_type_once ();
		g_once_init_leave (&boxes_assistant_downloadable_entry_type_id__once, boxes_assistant_downloadable_entry_type_id);
	}
	return boxes_assistant_downloadable_entry_type_id__once;
}

