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

/*
* Copyright 2018-2020 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 3 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 "onlineaccounts.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.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  {
	ONLINE_ACCOUNTS_ACCOUNT_MENU_ITEM_0_PROPERTY,
	ONLINE_ACCOUNTS_ACCOUNT_MENU_ITEM_CUSTOM_ICON_NAME_PROPERTY,
	ONLINE_ACCOUNTS_ACCOUNT_MENU_ITEM_PRIMARY_LABEL_PROPERTY,
	ONLINE_ACCOUNTS_ACCOUNT_MENU_ITEM_SECONDARY_LABEL_PROPERTY,
	ONLINE_ACCOUNTS_ACCOUNT_MENU_ITEM_NUM_PROPERTIES
};
static GParamSpec* online_accounts_account_menu_item_properties[ONLINE_ACCOUNTS_ACCOUNT_MENU_ITEM_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 _OnlineAccountsAccountMenuItemPrivate {
	gchar* _custom_icon_name;
	gchar* _primary_label;
	gchar* _secondary_label;
};

static gint OnlineAccountsAccountMenuItem_private_offset;
static gpointer online_accounts_account_menu_item_parent_class = NULL;

static GObject * online_accounts_account_menu_item_constructor (GType type,
                                                         guint n_construct_properties,
                                                         GObjectConstructParam * construct_properties);
static void online_accounts_account_menu_item_finalize (GObject * obj);
static GType online_accounts_account_menu_item_get_type_once (void);
static void _vala_online_accounts_account_menu_item_get_property (GObject * object,
                                                           guint property_id,
                                                           GValue * value,
                                                           GParamSpec * pspec);
static void _vala_online_accounts_account_menu_item_set_property (GObject * object,
                                                           guint property_id,
                                                           const GValue * value,
                                                           GParamSpec * pspec);

static inline gpointer
online_accounts_account_menu_item_get_instance_private (OnlineAccountsAccountMenuItem* self)
{
	return G_STRUCT_MEMBER_P (self, OnlineAccountsAccountMenuItem_private_offset);
}

OnlineAccountsAccountMenuItem*
online_accounts_account_menu_item_construct (GType object_type,
                                             const gchar* custom_icon_name,
                                             const gchar* primary_label,
                                             const gchar* secondary_label)
{
	OnlineAccountsAccountMenuItem * self = NULL;
	g_return_val_if_fail (custom_icon_name != NULL, NULL);
	g_return_val_if_fail (primary_label != NULL, NULL);
	g_return_val_if_fail (secondary_label != NULL, NULL);
	self = (OnlineAccountsAccountMenuItem*) g_object_new (object_type, "custom-icon-name", custom_icon_name, "primary-label", primary_label, "secondary-label", secondary_label, NULL);
	return self;
}

OnlineAccountsAccountMenuItem*
online_accounts_account_menu_item_new (const gchar* custom_icon_name,
                                       const gchar* primary_label,
                                       const gchar* secondary_label)
{
	return online_accounts_account_menu_item_construct (ONLINE_ACCOUNTS_TYPE_ACCOUNT_MENU_ITEM, custom_icon_name, primary_label, secondary_label);
}

const gchar*
online_accounts_account_menu_item_get_custom_icon_name (OnlineAccountsAccountMenuItem* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_custom_icon_name;
	result = _tmp0_;
	return result;
}

static void
online_accounts_account_menu_item_set_custom_icon_name (OnlineAccountsAccountMenuItem* self,
                                                        const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = online_accounts_account_menu_item_get_custom_icon_name (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_custom_icon_name);
		self->priv->_custom_icon_name = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, online_accounts_account_menu_item_properties[ONLINE_ACCOUNTS_ACCOUNT_MENU_ITEM_CUSTOM_ICON_NAME_PROPERTY]);
	}
}

const gchar*
online_accounts_account_menu_item_get_primary_label (OnlineAccountsAccountMenuItem* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_primary_label;
	result = _tmp0_;
	return result;
}

static void
online_accounts_account_menu_item_set_primary_label (OnlineAccountsAccountMenuItem* self,
                                                     const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = online_accounts_account_menu_item_get_primary_label (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_primary_label);
		self->priv->_primary_label = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, online_accounts_account_menu_item_properties[ONLINE_ACCOUNTS_ACCOUNT_MENU_ITEM_PRIMARY_LABEL_PROPERTY]);
	}
}

const gchar*
online_accounts_account_menu_item_get_secondary_label (OnlineAccountsAccountMenuItem* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_secondary_label;
	result = _tmp0_;
	return result;
}

static void
online_accounts_account_menu_item_set_secondary_label (OnlineAccountsAccountMenuItem* self,
                                                       const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = online_accounts_account_menu_item_get_secondary_label (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_secondary_label);
		self->priv->_secondary_label = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, online_accounts_account_menu_item_properties[ONLINE_ACCOUNTS_ACCOUNT_MENU_ITEM_SECONDARY_LABEL_PROPERTY]);
	}
}

static GObject *
online_accounts_account_menu_item_constructor (GType type,
                                               guint n_construct_properties,
                                               GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	OnlineAccountsAccountMenuItem * self;
	GtkLabel* label = NULL;
	const gchar* _tmp0_;
	GtkLabel* _tmp1_ = NULL;
	GtkLabel* _tmp2_;
	GtkLabel* description = NULL;
	const gchar* _tmp3_;
	GtkLabel* _tmp4_ = NULL;
	GtkLabel* _tmp5_;
	GtkImage* image = NULL;
	const gchar* _tmp6_;
	GtkImage* _tmp7_;
	GtkImage* _tmp8_;
	GtkGrid* grid = NULL;
	GtkGrid* _tmp9_ = NULL;
	GtkGrid* _tmp10_;
	GtkImage* _tmp11_;
	GtkGrid* _tmp12_;
	GtkLabel* _tmp13_;
	GtkGrid* _tmp14_;
	GtkLabel* _tmp15_;
	GtkGrid* _tmp16_;
	parent_class = G_OBJECT_CLASS (online_accounts_account_menu_item_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, ONLINE_ACCOUNTS_TYPE_ACCOUNT_MENU_ITEM, OnlineAccountsAccountMenuItem);
	_tmp0_ = self->priv->_primary_label;
	_tmp1_ = (GtkLabel*) gtk_label_new (_tmp0_);
	gtk_widget_set_halign ((GtkWidget*) _tmp1_, GTK_ALIGN_START);
	g_object_ref_sink (_tmp1_);
	label = _tmp1_;
	_tmp2_ = label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp2_, GRANITE_STYLE_CLASS_H3_LABEL);
	_tmp3_ = self->priv->_secondary_label;
	_tmp4_ = (GtkLabel*) gtk_label_new (_tmp3_);
	gtk_widget_set_halign ((GtkWidget*) _tmp4_, GTK_ALIGN_START);
	g_object_ref_sink (_tmp4_);
	description = _tmp4_;
	_tmp5_ = description;
	gtk_widget_add_css_class ((GtkWidget*) _tmp5_, GRANITE_STYLE_CLASS_SMALL_LABEL);
	_tmp6_ = self->priv->_custom_icon_name;
	_tmp7_ = (GtkImage*) gtk_image_new_from_icon_name (_tmp6_);
	g_object_ref_sink (_tmp7_);
	image = _tmp7_;
	_tmp8_ = image;
	gtk_widget_add_css_class ((GtkWidget*) _tmp8_, GRANITE_STYLE_CLASS_LARGE_ICONS);
	_tmp9_ = (GtkGrid*) gtk_grid_new ();
	gtk_grid_set_column_spacing (_tmp9_, 6);
	g_object_ref_sink (_tmp9_);
	grid = _tmp9_;
	_tmp10_ = grid;
	_tmp11_ = image;
	gtk_grid_attach (_tmp10_, (GtkWidget*) _tmp11_, 0, 0, 1, 2);
	_tmp12_ = grid;
	_tmp13_ = label;
	gtk_grid_attach (_tmp12_, (GtkWidget*) _tmp13_, 1, 0, 1, 1);
	_tmp14_ = grid;
	_tmp15_ = description;
	gtk_grid_attach (_tmp14_, (GtkWidget*) _tmp15_, 1, 1, 1, 1);
	_tmp16_ = grid;
	gtk_button_set_child ((GtkButton*) self, (GtkWidget*) _tmp16_);
	gtk_widget_add_css_class ((GtkWidget*) self, GRANITE_STYLE_CLASS_MENUITEM);
	_g_object_unref0 (grid);
	_g_object_unref0 (image);
	_g_object_unref0 (description);
	_g_object_unref0 (label);
	return obj;
}

static void
online_accounts_account_menu_item_class_init (OnlineAccountsAccountMenuItemClass * klass,
                                              gpointer klass_data)
{
	online_accounts_account_menu_item_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &OnlineAccountsAccountMenuItem_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_online_accounts_account_menu_item_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_online_accounts_account_menu_item_set_property;
	G_OBJECT_CLASS (klass)->constructor = online_accounts_account_menu_item_constructor;
	G_OBJECT_CLASS (klass)->finalize = online_accounts_account_menu_item_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), ONLINE_ACCOUNTS_ACCOUNT_MENU_ITEM_CUSTOM_ICON_NAME_PROPERTY, online_accounts_account_menu_item_properties[ONLINE_ACCOUNTS_ACCOUNT_MENU_ITEM_CUSTOM_ICON_NAME_PROPERTY] = g_param_spec_string ("custom-icon-name", "custom-icon-name", "custom-icon-name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), ONLINE_ACCOUNTS_ACCOUNT_MENU_ITEM_PRIMARY_LABEL_PROPERTY, online_accounts_account_menu_item_properties[ONLINE_ACCOUNTS_ACCOUNT_MENU_ITEM_PRIMARY_LABEL_PROPERTY] = g_param_spec_string ("primary-label", "primary-label", "primary-label", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), ONLINE_ACCOUNTS_ACCOUNT_MENU_ITEM_SECONDARY_LABEL_PROPERTY, online_accounts_account_menu_item_properties[ONLINE_ACCOUNTS_ACCOUNT_MENU_ITEM_SECONDARY_LABEL_PROPERTY] = g_param_spec_string ("secondary-label", "secondary-label", "secondary-label", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
online_accounts_account_menu_item_instance_init (OnlineAccountsAccountMenuItem * self,
                                                 gpointer klass)
{
	self->priv = online_accounts_account_menu_item_get_instance_private (self);
}

static void
online_accounts_account_menu_item_finalize (GObject * obj)
{
	OnlineAccountsAccountMenuItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, ONLINE_ACCOUNTS_TYPE_ACCOUNT_MENU_ITEM, OnlineAccountsAccountMenuItem);
	_g_free0 (self->priv->_custom_icon_name);
	_g_free0 (self->priv->_primary_label);
	_g_free0 (self->priv->_secondary_label);
	G_OBJECT_CLASS (online_accounts_account_menu_item_parent_class)->finalize (obj);
}

static GType
online_accounts_account_menu_item_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (OnlineAccountsAccountMenuItemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) online_accounts_account_menu_item_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (OnlineAccountsAccountMenuItem), 0, (GInstanceInitFunc) online_accounts_account_menu_item_instance_init, NULL };
	GType online_accounts_account_menu_item_type_id;
	online_accounts_account_menu_item_type_id = g_type_register_static (gtk_button_get_type (), "OnlineAccountsAccountMenuItem", &g_define_type_info, 0);
	OnlineAccountsAccountMenuItem_private_offset = g_type_add_instance_private (online_accounts_account_menu_item_type_id, sizeof (OnlineAccountsAccountMenuItemPrivate));
	return online_accounts_account_menu_item_type_id;
}

GType
online_accounts_account_menu_item_get_type (void)
{
	static volatile gsize online_accounts_account_menu_item_type_id__once = 0;
	if (g_once_init_enter (&online_accounts_account_menu_item_type_id__once)) {
		GType online_accounts_account_menu_item_type_id;
		online_accounts_account_menu_item_type_id = online_accounts_account_menu_item_get_type_once ();
		g_once_init_leave (&online_accounts_account_menu_item_type_id__once, online_accounts_account_menu_item_type_id);
	}
	return online_accounts_account_menu_item_type_id__once;
}

static void
_vala_online_accounts_account_menu_item_get_property (GObject * object,
                                                      guint property_id,
                                                      GValue * value,
                                                      GParamSpec * pspec)
{
	OnlineAccountsAccountMenuItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, ONLINE_ACCOUNTS_TYPE_ACCOUNT_MENU_ITEM, OnlineAccountsAccountMenuItem);
	switch (property_id) {
		case ONLINE_ACCOUNTS_ACCOUNT_MENU_ITEM_CUSTOM_ICON_NAME_PROPERTY:
		g_value_set_string (value, online_accounts_account_menu_item_get_custom_icon_name (self));
		break;
		case ONLINE_ACCOUNTS_ACCOUNT_MENU_ITEM_PRIMARY_LABEL_PROPERTY:
		g_value_set_string (value, online_accounts_account_menu_item_get_primary_label (self));
		break;
		case ONLINE_ACCOUNTS_ACCOUNT_MENU_ITEM_SECONDARY_LABEL_PROPERTY:
		g_value_set_string (value, online_accounts_account_menu_item_get_secondary_label (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_online_accounts_account_menu_item_set_property (GObject * object,
                                                      guint property_id,
                                                      const GValue * value,
                                                      GParamSpec * pspec)
{
	OnlineAccountsAccountMenuItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, ONLINE_ACCOUNTS_TYPE_ACCOUNT_MENU_ITEM, OnlineAccountsAccountMenuItem);
	switch (property_id) {
		case ONLINE_ACCOUNTS_ACCOUNT_MENU_ITEM_CUSTOM_ICON_NAME_PROPERTY:
		online_accounts_account_menu_item_set_custom_icon_name (self, g_value_get_string (value));
		break;
		case ONLINE_ACCOUNTS_ACCOUNT_MENU_ITEM_PRIMARY_LABEL_PROPERTY:
		online_accounts_account_menu_item_set_primary_label (self, g_value_get_string (value));
		break;
		case ONLINE_ACCOUNTS_ACCOUNT_MENU_ITEM_SECONDARY_LABEL_PROPERTY:
		online_accounts_account_menu_item_set_secondary_label (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

