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

/*
 * SPDX-License-Identifier: GPL-3.0-or-later
 * SPDX-FileCopyrightText: 2024 elementary, Inc. (https://elementary.io)
 */

#include "system.h"
#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <granite-7.h>

#define ABOUT_GETTEXT_PACKAGE "io.elementary.settings.system"
#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  {
	ABOUT_UPDATE_DETAILS_DIALOG_0_PROPERTY,
	ABOUT_UPDATE_DETAILS_DIALOG_PACKAGES_PROPERTY,
	ABOUT_UPDATE_DETAILS_DIALOG_NUM_PROPERTIES
};
static GParamSpec* about_update_details_dialog_properties[ABOUT_UPDATE_DETAILS_DIALOG_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))

struct _AboutUpdateDetailsDialogPrivate {
	GtkStringList* _packages;
};

static gint AboutUpdateDetailsDialog_private_offset;
static gpointer about_update_details_dialog_parent_class = NULL;

static GObject * about_update_details_dialog_constructor (GType type,
                                                   guint n_construct_properties,
                                                   GObjectConstructParam * construct_properties);
static GtkWidget* _about_update_details_dialog___lambda6_ (AboutUpdateDetailsDialog* self,
                                                    GObject* obj);
static GtkWidget* __about_update_details_dialog___lambda6__gtk_list_box_create_widget_func (GObject* item,
                                                                                     gpointer self);
static void _about_update_details_dialog___lambda7_ (AboutUpdateDetailsDialog* self);
static void __about_update_details_dialog___lambda7__gtk_dialog_response (GtkDialog* _sender,
                                                                   gint response_id,
                                                                   gpointer self);
static void about_update_details_dialog_finalize (GObject * obj);
static GType about_update_details_dialog_get_type_once (void);
static void _vala_about_update_details_dialog_get_property (GObject * object,
                                                     guint property_id,
                                                     GValue * value,
                                                     GParamSpec * pspec);
static void _vala_about_update_details_dialog_set_property (GObject * object,
                                                     guint property_id,
                                                     const GValue * value,
                                                     GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
about_update_details_dialog_get_instance_private (AboutUpdateDetailsDialog* self)
{
	return G_STRUCT_MEMBER_P (self, AboutUpdateDetailsDialog_private_offset);
}

AboutUpdateDetailsDialog*
about_update_details_dialog_construct (GType object_type,
                                       GtkStringList* packages)
{
	AboutUpdateDetailsDialog * self = NULL;
	g_return_val_if_fail (packages != NULL, NULL);
	self = (AboutUpdateDetailsDialog*) g_object_new (object_type, "packages", packages, NULL);
	return self;
}

AboutUpdateDetailsDialog*
about_update_details_dialog_new (GtkStringList* packages)
{
	return about_update_details_dialog_construct (ABOUT_TYPE_UPDATE_DETAILS_DIALOG, packages);
}

GtkStringList*
about_update_details_dialog_get_packages (AboutUpdateDetailsDialog* self)
{
	GtkStringList* result;
	GtkStringList* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_packages;
	result = _tmp0_;
	return result;
}

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

static void
about_update_details_dialog_set_packages (AboutUpdateDetailsDialog* self,
                                          GtkStringList* value)
{
	GtkStringList* old_value;
	g_return_if_fail (self != NULL);
	old_value = about_update_details_dialog_get_packages (self);
	if (old_value != value) {
		GtkStringList* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_packages);
		self->priv->_packages = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, about_update_details_dialog_properties[ABOUT_UPDATE_DETAILS_DIALOG_PACKAGES_PROPERTY]);
	}
}

static GtkWidget*
_about_update_details_dialog___lambda6_ (AboutUpdateDetailsDialog* self,
                                         GObject* obj)
{
	gchar* str = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	GtkImage* image = NULL;
	GtkImage* _tmp3_ = NULL;
	GtkLabel* label = NULL;
	const gchar* _tmp4_;
	GtkLabel* _tmp5_;
	GtkBox* box = NULL;
	GtkBox* _tmp6_;
	GtkBox* _tmp7_;
	GtkImage* _tmp8_;
	GtkBox* _tmp9_;
	GtkLabel* _tmp10_;
	GtkWidget* result;
	g_return_val_if_fail (obj != NULL, NULL);
	_tmp0_ = gtk_string_object_get_string (G_TYPE_CHECK_INSTANCE_CAST (obj, gtk_string_object_get_type (), GtkStringObject));
	_tmp1_ = _tmp0_;
	_tmp2_ = g_strdup (_tmp1_);
	str = _tmp2_;
	_tmp3_ = (GtkImage*) gtk_image_new_from_icon_name ("package-x-generic");
	gtk_image_set_icon_size (_tmp3_, GTK_ICON_SIZE_LARGE);
	g_object_ref_sink (_tmp3_);
	image = _tmp3_;
	_tmp4_ = str;
	_tmp5_ = (GtkLabel*) gtk_label_new (_tmp4_);
	g_object_ref_sink (_tmp5_);
	label = _tmp5_;
	_tmp6_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	g_object_ref_sink (_tmp6_);
	box = _tmp6_;
	_tmp7_ = box;
	_tmp8_ = image;
	gtk_box_append (_tmp7_, (GtkWidget*) _tmp8_);
	_tmp9_ = box;
	_tmp10_ = label;
	gtk_box_append (_tmp9_, (GtkWidget*) _tmp10_);
	result = (GtkWidget*) box;
	_g_object_unref0 (label);
	_g_object_unref0 (image);
	_g_free0 (str);
	return result;
}

static GtkWidget*
__about_update_details_dialog___lambda6__gtk_list_box_create_widget_func (GObject* item,
                                                                          gpointer self)
{
	GtkWidget* result;
	result = _about_update_details_dialog___lambda6_ ((AboutUpdateDetailsDialog*) self, item);
	return result;
}

static void
_about_update_details_dialog___lambda7_ (AboutUpdateDetailsDialog* self)
{
	g_signal_emit_by_name ((GtkDialog*) self, "close");
}

static void
__about_update_details_dialog___lambda7__gtk_dialog_response (GtkDialog* _sender,
                                                              gint response_id,
                                                              gpointer self)
{
	_about_update_details_dialog___lambda7_ ((AboutUpdateDetailsDialog*) self);
}

static GObject *
about_update_details_dialog_constructor (GType type,
                                         guint n_construct_properties,
                                         GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	AboutUpdateDetailsDialog * self;
	GtkLabel* title_label = NULL;
	GtkStringList* _tmp0_;
	GtkStringList* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	GtkLabel* _tmp4_ = NULL;
	GtkLabel* _tmp5_;
	GtkLabel* _tmp6_;
	GtkListBox* packages_listbox = NULL;
	GtkListBox* _tmp7_ = NULL;
	GtkListBox* _tmp8_;
	GtkListBox* _tmp9_;
	GtkStringList* _tmp10_;
	GtkScrolledWindow* scrolled = NULL;
	GtkListBox* _tmp11_;
	GtkWidget* _tmp12_;
	GtkScrolledWindow* _tmp13_ = NULL;
	GtkFrame* frame = NULL;
	GtkScrolledWindow* _tmp14_;
	GtkWidget* _tmp15_;
	GtkFrame* _tmp16_ = NULL;
	GtkBox* box = NULL;
	GtkBox* _tmp17_;
	GtkBox* _tmp18_;
	GtkLabel* _tmp19_;
	GtkBox* _tmp20_;
	GtkFrame* _tmp21_;
	GtkBox* _tmp22_;
	GtkBox* _tmp23_;
	parent_class = G_OBJECT_CLASS (about_update_details_dialog_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, ABOUT_TYPE_UPDATE_DETAILS_DIALOG, AboutUpdateDetailsDialog);
	gtk_window_set_title ((GtkWindow*) self, _ ("What's New"));
	gtk_window_set_modal ((GtkWindow*) self, TRUE);
	_tmp0_ = self->priv->_packages;
	_tmp1_ = self->priv->_packages;
	_tmp2_ = g_strdup_printf (g_dngettext (ABOUT_GETTEXT_PACKAGE, "%u package will be upgraded", "%u packages will be upgraded", (gulong) g_list_model_get_n_items ((GListModel*) _tmp0_)), g_list_model_get_n_items ((GListModel*) _tmp1_));
	_tmp3_ = _tmp2_;
	_tmp4_ = (GtkLabel*) gtk_label_new (_tmp3_);
	gtk_widget_set_halign ((GtkWidget*) _tmp4_, GTK_ALIGN_START);
	g_object_ref_sink (_tmp4_);
	_tmp5_ = _tmp4_;
	_g_free0 (_tmp3_);
	title_label = _tmp5_;
	_tmp6_ = title_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp6_, GRANITE_STYLE_CLASS_TITLE_LABEL);
	_tmp7_ = (GtkListBox*) gtk_list_box_new ();
	gtk_widget_set_vexpand ((GtkWidget*) _tmp7_, TRUE);
	gtk_list_box_set_selection_mode (_tmp7_, GTK_SELECTION_NONE);
	g_object_ref_sink (_tmp7_);
	packages_listbox = _tmp7_;
	_tmp8_ = packages_listbox;
	gtk_widget_add_css_class ((GtkWidget*) _tmp8_, GRANITE_STYLE_CLASS_RICH_LIST);
	_tmp9_ = packages_listbox;
	_tmp10_ = self->priv->_packages;
	gtk_list_box_bind_model (_tmp9_, (GListModel*) _tmp10_, __about_update_details_dialog___lambda6__gtk_list_box_create_widget_func, g_object_ref (self), g_object_unref);
	_tmp11_ = packages_listbox;
	_tmp12_ = _g_object_ref0 ((GtkWidget*) _tmp11_);
	_tmp13_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	gtk_scrolled_window_set_child (_tmp13_, _tmp12_);
	_g_object_unref0 (_tmp12_);
	g_object_set (_tmp13_, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
	gtk_scrolled_window_set_max_content_height (_tmp13_, 400);
	gtk_scrolled_window_set_propagate_natural_height (_tmp13_, TRUE);
	g_object_ref_sink (_tmp13_);
	scrolled = _tmp13_;
	_tmp14_ = scrolled;
	_tmp15_ = _g_object_ref0 ((GtkWidget*) _tmp14_);
	_tmp16_ = (GtkFrame*) gtk_frame_new (NULL);
	gtk_frame_set_child (_tmp16_, _tmp15_);
	_g_object_unref0 (_tmp15_);
	g_object_ref_sink (_tmp16_);
	frame = _tmp16_;
	_tmp17_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
	g_object_ref_sink (_tmp17_);
	box = _tmp17_;
	_tmp18_ = box;
	_tmp19_ = title_label;
	gtk_box_append (_tmp18_, (GtkWidget*) _tmp19_);
	_tmp20_ = box;
	_tmp21_ = frame;
	gtk_box_append (_tmp20_, (GtkWidget*) _tmp21_);
	_tmp22_ = gtk_dialog_get_content_area ((GtkDialog*) self);
	_tmp23_ = box;
	gtk_box_append (_tmp22_, (GtkWidget*) _tmp23_);
	granite_dialog_add_button ((GraniteDialog*) self, _ ("Close"), (gint) GTK_RESPONSE_CLOSE);
	g_signal_connect_object ((GtkDialog*) self, "response", (GCallback) __about_update_details_dialog___lambda7__gtk_dialog_response, self, 0);
	_g_object_unref0 (box);
	_g_object_unref0 (frame);
	_g_object_unref0 (scrolled);
	_g_object_unref0 (packages_listbox);
	_g_object_unref0 (title_label);
	return obj;
}

static void
about_update_details_dialog_class_init (AboutUpdateDetailsDialogClass * klass,
                                        gpointer klass_data)
{
	about_update_details_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &AboutUpdateDetailsDialog_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_about_update_details_dialog_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_about_update_details_dialog_set_property;
	G_OBJECT_CLASS (klass)->constructor = about_update_details_dialog_constructor;
	G_OBJECT_CLASS (klass)->finalize = about_update_details_dialog_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), ABOUT_UPDATE_DETAILS_DIALOG_PACKAGES_PROPERTY, about_update_details_dialog_properties[ABOUT_UPDATE_DETAILS_DIALOG_PACKAGES_PROPERTY] = g_param_spec_object ("packages", "packages", "packages", gtk_string_list_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
about_update_details_dialog_instance_init (AboutUpdateDetailsDialog * self,
                                           gpointer klass)
{
	self->priv = about_update_details_dialog_get_instance_private (self);
}

static void
about_update_details_dialog_finalize (GObject * obj)
{
	AboutUpdateDetailsDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, ABOUT_TYPE_UPDATE_DETAILS_DIALOG, AboutUpdateDetailsDialog);
	_g_object_unref0 (self->priv->_packages);
	G_OBJECT_CLASS (about_update_details_dialog_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
about_update_details_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (AboutUpdateDetailsDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) about_update_details_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (AboutUpdateDetailsDialog), 0, (GInstanceInitFunc) about_update_details_dialog_instance_init, NULL };
	GType about_update_details_dialog_type_id;
	about_update_details_dialog_type_id = g_type_register_static (GRANITE_TYPE_DIALOG, "AboutUpdateDetailsDialog", &g_define_type_info, 0);
	AboutUpdateDetailsDialog_private_offset = g_type_add_instance_private (about_update_details_dialog_type_id, sizeof (AboutUpdateDetailsDialogPrivate));
	return about_update_details_dialog_type_id;
}

GType
about_update_details_dialog_get_type (void)
{
	static volatile gsize about_update_details_dialog_type_id__once = 0;
	if (g_once_init_enter (&about_update_details_dialog_type_id__once)) {
		GType about_update_details_dialog_type_id;
		about_update_details_dialog_type_id = about_update_details_dialog_get_type_once ();
		g_once_init_leave (&about_update_details_dialog_type_id__once, about_update_details_dialog_type_id);
	}
	return about_update_details_dialog_type_id__once;
}

static void
_vala_about_update_details_dialog_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec)
{
	AboutUpdateDetailsDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, ABOUT_TYPE_UPDATE_DETAILS_DIALOG, AboutUpdateDetailsDialog);
	switch (property_id) {
		case ABOUT_UPDATE_DETAILS_DIALOG_PACKAGES_PROPERTY:
		g_value_set_object (value, about_update_details_dialog_get_packages (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_about_update_details_dialog_set_property (GObject * object,
                                                guint property_id,
                                                const GValue * value,
                                                GParamSpec * pspec)
{
	AboutUpdateDetailsDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, ABOUT_TYPE_UPDATE_DETAILS_DIALOG, AboutUpdateDetailsDialog);
	switch (property_id) {
		case ABOUT_UPDATE_DETAILS_DIALOG_PACKAGES_PROPERTY:
		about_update_details_dialog_set_packages (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

