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

/*
* Copyright (c) 2010 Michal Hruby <michal.mhr@gmail.com>
*               2017 elementary LLC.
*               2020-2021 Justin Haygood
*
* 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-object.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <gio/gdesktopappinfo.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <gdk/gdk.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_TYPE_RUNNER_ACTION (synapse_runner_action_get_type ())
#define SYNAPSE_RUNNER_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SYNAPSE_TYPE_RUNNER_ACTION, SynapseRunnerAction))
#define SYNAPSE_RUNNER_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SYNAPSE_TYPE_RUNNER_ACTION, SynapseRunnerActionClass))
#define SYNAPSE_IS_RUNNER_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SYNAPSE_TYPE_RUNNER_ACTION))
#define SYNAPSE_IS_RUNNER_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SYNAPSE_TYPE_RUNNER_ACTION))
#define SYNAPSE_RUNNER_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SYNAPSE_TYPE_RUNNER_ACTION, SynapseRunnerActionClass))

typedef struct _SynapseRunnerAction SynapseRunnerAction;
typedef struct _SynapseRunnerActionClass SynapseRunnerActionClass;
typedef struct _SynapseRunnerActionPrivate SynapseRunnerActionPrivate;
enum  {
	SYNAPSE_RUNNER_ACTION_0_PROPERTY,
	SYNAPSE_RUNNER_ACTION_NUM_PROPERTIES
};
static GParamSpec* synapse_runner_action_properties[SYNAPSE_RUNNER_ACTION_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))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _SynapseRunnerAction {
	SynapseBaseAction parent_instance;
	SynapseRunnerActionPrivate * priv;
};

struct _SynapseRunnerActionClass {
	SynapseBaseActionClass parent_class;
};

struct _SynapseRunnerActionPrivate {
	SlingshotBackendSwitcherooControl* switcheroo_control;
};

static gint SynapseRunnerAction_private_offset;
static gpointer synapse_runner_action_parent_class = NULL;
static GType synapse_runner_action_type_id = 0;

GType synapse_runner_action_register_type (GTypeModule * module);
VALA_EXTERN GType synapse_runner_action_get_type (void) G_GNUC_CONST ;
VALA_EXTERN SynapseRunnerAction* synapse_runner_action_new (void);
VALA_EXTERN SynapseRunnerAction* synapse_runner_action_construct (GType object_type);
static void synapse_runner_action_real_do_execute (SynapseBaseAction* base,
                                            SynapseMatch* match,
                                            SynapseMatch* target);
static void _vala_array_add20 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
static void _vala_array_add21 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
static void _vala_array_add22 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
static void _vala_array_add23 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
static void _vala_array_add24 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
static void _vala_array_add25 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
static void ____lambda14_ (SynapseRunnerAction* self,
                    GPid pid,
                    gint status);
static void _____lambda14__gchild_watch_func (GPid pid,
                                       gint wait_status,
                                       gpointer self);
static gboolean synapse_runner_action_real_valid_for_match (SynapseBaseAction* base,
                                                     SynapseMatch* match);
static GObject * synapse_runner_action_constructor (GType type,
                                             guint n_construct_properties,
                                             GObjectConstructParam * construct_properties);
static void synapse_runner_action_finalize (GObject * obj);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);

static inline gpointer
synapse_runner_action_get_instance_private (SynapseRunnerAction* self)
{
	return G_STRUCT_MEMBER_P (self, SynapseRunnerAction_private_offset);
}

SynapseRunnerAction*
synapse_runner_action_construct (GType object_type)
{
	SynapseRunnerAction * self = NULL;
	self = (SynapseRunnerAction*) g_object_new (object_type, "title", _ ("Run"), "description", _ ("Run an application, action or script"), "icon-name", "system-run", "has-thumbnail", FALSE, "match-type", SYNAPSE_MATCH_TYPE_ACTION, "default-relevancy", SYNAPSE_MATCH_SCORE_EXCELLENT, NULL);
	return self;
}

SynapseRunnerAction*
synapse_runner_action_new (void)
{
	return synapse_runner_action_construct (SYNAPSE_TYPE_RUNNER_ACTION);
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static void
_vala_array_add20 (gchar** * array,
                   gint* length,
                   gint* size,
                   gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add21 (gchar** * array,
                   gint* length,
                   gint* size,
                   gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add22 (gchar** * array,
                   gint* length,
                   gint* size,
                   gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add23 (gchar** * array,
                   gint* length,
                   gint* size,
                   gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add24 (gchar** * array,
                   gint* length,
                   gint* size,
                   gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add25 (gchar** * array,
                   gint* length,
                   gint* size,
                   gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
____lambda14_ (SynapseRunnerAction* self,
               GPid pid,
               gint status)
{
	g_spawn_close_pid (pid);
}

static void
_____lambda14__gchild_watch_func (GPid pid,
                                  gint wait_status,
                                  gpointer self)
{
	____lambda14_ ((SynapseRunnerAction*) self, pid, wait_status);
}

static void
synapse_runner_action_real_do_execute (SynapseBaseAction* base,
                                       SynapseMatch* match,
                                       SynapseMatch* target)
{
	SynapseRunnerAction * self;
	SynapseMatchType _tmp0_;
	SynapseMatchType _tmp1_;
	GError* _inner_error0_ = NULL;
	self = (SynapseRunnerAction*) base;
	_tmp0_ = synapse_match_get_match_type (match);
	_tmp1_ = _tmp0_;
	if (_tmp1_ == SYNAPSE_MATCH_TYPE_APPLICATION) {
		SynapseApplicationMatch* app_match = NULL;
		SynapseApplicationMatch* _tmp2_;
		GDesktopAppInfo* app_info = NULL;
		GAppInfo* app = NULL;
		SynapseApplicationMatch* _tmp3_;
		GAppInfo* _tmp4_;
		GAppInfo* _tmp5_;
		app_match = SYNAPSE_IS_APPLICATION_MATCH (match) ? ((SynapseApplicationMatch*) match) : NULL;
		_tmp2_ = app_match;
		g_return_if_fail (_tmp2_ != NULL);
		app_info = NULL;
		_tmp3_ = app_match;
		_tmp4_ = synapse_application_match_get_app_info (_tmp3_);
		_tmp5_ = _tmp4_;
		if (_tmp5_ != NULL) {
			SynapseApplicationMatch* _tmp6_;
			GAppInfo* _tmp7_;
			GAppInfo* _tmp8_;
			GAppInfo* _tmp9_;
			_tmp6_ = app_match;
			_tmp7_ = synapse_application_match_get_app_info (_tmp6_);
			_tmp8_ = _tmp7_;
			_tmp9_ = _g_object_ref0 (_tmp8_);
			_g_object_unref0 (app);
			app = _tmp9_;
		} else {
			SynapseApplicationMatch* _tmp10_;
			const gchar* _tmp11_;
			const gchar* _tmp12_;
			GDesktopAppInfo* _tmp13_;
			GDesktopAppInfo* _tmp14_;
			GAppInfo* _tmp15_;
			_tmp10_ = app_match;
			_tmp11_ = synapse_application_match_get_filename (_tmp10_);
			_tmp12_ = _tmp11_;
			_tmp13_ = g_desktop_app_info_new_from_filename (_tmp12_);
			_g_object_unref0 (app_info);
			app_info = _tmp13_;
			_tmp14_ = app_info;
			_tmp15_ = _g_object_ref0 ((GAppInfo*) _tmp14_);
			_g_object_unref0 (app);
			app = _tmp15_;
		}
		{
			GdkDisplay* display = NULL;
			GdkDisplay* _tmp16_;
			gchar* cmd = NULL;
			GAppInfo* _tmp17_;
			const gchar* _tmp18_;
			gchar* _tmp19_;
			gchar** parsed_args = NULL;
			gint parsed_args_length1 = 0;
			gint _parsed_args_size_ = 0;
			const gchar* _tmp20_;
			gchar** _tmp21_ = NULL;
			gint _tmp22_ = 0;
			gboolean _tmp23_ = FALSE;
			gchar** _tmp24_;
			gint _tmp24__length1;
			gint i = 0;
			gchar* wayland_display = NULL;
			const gchar* _tmp33_;
			gchar* _tmp34_;
			gchar* xdg_runtime_dir = NULL;
			const gchar* _tmp35_;
			gchar* _tmp36_;
			gchar** argv = NULL;
			gchar** _tmp37_;
			gint argv_length1;
			gint _argv_size_;
			gchar* _tmp38_;
			gchar* _tmp44_;
			gboolean _tmp45_ = FALSE;
			const gchar* _tmp46_;
			gboolean _tmp52_ = FALSE;
			const gchar* _tmp53_;
			gchar** envv = NULL;
			gchar** _tmp65_;
			gchar** _tmp66_;
			gint envv_length1;
			gint _envv_size_;
			GPid child_pid = 0;
			gchar** _tmp67_;
			gint _tmp67__length1;
			gchar** _tmp68_;
			gint _tmp68__length1;
			GPid _tmp69_ = 0;
			_tmp16_ = gdk_display_get_default ();
			display = _tmp16_;
			_tmp17_ = app;
			_tmp18_ = g_app_info_get_commandline (_tmp17_);
			_tmp19_ = g_strdup (_tmp18_);
			cmd = _tmp19_;
			_tmp20_ = cmd;
			g_shell_parse_argv (_tmp20_, &_tmp22_, &_tmp21_, &_inner_error0_);
			parsed_args = (_vala_array_free (parsed_args, parsed_args_length1, (GDestroyNotify) g_free), NULL);
			parsed_args = _tmp21_;
			parsed_args_length1 = _tmp22_;
			_parsed_args_size_ = parsed_args_length1;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				parsed_args = (_vala_array_free (parsed_args, parsed_args_length1, (GDestroyNotify) g_free), NULL);
				_g_free0 (cmd);
				goto __catch0_g_error;
			}
			_tmp24_ = parsed_args;
			_tmp24__length1 = parsed_args_length1;
			if (_tmp24__length1 == 0) {
				_tmp23_ = TRUE;
			} else {
				gchar** _tmp25_;
				gint _tmp25__length1;
				const gchar* _tmp26_;
				_tmp25_ = parsed_args;
				_tmp25__length1 = parsed_args_length1;
				_tmp26_ = _tmp25_[0];
				_tmp23_ = g_strcmp0 (_tmp26_, "pkexec") != 0;
			}
			if (_tmp23_) {
				GAppInfo* _tmp27_;
				_tmp27_ = app;
				g_app_info_launch (_tmp27_, NULL, NULL, &_inner_error0_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					parsed_args = (_vala_array_free (parsed_args, parsed_args_length1, (GDestroyNotify) g_free), NULL);
					_g_free0 (cmd);
					goto __catch0_g_error;
				}
				parsed_args = (_vala_array_free (parsed_args, parsed_args_length1, (GDestroyNotify) g_free), NULL);
				_g_free0 (cmd);
				_g_object_unref0 (app);
				_g_object_unref0 (app_info);
				return;
			}
			i = 1;
			while (TRUE) {
				gboolean _tmp28_ = FALSE;
				gchar** _tmp29_;
				gint _tmp29__length1;
				gint _tmp32_;
				_tmp29_ = parsed_args;
				_tmp29__length1 = parsed_args_length1;
				if (i < _tmp29__length1) {
					gchar** _tmp30_;
					gint _tmp30__length1;
					const gchar* _tmp31_;
					_tmp30_ = parsed_args;
					_tmp30__length1 = parsed_args_length1;
					_tmp31_ = _tmp30_[i];
					_tmp28_ = g_str_has_prefix (_tmp31_, "-");
				} else {
					_tmp28_ = FALSE;
				}
				if (!_tmp28_) {
					break;
				}
				_tmp32_ = i;
				i = _tmp32_ + 1;
			}
			_tmp33_ = g_getenv ("WAYLAND_DISPLAY");
			_tmp34_ = g_strdup (_tmp33_);
			wayland_display = _tmp34_;
			_tmp35_ = g_getenv ("XDG_RUNTIME_DIR");
			_tmp36_ = g_strdup (_tmp35_);
			xdg_runtime_dir = _tmp36_;
			_tmp37_ = g_new0 (gchar*, 0 + 1);
			argv = _tmp37_;
			argv_length1 = 0;
			_argv_size_ = argv_length1;
			_tmp38_ = g_strdup ("pkexec");
			_vala_array_add20 (&argv, &argv_length1, &_argv_size_, _tmp38_);
			{
				gint j = 0;
				j = 1;
				{
					gboolean _tmp39_ = FALSE;
					_tmp39_ = TRUE;
					while (TRUE) {
						gchar** _tmp41_;
						gint _tmp41__length1;
						const gchar* _tmp42_;
						gchar* _tmp43_;
						if (!_tmp39_) {
							gint _tmp40_;
							_tmp40_ = j;
							j = _tmp40_ + 1;
						}
						_tmp39_ = FALSE;
						if (!(j < i)) {
							break;
						}
						_tmp41_ = parsed_args;
						_tmp41__length1 = parsed_args_length1;
						_tmp42_ = _tmp41_[j];
						_tmp43_ = g_strdup (_tmp42_);
						_vala_array_add21 (&argv, &argv_length1, &_argv_size_, _tmp43_);
					}
				}
			}
			_tmp44_ = g_strdup ("env");
			_vala_array_add22 (&argv, &argv_length1, &_argv_size_, _tmp44_);
			_tmp46_ = wayland_display;
			if (_tmp46_ != NULL) {
				const gchar* _tmp47_;
				gint _tmp48_;
				gint _tmp49_;
				_tmp47_ = wayland_display;
				_tmp48_ = strlen (_tmp47_);
				_tmp49_ = _tmp48_;
				_tmp45_ = _tmp49_ > 0;
			} else {
				_tmp45_ = FALSE;
			}
			if (_tmp45_) {
				const gchar* _tmp50_;
				gchar* _tmp51_;
				_tmp50_ = wayland_display;
				_tmp51_ = g_strdup_printf ("WAYLAND_DISPLAY=%s", _tmp50_);
				_vala_array_add23 (&argv, &argv_length1, &_argv_size_, _tmp51_);
			}
			_tmp53_ = xdg_runtime_dir;
			if (_tmp53_ != NULL) {
				const gchar* _tmp54_;
				gint _tmp55_;
				gint _tmp56_;
				_tmp54_ = xdg_runtime_dir;
				_tmp55_ = strlen (_tmp54_);
				_tmp56_ = _tmp55_;
				_tmp52_ = _tmp56_ > 0;
			} else {
				_tmp52_ = FALSE;
			}
			if (_tmp52_) {
				const gchar* _tmp57_;
				gchar* _tmp58_;
				_tmp57_ = xdg_runtime_dir;
				_tmp58_ = g_strdup_printf ("XDG_RUNTIME_DIR=%s", _tmp57_);
				_vala_array_add24 (&argv, &argv_length1, &_argv_size_, _tmp58_);
			}
			{
				gint j = 0;
				j = i;
				{
					gboolean _tmp59_ = FALSE;
					_tmp59_ = TRUE;
					while (TRUE) {
						gchar** _tmp61_;
						gint _tmp61__length1;
						gchar** _tmp62_;
						gint _tmp62__length1;
						const gchar* _tmp63_;
						gchar* _tmp64_;
						if (!_tmp59_) {
							gint _tmp60_;
							_tmp60_ = j;
							j = _tmp60_ + 1;
						}
						_tmp59_ = FALSE;
						_tmp61_ = parsed_args;
						_tmp61__length1 = parsed_args_length1;
						if (!(j < _tmp61__length1)) {
							break;
						}
						_tmp62_ = parsed_args;
						_tmp62__length1 = parsed_args_length1;
						_tmp63_ = _tmp62_[j];
						_tmp64_ = g_strdup (_tmp63_);
						_vala_array_add25 (&argv, &argv_length1, &_argv_size_, _tmp64_);
					}
				}
			}
			_tmp66_ = _tmp65_ = g_get_environ ();
			envv = _tmp66_;
			envv_length1 = _vala_array_length (_tmp65_);
			_envv_size_ = envv_length1;
			_tmp67_ = argv;
			_tmp67__length1 = argv_length1;
			_tmp68_ = envv;
			_tmp68__length1 = envv_length1;
			g_spawn_async ("/", _tmp67_, _tmp68_, G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &_tmp69_, &_inner_error0_);
			child_pid = _tmp69_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				envv = (_vala_array_free (envv, envv_length1, (GDestroyNotify) g_free), NULL);
				argv = (_vala_array_free (argv, argv_length1, (GDestroyNotify) g_free), NULL);
				_g_free0 (xdg_runtime_dir);
				_g_free0 (wayland_display);
				parsed_args = (_vala_array_free (parsed_args, parsed_args_length1, (GDestroyNotify) g_free), NULL);
				_g_free0 (cmd);
				goto __catch0_g_error;
			}
			g_child_watch_add_full (G_PRIORITY_DEFAULT_IDLE, child_pid, _____lambda14__gchild_watch_func, g_object_ref (self), g_object_unref);
			envv = (_vala_array_free (envv, envv_length1, (GDestroyNotify) g_free), NULL);
			argv = (_vala_array_free (argv, argv_length1, (GDestroyNotify) g_free), NULL);
			_g_free0 (xdg_runtime_dir);
			_g_free0 (wayland_display);
			parsed_args = (_vala_array_free (parsed_args, parsed_args_length1, (GDestroyNotify) g_free), NULL);
			_g_free0 (cmd);
		}
		goto __finally0;
		__catch0_g_error:
		{
			GError* err = NULL;
			GError* _tmp70_;
			const gchar* _tmp71_;
			err = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp70_ = err;
			_tmp71_ = _tmp70_->message;
			g_critical ("RunnerAction.vala:121: %s", _tmp71_);
			_g_error_free0 (err);
		}
		__finally0:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (app);
			_g_object_unref0 (app_info);
			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);
			g_clear_error (&_inner_error0_);
			return;
		}
		_g_object_unref0 (app);
		_g_object_unref0 (app_info);
	} else {
		synapse_match_execute (match, NULL);
	}
}

static gboolean
synapse_runner_action_real_valid_for_match (SynapseBaseAction* base,
                                            SynapseMatch* match)
{
	SynapseRunnerAction * self;
	SynapseMatchType _tmp0_;
	SynapseMatchType _tmp1_;
	gboolean result;
	self = (SynapseRunnerAction*) base;
	g_return_val_if_fail (match != NULL, FALSE);
	_tmp0_ = synapse_match_get_match_type (match);
	_tmp1_ = _tmp0_;
	switch (_tmp1_) {
		case SYNAPSE_MATCH_TYPE_SEARCH:
		{
			result = TRUE;
			return result;
		}
		case SYNAPSE_MATCH_TYPE_ACTION:
		{
			result = TRUE;
			return result;
		}
		case SYNAPSE_MATCH_TYPE_APPLICATION:
		{
			SynapseApplicationMatch* am = NULL;
			gboolean _tmp2_ = FALSE;
			SynapseApplicationMatch* _tmp3_;
			am = SYNAPSE_IS_APPLICATION_MATCH (match) ? ((SynapseApplicationMatch*) match) : NULL;
			_tmp3_ = am;
			if (_tmp3_ == NULL) {
				_tmp2_ = TRUE;
			} else {
				SynapseApplicationMatch* _tmp4_;
				gboolean _tmp5_;
				gboolean _tmp6_;
				_tmp4_ = am;
				_tmp5_ = synapse_application_match_get_needs_terminal (_tmp4_);
				_tmp6_ = _tmp5_;
				_tmp2_ = !_tmp6_;
			}
			result = _tmp2_;
			return result;
		}
		default:
		{
			result = FALSE;
			return result;
		}
	}
}

static GObject *
synapse_runner_action_constructor (GType type,
                                   guint n_construct_properties,
                                   GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	SynapseRunnerAction * self;
	SlingshotBackendSwitcherooControl* _tmp0_;
	parent_class = G_OBJECT_CLASS (synapse_runner_action_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SYNAPSE_TYPE_RUNNER_ACTION, SynapseRunnerAction);
	_tmp0_ = slingshot_backend_switcheroo_control_new ();
	_g_object_unref0 (self->priv->switcheroo_control);
	self->priv->switcheroo_control = _tmp0_;
	return obj;
}

static void
synapse_runner_action_class_init (SynapseRunnerActionClass * klass,
                                  gpointer klass_data)
{
	synapse_runner_action_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &SynapseRunnerAction_private_offset);
	((SynapseBaseActionClass *) klass)->do_execute = (void (*) (SynapseBaseAction*, SynapseMatch*, SynapseMatch*)) synapse_runner_action_real_do_execute;
	((SynapseBaseActionClass *) klass)->valid_for_match = (gboolean (*) (SynapseBaseAction*, SynapseMatch*)) synapse_runner_action_real_valid_for_match;
	G_OBJECT_CLASS (klass)->constructor = synapse_runner_action_constructor;
	G_OBJECT_CLASS (klass)->finalize = synapse_runner_action_finalize;
}

static void
synapse_runner_action_instance_init (SynapseRunnerAction * self,
                                     gpointer klass)
{
	self->priv = synapse_runner_action_get_instance_private (self);
}

static void
synapse_runner_action_finalize (GObject * obj)
{
	SynapseRunnerAction * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SYNAPSE_TYPE_RUNNER_ACTION, SynapseRunnerAction);
	_g_object_unref0 (self->priv->switcheroo_control);
	G_OBJECT_CLASS (synapse_runner_action_parent_class)->finalize (obj);
}

GType
synapse_runner_action_get_type (void)
{
	return synapse_runner_action_type_id;
}

GType
synapse_runner_action_register_type (GTypeModule * module)
{
	static const GTypeInfo g_define_type_info = { sizeof (SynapseRunnerActionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) synapse_runner_action_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SynapseRunnerAction), 0, (GInstanceInitFunc) synapse_runner_action_instance_init, NULL };
	synapse_runner_action_type_id = g_type_module_register_type (module, SYNAPSE_TYPE_BASE_ACTION, "SynapseRunnerAction", &g_define_type_info, 0);
	SynapseRunnerAction_private_offset = sizeof (SynapseRunnerActionPrivate);
	return synapse_runner_action_type_id;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

