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

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

#include "applications.h"
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <pango/pango.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  {
	APP_CHOOSER_BUTTON_ROW_0_PROPERTY,
	APP_CHOOSER_BUTTON_ROW_APP_ICON_PROPERTY,
	APP_CHOOSER_BUTTON_ROW_APP_NAME_PROPERTY,
	APP_CHOOSER_BUTTON_ROW_NUM_PROPERTIES
};
static GParamSpec* app_chooser_button_row_properties[APP_CHOOSER_BUTTON_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 _AppChooserButtonRowPrivate {
	GIcon* _app_icon;
	gchar* _app_name;
};

static gint AppChooserButtonRow_private_offset;
static gpointer app_chooser_button_row_parent_class = NULL;

static GObject * app_chooser_button_row_constructor (GType type,
                                              guint n_construct_properties,
                                              GObjectConstructParam * construct_properties);
static void app_chooser_button_row_finalize (GObject * obj);
static GType app_chooser_button_row_get_type_once (void);
static void _vala_app_chooser_button_row_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec);
static void _vala_app_chooser_button_row_set_property (GObject * object,
                                                guint property_id,
                                                const GValue * value,
                                                GParamSpec * pspec);

static inline gpointer
app_chooser_button_row_get_instance_private (AppChooserButtonRow* self)
{
	return G_STRUCT_MEMBER_P (self, AppChooserButtonRow_private_offset);
}

AppChooserButtonRow*
app_chooser_button_row_construct (GType object_type)
{
	AppChooserButtonRow * self = NULL;
	self = (AppChooserButtonRow*) g_object_new (object_type, NULL);
	return self;
}

AppChooserButtonRow*
app_chooser_button_row_new (void)
{
	return app_chooser_button_row_construct (TYPE_APP_CHOOSER_BUTTON_ROW);
}

GIcon*
app_chooser_button_row_get_app_icon (AppChooserButtonRow* self)
{
	GIcon* result;
	GIcon* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_app_icon;
	result = _tmp0_;
	return result;
}

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

void
app_chooser_button_row_set_app_icon (AppChooserButtonRow* self,
                                     GIcon* value)
{
	GIcon* old_value;
	g_return_if_fail (self != NULL);
	old_value = app_chooser_button_row_get_app_icon (self);
	if (old_value != value) {
		GIcon* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_app_icon);
		self->priv->_app_icon = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, app_chooser_button_row_properties[APP_CHOOSER_BUTTON_ROW_APP_ICON_PROPERTY]);
	}
}

const gchar*
app_chooser_button_row_get_app_name (AppChooserButtonRow* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_app_name;
	result = _tmp0_;
	return result;
}

void
app_chooser_button_row_set_app_name (AppChooserButtonRow* self,
                                     const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = app_chooser_button_row_get_app_name (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_app_name);
		self->priv->_app_name = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, app_chooser_button_row_properties[APP_CHOOSER_BUTTON_ROW_APP_NAME_PROPERTY]);
	}
}

static GObject *
app_chooser_button_row_constructor (GType type,
                                    guint n_construct_properties,
                                    GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	AppChooserButtonRow * self;
	GtkImage* icon = NULL;
	GtkImage* _tmp0_ = NULL;
	GtkLabel* label = NULL;
	GtkLabel* _tmp1_ = NULL;
	GtkImage* _tmp2_;
	GtkLabel* _tmp3_;
	GtkImage* _tmp4_;
	GtkLabel* _tmp5_;
	parent_class = G_OBJECT_CLASS (app_chooser_button_row_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_APP_CHOOSER_BUTTON_ROW, AppChooserButtonRow);
	gtk_orientable_set_orientation ((GtkOrientable*) self, GTK_ORIENTATION_HORIZONTAL);
	gtk_box_set_spacing ((GtkBox*) self, 6);
	_tmp0_ = (GtkImage*) gtk_image_new ();
	gtk_widget_set_halign ((GtkWidget*) _tmp0_, GTK_ALIGN_START);
	g_object_ref_sink (_tmp0_);
	icon = _tmp0_;
	_tmp1_ = (GtkLabel*) gtk_label_new (NULL);
	gtk_widget_set_halign ((GtkWidget*) _tmp1_, GTK_ALIGN_START);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp1_, TRUE);
	gtk_label_set_ellipsize (_tmp1_, PANGO_ELLIPSIZE_END);
	g_object_ref_sink (_tmp1_);
	label = _tmp1_;
	_tmp2_ = icon;
	g_object_bind_property_with_closures ((GObject*) self, "app-icon", (GObject*) _tmp2_, "gicon", G_BINDING_DEFAULT, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp3_ = label;
	g_object_bind_property_with_closures ((GObject*) self, "app-name", (GObject*) _tmp3_, "label", G_BINDING_DEFAULT, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp4_ = icon;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp4_);
	_tmp5_ = label;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp5_);
	_g_object_unref0 (label);
	_g_object_unref0 (icon);
	return obj;
}

static void
app_chooser_button_row_class_init (AppChooserButtonRowClass * klass,
                                   gpointer klass_data)
{
	app_chooser_button_row_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &AppChooserButtonRow_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_app_chooser_button_row_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_app_chooser_button_row_set_property;
	G_OBJECT_CLASS (klass)->constructor = app_chooser_button_row_constructor;
	G_OBJECT_CLASS (klass)->finalize = app_chooser_button_row_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), APP_CHOOSER_BUTTON_ROW_APP_ICON_PROPERTY, app_chooser_button_row_properties[APP_CHOOSER_BUTTON_ROW_APP_ICON_PROPERTY] = g_param_spec_object ("app-icon", "app-icon", "app-icon", g_icon_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), APP_CHOOSER_BUTTON_ROW_APP_NAME_PROPERTY, app_chooser_button_row_properties[APP_CHOOSER_BUTTON_ROW_APP_NAME_PROPERTY] = g_param_spec_string ("app-name", "app-name", "app-name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
app_chooser_button_row_instance_init (AppChooserButtonRow * self,
                                      gpointer klass)
{
	self->priv = app_chooser_button_row_get_instance_private (self);
}

static void
app_chooser_button_row_finalize (GObject * obj)
{
	AppChooserButtonRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_APP_CHOOSER_BUTTON_ROW, AppChooserButtonRow);
	_g_object_unref0 (self->priv->_app_icon);
	_g_free0 (self->priv->_app_name);
	G_OBJECT_CLASS (app_chooser_button_row_parent_class)->finalize (obj);
}

static GType
app_chooser_button_row_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (AppChooserButtonRowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) app_chooser_button_row_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (AppChooserButtonRow), 0, (GInstanceInitFunc) app_chooser_button_row_instance_init, NULL };
	GType app_chooser_button_row_type_id;
	app_chooser_button_row_type_id = g_type_register_static (gtk_box_get_type (), "AppChooserButtonRow", &g_define_type_info, 0);
	AppChooserButtonRow_private_offset = g_type_add_instance_private (app_chooser_button_row_type_id, sizeof (AppChooserButtonRowPrivate));
	return app_chooser_button_row_type_id;
}

GType
app_chooser_button_row_get_type (void)
{
	static volatile gsize app_chooser_button_row_type_id__once = 0;
	if (g_once_init_enter (&app_chooser_button_row_type_id__once)) {
		GType app_chooser_button_row_type_id;
		app_chooser_button_row_type_id = app_chooser_button_row_get_type_once ();
		g_once_init_leave (&app_chooser_button_row_type_id__once, app_chooser_button_row_type_id);
	}
	return app_chooser_button_row_type_id__once;
}

static void
_vala_app_chooser_button_row_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec)
{
	AppChooserButtonRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_APP_CHOOSER_BUTTON_ROW, AppChooserButtonRow);
	switch (property_id) {
		case APP_CHOOSER_BUTTON_ROW_APP_ICON_PROPERTY:
		g_value_set_object (value, app_chooser_button_row_get_app_icon (self));
		break;
		case APP_CHOOSER_BUTTON_ROW_APP_NAME_PROPERTY:
		g_value_set_string (value, app_chooser_button_row_get_app_name (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_app_chooser_button_row_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec)
{
	AppChooserButtonRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_APP_CHOOSER_BUTTON_ROW, AppChooserButtonRow);
	switch (property_id) {
		case APP_CHOOSER_BUTTON_ROW_APP_ICON_PROPERTY:
		app_chooser_button_row_set_app_icon (self, g_value_get_object (value));
		break;
		case APP_CHOOSER_BUTTON_ROW_APP_NAME_PROPERTY:
		app_chooser_button_row_set_app_name (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

