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

#include <gtk/gtk.h>
#include <glib-object.h>
#include "budgie-private.h"
#include <glib.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define TYPE_LAUNCHER_BUTTON (launcher_button_get_type ())
#define LAUNCHER_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_LAUNCHER_BUTTON, LauncherButton))
#define LAUNCHER_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_LAUNCHER_BUTTON, LauncherButtonClass))
#define IS_LAUNCHER_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_LAUNCHER_BUTTON))
#define IS_LAUNCHER_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_LAUNCHER_BUTTON))
#define LAUNCHER_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_LAUNCHER_BUTTON, LauncherButtonClass))

typedef struct _LauncherButton LauncherButton;
typedef struct _LauncherButtonClass LauncherButtonClass;
typedef struct _LauncherButtonPrivate LauncherButtonPrivate;
enum  {
	LAUNCHER_BUTTON_0_PROPERTY,
	LAUNCHER_BUTTON_APPLICATION_PROPERTY,
	LAUNCHER_BUTTON_NUM_PROPERTIES
};
static GParamSpec* launcher_button_properties[LAUNCHER_BUTTON_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 _LauncherButton {
	GtkBox parent_instance;
	LauncherButtonPrivate * priv;
};

struct _LauncherButtonClass {
	GtkBoxClass parent_class;
};

struct _LauncherButtonPrivate {
	BudgieApplication* _application;
};

static gint LauncherButton_private_offset;
static gpointer launcher_button_parent_class = NULL;

VALA_EXTERN GType launcher_button_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (LauncherButton, g_object_unref)
VALA_EXTERN LauncherButton* launcher_button_new (BudgieApplication* app);
VALA_EXTERN LauncherButton* launcher_button_construct (GType object_type,
                                           BudgieApplication* app);
VALA_EXTERN BudgieApplication* launcher_button_get_application (LauncherButton* self);
static void launcher_button_set_application (LauncherButton* self,
                                      BudgieApplication* value);
static GObject * launcher_button_constructor (GType type,
                                       guint n_construct_properties,
                                       GObjectConstructParam * construct_properties);
static void launcher_button_finalize (GObject * obj);
static GType launcher_button_get_type_once (void);
static void _vala_launcher_button_get_property (GObject * object,
                                         guint property_id,
                                         GValue * value,
                                         GParamSpec * pspec);
static void _vala_launcher_button_set_property (GObject * object,
                                         guint property_id,
                                         const GValue * value,
                                         GParamSpec * pspec);

static inline gpointer
launcher_button_get_instance_private (LauncherButton* self)
{
	return G_STRUCT_MEMBER_P (self, LauncherButton_private_offset);
}

LauncherButton*
launcher_button_construct (GType object_type,
                           BudgieApplication* app)
{
	LauncherButton * self = NULL;
	g_return_val_if_fail (app != NULL, NULL);
	self = (LauncherButton*) g_object_new (object_type, "application", app, "orientation", GTK_ORIENTATION_HORIZONTAL, "spacing", 12, "hexpand", FALSE, "vexpand", FALSE, "halign", GTK_ALIGN_START, "valign", GTK_ALIGN_START, "margin-top", 3, "margin-bottom", 3, NULL);
	return self;
}

LauncherButton*
launcher_button_new (BudgieApplication* app)
{
	return launcher_button_construct (TYPE_LAUNCHER_BUTTON, app);
}

BudgieApplication*
launcher_button_get_application (LauncherButton* self)
{
	BudgieApplication* result;
	BudgieApplication* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_application;
	result = _tmp0_;
	return result;
}

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

static void
launcher_button_set_application (LauncherButton* self,
                                 BudgieApplication* value)
{
	BudgieApplication* old_value;
	g_return_if_fail (self != NULL);
	old_value = launcher_button_get_application (self);
	if (old_value != value) {
		BudgieApplication* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_application);
		self->priv->_application = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, launcher_button_properties[LAUNCHER_BUTTON_APPLICATION_PROPERTY]);
	}
}

static GObject *
launcher_button_constructor (GType type,
                             guint n_construct_properties,
                             GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	LauncherButton * self;
	GtkStyleContext* _tmp0_;
	GtkImage* image = NULL;
	BudgieApplication* _tmp1_;
	GIcon* _tmp2_;
	GIcon* _tmp3_;
	GtkImage* _tmp4_ = NULL;
	GtkBox* right_box = NULL;
	GtkBox* _tmp5_;
	gchar* app_name = NULL;
	BudgieApplication* _tmp6_;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	gchar* _tmp9_;
	const gchar* _tmp10_ = NULL;
	BudgieApplication* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	gchar* sdesc = NULL;
	gchar* _tmp14_;
	gchar* desc = NULL;
	const gchar* _tmp15_;
	gchar* _tmp16_;
	GtkLabel* name_label = NULL;
	const gchar* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	GtkLabel* _tmp20_ = NULL;
	GtkLabel* _tmp21_;
	GtkLabel* desc_label = NULL;
	const gchar* _tmp22_;
	GtkLabel* _tmp23_ = NULL;
	GtkLabel* _tmp24_;
	GtkStyleContext* _tmp25_;
	GtkBox* _tmp26_;
	GtkLabel* _tmp27_;
	GtkBox* _tmp28_;
	GtkLabel* _tmp29_;
	GtkImage* _tmp30_;
	GtkBox* _tmp31_;
	BudgieApplication* _tmp32_;
	const gchar* _tmp33_;
	const gchar* _tmp34_;
	parent_class = G_OBJECT_CLASS (launcher_button_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_LAUNCHER_BUTTON, LauncherButton);
	_tmp0_ = gtk_widget_get_style_context ((GtkWidget*) self);
	gtk_style_context_add_class (_tmp0_, "launcher-button");
	_tmp1_ = self->priv->_application;
	_tmp2_ = budgie_application_get_icon (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = (GtkImage*) gtk_image_new_from_gicon (_tmp3_, (GtkIconSize) GTK_ICON_SIZE_DIALOG);
	gtk_image_set_pixel_size (_tmp4_, 48);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp4_, 8);
	g_object_ref_sink (_tmp4_);
	image = _tmp4_;
	_tmp5_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
	g_object_ref_sink (_tmp5_);
	right_box = _tmp5_;
	_tmp6_ = self->priv->_application;
	_tmp7_ = budgie_application_get_name (_tmp6_);
	_tmp8_ = _tmp7_;
	_tmp9_ = g_markup_escape_text (_tmp8_, (gssize) -1);
	app_name = _tmp9_;
	_tmp11_ = self->priv->_application;
	_tmp12_ = budgie_application_get_description (_tmp11_);
	_tmp13_ = _tmp12_;
	_tmp10_ = _tmp13_;
	if (_tmp10_ == NULL) {
		_tmp10_ = "";
	}
	_tmp14_ = g_strdup (_tmp10_);
	sdesc = _tmp14_;
	_tmp15_ = sdesc;
	_tmp16_ = g_markup_escape_text (_tmp15_, (gssize) -1);
	desc = _tmp16_;
	_tmp17_ = app_name;
	_tmp18_ = g_strdup_printf ("<big>%s</big>", _tmp17_);
	_tmp19_ = _tmp18_;
	_tmp20_ = (GtkLabel*) gtk_label_new (_tmp19_);
	gtk_widget_set_halign ((GtkWidget*) _tmp20_, GTK_ALIGN_START);
	gtk_label_set_xalign (_tmp20_, (gfloat) 0);
	gtk_label_set_use_markup (_tmp20_, TRUE);
	g_object_ref_sink (_tmp20_);
	_tmp21_ = _tmp20_;
	_g_free0 (_tmp19_);
	name_label = _tmp21_;
	_tmp22_ = desc;
	_tmp23_ = (GtkLabel*) gtk_label_new (_tmp22_);
	gtk_widget_set_halign ((GtkWidget*) _tmp23_, GTK_ALIGN_START);
	gtk_label_set_xalign (_tmp23_, (gfloat) 0);
	g_object_set (_tmp23_, "wrap", TRUE, NULL);
	gtk_label_set_max_width_chars (_tmp23_, 240);
	gtk_label_set_use_markup (_tmp23_, TRUE);
	g_object_ref_sink (_tmp23_);
	desc_label = _tmp23_;
	_tmp24_ = desc_label;
	_tmp25_ = gtk_widget_get_style_context ((GtkWidget*) _tmp24_);
	gtk_style_context_add_class (_tmp25_, "dim-label");
	_tmp26_ = right_box;
	_tmp27_ = name_label;
	gtk_box_pack_start (_tmp26_, (GtkWidget*) _tmp27_, FALSE, FALSE, (guint) 0);
	_tmp28_ = right_box;
	_tmp29_ = desc_label;
	gtk_box_pack_start (_tmp28_, (GtkWidget*) _tmp29_, TRUE, TRUE, (guint) 0);
	_tmp30_ = image;
	gtk_box_pack_start ((GtkBox*) self, (GtkWidget*) _tmp30_, FALSE, FALSE, (guint) 0);
	_tmp31_ = right_box;
	gtk_box_pack_start ((GtkBox*) self, (GtkWidget*) _tmp31_, TRUE, TRUE, (guint) 0);
	_tmp32_ = self->priv->_application;
	_tmp33_ = budgie_application_get_name (_tmp32_);
	_tmp34_ = _tmp33_;
	gtk_widget_set_tooltip_text ((GtkWidget*) self, _tmp34_);
	_g_object_unref0 (desc_label);
	_g_object_unref0 (name_label);
	_g_free0 (desc);
	_g_free0 (sdesc);
	_g_free0 (app_name);
	_g_object_unref0 (right_box);
	_g_object_unref0 (image);
	return obj;
}

static void
launcher_button_class_init (LauncherButtonClass * klass,
                            gpointer klass_data)
{
	launcher_button_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &LauncherButton_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_launcher_button_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_launcher_button_set_property;
	G_OBJECT_CLASS (klass)->constructor = launcher_button_constructor;
	G_OBJECT_CLASS (klass)->finalize = launcher_button_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), LAUNCHER_BUTTON_APPLICATION_PROPERTY, launcher_button_properties[LAUNCHER_BUTTON_APPLICATION_PROPERTY] = g_param_spec_object ("application", "application", "application", BUDGIE_TYPE_APPLICATION, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
launcher_button_instance_init (LauncherButton * self,
                               gpointer klass)
{
	self->priv = launcher_button_get_instance_private (self);
}

static void
launcher_button_finalize (GObject * obj)
{
	LauncherButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_LAUNCHER_BUTTON, LauncherButton);
	_g_object_unref0 (self->priv->_application);
	G_OBJECT_CLASS (launcher_button_parent_class)->finalize (obj);
}

/**
 * Simple widget that shows an application icon, name, and description.
 */
static GType
launcher_button_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (LauncherButtonClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) launcher_button_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (LauncherButton), 0, (GInstanceInitFunc) launcher_button_instance_init, NULL };
	GType launcher_button_type_id;
	launcher_button_type_id = g_type_register_static (gtk_box_get_type (), "LauncherButton", &g_define_type_info, 0);
	LauncherButton_private_offset = g_type_add_instance_private (launcher_button_type_id, sizeof (LauncherButtonPrivate));
	return launcher_button_type_id;
}

GType
launcher_button_get_type (void)
{
	static volatile gsize launcher_button_type_id__once = 0;
	if (g_once_init_enter (&launcher_button_type_id__once)) {
		GType launcher_button_type_id;
		launcher_button_type_id = launcher_button_get_type_once ();
		g_once_init_leave (&launcher_button_type_id__once, launcher_button_type_id);
	}
	return launcher_button_type_id__once;
}

static void
_vala_launcher_button_get_property (GObject * object,
                                    guint property_id,
                                    GValue * value,
                                    GParamSpec * pspec)
{
	LauncherButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_LAUNCHER_BUTTON, LauncherButton);
	switch (property_id) {
		case LAUNCHER_BUTTON_APPLICATION_PROPERTY:
		g_value_set_object (value, launcher_button_get_application (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_launcher_button_set_property (GObject * object,
                                    guint property_id,
                                    const GValue * value,
                                    GParamSpec * pspec)
{
	LauncherButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_LAUNCHER_BUTTON, LauncherButton);
	switch (property_id) {
		case LAUNCHER_BUTTON_APPLICATION_PROPERTY:
		launcher_button_set_application (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

