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

/* SPDX-License-Identifier: GPL-3.0-or-later
 * SPDX-FileCopyrightText: 2013-2023 elementary, Inc. (https://elementary.io)
 *
 * Authored by: Julien Spautz <spautz.julien@gmail.com>
 */

#include "applications.h"
#include <glib-object.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.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  {
	STARTUP_WIDGETS_APP_CHOOSER_ROW_0_PROPERTY,
	STARTUP_WIDGETS_APP_CHOOSER_ROW_APP_INFO_PROPERTY,
	STARTUP_WIDGETS_APP_CHOOSER_ROW_NUM_PROPERTIES
};
static GParamSpec* startup_widgets_app_chooser_row_properties[STARTUP_WIDGETS_APP_CHOOSER_ROW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	STARTUP_WIDGETS_APP_CHOOSER_ROW_DELETED_SIGNAL,
	STARTUP_WIDGETS_APP_CHOOSER_ROW_NUM_SIGNALS
};
static guint startup_widgets_app_chooser_row_signals[STARTUP_WIDGETS_APP_CHOOSER_ROW_NUM_SIGNALS] = {0};

struct _StartupWidgetsAppChooserRowPrivate {
	StartupEntityAppInfo _app_info;
};

static gint StartupWidgetsAppChooserRow_private_offset;
static gpointer startup_widgets_app_chooser_row_parent_class = NULL;

static gboolean _startup_entity_app_info_equal (const StartupEntityAppInfo * s1,
                                         const StartupEntityAppInfo * s2);
static GObject * startup_widgets_app_chooser_row_constructor (GType type,
                                                       guint n_construct_properties,
                                                       GObjectConstructParam * construct_properties);
static void startup_widgets_app_chooser_row_finalize (GObject * obj);
static GType startup_widgets_app_chooser_row_get_type_once (void);
static void _vala_startup_widgets_app_chooser_row_get_property (GObject * object,
                                                         guint property_id,
                                                         GValue * value,
                                                         GParamSpec * pspec);
static void _vala_startup_widgets_app_chooser_row_set_property (GObject * object,
                                                         guint property_id,
                                                         const GValue * value,
                                                         GParamSpec * pspec);

static inline gpointer
startup_widgets_app_chooser_row_get_instance_private (StartupWidgetsAppChooserRow* self)
{
	return G_STRUCT_MEMBER_P (self, StartupWidgetsAppChooserRow_private_offset);
}

StartupWidgetsAppChooserRow*
startup_widgets_app_chooser_row_construct (GType object_type,
                                           StartupEntityAppInfo* app_info)
{
	StartupWidgetsAppChooserRow * self = NULL;
	StartupEntityAppInfo _tmp0_;
	g_return_val_if_fail (app_info != NULL, NULL);
	_tmp0_ = *app_info;
	self = (StartupWidgetsAppChooserRow*) g_object_new (object_type, "app-info", &_tmp0_, NULL);
	return self;
}

StartupWidgetsAppChooserRow*
startup_widgets_app_chooser_row_new (StartupEntityAppInfo* app_info)
{
	return startup_widgets_app_chooser_row_construct (STARTUP_WIDGETS_TYPE_APP_CHOOSER_ROW, app_info);
}

void
startup_widgets_app_chooser_row_get_app_info (StartupWidgetsAppChooserRow* self,
                                              StartupEntityAppInfo * result)
{
	StartupEntityAppInfo _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_app_info;
	*result = _tmp0_;
	return;
}

static gboolean
_startup_entity_app_info_equal (const StartupEntityAppInfo * s1,
                                const StartupEntityAppInfo * s2)
{
	if (s1 == s2) {
		return TRUE;
	}
	if (s1 == NULL) {
		return FALSE;
	}
	if (s2 == NULL) {
		return FALSE;
	}
	if (g_strcmp0 (s1->name, s2->name)) {
		return FALSE;
	}
	if (g_strcmp0 (s1->comment, s2->comment)) {
		return FALSE;
	}
	if (g_strcmp0 (s1->icon, s2->icon)) {
		return FALSE;
	}
	if (s1->active != s2->active) {
		return FALSE;
	}
	if (g_strcmp0 (s1->path, s2->path)) {
		return FALSE;
	}
	return TRUE;
}

static void
startup_widgets_app_chooser_row_set_app_info (StartupWidgetsAppChooserRow* self,
                                              StartupEntityAppInfo * value)
{
	StartupEntityAppInfo old_value;
	g_return_if_fail (self != NULL);
	startup_widgets_app_chooser_row_get_app_info (self, &old_value);
	if (_startup_entity_app_info_equal (value, &old_value) != TRUE) {
		StartupEntityAppInfo _tmp0_;
		StartupEntityAppInfo _tmp1_;
		StartupEntityAppInfo _tmp2_ = {0};
		_tmp0_ = *value;
		_tmp1_ = _tmp0_;
		startup_entity_app_info_copy (&_tmp1_, &_tmp2_);
		startup_entity_app_info_destroy (&self->priv->_app_info);
		self->priv->_app_info = _tmp2_;
		g_object_notify_by_pspec ((GObject *) self, startup_widgets_app_chooser_row_properties[STARTUP_WIDGETS_APP_CHOOSER_ROW_APP_INFO_PROPERTY]);
	}
}

static GObject *
startup_widgets_app_chooser_row_constructor (GType type,
                                             guint n_construct_properties,
                                             GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	StartupWidgetsAppChooserRow * self;
	GtkImage* image = NULL;
	StartupEntityAppInfo _tmp0_;
	GtkImage* _tmp1_;
	GtkLabel* app_name = NULL;
	StartupEntityAppInfo _tmp2_;
	const gchar* _tmp3_;
	GtkLabel* _tmp4_ = NULL;
	GtkLabel* app_comment = NULL;
	StartupEntityAppInfo _tmp5_;
	const gchar* _tmp6_;
	GtkLabel* _tmp7_ = NULL;
	GtkLabel* _tmp8_;
	GtkImage* _tmp9_;
	GtkLabel* _tmp10_;
	GtkLabel* _tmp11_;
	parent_class = G_OBJECT_CLASS (startup_widgets_app_chooser_row_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, STARTUP_WIDGETS_TYPE_APP_CHOOSER_ROW, StartupWidgetsAppChooserRow);
	_tmp0_ = self->priv->_app_info;
	_tmp1_ = startup_utils_create_icon (&_tmp0_);
	image = _tmp1_;
	_tmp2_ = self->priv->_app_info;
	_tmp3_ = _tmp2_.name;
	_tmp4_ = (GtkLabel*) gtk_label_new (_tmp3_);
	gtk_label_set_xalign (_tmp4_, (gfloat) 0);
	gtk_label_set_ellipsize (_tmp4_, PANGO_ELLIPSIZE_END);
	g_object_ref_sink (_tmp4_);
	app_name = _tmp4_;
	_tmp5_ = self->priv->_app_info;
	_tmp6_ = _tmp5_.comment;
	_tmp7_ = (GtkLabel*) gtk_label_new (_tmp6_);
	gtk_label_set_xalign (_tmp7_, (gfloat) 0);
	gtk_label_set_ellipsize (_tmp7_, PANGO_ELLIPSIZE_END);
	g_object_ref_sink (_tmp7_);
	app_comment = _tmp7_;
	_tmp8_ = app_comment;
	gtk_widget_add_css_class ((GtkWidget*) _tmp8_, GRANITE_STYLE_CLASS_SMALL_LABEL);
	gtk_grid_set_column_spacing ((GtkGrid*) self, 6);
	_tmp9_ = image;
	gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) _tmp9_, 0, 0, 1, 2);
	_tmp10_ = app_name;
	gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) _tmp10_, 1, 0, 1, 1);
	_tmp11_ = app_comment;
	gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) _tmp11_, 1, 1, 1, 1);
	_g_object_unref0 (app_comment);
	_g_object_unref0 (app_name);
	_g_object_unref0 (image);
	return obj;
}

static void
startup_widgets_app_chooser_row_class_init (StartupWidgetsAppChooserRowClass * klass,
                                            gpointer klass_data)
{
	startup_widgets_app_chooser_row_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &StartupWidgetsAppChooserRow_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_startup_widgets_app_chooser_row_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_startup_widgets_app_chooser_row_set_property;
	G_OBJECT_CLASS (klass)->constructor = startup_widgets_app_chooser_row_constructor;
	G_OBJECT_CLASS (klass)->finalize = startup_widgets_app_chooser_row_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), STARTUP_WIDGETS_APP_CHOOSER_ROW_APP_INFO_PROPERTY, startup_widgets_app_chooser_row_properties[STARTUP_WIDGETS_APP_CHOOSER_ROW_APP_INFO_PROPERTY] = g_param_spec_boxed ("app-info", "app-info", "app-info", STARTUP_ENTITY_TYPE_APP_INFO, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	startup_widgets_app_chooser_row_signals[STARTUP_WIDGETS_APP_CHOOSER_ROW_DELETED_SIGNAL] = g_signal_new ("deleted", STARTUP_WIDGETS_TYPE_APP_CHOOSER_ROW, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
startup_widgets_app_chooser_row_instance_init (StartupWidgetsAppChooserRow * self,
                                               gpointer klass)
{
	self->priv = startup_widgets_app_chooser_row_get_instance_private (self);
}

static void
startup_widgets_app_chooser_row_finalize (GObject * obj)
{
	StartupWidgetsAppChooserRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, STARTUP_WIDGETS_TYPE_APP_CHOOSER_ROW, StartupWidgetsAppChooserRow);
	startup_entity_app_info_destroy (&self->priv->_app_info);
	G_OBJECT_CLASS (startup_widgets_app_chooser_row_parent_class)->finalize (obj);
}

static GType
startup_widgets_app_chooser_row_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (StartupWidgetsAppChooserRowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) startup_widgets_app_chooser_row_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (StartupWidgetsAppChooserRow), 0, (GInstanceInitFunc) startup_widgets_app_chooser_row_instance_init, NULL };
	GType startup_widgets_app_chooser_row_type_id;
	startup_widgets_app_chooser_row_type_id = g_type_register_static (gtk_grid_get_type (), "StartupWidgetsAppChooserRow", &g_define_type_info, 0);
	StartupWidgetsAppChooserRow_private_offset = g_type_add_instance_private (startup_widgets_app_chooser_row_type_id, sizeof (StartupWidgetsAppChooserRowPrivate));
	return startup_widgets_app_chooser_row_type_id;
}

GType
startup_widgets_app_chooser_row_get_type (void)
{
	static volatile gsize startup_widgets_app_chooser_row_type_id__once = 0;
	if (g_once_init_enter (&startup_widgets_app_chooser_row_type_id__once)) {
		GType startup_widgets_app_chooser_row_type_id;
		startup_widgets_app_chooser_row_type_id = startup_widgets_app_chooser_row_get_type_once ();
		g_once_init_leave (&startup_widgets_app_chooser_row_type_id__once, startup_widgets_app_chooser_row_type_id);
	}
	return startup_widgets_app_chooser_row_type_id__once;
}

static void
_vala_startup_widgets_app_chooser_row_get_property (GObject * object,
                                                    guint property_id,
                                                    GValue * value,
                                                    GParamSpec * pspec)
{
	StartupWidgetsAppChooserRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, STARTUP_WIDGETS_TYPE_APP_CHOOSER_ROW, StartupWidgetsAppChooserRow);
	switch (property_id) {
		case STARTUP_WIDGETS_APP_CHOOSER_ROW_APP_INFO_PROPERTY:
		{
			StartupEntityAppInfo boxed;
			startup_widgets_app_chooser_row_get_app_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_startup_widgets_app_chooser_row_set_property (GObject * object,
                                                    guint property_id,
                                                    const GValue * value,
                                                    GParamSpec * pspec)
{
	StartupWidgetsAppChooserRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, STARTUP_WIDGETS_TYPE_APP_CHOOSER_ROW, StartupWidgetsAppChooserRow);
	switch (property_id) {
		case STARTUP_WIDGETS_APP_CHOOSER_ROW_APP_INFO_PROPERTY:
		startup_widgets_app_chooser_row_set_app_info (self, g_value_get_boxed (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

