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

/*
* Budgie Screencast
* Author: Sam Lane
* Copyright © 2026 Ubuntu Budgie Developers
* Website=https://ubuntubudgie.org
* 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 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, see
* <https://www.gnu.org/licenses/>.
*/
/*
 * RecorderControl — wf-recorder process manager
 *
 * Responsibilities:
 *   - Build the correct wf-recorder argv for SCREEN and AREA capture modes
 *   - Optionally invoke slurp before recording to obtain an area geometry string
 *   - Implement a start delay (countdown before wf-recorder is spawned)
 *   - Implement auto-stop after a set duration
 *   - Show an amber countdown badge on the panel icon during the final
 *     COUNTDOWN_WINDOW seconds of either a start delay or a duration stop
 *   - Gracefully terminate wf-recorder via SIGINT, with SIGTERM / SIGKILL
 *     escalation as a safety net
 *
 * No UI code lives here. All state changes are communicated via signals that
 * ScreencastApplet connects to and forwards to ScreencastIcon.
 *
 */

#include "budgie-screencast.h"
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <sys/types.h>
#include <glib-object.h>

#define RECORDER_CONTROL_RECORDER_COUNTDOWN_WINDOW 5
#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  {
	RECORDER_CONTROL_RECORDER_0_PROPERTY,
	RECORDER_CONTROL_RECORDER_RECORDING_PROPERTY,
	RECORDER_CONTROL_RECORDER_PENDING_PROPERTY,
	RECORDER_CONTROL_RECORDER_NUM_PROPERTIES
};
static GParamSpec* recorder_control_recorder_properties[RECORDER_CONTROL_RECORDER_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block7Data Block7Data;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block8Data Block8Data;
typedef struct _Block9Data Block9Data;
typedef struct _Block10Data Block10Data;
#define _g_io_channel_unref0(var) ((var == NULL) ? NULL : (var = (g_io_channel_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))
typedef struct _Block11Data Block11Data;
enum  {
	RECORDER_CONTROL_RECORDER_RECORDING_CHANGED_SIGNAL,
	RECORDER_CONTROL_RECORDER_PENDING_CHANGED_SIGNAL,
	RECORDER_CONTROL_RECORDER_AREA_SELECTION_FAILED_SIGNAL,
	RECORDER_CONTROL_RECORDER_NUM_SIGNALS
};
static guint recorder_control_recorder_signals[RECORDER_CONTROL_RECORDER_NUM_SIGNALS] = {0};

struct _RecorderControlRecorderPrivate {
	gboolean _recording;
	gboolean _pending;
	gchar* save_path;
	GPid pid;
	guint delay_source;
	guint duration_source;
	guint duration_tick_source;
};

struct _Block7Data {
	int _ref_count_;
	RecorderControlRecorder* self;
	GPid stopping_pid;
};

struct _Block8Data {
	int _ref_count_;
	RecorderControlRecorder* self;
	gint remaining;
	gchar* output;
	RecorderControlCaptureMode mode;
	gint duration_seconds;
	gboolean audio_enabled;
	gchar* audio_device;
};

struct _Block9Data {
	int _ref_count_;
	RecorderControlRecorder* self;
	gint duration_seconds;
	gboolean audio_enabled;
	gchar* audio_device;
};

struct _Block10Data {
	int _ref_count_;
	Block9Data * _data9_;
	GIOChannel* channel;
};

struct _Block11Data {
	int _ref_count_;
	RecorderControlRecorder* self;
	gint remaining;
};

static gint RecorderControlRecorder_private_offset;
static gpointer recorder_control_recorder_parent_class = NULL;
static GType recorder_control_recorder_type_id = 0;

static void recorder_control_recorder_cancel_all_timers (RecorderControlRecorder* self);
static void recorder_control_recorder_clear_pending (RecorderControlRecorder* self);
static void recorder_control_recorder_run_with_delay (RecorderControlRecorder* self,
                                               const gchar* output,
                                               RecorderControlCaptureMode mode,
                                               gint delay_seconds,
                                               gint duration_seconds,
                                               gboolean audio_enabled,
                                               const gchar* audio_device);
static void recorder_control_recorder_launch (RecorderControlRecorder* self,
                                       const gchar* output,
                                       RecorderControlCaptureMode mode,
                                       gint duration_seconds,
                                       gboolean audio_enabled,
                                       const gchar* audio_device);
static Block7Data* block7_data_ref (Block7Data* _data7_);
static void block7_data_unref (void * _userdata_);
static void recorder_control_recorder_cancel_duration_timers (RecorderControlRecorder* self);
static gboolean __lambda18_ (Block7Data* _data7_);
static gboolean ___lambda18__gsource_func (gpointer self);
static gboolean __lambda19_ (Block7Data* _data7_);
static gboolean ___lambda19__gsource_func (gpointer self);
static Block8Data* block8_data_ref (Block8Data* _data8_);
static void block8_data_unref (void * _userdata_);
static void recorder_control_recorder_show_pending (RecorderControlRecorder* self,
                                             gint countdown);
static gboolean __lambda20_ (Block8Data* _data8_);
static gboolean ___lambda20__gsource_func (gpointer self);
static void recorder_control_recorder_set_pending (RecorderControlRecorder* self,
                                            gboolean value);
static void recorder_control_recorder_cancel_pending_delay (RecorderControlRecorder* self);
static void recorder_control_recorder_start_area_capture (RecorderControlRecorder* self,
                                                   gint duration_seconds,
                                                   gboolean audio_enabled,
                                                   const gchar* audio_device);
static void recorder_control_recorder_spawn_recorder (RecorderControlRecorder* self,
                                               gchar** argv,
                                               gint argv_length1,
                                               gint duration_seconds);
static gchar** recorder_control_recorder_build_argv (RecorderControlRecorder* self,
                                              const gchar* output,
                                              const gchar* geometry,
                                              gboolean audio_enabled,
                                              const gchar* audio_device,
                                              gint* result_length1);
static Block9Data* block9_data_ref (Block9Data* _data9_);
static void block9_data_unref (void * _userdata_);
static Block10Data* block10_data_ref (Block10Data* _data10_);
static void block10_data_unref (void * _userdata_);
static void ___lambda21_ (Block10Data* _data10_,
                   GPid child_pid,
                   gint status);
static void ____lambda21__gchild_watch_func (GPid pid,
                                      gint wait_status,
                                      gpointer self);
static void _vala_array_add3 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static void _vala_array_add4 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static void _vala_array_add5 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static void _vala_array_add6 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static void _vala_array_add7 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static void _vala_array_add8 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static gchar* recorder_control_recorder_output_path (RecorderControlRecorder* self);
static void _vala_array_add9 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static void _vala_array_add10 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
static void _vala_array_add11 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
static void _vala_array_add12 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
static void ___lambda22_ (RecorderControlRecorder* self,
                   GPid child_pid,
                   gint status);
static void recorder_control_recorder_set_recording_state (RecorderControlRecorder* self,
                                                    gboolean value);
static void ____lambda22__gchild_watch_func (GPid pid,
                                      gint wait_status,
                                      gpointer self);
static void recorder_control_recorder_schedule_duration_stop (RecorderControlRecorder* self,
                                                       gint duration_seconds);
static gboolean ___lambda23_ (RecorderControlRecorder* self);
static void recorder_control_recorder_start_duration_tick (RecorderControlRecorder* self,
                                                    gint initial_countdown);
static gboolean ____lambda23__gsource_func (gpointer self);
static Block11Data* block11_data_ref (Block11Data* _data11_);
static void block11_data_unref (void * _userdata_);
static gboolean __lambda24_ (Block11Data* _data11_);
static gboolean ___lambda24__gsource_func (gpointer self);
static void recorder_control_recorder_set_recording (RecorderControlRecorder* self,
                                              gboolean value);
static void g_cclosure_user_marshal_VOID__BOOLEAN_INT (GClosure * closure,
                                                GValue * return_value,
                                                guint n_param_values,
                                                const GValue * param_values,
                                                gpointer invocation_hint,
                                                gpointer marshal_data);
static void recorder_control_recorder_finalize (GObject * obj);
static void _vala_recorder_control_recorder_get_property (GObject * object,
                                                   guint property_id,
                                                   GValue * value,
                                                   GParamSpec * pspec);
static void _vala_recorder_control_recorder_set_property (GObject * object,
                                                   guint property_id,
                                                   const GValue * value,
                                                   GParamSpec * pspec);
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 GType
recorder_control_capture_mode_get_type_once (void)
{
	static const GEnumValue values[] = {{RECORDER_CONTROL_CAPTURE_MODE_SCREEN, "RECORDER_CONTROL_CAPTURE_MODE_SCREEN", "screen"}, {RECORDER_CONTROL_CAPTURE_MODE_AREA, "RECORDER_CONTROL_CAPTURE_MODE_AREA", "area"}, {0, NULL, NULL}};
	GType recorder_control_capture_mode_type_id;
	recorder_control_capture_mode_type_id = g_enum_register_static ("RecorderControlCaptureMode", values);
	return recorder_control_capture_mode_type_id;
}

GType
recorder_control_capture_mode_get_type (void)
{
	static volatile gsize recorder_control_capture_mode_type_id__once = 0;
	if (g_once_init_enter (&recorder_control_capture_mode_type_id__once)) {
		GType recorder_control_capture_mode_type_id;
		recorder_control_capture_mode_type_id = recorder_control_capture_mode_get_type_once ();
		g_once_init_leave (&recorder_control_capture_mode_type_id__once, recorder_control_capture_mode_type_id);
	}
	return recorder_control_capture_mode_type_id__once;
}

static inline gpointer
recorder_control_recorder_get_instance_private (RecorderControlRecorder* self)
{
	return G_STRUCT_MEMBER_P (self, RecorderControlRecorder_private_offset);
}

void
recorder_control_recorder_toggle (RecorderControlRecorder* self,
                                  const gchar* output,
                                  RecorderControlCaptureMode mode,
                                  gint delay_seconds,
                                  gint duration_seconds,
                                  gboolean audio_enabled,
                                  const gchar* audio_device)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (output != NULL);
	g_return_if_fail (audio_device != NULL);
	_tmp1_ = self->priv->_recording;
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		gboolean _tmp2_;
		_tmp2_ = self->priv->_pending;
		_tmp0_ = _tmp2_;
	}
	if (_tmp0_) {
		recorder_control_recorder_cancel_all_timers (self);
		recorder_control_recorder_clear_pending (self);
		recorder_control_recorder_stop (self);
	} else {
		recorder_control_recorder_start (self, output, mode, delay_seconds, duration_seconds, audio_enabled, audio_device);
	}
}

void
recorder_control_recorder_start (RecorderControlRecorder* self,
                                 const gchar* output,
                                 RecorderControlCaptureMode mode,
                                 gint delay_seconds,
                                 gint duration_seconds,
                                 gboolean audio_enabled,
                                 const gchar* audio_device)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (output != NULL);
	g_return_if_fail (audio_device != NULL);
	_tmp1_ = self->priv->_recording;
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		gboolean _tmp2_;
		_tmp2_ = self->priv->_pending;
		_tmp0_ = _tmp2_;
	}
	if (_tmp0_) {
		return;
	}
	if (delay_seconds > 0) {
		recorder_control_recorder_run_with_delay (self, output, mode, delay_seconds, duration_seconds, audio_enabled, audio_device);
	} else {
		recorder_control_recorder_launch (self, output, mode, duration_seconds, audio_enabled, audio_device);
	}
}

static Block7Data*
block7_data_ref (Block7Data* _data7_)
{
	g_atomic_int_inc (&_data7_->_ref_count_);
	return _data7_;
}

static void
block7_data_unref (void * _userdata_)
{
	Block7Data* _data7_;
	_data7_ = (Block7Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data7_->_ref_count_)) {
		RecorderControlRecorder* self;
		self = _data7_->self;
		_g_object_unref0 (self);
		g_slice_free (Block7Data, _data7_);
	}
}

static gboolean
__lambda18_ (Block7Data* _data7_)
{
	RecorderControlRecorder* self;
	gboolean result;
	self = _data7_->self;
	if (self->priv->pid == _data7_->stopping_pid) {
		kill ((pid_t) ((gint) self->priv->pid), (gint) SIGTERM);
	}
	result = FALSE;
	return result;
}

static gboolean
___lambda18__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda18_ (self);
	return result;
}

static gboolean
__lambda19_ (Block7Data* _data7_)
{
	RecorderControlRecorder* self;
	gboolean result;
	self = _data7_->self;
	if (self->priv->pid == _data7_->stopping_pid) {
		kill ((pid_t) ((gint) self->priv->pid), (gint) SIGKILL);
	}
	result = FALSE;
	return result;
}

static gboolean
___lambda19__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda19_ (self);
	return result;
}

void
recorder_control_recorder_stop (RecorderControlRecorder* self)
{
	Block7Data* _data7_;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_;
	g_return_if_fail (self != NULL);
	_data7_ = g_slice_new0 (Block7Data);
	_data7_->_ref_count_ = 1;
	_data7_->self = g_object_ref (self);
	recorder_control_recorder_cancel_duration_timers (self);
	_tmp1_ = self->priv->_recording;
	if (!_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = self->priv->pid == ((GPid) 0);
	}
	if (_tmp0_) {
		block7_data_unref (_data7_);
		_data7_ = NULL;
		return;
	}
	kill ((pid_t) ((gint) self->priv->pid), (gint) SIGINT);
	_data7_->stopping_pid = self->priv->pid;
	g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 1500, ___lambda18__gsource_func, block7_data_ref (_data7_), block7_data_unref);
	g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 3500, ___lambda19__gsource_func, block7_data_ref (_data7_), block7_data_unref);
	block7_data_unref (_data7_);
	_data7_ = NULL;
}

void
recorder_control_recorder_set_save_path (RecorderControlRecorder* self,
                                         const gchar* path)
{
	gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (path != NULL);
	_tmp0_ = g_strdup (path);
	_g_free0 (self->priv->save_path);
	self->priv->save_path = _tmp0_;
}

static Block8Data*
block8_data_ref (Block8Data* _data8_)
{
	g_atomic_int_inc (&_data8_->_ref_count_);
	return _data8_;
}

static void
block8_data_unref (void * _userdata_)
{
	Block8Data* _data8_;
	_data8_ = (Block8Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data8_->_ref_count_)) {
		RecorderControlRecorder* self;
		self = _data8_->self;
		_g_free0 (_data8_->output);
		_g_free0 (_data8_->audio_device);
		_g_object_unref0 (self);
		g_slice_free (Block8Data, _data8_);
	}
}

static gboolean
__lambda20_ (Block8Data* _data8_)
{
	RecorderControlRecorder* self;
	gint _tmp0_;
	gboolean result;
	self = _data8_->self;
	_tmp0_ = _data8_->remaining;
	_data8_->remaining = _tmp0_ - 1;
	if (_data8_->remaining <= 0) {
		self->priv->delay_source = (guint) 0;
		recorder_control_recorder_clear_pending (self);
		recorder_control_recorder_launch (self, _data8_->output, _data8_->mode, _data8_->duration_seconds, _data8_->audio_enabled, _data8_->audio_device);
		result = FALSE;
		return result;
	}
	if (_data8_->remaining <= RECORDER_CONTROL_RECORDER_COUNTDOWN_WINDOW) {
		recorder_control_recorder_show_pending (self, _data8_->remaining);
	}
	result = TRUE;
	return result;
}

static gboolean
___lambda20__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda20_ (self);
	return result;
}

static void
recorder_control_recorder_run_with_delay (RecorderControlRecorder* self,
                                          const gchar* output,
                                          RecorderControlCaptureMode mode,
                                          gint delay_seconds,
                                          gint duration_seconds,
                                          gboolean audio_enabled,
                                          const gchar* audio_device)
{
	Block8Data* _data8_;
	gchar* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (output != NULL);
	g_return_if_fail (audio_device != NULL);
	_data8_ = g_slice_new0 (Block8Data);
	_data8_->_ref_count_ = 1;
	_data8_->self = g_object_ref (self);
	_tmp0_ = g_strdup (output);
	_g_free0 (_data8_->output);
	_data8_->output = _tmp0_;
	_data8_->mode = mode;
	_data8_->duration_seconds = duration_seconds;
	_data8_->audio_enabled = audio_enabled;
	_tmp1_ = g_strdup (audio_device);
	_g_free0 (_data8_->audio_device);
	_data8_->audio_device = _tmp1_;
	_data8_->remaining = delay_seconds;
	if (_data8_->remaining <= RECORDER_CONTROL_RECORDER_COUNTDOWN_WINDOW) {
		recorder_control_recorder_show_pending (self, _data8_->remaining);
	}
	self->priv->delay_source = g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 1000, ___lambda20__gsource_func, block8_data_ref (_data8_), block8_data_unref);
	block8_data_unref (_data8_);
	_data8_ = NULL;
}

static void
recorder_control_recorder_show_pending (RecorderControlRecorder* self,
                                        gint countdown)
{
	g_return_if_fail (self != NULL);
	recorder_control_recorder_set_pending (self, TRUE);
	g_signal_emit (self, recorder_control_recorder_signals[RECORDER_CONTROL_RECORDER_PENDING_CHANGED_SIGNAL], 0, TRUE, countdown);
}

static void
recorder_control_recorder_clear_pending (RecorderControlRecorder* self)
{
	gboolean _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_pending;
	if (!_tmp0_) {
		return;
	}
	recorder_control_recorder_set_pending (self, FALSE);
	g_signal_emit (self, recorder_control_recorder_signals[RECORDER_CONTROL_RECORDER_PENDING_CHANGED_SIGNAL], 0, FALSE, 0);
}

static void
recorder_control_recorder_cancel_pending_delay (RecorderControlRecorder* self)
{
	g_return_if_fail (self != NULL);
	if (self->priv->delay_source != ((guint) 0)) {
		g_source_remove (self->priv->delay_source);
		self->priv->delay_source = (guint) 0;
	}
	recorder_control_recorder_clear_pending (self);
}

static void
recorder_control_recorder_launch (RecorderControlRecorder* self,
                                  const gchar* output,
                                  RecorderControlCaptureMode mode,
                                  gint duration_seconds,
                                  gboolean audio_enabled,
                                  const gchar* audio_device)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (output != NULL);
	g_return_if_fail (audio_device != NULL);
	if (mode == RECORDER_CONTROL_CAPTURE_MODE_AREA) {
		recorder_control_recorder_start_area_capture (self, duration_seconds, audio_enabled, audio_device);
	} else {
		gint _tmp0_ = 0;
		gchar** _tmp1_;
		gchar** _tmp2_;
		gint _tmp2__length1;
		_tmp1_ = recorder_control_recorder_build_argv (self, output, NULL, audio_enabled, audio_device, &_tmp0_);
		_tmp2_ = _tmp1_;
		_tmp2__length1 = _tmp0_;
		recorder_control_recorder_spawn_recorder (self, _tmp2_, (gint) _tmp0_, duration_seconds);
		_tmp2_ = (_vala_array_free (_tmp2_, _tmp2__length1, (GDestroyNotify) g_free), NULL);
	}
}

static Block9Data*
block9_data_ref (Block9Data* _data9_)
{
	g_atomic_int_inc (&_data9_->_ref_count_);
	return _data9_;
}

static void
block9_data_unref (void * _userdata_)
{
	Block9Data* _data9_;
	_data9_ = (Block9Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data9_->_ref_count_)) {
		RecorderControlRecorder* self;
		self = _data9_->self;
		_g_free0 (_data9_->audio_device);
		_g_object_unref0 (self);
		g_slice_free (Block9Data, _data9_);
	}
}

static Block10Data*
block10_data_ref (Block10Data* _data10_)
{
	g_atomic_int_inc (&_data10_->_ref_count_);
	return _data10_;
}

static void
block10_data_unref (void * _userdata_)
{
	Block10Data* _data10_;
	_data10_ = (Block10Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data10_->_ref_count_)) {
		RecorderControlRecorder* self;
		self = _data10_->_data9_->self;
		_g_io_channel_unref0 (_data10_->channel);
		block9_data_unref (_data10_->_data9_);
		_data10_->_data9_ = NULL;
		g_slice_free (Block10Data, _data10_);
	}
}

static gchar*
string_strip (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strstrip (_result_);
	result = _result_;
	return result;
}

static void
___lambda21_ (Block10Data* _data10_,
              GPid child_pid,
              gint status)
{
	Block9Data* _data9_;
	RecorderControlRecorder* self;
	gchar* geometry = NULL;
	gchar* _tmp0_;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	gint _tmp9_ = 0;
	gchar** _tmp10_;
	gchar** _tmp11_;
	gint _tmp11__length1;
	GError* _inner_error0_ = NULL;
	_data9_ = _data10_->_data9_;
	self = _data9_->self;
	g_spawn_close_pid (child_pid);
	if (status != 0) {
		g_signal_emit (self, recorder_control_recorder_signals[RECORDER_CONTROL_RECORDER_AREA_SELECTION_FAILED_SIGNAL], 0);
		return;
	}
	_tmp0_ = g_strdup ("");
	geometry = _tmp0_;
	{
		GIOChannel* _tmp1_;
		gchar* _tmp2_ = NULL;
		const gchar* _tmp3_;
		gchar* _tmp4_;
		_tmp1_ = _data10_->channel;
		g_io_channel_read_line (_tmp1_, &_tmp2_, NULL, NULL, &_inner_error0_);
		_g_free0 (geometry);
		geometry = _tmp2_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp3_ = geometry;
		_tmp4_ = string_strip (_tmp3_);
		_g_free0 (geometry);
		geometry = _tmp4_;
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp5_;
		const gchar* _tmp6_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp5_ = e;
		_tmp6_ = _tmp5_->message;
		g_warning ("RecorderControl.vala:245: Failed to read slurp output: %s", _tmp6_);
		g_signal_emit (self, recorder_control_recorder_signals[RECORDER_CONTROL_RECORDER_AREA_SELECTION_FAILED_SIGNAL], 0);
		_g_error_free0 (e);
		_g_free0 (geometry);
		return;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (geometry);
		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;
	}
	_tmp7_ = geometry;
	if (g_strcmp0 (_tmp7_, "") == 0) {
		g_signal_emit (self, recorder_control_recorder_signals[RECORDER_CONTROL_RECORDER_AREA_SELECTION_FAILED_SIGNAL], 0);
		_g_free0 (geometry);
		return;
	}
	_tmp8_ = geometry;
	_tmp10_ = recorder_control_recorder_build_argv (self, NULL, _tmp8_, _data9_->audio_enabled, _data9_->audio_device, &_tmp9_);
	_tmp11_ = _tmp10_;
	_tmp11__length1 = _tmp9_;
	recorder_control_recorder_spawn_recorder (self, _tmp11_, (gint) _tmp9_, _data9_->duration_seconds);
	_tmp11_ = (_vala_array_free (_tmp11_, _tmp11__length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (geometry);
}

static void
____lambda21__gchild_watch_func (GPid pid,
                                 gint wait_status,
                                 gpointer self)
{
	___lambda21_ (self, pid, wait_status);
}

static void
recorder_control_recorder_start_area_capture (RecorderControlRecorder* self,
                                              gint duration_seconds,
                                              gboolean audio_enabled,
                                              const gchar* audio_device)
{
	Block9Data* _data9_;
	gchar* _tmp0_;
	gchar* slurp = NULL;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar** slurp_argv = NULL;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gchar** _tmp5_;
	gint slurp_argv_length1;
	gint _slurp_argv_size_;
	GPid slurp_pid = 0;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (audio_device != NULL);
	_data9_ = g_slice_new0 (Block9Data);
	_data9_->_ref_count_ = 1;
	_data9_->self = g_object_ref (self);
	_data9_->duration_seconds = duration_seconds;
	_data9_->audio_enabled = audio_enabled;
	_tmp0_ = g_strdup (audio_device);
	_g_free0 (_data9_->audio_device);
	_data9_->audio_device = _tmp0_;
	_tmp1_ = g_find_program_in_path ("slurp");
	slurp = _tmp1_;
	_tmp2_ = slurp;
	if (_tmp2_ == NULL) {
		g_warning ("RecorderControl.vala:213: Unable to locate slurp — needed for area cap" \
"ture");
		g_signal_emit (self, recorder_control_recorder_signals[RECORDER_CONTROL_RECORDER_AREA_SELECTION_FAILED_SIGNAL], 0);
		_g_free0 (slurp);
		block9_data_unref (_data9_);
		_data9_ = NULL;
		return;
	}
	_tmp3_ = slurp;
	_tmp4_ = g_strdup (_tmp3_);
	_tmp5_ = g_new0 (gchar*, 2 + 1);
	_tmp5_[0] = _tmp4_;
	_tmp5_[1] = NULL;
	slurp_argv = _tmp5_;
	slurp_argv_length1 = 2;
	_slurp_argv_size_ = slurp_argv_length1;
	{
		Block10Data* _data10_;
		gint stdout_fd = 0;
		gchar** _tmp6_;
		gint _tmp6__length1;
		GPid _tmp7_ = 0;
		gint _tmp8_ = 0;
		GIOChannel* _tmp9_;
		_data10_ = g_slice_new0 (Block10Data);
		_data10_->_ref_count_ = 1;
		_data10_->_data9_ = block9_data_ref (_data9_);
		_tmp6_ = slurp_argv;
		_tmp6__length1 = slurp_argv_length1;
		g_spawn_async_with_pipes (NULL, _tmp6_, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &_tmp7_, NULL, &_tmp8_, NULL, &_inner_error0_);
		slurp_pid = _tmp7_;
		stdout_fd = _tmp8_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			block10_data_unref (_data10_);
			_data10_ = NULL;
			if (_inner_error0_->domain == G_SPAWN_ERROR) {
				goto __catch0_g_spawn_error;
			}
			slurp_argv = (_vala_array_free (slurp_argv, slurp_argv_length1, (GDestroyNotify) g_free), NULL);
			_g_free0 (slurp);
			block9_data_unref (_data9_);
			_data9_ = NULL;
			g_critical ("file %s: line %d: unexpected 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;
		}
		_tmp9_ = g_io_channel_unix_new (stdout_fd);
		_data10_->channel = _tmp9_;
		g_child_watch_add_full (G_PRIORITY_DEFAULT_IDLE, slurp_pid, ____lambda21__gchild_watch_func, block10_data_ref (_data10_), block10_data_unref);
		block10_data_unref (_data10_);
		_data10_ = NULL;
	}
	goto __finally0;
	__catch0_g_spawn_error:
	{
		GError* e = NULL;
		GError* _tmp10_;
		const gchar* _tmp11_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp10_ = e;
		_tmp11_ = _tmp10_->message;
		g_warning ("RecorderControl.vala:260: Failed to start slurp: %s", _tmp11_);
		g_signal_emit (self, recorder_control_recorder_signals[RECORDER_CONTROL_RECORDER_AREA_SELECTION_FAILED_SIGNAL], 0);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		slurp_argv = (_vala_array_free (slurp_argv, slurp_argv_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (slurp);
		block9_data_unref (_data9_);
		_data9_ = NULL;
		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;
	}
	slurp_argv = (_vala_array_free (slurp_argv, slurp_argv_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (slurp);
	block9_data_unref (_data9_);
	_data9_ = NULL;
}

static void
_vala_array_add3 (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_add4 (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_add5 (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_add6 (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_add7 (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_add8 (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_add9 (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_add10 (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_add11 (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_add12 (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 gchar**
recorder_control_recorder_build_argv (RecorderControlRecorder* self,
                                      const gchar* output,
                                      const gchar* geometry,
                                      gboolean audio_enabled,
                                      const gchar* audio_device,
                                      gint* result_length1)
{
	gchar** args = NULL;
	gchar** _tmp0_;
	gint args_length1;
	gint _args_size_;
	gchar* _tmp1_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar** _tmp13_;
	gint _tmp13__length1;
	gchar** result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (audio_device != NULL, NULL);
	_tmp0_ = g_new0 (gchar*, 0 + 1);
	args = _tmp0_;
	args_length1 = 0;
	_args_size_ = args_length1;
	_tmp1_ = g_find_program_in_path ("wf-recorder");
	_vala_array_add3 (&args, &args_length1, &_args_size_, _tmp1_);
	if (output != NULL) {
		gchar* _tmp2_;
		gchar* _tmp3_;
		_tmp2_ = g_strdup ("-o");
		_vala_array_add4 (&args, &args_length1, &_args_size_, _tmp2_);
		_tmp3_ = g_strdup (output);
		_vala_array_add5 (&args, &args_length1, &_args_size_, _tmp3_);
	} else {
		if (geometry != NULL) {
			gchar* _tmp4_;
			gchar* _tmp5_;
			_tmp4_ = g_strdup ("-g");
			_vala_array_add6 (&args, &args_length1, &_args_size_, _tmp4_);
			_tmp5_ = g_strdup (geometry);
			_vala_array_add7 (&args, &args_length1, &_args_size_, _tmp5_);
		}
	}
	_tmp6_ = g_strdup ("-f");
	_vala_array_add8 (&args, &args_length1, &_args_size_, _tmp6_);
	_tmp7_ = recorder_control_recorder_output_path (self);
	_vala_array_add9 (&args, &args_length1, &_args_size_, _tmp7_);
	if (audio_enabled) {
		gboolean _tmp8_ = FALSE;
		if (audio_device != NULL) {
			gchar* _tmp9_;
			gchar* _tmp10_;
			_tmp9_ = string_strip (audio_device);
			_tmp10_ = _tmp9_;
			_tmp8_ = g_strcmp0 (_tmp10_, "") != 0;
			_g_free0 (_tmp10_);
		} else {
			_tmp8_ = FALSE;
		}
		if (_tmp8_) {
			gchar* _tmp11_;
			_tmp11_ = g_strconcat ("-a", audio_device, NULL);
			_vala_array_add10 (&args, &args_length1, &_args_size_, _tmp11_);
		} else {
			gchar* _tmp12_;
			_tmp12_ = g_strdup ("-a");
			_vala_array_add11 (&args, &args_length1, &_args_size_, _tmp12_);
		}
	}
	_vala_array_add12 (&args, &args_length1, &_args_size_, NULL);
	_tmp13_ = args;
	_tmp13__length1 = args_length1;
	if (result_length1) {
		*result_length1 = _tmp13__length1;
	}
	result = _tmp13_;
	return result;
}

static gchar*
recorder_control_recorder_output_path (RecorderControlRecorder* self)
{
	gchar* timestamp = NULL;
	GDateTime* _tmp0_;
	GDateTime* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_date_time_new_now_local ();
	_tmp1_ = _tmp0_;
	_tmp2_ = g_date_time_format (_tmp1_, "%Y-%m-%d-%H-%M-%S");
	_tmp3_ = _tmp2_;
	_g_date_time_unref0 (_tmp1_);
	timestamp = _tmp3_;
	_tmp4_ = self->priv->save_path;
	_tmp5_ = g_strdup_printf ("recording_%s.mp4", timestamp);
	_tmp6_ = _tmp5_;
	_tmp7_ = g_build_filename (_tmp4_, _tmp6_, NULL);
	_tmp8_ = _tmp7_;
	_g_free0 (_tmp6_);
	result = _tmp8_;
	_g_free0 (timestamp);
	return result;
}

static void
___lambda22_ (RecorderControlRecorder* self,
              GPid child_pid,
              gint status)
{
	g_spawn_close_pid (child_pid);
	if (self->priv->pid == child_pid) {
		self->priv->pid = (GPid) 0;
		recorder_control_recorder_cancel_duration_timers (self);
		recorder_control_recorder_clear_pending (self);
		recorder_control_recorder_set_recording_state (self, FALSE);
	}
}

static void
____lambda22__gchild_watch_func (GPid pid,
                                 gint wait_status,
                                 gpointer self)
{
	___lambda22_ ((RecorderControlRecorder*) self, pid, wait_status);
}

static void
recorder_control_recorder_spawn_recorder (RecorderControlRecorder* self,
                                          gchar** argv,
                                          gint argv_length1,
                                          gint duration_seconds)
{
	const gchar* _tmp0_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = argv[0];
	if (_tmp0_ == NULL) {
		g_warning ("RecorderControl.vala:319: Unable to locate wf-recorder");
		return;
	}
	{
		GPid _tmp1_ = 0;
		g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &_tmp1_, &_inner_error0_);
		self->priv->pid = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_SPAWN_ERROR) {
				goto __catch0_g_spawn_error;
			}
			g_critical ("file %s: line %d: unexpected 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_child_watch_add_full (G_PRIORITY_DEFAULT_IDLE, self->priv->pid, ____lambda22__gchild_watch_func, g_object_ref (self), g_object_unref);
		recorder_control_recorder_set_recording_state (self, TRUE);
		if (duration_seconds > 0) {
			recorder_control_recorder_schedule_duration_stop (self, duration_seconds);
		}
	}
	goto __finally0;
	__catch0_g_spawn_error:
	{
		GError* e = NULL;
		GError* _tmp2_;
		const gchar* _tmp3_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		self->priv->pid = (GPid) 0;
		recorder_control_recorder_set_recording_state (self, FALSE);
		_tmp2_ = e;
		_tmp3_ = _tmp2_->message;
		g_warning ("RecorderControl.vala:350: Failed to start wf-recorder: %s", _tmp3_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		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;
	}
}

static gboolean
___lambda23_ (RecorderControlRecorder* self)
{
	gboolean result;
	self->priv->duration_source = (guint) 0;
	recorder_control_recorder_start_duration_tick (self, RECORDER_CONTROL_RECORDER_COUNTDOWN_WINDOW);
	result = FALSE;
	return result;
}

static gboolean
____lambda23__gsource_func (gpointer self)
{
	gboolean result;
	result = ___lambda23_ ((RecorderControlRecorder*) self);
	return result;
}

static void
recorder_control_recorder_schedule_duration_stop (RecorderControlRecorder* self,
                                                  gint duration_seconds)
{
	gint silent_wait = 0;
	g_return_if_fail (self != NULL);
	silent_wait = duration_seconds - RECORDER_CONTROL_RECORDER_COUNTDOWN_WINDOW;
	if (silent_wait > 0) {
		self->priv->duration_source = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) silent_wait, ____lambda23__gsource_func, g_object_ref (self), g_object_unref);
	} else {
		recorder_control_recorder_start_duration_tick (self, duration_seconds);
	}
}

static Block11Data*
block11_data_ref (Block11Data* _data11_)
{
	g_atomic_int_inc (&_data11_->_ref_count_);
	return _data11_;
}

static void
block11_data_unref (void * _userdata_)
{
	Block11Data* _data11_;
	_data11_ = (Block11Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data11_->_ref_count_)) {
		RecorderControlRecorder* self;
		self = _data11_->self;
		_g_object_unref0 (self);
		g_slice_free (Block11Data, _data11_);
	}
}

static gboolean
__lambda24_ (Block11Data* _data11_)
{
	RecorderControlRecorder* self;
	gint _tmp0_;
	gboolean result;
	self = _data11_->self;
	_tmp0_ = _data11_->remaining;
	_data11_->remaining = _tmp0_ - 1;
	if (_data11_->remaining <= 0) {
		self->priv->duration_tick_source = (guint) 0;
		recorder_control_recorder_clear_pending (self);
		recorder_control_recorder_stop (self);
		result = FALSE;
		return result;
	}
	recorder_control_recorder_show_pending (self, _data11_->remaining);
	result = TRUE;
	return result;
}

static gboolean
___lambda24__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda24_ (self);
	return result;
}

static void
recorder_control_recorder_start_duration_tick (RecorderControlRecorder* self,
                                               gint initial_countdown)
{
	Block11Data* _data11_;
	g_return_if_fail (self != NULL);
	_data11_ = g_slice_new0 (Block11Data);
	_data11_->_ref_count_ = 1;
	_data11_->self = g_object_ref (self);
	_data11_->remaining = initial_countdown;
	recorder_control_recorder_show_pending (self, _data11_->remaining);
	self->priv->duration_tick_source = g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 1000, ___lambda24__gsource_func, block11_data_ref (_data11_), block11_data_unref);
	block11_data_unref (_data11_);
	_data11_ = NULL;
}

static void
recorder_control_recorder_cancel_duration_timers (RecorderControlRecorder* self)
{
	g_return_if_fail (self != NULL);
	if (self->priv->duration_source != ((guint) 0)) {
		g_source_remove (self->priv->duration_source);
		self->priv->duration_source = (guint) 0;
	}
	if (self->priv->duration_tick_source != ((guint) 0)) {
		g_source_remove (self->priv->duration_tick_source);
		self->priv->duration_tick_source = (guint) 0;
	}
}

static void
recorder_control_recorder_cancel_all_timers (RecorderControlRecorder* self)
{
	g_return_if_fail (self != NULL);
	recorder_control_recorder_cancel_pending_delay (self);
	recorder_control_recorder_cancel_duration_timers (self);
}

static void
recorder_control_recorder_set_recording_state (RecorderControlRecorder* self,
                                               gboolean value)
{
	gboolean _tmp0_;
	gboolean _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_recording;
	if (_tmp0_ == value) {
		return;
	}
	recorder_control_recorder_set_recording (self, value);
	_tmp1_ = self->priv->_recording;
	g_signal_emit (self, recorder_control_recorder_signals[RECORDER_CONTROL_RECORDER_RECORDING_CHANGED_SIGNAL], 0, _tmp1_);
}

RecorderControlRecorder*
recorder_control_recorder_construct (GType object_type)
{
	RecorderControlRecorder * self = NULL;
	self = (RecorderControlRecorder*) g_object_new (object_type, NULL);
	return self;
}

RecorderControlRecorder*
recorder_control_recorder_new (void)
{
	return recorder_control_recorder_construct (RECORDER_CONTROL_TYPE_RECORDER);
}

gboolean
recorder_control_recorder_get_recording (RecorderControlRecorder* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_recording;
	return result;
}

static void
recorder_control_recorder_set_recording (RecorderControlRecorder* self,
                                         gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = recorder_control_recorder_get_recording (self);
	if (old_value != value) {
		self->priv->_recording = value;
		g_object_notify_by_pspec ((GObject *) self, recorder_control_recorder_properties[RECORDER_CONTROL_RECORDER_RECORDING_PROPERTY]);
	}
}

gboolean
recorder_control_recorder_get_pending (RecorderControlRecorder* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_pending;
	return result;
}

static void
recorder_control_recorder_set_pending (RecorderControlRecorder* self,
                                       gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = recorder_control_recorder_get_pending (self);
	if (old_value != value) {
		self->priv->_pending = value;
		g_object_notify_by_pspec ((GObject *) self, recorder_control_recorder_properties[RECORDER_CONTROL_RECORDER_PENDING_PROPERTY]);
	}
}

static void
g_cclosure_user_marshal_VOID__BOOLEAN_INT (GClosure * closure,
                                           GValue * return_value,
                                           guint n_param_values,
                                           const GValue * param_values,
                                           gpointer invocation_hint,
                                           gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__BOOLEAN_INT) (gpointer data1, gboolean arg_1, gint arg_2, gpointer data2);
	register GMarshalFunc_VOID__BOOLEAN_INT 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_INT) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_boolean (param_values + 1), g_value_get_int (param_values + 2), data2);
}

static void
recorder_control_recorder_class_init (RecorderControlRecorderClass * klass,
                                      gpointer klass_data)
{
	recorder_control_recorder_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &RecorderControlRecorder_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_recorder_control_recorder_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_recorder_control_recorder_set_property;
	G_OBJECT_CLASS (klass)->finalize = recorder_control_recorder_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), RECORDER_CONTROL_RECORDER_RECORDING_PROPERTY, recorder_control_recorder_properties[RECORDER_CONTROL_RECORDER_RECORDING_PROPERTY] = g_param_spec_boolean ("recording", "recording", "recording", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), RECORDER_CONTROL_RECORDER_PENDING_PROPERTY, recorder_control_recorder_properties[RECORDER_CONTROL_RECORDER_PENDING_PROPERTY] = g_param_spec_boolean ("pending", "pending", "pending", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	recorder_control_recorder_signals[RECORDER_CONTROL_RECORDER_RECORDING_CHANGED_SIGNAL] = g_signal_new ("recording-changed", RECORDER_CONTROL_TYPE_RECORDER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
	recorder_control_recorder_signals[RECORDER_CONTROL_RECORDER_PENDING_CHANGED_SIGNAL] = g_signal_new ("pending-changed", RECORDER_CONTROL_TYPE_RECORDER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__BOOLEAN_INT, G_TYPE_NONE, 2, G_TYPE_BOOLEAN, G_TYPE_INT);
	recorder_control_recorder_signals[RECORDER_CONTROL_RECORDER_AREA_SELECTION_FAILED_SIGNAL] = g_signal_new ("area-selection-failed", RECORDER_CONTROL_TYPE_RECORDER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
recorder_control_recorder_instance_init (RecorderControlRecorder * self,
                                         gpointer klass)
{
	gchar* _tmp0_;
	self->priv = recorder_control_recorder_get_instance_private (self);
	self->priv->_recording = FALSE;
	self->priv->_pending = FALSE;
	_tmp0_ = g_strdup ("");
	self->priv->save_path = _tmp0_;
	self->priv->pid = (GPid) 0;
	self->priv->delay_source = (guint) 0;
	self->priv->duration_source = (guint) 0;
	self->priv->duration_tick_source = (guint) 0;
}

static void
recorder_control_recorder_finalize (GObject * obj)
{
	RecorderControlRecorder * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RECORDER_CONTROL_TYPE_RECORDER, RecorderControlRecorder);
	_g_free0 (self->priv->save_path);
	G_OBJECT_CLASS (recorder_control_recorder_parent_class)->finalize (obj);
}

GType
recorder_control_recorder_get_type (void)
{
	return recorder_control_recorder_type_id;
}

GType
recorder_control_recorder_register_type (GTypeModule * module)
{
	static const GTypeInfo g_define_type_info = { sizeof (RecorderControlRecorderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) recorder_control_recorder_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RecorderControlRecorder), 0, (GInstanceInitFunc) recorder_control_recorder_instance_init, NULL };
	recorder_control_recorder_type_id = g_type_module_register_type (module, G_TYPE_OBJECT, "RecorderControlRecorder", &g_define_type_info, 0);
	RecorderControlRecorder_private_offset = sizeof (RecorderControlRecorderPrivate);
	return recorder_control_recorder_type_id;
}

static void
_vala_recorder_control_recorder_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec)
{
	RecorderControlRecorder * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, RECORDER_CONTROL_TYPE_RECORDER, RecorderControlRecorder);
	switch (property_id) {
		case RECORDER_CONTROL_RECORDER_RECORDING_PROPERTY:
		g_value_set_boolean (value, recorder_control_recorder_get_recording (self));
		break;
		case RECORDER_CONTROL_RECORDER_PENDING_PROPERTY:
		g_value_set_boolean (value, recorder_control_recorder_get_pending (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_recorder_control_recorder_set_property (GObject * object,
                                              guint property_id,
                                              const GValue * value,
                                              GParamSpec * pspec)
{
	RecorderControlRecorder * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, RECORDER_CONTROL_TYPE_RECORDER, RecorderControlRecorder);
	switch (property_id) {
		case RECORDER_CONTROL_RECORDER_RECORDING_PROPERTY:
		recorder_control_recorder_set_recording (self, g_value_get_boolean (value));
		break;
		case RECORDER_CONTROL_RECORDER_PENDING_PROPERTY:
		recorder_control_recorder_set_pending (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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);
}

