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

/*
 *  vtgprojectsearchdialog.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 <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>


#define VTG_TYPE_PROJECT_SEARCH_DIALOG (vtg_project_search_dialog_get_type ())
#define VTG_PROJECT_SEARCH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VTG_TYPE_PROJECT_SEARCH_DIALOG, VtgProjectSearchDialog))
#define VTG_PROJECT_SEARCH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VTG_TYPE_PROJECT_SEARCH_DIALOG, VtgProjectSearchDialogClass))
#define VTG_IS_PROJECT_SEARCH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VTG_TYPE_PROJECT_SEARCH_DIALOG))
#define VTG_IS_PROJECT_SEARCH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VTG_TYPE_PROJECT_SEARCH_DIALOG))
#define VTG_PROJECT_SEARCH_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VTG_TYPE_PROJECT_SEARCH_DIALOG, VtgProjectSearchDialogClass))

typedef struct _VtgProjectSearchDialog VtgProjectSearchDialog;
typedef struct _VtgProjectSearchDialogClass VtgProjectSearchDialogClass;
typedef struct _VtgProjectSearchDialogPrivate VtgProjectSearchDialogPrivate;
#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)))

struct _VtgProjectSearchDialog {
	GObject parent_instance;
	VtgProjectSearchDialogPrivate * priv;
	gchar* search_text;
	gboolean match_case;
};

struct _VtgProjectSearchDialogClass {
	GObjectClass parent_class;
};

struct _VtgProjectSearchDialogPrivate {
	GtkDialog* _dialog;
	GtkEntry* _entry;
	GtkButton* _button_find;
	GtkCheckButton* _check_match_case;
};


static gpointer vtg_project_search_dialog_parent_class = NULL;
static GType vtg_project_search_dialog_type_id = 0;

GType vtg_project_search_dialog_get_type (void) G_GNUC_CONST;
GType vtg_project_search_dialog_register_type (GTypeModule * module);
#define VTG_PROJECT_SEARCH_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VTG_TYPE_PROJECT_SEARCH_DIALOG, VtgProjectSearchDialogPrivate))
enum  {
	VTG_PROJECT_SEARCH_DIALOG_DUMMY_PROPERTY
};
VtgProjectSearchDialog* vtg_project_search_dialog_new (GtkWindow* parent, const gchar* proposed_text);
VtgProjectSearchDialog* vtg_project_search_dialog_construct (GType object_type, GtkWindow* parent, const gchar* proposed_text);
static void vtg_project_search_dialog_initialize_ui (VtgProjectSearchDialog* self, GtkWindow* parent);
gchar* vtg_utils_get_ui_path (const gchar* id);
static void vtg_project_search_dialog_on_entry_text_changed (VtgProjectSearchDialog* self, GObject* pspec, GParamSpec* gobject);
static void _vtg_project_search_dialog_on_entry_text_changed_g_object_notify (GtkEntry* _sender, GParamSpec* pspec, gpointer self);
gint vtg_project_search_dialog_run (VtgProjectSearchDialog* self);
static void vtg_project_search_dialog_finalize (GObject* obj);


VtgProjectSearchDialog* vtg_project_search_dialog_construct (GType object_type, GtkWindow* parent, const gchar* proposed_text) {
	VtgProjectSearchDialog * self = NULL;
	g_return_val_if_fail (parent != NULL, NULL);
	g_return_val_if_fail (proposed_text != NULL, NULL);
	self = (VtgProjectSearchDialog*) g_object_new (object_type, NULL);
	vtg_project_search_dialog_initialize_ui (self, parent);
	gtk_entry_set_text (self->priv->_entry, proposed_text);
	return self;
}


VtgProjectSearchDialog* vtg_project_search_dialog_new (GtkWindow* parent, const gchar* proposed_text) {
	return vtg_project_search_dialog_construct (VTG_TYPE_PROJECT_SEARCH_DIALOG, parent, proposed_text);
}


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


static void _vtg_project_search_dialog_on_entry_text_changed_g_object_notify (GtkEntry* _sender, GParamSpec* pspec, gpointer self) {
	vtg_project_search_dialog_on_entry_text_changed (self, _sender, pspec);
}


static void vtg_project_search_dialog_initialize_ui (VtgProjectSearchDialog* self, GtkWindow* parent) {
	GtkBuilder* _tmp0_ = NULL;
	GtkBuilder* builder;
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_;
	GObject* _tmp3_ = NULL;
	GtkDialog* _tmp4_;
	GObject* _tmp5_ = NULL;
	GtkButton* _tmp6_;
	GObject* _tmp7_ = NULL;
	GtkEntry* _tmp8_;
	GObject* _tmp9_ = NULL;
	GtkCheckButton* _tmp10_;
	gchar* _tmp11_;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (parent != 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 __catch31_g_error;
	}
	goto __finally31;
	__catch31_g_error:
	{
		GError * err;
		err = _inner_error_;
		_inner_error_ = NULL;
		g_warning ("vtgprojectsearchdialog.vala:51: initialize_ui: %s", err->message);
		_g_error_free0 (err);
	}
	__finally31:
	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-search");
	_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_transient_for ((GtkWindow*) self->priv->_dialog, parent);
	_tmp5_ = gtk_builder_get_object (builder, "button_find");
	_tmp6_ = _g_object_ref0 (GTK_BUTTON (_tmp5_));
	_g_object_unref0 (self->priv->_button_find);
	self->priv->_button_find = _tmp6_;
	g_assert (self->priv->_button_find != NULL);
	_tmp7_ = gtk_builder_get_object (builder, "entry_search");
	_tmp8_ = _g_object_ref0 (GTK_ENTRY (_tmp7_));
	_g_object_unref0 (self->priv->_entry);
	self->priv->_entry = _tmp8_;
	g_assert (self->priv->_entry != NULL);
	g_signal_connect_object ((GObject*) self->priv->_entry, "notify::text", (GCallback) _vtg_project_search_dialog_on_entry_text_changed_g_object_notify, self, 0);
	_tmp9_ = gtk_builder_get_object (builder, "checkbutton_match_case");
	_tmp10_ = _g_object_ref0 (GTK_CHECK_BUTTON (_tmp9_));
	_g_object_unref0 (self->priv->_check_match_case);
	self->priv->_check_match_case = _tmp10_;
	g_assert (self->priv->_check_match_case != NULL);
	_tmp11_ = g_strdup ("");
	_g_free0 (self->search_text);
	self->search_text = _tmp11_;
	self->match_case = FALSE;
	gtk_entry_set_text (self->priv->_entry, self->search_text);
	gtk_toggle_button_set_active ((GtkToggleButton*) self->priv->_check_match_case, self->match_case);
	_g_object_unref0 (builder);
}


gint vtg_project_search_dialog_run (VtgProjectSearchDialog* self) {
	gint result = 0;
	gint _tmp0_;
	gint dialog_result;
	g_return_val_if_fail (self != NULL, 0);
	gtk_window_set_modal ((GtkWindow*) self->priv->_dialog, TRUE);
	gtk_widget_show_all ((GtkWidget*) self->priv->_dialog);
	_tmp0_ = gtk_dialog_run (self->priv->_dialog);
	dialog_result = _tmp0_;
	if (dialog_result == GTK_RESPONSE_OK) {
		const gchar* _tmp1_ = NULL;
		gchar* _tmp2_;
		gboolean _tmp3_;
		_tmp1_ = gtk_entry_get_text (self->priv->_entry);
		_tmp2_ = g_strdup (_tmp1_);
		_g_free0 (self->search_text);
		self->search_text = _tmp2_;
		_tmp3_ = gtk_toggle_button_get_active ((GtkToggleButton*) self->priv->_check_match_case);
		self->match_case = _tmp3_;
	}
	gtk_widget_destroy ((GtkWidget*) self->priv->_dialog);
	result = dialog_result;
	return result;
}


static void vtg_project_search_dialog_on_entry_text_changed (VtgProjectSearchDialog* self, GObject* pspec, GParamSpec* gobject) {
	guint16 _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (pspec != NULL);
	g_return_if_fail (gobject != NULL);
	_tmp0_ = gtk_entry_get_text_length (self->priv->_entry);
	gtk_widget_set_sensitive ((GtkWidget*) self->priv->_button_find, _tmp0_ > 0);
}


static void vtg_project_search_dialog_class_init (VtgProjectSearchDialogClass * klass) {
	vtg_project_search_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (VtgProjectSearchDialogPrivate));
	G_OBJECT_CLASS (klass)->finalize = vtg_project_search_dialog_finalize;
}


static void vtg_project_search_dialog_instance_init (VtgProjectSearchDialog * self) {
	self->priv = VTG_PROJECT_SEARCH_DIALOG_GET_PRIVATE (self);
	self->search_text = NULL;
	self->match_case = FALSE;
}


static void vtg_project_search_dialog_finalize (GObject* obj) {
	VtgProjectSearchDialog * self;
	self = VTG_PROJECT_SEARCH_DIALOG (obj);
	_g_object_unref0 (self->priv->_dialog);
	_g_object_unref0 (self->priv->_entry);
	_g_object_unref0 (self->priv->_button_find);
	_g_object_unref0 (self->priv->_check_match_case);
	_g_free0 (self->search_text);
	G_OBJECT_CLASS (vtg_project_search_dialog_parent_class)->finalize (obj);
}


GType vtg_project_search_dialog_get_type (void) {
	return vtg_project_search_dialog_type_id;
}


GType vtg_project_search_dialog_register_type (GTypeModule * module) {
	static const GTypeInfo g_define_type_info = { sizeof (VtgProjectSearchDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vtg_project_search_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (VtgProjectSearchDialog), 0, (GInstanceInitFunc) vtg_project_search_dialog_instance_init, NULL };
	vtg_project_search_dialog_type_id = g_type_module_register_type (module, G_TYPE_OBJECT, "VtgProjectSearchDialog", &g_define_type_info, 0);
	return vtg_project_search_dialog_type_id;
}



