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

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

#include <gtk/gtk.h>
#include <glib-object.h>
#include <handy.h>
#include <glib.h>
#include "common.h"
#include <gio/gio.h>
#include <gdk/gdk.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_ICON_VIEW (boxes_icon_view_get_type ())
#define BOXES_ICON_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_ICON_VIEW, BoxesIconView))
#define BOXES_ICON_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_ICON_VIEW, BoxesIconViewClass))
#define BOXES_IS_ICON_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_ICON_VIEW))
#define BOXES_IS_ICON_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_ICON_VIEW))
#define BOXES_ICON_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_ICON_VIEW, BoxesIconViewClass))

typedef struct _BoxesIconView BoxesIconView;
typedef struct _BoxesIconViewClass BoxesIconViewClass;
typedef struct _BoxesIconViewPrivate BoxesIconViewPrivate;

#define BOXES_TYPE_APP_WINDOW (boxes_app_window_get_type ())
#define BOXES_APP_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_APP_WINDOW, BoxesAppWindow))
#define BOXES_APP_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_APP_WINDOW, BoxesAppWindowClass))
#define BOXES_IS_APP_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_APP_WINDOW))
#define BOXES_IS_APP_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_APP_WINDOW))
#define BOXES_APP_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_APP_WINDOW, BoxesAppWindowClass))

typedef struct _BoxesAppWindow BoxesAppWindow;
typedef struct _BoxesAppWindowClass BoxesAppWindowClass;

#define BOXES_TYPE_ACTIONS_POPOVER (boxes_actions_popover_get_type ())
#define BOXES_ACTIONS_POPOVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_ACTIONS_POPOVER, BoxesActionsPopover))
#define BOXES_ACTIONS_POPOVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_ACTIONS_POPOVER, BoxesActionsPopoverClass))
#define BOXES_IS_ACTIONS_POPOVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_ACTIONS_POPOVER))
#define BOXES_IS_ACTIONS_POPOVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_ACTIONS_POPOVER))
#define BOXES_ACTIONS_POPOVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_ACTIONS_POPOVER, BoxesActionsPopoverClass))

typedef struct _BoxesActionsPopover BoxesActionsPopover;
typedef struct _BoxesActionsPopoverClass BoxesActionsPopoverClass;
enum  {
	BOXES_ICON_VIEW_0_PROPERTY,
	BOXES_ICON_VIEW_NUM_PROPERTIES
};
static GParamSpec* boxes_icon_view_properties[BOXES_ICON_VIEW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define BOXES_TYPE_APP (boxes_app_get_type ())
#define BOXES_APP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_APP, BoxesApp))
#define BOXES_APP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_APP, BoxesAppClass))
#define BOXES_IS_APP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_APP))
#define BOXES_IS_APP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_APP))
#define BOXES_APP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_APP, BoxesAppClass))

typedef struct _BoxesApp BoxesApp;
typedef struct _BoxesAppClass BoxesAppClass;
typedef struct _BoxesAppPrivate BoxesAppPrivate;

#define BOXES_TYPE_COLLECTION (boxes_collection_get_type ())
#define BOXES_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_COLLECTION, BoxesCollection))
#define BOXES_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_COLLECTION, BoxesCollectionClass))
#define BOXES_IS_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_COLLECTION))
#define BOXES_IS_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_COLLECTION))
#define BOXES_COLLECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_COLLECTION, BoxesCollectionClass))

typedef struct _BoxesCollection BoxesCollection;
typedef struct _BoxesCollectionClass BoxesCollectionClass;

#define BOXES_TYPE_SHARED_FOLDERS_MANAGER (boxes_shared_folders_manager_get_type ())
#define BOXES_SHARED_FOLDERS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_SHARED_FOLDERS_MANAGER, BoxesSharedFoldersManager))
#define BOXES_SHARED_FOLDERS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_SHARED_FOLDERS_MANAGER, BoxesSharedFoldersManagerClass))
#define BOXES_IS_SHARED_FOLDERS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_SHARED_FOLDERS_MANAGER))
#define BOXES_IS_SHARED_FOLDERS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_SHARED_FOLDERS_MANAGER))
#define BOXES_SHARED_FOLDERS_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_SHARED_FOLDERS_MANAGER, BoxesSharedFoldersManagerClass))

typedef struct _BoxesSharedFoldersManager BoxesSharedFoldersManager;
typedef struct _BoxesSharedFoldersManagerClass BoxesSharedFoldersManagerClass;
typedef struct _BoxesCollectionPrivate BoxesCollectionPrivate;

#define BOXES_TYPE_ICON_VIEW_CHILD (boxes_icon_view_child_get_type ())
#define BOXES_ICON_VIEW_CHILD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_ICON_VIEW_CHILD, BoxesIconViewChild))
#define BOXES_ICON_VIEW_CHILD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_ICON_VIEW_CHILD, BoxesIconViewChildClass))
#define BOXES_IS_ICON_VIEW_CHILD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_ICON_VIEW_CHILD))
#define BOXES_IS_ICON_VIEW_CHILD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_ICON_VIEW_CHILD))
#define BOXES_ICON_VIEW_CHILD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_ICON_VIEW_CHILD, BoxesIconViewChildClass))

typedef struct _BoxesIconViewChild BoxesIconViewChild;
typedef struct _BoxesIconViewChildClass BoxesIconViewChildClass;

#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;

#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;

#define BOXES_TYPE_LIBVIRT_MACHINE (boxes_libvirt_machine_get_type ())
#define BOXES_LIBVIRT_MACHINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_LIBVIRT_MACHINE, BoxesLibvirtMachine))
#define BOXES_LIBVIRT_MACHINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_LIBVIRT_MACHINE, BoxesLibvirtMachineClass))
#define BOXES_IS_LIBVIRT_MACHINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_LIBVIRT_MACHINE))
#define BOXES_IS_LIBVIRT_MACHINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_LIBVIRT_MACHINE))
#define BOXES_LIBVIRT_MACHINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_LIBVIRT_MACHINE, BoxesLibvirtMachineClass))

typedef struct _BoxesLibvirtMachine BoxesLibvirtMachine;
typedef struct _BoxesLibvirtMachineClass BoxesLibvirtMachineClass;

#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;
typedef struct _BoxesIconViewChildPrivate BoxesIconViewChildPrivate;

struct _BoxesIconView {
	GtkScrolledWindow parent_instance;
	BoxesIconViewPrivate * priv;
};

struct _BoxesIconViewClass {
	GtkScrolledWindowClass parent_class;
};

struct _BoxesIconViewPrivate {
	GtkFlowBox* flowbox;
	BoxesAppWindow* window;
	BoxesActionsPopover* context_popover;
};

struct _BoxesApp {
	GtkApplication parent_instance;
	BoxesAppPrivate * priv;
	BoxesCollection* collection;
	BoxesAsyncLauncher* async_launcher;
	BoxesSharedFoldersManager* shared_folders_manager;
};

struct _BoxesAppClass {
	GtkApplicationClass parent_class;
};

struct _BoxesCollection {
	GObject parent_instance;
	BoxesCollectionPrivate * priv;
	GListStore* filtered_items;
};

struct _BoxesCollectionClass {
	GObjectClass parent_class;
};

struct _BoxesIconViewChild {
	GtkBox parent_instance;
	BoxesIconViewChildPrivate * priv;
	BoxesThumbnail* thumbnail;
};

struct _BoxesIconViewChildClass {
	GtkBoxClass parent_class;
};

static gint BoxesIconView_private_offset;
static gpointer boxes_icon_view_parent_class = NULL;
VALA_EXTERN BoxesApp* boxes_app_app;

VALA_EXTERN GType boxes_icon_view_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesIconView, g_object_unref)
VALA_EXTERN GType boxes_app_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesAppWindow, g_object_unref)
VALA_EXTERN GType boxes_actions_popover_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesActionsPopover, g_object_unref)
VALA_EXTERN void boxes_icon_view_setup_ui (BoxesIconView* self,
                               BoxesAppWindow* window);
VALA_EXTERN BoxesActionsPopover* boxes_actions_popover_new (BoxesAppWindow* window);
VALA_EXTERN BoxesActionsPopover* boxes_actions_popover_construct (GType object_type,
                                                      BoxesAppWindow* window);
static void boxes_icon_view_setup_flowbox (BoxesIconView* self);
VALA_EXTERN GType boxes_app_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesApp, g_object_unref)
VALA_EXTERN GType boxes_collection_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesCollection, g_object_unref)
VALA_EXTERN GType boxes_shared_folders_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesSharedFoldersManager, g_object_unref)
static GtkWidget* __lambda60_ (BoxesIconView* self,
                        GObject* item);
VALA_EXTERN GType boxes_icon_view_child_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesIconViewChild, 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 BoxesIconViewChild* boxes_icon_view_child_new (BoxesCollectionItem* item);
VALA_EXTERN BoxesIconViewChild* boxes_icon_view_child_construct (GType object_type,
                                                     BoxesCollectionItem* item);
static GtkWidget* ___lambda60__gtk_flow_box_create_widget_func (gpointer item,
                                                         gpointer self);
static BoxesCollectionItem* boxes_icon_view_get_item_for_child (BoxesIconView* self,
                                                         GtkFlowBoxChild* child);
VALA_EXTERN BoxesCollectionItem* boxes_icon_view_child_get_item (BoxesIconViewChild* self);
static void boxes_icon_view_on_child_activated (BoxesIconView* self,
                                         GtkFlowBoxChild* child);
VALA_EXTERN GType boxes_machine_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesMachine, g_object_unref)
VALA_EXTERN GType boxes_libvirt_machine_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesLibvirtMachine, g_object_unref)
VALA_EXTERN gboolean boxes_libvirt_machine_get_importing (BoxesLibvirtMachine* self);
VALA_EXTERN void boxes_app_window_select_item (BoxesAppWindow* self,
                                   BoxesCollectionItem* item);
static void _boxes_icon_view_on_child_activated_gtk_flow_box_child_activated (GtkFlowBox* _sender,
                                                                       GtkFlowBoxChild* child,
                                                                       gpointer self);
static gboolean boxes_icon_view_on_button_press_event (BoxesIconView* self,
                                                GdkEventButton* event);
static gboolean boxes_icon_view_launch_context_popover_for_child (BoxesIconView* self,
                                                           GtkFlowBoxChild* child);
static gboolean _boxes_icon_view_on_button_press_event_gtk_widget_button_release_event (GtkWidget* _sender,
                                                                                 GdkEventButton* event,
                                                                                 gpointer self);
static gboolean boxes_icon_view_on_key_press_event (BoxesIconView* self,
                                             GdkEventKey* event);
static gboolean _boxes_icon_view_on_key_press_event_gtk_widget_key_press_event (GtkWidget* _sender,
                                                                         GdkEventKey* event,
                                                                         gpointer self);
VALA_EXTERN GType boxes_thumbnail_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesThumbnail, g_object_unref)
VALA_EXTERN void boxes_actions_popover_update_for_item (BoxesActionsPopover* self,
                                            BoxesCollectionItem* item);
VALA_EXTERN BoxesIconView* boxes_icon_view_new (void);
VALA_EXTERN BoxesIconView* boxes_icon_view_construct (GType object_type);
static GObject * boxes_icon_view_constructor (GType type,
                                       guint n_construct_properties,
                                       GObjectConstructParam * construct_properties);
static void boxes_icon_view_finalize (GObject * obj);
static GType boxes_icon_view_get_type_once (void);

static inline gpointer
boxes_icon_view_get_instance_private (BoxesIconView* self)
{
	return G_STRUCT_MEMBER_P (self, BoxesIconView_private_offset);
}

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

void
boxes_icon_view_setup_ui (BoxesIconView* self,
                          BoxesAppWindow* window)
{
	BoxesAppWindow* _tmp0_;
	BoxesActionsPopover* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (window != NULL);
	_tmp0_ = _g_object_ref0 (window);
	_g_object_unref0 (self->priv->window);
	self->priv->window = _tmp0_;
	_tmp1_ = boxes_actions_popover_new (window);
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->priv->context_popover);
	self->priv->context_popover = _tmp1_;
}

static GtkWidget*
__lambda60_ (BoxesIconView* self,
             GObject* item)
{
	GtkFlowBoxChild* child = NULL;
	GtkFlowBoxChild* _tmp0_;
	BoxesIconViewChild* box = NULL;
	BoxesIconViewChild* _tmp1_;
	GtkWidget* result;
	g_return_val_if_fail (item != NULL, NULL);
	_tmp0_ = (GtkFlowBoxChild*) gtk_flow_box_child_new ();
	g_object_ref_sink (_tmp0_);
	child = _tmp0_;
	gtk_widget_set_halign ((GtkWidget*) child, GTK_ALIGN_START);
	_tmp1_ = boxes_icon_view_child_new (BOXES_IS_COLLECTION_ITEM (item) ? ((BoxesCollectionItem*) item) : NULL);
	g_object_ref_sink (_tmp1_);
	box = _tmp1_;
	gtk_container_add ((GtkContainer*) child, (GtkWidget*) box);
	gtk_widget_set_visible ((GtkWidget*) box, TRUE);
	gtk_widget_set_visible ((GtkWidget*) child, TRUE);
	result = (GtkWidget*) child;
	_g_object_unref0 (box);
	return result;
}

static GtkWidget*
___lambda60__gtk_flow_box_create_widget_func (gpointer item,
                                              gpointer self)
{
	GtkWidget* result;
	result = __lambda60_ ((BoxesIconView*) self, item);
	return result;
}

static void
boxes_icon_view_setup_flowbox (BoxesIconView* self)
{
	GtkFlowBox* _tmp0_;
	BoxesApp* _tmp1_;
	BoxesCollection* _tmp2_;
	GListStore* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->flowbox;
	_tmp1_ = boxes_app_app;
	_tmp2_ = _tmp1_->collection;
	_tmp3_ = _tmp2_->filtered_items;
	gtk_flow_box_bind_model (_tmp0_, (GListModel*) _tmp3_, ___lambda60__gtk_flow_box_create_widget_func, g_object_ref (self), g_object_unref);
}

static BoxesCollectionItem*
boxes_icon_view_get_item_for_child (BoxesIconView* self,
                                    GtkFlowBoxChild* child)
{
	BoxesIconViewChild* view = NULL;
	GtkWidget* _tmp0_;
	BoxesIconViewChild* _tmp1_;
	BoxesIconViewChild* _tmp2_;
	BoxesIconViewChild* _tmp3_;
	BoxesCollectionItem* _tmp4_;
	BoxesCollectionItem* _tmp5_;
	BoxesCollectionItem* _tmp6_;
	BoxesCollectionItem* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (child != NULL, NULL);
	_tmp0_ = gtk_bin_get_child ((GtkBin*) child);
	_tmp1_ = _g_object_ref0 (BOXES_IS_ICON_VIEW_CHILD (_tmp0_) ? ((BoxesIconViewChild*) _tmp0_) : NULL);
	view = _tmp1_;
	_tmp2_ = view;
	if (_tmp2_ == NULL) {
		result = NULL;
		_g_object_unref0 (view);
		return result;
	}
	_tmp3_ = view;
	_tmp4_ = boxes_icon_view_child_get_item (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = _g_object_ref0 (_tmp5_);
	result = _tmp6_;
	_g_object_unref0 (view);
	return result;
}

static void
boxes_icon_view_on_child_activated (BoxesIconView* self,
                                    GtkFlowBoxChild* child)
{
	BoxesCollectionItem* item = NULL;
	BoxesCollectionItem* _tmp0_;
	BoxesCollectionItem* _tmp1_;
	BoxesAppWindow* _tmp7_;
	BoxesCollectionItem* _tmp8_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (child != NULL);
	_tmp0_ = boxes_icon_view_get_item_for_child (self, child);
	item = _tmp0_;
	_tmp1_ = item;
	if (BOXES_IS_LIBVIRT_MACHINE (_tmp1_)) {
		BoxesLibvirtMachine* machine = NULL;
		BoxesCollectionItem* _tmp2_;
		BoxesLibvirtMachine* _tmp3_;
		BoxesLibvirtMachine* _tmp4_;
		gboolean _tmp5_;
		gboolean _tmp6_;
		_tmp2_ = item;
		_tmp3_ = _g_object_ref0 (BOXES_IS_LIBVIRT_MACHINE (_tmp2_) ? ((BoxesLibvirtMachine*) _tmp2_) : NULL);
		machine = _tmp3_;
		_tmp4_ = machine;
		_tmp5_ = boxes_libvirt_machine_get_importing (_tmp4_);
		_tmp6_ = _tmp5_;
		if (_tmp6_) {
			_g_object_unref0 (machine);
			_g_object_unref0 (item);
			return;
		}
		_g_object_unref0 (machine);
	}
	_tmp7_ = self->priv->window;
	_tmp8_ = item;
	boxes_app_window_select_item (_tmp7_, _tmp8_);
	_g_object_unref0 (item);
}

static void
_boxes_icon_view_on_child_activated_gtk_flow_box_child_activated (GtkFlowBox* _sender,
                                                                  GtkFlowBoxChild* child,
                                                                  gpointer self)
{
	boxes_icon_view_on_child_activated ((BoxesIconView*) self, child);
}

static gboolean
boxes_icon_view_on_button_press_event (BoxesIconView* self,
                                       GdkEventButton* event)
{
	gboolean _tmp0_ = FALSE;
	GtkFlowBoxChild* child = NULL;
	GtkFlowBox* _tmp1_;
	GtkFlowBoxChild* _tmp2_;
	GtkFlowBoxChild* _tmp3_;
	GtkFlowBoxChild* _tmp4_;
	GtkFlowBoxChild* _tmp5_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	if (event->type != GDK_BUTTON_RELEASE) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = event->button != ((guint) 3);
	}
	if (_tmp0_) {
		result = FALSE;
		return result;
	}
	_tmp1_ = self->priv->flowbox;
	_tmp2_ = gtk_flow_box_get_child_at_pos (_tmp1_, (gint) event->x, (gint) event->y);
	_tmp3_ = _g_object_ref0 (_tmp2_);
	child = _tmp3_;
	_tmp4_ = child;
	if (_tmp4_ == NULL) {
		result = FALSE;
		_g_object_unref0 (child);
		return result;
	}
	_tmp5_ = child;
	result = boxes_icon_view_launch_context_popover_for_child (self, _tmp5_);
	_g_object_unref0 (child);
	return result;
}

static gboolean
_boxes_icon_view_on_button_press_event_gtk_widget_button_release_event (GtkWidget* _sender,
                                                                        GdkEventButton* event,
                                                                        gpointer self)
{
	gboolean result;
	result = boxes_icon_view_on_button_press_event ((BoxesIconView*) self, event);
	return result;
}

static gboolean
boxes_icon_view_on_key_press_event (BoxesIconView* self,
                                    GdkEventKey* event)
{
	GtkFlowBoxChild* child = NULL;
	GtkFlowBox* _tmp0_;
	GList* _tmp1_;
	GList* _tmp2_;
	gconstpointer _tmp3_;
	GtkFlowBoxChild* _tmp4_;
	GtkFlowBoxChild* _tmp5_;
	GtkFlowBoxChild* _tmp6_;
	GtkFlowBoxChild* _tmp7_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	if (event->keyval != GDK_KEY_Menu) {
		result = FALSE;
		return result;
	}
	_tmp0_ = self->priv->flowbox;
	_tmp1_ = gtk_flow_box_get_selected_children (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_list_nth_data (_tmp2_, (guint) 0);
	_tmp4_ = _g_object_ref0 ((GtkFlowBoxChild*) _tmp3_);
	_tmp5_ = _tmp4_;
	(_tmp2_ == NULL) ? NULL : (_tmp2_ = (g_list_free (_tmp2_), NULL));
	child = _tmp5_;
	_tmp6_ = child;
	if (_tmp6_ == NULL) {
		result = FALSE;
		_g_object_unref0 (child);
		return result;
	}
	_tmp7_ = child;
	result = boxes_icon_view_launch_context_popover_for_child (self, _tmp7_);
	_g_object_unref0 (child);
	return result;
}

static gboolean
_boxes_icon_view_on_key_press_event_gtk_widget_key_press_event (GtkWidget* _sender,
                                                                GdkEventKey* event,
                                                                gpointer self)
{
	gboolean result;
	result = boxes_icon_view_on_key_press_event ((BoxesIconView*) self, event);
	return result;
}

static gboolean
boxes_icon_view_launch_context_popover_for_child (BoxesIconView* self,
                                                  GtkFlowBoxChild* child)
{
	BoxesCollectionItem* item = NULL;
	BoxesCollectionItem* _tmp0_;
	BoxesCollectionItem* _tmp1_;
	BoxesIconViewChild* icon_view_child = NULL;
	GtkWidget* _tmp2_;
	BoxesIconViewChild* _tmp3_;
	BoxesThumbnail* thumbnail = NULL;
	BoxesIconViewChild* _tmp4_;
	BoxesThumbnail* _tmp5_;
	BoxesThumbnail* _tmp6_;
	BoxesActionsPopover* _tmp7_;
	BoxesCollectionItem* _tmp8_;
	BoxesActionsPopover* _tmp9_;
	BoxesThumbnail* _tmp10_;
	GtkContainer* _tmp11_;
	BoxesActionsPopover* _tmp12_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (child != NULL, FALSE);
	_tmp0_ = boxes_icon_view_get_item_for_child (self, child);
	item = _tmp0_;
	_tmp1_ = item;
	if (_tmp1_ == NULL) {
		result = FALSE;
		_g_object_unref0 (item);
		return result;
	}
	_tmp2_ = gtk_bin_get_child ((GtkBin*) child);
	_tmp3_ = _g_object_ref0 (BOXES_IS_ICON_VIEW_CHILD (_tmp2_) ? ((BoxesIconViewChild*) _tmp2_) : NULL);
	icon_view_child = _tmp3_;
	_tmp4_ = icon_view_child;
	_tmp5_ = _tmp4_->thumbnail;
	_tmp6_ = _g_object_ref0 (_tmp5_);
	thumbnail = _tmp6_;
	_tmp7_ = self->priv->context_popover;
	_tmp8_ = item;
	boxes_actions_popover_update_for_item (_tmp7_, _tmp8_);
	_tmp9_ = self->priv->context_popover;
	_tmp10_ = thumbnail;
	_tmp11_ = gtk_widget_get_parent ((GtkWidget*) _tmp10_);
	gtk_popover_set_relative_to ((GtkPopover*) _tmp9_, (GtkWidget*) _tmp11_);
	_tmp12_ = self->priv->context_popover;
	gtk_widget_show ((GtkWidget*) _tmp12_);
	result = TRUE;
	_g_object_unref0 (thumbnail);
	_g_object_unref0 (icon_view_child);
	_g_object_unref0 (item);
	return result;
}

BoxesIconView*
boxes_icon_view_construct (GType object_type)
{
	BoxesIconView * self = NULL;
	self = (BoxesIconView*) g_object_new (object_type, NULL);
	return self;
}

BoxesIconView*
boxes_icon_view_new (void)
{
	return boxes_icon_view_construct (BOXES_TYPE_ICON_VIEW);
}

static GObject *
boxes_icon_view_constructor (GType type,
                             guint n_construct_properties,
                             GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	BoxesIconView * self;
	parent_class = G_OBJECT_CLASS (boxes_icon_view_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BOXES_TYPE_ICON_VIEW, BoxesIconView);
	boxes_icon_view_setup_flowbox (self);
	return obj;
}

static void
boxes_icon_view_class_init (BoxesIconViewClass * klass,
                            gpointer klass_data)
{
	boxes_icon_view_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BoxesIconView_private_offset);
	G_OBJECT_CLASS (klass)->constructor = boxes_icon_view_constructor;
	G_OBJECT_CLASS (klass)->finalize = boxes_icon_view_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Boxes/ui/icon-view.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "flowbox", FALSE, BoxesIconView_private_offset + G_STRUCT_OFFSET (BoxesIconViewPrivate, flowbox));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_child_activated", G_CALLBACK(_boxes_icon_view_on_child_activated_gtk_flow_box_child_activated));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_button_press_event", G_CALLBACK(_boxes_icon_view_on_button_press_event_gtk_widget_button_release_event));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_key_press_event", G_CALLBACK(_boxes_icon_view_on_key_press_event_gtk_widget_key_press_event));
}

static void
boxes_icon_view_instance_init (BoxesIconView * self,
                               gpointer klass)
{
	self->priv = boxes_icon_view_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
boxes_icon_view_finalize (GObject * obj)
{
	BoxesIconView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BOXES_TYPE_ICON_VIEW, BoxesIconView);
	_g_object_unref0 (self->priv->window);
	_g_object_unref0 (self->priv->context_popover);
	G_OBJECT_CLASS (boxes_icon_view_parent_class)->finalize (obj);
}

static GType
boxes_icon_view_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BoxesIconViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) boxes_icon_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BoxesIconView), 0, (GInstanceInitFunc) boxes_icon_view_instance_init, NULL };
	GType boxes_icon_view_type_id;
	boxes_icon_view_type_id = g_type_register_static (gtk_scrolled_window_get_type (), "BoxesIconView", &g_define_type_info, 0);
	BoxesIconView_private_offset = g_type_add_instance_private (boxes_icon_view_type_id, sizeof (BoxesIconViewPrivate));
	return boxes_icon_view_type_id;
}

GType
boxes_icon_view_get_type (void)
{
	static volatile gsize boxes_icon_view_type_id__once = 0;
	if (g_once_init_enter (&boxes_icon_view_type_id__once)) {
		GType boxes_icon_view_type_id;
		boxes_icon_view_type_id = boxes_icon_view_get_type_once ();
		g_once_init_leave (&boxes_icon_view_type_id__once, boxes_icon_view_type_id);
	}
	return boxes_icon_view_type_id__once;
}

