/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
 * 
 * Copyright (C) Armin Burgmeier 2007 <armin@arbur.net>
 * 
 * c4s-script-view.c is free software.
 * 
 * You may 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.
 * 
 * c4s-script-view.c 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 c4s-script-view.c.  If not, write to:
 * 	The Free Software Foundation, Inc.,
 * 	51 Franklin Street, Fifth Floor
 * 	Boston, MA  02110-1301, USA.
 */

#include "c4s-script-view.h"

typedef struct _C4sScriptViewPrivate C4sScriptViewPrivate;
struct _C4sScriptViewPrivate
{
	GdkRectangle tip_rect;
};

#define C4S_SCRIPT_VIEW_PRIVATE(o)  (G_TYPE_INSTANCE_GET_PRIVATE ((o), C4S_TYPE_SCRIPT_VIEW, C4sScriptViewPrivate))

enum
{
	PROP_0,

	PROP_TIP_RECT,
	PROP_BUFFER
};

enum
{
	SCRIPT_CHANGED,

	LAST_SIGNAL
};

static GtkTextViewClass* parent_class = NULL;
static guint script_view_signals[LAST_SIGNAL] = { 0 };

static void
c4s_script_view_recalc_tip_rect (C4sScriptView *view)
{
	/* TODO: Add private function implementation here */
}

static void
c4s_script_view_init (C4sScriptView *object)
{
	/* TODO: Add initialization code here */
}

static void
c4s_script_view_finalize (GObject *object)
{
	/* TODO: Add deinitalization code here */

	G_OBJECT_CLASS (parent_class)->finalize (object);
}

static void
c4s_script_view_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
	g_return_if_fail (C4S_IS_SCRIPT_VIEW (object));

	switch (prop_id)
	{
	case PROP_TIP_RECT:
		/* TODO: Add setter for "tip-rect" property here */
		break;
	case PROP_BUFFER:
		/* TODO: Add setter for "buffer" property here */
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
		break;
	}
}

static void
c4s_script_view_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
	g_return_if_fail (C4S_IS_SCRIPT_VIEW (object));

	switch (prop_id)
	{
	case PROP_TIP_RECT:
		/* TODO: Add getter for "tip-rect" property here */
		break;
	case PROP_BUFFER:
		/* TODO: Add getter for "buffer" property here */
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
		break;
	}
}

static void
c4s_script_view_script_changed (C4sScriptView *self, const gchar *new_content)
{
	/* TODO: Add default signal handler implementation here */
}

static void
c4s_script_view_class_init (C4sScriptViewClass *klass)
{
	GObjectClass* object_class = G_OBJECT_CLASS (klass);
	parent_class = GTK_TEXT_VIEW_CLASS (g_type_class_peek_parent (klass));

	g_type_class_add_private (klass, sizeof (C4sScriptViewPrivate));

	object_class->finalize = c4s_script_view_finalize;
	object_class->set_property = c4s_script_view_set_property;
	object_class->get_property = c4s_script_view_get_property;

	klass->script_changed = c4s_script_view_script_changed;

	g_object_class_install_property (object_class,
	                                 PROP_TIP_RECT,
	                                 g_param_spec_boxed ("tip-rect",
	                                                     "Tip rect",
	                                                     "Tooltip area",
	                                                     GDK_TYPE_RECTANGLE,
	                                                     G_PARAM_READABLE));

	g_object_class_install_property (object_class,
	                                 PROP_BUFFER,
	                                 g_param_spec_object ("buffer",
	                                                      "Buffer",
	                                                      "Text buffer to display",
	                                                      GTK_TYPE_TEXT_BUFFER,
	                                                      G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));

	script_view_signals[SCRIPT_CHANGED] =
		g_signal_new ("script-changed",
		              G_OBJECT_CLASS_TYPE (klass),
		              G_SIGNAL_RUN_LAST,
		              G_STRUCT_OFFSET (C4sScriptViewClass, script_changed),
		              NULL, NULL,
		              c4s_marshal_VOID__STRING,
		              G_TYPE_NONE, 1,
		              G_TYPE_STRING);
}

GType
c4s_script_view_get_type (void)
{
	static GType our_type = 0;

	if(our_type == 0)
	{
		static const GTypeInfo our_info =
		{
			sizeof (C4sScriptViewClass), /* class_size */
			(GBaseInitFunc) NULL, /* base_init */
			(GBaseFinalizeFunc) NULL, /* base_finalize */
			(GClassInitFunc) c4s_script_view_class_init, /* class_init */
			(GClassFinalizeFunc) NULL, /* class_finalize */
			NULL /* class_data */,
			sizeof (C4sScriptView), /* instance_size */
			0, /* n_preallocs */
			(GInstanceInitFunc) c4s_script_view_init, /* instance_init */
			NULL /* value_table */
		};

		our_type = g_type_register_static (GTK_TYPE_TEXT_VIEW, "C4sScriptView",
		                                   &our_info, 0);
	}

	return our_type;
}

GtkWidget*
c4s_script_view_new (void)
{
	/* TODO: Add public function implementation here */
}

GtkWidget*
c4s_script_view_new_with_buffer (GtkTextBuffer *buffer)
{
	/* TODO: Add public function implementation here */
}

