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

/*
 *  vtgparametersdialog.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 <gobject/gvaluecollector.h>


#define VTG_INTERACTION_TYPE_PARAMETERS_DIALOG (vtg_interaction_parameters_dialog_get_type ())
#define VTG_INTERACTION_PARAMETERS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VTG_INTERACTION_TYPE_PARAMETERS_DIALOG, VtgInteractionParametersDialog))
#define VTG_INTERACTION_PARAMETERS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VTG_INTERACTION_TYPE_PARAMETERS_DIALOG, VtgInteractionParametersDialogClass))
#define VTG_INTERACTION_IS_PARAMETERS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VTG_INTERACTION_TYPE_PARAMETERS_DIALOG))
#define VTG_INTERACTION_IS_PARAMETERS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VTG_INTERACTION_TYPE_PARAMETERS_DIALOG))
#define VTG_INTERACTION_PARAMETERS_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VTG_INTERACTION_TYPE_PARAMETERS_DIALOG, VtgInteractionParametersDialogClass))

typedef struct _VtgInteractionParametersDialog VtgInteractionParametersDialog;
typedef struct _VtgInteractionParametersDialogClass VtgInteractionParametersDialogClass;
typedef struct _VtgInteractionParametersDialogPrivate VtgInteractionParametersDialogPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#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 _VtgInteractionParamSpecParametersDialog VtgInteractionParamSpecParametersDialog;

struct _VtgInteractionParametersDialog {
	GTypeInstance parent_instance;
	volatile int ref_count;
	VtgInteractionParametersDialogPrivate * priv;
};

struct _VtgInteractionParametersDialogClass {
	GTypeClass parent_class;
	void (*finalize) (VtgInteractionParametersDialog *self);
};

struct _VtgInteractionParametersDialogPrivate {
	GtkEntryCompletion* _completion;
	GtkDialog* _dialog;
};

struct _VtgInteractionParamSpecParametersDialog {
	GParamSpec parent_instance;
};


static gpointer vtg_interaction_parameters_dialog_parent_class = NULL;
static GType vtg_interaction_parameters_dialog_type_id = 0;

gpointer vtg_interaction_parameters_dialog_ref (gpointer instance);
void vtg_interaction_parameters_dialog_unref (gpointer instance);
GParamSpec* vtg_interaction_param_spec_parameters_dialog (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void vtg_interaction_value_set_parameters_dialog (GValue* value, gpointer v_object);
void vtg_interaction_value_take_parameters_dialog (GValue* value, gpointer v_object);
gpointer vtg_interaction_value_get_parameters_dialog (const GValue* value);
GType vtg_interaction_parameters_dialog_get_type (void) G_GNUC_CONST;
GType vtg_interaction_parameters_dialog_register_type (GTypeModule * module);
#define VTG_INTERACTION_PARAMETERS_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VTG_INTERACTION_TYPE_PARAMETERS_DIALOG, VtgInteractionParametersDialogPrivate))
enum  {
	VTG_INTERACTION_PARAMETERS_DIALOG_DUMMY_PROPERTY
};
VtgInteractionParametersDialog* vtg_interaction_parameters_dialog_new (const gchar* title, GtkWindow* parent, GtkListStore* completions);
VtgInteractionParametersDialog* vtg_interaction_parameters_dialog_construct (GType object_type, const gchar* title, GtkWindow* parent, GtkListStore* completions);
static void vtg_interaction_parameters_dialog_initialize_ui (VtgInteractionParametersDialog* self, const gchar* title, GtkWindow* parent, GtkListStore* completions);
gchar* vtg_utils_get_ui_path (const gchar* id);
gint vtg_interaction_parameters_dialog_run (VtgInteractionParametersDialog* self);
const gchar* vtg_interaction_parameters_dialog_get_parameters (VtgInteractionParametersDialog* self);
static void vtg_interaction_parameters_dialog_finalize (VtgInteractionParametersDialog* obj);


VtgInteractionParametersDialog* vtg_interaction_parameters_dialog_construct (GType object_type, const gchar* title, GtkWindow* parent, GtkListStore* completions) {
	VtgInteractionParametersDialog* self = NULL;
	g_return_val_if_fail (title != NULL, NULL);
	g_return_val_if_fail (parent != NULL, NULL);
	g_return_val_if_fail (completions != NULL, NULL);
	self = (VtgInteractionParametersDialog*) g_type_create_instance (object_type);
	vtg_interaction_parameters_dialog_initialize_ui (self, title, parent, completions);
	return self;
}


VtgInteractionParametersDialog* vtg_interaction_parameters_dialog_new (const gchar* title, GtkWindow* parent, GtkListStore* completions) {
	return vtg_interaction_parameters_dialog_construct (VTG_INTERACTION_TYPE_PARAMETERS_DIALOG, title, parent, completions);
}


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


static void vtg_interaction_parameters_dialog_initialize_ui (VtgInteractionParametersDialog* self, const gchar* title, GtkWindow* parent, GtkListStore* completions) {
	GtkBuilder* _tmp0_ = NULL;
	GtkBuilder* builder;
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_;
	GObject* _tmp3_ = NULL;
	GtkDialog* _tmp4_;
	GtkEntryCompletion* _tmp5_ = NULL;
	GObject* _tmp6_ = NULL;
	GtkEntry* _tmp7_;
	GtkEntry* entry;
	GtkTreeIter iter = {0};
	GtkTreeIter _tmp8_ = {0};
	gboolean _tmp9_;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (title != NULL);
	g_return_if_fail (parent != NULL);
	g_return_if_fail (completions != NULL);
	_tmp0_ = gtk_builder_new ();
	builder = _tmp0_;
	_tmp1_ = vtg_utils_get_ui_path ("vtg.ui");
	_tmp2_ = _tmp1_;
	gtk_builder_add_from_file (builder, _tmp2_, &_inner_error_);
	_g_free0 (_tmp2_);
	if (_inner_error_ != NULL) {
		goto __catch42_g_error;
	}
	goto __finally42;
	__catch42_g_error:
	{
		GError * err;
		err = _inner_error_;
		_inner_error_ = NULL;
		g_warning ("vtgparametersdialog.vala:50: initialize_ui: %s", err->message);
		_g_error_free0 (err);
	}
	__finally42:
	if (_inner_error_ != NULL) {
		_g_object_unref0 (builder);
		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;
	}
	_tmp3_ = gtk_builder_get_object (builder, "dialog-ask-params");
	_tmp4_ = _g_object_ref0 (GTK_DIALOG (_tmp3_));
	_g_object_unref0 (self->priv->_dialog);
	self->priv->_dialog = _tmp4_;
	g_assert (self->priv->_dialog != NULL);
	gtk_window_set_title ((GtkWindow*) self->priv->_dialog, title);
	gtk_window_set_transient_for ((GtkWindow*) self->priv->_dialog, parent);
	_tmp5_ = gtk_entry_completion_new ();
	_g_object_unref0 (self->priv->_completion);
	self->priv->_completion = _tmp5_;
	gtk_entry_completion_set_model (self->priv->_completion, (GtkTreeModel*) completions);
	gtk_entry_completion_set_text_column (self->priv->_completion, 0);
	_tmp6_ = gtk_builder_get_object (builder, "entry-params");
	_tmp7_ = _g_object_ref0 (GTK_ENTRY (_tmp6_));
	entry = _tmp7_;
	gtk_entry_set_completion (entry, self->priv->_completion);
	_tmp9_ = gtk_tree_model_get_iter_first ((GtkTreeModel*) completions, &_tmp8_);
	iter = _tmp8_;
	if (_tmp9_) {
		gchar* val = NULL;
		gtk_tree_model_get ((GtkTreeModel*) completions, &iter, 0, &val, -1);
		gtk_entry_set_text (entry, val);
		gtk_editable_select_region ((GtkEditable*) entry, 0, -1);
		_g_free0 (val);
	}
	_g_object_unref0 (entry);
	_g_object_unref0 (builder);
}


gint vtg_interaction_parameters_dialog_run (VtgInteractionParametersDialog* self) {
	gint result = 0;
	gint _tmp0_;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = gtk_dialog_run (self->priv->_dialog);
	result = _tmp0_;
	return result;
}


const gchar* vtg_interaction_parameters_dialog_get_parameters (VtgInteractionParametersDialog* 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_interaction_value_parameters_dialog_init (GValue* value) {
	value->data[0].v_pointer = NULL;
}


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


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


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


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


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


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


void vtg_interaction_value_set_parameters_dialog (GValue* value, gpointer v_object) {
	VtgInteractionParametersDialog* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VTG_INTERACTION_TYPE_PARAMETERS_DIALOG));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, VTG_INTERACTION_TYPE_PARAMETERS_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_interaction_parameters_dialog_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		vtg_interaction_parameters_dialog_unref (old);
	}
}


void vtg_interaction_value_take_parameters_dialog (GValue* value, gpointer v_object) {
	VtgInteractionParametersDialog* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VTG_INTERACTION_TYPE_PARAMETERS_DIALOG));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, VTG_INTERACTION_TYPE_PARAMETERS_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_interaction_parameters_dialog_unref (old);
	}
}


static void vtg_interaction_parameters_dialog_class_init (VtgInteractionParametersDialogClass * klass) {
	vtg_interaction_parameters_dialog_parent_class = g_type_class_peek_parent (klass);
	VTG_INTERACTION_PARAMETERS_DIALOG_CLASS (klass)->finalize = vtg_interaction_parameters_dialog_finalize;
	g_type_class_add_private (klass, sizeof (VtgInteractionParametersDialogPrivate));
}


static void vtg_interaction_parameters_dialog_instance_init (VtgInteractionParametersDialog * self) {
	self->priv = VTG_INTERACTION_PARAMETERS_DIALOG_GET_PRIVATE (self);
	self->ref_count = 1;
}


static void vtg_interaction_parameters_dialog_finalize (VtgInteractionParametersDialog* obj) {
	VtgInteractionParametersDialog * self;
	self = VTG_INTERACTION_PARAMETERS_DIALOG (obj);
	gtk_widget_destroy ((GtkWidget*) self->priv->_dialog);
	_g_object_unref0 (self->priv->_completion);
	_g_object_unref0 (self->priv->_dialog);
}


GType vtg_interaction_parameters_dialog_get_type (void) {
	return vtg_interaction_parameters_dialog_type_id;
}


GType vtg_interaction_parameters_dialog_register_type (GTypeModule * module) {
	static const GTypeValueTable g_define_type_value_table = { vtg_interaction_value_parameters_dialog_init, vtg_interaction_value_parameters_dialog_free_value, vtg_interaction_value_parameters_dialog_copy_value, vtg_interaction_value_parameters_dialog_peek_pointer, "p", vtg_interaction_value_parameters_dialog_collect_value, "p", vtg_interaction_value_parameters_dialog_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (VtgInteractionParametersDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vtg_interaction_parameters_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (VtgInteractionParametersDialog), 0, (GInstanceInitFunc) vtg_interaction_parameters_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_interaction_parameters_dialog_type_id = g_type_register_fundamental (g_type_fundamental_next (), "VtgInteractionParametersDialog", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return vtg_interaction_parameters_dialog_type_id;
}


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


void vtg_interaction_parameters_dialog_unref (gpointer instance) {
	VtgInteractionParametersDialog* self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		VTG_INTERACTION_PARAMETERS_DIALOG_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}



