/*
 * Copyright (C) 2012 - Juan Ferrer Toribio
 *
 * 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 3 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, see <http://www.gnu.org/licenses/>.
 */

#ifndef VN_HANDLER_H
#define VN_HANDLER_H

#include <db/db.h>
#include <gtk/gtk.h>

#define VN_TYPE_HANDLER				(vn_handler_get_type ())
#define VN_IS_HANDLER(obj)			(G_TYPE_CHECK_INSTANCE_TYPE (obj, VN_TYPE_HANDLER))
#define VN_HANDLER(obj)				(G_TYPE_CHECK_INSTANCE_CAST (obj, VN_TYPE_HANDLER , VnHandler))
#define VN_HANDLER_CLASS(klass)		(G_TYPE_CHECK_CLASS_CAST (klass, VN_TYPE_HANDLER, VnHandlerClass))
#define VN_HANDLER_GET_CLASS(obj)	(G_TYPE_INSTANCE_GET_CLASS (obj, VN_TYPE_HANDLER, VnHandlerClass))

#define VN_TYPE_HANDLER_SHOW_FLAGS	(vn_handler_show_flags_get_type ())

typedef struct _VnHandler VnHandler;
typedef struct _VnHandlerClass VnHandlerClass;

typedef enum
{
	 VN_HANDLER_SHOW_REFRESH = 1 << 0
	,VN_HANDLER_SHOW_UNDO    = 1 << 1
	,VN_HANDLER_SHOW_SAVE    = 1 << 2
	,VN_HANDLER_SHOW_REMOVE  = 1 << 3
	,VN_HANDLER_SHOW_ADD     = 1 << 4
	,VN_HANDLER_SHOW_SCROLL  = 1 << 5
}
VnHandlerShowFlags;

struct _VnHandler
{
	GtkHButtonBox parent;
	DbIterator * iterator;
	VnHandlerShowFlags show_flags;
	gboolean simple_record;
	GtkToolbar * toolbar;
	GtkActionGroup * group;
	GtkAction * move_first;
	GtkAction * move_previous;
	GtkAction * move_next;
	GtkAction * move_last;
	GtkAction * add;
	GtkAction * remove;
	GtkAction * save;
	GtkAction * undo;
};

struct _VnHandlerClass
{
	/* <private> */
	GtkHButtonBoxClass parent;
};

GType			vn_handler_get_type				();
GType			vn_handler_show_flags_get_type	() G_GNUC_CONST;

GtkWidget *		vn_handler_new					();
GtkWidget *		vn_handler_new_with_iterator	(DbIterator * iterator);
DbIterator *	vn_handler_get_iterator			(VnHandler * obj);
void			vn_handler_set_iterator			(VnHandler * obj, DbIterator * iterator);
void			vn_handler_set_show_flags		(VnHandler * obj, VnHandlerShowFlags show_flags);
void			vn_handler_set_simple_record	(VnHandler * obj, gboolean simple);

#endif