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

/*
 * BrightnessController
 * This file is part of budgie-extras
 *
 * Author: Serdar ŞEN github.com/serdarsen
 *
 * Copyright © 2018 Ubuntu Budgie Developers
 *
 * 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
 * (at your option) any later version.
*/

#include "brightnesscontroller.h"
#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include <config.h>
#include <gobject/gvaluecollector.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 _brightness_controller_helpers_subprocess_helper_unref0(var) ((var == NULL) ? NULL : (var = (brightness_controller_helpers_subprocess_helper_unref (var), NULL)))
#define _brightness_controller_helpers_config_helper_unref0(var) ((var == NULL) ? NULL : (var = (brightness_controller_helpers_config_helper_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _brightness_controller_models_flame_unref0(var) ((var == NULL) ? NULL : (var = (brightness_controller_models_flame_unref (var), NULL)))
typedef struct _Block6Data Block6Data;
#define _brightness_controller_helpers_light_helper_unref0(var) ((var == NULL) ? NULL : (var = (brightness_controller_helpers_light_helper_unref (var), NULL)))
typedef struct _BrightnessControllerHelpersParamSpecLightHelper BrightnessControllerHelpersParamSpecLightHelper;

struct _BrightnessControllerHelpersLightHelperPrivate {
	gboolean _IsAvailable;
	BrightnessControllerHelpersSubprocessHelper* subprocessHelper;
	BrightnessControllerHelpersConfigHelper* configHelper;
};

struct _Block6Data {
	int _ref_count_;
	BrightnessControllerHelpersLightHelper* self;
	gchar** data;
	gint data_length1;
	gint _data_size_;
};

struct _BrightnessControllerHelpersParamSpecLightHelper {
	GParamSpec parent_instance;
};

static gint BrightnessControllerHelpersLightHelper_private_offset;
static gpointer brightness_controller_helpers_light_helper_parent_class = NULL;
static GType brightness_controller_helpers_light_helper_type_id = 0;

static void _brightness_controller_models_flame_unref0_ (gpointer var);
static inline void _g_list_free__brightness_controller_models_flame_unref0_ (GList* self);
static void brightness_controller_helpers_light_helper_Load (BrightnessControllerHelpersLightHelper* self);
static void _vala_array_add3 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static gdouble brightness_controller_helpers_light_helper_GetCurrentBrightnessPercent (BrightnessControllerHelpersLightHelper* self);
static void __lambda7_ (BrightnessControllerHelpersLightHelper* self,
                 BrightnessControllerModelsLight* light);
static void ___lambda7__gfunc (gconstpointer data,
                        gpointer self);
static Block6Data* block6_data_ref (Block6Data* _data6_);
static void block6_data_unref (void * _userdata_);
static void __lambda6_ (Block6Data* _data6_,
                 BrightnessControllerModelsLight* light);
static void _vala_array_add4 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static void ___lambda6__gfunc (gconstpointer data,
                        gpointer self);
static void brightness_controller_helpers_light_helper_finalize (BrightnessControllerHelpersLightHelper * 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
brightness_controller_helpers_light_helper_get_instance_private (BrightnessControllerHelpersLightHelper* self)
{
	return G_STRUCT_MEMBER_P (self, BrightnessControllerHelpersLightHelper_private_offset);
}

static void
_brightness_controller_models_flame_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (brightness_controller_models_flame_unref (var), NULL));
}

static inline void
_g_list_free__brightness_controller_models_flame_unref0_ (GList* self)
{
	g_list_free_full (self, (GDestroyNotify) _brightness_controller_models_flame_unref0_);
}

BrightnessControllerHelpersLightHelper*
brightness_controller_helpers_light_helper_construct (GType object_type)
{
	BrightnessControllerHelpersLightHelper* self = NULL;
	BrightnessControllerHelpersSubprocessHelper* _tmp0_;
	BrightnessControllerHelpersConfigHelper* _tmp1_;
	self = (BrightnessControllerHelpersLightHelper*) g_type_create_instance (object_type);
	_tmp0_ = brightness_controller_helpers_subprocess_helper_new ();
	_brightness_controller_helpers_subprocess_helper_unref0 (self->priv->subprocessHelper);
	self->priv->subprocessHelper = _tmp0_;
	_tmp1_ = brightness_controller_helpers_config_helper_new ("budgie-advanced-brightness-controller", "light");
	_brightness_controller_helpers_config_helper_unref0 (self->priv->configHelper);
	self->priv->configHelper = _tmp1_;
	brightness_controller_helpers_light_helper_Load (self);
	return self;
}

BrightnessControllerHelpersLightHelper*
brightness_controller_helpers_light_helper_new (void)
{
	return brightness_controller_helpers_light_helper_construct (BRIGHTNESS_CONTROLLER_HELPERS_TYPE_LIGHT_HELPER);
}

static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

gdouble
brightness_controller_helpers_light_helper_GetBrightness (BrightnessControllerHelpersLightHelper* self,
                                                          const gchar* name)
{
	BrightnessControllerHelpersSubprocessHelper* _tmp0_;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar** _tmp4_;
	gchar** _tmp5_;
	gint _tmp5__length1;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gdouble _tmp8_;
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	g_return_val_if_fail (name != NULL, -1.0);
	_tmp0_ = self->priv->subprocessHelper;
	_tmp1_ = g_strdup ("cat");
	_tmp2_ = string_to_string (name);
	_tmp3_ = g_strconcat ("/sys/class/backlight/", _tmp2_, "/brightness", NULL);
	_tmp4_ = g_new0 (gchar*, 2 + 1);
	_tmp4_[0] = _tmp1_;
	_tmp4_[1] = _tmp3_;
	_tmp5_ = _tmp4_;
	_tmp5__length1 = 2;
	_tmp6_ = brightness_controller_helpers_subprocess_helper_RunAndGetResult (_tmp0_, _tmp5_, (gint) 2);
	_tmp7_ = _tmp6_;
	_tmp8_ = g_ascii_strtod (_tmp7_, NULL);
	_g_free0 (_tmp7_);
	_tmp5_ = (_vala_array_free (_tmp5_, _tmp5__length1, (GDestroyNotify) g_free), NULL);
	result = _tmp8_;
	return result;
}

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 gboolean
string_to_bool (const gchar* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	if (g_strcmp0 (self, "true") == 0) {
		result = TRUE;
		return result;
	} else {
		result = FALSE;
		return result;
	}
}

static gpointer
_brightness_controller_models_flame_ref0 (gpointer self)
{
	return self ? brightness_controller_models_flame_ref (self) : NULL;
}

static gchar*
bool_to_string (gboolean self)
{
	gchar* result;
	if (self) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup ("true");
		result = _tmp0_;
		return result;
	} else {
		gchar* _tmp1_;
		_tmp1_ = g_strdup ("false");
		result = _tmp1_;
		return result;
	}
}

static void
brightness_controller_helpers_light_helper_Load (BrightnessControllerHelpersLightHelper* self)
{
	gchar* helperCheck = NULL;
	BrightnessControllerHelpersSubprocessHelper* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar** _tmp3_;
	gchar** _tmp4_;
	gint _tmp4__length1;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar** retrivedLightNames = NULL;
	gchar** _tmp7_;
	gint retrivedLightNames_length1;
	gint _retrivedLightNames_size_;
	gchar** lightObjects = NULL;
	BrightnessControllerHelpersConfigHelper* _tmp8_;
	gint _tmp9_ = 0;
	gchar** _tmp10_;
	gint lightObjects_length1;
	gint _lightObjects_size_;
	gchar** _tmp11_;
	gint _tmp11__length1;
	gchar* lightsString = NULL;
	BrightnessControllerHelpersSubprocessHelper* _tmp46_;
	gchar* _tmp47_;
	gchar* _tmp48_;
	gchar** _tmp49_;
	gchar** _tmp50_;
	gint _tmp50__length1;
	gchar* _tmp51_;
	gchar* _tmp52_;
	const gchar* _tmp53_;
	const gchar* _tmp54_;
	gchar* _tmp55_;
	const gchar* _tmp56_;
	gchar** lightNames = NULL;
	const gchar* _tmp66_;
	gchar** _tmp67_;
	gchar** _tmp68_;
	gint lightNames_length1;
	gint _lightNames_size_;
	gint lightNamesCount = 0;
	gchar** _tmp69_;
	gint _tmp69__length1;
	GList* _tmp100_;
	g_return_if_fail (self != NULL);
	(self->list == NULL) ? NULL : (self->list = (_g_list_free__brightness_controller_models_flame_unref0_ (self->list), NULL));
	self->list = NULL;
	_tmp0_ = self->priv->subprocessHelper;
	_tmp1_ = g_strdup (PACKAGE_BINDIR "/budgie-brightness-helper");
	_tmp2_ = g_strdup ("--help");
	_tmp3_ = g_new0 (gchar*, 2 + 1);
	_tmp3_[0] = _tmp1_;
	_tmp3_[1] = _tmp2_;
	_tmp4_ = _tmp3_;
	_tmp4__length1 = 2;
	_tmp5_ = brightness_controller_helpers_subprocess_helper_RunAndGetResult (_tmp0_, _tmp4_, (gint) 2);
	_tmp6_ = _tmp5_;
	_tmp4_ = (_vala_array_free (_tmp4_, _tmp4__length1, (GDestroyNotify) g_free), NULL);
	helperCheck = _tmp6_;
	_tmp7_ = g_new0 (gchar*, 0 + 1);
	retrivedLightNames = _tmp7_;
	retrivedLightNames_length1 = 0;
	_retrivedLightNames_size_ = retrivedLightNames_length1;
	_tmp8_ = self->priv->configHelper;
	_tmp10_ = brightness_controller_helpers_config_helper_Read (_tmp8_, &_tmp9_);
	lightObjects = _tmp10_;
	lightObjects_length1 = _tmp9_;
	_lightObjects_size_ = lightObjects_length1;
	_tmp11_ = lightObjects;
	_tmp11__length1 = lightObjects_length1;
	{
		gchar** obj_collection = NULL;
		gint obj_collection_length1 = 0;
		gint _obj_collection_size_ = 0;
		gint obj_it = 0;
		obj_collection = _tmp11_;
		obj_collection_length1 = _tmp11__length1;
		for (obj_it = 0; obj_it < obj_collection_length1; obj_it = obj_it + 1) {
			gchar* _tmp12_;
			gchar* obj = NULL;
			_tmp12_ = g_strdup (obj_collection[obj_it]);
			obj = _tmp12_;
			{
				gchar** properties = NULL;
				const gchar* _tmp13_;
				gchar** _tmp14_;
				gchar** _tmp15_;
				gint properties_length1;
				gint _properties_size_;
				gchar** _tmp16_;
				gint _tmp16__length1;
				_tmp13_ = obj;
				_tmp15_ = _tmp14_ = g_strsplit (_tmp13_, " ", 0);
				properties = _tmp15_;
				properties_length1 = _vala_array_length (_tmp14_);
				_properties_size_ = properties_length1;
				_tmp16_ = properties;
				_tmp16__length1 = properties_length1;
				if (_tmp16__length1 > 3) {
					BrightnessControllerModelsLight* light = NULL;
					BrightnessControllerModelsLight* _tmp17_;
					BrightnessControllerModelsLight* _tmp18_;
					gchar** _tmp19_;
					gint _tmp19__length1;
					const gchar* _tmp20_;
					BrightnessControllerModelsLight* _tmp21_;
					const gchar* _tmp22_;
					const gchar* _tmp23_;
					gchar* _tmp24_;
					BrightnessControllerModelsLight* _tmp25_;
					gchar** _tmp26_;
					gint _tmp26__length1;
					const gchar* _tmp27_;
					BrightnessControllerModelsLight* _tmp28_;
					BrightnessControllerModelsLight* _tmp29_;
					const gchar* _tmp30_;
					const gchar* _tmp31_;
					BrightnessControllerModelsLight* _tmp32_;
					gchar** _tmp33_;
					gint _tmp33__length1;
					const gchar* _tmp34_;
					BrightnessControllerModelsLight* _tmp35_;
					const gchar* _tmp36_;
					const gchar* _tmp37_;
					BrightnessControllerModelsLight* _tmp38_;
					gdouble _tmp39_;
					gdouble _tmp40_;
					BrightnessControllerModelsLight* _tmp41_;
					gdouble _tmp42_;
					gdouble _tmp43_;
					BrightnessControllerModelsLight* _tmp44_;
					BrightnessControllerModelsLight* _tmp45_;
					_tmp17_ = brightness_controller_models_light_new ();
					light = _tmp17_;
					_tmp18_ = light;
					_tmp19_ = properties;
					_tmp19__length1 = properties_length1;
					_tmp20_ = _tmp19_[0];
					brightness_controller_models_flame_set_Name ((BrightnessControllerModelsFlame*) _tmp18_, _tmp20_);
					_tmp21_ = light;
					_tmp22_ = brightness_controller_models_flame_get_Name ((BrightnessControllerModelsFlame*) _tmp21_);
					_tmp23_ = _tmp22_;
					_tmp24_ = g_strdup (_tmp23_);
					_vala_array_add3 (&retrivedLightNames, &retrivedLightNames_length1, &_retrivedLightNames_size_, _tmp24_);
					_tmp25_ = light;
					_tmp26_ = properties;
					_tmp26__length1 = properties_length1;
					_tmp27_ = _tmp26_[1];
					brightness_controller_models_flame_set_MaxBrightness ((BrightnessControllerModelsFlame*) _tmp25_, g_ascii_strtod (_tmp27_, NULL));
					_tmp28_ = light;
					_tmp29_ = light;
					_tmp30_ = brightness_controller_models_flame_get_Name ((BrightnessControllerModelsFlame*) _tmp29_);
					_tmp31_ = _tmp30_;
					brightness_controller_models_flame_set_Brightness ((BrightnessControllerModelsFlame*) _tmp28_, brightness_controller_helpers_light_helper_GetBrightness (self, _tmp31_));
					_tmp32_ = light;
					_tmp33_ = properties;
					_tmp33__length1 = properties_length1;
					_tmp34_ = _tmp33_[3];
					brightness_controller_models_flame_set_IsActive ((BrightnessControllerModelsFlame*) _tmp32_, string_to_bool (_tmp34_));
					_tmp35_ = light;
					_tmp36_ = brightness_controller_models_flame_get_Name ((BrightnessControllerModelsFlame*) _tmp35_);
					_tmp37_ = _tmp36_;
					_tmp38_ = light;
					_tmp39_ = brightness_controller_models_flame_get_MaxBrightness ((BrightnessControllerModelsFlame*) _tmp38_);
					_tmp40_ = _tmp39_;
					_tmp41_ = light;
					_tmp42_ = brightness_controller_models_flame_get_Brightness ((BrightnessControllerModelsFlame*) _tmp41_);
					_tmp43_ = _tmp42_;
					g_debug ("LightHelper.vala:69: LightHelper.Load config: name=%s MaxBrightness=%." \
"1f LiveBrightness=%.1f", _tmp37_, _tmp40_, _tmp43_);
					_tmp44_ = light;
					_tmp45_ = _brightness_controller_models_flame_ref0 (_tmp44_);
					self->list = g_list_append (self->list, _tmp45_);
					_brightness_controller_models_flame_unref0 (light);
				}
				properties = (_vala_array_free (properties, properties_length1, (GDestroyNotify) g_free), NULL);
				_g_free0 (obj);
			}
		}
	}
	_tmp46_ = self->priv->subprocessHelper;
	_tmp47_ = g_strdup ("ls");
	_tmp48_ = g_strdup ("/sys/class/backlight");
	_tmp49_ = g_new0 (gchar*, 2 + 1);
	_tmp49_[0] = _tmp47_;
	_tmp49_[1] = _tmp48_;
	_tmp50_ = _tmp49_;
	_tmp50__length1 = 2;
	_tmp51_ = brightness_controller_helpers_subprocess_helper_RunAndGetResult (_tmp46_, _tmp50_, (gint) 2);
	_tmp52_ = _tmp51_;
	_tmp50_ = (_vala_array_free (_tmp50_, _tmp50__length1, (GDestroyNotify) g_free), NULL);
	lightsString = _tmp52_;
	_tmp53_ = lightsString;
	_tmp54_ = g_strstrip (_tmp53_);
	_tmp55_ = g_strdup (_tmp54_);
	_g_free0 (lightsString);
	lightsString = _tmp55_;
	_tmp56_ = lightsString;
	if (g_strcmp0 (_tmp56_, "") == 0) {
		const gchar* _tmp57_;
		_tmp57_ = helperCheck;
		if (g_strcmp0 (_tmp57_, "") != 0) {
			GList* _tmp58_;
			_tmp58_ = self->list;
			if (g_list_length (_tmp58_) == ((guint) 0)) {
				BrightnessControllerModelsLight* light = NULL;
				BrightnessControllerModelsLight* _tmp59_;
				BrightnessControllerModelsLight* _tmp60_;
				BrightnessControllerModelsLight* _tmp61_;
				BrightnessControllerModelsLight* _tmp62_;
				BrightnessControllerModelsLight* _tmp63_;
				BrightnessControllerModelsLight* _tmp64_;
				BrightnessControllerModelsLight* _tmp65_;
				_tmp59_ = brightness_controller_models_light_new ();
				light = _tmp59_;
				_tmp60_ = light;
				brightness_controller_models_flame_set_Name ((BrightnessControllerModelsFlame*) _tmp60_, "backlight");
				_tmp61_ = light;
				brightness_controller_models_flame_set_MaxBrightness ((BrightnessControllerModelsFlame*) _tmp61_, (gdouble) 100);
				_tmp62_ = light;
				brightness_controller_models_flame_set_Brightness ((BrightnessControllerModelsFlame*) _tmp62_, brightness_controller_helpers_light_helper_GetCurrentBrightnessPercent (self));
				_tmp63_ = light;
				brightness_controller_models_flame_set_IsActive ((BrightnessControllerModelsFlame*) _tmp63_, TRUE);
				_tmp64_ = light;
				_tmp65_ = _brightness_controller_models_flame_ref0 (_tmp64_);
				self->list = g_list_append (self->list, _tmp65_);
				_brightness_controller_models_flame_unref0 (light);
			}
			brightness_controller_helpers_light_helper_set_IsAvailable (self, TRUE);
		} else {
			brightness_controller_helpers_light_helper_set_IsAvailable (self, FALSE);
		}
		_g_free0 (lightsString);
		lightObjects = (_vala_array_free (lightObjects, lightObjects_length1, (GDestroyNotify) g_free), NULL);
		retrivedLightNames = (_vala_array_free (retrivedLightNames, retrivedLightNames_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (helperCheck);
		return;
	}
	_tmp66_ = lightsString;
	_tmp68_ = _tmp67_ = g_strsplit (_tmp66_, "\n", 0);
	lightNames = _tmp68_;
	lightNames_length1 = _vala_array_length (_tmp67_);
	_lightNames_size_ = lightNames_length1;
	lightNamesCount = 0;
	_tmp69_ = lightNames;
	_tmp69__length1 = lightNames_length1;
	{
		gchar** name_collection = NULL;
		gint name_collection_length1 = 0;
		gint _name_collection_size_ = 0;
		gint name_it = 0;
		name_collection = _tmp69_;
		name_collection_length1 = _tmp69__length1;
		for (name_it = 0; name_it < name_collection_length1; name_it = name_it + 1) {
			gchar* _tmp70_;
			gchar* name = NULL;
			_tmp70_ = g_strdup (name_collection[name_it]);
			name = _tmp70_;
			{
				const gchar* _tmp71_;
				const gchar* _tmp72_;
				gchar* _tmp73_;
				gboolean _tmp74_ = FALSE;
				const gchar* _tmp75_;
				_tmp71_ = name;
				_tmp72_ = g_strstrip (_tmp71_);
				_tmp73_ = g_strdup (_tmp72_);
				_g_free0 (name);
				name = _tmp73_;
				_tmp75_ = name;
				if (g_strcmp0 (_tmp75_, "") != 0) {
					gchar** _tmp76_;
					gint _tmp76__length1;
					const gchar* _tmp77_;
					_tmp76_ = retrivedLightNames;
					_tmp76__length1 = retrivedLightNames_length1;
					_tmp77_ = name;
					_tmp74_ = !g_strv_contains (_tmp76_, _tmp77_);
				} else {
					_tmp74_ = FALSE;
				}
				if (_tmp74_) {
					BrightnessControllerModelsLight* light = NULL;
					BrightnessControllerModelsLight* _tmp78_;
					BrightnessControllerModelsLight* _tmp79_;
					const gchar* _tmp80_;
					BrightnessControllerModelsLight* _tmp81_;
					BrightnessControllerModelsLight* _tmp82_;
					BrightnessControllerModelsLight* _tmp85_;
					BrightnessControllerModelsLight* _tmp86_;
					BrightnessControllerModelsLight* _tmp87_;
					const gchar* _tmp88_;
					const gchar* _tmp89_;
					BrightnessControllerModelsLight* _tmp90_;
					gchar* _tmp91_;
					gchar* _tmp92_;
					gchar* _tmp93_;
					BrightnessControllerModelsLight* _tmp94_;
					gboolean _tmp95_;
					gboolean _tmp96_;
					gchar* _tmp97_;
					gchar* _tmp98_;
					gint _tmp99_;
					_tmp78_ = brightness_controller_models_light_new ();
					light = _tmp78_;
					_tmp79_ = light;
					_tmp80_ = name;
					brightness_controller_models_flame_set_Name ((BrightnessControllerModelsFlame*) _tmp79_, _tmp80_);
					_tmp81_ = light;
					brightness_controller_models_flame_set_MaxBrightness ((BrightnessControllerModelsFlame*) _tmp81_, (gdouble) 100);
					_tmp82_ = light;
					brightness_controller_models_flame_set_Brightness ((BrightnessControllerModelsFlame*) _tmp82_, brightness_controller_helpers_light_helper_GetCurrentBrightnessPercent (self));
					if (lightNamesCount == 0) {
						BrightnessControllerModelsLight* _tmp83_;
						_tmp83_ = light;
						brightness_controller_models_flame_set_IsActive ((BrightnessControllerModelsFlame*) _tmp83_, TRUE);
					} else {
						BrightnessControllerModelsLight* _tmp84_;
						_tmp84_ = light;
						brightness_controller_models_flame_set_IsActive ((BrightnessControllerModelsFlame*) _tmp84_, FALSE);
					}
					_tmp85_ = light;
					_tmp86_ = _brightness_controller_models_flame_ref0 (_tmp85_);
					self->list = g_list_append (self->list, _tmp86_);
					_tmp87_ = light;
					_tmp88_ = brightness_controller_models_flame_get_Name ((BrightnessControllerModelsFlame*) _tmp87_);
					_tmp89_ = _tmp88_;
					_tmp90_ = light;
					_tmp91_ = brightness_controller_models_light_get_MaxBrightnessText (_tmp90_);
					_tmp92_ = _tmp91_;
					_tmp93_ = _tmp92_;
					_tmp94_ = light;
					_tmp95_ = brightness_controller_models_flame_get_IsActive ((BrightnessControllerModelsFlame*) _tmp94_);
					_tmp96_ = _tmp95_;
					_tmp97_ = bool_to_string (_tmp96_);
					_tmp98_ = _tmp97_;
					g_print ("Load Lights From Device: %s, %s, %s \n", _tmp89_, _tmp93_, _tmp98_);
					_g_free0 (_tmp98_);
					_g_free0 (_tmp93_);
					_tmp99_ = lightNamesCount;
					lightNamesCount = _tmp99_ + 1;
					_brightness_controller_models_flame_unref0 (light);
				}
				_g_free0 (name);
			}
		}
	}
	_tmp100_ = self->list;
	if (g_list_length (_tmp100_) > ((guint) 0)) {
		brightness_controller_helpers_light_helper_set_IsAvailable (self, TRUE);
	} else {
		guint lightListLength = 0U;
		GList* _tmp101_;
		gchar* _tmp102_;
		gchar* _tmp103_;
		gchar* _tmp104_;
		gchar* _tmp105_;
		g_print ("is not available");
		brightness_controller_helpers_light_helper_set_IsAvailable (self, FALSE);
		_tmp101_ = self->list;
		lightListLength = g_list_length (_tmp101_);
		_tmp102_ = g_strdup_printf ("%u", lightListLength);
		_tmp103_ = _tmp102_;
		_tmp104_ = g_strconcat ("Light is not available (Number of Lights: ", _tmp103_, ")\n", NULL);
		_tmp105_ = _tmp104_;
		g_debug ("LightHelper.vala:142: %s", _tmp105_);
		_g_free0 (_tmp105_);
		_g_free0 (_tmp103_);
	}
	lightNames = (_vala_array_free (lightNames, lightNames_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (lightsString);
	lightObjects = (_vala_array_free (lightObjects, lightObjects_length1, (GDestroyNotify) g_free), NULL);
	retrivedLightNames = (_vala_array_free (retrivedLightNames, retrivedLightNames_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (helperCheck);
}

/**
        * Read the current brightness percentage by inspecting sysfs directly.
        * Falls back to 100 if unavailable.
        */
static gdouble
brightness_controller_helpers_light_helper_GetCurrentBrightnessPercent (BrightnessControllerHelpersLightHelper* self)
{
	gchar* lightsString = NULL;
	BrightnessControllerHelpersSubprocessHelper* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar** _tmp3_;
	gchar** _tmp4_;
	gint _tmp4__length1;
	gchar* _tmp5_;
	gchar* _tmp6_;
	const gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	const gchar* _tmp10_;
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	_tmp0_ = self->priv->subprocessHelper;
	_tmp1_ = g_strdup ("ls");
	_tmp2_ = g_strdup ("/sys/class/backlight");
	_tmp3_ = g_new0 (gchar*, 2 + 1);
	_tmp3_[0] = _tmp1_;
	_tmp3_[1] = _tmp2_;
	_tmp4_ = _tmp3_;
	_tmp4__length1 = 2;
	_tmp5_ = brightness_controller_helpers_subprocess_helper_RunAndGetResult (_tmp0_, _tmp4_, (gint) 2);
	_tmp6_ = _tmp5_;
	_tmp7_ = g_strstrip (_tmp6_);
	_tmp8_ = g_strdup (_tmp7_);
	_tmp9_ = _tmp8_;
	_g_free0 (_tmp6_);
	_tmp4_ = (_vala_array_free (_tmp4_, _tmp4__length1, (GDestroyNotify) g_free), NULL);
	lightsString = _tmp9_;
	_tmp10_ = lightsString;
	if (g_strcmp0 (_tmp10_, "") != 0) {
		gchar** names = NULL;
		const gchar* _tmp11_;
		gchar** _tmp12_;
		gchar** _tmp13_;
		gint names_length1;
		gint _names_size_;
		gchar** _tmp14_;
		gint _tmp14__length1;
		_tmp11_ = lightsString;
		_tmp13_ = _tmp12_ = g_strsplit (_tmp11_, "\n", 0);
		names = _tmp13_;
		names_length1 = _vala_array_length (_tmp12_);
		_names_size_ = names_length1;
		_tmp14_ = names;
		_tmp14__length1 = names_length1;
		if (_tmp14__length1 > 0) {
			gchar* name = NULL;
			gchar** _tmp15_;
			gint _tmp15__length1;
			const gchar* _tmp16_;
			const gchar* _tmp17_;
			gchar* _tmp18_;
			const gchar* _tmp19_;
			_tmp15_ = names;
			_tmp15__length1 = names_length1;
			_tmp16_ = _tmp15_[0];
			_tmp17_ = g_strstrip (_tmp16_);
			_tmp18_ = g_strdup (_tmp17_);
			name = _tmp18_;
			_tmp19_ = name;
			if (g_strcmp0 (_tmp19_, "") != 0) {
				gchar* maxStr = NULL;
				BrightnessControllerHelpersSubprocessHelper* _tmp20_;
				gchar* _tmp21_;
				const gchar* _tmp22_;
				const gchar* _tmp23_;
				gchar* _tmp24_;
				gchar** _tmp25_;
				gchar** _tmp26_;
				gint _tmp26__length1;
				gchar* _tmp27_;
				gchar* _tmp28_;
				const gchar* _tmp29_;
				gchar* _tmp30_;
				gchar* _tmp31_;
				gchar* curStr = NULL;
				BrightnessControllerHelpersSubprocessHelper* _tmp32_;
				gchar* _tmp33_;
				const gchar* _tmp34_;
				const gchar* _tmp35_;
				gchar* _tmp36_;
				gchar** _tmp37_;
				gchar** _tmp38_;
				gint _tmp38__length1;
				gchar* _tmp39_;
				gchar* _tmp40_;
				const gchar* _tmp41_;
				gchar* _tmp42_;
				gchar* _tmp43_;
				gdouble maxVal = 0.0;
				const gchar* _tmp44_;
				gdouble curVal = 0.0;
				const gchar* _tmp45_;
				_tmp20_ = self->priv->subprocessHelper;
				_tmp21_ = g_strdup ("cat");
				_tmp22_ = name;
				_tmp23_ = string_to_string (_tmp22_);
				_tmp24_ = g_strconcat ("/sys/class/backlight/", _tmp23_, "/max_brightness", NULL);
				_tmp25_ = g_new0 (gchar*, 2 + 1);
				_tmp25_[0] = _tmp21_;
				_tmp25_[1] = _tmp24_;
				_tmp26_ = _tmp25_;
				_tmp26__length1 = 2;
				_tmp27_ = brightness_controller_helpers_subprocess_helper_RunAndGetResult (_tmp20_, _tmp26_, (gint) 2);
				_tmp28_ = _tmp27_;
				_tmp29_ = g_strstrip (_tmp28_);
				_tmp30_ = g_strdup (_tmp29_);
				_tmp31_ = _tmp30_;
				_g_free0 (_tmp28_);
				_tmp26_ = (_vala_array_free (_tmp26_, _tmp26__length1, (GDestroyNotify) g_free), NULL);
				maxStr = _tmp31_;
				_tmp32_ = self->priv->subprocessHelper;
				_tmp33_ = g_strdup ("cat");
				_tmp34_ = name;
				_tmp35_ = string_to_string (_tmp34_);
				_tmp36_ = g_strconcat ("/sys/class/backlight/", _tmp35_, "/brightness", NULL);
				_tmp37_ = g_new0 (gchar*, 2 + 1);
				_tmp37_[0] = _tmp33_;
				_tmp37_[1] = _tmp36_;
				_tmp38_ = _tmp37_;
				_tmp38__length1 = 2;
				_tmp39_ = brightness_controller_helpers_subprocess_helper_RunAndGetResult (_tmp32_, _tmp38_, (gint) 2);
				_tmp40_ = _tmp39_;
				_tmp41_ = g_strstrip (_tmp40_);
				_tmp42_ = g_strdup (_tmp41_);
				_tmp43_ = _tmp42_;
				_g_free0 (_tmp40_);
				_tmp38_ = (_vala_array_free (_tmp38_, _tmp38__length1, (GDestroyNotify) g_free), NULL);
				curStr = _tmp43_;
				_tmp44_ = maxStr;
				maxVal = g_ascii_strtod (_tmp44_, NULL);
				_tmp45_ = curStr;
				curVal = g_ascii_strtod (_tmp45_, NULL);
				if (maxVal > ((gdouble) 0)) {
					result = (curVal / maxVal) * 100.0;
					_g_free0 (curStr);
					_g_free0 (maxStr);
					_g_free0 (name);
					names = (_vala_array_free (names, names_length1, (GDestroyNotify) g_free), NULL);
					_g_free0 (lightsString);
					return result;
				}
				_g_free0 (curStr);
				_g_free0 (maxStr);
			}
			_g_free0 (name);
		}
		names = (_vala_array_free (names, names_length1, (GDestroyNotify) g_free), NULL);
	}
	result = 100.0;
	_g_free0 (lightsString);
	return result;
}

/**
        * Set brightness using budgie-brightness-helper --set=PERCENT (0-100).
        * brightness_percentage is already in the 0-100 range.
        */
void
brightness_controller_helpers_light_helper_SetBrightness (BrightnessControllerHelpersLightHelper* self,
                                                          gint brightness_percentage)
{
	gint clamped = 0;
	gchar* setArg = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	BrightnessControllerHelpersSubprocessHelper* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar** _tmp7_;
	gchar** _tmp8_;
	gint _tmp8__length1;
	g_return_if_fail (self != NULL);
	clamped = CLAMP (brightness_percentage, 0, 100);
	_tmp0_ = g_strdup_printf ("%i", clamped);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_strconcat ("--set=", _tmp1_, NULL);
	_tmp3_ = _tmp2_;
	_g_free0 (_tmp1_);
	setArg = _tmp3_;
	g_debug ("LightHelper.vala:185: LightHelper.SetBrightness: brightness_percentage" \
"=%d setArg=%s", brightness_percentage, setArg);
	_tmp4_ = self->priv->subprocessHelper;
	_tmp5_ = g_strdup (PACKAGE_BINDIR "/budgie-brightness-helper");
	_tmp6_ = g_strdup (setArg);
	_tmp7_ = g_new0 (gchar*, 2 + 1);
	_tmp7_[0] = _tmp5_;
	_tmp7_[1] = _tmp6_;
	_tmp8_ = _tmp7_;
	_tmp8__length1 = 2;
	brightness_controller_helpers_subprocess_helper_Run (_tmp4_, _tmp8_, (gint) 2);
	_tmp8_ = (_vala_array_free (_tmp8_, _tmp8__length1, (GDestroyNotify) g_free), NULL);
	brightness_controller_helpers_light_helper_Save (self);
	_g_free0 (setArg);
}

static void
__lambda7_ (BrightnessControllerHelpersLightHelper* self,
            BrightnessControllerModelsLight* light)
{
	g_return_if_fail (light != NULL);
	brightness_controller_models_flame_set_IsActive ((BrightnessControllerModelsFlame*) light, FALSE);
}

static void
___lambda7__gfunc (gconstpointer data,
                   gpointer self)
{
	__lambda7_ ((BrightnessControllerHelpersLightHelper*) self, (BrightnessControllerModelsLight*) data);
}

void
brightness_controller_helpers_light_helper_SetActive (BrightnessControllerHelpersLightHelper* self,
                                                      BrightnessControllerModelsLight* light)
{
	GList* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (light != NULL);
	_tmp0_ = self->list;
	g_list_foreach (_tmp0_, ___lambda7__gfunc, self);
	brightness_controller_models_flame_set_IsActive ((BrightnessControllerModelsFlame*) light, TRUE);
	brightness_controller_helpers_light_helper_Save (self);
}

static Block6Data*
block6_data_ref (Block6Data* _data6_)
{
	g_atomic_int_inc (&_data6_->_ref_count_);
	return _data6_;
}

static void
block6_data_unref (void * _userdata_)
{
	Block6Data* _data6_;
	_data6_ = (Block6Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data6_->_ref_count_)) {
		BrightnessControllerHelpersLightHelper* self;
		self = _data6_->self;
		_data6_->data = (_vala_array_free (_data6_->data, _data6_->data_length1, (GDestroyNotify) g_free), NULL);
		_brightness_controller_helpers_light_helper_unref0 (self);
		g_slice_free (Block6Data, _data6_);
	}
}

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
__lambda6_ (Block6Data* _data6_,
            BrightnessControllerModelsLight* light)
{
	BrightnessControllerHelpersLightHelper* self;
	gchar* name = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* maxBrightness = NULL;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* brightness = NULL;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gboolean isActive = FALSE;
	gboolean _tmp7_;
	gboolean _tmp8_;
	const gchar* _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	self = _data6_->self;
	g_return_if_fail (light != NULL);
	_tmp0_ = brightness_controller_models_flame_get_Name ((BrightnessControllerModelsFlame*) light);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_strdup (_tmp1_);
	name = _tmp2_;
	_tmp3_ = brightness_controller_models_light_get_MaxBrightnessText (light);
	_tmp4_ = _tmp3_;
	maxBrightness = _tmp4_;
	_tmp5_ = brightness_controller_models_light_get_BrightnessText (light);
	_tmp6_ = _tmp5_;
	brightness = _tmp6_;
	_tmp7_ = brightness_controller_models_flame_get_IsActive ((BrightnessControllerModelsFlame*) light);
	_tmp8_ = _tmp7_;
	isActive = _tmp8_;
	_tmp9_ = string_to_string (name);
	_tmp10_ = string_to_string (maxBrightness);
	_tmp11_ = string_to_string (brightness);
	_tmp12_ = bool_to_string (isActive);
	_tmp13_ = _tmp12_;
	_tmp14_ = g_strconcat (_tmp9_, " ", _tmp10_, " ", _tmp11_, " ", _tmp13_, NULL);
	_vala_array_add4 (&_data6_->data, &_data6_->data_length1, &_data6_->_data_size_, _tmp14_);
	_g_free0 (_tmp13_);
	_g_free0 (brightness);
	_g_free0 (maxBrightness);
	_g_free0 (name);
}

static void
___lambda6__gfunc (gconstpointer data,
                   gpointer self)
{
	__lambda6_ (self, (BrightnessControllerModelsLight*) data);
}

void
brightness_controller_helpers_light_helper_Save (BrightnessControllerHelpersLightHelper* self)
{
	Block6Data* _data6_;
	gchar** _tmp0_;
	GList* _tmp1_;
	BrightnessControllerHelpersConfigHelper* _tmp2_;
	g_return_if_fail (self != NULL);
	_data6_ = g_slice_new0 (Block6Data);
	_data6_->_ref_count_ = 1;
	_data6_->self = brightness_controller_helpers_light_helper_ref (self);
	_tmp0_ = g_new0 (gchar*, 0 + 1);
	_data6_->data = _tmp0_;
	_data6_->data_length1 = 0;
	_data6_->_data_size_ = _data6_->data_length1;
	_tmp1_ = self->list;
	g_list_foreach (_tmp1_, ___lambda6__gfunc, _data6_);
	_tmp2_ = self->priv->configHelper;
	brightness_controller_helpers_config_helper_Write (_tmp2_, _data6_->data, (gint) _data6_->data_length1);
	block6_data_unref (_data6_);
	_data6_ = NULL;
}

gboolean
brightness_controller_helpers_light_helper_get_IsAvailable (BrightnessControllerHelpersLightHelper* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_IsAvailable;
	return result;
}

void
brightness_controller_helpers_light_helper_set_IsAvailable (BrightnessControllerHelpersLightHelper* self,
                                                            gboolean value)
{
	g_return_if_fail (self != NULL);
	self->priv->_IsAvailable = value;
}

static void
brightness_controller_helpers_value_light_helper_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
brightness_controller_helpers_value_light_helper_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		brightness_controller_helpers_light_helper_unref (value->data[0].v_pointer);
	}
}

static void
brightness_controller_helpers_value_light_helper_copy_value (const GValue* src_value,
                                                             GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = brightness_controller_helpers_light_helper_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
brightness_controller_helpers_value_light_helper_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
brightness_controller_helpers_value_light_helper_collect_value (GValue* value,
                                                                guint n_collect_values,
                                                                GTypeCValue* collect_values,
                                                                guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		BrightnessControllerHelpersLightHelper * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = brightness_controller_helpers_light_helper_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
brightness_controller_helpers_value_light_helper_lcopy_value (const GValue* value,
                                                              guint n_collect_values,
                                                              GTypeCValue* collect_values,
                                                              guint collect_flags)
{
	BrightnessControllerHelpersLightHelper ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = brightness_controller_helpers_light_helper_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
brightness_controller_helpers_param_spec_light_helper (const gchar* name,
                                                       const gchar* nick,
                                                       const gchar* blurb,
                                                       GType object_type,
                                                       GParamFlags flags)
{
	BrightnessControllerHelpersParamSpecLightHelper* spec;
	g_return_val_if_fail (g_type_is_a (object_type, BRIGHTNESS_CONTROLLER_HELPERS_TYPE_LIGHT_HELPER), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
brightness_controller_helpers_value_get_light_helper (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, BRIGHTNESS_CONTROLLER_HELPERS_TYPE_LIGHT_HELPER), NULL);
	return value->data[0].v_pointer;
}

void
brightness_controller_helpers_value_set_light_helper (GValue* value,
                                                      gpointer v_object)
{
	BrightnessControllerHelpersLightHelper * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, BRIGHTNESS_CONTROLLER_HELPERS_TYPE_LIGHT_HELPER));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, BRIGHTNESS_CONTROLLER_HELPERS_TYPE_LIGHT_HELPER));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		brightness_controller_helpers_light_helper_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		brightness_controller_helpers_light_helper_unref (old);
	}
}

void
brightness_controller_helpers_value_take_light_helper (GValue* value,
                                                       gpointer v_object)
{
	BrightnessControllerHelpersLightHelper * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, BRIGHTNESS_CONTROLLER_HELPERS_TYPE_LIGHT_HELPER));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, BRIGHTNESS_CONTROLLER_HELPERS_TYPE_LIGHT_HELPER));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		brightness_controller_helpers_light_helper_unref (old);
	}
}

static void
brightness_controller_helpers_light_helper_class_init (BrightnessControllerHelpersLightHelperClass * klass,
                                                       gpointer klass_data)
{
	brightness_controller_helpers_light_helper_parent_class = g_type_class_peek_parent (klass);
	((BrightnessControllerHelpersLightHelperClass *) klass)->finalize = brightness_controller_helpers_light_helper_finalize;
	g_type_class_adjust_private_offset (klass, &BrightnessControllerHelpersLightHelper_private_offset);
}

static void
brightness_controller_helpers_light_helper_instance_init (BrightnessControllerHelpersLightHelper * self,
                                                          gpointer klass)
{
	self->priv = brightness_controller_helpers_light_helper_get_instance_private (self);
	self->ref_count = 1;
}

static void
brightness_controller_helpers_light_helper_finalize (BrightnessControllerHelpersLightHelper * obj)
{
	BrightnessControllerHelpersLightHelper * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BRIGHTNESS_CONTROLLER_HELPERS_TYPE_LIGHT_HELPER, BrightnessControllerHelpersLightHelper);
	g_signal_handlers_destroy (self);
	(self->list == NULL) ? NULL : (self->list = (_g_list_free__brightness_controller_models_flame_unref0_ (self->list), NULL));
	_brightness_controller_helpers_subprocess_helper_unref0 (self->priv->subprocessHelper);
	_brightness_controller_helpers_config_helper_unref0 (self->priv->configHelper);
}

/**
    * LightHelper is a helper to work with
    * budgie-brightness-helper
    *
    */
GType
brightness_controller_helpers_light_helper_get_type (void)
{
	return brightness_controller_helpers_light_helper_type_id;
}

GType
brightness_controller_helpers_light_helper_register_type (GTypeModule * module)
{
	static const GTypeValueTable g_define_type_value_table = { brightness_controller_helpers_value_light_helper_init, brightness_controller_helpers_value_light_helper_free_value, brightness_controller_helpers_value_light_helper_copy_value, brightness_controller_helpers_value_light_helper_peek_pointer, "p", brightness_controller_helpers_value_light_helper_collect_value, "p", brightness_controller_helpers_value_light_helper_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (BrightnessControllerHelpersLightHelperClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) brightness_controller_helpers_light_helper_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BrightnessControllerHelpersLightHelper), 0, (GInstanceInitFunc) brightness_controller_helpers_light_helper_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	brightness_controller_helpers_light_helper_type_id = g_type_register_fundamental (g_type_fundamental_next (), "BrightnessControllerHelpersLightHelper", &g_define_type_info, &g_define_type_fundamental_info, 0);
	BrightnessControllerHelpersLightHelper_private_offset = sizeof (BrightnessControllerHelpersLightHelperPrivate);
	return brightness_controller_helpers_light_helper_type_id;
}

gpointer
brightness_controller_helpers_light_helper_ref (gpointer instance)
{
	BrightnessControllerHelpersLightHelper * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
brightness_controller_helpers_light_helper_unref (gpointer instance)
{
	BrightnessControllerHelpersLightHelper * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		BRIGHTNESS_CONTROLLER_HELPERS_LIGHT_HELPER_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

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

