/* list-view-row.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from list-view-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 <glib.h>
#include <stdlib.h>
#include <string.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 BOXES_TYPE_LIST_VIEW_ROW (boxes_list_view_row_get_type ())
#define BOXES_LIST_VIEW_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_LIST_VIEW_ROW, BoxesListViewRow))
#define BOXES_LIST_VIEW_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_LIST_VIEW_ROW, BoxesListViewRowClass))
#define BOXES_IS_LIST_VIEW_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_LIST_VIEW_ROW))
#define BOXES_IS_LIST_VIEW_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_LIST_VIEW_ROW))
#define BOXES_LIST_VIEW_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_LIST_VIEW_ROW, BoxesListViewRowClass))

typedef struct _BoxesListViewRow BoxesListViewRow;
typedef struct _BoxesListViewRowClass BoxesListViewRowClass;
typedef struct _BoxesListViewRowPrivate BoxesListViewRowPrivate;

#define BOXES_TYPE_THUMBNAIL (boxes_thumbnail_get_type ())
#define BOXES_THUMBNAIL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_THUMBNAIL, BoxesThumbnail))
#define BOXES_THUMBNAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_THUMBNAIL, BoxesThumbnailClass))
#define BOXES_IS_THUMBNAIL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_THUMBNAIL))
#define BOXES_IS_THUMBNAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_THUMBNAIL))
#define BOXES_THUMBNAIL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_THUMBNAIL, BoxesThumbnailClass))

typedef struct _BoxesThumbnail BoxesThumbnail;
typedef struct _BoxesThumbnailClass BoxesThumbnailClass;

#define BOXES_TYPE_COLLECTION_ITEM (boxes_collection_item_get_type ())
#define BOXES_COLLECTION_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_COLLECTION_ITEM, BoxesCollectionItem))
#define BOXES_COLLECTION_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_COLLECTION_ITEM, BoxesCollectionItemClass))
#define BOXES_IS_COLLECTION_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_COLLECTION_ITEM))
#define BOXES_IS_COLLECTION_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_COLLECTION_ITEM))
#define BOXES_COLLECTION_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_COLLECTION_ITEM, BoxesCollectionItemClass))

typedef struct _BoxesCollectionItem BoxesCollectionItem;
typedef struct _BoxesCollectionItemClass BoxesCollectionItemClass;
enum  {
	BOXES_LIST_VIEW_ROW_0_PROPERTY,
	BOXES_LIST_VIEW_ROW_ITEM_PROPERTY,
	BOXES_LIST_VIEW_ROW_NUM_PROPERTIES
};
static GParamSpec* boxes_list_view_row_properties[BOXES_LIST_VIEW_ROW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define BOXES_TYPE_MACHINE (boxes_machine_get_type ())
#define BOXES_MACHINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_MACHINE, BoxesMachine))
#define BOXES_MACHINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_MACHINE, BoxesMachineClass))
#define BOXES_IS_MACHINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_MACHINE))
#define BOXES_IS_MACHINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_MACHINE))
#define BOXES_MACHINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_MACHINE, BoxesMachineClass))

typedef struct _BoxesMachine BoxesMachine;
typedef struct _BoxesMachineClass BoxesMachineClass;
enum  {
	BOXES_LIST_VIEW_ROW_POP_CONTEXT_MENU_SIGNAL,
	BOXES_LIST_VIEW_ROW_NUM_SIGNALS
};
static guint boxes_list_view_row_signals[BOXES_LIST_VIEW_ROW_NUM_SIGNALS] = {0};

struct _BoxesListViewRow {
	HdyActionRow parent_instance;
	BoxesListViewRowPrivate * priv;
	BoxesThumbnail* thumbnail;
	GtkButton* menu_button;
};

struct _BoxesListViewRowClass {
	HdyActionRowClass parent_class;
};

struct _BoxesListViewRowPrivate {
	BoxesCollectionItem* _item;
};

static gint BoxesListViewRow_private_offset;
static gpointer boxes_list_view_row_parent_class = NULL;

VALA_EXTERN GType boxes_list_view_row_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesListViewRow, g_object_unref)
VALA_EXTERN GType boxes_thumbnail_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesThumbnail, g_object_unref)
VALA_EXTERN GType boxes_collection_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesCollectionItem, g_object_unref)
VALA_EXTERN BoxesListViewRow* boxes_list_view_row_new (BoxesCollectionItem* item);
VALA_EXTERN BoxesListViewRow* boxes_list_view_row_construct (GType object_type,
                                                 BoxesCollectionItem* item);
static void boxes_list_view_row_set_item (BoxesListViewRow* self,
                                   BoxesCollectionItem* value);
static void boxes_list_view_row_update_status (BoxesListViewRow* self);
VALA_EXTERN GType boxes_machine_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesMachine, g_object_unref)
static BoxesMachine* boxes_list_view_row_get_machine (BoxesListViewRow* self);
static void _boxes_list_view_row_update_status_g_object_notify (GObject* _sender,
                                                         GParamSpec* pspec,
                                                         gpointer self);
static void boxes_list_view_row_update_thumbnail (BoxesListViewRow* self);
static void _boxes_list_view_row_update_thumbnail_g_object_notify (GObject* _sender,
                                                            GParamSpec* pspec,
                                                            gpointer self);
VALA_EXTERN void boxes_thumbnail_update (BoxesThumbnail* self,
                             BoxesMachine* machine);
VALA_EXTERN const gchar* boxes_machine_get_status (BoxesMachine* self);
VALA_EXTERN gboolean boxes_machine_get_is_running (BoxesMachine* self);
VALA_EXTERN gboolean boxes_machine_get_is_on (BoxesMachine* self);
VALA_EXTERN void boxes_list_view_row_pop_menu (BoxesListViewRow* self);
static void _boxes_list_view_row_pop_menu_gtk_button_clicked (GtkButton* _sender,
                                                       gpointer self);
VALA_EXTERN BoxesCollectionItem* boxes_list_view_row_get_item (BoxesListViewRow* self);
static void boxes_list_view_row_finalize (GObject * obj);
static GType boxes_list_view_row_get_type_once (void);
static void _vala_boxes_list_view_row_get_property (GObject * object,
                                             guint property_id,
                                             GValue * value,
                                             GParamSpec * pspec);
static void _vala_boxes_list_view_row_set_property (GObject * object,
                                             guint property_id,
                                             const GValue * value,
                                             GParamSpec * pspec);

static inline gpointer
boxes_list_view_row_get_instance_private (BoxesListViewRow* self)
{
	return G_STRUCT_MEMBER_P (self, BoxesListViewRow_private_offset);
}

static void
_boxes_list_view_row_update_status_g_object_notify (GObject* _sender,
                                                    GParamSpec* pspec,
                                                    gpointer self)
{
	boxes_list_view_row_update_status ((BoxesListViewRow*) self);
}

static void
_boxes_list_view_row_update_thumbnail_g_object_notify (GObject* _sender,
                                                       GParamSpec* pspec,
                                                       gpointer self)
{
	boxes_list_view_row_update_thumbnail ((BoxesListViewRow*) self);
}

BoxesListViewRow*
boxes_list_view_row_construct (GType object_type,
                               BoxesCollectionItem* item)
{
	BoxesListViewRow * self = NULL;
	BoxesMachine* _tmp0_;
	BoxesMachine* _tmp1_;
	BoxesMachine* _tmp2_;
	BoxesMachine* _tmp3_;
	BoxesMachine* _tmp4_;
	BoxesMachine* _tmp5_;
	BoxesMachine* _tmp6_;
	BoxesMachine* _tmp7_;
	BoxesMachine* _tmp8_;
	BoxesMachine* _tmp9_;
	BoxesMachine* _tmp10_;
	BoxesMachine* _tmp11_;
	GtkWidget* _tmp12_;
	GtkWidget* _tmp13_;
	GtkContainer* _tmp14_;
	g_return_val_if_fail (item != NULL, NULL);
	self = (BoxesListViewRow*) g_object_new (object_type, NULL);
	boxes_list_view_row_set_item (self, item);
	boxes_list_view_row_update_status (self);
	_tmp0_ = boxes_list_view_row_get_machine (self);
	_tmp1_ = _tmp0_;
	g_signal_connect_object ((GObject*) _tmp1_, "notify::state", (GCallback) _boxes_list_view_row_update_status_g_object_notify, self, 0);
	_tmp2_ = boxes_list_view_row_get_machine (self);
	_tmp3_ = _tmp2_;
	g_signal_connect_object ((GObject*) _tmp3_, "notify::status", (GCallback) _boxes_list_view_row_update_status_g_object_notify, self, 0);
	boxes_list_view_row_update_thumbnail (self);
	_tmp4_ = boxes_list_view_row_get_machine (self);
	_tmp5_ = _tmp4_;
	g_signal_connect_object ((GObject*) _tmp5_, "notify::under-construction", (GCallback) _boxes_list_view_row_update_thumbnail_g_object_notify, self, 0);
	_tmp6_ = boxes_list_view_row_get_machine (self);
	_tmp7_ = _tmp6_;
	g_signal_connect_object ((GObject*) _tmp7_, "notify::is-stopped", (GCallback) _boxes_list_view_row_update_thumbnail_g_object_notify, self, 0);
	_tmp8_ = boxes_list_view_row_get_machine (self);
	_tmp9_ = _tmp8_;
	g_signal_connect_object ((GObject*) _tmp9_, "notify::pixbuf", (GCallback) _boxes_list_view_row_update_thumbnail_g_object_notify, self, 0);
	_tmp10_ = boxes_list_view_row_get_machine (self);
	_tmp11_ = _tmp10_;
	g_object_bind_property_with_closures ((GObject*) _tmp11_, "name", (GObject*) self, "title", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp12_ = hdy_action_row_get_activatable_widget ((HdyActionRow*) self);
	_tmp13_ = _tmp12_;
	_tmp14_ = gtk_widget_get_parent (_tmp13_);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp14_, FALSE);
	return self;
}

BoxesListViewRow*
boxes_list_view_row_new (BoxesCollectionItem* item)
{
	return boxes_list_view_row_construct (BOXES_TYPE_LIST_VIEW_ROW, item);
}

static void
boxes_list_view_row_update_thumbnail (BoxesListViewRow* self)
{
	BoxesThumbnail* _tmp0_;
	BoxesMachine* _tmp1_;
	BoxesMachine* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->thumbnail;
	_tmp1_ = boxes_list_view_row_get_machine (self);
	_tmp2_ = _tmp1_;
	boxes_thumbnail_update (_tmp0_, _tmp2_);
}

static void
boxes_list_view_row_update_status (BoxesListViewRow* self)
{
	BoxesMachine* _tmp0_;
	BoxesMachine* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	BoxesMachine* _tmp8_;
	BoxesMachine* _tmp9_;
	gboolean _tmp10_;
	gboolean _tmp11_;
	BoxesMachine* _tmp12_;
	BoxesMachine* _tmp13_;
	gboolean _tmp14_;
	gboolean _tmp15_;
	g_return_if_fail (self != NULL);
	_tmp0_ = boxes_list_view_row_get_machine (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = boxes_machine_get_status (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_ != NULL) {
		BoxesMachine* _tmp4_;
		BoxesMachine* _tmp5_;
		const gchar* _tmp6_;
		const gchar* _tmp7_;
		_tmp4_ = boxes_list_view_row_get_machine (self);
		_tmp5_ = _tmp4_;
		_tmp6_ = boxes_machine_get_status (_tmp5_);
		_tmp7_ = _tmp6_;
		hdy_action_row_set_subtitle ((HdyActionRow*) self, _tmp7_);
		return;
	}
	_tmp8_ = boxes_list_view_row_get_machine (self);
	_tmp9_ = _tmp8_;
	_tmp10_ = boxes_machine_get_is_running (_tmp9_);
	_tmp11_ = _tmp10_;
	if (_tmp11_) {
		hdy_action_row_set_subtitle ((HdyActionRow*) self, _ ("Running"));
		return;
	}
	_tmp12_ = boxes_list_view_row_get_machine (self);
	_tmp13_ = _tmp12_;
	_tmp14_ = boxes_machine_get_is_on (_tmp13_);
	_tmp15_ = _tmp14_;
	if (_tmp15_) {
		hdy_action_row_set_subtitle ((HdyActionRow*) self, _ ("Paused"));
		return;
	}
	hdy_action_row_set_subtitle ((HdyActionRow*) self, _ ("Powered Off"));
}

void
boxes_list_view_row_pop_menu (BoxesListViewRow* self)
{
	g_return_if_fail (self != NULL);
	g_signal_emit (self, boxes_list_view_row_signals[BOXES_LIST_VIEW_ROW_POP_CONTEXT_MENU_SIGNAL], 0);
}

static void
_boxes_list_view_row_pop_menu_gtk_button_clicked (GtkButton* _sender,
                                                  gpointer self)
{
	boxes_list_view_row_pop_menu ((BoxesListViewRow*) self);
}

BoxesCollectionItem*
boxes_list_view_row_get_item (BoxesListViewRow* self)
{
	BoxesCollectionItem* result;
	BoxesCollectionItem* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_item;
	result = _tmp0_;
	return result;
}

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

static void
boxes_list_view_row_set_item (BoxesListViewRow* self,
                              BoxesCollectionItem* value)
{
	BoxesCollectionItem* old_value;
	g_return_if_fail (self != NULL);
	old_value = boxes_list_view_row_get_item (self);
	if (old_value != value) {
		BoxesCollectionItem* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_item);
		self->priv->_item = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, boxes_list_view_row_properties[BOXES_LIST_VIEW_ROW_ITEM_PROPERTY]);
	}
}

static BoxesMachine*
boxes_list_view_row_get_machine (BoxesListViewRow* self)
{
	BoxesMachine* result;
	BoxesCollectionItem* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_item;
	result = BOXES_IS_MACHINE (_tmp0_) ? ((BoxesMachine*) _tmp0_) : NULL;
	return result;
}

static void
boxes_list_view_row_class_init (BoxesListViewRowClass * klass,
                                gpointer klass_data)
{
	boxes_list_view_row_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BoxesListViewRow_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_boxes_list_view_row_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_boxes_list_view_row_set_property;
	G_OBJECT_CLASS (klass)->finalize = boxes_list_view_row_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), BOXES_LIST_VIEW_ROW_ITEM_PROPERTY, boxes_list_view_row_properties[BOXES_LIST_VIEW_ROW_ITEM_PROPERTY] = g_param_spec_object ("item", "item", "item", BOXES_TYPE_COLLECTION_ITEM, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Boxes/ui/list-view-row.ui");
	boxes_list_view_row_signals[BOXES_LIST_VIEW_ROW_POP_CONTEXT_MENU_SIGNAL] = g_signal_new ("pop-context-menu", BOXES_TYPE_LIST_VIEW_ROW, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "thumbnail", FALSE, G_STRUCT_OFFSET (BoxesListViewRow, thumbnail));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "menu_button", FALSE, G_STRUCT_OFFSET (BoxesListViewRow, menu_button));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "pop_menu", G_CALLBACK(_boxes_list_view_row_pop_menu_gtk_button_clicked));
}

static void
boxes_list_view_row_instance_init (BoxesListViewRow * self,
                                   gpointer klass)
{
	self->priv = boxes_list_view_row_get_instance_private (self);
	g_type_ensure (BOXES_TYPE_THUMBNAIL);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
boxes_list_view_row_finalize (GObject * obj)
{
	BoxesListViewRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BOXES_TYPE_LIST_VIEW_ROW, BoxesListViewRow);
	_g_object_unref0 (self->priv->_item);
	G_OBJECT_CLASS (boxes_list_view_row_parent_class)->finalize (obj);
}

static GType
boxes_list_view_row_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BoxesListViewRowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) boxes_list_view_row_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BoxesListViewRow), 0, (GInstanceInitFunc) boxes_list_view_row_instance_init, NULL };
	GType boxes_list_view_row_type_id;
	boxes_list_view_row_type_id = g_type_register_static (hdy_action_row_get_type (), "BoxesListViewRow", &g_define_type_info, 0);
	BoxesListViewRow_private_offset = g_type_add_instance_private (boxes_list_view_row_type_id, sizeof (BoxesListViewRowPrivate));
	return boxes_list_view_row_type_id;
}

GType
boxes_list_view_row_get_type (void)
{
	static volatile gsize boxes_list_view_row_type_id__once = 0;
	if (g_once_init_enter (&boxes_list_view_row_type_id__once)) {
		GType boxes_list_view_row_type_id;
		boxes_list_view_row_type_id = boxes_list_view_row_get_type_once ();
		g_once_init_leave (&boxes_list_view_row_type_id__once, boxes_list_view_row_type_id);
	}
	return boxes_list_view_row_type_id__once;
}

static void
_vala_boxes_list_view_row_get_property (GObject * object,
                                        guint property_id,
                                        GValue * value,
                                        GParamSpec * pspec)
{
	BoxesListViewRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, BOXES_TYPE_LIST_VIEW_ROW, BoxesListViewRow);
	switch (property_id) {
		case BOXES_LIST_VIEW_ROW_ITEM_PROPERTY:
		g_value_set_object (value, boxes_list_view_row_get_item (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_boxes_list_view_row_set_property (GObject * object,
                                        guint property_id,
                                        const GValue * value,
                                        GParamSpec * pspec)
{
	BoxesListViewRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, BOXES_TYPE_LIST_VIEW_ROW, BoxesListViewRow);
	switch (property_id) {
		case BOXES_LIST_VIEW_ROW_ITEM_PROPERTY:
		boxes_list_view_row_set_item (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

