/* collection-view.c generated by valac 0.56.19, the Vala compiler
 * generated from collection-view.vala, do not modify */

/* collection-view.vala
 *
 * Copyright (C) Red Hat, Inc
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Author: Felipe Borges <felipeborges@gnome.org>
 *
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <glib.h>
#include <gdk/gdk.h>
#include <stdlib.h>
#include <string.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 CONNECTIONS_TYPE_COLLECTION_VIEW (connections_collection_view_get_type ())
#define CONNECTIONS_COLLECTION_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONNECTIONS_TYPE_COLLECTION_VIEW, ConnectionsCollectionView))
#define CONNECTIONS_COLLECTION_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONNECTIONS_TYPE_COLLECTION_VIEW, ConnectionsCollectionViewClass))
#define CONNECTIONS_IS_COLLECTION_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONNECTIONS_TYPE_COLLECTION_VIEW))
#define CONNECTIONS_IS_COLLECTION_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONNECTIONS_TYPE_COLLECTION_VIEW))
#define CONNECTIONS_COLLECTION_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONNECTIONS_TYPE_COLLECTION_VIEW, ConnectionsCollectionViewClass))

typedef struct _ConnectionsCollectionView ConnectionsCollectionView;
typedef struct _ConnectionsCollectionViewClass ConnectionsCollectionViewClass;
typedef struct _ConnectionsCollectionViewPrivate ConnectionsCollectionViewPrivate;

#define CONNECTIONS_TYPE_ACTIONS_POPOVER (connections_actions_popover_get_type ())
#define CONNECTIONS_ACTIONS_POPOVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONNECTIONS_TYPE_ACTIONS_POPOVER, ConnectionsActionsPopover))
#define CONNECTIONS_ACTIONS_POPOVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONNECTIONS_TYPE_ACTIONS_POPOVER, ConnectionsActionsPopoverClass))
#define CONNECTIONS_IS_ACTIONS_POPOVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONNECTIONS_TYPE_ACTIONS_POPOVER))
#define CONNECTIONS_IS_ACTIONS_POPOVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONNECTIONS_TYPE_ACTIONS_POPOVER))
#define CONNECTIONS_ACTIONS_POPOVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONNECTIONS_TYPE_ACTIONS_POPOVER, ConnectionsActionsPopoverClass))

typedef struct _ConnectionsActionsPopover ConnectionsActionsPopover;
typedef struct _ConnectionsActionsPopoverClass ConnectionsActionsPopoverClass;
enum  {
	CONNECTIONS_COLLECTION_VIEW_0_PROPERTY,
	CONNECTIONS_COLLECTION_VIEW_NUM_PROPERTIES
};
static GParamSpec* connections_collection_view_properties[CONNECTIONS_COLLECTION_VIEW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define CONNECTIONS_TYPE_COLLECTION_VIEW_CHILD (connections_collection_view_child_get_type ())
#define CONNECTIONS_COLLECTION_VIEW_CHILD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONNECTIONS_TYPE_COLLECTION_VIEW_CHILD, ConnectionsCollectionViewChild))
#define CONNECTIONS_COLLECTION_VIEW_CHILD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONNECTIONS_TYPE_COLLECTION_VIEW_CHILD, ConnectionsCollectionViewChildClass))
#define CONNECTIONS_IS_COLLECTION_VIEW_CHILD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONNECTIONS_TYPE_COLLECTION_VIEW_CHILD))
#define CONNECTIONS_IS_COLLECTION_VIEW_CHILD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONNECTIONS_TYPE_COLLECTION_VIEW_CHILD))
#define CONNECTIONS_COLLECTION_VIEW_CHILD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONNECTIONS_TYPE_COLLECTION_VIEW_CHILD, ConnectionsCollectionViewChildClass))

typedef struct _ConnectionsCollectionViewChild ConnectionsCollectionViewChild;
typedef struct _ConnectionsCollectionViewChildClass ConnectionsCollectionViewChildClass;

#define CONNECTIONS_TYPE_CONNECTION (connections_connection_get_type ())
#define CONNECTIONS_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONNECTIONS_TYPE_CONNECTION, ConnectionsConnection))
#define CONNECTIONS_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONNECTIONS_TYPE_CONNECTION, ConnectionsConnectionClass))
#define CONNECTIONS_IS_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONNECTIONS_TYPE_CONNECTION))
#define CONNECTIONS_IS_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONNECTIONS_TYPE_CONNECTION))
#define CONNECTIONS_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONNECTIONS_TYPE_CONNECTION, ConnectionsConnectionClass))

typedef struct _ConnectionsConnection ConnectionsConnection;
typedef struct _ConnectionsConnectionClass ConnectionsConnectionClass;

#define CONNECTIONS_TYPE_APPLICATION (connections_application_get_type ())
#define CONNECTIONS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONNECTIONS_TYPE_APPLICATION, ConnectionsApplication))
#define CONNECTIONS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONNECTIONS_TYPE_APPLICATION, ConnectionsApplicationClass))
#define CONNECTIONS_IS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONNECTIONS_TYPE_APPLICATION))
#define CONNECTIONS_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONNECTIONS_TYPE_APPLICATION))
#define CONNECTIONS_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONNECTIONS_TYPE_APPLICATION, ConnectionsApplicationClass))

typedef struct _ConnectionsApplication ConnectionsApplication;
typedef struct _ConnectionsApplicationClass ConnectionsApplicationClass;
typedef struct _ConnectionsCollectionViewChildPrivate ConnectionsCollectionViewChildPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))

struct _ConnectionsCollectionView {
	GtkScrolledWindow parent_instance;
	ConnectionsCollectionViewPrivate * priv;
	GtkSearchBar* search_bar;
};

struct _ConnectionsCollectionViewClass {
	GtkScrolledWindowClass parent_class;
};

struct _ConnectionsCollectionViewPrivate {
	GtkFlowBox* flowbox;
	GtkSearchEntry* search_entry;
	ConnectionsActionsPopover* popover;
};

struct _ConnectionsCollectionViewChild {
	GtkBox parent_instance;
	ConnectionsCollectionViewChildPrivate * priv;
	ConnectionsConnection* connection;
	GtkImage* thumbnail;
};

struct _ConnectionsCollectionViewChildClass {
	GtkBoxClass parent_class;
};

static gint ConnectionsCollectionView_private_offset;
static gpointer connections_collection_view_parent_class = NULL;
VALA_EXTERN ConnectionsApplication* connections_application_application;

VALA_EXTERN GType connections_collection_view_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConnectionsCollectionView, g_object_unref)
VALA_EXTERN GType connections_actions_popover_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConnectionsActionsPopover, g_object_unref)
VALA_EXTERN void connections_collection_view_bind_model (ConnectionsCollectionView* self,
                                             GListModel* model);
static GtkWidget* connections_collection_view_create_child (ConnectionsCollectionView* self,
                                                     GObject* item);
static GtkWidget* _connections_collection_view_create_child_gtk_flow_box_create_widget_func (gpointer item,
                                                                                      gpointer self);
VALA_EXTERN GType connections_collection_view_child_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConnectionsCollectionViewChild, g_object_unref)
VALA_EXTERN GType connections_connection_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConnectionsConnection, g_object_unref)
VALA_EXTERN ConnectionsCollectionViewChild* connections_collection_view_child_new (ConnectionsConnection* connection);
VALA_EXTERN ConnectionsCollectionViewChild* connections_collection_view_child_construct (GType object_type,
                                                                             ConnectionsConnection* connection);
static void connections_collection_view_on_child_activated (ConnectionsCollectionView* self,
                                                     GtkFlowBoxChild* child);
VALA_EXTERN GType connections_application_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConnectionsApplication, g_object_unref)
VALA_EXTERN void connections_application_open_connection (ConnectionsApplication* self,
                                              ConnectionsConnection* connection);
static void _connections_collection_view_on_child_activated_gtk_flow_box_child_activated (GtkFlowBox* _sender,
                                                                                   GtkFlowBoxChild* child,
                                                                                   gpointer self);
static gboolean connections_collection_view_on_button_release_event (ConnectionsCollectionView* self,
                                                              GdkEventButton* event);
static gboolean connections_collection_view_launch_context_popover_for_child (ConnectionsCollectionView* self,
                                                                       GtkFlowBoxChild* child);
static gboolean _connections_collection_view_on_button_release_event_gtk_widget_button_release_event (GtkWidget* _sender,
                                                                                               GdkEventButton* event,
                                                                                               gpointer self);
VALA_EXTERN void connections_actions_popover_update_for_item (ConnectionsActionsPopover* self,
                                                  ConnectionsConnection* connection);
static gboolean connections_collection_view_model_filter (ConnectionsCollectionView* self,
                                                   GtkFlowBoxChild* child);
VALA_EXTERN gchar* connections_connection_get_uri (ConnectionsConnection* self);
VALA_EXTERN const gchar* connections_connection_get_display_name (ConnectionsConnection* self);
static void connections_collection_view_on_search_changed (ConnectionsCollectionView* self);
static void _connections_collection_view_on_search_changed_gtk_search_entry_search_changed (GtkSearchEntry* _sender,
                                                                                     gpointer self);
VALA_EXTERN ConnectionsCollectionView* connections_collection_view_new (void);
VALA_EXTERN ConnectionsCollectionView* connections_collection_view_construct (GType object_type);
static GObject * connections_collection_view_constructor (GType type,
                                                   guint n_construct_properties,
                                                   GObjectConstructParam * construct_properties);
VALA_EXTERN ConnectionsActionsPopover* connections_actions_popover_new (void);
VALA_EXTERN ConnectionsActionsPopover* connections_actions_popover_construct (GType object_type);
static gboolean _connections_collection_view_model_filter_gtk_flow_box_filter_func (GtkFlowBoxChild* child,
                                                                             gpointer self);
static void connections_collection_view_finalize (GObject * obj);
static GType connections_collection_view_get_type_once (void);

static inline gpointer
connections_collection_view_get_instance_private (ConnectionsCollectionView* self)
{
	return G_STRUCT_MEMBER_P (self, ConnectionsCollectionView_private_offset);
}

static GtkWidget*
_connections_collection_view_create_child_gtk_flow_box_create_widget_func (gpointer item,
                                                                           gpointer self)
{
	GtkWidget* result;
	result = connections_collection_view_create_child ((ConnectionsCollectionView*) self, item);
	return result;
}

void
connections_collection_view_bind_model (ConnectionsCollectionView* self,
                                        GListModel* model)
{
	GtkFlowBox* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (model != NULL);
	_tmp0_ = self->priv->flowbox;
	gtk_flow_box_bind_model (_tmp0_, model, _connections_collection_view_create_child_gtk_flow_box_create_widget_func, g_object_ref (self), g_object_unref);
}

static GtkWidget*
connections_collection_view_create_child (ConnectionsCollectionView* self,
                                          GObject* item)
{
	GtkFlowBoxChild* child = NULL;
	GtkFlowBoxChild* _tmp0_;
	ConnectionsCollectionViewChild* box = NULL;
	ConnectionsCollectionViewChild* _tmp1_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	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_ = connections_collection_view_child_new (CONNECTIONS_IS_CONNECTION (item) ? ((ConnectionsConnection*) item) : NULL);
	g_object_ref_sink (_tmp1_);
	box = _tmp1_;
	gtk_container_add ((GtkContainer*) child, (GtkWidget*) box);
	result = (GtkWidget*) child;
	_g_object_unref0 (box);
	return result;
}

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

static void
connections_collection_view_on_child_activated (ConnectionsCollectionView* self,
                                                GtkFlowBoxChild* child)
{
	ConnectionsCollectionViewChild* item = NULL;
	GtkWidget* _tmp0_;
	ConnectionsCollectionViewChild* _tmp1_;
	ConnectionsCollectionViewChild* _tmp2_;
	ConnectionsApplication* _tmp3_;
	ConnectionsCollectionViewChild* _tmp4_;
	ConnectionsConnection* _tmp5_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (child != NULL);
	_tmp0_ = gtk_bin_get_child ((GtkBin*) child);
	_tmp1_ = _g_object_ref0 (CONNECTIONS_IS_COLLECTION_VIEW_CHILD (_tmp0_) ? ((ConnectionsCollectionViewChild*) _tmp0_) : NULL);
	item = _tmp1_;
	_tmp2_ = item;
	if (_tmp2_ == NULL) {
		_g_object_unref0 (item);
		return;
	}
	_tmp3_ = connections_application_application;
	_tmp4_ = item;
	_tmp5_ = _tmp4_->connection;
	connections_application_open_connection (_tmp3_, _tmp5_);
	_g_object_unref0 (item);
}

static void
_connections_collection_view_on_child_activated_gtk_flow_box_child_activated (GtkFlowBox* _sender,
                                                                              GtkFlowBoxChild* child,
                                                                              gpointer self)
{
	connections_collection_view_on_child_activated ((ConnectionsCollectionView*) self, child);
}

static gboolean
connections_collection_view_on_button_release_event (ConnectionsCollectionView* self,
                                                     GdkEventButton* event)
{
	gboolean _tmp0_ = FALSE;
	GtkFlowBoxChild* child = NULL;
	GtkFlowBox* _tmp1_;
	GtkFlowBoxChild* _tmp2_;
	GtkFlowBoxChild* _tmp3_;
	GtkFlowBoxChild* _tmp4_;
	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;
	result = connections_collection_view_launch_context_popover_for_child (self, _tmp4_);
	_g_object_unref0 (child);
	return result;
}

static gboolean
_connections_collection_view_on_button_release_event_gtk_widget_button_release_event (GtkWidget* _sender,
                                                                                      GdkEventButton* event,
                                                                                      gpointer self)
{
	gboolean result;
	result = connections_collection_view_on_button_release_event ((ConnectionsCollectionView*) self, event);
	return result;
}

static gboolean
connections_collection_view_launch_context_popover_for_child (ConnectionsCollectionView* self,
                                                              GtkFlowBoxChild* child)
{
	ConnectionsCollectionViewChild* item = NULL;
	GtkWidget* _tmp0_;
	ConnectionsCollectionViewChild* _tmp1_;
	ConnectionsCollectionViewChild* _tmp2_;
	ConnectionsActionsPopover* _tmp3_;
	ConnectionsCollectionViewChild* _tmp4_;
	ConnectionsConnection* _tmp5_;
	ConnectionsActionsPopover* _tmp6_;
	ConnectionsCollectionViewChild* _tmp7_;
	GtkImage* _tmp8_;
	ConnectionsActionsPopover* _tmp9_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (child != NULL, FALSE);
	_tmp0_ = gtk_bin_get_child ((GtkBin*) child);
	_tmp1_ = _g_object_ref0 (CONNECTIONS_IS_COLLECTION_VIEW_CHILD (_tmp0_) ? ((ConnectionsCollectionViewChild*) _tmp0_) : NULL);
	item = _tmp1_;
	_tmp2_ = item;
	if (_tmp2_ == NULL) {
		result = FALSE;
		_g_object_unref0 (item);
		return result;
	}
	_tmp3_ = self->priv->popover;
	_tmp4_ = item;
	_tmp5_ = _tmp4_->connection;
	connections_actions_popover_update_for_item (_tmp3_, _tmp5_);
	_tmp6_ = self->priv->popover;
	_tmp7_ = item;
	_tmp8_ = _tmp7_->thumbnail;
	gtk_popover_set_relative_to ((GtkPopover*) _tmp6_, (GtkWidget*) _tmp8_);
	_tmp9_ = self->priv->popover;
	gtk_widget_show ((GtkWidget*) _tmp9_);
	result = TRUE;
	_g_object_unref0 (item);
	return result;
}

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
connections_collection_view_model_filter (ConnectionsCollectionView* self,
                                          GtkFlowBoxChild* child)
{
	ConnectionsCollectionViewChild* item = NULL;
	GtkWidget* _tmp0_;
	ConnectionsCollectionViewChild* _tmp1_;
	ConnectionsCollectionViewChild* _tmp2_;
	gboolean _tmp3_ = FALSE;
	ConnectionsCollectionViewChild* _tmp4_;
	ConnectionsConnection* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	GtkSearchEntry* _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	gboolean _tmp12_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (child != NULL, FALSE);
	if (child == NULL) {
		result = FALSE;
		return result;
	}
	_tmp0_ = gtk_bin_get_child ((GtkBin*) child);
	_tmp1_ = _g_object_ref0 (CONNECTIONS_IS_COLLECTION_VIEW_CHILD (_tmp0_) ? ((ConnectionsCollectionViewChild*) _tmp0_) : NULL);
	item = _tmp1_;
	_tmp2_ = item;
	if (_tmp2_ == NULL) {
		result = FALSE;
		_g_object_unref0 (item);
		return result;
	}
	_tmp4_ = item;
	_tmp5_ = _tmp4_->connection;
	_tmp6_ = connections_connection_get_uri (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = _tmp7_;
	_tmp9_ = self->priv->search_entry;
	_tmp10_ = gtk_entry_get_text ((GtkEntry*) _tmp9_);
	_tmp11_ = _tmp10_;
	_tmp12_ = string_contains (_tmp8_, _tmp11_);
	_g_free0 (_tmp8_);
	if (_tmp12_) {
		_tmp3_ = TRUE;
	} else {
		ConnectionsCollectionViewChild* _tmp13_;
		ConnectionsConnection* _tmp14_;
		const gchar* _tmp15_;
		const gchar* _tmp16_;
		GtkSearchEntry* _tmp17_;
		const gchar* _tmp18_;
		const gchar* _tmp19_;
		_tmp13_ = item;
		_tmp14_ = _tmp13_->connection;
		_tmp15_ = connections_connection_get_display_name (_tmp14_);
		_tmp16_ = _tmp15_;
		_tmp17_ = self->priv->search_entry;
		_tmp18_ = gtk_entry_get_text ((GtkEntry*) _tmp17_);
		_tmp19_ = _tmp18_;
		_tmp3_ = string_contains (_tmp16_, _tmp19_);
	}
	result = _tmp3_;
	_g_object_unref0 (item);
	return result;
}

static void
connections_collection_view_on_search_changed (ConnectionsCollectionView* self)
{
	GtkFlowBox* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->flowbox;
	gtk_flow_box_invalidate_filter (_tmp0_);
}

static void
_connections_collection_view_on_search_changed_gtk_search_entry_search_changed (GtkSearchEntry* _sender,
                                                                                gpointer self)
{
	connections_collection_view_on_search_changed ((ConnectionsCollectionView*) self);
}

ConnectionsCollectionView*
connections_collection_view_construct (GType object_type)
{
	ConnectionsCollectionView * self = NULL;
	self = (ConnectionsCollectionView*) g_object_new (object_type, NULL);
	return self;
}

ConnectionsCollectionView*
connections_collection_view_new (void)
{
	return connections_collection_view_construct (CONNECTIONS_TYPE_COLLECTION_VIEW);
}

static gboolean
_connections_collection_view_model_filter_gtk_flow_box_filter_func (GtkFlowBoxChild* child,
                                                                    gpointer self)
{
	gboolean result;
	result = connections_collection_view_model_filter ((ConnectionsCollectionView*) self, child);
	return result;
}

static GObject *
connections_collection_view_constructor (GType type,
                                         guint n_construct_properties,
                                         GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	ConnectionsCollectionView * self;
	ConnectionsActionsPopover* _tmp0_;
	GtkFlowBox* _tmp1_;
	parent_class = G_OBJECT_CLASS (connections_collection_view_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CONNECTIONS_TYPE_COLLECTION_VIEW, ConnectionsCollectionView);
	_tmp0_ = connections_actions_popover_new ();
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->popover);
	self->priv->popover = _tmp0_;
	_tmp1_ = self->priv->flowbox;
	gtk_flow_box_set_filter_func (_tmp1_, _connections_collection_view_model_filter_gtk_flow_box_filter_func, g_object_ref (self), g_object_unref);
	return obj;
}

static void
connections_collection_view_class_init (ConnectionsCollectionViewClass * klass,
                                        gpointer klass_data)
{
	connections_collection_view_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ConnectionsCollectionView_private_offset);
	G_OBJECT_CLASS (klass)->constructor = connections_collection_view_constructor;
	G_OBJECT_CLASS (klass)->finalize = connections_collection_view_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Connections/ui/collection-view.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "flowbox", FALSE, ConnectionsCollectionView_private_offset + G_STRUCT_OFFSET (ConnectionsCollectionViewPrivate, flowbox));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "search_bar", FALSE, G_STRUCT_OFFSET (ConnectionsCollectionView, search_bar));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "search_entry", FALSE, ConnectionsCollectionView_private_offset + G_STRUCT_OFFSET (ConnectionsCollectionViewPrivate, search_entry));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_child_activated", G_CALLBACK(_connections_collection_view_on_child_activated_gtk_flow_box_child_activated));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_button_release_event", G_CALLBACK(_connections_collection_view_on_button_release_event_gtk_widget_button_release_event));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_search_changed", G_CALLBACK(_connections_collection_view_on_search_changed_gtk_search_entry_search_changed));
}

static void
connections_collection_view_instance_init (ConnectionsCollectionView * self,
                                           gpointer klass)
{
	self->priv = connections_collection_view_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
connections_collection_view_finalize (GObject * obj)
{
	ConnectionsCollectionView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CONNECTIONS_TYPE_COLLECTION_VIEW, ConnectionsCollectionView);
	_g_object_unref0 (self->priv->popover);
	G_OBJECT_CLASS (connections_collection_view_parent_class)->finalize (obj);
}

static GType
connections_collection_view_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ConnectionsCollectionViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) connections_collection_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ConnectionsCollectionView), 0, (GInstanceInitFunc) connections_collection_view_instance_init, NULL };
	GType connections_collection_view_type_id;
	connections_collection_view_type_id = g_type_register_static (gtk_scrolled_window_get_type (), "ConnectionsCollectionView", &g_define_type_info, 0);
	ConnectionsCollectionView_private_offset = g_type_add_instance_private (connections_collection_view_type_id, sizeof (ConnectionsCollectionViewPrivate));
	return connections_collection_view_type_id;
}

GType
connections_collection_view_get_type (void)
{
	static volatile gsize connections_collection_view_type_id__once = 0;
	if (g_once_init_enter (&connections_collection_view_type_id__once)) {
		GType connections_collection_view_type_id;
		connections_collection_view_type_id = connections_collection_view_get_type_once ();
		g_once_init_leave (&connections_collection_view_type_id__once, connections_collection_view_type_id);
	}
	return connections_collection_view_type_id__once;
}

