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

/*
 * This file is part of budgie-desktop
 *
 * Copyright Budgie Desktop Developers
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */

#include "raven.h"
#include "budgie-private.h"
#include <glib-object.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <pango/pango.h>
#include <float.h>
#include <math.h>
#include <gio/gio.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  {
	NOTIFICATION_WIDGET_0_PROPERTY,
	NOTIFICATION_WIDGET_NOTIFICATION_PROPERTY,
	NOTIFICATION_WIDGET_NUM_PROPERTIES
};
static GParamSpec* notification_widget_properties[NOTIFICATION_WIDGET_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))
enum  {
	NOTIFICATION_WIDGET_CLOSED_INDIVIDUALLY_SIGNAL,
	NOTIFICATION_WIDGET_NUM_SIGNALS
};
static guint notification_widget_signals[NOTIFICATION_WIDGET_NUM_SIGNALS] = {0};

struct _NotificationWidgetPrivate {
	BudgieNotification* _notification;
};

static gint NotificationWidget_private_offset;
static gpointer notification_widget_parent_class = NULL;

static GObject * notification_widget_constructor (GType type,
                                           guint n_construct_properties,
                                           GObjectConstructParam * construct_properties);
static void _notification_widget_Dismiss_gtk_button_clicked (GtkButton* _sender,
                                                      gpointer self);
static void notification_widget_finalize (GObject * obj);
static GType notification_widget_get_type_once (void);
static void _vala_notification_widget_get_property (GObject * object,
                                             guint property_id,
                                             GValue * value,
                                             GParamSpec * pspec);
static void _vala_notification_widget_set_property (GObject * object,
                                             guint property_id,
                                             const GValue * value,
                                             GParamSpec * pspec);

static inline gpointer
notification_widget_get_instance_private (NotificationWidget* self)
{
	return G_STRUCT_MEMBER_P (self, NotificationWidget_private_offset);
}

NotificationWidget*
notification_widget_construct (GType object_type,
                               BudgieNotification* notification)
{
	NotificationWidget * self = NULL;
	g_return_val_if_fail (notification != NULL, NULL);
	self = (NotificationWidget*) g_object_new (object_type, "notification", notification, NULL);
	return self;
}

NotificationWidget*
notification_widget_new (BudgieNotification* notification)
{
	return notification_widget_construct (TYPE_NOTIFICATION_WIDGET, notification);
}

/**
 * Dismiss this notification
 */
void
notification_widget_Dismiss (NotificationWidget* self)
{
	g_return_if_fail (self != NULL);
	g_signal_emit (self, notification_widget_signals[NOTIFICATION_WIDGET_CLOSED_INDIVIDUALLY_SIGNAL], 0);
}

BudgieNotification*
notification_widget_get_notification (NotificationWidget* self)
{
	BudgieNotification* result;
	BudgieNotification* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_notification;
	result = _tmp0_;
	return result;
}

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

static void
notification_widget_set_notification (NotificationWidget* self,
                                      BudgieNotification* value)
{
	BudgieNotification* old_value;
	g_return_if_fail (self != NULL);
	old_value = notification_widget_get_notification (self);
	if (old_value != value) {
		BudgieNotification* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_notification);
		self->priv->_notification = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, notification_widget_properties[NOTIFICATION_WIDGET_NOTIFICATION_PROPERTY]);
	}
}

static void
_notification_widget_Dismiss_gtk_button_clicked (GtkButton* _sender,
                                                 gpointer self)
{
	notification_widget_Dismiss ((NotificationWidget*) self);
}

static GObject *
notification_widget_constructor (GType type,
                                 guint n_construct_properties,
                                 GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	NotificationWidget * self;
	GtkBox* box = NULL;
	GtkBox* _tmp0_ = NULL;
	GtkBox* _tmp1_;
	GtkStyleContext* _tmp2_;
	GtkBox* header = NULL;
	GtkBox* _tmp3_;
	GtkButton* dismiss_button = NULL;
	GtkButton* _tmp4_;
	GtkButton* _tmp5_;
	GtkStyleContext* _tmp6_;
	GtkButton* _tmp7_;
	GtkStyleContext* _tmp8_;
	GtkLabel* label_title = NULL;
	BudgieNotification* _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	GtkLabel* _tmp12_ = NULL;
	GtkLabel* label_body = NULL;
	BudgieNotification* _tmp13_;
	const gchar* _tmp14_;
	const gchar* _tmp15_;
	GDateTime* date = NULL;
	BudgieNotification* _tmp20_;
	gint64 _tmp21_;
	gint64 _tmp22_;
	GDateTime* _tmp23_;
	GSettings* gnome_settings = NULL;
	GSettings* _tmp24_;
	gchar* clock_format = NULL;
	GSettings* _tmp25_;
	gchar* _tmp26_;
	gchar* _tmp27_ = NULL;
	const gchar* _tmp28_;
	gchar* _tmp33_;
	GtkLabel* label_timestamp = NULL;
	const gchar* _tmp34_;
	GtkLabel* _tmp35_ = NULL;
	GtkLabel* _tmp36_;
	GtkStyleContext* _tmp37_;
	GtkBox* _tmp38_;
	GtkLabel* _tmp39_;
	GtkBox* _tmp40_;
	GtkButton* _tmp41_;
	GtkBox* _tmp42_;
	GtkBox* _tmp43_;
	GtkBox* _tmp44_;
	GtkLabel* _tmp45_;
	GtkLabel* _tmp46_;
	GtkButton* _tmp49_;
	GtkBox* _tmp50_;
	parent_class = G_OBJECT_CLASS (notification_widget_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_NOTIFICATION_WIDGET, NotificationWidget);
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
	g_object_set ((GtkWidget*) _tmp0_, "expand", FALSE, NULL);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp0_, 4);
	g_object_ref_sink (_tmp0_);
	box = _tmp0_;
	_tmp1_ = box;
	_tmp2_ = gtk_widget_get_style_context ((GtkWidget*) _tmp1_);
	gtk_style_context_add_class (_tmp2_, "notification-clone");
	_tmp3_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	g_object_ref_sink (_tmp3_);
	header = _tmp3_;
	_tmp4_ = (GtkButton*) gtk_button_new_from_icon_name ("window-close-symbolic", (GtkIconSize) GTK_ICON_SIZE_MENU);
	g_object_ref_sink (_tmp4_);
	dismiss_button = _tmp4_;
	_tmp5_ = dismiss_button;
	_tmp6_ = gtk_widget_get_style_context ((GtkWidget*) _tmp5_);
	gtk_style_context_add_class (_tmp6_, "flat");
	_tmp7_ = dismiss_button;
	_tmp8_ = gtk_widget_get_style_context ((GtkWidget*) _tmp7_);
	gtk_style_context_add_class (_tmp8_, "image-button");
	_tmp9_ = self->priv->_notification;
	_tmp10_ = budgie_notification_get_summary (_tmp9_);
	_tmp11_ = _tmp10_;
	_tmp12_ = (GtkLabel*) gtk_label_new (_tmp11_);
	gtk_label_set_ellipsize (_tmp12_, PANGO_ELLIPSIZE_END);
	gtk_widget_set_halign ((GtkWidget*) _tmp12_, GTK_ALIGN_START);
	gtk_label_set_justify (_tmp12_, GTK_JUSTIFY_LEFT);
	gtk_label_set_use_markup (_tmp12_, TRUE);
	g_object_ref_sink (_tmp12_);
	label_title = _tmp12_;
	label_body = NULL;
	_tmp13_ = self->priv->_notification;
	_tmp14_ = budgie_notification_get_body (_tmp13_);
	_tmp15_ = _tmp14_;
	if (g_strcmp0 (_tmp15_, "") != 0) {
		BudgieNotification* _tmp16_;
		const gchar* _tmp17_;
		const gchar* _tmp18_;
		GtkLabel* _tmp19_ = NULL;
		_tmp16_ = self->priv->_notification;
		_tmp17_ = budgie_notification_get_body (_tmp16_);
		_tmp18_ = _tmp17_;
		_tmp19_ = (GtkLabel*) gtk_label_new (_tmp18_);
		gtk_widget_set_halign ((GtkWidget*) _tmp19_, GTK_ALIGN_START);
		gtk_label_set_justify (_tmp19_, GTK_JUSTIFY_LEFT);
		gtk_label_set_use_markup (_tmp19_, TRUE);
		gtk_label_set_width_chars (_tmp19_, 30);
		g_object_set (_tmp19_, "wrap", TRUE, NULL);
		g_object_set (_tmp19_, "wrap-mode", PANGO_WRAP_WORD_CHAR, NULL);
		gtk_label_set_xalign (_tmp19_, (gfloat) 0);
		g_object_ref_sink (_tmp19_);
		_g_object_unref0 (label_body);
		label_body = _tmp19_;
	}
	_tmp20_ = self->priv->_notification;
	_tmp21_ = budgie_notification_get_timestamp (_tmp20_);
	_tmp22_ = _tmp21_;
	_tmp23_ = g_date_time_new_from_unix_local (_tmp22_);
	date = _tmp23_;
	_tmp24_ = g_settings_new ("org.gnome.desktop.interface");
	gnome_settings = _tmp24_;
	_tmp25_ = gnome_settings;
	_tmp26_ = g_settings_get_string (_tmp25_, "clock-format");
	clock_format = _tmp26_;
	_tmp28_ = clock_format;
	if (g_strcmp0 (_tmp28_, "12h") == 0) {
		GDateTime* _tmp29_;
		gchar* _tmp30_;
		_tmp29_ = date;
		_tmp30_ = g_date_time_format (_tmp29_, "%l:%M %p");
		_g_free0 (_tmp27_);
		_tmp27_ = _tmp30_;
	} else {
		GDateTime* _tmp31_;
		gchar* _tmp32_;
		_tmp31_ = date;
		_tmp32_ = g_date_time_format (_tmp31_, "%H:%M");
		_g_free0 (_tmp27_);
		_tmp27_ = _tmp32_;
	}
	_tmp33_ = g_strdup (_tmp27_);
	_g_free0 (clock_format);
	clock_format = _tmp33_;
	_tmp34_ = clock_format;
	_tmp35_ = (GtkLabel*) gtk_label_new (_tmp34_);
	gtk_widget_set_halign ((GtkWidget*) _tmp35_, GTK_ALIGN_START);
	gtk_label_set_justify (_tmp35_, GTK_JUSTIFY_LEFT);
	g_object_ref_sink (_tmp35_);
	label_timestamp = _tmp35_;
	_tmp36_ = label_timestamp;
	_tmp37_ = gtk_widget_get_style_context ((GtkWidget*) _tmp36_);
	gtk_style_context_add_class (_tmp37_, "dim-label");
	_tmp38_ = header;
	_tmp39_ = label_title;
	gtk_box_pack_start (_tmp38_, (GtkWidget*) _tmp39_, FALSE, FALSE, (guint) 0);
	_tmp40_ = header;
	_tmp41_ = dismiss_button;
	gtk_box_pack_end (_tmp40_, (GtkWidget*) _tmp41_, FALSE, FALSE, (guint) 0);
	_tmp42_ = box;
	_tmp43_ = header;
	gtk_box_pack_start (_tmp42_, (GtkWidget*) _tmp43_, TRUE, TRUE, (guint) 0);
	_tmp44_ = box;
	_tmp45_ = label_timestamp;
	gtk_box_pack_end (_tmp44_, (GtkWidget*) _tmp45_, TRUE, TRUE, (guint) 0);
	_tmp46_ = label_body;
	if (_tmp46_ != NULL) {
		GtkBox* _tmp47_;
		GtkLabel* _tmp48_;
		_tmp47_ = box;
		_tmp48_ = label_body;
		gtk_box_pack_end (_tmp47_, (GtkWidget*) _tmp48_, TRUE, TRUE, (guint) 0);
	}
	_tmp49_ = dismiss_button;
	g_signal_connect_object (_tmp49_, "clicked", (GCallback) _notification_widget_Dismiss_gtk_button_clicked, self, 0);
	_tmp50_ = box;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp50_);
	_g_object_unref0 (label_timestamp);
	_g_free0 (_tmp27_);
	_g_free0 (clock_format);
	_g_object_unref0 (gnome_settings);
	_g_date_time_unref0 (date);
	_g_object_unref0 (label_body);
	_g_object_unref0 (label_title);
	_g_object_unref0 (dismiss_button);
	_g_object_unref0 (header);
	_g_object_unref0 (box);
	return obj;
}

static void
notification_widget_class_init (NotificationWidgetClass * klass,
                                gpointer klass_data)
{
	notification_widget_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &NotificationWidget_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_notification_widget_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_notification_widget_set_property;
	G_OBJECT_CLASS (klass)->constructor = notification_widget_constructor;
	G_OBJECT_CLASS (klass)->finalize = notification_widget_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), NOTIFICATION_WIDGET_NOTIFICATION_PROPERTY, notification_widget_properties[NOTIFICATION_WIDGET_NOTIFICATION_PROPERTY] = g_param_spec_object ("notification", "notification", "notification", BUDGIE_TYPE_NOTIFICATION, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	notification_widget_signals[NOTIFICATION_WIDGET_CLOSED_INDIVIDUALLY_SIGNAL] = g_signal_new ("closed-individually", TYPE_NOTIFICATION_WIDGET, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
notification_widget_instance_init (NotificationWidget * self,
                                   gpointer klass)
{
	self->priv = notification_widget_get_instance_private (self);
}

static void
notification_widget_finalize (GObject * obj)
{
	NotificationWidget * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_NOTIFICATION_WIDGET, NotificationWidget);
	_g_object_unref0 (self->priv->_notification);
	G_OBJECT_CLASS (notification_widget_parent_class)->finalize (obj);
}

static GType
notification_widget_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (NotificationWidgetClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) notification_widget_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (NotificationWidget), 0, (GInstanceInitFunc) notification_widget_instance_init, NULL };
	GType notification_widget_type_id;
	notification_widget_type_id = g_type_register_static (gtk_list_box_row_get_type (), "NotificationWidget", &g_define_type_info, 0);
	NotificationWidget_private_offset = g_type_add_instance_private (notification_widget_type_id, sizeof (NotificationWidgetPrivate));
	return notification_widget_type_id;
}

GType
notification_widget_get_type (void)
{
	static volatile gsize notification_widget_type_id__once = 0;
	if (g_once_init_enter (&notification_widget_type_id__once)) {
		GType notification_widget_type_id;
		notification_widget_type_id = notification_widget_get_type_once ();
		g_once_init_leave (&notification_widget_type_id__once, notification_widget_type_id);
	}
	return notification_widget_type_id__once;
}

static void
_vala_notification_widget_get_property (GObject * object,
                                        guint property_id,
                                        GValue * value,
                                        GParamSpec * pspec)
{
	NotificationWidget * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_NOTIFICATION_WIDGET, NotificationWidget);
	switch (property_id) {
		case NOTIFICATION_WIDGET_NOTIFICATION_PROPERTY:
		g_value_set_object (value, notification_widget_get_notification (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_notification_widget_set_property (GObject * object,
                                        guint property_id,
                                        const GValue * value,
                                        GParamSpec * pspec)
{
	NotificationWidget * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_NOTIFICATION_WIDGET, NotificationWidget);
	switch (property_id) {
		case NOTIFICATION_WIDGET_NOTIFICATION_PROPERTY:
		notification_widget_set_notification (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

