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

/*-
 * Copyright 2015-2019 elementary, Inc. (https://elementary.io)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 2.1 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "notifications.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib/gi18n-lib.h>
#include <float.h>
#include <math.h>
#include <granite-7.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

enum  {
	NOTIFICATIONS_APP_ENTRY_0_PROPERTY,
	NOTIFICATIONS_APP_ENTRY_APP_ID_PROPERTY,
	NOTIFICATIONS_APP_ENTRY_APP_INFO_PROPERTY,
	NOTIFICATIONS_APP_ENTRY_NUM_PROPERTIES
};
static GParamSpec* notifications_app_entry_properties[NOTIFICATIONS_APP_ENTRY_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
typedef struct _Block3Data Block3Data;
typedef struct _Block4Data Block4Data;
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
enum  {
	NOTIFICATIONS_APP_ENTRY_CLEAR_SIGNAL,
	NOTIFICATIONS_APP_ENTRY_NUM_SIGNALS
};
static guint notifications_app_entry_signals[NOTIFICATIONS_APP_ENTRY_NUM_SIGNALS] = {0};

struct _NotificationsAppEntryPrivate {
	gchar* _app_id;
	GAppInfo* _app_info;
	GtkToggleButton* expander;
};

struct _Block3Data {
	int _ref_count_;
	NotificationsAppEntry* self;
	NotificationsNotification** to_remove;
	gint to_remove_length1;
	gint _to_remove_size_;
};

struct _Block4Data {
	int _ref_count_;
	NotificationsAppEntry* self;
	GtkImage* clear_btn_image;
};

static gint NotificationsAppEntry_private_offset;
static gpointer notifications_app_entry_parent_class = NULL;
static GtkCssProvider* notifications_app_entry_provider;
static GtkCssProvider* notifications_app_entry_provider = NULL;
static GSettings* notifications_app_entry_settings;
static GSettings* notifications_app_entry_settings = NULL;
static GHashTable* notifications_app_entry_headers;
static GHashTable* notifications_app_entry_headers = NULL;

static void _g_object_unref0_ (gpointer var);
static inline void _g_list_free__g_object_unref0_ (GList* self);
static void _notifications_app_entry_remove_notification_entry_notifications_notification_entry_clear (NotificationsNotificationEntry* _sender,
                                                                                                gpointer self);
static GVariant* _variant_new2 (GHashTable* value);
static Block3Data* block3_data_ref (Block3Data* _data3_);
static void block3_data_unref (void * _userdata_);
static void __lambda11_ (Block3Data* _data3_,
                  NotificationsNotificationEntry* entry);
static void _vala_array_add1 (NotificationsNotification** * array,
                       gint* length,
                       gint* size,
                       NotificationsNotification* value);
static void ___lambda11__gfunc (gconstpointer data,
                         gpointer self);
static void notifications_app_entry_set_app_id (NotificationsAppEntry* self,
                                         const gchar* value);
static GObject * notifications_app_entry_constructor (GType type,
                                               guint n_construct_properties,
                                               GObjectConstructParam * construct_properties);
static Block4Data* block4_data_ref (Block4Data* _data4_);
static void block4_data_unref (void * _userdata_);
static void _notifications_app_entry___lambda12_ (NotificationsAppEntry* self);
static GVariant* _variant_new3 (GHashTable* value);
static void __notifications_app_entry___lambda12__gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                                      gpointer self);
static void _notifications_app_entry___lambda13_ (Block4Data* _data4_);
static gboolean __lambda14_ (NotificationsAppEntry* self);
static gboolean ___lambda14__gsource_func (gpointer self);
static void __notifications_app_entry___lambda13__gtk_button_clicked (GtkButton* _sender,
                                                               gpointer self);
static gboolean _notifications_app_entry___lambda15_ (NotificationsAppEntry* self,
                                               GBinding* binding,
                                               GValue* srcval,
                                               GValue* targetval);
static gboolean __notifications_app_entry___lambda15__gbinding_transform_func (GBinding* binding,
                                                                        GValue* from_value,
                                                                        GValue* to_value,
                                                                        gpointer self);
static GHashTable* _variant_get1 (GVariant* value);
static void notifications_app_entry_finalize (GObject * obj);
static GType notifications_app_entry_get_type_once (void);
static void _vala_notifications_app_entry_get_property (GObject * object,
                                                 guint property_id,
                                                 GValue * value,
                                                 GParamSpec * pspec);
static void _vala_notifications_app_entry_set_property (GObject * object,
                                                 guint property_id,
                                                 const GValue * value,
                                                 GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static inline gpointer
notifications_app_entry_get_instance_private (NotificationsAppEntry* self)
{
	return G_STRUCT_MEMBER_P (self, NotificationsAppEntry_private_offset);
}

static void
_g_object_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}

static inline void
_g_list_free__g_object_unref0_ (GList* self)
{
	g_list_free_full (self, (GDestroyNotify) _g_object_unref0_);
}

NotificationsAppEntry*
notifications_app_entry_construct (GType object_type,
                                   GAppInfo* app_info)
{
	NotificationsAppEntry * self = NULL;
	self = (NotificationsAppEntry*) g_object_new (object_type, "app-info", app_info, NULL);
	return self;
}

NotificationsAppEntry*
notifications_app_entry_new (GAppInfo* app_info)
{
	return notifications_app_entry_construct (NOTIFICATIONS_TYPE_APP_ENTRY, app_info);
}

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

static void
_notifications_app_entry_remove_notification_entry_notifications_notification_entry_clear (NotificationsNotificationEntry* _sender,
                                                                                           gpointer self)
{
	notifications_app_entry_remove_notification_entry ((NotificationsAppEntry*) self, _sender);
}

void
notifications_app_entry_add_notification_entry (NotificationsAppEntry* self,
                                                NotificationsNotificationEntry* entry)
{
	NotificationsNotificationEntry* _tmp0_;
	GtkToggleButton* _tmp1_;
	GtkRevealer* _tmp2_;
	GtkRevealer* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (entry != NULL);
	_tmp0_ = _g_object_ref0 (entry);
	self->app_notifications = g_list_prepend (self->app_notifications, _tmp0_);
	g_signal_connect_object (entry, "clear", (GCallback) _notifications_app_entry_remove_notification_entry_notifications_notification_entry_clear, self, 0);
	_tmp1_ = self->priv->expander;
	_tmp2_ = notifications_notification_entry_get_revealer (entry);
	_tmp3_ = _tmp2_;
	g_object_bind_property_with_closures ((GObject*) _tmp1_, "active", (GObject*) _tmp3_, "reveal-child", 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)));
}

static GList*
vala_g_list_remove_full (GList* self,
                         gconstpointer data,
                         GFreeFunc func)
{
	GList* l = NULL;
	GList* result;
	l = self;
	while (TRUE) {
		GList* _tmp0_;
		GList* _tmp1_;
		gconstpointer _tmp2_;
		_tmp0_ = l;
		if (!(_tmp0_ != NULL)) {
			break;
		}
		_tmp1_ = l;
		_tmp2_ = ((GList*) _tmp1_)->data;
		if (_tmp2_ != data) {
			GList* _tmp3_;
			GList* _tmp4_;
			_tmp3_ = l;
			_tmp4_ = ((GList*) _tmp3_)->next;
			l = _tmp4_;
		} else {
			GList* _tmp5_;
			gconstpointer _tmp6_;
			GList* _tmp7_;
			_tmp5_ = l;
			_tmp6_ = ((GList*) _tmp5_)->data;
			func (_tmp6_);
			_tmp7_ = l;
			self = g_list_delete_link (self, (GList*) _tmp7_);
			break;
		}
	}
	result = self;
	return result;
}

static GVariant*
_variant_new2 (GHashTable* value)
{
	GVariantBuilder _tmp9_;
	GHashTableIter _tmp10_;
	gpointer _tmp11_;
	gpointer _tmp12_;
	g_hash_table_iter_init (&_tmp10_, value);
	g_variant_builder_init (&_tmp9_, G_VARIANT_TYPE ("a{sb}"));
	while (g_hash_table_iter_next (&_tmp10_, &_tmp11_, &_tmp12_)) {
		gchar* _key;
		gboolean _value;
		_key = (gchar*) _tmp11_;
		_value = (gboolean) ((gintptr) _tmp12_);
		g_variant_builder_add (&_tmp9_, "{?*}", g_variant_new_string (_key), g_variant_new_boolean (_value));
	}
	return g_variant_ref_sink (g_variant_builder_end (&_tmp9_));
}

void
notifications_app_entry_remove_notification_entry (NotificationsAppEntry* self,
                                                   NotificationsNotificationEntry* entry)
{
	NotificationsSession* _tmp0_;
	NotificationsSession* _tmp1_;
	NotificationsNotification* _tmp2_;
	NotificationsNotification* _tmp3_;
	GList* _tmp4_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (entry != NULL);
	self->app_notifications = vala_g_list_remove_full (self->app_notifications, entry, _g_object_unref0_);
	notifications_notification_entry_dismiss (entry);
	_tmp0_ = notifications_session_get_instance ();
	_tmp1_ = _tmp0_;
	_tmp2_ = notifications_notification_entry_get_notification (entry);
	_tmp3_ = _tmp2_;
	notifications_session_remove_notification (_tmp1_, _tmp3_, TRUE);
	_g_object_unref0 (_tmp1_);
	_tmp4_ = self->app_notifications;
	if (g_list_length (_tmp4_) == ((guint) 0)) {
		GHashTable* _tmp5_;
		const gchar* _tmp6_;
		_tmp5_ = notifications_app_entry_headers;
		_tmp6_ = self->priv->_app_id;
		if (g_hash_table_remove (_tmp5_, _tmp6_)) {
			GSettings* _tmp7_;
			GHashTable* _tmp8_;
			GVariant* _tmp13_;
			_tmp7_ = notifications_app_entry_settings;
			_tmp8_ = notifications_app_entry_headers;
			_tmp13_ = _variant_new2 (_tmp8_);
			g_settings_set_value (_tmp7_, "headers", _tmp13_);
			_g_variant_unref0 (_tmp13_);
		}
		g_signal_emit (self, notifications_app_entry_signals[NOTIFICATIONS_APP_ENTRY_CLEAR_SIGNAL], 0);
	}
}

static Block3Data*
block3_data_ref (Block3Data* _data3_)
{
	g_atomic_int_inc (&_data3_->_ref_count_);
	return _data3_;
}

static void
block3_data_unref (void * _userdata_)
{
	Block3Data* _data3_;
	_data3_ = (Block3Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data3_->_ref_count_)) {
		NotificationsAppEntry* self;
		self = _data3_->self;
		_data3_->to_remove = (_vala_array_free (_data3_->to_remove, _data3_->to_remove_length1, (GDestroyNotify) g_object_unref), NULL);
		_g_object_unref0 (self);
		g_slice_free (Block3Data, _data3_);
	}
}

static void
_vala_array_add1 (NotificationsNotification** * array,
                  gint* length,
                  gint* size,
                  NotificationsNotification* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (NotificationsNotification*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
__lambda11_ (Block3Data* _data3_,
             NotificationsNotificationEntry* entry)
{
	NotificationsAppEntry* self;
	NotificationsNotification* _tmp0_;
	NotificationsNotification* _tmp1_;
	NotificationsNotification* _tmp2_;
	self = _data3_->self;
	g_return_if_fail (entry != NULL);
	notifications_notification_entry_dismiss (entry);
	_tmp0_ = notifications_notification_entry_get_notification (entry);
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_vala_array_add1 (&_data3_->to_remove, &_data3_->to_remove_length1, &_data3_->_to_remove_size_, _tmp2_);
}

static void
___lambda11__gfunc (gconstpointer data,
                    gpointer self)
{
	__lambda11_ (self, (NotificationsNotificationEntry*) data);
}

void
notifications_app_entry_clear_all_notification_entries (NotificationsAppEntry* self)
{
	Block3Data* _data3_;
	NotificationsNotification** _tmp0_;
	GList* _tmp1_;
	NotificationsSession* _tmp2_;
	NotificationsSession* _tmp3_;
	g_return_if_fail (self != NULL);
	_data3_ = g_slice_new0 (Block3Data);
	_data3_->_ref_count_ = 1;
	_data3_->self = g_object_ref (self);
	_tmp0_ = g_new0 (NotificationsNotification*, 0 + 1);
	_data3_->to_remove = _tmp0_;
	_data3_->to_remove_length1 = 0;
	_data3_->_to_remove_size_ = _data3_->to_remove_length1;
	_tmp1_ = self->app_notifications;
	g_list_foreach (_tmp1_, ___lambda11__gfunc, _data3_);
	(self->app_notifications == NULL) ? NULL : (self->app_notifications = (_g_list_free__g_object_unref0_ (self->app_notifications), NULL));
	self->app_notifications = NULL;
	_tmp2_ = notifications_session_get_instance ();
	_tmp3_ = _tmp2_;
	notifications_session_remove_notifications (_tmp3_, _data3_->to_remove, (gint) _data3_->to_remove_length1);
	_g_object_unref0 (_tmp3_);
	block3_data_unref (_data3_);
	_data3_ = NULL;
}

const gchar*
notifications_app_entry_get_app_id (NotificationsAppEntry* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_app_id;
	result = _tmp0_;
	return result;
}

static void
notifications_app_entry_set_app_id (NotificationsAppEntry* self,
                                    const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = notifications_app_entry_get_app_id (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_app_id);
		self->priv->_app_id = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, notifications_app_entry_properties[NOTIFICATIONS_APP_ENTRY_APP_ID_PROPERTY]);
	}
}

GAppInfo*
notifications_app_entry_get_app_info (NotificationsAppEntry* self)
{
	GAppInfo* result;
	GAppInfo* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_app_info;
	result = _tmp0_;
	return result;
}

static void
notifications_app_entry_set_app_info (NotificationsAppEntry* self,
                                      GAppInfo* value)
{
	GAppInfo* old_value;
	g_return_if_fail (self != NULL);
	old_value = notifications_app_entry_get_app_info (self);
	if (old_value != value) {
		GAppInfo* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_app_info);
		self->priv->_app_info = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, notifications_app_entry_properties[NOTIFICATIONS_APP_ENTRY_APP_INFO_PROPERTY]);
	}
}

static Block4Data*
block4_data_ref (Block4Data* _data4_)
{
	g_atomic_int_inc (&_data4_->_ref_count_);
	return _data4_;
}

static void
block4_data_unref (void * _userdata_)
{
	Block4Data* _data4_;
	_data4_ = (Block4Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data4_->_ref_count_)) {
		NotificationsAppEntry* self;
		self = _data4_->self;
		_g_object_unref0 (_data4_->clear_btn_image);
		_g_object_unref0 (self);
		g_slice_free (Block4Data, _data4_);
	}
}

static GVariant*
_variant_new3 (GHashTable* value)
{
	GVariantBuilder _tmp8_;
	GHashTableIter _tmp9_;
	gpointer _tmp10_;
	gpointer _tmp11_;
	g_hash_table_iter_init (&_tmp9_, value);
	g_variant_builder_init (&_tmp8_, G_VARIANT_TYPE ("a{sb}"));
	while (g_hash_table_iter_next (&_tmp9_, &_tmp10_, &_tmp11_)) {
		gchar* _key;
		gboolean _value;
		_key = (gchar*) _tmp10_;
		_value = (gboolean) ((gintptr) _tmp11_);
		g_variant_builder_add (&_tmp8_, "{?*}", g_variant_new_string (_key), g_variant_new_boolean (_value));
	}
	return g_variant_ref_sink (g_variant_builder_end (&_tmp8_));
}

static void
_notifications_app_entry___lambda12_ (NotificationsAppEntry* self)
{
	GHashTable* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	GtkToggleButton* _tmp3_;
	gboolean _tmp4_;
	gboolean _tmp5_;
	GSettings* _tmp6_;
	GHashTable* _tmp7_;
	GVariant* _tmp12_;
	_tmp0_ = notifications_app_entry_headers;
	_tmp1_ = self->priv->_app_id;
	_tmp2_ = g_strdup (_tmp1_);
	_tmp3_ = self->priv->expander;
	_tmp4_ = gtk_toggle_button_get_active (_tmp3_);
	_tmp5_ = _tmp4_;
	g_hash_table_insert (_tmp0_, _tmp2_, (gpointer) ((gintptr) _tmp5_));
	_tmp6_ = notifications_app_entry_settings;
	_tmp7_ = notifications_app_entry_headers;
	_tmp12_ = _variant_new3 (_tmp7_);
	g_settings_set_value (_tmp6_, "headers", _tmp12_);
	_g_variant_unref0 (_tmp12_);
}

static void
__notifications_app_entry___lambda12__gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                                 gpointer self)
{
	_notifications_app_entry___lambda12_ ((NotificationsAppEntry*) self);
}

static gboolean
__lambda14_ (NotificationsAppEntry* self)
{
	gboolean result;
	g_signal_emit (self, notifications_app_entry_signals[NOTIFICATIONS_APP_ENTRY_CLEAR_SIGNAL], 0);
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
___lambda14__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda14_ ((NotificationsAppEntry*) self);
	return result;
}

static void
_notifications_app_entry___lambda13_ (Block4Data* _data4_)
{
	NotificationsAppEntry* self;
	GtkImage* _tmp0_;
	self = _data4_->self;
	_tmp0_ = _data4_->clear_btn_image;
	gtk_widget_add_css_class ((GtkWidget*) _tmp0_, "active");
	notifications_app_entry_clear_all_notification_entries (self);
	g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 600, ___lambda14__gsource_func, g_object_ref (self), g_object_unref);
}

static void
__notifications_app_entry___lambda13__gtk_button_clicked (GtkButton* _sender,
                                                          gpointer self)
{
	_notifications_app_entry___lambda13_ (self);
}

static gboolean
_notifications_app_entry___lambda15_ (NotificationsAppEntry* self,
                                      GBinding* binding,
                                      GValue* srcval,
                                      GValue* targetval)
{
	const gchar* _tmp0_ = NULL;
	GValue _tmp1_;
	GValue _tmp2_ = {0};
	gboolean result;
	g_return_val_if_fail (binding != NULL, FALSE);
	g_return_val_if_fail (srcval != NULL, FALSE);
	g_return_val_if_fail (targetval != NULL, FALSE);
	_tmp1_ = *srcval;
	if (g_value_get_boolean (&_tmp1_)) {
		_tmp0_ = _ ("Show less");
	} else {
		_tmp0_ = _ ("Show more");
	}
	g_value_init (&_tmp2_, G_TYPE_STRING);
	g_value_set_string (&_tmp2_, _tmp0_);
	G_IS_VALUE (targetval) ? (g_value_unset (targetval), NULL) : NULL;
	*targetval = _tmp2_;
	result = TRUE;
	return result;
}

static gboolean
__notifications_app_entry___lambda15__gbinding_transform_func (GBinding* binding,
                                                               GValue* from_value,
                                                               GValue* to_value,
                                                               gpointer self)
{
	gboolean result;
	result = _notifications_app_entry___lambda15_ ((NotificationsAppEntry*) self, binding, from_value, to_value);
	return result;
}

static GObject *
notifications_app_entry_constructor (GType type,
                                     guint n_construct_properties,
                                     GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	NotificationsAppEntry * self;
	Block4Data* _data4_;
	const gchar* name = NULL;
	GAppInfo* _tmp0_;
	GtkImage* image = NULL;
	GtkImage* _tmp5_;
	GtkLabel* label = NULL;
	const gchar* _tmp6_;
	GtkLabel* _tmp7_ = NULL;
	GtkLabel* _tmp8_;
	GtkBox* expander_content = NULL;
	GtkBox* _tmp9_;
	GtkBox* _tmp10_;
	GtkLabel* _tmp11_;
	GtkBox* _tmp12_;
	GtkImage* _tmp13_;
	GtkBox* _tmp14_;
	GtkWidget* _tmp15_;
	GtkToggleButton* _tmp16_ = NULL;
	GtkToggleButton* _tmp17_;
	GtkToggleButton* _tmp18_;
	GtkImage* _tmp19_;
	GtkImage* _tmp20_;
	GtkButton* clear_btn_entry = NULL;
	const gchar* _tmp21_;
	gchar* _tmp22_;
	GtkImage* _tmp23_;
	GtkWidget* _tmp24_;
	GtkButton* _tmp25_ = NULL;
	GtkBox* box = NULL;
	GtkBox* _tmp26_;
	GtkBox* _tmp27_;
	GtkToggleButton* _tmp28_;
	GtkBox* _tmp29_;
	GtkButton* _tmp30_;
	GtkBox* _tmp31_;
	GHashTable* _tmp32_;
	const gchar* _tmp33_;
	GtkToggleButton* _tmp38_;
	GtkButton* _tmp39_;
	GtkToggleButton* _tmp40_;
	GtkImage* _tmp41_;
	parent_class = G_OBJECT_CLASS (notifications_app_entry_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, NOTIFICATIONS_TYPE_APP_ENTRY, NotificationsAppEntry);
	_data4_ = g_slice_new0 (Block4Data);
	_data4_->_ref_count_ = 1;
	_data4_->self = g_object_ref (self);
	(self->app_notifications == NULL) ? NULL : (self->app_notifications = (_g_list_free__g_object_unref0_ (self->app_notifications), NULL));
	self->app_notifications = NULL;
	_tmp0_ = self->priv->_app_info;
	if (_tmp0_ != NULL) {
		GAppInfo* _tmp1_;
		const gchar* _tmp2_;
		GAppInfo* _tmp3_;
		const gchar* _tmp4_;
		_tmp1_ = self->priv->_app_info;
		_tmp2_ = g_app_info_get_id (_tmp1_);
		notifications_app_entry_set_app_id (self, _tmp2_);
		_tmp3_ = self->priv->_app_info;
		_tmp4_ = g_app_info_get_name (_tmp3_);
		name = _tmp4_;
	} else {
		notifications_app_entry_set_app_id (self, "other");
		name = _ ("Other");
	}
	_tmp5_ = (GtkImage*) gtk_image_new_from_icon_name ("pan-end-symbolic");
	g_object_ref_sink (_tmp5_);
	image = _tmp5_;
	_tmp6_ = name;
	_tmp7_ = (GtkLabel*) gtk_label_new (_tmp6_);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp7_, TRUE);
	gtk_label_set_xalign (_tmp7_, (gfloat) 0);
	g_object_ref_sink (_tmp7_);
	label = _tmp7_;
	_tmp8_ = label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp8_, GRANITE_STYLE_CLASS_H3_LABEL);
	_tmp9_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
	g_object_ref_sink (_tmp9_);
	expander_content = _tmp9_;
	_tmp10_ = expander_content;
	_tmp11_ = label;
	gtk_box_append (_tmp10_, (GtkWidget*) _tmp11_);
	_tmp12_ = expander_content;
	_tmp13_ = image;
	gtk_box_append (_tmp12_, (GtkWidget*) _tmp13_);
	_tmp14_ = expander_content;
	_tmp15_ = _g_object_ref0 ((GtkWidget*) _tmp14_);
	_tmp16_ = (GtkToggleButton*) gtk_toggle_button_new ();
	gtk_button_set_child ((GtkButton*) _tmp16_, _tmp15_);
	_g_object_unref0 (_tmp15_);
	gtk_toggle_button_set_active (_tmp16_, TRUE);
	g_object_ref_sink (_tmp16_);
	_g_object_unref0 (self->priv->expander);
	self->priv->expander = _tmp16_;
	_tmp17_ = self->priv->expander;
	gtk_widget_add_css_class ((GtkWidget*) _tmp17_, "image-button");
	_tmp18_ = self->priv->expander;
	gtk_widget_add_css_class ((GtkWidget*) _tmp18_, "expander");
	_tmp19_ = (GtkImage*) gtk_image_new_from_icon_name ("edit-clear-all-symbolic");
	g_object_ref_sink (_tmp19_);
	_data4_->clear_btn_image = _tmp19_;
	_tmp20_ = _data4_->clear_btn_image;
	gtk_widget_add_css_class ((GtkWidget*) _tmp20_, "sweep-animation");
	_tmp21_ = name;
	_tmp22_ = g_strdup_printf (_ ("Clear all %s notifications"), _tmp21_);
	_tmp23_ = _data4_->clear_btn_image;
	_tmp24_ = _g_object_ref0 ((GtkWidget*) _tmp23_);
	_tmp25_ = (GtkButton*) gtk_button_new ();
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp25_, _tmp22_);
	_g_free0 (_tmp22_);
	gtk_button_set_child (_tmp25_, _tmp24_);
	_g_object_unref0 (_tmp24_);
	gtk_button_set_has_frame (_tmp25_, FALSE);
	g_object_ref_sink (_tmp25_);
	clear_btn_entry = _tmp25_;
	_tmp26_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	g_object_ref_sink (_tmp26_);
	box = _tmp26_;
	_tmp27_ = box;
	_tmp28_ = self->priv->expander;
	gtk_box_append (_tmp27_, (GtkWidget*) _tmp28_);
	_tmp29_ = box;
	_tmp30_ = clear_btn_entry;
	gtk_box_append (_tmp29_, (GtkWidget*) _tmp30_);
	gtk_widget_set_margin_start ((GtkWidget*) self, 12);
	gtk_widget_set_margin_end ((GtkWidget*) self, 12);
	gtk_widget_set_margin_bottom ((GtkWidget*) self, 3);
	gtk_widget_set_margin_top ((GtkWidget*) self, 6);
	gtk_widget_set_can_focus ((GtkWidget*) self, FALSE);
	_tmp31_ = box;
	gtk_list_box_row_set_child ((GtkListBoxRow*) self, (GtkWidget*) _tmp31_);
	_tmp32_ = notifications_app_entry_headers;
	_tmp33_ = self->priv->_app_id;
	if (g_hash_table_contains (_tmp32_, _tmp33_)) {
		GtkToggleButton* _tmp34_;
		GHashTable* _tmp35_;
		const gchar* _tmp36_;
		gconstpointer _tmp37_;
		_tmp34_ = self->priv->expander;
		_tmp35_ = notifications_app_entry_headers;
		_tmp36_ = self->priv->_app_id;
		_tmp37_ = g_hash_table_lookup (_tmp35_, _tmp36_);
		gtk_toggle_button_set_active (_tmp34_, (gboolean) ((gintptr) _tmp37_));
	}
	_tmp38_ = self->priv->expander;
	g_signal_connect_object (_tmp38_, "toggled", (GCallback) __notifications_app_entry___lambda12__gtk_toggle_button_toggled, self, 0);
	_tmp39_ = clear_btn_entry;
	g_signal_connect_data (_tmp39_, "clicked", (GCallback) __notifications_app_entry___lambda13__gtk_button_clicked, block4_data_ref (_data4_), (GClosureNotify) block4_data_unref, 0);
	_tmp40_ = self->priv->expander;
	_tmp41_ = image;
	g_object_bind_property_with_closures ((GObject*) _tmp40_, "active", (GObject*) _tmp41_, "tooltip-text", G_BINDING_SYNC_CREATE, (GClosure*) ((__notifications_app_entry___lambda15__gbinding_transform_func == NULL) ? NULL : g_cclosure_new ((GCallback) __notifications_app_entry___lambda15__gbinding_transform_func, g_object_ref (self), (GClosureNotify) g_object_unref)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_g_object_unref0 (box);
	_g_object_unref0 (clear_btn_entry);
	_g_object_unref0 (expander_content);
	_g_object_unref0 (label);
	_g_object_unref0 (image);
	block4_data_unref (_data4_);
	_data4_ = NULL;
	return obj;
}

static GHashTable*
_variant_get1 (GVariant* value)
{
	GHashTable* _tmp0_;
	GVariantIter _tmp1_;
	GVariant* _tmp2_;
	GVariant* _tmp3_;
	_tmp0_ = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
	g_variant_iter_init (&_tmp1_, value);
	while (g_variant_iter_loop (&_tmp1_, "{?*}", &_tmp2_, &_tmp3_)) {
		g_hash_table_insert (_tmp0_, g_variant_dup_string (_tmp2_, NULL), (gpointer) ((gintptr) g_variant_get_boolean (_tmp3_)));
	}
	return _tmp0_;
}

static void
notifications_app_entry_class_init (NotificationsAppEntryClass * klass,
                                    gpointer klass_data)
{
	GtkCssProvider* _tmp0_;
	GtkCssProvider* _tmp1_;
	GdkDisplay* _tmp2_;
	GtkCssProvider* _tmp3_;
	GSettings* _tmp4_;
	GSettings* _tmp5_;
	GVariant* _tmp6_;
	GVariant* _tmp7_;
	GHashTable* _tmp8_;
	notifications_app_entry_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &NotificationsAppEntry_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_notifications_app_entry_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_notifications_app_entry_set_property;
	G_OBJECT_CLASS (klass)->constructor = notifications_app_entry_constructor;
	G_OBJECT_CLASS (klass)->finalize = notifications_app_entry_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), NOTIFICATIONS_APP_ENTRY_APP_ID_PROPERTY, notifications_app_entry_properties[NOTIFICATIONS_APP_ENTRY_APP_ID_PROPERTY] = g_param_spec_string ("app-id", "app-id", "app-id", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), NOTIFICATIONS_APP_ENTRY_APP_INFO_PROPERTY, notifications_app_entry_properties[NOTIFICATIONS_APP_ENTRY_APP_INFO_PROPERTY] = g_param_spec_object ("app-info", "app-info", "app-info", g_app_info_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	notifications_app_entry_signals[NOTIFICATIONS_APP_ENTRY_CLEAR_SIGNAL] = g_signal_new ("clear", NOTIFICATIONS_TYPE_APP_ENTRY, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	_tmp0_ = gtk_css_provider_new ();
	_g_object_unref0 (notifications_app_entry_provider);
	notifications_app_entry_provider = _tmp0_;
	_tmp1_ = notifications_app_entry_provider;
	gtk_css_provider_load_from_resource (_tmp1_, "/io/elementary/wingpanel/notifications/AppEntry.css");
	_tmp2_ = gdk_display_get_default ();
	_tmp3_ = notifications_app_entry_provider;
	gtk_style_context_add_provider_for_display (_tmp2_, (GtkStyleProvider*) _tmp3_, (guint) GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
	_tmp4_ = g_settings_new ("io.elementary.panel.notifications");
	_g_object_unref0 (notifications_app_entry_settings);
	notifications_app_entry_settings = _tmp4_;
	_tmp5_ = notifications_app_entry_settings;
	_tmp6_ = g_settings_get_value (_tmp5_, "headers");
	_tmp7_ = _tmp6_;
	_tmp8_ = _variant_get1 (_tmp7_);
	_g_hash_table_unref0 (notifications_app_entry_headers);
	notifications_app_entry_headers = _tmp8_;
	_g_variant_unref0 (_tmp7_);
}

static void
notifications_app_entry_instance_init (NotificationsAppEntry * self,
                                       gpointer klass)
{
	self->priv = notifications_app_entry_get_instance_private (self);
	self->priv->_app_info = NULL;
}

static void
notifications_app_entry_finalize (GObject * obj)
{
	NotificationsAppEntry * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, NOTIFICATIONS_TYPE_APP_ENTRY, NotificationsAppEntry);
	_g_free0 (self->priv->_app_id);
	_g_object_unref0 (self->priv->_app_info);
	(self->app_notifications == NULL) ? NULL : (self->app_notifications = (_g_list_free__g_object_unref0_ (self->app_notifications), NULL));
	_g_object_unref0 (self->priv->expander);
	G_OBJECT_CLASS (notifications_app_entry_parent_class)->finalize (obj);
}

static GType
notifications_app_entry_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (NotificationsAppEntryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) notifications_app_entry_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (NotificationsAppEntry), 0, (GInstanceInitFunc) notifications_app_entry_instance_init, NULL };
	GType notifications_app_entry_type_id;
	notifications_app_entry_type_id = g_type_register_static (gtk_list_box_row_get_type (), "NotificationsAppEntry", &g_define_type_info, 0);
	NotificationsAppEntry_private_offset = g_type_add_instance_private (notifications_app_entry_type_id, sizeof (NotificationsAppEntryPrivate));
	return notifications_app_entry_type_id;
}

GType
notifications_app_entry_get_type (void)
{
	static volatile gsize notifications_app_entry_type_id__once = 0;
	if (g_once_init_enter (&notifications_app_entry_type_id__once)) {
		GType notifications_app_entry_type_id;
		notifications_app_entry_type_id = notifications_app_entry_get_type_once ();
		g_once_init_leave (&notifications_app_entry_type_id__once, notifications_app_entry_type_id);
	}
	return notifications_app_entry_type_id__once;
}

static void
_vala_notifications_app_entry_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec)
{
	NotificationsAppEntry * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, NOTIFICATIONS_TYPE_APP_ENTRY, NotificationsAppEntry);
	switch (property_id) {
		case NOTIFICATIONS_APP_ENTRY_APP_ID_PROPERTY:
		g_value_set_string (value, notifications_app_entry_get_app_id (self));
		break;
		case NOTIFICATIONS_APP_ENTRY_APP_INFO_PROPERTY:
		g_value_set_object (value, notifications_app_entry_get_app_info (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_notifications_app_entry_set_property (GObject * object,
                                            guint property_id,
                                            const GValue * value,
                                            GParamSpec * pspec)
{
	NotificationsAppEntry * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, NOTIFICATIONS_TYPE_APP_ENTRY, NotificationsAppEntry);
	switch (property_id) {
		case NOTIFICATIONS_APP_ENTRY_APP_ID_PROPERTY:
		notifications_app_entry_set_app_id (self, g_value_get_string (value));
		break;
		case NOTIFICATIONS_APP_ENTRY_APP_INFO_PROPERTY:
		notifications_app_entry_set_app_info (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

