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

/*
 * SPDX-License-Identifier: GPL-3.0-or-later
 * SPDX-FileCopyrightText: 2017-2023 elementary, Inc. (https://elementary.io)
 *
 * Authored by: Leonhard Kargl <leo.kargl@proton.me>
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <camel/camel.h>
#include <glib.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <float.h>
#include <math.h>
#include <granite.h>
#include <handy.h>

#define MAIL_MAIN_WINDOW_ACTION_MOVE "move"
#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 MAIL_TYPE_FOLDER_POPOVER (mail_folder_popover_get_type ())
#define MAIL_FOLDER_POPOVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAIL_TYPE_FOLDER_POPOVER, MailFolderPopover))
#define MAIL_FOLDER_POPOVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MAIL_TYPE_FOLDER_POPOVER, MailFolderPopoverClass))
#define MAIL_IS_FOLDER_POPOVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAIL_TYPE_FOLDER_POPOVER))
#define MAIL_IS_FOLDER_POPOVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MAIL_TYPE_FOLDER_POPOVER))
#define MAIL_FOLDER_POPOVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MAIL_TYPE_FOLDER_POPOVER, MailFolderPopoverClass))

typedef struct _MailFolderPopover MailFolderPopover;
typedef struct _MailFolderPopoverClass MailFolderPopoverClass;
typedef struct _MailFolderPopoverPrivate MailFolderPopoverPrivate;
enum  {
	MAIL_FOLDER_POPOVER_0_PROPERTY,
	MAIL_FOLDER_POPOVER_NUM_PROPERTIES
};
static GParamSpec* mail_folder_popover_properties[MAIL_FOLDER_POPOVER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block46Data Block46Data;
#define __vala_CamelFolderInfo_free0(var) ((var == NULL) ? NULL : (var = (_vala_CamelFolderInfo_free (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

#define MAIL_TYPE_FOLDER_ROW (mail_folder_row_get_type ())
#define MAIL_FOLDER_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAIL_TYPE_FOLDER_ROW, MailFolderRow))
#define MAIL_FOLDER_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MAIL_TYPE_FOLDER_ROW, MailFolderRowClass))
#define MAIL_IS_FOLDER_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAIL_TYPE_FOLDER_ROW))
#define MAIL_IS_FOLDER_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MAIL_TYPE_FOLDER_ROW))
#define MAIL_FOLDER_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MAIL_TYPE_FOLDER_ROW, MailFolderRowClass))

typedef struct _MailFolderRow MailFolderRow;
typedef struct _MailFolderRowClass MailFolderRowClass;
#define _g_free0(var) (var = (g_free (var), NULL))

#define MAIL_TYPE_MAIN_WINDOW (mail_main_window_get_type ())
#define MAIL_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAIL_TYPE_MAIN_WINDOW, MailMainWindow))
#define MAIL_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MAIL_TYPE_MAIN_WINDOW, MailMainWindowClass))
#define MAIL_IS_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAIL_TYPE_MAIN_WINDOW))
#define MAIL_IS_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MAIL_TYPE_MAIN_WINDOW))
#define MAIL_MAIN_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MAIL_TYPE_MAIN_WINDOW, MailMainWindowClass))

typedef struct _MailMainWindow MailMainWindow;
typedef struct _MailMainWindowClass MailMainWindowClass;
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))

struct _MailFolderPopover {
	GtkPopover parent_instance;
	MailFolderPopoverPrivate * priv;
};

struct _MailFolderPopoverClass {
	GtkPopoverClass parent_class;
};

struct _MailFolderPopoverPrivate {
	GtkSearchEntry* search_entry;
	GtkListBox* list_box;
};

struct _Block46Data {
	int _ref_count_;
	MailFolderPopover* self;
	CamelStore* store;
};

static gint MailFolderPopover_private_offset;
static gpointer mail_folder_popover_parent_class = NULL;

VALA_EXTERN GType mail_folder_popover_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MailFolderPopover, g_object_unref)
VALA_EXTERN void mail_folder_popover_set_store (MailFolderPopover* self,
                                    CamelStore* store);
static Block46Data* block46_data_ref (Block46Data* _data46_);
static void block46_data_unref (void * _userdata_);
static void __lambda56_ (Block46Data* _data46_,
                  GObject* obj,
                  GAsyncResult* res);
static void mail_folder_popover_update (MailFolderPopover* self,
                                 CamelFolderInfo* top,
                                 gint depth,
                                 CamelStore* store);
static void _vala_CamelFolderInfo_free (CamelFolderInfo* self);
static void ___lambda56__gasync_ready_callback (GObject* source_object,
                                         GAsyncResult* res,
                                         gpointer self);
static CamelFolderInfo* _vala_CamelFolderInfo_copy (CamelFolderInfo* self);
VALA_EXTERN MailFolderRow* mail_folder_row_new (gint depth,
                                    CamelFolderInfo* folder_info,
                                    CamelStore* store);
VALA_EXTERN MailFolderRow* mail_folder_row_construct (GType object_type,
                                          gint depth,
                                          CamelFolderInfo* folder_info,
                                          CamelStore* store);
VALA_EXTERN GType mail_folder_row_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MailFolderRow, g_object_unref)
static gint mail_folder_popover_sort_func (MailFolderPopover* self,
                                    GtkListBoxRow* row1,
                                    GtkListBoxRow* row2);
VALA_EXTERN gint mail_folder_row_get_pos (MailFolderRow* self);
static gboolean mail_folder_popover_filter_func (MailFolderPopover* self,
                                          GtkListBoxRow* row);
VALA_EXTERN CamelFolderInfo* mail_folder_row_get_folder_info (MailFolderRow* self);
VALA_EXTERN MailFolderPopover* mail_folder_popover_new (void);
VALA_EXTERN MailFolderPopover* mail_folder_popover_construct (GType object_type);
static GObject * mail_folder_popover_constructor (GType type,
                                           guint n_construct_properties,
                                           GObjectConstructParam * construct_properties);
static gint _mail_folder_popover_sort_func_gtk_list_box_sort_func (GtkListBoxRow* row1,
                                                            GtkListBoxRow* row2,
                                                            gpointer self);
static gboolean _mail_folder_popover_filter_func_gtk_list_box_filter_func (GtkListBoxRow* row,
                                                                    gpointer self);
static void _gtk_list_box_invalidate_filter_gtk_search_entry_search_changed (GtkSearchEntry* _sender,
                                                                      gpointer self);
static void _mail_folder_popover___lambda57_ (MailFolderPopover* self,
                                       GtkListBoxRow* row);
VALA_EXTERN GType mail_main_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MailMainWindow, g_object_unref)
static GVariant* _variant_new19 (const gchar* value);
static void __mail_folder_popover___lambda57__gtk_list_box_row_activated (GtkListBox* _sender,
                                                                   GtkListBoxRow* row,
                                                                   gpointer self);
static void mail_folder_popover_finalize (GObject * obj);
static GType mail_folder_popover_get_type_once (void);

static inline gpointer
mail_folder_popover_get_instance_private (MailFolderPopover* self)
{
	return G_STRUCT_MEMBER_P (self, MailFolderPopover_private_offset);
}

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

static Block46Data*
block46_data_ref (Block46Data* _data46_)
{
	g_atomic_int_inc (&_data46_->_ref_count_);
	return _data46_;
}

static void
block46_data_unref (void * _userdata_)
{
	Block46Data* _data46_;
	_data46_ = (Block46Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data46_->_ref_count_)) {
		MailFolderPopover* self;
		self = _data46_->self;
		_g_object_unref0 (_data46_->store);
		_g_object_unref0 (self);
		g_slice_free (Block46Data, _data46_);
	}
}

static void
_vala_CamelFolderInfo_free (CamelFolderInfo* self)
{
	g_boxed_free (camel_folder_info_get_type (), self);
}

static void
__lambda56_ (Block46Data* _data46_,
             GObject* obj,
             GAsyncResult* res)
{
	MailFolderPopover* self;
	GError* _inner_error0_ = NULL;
	self = _data46_->self;
	g_return_if_fail (res != NULL);
	{
		CamelFolderInfo* folder_info = NULL;
		CamelFolderInfo* _tmp0_;
		_tmp0_ = camel_store_get_folder_info_finish (_data46_->store, res, &_inner_error0_);
		folder_info = _tmp0_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		mail_folder_popover_update (self, folder_info, 0, _data46_->store);
		__vala_CamelFolderInfo_free0 (folder_info);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp1_;
		const gchar* _tmp2_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp1_ = e;
		_tmp2_ = _tmp1_->message;
		g_critical ("FolderPopover.vala:91: %s", _tmp2_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		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;
	}
}

static void
___lambda56__gasync_ready_callback (GObject* source_object,
                                    GAsyncResult* res,
                                    gpointer self)
{
	__lambda56_ (self, source_object, res);
	block46_data_unref (self);
}

void
mail_folder_popover_set_store (MailFolderPopover* self,
                               CamelStore* store)
{
	Block46Data* _data46_;
	CamelStore* _tmp0_;
	GtkListBox* _tmp1_;
	GList* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (store != NULL);
	_data46_ = g_slice_new0 (Block46Data);
	_data46_->_ref_count_ = 1;
	_data46_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (store);
	_g_object_unref0 (_data46_->store);
	_data46_->store = _tmp0_;
	_tmp1_ = self->priv->list_box;
	_tmp2_ = gtk_container_get_children ((GtkContainer*) _tmp1_);
	{
		GList* child_collection = NULL;
		GList* child_it = NULL;
		child_collection = _tmp2_;
		for (child_it = child_collection; child_it != NULL; child_it = child_it->next) {
			GtkWidget* child = NULL;
			child = (GtkWidget*) child_it->data;
			{
				GtkWidget* _tmp3_;
				_tmp3_ = child;
				gtk_widget_destroy (_tmp3_);
			}
		}
		(child_collection == NULL) ? NULL : (child_collection = (g_list_free (child_collection), NULL));
	}
	camel_store_get_folder_info (_data46_->store, NULL, CAMEL_STORE_FOLDER_INFO_RECURSIVE, G_PRIORITY_DEFAULT, NULL, ___lambda56__gasync_ready_callback, block46_data_ref (_data46_));
	block46_data_unref (_data46_);
	_data46_ = NULL;
}

static CamelFolderInfo*
_vala_CamelFolderInfo_copy (CamelFolderInfo* self)
{
	return g_boxed_copy (camel_folder_info_get_type (), self);
}

static gpointer
__vala_CamelFolderInfo_copy0 (gpointer self)
{
	return self ? _vala_CamelFolderInfo_copy (self) : NULL;
}

static void
mail_folder_popover_update (MailFolderPopover* self,
                            CamelFolderInfo* top,
                            gint depth,
                            CamelStore* store)
{
	CamelFolderInfo* folder_info = NULL;
	CamelFolderInfo* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (top != NULL);
	g_return_if_fail (store != NULL);
	_tmp0_ = __vala_CamelFolderInfo_copy0 (top);
	folder_info = _tmp0_;
	while (TRUE) {
		CamelFolderInfo* _tmp1_;
		GtkListBox* _tmp2_;
		CamelFolderInfo* _tmp3_;
		MailFolderRow* _tmp4_;
		MailFolderRow* _tmp5_;
		CamelFolderInfo* _tmp6_;
		CamelFolderInfo* _tmp7_;
		CamelFolderInfo* _tmp10_;
		CamelFolderInfo* _tmp11_;
		CamelFolderInfo* _tmp12_;
		_tmp1_ = folder_info;
		if (!(_tmp1_ != NULL)) {
			break;
		}
		_tmp2_ = self->priv->list_box;
		_tmp3_ = folder_info;
		_tmp4_ = mail_folder_row_new (depth, _tmp3_, store);
		g_object_ref_sink (_tmp4_);
		_tmp5_ = _tmp4_;
		gtk_container_add ((GtkContainer*) _tmp2_, (GtkWidget*) _tmp5_);
		_g_object_unref0 (_tmp5_);
		_tmp6_ = folder_info;
		_tmp7_ = _tmp6_->child;
		if (_tmp7_ != NULL) {
			CamelFolderInfo* _tmp8_;
			CamelFolderInfo* _tmp9_;
			_tmp8_ = folder_info;
			_tmp9_ = _tmp8_->child;
			mail_folder_popover_update (self, _tmp9_, depth + 1, store);
		}
		_tmp10_ = folder_info;
		_tmp11_ = _tmp10_->next;
		_tmp12_ = __vala_CamelFolderInfo_copy0 (_tmp11_);
		__vala_CamelFolderInfo_free0 (folder_info);
		folder_info = _tmp12_;
	}
	__vala_CamelFolderInfo_free0 (folder_info);
}

static gint
mail_folder_popover_sort_func (MailFolderPopover* self,
                               GtkListBoxRow* row1,
                               GtkListBoxRow* row2)
{
	gboolean _tmp0_ = FALSE;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (row1 != NULL, -1);
	g_return_val_if_fail (row2 != NULL, -1);
	if (MAIL_IS_FOLDER_ROW (row1)) {
		_tmp0_ = MAIL_IS_FOLDER_ROW (row2);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		MailFolderRow* folder_row1 = NULL;
		MailFolderRow* _tmp1_;
		MailFolderRow* folder_row2 = NULL;
		MailFolderRow* _tmp2_;
		MailFolderRow* _tmp3_;
		gint _tmp4_;
		gint _tmp5_;
		MailFolderRow* _tmp6_;
		gint _tmp7_;
		gint _tmp8_;
		_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (row1, MAIL_TYPE_FOLDER_ROW, MailFolderRow));
		folder_row1 = _tmp1_;
		_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (row2, MAIL_TYPE_FOLDER_ROW, MailFolderRow));
		folder_row2 = _tmp2_;
		_tmp3_ = folder_row1;
		_tmp4_ = mail_folder_row_get_pos (_tmp3_);
		_tmp5_ = _tmp4_;
		_tmp6_ = folder_row2;
		_tmp7_ = mail_folder_row_get_pos (_tmp6_);
		_tmp8_ = _tmp7_;
		result = _tmp5_ - _tmp8_;
		_g_object_unref0 (folder_row2);
		_g_object_unref0 (folder_row1);
		return result;
	}
	result = 0;
	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 gchar*
string_strip (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strstrip (_result_);
	result = _result_;
	return result;
}

static gboolean
mail_folder_popover_filter_func (MailFolderPopover* self,
                                 GtkListBoxRow* row)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (row != NULL, FALSE);
	if (MAIL_IS_FOLDER_ROW (row)) {
		MailFolderRow* folder_row = NULL;
		MailFolderRow* _tmp0_;
		MailFolderRow* _tmp1_;
		CamelFolderInfo* _tmp2_;
		CamelFolderInfo* _tmp3_;
		const gchar* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp6_;
		GtkSearchEntry* _tmp7_;
		const gchar* _tmp8_;
		const gchar* _tmp9_;
		gchar* _tmp10_;
		gchar* _tmp11_;
		gchar* _tmp12_;
		gchar* _tmp13_;
		gboolean _tmp14_;
		_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (row, MAIL_TYPE_FOLDER_ROW, MailFolderRow));
		folder_row = _tmp0_;
		_tmp1_ = folder_row;
		_tmp2_ = mail_folder_row_get_folder_info (_tmp1_);
		_tmp3_ = _tmp2_;
		_tmp4_ = _tmp3_->display_name;
		_tmp5_ = g_utf8_strdown (_tmp4_, (gssize) -1);
		_tmp6_ = _tmp5_;
		_tmp7_ = self->priv->search_entry;
		_tmp8_ = gtk_entry_get_text ((GtkEntry*) _tmp7_);
		_tmp9_ = _tmp8_;
		_tmp10_ = g_utf8_strdown (_tmp9_, (gssize) -1);
		_tmp11_ = _tmp10_;
		_tmp12_ = string_strip (_tmp11_);
		_tmp13_ = _tmp12_;
		_tmp14_ = string_contains (_tmp6_, _tmp13_);
		_g_free0 (_tmp13_);
		_g_free0 (_tmp11_);
		_g_free0 (_tmp6_);
		result = _tmp14_;
		_g_object_unref0 (folder_row);
		return result;
	}
	result = TRUE;
	return result;
}

MailFolderPopover*
mail_folder_popover_construct (GType object_type)
{
	MailFolderPopover * self = NULL;
	self = (MailFolderPopover*) g_object_new (object_type, NULL);
	return self;
}

MailFolderPopover*
mail_folder_popover_new (void)
{
	return mail_folder_popover_construct (MAIL_TYPE_FOLDER_POPOVER);
}

static gint
_mail_folder_popover_sort_func_gtk_list_box_sort_func (GtkListBoxRow* row1,
                                                       GtkListBoxRow* row2,
                                                       gpointer self)
{
	gint result;
	result = mail_folder_popover_sort_func ((MailFolderPopover*) self, row1, row2);
	return result;
}

static gboolean
_mail_folder_popover_filter_func_gtk_list_box_filter_func (GtkListBoxRow* row,
                                                           gpointer self)
{
	gboolean result;
	result = mail_folder_popover_filter_func ((MailFolderPopover*) self, row);
	return result;
}

static void
_gtk_list_box_invalidate_filter_gtk_search_entry_search_changed (GtkSearchEntry* _sender,
                                                                 gpointer self)
{
	gtk_list_box_invalidate_filter ((GtkListBox*) self);
}

static GVariant*
_variant_new19 (const gchar* value)
{
	return g_variant_ref_sink (g_variant_new_string (value));
}

static void
_mail_folder_popover___lambda57_ (MailFolderPopover* self,
                                  GtkListBoxRow* row)
{
	g_return_if_fail (row != NULL);
	if (MAIL_IS_FOLDER_ROW (row)) {
		MailFolderRow* folder_row = NULL;
		MailFolderRow* _tmp0_;
		GtkWidget* _tmp1_;
		CamelFolderInfo* _tmp2_;
		CamelFolderInfo* _tmp3_;
		const gchar* _tmp4_;
		GVariant* _tmp5_;
		_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (row, MAIL_TYPE_FOLDER_ROW, MailFolderRow));
		folder_row = _tmp0_;
		gtk_popover_popdown ((GtkPopover*) self);
		_tmp1_ = gtk_widget_get_toplevel ((GtkWidget*) self);
		_tmp2_ = mail_folder_row_get_folder_info ((MailFolderRow*) row);
		_tmp3_ = _tmp2_;
		_tmp4_ = _tmp3_->full_name;
		_tmp5_ = _variant_new19 (_tmp4_);
		g_action_group_activate_action ((GActionGroup*) G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, MAIL_TYPE_MAIN_WINDOW, MailMainWindow), MAIL_MAIN_WINDOW_ACTION_MOVE, _tmp5_);
		_g_variant_unref0 (_tmp5_);
		_g_object_unref0 (folder_row);
	}
}

static void
__mail_folder_popover___lambda57__gtk_list_box_row_activated (GtkListBox* _sender,
                                                              GtkListBoxRow* row,
                                                              gpointer self)
{
	_mail_folder_popover___lambda57_ ((MailFolderPopover*) self, row);
}

static GObject *
mail_folder_popover_constructor (GType type,
                                 guint n_construct_properties,
                                 GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	MailFolderPopover * self;
	GtkSearchEntry* _tmp0_ = NULL;
	GtkImage* placeholder_image = NULL;
	GtkImage* _tmp1_;
	GtkLabel* placeholder_title = NULL;
	GtkLabel* _tmp2_ = NULL;
	GtkLabel* placeholder_subtitle = NULL;
	GtkLabel* _tmp3_ = NULL;
	GtkLabel* _tmp4_;
	GtkStyleContext* _tmp5_;
	GtkLabel* _tmp6_;
	GtkStyleContext* _tmp7_;
	GtkGrid* placeholder = NULL;
	GtkGrid* _tmp8_ = NULL;
	GtkGrid* _tmp9_;
	GtkImage* _tmp10_;
	GtkGrid* _tmp11_;
	GtkLabel* _tmp12_;
	GtkGrid* _tmp13_;
	GtkLabel* _tmp14_;
	GtkGrid* _tmp15_;
	GtkListBox* _tmp16_ = NULL;
	GtkListBox* _tmp17_;
	GtkListBox* _tmp18_;
	GtkListBox* _tmp19_;
	GtkGrid* _tmp20_;
	GtkScrolledWindow* scrolled_window = NULL;
	GtkListBox* _tmp21_;
	GtkWidget* _tmp22_;
	GtkScrolledWindow* _tmp23_ = NULL;
	GtkBox* box = NULL;
	GtkBox* _tmp24_;
	GtkBox* _tmp25_;
	GtkSearchEntry* _tmp26_;
	GtkBox* _tmp27_;
	GtkScrolledWindow* _tmp28_;
	GtkBox* _tmp29_;
	GtkBox* _tmp30_;
	GtkSearchEntry* _tmp31_;
	GtkListBox* _tmp32_;
	GtkListBox* _tmp33_;
	parent_class = G_OBJECT_CLASS (mail_folder_popover_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, MAIL_TYPE_FOLDER_POPOVER, MailFolderPopover);
	_tmp0_ = (GtkSearchEntry*) gtk_search_entry_new ();
	gtk_widget_set_margin_top ((GtkWidget*) _tmp0_, 12);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp0_, 9);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp0_, 12);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp0_, 12);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->search_entry);
	self->priv->search_entry = _tmp0_;
	_tmp1_ = (GtkImage*) gtk_image_new_from_icon_name ("edit-find-symbolic", (GtkIconSize) GTK_ICON_SIZE_DND);
	g_object_ref_sink (_tmp1_);
	placeholder_image = _tmp1_;
	_tmp2_ = (GtkLabel*) gtk_label_new (_ ("No mailboxes found"));
	gtk_label_set_xalign (_tmp2_, (gfloat) 0);
	g_object_ref_sink (_tmp2_);
	placeholder_title = _tmp2_;
	_tmp3_ = (GtkLabel*) gtk_label_new (_ ("Try changing search terms"));
	gtk_label_set_xalign (_tmp3_, (gfloat) 0);
	g_object_ref_sink (_tmp3_);
	placeholder_subtitle = _tmp3_;
	_tmp4_ = placeholder_subtitle;
	_tmp5_ = gtk_widget_get_style_context ((GtkWidget*) _tmp4_);
	gtk_style_context_add_class (_tmp5_, GTK_STYLE_CLASS_DIM_LABEL);
	_tmp6_ = placeholder_subtitle;
	_tmp7_ = gtk_widget_get_style_context ((GtkWidget*) _tmp6_);
	gtk_style_context_add_class (_tmp7_, GRANITE_STYLE_CLASS_SMALL_LABEL);
	_tmp8_ = (GtkGrid*) gtk_grid_new ();
	gtk_grid_set_column_spacing (_tmp8_, 6);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp8_, 6);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp8_, 12);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp8_, 12);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp8_, 12);
	g_object_ref_sink (_tmp8_);
	placeholder = _tmp8_;
	_tmp9_ = placeholder;
	_tmp10_ = placeholder_image;
	gtk_grid_attach (_tmp9_, (GtkWidget*) _tmp10_, 0, 0, 1, 2);
	_tmp11_ = placeholder;
	_tmp12_ = placeholder_title;
	gtk_grid_attach (_tmp11_, (GtkWidget*) _tmp12_, 1, 0, 1, 1);
	_tmp13_ = placeholder;
	_tmp14_ = placeholder_subtitle;
	gtk_grid_attach (_tmp13_, (GtkWidget*) _tmp14_, 1, 1, 1, 1);
	_tmp15_ = placeholder;
	gtk_widget_show_all ((GtkWidget*) _tmp15_);
	_tmp16_ = (GtkListBox*) gtk_list_box_new ();
	gtk_list_box_set_activate_on_single_click (_tmp16_, TRUE);
	g_object_ref_sink (_tmp16_);
	_g_object_unref0 (self->priv->list_box);
	self->priv->list_box = _tmp16_;
	_tmp17_ = self->priv->list_box;
	gtk_list_box_set_sort_func (_tmp17_, _mail_folder_popover_sort_func_gtk_list_box_sort_func, g_object_ref (self), g_object_unref);
	_tmp18_ = self->priv->list_box;
	gtk_list_box_set_filter_func (_tmp18_, _mail_folder_popover_filter_func_gtk_list_box_filter_func, g_object_ref (self), g_object_unref);
	_tmp19_ = self->priv->list_box;
	_tmp20_ = placeholder;
	gtk_list_box_set_placeholder (_tmp19_, (GtkWidget*) _tmp20_);
	_tmp21_ = self->priv->list_box;
	_tmp22_ = _g_object_ref0 ((GtkWidget*) _tmp21_);
	_tmp23_ = (GtkScrolledWindow*) gtk_scrolled_window_new (NULL, NULL);
	g_object_set ((GtkContainer*) _tmp23_, "child", _tmp22_, NULL);
	_g_object_unref0 (_tmp22_);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp23_, TRUE);
	gtk_widget_set_vexpand ((GtkWidget*) _tmp23_, TRUE);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp23_, 3);
	gtk_scrolled_window_set_max_content_height (_tmp23_, 350);
	gtk_scrolled_window_set_propagate_natural_height (_tmp23_, TRUE);
	g_object_set (_tmp23_, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
	g_object_ref_sink (_tmp23_);
	scrolled_window = _tmp23_;
	_tmp24_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp24_);
	box = _tmp24_;
	_tmp25_ = box;
	_tmp26_ = self->priv->search_entry;
	gtk_container_add ((GtkContainer*) _tmp25_, (GtkWidget*) _tmp26_);
	_tmp27_ = box;
	_tmp28_ = scrolled_window;
	gtk_container_add ((GtkContainer*) _tmp27_, (GtkWidget*) _tmp28_);
	_tmp29_ = box;
	gtk_widget_show_all ((GtkWidget*) _tmp29_);
	g_object_set ((GtkWidget*) self, "width-request", 250, NULL);
	_tmp30_ = box;
	g_object_set ((GtkContainer*) self, "child", (GtkWidget*) _tmp30_, NULL);
	_tmp31_ = self->priv->search_entry;
	_tmp32_ = self->priv->list_box;
	g_signal_connect_object (_tmp31_, "search-changed", (GCallback) _gtk_list_box_invalidate_filter_gtk_search_entry_search_changed, _tmp32_, 0);
	_tmp33_ = self->priv->list_box;
	g_signal_connect_object (_tmp33_, "row-activated", (GCallback) __mail_folder_popover___lambda57__gtk_list_box_row_activated, self, 0);
	_g_object_unref0 (box);
	_g_object_unref0 (scrolled_window);
	_g_object_unref0 (placeholder);
	_g_object_unref0 (placeholder_subtitle);
	_g_object_unref0 (placeholder_title);
	_g_object_unref0 (placeholder_image);
	return obj;
}

static void
mail_folder_popover_class_init (MailFolderPopoverClass * klass,
                                gpointer klass_data)
{
	mail_folder_popover_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &MailFolderPopover_private_offset);
	G_OBJECT_CLASS (klass)->constructor = mail_folder_popover_constructor;
	G_OBJECT_CLASS (klass)->finalize = mail_folder_popover_finalize;
}

static void
mail_folder_popover_instance_init (MailFolderPopover * self,
                                   gpointer klass)
{
	self->priv = mail_folder_popover_get_instance_private (self);
}

static void
mail_folder_popover_finalize (GObject * obj)
{
	MailFolderPopover * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, MAIL_TYPE_FOLDER_POPOVER, MailFolderPopover);
	_g_object_unref0 (self->priv->search_entry);
	_g_object_unref0 (self->priv->list_box);
	G_OBJECT_CLASS (mail_folder_popover_parent_class)->finalize (obj);
}

static GType
mail_folder_popover_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (MailFolderPopoverClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) mail_folder_popover_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MailFolderPopover), 0, (GInstanceInitFunc) mail_folder_popover_instance_init, NULL };
	GType mail_folder_popover_type_id;
	mail_folder_popover_type_id = g_type_register_static (gtk_popover_get_type (), "MailFolderPopover", &g_define_type_info, 0);
	MailFolderPopover_private_offset = g_type_add_instance_private (mail_folder_popover_type_id, sizeof (MailFolderPopoverPrivate));
	return mail_folder_popover_type_id;
}

GType
mail_folder_popover_get_type (void)
{
	static volatile gsize mail_folder_popover_type_id__once = 0;
	if (g_once_init_enter (&mail_folder_popover_type_id__once)) {
		GType mail_folder_popover_type_id;
		mail_folder_popover_type_id = mail_folder_popover_get_type_once ();
		g_once_init_leave (&mail_folder_popover_type_id__once, mail_folder_popover_type_id);
	}
	return mail_folder_popover_type_id__once;
}

