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

/*
* Copyright (c) 2016-2019 elementary, Inc. (https://elementary.io)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/

#include <gtk/gtk.h>
#include <glib-object.h>
#include "switchboard.h"
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <pango/pango.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 SWITCHBOARD_TYPE_CATEGORY_ICON (switchboard_category_icon_get_type ())
#define SWITCHBOARD_CATEGORY_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWITCHBOARD_TYPE_CATEGORY_ICON, SwitchboardCategoryIcon))
#define SWITCHBOARD_CATEGORY_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWITCHBOARD_TYPE_CATEGORY_ICON, SwitchboardCategoryIconClass))
#define SWITCHBOARD_IS_CATEGORY_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWITCHBOARD_TYPE_CATEGORY_ICON))
#define SWITCHBOARD_IS_CATEGORY_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWITCHBOARD_TYPE_CATEGORY_ICON))
#define SWITCHBOARD_CATEGORY_ICON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWITCHBOARD_TYPE_CATEGORY_ICON, SwitchboardCategoryIconClass))

typedef struct _SwitchboardCategoryIcon SwitchboardCategoryIcon;
typedef struct _SwitchboardCategoryIconClass SwitchboardCategoryIconClass;
typedef struct _SwitchboardCategoryIconPrivate SwitchboardCategoryIconPrivate;
enum  {
	SWITCHBOARD_CATEGORY_ICON_0_PROPERTY,
	SWITCHBOARD_CATEGORY_ICON_PLUG_PROPERTY,
	SWITCHBOARD_CATEGORY_ICON_NUM_PROPERTIES
};
static GParamSpec* switchboard_category_icon_properties[SWITCHBOARD_CATEGORY_ICON_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _SwitchboardCategoryIcon {
	GtkFlowBoxChild parent_instance;
	SwitchboardCategoryIconPrivate * priv;
};

struct _SwitchboardCategoryIconClass {
	GtkFlowBoxChildClass parent_class;
};

struct _SwitchboardCategoryIconPrivate {
	SwitchboardPlug* _plug;
};

static gint SwitchboardCategoryIcon_private_offset;
static gpointer switchboard_category_icon_parent_class = NULL;
static GtkSizeGroup* switchboard_category_icon_size_group;
static GtkSizeGroup* switchboard_category_icon_size_group = NULL;

VALA_EXTERN GType switchboard_category_icon_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SwitchboardCategoryIcon, g_object_unref)
VALA_EXTERN SwitchboardCategoryIcon* switchboard_category_icon_new (SwitchboardPlug* plug);
VALA_EXTERN SwitchboardCategoryIcon* switchboard_category_icon_construct (GType object_type,
                                                              SwitchboardPlug* plug);
VALA_EXTERN SwitchboardPlug* switchboard_category_icon_get_plug (SwitchboardCategoryIcon* self);
static void switchboard_category_icon_set_plug (SwitchboardCategoryIcon* self,
                                         SwitchboardPlug* value);
static GObject * switchboard_category_icon_constructor (GType type,
                                                 guint n_construct_properties,
                                                 GObjectConstructParam * construct_properties);
static void _switchboard_category_icon___lambda5_ (SwitchboardCategoryIcon* self);
static void __switchboard_category_icon___lambda5__switchboard_plug_visibility_changed (SwitchboardPlug* _sender,
                                                                                 gpointer self);
static void _switchboard_category_icon___lambda6_ (SwitchboardCategoryIcon* self);
static void __switchboard_category_icon___lambda6__g_object_notify (GObject* _sender,
                                                             GParamSpec* pspec,
                                                             gpointer self);
static void switchboard_category_icon_finalize (GObject * obj);
static GType switchboard_category_icon_get_type_once (void);
static void _vala_switchboard_category_icon_get_property (GObject * object,
                                                   guint property_id,
                                                   GValue * value,
                                                   GParamSpec * pspec);
static void _vala_switchboard_category_icon_set_property (GObject * object,
                                                   guint property_id,
                                                   const GValue * value,
                                                   GParamSpec * pspec);

static inline gpointer
switchboard_category_icon_get_instance_private (SwitchboardCategoryIcon* self)
{
	return G_STRUCT_MEMBER_P (self, SwitchboardCategoryIcon_private_offset);
}

SwitchboardCategoryIcon*
switchboard_category_icon_construct (GType object_type,
                                     SwitchboardPlug* plug)
{
	SwitchboardCategoryIcon * self = NULL;
	g_return_val_if_fail (plug != NULL, NULL);
	self = (SwitchboardCategoryIcon*) g_object_new (object_type, "plug", plug, NULL);
	return self;
}

SwitchboardCategoryIcon*
switchboard_category_icon_new (SwitchboardPlug* plug)
{
	return switchboard_category_icon_construct (SWITCHBOARD_TYPE_CATEGORY_ICON, plug);
}

SwitchboardPlug*
switchboard_category_icon_get_plug (SwitchboardCategoryIcon* self)
{
	SwitchboardPlug* result;
	SwitchboardPlug* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_plug;
	result = _tmp0_;
	return result;
}

static void
switchboard_category_icon_set_plug (SwitchboardCategoryIcon* self,
                                    SwitchboardPlug* value)
{
	SwitchboardPlug* old_value;
	g_return_if_fail (self != NULL);
	old_value = switchboard_category_icon_get_plug (self);
	if (old_value != value) {
		self->priv->_plug = value;
		g_object_notify_by_pspec ((GObject *) self, switchboard_category_icon_properties[SWITCHBOARD_CATEGORY_ICON_PLUG_PROPERTY]);
	}
}

static void
_switchboard_category_icon___lambda5_ (SwitchboardCategoryIcon* self)
{
	gtk_flow_box_child_changed ((GtkFlowBoxChild*) self);
}

static void
__switchboard_category_icon___lambda5__switchboard_plug_visibility_changed (SwitchboardPlug* _sender,
                                                                            gpointer self)
{
	_switchboard_category_icon___lambda5_ ((SwitchboardCategoryIcon*) self);
}

static void
_switchboard_category_icon___lambda6_ (SwitchboardCategoryIcon* self)
{
	gtk_flow_box_child_changed ((GtkFlowBoxChild*) self);
}

static void
__switchboard_category_icon___lambda6__g_object_notify (GObject* _sender,
                                                        GParamSpec* pspec,
                                                        gpointer self)
{
	_switchboard_category_icon___lambda6_ ((SwitchboardCategoryIcon*) self);
}

static GObject *
switchboard_category_icon_constructor (GType type,
                                       guint n_construct_properties,
                                       GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	SwitchboardCategoryIcon * self;
	GtkImage* icon = NULL;
	SwitchboardPlug* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	SwitchboardPlug* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	GtkImage* _tmp7_ = NULL;
	GtkLabel* plug_name = NULL;
	SwitchboardPlug* _tmp8_;
	const gchar* _tmp9_;
	const gchar* _tmp10_;
	GtkLabel* _tmp11_ = NULL;
	GtkBox* layout = NULL;
	GtkBox* _tmp12_ = NULL;
	GtkBox* _tmp13_;
	GtkImage* _tmp14_;
	GtkBox* _tmp15_;
	GtkLabel* _tmp16_;
	GtkSizeGroup* _tmp17_;
	GtkBox* _tmp18_;
	GtkBox* _tmp19_;
	SwitchboardPlug* _tmp20_;
	SwitchboardPlug* _tmp21_;
	parent_class = G_OBJECT_CLASS (switchboard_category_icon_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SWITCHBOARD_TYPE_CATEGORY_ICON, SwitchboardCategoryIcon);
	_tmp0_ = self->priv->_plug;
	_tmp1_ = switchboard_plug_get_icon (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = self->priv->_plug;
	_tmp4_ = switchboard_plug_get_description (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = g_strdup (_tmp5_);
	_tmp7_ = (GtkImage*) gtk_image_new_from_icon_name (_tmp2_);
	gtk_image_set_pixel_size (_tmp7_, 32);
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp7_, _tmp6_);
	_g_free0 (_tmp6_);
	g_object_ref_sink (_tmp7_);
	icon = _tmp7_;
	_tmp8_ = self->priv->_plug;
	_tmp9_ = switchboard_plug_get_display_name (_tmp8_);
	_tmp10_ = _tmp9_;
	_tmp11_ = (GtkLabel*) gtk_label_new (_tmp10_);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp11_, TRUE);
	gtk_label_set_wrap (_tmp11_, TRUE);
	gtk_label_set_wrap_mode (_tmp11_, PANGO_WRAP_WORD_CHAR);
	gtk_label_set_xalign (_tmp11_, (gfloat) 0);
	g_object_ref_sink (_tmp11_);
	plug_name = _tmp11_;
	_tmp12_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp12_, 6);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp12_, 6);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp12_, 6);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp12_, 6);
	g_object_ref_sink (_tmp12_);
	layout = _tmp12_;
	_tmp13_ = layout;
	_tmp14_ = icon;
	gtk_box_append (_tmp13_, (GtkWidget*) _tmp14_);
	_tmp15_ = layout;
	_tmp16_ = plug_name;
	gtk_box_append (_tmp15_, (GtkWidget*) _tmp16_);
	_tmp17_ = switchboard_category_icon_size_group;
	_tmp18_ = layout;
	gtk_size_group_add_widget (_tmp17_, (GtkWidget*) _tmp18_);
	_tmp19_ = layout;
	gtk_flow_box_child_set_child ((GtkFlowBoxChild*) self, (GtkWidget*) _tmp19_);
	_tmp20_ = self->priv->_plug;
	g_signal_connect_object (_tmp20_, "visibility-changed", (GCallback) __switchboard_category_icon___lambda5__switchboard_plug_visibility_changed, self, 0);
	_tmp21_ = self->priv->_plug;
	g_signal_connect_object ((GObject*) _tmp21_, "notify::can-show", (GCallback) __switchboard_category_icon___lambda6__g_object_notify, self, 0);
	_g_object_unref0 (layout);
	_g_object_unref0 (plug_name);
	_g_object_unref0 (icon);
	return obj;
}

static void
switchboard_category_icon_class_init (SwitchboardCategoryIconClass * klass,
                                      gpointer klass_data)
{
	GtkSizeGroup* _tmp0_;
	switchboard_category_icon_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &SwitchboardCategoryIcon_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_switchboard_category_icon_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_switchboard_category_icon_set_property;
	G_OBJECT_CLASS (klass)->constructor = switchboard_category_icon_constructor;
	G_OBJECT_CLASS (klass)->finalize = switchboard_category_icon_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), SWITCHBOARD_CATEGORY_ICON_PLUG_PROPERTY, switchboard_category_icon_properties[SWITCHBOARD_CATEGORY_ICON_PLUG_PROPERTY] = g_param_spec_object ("plug", "plug", "plug", SWITCHBOARD_TYPE_PLUG, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	_tmp0_ = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
	_g_object_unref0 (switchboard_category_icon_size_group);
	switchboard_category_icon_size_group = _tmp0_;
}

static void
switchboard_category_icon_instance_init (SwitchboardCategoryIcon * self,
                                         gpointer klass)
{
	self->priv = switchboard_category_icon_get_instance_private (self);
}

static void
switchboard_category_icon_finalize (GObject * obj)
{
	SwitchboardCategoryIcon * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SWITCHBOARD_TYPE_CATEGORY_ICON, SwitchboardCategoryIcon);
	G_OBJECT_CLASS (switchboard_category_icon_parent_class)->finalize (obj);
}

static GType
switchboard_category_icon_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SwitchboardCategoryIconClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) switchboard_category_icon_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SwitchboardCategoryIcon), 0, (GInstanceInitFunc) switchboard_category_icon_instance_init, NULL };
	GType switchboard_category_icon_type_id;
	switchboard_category_icon_type_id = g_type_register_static (gtk_flow_box_child_get_type (), "SwitchboardCategoryIcon", &g_define_type_info, 0);
	SwitchboardCategoryIcon_private_offset = g_type_add_instance_private (switchboard_category_icon_type_id, sizeof (SwitchboardCategoryIconPrivate));
	return switchboard_category_icon_type_id;
}

GType
switchboard_category_icon_get_type (void)
{
	static volatile gsize switchboard_category_icon_type_id__once = 0;
	if (g_once_init_enter (&switchboard_category_icon_type_id__once)) {
		GType switchboard_category_icon_type_id;
		switchboard_category_icon_type_id = switchboard_category_icon_get_type_once ();
		g_once_init_leave (&switchboard_category_icon_type_id__once, switchboard_category_icon_type_id);
	}
	return switchboard_category_icon_type_id__once;
}

static void
_vala_switchboard_category_icon_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec)
{
	SwitchboardCategoryIcon * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SWITCHBOARD_TYPE_CATEGORY_ICON, SwitchboardCategoryIcon);
	switch (property_id) {
		case SWITCHBOARD_CATEGORY_ICON_PLUG_PROPERTY:
		g_value_set_object (value, switchboard_category_icon_get_plug (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_switchboard_category_icon_set_property (GObject * object,
                                              guint property_id,
                                              const GValue * value,
                                              GParamSpec * pspec)
{
	SwitchboardCategoryIcon * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SWITCHBOARD_TYPE_CATEGORY_ICON, SwitchboardCategoryIcon);
	switch (property_id) {
		case SWITCHBOARD_CATEGORY_ICON_PLUG_PROPERTY:
		switchboard_category_icon_set_plug (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

