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

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

#include "keyboard.h"
#include <glib-object.h>
#include <glib.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include <float.h>
#include <math.h>
#include <pango/pango.h>
#include <granite-7.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  {
	KEYBOARD_SHORTCUTS_APP_CHOOSER_ROW_0_PROPERTY,
	KEYBOARD_SHORTCUTS_APP_CHOOSER_ROW_INFO_PROPERTY,
	KEYBOARD_SHORTCUTS_APP_CHOOSER_ROW_NUM_PROPERTIES
};
static GParamSpec* keyboard_shortcuts_app_chooser_row_properties[KEYBOARD_SHORTCUTS_APP_CHOOSER_ROW_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 _KeyboardShortcutsAppChooserRowPrivate {
	KeyboardShortcutsAppChooserRowInfo _info;
};

static gint KeyboardShortcutsAppChooserRow_private_offset;
static gpointer keyboard_shortcuts_app_chooser_row_parent_class = NULL;

static gboolean _keyboard_shortcuts_app_chooser_row_info_equal (const KeyboardShortcutsAppChooserRowInfo * s1,
                                                         const KeyboardShortcutsAppChooserRowInfo * s2);
static GObject * keyboard_shortcuts_app_chooser_row_constructor (GType type,
                                                          guint n_construct_properties,
                                                          GObjectConstructParam * construct_properties);
static void keyboard_shortcuts_app_chooser_row_finalize (GObject * obj);
static GType keyboard_shortcuts_app_chooser_row_get_type_once (void);
static void _vala_keyboard_shortcuts_app_chooser_row_get_property (GObject * object,
                                                            guint property_id,
                                                            GValue * value,
                                                            GParamSpec * pspec);
static void _vala_keyboard_shortcuts_app_chooser_row_set_property (GObject * object,
                                                            guint property_id,
                                                            const GValue * value,
                                                            GParamSpec * pspec);

static inline gpointer
keyboard_shortcuts_app_chooser_row_get_instance_private (KeyboardShortcutsAppChooserRow* self)
{
	return G_STRUCT_MEMBER_P (self, KeyboardShortcutsAppChooserRow_private_offset);
}

KeyboardShortcutsAppChooserRow*
keyboard_shortcuts_app_chooser_row_construct (GType object_type,
                                              KeyboardShortcutsAppChooserRowInfo* info)
{
	KeyboardShortcutsAppChooserRow * self = NULL;
	KeyboardShortcutsAppChooserRowInfo _tmp0_;
	g_return_val_if_fail (info != NULL, NULL);
	_tmp0_ = *info;
	self = (KeyboardShortcutsAppChooserRow*) g_object_new (object_type, "info", &_tmp0_, NULL);
	return self;
}

KeyboardShortcutsAppChooserRow*
keyboard_shortcuts_app_chooser_row_new (KeyboardShortcutsAppChooserRowInfo* info)
{
	return keyboard_shortcuts_app_chooser_row_construct (KEYBOARD_SHORTCUTS_TYPE_APP_CHOOSER_ROW, info);
}

void
keyboard_shortcuts_app_chooser_row_get_info (KeyboardShortcutsAppChooserRow* self,
                                             KeyboardShortcutsAppChooserRowInfo * result)
{
	KeyboardShortcutsAppChooserRowInfo _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_info;
	*result = _tmp0_;
	return;
}

static gboolean
_keyboard_shortcuts_app_chooser_row_info_equal (const KeyboardShortcutsAppChooserRowInfo * s1,
                                                const KeyboardShortcutsAppChooserRowInfo * s2)
{
	if (s1 == s2) {
		return TRUE;
	}
	if (s1 == NULL) {
		return FALSE;
	}
	if (s2 == NULL) {
		return FALSE;
	}
	if (s1->icon != s2->icon) {
		return FALSE;
	}
	if (s1->overlay_icon != s2->overlay_icon) {
		return FALSE;
	}
	if (g_strcmp0 (s1->name, s2->name)) {
		return FALSE;
	}
	if (g_strcmp0 (s1->description, s2->description)) {
		return FALSE;
	}
	if (g_strcmp0 (s1->action, s2->action)) {
		return FALSE;
	}
	if (g_strcmp0 (s1->filename, s2->filename)) {
		return FALSE;
	}
	return TRUE;
}

static void
keyboard_shortcuts_app_chooser_row_set_info (KeyboardShortcutsAppChooserRow* self,
                                             KeyboardShortcutsAppChooserRowInfo * value)
{
	KeyboardShortcutsAppChooserRowInfo old_value;
	g_return_if_fail (self != NULL);
	keyboard_shortcuts_app_chooser_row_get_info (self, &old_value);
	if (_keyboard_shortcuts_app_chooser_row_info_equal (value, &old_value) != TRUE) {
		KeyboardShortcutsAppChooserRowInfo _tmp0_;
		KeyboardShortcutsAppChooserRowInfo _tmp1_;
		KeyboardShortcutsAppChooserRowInfo _tmp2_ = {0};
		_tmp0_ = *value;
		_tmp1_ = _tmp0_;
		keyboard_shortcuts_app_chooser_row_info_copy (&_tmp1_, &_tmp2_);
		keyboard_shortcuts_app_chooser_row_info_destroy (&self->priv->_info);
		self->priv->_info = _tmp2_;
		g_object_notify_by_pspec ((GObject *) self, keyboard_shortcuts_app_chooser_row_properties[KEYBOARD_SHORTCUTS_APP_CHOOSER_ROW_INFO_PROPERTY]);
	}
}

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

void
keyboard_shortcuts_app_chooser_row_info_copy (const KeyboardShortcutsAppChooserRowInfo* self,
                                              KeyboardShortcutsAppChooserRowInfo* dest)
{
	GIcon* _tmp0_;
	GIcon* _tmp1_;
	GIcon* _tmp2_;
	GIcon* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	const gchar* _tmp8_;
	gchar* _tmp9_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	_tmp0_ = (*self).icon;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 ((*dest).icon);
	(*dest).icon = _tmp1_;
	_tmp2_ = (*self).overlay_icon;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	_g_object_unref0 ((*dest).overlay_icon);
	(*dest).overlay_icon = _tmp3_;
	_tmp4_ = (*self).name;
	_tmp5_ = g_strdup (_tmp4_);
	_g_free0 ((*dest).name);
	(*dest).name = _tmp5_;
	_tmp6_ = (*self).description;
	_tmp7_ = g_strdup (_tmp6_);
	_g_free0 ((*dest).description);
	(*dest).description = _tmp7_;
	_tmp8_ = (*self).action;
	_tmp9_ = g_strdup (_tmp8_);
	_g_free0 ((*dest).action);
	(*dest).action = _tmp9_;
	_tmp10_ = (*self).filename;
	_tmp11_ = g_strdup (_tmp10_);
	_g_free0 ((*dest).filename);
	(*dest).filename = _tmp11_;
}

void
keyboard_shortcuts_app_chooser_row_info_destroy (KeyboardShortcutsAppChooserRowInfo* self)
{
	_g_object_unref0 ((*self).icon);
	_g_object_unref0 ((*self).overlay_icon);
	_g_free0 ((*self).name);
	_g_free0 ((*self).description);
	_g_free0 ((*self).action);
	_g_free0 ((*self).filename);
}

KeyboardShortcutsAppChooserRowInfo*
keyboard_shortcuts_app_chooser_row_info_dup (const KeyboardShortcutsAppChooserRowInfo* self)
{
	KeyboardShortcutsAppChooserRowInfo* dup;
	dup = g_new0 (KeyboardShortcutsAppChooserRowInfo, 1);
	keyboard_shortcuts_app_chooser_row_info_copy (self, dup);
	return dup;
}

void
keyboard_shortcuts_app_chooser_row_info_free (KeyboardShortcutsAppChooserRowInfo* self)
{
	keyboard_shortcuts_app_chooser_row_info_destroy (self);
	g_free (self);
}

static GType
keyboard_shortcuts_app_chooser_row_info_get_type_once (void)
{
	GType keyboard_shortcuts_app_chooser_row_info_type_id;
	keyboard_shortcuts_app_chooser_row_info_type_id = g_boxed_type_register_static ("KeyboardShortcutsAppChooserRowInfo", (GBoxedCopyFunc) keyboard_shortcuts_app_chooser_row_info_dup, (GBoxedFreeFunc) keyboard_shortcuts_app_chooser_row_info_free);
	return keyboard_shortcuts_app_chooser_row_info_type_id;
}

GType
keyboard_shortcuts_app_chooser_row_info_get_type (void)
{
	static volatile gsize keyboard_shortcuts_app_chooser_row_info_type_id__once = 0;
	if (g_once_init_enter (&keyboard_shortcuts_app_chooser_row_info_type_id__once)) {
		GType keyboard_shortcuts_app_chooser_row_info_type_id;
		keyboard_shortcuts_app_chooser_row_info_type_id = keyboard_shortcuts_app_chooser_row_info_get_type_once ();
		g_once_init_leave (&keyboard_shortcuts_app_chooser_row_info_type_id__once, keyboard_shortcuts_app_chooser_row_info_type_id);
	}
	return keyboard_shortcuts_app_chooser_row_info_type_id__once;
}

static GObject *
keyboard_shortcuts_app_chooser_row_constructor (GType type,
                                                guint n_construct_properties,
                                                GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	KeyboardShortcutsAppChooserRow * self;
	GtkImage* image = NULL;
	KeyboardShortcutsAppChooserRowInfo _tmp0_;
	GIcon* _tmp1_;
	GIcon* _tmp2_;
	GtkImage* _tmp3_ = NULL;
	GtkOverlay* overlay = NULL;
	KeyboardShortcutsAppChooserRowInfo _tmp4_;
	GIcon* _tmp5_;
	GtkLabel* app_name = NULL;
	KeyboardShortcutsAppChooserRowInfo _tmp15_;
	const gchar* _tmp16_;
	GtkLabel* _tmp17_ = NULL;
	GtkLabel* app_comment = NULL;
	KeyboardShortcutsAppChooserRowInfo _tmp18_;
	const gchar* _tmp19_;
	GtkLabel* _tmp20_ = NULL;
	GtkLabel* _tmp21_;
	GtkOverlay* _tmp22_;
	GtkLabel* _tmp25_;
	GtkLabel* _tmp26_;
	parent_class = G_OBJECT_CLASS (keyboard_shortcuts_app_chooser_row_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, KEYBOARD_SHORTCUTS_TYPE_APP_CHOOSER_ROW, KeyboardShortcutsAppChooserRow);
	_tmp0_ = self->priv->_info;
	_tmp1_ = _tmp0_.icon;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_tmp3_ = (GtkImage*) gtk_image_new ();
	gtk_image_set_pixel_size (_tmp3_, 32);
	g_object_set (_tmp3_, "gicon", _tmp2_, NULL);
	_g_object_unref0 (_tmp2_);
	g_object_ref_sink (_tmp3_);
	image = _tmp3_;
	overlay = NULL;
	_tmp4_ = self->priv->_info;
	_tmp5_ = _tmp4_.overlay_icon;
	if (_tmp5_ != NULL) {
		GtkImage* overlay_image = NULL;
		KeyboardShortcutsAppChooserRowInfo _tmp6_;
		GIcon* _tmp7_;
		GIcon* _tmp8_;
		GtkImage* _tmp9_ = NULL;
		GtkImage* _tmp10_;
		GtkWidget* _tmp11_;
		GtkOverlay* _tmp12_ = NULL;
		GtkOverlay* _tmp13_;
		GtkImage* _tmp14_;
		_tmp6_ = self->priv->_info;
		_tmp7_ = _tmp6_.overlay_icon;
		_tmp8_ = _g_object_ref0 (_tmp7_);
		_tmp9_ = (GtkImage*) gtk_image_new ();
		gtk_image_set_pixel_size (_tmp9_, 16);
		g_object_set (_tmp9_, "gicon", _tmp8_, NULL);
		_g_object_unref0 (_tmp8_);
		gtk_widget_set_halign ((GtkWidget*) _tmp9_, GTK_ALIGN_END);
		gtk_widget_set_valign ((GtkWidget*) _tmp9_, GTK_ALIGN_END);
		g_object_ref_sink (_tmp9_);
		overlay_image = _tmp9_;
		_tmp10_ = image;
		_tmp11_ = _g_object_ref0 ((GtkWidget*) _tmp10_);
		_tmp12_ = (GtkOverlay*) gtk_overlay_new ();
		gtk_overlay_set_child (_tmp12_, _tmp11_);
		_g_object_unref0 (_tmp11_);
		g_object_ref_sink (_tmp12_);
		_g_object_unref0 (overlay);
		overlay = _tmp12_;
		_tmp13_ = overlay;
		_tmp14_ = overlay_image;
		gtk_overlay_add_overlay (_tmp13_, (GtkWidget*) _tmp14_);
		_g_object_unref0 (overlay_image);
	}
	_tmp15_ = self->priv->_info;
	_tmp16_ = _tmp15_.name;
	_tmp17_ = (GtkLabel*) gtk_label_new (_tmp16_);
	gtk_label_set_xalign (_tmp17_, (gfloat) 0);
	gtk_label_set_ellipsize (_tmp17_, PANGO_ELLIPSIZE_END);
	g_object_ref_sink (_tmp17_);
	app_name = _tmp17_;
	_tmp18_ = self->priv->_info;
	_tmp19_ = _tmp18_.description;
	_tmp20_ = (GtkLabel*) gtk_label_new (_tmp19_);
	gtk_label_set_xalign (_tmp20_, (gfloat) 0);
	gtk_label_set_ellipsize (_tmp20_, PANGO_ELLIPSIZE_END);
	g_object_ref_sink (_tmp20_);
	app_comment = _tmp20_;
	_tmp21_ = app_comment;
	gtk_widget_add_css_class ((GtkWidget*) _tmp21_, GRANITE_STYLE_CLASS_SMALL_LABEL);
	gtk_grid_set_column_spacing ((GtkGrid*) self, 6);
	_tmp22_ = overlay;
	if (_tmp22_ != NULL) {
		GtkOverlay* _tmp23_;
		_tmp23_ = overlay;
		gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) _tmp23_, 0, 0, 1, 2);
	} else {
		GtkImage* _tmp24_;
		_tmp24_ = image;
		gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) _tmp24_, 0, 0, 1, 2);
	}
	_tmp25_ = app_name;
	gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) _tmp25_, 1, 0, 1, 1);
	_tmp26_ = app_comment;
	gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) _tmp26_, 1, 1, 1, 1);
	_g_object_unref0 (app_comment);
	_g_object_unref0 (app_name);
	_g_object_unref0 (overlay);
	_g_object_unref0 (image);
	return obj;
}

static void
keyboard_shortcuts_app_chooser_row_class_init (KeyboardShortcutsAppChooserRowClass * klass,
                                               gpointer klass_data)
{
	keyboard_shortcuts_app_chooser_row_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &KeyboardShortcutsAppChooserRow_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_keyboard_shortcuts_app_chooser_row_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_keyboard_shortcuts_app_chooser_row_set_property;
	G_OBJECT_CLASS (klass)->constructor = keyboard_shortcuts_app_chooser_row_constructor;
	G_OBJECT_CLASS (klass)->finalize = keyboard_shortcuts_app_chooser_row_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), KEYBOARD_SHORTCUTS_APP_CHOOSER_ROW_INFO_PROPERTY, keyboard_shortcuts_app_chooser_row_properties[KEYBOARD_SHORTCUTS_APP_CHOOSER_ROW_INFO_PROPERTY] = g_param_spec_boxed ("info", "info", "info", KEYBOARD_SHORTCUTS_APP_CHOOSER_ROW_TYPE_INFO, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
keyboard_shortcuts_app_chooser_row_instance_init (KeyboardShortcutsAppChooserRow * self,
                                                  gpointer klass)
{
	self->priv = keyboard_shortcuts_app_chooser_row_get_instance_private (self);
}

static void
keyboard_shortcuts_app_chooser_row_finalize (GObject * obj)
{
	KeyboardShortcutsAppChooserRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, KEYBOARD_SHORTCUTS_TYPE_APP_CHOOSER_ROW, KeyboardShortcutsAppChooserRow);
	keyboard_shortcuts_app_chooser_row_info_destroy (&self->priv->_info);
	G_OBJECT_CLASS (keyboard_shortcuts_app_chooser_row_parent_class)->finalize (obj);
}

static GType
keyboard_shortcuts_app_chooser_row_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (KeyboardShortcutsAppChooserRowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) keyboard_shortcuts_app_chooser_row_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (KeyboardShortcutsAppChooserRow), 0, (GInstanceInitFunc) keyboard_shortcuts_app_chooser_row_instance_init, NULL };
	GType keyboard_shortcuts_app_chooser_row_type_id;
	keyboard_shortcuts_app_chooser_row_type_id = g_type_register_static (gtk_grid_get_type (), "KeyboardShortcutsAppChooserRow", &g_define_type_info, 0);
	KeyboardShortcutsAppChooserRow_private_offset = g_type_add_instance_private (keyboard_shortcuts_app_chooser_row_type_id, sizeof (KeyboardShortcutsAppChooserRowPrivate));
	return keyboard_shortcuts_app_chooser_row_type_id;
}

GType
keyboard_shortcuts_app_chooser_row_get_type (void)
{
	static volatile gsize keyboard_shortcuts_app_chooser_row_type_id__once = 0;
	if (g_once_init_enter (&keyboard_shortcuts_app_chooser_row_type_id__once)) {
		GType keyboard_shortcuts_app_chooser_row_type_id;
		keyboard_shortcuts_app_chooser_row_type_id = keyboard_shortcuts_app_chooser_row_get_type_once ();
		g_once_init_leave (&keyboard_shortcuts_app_chooser_row_type_id__once, keyboard_shortcuts_app_chooser_row_type_id);
	}
	return keyboard_shortcuts_app_chooser_row_type_id__once;
}

static void
_vala_keyboard_shortcuts_app_chooser_row_get_property (GObject * object,
                                                       guint property_id,
                                                       GValue * value,
                                                       GParamSpec * pspec)
{
	KeyboardShortcutsAppChooserRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, KEYBOARD_SHORTCUTS_TYPE_APP_CHOOSER_ROW, KeyboardShortcutsAppChooserRow);
	switch (property_id) {
		case KEYBOARD_SHORTCUTS_APP_CHOOSER_ROW_INFO_PROPERTY:
		{
			KeyboardShortcutsAppChooserRowInfo boxed;
			keyboard_shortcuts_app_chooser_row_get_info (self, &boxed);
			g_value_set_boxed (value, &boxed);
		}
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_keyboard_shortcuts_app_chooser_row_set_property (GObject * object,
                                                       guint property_id,
                                                       const GValue * value,
                                                       GParamSpec * pspec)
{
	KeyboardShortcutsAppChooserRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, KEYBOARD_SHORTCUTS_TYPE_APP_CHOOSER_ROW, KeyboardShortcutsAppChooserRow);
	switch (property_id) {
		case KEYBOARD_SHORTCUTS_APP_CHOOSER_ROW_INFO_PROPERTY:
		keyboard_shortcuts_app_chooser_row_set_info (self, g_value_get_boxed (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

