/*
    GDAM - Geoff & Dave's Audio Mixer
    Copyright (C) 1999    Dave Benson, Geoff Matters.

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library 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
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA

    Contact:
        daveb@ffem.org <Dave Benson>
        geoff@ugcs.caltech.edu <Geoff Matters>
*/
#ifndef __GDAM_SONG_SELECTOR_SKIN_H__
#define __GDAM_SONG_SELECTOR_SKIN_H__

#include "gdamskin.h"
#include "gtktrackdisplay.h"
#include <gdam/component/gdamsonginfo.h>
#include <gdam/component/gdamsongdatabase.h>
#include <gtk/gtkwindow.h>
#include <gtk/gtklabel.h>
#include <gtk/gtkclist.h>
#include <gtk/gtkentry.h>
#include <gtk/gtktogglebutton.h>

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

GtkType gdam_song_selector_skin_get_type();

#define GDAM_TYPE_SONG_SELECTOR_SKIN			(gdam_song_selector_skin_get_type ())
#define GDAM_SONG_SELECTOR_SKIN(obj)              (GTK_CHECK_CAST ((obj), GDAM_TYPE_SONG_SELECTOR_SKIN, GdamSongSelectorSkin))
#define GDAM_SONG_SELECTOR_SKIN_CLASS(klass)      (GTK_CHECK_CLASS_CAST ((klass), GDAM_TYPE_SONG_SELECTOR_SKIN, GdamSongSelectorSkinClass))
#define GDAM_IS_SONG_SELECTOR_SKIN(obj)           (GTK_CHECK_TYPE ((obj), GDAM_TYPE_SONG_SELECTOR_SKIN))
#define GDAM_IS_SONG_SELECTOR_SKIN_CLASS(klass)   (GTK_CHECK_CLASS_TYPE ((klass), GDAM_TYPE_SONG_SELECTOR_SKIN))

typedef struct _GdamSongSelectorSkin GdamSongSelectorSkin;
typedef struct _GdamSongSelectorSkinClass GdamSongSelectorSkinClass;

typedef enum {
	GDAM_SORT_BY_FILENAME,
	GDAM_SORT_BY_BPM,
	GDAM_SORT_BY_ORDER
} GdamSorting;


  /*   A function which extracts and stringifies info relevant to 
   *     a specific clist column. 
   */
typedef char*   (*CListEntryGetter)(GdamSongInfo*   info);
typedef char*   (*RangeCListEntryGetter)(GdamBeatInfoRange*   range);
typedef char*   (*LoopCListEntryGetter)(GdamBeatInfo* info, GdamLoopInfo* loop);

struct _GdamSongSelectorSkinClass {
	GdamSkinClass		skin_class;
};

struct _GdamSongSelectorSkin {
	GdamSkin		skin;
	GdamSongDatabase* database;
	GdamSongInfo* current;
	GtkWindow* toplevel;
	GtkLabel* info_label;
	GtkEntry* filename_entry;
	GtkEntry* find_entry;
	GtkEntry* info_entry;
	GtkCList* scrlist;
	GtkCList* range_scrlist;
	GtkCList* loop_scrlist;
	int last_w;
	int last_h;
	int last_found;
	int sort_by;
	gboolean amVisible;
	  /* Arrays which control each column's behavior. */
	int*			column_widths;
	CListEntryGetter*   	column_fillers;
	GdamSorting*   		column_sortings;
	gboolean*   		column_expands;
	int*			range_column_widths;
	int*			loop_column_widths;
	/* Extract the default info from a songsel, into the range clist */
	CListEntryGetter*  	range_default_column_fillers;
	CListEntryGetter*  	loop_default_column_fillers;
	/* Extract one range's info into the range clist */
	RangeCListEntryGetter*  range_column_fillers;
	GdamSorting*   		range_column_sortings;
	gboolean*   		range_column_expands;
	LoopCListEntryGetter*   loop_column_fillers;
	GdamSorting*   		loop_column_sortings;
	gboolean*   		loop_column_expands;
	  /* Whether to suppress display/saving of songs with various
	   * properties. */
	gboolean		hide_unknown_bpm;
	gboolean		save_unknown_bpm;
	gboolean		hide_default;
	gboolean		have_read_history;
	GtkToggleButton*	hide_unknown_tbutton;
	GtkToggleButton*	save_unknown_tbutton;
	GtkToggleButton*	hide_default_tbutton;
	GdamSongDatabase*	hide_songdb;
	GdamSongDatabase*	show_songdb;
	GtkEntry*		hide_file_entry;
	GtkEntry*		show_file_entry;
	GtkEntry*		show_key_entry;
	GtkEntry*		show_value_entry;
	GtkEntry*		hide_key_entry;
	GtkEntry*		hide_value_entry;
	float			min_bpm;
	float			max_bpm;
	GtkTrackDisplay*        track_display;
};

void gdam_song_selector_skin_update_table(GdamSongSelectorSkin* sel_skin);

/* Used to get the current selection as a concatenated string of filenames.
 * This is the same format used to pass the selection around via drag-n-drop. */
char*  gdam_song_selector_export_selection_string(GdamSongSelectorSkin* skin);

GdamSongSelectorSkin *gdam_song_selector_default ();

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif
