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

/*
Copyright (C) 2015 Johan Mattsson

This library is free software; you can redistribute it and/or modify 
it under the terms of the GNU Lesser General Public License as 
published by the Free Software Foundation; either version 3 of the 
License, or (at your option) any later version.

This library 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 
Lesser General Public License for more details.
*/

#include "birdfont.h"
#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.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  {
	BIRD_FONT_OTF_LABEL_0_PROPERTY,
	BIRD_FONT_OTF_LABEL_NUM_PROPERTIES
};
static GParamSpec* bird_font_otf_label_properties[BIRD_FONT_OTF_LABEL_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
enum  {
	BIRD_FONT_OTF_LABEL_OTF_FEATURE_ACTIVITY_SIGNAL,
	BIRD_FONT_OTF_LABEL_NUM_SIGNALS
};
static guint bird_font_otf_label_signals[BIRD_FONT_OTF_LABEL_NUM_SIGNALS] = {0};

static gpointer bird_font_otf_label_parent_class = NULL;

static void __lambda225_ (BirdFontOtfLabel* self,
                   BirdFontTool* _self_);
static void ___lambda225__bird_font_tool_select_action (BirdFontTool* _sender,
                                                 BirdFontTool* selected,
                                                 gpointer self);
static void g_cclosure_user_marshal_VOID__BOOLEAN_STRING (GClosure * closure,
                                                   GValue * return_value,
                                                   guint n_param_values,
                                                   const GValue * param_values,
                                                   gpointer invocation_hint,
                                                   gpointer marshal_data);
static void bird_font_otf_label_finalize (GObject * obj);
static GType bird_font_otf_label_get_type_once (void);

static void
__lambda225_ (BirdFontOtfLabel* self,
              BirdFontTool* _self_)
{
	g_return_if_fail (_self_ != NULL);
	self->active_substitution = !self->active_substitution;
	bird_font_otf_label_set_selected_tag (self, self->active_substitution);
}

static void
___lambda225__bird_font_tool_select_action (BirdFontTool* _sender,
                                            BirdFontTool* selected,
                                            gpointer self)
{
	__lambda225_ ((BirdFontOtfLabel*) self, selected);
}

BirdFontOtfLabel*
bird_font_otf_label_construct (GType object_type,
                               const gchar* tag)
{
	BirdFontOtfLabel * self = NULL;
	gchar* label = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	g_return_val_if_fail (tag != NULL, NULL);
	_tmp0_ = bird_font_otf_label_get_string (tag);
	label = _tmp0_;
	self = (BirdFontOtfLabel*) bird_font_label_tool_construct (object_type, label);
	_tmp1_ = g_strdup (tag);
	_g_free0 (self->tag);
	self->tag = _tmp1_;
	g_signal_connect_object ((BirdFontTool*) self, "select-action", (GCallback) ___lambda225__bird_font_tool_select_action, self, 0);
	_g_free0 (label);
	return self;
}

BirdFontOtfLabel*
bird_font_otf_label_new (const gchar* tag)
{
	return bird_font_otf_label_construct (BIRD_FONT_TYPE_OTF_LABEL, tag);
}

void
bird_font_otf_label_set_selected_tag (BirdFontOtfLabel* self,
                                      gboolean enabled)
{
	const gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	bird_font_tool_set_selected ((BirdFontTool*) self, enabled);
	_tmp0_ = self->tag;
	g_signal_emit (self, bird_font_otf_label_signals[BIRD_FONT_OTF_LABEL_OTF_FEATURE_ACTIVITY_SIGNAL], 0, enabled, _tmp0_);
}

/** @return translated string representation of an OTF feature tag. */
static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

gchar*
bird_font_otf_label_get_string (const gchar* tag)
{
	const gchar* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* result;
	g_return_val_if_fail (tag != NULL, NULL);
	if (g_strcmp0 (tag, "salt") == 0) {
		gchar* _tmp0_;
		gchar* _tmp1_;
		gchar* _tmp2_;
		gchar* _tmp3_;
		_tmp0_ = bird_font_t_ ("Stylistic Alternate");
		_tmp1_ = _tmp0_;
		_tmp2_ = g_strconcat (_tmp1_, " (salt)", NULL);
		_tmp3_ = _tmp2_;
		_g_free0 (_tmp1_);
		result = _tmp3_;
		return result;
	} else {
		if (g_strcmp0 (tag, "smcp") == 0) {
			gchar* _tmp4_;
			gchar* _tmp5_;
			gchar* _tmp6_;
			gchar* _tmp7_;
			_tmp4_ = bird_font_t_ ("Small Caps");
			_tmp5_ = _tmp4_;
			_tmp6_ = g_strconcat (_tmp5_, " (smcp)", NULL);
			_tmp7_ = _tmp6_;
			_g_free0 (_tmp5_);
			result = _tmp7_;
			return result;
		} else {
			if (g_strcmp0 (tag, "c2sc") == 0) {
				gchar* _tmp8_;
				gchar* _tmp9_;
				gchar* _tmp10_;
				gchar* _tmp11_;
				_tmp8_ = bird_font_t_ ("Capitals to Small Caps");
				_tmp9_ = _tmp8_;
				_tmp10_ = g_strconcat (_tmp9_, " (c2sc)", NULL);
				_tmp11_ = _tmp10_;
				_g_free0 (_tmp9_);
				result = _tmp11_;
				return result;
			} else {
				if (g_strcmp0 (tag, "swsh") == 0) {
					gchar* _tmp12_;
					gchar* _tmp13_;
					gchar* _tmp14_;
					gchar* _tmp15_;
					_tmp12_ = bird_font_t_ ("Swashes");
					_tmp13_ = _tmp12_;
					_tmp14_ = g_strconcat (_tmp13_, " (swsh)", NULL);
					_tmp15_ = _tmp14_;
					_g_free0 (_tmp13_);
					result = _tmp15_;
					return result;
				}
			}
		}
	}
	_tmp16_ = string_to_string (tag);
	_tmp17_ = g_strconcat ("Unknown tag: ", _tmp16_, NULL);
	_tmp18_ = _tmp17_;
	g_warning ("OtfLabel.vala:56: %s", _tmp18_);
	_g_free0 (_tmp18_);
	_tmp19_ = g_strdup (tag);
	result = _tmp19_;
	return result;
}

static void
g_cclosure_user_marshal_VOID__BOOLEAN_STRING (GClosure * closure,
                                              GValue * return_value,
                                              guint n_param_values,
                                              const GValue * param_values,
                                              gpointer invocation_hint,
                                              gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__BOOLEAN_STRING) (gpointer data1, gboolean arg_1, const char* arg_2, gpointer data2);
	register GMarshalFunc_VOID__BOOLEAN_STRING callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__BOOLEAN_STRING) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_boolean (param_values + 1), g_value_get_string (param_values + 2), data2);
}

static void
bird_font_otf_label_class_init (BirdFontOtfLabelClass * klass,
                                gpointer klass_data)
{
	bird_font_otf_label_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = bird_font_otf_label_finalize;
	bird_font_otf_label_signals[BIRD_FONT_OTF_LABEL_OTF_FEATURE_ACTIVITY_SIGNAL] = g_signal_new ("otf-feature-activity", BIRD_FONT_TYPE_OTF_LABEL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__BOOLEAN_STRING, G_TYPE_NONE, 2, G_TYPE_BOOLEAN, G_TYPE_STRING);
}

static void
bird_font_otf_label_instance_init (BirdFontOtfLabel * self,
                                   gpointer klass)
{
	self->active_substitution = FALSE;
}

static void
bird_font_otf_label_finalize (GObject * obj)
{
	BirdFontOtfLabel * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BIRD_FONT_TYPE_OTF_LABEL, BirdFontOtfLabel);
	_g_free0 (self->tag);
	G_OBJECT_CLASS (bird_font_otf_label_parent_class)->finalize (obj);
}

/** Gsub substitutions will be performed kening and spacing tab when 
 * this tool is selected.
 */
static GType
bird_font_otf_label_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontOtfLabelClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_otf_label_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontOtfLabel), 0, (GInstanceInitFunc) bird_font_otf_label_instance_init, NULL };
	GType bird_font_otf_label_type_id;
	bird_font_otf_label_type_id = g_type_register_static (BIRD_FONT_TYPE_LABEL_TOOL, "BirdFontOtfLabel", &g_define_type_info, 0);
	return bird_font_otf_label_type_id;
}

GType
bird_font_otf_label_get_type (void)
{
	static volatile gsize bird_font_otf_label_type_id__once = 0;
	if (g_once_init_enter (&bird_font_otf_label_type_id__once)) {
		GType bird_font_otf_label_type_id;
		bird_font_otf_label_type_id = bird_font_otf_label_get_type_once ();
		g_once_init_leave (&bird_font_otf_label_type_id__once, bird_font_otf_label_type_id);
	}
	return bird_font_otf_label_type_id__once;
}

