/* vtgprojectexecuterdialog.c generated by valac 0.12.1.1-323029-dirty, the Vala compiler
 * generated from vtgprojectexecuterdialog.vala, do not modify */

/*
 *  vtgprojectexecuterdialog.vala - Vala developer toys for GEdit
 *  
 *  Copyright (C) 2008 - Andrea Del Signore <sejerpz@tin.it>
 *  
 *  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., 59 Temple Place, Suite 330,
 *  Boston, MA 02111-1307, USA.
 */

#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <gdk/gdk.h>
#include <valagee.h>
#include <vbf.h>
#include <gdk/gdkkeysyms.h>
#include <float.h>
#include <math.h>
#include <gobject/gvaluecollector.h>


#define VTG_TYPE_PROJECT_EXECUTER_DIALOG (vtg_project_executer_dialog_get_type ())
#define VTG_PROJECT_EXECUTER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VTG_TYPE_PROJECT_EXECUTER_DIALOG, VtgProjectExecuterDialog))
#define VTG_PROJECT_EXECUTER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VTG_TYPE_PROJECT_EXECUTER_DIALOG, VtgProjectExecuterDialogClass))
#define VTG_IS_PROJECT_EXECUTER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VTG_TYPE_PROJECT_EXECUTER_DIALOG))
#define VTG_IS_PROJECT_EXECUTER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VTG_TYPE_PROJECT_EXECUTER_DIALOG))
#define VTG_PROJECT_EXECUTER_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VTG_TYPE_PROJECT_EXECUTER_DIALOG, VtgProjectExecuterDialogClass))

typedef struct _VtgProjectExecuterDialog VtgProjectExecuterDialog;
typedef struct _VtgProjectExecuterDialogClass VtgProjectExecuterDialogClass;
typedef struct _VtgProjectExecuterDialogPrivate VtgProjectExecuterDialogPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define VTG_TYPE_PROJECT_MANAGER (vtg_project_manager_get_type ())
#define VTG_PROJECT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VTG_TYPE_PROJECT_MANAGER, VtgProjectManager))
#define VTG_PROJECT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VTG_TYPE_PROJECT_MANAGER, VtgProjectManagerClass))
#define VTG_IS_PROJECT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VTG_TYPE_PROJECT_MANAGER))
#define VTG_IS_PROJECT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VTG_TYPE_PROJECT_MANAGER))
#define VTG_PROJECT_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VTG_TYPE_PROJECT_MANAGER, VtgProjectManagerClass))

typedef struct _VtgProjectManager VtgProjectManager;
typedef struct _VtgProjectManagerClass VtgProjectManagerClass;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _VtgProjectManagerPrivate VtgProjectManagerPrivate;

#define VTG_TYPE_VCS_TYPES (vtg_vcs_types_get_type ())
#define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))
#define _gtk_tree_path_free0(var) ((var == NULL) ? NULL : (var = (gtk_tree_path_free (var), NULL)))
typedef struct _VtgParamSpecProjectExecuterDialog VtgParamSpecProjectExecuterDialog;

struct _VtgProjectExecuterDialog {
	GTypeInstance parent_instance;
	volatile int ref_count;
	VtgProjectExecuterDialogPrivate * priv;
};

struct _VtgProjectExecuterDialogClass {
	GTypeClass parent_class;
	void (*finalize) (VtgProjectExecuterDialog *self);
};

struct _VtgProjectExecuterDialogPrivate {
	GtkEntryCompletion* _completion;
	GtkDialog* _dialog;
	GtkTreeView* _tree;
	GtkButton* _button_exec;
};

typedef enum  {
	VTG_VCS_TYPES_NONE,
	VTG_VCS_TYPES_GIT,
	VTG_VCS_TYPES_BZR,
	VTG_VCS_TYPES_SVN
} VtgVcsTypes;

struct _VtgProjectManager {
	GObject parent_instance;
	VtgProjectManagerPrivate * priv;
	gchar* filename;
	gboolean is_default;
	ValaList* exec_targets;
	ValaList* all_vala_sources;
	VtgVcsTypes vcs_type;
	gchar* changelog_uri;
};

struct _VtgProjectManagerClass {
	GObjectClass parent_class;
};

struct _VtgParamSpecProjectExecuterDialog {
	GParamSpec parent_instance;
};


static gpointer vtg_project_executer_dialog_parent_class = NULL;
static GType vtg_project_executer_dialog_type_id = 0;

gpointer vtg_project_executer_dialog_ref (gpointer instance);
void vtg_project_executer_dialog_unref (gpointer instance);
GParamSpec* vtg_param_spec_project_executer_dialog (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void vtg_value_set_project_executer_dialog (GValue* value, gpointer v_object);
void vtg_value_take_project_executer_dialog (GValue* value, gpointer v_object);
gpointer vtg_value_get_project_executer_dialog (const GValue* value);
GType vtg_project_executer_dialog_get_type (void) G_GNUC_CONST;
GType vtg_project_executer_dialog_register_type (GTypeModule * module);
#define VTG_PROJECT_EXECUTER_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VTG_TYPE_PROJECT_EXECUTER_DIALOG, VtgProjectExecuterDialogPrivate))
enum  {
	VTG_PROJECT_EXECUTER_DIALOG_DUMMY_PROPERTY
};
GType vtg_project_manager_get_type (void) G_GNUC_CONST;
GType vtg_project_manager_register_type (GTypeModule * module);
VtgProjectExecuterDialog* vtg_project_executer_dialog_new (GtkWindow* parent, VtgProjectManager* project);
VtgProjectExecuterDialog* vtg_project_executer_dialog_construct (GType object_type, GtkWindow* parent, VtgProjectManager* project);
static void vtg_project_executer_dialog_initialize_ui (VtgProjectExecuterDialog* self, GtkWindow* parent, VtgProjectManager* project);
GtkListStore* vtg_caches_get_executer_cache (void);
gchar* vtg_utils_get_ui_path (const gchar* id);
static gboolean vtg_project_executer_dialog_on_entry_key_press (VtgProjectExecuterDialog* self, GtkWidget* sender, GdkEventKey* evt);
static gboolean _vtg_project_executer_dialog_on_entry_key_press_gtk_widget_key_press_event (GtkWidget* _sender, GdkEventKey* event, gpointer self);
static void vtg_project_executer_dialog_on_command_line_changed (VtgProjectExecuterDialog* self, GObject* pspec, GParamSpec* gobject);
static void _vtg_project_executer_dialog_on_command_line_changed_g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self);
static void vtg_project_executer_dialog_on_tree_selection_changed (VtgProjectExecuterDialog* self, GtkTreeSelection* treeselection);
static void _vtg_project_executer_dialog_on_tree_selection_changed_gtk_tree_selection_changed (GtkTreeSelection* _sender, gpointer self);
GType vtg_vcs_types_get_type (void) G_GNUC_CONST;
gint vtg_project_executer_dialog_run (VtgProjectExecuterDialog* self);
const gchar* vtg_project_executer_dialog_get_command_line (VtgProjectExecuterDialog* self);
gboolean vtg_string_utils_is_null_or_empty (const gchar* data);
gboolean vtg_caches_cache_contains (GtkListStore* cache, const gchar* data);
void vtg_caches_cache_add (GtkListStore* cache, const gchar* data);
static void vtg_project_executer_dialog_finalize (VtgProjectExecuterDialog* obj);


VtgProjectExecuterDialog* vtg_project_executer_dialog_construct (GType object_type, GtkWindow* parent, VtgProjectManager* project) {
	VtgProjectExecuterDialog* self = NULL;
	g_return_val_if_fail (parent != NULL, NULL);
	g_return_val_if_fail (project != NULL, NULL);
	self = (VtgProjectExecuterDialog*) g_type_create_instance (object_type);
	vtg_project_executer_dialog_initialize_ui (self, parent, project);
	return self;
}


VtgProjectExecuterDialog* vtg_project_executer_dialog_new (GtkWindow* parent, VtgProjectManager* project) {
	return vtg_project_executer_dialog_construct (VTG_TYPE_PROJECT_EXECUTER_DIALOG, parent, project);
}


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


static gboolean _vtg_project_executer_dialog_on_entry_key_press_gtk_widget_key_press_event (GtkWidget* _sender, GdkEventKey* event, gpointer self) {
	gboolean result;
	result = vtg_project_executer_dialog_on_entry_key_press (self, _sender, event);
	return result;
}


static void _vtg_project_executer_dialog_on_command_line_changed_g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) {
	vtg_project_executer_dialog_on_command_line_changed (self, _sender, pspec);
}


static void _vtg_project_executer_dialog_on_tree_selection_changed_gtk_tree_selection_changed (GtkTreeSelection* _sender, gpointer self) {
	vtg_project_executer_dialog_on_tree_selection_changed (self, _sender);
}


static gpointer _vala_iterable_ref0 (gpointer self) {
	return self ? vala_iterable_ref (self) : NULL;
}


static glong string_strnlen (gchar* str, glong maxlen) {
	glong result = 0L;
	gchar* _tmp0_ = NULL;
	gchar* end;
	_tmp0_ = memchr (str, 0, (gsize) maxlen);
	end = _tmp0_;
	if (end == NULL) {
		result = maxlen;
		return result;
	} else {
		result = (glong) (end - str);
		return result;
	}
}


static gchar* string_substring (const gchar* self, glong offset, glong len) {
	gchar* result = NULL;
	glong string_length = 0L;
	gboolean _tmp0_ = FALSE;
	gchar* _tmp3_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	if (offset >= 0) {
		_tmp0_ = len >= 0;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		glong _tmp1_;
		_tmp1_ = string_strnlen ((gchar*) self, offset + len);
		string_length = _tmp1_;
	} else {
		gint _tmp2_;
		_tmp2_ = strlen (self);
		string_length = (glong) _tmp2_;
	}
	if (offset < 0) {
		offset = string_length + offset;
		g_return_val_if_fail (offset >= 0, NULL);
	} else {
		g_return_val_if_fail (offset <= string_length, NULL);
	}
	if (len < 0) {
		len = string_length - offset;
	}
	g_return_val_if_fail ((offset + len) <= string_length, NULL);
	_tmp3_ = g_strndup (((gchar*) self) + offset, (gsize) len);
	result = _tmp3_;
	return result;
}


static void vtg_project_executer_dialog_initialize_ui (VtgProjectExecuterDialog* self, GtkWindow* parent, VtgProjectManager* project) {
	GtkListStore* _tmp0_ = NULL;
	GtkListStore* completions;
	GtkBuilder* _tmp1_ = NULL;
	GtkBuilder* builder;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_;
	GObject* _tmp4_ = NULL;
	GtkDialog* _tmp5_;
	GtkEntryCompletion* _tmp6_ = NULL;
	GObject* _tmp7_ = NULL;
	GtkEntry* _tmp8_;
	GtkEntry* entry;
	GObject* _tmp9_ = NULL;
	GtkButton* _tmp10_;
	GObject* _tmp11_ = NULL;
	GtkTreeView* _tmp12_;
	GtkTreeViewColumn* _tmp13_ = NULL;
	GtkTreeViewColumn* column;
	GtkCellRendererText* _tmp14_ = NULL;
	GtkCellRendererText* renderer;
	GtkTreeSelection* _tmp15_ = NULL;
	GtkTreeSelection* _tmp16_ = NULL;
	ValaList* _tmp17_;
	ValaList* targets;
	GtkTreeIter iter = {0};
	GtkListStore* _tmp18_ = NULL;
	GtkListStore* list;
	GtkTreeIter _tmp28_ = {0};
	gboolean _tmp29_;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (parent != NULL);
	g_return_if_fail (project != NULL);
	_tmp0_ = vtg_caches_get_executer_cache ();
	completions = _tmp0_;
	_tmp1_ = gtk_builder_new ();
	builder = _tmp1_;
	_tmp2_ = vtg_utils_get_ui_path ("vtg.ui");
	_tmp3_ = _tmp2_;
	gtk_builder_add_from_file (builder, _tmp3_, &_inner_error_);
	_g_free0 (_tmp3_);
	if (_inner_error_ != NULL) {
		goto __catch27_g_error;
	}
	goto __finally27;
	__catch27_g_error:
	{
		GError * err;
		err = _inner_error_;
		_inner_error_ = NULL;
		g_warning ("vtgprojectexecuterdialog.vala:54: initialize_ui: %s", err->message);
		_g_error_free0 (err);
	}
	__finally27:
	if (_inner_error_ != NULL) {
		_g_object_unref0 (builder);
		_g_object_unref0 (completions);
		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;
	}
	_tmp4_ = gtk_builder_get_object (builder, "dialog-run");
	_tmp5_ = _g_object_ref0 (GTK_DIALOG (_tmp4_));
	_g_object_unref0 (self->priv->_dialog);
	self->priv->_dialog = _tmp5_;
	g_assert (self->priv->_dialog != NULL);
	gtk_window_set_transient_for ((GtkWindow*) self->priv->_dialog, parent);
	_tmp6_ = gtk_entry_completion_new ();
	_g_object_unref0 (self->priv->_completion);
	self->priv->_completion = _tmp6_;
	gtk_entry_completion_set_model (self->priv->_completion, (GtkTreeModel*) completions);
	gtk_entry_completion_set_text_column (self->priv->_completion, 0);
	_tmp7_ = gtk_builder_get_object (builder, "entry-command-line");
	_tmp8_ = _g_object_ref0 (GTK_ENTRY (_tmp7_));
	entry = _tmp8_;
	g_assert (entry != NULL);
	gtk_entry_set_completion (entry, self->priv->_completion);
	g_signal_connect ((GtkWidget*) entry, "key-press-event", (GCallback) _vtg_project_executer_dialog_on_entry_key_press_gtk_widget_key_press_event, self);
	g_signal_connect ((GObject*) entry, "notify::text", (GCallback) _vtg_project_executer_dialog_on_command_line_changed_g_object_notify, self);
	_tmp9_ = gtk_builder_get_object (builder, "button-run-execute");
	_tmp10_ = _g_object_ref0 (GTK_BUTTON (_tmp9_));
	_g_object_unref0 (self->priv->_button_exec);
	self->priv->_button_exec = _tmp10_;
	g_assert (self->priv->_button_exec != NULL);
	_tmp11_ = gtk_builder_get_object (builder, "treeview-executables");
	_tmp12_ = _g_object_ref0 (GTK_TREE_VIEW (_tmp11_));
	_g_object_unref0 (self->priv->_tree);
	self->priv->_tree = _tmp12_;
	g_assert (self->priv->_tree != NULL);
	_tmp13_ = gtk_tree_view_column_new ();
	column = g_object_ref_sink (_tmp13_);
	_tmp14_ = (GtkCellRendererText*) gtk_cell_renderer_text_new ();
	renderer = g_object_ref_sink (_tmp14_);
	gtk_cell_layout_pack_start ((GtkCellLayout*) column, (GtkCellRenderer*) renderer, TRUE);
	gtk_cell_layout_add_attribute ((GtkCellLayout*) column, (GtkCellRenderer*) renderer, "text", 0);
	gtk_tree_view_append_column (self->priv->_tree, column);
	_tmp15_ = gtk_tree_view_get_selection (self->priv->_tree);
	gtk_tree_selection_set_mode (_tmp15_, GTK_SELECTION_SINGLE);
	_tmp16_ = gtk_tree_view_get_selection (self->priv->_tree);
	g_signal_connect (_tmp16_, "changed", (GCallback) _vtg_project_executer_dialog_on_tree_selection_changed_gtk_tree_selection_changed, self);
	_tmp17_ = _vala_iterable_ref0 (project->exec_targets);
	targets = _tmp17_;
	_tmp18_ = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
	list = _tmp18_;
	{
		ValaList* _tmp19_;
		ValaList* _target_list;
		gint _tmp20_;
		gint _target_size;
		gint _target_index;
		_tmp19_ = _vala_iterable_ref0 (targets);
		_target_list = _tmp19_;
		_tmp20_ = vala_collection_get_size ((ValaCollection*) _target_list);
		_target_size = _tmp20_;
		_target_index = -1;
		while (TRUE) {
			gpointer _tmp21_ = NULL;
			VbfTarget* target;
			GtkTreeIter _tmp22_ = {0};
			gchar* _tmp23_ = NULL;
			gchar* _tmp24_;
			gint _tmp25_;
			gchar* _tmp26_ = NULL;
			gchar* _tmp27_;
			gchar* path;
			_target_index = _target_index + 1;
			if (!(_target_index < _target_size)) {
				break;
			}
			_tmp21_ = vala_list_get (_target_list, _target_index);
			target = (VbfTarget*) _tmp21_;
			gtk_list_store_append (list, &_tmp22_);
			iter = _tmp22_;
			_tmp23_ = g_build_filename (target->group->id, target->name, NULL);
			_tmp24_ = _tmp23_;
			_tmp25_ = strlen (target->group->project->id);
			_tmp26_ = string_substring (_tmp24_, (glong) (_tmp25_ + 1), (glong) (-1));
			_tmp27_ = _tmp26_;
			_g_free0 (_tmp24_);
			path = _tmp27_;
			gtk_list_store_set (list, &iter, 0, target->name, 1, path, -1);
			_g_free0 (path);
			_g_object_unref0 (target);
		}
		_vala_iterable_unref0 (_target_list);
	}
	gtk_tree_view_set_model (self->priv->_tree, (GtkTreeModel*) list);
	_tmp29_ = gtk_tree_model_get_iter_first ((GtkTreeModel*) completions, &_tmp28_);
	iter = _tmp28_;
	if (_tmp29_) {
		gchar* val = NULL;
		gtk_tree_model_get ((GtkTreeModel*) completions, &iter, 0, &val, -1);
		gtk_entry_set_text (entry, val);
		gtk_editable_set_position ((GtkEditable*) entry, -1);
		_g_free0 (val);
	} else {
		GtkTreeIter _tmp30_ = {0};
		gboolean _tmp31_;
		_tmp31_ = gtk_tree_model_get_iter_first ((GtkTreeModel*) list, &_tmp30_);
		iter = _tmp30_;
		if (_tmp31_) {
			gchar* program = NULL;
			gtk_tree_model_get ((GtkTreeModel*) list, &iter, 1, &program, -1);
			gtk_entry_set_text (entry, program);
			gtk_editable_set_position ((GtkEditable*) entry, -1);
			_g_free0 (program);
		}
	}
	_g_object_unref0 (list);
	_vala_iterable_unref0 (targets);
	_g_object_unref0 (renderer);
	_g_object_unref0 (column);
	_g_object_unref0 (entry);
	_g_object_unref0 (builder);
	_g_object_unref0 (completions);
}


gint vtg_project_executer_dialog_run (VtgProjectExecuterDialog* self) {
	gint result = 0;
	gint _tmp0_;
	gint res;
	const gchar* _tmp1_ = NULL;
	gchar* _tmp2_;
	gchar* cmd;
	GtkListStore* _tmp3_ = NULL;
	GtkListStore* cache;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = gtk_dialog_run (self->priv->_dialog);
	res = _tmp0_;
	_tmp1_ = vtg_project_executer_dialog_get_command_line (self);
	_tmp2_ = g_strdup (_tmp1_);
	cmd = _tmp2_;
	_tmp3_ = vtg_caches_get_executer_cache ();
	cache = _tmp3_;
	_tmp5_ = vtg_string_utils_is_null_or_empty (cmd);
	if (!_tmp5_) {
		gboolean _tmp6_;
		_tmp6_ = vtg_caches_cache_contains (cache, cmd);
		_tmp4_ = !_tmp6_;
	} else {
		_tmp4_ = FALSE;
	}
	if (_tmp4_) {
		vtg_caches_cache_add (cache, cmd);
	}
	result = res;
	_g_object_unref0 (cache);
	_g_free0 (cmd);
	return result;
}


static void vtg_project_executer_dialog_on_tree_selection_changed (VtgProjectExecuterDialog* self, GtkTreeSelection* treeselection) {
	GtkTreeIter iter = {0};
	GtkTreeModel* m = NULL;
	GtkTreeModel* _tmp0_ = NULL;
	GtkTreeIter _tmp1_ = {0};
	gboolean _tmp2_;
	GtkTreeModel* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (treeselection != NULL);
	_tmp2_ = gtk_tree_selection_get_selected (treeselection, &_tmp0_, &_tmp1_);
	_g_object_unref0 (m);
	_tmp3_ = _g_object_ref0 (_tmp0_);
	m = _tmp3_;
	iter = _tmp1_;
	if (_tmp2_) {
		GtkListStore* _tmp4_;
		GtkListStore* model;
		gchar* program = NULL;
		GtkWidget* _tmp5_ = NULL;
		GtkEntry* _tmp6_;
		GtkEntry* entry;
		_tmp4_ = _g_object_ref0 (GTK_LIST_STORE (m));
		model = _tmp4_;
		gtk_tree_model_get ((GtkTreeModel*) model, &iter, 1, &program, -1);
		_tmp5_ = gtk_entry_completion_get_entry (self->priv->_completion);
		_tmp6_ = _g_object_ref0 (GTK_ENTRY (_tmp5_));
		entry = _tmp6_;
		gtk_entry_set_text (entry, program);
		gtk_editable_set_position ((GtkEditable*) entry, -1);
		_g_object_unref0 (entry);
		_g_free0 (program);
		_g_object_unref0 (model);
	}
	_g_object_unref0 (m);
}


static void vtg_project_executer_dialog_on_command_line_changed (VtgProjectExecuterDialog* self, GObject* pspec, GParamSpec* gobject) {
	GtkWidget* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	gboolean _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (pspec != NULL);
	g_return_if_fail (gobject != NULL);
	_tmp0_ = gtk_entry_completion_get_entry (self->priv->_completion);
	_tmp1_ = gtk_entry_get_text (GTK_ENTRY (_tmp0_));
	_tmp2_ = vtg_string_utils_is_null_or_empty (_tmp1_);
	gtk_widget_set_sensitive ((GtkWidget*) self->priv->_button_exec, !_tmp2_);
}


static gboolean vtg_project_executer_dialog_on_entry_key_press (VtgProjectExecuterDialog* self, GtkWidget* sender, GdkEventKey* evt) {
	gboolean result = FALSE;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (sender != NULL, FALSE);
	if ((*evt).keyval == GDK_KEY_Down) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = (*evt).keyval == GDK_KEY_Up;
	}
	if (_tmp0_) {
		GtkTreeIter sel = {0};
		GtkTreeModel* model = NULL;
		GtkTreePath* path = NULL;
		GtkTreeSelection* _tmp1_ = NULL;
		GtkTreeModel* _tmp2_ = NULL;
		GtkTreeIter _tmp3_ = {0};
		gboolean _tmp4_;
		GtkTreeModel* _tmp5_;
		GtkTreePath* _tmp13_ = NULL;
		GtkTreeSelection* _tmp14_ = NULL;
		_tmp1_ = gtk_tree_view_get_selection (self->priv->_tree);
		_tmp4_ = gtk_tree_selection_get_selected (_tmp1_, &_tmp2_, &_tmp3_);
		_g_object_unref0 (model);
		_tmp5_ = _g_object_ref0 (_tmp2_);
		model = _tmp5_;
		sel = _tmp3_;
		if (_tmp4_) {
			if ((*evt).keyval == GDK_KEY_Down) {
				gtk_tree_model_iter_next (model, &sel);
			} else {
				GtkTreePath* _tmp6_ = NULL;
				gboolean _tmp7_;
				_tmp6_ = gtk_tree_model_get_path (model, &sel);
				_gtk_tree_path_free0 (path);
				path = _tmp6_;
				_tmp7_ = gtk_tree_path_prev (path);
				if (_tmp7_) {
					GtkTreeIter _tmp8_ = {0};
					gtk_tree_model_get_iter (model, &_tmp8_, path);
					sel = _tmp8_;
				} else {
					GtkTreeSelection* _tmp9_ = NULL;
					_tmp9_ = gtk_tree_view_get_selection (self->priv->_tree);
					gtk_tree_selection_select_iter (_tmp9_, &sel);
				}
			}
		} else {
			GtkTreeModel* _tmp10_ = NULL;
			GtkTreeModel* _tmp11_;
			GtkTreeIter _tmp12_ = {0};
			_tmp10_ = gtk_tree_view_get_model (self->priv->_tree);
			_tmp11_ = _g_object_ref0 (_tmp10_);
			_g_object_unref0 (model);
			model = _tmp11_;
			gtk_tree_model_get_iter_first (model, &_tmp12_);
			sel = _tmp12_;
		}
		_tmp13_ = gtk_tree_model_get_path (model, &sel);
		_gtk_tree_path_free0 (path);
		path = _tmp13_;
		_tmp14_ = gtk_tree_view_get_selection (self->priv->_tree);
		gtk_tree_selection_select_iter (_tmp14_, &sel);
		gtk_tree_view_scroll_to_cell (self->priv->_tree, path, NULL, FALSE, (gfloat) 0, (gfloat) 0);
		result = TRUE;
		_gtk_tree_path_free0 (path);
		_g_object_unref0 (model);
		return result;
	}
	result = FALSE;
	return result;
}


const gchar* vtg_project_executer_dialog_get_command_line (VtgProjectExecuterDialog* self) {
	const gchar* result;
	GtkWidget* _tmp0_ = NULL;
	GtkEntry* _tmp1_;
	GtkEntry* en;
	const gchar* _tmp2_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = gtk_entry_completion_get_entry (self->priv->_completion);
	_tmp1_ = _g_object_ref0 (GTK_ENTRY (_tmp0_));
	en = _tmp1_;
	_tmp2_ = gtk_entry_get_text (en);
	result = _tmp2_;
	_g_object_unref0 (en);
	return result;
}


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


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


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


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


static gchar* vtg_value_project_executer_dialog_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	if (collect_values[0].v_pointer) {
		VtgProjectExecuterDialog* 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 = vtg_project_executer_dialog_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}


static gchar* vtg_value_project_executer_dialog_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	VtgProjectExecuterDialog** 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 = vtg_project_executer_dialog_ref (value->data[0].v_pointer);
	}
	return NULL;
}


GParamSpec* vtg_param_spec_project_executer_dialog (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
	VtgParamSpecProjectExecuterDialog* spec;
	g_return_val_if_fail (g_type_is_a (object_type, VTG_TYPE_PROJECT_EXECUTER_DIALOG), 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 vtg_value_get_project_executer_dialog (const GValue* value) {
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VTG_TYPE_PROJECT_EXECUTER_DIALOG), NULL);
	return value->data[0].v_pointer;
}


void vtg_value_set_project_executer_dialog (GValue* value, gpointer v_object) {
	VtgProjectExecuterDialog* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VTG_TYPE_PROJECT_EXECUTER_DIALOG));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, VTG_TYPE_PROJECT_EXECUTER_DIALOG));
		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;
		vtg_project_executer_dialog_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		vtg_project_executer_dialog_unref (old);
	}
}


void vtg_value_take_project_executer_dialog (GValue* value, gpointer v_object) {
	VtgProjectExecuterDialog* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VTG_TYPE_PROJECT_EXECUTER_DIALOG));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, VTG_TYPE_PROJECT_EXECUTER_DIALOG));
		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) {
		vtg_project_executer_dialog_unref (old);
	}
}


static void vtg_project_executer_dialog_class_init (VtgProjectExecuterDialogClass * klass) {
	vtg_project_executer_dialog_parent_class = g_type_class_peek_parent (klass);
	VTG_PROJECT_EXECUTER_DIALOG_CLASS (klass)->finalize = vtg_project_executer_dialog_finalize;
	g_type_class_add_private (klass, sizeof (VtgProjectExecuterDialogPrivate));
}


static void vtg_project_executer_dialog_instance_init (VtgProjectExecuterDialog * self) {
	self->priv = VTG_PROJECT_EXECUTER_DIALOG_GET_PRIVATE (self);
	self->ref_count = 1;
}


static void vtg_project_executer_dialog_finalize (VtgProjectExecuterDialog* obj) {
	VtgProjectExecuterDialog * self;
	self = VTG_PROJECT_EXECUTER_DIALOG (obj);
	gtk_widget_destroy ((GtkWidget*) self->priv->_dialog);
	_g_object_unref0 (self->priv->_completion);
	_g_object_unref0 (self->priv->_dialog);
	_g_object_unref0 (self->priv->_tree);
	_g_object_unref0 (self->priv->_button_exec);
}


GType vtg_project_executer_dialog_get_type (void) {
	return vtg_project_executer_dialog_type_id;
}


GType vtg_project_executer_dialog_register_type (GTypeModule * module) {
	static const GTypeValueTable g_define_type_value_table = { vtg_value_project_executer_dialog_init, vtg_value_project_executer_dialog_free_value, vtg_value_project_executer_dialog_copy_value, vtg_value_project_executer_dialog_peek_pointer, "p", vtg_value_project_executer_dialog_collect_value, "p", vtg_value_project_executer_dialog_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (VtgProjectExecuterDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vtg_project_executer_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (VtgProjectExecuterDialog), 0, (GInstanceInitFunc) vtg_project_executer_dialog_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) };
	vtg_project_executer_dialog_type_id = g_type_register_fundamental (g_type_fundamental_next (), "VtgProjectExecuterDialog", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return vtg_project_executer_dialog_type_id;
}


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


void vtg_project_executer_dialog_unref (gpointer instance) {
	VtgProjectExecuterDialog* self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		VTG_PROJECT_EXECUTER_DIALOG_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}



