/*
    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_SKIN_UTIL_H_
#define __GDAM_SKIN_UTIL_H_

#include <gdk/gdk.h>
#include <gtk/gtkadjustment.h>
#include <gtk/gtkcontainer.h>
#include <gtk/gtkwidget.h>
#include <gtk/gtkdnd.h>

#ifndef G_N_ELEMENTS
#define G_N_ELEMENTS(array)   ((int)  (sizeof(array) / sizeof((array)[0])))
#endif

#define GDAM_STATIC_ARRAY_LENGTH(array)  G_N_ELEMENTS(array)

typedef void (*GdamStringDropFunc) (const char* text, gpointer user_data);
typedef void (*GdamStringDragFunc) (GtkSelectionData* 	selection_data,
				    gpointer 		data);

GtkAdjustment*   util_get_widget_adjustment         (GtkWidget* adj_widget);
GtkAdjustment*   util_get_indexed_widget_adjustment (GtkWidget *adj_widget,
                                                     int        adj_index);
GdkColor*        util_alloc_color_cached(int r, int g, int b);

void gdam_set_container(GtkContainer* new_container, GtkWidget* child);
void gdam_gtk_container_remove_all(GtkContainer* container);

void gdam_widget_string_source_set(GtkWidget* 		widget, 
				   GdamStringDragFunc 	func,
				   const char* 		data_type,
				   gpointer		user_data);
void gdam_widget_string_dest_set  (GtkWidget* 		widget, 
				   GdamStringDropFunc 	func,
				   const char* 		data_type,
				   gpointer		user_data);

/* create a new toplevel window with the widget inside.
 * destroying the toplevel window, or calling gdam_widget_maximize
 * on widget again will reparent it back.
 */
void gdam_widget_maximize (GtkWidget *widget);

/* Add an idle callback to set the adjustment to its current value */
void gdam_delayed_adjustment_init (GtkAdjustment*	adj);

char** gdam_strdupv(char** input);
#endif
