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

/* 
 *      Copyright 2011 Julien Lavergne <gilir@ubuntu.com>
 *
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>


#define LXSESSION_TYPE_LXSESSION_ENV (lxsession_lxsession_env_get_type ())
#define LXSESSION_LXSESSION_ENV(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LXSESSION_TYPE_LXSESSION_ENV, LxsessionLxsessionEnv))
#define LXSESSION_LXSESSION_ENV_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), LXSESSION_TYPE_LXSESSION_ENV, LxsessionLxsessionEnvClass))
#define LXSESSION_IS_LXSESSION_ENV(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LXSESSION_TYPE_LXSESSION_ENV))
#define LXSESSION_IS_LXSESSION_ENV_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LXSESSION_TYPE_LXSESSION_ENV))
#define LXSESSION_LXSESSION_ENV_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), LXSESSION_TYPE_LXSESSION_ENV, LxsessionLxsessionEnvClass))

typedef struct _LxsessionLxsessionEnv LxsessionLxsessionEnv;
typedef struct _LxsessionLxsessionEnvClass LxsessionLxsessionEnvClass;
typedef struct _LxsessionLxsessionEnvPrivate LxsessionLxsessionEnvPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))

#define LXSESSION_TYPE_LXSESSION_CONFIG (lxsession_lxsession_config_get_type ())
#define LXSESSION_LXSESSION_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LXSESSION_TYPE_LXSESSION_CONFIG, LxsessionLxsessionConfig))
#define LXSESSION_LXSESSION_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), LXSESSION_TYPE_LXSESSION_CONFIG, LxsessionLxsessionConfigClass))
#define LXSESSION_IS_LXSESSION_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LXSESSION_TYPE_LXSESSION_CONFIG))
#define LXSESSION_IS_LXSESSION_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LXSESSION_TYPE_LXSESSION_CONFIG))
#define LXSESSION_LXSESSION_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), LXSESSION_TYPE_LXSESSION_CONFIG, LxsessionLxsessionConfigClass))

typedef struct _LxsessionLxsessionConfig LxsessionLxsessionConfig;
typedef struct _LxsessionLxsessionConfigClass LxsessionLxsessionConfigClass;

#define LXSESSION_TYPE_LXSESSION_CONFIG_KEY_FILE (lxsession_lxsession_config_key_file_get_type ())
#define LXSESSION_LXSESSION_CONFIG_KEY_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LXSESSION_TYPE_LXSESSION_CONFIG_KEY_FILE, LxsessionLxsessionConfigKeyFile))
#define LXSESSION_LXSESSION_CONFIG_KEY_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), LXSESSION_TYPE_LXSESSION_CONFIG_KEY_FILE, LxsessionLxsessionConfigKeyFileClass))
#define LXSESSION_IS_LXSESSION_CONFIG_KEY_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LXSESSION_TYPE_LXSESSION_CONFIG_KEY_FILE))
#define LXSESSION_IS_LXSESSION_CONFIG_KEY_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LXSESSION_TYPE_LXSESSION_CONFIG_KEY_FILE))
#define LXSESSION_LXSESSION_CONFIG_KEY_FILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), LXSESSION_TYPE_LXSESSION_CONFIG_KEY_FILE, LxsessionLxsessionConfigKeyFileClass))

typedef struct _LxsessionLxsessionConfigKeyFile LxsessionLxsessionConfigKeyFile;
typedef struct _LxsessionLxsessionConfigKeyFileClass LxsessionLxsessionConfigKeyFileClass;

struct _LxsessionLxsessionEnv {
	GObject parent_instance;
	LxsessionLxsessionEnvPrivate * priv;
};

struct _LxsessionLxsessionEnvClass {
	GObjectClass parent_class;
};

struct _LxsessionLxsessionEnvPrivate {
	gchar* display_env;
	gchar* pid_env;
	gchar* session_env;
	gchar* desktop_environment_env;
	gchar* display_name;
	gchar* pid_str;
	gchar* session;
	gchar* desktop_environment;
	gchar* config_home;
	gchar* config_dirs;
	gchar* data_dirs;
	gchar* home_path;
};


static gpointer lxsession_lxsession_env_parent_class = NULL;
extern LxsessionLxsessionConfigKeyFile* lxsession_global_settings;

GType lxsession_lxsession_env_get_type (void) G_GNUC_CONST;
#define LXSESSION_LXSESSION_ENV_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), LXSESSION_TYPE_LXSESSION_ENV, LxsessionLxsessionEnvPrivate))
enum  {
	LXSESSION_LXSESSION_ENV_DUMMY_PROPERTY
};
LxsessionLxsessionEnv* lxsession_lxsession_env_new (const gchar* session_arg, const gchar* desktop_environment_arg);
LxsessionLxsessionEnv* lxsession_lxsession_env_construct (GType object_type, const gchar* session_arg, const gchar* desktop_environment_arg);
void lxsession_lxsession_env_export_primary_env (LxsessionLxsessionEnv* self);
void lxsession_lxsession_env_set_xdg_dirs (LxsessionLxsessionEnv* self, const gchar* mode);
void lxsession_lxsession_env_export_env (LxsessionLxsessionEnv* self);
GType lxsession_lxsession_config_get_type (void) G_GNUC_CONST;
GType lxsession_lxsession_config_key_file_get_type (void) G_GNUC_CONST;
gchar* lxsession_lxsession_config_get_item_string (LxsessionLxsessionConfig* self, const gchar* categorie, const gchar* key1, const gchar* key2);
void lxsession_lxsession_env_set_misc (LxsessionLxsessionEnv* self);
gboolean lxsession_lxsession_env_check_alone (LxsessionLxsessionEnv* self);
void lxsession_lxsession_spawn_command_line_async (const gchar* command_line);
static void lxsession_lxsession_env_finalize (GObject* obj);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
static gint _vala_array_length (gpointer array);


LxsessionLxsessionEnv* lxsession_lxsession_env_construct (GType object_type, const gchar* session_arg, const gchar* desktop_environment_arg) {
	LxsessionLxsessionEnv * self = NULL;
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	const gchar* _tmp4_ = NULL;
	const gchar* _tmp5_ = NULL;
	gchar* _tmp6_ = NULL;
	const gchar* _tmp7_ = NULL;
	gchar* _tmp8_ = NULL;
	const gchar* _tmp9_ = NULL;
	gchar* _tmp10_ = NULL;
	g_return_val_if_fail (session_arg != NULL, NULL);
	g_return_val_if_fail (desktop_environment_arg != NULL, NULL);
	self = (LxsessionLxsessionEnv*) g_object_new (object_type, NULL);
	_tmp0_ = session_arg;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 (self->priv->session);
	self->priv->session = _tmp1_;
	_tmp2_ = desktop_environment_arg;
	_tmp3_ = g_strdup (_tmp2_);
	_g_free0 (self->priv->desktop_environment);
	self->priv->desktop_environment = _tmp3_;
	_tmp4_ = self->priv->display_env;
	_tmp5_ = g_getenv (_tmp4_);
	_tmp6_ = g_strdup (_tmp5_);
	_g_free0 (self->priv->display_name);
	self->priv->display_name = _tmp6_;
	_tmp7_ = g_getenv ("HOME");
	_tmp8_ = g_strdup (_tmp7_);
	_g_free0 (self->priv->home_path);
	self->priv->home_path = _tmp8_;
	_tmp9_ = g_getenv ("XDG_CONFIG_HOME");
	_tmp10_ = g_strdup (_tmp9_);
	_g_free0 (self->priv->config_home);
	self->priv->config_home = _tmp10_;
	return self;
}


LxsessionLxsessionEnv* lxsession_lxsession_env_new (const gchar* session_arg, const gchar* desktop_environment_arg) {
	return lxsession_lxsession_env_construct (LXSESSION_TYPE_LXSESSION_ENV, session_arg, desktop_environment_arg);
}


void lxsession_lxsession_env_export_primary_env (LxsessionLxsessionEnv* self) {
	const gchar* _tmp0_ = NULL;
	pid_t _tmp1_ = 0;
	gchar* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	const gchar* _tmp4_ = NULL;
	const gchar* _tmp5_ = NULL;
	const gchar* _tmp6_ = NULL;
	const gchar* _tmp7_ = NULL;
	const gchar* _tmp8_ = NULL;
	const gchar* _tmp9_ = NULL;
	const gchar* _tmp10_ = NULL;
	const gchar* _tmp11_ = NULL;
	g_return_if_fail (self != NULL);
	g_message ("environement.vala:58: Exporting primary_variable");
	_tmp0_ = self->priv->desktop_environment_env;
	g_message ("environement.vala:59: desktop_environnement %s", _tmp0_);
	_tmp1_ = getpid ();
	_tmp2_ = g_strdup_printf ("%d", (gint) _tmp1_);
	_g_free0 (self->priv->pid_str);
	self->priv->pid_str = _tmp2_;
	_tmp3_ = self->priv->session_env;
	_tmp4_ = self->priv->session;
	g_setenv (_tmp3_, _tmp4_, TRUE);
	_tmp5_ = self->priv->desktop_environment_env;
	_tmp6_ = self->priv->desktop_environment;
	g_setenv (_tmp5_, _tmp6_, TRUE);
	_tmp7_ = self->priv->pid_env;
	_tmp8_ = self->priv->pid_str;
	g_setenv (_tmp7_, _tmp8_, TRUE);
	_tmp9_ = self->priv->display_env;
	_tmp10_ = self->priv->display_name;
	g_setenv (_tmp9_, _tmp10_, TRUE);
	g_set_application_name ("lxsession");
	_tmp11_ = self->priv->config_home;
	if (_tmp11_ == NULL) {
		const gchar* _tmp12_ = NULL;
		gchar* _tmp13_ = NULL;
		const gchar* _tmp14_ = NULL;
		_tmp12_ = self->priv->home_path;
		_tmp13_ = g_strconcat (_tmp12_, "/.config", NULL);
		_g_free0 (self->priv->config_home);
		self->priv->config_home = _tmp13_;
		_tmp14_ = self->priv->config_home;
		g_setenv ("XDG_CONFIG_HOME", _tmp14_, TRUE);
	}
	lxsession_lxsession_env_set_xdg_dirs (self, NULL);
}


void lxsession_lxsession_env_export_env (LxsessionLxsessionEnv* self) {
	const gchar* _tmp0_ = NULL;
	LxsessionLxsessionConfigKeyFile* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	g_return_if_fail (self != NULL);
	g_message ("environement.vala:79: Exporting variable");
	_tmp0_ = self->priv->desktop_environment_env;
	g_message ("environement.vala:80: desktop_environnement %s", _tmp0_);
	_tmp1_ = lxsession_global_settings;
	_tmp2_ = lxsession_lxsession_config_get_item_string ((LxsessionLxsessionConfig*) _tmp1_, "Environment", "menu_prefix", NULL);
	_tmp3_ = _tmp2_;
	g_setenv ("XDG_MENU_PREFIX", _tmp3_, TRUE);
	_g_free0 (_tmp3_);
	lxsession_lxsession_env_set_xdg_dirs (self, "all");
	lxsession_lxsession_env_set_misc (self);
}


gboolean lxsession_lxsession_env_check_alone (LxsessionLxsessionEnv* self) {
	gboolean result = FALSE;
	gchar* lxsession_pid = NULL;
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	const gchar* _tmp4_ = NULL;
	g_return_val_if_fail (self != NULL, FALSE);
	g_message ("environement.vala:93: Getting lxsession pid");
	_tmp0_ = self->priv->pid_env;
	_tmp1_ = g_getenv (_tmp0_);
	_tmp2_ = g_strdup (_tmp1_);
	_g_free0 (lxsession_pid);
	lxsession_pid = _tmp2_;
	_tmp3_ = lxsession_pid;
	g_message ("environement.vala:96: Checking pid : %s", _tmp3_);
	_tmp4_ = lxsession_pid;
	if (_tmp4_ == NULL) {
		g_message ("environement.vala:100: Lxsession not detected");
		result = TRUE;
		_g_free0 (lxsession_pid);
		return result;
	} else {
		g_message ("environement.vala:105: Lxsession detected");
		result = FALSE;
		_g_free0 (lxsession_pid);
		return result;
	}
	_g_free0 (lxsession_pid);
}


void lxsession_lxsession_env_set_xdg_dirs (LxsessionLxsessionEnv* self, const gchar* mode) {
	gchar* custom_config = NULL;
	gchar* custom_data = NULL;
	gchar* return_config = NULL;
	gchar* return_data = NULL;
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	const gchar* _tmp4_ = NULL;
	const gchar* _tmp9_ = NULL;
	const gchar* _tmp17_ = NULL;
	const gchar* _tmp46_ = NULL;
	const gchar* _tmp48_ = NULL;
	const gchar* _tmp77_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_getenv ("XDG_CONFIG_DIRS");
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 (self->priv->config_dirs);
	self->priv->config_dirs = _tmp1_;
	_tmp2_ = g_getenv ("XDG_DATA_DIRS");
	_tmp3_ = g_strdup (_tmp2_);
	_g_free0 (self->priv->data_dirs);
	self->priv->data_dirs = _tmp3_;
	_tmp4_ = self->priv->session;
	if (g_strcmp0 (_tmp4_, "Lubuntu") == 0) {
		gchar* _tmp5_ = NULL;
		gchar* _tmp6_ = NULL;
		_tmp5_ = g_strdup ("/etc/xdg/lubuntu:/etc/xdg");
		_g_free0 (custom_config);
		custom_config = _tmp5_;
		_tmp6_ = g_strdup ("/etc/xdg/lubuntu:/usr/local/share:/usr/share:/usr/share/gdm:/var/lib/m" \
"enu-xdg");
		_g_free0 (custom_data);
		custom_data = _tmp6_;
	} else {
		gchar* _tmp7_ = NULL;
		gchar* _tmp8_ = NULL;
		_tmp7_ = g_strdup ("/etc/xdg");
		_g_free0 (custom_config);
		custom_config = _tmp7_;
		_tmp8_ = g_strdup ("/usr/local/share:/usr/share:/usr/share/gdm:/var/lib/menu-xdg");
		_g_free0 (custom_data);
		custom_data = _tmp8_;
	}
	_tmp9_ = mode;
	if (g_strcmp0 (_tmp9_, "all") == 0) {
		LxsessionLxsessionConfigKeyFile* _tmp10_ = NULL;
		gchar* _tmp11_ = NULL;
		gchar* _tmp12_ = NULL;
		GQuark _tmp14_ = 0U;
		static GQuark _tmp13_label0 = 0;
		_tmp10_ = lxsession_global_settings;
		_tmp11_ = lxsession_lxsession_config_get_item_string ((LxsessionLxsessionConfig*) _tmp10_, "Environment", "type", NULL);
		_tmp12_ = _tmp11_;
		_tmp14_ = (NULL == _tmp12_) ? 0 : g_quark_from_string (_tmp12_);
		g_free (_tmp12_);
		if (_tmp14_ == ((0 != _tmp13_label0) ? _tmp13_label0 : (_tmp13_label0 = g_quark_from_static_string ("lubuntu")))) {
			switch (0) {
				default:
				{
					gchar* _tmp15_ = NULL;
					gchar* _tmp16_ = NULL;
					_tmp15_ = g_strdup ("/etc/xdg/lubuntu:/etc/xdg");
					_g_free0 (custom_config);
					custom_config = _tmp15_;
					_tmp16_ = g_strdup ("/etc/xdg/lubuntu:/usr/local/share:/usr/share:/usr/share/gdm:/var/lib/m" \
"enu-xdg");
					_g_free0 (custom_data);
					custom_data = _tmp16_;
					break;
				}
			}
		} else {
			switch (0) {
				default:
				{
					break;
				}
			}
		}
	}
	_tmp17_ = self->priv->config_dirs;
	if (_tmp17_ == NULL) {
		const gchar* _tmp18_ = NULL;
		gchar* _tmp19_ = NULL;
		const gchar* _tmp20_ = NULL;
		_tmp18_ = custom_config;
		_tmp19_ = g_strdup (_tmp18_);
		_g_free0 (return_config);
		return_config = _tmp19_;
		_tmp20_ = return_config;
		g_message ("environement.vala:149: confir_dirs is null, export : %s", _tmp20_);
	} else {
		gchar** custom_config_array = NULL;
		const gchar* _tmp21_ = NULL;
		gchar** _tmp22_ = NULL;
		gchar** _tmp23_ = NULL;
		gint custom_config_array_length1 = 0;
		gint _custom_config_array_size_ = 0;
		gchar** config_dirs_array = NULL;
		const gchar* _tmp24_ = NULL;
		gchar** _tmp25_ = NULL;
		gchar** _tmp26_ = NULL;
		gint config_dirs_array_length1 = 0;
		gint _config_dirs_array_size_ = 0;
		gchar* custom_config_check = NULL;
		gchar* _tmp27_ = NULL;
		gchar** _tmp28_ = NULL;
		gint _tmp28__length1 = 0;
		const gchar* _tmp40_ = NULL;
		const gchar* _tmp41_ = NULL;
		gchar* _tmp42_ = NULL;
		const gchar* _tmp43_ = NULL;
		const gchar* _tmp44_ = NULL;
		const gchar* _tmp45_ = NULL;
		_tmp21_ = custom_config;
		_tmp23_ = _tmp22_ = g_strsplit_set (_tmp21_, ":", 0);
		custom_config_array = _tmp23_;
		custom_config_array_length1 = _vala_array_length (_tmp22_);
		_custom_config_array_size_ = custom_config_array_length1;
		_tmp24_ = self->priv->config_dirs;
		_tmp26_ = _tmp25_ = g_strsplit_set (_tmp24_, ":", 0);
		config_dirs_array = _tmp26_;
		config_dirs_array_length1 = _vala_array_length (_tmp25_);
		_config_dirs_array_size_ = config_dirs_array_length1;
		_tmp27_ = g_strdup ("");
		custom_config_check = _tmp27_;
		_tmp28_ = custom_config_array;
		_tmp28__length1 = custom_config_array_length1;
		{
			gchar** custom_str_collection = NULL;
			gint custom_str_collection_length1 = 0;
			gint _custom_str_collection_size_ = 0;
			gint custom_str_it = 0;
			custom_str_collection = _tmp28_;
			custom_str_collection_length1 = _tmp28__length1;
			for (custom_str_it = 0; custom_str_it < _tmp28__length1; custom_str_it = custom_str_it + 1) {
				gchar* _tmp29_ = NULL;
				gchar* custom_str = NULL;
				_tmp29_ = g_strdup (custom_str_collection[custom_str_it]);
				custom_str = _tmp29_;
				{
					gboolean delete_str = FALSE;
					gchar** _tmp30_ = NULL;
					gint _tmp30__length1 = 0;
					gboolean _tmp34_ = FALSE;
					delete_str = FALSE;
					_tmp30_ = config_dirs_array;
					_tmp30__length1 = config_dirs_array_length1;
					{
						gchar** config_str_collection = NULL;
						gint config_str_collection_length1 = 0;
						gint _config_str_collection_size_ = 0;
						gint config_str_it = 0;
						config_str_collection = _tmp30_;
						config_str_collection_length1 = _tmp30__length1;
						for (config_str_it = 0; config_str_it < _tmp30__length1; config_str_it = config_str_it + 1) {
							gchar* _tmp31_ = NULL;
							gchar* config_str = NULL;
							_tmp31_ = g_strdup (config_str_collection[config_str_it]);
							config_str = _tmp31_;
							{
								const gchar* _tmp32_ = NULL;
								const gchar* _tmp33_ = NULL;
								_tmp32_ = custom_str;
								_tmp33_ = config_str;
								if (g_strcmp0 (_tmp32_, _tmp33_) == 0) {
									delete_str = TRUE;
								}
								_g_free0 (config_str);
							}
						}
					}
					_tmp34_ = delete_str;
					if (_tmp34_ == FALSE) {
						const gchar* _tmp35_ = NULL;
						const gchar* _tmp36_ = NULL;
						gchar* _tmp37_ = NULL;
						gchar* _tmp38_ = NULL;
						gchar* _tmp39_ = NULL;
						_tmp35_ = custom_config_check;
						_tmp36_ = custom_str;
						_tmp37_ = g_strconcat (_tmp35_, _tmp36_, NULL);
						_tmp38_ = _tmp37_;
						_tmp39_ = g_strconcat (_tmp38_, ":", NULL);
						_g_free0 (custom_config_check);
						custom_config_check = _tmp39_;
						_g_free0 (_tmp38_);
					}
					_g_free0 (custom_str);
				}
			}
		}
		_tmp40_ = custom_config_check;
		_tmp41_ = self->priv->config_dirs;
		_tmp42_ = g_strconcat (_tmp40_, _tmp41_, NULL);
		_g_free0 (return_config);
		return_config = _tmp42_;
		_tmp43_ = custom_config_check;
		g_message ("environement.vala:176: custom_config :%s", _tmp43_);
		_tmp44_ = self->priv->config_dirs;
		g_message ("environement.vala:177: config_dirs :%s", _tmp44_);
		_tmp45_ = return_config;
		g_message ("environement.vala:178: confir_dirs not null, export : %s", _tmp45_);
		_g_free0 (custom_config_check);
		config_dirs_array = (_vala_array_free (config_dirs_array, config_dirs_array_length1, (GDestroyNotify) g_free), NULL);
		custom_config_array = (_vala_array_free (custom_config_array, custom_config_array_length1, (GDestroyNotify) g_free), NULL);
	}
	_tmp46_ = return_config;
	if (_tmp46_ != NULL) {
		const gchar* _tmp47_ = NULL;
		g_message ("environement.vala:183: Exporting XDG_CONFIG_DIRS");
		_tmp47_ = return_config;
		g_setenv ("XDG_CONFIG_DIRS", _tmp47_, TRUE);
	}
	_tmp48_ = self->priv->data_dirs;
	if (_tmp48_ == NULL) {
		const gchar* _tmp49_ = NULL;
		gchar* _tmp50_ = NULL;
		const gchar* _tmp51_ = NULL;
		_tmp49_ = custom_data;
		_tmp50_ = g_strdup (_tmp49_);
		_g_free0 (return_data);
		return_data = _tmp50_;
		_tmp51_ = return_data;
		g_message ("environement.vala:190: data_dirs is null, export : %s", _tmp51_);
	} else {
		gchar** custom_data_array = NULL;
		const gchar* _tmp52_ = NULL;
		gchar** _tmp53_ = NULL;
		gchar** _tmp54_ = NULL;
		gint custom_data_array_length1 = 0;
		gint _custom_data_array_size_ = 0;
		gchar** data_dirs_array = NULL;
		const gchar* _tmp55_ = NULL;
		gchar** _tmp56_ = NULL;
		gchar** _tmp57_ = NULL;
		gint data_dirs_array_length1 = 0;
		gint _data_dirs_array_size_ = 0;
		gchar* custom_data_check = NULL;
		gchar* _tmp58_ = NULL;
		gchar** _tmp59_ = NULL;
		gint _tmp59__length1 = 0;
		const gchar* _tmp71_ = NULL;
		const gchar* _tmp72_ = NULL;
		gchar* _tmp73_ = NULL;
		const gchar* _tmp74_ = NULL;
		const gchar* _tmp75_ = NULL;
		const gchar* _tmp76_ = NULL;
		_tmp52_ = custom_data;
		_tmp54_ = _tmp53_ = g_strsplit_set (_tmp52_, ":", 0);
		custom_data_array = _tmp54_;
		custom_data_array_length1 = _vala_array_length (_tmp53_);
		_custom_data_array_size_ = custom_data_array_length1;
		_tmp55_ = self->priv->data_dirs;
		_tmp57_ = _tmp56_ = g_strsplit_set (_tmp55_, ":", 0);
		data_dirs_array = _tmp57_;
		data_dirs_array_length1 = _vala_array_length (_tmp56_);
		_data_dirs_array_size_ = data_dirs_array_length1;
		_tmp58_ = g_strdup ("");
		custom_data_check = _tmp58_;
		_tmp59_ = custom_data_array;
		_tmp59__length1 = custom_data_array_length1;
		{
			gchar** custom_data_str_collection = NULL;
			gint custom_data_str_collection_length1 = 0;
			gint _custom_data_str_collection_size_ = 0;
			gint custom_data_str_it = 0;
			custom_data_str_collection = _tmp59_;
			custom_data_str_collection_length1 = _tmp59__length1;
			for (custom_data_str_it = 0; custom_data_str_it < _tmp59__length1; custom_data_str_it = custom_data_str_it + 1) {
				gchar* _tmp60_ = NULL;
				gchar* custom_data_str = NULL;
				_tmp60_ = g_strdup (custom_data_str_collection[custom_data_str_it]);
				custom_data_str = _tmp60_;
				{
					gboolean delete_data_str = FALSE;
					gchar** _tmp61_ = NULL;
					gint _tmp61__length1 = 0;
					gboolean _tmp65_ = FALSE;
					delete_data_str = FALSE;
					_tmp61_ = data_dirs_array;
					_tmp61__length1 = data_dirs_array_length1;
					{
						gchar** data_str_collection = NULL;
						gint data_str_collection_length1 = 0;
						gint _data_str_collection_size_ = 0;
						gint data_str_it = 0;
						data_str_collection = _tmp61_;
						data_str_collection_length1 = _tmp61__length1;
						for (data_str_it = 0; data_str_it < _tmp61__length1; data_str_it = data_str_it + 1) {
							gchar* _tmp62_ = NULL;
							gchar* data_str = NULL;
							_tmp62_ = g_strdup (data_str_collection[data_str_it]);
							data_str = _tmp62_;
							{
								const gchar* _tmp63_ = NULL;
								const gchar* _tmp64_ = NULL;
								_tmp63_ = custom_data_str;
								_tmp64_ = data_str;
								if (g_strcmp0 (_tmp63_, _tmp64_) == 0) {
									delete_data_str = TRUE;
								}
								_g_free0 (data_str);
							}
						}
					}
					_tmp65_ = delete_data_str;
					if (_tmp65_ == FALSE) {
						const gchar* _tmp66_ = NULL;
						const gchar* _tmp67_ = NULL;
						gchar* _tmp68_ = NULL;
						gchar* _tmp69_ = NULL;
						gchar* _tmp70_ = NULL;
						_tmp66_ = custom_data_check;
						_tmp67_ = custom_data_str;
						_tmp68_ = g_strconcat (_tmp66_, _tmp67_, NULL);
						_tmp69_ = _tmp68_;
						_tmp70_ = g_strconcat (_tmp69_, ":", NULL);
						_g_free0 (custom_data_check);
						custom_data_check = _tmp70_;
						_g_free0 (_tmp69_);
					}
					_g_free0 (custom_data_str);
				}
			}
		}
		_tmp71_ = custom_data_check;
		_tmp72_ = self->priv->data_dirs;
		_tmp73_ = g_strconcat (_tmp71_, _tmp72_, NULL);
		_g_free0 (return_data);
		return_data = _tmp73_;
		_tmp74_ = custom_data_check;
		g_message ("environement.vala:217: custom_data :%s", _tmp74_);
		_tmp75_ = self->priv->data_dirs;
		g_message ("environement.vala:218: data_dirs :%s", _tmp75_);
		_tmp76_ = return_data;
		g_message ("environement.vala:219: data_dirs not null, export : %s", _tmp76_);
		_g_free0 (custom_data_check);
		data_dirs_array = (_vala_array_free (data_dirs_array, data_dirs_array_length1, (GDestroyNotify) g_free), NULL);
		custom_data_array = (_vala_array_free (custom_data_array, custom_data_array_length1, (GDestroyNotify) g_free), NULL);
	}
	_tmp77_ = return_data;
	if (_tmp77_ != NULL) {
		const gchar* _tmp78_ = NULL;
		g_message ("environement.vala:224: Exporting XDG_DATA_DIRS");
		_tmp78_ = return_data;
		g_setenv ("XDG_DATA_DIRS", _tmp78_, TRUE);
	}
	_g_free0 (return_data);
	_g_free0 (return_config);
	_g_free0 (custom_data);
	_g_free0 (custom_config);
}


void lxsession_lxsession_env_set_misc (LxsessionLxsessionEnv* self) {
	gchar* dbus_path = NULL;
	gchar* dbus_env = NULL;
	gchar* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	gchar* qt_plugin = NULL;
	const gchar* _tmp5_ = NULL;
	gchar* _tmp6_ = NULL;
	const gchar* _tmp7_ = NULL;
	LxsessionLxsessionConfigKeyFile* _tmp12_ = NULL;
	gchar* _tmp13_ = NULL;
	gchar* _tmp14_ = NULL;
	gboolean _tmp15_ = FALSE;
	g_return_if_fail (self != NULL);
	lxsession_lxsession_spawn_command_line_async ("xprop -root -remove _NET_NUMBER_OF_DESKTOPS -remove _NET_DESKTOP_NAMES" \
" -remove _NET_CURRENT_DESKTOP");
	_tmp0_ = g_find_program_in_path ("dbus-launch");
	_g_free0 (dbus_path);
	dbus_path = _tmp0_;
	_tmp1_ = g_getenv ("DBUS_SESSION_BUS_ADDRESS");
	_tmp2_ = g_strdup (_tmp1_);
	_g_free0 (dbus_env);
	dbus_env = _tmp2_;
	_tmp3_ = dbus_path;
	if (_tmp3_ == NULL) {
		const gchar* _tmp4_ = NULL;
		_tmp4_ = dbus_env;
		if (_tmp4_ == NULL) {
			lxsession_lxsession_spawn_command_line_async ("dbus-launch --sh-syntax --exit-with-session");
		}
	}
	g_setenv ("SAL_USE_VCLPLUGIN", "gtk", TRUE);
	_tmp5_ = g_getenv ("QT_PLUGIN_PATH");
	_tmp6_ = g_strdup (_tmp5_);
	_g_free0 (qt_plugin);
	qt_plugin = _tmp6_;
	_tmp7_ = qt_plugin;
	if (_tmp7_ != NULL) {
		const gchar* _tmp8_ = NULL;
		_tmp8_ = qt_plugin;
		if (g_strcmp0 (_tmp8_, "") != 0) {
			const gchar* _tmp9_ = NULL;
			gchar* _tmp10_ = NULL;
			gchar* _tmp11_ = NULL;
			_tmp9_ = qt_plugin;
			_tmp10_ = g_strconcat (_tmp9_, ":/usr/lib64/kde4/plugins:/usr/lib/kde4/plugins", NULL);
			_tmp11_ = _tmp10_;
			g_setenv ("QT_PLUGIN_PATH", _tmp11_, TRUE);
			_g_free0 (_tmp11_);
		}
	}
	_tmp12_ = lxsession_global_settings;
	_tmp13_ = lxsession_lxsession_config_get_item_string ((LxsessionLxsessionConfig*) _tmp12_, "Environment", "ubuntu_menuproxy", NULL);
	_tmp14_ = _tmp13_;
	_tmp15_ = g_strcmp0 (_tmp14_, "true") == 0;
	_g_free0 (_tmp14_);
	if (_tmp15_) {
		g_setenv ("UBUNTU_MENUPROXY", "libappmenu.so", TRUE);
	}
	g_setenv ("QT_PLATFORM_PLUGIN", "lxqt", TRUE);
	g_setenv ("QT_QPA_PLATFORMTHEME", "lxqt", TRUE);
	_g_free0 (qt_plugin);
	_g_free0 (dbus_env);
	_g_free0 (dbus_path);
}


static void lxsession_lxsession_env_class_init (LxsessionLxsessionEnvClass * klass) {
	lxsession_lxsession_env_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (LxsessionLxsessionEnvPrivate));
	G_OBJECT_CLASS (klass)->finalize = lxsession_lxsession_env_finalize;
}


static void lxsession_lxsession_env_instance_init (LxsessionLxsessionEnv * self) {
	gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	self->priv = LXSESSION_LXSESSION_ENV_GET_PRIVATE (self);
	_tmp0_ = g_strdup ("DISPLAY");
	self->priv->display_env = _tmp0_;
	_tmp1_ = g_strdup ("_LXSESSION_PID");
	self->priv->pid_env = _tmp1_;
	_tmp2_ = g_strdup ("DESKTOP_SESSION");
	self->priv->session_env = _tmp2_;
	_tmp3_ = g_strdup ("XDG_CURRENT_DESKTOP");
	self->priv->desktop_environment_env = _tmp3_;
}


static void lxsession_lxsession_env_finalize (GObject* obj) {
	LxsessionLxsessionEnv * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, LXSESSION_TYPE_LXSESSION_ENV, LxsessionLxsessionEnv);
	_g_free0 (self->priv->display_env);
	_g_free0 (self->priv->pid_env);
	_g_free0 (self->priv->session_env);
	_g_free0 (self->priv->desktop_environment_env);
	_g_free0 (self->priv->display_name);
	_g_free0 (self->priv->pid_str);
	_g_free0 (self->priv->session);
	_g_free0 (self->priv->desktop_environment);
	_g_free0 (self->priv->config_home);
	_g_free0 (self->priv->config_dirs);
	_g_free0 (self->priv->data_dirs);
	_g_free0 (self->priv->home_path);
	G_OBJECT_CLASS (lxsession_lxsession_env_parent_class)->finalize (obj);
}


GType lxsession_lxsession_env_get_type (void) {
	static volatile gsize lxsession_lxsession_env_type_id__volatile = 0;
	if (g_once_init_enter (&lxsession_lxsession_env_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (LxsessionLxsessionEnvClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) lxsession_lxsession_env_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (LxsessionLxsessionEnv), 0, (GInstanceInitFunc) lxsession_lxsession_env_instance_init, NULL };
		GType lxsession_lxsession_env_type_id;
		lxsession_lxsession_env_type_id = g_type_register_static (G_TYPE_OBJECT, "LxsessionLxsessionEnv", &g_define_type_info, 0);
		g_once_init_leave (&lxsession_lxsession_env_type_id__volatile, lxsession_lxsession_env_type_id);
	}
	return lxsession_lxsession_env_type_id__volatile;
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int 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, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}


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



