/* os-chooser-row.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from os-chooser-row.vala, do not modify */

/* This file is part of GNOME Boxes. License: LGPLv2+*/

#include <handy.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <glib.h>
#include <osinfo/osinfo.h>
#include <stdlib.h>
#include <string.h>
#include "common.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
#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_OS_CHOOSER_ROW (boxes_os_chooser_row_get_type ())
#define BOXES_OS_CHOOSER_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_OS_CHOOSER_ROW, BoxesOsChooserRow))
#define BOXES_OS_CHOOSER_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_OS_CHOOSER_ROW, BoxesOsChooserRowClass))
#define BOXES_IS_OS_CHOOSER_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_OS_CHOOSER_ROW))
#define BOXES_IS_OS_CHOOSER_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_OS_CHOOSER_ROW))
#define BOXES_OS_CHOOSER_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_OS_CHOOSER_ROW, BoxesOsChooserRowClass))

typedef struct _BoxesOsChooserRow BoxesOsChooserRow;
typedef struct _BoxesOsChooserRowClass BoxesOsChooserRowClass;
typedef struct _BoxesOsChooserRowPrivate BoxesOsChooserRowPrivate;
enum  {
	BOXES_OS_CHOOSER_ROW_0_PROPERTY,
	BOXES_OS_CHOOSER_ROW_NUM_PROPERTIES
};
static GParamSpec* boxes_os_chooser_row_properties[BOXES_OS_CHOOSER_ROW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _BoxesOsChooserRowOnOsSelectedData BoxesOsChooserRowOnOsSelectedData;

#define BOXES_TYPE_MEDIA_MANAGER (boxes_media_manager_get_type ())
#define BOXES_MEDIA_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_MEDIA_MANAGER, BoxesMediaManager))
#define BOXES_MEDIA_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_MEDIA_MANAGER, BoxesMediaManagerClass))
#define BOXES_IS_MEDIA_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_MEDIA_MANAGER))
#define BOXES_IS_MEDIA_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_MEDIA_MANAGER))
#define BOXES_MEDIA_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_MEDIA_MANAGER, BoxesMediaManagerClass))

typedef struct _BoxesMediaManager BoxesMediaManager;
typedef struct _BoxesMediaManagerClass BoxesMediaManagerClass;

#define BOXES_TYPE_OS_DATABASE (boxes_os_database_get_type ())
#define BOXES_OS_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_OS_DATABASE, BoxesOSDatabase))
#define BOXES_OS_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_OS_DATABASE, BoxesOSDatabaseClass))
#define BOXES_IS_OS_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_OS_DATABASE))
#define BOXES_IS_OS_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_OS_DATABASE))
#define BOXES_OS_DATABASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_OS_DATABASE, BoxesOSDatabaseClass))

typedef struct _BoxesOSDatabase BoxesOSDatabase;
typedef struct _BoxesOSDatabaseClass BoxesOSDatabaseClass;

#define BOXES_TYPE_OS_DATABASE_ERROR (boxes_os_database_error_get_type ())
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _BoxesOsChooserRowSetupModelData BoxesOsChooserRowSetupModelData;

#define TYPE_OS_LIST_ENTRY (os_list_entry_get_type ())
#define OS_LIST_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_OS_LIST_ENTRY, OsListEntry))
#define OS_LIST_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_OS_LIST_ENTRY, OsListEntryClass))
#define IS_OS_LIST_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_OS_LIST_ENTRY))
#define IS_OS_LIST_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_OS_LIST_ENTRY))
#define OS_LIST_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_OS_LIST_ENTRY, OsListEntryClass))

typedef struct _OsListEntry OsListEntry;
typedef struct _OsListEntryClass OsListEntryClass;
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _BoxesOsChooserRowOnSearchEntryChangedData BoxesOsChooserRowOnSearchEntryChangedData;
typedef struct _OsListEntryPrivate OsListEntryPrivate;
typedef struct _BoxesOsChooserRowOnListboxRowSelectedData BoxesOsChooserRowOnListboxRowSelectedData;
enum  {
	BOXES_OS_CHOOSER_ROW_OS_SELECTED_SIGNAL,
	BOXES_OS_CHOOSER_ROW_NUM_SIGNALS
};
static guint boxes_os_chooser_row_signals[BOXES_OS_CHOOSER_ROW_NUM_SIGNALS] = {0};
enum  {
	OS_LIST_ENTRY_0_PROPERTY,
	OS_LIST_ENTRY_SELECTED_PROPERTY,
	OS_LIST_ENTRY_NUM_PROPERTIES
};
static GParamSpec* os_list_entry_properties[OS_LIST_ENTRY_NUM_PROPERTIES];
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))

struct _BoxesOsChooserRow {
	HdyExpanderRow parent_instance;
	BoxesOsChooserRowPrivate * priv;
};

struct _BoxesOsChooserRowClass {
	HdyExpanderRowClass parent_class;
};

struct _BoxesOsChooserRowPrivate {
	GtkSearchEntry* search_entry;
	GtkImage* os_icon;
	GtkListBox* listbox;
	GListStore* model;
	GList* os_list;
	GtkListBoxRow* previous_row;
};

struct _BoxesOsChooserRowOnOsSelectedData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	BoxesOsChooserRow* self;
	OsinfoOs* os;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	GtkImage* _tmp2_;
	GtkImage* _tmp3_;
	GtkImage* _tmp4_;
	GtkImage* _tmp5_;
	gint _tmp6_;
	gint _tmp7_;
};

typedef enum  {
	BOXES_OS_DATABASE_ERROR_NON_BOOTABLE,
	BOXES_OS_DATABASE_ERROR_DB_LOADING_FAILED,
	BOXES_OS_DATABASE_ERROR_UNKNOWN_OS_ID,
	BOXES_OS_DATABASE_ERROR_UNKNOWN_MEDIA_ID
} BoxesOSDatabaseError;
#define BOXES_OS_DATABASE_ERROR boxes_os_database_error_quark ()

struct _BoxesOsChooserRowSetupModelData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	BoxesOsChooserRow* self;
	BoxesMediaManager* media_manager;
	BoxesMediaManager* _tmp0_;
	GList* _tmp1_;
	BoxesOSDatabase* _tmp2_;
	BoxesOSDatabase* _tmp3_;
	GList* _tmp4_;
	GList* _tmp5_;
	GError* _error_;
	GError* _tmp6_;
	const gchar* _tmp7_;
	GListStore* _tmp8_;
	GtkListBox* _tmp9_;
	GListStore* _tmp10_;
	GError* _inner_error0_;
};

struct _BoxesOsChooserRowOnSearchEntryChangedData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	BoxesOsChooserRow* self;
	gchar* text;
	GtkSearchEntry* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	GListStore* _tmp6_;
	GListStore* _tmp7_;
	GtkListBox* _tmp8_;
	gchar* query;
	const gchar* _tmp9_;
	gchar* _tmp10_;
	gint nresults;
	GList* _tmp11_;
	GList* entity_collection;
	GList* entity_it;
	OsinfoEntity* entity;
	OsinfoOs* os;
	OsinfoEntity* _tmp12_;
	OsinfoOs* _tmp13_;
	gchar* os_name;
	OsinfoOs* _tmp14_;
	const gchar* _tmp15_;
	gchar* _tmp16_;
	const gchar* _tmp17_;
	gchar* name;
	const gchar* _tmp18_;
	gchar* _tmp19_;
	const gchar* _tmp20_;
	const gchar* _tmp21_;
	GListStore* _tmp22_;
	OsinfoOs* _tmp23_;
};

struct _OsListEntry {
	GtkBox parent_instance;
	OsListEntryPrivate * priv;
	OsinfoOs* os;
};

struct _OsListEntryClass {
	GtkBoxClass parent_class;
};

struct _BoxesOsChooserRowOnListboxRowSelectedData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	BoxesOsChooserRow* self;
	GtkListBoxRow* row;
	GtkListBox* _tmp0_;
	GtkListBoxRow* _tmp1_;
	GtkListBoxRow* _tmp2_;
	GtkListBoxRow* _tmp3_;
	GtkListBox* _tmp4_;
	GList* _tmp5_;
	GList* widget_collection;
	GList* widget_it;
	GtkWidget* widget;
	GtkListBoxRow* entry;
	GtkWidget* _tmp6_;
	GtkListBoxRow* _tmp7_;
	OsListEntry* child;
	GtkListBoxRow* _tmp8_;
	GtkWidget* _tmp9_;
	OsListEntry* _tmp10_;
	OsListEntry* _tmp11_;
	OsListEntry* os_list_entry;
	GtkListBoxRow* _tmp12_;
	GtkWidget* _tmp13_;
	OsListEntry* _tmp14_;
	OsListEntry* _tmp15_;
	OsListEntry* _tmp16_;
	OsinfoOs* _tmp17_;
};

struct _OsListEntryPrivate {
	GtkLabel* label;
	GtkImage* image;
};

static gint BoxesOsChooserRow_private_offset;
static gpointer boxes_os_chooser_row_parent_class = NULL;
static gint OsListEntry_private_offset;
static gpointer os_list_entry_parent_class = NULL;

VALA_EXTERN GType boxes_os_chooser_row_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesOsChooserRow, g_object_unref)
static void boxes_os_chooser_row_on_os_selected_data_free (gpointer _data);
static void boxes_os_chooser_row_on_os_selected (BoxesOsChooserRow* self,
                                          OsinfoOs* os,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_);
static void boxes_os_chooser_row_on_os_selected_finish (BoxesOsChooserRow* self,
                                                 GAsyncResult* _res_);
static gboolean boxes_os_chooser_row_on_os_selected_co (BoxesOsChooserRowOnOsSelectedData* _data_);
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_);
static void boxes_os_chooser_row_on_os_selected_ready (GObject* source_object,
                                                GAsyncResult* _res_,
                                                gpointer _user_data_);
static void boxes_os_chooser_row_setup_model_data_free (gpointer _data);
static void boxes_os_chooser_row_setup_model (BoxesOsChooserRow* self,
                                       GAsyncReadyCallback _callback_,
                                       gpointer _user_data_);
static void boxes_os_chooser_row_setup_model_finish (BoxesOsChooserRow* self,
                                              GAsyncResult* _res_);
static gboolean boxes_os_chooser_row_setup_model_co (BoxesOsChooserRowSetupModelData* _data_);
VALA_EXTERN GType boxes_media_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesMediaManager, g_object_unref)
VALA_EXTERN BoxesMediaManager* boxes_media_manager_get_default (void);
VALA_EXTERN GType boxes_os_database_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesOSDatabase, g_object_unref)
VALA_EXTERN BoxesOSDatabase* boxes_media_manager_get_os_db (BoxesMediaManager* self);
VALA_EXTERN void boxes_os_database_get_all_oses_sorted_by_release_date (BoxesOSDatabase* self,
                                                            GAsyncReadyCallback _callback_,
                                                            gpointer _user_data_);
VALA_EXTERN GQuark boxes_os_database_error_quark (void);
VALA_EXTERN GType boxes_os_database_error_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GList* boxes_os_database_get_all_oses_sorted_by_release_date_finish (BoxesOSDatabase* self,
                                                                     GAsyncResult* _res_,
                                                                     GError** error);
static void boxes_os_chooser_row_setup_model_ready (GObject* source_object,
                                             GAsyncResult* _res_,
                                             gpointer _user_data_);
static GtkWidget* boxes_os_chooser_row_create_listbox_entry (BoxesOsChooserRow* self,
                                                      GObject* item);
static GtkWidget* _boxes_os_chooser_row_create_listbox_entry_gtk_list_box_create_widget_func (GObject* item,
                                                                                       gpointer self);
VALA_EXTERN OsListEntry* os_list_entry_new (OsinfoOs* os);
VALA_EXTERN OsListEntry* os_list_entry_construct (GType object_type,
                                      OsinfoOs* os);
VALA_EXTERN GType os_list_entry_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OsListEntry, g_object_unref)
static void boxes_os_chooser_row_on_search_entry_changed_data_free (gpointer _data);
static void boxes_os_chooser_row_on_search_entry_changed (BoxesOsChooserRow* self,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_);
static void boxes_os_chooser_row_on_search_entry_changed_finish (BoxesOsChooserRow* self,
                                                          GAsyncResult* _res_);
static gboolean boxes_os_chooser_row_on_search_entry_changed_co (BoxesOsChooserRowOnSearchEntryChangedData* _data_);
static void _boxes_os_chooser_row_on_search_entry_changed_gtk_search_entry_search_changed (GtkSearchEntry* _sender,
                                                                                    gpointer self);
static void boxes_os_chooser_row_on_listbox_row_activated (BoxesOsChooserRow* self,
                                                    GtkListBoxRow* row);
VALA_EXTERN void os_list_entry_set_selected (OsListEntry* self,
                                 gboolean value);
static void _boxes_os_chooser_row_on_listbox_row_activated_gtk_list_box_row_activated (GtkListBox* _sender,
                                                                                GtkListBoxRow* row,
                                                                                gpointer self);
VALA_EXTERN void boxes_os_chooser_row_select_os (BoxesOsChooserRow* self,
                                     OsinfoOs* os);
static void boxes_os_chooser_row_on_listbox_row_selected_data_free (gpointer _data);
static void boxes_os_chooser_row_on_listbox_row_selected (BoxesOsChooserRow* self,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_);
static void boxes_os_chooser_row_on_listbox_row_selected_finish (BoxesOsChooserRow* self,
                                                          GAsyncResult* _res_);
static gboolean boxes_os_chooser_row_on_listbox_row_selected_co (BoxesOsChooserRowOnListboxRowSelectedData* _data_);
static void boxes_os_chooser_row_on_listbox_row_selected_ready (GObject* source_object,
                                                         GAsyncResult* _res_,
                                                         gpointer _user_data_);
static void _boxes_os_chooser_row_on_listbox_row_selected_gtk_list_box_row_selected (GtkListBox* _sender,
                                                                              GtkListBoxRow* row,
                                                                              gpointer self);
VALA_EXTERN BoxesOsChooserRow* boxes_os_chooser_row_new (void);
VALA_EXTERN BoxesOsChooserRow* boxes_os_chooser_row_construct (GType object_type);
static GObject * boxes_os_chooser_row_constructor (GType type,
                                            guint n_construct_properties,
                                            GObjectConstructParam * construct_properties);
static void boxes_os_chooser_row_finalize (GObject * obj);
static GType boxes_os_chooser_row_get_type_once (void);
VALA_EXTERN gboolean os_list_entry_get_selected (OsListEntry* self);
static void os_list_entry_finalize (GObject * obj);
static GType os_list_entry_get_type_once (void);
static void _vala_os_list_entry_get_property (GObject * object,
                                       guint property_id,
                                       GValue * value,
                                       GParamSpec * pspec);
static void _vala_os_list_entry_set_property (GObject * object,
                                       guint property_id,
                                       const GValue * value,
                                       GParamSpec * pspec);

static inline gpointer
boxes_os_chooser_row_get_instance_private (BoxesOsChooserRow* self)
{
	return G_STRUCT_MEMBER_P (self, BoxesOsChooserRow_private_offset);
}

static void
boxes_os_chooser_row_on_os_selected_data_free (gpointer _data)
{
	BoxesOsChooserRowOnOsSelectedData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->os);
	_g_object_unref0 (_data_->self);
	g_slice_free (BoxesOsChooserRowOnOsSelectedData, _data_);
}

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

static void
boxes_os_chooser_row_on_os_selected (BoxesOsChooserRow* self,
                                     OsinfoOs* os,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_)
{
	BoxesOsChooserRowOnOsSelectedData* _data_;
	BoxesOsChooserRow* _tmp0_;
	OsinfoOs* _tmp1_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (BoxesOsChooserRowOnOsSelectedData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, boxes_os_chooser_row_on_os_selected_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (os);
	_g_object_unref0 (_data_->os);
	_data_->os = _tmp1_;
	boxes_os_chooser_row_on_os_selected_co (_data_);
}

static void
boxes_os_chooser_row_on_os_selected_finish (BoxesOsChooserRow* self,
                                            GAsyncResult* _res_)
{
	BoxesOsChooserRowOnOsSelectedData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
boxes_os_chooser_row_on_os_selected_ready (GObject* source_object,
                                           GAsyncResult* _res_,
                                           gpointer _user_data_)
{
	BoxesOsChooserRowOnOsSelectedData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	boxes_os_chooser_row_on_os_selected_co (_data_);
}

static gboolean
boxes_os_chooser_row_on_os_selected_co (BoxesOsChooserRowOnOsSelectedData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	hdy_expander_row_set_expanded ((HdyExpanderRow*) _data_->self, FALSE);
	_data_->_tmp0_ = osinfo_product_get_name ((OsinfoProduct*) _data_->os);
	hdy_preferences_row_set_title ((HdyPreferencesRow*) _data_->self, _data_->_tmp0_);
	_data_->_tmp1_ = osinfo_product_get_vendor ((OsinfoProduct*) _data_->os);
	hdy_expander_row_set_subtitle ((HdyExpanderRow*) _data_->self, _data_->_tmp1_);
	_data_->_tmp2_ = _data_->self->priv->os_icon;
	g_object_set (_data_->_tmp2_, "icon-name", "media-optical-symbolic", NULL);
	_data_->_tmp3_ = _data_->self->priv->os_icon;
	gtk_image_set_pixel_size (_data_->_tmp3_, 32);
	_data_->_tmp4_ = _data_->self->priv->os_icon;
	_data_->_tmp5_ = _data_->self->priv->os_icon;
	_data_->_tmp6_ = gtk_image_get_pixel_size (_data_->_tmp5_);
	_data_->_tmp7_ = _data_->_tmp6_;
	_data_->_state_ = 1;
	boxes_downloader_fetch_os_logo (_data_->_tmp4_, _data_->os, _data_->_tmp7_, boxes_os_chooser_row_on_os_selected_ready, _data_);
	return FALSE;
	_state_1:
	boxes_downloader_fetch_os_logo_finish (_data_->_res_);
	g_signal_emit (_data_->self, boxes_os_chooser_row_signals[BOXES_OS_CHOOSER_ROW_OS_SELECTED_SIGNAL], 0, _data_->os);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
boxes_os_chooser_row_setup_model_data_free (gpointer _data)
{
	BoxesOsChooserRowSetupModelData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (BoxesOsChooserRowSetupModelData, _data_);
}

static void
boxes_os_chooser_row_setup_model (BoxesOsChooserRow* self,
                                  GAsyncReadyCallback _callback_,
                                  gpointer _user_data_)
{
	BoxesOsChooserRowSetupModelData* _data_;
	BoxesOsChooserRow* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (BoxesOsChooserRowSetupModelData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, boxes_os_chooser_row_setup_model_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	boxes_os_chooser_row_setup_model_co (_data_);
}

static void
boxes_os_chooser_row_setup_model_finish (BoxesOsChooserRow* self,
                                         GAsyncResult* _res_)
{
	BoxesOsChooserRowSetupModelData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
boxes_os_chooser_row_setup_model_ready (GObject* source_object,
                                        GAsyncResult* _res_,
                                        gpointer _user_data_)
{
	BoxesOsChooserRowSetupModelData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	boxes_os_chooser_row_setup_model_co (_data_);
}

static GtkWidget*
_boxes_os_chooser_row_create_listbox_entry_gtk_list_box_create_widget_func (GObject* item,
                                                                            gpointer self)
{
	GtkWidget* result;
	result = boxes_os_chooser_row_create_listbox_entry ((BoxesOsChooserRow*) self, item);
	return result;
}

static gboolean
boxes_os_chooser_row_setup_model_co (BoxesOsChooserRowSetupModelData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->_tmp0_ = boxes_media_manager_get_default ();
		_data_->media_manager = _data_->_tmp0_;
		_data_->_tmp2_ = boxes_media_manager_get_os_db (_data_->media_manager);
		_data_->_tmp3_ = _data_->_tmp2_;
		_data_->_state_ = 1;
		boxes_os_database_get_all_oses_sorted_by_release_date (_data_->_tmp3_, boxes_os_chooser_row_setup_model_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp4_ = boxes_os_database_get_all_oses_sorted_by_release_date_finish (_data_->_tmp3_, _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp1_ = _data_->_tmp4_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_object_unref0 (_data_->media_manager);
			goto __catch0_g_error;
		}
		_data_->_tmp5_ = _data_->_tmp1_;
		_data_->_tmp1_ = NULL;
		(_data_->self->priv->os_list == NULL) ? NULL : (_data_->self->priv->os_list = (g_list_free (_data_->self->priv->os_list), NULL));
		_data_->self->priv->os_list = _data_->_tmp5_;
		(_data_->_tmp1_ == NULL) ? NULL : (_data_->_tmp1_ = (g_list_free (_data_->_tmp1_), NULL));
		_g_object_unref0 (_data_->media_manager);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->_error_ = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp6_ = _data_->_error_;
		_data_->_tmp7_ = _data_->_tmp6_->message;
		g_warning ("os-chooser-row.vala:42: Failed to load OS list: %s", _data_->_tmp7_);
		_g_error_free0 (_data_->_error_);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp8_ = g_list_store_new (osinfo_os_get_type ());
	_g_object_unref0 (_data_->self->priv->model);
	_data_->self->priv->model = _data_->_tmp8_;
	_data_->_tmp9_ = _data_->self->priv->listbox;
	_data_->_tmp10_ = _data_->self->priv->model;
	gtk_list_box_bind_model (_data_->_tmp9_, (GListModel*) _data_->_tmp10_, _boxes_os_chooser_row_create_listbox_entry_gtk_list_box_create_widget_func, g_object_ref (_data_->self), g_object_unref);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static GtkWidget*
boxes_os_chooser_row_create_listbox_entry (BoxesOsChooserRow* self,
                                           GObject* item)
{
	OsinfoOs* os_item = NULL;
	OsinfoOs* _tmp0_;
	OsListEntry* _tmp1_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (item != NULL, NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (item, osinfo_os_get_type ()) ? ((OsinfoOs*) item) : NULL);
	os_item = _tmp0_;
	_tmp1_ = os_list_entry_new (os_item);
	g_object_ref_sink (_tmp1_);
	result = (GtkWidget*) _tmp1_;
	_g_object_unref0 (os_item);
	return result;
}

static void
boxes_os_chooser_row_on_search_entry_changed_data_free (gpointer _data)
{
	BoxesOsChooserRowOnSearchEntryChangedData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (BoxesOsChooserRowOnSearchEntryChangedData, _data_);
}

static void
boxes_os_chooser_row_on_search_entry_changed (BoxesOsChooserRow* self,
                                              GAsyncReadyCallback _callback_,
                                              gpointer _user_data_)
{
	BoxesOsChooserRowOnSearchEntryChangedData* _data_;
	BoxesOsChooserRow* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (BoxesOsChooserRowOnSearchEntryChangedData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, boxes_os_chooser_row_on_search_entry_changed_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	boxes_os_chooser_row_on_search_entry_changed_co (_data_);
}

static void
boxes_os_chooser_row_on_search_entry_changed_finish (BoxesOsChooserRow* self,
                                                     GAsyncResult* _res_)
{
	BoxesOsChooserRowOnSearchEntryChangedData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static gboolean
string_contains (const gchar* self,
                 const gchar* needle)
{
	gchar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (needle != NULL, FALSE);
	_tmp0_ = strstr ((gchar*) self, (gchar*) needle);
	result = _tmp0_ != NULL;
	return result;
}

static gboolean
boxes_os_chooser_row_on_search_entry_changed_co (BoxesOsChooserRowOnSearchEntryChangedData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->search_entry;
	_data_->_tmp1_ = gtk_entry_get_text ((GtkEntry*) _data_->_tmp0_);
	_data_->_tmp2_ = g_strdup (_data_->_tmp1_);
	_data_->text = _data_->_tmp2_;
	_data_->_tmp3_ = _data_->text;
	_data_->_tmp4_ = strlen (_data_->_tmp3_);
	_data_->_tmp5_ = _data_->_tmp4_;
	if (_data_->_tmp5_ == 0) {
		_data_->_tmp6_ = _data_->self->priv->model;
		g_list_store_remove_all (_data_->_tmp6_);
		_g_free0 (_data_->text);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	} else {
		_data_->_tmp7_ = _data_->self->priv->model;
		g_list_store_remove_all (_data_->_tmp7_);
	}
	_data_->_tmp8_ = _data_->self->priv->listbox;
	gtk_list_box_select_row (_data_->_tmp8_, NULL);
	_data_->_tmp9_ = _data_->text;
	_data_->_tmp10_ = boxes_canonicalize_for_search (_data_->_tmp9_);
	_data_->query = _data_->_tmp10_;
	_data_->nresults = 6;
	_data_->_tmp11_ = _data_->self->priv->os_list;
	{
		_data_->entity_collection = _data_->_tmp11_;
		for (_data_->entity_it = _data_->entity_collection; _data_->entity_it != NULL; _data_->entity_it = _data_->entity_it->next) {
			_data_->entity = (OsinfoEntity*) _data_->entity_it->data;
			{
				if (_data_->nresults == 0) {
					_g_free0 (_data_->query);
					_g_free0 (_data_->text);
					g_task_return_pointer (_data_->_async_result, _data_, NULL);
					if (_data_->_state_ != 0) {
						while (!g_task_get_completed (_data_->_async_result)) {
							g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
						}
					}
					g_object_unref (_data_->_async_result);
					return FALSE;
				}
				_data_->_tmp12_ = _data_->entity;
				_data_->_tmp13_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_data_->_tmp12_, osinfo_os_get_type ()) ? ((OsinfoOs*) _data_->_tmp12_) : NULL);
				_data_->os = _data_->_tmp13_;
				_data_->_tmp14_ = _data_->os;
				_data_->_tmp15_ = osinfo_product_get_name ((OsinfoProduct*) _data_->_tmp14_);
				_data_->_tmp16_ = g_strdup (_data_->_tmp15_);
				_data_->os_name = _data_->_tmp16_;
				_data_->_tmp17_ = _data_->os_name;
				if (_data_->_tmp17_ == NULL) {
					_g_free0 (_data_->os_name);
					_g_object_unref0 (_data_->os);
					continue;
				}
				_data_->_tmp18_ = _data_->os_name;
				_data_->_tmp19_ = boxes_canonicalize_for_search (_data_->_tmp18_);
				_data_->name = _data_->_tmp19_;
				_data_->_tmp20_ = _data_->name;
				_data_->_tmp21_ = _data_->query;
				if (string_contains (_data_->_tmp20_, _data_->_tmp21_)) {
					_data_->_tmp22_ = _data_->self->priv->model;
					_data_->_tmp23_ = _data_->os;
					g_list_store_append (_data_->_tmp22_, (GObject*) _data_->_tmp23_);
					_data_->nresults -= 1;
				}
				_g_free0 (_data_->name);
				_g_free0 (_data_->os_name);
				_g_object_unref0 (_data_->os);
			}
		}
	}
	_g_free0 (_data_->query);
	_g_free0 (_data_->text);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
_boxes_os_chooser_row_on_search_entry_changed_gtk_search_entry_search_changed (GtkSearchEntry* _sender,
                                                                               gpointer self)
{
	boxes_os_chooser_row_on_search_entry_changed ((BoxesOsChooserRow*) self, NULL, NULL);
}

static void
boxes_os_chooser_row_on_listbox_row_activated (BoxesOsChooserRow* self,
                                               GtkListBoxRow* row)
{
	GtkListBoxRow* _tmp0_;
	GtkListBox* _tmp2_;
	OsListEntry* child = NULL;
	GtkWidget* _tmp3_;
	OsListEntry* _tmp4_;
	OsListEntry* _tmp5_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (row != NULL);
	_tmp0_ = self->priv->previous_row;
	if (row != _tmp0_) {
		GtkListBoxRow* _tmp1_;
		_tmp1_ = _g_object_ref0 (row);
		_g_object_unref0 (self->priv->previous_row);
		self->priv->previous_row = _tmp1_;
		return;
	}
	_tmp2_ = self->priv->listbox;
	gtk_list_box_unselect_row (_tmp2_, row);
	_g_object_unref0 (self->priv->previous_row);
	self->priv->previous_row = NULL;
	_tmp3_ = gtk_bin_get_child ((GtkBin*) row);
	_tmp4_ = _g_object_ref0 (IS_OS_LIST_ENTRY (_tmp3_) ? ((OsListEntry*) _tmp3_) : NULL);
	child = _tmp4_;
	_tmp5_ = child;
	os_list_entry_set_selected (_tmp5_, FALSE);
	g_signal_emit (self, boxes_os_chooser_row_signals[BOXES_OS_CHOOSER_ROW_OS_SELECTED_SIGNAL], 0, NULL);
	_g_object_unref0 (child);
}

static void
_boxes_os_chooser_row_on_listbox_row_activated_gtk_list_box_row_activated (GtkListBox* _sender,
                                                                           GtkListBoxRow* row,
                                                                           gpointer self)
{
	boxes_os_chooser_row_on_listbox_row_activated ((BoxesOsChooserRow*) self, row);
}

void
boxes_os_chooser_row_select_os (BoxesOsChooserRow* self,
                                OsinfoOs* os)
{
	GtkListBox* _tmp0_;
	GList* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (os != NULL);
	_tmp0_ = self->priv->listbox;
	_tmp1_ = gtk_container_get_children ((GtkContainer*) _tmp0_);
	{
		GList* widget_collection = NULL;
		GList* widget_it = NULL;
		widget_collection = _tmp1_;
		for (widget_it = widget_collection; widget_it != NULL; widget_it = widget_it->next) {
			GtkWidget* widget = NULL;
			widget = (GtkWidget*) widget_it->data;
			{
				GtkListBoxRow* entry = NULL;
				GtkWidget* _tmp2_;
				GtkListBoxRow* _tmp3_;
				OsListEntry* child = NULL;
				GtkListBoxRow* _tmp4_;
				GtkWidget* _tmp5_;
				OsListEntry* _tmp6_;
				OsListEntry* _tmp7_;
				OsListEntry* _tmp8_;
				OsinfoOs* _tmp9_;
				gchar* _tmp10_;
				gchar* _tmp11_;
				gchar* _tmp12_;
				gchar* _tmp13_;
				gchar* _tmp14_;
				gchar* _tmp15_;
				_tmp2_ = widget;
				_tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp2_, gtk_list_box_row_get_type ()) ? ((GtkListBoxRow*) _tmp2_) : NULL);
				entry = _tmp3_;
				_tmp4_ = entry;
				_tmp5_ = gtk_bin_get_child ((GtkBin*) _tmp4_);
				_tmp6_ = _g_object_ref0 (IS_OS_LIST_ENTRY (_tmp5_) ? ((OsListEntry*) _tmp5_) : NULL);
				child = _tmp6_;
				_tmp7_ = child;
				_tmp8_ = child;
				_tmp9_ = _tmp8_->os;
				g_object_get ((OsinfoEntity*) _tmp9_, "id", &_tmp10_, NULL);
				_tmp11_ = _tmp10_;
				_tmp12_ = _tmp11_;
				g_object_get ((OsinfoEntity*) os, "id", &_tmp13_, NULL);
				_tmp14_ = _tmp13_;
				_tmp15_ = _tmp14_;
				os_list_entry_set_selected (_tmp7_, g_strcmp0 (_tmp12_, _tmp15_) == 0);
				_g_free0 (_tmp15_);
				_g_free0 (_tmp12_);
				_g_object_unref0 (child);
				_g_object_unref0 (entry);
			}
		}
		(widget_collection == NULL) ? NULL : (widget_collection = (g_list_free (widget_collection), NULL));
	}
	boxes_os_chooser_row_on_os_selected (self, os, NULL, NULL);
}

static void
boxes_os_chooser_row_on_listbox_row_selected_data_free (gpointer _data)
{
	BoxesOsChooserRowOnListboxRowSelectedData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (BoxesOsChooserRowOnListboxRowSelectedData, _data_);
}

static void
boxes_os_chooser_row_on_listbox_row_selected (BoxesOsChooserRow* self,
                                              GAsyncReadyCallback _callback_,
                                              gpointer _user_data_)
{
	BoxesOsChooserRowOnListboxRowSelectedData* _data_;
	BoxesOsChooserRow* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (BoxesOsChooserRowOnListboxRowSelectedData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, boxes_os_chooser_row_on_listbox_row_selected_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	boxes_os_chooser_row_on_listbox_row_selected_co (_data_);
}

static void
boxes_os_chooser_row_on_listbox_row_selected_finish (BoxesOsChooserRow* self,
                                                     GAsyncResult* _res_)
{
	BoxesOsChooserRowOnListboxRowSelectedData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
boxes_os_chooser_row_on_listbox_row_selected_ready (GObject* source_object,
                                                    GAsyncResult* _res_,
                                                    gpointer _user_data_)
{
	BoxesOsChooserRowOnListboxRowSelectedData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	boxes_os_chooser_row_on_listbox_row_selected_co (_data_);
}

static gboolean
boxes_os_chooser_row_on_listbox_row_selected_co (BoxesOsChooserRowOnListboxRowSelectedData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->listbox;
	_data_->_tmp1_ = gtk_list_box_get_selected_row (_data_->_tmp0_);
	_data_->_tmp2_ = _g_object_ref0 (_data_->_tmp1_);
	_data_->row = _data_->_tmp2_;
	_data_->_tmp3_ = _data_->row;
	if (_data_->_tmp3_ == NULL) {
		_g_object_unref0 (_data_->row);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp4_ = _data_->self->priv->listbox;
	_data_->_tmp5_ = gtk_container_get_children ((GtkContainer*) _data_->_tmp4_);
	{
		_data_->widget_collection = _data_->_tmp5_;
		for (_data_->widget_it = _data_->widget_collection; _data_->widget_it != NULL; _data_->widget_it = _data_->widget_it->next) {
			_data_->widget = (GtkWidget*) _data_->widget_it->data;
			{
				_data_->_tmp6_ = _data_->widget;
				_data_->_tmp7_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_data_->_tmp6_, gtk_list_box_row_get_type ()) ? ((GtkListBoxRow*) _data_->_tmp6_) : NULL);
				_data_->entry = _data_->_tmp7_;
				_data_->_tmp8_ = _data_->entry;
				_data_->_tmp9_ = gtk_bin_get_child ((GtkBin*) _data_->_tmp8_);
				_data_->_tmp10_ = _g_object_ref0 (IS_OS_LIST_ENTRY (_data_->_tmp9_) ? ((OsListEntry*) _data_->_tmp9_) : NULL);
				_data_->child = _data_->_tmp10_;
				_data_->_tmp11_ = _data_->child;
				os_list_entry_set_selected (_data_->_tmp11_, FALSE);
				_g_object_unref0 (_data_->child);
				_g_object_unref0 (_data_->entry);
			}
		}
		(_data_->widget_collection == NULL) ? NULL : (_data_->widget_collection = (g_list_free (_data_->widget_collection), NULL));
	}
	_data_->_tmp12_ = _data_->row;
	_data_->_tmp13_ = gtk_bin_get_child ((GtkBin*) _data_->_tmp12_);
	_data_->_tmp14_ = _g_object_ref0 (IS_OS_LIST_ENTRY (_data_->_tmp13_) ? ((OsListEntry*) _data_->_tmp13_) : NULL);
	_data_->os_list_entry = _data_->_tmp14_;
	_data_->_tmp15_ = _data_->os_list_entry;
	os_list_entry_set_selected (_data_->_tmp15_, TRUE);
	_data_->_tmp16_ = _data_->os_list_entry;
	_data_->_tmp17_ = _data_->_tmp16_->os;
	_data_->_state_ = 1;
	boxes_os_chooser_row_on_os_selected (_data_->self, _data_->_tmp17_, boxes_os_chooser_row_on_listbox_row_selected_ready, _data_);
	return FALSE;
	_state_1:
	boxes_os_chooser_row_on_os_selected_finish (_data_->self, _data_->_res_);
	_g_object_unref0 (_data_->os_list_entry);
	_g_object_unref0 (_data_->row);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
_boxes_os_chooser_row_on_listbox_row_selected_gtk_list_box_row_selected (GtkListBox* _sender,
                                                                         GtkListBoxRow* row,
                                                                         gpointer self)
{
	boxes_os_chooser_row_on_listbox_row_selected ((BoxesOsChooserRow*) self, NULL, NULL);
}

BoxesOsChooserRow*
boxes_os_chooser_row_construct (GType object_type)
{
	BoxesOsChooserRow * self = NULL;
	self = (BoxesOsChooserRow*) g_object_new (object_type, NULL);
	return self;
}

BoxesOsChooserRow*
boxes_os_chooser_row_new (void)
{
	return boxes_os_chooser_row_construct (BOXES_TYPE_OS_CHOOSER_ROW);
}

static GObject *
boxes_os_chooser_row_constructor (GType type,
                                  guint n_construct_properties,
                                  GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	BoxesOsChooserRow * self;
	parent_class = G_OBJECT_CLASS (boxes_os_chooser_row_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BOXES_TYPE_OS_CHOOSER_ROW, BoxesOsChooserRow);
	boxes_os_chooser_row_setup_model (self, NULL, NULL);
	return obj;
}

static void
boxes_os_chooser_row_class_init (BoxesOsChooserRowClass * klass,
                                 gpointer klass_data)
{
	boxes_os_chooser_row_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BoxesOsChooserRow_private_offset);
	G_OBJECT_CLASS (klass)->constructor = boxes_os_chooser_row_constructor;
	G_OBJECT_CLASS (klass)->finalize = boxes_os_chooser_row_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Boxes/ui/assistant/os-chooser-row.ui");
	boxes_os_chooser_row_signals[BOXES_OS_CHOOSER_ROW_OS_SELECTED_SIGNAL] = g_signal_new ("os-selected", BOXES_TYPE_OS_CHOOSER_ROW, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, osinfo_os_get_type ());
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "search_entry", FALSE, BoxesOsChooserRow_private_offset + G_STRUCT_OFFSET (BoxesOsChooserRowPrivate, search_entry));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "os_icon", FALSE, BoxesOsChooserRow_private_offset + G_STRUCT_OFFSET (BoxesOsChooserRowPrivate, os_icon));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "listbox", FALSE, BoxesOsChooserRow_private_offset + G_STRUCT_OFFSET (BoxesOsChooserRowPrivate, listbox));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_search_entry_changed", G_CALLBACK(_boxes_os_chooser_row_on_search_entry_changed_gtk_search_entry_search_changed));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_listbox_row_activated", G_CALLBACK(_boxes_os_chooser_row_on_listbox_row_activated_gtk_list_box_row_activated));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_listbox_row_selected", G_CALLBACK(_boxes_os_chooser_row_on_listbox_row_selected_gtk_list_box_row_selected));
}

static void
boxes_os_chooser_row_instance_init (BoxesOsChooserRow * self,
                                    gpointer klass)
{
	self->priv = boxes_os_chooser_row_get_instance_private (self);
	self->priv->previous_row = NULL;
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
boxes_os_chooser_row_finalize (GObject * obj)
{
	BoxesOsChooserRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BOXES_TYPE_OS_CHOOSER_ROW, BoxesOsChooserRow);
	_g_object_unref0 (self->priv->model);
	(self->priv->os_list == NULL) ? NULL : (self->priv->os_list = (g_list_free (self->priv->os_list), NULL));
	_g_object_unref0 (self->priv->previous_row);
	G_OBJECT_CLASS (boxes_os_chooser_row_parent_class)->finalize (obj);
}

static GType
boxes_os_chooser_row_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BoxesOsChooserRowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) boxes_os_chooser_row_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BoxesOsChooserRow), 0, (GInstanceInitFunc) boxes_os_chooser_row_instance_init, NULL };
	GType boxes_os_chooser_row_type_id;
	boxes_os_chooser_row_type_id = g_type_register_static (hdy_expander_row_get_type (), "BoxesOsChooserRow", &g_define_type_info, 0);
	BoxesOsChooserRow_private_offset = g_type_add_instance_private (boxes_os_chooser_row_type_id, sizeof (BoxesOsChooserRowPrivate));
	return boxes_os_chooser_row_type_id;
}

GType
boxes_os_chooser_row_get_type (void)
{
	static volatile gsize boxes_os_chooser_row_type_id__once = 0;
	if (g_once_init_enter (&boxes_os_chooser_row_type_id__once)) {
		GType boxes_os_chooser_row_type_id;
		boxes_os_chooser_row_type_id = boxes_os_chooser_row_get_type_once ();
		g_once_init_leave (&boxes_os_chooser_row_type_id__once, boxes_os_chooser_row_type_id);
	}
	return boxes_os_chooser_row_type_id__once;
}

static inline gpointer
os_list_entry_get_instance_private (OsListEntry* self)
{
	return G_STRUCT_MEMBER_P (self, OsListEntry_private_offset);
}

static gchar*
string_replace (const gchar* self,
                const gchar* old,
                const gchar* replacement)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	if ((*((gchar*) self)) == '\0') {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = (*((gchar*) old)) == '\0';
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = g_strcmp0 (old, replacement) == 0;
	}
	if (_tmp0_) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup (self);
		result = _tmp2_;
		return result;
	}
	{
		GRegex* regex = NULL;
		gchar* _tmp3_;
		gchar* _tmp4_;
		GRegex* _tmp5_;
		GRegex* _tmp6_;
		gchar* _tmp7_ = NULL;
		GRegex* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp3_ = g_regex_escape_string (old, -1);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_regex_new (_tmp4_, 0, 0, &_inner_error0_);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		regex = _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp8_ = regex;
		_tmp9_ = g_regex_replace_literal (_tmp8_, self, (gssize) -1, 0, replacement, 0, &_inner_error0_);
		_tmp7_ = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_regex_unref0 (regex);
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp10_ = _tmp7_;
		_tmp7_ = NULL;
		result = _tmp10_;
		_g_free0 (_tmp7_);
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return NULL;
}

OsListEntry*
os_list_entry_construct (GType object_type,
                         OsinfoOs* os)
{
	OsListEntry * self = NULL;
	OsinfoOs* _tmp0_;
	gchar* os_name = NULL;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	GtkLabel* _tmp8_;
	GtkImage* _tmp9_;
	GtkImage* _tmp10_;
	g_return_val_if_fail (os != NULL, NULL);
	self = (OsListEntry*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (os);
	_g_object_unref0 (self->os);
	self->os = _tmp0_;
	_tmp1_ = osinfo_product_get_name ((OsinfoProduct*) os);
	_tmp2_ = g_strdup (_tmp1_);
	os_name = _tmp2_;
	_tmp3_ = os_name;
	if (_tmp3_ != NULL) {
		GtkLabel* _tmp4_;
		const gchar* _tmp5_;
		gchar* _tmp6_;
		gchar* _tmp7_;
		_tmp4_ = self->priv->label;
		_tmp5_ = os_name;
		_tmp6_ = string_replace (_tmp5_, "Unknown", "");
		_tmp7_ = _tmp6_;
		gtk_label_set_label (_tmp4_, _tmp7_);
		_g_free0 (_tmp7_);
		gtk_widget_set_visible ((GtkWidget*) self, TRUE);
	}
	_tmp8_ = self->priv->label;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp8_);
	_tmp9_ = self->priv->image;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp9_);
	_tmp10_ = self->priv->image;
	gtk_widget_set_visible ((GtkWidget*) _tmp10_, FALSE);
	_g_free0 (os_name);
	return self;
}

OsListEntry*
os_list_entry_new (OsinfoOs* os)
{
	return os_list_entry_construct (TYPE_OS_LIST_ENTRY, os);
}

gboolean
os_list_entry_get_selected (OsListEntry* self)
{
	gboolean result;
	GtkImage* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->image;
	_tmp1_ = gtk_widget_get_visible ((GtkWidget*) _tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

void
os_list_entry_set_selected (OsListEntry* self,
                            gboolean value)
{
	GtkImage* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->image;
	gtk_widget_set_visible ((GtkWidget*) _tmp0_, value);
	g_object_notify_by_pspec ((GObject *) self, os_list_entry_properties[OS_LIST_ENTRY_SELECTED_PROPERTY]);
}

static void
os_list_entry_class_init (OsListEntryClass * klass,
                          gpointer klass_data)
{
	os_list_entry_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &OsListEntry_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_os_list_entry_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_os_list_entry_set_property;
	G_OBJECT_CLASS (klass)->finalize = os_list_entry_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), OS_LIST_ENTRY_SELECTED_PROPERTY, os_list_entry_properties[OS_LIST_ENTRY_SELECTED_PROPERTY] = g_param_spec_boolean ("selected", "selected", "selected", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
os_list_entry_instance_init (OsListEntry * self,
                             gpointer klass)
{
	GtkLabel* _tmp0_ = NULL;
	GtkImage* _tmp1_;
	self->priv = os_list_entry_get_instance_private (self);
	_tmp0_ = (GtkLabel*) gtk_label_new (NULL);
	g_object_set ((GtkWidget*) _tmp0_, "margin", 5, NULL);
	gtk_widget_set_halign ((GtkWidget*) _tmp0_, GTK_ALIGN_START);
	gtk_label_set_xalign (_tmp0_, (gfloat) 0);
	gtk_widget_set_visible ((GtkWidget*) _tmp0_, TRUE);
	g_object_ref_sink (_tmp0_);
	self->priv->label = _tmp0_;
	_tmp1_ = (GtkImage*) gtk_image_new_from_icon_name ("object-select-symbolic", (GtkIconSize) GTK_ICON_SIZE_MENU);
	g_object_ref_sink (_tmp1_);
	self->priv->image = _tmp1_;
}

static void
os_list_entry_finalize (GObject * obj)
{
	OsListEntry * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_OS_LIST_ENTRY, OsListEntry);
	_g_object_unref0 (self->os);
	_g_object_unref0 (self->priv->label);
	_g_object_unref0 (self->priv->image);
	G_OBJECT_CLASS (os_list_entry_parent_class)->finalize (obj);
}

static GType
os_list_entry_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (OsListEntryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) os_list_entry_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (OsListEntry), 0, (GInstanceInitFunc) os_list_entry_instance_init, NULL };
	GType os_list_entry_type_id;
	os_list_entry_type_id = g_type_register_static (gtk_box_get_type (), "OsListEntry", &g_define_type_info, 0);
	OsListEntry_private_offset = g_type_add_instance_private (os_list_entry_type_id, sizeof (OsListEntryPrivate));
	return os_list_entry_type_id;
}

GType
os_list_entry_get_type (void)
{
	static volatile gsize os_list_entry_type_id__once = 0;
	if (g_once_init_enter (&os_list_entry_type_id__once)) {
		GType os_list_entry_type_id;
		os_list_entry_type_id = os_list_entry_get_type_once ();
		g_once_init_leave (&os_list_entry_type_id__once, os_list_entry_type_id);
	}
	return os_list_entry_type_id__once;
}

static void
_vala_os_list_entry_get_property (GObject * object,
                                  guint property_id,
                                  GValue * value,
                                  GParamSpec * pspec)
{
	OsListEntry * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_OS_LIST_ENTRY, OsListEntry);
	switch (property_id) {
		case OS_LIST_ENTRY_SELECTED_PROPERTY:
		g_value_set_boolean (value, os_list_entry_get_selected (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_os_list_entry_set_property (GObject * object,
                                  guint property_id,
                                  const GValue * value,
                                  GParamSpec * pspec)
{
	OsListEntry * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_OS_LIST_ENTRY, OsListEntry);
	switch (property_id) {
		case OS_LIST_ENTRY_SELECTED_PROPERTY:
		os_list_entry_set_selected (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

