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

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

#include "notifications.h"
#include <gee.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <gio/gdesktopappinfo.h>
#include <gdk/gdk.h>
#include <granite-7.h>
#include <glib/gi18n-lib.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	NOTIFICATIONS_NOTIFICATIONS_LIST_0_PROPERTY,
	NOTIFICATIONS_NOTIFICATIONS_LIST_APP_ENTRIES_PROPERTY,
	NOTIFICATIONS_NOTIFICATIONS_LIST_NUM_PROPERTIES
};
static GParamSpec* notifications_notifications_list_properties[NOTIFICATIONS_NOTIFICATIONS_LIST_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
typedef struct _NotificationsNotificationsListAddEntryData NotificationsNotificationsListAddEntryData;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _NotificationsNotificationsMonitor NotificationsNotificationsMonitor;
typedef struct _NotificationsNotificationsMonitorClass NotificationsNotificationsMonitorClass;
enum  {
	NOTIFICATIONS_NOTIFICATIONS_LIST_CLOSE_POPOVER_SIGNAL,
	NOTIFICATIONS_NOTIFICATIONS_LIST_ITEMS_CHANGED_SIGNAL,
	NOTIFICATIONS_NOTIFICATIONS_LIST_NUM_SIGNALS
};
static guint notifications_notifications_list_signals[NOTIFICATIONS_NOTIFICATIONS_LIST_NUM_SIGNALS] = {0};

struct _NotificationsNotificationsListPrivate {
	GeeHashMap* _app_entries;
	GHashTable* table;
	GtkListBox* listbox;
};

struct _NotificationsNotificationsListAddEntryData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	NotificationsNotificationsList* self;
	NotificationsNotification* notification;
	gboolean add_to_session;
	NotificationsNotificationEntry* entry;
	NotificationsNotificationEntry* _tmp0_;
	GeeHashMap* _tmp1_;
	const gchar* _tmp2_;
	gpointer _tmp3_;
	NotificationsAppEntry* _tmp4_;
	gboolean _tmp5_;
	NotificationsAppEntry* app_entry;
	GeeHashMap* _tmp6_;
	const gchar* _tmp7_;
	gpointer _tmp8_;
	NotificationsAppEntry* _tmp9_;
	NotificationsAppEntry* _tmp10_;
	NotificationsNotificationEntry* _tmp11_;
	gint insert_pos;
	GHashTable* _tmp12_;
	NotificationsAppEntry* _tmp13_;
	const gchar* _tmp14_;
	const gchar* _tmp15_;
	gconstpointer _tmp16_;
	GtkListBox* _tmp17_;
	NotificationsNotificationEntry* _tmp18_;
	NotificationsAppEntry* _vala1_app_entry;
	GDesktopAppInfo* _tmp19_;
	NotificationsAppEntry* _tmp20_;
	NotificationsAppEntry* _tmp21_;
	NotificationsNotificationEntry* _tmp22_;
	NotificationsAppEntry* _tmp23_;
	GeeHashMap* _tmp24_;
	const gchar* _tmp25_;
	NotificationsAppEntry* _tmp26_;
	GtkListBox* _tmp27_;
	NotificationsAppEntry* _tmp28_;
	GtkListBox* _tmp29_;
	NotificationsNotificationEntry* _tmp30_;
	GHashTable* _tmp31_;
	NotificationsAppEntry* _tmp32_;
	const gchar* _tmp33_;
	const gchar* _tmp34_;
	gchar* _tmp35_;
	NotificationsSession* _tmp36_;
	NotificationsSession* _tmp37_;
};

static gint NotificationsNotificationsList_private_offset;
static gpointer notifications_notifications_list_parent_class = NULL;

static void notifications_notifications_list_add_entry_data_free (gpointer _data);
static gboolean notifications_notifications_list_add_entry_co (NotificationsNotificationsListAddEntryData* _data_);
static void notifications_notifications_list_resort_app_entry (NotificationsNotificationsList* self,
                                                        NotificationsAppEntry* app_entry);
static void notifications_notifications_list_clear_app_entry (NotificationsNotificationsList* self,
                                                       NotificationsAppEntry* app_entry);
static void _notifications_notifications_list_clear_app_entry_notifications_app_entry_clear (NotificationsAppEntry* _sender,
                                                                                      gpointer self);
static gboolean _notifications_notifications_list_add_entry_co_gsource_func (gpointer self);
static void ___lambda16_ (NotificationsNotificationsList* self,
                   NotificationsNotificationEntry* notification_entry);
static void ____lambda16__gfunc (gconstpointer data,
                          gpointer self);
static void notifications_notifications_list_on_row_activated (NotificationsNotificationsList* self,
                                                        GtkListBoxRow* row);
static void notifications_notifications_list_set_app_entries (NotificationsNotificationsList* self,
                                                       GeeHashMap* value);
static GObject * notifications_notifications_list_constructor (GType type,
                                                        guint n_construct_properties,
                                                        GObjectConstructParam * construct_properties);
static void _g_free0_ (gpointer var);
static void _notifications_notifications_list_on_row_activated_gtk_list_box_row_activated (GtkListBox* _sender,
                                                                                    GtkListBoxRow* row,
                                                                                    gpointer self);
static void notifications_notifications_list_finalize (GObject * obj);
static GType notifications_notifications_list_get_type_once (void);
static void _vala_notifications_notifications_list_get_property (GObject * object,
                                                          guint property_id,
                                                          GValue * value,
                                                          GParamSpec * pspec);
static void _vala_notifications_notifications_list_set_property (GObject * object,
                                                          guint property_id,
                                                          const GValue * value,
                                                          GParamSpec * pspec);

static inline gpointer
notifications_notifications_list_get_instance_private (NotificationsNotificationsList* self)
{
	return G_STRUCT_MEMBER_P (self, NotificationsNotificationsList_private_offset);
}

static void
notifications_notifications_list_add_entry_data_free (gpointer _data)
{
	NotificationsNotificationsListAddEntryData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->notification);
	_g_object_unref0 (_data_->self);
	g_slice_free (NotificationsNotificationsListAddEntryData, _data_);
}

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

void
notifications_notifications_list_add_entry (NotificationsNotificationsList* self,
                                            NotificationsNotification* notification,
                                            gboolean add_to_session,
                                            GAsyncReadyCallback _callback_,
                                            gpointer _user_data_)
{
	NotificationsNotificationsListAddEntryData* _data_;
	NotificationsNotificationsList* _tmp0_;
	NotificationsNotification* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (notification != NULL);
	_data_ = g_slice_new0 (NotificationsNotificationsListAddEntryData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, notifications_notifications_list_add_entry_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (notification);
	_g_object_unref0 (_data_->notification);
	_data_->notification = _tmp1_;
	_data_->add_to_session = add_to_session;
	notifications_notifications_list_add_entry_co (_data_);
}

void
notifications_notifications_list_add_entry_finish (NotificationsNotificationsList* self,
                                                   GAsyncResult* _res_)
{
	NotificationsNotificationsListAddEntryData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
_notifications_notifications_list_clear_app_entry_notifications_app_entry_clear (NotificationsAppEntry* _sender,
                                                                                 gpointer self)
{
	notifications_notifications_list_clear_app_entry ((NotificationsNotificationsList*) self, _sender);
}

static gboolean
_notifications_notifications_list_add_entry_co_gsource_func (gpointer self)
{
	gboolean result;
	result = notifications_notifications_list_add_entry_co (self);
	return result;
}

static gboolean
notifications_notifications_list_add_entry_co (NotificationsNotificationsListAddEntryData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = notifications_notification_entry_new (_data_->notification);
	g_object_ref_sink (_data_->_tmp0_);
	_data_->entry = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->self->priv->_app_entries;
	_data_->_tmp2_ = _data_->notification->desktop_id;
	_data_->_tmp3_ = gee_abstract_map_get ((GeeAbstractMap*) _data_->_tmp1_, _data_->_tmp2_);
	_data_->_tmp4_ = (NotificationsAppEntry*) _data_->_tmp3_;
	_data_->_tmp5_ = _data_->_tmp4_ != NULL;
	_g_object_unref0 (_data_->_tmp4_);
	if (_data_->_tmp5_) {
		_data_->_tmp6_ = _data_->self->priv->_app_entries;
		_data_->_tmp7_ = _data_->notification->desktop_id;
		_data_->_tmp8_ = gee_abstract_map_get ((GeeAbstractMap*) _data_->_tmp6_, _data_->_tmp7_);
		_data_->app_entry = (NotificationsAppEntry*) _data_->_tmp8_;
		_data_->_tmp9_ = _data_->app_entry;
		notifications_notifications_list_resort_app_entry (_data_->self, _data_->_tmp9_);
		_data_->_tmp10_ = _data_->app_entry;
		_data_->_tmp11_ = _data_->entry;
		notifications_app_entry_add_notification_entry (_data_->_tmp10_, _data_->_tmp11_);
		_data_->_tmp12_ = _data_->self->priv->table;
		_data_->_tmp13_ = _data_->app_entry;
		_data_->_tmp14_ = notifications_app_entry_get_app_id (_data_->_tmp13_);
		_data_->_tmp15_ = _data_->_tmp14_;
		_data_->_tmp16_ = g_hash_table_lookup (_data_->_tmp12_, _data_->_tmp15_);
		_data_->insert_pos = (gint) ((gintptr) _data_->_tmp16_);
		_data_->_tmp17_ = _data_->self->priv->listbox;
		_data_->_tmp18_ = _data_->entry;
		gtk_list_box_insert (_data_->_tmp17_, (GtkWidget*) _data_->_tmp18_, _data_->insert_pos + 1);
		_g_object_unref0 (_data_->app_entry);
	} else {
		_data_->_tmp19_ = _data_->notification->app_info;
		_data_->_tmp20_ = notifications_app_entry_new ((GAppInfo*) _data_->_tmp19_);
		g_object_ref_sink (_data_->_tmp20_);
		_data_->_vala1_app_entry = _data_->_tmp20_;
		_data_->_tmp21_ = _data_->_vala1_app_entry;
		_data_->_tmp22_ = _data_->entry;
		notifications_app_entry_add_notification_entry (_data_->_tmp21_, _data_->_tmp22_);
		_data_->_tmp23_ = _data_->_vala1_app_entry;
		g_signal_connect_object (_data_->_tmp23_, "clear", (GCallback) _notifications_notifications_list_clear_app_entry_notifications_app_entry_clear, _data_->self, 0);
		_data_->_tmp24_ = _data_->self->priv->_app_entries;
		_data_->_tmp25_ = _data_->notification->desktop_id;
		_data_->_tmp26_ = _data_->_vala1_app_entry;
		gee_abstract_map_set ((GeeAbstractMap*) _data_->_tmp24_, _data_->_tmp25_, _data_->_tmp26_);
		_data_->_tmp27_ = _data_->self->priv->listbox;
		_data_->_tmp28_ = _data_->_vala1_app_entry;
		gtk_list_box_prepend (_data_->_tmp27_, (GtkWidget*) _data_->_tmp28_);
		_data_->_tmp29_ = _data_->self->priv->listbox;
		_data_->_tmp30_ = _data_->entry;
		gtk_list_box_insert (_data_->_tmp29_, (GtkWidget*) _data_->_tmp30_, 1);
		_data_->_tmp31_ = _data_->self->priv->table;
		_data_->_tmp32_ = _data_->_vala1_app_entry;
		_data_->_tmp33_ = notifications_app_entry_get_app_id (_data_->_tmp32_);
		_data_->_tmp34_ = _data_->_tmp33_;
		_data_->_tmp35_ = g_strdup (_data_->_tmp34_);
		g_hash_table_insert (_data_->_tmp31_, _data_->_tmp35_, (gpointer) ((gintptr) 0));
		_g_object_unref0 (_data_->_vala1_app_entry);
	}
	g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, _notifications_notifications_list_add_entry_co_gsource_func, _data_, NULL);
	_data_->_state_ = 1;
	return FALSE;
	_state_1:
	;
	if (_data_->add_to_session) {
		_data_->_tmp36_ = notifications_session_get_instance ();
		_data_->_tmp37_ = _data_->_tmp36_;
		notifications_session_add_notification (_data_->_tmp37_, _data_->notification, TRUE);
		_g_object_unref0 (_data_->_tmp37_);
	}
	g_signal_emit (_data_->self, notifications_notifications_list_signals[NOTIFICATIONS_NOTIFICATIONS_LIST_ITEMS_CHANGED_SIGNAL], 0);
	_g_object_unref0 (_data_->entry);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

guint
notifications_notifications_list_count_notifications (NotificationsNotificationsList* self,
                                                      guint* number_of_apps)
{
	guint _vala_number_of_apps = 0U;
	gint count = 0;
	gint n_apps = 0;
	guint result;
	g_return_val_if_fail (self != NULL, 0U);
	count = 0;
	n_apps = 0;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GtkListBox* _tmp2_;
				GtkListBoxRow* _tmp3_;
				GtkListBox* _tmp4_;
				GtkListBoxRow* _tmp5_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = self->priv->listbox;
				_tmp3_ = gtk_list_box_get_row_at_index (_tmp2_, i);
				if (!(_tmp3_ != NULL)) {
					break;
				}
				_tmp4_ = self->priv->listbox;
				_tmp5_ = gtk_list_box_get_row_at_index (_tmp4_, i);
				if (NOTIFICATIONS_IS_NOTIFICATION_ENTRY (_tmp5_)) {
					gint _tmp6_;
					_tmp6_ = count;
					count = _tmp6_ + 1;
				} else {
					GtkListBox* _tmp7_;
					GtkListBoxRow* _tmp8_;
					_tmp7_ = self->priv->listbox;
					_tmp8_ = gtk_list_box_get_row_at_index (_tmp7_, i);
					if (NOTIFICATIONS_IS_APP_ENTRY (_tmp8_)) {
						gint _tmp9_;
						_tmp9_ = n_apps;
						n_apps = _tmp9_ + 1;
					}
				}
			}
		}
	}
	_vala_number_of_apps = (guint) n_apps;
	result = (guint) count;
	if (number_of_apps) {
		*number_of_apps = _vala_number_of_apps;
	}
	return result;
}

void
notifications_notifications_list_clear_all (NotificationsNotificationsList* self)
{
	GeeMapIterator* iter = NULL;
	GeeHashMap* _tmp0_;
	GeeMapIterator* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_app_entries;
	_tmp1_ = gee_abstract_map_map_iterator ((GeeAbstractMap*) _tmp0_);
	iter = _tmp1_;
	while (TRUE) {
		GeeMapIterator* _tmp2_;
		NotificationsAppEntry* entry = NULL;
		GeeMapIterator* _tmp3_;
		gpointer _tmp4_;
		GeeMapIterator* _tmp5_;
		NotificationsAppEntry* _tmp6_;
		_tmp2_ = iter;
		if (!gee_map_iterator_next (_tmp2_)) {
			break;
		}
		_tmp3_ = iter;
		_tmp4_ = gee_map_iterator_get_value (_tmp3_);
		entry = (NotificationsAppEntry*) _tmp4_;
		_tmp5_ = iter;
		gee_map_iterator_unset (_tmp5_);
		_tmp6_ = entry;
		notifications_notifications_list_clear_app_entry (self, _tmp6_);
		_g_object_unref0 (entry);
	}
	g_signal_emit (self, notifications_notifications_list_signals[NOTIFICATIONS_NOTIFICATIONS_LIST_CLOSE_POPOVER_SIGNAL], 0);
	_g_object_unref0 (iter);
}

static void
___lambda16_ (NotificationsNotificationsList* self,
              NotificationsNotificationEntry* notification_entry)
{
	GtkListBox* _tmp0_;
	GtkListBox* _tmp1_;
	g_return_if_fail (notification_entry != NULL);
	_tmp0_ = self->priv->listbox;
	gtk_list_box_remove (_tmp0_, (GtkWidget*) notification_entry);
	_tmp1_ = self->priv->listbox;
	gtk_list_box_insert (_tmp1_, (GtkWidget*) notification_entry, 1);
}

static void
____lambda16__gfunc (gconstpointer data,
                     gpointer self)
{
	___lambda16_ ((NotificationsNotificationsList*) self, (NotificationsNotificationEntry*) data);
}

static void
notifications_notifications_list_resort_app_entry (NotificationsNotificationsList* self,
                                                   NotificationsAppEntry* app_entry)
{
	GtkListBox* _tmp0_;
	GtkListBoxRow* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (app_entry != NULL);
	_tmp0_ = self->priv->listbox;
	_tmp1_ = gtk_list_box_get_row_at_index (_tmp0_, 0);
	if (_tmp1_ != G_TYPE_CHECK_INSTANCE_CAST (app_entry, gtk_list_box_row_get_type (), GtkListBoxRow)) {
		GtkListBox* _tmp2_;
		GtkListBox* _tmp3_;
		GList* _tmp4_;
		_tmp2_ = self->priv->listbox;
		gtk_list_box_remove (_tmp2_, (GtkWidget*) app_entry);
		_tmp3_ = self->priv->listbox;
		gtk_list_box_prepend (_tmp3_, (GtkWidget*) app_entry);
		_tmp4_ = app_entry->app_notifications;
		g_list_foreach (_tmp4_, ____lambda16__gfunc, self);
	}
}

static void
notifications_notifications_list_clear_app_entry (NotificationsNotificationsList* self,
                                                  NotificationsAppEntry* app_entry)
{
	guint _tmp0_;
	GeeHashMap* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	GtkListBox* _tmp4_;
	GeeHashMap* _tmp5_;
	gint _tmp6_;
	gint _tmp7_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (app_entry != NULL);
	g_signal_parse_name ("clear", NOTIFICATIONS_TYPE_APP_ENTRY, &_tmp0_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (app_entry, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp0_, 0, NULL, (GCallback) _notifications_notifications_list_clear_app_entry_notifications_app_entry_clear, self);
	_tmp1_ = self->priv->_app_entries;
	_tmp2_ = notifications_app_entry_get_app_id (app_entry);
	_tmp3_ = _tmp2_;
	gee_abstract_map_unset ((GeeAbstractMap*) _tmp1_, _tmp3_, NULL);
	notifications_app_entry_clear_all_notification_entries (app_entry);
	_tmp4_ = self->priv->listbox;
	gtk_list_box_remove (_tmp4_, (GtkWidget*) app_entry);
	_tmp5_ = self->priv->_app_entries;
	_tmp6_ = gee_abstract_map_get_size ((GeeAbstractMap*) _tmp5_);
	_tmp7_ = _tmp6_;
	if (_tmp7_ == 0) {
		NotificationsSession* _tmp8_;
		NotificationsSession* _tmp9_;
		_tmp8_ = notifications_session_get_instance ();
		_tmp9_ = _tmp8_;
		notifications_session_clear (_tmp9_);
		_g_object_unref0 (_tmp9_);
	}
	g_signal_emit (self, notifications_notifications_list_signals[NOTIFICATIONS_NOTIFICATIONS_LIST_ITEMS_CHANGED_SIGNAL], 0);
}

static void
notifications_notifications_list_on_row_activated (NotificationsNotificationsList* self,
                                                   GtkListBoxRow* row)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (row != NULL);
	if (NOTIFICATIONS_IS_NOTIFICATION_ENTRY (row)) {
		NotificationsNotificationEntry* notification_entry = NULL;
		NotificationsNotificationEntry* _tmp0_;
		NotificationsNotification* _tmp1_;
		NotificationsNotification* _tmp2_;
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		notification_entry = G_TYPE_CHECK_INSTANCE_CAST (row, NOTIFICATIONS_TYPE_NOTIFICATION_ENTRY, NotificationsNotificationEntry);
		_tmp0_ = notification_entry;
		_tmp1_ = notifications_notification_entry_get_notification (_tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = notifications_notification_get_default_action (_tmp2_);
		_tmp4_ = _tmp3_;
		if (_tmp4_ != NULL) {
			NotificationsNotificationEntry* _tmp5_;
			NotificationsNotification* _tmp6_;
			NotificationsNotification* _tmp7_;
			const gchar* _tmp8_;
			const gchar* _tmp9_;
			gchar* _tmp10_;
			gchar* _tmp11_;
			_tmp5_ = notification_entry;
			_tmp6_ = notifications_notification_entry_get_notification (_tmp5_);
			_tmp7_ = _tmp6_;
			_tmp8_ = notifications_notification_get_default_action (_tmp7_);
			_tmp9_ = _tmp8_;
			_tmp10_ = g_strconcat (NOTIFICATIONS_NOTIFICATIONS_LIST_ACTION_PREFIX, _tmp9_, NULL);
			_tmp11_ = _tmp10_;
			gtk_widget_activate_action ((GtkWidget*) self, _tmp11_, NULL, NULL);
			_g_free0 (_tmp11_);
			g_signal_emit (self, notifications_notifications_list_signals[NOTIFICATIONS_NOTIFICATIONS_LIST_CLOSE_POPOVER_SIGNAL], 0);
		} else {
			{
				GdkAppLaunchContext* context = NULL;
				NotificationsNotificationEntry* _tmp12_;
				GdkDisplay* _tmp13_;
				GdkAppLaunchContext* _tmp14_;
				NotificationsNotificationEntry* _tmp15_;
				NotificationsNotification* _tmp16_;
				NotificationsNotification* _tmp17_;
				GDesktopAppInfo* _tmp18_;
				GdkAppLaunchContext* _tmp19_;
				NotificationsNotificationEntry* _tmp20_;
				_tmp12_ = notification_entry;
				_tmp13_ = gtk_widget_get_display ((GtkWidget*) _tmp12_);
				_tmp14_ = gdk_display_get_app_launch_context (_tmp13_);
				context = _tmp14_;
				_tmp15_ = notification_entry;
				_tmp16_ = notifications_notification_entry_get_notification (_tmp15_);
				_tmp17_ = _tmp16_;
				_tmp18_ = _tmp17_->app_info;
				_tmp19_ = context;
				g_app_info_launch ((GAppInfo*) _tmp18_, NULL, (GAppLaunchContext*) _tmp19_, &_inner_error0_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					_g_object_unref0 (context);
					goto __catch0_g_error;
				}
				_tmp20_ = notification_entry;
				g_signal_emit_by_name (_tmp20_, "clear");
				g_signal_emit (self, notifications_notifications_list_signals[NOTIFICATIONS_NOTIFICATIONS_LIST_CLOSE_POPOVER_SIGNAL], 0);
				_g_object_unref0 (context);
			}
			goto __finally0;
			__catch0_g_error:
			{
				GError* e = NULL;
				GError* _tmp21_;
				const gchar* _tmp22_;
				e = _inner_error0_;
				_inner_error0_ = NULL;
				_tmp21_ = e;
				_tmp22_ = _tmp21_->message;
				g_warning ("NotificationsList.vala:160: Unable to launch app: %s", _tmp22_);
				_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;
			}
		}
	}
}

NotificationsNotificationsList*
notifications_notifications_list_construct (GType object_type)
{
	NotificationsNotificationsList * self = NULL;
	self = (NotificationsNotificationsList*) granite_bin_construct (object_type);
	return self;
}

NotificationsNotificationsList*
notifications_notifications_list_new (void)
{
	return notifications_notifications_list_construct (NOTIFICATIONS_TYPE_NOTIFICATIONS_LIST);
}

GeeHashMap*
notifications_notifications_list_get_app_entries (NotificationsNotificationsList* self)
{
	GeeHashMap* result;
	GeeHashMap* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_app_entries;
	result = _tmp0_;
	return result;
}

static void
notifications_notifications_list_set_app_entries (NotificationsNotificationsList* self,
                                                  GeeHashMap* value)
{
	GeeHashMap* old_value;
	g_return_if_fail (self != NULL);
	old_value = notifications_notifications_list_get_app_entries (self);
	if (old_value != value) {
		GeeHashMap* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_app_entries);
		self->priv->_app_entries = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, notifications_notifications_list_properties[NOTIFICATIONS_NOTIFICATIONS_LIST_APP_ENTRIES_PROPERTY]);
	}
}

static void
_g_free0_ (gpointer var)
{
	var = (g_free (var), NULL);
}

static void
_notifications_notifications_list_on_row_activated_gtk_list_box_row_activated (GtkListBox* _sender,
                                                                               GtkListBoxRow* row,
                                                                               gpointer self)
{
	notifications_notifications_list_on_row_activated ((NotificationsNotificationsList*) self, row);
}

static GObject *
notifications_notifications_list_constructor (GType type,
                                              guint n_construct_properties,
                                              GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	NotificationsNotificationsList * self;
	GeeHashMap* _tmp0_;
	GeeHashMap* _tmp1_;
	GHashFunc _tmp2_;
	GEqualFunc _tmp3_;
	GHashTable* _tmp4_;
	GtkLabel* placeholder = NULL;
	GtkLabel* _tmp5_ = NULL;
	GtkLabel* _tmp6_;
	GtkLabel* _tmp7_;
	GtkListBox* _tmp8_ = NULL;
	GtkListBox* _tmp9_;
	GtkLabel* _tmp10_;
	GtkListBox* _tmp11_;
	NotificationsNotificationsMonitor* _tmp12_;
	NotificationsNotificationsMonitor* _tmp13_;
	GDBusActionGroup* _tmp14_;
	GDBusActionGroup* _tmp15_;
	GtkListBox* _tmp16_;
	parent_class = G_OBJECT_CLASS (notifications_notifications_list_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, NOTIFICATIONS_TYPE_NOTIFICATIONS_LIST, NotificationsNotificationsList);
	_tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NOTIFICATIONS_TYPE_APP_ENTRY, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_tmp1_ = _tmp0_;
	notifications_notifications_list_set_app_entries (self, _tmp1_);
	_g_object_unref0 (_tmp1_);
	_tmp2_ = g_str_hash;
	_tmp3_ = g_str_equal;
	_tmp4_ = g_hash_table_new_full (_tmp2_, _tmp3_, _g_free0_, NULL);
	_g_hash_table_unref0 (self->priv->table);
	self->priv->table = _tmp4_;
	_tmp5_ = (GtkLabel*) gtk_label_new (_ ("No Notifications"));
	gtk_widget_set_margin_top ((GtkWidget*) _tmp5_, 24);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp5_, 24);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp5_, 12);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp5_, 12);
	gtk_widget_set_visible ((GtkWidget*) _tmp5_, TRUE);
	g_object_ref_sink (_tmp5_);
	placeholder = _tmp5_;
	_tmp6_ = placeholder;
	gtk_widget_add_css_class ((GtkWidget*) _tmp6_, GRANITE_STYLE_CLASS_H2_LABEL);
	_tmp7_ = placeholder;
	gtk_widget_add_css_class ((GtkWidget*) _tmp7_, GRANITE_CSS_CLASS_DIM);
	_tmp8_ = (GtkListBox*) gtk_list_box_new ();
	gtk_list_box_set_activate_on_single_click (_tmp8_, TRUE);
	gtk_list_box_set_selection_mode (_tmp8_, GTK_SELECTION_NONE);
	g_object_ref_sink (_tmp8_);
	_g_object_unref0 (self->priv->listbox);
	self->priv->listbox = _tmp8_;
	_tmp9_ = self->priv->listbox;
	_tmp10_ = placeholder;
	gtk_list_box_set_placeholder (_tmp9_, (GtkWidget*) _tmp10_);
	_tmp11_ = self->priv->listbox;
	granite_bin_set_child ((GraniteBin*) self, (GtkWidget*) _tmp11_);
	_tmp12_ = notifications_notifications_monitor_new ();
	_tmp13_ = _tmp12_;
	_tmp14_ = notifications_notifications_monitor_get_notifications_action_group (_tmp13_);
	_tmp15_ = _tmp14_;
	gtk_widget_insert_action_group ((GtkWidget*) self, NOTIFICATIONS_NOTIFICATIONS_LIST_ACTION_GROUP_PREFIX, (GActionGroup*) _tmp15_);
	_g_object_unref0 (_tmp13_);
	_tmp16_ = self->priv->listbox;
	g_signal_connect_object (_tmp16_, "row-activated", (GCallback) _notifications_notifications_list_on_row_activated_gtk_list_box_row_activated, self, 0);
	_g_object_unref0 (placeholder);
	return obj;
}

static void
notifications_notifications_list_class_init (NotificationsNotificationsListClass * klass,
                                             gpointer klass_data)
{
	notifications_notifications_list_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &NotificationsNotificationsList_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_notifications_notifications_list_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_notifications_notifications_list_set_property;
	G_OBJECT_CLASS (klass)->constructor = notifications_notifications_list_constructor;
	G_OBJECT_CLASS (klass)->finalize = notifications_notifications_list_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), NOTIFICATIONS_NOTIFICATIONS_LIST_APP_ENTRIES_PROPERTY, notifications_notifications_list_properties[NOTIFICATIONS_NOTIFICATIONS_LIST_APP_ENTRIES_PROPERTY] = g_param_spec_object ("app-entries", "app-entries", "app-entries", GEE_TYPE_HASH_MAP, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	notifications_notifications_list_signals[NOTIFICATIONS_NOTIFICATIONS_LIST_CLOSE_POPOVER_SIGNAL] = g_signal_new ("close-popover", NOTIFICATIONS_TYPE_NOTIFICATIONS_LIST, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	notifications_notifications_list_signals[NOTIFICATIONS_NOTIFICATIONS_LIST_ITEMS_CHANGED_SIGNAL] = g_signal_new ("items-changed", NOTIFICATIONS_TYPE_NOTIFICATIONS_LIST, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
notifications_notifications_list_instance_init (NotificationsNotificationsList * self,
                                                gpointer klass)
{
	self->priv = notifications_notifications_list_get_instance_private (self);
}

static void
notifications_notifications_list_finalize (GObject * obj)
{
	NotificationsNotificationsList * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, NOTIFICATIONS_TYPE_NOTIFICATIONS_LIST, NotificationsNotificationsList);
	_g_object_unref0 (self->priv->_app_entries);
	_g_hash_table_unref0 (self->priv->table);
	_g_object_unref0 (self->priv->listbox);
	G_OBJECT_CLASS (notifications_notifications_list_parent_class)->finalize (obj);
}

static GType
notifications_notifications_list_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (NotificationsNotificationsListClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) notifications_notifications_list_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (NotificationsNotificationsList), 0, (GInstanceInitFunc) notifications_notifications_list_instance_init, NULL };
	GType notifications_notifications_list_type_id;
	notifications_notifications_list_type_id = g_type_register_static (GRANITE_TYPE_BIN, "NotificationsNotificationsList", &g_define_type_info, 0);
	NotificationsNotificationsList_private_offset = g_type_add_instance_private (notifications_notifications_list_type_id, sizeof (NotificationsNotificationsListPrivate));
	return notifications_notifications_list_type_id;
}

GType
notifications_notifications_list_get_type (void)
{
	static volatile gsize notifications_notifications_list_type_id__once = 0;
	if (g_once_init_enter (&notifications_notifications_list_type_id__once)) {
		GType notifications_notifications_list_type_id;
		notifications_notifications_list_type_id = notifications_notifications_list_get_type_once ();
		g_once_init_leave (&notifications_notifications_list_type_id__once, notifications_notifications_list_type_id);
	}
	return notifications_notifications_list_type_id__once;
}

static void
_vala_notifications_notifications_list_get_property (GObject * object,
                                                     guint property_id,
                                                     GValue * value,
                                                     GParamSpec * pspec)
{
	NotificationsNotificationsList * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, NOTIFICATIONS_TYPE_NOTIFICATIONS_LIST, NotificationsNotificationsList);
	switch (property_id) {
		case NOTIFICATIONS_NOTIFICATIONS_LIST_APP_ENTRIES_PROPERTY:
		g_value_set_object (value, notifications_notifications_list_get_app_entries (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_notifications_notifications_list_set_property (GObject * object,
                                                     guint property_id,
                                                     const GValue * value,
                                                     GParamSpec * pspec)
{
	NotificationsNotificationsList * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, NOTIFICATIONS_TYPE_NOTIFICATIONS_LIST, NotificationsNotificationsList);
	switch (property_id) {
		case NOTIFICATIONS_NOTIFICATIONS_LIST_APP_ENTRIES_PROPERTY:
		notifications_notifications_list_set_app_entries (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

