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

/*
* Copyright (c) 2010 Michal Hruby <michal.mhr@gmail.com>
*               2017 elementary LLC.
*
* 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
*
* Authored by: Michal Hruby <michal.mhr@gmail.com>
*/

#include "slingshot.h"
#include <glib.h>
#include <glib-object.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  {
	SYNAPSE_BASE_ACTION_0_PROPERTY,
	SYNAPSE_BASE_ACTION_DEFAULT_RELEVANCY_PROPERTY,
	SYNAPSE_BASE_ACTION_NOTIFY_MATCH_PROPERTY,
	SYNAPSE_BASE_ACTION_NUM_PROPERTIES
};
static GParamSpec* synapse_base_action_properties[SYNAPSE_BASE_ACTION_NUM_PROPERTIES];

struct _SynapseBaseActionPrivate {
	gint _default_relevancy;
	gboolean _notify_match;
};

static gint SynapseBaseAction_private_offset;
static gpointer synapse_base_action_parent_class = NULL;

static gboolean synapse_base_action_real_valid_for_match (SynapseBaseAction* self,
                                                   SynapseMatch* match);
static gint synapse_base_action_real_get_relevancy_for_match (SynapseBaseAction* self,
                                                       SynapseMatch* match);
static void synapse_base_action_real_do_execute (SynapseBaseAction* self,
                                          SynapseMatch* source,
                                          SynapseMatch* target);
static void synapse_base_action_real_execute_with_target (SynapseMatch* base,
                                                   SynapseMatch* source,
                                                   SynapseMatch* target);
static gboolean synapse_base_action_real_needs_target (SynapseMatch* base);
static SynapseQueryFlags synapse_base_action_real_target_flags (SynapseMatch* base);
static void synapse_base_action_finalize (GObject * obj);
static GType synapse_base_action_get_type_once (void);
static void _vala_synapse_base_action_get_property (GObject * object,
                                             guint property_id,
                                             GValue * value,
                                             GParamSpec * pspec);
static void _vala_synapse_base_action_set_property (GObject * object,
                                             guint property_id,
                                             const GValue * value,
                                             GParamSpec * pspec);

static inline gpointer
synapse_base_action_get_instance_private (SynapseBaseAction* self)
{
	return G_STRUCT_MEMBER_P (self, SynapseBaseAction_private_offset);
}

static gboolean
synapse_base_action_real_valid_for_match (SynapseBaseAction* self,
                                          SynapseMatch* match)
{
	gboolean _tmp0_ = FALSE;
	g_critical ("Type `%s' does not implement abstract method `synapse_base_action_valid_for_match'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return _tmp0_;
}

gboolean
synapse_base_action_valid_for_match (SynapseBaseAction* self,
                                     SynapseMatch* match)
{
	SynapseBaseActionClass* _klass_;
	g_return_val_if_fail (self != NULL, FALSE);
	_klass_ = SYNAPSE_BASE_ACTION_GET_CLASS (self);
	if (_klass_->valid_for_match) {
		return _klass_->valid_for_match (self, match);
	}
	return FALSE;
}

static gint
synapse_base_action_real_get_relevancy_for_match (SynapseBaseAction* self,
                                                  SynapseMatch* match)
{
	gint _tmp0_;
	gint result;
	g_return_val_if_fail (match != NULL, 0);
	_tmp0_ = self->priv->_default_relevancy;
	result = _tmp0_;
	return result;
}

gint
synapse_base_action_get_relevancy_for_match (SynapseBaseAction* self,
                                             SynapseMatch* match)
{
	SynapseBaseActionClass* _klass_;
	g_return_val_if_fail (self != NULL, 0);
	_klass_ = SYNAPSE_BASE_ACTION_GET_CLASS (self);
	if (_klass_->get_relevancy_for_match) {
		return _klass_->get_relevancy_for_match (self, match);
	}
	return -1;
}

static void
synapse_base_action_real_do_execute (SynapseBaseAction* self,
                                     SynapseMatch* source,
                                     SynapseMatch* target)
{
	g_critical ("Type `%s' does not implement abstract method `synapse_base_action_do_execute'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return;
}

void
synapse_base_action_do_execute (SynapseBaseAction* self,
                                SynapseMatch* source,
                                SynapseMatch* target)
{
	SynapseBaseActionClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = SYNAPSE_BASE_ACTION_GET_CLASS (self);
	if (_klass_->do_execute) {
		_klass_->do_execute (self, source, target);
	}
}

static void
synapse_base_action_real_execute_with_target (SynapseMatch* base,
                                              SynapseMatch* source,
                                              SynapseMatch* target)
{
	SynapseBaseAction * self;
	gboolean _tmp0_;
	self = (SynapseBaseAction*) base;
	synapse_base_action_do_execute (self, source, target);
	_tmp0_ = self->priv->_notify_match;
	if (_tmp0_) {
		g_signal_emit_by_name (source, "executed");
	}
}

static gboolean
synapse_base_action_real_needs_target (SynapseMatch* base)
{
	SynapseBaseAction * self;
	gboolean result;
	self = (SynapseBaseAction*) base;
	result = FALSE;
	return result;
}

static SynapseQueryFlags
synapse_base_action_real_target_flags (SynapseMatch* base)
{
	SynapseBaseAction * self;
	SynapseQueryFlags result;
	self = (SynapseBaseAction*) base;
	result = SYNAPSE_QUERY_FLAGS_ALL;
	return result;
}

SynapseBaseAction*
synapse_base_action_construct (GType object_type)
{
	SynapseBaseAction * self = NULL;
	self = (SynapseBaseAction*) synapse_match_construct (object_type);
	return self;
}

gint
synapse_base_action_get_default_relevancy (SynapseBaseAction* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_default_relevancy;
	return result;
}

void
synapse_base_action_set_default_relevancy (SynapseBaseAction* self,
                                           gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = synapse_base_action_get_default_relevancy (self);
	if (old_value != value) {
		self->priv->_default_relevancy = value;
		g_object_notify_by_pspec ((GObject *) self, synapse_base_action_properties[SYNAPSE_BASE_ACTION_DEFAULT_RELEVANCY_PROPERTY]);
	}
}

gboolean
synapse_base_action_get_notify_match (SynapseBaseAction* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_notify_match;
	return result;
}

void
synapse_base_action_set_notify_match (SynapseBaseAction* self,
                                      gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = synapse_base_action_get_notify_match (self);
	if (old_value != value) {
		self->priv->_notify_match = value;
		g_object_notify_by_pspec ((GObject *) self, synapse_base_action_properties[SYNAPSE_BASE_ACTION_NOTIFY_MATCH_PROPERTY]);
	}
}

static void
synapse_base_action_class_init (SynapseBaseActionClass * klass,
                                gpointer klass_data)
{
	synapse_base_action_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &SynapseBaseAction_private_offset);
	((SynapseBaseActionClass *) klass)->valid_for_match = (gboolean (*) (SynapseBaseAction*, SynapseMatch*)) synapse_base_action_real_valid_for_match;
	((SynapseBaseActionClass *) klass)->get_relevancy_for_match = (gint (*) (SynapseBaseAction*, SynapseMatch*)) synapse_base_action_real_get_relevancy_for_match;
	((SynapseBaseActionClass *) klass)->do_execute = (void (*) (SynapseBaseAction*, SynapseMatch*, SynapseMatch*)) synapse_base_action_real_do_execute;
	((SynapseMatchClass *) klass)->execute_with_target = (void (*) (SynapseMatch*, SynapseMatch*, SynapseMatch*)) synapse_base_action_real_execute_with_target;
	((SynapseMatchClass *) klass)->needs_target = (gboolean (*) (SynapseMatch*)) synapse_base_action_real_needs_target;
	((SynapseMatchClass *) klass)->target_flags = (SynapseQueryFlags (*) (SynapseMatch*)) synapse_base_action_real_target_flags;
	G_OBJECT_CLASS (klass)->get_property = _vala_synapse_base_action_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_synapse_base_action_set_property;
	G_OBJECT_CLASS (klass)->finalize = synapse_base_action_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), SYNAPSE_BASE_ACTION_DEFAULT_RELEVANCY_PROPERTY, synapse_base_action_properties[SYNAPSE_BASE_ACTION_DEFAULT_RELEVANCY_PROPERTY] = g_param_spec_int ("default-relevancy", "default-relevancy", "default-relevancy", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), SYNAPSE_BASE_ACTION_NOTIFY_MATCH_PROPERTY, synapse_base_action_properties[SYNAPSE_BASE_ACTION_NOTIFY_MATCH_PROPERTY] = g_param_spec_boolean ("notify-match", "notify-match", "notify-match", TRUE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
synapse_base_action_instance_init (SynapseBaseAction * self,
                                   gpointer klass)
{
	self->priv = synapse_base_action_get_instance_private (self);
	self->priv->_notify_match = TRUE;
}

static void
synapse_base_action_finalize (GObject * obj)
{
	SynapseBaseAction * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SYNAPSE_TYPE_BASE_ACTION, SynapseBaseAction);
	G_OBJECT_CLASS (synapse_base_action_parent_class)->finalize (obj);
}

static GType
synapse_base_action_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SynapseBaseActionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) synapse_base_action_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SynapseBaseAction), 0, (GInstanceInitFunc) synapse_base_action_instance_init, NULL };
	GType synapse_base_action_type_id;
	synapse_base_action_type_id = g_type_register_static (SYNAPSE_TYPE_MATCH, "SynapseBaseAction", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	SynapseBaseAction_private_offset = g_type_add_instance_private (synapse_base_action_type_id, sizeof (SynapseBaseActionPrivate));
	return synapse_base_action_type_id;
}

GType
synapse_base_action_get_type (void)
{
	static volatile gsize synapse_base_action_type_id__once = 0;
	if (g_once_init_enter (&synapse_base_action_type_id__once)) {
		GType synapse_base_action_type_id;
		synapse_base_action_type_id = synapse_base_action_get_type_once ();
		g_once_init_leave (&synapse_base_action_type_id__once, synapse_base_action_type_id);
	}
	return synapse_base_action_type_id__once;
}

static void
_vala_synapse_base_action_get_property (GObject * object,
                                        guint property_id,
                                        GValue * value,
                                        GParamSpec * pspec)
{
	SynapseBaseAction * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SYNAPSE_TYPE_BASE_ACTION, SynapseBaseAction);
	switch (property_id) {
		case SYNAPSE_BASE_ACTION_DEFAULT_RELEVANCY_PROPERTY:
		g_value_set_int (value, synapse_base_action_get_default_relevancy (self));
		break;
		case SYNAPSE_BASE_ACTION_NOTIFY_MATCH_PROPERTY:
		g_value_set_boolean (value, synapse_base_action_get_notify_match (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_synapse_base_action_set_property (GObject * object,
                                        guint property_id,
                                        const GValue * value,
                                        GParamSpec * pspec)
{
	SynapseBaseAction * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SYNAPSE_TYPE_BASE_ACTION, SynapseBaseAction);
	switch (property_id) {
		case SYNAPSE_BASE_ACTION_DEFAULT_RELEVANCY_PROPERTY:
		synapse_base_action_set_default_relevancy (self, g_value_get_int (value));
		break;
		case SYNAPSE_BASE_ACTION_NOTIFY_MATCH_PROPERTY:
		synapse_base_action_set_notify_match (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

