/*

This file is part of Tins IMage Viewer (timv).
Copyright (c) 2010, Martin Furter
All rights reserved.

ANY-LICENSE:
You can use this software under any license approved by the
Open Source Initiative as long as the license you choose is
compatible to the dependencies of Tins IMage Viewer (timv).

See http://www.opensource.org/licenses/ for a list of
approved licenses.

*/

#ifndef _DIR_TREE_H_INCLUDED_
#define _DIR_TREE_H_INCLUDED_

#include <gtk/gtk.h>

/* Some boilerplate GObject defines. 'klass' is used
 *   instead of 'class', because 'class' is a C++ keyword */

#define DIR_TREE_TYPE            (dir_tree_get_type())
#define DIR_TREE(obj)            (G_TYPE_CHECK_INSTANCE_CAST( (obj), DIR_TREE_TYPE, DirTree) )
#define DIR_TREE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST( (klass),  DIR_TREE_TYPE, DirTreeClass) )
#define IS_DIR_TREE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE( (obj), DIR_TREE_TYPE) )
#define IS_DIR_TREE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE( (klass),  DIR_TREE_TYPE) )
#define DIR_TREE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS( (obj),  DIR_TREE_TYPE, DirTreeClass) )



/* DirTreeNode: this structure represents a row */

typedef struct DirTreeNode
{
	gchar* name;
	gchar* path;
	guint flags;
	guint child_count;
	guint children_size;
	gint index;
	struct DirTreeNode* parent;
	struct DirTreeNode** children;
} DirTreeNode;

#define DIR_TREE_NODE_LOADED	1


/* DirTree: this structure contains everything we need for our
 *             model implementation. You can add extra fields to
 *             this structure, e.g. hashtables to quickly lookup
 *             rows or whatever else you might need, but it is
 *             crucial that 'parent' is the first member of the
 *             structure.                                          */

typedef struct {
	/* this MUST be the first member */
	GObject         parent;

	DirTreeNode root_node;
	DirTreeNode* base_node;
	/* Random integer to check whether an iter belongs to our model */
	gint            stamp;
} DirTree;


/* DirTreeClass: more boilerplate GObject stuff */
typedef struct {
  GObjectClass parent_class;
} DirTreeClass;


GType dir_tree_get_type();
DirTree* dir_tree_new( const char* basedir );
void dir_tree_up( DirTree* dir_tree );
#if 0
gboolean dir_tree_test_expand( GtkTreeView* tree_view, GtkTreeIter* iter,
		GtkTreePath* treepath, gpointer data )
#endif
gboolean dir_tree_test_expand( DirTree* dir_tree, GtkTreeIter* iter );

#endif /* _DIR_TREE_H_INCLUDED_ */

