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

/*
 * This file is part of LaTeXila.
 *
 * Copyright © 2010-2011 Sébastien Wilmet
 *
 * LaTeXila 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.
 *
 * LaTeXila 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 LaTeXila.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <float.h>
#include <math.h>
#include <gdk/gdkx.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>
#include <X11/Xregion.h>
#include <gee.h>
#include <stdio.h>

#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define __g_list_free__g_object_unref0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__g_object_unref0_ (var), NULL)))
#define _gtk_tree_path_free0(var) ((var == NULL) ? NULL : (var = (gtk_tree_path_free (var), NULL)))

#define TYPE_BUILD_TOOL (build_tool_get_type ())

#define TYPE_BUILD_JOB (build_job_get_type ())

#define TYPE_POST_PROCESSOR_TYPE (post_processor_type_get_type ())
typedef struct _BuildJob BuildJob;
typedef struct _BuildTool BuildTool;
#define _build_job_free0(var) ((var == NULL) ? NULL : (var = (build_job_free (var), NULL)))

typedef enum  {
	POST_PROCESSOR_TYPE_ALL_OUTPUT = 0,
	POST_PROCESSOR_TYPE_LATEX,
	POST_PROCESSOR_TYPE_LATEXMK,
	POST_PROCESSOR_TYPE_NO_OUTPUT,
	POST_PROCESSOR_TYPE_RUBBER,
	POST_PROCESSOR_TYPE_N_POST_PROCESSORS
} PostProcessorType;

struct _BuildJob {
	gboolean must_succeed;
	PostProcessorType post_processor;
	gchar* command;
};

struct _BuildTool {
	gchar* description;
	gchar* extensions;
	gchar* label;
	gchar* icon;
	gboolean show;
	gboolean compilation;
	GeeArrayList* jobs;
};



gchar* utils_str_middle_truncate (const gchar* str, guint max_length);
gboolean utils_char_is_escaped (const gchar* text, glong char_index);
gboolean utils_string_get_prev_char (const gchar* str, gint* index, gunichar* c);
gchar* utils_replace_home_dir_with_tilde (const gchar* uri);
gchar* utils_uri_get_dirname (const gchar* uri);
gchar* utils_get_dirname_for_display (GFile* location);
gchar* utils_get_shortname (const gchar* path);
glong utils_get_extension_pos (const gchar* path);
gchar* utils_get_extension (const gchar* path);
void utils_delete_file (GFile* file);
gchar* utils_get_relative_path (GFile* origin, GFile* target, GFile* common_dir);
static void _g_object_unref0_ (gpointer var);
static void _g_list_free__g_object_unref0_ (GList* self);
GtkWidget* utils_add_scrollbar (GtkWidget* child);
void utils_set_entry_error (GtkWidget* entry, gboolean _error_);
gboolean utils_tree_model_iter_prev (GtkTreeModel* model, GtkTreeIter* iter);
gint utils_get_selected_row (GtkTreeView* view, GtkTreeIter* iter);
GdkPixbuf* utils_get_pixbuf_from_stock (const gchar* stock_id, GtkIconSize size);
GtkButton* utils_get_toolbar_button (const gchar* stock_id);
GtkButton* _utils_get_toolbar_button_impl (const gchar* stock_id, gboolean toggle);
GtkToggleButton* utils_get_toolbar_toggle_button (const gchar* stock_id);
GtkWidget* utils_get_dialog_component (const gchar* title, GtkWidget* widget);
void utils_flush_queue (void);
#define UTILS_ALL_WORKSPACES ((guint) 0xffffff)
guint utils_get_window_workspace (GtkWindow* gtkwindow);
GType build_tool_get_type (void) G_GNUC_CONST;
GType build_job_get_type (void) G_GNUC_CONST;
GType post_processor_type_get_type (void) G_GNUC_CONST;
BuildJob* build_job_dup (const BuildJob* self);
void build_job_free (BuildJob* self);
void build_job_copy (const BuildJob* self, BuildJob* dest);
void build_job_destroy (BuildJob* self);
BuildTool* build_tool_dup (const BuildTool* self);
void build_tool_free (BuildTool* self);
void build_tool_copy (const BuildTool* self, BuildTool* dest);
void build_tool_destroy (BuildTool* self);
void utils_print_build_tool (BuildTool* build_tool);
gchar* build_tools_get_post_processor_name_from_type (PostProcessorType type);


/*************************************************************************/
static gchar* string_slice (const gchar* self, glong start, glong end) {
	gchar* result = NULL;
	gint _tmp0_;
	gint _tmp1_;
	glong string_length;
	glong _tmp2_;
	glong _tmp5_;
	gboolean _tmp8_ = FALSE;
	glong _tmp9_;
	gboolean _tmp12_;
	gboolean _tmp13_ = FALSE;
	glong _tmp14_;
	gboolean _tmp17_;
	glong _tmp18_;
	glong _tmp19_;
	glong _tmp20_;
	glong _tmp21_;
	glong _tmp22_;
	gchar* _tmp23_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	string_length = (glong) _tmp1_;
	_tmp2_ = start;
	if (_tmp2_ < ((glong) 0)) {
		glong _tmp3_;
		glong _tmp4_;
		_tmp3_ = string_length;
		_tmp4_ = start;
		start = _tmp3_ + _tmp4_;
	}
	_tmp5_ = end;
	if (_tmp5_ < ((glong) 0)) {
		glong _tmp6_;
		glong _tmp7_;
		_tmp6_ = string_length;
		_tmp7_ = end;
		end = _tmp6_ + _tmp7_;
	}
	_tmp9_ = start;
	if (_tmp9_ >= ((glong) 0)) {
		glong _tmp10_;
		glong _tmp11_;
		_tmp10_ = start;
		_tmp11_ = string_length;
		_tmp8_ = _tmp10_ <= _tmp11_;
	} else {
		_tmp8_ = FALSE;
	}
	_tmp12_ = _tmp8_;
	g_return_val_if_fail (_tmp12_, NULL);
	_tmp14_ = end;
	if (_tmp14_ >= ((glong) 0)) {
		glong _tmp15_;
		glong _tmp16_;
		_tmp15_ = end;
		_tmp16_ = string_length;
		_tmp13_ = _tmp15_ <= _tmp16_;
	} else {
		_tmp13_ = FALSE;
	}
	_tmp17_ = _tmp13_;
	g_return_val_if_fail (_tmp17_, NULL);
	_tmp18_ = start;
	_tmp19_ = end;
	g_return_val_if_fail (_tmp18_ <= _tmp19_, NULL);
	_tmp20_ = start;
	_tmp21_ = end;
	_tmp22_ = start;
	_tmp23_ = g_strndup (((gchar*) self) + _tmp20_, (gsize) (_tmp21_ - _tmp22_));
	result = _tmp23_;
	return result;
}


gchar* utils_str_middle_truncate (const gchar* str, guint max_length) {
	gchar* result = NULL;
	const gchar* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	guint _tmp3_;
	guint _tmp6_;
	guint half_length;
	const gchar* _tmp7_;
	gint _tmp8_;
	gint _tmp9_;
	gint l;
	const gchar* _tmp10_;
	guint _tmp11_;
	gchar* _tmp12_ = NULL;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	const gchar* _tmp16_;
	gint _tmp17_;
	guint _tmp18_;
	gint _tmp19_;
	gchar* _tmp20_ = NULL;
	gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	g_return_val_if_fail (str != NULL, NULL);
	_tmp0_ = str;
	_tmp1_ = strlen (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = max_length;
	if (((guint) _tmp2_) <= _tmp3_) {
		const gchar* _tmp4_;
		gchar* _tmp5_;
		_tmp4_ = str;
		_tmp5_ = g_strdup (_tmp4_);
		result = _tmp5_;
		return result;
	}
	_tmp6_ = max_length;
	half_length = (_tmp6_ - 4) / 2;
	_tmp7_ = str;
	_tmp8_ = strlen (_tmp7_);
	_tmp9_ = _tmp8_;
	l = _tmp9_;
	_tmp10_ = str;
	_tmp11_ = half_length;
	_tmp12_ = string_slice (_tmp10_, (glong) 0, (glong) _tmp11_);
	_tmp13_ = _tmp12_;
	_tmp14_ = g_strconcat (_tmp13_, "...", NULL);
	_tmp15_ = _tmp14_;
	_tmp16_ = str;
	_tmp17_ = l;
	_tmp18_ = half_length;
	_tmp19_ = l;
	_tmp20_ = string_slice (_tmp16_, (glong) (_tmp17_ - _tmp18_), (glong) _tmp19_);
	_tmp21_ = _tmp20_;
	_tmp22_ = g_strconcat (_tmp15_, _tmp21_, NULL);
	_tmp23_ = _tmp22_;
	_g_free0 (_tmp21_);
	_g_free0 (_tmp15_);
	_g_free0 (_tmp13_);
	result = _tmp23_;
	return result;
}


gboolean utils_char_is_escaped (const gchar* text, glong char_index) {
	gboolean result = FALSE;
	glong _tmp0_;
	const gchar* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	glong _tmp4_;
	gint index;
	const gchar* _tmp5_;
	gboolean _tmp6_ = FALSE;
	gboolean escaped;
	g_return_val_if_fail (text != NULL, FALSE);
	_tmp0_ = char_index;
	_tmp1_ = text;
	_tmp2_ = strlen (_tmp1_);
	_tmp3_ = _tmp2_;
	g_return_val_if_fail (_tmp0_ < ((glong) _tmp3_), FALSE);
	_tmp4_ = char_index;
	index = (gint) _tmp4_;
	_tmp5_ = text;
	_tmp6_ = utils_string_get_prev_char (_tmp5_, &index, NULL);
	if (!_tmp6_) {
		result = FALSE;
		return result;
	}
	escaped = FALSE;
	while (TRUE) {
		gunichar cur_char = 0U;
		const gchar* _tmp7_;
		gunichar _tmp8_ = 0U;
		gboolean _tmp9_ = FALSE;
		gboolean first_char;
		gunichar _tmp10_;
		gboolean _tmp11_;
		gboolean _tmp12_;
		_tmp7_ = text;
		_tmp9_ = utils_string_get_prev_char (_tmp7_, &index, &_tmp8_);
		cur_char = _tmp8_;
		first_char = !_tmp9_;
		_tmp10_ = cur_char;
		if (_tmp10_ != ((gunichar) '\\')) {
			break;
		}
		_tmp11_ = escaped;
		escaped = !_tmp11_;
		_tmp12_ = first_char;
		if (_tmp12_) {
			break;
		}
	}
	result = escaped;
	return result;
}


static gunichar string_get_char (const gchar* self, glong index) {
	gunichar result = 0U;
	glong _tmp0_;
	gunichar _tmp1_ = 0U;
	g_return_val_if_fail (self != NULL, 0U);
	_tmp0_ = index;
	_tmp1_ = g_utf8_get_char (((gchar*) self) + _tmp0_);
	result = _tmp1_;
	return result;
}


gboolean utils_string_get_prev_char (const gchar* str, gint* index, gunichar* c) {
	gunichar _vala_c = 0U;
	gboolean result = FALSE;
	const gchar* _tmp0_;
	gint _tmp1_;
	gunichar _tmp2_ = 0U;
	gint _tmp3_;
	const gchar* _tmp4_;
	gint _tmp5_;
	const gchar* str_at_index;
	const gchar* _tmp6_;
	const gchar* _tmp7_ = NULL;
	const gchar* str_prev;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	g_return_val_if_fail (str != NULL, FALSE);
	_tmp0_ = str;
	_tmp1_ = *index;
	_tmp2_ = string_get_char (_tmp0_, (glong) _tmp1_);
	_vala_c = _tmp2_;
	_tmp3_ = *index;
	if (_tmp3_ <= 0) {
		result = FALSE;
		if (c) {
			*c = _vala_c;
		}
		return result;
	}
	_tmp4_ = str;
	_tmp5_ = *index;
	str_at_index = (const gchar*) (((gchar*) _tmp4_) + _tmp5_);
	_tmp6_ = str_at_index;
	_tmp7_ = g_utf8_prev_char (_tmp6_);
	str_prev = _tmp7_;
	_tmp8_ = str_prev;
	_tmp9_ = str;
	*index = (gint) (((gchar*) _tmp8_) - ((gchar*) _tmp9_));
	result = TRUE;
	if (c) {
		*c = _vala_c;
	}
	return result;
}


/*************************************************************************/
gchar* utils_replace_home_dir_with_tilde (const gchar* uri) {
	gchar* result = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_ = NULL;
	gchar* _tmp2_;
	gchar* home;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	gboolean _tmp8_ = FALSE;
	const gchar* _tmp20_;
	gchar* _tmp21_;
	g_return_val_if_fail (uri != NULL, NULL);
	_tmp0_ = uri;
	g_return_val_if_fail (_tmp0_ != NULL, NULL);
	_tmp1_ = g_get_home_dir ();
	_tmp2_ = g_strdup (_tmp1_);
	home = _tmp2_;
	_tmp3_ = uri;
	_tmp4_ = home;
	if (g_strcmp0 (_tmp3_, _tmp4_) == 0) {
		gchar* _tmp5_;
		_tmp5_ = g_strdup ("~");
		result = _tmp5_;
		_g_free0 (home);
		return result;
	}
	_tmp6_ = uri;
	_tmp7_ = home;
	_tmp8_ = g_str_has_prefix (_tmp6_, _tmp7_);
	if (_tmp8_) {
		const gchar* _tmp9_;
		const gchar* _tmp10_;
		gint _tmp11_;
		gint _tmp12_;
		const gchar* _tmp13_;
		gint _tmp14_;
		gint _tmp15_;
		gchar* _tmp16_ = NULL;
		gchar* _tmp17_;
		gchar* _tmp18_;
		gchar* _tmp19_;
		_tmp9_ = uri;
		_tmp10_ = home;
		_tmp11_ = strlen (_tmp10_);
		_tmp12_ = _tmp11_;
		_tmp13_ = uri;
		_tmp14_ = strlen (_tmp13_);
		_tmp15_ = _tmp14_;
		_tmp16_ = string_slice (_tmp9_, (glong) _tmp12_, (glong) _tmp15_);
		_tmp17_ = _tmp16_;
		_tmp18_ = g_strconcat ("~", _tmp17_, NULL);
		_tmp19_ = _tmp18_;
		_g_free0 (_tmp17_);
		result = _tmp19_;
		_g_free0 (home);
		return result;
	}
	_tmp20_ = uri;
	_tmp21_ = g_strdup (_tmp20_);
	result = _tmp21_;
	_g_free0 (home);
	return result;
}


gchar* utils_uri_get_dirname (const gchar* uri) {
	gchar* result = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_ = NULL;
	gchar* dir;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_ = NULL;
	g_return_val_if_fail (uri != NULL, NULL);
	_tmp0_ = uri;
	g_return_val_if_fail (_tmp0_ != NULL, NULL);
	_tmp1_ = uri;
	_tmp2_ = g_path_get_dirname (_tmp1_);
	dir = _tmp2_;
	_tmp3_ = dir;
	if (g_strcmp0 (_tmp3_, ".") == 0) {
		result = NULL;
		_g_free0 (dir);
		return result;
	}
	_tmp4_ = dir;
	_tmp5_ = utils_replace_home_dir_with_tilde (_tmp4_);
	result = _tmp5_;
	_g_free0 (dir);
	return result;
}


gchar* utils_get_dirname_for_display (GFile* location) {
	gchar* result = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (location != NULL, NULL);
	{
		GFile* _tmp0_;
		GMount* _tmp1_ = NULL;
		GMount* mount;
		GMount* _tmp2_;
		gchar* _tmp3_ = NULL;
		gchar* mount_name;
		GFile* _tmp4_;
		gchar* _tmp5_ = NULL;
		gchar* _tmp6_;
		const gchar* _tmp7_;
		const gchar* _tmp10_;
		gchar* _tmp11_ = NULL;
		gchar* dirname;
		gboolean _tmp12_ = FALSE;
		const gchar* _tmp13_;
		gboolean _tmp15_;
		const gchar* _tmp16_;
		gchar* _tmp17_;
		gchar* _tmp18_;
		const gchar* _tmp19_;
		gchar* _tmp20_;
		gchar* _tmp21_;
		_tmp0_ = location;
		_tmp1_ = g_file_find_enclosing_mount (_tmp0_, NULL, &_inner_error_);
		mount = _tmp1_;
		if (_inner_error_ != NULL) {
			goto __catch40_g_error;
		}
		_tmp2_ = mount;
		_tmp3_ = g_mount_get_name (_tmp2_);
		mount_name = _tmp3_;
		_tmp4_ = location;
		_tmp5_ = g_file_get_path (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp7_ = _tmp6_;
		if (_tmp7_ == NULL) {
			GFile* _tmp8_;
			gchar* _tmp9_ = NULL;
			_tmp8_ = location;
			_tmp9_ = g_file_get_uri (_tmp8_);
			_g_free0 (_tmp6_);
			_tmp6_ = _tmp9_;
		}
		_tmp10_ = _tmp6_;
		_tmp11_ = utils_uri_get_dirname (_tmp10_);
		dirname = _tmp11_;
		_tmp13_ = dirname;
		if (_tmp13_ == NULL) {
			_tmp12_ = TRUE;
		} else {
			const gchar* _tmp14_;
			_tmp14_ = dirname;
			_tmp12_ = g_strcmp0 (_tmp14_, ".") == 0;
		}
		_tmp15_ = _tmp12_;
		if (_tmp15_) {
			result = mount_name;
			_g_free0 (dirname);
			_g_free0 (_tmp6_);
			_g_object_unref0 (mount);
			return result;
		}
		_tmp16_ = mount_name;
		_tmp17_ = g_strconcat (_tmp16_, " ", NULL);
		_tmp18_ = _tmp17_;
		_tmp19_ = dirname;
		_tmp20_ = g_strconcat (_tmp18_, _tmp19_, NULL);
		_tmp21_ = _tmp20_;
		_g_free0 (_tmp18_);
		result = _tmp21_;
		_g_free0 (dirname);
		_g_free0 (_tmp6_);
		_g_free0 (mount_name);
		_g_object_unref0 (mount);
		return result;
	}
	goto __finally40;
	__catch40_g_error:
	{
		GError* e = NULL;
		GFile* _tmp22_;
		gchar* _tmp23_ = NULL;
		gchar* _tmp24_;
		const gchar* _tmp25_;
		const gchar* _tmp28_;
		gchar* _tmp29_ = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp22_ = location;
		_tmp23_ = g_file_get_path (_tmp22_);
		_tmp24_ = _tmp23_;
		_tmp25_ = _tmp24_;
		if (_tmp25_ == NULL) {
			GFile* _tmp26_;
			gchar* _tmp27_ = NULL;
			_tmp26_ = location;
			_tmp27_ = g_file_get_uri (_tmp26_);
			_g_free0 (_tmp24_);
			_tmp24_ = _tmp27_;
		}
		_tmp28_ = _tmp24_;
		_tmp29_ = utils_uri_get_dirname (_tmp28_);
		result = _tmp29_;
		_g_free0 (_tmp24_);
		_g_error_free0 (e);
		return result;
	}
	__finally40:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
	g_clear_error (&_inner_error_);
	return NULL;
}


gchar* utils_get_shortname (const gchar* path) {
	gchar* result = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	glong _tmp2_ = 0L;
	gchar* _tmp3_ = NULL;
	g_return_val_if_fail (path != NULL, NULL);
	_tmp0_ = path;
	_tmp1_ = path;
	_tmp2_ = utils_get_extension_pos (_tmp1_);
	_tmp3_ = string_slice (_tmp0_, (glong) 0, _tmp2_);
	result = _tmp3_;
	return result;
}


gchar* utils_get_extension (const gchar* path) {
	gchar* result = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	glong _tmp2_ = 0L;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	gchar* _tmp6_ = NULL;
	gchar* _tmp7_;
	gchar* _tmp8_ = NULL;
	gchar* _tmp9_;
	g_return_val_if_fail (path != NULL, NULL);
	_tmp0_ = path;
	_tmp1_ = path;
	_tmp2_ = utils_get_extension_pos (_tmp1_);
	_tmp3_ = path;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = string_slice (_tmp0_, _tmp2_, (glong) _tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = g_utf8_strdown (_tmp7_, (gssize) (-1));
	_tmp9_ = _tmp8_;
	_g_free0 (_tmp7_);
	result = _tmp9_;
	return result;
}


static gchar string_get (const gchar* self, glong index) {
	gchar result = '\0';
	glong _tmp0_;
	gchar _tmp1_;
	g_return_val_if_fail (self != NULL, '\0');
	_tmp0_ = index;
	_tmp1_ = ((gchar*) self)[_tmp0_];
	result = _tmp1_;
	return result;
}


glong utils_get_extension_pos (const gchar* path) {
	glong result = 0L;
	const gchar* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	glong l;
	g_return_val_if_fail (path != NULL, 0L);
	_tmp0_ = path;
	_tmp1_ = strlen (_tmp0_);
	_tmp2_ = _tmp1_;
	l = (glong) _tmp2_;
	{
		glong _tmp3_;
		glong i;
		_tmp3_ = l;
		i = _tmp3_ - 1;
		{
			gboolean _tmp4_;
			_tmp4_ = TRUE;
			while (TRUE) {
				gboolean _tmp5_;
				glong _tmp7_;
				const gchar* _tmp8_;
				glong _tmp9_;
				gchar _tmp10_ = '\0';
				_tmp5_ = _tmp4_;
				if (!_tmp5_) {
					glong _tmp6_;
					_tmp6_ = i;
					i = _tmp6_ - 1;
				}
				_tmp4_ = FALSE;
				_tmp7_ = i;
				if (!(_tmp7_ >= ((glong) 0))) {
					break;
				}
				_tmp8_ = path;
				_tmp9_ = i;
				_tmp10_ = string_get (_tmp8_, _tmp9_);
				if (_tmp10_ == '/') {
					result = l;
					return result;
				} else {
					const gchar* _tmp11_;
					glong _tmp12_;
					gchar _tmp13_ = '\0';
					_tmp11_ = path;
					_tmp12_ = i;
					_tmp13_ = string_get (_tmp11_, _tmp12_);
					if (_tmp13_ == '.') {
						result = i;
						return result;
					}
				}
			}
		}
	}
	result = l;
	return result;
}


void utils_delete_file (GFile* file) {
	GError * _inner_error_ = NULL;
	g_return_if_fail (file != NULL);
	{
		GFile* _tmp0_;
		_tmp0_ = file;
		g_file_delete (_tmp0_, NULL, &_inner_error_);
		if (_inner_error_ != NULL) {
			goto __catch41_g_error;
		}
	}
	goto __finally41;
	__catch41_g_error:
	{
		GError* e = NULL;
		GFile* _tmp1_;
		gchar* _tmp2_ = NULL;
		gchar* _tmp3_;
		GError* _tmp4_;
		const gchar* _tmp5_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp1_ = file;
		_tmp2_ = g_file_get_parse_name (_tmp1_);
		_tmp3_ = _tmp2_;
		_tmp4_ = e;
		_tmp5_ = _tmp4_->message;
		g_warning ("utils.vala:163: Delete file '%s' failed: %s", _tmp3_, _tmp5_);
		_g_free0 (_tmp3_);
		_g_error_free0 (e);
	}
	__finally41:
	if (_inner_error_ != NULL) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
}


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


static void _g_object_unref0_ (gpointer var) {
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}


static void _g_list_free__g_object_unref0_ (GList* self) {
	g_list_foreach (self, (GFunc) _g_object_unref0_, NULL);
	g_list_free (self);
}


gchar* utils_get_relative_path (GFile* origin, GFile* target, GFile* common_dir) {
	gchar* result = NULL;
	GFile* origin_dir = NULL;
	GFile* _tmp0_;
	GFile* _tmp1_;
	gboolean _tmp2_ = FALSE;
	GFile* _tmp7_;
	GFile* _tmp8_ = NULL;
	GFile* target_parent;
	GFile* _tmp9_;
	GFile* _tmp10_;
	GFile* _tmp11_;
	GFile* _tmp12_;
	gboolean _tmp13_ = FALSE;
	GList* target_dirs;
	GList* origin_dirs;
	guint dir_index;
	guint _tmp56_;
	guint nb_common_dirs;
	gchar* _tmp57_;
	gchar* relative_path;
	GList* _tmp58_;
	guint _tmp59_ = 0U;
	guint _tmp60_;
	guint nb_remaining_origin_dirs;
	const gchar* _tmp86_;
	GFile* _tmp87_;
	gchar* _tmp88_ = NULL;
	gchar* _tmp89_;
	gchar* _tmp90_;
	g_return_val_if_fail (origin != NULL, NULL);
	g_return_val_if_fail (target != NULL, NULL);
	g_return_val_if_fail (common_dir != NULL, NULL);
	_tmp0_ = origin;
	_tmp1_ = common_dir;
	_tmp2_ = g_file_equal (_tmp0_, _tmp1_);
	if (_tmp2_) {
		GFile* _tmp3_;
		GFile* _tmp4_;
		_tmp3_ = origin;
		_tmp4_ = _g_object_ref0 (_tmp3_);
		_g_object_unref0 (origin_dir);
		origin_dir = _tmp4_;
	} else {
		GFile* _tmp5_;
		GFile* _tmp6_ = NULL;
		_tmp5_ = origin;
		_tmp6_ = g_file_get_parent (_tmp5_);
		_g_object_unref0 (origin_dir);
		origin_dir = _tmp6_;
	}
	_tmp7_ = target;
	_tmp8_ = g_file_get_parent (_tmp7_);
	target_parent = _tmp8_;
	_tmp9_ = origin_dir;
	g_return_val_if_fail (_tmp9_ != NULL, NULL);
	_tmp10_ = target_parent;
	g_return_val_if_fail (_tmp10_ != NULL, NULL);
	_tmp11_ = target_parent;
	_tmp12_ = origin_dir;
	_tmp13_ = g_file_equal (_tmp11_, _tmp12_);
	if (_tmp13_) {
		GFile* _tmp14_;
		gchar* _tmp15_ = NULL;
		_tmp14_ = target;
		_tmp15_ = g_file_get_basename (_tmp14_);
		result = _tmp15_;
		_g_object_unref0 (target_parent);
		_g_object_unref0 (origin_dir);
		return result;
	}
	target_dirs = NULL;
	origin_dirs = NULL;
	while (TRUE) {
		gboolean _tmp16_ = FALSE;
		GFile* _tmp17_;
		gboolean _tmp21_;
		GFile* _tmp22_;
		GFile* _tmp23_;
		GFile* _tmp24_;
		GFile* _tmp25_ = NULL;
		_tmp17_ = target_parent;
		if (_tmp17_ != NULL) {
			GFile* _tmp18_;
			GFile* _tmp19_;
			gboolean _tmp20_ = FALSE;
			_tmp18_ = target_parent;
			_tmp19_ = common_dir;
			_tmp20_ = g_file_equal (_tmp18_, _tmp19_);
			_tmp16_ = !_tmp20_;
		} else {
			_tmp16_ = FALSE;
		}
		_tmp21_ = _tmp16_;
		if (!_tmp21_) {
			break;
		}
		_tmp22_ = target_parent;
		_tmp23_ = _g_object_ref0 (_tmp22_);
		target_dirs = g_list_prepend (target_dirs, _tmp23_);
		_tmp24_ = target_parent;
		_tmp25_ = g_file_get_parent (_tmp24_);
		_g_object_unref0 (target_parent);
		target_parent = _tmp25_;
	}
	while (TRUE) {
		gboolean _tmp26_ = FALSE;
		GFile* _tmp27_;
		gboolean _tmp31_;
		GFile* _tmp32_;
		GFile* _tmp33_;
		GFile* _tmp34_;
		GFile* _tmp35_ = NULL;
		_tmp27_ = origin_dir;
		if (_tmp27_ != NULL) {
			GFile* _tmp28_;
			GFile* _tmp29_;
			gboolean _tmp30_ = FALSE;
			_tmp28_ = origin_dir;
			_tmp29_ = common_dir;
			_tmp30_ = g_file_equal (_tmp28_, _tmp29_);
			_tmp26_ = !_tmp30_;
		} else {
			_tmp26_ = FALSE;
		}
		_tmp31_ = _tmp26_;
		if (!_tmp31_) {
			break;
		}
		_tmp32_ = origin_dir;
		_tmp33_ = _g_object_ref0 (_tmp32_);
		origin_dirs = g_list_prepend (origin_dirs, _tmp33_);
		_tmp34_ = origin_dir;
		_tmp35_ = g_file_get_parent (_tmp34_);
		_g_object_unref0 (origin_dir);
		origin_dir = _tmp35_;
	}
	dir_index = (guint) 0;
	while (TRUE) {
		gboolean _tmp36_ = FALSE;
		guint _tmp37_;
		GList* _tmp38_;
		guint _tmp39_ = 0U;
		gboolean _tmp43_;
		GList* _tmp44_;
		guint _tmp45_;
		gconstpointer _tmp46_ = NULL;
		GFile* _tmp47_;
		GFile* cur_target_dir;
		GList* _tmp48_;
		guint _tmp49_;
		gconstpointer _tmp50_ = NULL;
		GFile* _tmp51_;
		GFile* cur_origin_dir;
		GFile* _tmp52_;
		GFile* _tmp53_;
		gboolean _tmp54_ = FALSE;
		guint _tmp55_;
		_tmp37_ = dir_index;
		_tmp38_ = target_dirs;
		_tmp39_ = g_list_length (_tmp38_);
		if (_tmp37_ < _tmp39_) {
			guint _tmp40_;
			GList* _tmp41_;
			guint _tmp42_ = 0U;
			_tmp40_ = dir_index;
			_tmp41_ = origin_dirs;
			_tmp42_ = g_list_length (_tmp41_);
			_tmp36_ = _tmp40_ < _tmp42_;
		} else {
			_tmp36_ = FALSE;
		}
		_tmp43_ = _tmp36_;
		if (!_tmp43_) {
			break;
		}
		_tmp44_ = target_dirs;
		_tmp45_ = dir_index;
		_tmp46_ = g_list_nth_data (_tmp44_, _tmp45_);
		_tmp47_ = _g_object_ref0 ((GFile*) _tmp46_);
		cur_target_dir = _tmp47_;
		_tmp48_ = origin_dirs;
		_tmp49_ = dir_index;
		_tmp50_ = g_list_nth_data (_tmp48_, _tmp49_);
		_tmp51_ = _g_object_ref0 ((GFile*) _tmp50_);
		cur_origin_dir = _tmp51_;
		_tmp52_ = cur_target_dir;
		_tmp53_ = cur_origin_dir;
		_tmp54_ = g_file_equal (_tmp52_, _tmp53_);
		if (!_tmp54_) {
			_g_object_unref0 (cur_origin_dir);
			_g_object_unref0 (cur_target_dir);
			break;
		}
		_tmp55_ = dir_index;
		dir_index = _tmp55_ + 1;
		_g_object_unref0 (cur_origin_dir);
		_g_object_unref0 (cur_target_dir);
	}
	_tmp56_ = dir_index;
	nb_common_dirs = _tmp56_;
	_tmp57_ = g_strdup ("");
	relative_path = _tmp57_;
	_tmp58_ = origin_dirs;
	_tmp59_ = g_list_length (_tmp58_);
	_tmp60_ = nb_common_dirs;
	nb_remaining_origin_dirs = _tmp59_ - _tmp60_;
	{
		guint i;
		i = (guint) 0;
		{
			gboolean _tmp61_;
			_tmp61_ = TRUE;
			while (TRUE) {
				gboolean _tmp62_;
				guint _tmp64_;
				guint _tmp65_;
				const gchar* _tmp66_;
				gchar* _tmp67_;
				_tmp62_ = _tmp61_;
				if (!_tmp62_) {
					guint _tmp63_;
					_tmp63_ = i;
					i = _tmp63_ + 1;
				}
				_tmp61_ = FALSE;
				_tmp64_ = i;
				_tmp65_ = nb_remaining_origin_dirs;
				if (!(_tmp64_ < _tmp65_)) {
					break;
				}
				_tmp66_ = relative_path;
				_tmp67_ = g_strconcat (_tmp66_, "../", NULL);
				_g_free0 (relative_path);
				relative_path = _tmp67_;
			}
		}
	}
	{
		guint _tmp68_;
		guint i;
		_tmp68_ = nb_common_dirs;
		i = _tmp68_;
		{
			gboolean _tmp69_;
			_tmp69_ = TRUE;
			while (TRUE) {
				gboolean _tmp70_;
				guint _tmp72_;
				GList* _tmp73_;
				guint _tmp74_ = 0U;
				GList* _tmp75_;
				guint _tmp76_;
				gconstpointer _tmp77_ = NULL;
				GFile* _tmp78_;
				GFile* cur_target_dir;
				const gchar* _tmp79_;
				GFile* _tmp80_;
				gchar* _tmp81_ = NULL;
				gchar* _tmp82_;
				gchar* _tmp83_;
				gchar* _tmp84_;
				gchar* _tmp85_;
				_tmp70_ = _tmp69_;
				if (!_tmp70_) {
					guint _tmp71_;
					_tmp71_ = i;
					i = _tmp71_ + 1;
				}
				_tmp69_ = FALSE;
				_tmp72_ = i;
				_tmp73_ = target_dirs;
				_tmp74_ = g_list_length (_tmp73_);
				if (!(_tmp72_ < _tmp74_)) {
					break;
				}
				_tmp75_ = target_dirs;
				_tmp76_ = i;
				_tmp77_ = g_list_nth_data (_tmp75_, _tmp76_);
				_tmp78_ = _g_object_ref0 ((GFile*) _tmp77_);
				cur_target_dir = _tmp78_;
				_tmp79_ = relative_path;
				_tmp80_ = cur_target_dir;
				_tmp81_ = g_file_get_basename (_tmp80_);
				_tmp82_ = _tmp81_;
				_tmp83_ = g_strconcat (_tmp82_, "/", NULL);
				_tmp84_ = _tmp83_;
				_tmp85_ = g_strconcat (_tmp79_, _tmp84_, NULL);
				_g_free0 (relative_path);
				relative_path = _tmp85_;
				_g_free0 (_tmp84_);
				_g_free0 (_tmp82_);
				_g_object_unref0 (cur_target_dir);
			}
		}
	}
	_tmp86_ = relative_path;
	_tmp87_ = target;
	_tmp88_ = g_file_get_basename (_tmp87_);
	_tmp89_ = _tmp88_;
	_tmp90_ = g_strconcat (_tmp86_, _tmp89_, NULL);
	_g_free0 (relative_path);
	relative_path = _tmp90_;
	_g_free0 (_tmp89_);
	result = relative_path;
	__g_list_free__g_object_unref0_0 (origin_dirs);
	__g_list_free__g_object_unref0_0 (target_dirs);
	_g_object_unref0 (target_parent);
	_g_object_unref0 (origin_dir);
	return result;
}


/*************************************************************************/
GtkWidget* utils_add_scrollbar (GtkWidget* child) {
	GtkWidget* result = NULL;
	GtkScrolledWindow* _tmp0_;
	GtkScrolledWindow* _tmp1_;
	GtkScrolledWindow* scrollbar;
	GtkWidget* _tmp2_;
	g_return_val_if_fail (child != NULL, NULL);
	_tmp0_ = (GtkScrolledWindow*) gtk_scrolled_window_new (NULL, NULL);
	_tmp1_ = g_object_ref_sink (_tmp0_);
	scrollbar = _tmp1_;
	gtk_scrolled_window_set_policy (scrollbar, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	_tmp2_ = child;
	gtk_container_add ((GtkContainer*) scrollbar, _tmp2_);
	result = (GtkWidget*) scrollbar;
	return result;
}


void utils_set_entry_error (GtkWidget* entry, gboolean _error_) {
	gboolean _tmp0_;
	g_return_if_fail (entry != NULL);
	_tmp0_ = _error_;
	if (_tmp0_) {
		GdkColor red = {0};
		GdkColor white = {0};
		GdkColor _tmp1_ = {0};
		GdkColor _tmp2_ = {0};
		GtkWidget* _tmp3_;
		GdkColor _tmp4_;
		GtkWidget* _tmp5_;
		GdkColor _tmp6_;
		gdk_color_parse ("#FF6666", &_tmp1_);
		red = _tmp1_;
		gdk_color_parse ("white", &_tmp2_);
		white = _tmp2_;
		_tmp3_ = entry;
		_tmp4_ = red;
		gtk_widget_modify_base (_tmp3_, GTK_STATE_NORMAL, &_tmp4_);
		_tmp5_ = entry;
		_tmp6_ = white;
		gtk_widget_modify_text (_tmp5_, GTK_STATE_NORMAL, &_tmp6_);
	} else {
		GtkWidget* _tmp7_;
		GtkWidget* _tmp8_;
		_tmp7_ = entry;
		gtk_widget_modify_base (_tmp7_, GTK_STATE_NORMAL, NULL);
		_tmp8_ = entry;
		gtk_widget_modify_text (_tmp8_, GTK_STATE_NORMAL, NULL);
	}
}


gboolean utils_tree_model_iter_prev (GtkTreeModel* model, GtkTreeIter* iter) {
	gboolean result = FALSE;
	GtkTreeModel* _tmp0_;
	GtkTreeIter _tmp1_;
	GtkTreePath* _tmp2_ = NULL;
	GtkTreePath* path;
	GtkTreePath* _tmp3_;
	gboolean _tmp4_ = FALSE;
	g_return_val_if_fail (model != NULL, FALSE);
	g_return_val_if_fail (iter != NULL, FALSE);
	_tmp0_ = model;
	_tmp1_ = *iter;
	_tmp2_ = gtk_tree_model_get_path (_tmp0_, &_tmp1_);
	path = _tmp2_;
	_tmp3_ = path;
	_tmp4_ = gtk_tree_path_prev (_tmp3_);
	if (_tmp4_) {
		GtkTreeModel* _tmp5_;
		GtkTreePath* _tmp6_;
		GtkTreeIter _tmp7_ = {0};
		gboolean _tmp8_ = FALSE;
		gboolean ret;
		_tmp5_ = model;
		_tmp6_ = path;
		_tmp8_ = gtk_tree_model_get_iter (_tmp5_, &_tmp7_, _tmp6_);
		*iter = _tmp7_;
		ret = _tmp8_;
		result = ret;
		_gtk_tree_path_free0 (path);
		return result;
	}
	result = FALSE;
	_gtk_tree_path_free0 (path);
	return result;
}


gint utils_get_selected_row (GtkTreeView* view, GtkTreeIter* iter) {
	GtkTreeIter _vala_iter = {0};
	gint result = 0;
	GtkTreeView* _tmp0_;
	GtkTreeSelection* _tmp1_ = NULL;
	GtkTreeSelection* _tmp2_;
	GtkTreeSelection* select;
	GtkTreeSelection* _tmp3_;
	GtkTreeIter _tmp4_ = {0};
	gboolean _tmp5_ = FALSE;
	g_return_val_if_fail (view != NULL, 0);
	_tmp0_ = view;
	_tmp1_ = gtk_tree_view_get_selection (_tmp0_);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	select = _tmp2_;
	_tmp3_ = select;
	_tmp5_ = gtk_tree_selection_get_selected (_tmp3_, NULL, &_tmp4_);
	_vala_iter = _tmp4_;
	if (_tmp5_) {
		GtkTreeView* _tmp6_;
		GtkTreeModel* _tmp7_ = NULL;
		GtkTreeModel* _tmp8_;
		GtkTreeModel* model;
		GtkTreeModel* _tmp9_;
		GtkTreeIter _tmp10_;
		GtkTreePath* _tmp11_ = NULL;
		GtkTreePath* path;
		GtkTreePath* _tmp12_;
		gint* _tmp13_ = NULL;
		gint _tmp14_;
		_tmp6_ = view;
		_tmp7_ = gtk_tree_view_get_model (_tmp6_);
		_tmp8_ = _g_object_ref0 (_tmp7_);
		model = _tmp8_;
		_tmp9_ = model;
		_tmp10_ = _vala_iter;
		_tmp11_ = gtk_tree_model_get_path (_tmp9_, &_tmp10_);
		path = _tmp11_;
		_tmp12_ = path;
		_tmp13_ = gtk_tree_path_get_indices (_tmp12_);
		_tmp14_ = _tmp13_[0];
		result = _tmp14_;
		_gtk_tree_path_free0 (path);
		_g_object_unref0 (model);
		_g_object_unref0 (select);
		if (iter) {
			*iter = _vala_iter;
		}
		return result;
	}
	result = -1;
	_g_object_unref0 (select);
	if (iter) {
		*iter = _vala_iter;
	}
	return result;
}


GdkPixbuf* utils_get_pixbuf_from_stock (const gchar* stock_id, GtkIconSize size) {
	GdkPixbuf* result = NULL;
	GtkInvisible* _tmp0_;
	GtkInvisible* _tmp1_;
	GtkInvisible* w;
	const gchar* _tmp2_;
	GtkIconSize _tmp3_;
	GdkPixbuf* _tmp4_ = NULL;
	GdkPixbuf* pixbuf;
	g_return_val_if_fail (stock_id != NULL, NULL);
	_tmp0_ = (GtkInvisible*) gtk_invisible_new ();
	_tmp1_ = g_object_ref_sink (_tmp0_);
	w = _tmp1_;
	_tmp2_ = stock_id;
	_tmp3_ = size;
	_tmp4_ = gtk_widget_render_icon ((GtkWidget*) w, _tmp2_, _tmp3_, "vala");
	pixbuf = _tmp4_;
	result = pixbuf;
	_g_object_unref0 (w);
	return result;
}


GtkButton* utils_get_toolbar_button (const gchar* stock_id) {
	GtkButton* result = NULL;
	const gchar* _tmp0_;
	GtkButton* _tmp1_ = NULL;
	g_return_val_if_fail (stock_id != NULL, NULL);
	_tmp0_ = stock_id;
	_tmp1_ = _utils_get_toolbar_button_impl (_tmp0_, FALSE);
	result = _tmp1_;
	return result;
}


GtkToggleButton* utils_get_toolbar_toggle_button (const gchar* stock_id) {
	GtkToggleButton* result = NULL;
	const gchar* _tmp0_;
	GtkButton* _tmp1_ = NULL;
	g_return_val_if_fail (stock_id != NULL, NULL);
	_tmp0_ = stock_id;
	_tmp1_ = _utils_get_toolbar_button_impl (_tmp0_, TRUE);
	result = GTK_TOGGLE_BUTTON (_tmp1_);
	return result;
}


GtkButton* _utils_get_toolbar_button_impl (const gchar* stock_id, gboolean toggle) {
	GtkButton* result = NULL;
	GtkButton* button = NULL;
	gboolean _tmp0_;
	const gchar* _tmp5_;
	GtkImage* _tmp6_;
	GtkImage* _tmp7_;
	GtkImage* image;
	GtkButton* _tmp8_;
	GtkButton* _tmp9_;
	g_return_val_if_fail (stock_id != NULL, NULL);
	_tmp0_ = toggle;
	if (_tmp0_) {
		GtkToggleButton* _tmp1_;
		GtkButton* _tmp2_;
		_tmp1_ = (GtkToggleButton*) gtk_toggle_button_new ();
		_tmp2_ = (GtkButton*) g_object_ref_sink (_tmp1_);
		_g_object_unref0 (button);
		button = _tmp2_;
	} else {
		GtkButton* _tmp3_;
		GtkButton* _tmp4_;
		_tmp3_ = (GtkButton*) gtk_button_new ();
		_tmp4_ = g_object_ref_sink (_tmp3_);
		_g_object_unref0 (button);
		button = _tmp4_;
	}
	_tmp5_ = stock_id;
	_tmp6_ = (GtkImage*) gtk_image_new_from_stock (_tmp5_, GTK_ICON_SIZE_MENU);
	_tmp7_ = g_object_ref_sink (_tmp6_);
	image = _tmp7_;
	_tmp8_ = button;
	gtk_container_add ((GtkContainer*) _tmp8_, (GtkWidget*) image);
	_tmp9_ = button;
	gtk_button_set_relief (_tmp9_, GTK_RELIEF_NONE);
	result = button;
	_g_object_unref0 (image);
	return result;
}


GtkWidget* utils_get_dialog_component (const gchar* title, GtkWidget* widget) {
	GtkWidget* result = NULL;
	GtkVBox* _tmp0_;
	GtkVBox* _tmp1_;
	GtkVBox* vbox;
	GtkLabel* _tmp2_;
	GtkLabel* _tmp3_;
	GtkLabel* label;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	GtkAlignment* _tmp9_;
	GtkAlignment* _tmp10_;
	GtkAlignment* alignment;
	GtkWidget* _tmp11_;
	g_return_val_if_fail (title != NULL, NULL);
	g_return_val_if_fail (widget != NULL, NULL);
	_tmp0_ = (GtkVBox*) gtk_vbox_new (FALSE, 6);
	_tmp1_ = g_object_ref_sink (_tmp0_);
	vbox = _tmp1_;
	gtk_container_set_border_width ((GtkContainer*) vbox, (guint) 6);
	_tmp2_ = (GtkLabel*) gtk_label_new (NULL);
	_tmp3_ = g_object_ref_sink (_tmp2_);
	label = _tmp3_;
	_tmp4_ = title;
	_tmp5_ = g_strconcat ("<b>", _tmp4_, NULL);
	_tmp6_ = _tmp5_;
	_tmp7_ = g_strconcat (_tmp6_, "</b>", NULL);
	_tmp8_ = _tmp7_;
	gtk_label_set_markup (label, _tmp8_);
	_g_free0 (_tmp8_);
	_g_free0 (_tmp6_);
	g_object_set ((GtkMisc*) label, "xalign", (gfloat) 0.0, NULL);
	gtk_box_pack_start ((GtkBox*) vbox, (GtkWidget*) label, FALSE, FALSE, (guint) 0);
	_tmp9_ = (GtkAlignment*) gtk_alignment_new ((gfloat) 0.5, (gfloat) 0.5, (gfloat) 1.0, (gfloat) 1.0);
	_tmp10_ = g_object_ref_sink (_tmp9_);
	alignment = _tmp10_;
	g_object_set (alignment, "left-padding", (guint) 12, NULL);
	_tmp11_ = widget;
	gtk_container_add ((GtkContainer*) alignment, _tmp11_);
	gtk_box_pack_start ((GtkBox*) vbox, (GtkWidget*) alignment, TRUE, TRUE, (guint) 0);
	result = (GtkWidget*) vbox;
	_g_object_unref0 (alignment);
	_g_object_unref0 (label);
	return result;
}


/*************************************************************************/
void utils_flush_queue (void) {
	while (TRUE) {
		gboolean _tmp0_ = FALSE;
		_tmp0_ = gtk_events_pending ();
		if (!_tmp0_) {
			break;
		}
		gtk_main_iteration ();
	}
}


guint utils_get_window_workspace (GtkWindow* gtkwindow) {
	guint result = 0U;
	GtkWindow* _tmp0_;
	gboolean _tmp1_ = FALSE;
	guint ret;
	GtkWindow* _tmp2_;
	GdkWindow* _tmp3_ = NULL;
	GdkWindow* _tmp4_;
	GdkWindow* window;
	GdkWindow* _tmp5_;
	GdkDisplay* _tmp6_ = NULL;
	GdkDisplay* _tmp7_;
	GdkDisplay* display;
	GdkDisplay* _tmp8_;
	Display* _tmp9_ = NULL;
	Display* x_display;
	Atom type = {0};
	gint format = 0;
	gulong nitems = 0UL;
	gulong bytes_after = 0UL;
	guint* workspace = NULL;
	Display* _tmp10_;
	GdkWindow* _tmp11_;
	XID _tmp12_ = 0;
	GdkDisplay* _tmp13_;
	Atom _tmp14_ = {0};
	glong _tmp15_;
	Atom _tmp16_ = {0};
	gint _tmp17_ = 0;
	gulong _tmp18_ = 0UL;
	gulong _tmp19_ = 0UL;
	void* _tmp20_ = NULL;
	gint _tmp21_ = 0;
	gint _result_;
	gint _tmp22_ = 0;
	gint err;
	gboolean _tmp23_ = FALSE;
	gint _tmp24_;
	gint _tmp25_;
	gboolean _tmp28_;
	gboolean _tmp29_ = FALSE;
	gboolean _tmp30_ = FALSE;
	Atom _tmp31_;
	gboolean _tmp33_;
	gboolean _tmp35_;
	guint* _tmp38_;
	g_return_val_if_fail (gtkwindow != NULL, 0U);
	_tmp0_ = gtkwindow;
	_tmp1_ = gtk_widget_get_realized ((GtkWidget*) _tmp0_);
	g_return_val_if_fail (_tmp1_, 0);
	ret = UTILS_ALL_WORKSPACES;
	_tmp2_ = gtkwindow;
	_tmp3_ = gtk_widget_get_window ((GtkWidget*) _tmp2_);
	_tmp4_ = _g_object_ref0 (_tmp3_);
	window = _tmp4_;
	_tmp5_ = window;
	_tmp6_ = gdk_drawable_get_display ((GdkDrawable*) _tmp5_);
	_tmp7_ = _g_object_ref0 (_tmp6_);
	display = _tmp7_;
	_tmp8_ = display;
	_tmp9_ = gdk_x11_display_get_xdisplay (_tmp8_);
	x_display = _tmp9_;
	gdk_error_trap_push ();
	_tmp10_ = x_display;
	_tmp11_ = window;
	_tmp12_ = gdk_x11_drawable_get_xid ((GdkDrawable*) _tmp11_);
	_tmp13_ = display;
	_tmp14_ = gdk_x11_get_xatom_by_name_for_display (_tmp13_, "_NET_WM_DESKTOP");
	_tmp15_ = G_MAXLONG;
	_tmp21_ = XGetWindowProperty (_tmp10_, (Window) _tmp12_, _tmp14_, (glong) 0, _tmp15_, FALSE, XA_CARDINAL, &_tmp16_, &_tmp17_, &_tmp18_, &_tmp19_, (unsigned char **) (&_tmp20_));
	type = _tmp16_;
	format = _tmp17_;
	nitems = _tmp18_;
	bytes_after = _tmp19_;
	workspace = _tmp20_;
	_result_ = _tmp21_;
	_tmp22_ = gdk_error_trap_pop ();
	err = _tmp22_;
	_tmp24_ = err;
	_tmp25_ = Success;
	if (_tmp24_ != _tmp25_) {
		_tmp23_ = TRUE;
	} else {
		gint _tmp26_;
		gint _tmp27_;
		_tmp26_ = _result_;
		_tmp27_ = Success;
		_tmp23_ = _tmp26_ != _tmp27_;
	}
	_tmp28_ = _tmp23_;
	if (_tmp28_) {
		result = ret;
		_g_object_unref0 (display);
		_g_object_unref0 (window);
		return result;
	}
	_tmp31_ = type;
	if (_tmp31_ == XA_CARDINAL) {
		gint _tmp32_;
		_tmp32_ = format;
		_tmp30_ = _tmp32_ == 32;
	} else {
		_tmp30_ = FALSE;
	}
	_tmp33_ = _tmp30_;
	if (_tmp33_) {
		gulong _tmp34_;
		_tmp34_ = nitems;
		_tmp29_ = _tmp34_ > ((gulong) 0);
	} else {
		_tmp29_ = FALSE;
	}
	_tmp35_ = _tmp29_;
	if (_tmp35_) {
		guint* _tmp36_;
		guint _tmp37_;
		_tmp36_ = workspace;
		_tmp37_ = _tmp36_[0];
		ret = _tmp37_;
	}
	_tmp38_ = workspace;
	XFree (_tmp38_);
	result = ret;
	_g_object_unref0 (display);
	_g_object_unref0 (window);
	return result;
}


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


void utils_print_build_tool (BuildTool* build_tool) {
	FILE* _tmp0_;
	FILE* _tmp1_;
	BuildTool _tmp2_;
	const gchar* _tmp3_;
	FILE* _tmp4_;
	BuildTool _tmp5_;
	const gchar* _tmp6_;
	FILE* _tmp7_;
	BuildTool _tmp8_;
	const gchar* _tmp9_;
	FILE* _tmp10_;
	BuildTool _tmp11_;
	const gchar* _tmp12_;
	g_return_if_fail (build_tool != NULL);
	_tmp0_ = stdout;
	fprintf (_tmp0_, "\n=== Build Tool ===\n");
	_tmp1_ = stdout;
	_tmp2_ = *build_tool;
	_tmp3_ = _tmp2_.description;
	fprintf (_tmp1_, "desc: %s\n", _tmp3_);
	_tmp4_ = stdout;
	_tmp5_ = *build_tool;
	_tmp6_ = _tmp5_.extensions;
	fprintf (_tmp4_, "ext: %s\n", _tmp6_);
	_tmp7_ = stdout;
	_tmp8_ = *build_tool;
	_tmp9_ = _tmp8_.label;
	fprintf (_tmp7_, "label: %s\n", _tmp9_);
	_tmp10_ = stdout;
	_tmp11_ = *build_tool;
	_tmp12_ = _tmp11_.icon;
	fprintf (_tmp10_, "icon: %s\n\n", _tmp12_);
	{
		BuildTool _tmp13_;
		GeeArrayList* _tmp14_;
		GeeArrayList* _tmp15_;
		GeeArrayList* _build_job_list;
		GeeArrayList* _tmp16_;
		gint _tmp17_;
		gint _tmp18_;
		gint _build_job_size;
		gint _build_job_index;
		_tmp13_ = *build_tool;
		_tmp14_ = _tmp13_.jobs;
		_tmp15_ = _g_object_ref0 (_tmp14_);
		_build_job_list = _tmp15_;
		_tmp16_ = _build_job_list;
		_tmp17_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp16_);
		_tmp18_ = _tmp17_;
		_build_job_size = _tmp18_;
		_build_job_index = -1;
		while (TRUE) {
			gint _tmp19_;
			gint _tmp20_;
			gint _tmp21_;
			GeeArrayList* _tmp22_;
			gint _tmp23_;
			gpointer _tmp24_ = NULL;
			BuildJob* _tmp25_;
			BuildJob _tmp26_ = {0};
			BuildJob _tmp27_;
			BuildJob build_job;
			FILE* _tmp28_;
			FILE* _tmp29_;
			BuildJob _tmp30_;
			gboolean _tmp31_;
			gchar* _tmp32_ = NULL;
			gchar* _tmp33_;
			FILE* _tmp34_;
			BuildJob _tmp35_;
			PostProcessorType _tmp36_;
			gchar* _tmp37_ = NULL;
			gchar* _tmp38_;
			FILE* _tmp39_;
			BuildJob _tmp40_;
			const gchar* _tmp41_;
			_tmp19_ = _build_job_index;
			_build_job_index = _tmp19_ + 1;
			_tmp20_ = _build_job_index;
			_tmp21_ = _build_job_size;
			if (!(_tmp20_ < _tmp21_)) {
				break;
			}
			_tmp22_ = _build_job_list;
			_tmp23_ = _build_job_index;
			_tmp24_ = gee_abstract_list_get ((GeeAbstractList*) _tmp22_, _tmp23_);
			_tmp25_ = (BuildJob*) _tmp24_;
			build_job_copy (_tmp25_, &_tmp26_);
			_tmp27_ = _tmp26_;
			_build_job_free0 (_tmp25_);
			build_job = _tmp27_;
			_tmp28_ = stdout;
			fprintf (_tmp28_, "== Build Job ==\n");
			_tmp29_ = stdout;
			_tmp30_ = build_job;
			_tmp31_ = _tmp30_.must_succeed;
			_tmp32_ = bool_to_string (_tmp31_);
			_tmp33_ = _tmp32_;
			fprintf (_tmp29_, "must succeed: %s\n", _tmp33_);
			_g_free0 (_tmp33_);
			_tmp34_ = stdout;
			_tmp35_ = build_job;
			_tmp36_ = _tmp35_.post_processor;
			_tmp37_ = build_tools_get_post_processor_name_from_type (_tmp36_);
			_tmp38_ = _tmp37_;
			fprintf (_tmp34_, "post processor: %s\n", _tmp38_);
			_g_free0 (_tmp38_);
			_tmp39_ = stdout;
			_tmp40_ = build_job;
			_tmp41_ = _tmp40_.command;
			fprintf (_tmp39_, "command: %s\n\n", _tmp41_);
			build_job_destroy (&build_job);
		}
		_g_object_unref0 (_build_job_list);
	}
}



