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

/*
 * Copyright 2014-2017 Artem Anufrij <artem.anufrij@live.de>
 * SPDX-License-Identifier: LGPL-3.0-or-later
 */

#include "granite.h"
#include <gtk/gtk.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib-object.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  {
	GRANITE_WIDGETS_WELCOME_BUTTON_0_PROPERTY,
	GRANITE_WIDGETS_WELCOME_BUTTON_TITLE_PROPERTY,
	GRANITE_WIDGETS_WELCOME_BUTTON_DESCRIPTION_PROPERTY,
	GRANITE_WIDGETS_WELCOME_BUTTON_ICON_PROPERTY,
	GRANITE_WIDGETS_WELCOME_BUTTON_NUM_PROPERTIES
};
static GParamSpec* granite_widgets_welcome_button_properties[GRANITE_WIDGETS_WELCOME_BUTTON_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _GraniteWidgetsWelcomeButtonPrivate {
	GtkLabel* button_title;
	GtkLabel* button_description;
	GtkImage* _icon;
	GtkGrid* button_grid;
};

static gint GraniteWidgetsWelcomeButton_private_offset;
static gpointer granite_widgets_welcome_button_parent_class = NULL;

static GObject * granite_widgets_welcome_button_constructor (GType type,
                                                      guint n_construct_properties,
                                                      GObjectConstructParam * construct_properties);
static void granite_widgets_welcome_button_finalize (GObject * obj);
static GType granite_widgets_welcome_button_get_type_once (void);
static void _vala_granite_widgets_welcome_button_get_property (GObject * object,
                                                        guint property_id,
                                                        GValue * value,
                                                        GParamSpec * pspec);
static void _vala_granite_widgets_welcome_button_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
granite_widgets_welcome_button_get_instance_private (GraniteWidgetsWelcomeButton* self)
{
	return G_STRUCT_MEMBER_P (self, GraniteWidgetsWelcomeButton_private_offset);
}

const gchar*
granite_widgets_welcome_button_get_title (GraniteWidgetsWelcomeButton* self)
{
	const gchar* result;
	GtkLabel* _tmp0_;
	const gchar* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->button_title;
	_tmp1_ = gtk_label_get_text (_tmp0_);
	result = _tmp1_;
	return result;
}

void
granite_widgets_welcome_button_set_title (GraniteWidgetsWelcomeButton* self,
                                          const gchar* value)
{
	GtkLabel* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->button_title;
	gtk_label_set_text (_tmp0_, value);
	g_object_notify_by_pspec ((GObject *) self, granite_widgets_welcome_button_properties[GRANITE_WIDGETS_WELCOME_BUTTON_TITLE_PROPERTY]);
}

const gchar*
granite_widgets_welcome_button_get_description (GraniteWidgetsWelcomeButton* self)
{
	const gchar* result;
	GtkLabel* _tmp0_;
	const gchar* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->button_description;
	_tmp1_ = gtk_label_get_text (_tmp0_);
	result = _tmp1_;
	return result;
}

void
granite_widgets_welcome_button_set_description (GraniteWidgetsWelcomeButton* self,
                                                const gchar* value)
{
	GtkLabel* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->button_description;
	gtk_label_set_text (_tmp0_, value);
	g_object_notify_by_pspec ((GObject *) self, granite_widgets_welcome_button_properties[GRANITE_WIDGETS_WELCOME_BUTTON_DESCRIPTION_PROPERTY]);
}

GtkImage*
granite_widgets_welcome_button_get_icon (GraniteWidgetsWelcomeButton* self)
{
	GtkImage* result;
	GtkImage* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_icon;
	result = _tmp0_;
	return result;
}

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

void
granite_widgets_welcome_button_set_icon (GraniteWidgetsWelcomeButton* self,
                                         GtkImage* value)
{
	GtkImage* _tmp0_;
	GtkImage* _tmp2_;
	GtkImage* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_icon;
	if (_tmp0_ != NULL) {
		GtkImage* _tmp1_;
		_tmp1_ = self->priv->_icon;
		gtk_widget_destroy ((GtkWidget*) _tmp1_);
	}
	_tmp2_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_icon);
	self->priv->_icon = _tmp2_;
	_tmp3_ = self->priv->_icon;
	if (_tmp3_ != NULL) {
		GtkImage* _tmp4_;
		GtkImage* _tmp5_;
		GtkImage* _tmp6_;
		GtkGrid* _tmp7_;
		GtkImage* _tmp8_;
		_tmp4_ = self->priv->_icon;
		gtk_image_set_pixel_size (_tmp4_, 48);
		_tmp5_ = self->priv->_icon;
		gtk_widget_set_halign ((GtkWidget*) _tmp5_, GTK_ALIGN_CENTER);
		_tmp6_ = self->priv->_icon;
		gtk_widget_set_valign ((GtkWidget*) _tmp6_, GTK_ALIGN_CENTER);
		_tmp7_ = self->priv->button_grid;
		_tmp8_ = self->priv->_icon;
		gtk_grid_attach (_tmp7_, (GtkWidget*) _tmp8_, 0, 0, 1, 2);
	}
	g_object_notify_by_pspec ((GObject *) self, granite_widgets_welcome_button_properties[GRANITE_WIDGETS_WELCOME_BUTTON_ICON_PROPERTY]);
}

GraniteWidgetsWelcomeButton*
granite_widgets_welcome_button_construct (GType object_type,
                                          GtkImage* image,
                                          const gchar* option_text,
                                          const gchar* description_text)
{
	GraniteWidgetsWelcomeButton * self = NULL;
	g_return_val_if_fail (option_text != NULL, NULL);
	g_return_val_if_fail (description_text != NULL, NULL);
	self = (GraniteWidgetsWelcomeButton*) g_object_new (object_type, "title", option_text, "description", description_text, "icon", image, NULL);
	return self;
}

GraniteWidgetsWelcomeButton*
granite_widgets_welcome_button_new (GtkImage* image,
                                    const gchar* option_text,
                                    const gchar* description_text)
{
	return granite_widgets_welcome_button_construct (GRANITE_WIDGETS_TYPE_WELCOME_BUTTON, image, option_text, description_text);
}

static GObject *
granite_widgets_welcome_button_constructor (GType type,
                                            guint n_construct_properties,
                                            GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GraniteWidgetsWelcomeButton * self;
	GtkLabel* _tmp0_;
	GtkLabel* _tmp1_;
	GtkStyleContext* _tmp2_;
	GtkLabel* _tmp3_;
	GtkLabel* _tmp4_;
	GtkLabel* _tmp5_;
	GtkLabel* _tmp6_;
	GtkLabel* _tmp7_;
	GtkLabel* _tmp8_;
	GtkLabel* _tmp9_;
	GtkLabel* _tmp10_;
	GtkStyleContext* _tmp11_;
	GtkStyleContext* _tmp12_;
	GtkGrid* _tmp13_;
	GtkGrid* _tmp14_;
	GtkGrid* _tmp15_;
	GtkLabel* _tmp16_;
	GtkGrid* _tmp17_;
	GtkLabel* _tmp18_;
	GtkGrid* _tmp19_;
	parent_class = G_OBJECT_CLASS (granite_widgets_welcome_button_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRANITE_WIDGETS_TYPE_WELCOME_BUTTON, GraniteWidgetsWelcomeButton);
	_tmp0_ = (GtkLabel*) gtk_label_new (NULL);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->button_title);
	self->priv->button_title = _tmp0_;
	_tmp1_ = self->priv->button_title;
	_tmp2_ = gtk_widget_get_style_context ((GtkWidget*) _tmp1_);
	gtk_style_context_add_class (_tmp2_, GRANITE_STYLE_CLASS_H3_LABEL);
	_tmp3_ = self->priv->button_title;
	gtk_widget_set_halign ((GtkWidget*) _tmp3_, GTK_ALIGN_START);
	_tmp4_ = self->priv->button_title;
	gtk_widget_set_valign ((GtkWidget*) _tmp4_, GTK_ALIGN_END);
	_tmp5_ = (GtkLabel*) gtk_label_new (NULL);
	g_object_ref_sink (_tmp5_);
	_g_object_unref0 (self->priv->button_description);
	self->priv->button_description = _tmp5_;
	_tmp6_ = self->priv->button_description;
	gtk_widget_set_halign ((GtkWidget*) _tmp6_, GTK_ALIGN_START);
	_tmp7_ = self->priv->button_description;
	gtk_widget_set_valign ((GtkWidget*) _tmp7_, GTK_ALIGN_START);
	_tmp8_ = self->priv->button_description;
	gtk_label_set_line_wrap (_tmp8_, TRUE);
	_tmp9_ = self->priv->button_description;
	gtk_label_set_line_wrap_mode (_tmp9_, PANGO_WRAP_WORD);
	_tmp10_ = self->priv->button_description;
	_tmp11_ = gtk_widget_get_style_context ((GtkWidget*) _tmp10_);
	gtk_style_context_add_class (_tmp11_, GTK_STYLE_CLASS_DIM_LABEL);
	_tmp12_ = gtk_widget_get_style_context ((GtkWidget*) self);
	gtk_style_context_add_class (_tmp12_, GTK_STYLE_CLASS_FLAT);
	_tmp13_ = (GtkGrid*) gtk_grid_new ();
	g_object_ref_sink (_tmp13_);
	_g_object_unref0 (self->priv->button_grid);
	self->priv->button_grid = _tmp13_;
	_tmp14_ = self->priv->button_grid;
	gtk_grid_set_column_spacing (_tmp14_, 12);
	_tmp15_ = self->priv->button_grid;
	_tmp16_ = self->priv->button_title;
	gtk_grid_attach (_tmp15_, (GtkWidget*) _tmp16_, 1, 0, 1, 1);
	_tmp17_ = self->priv->button_grid;
	_tmp18_ = self->priv->button_description;
	gtk_grid_attach (_tmp17_, (GtkWidget*) _tmp18_, 1, 1, 1, 1);
	_tmp19_ = self->priv->button_grid;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp19_);
	return obj;
}

static void
granite_widgets_welcome_button_class_init (GraniteWidgetsWelcomeButtonClass * klass,
                                           gpointer klass_data)
{
	granite_widgets_welcome_button_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GraniteWidgetsWelcomeButton_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_granite_widgets_welcome_button_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_granite_widgets_welcome_button_set_property;
	G_OBJECT_CLASS (klass)->constructor = granite_widgets_welcome_button_constructor;
	G_OBJECT_CLASS (klass)->finalize = granite_widgets_welcome_button_finalize;
	/**
	     * Title property of the Welcome Button
	     *
	     * @since 0.3
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRANITE_WIDGETS_WELCOME_BUTTON_TITLE_PROPERTY, granite_widgets_welcome_button_properties[GRANITE_WIDGETS_WELCOME_BUTTON_TITLE_PROPERTY] = g_param_spec_string ("title", "title", "title", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Description property of the Welcome Button
	     *
	     * @since 0.3
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRANITE_WIDGETS_WELCOME_BUTTON_DESCRIPTION_PROPERTY, granite_widgets_welcome_button_properties[GRANITE_WIDGETS_WELCOME_BUTTON_DESCRIPTION_PROPERTY] = g_param_spec_string ("description", "description", "description", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Image of the Welcome Button
	     *
	     * @since 0.3
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRANITE_WIDGETS_WELCOME_BUTTON_ICON_PROPERTY, granite_widgets_welcome_button_properties[GRANITE_WIDGETS_WELCOME_BUTTON_ICON_PROPERTY] = g_param_spec_object ("icon", "icon", "icon", gtk_image_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
granite_widgets_welcome_button_instance_init (GraniteWidgetsWelcomeButton * self,
                                              gpointer klass)
{
	self->priv = granite_widgets_welcome_button_get_instance_private (self);
}

static void
granite_widgets_welcome_button_finalize (GObject * obj)
{
	GraniteWidgetsWelcomeButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRANITE_WIDGETS_TYPE_WELCOME_BUTTON, GraniteWidgetsWelcomeButton);
	_g_object_unref0 (self->priv->button_title);
	_g_object_unref0 (self->priv->button_description);
	_g_object_unref0 (self->priv->_icon);
	_g_object_unref0 (self->priv->button_grid);
	G_OBJECT_CLASS (granite_widgets_welcome_button_parent_class)->finalize (obj);
}

static GType
granite_widgets_welcome_button_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GraniteWidgetsWelcomeButtonClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) granite_widgets_welcome_button_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GraniteWidgetsWelcomeButton), 0, (GInstanceInitFunc) granite_widgets_welcome_button_instance_init, NULL };
	GType granite_widgets_welcome_button_type_id;
	granite_widgets_welcome_button_type_id = g_type_register_static (gtk_button_get_type (), "GraniteWidgetsWelcomeButton", &g_define_type_info, 0);
	GraniteWidgetsWelcomeButton_private_offset = g_type_add_instance_private (granite_widgets_welcome_button_type_id, sizeof (GraniteWidgetsWelcomeButtonPrivate));
	return granite_widgets_welcome_button_type_id;
}

GType
granite_widgets_welcome_button_get_type (void)
{
	static volatile gsize granite_widgets_welcome_button_type_id__once = 0;
	if (g_once_init_enter (&granite_widgets_welcome_button_type_id__once)) {
		GType granite_widgets_welcome_button_type_id;
		granite_widgets_welcome_button_type_id = granite_widgets_welcome_button_get_type_once ();
		g_once_init_leave (&granite_widgets_welcome_button_type_id__once, granite_widgets_welcome_button_type_id);
	}
	return granite_widgets_welcome_button_type_id__once;
}

static void
_vala_granite_widgets_welcome_button_get_property (GObject * object,
                                                   guint property_id,
                                                   GValue * value,
                                                   GParamSpec * pspec)
{
	GraniteWidgetsWelcomeButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRANITE_WIDGETS_TYPE_WELCOME_BUTTON, GraniteWidgetsWelcomeButton);
	switch (property_id) {
		case GRANITE_WIDGETS_WELCOME_BUTTON_TITLE_PROPERTY:
		g_value_set_string (value, granite_widgets_welcome_button_get_title (self));
		break;
		case GRANITE_WIDGETS_WELCOME_BUTTON_DESCRIPTION_PROPERTY:
		g_value_set_string (value, granite_widgets_welcome_button_get_description (self));
		break;
		case GRANITE_WIDGETS_WELCOME_BUTTON_ICON_PROPERTY:
		g_value_set_object (value, granite_widgets_welcome_button_get_icon (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_granite_widgets_welcome_button_set_property (GObject * object,
                                                   guint property_id,
                                                   const GValue * value,
                                                   GParamSpec * pspec)
{
	GraniteWidgetsWelcomeButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRANITE_WIDGETS_TYPE_WELCOME_BUTTON, GraniteWidgetsWelcomeButton);
	switch (property_id) {
		case GRANITE_WIDGETS_WELCOME_BUTTON_TITLE_PROPERTY:
		granite_widgets_welcome_button_set_title (self, g_value_get_string (value));
		break;
		case GRANITE_WIDGETS_WELCOME_BUTTON_DESCRIPTION_PROPERTY:
		granite_widgets_welcome_button_set_description (self, g_value_get_string (value));
		break;
		case GRANITE_WIDGETS_WELCOME_BUTTON_ICON_PROPERTY:
		granite_widgets_welcome_button_set_icon (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;
}

