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

/*
 * Copyright (C) 2010 Michal Hruby <michal.mhr@gmail.com>
 *
 * 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 St, Fifth Floor, Boston, MA 02110-1301  USA.
 *
 * Authored by Michal Hruby <michal.mhr@gmail.com>
 *
 */

#include "plugins.h"
#include <glib.h>
#include <synapse-core.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <gee.h>
#include <gio/gio.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

#define SYNAPSE_DICTIONARY_PLUGIN_TYPE_DEFINE (synapse_dictionary_plugin_define_get_type ())
#define SYNAPSE_DICTIONARY_PLUGIN_DEFINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SYNAPSE_DICTIONARY_PLUGIN_TYPE_DEFINE, SynapseDictionaryPluginDefine))
#define SYNAPSE_DICTIONARY_PLUGIN_DEFINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SYNAPSE_DICTIONARY_PLUGIN_TYPE_DEFINE, SynapseDictionaryPluginDefineClass))
#define SYNAPSE_DICTIONARY_PLUGIN_IS_DEFINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SYNAPSE_DICTIONARY_PLUGIN_TYPE_DEFINE))
#define SYNAPSE_DICTIONARY_PLUGIN_IS_DEFINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SYNAPSE_DICTIONARY_PLUGIN_TYPE_DEFINE))
#define SYNAPSE_DICTIONARY_PLUGIN_DEFINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SYNAPSE_DICTIONARY_PLUGIN_TYPE_DEFINE, SynapseDictionaryPluginDefineClass))

typedef struct _SynapseDictionaryPluginDefine SynapseDictionaryPluginDefine;
typedef struct _SynapseDictionaryPluginDefineClass SynapseDictionaryPluginDefineClass;
enum  {
	SYNAPSE_DICTIONARY_PLUGIN_0_PROPERTY,
	SYNAPSE_DICTIONARY_PLUGIN_ENABLED_PROPERTY,
	SYNAPSE_DICTIONARY_PLUGIN_NUM_PROPERTIES
};
static GParamSpec* synapse_dictionary_plugin_properties[SYNAPSE_DICTIONARY_PLUGIN_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _SynapseDictionaryPluginDefinePrivate SynapseDictionaryPluginDefinePrivate;
enum  {
	SYNAPSE_DICTIONARY_PLUGIN_DEFINE_0_PROPERTY,
	SYNAPSE_DICTIONARY_PLUGIN_DEFINE_DEFAULT_RELEVANCY_PROPERTY,
	SYNAPSE_DICTIONARY_PLUGIN_DEFINE_DICTIONARY_EXEC_PROPERTY,
	SYNAPSE_DICTIONARY_PLUGIN_DEFINE_NUM_PROPERTIES
};
static GParamSpec* synapse_dictionary_plugin_define_properties[SYNAPSE_DICTIONARY_PLUGIN_DEFINE_NUM_PROPERTIES];
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _SynapseDictionaryPluginPrivate {
	gboolean _enabled;
	SynapseDictionaryPluginDefine* action;
	gboolean has_dictionary;
};

struct _SynapseDictionaryPluginDefine {
	SynapseMatch parent_instance;
	SynapseDictionaryPluginDefinePrivate * priv;
};

struct _SynapseDictionaryPluginDefineClass {
	SynapseMatchClass parent_class;
};

struct _SynapseDictionaryPluginDefinePrivate {
	gint _default_relevancy;
	gchar* _dictionary_exec;
};

static gint SynapseDictionaryPlugin_private_offset;
static gpointer synapse_dictionary_plugin_parent_class = NULL;
static gint SynapseDictionaryPluginDefine_private_offset;
static gpointer synapse_dictionary_plugin_define_parent_class = NULL;
static SynapseActivatableIface * synapse_dictionary_plugin_synapse_activatable_parent_iface = NULL;
static SynapseActionProviderIface * synapse_dictionary_plugin_synapse_action_provider_parent_iface = NULL;

static GType synapse_dictionary_plugin_define_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static void synapse_dictionary_plugin_real_activate (SynapseActivatable* base);
static void synapse_dictionary_plugin_real_deactivate (SynapseActivatable* base);
static void synapse_dictionary_plugin_register_plugin (void);
static void _synapse_dictionary_plugin_register_plugin_synapse_plugin_register_func (void);
static gboolean synapse_dictionary_plugin_real_handles_unknown (SynapseActionProvider* base);
static SynapseResultSet* synapse_dictionary_plugin_real_find_for_match (SynapseActionProvider* base,
                                                                 SynapseQuery* query,
                                                                 SynapseMatch* match);
static gint synapse_dictionary_plugin_define_get_default_relevancy (SynapseDictionaryPluginDefine* self);
static void synapse_dictionary_plugin_define_real_execute (SynapseMatch* base,
                                                    SynapseMatch* match);
static const gchar* synapse_dictionary_plugin_define_get_dictionary_exec (SynapseDictionaryPluginDefine* self);
static SynapseDictionaryPluginDefine* synapse_dictionary_plugin_define_new (const gchar* dictionary_exec);
static SynapseDictionaryPluginDefine* synapse_dictionary_plugin_define_construct (GType object_type,
                                                                           const gchar* dictionary_exec);
static void synapse_dictionary_plugin_define_set_default_relevancy (SynapseDictionaryPluginDefine* self,
                                                             gint value);
static void synapse_dictionary_plugin_define_set_dictionary_exec (SynapseDictionaryPluginDefine* self,
                                                           const gchar* value);
static void synapse_dictionary_plugin_define_finalize (GObject * obj);
static GType synapse_dictionary_plugin_define_get_type_once (void);
static void _vala_synapse_dictionary_plugin_define_get_property (GObject * object,
                                                          guint property_id,
                                                          GValue * value,
                                                          GParamSpec * pspec);
static void _vala_synapse_dictionary_plugin_define_set_property (GObject * object,
                                                          guint property_id,
                                                          const GValue * value,
                                                          GParamSpec * pspec);
static GObject * synapse_dictionary_plugin_constructor (GType type,
                                                 guint n_construct_properties,
                                                 GObjectConstructParam * construct_properties);
static void synapse_dictionary_plugin_finalize (GObject * obj);
static GType synapse_dictionary_plugin_get_type_once (void);
static void _vala_synapse_dictionary_plugin_get_property (GObject * object,
                                                   guint property_id,
                                                   GValue * value,
                                                   GParamSpec * pspec);
static void _vala_synapse_dictionary_plugin_set_property (GObject * object,
                                                   guint property_id,
                                                   const GValue * value,
                                                   GParamSpec * pspec);

static inline gpointer
synapse_dictionary_plugin_get_instance_private (SynapseDictionaryPlugin* self)
{
	return G_STRUCT_MEMBER_P (self, SynapseDictionaryPlugin_private_offset);
}

static void
synapse_dictionary_plugin_real_activate (SynapseActivatable* base)
{
	SynapseDictionaryPlugin * self;
#line 28 "dictionary.vala"
	self = (SynapseDictionaryPlugin*) base;
#line 155 "dictionary.c"
}

static void
synapse_dictionary_plugin_real_deactivate (SynapseActivatable* base)
{
	SynapseDictionaryPlugin * self;
#line 33 "dictionary.vala"
	self = (SynapseDictionaryPlugin*) base;
#line 164 "dictionary.c"
}

static void
_synapse_dictionary_plugin_register_plugin_synapse_plugin_register_func (void)
{
#line 70 "dictionary.vala"
	synapse_dictionary_plugin_register_plugin ();
#line 172 "dictionary.c"
}

static void
synapse_dictionary_plugin_register_plugin (void)
{
	gboolean _tmp0_ = FALSE;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gboolean _tmp3_;
	SynapsePluginRegistry* _tmp6_;
	SynapsePluginRegistry* _tmp7_;
#line 76 "dictionary.vala"
	_tmp1_ = g_find_program_in_path ("gnome-dictionary");
#line 76 "dictionary.vala"
	_tmp2_ = _tmp1_;
#line 76 "dictionary.vala"
	_tmp3_ = _tmp2_ != NULL;
#line 76 "dictionary.vala"
	_g_free0 (_tmp2_);
#line 76 "dictionary.vala"
	if (_tmp3_) {
#line 76 "dictionary.vala"
		_tmp0_ = TRUE;
#line 196 "dictionary.c"
	} else {
		gchar* _tmp4_;
		gchar* _tmp5_;
#line 77 "dictionary.vala"
		_tmp4_ = g_find_program_in_path ("mate-dictionary");
#line 77 "dictionary.vala"
		_tmp5_ = _tmp4_;
#line 77 "dictionary.vala"
		_tmp0_ = _tmp5_ != NULL;
#line 77 "dictionary.vala"
		_g_free0 (_tmp5_);
#line 208 "dictionary.c"
	}
#line 70 "dictionary.vala"
	_tmp6_ = synapse_plugin_registry_get_default ();
#line 70 "dictionary.vala"
	_tmp7_ = _tmp6_;
#line 70 "dictionary.vala"
	synapse_plugin_registry_register_plugin (_tmp7_, SYNAPSE_TYPE_DICTIONARY_PLUGIN, "Dictionary", _ ("Look up definitions of words."), "accessories-dictionary", _synapse_dictionary_plugin_register_plugin_synapse_plugin_register_func, _tmp0_, _ ("No compatible Dictionary installed"));
#line 70 "dictionary.vala"
	_g_object_unref0 (_tmp7_);
#line 218 "dictionary.c"
}

static gboolean
synapse_dictionary_plugin_real_handles_unknown (SynapseActionProvider* base)
{
	SynapseDictionaryPlugin * self;
	gboolean result;
#line 104 "dictionary.vala"
	self = (SynapseDictionaryPlugin*) base;
#line 106 "dictionary.vala"
	result = self->priv->has_dictionary;
#line 106 "dictionary.vala"
	return result;
#line 232 "dictionary.c"
}

static SynapseResultSet*
synapse_dictionary_plugin_real_find_for_match (SynapseActionProvider* base,
                                               SynapseQuery* query,
                                               SynapseMatch* match)
{
	SynapseDictionaryPlugin * self;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean query_empty = FALSE;
	SynapseQuery _tmp3_;
	const gchar* _tmp4_;
	SynapseResultSet* results = NULL;
	SynapseResultSet* _tmp5_;
	SynapseResultSet* result;
#line 109 "dictionary.vala"
	self = (SynapseDictionaryPlugin*) base;
#line 109 "dictionary.vala"
	g_return_val_if_fail (query != NULL, NULL);
#line 109 "dictionary.vala"
	g_return_val_if_fail (match != NULL, NULL);
#line 111 "dictionary.vala"
	if (!self->priv->has_dictionary) {
#line 111 "dictionary.vala"
		_tmp1_ = TRUE;
#line 259 "dictionary.c"
	} else {
#line 111 "dictionary.vala"
		_tmp1_ = !G_TYPE_CHECK_INSTANCE_TYPE (match, SYNAPSE_TYPE_UNKNOWN_MATCH);
#line 263 "dictionary.c"
	}
#line 111 "dictionary.vala"
	if (_tmp1_) {
#line 111 "dictionary.vala"
		_tmp0_ = TRUE;
#line 269 "dictionary.c"
	} else {
		SynapseQuery _tmp2_;
#line 112 "dictionary.vala"
		_tmp2_ = *query;
#line 112 "dictionary.vala"
		_tmp0_ = !((_tmp2_.query_type & SYNAPSE_QUERY_FLAGS_ACTIONS) == SYNAPSE_QUERY_FLAGS_ACTIONS);
#line 276 "dictionary.c"
	}
#line 111 "dictionary.vala"
	if (_tmp0_) {
#line 114 "dictionary.vala"
		result = NULL;
#line 114 "dictionary.vala"
		return result;
#line 284 "dictionary.c"
	}
#line 117 "dictionary.vala"
	_tmp3_ = *query;
#line 117 "dictionary.vala"
	_tmp4_ = _tmp3_.query_string;
#line 117 "dictionary.vala"
	query_empty = g_strcmp0 (_tmp4_, "") == 0;
#line 118 "dictionary.vala"
	_tmp5_ = synapse_result_set_new ();
#line 118 "dictionary.vala"
	results = _tmp5_;
#line 120 "dictionary.vala"
	if (query_empty) {
#line 298 "dictionary.c"
		SynapseResultSet* _tmp6_;
		SynapseDictionaryPluginDefine* _tmp7_;
		SynapseDictionaryPluginDefine* _tmp8_;
		gint _tmp9_;
		gint _tmp10_;
#line 122 "dictionary.vala"
		_tmp6_ = results;
#line 122 "dictionary.vala"
		_tmp7_ = self->priv->action;
#line 122 "dictionary.vala"
		_tmp8_ = self->priv->action;
#line 122 "dictionary.vala"
		_tmp9_ = synapse_dictionary_plugin_define_get_default_relevancy (_tmp8_);
#line 122 "dictionary.vala"
		_tmp10_ = _tmp9_;
#line 122 "dictionary.vala"
		synapse_result_set_add (_tmp6_, (SynapseMatch*) _tmp7_, _tmp10_);
#line 316 "dictionary.c"
	} else {
		GeeList* matchers = NULL;
		SynapseQuery _tmp11_;
		const gchar* _tmp12_;
		GeeList* _tmp13_;
#line 126 "dictionary.vala"
		_tmp11_ = *query;
#line 126 "dictionary.vala"
		_tmp12_ = _tmp11_.query_string;
#line 126 "dictionary.vala"
		_tmp13_ = synapse_query_get_matchers_for_query (_tmp12_, 0, G_REGEX_CASELESS);
#line 126 "dictionary.vala"
		matchers = _tmp13_;
#line 330 "dictionary.c"
		{
			GeeList* _matcher_list = NULL;
			GeeList* _tmp14_;
			gint _matcher_size = 0;
			GeeList* _tmp15_;
			gint _tmp16_;
			gint _tmp17_;
			gint _matcher_index = 0;
#line 128 "dictionary.vala"
			_tmp14_ = matchers;
#line 128 "dictionary.vala"
			_matcher_list = _tmp14_;
#line 128 "dictionary.vala"
			_tmp15_ = _matcher_list;
#line 128 "dictionary.vala"
			_tmp16_ = gee_collection_get_size ((GeeCollection*) _tmp15_);
#line 128 "dictionary.vala"
			_tmp17_ = _tmp16_;
#line 128 "dictionary.vala"
			_matcher_size = _tmp17_;
#line 128 "dictionary.vala"
			_matcher_index = -1;
#line 128 "dictionary.vala"
			while (TRUE) {
#line 355 "dictionary.c"
				gint _tmp18_;
				gint _tmp19_;
				GeeMapEntry* matcher = NULL;
				GeeList* _tmp20_;
				gpointer _tmp21_;
				GeeMapEntry* _tmp22_;
				gconstpointer _tmp23_;
				gconstpointer _tmp24_;
				SynapseDictionaryPluginDefine* _tmp25_;
				const gchar* _tmp26_;
				const gchar* _tmp27_;
#line 128 "dictionary.vala"
				_matcher_index = _matcher_index + 1;
#line 128 "dictionary.vala"
				_tmp18_ = _matcher_index;
#line 128 "dictionary.vala"
				_tmp19_ = _matcher_size;
#line 128 "dictionary.vala"
				if (!(_tmp18_ < _tmp19_)) {
#line 128 "dictionary.vala"
					break;
#line 377 "dictionary.c"
				}
#line 128 "dictionary.vala"
				_tmp20_ = _matcher_list;
#line 128 "dictionary.vala"
				_tmp21_ = gee_list_get (_tmp20_, _matcher_index);
#line 128 "dictionary.vala"
				matcher = (GeeMapEntry*) _tmp21_;
#line 130 "dictionary.vala"
				_tmp22_ = matcher;
#line 130 "dictionary.vala"
				_tmp23_ = gee_map_entry_get_key (_tmp22_);
#line 130 "dictionary.vala"
				_tmp24_ = _tmp23_;
#line 130 "dictionary.vala"
				_tmp25_ = self->priv->action;
#line 130 "dictionary.vala"
				_tmp26_ = synapse_match_get_title ((SynapseMatch*) _tmp25_);
#line 130 "dictionary.vala"
				_tmp27_ = _tmp26_;
#line 130 "dictionary.vala"
				if (g_regex_match ((GRegex*) _tmp24_, _tmp27_, 0, NULL)) {
#line 399 "dictionary.c"
					SynapseResultSet* _tmp28_;
					SynapseDictionaryPluginDefine* _tmp29_;
					GeeMapEntry* _tmp30_;
					gconstpointer _tmp31_;
					gconstpointer _tmp32_;
#line 132 "dictionary.vala"
					_tmp28_ = results;
#line 132 "dictionary.vala"
					_tmp29_ = self->priv->action;
#line 132 "dictionary.vala"
					_tmp30_ = matcher;
#line 132 "dictionary.vala"
					_tmp31_ = gee_map_entry_get_value (_tmp30_);
#line 132 "dictionary.vala"
					_tmp32_ = _tmp31_;
#line 132 "dictionary.vala"
					synapse_result_set_add (_tmp28_, (SynapseMatch*) _tmp29_, (gint) ((gintptr) _tmp32_));
#line 133 "dictionary.vala"
					_g_object_unref0 (matcher);
#line 133 "dictionary.vala"
					break;
#line 421 "dictionary.c"
				}
#line 128 "dictionary.vala"
				_g_object_unref0 (matcher);
#line 425 "dictionary.c"
			}
		}
#line 120 "dictionary.vala"
		_g_object_unref0 (matchers);
#line 430 "dictionary.c"
	}
#line 138 "dictionary.vala"
	result = results;
#line 138 "dictionary.vala"
	return result;
#line 436 "dictionary.c"
}

SynapseDictionaryPlugin*
synapse_dictionary_plugin_construct (GType object_type)
{
	SynapseDictionaryPlugin * self = NULL;
#line 24 "dictionary.vala"
	self = (SynapseDictionaryPlugin*) g_object_new (object_type, NULL);
#line 24 "dictionary.vala"
	return self;
#line 447 "dictionary.c"
}

SynapseDictionaryPlugin*
synapse_dictionary_plugin_new (void)
{
#line 24 "dictionary.vala"
	return synapse_dictionary_plugin_construct (SYNAPSE_TYPE_DICTIONARY_PLUGIN);
#line 455 "dictionary.c"
}

static gboolean
synapse_dictionary_plugin_real_get_enabled (SynapseActivatable* base)
{
	gboolean result;
	SynapseDictionaryPlugin* self;
#line 26 "dictionary.vala"
	self = (SynapseDictionaryPlugin*) base;
#line 26 "dictionary.vala"
	result = self->priv->_enabled;
#line 26 "dictionary.vala"
	return result;
#line 469 "dictionary.c"
}

static void
synapse_dictionary_plugin_real_set_enabled (SynapseActivatable* base,
                                            gboolean value)
{
	SynapseDictionaryPlugin* self;
	gboolean old_value;
#line 26 "dictionary.vala"
	self = (SynapseDictionaryPlugin*) base;
#line 26 "dictionary.vala"
	old_value = synapse_dictionary_plugin_real_get_enabled (base);
#line 26 "dictionary.vala"
	if (old_value != value) {
#line 26 "dictionary.vala"
		self->priv->_enabled = value;
#line 26 "dictionary.vala"
		g_object_notify_by_pspec ((GObject *) self, synapse_dictionary_plugin_properties[SYNAPSE_DICTIONARY_PLUGIN_ENABLED_PROPERTY]);
#line 488 "dictionary.c"
	}
}

static inline gpointer
synapse_dictionary_plugin_define_get_instance_private (SynapseDictionaryPluginDefine* self)
{
	return G_STRUCT_MEMBER_P (self, SynapseDictionaryPluginDefine_private_offset);
}

static void
synapse_dictionary_plugin_define_real_execute (SynapseMatch* base,
                                               SynapseMatch* match)
{
	SynapseDictionaryPluginDefine * self;
	GError* _inner_error0_ = NULL;
#line 44 "dictionary.vala"
	self = (SynapseDictionaryPluginDefine*) base;
#line 44 "dictionary.vala"
	g_return_if_fail (match != NULL);
#line 508 "dictionary.c"
	{
		GAppInfo* ai = NULL;
		const gchar* _tmp0_;
		const gchar* _tmp1_;
		const gchar* _tmp2_;
		gchar* _tmp3_;
		gchar* _tmp4_;
		const gchar* _tmp5_;
		GAppInfo* _tmp6_;
		GAppInfo* _tmp7_;
		GAppInfo* _tmp8_;
#line 48 "dictionary.vala"
		_tmp0_ = self->priv->_dictionary_exec;
#line 48 "dictionary.vala"
		_tmp1_ = synapse_match_get_title (match);
#line 48 "dictionary.vala"
		_tmp2_ = _tmp1_;
#line 48 "dictionary.vala"
		_tmp3_ = g_strdup_printf ("%s --look-up=\"%s\"", _tmp0_, _tmp2_);
#line 48 "dictionary.vala"
		_tmp4_ = _tmp3_;
#line 48 "dictionary.vala"
		_tmp5_ = self->priv->_dictionary_exec;
#line 48 "dictionary.vala"
		_tmp6_ = g_app_info_create_from_commandline (_tmp4_, _tmp5_, 0, &_inner_error0_);
#line 48 "dictionary.vala"
		_tmp7_ = _tmp6_;
#line 48 "dictionary.vala"
		_g_free0 (_tmp4_);
#line 48 "dictionary.vala"
		ai = _tmp7_;
#line 48 "dictionary.vala"
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
#line 542 "dictionary.c"
			goto __catch0_g_error;
		}
#line 51 "dictionary.vala"
		_tmp8_ = ai;
#line 51 "dictionary.vala"
		g_app_info_launch (_tmp8_, NULL, NULL, &_inner_error0_);
#line 51 "dictionary.vala"
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
#line 51 "dictionary.vala"
			_g_object_unref0 (ai);
#line 553 "dictionary.c"
			goto __catch0_g_error;
		}
#line 46 "dictionary.vala"
		_g_object_unref0 (ai);
#line 558 "dictionary.c"
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* err = NULL;
		GError* _tmp9_;
		const gchar* _tmp10_;
#line 46 "dictionary.vala"
		err = _inner_error0_;
#line 46 "dictionary.vala"
		_inner_error0_ = NULL;
#line 55 "dictionary.vala"
		_tmp9_ = err;
#line 55 "dictionary.vala"
		_tmp10_ = _tmp9_->message;
#line 55 "dictionary.vala"
		g_warning ("dictionary.vala:55: %s", _tmp10_);
#line 46 "dictionary.vala"
		_g_error_free0 (err);
#line 578 "dictionary.c"
	}
	__finally0:
#line 46 "dictionary.vala"
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
#line 46 "dictionary.vala"
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
#line 46 "dictionary.vala"
		g_clear_error (&_inner_error0_);
#line 46 "dictionary.vala"
		return;
#line 589 "dictionary.c"
	}
}

static SynapseDictionaryPluginDefine*
synapse_dictionary_plugin_define_construct (GType object_type,
                                            const gchar* dictionary_exec)
{
	SynapseDictionaryPluginDefine * self = NULL;
#line 59 "dictionary.vala"
	g_return_val_if_fail (dictionary_exec != NULL, NULL);
#line 61 "dictionary.vala"
	self = (SynapseDictionaryPluginDefine*) g_object_new (object_type, "title", _ ("Define"), "description", _ ("Look up definition in dictionary"), "has-thumbnail", FALSE, "icon-name", "accessories-dictionary", "dictionary-exec", dictionary_exec, NULL);
#line 59 "dictionary.vala"
	return self;
#line 604 "dictionary.c"
}

static SynapseDictionaryPluginDefine*
synapse_dictionary_plugin_define_new (const gchar* dictionary_exec)
{
#line 59 "dictionary.vala"
	return synapse_dictionary_plugin_define_construct (SYNAPSE_DICTIONARY_PLUGIN_TYPE_DEFINE, dictionary_exec);
#line 612 "dictionary.c"
}

static gint
synapse_dictionary_plugin_define_get_default_relevancy (SynapseDictionaryPluginDefine* self)
{
	gint result;
#line 40 "dictionary.vala"
	g_return_val_if_fail (self != NULL, 0);
#line 40 "dictionary.vala"
	result = self->priv->_default_relevancy;
#line 40 "dictionary.vala"
	return result;
#line 625 "dictionary.c"
}

static void
synapse_dictionary_plugin_define_set_default_relevancy (SynapseDictionaryPluginDefine* self,
                                                        gint value)
{
	gint old_value;
#line 40 "dictionary.vala"
	g_return_if_fail (self != NULL);
#line 40 "dictionary.vala"
	old_value = synapse_dictionary_plugin_define_get_default_relevancy (self);
#line 40 "dictionary.vala"
	if (old_value != value) {
#line 40 "dictionary.vala"
		self->priv->_default_relevancy = value;
#line 40 "dictionary.vala"
		g_object_notify_by_pspec ((GObject *) self, synapse_dictionary_plugin_define_properties[SYNAPSE_DICTIONARY_PLUGIN_DEFINE_DEFAULT_RELEVANCY_PROPERTY]);
#line 643 "dictionary.c"
	}
}

static const gchar*
synapse_dictionary_plugin_define_get_dictionary_exec (SynapseDictionaryPluginDefine* self)
{
	const gchar* result;
	const gchar* _tmp0_;
#line 42 "dictionary.vala"
	g_return_val_if_fail (self != NULL, NULL);
#line 42 "dictionary.vala"
	_tmp0_ = self->priv->_dictionary_exec;
#line 42 "dictionary.vala"
	result = _tmp0_;
#line 42 "dictionary.vala"
	return result;
#line 660 "dictionary.c"
}

static void
synapse_dictionary_plugin_define_set_dictionary_exec (SynapseDictionaryPluginDefine* self,
                                                      const gchar* value)
{
	gchar* old_value;
#line 42 "dictionary.vala"
	g_return_if_fail (self != NULL);
#line 42 "dictionary.vala"
	old_value = synapse_dictionary_plugin_define_get_dictionary_exec (self);
#line 42 "dictionary.vala"
	if (g_strcmp0 (value, old_value) != 0) {
#line 674 "dictionary.c"
		gchar* _tmp0_;
#line 42 "dictionary.vala"
		_tmp0_ = g_strdup (value);
#line 42 "dictionary.vala"
		_g_free0 (self->priv->_dictionary_exec);
#line 42 "dictionary.vala"
		self->priv->_dictionary_exec = _tmp0_;
#line 42 "dictionary.vala"
		g_object_notify_by_pspec ((GObject *) self, synapse_dictionary_plugin_define_properties[SYNAPSE_DICTIONARY_PLUGIN_DEFINE_DICTIONARY_EXEC_PROPERTY]);
#line 684 "dictionary.c"
	}
}

static void
synapse_dictionary_plugin_define_class_init (SynapseDictionaryPluginDefineClass * klass,
                                             gpointer klass_data)
{
#line 38 "dictionary.vala"
	synapse_dictionary_plugin_define_parent_class = g_type_class_peek_parent (klass);
#line 38 "dictionary.vala"
	g_type_class_adjust_private_offset (klass, &SynapseDictionaryPluginDefine_private_offset);
#line 38 "dictionary.vala"
	((SynapseMatchClass *) klass)->execute = (void (*) (SynapseMatch*, SynapseMatch*)) synapse_dictionary_plugin_define_real_execute;
#line 38 "dictionary.vala"
	G_OBJECT_CLASS (klass)->get_property = _vala_synapse_dictionary_plugin_define_get_property;
#line 38 "dictionary.vala"
	G_OBJECT_CLASS (klass)->set_property = _vala_synapse_dictionary_plugin_define_set_property;
#line 38 "dictionary.vala"
	G_OBJECT_CLASS (klass)->finalize = synapse_dictionary_plugin_define_finalize;
#line 38 "dictionary.vala"
	g_object_class_install_property (G_OBJECT_CLASS (klass), SYNAPSE_DICTIONARY_PLUGIN_DEFINE_DEFAULT_RELEVANCY_PROPERTY, synapse_dictionary_plugin_define_properties[SYNAPSE_DICTIONARY_PLUGIN_DEFINE_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));
#line 38 "dictionary.vala"
	g_object_class_install_property (G_OBJECT_CLASS (klass), SYNAPSE_DICTIONARY_PLUGIN_DEFINE_DICTIONARY_EXEC_PROPERTY, synapse_dictionary_plugin_define_properties[SYNAPSE_DICTIONARY_PLUGIN_DEFINE_DICTIONARY_EXEC_PROPERTY] = g_param_spec_string ("dictionary-exec", "dictionary-exec", "dictionary-exec", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
#line 708 "dictionary.c"
}

static void
synapse_dictionary_plugin_define_instance_init (SynapseDictionaryPluginDefine * self,
                                                gpointer klass)
{
#line 38 "dictionary.vala"
	self->priv = synapse_dictionary_plugin_define_get_instance_private (self);
#line 40 "dictionary.vala"
	self->priv->_default_relevancy = 0;
#line 719 "dictionary.c"
}

static void
synapse_dictionary_plugin_define_finalize (GObject * obj)
{
	SynapseDictionaryPluginDefine * self;
#line 38 "dictionary.vala"
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SYNAPSE_DICTIONARY_PLUGIN_TYPE_DEFINE, SynapseDictionaryPluginDefine);
#line 42 "dictionary.vala"
	_g_free0 (self->priv->_dictionary_exec);
#line 38 "dictionary.vala"
	G_OBJECT_CLASS (synapse_dictionary_plugin_define_parent_class)->finalize (obj);
#line 732 "dictionary.c"
}

static GType
synapse_dictionary_plugin_define_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SynapseDictionaryPluginDefineClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) synapse_dictionary_plugin_define_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SynapseDictionaryPluginDefine), 0, (GInstanceInitFunc) synapse_dictionary_plugin_define_instance_init, NULL };
	GType synapse_dictionary_plugin_define_type_id;
	synapse_dictionary_plugin_define_type_id = g_type_register_static (SYNAPSE_TYPE_MATCH, "SynapseDictionaryPluginDefine", &g_define_type_info, 0);
	SynapseDictionaryPluginDefine_private_offset = g_type_add_instance_private (synapse_dictionary_plugin_define_type_id, sizeof (SynapseDictionaryPluginDefinePrivate));
	return synapse_dictionary_plugin_define_type_id;
}

static GType
synapse_dictionary_plugin_define_get_type (void)
{
	static volatile gsize synapse_dictionary_plugin_define_type_id__once = 0;
	if (g_once_init_enter (&synapse_dictionary_plugin_define_type_id__once)) {
		GType synapse_dictionary_plugin_define_type_id;
		synapse_dictionary_plugin_define_type_id = synapse_dictionary_plugin_define_get_type_once ();
		g_once_init_leave (&synapse_dictionary_plugin_define_type_id__once, synapse_dictionary_plugin_define_type_id);
	}
	return synapse_dictionary_plugin_define_type_id__once;
}

static void
_vala_synapse_dictionary_plugin_define_get_property (GObject * object,
                                                     guint property_id,
                                                     GValue * value,
                                                     GParamSpec * pspec)
{
	SynapseDictionaryPluginDefine * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SYNAPSE_DICTIONARY_PLUGIN_TYPE_DEFINE, SynapseDictionaryPluginDefine);
#line 38 "dictionary.vala"
	switch (property_id) {
#line 38 "dictionary.vala"
		case SYNAPSE_DICTIONARY_PLUGIN_DEFINE_DEFAULT_RELEVANCY_PROPERTY:
#line 38 "dictionary.vala"
		g_value_set_int (value, synapse_dictionary_plugin_define_get_default_relevancy (self));
#line 38 "dictionary.vala"
		break;
#line 38 "dictionary.vala"
		case SYNAPSE_DICTIONARY_PLUGIN_DEFINE_DICTIONARY_EXEC_PROPERTY:
#line 38 "dictionary.vala"
		g_value_set_string (value, synapse_dictionary_plugin_define_get_dictionary_exec (self));
#line 38 "dictionary.vala"
		break;
#line 779 "dictionary.c"
		default:
#line 38 "dictionary.vala"
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
#line 38 "dictionary.vala"
		break;
#line 785 "dictionary.c"
	}
}

static void
_vala_synapse_dictionary_plugin_define_set_property (GObject * object,
                                                     guint property_id,
                                                     const GValue * value,
                                                     GParamSpec * pspec)
{
	SynapseDictionaryPluginDefine * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SYNAPSE_DICTIONARY_PLUGIN_TYPE_DEFINE, SynapseDictionaryPluginDefine);
#line 38 "dictionary.vala"
	switch (property_id) {
#line 38 "dictionary.vala"
		case SYNAPSE_DICTIONARY_PLUGIN_DEFINE_DEFAULT_RELEVANCY_PROPERTY:
#line 38 "dictionary.vala"
		synapse_dictionary_plugin_define_set_default_relevancy (self, g_value_get_int (value));
#line 38 "dictionary.vala"
		break;
#line 38 "dictionary.vala"
		case SYNAPSE_DICTIONARY_PLUGIN_DEFINE_DICTIONARY_EXEC_PROPERTY:
#line 38 "dictionary.vala"
		synapse_dictionary_plugin_define_set_dictionary_exec (self, g_value_get_string (value));
#line 38 "dictionary.vala"
		break;
#line 811 "dictionary.c"
		default:
#line 38 "dictionary.vala"
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
#line 38 "dictionary.vala"
		break;
#line 817 "dictionary.c"
	}
}

static GObject *
synapse_dictionary_plugin_constructor (GType type,
                                       guint n_construct_properties,
                                       GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	SynapseDictionaryPlugin * self;
	const gchar* dictionary_exec = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gboolean _tmp2_;
	const gchar* _tmp6_;
	SynapseDictionaryPluginDefine* _tmp7_;
	const gchar* _tmp8_;
#line 90 "dictionary.vala"
	parent_class = G_OBJECT_CLASS (synapse_dictionary_plugin_parent_class);
#line 90 "dictionary.vala"
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
#line 90 "dictionary.vala"
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SYNAPSE_TYPE_DICTIONARY_PLUGIN, SynapseDictionaryPlugin);
#line 93 "dictionary.vala"
	_tmp0_ = g_find_program_in_path ("gnome-dictionary");
#line 93 "dictionary.vala"
	_tmp1_ = _tmp0_;
#line 93 "dictionary.vala"
	_tmp2_ = _tmp1_ != NULL;
#line 93 "dictionary.vala"
	_g_free0 (_tmp1_);
#line 93 "dictionary.vala"
	if (_tmp2_) {
#line 94 "dictionary.vala"
		dictionary_exec = "gnome-dictionary";
#line 854 "dictionary.c"
	} else {
		gchar* _tmp3_;
		gchar* _tmp4_;
		gboolean _tmp5_;
#line 95 "dictionary.vala"
		_tmp3_ = g_find_program_in_path ("mate-dictionary");
#line 95 "dictionary.vala"
		_tmp4_ = _tmp3_;
#line 95 "dictionary.vala"
		_tmp5_ = _tmp4_ != NULL;
#line 95 "dictionary.vala"
		_g_free0 (_tmp4_);
#line 95 "dictionary.vala"
		if (_tmp5_) {
#line 96 "dictionary.vala"
			dictionary_exec = "mate-dictionary";
#line 871 "dictionary.c"
		} else {
#line 98 "dictionary.vala"
			g_assert_not_reached ();
#line 875 "dictionary.c"
		}
	}
#line 100 "dictionary.vala"
	_tmp6_ = dictionary_exec;
#line 100 "dictionary.vala"
	_tmp7_ = synapse_dictionary_plugin_define_new (_tmp6_);
#line 100 "dictionary.vala"
	_g_object_unref0 (self->priv->action);
#line 100 "dictionary.vala"
	self->priv->action = _tmp7_;
#line 101 "dictionary.vala"
	_tmp8_ = dictionary_exec;
#line 101 "dictionary.vala"
	self->priv->has_dictionary = _tmp8_ != NULL;
#line 90 "dictionary.vala"
	return obj;
#line 892 "dictionary.c"
}

static void
synapse_dictionary_plugin_class_init (SynapseDictionaryPluginClass * klass,
                                      gpointer klass_data)
{
#line 24 "dictionary.vala"
	synapse_dictionary_plugin_parent_class = g_type_class_peek_parent (klass);
#line 24 "dictionary.vala"
	g_type_class_adjust_private_offset (klass, &SynapseDictionaryPlugin_private_offset);
#line 24 "dictionary.vala"
	G_OBJECT_CLASS (klass)->get_property = _vala_synapse_dictionary_plugin_get_property;
#line 24 "dictionary.vala"
	G_OBJECT_CLASS (klass)->set_property = _vala_synapse_dictionary_plugin_set_property;
#line 24 "dictionary.vala"
	G_OBJECT_CLASS (klass)->constructor = synapse_dictionary_plugin_constructor;
#line 24 "dictionary.vala"
	G_OBJECT_CLASS (klass)->finalize = synapse_dictionary_plugin_finalize;
#line 24 "dictionary.vala"
	g_object_class_install_property (G_OBJECT_CLASS (klass), SYNAPSE_DICTIONARY_PLUGIN_ENABLED_PROPERTY, synapse_dictionary_plugin_properties[SYNAPSE_DICTIONARY_PLUGIN_ENABLED_PROPERTY] = g_param_spec_boolean ("enabled", "enabled", "enabled", TRUE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
#line 84 "dictionary.vala"
	synapse_dictionary_plugin_register_plugin ();
#line 915 "dictionary.c"
}

static void
synapse_dictionary_plugin_synapse_activatable_interface_init (SynapseActivatableIface * iface,
                                                              gpointer iface_data)
{
#line 24 "dictionary.vala"
	synapse_dictionary_plugin_synapse_activatable_parent_iface = g_type_interface_peek_parent (iface);
#line 24 "dictionary.vala"
	iface->activate = (void (*) (SynapseActivatable*)) synapse_dictionary_plugin_real_activate;
#line 24 "dictionary.vala"
	iface->deactivate = (void (*) (SynapseActivatable*)) synapse_dictionary_plugin_real_deactivate;
#line 24 "dictionary.vala"
	iface->get_enabled = synapse_dictionary_plugin_real_get_enabled;
#line 24 "dictionary.vala"
	iface->set_enabled = synapse_dictionary_plugin_real_set_enabled;
#line 932 "dictionary.c"
}

static void
synapse_dictionary_plugin_synapse_action_provider_interface_init (SynapseActionProviderIface * iface,
                                                                  gpointer iface_data)
{
#line 24 "dictionary.vala"
	synapse_dictionary_plugin_synapse_action_provider_parent_iface = g_type_interface_peek_parent (iface);
#line 24 "dictionary.vala"
	iface->handles_unknown = (gboolean (*) (SynapseActionProvider*)) synapse_dictionary_plugin_real_handles_unknown;
#line 24 "dictionary.vala"
	iface->find_for_match = (SynapseResultSet* (*) (SynapseActionProvider*, SynapseQuery*, SynapseMatch*)) synapse_dictionary_plugin_real_find_for_match;
#line 945 "dictionary.c"
}

static void
synapse_dictionary_plugin_instance_init (SynapseDictionaryPlugin * self,
                                         gpointer klass)
{
#line 24 "dictionary.vala"
	self->priv = synapse_dictionary_plugin_get_instance_private (self);
#line 26 "dictionary.vala"
	self->priv->_enabled = TRUE;
#line 956 "dictionary.c"
}

static void
synapse_dictionary_plugin_finalize (GObject * obj)
{
	SynapseDictionaryPlugin * self;
#line 24 "dictionary.vala"
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SYNAPSE_TYPE_DICTIONARY_PLUGIN, SynapseDictionaryPlugin);
#line 87 "dictionary.vala"
	_g_object_unref0 (self->priv->action);
#line 24 "dictionary.vala"
	G_OBJECT_CLASS (synapse_dictionary_plugin_parent_class)->finalize (obj);
#line 969 "dictionary.c"
}

static GType
synapse_dictionary_plugin_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SynapseDictionaryPluginClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) synapse_dictionary_plugin_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SynapseDictionaryPlugin), 0, (GInstanceInitFunc) synapse_dictionary_plugin_instance_init, NULL };
	static const GInterfaceInfo synapse_activatable_info = { (GInterfaceInitFunc) synapse_dictionary_plugin_synapse_activatable_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	static const GInterfaceInfo synapse_action_provider_info = { (GInterfaceInitFunc) synapse_dictionary_plugin_synapse_action_provider_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType synapse_dictionary_plugin_type_id;
	synapse_dictionary_plugin_type_id = g_type_register_static (G_TYPE_OBJECT, "SynapseDictionaryPlugin", &g_define_type_info, 0);
	g_type_add_interface_static (synapse_dictionary_plugin_type_id, SYNAPSE_TYPE_ACTIVATABLE, &synapse_activatable_info);
	g_type_add_interface_static (synapse_dictionary_plugin_type_id, SYNAPSE_TYPE_ACTION_PROVIDER, &synapse_action_provider_info);
	SynapseDictionaryPlugin_private_offset = g_type_add_instance_private (synapse_dictionary_plugin_type_id, sizeof (SynapseDictionaryPluginPrivate));
	return synapse_dictionary_plugin_type_id;
}

GType
synapse_dictionary_plugin_get_type (void)
{
	static volatile gsize synapse_dictionary_plugin_type_id__once = 0;
	if (g_once_init_enter (&synapse_dictionary_plugin_type_id__once)) {
		GType synapse_dictionary_plugin_type_id;
		synapse_dictionary_plugin_type_id = synapse_dictionary_plugin_get_type_once ();
		g_once_init_leave (&synapse_dictionary_plugin_type_id__once, synapse_dictionary_plugin_type_id);
	}
	return synapse_dictionary_plugin_type_id__once;
}

static void
_vala_synapse_dictionary_plugin_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec)
{
	SynapseDictionaryPlugin * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SYNAPSE_TYPE_DICTIONARY_PLUGIN, SynapseDictionaryPlugin);
#line 24 "dictionary.vala"
	switch (property_id) {
#line 24 "dictionary.vala"
		case SYNAPSE_DICTIONARY_PLUGIN_ENABLED_PROPERTY:
#line 24 "dictionary.vala"
		g_value_set_boolean (value, synapse_activatable_get_enabled ((SynapseActivatable*) self));
#line 24 "dictionary.vala"
		break;
#line 1014 "dictionary.c"
		default:
#line 24 "dictionary.vala"
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
#line 24 "dictionary.vala"
		break;
#line 1020 "dictionary.c"
	}
}

static void
_vala_synapse_dictionary_plugin_set_property (GObject * object,
                                              guint property_id,
                                              const GValue * value,
                                              GParamSpec * pspec)
{
	SynapseDictionaryPlugin * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SYNAPSE_TYPE_DICTIONARY_PLUGIN, SynapseDictionaryPlugin);
#line 24 "dictionary.vala"
	switch (property_id) {
#line 24 "dictionary.vala"
		case SYNAPSE_DICTIONARY_PLUGIN_ENABLED_PROPERTY:
#line 24 "dictionary.vala"
		synapse_activatable_set_enabled ((SynapseActivatable*) self, g_value_get_boolean (value));
#line 24 "dictionary.vala"
		break;
#line 1040 "dictionary.c"
		default:
#line 24 "dictionary.vala"
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
#line 24 "dictionary.vala"
		break;
#line 1046 "dictionary.c"
	}
}

