#ifndef _PWM_THEME_H_
#define _PWM_THEME_H_

/*********************************************************************/
/* theme.h - theme loader definition                                 */
/* provides a template for theme engines, and an interface for       */
/* the main application to access theme engines.  this is ripped     */
/* almost directly from the plib resource loader :)                  */
/*                                                                   */
/* - pabs 20010214                                                   */
/*********************************************************************/

#include <libpwm/object.h>
#include <libpwm/action.h>
#include <libpwm/image.h>
#include <libpwm/borderpart.h>
#include <libpwm/border.h>
#include <libpwm/global.h>

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

typedef enum {
  PWM_THEME_LOADING,
  PWM_THEME_DONE,
  PWM_THEME_ERROR
} PWMThemeStatus;
  
#define PWM_THEME(a) ((PWMTheme*)a)
typedef struct _PWMTheme PWMTheme;

struct _PWMTheme {
  PWMObject        obj;

  char            *url;

  PBool            is_done;
  double           progress; /* from 0.0 to 1.0 */

  PWMThemeStatus   status;
  char            *status_string;      

  void            *dl;
  void            *loader_data;

  PWMThemeStatus (*init)(PWMTheme *);
  PWMThemeStatus (*load)(PWMTheme *);
};

/******************************************/
/* PWM THEME LOADER SEARCH PATH FUNCTIONS */
/******************************************/
void            pwm_theme_add_loader_path(char *path);
void            pwm_theme_remove_loader_path(char *path);
PList          *pwm_theme_list_loader_paths();

char           *pwm_theme_find_loader(char *loader);

/***************************/
/* THEME LOADING FUNCTIONS */
/***************************/
PWMTheme       *pwm_theme_load(char *url, PBool progressive);
double          pwm_theme_load_progressive(PWMTheme *theme);

/**************************/
/* THEME MEMBER FUNCTIONS */
/**************************/
char           *pwm_theme_get_url(PWMTheme *theme);
PBool           pwm_theme_is_done(PWMTheme *theme);
double          pwm_theme_get_progress(PWMTheme *theme);
PWMThemeStatus  pwm_theme_get_status(PWMTheme *theme);
char           *pwm_theme_get_status_string(PWMTheme *theme);

/**************************/
/* THEME LOADER FUNCTIONS */
/**************************/
void           *pwm_theme_get_loader_data(PWMTheme *theme);
void            pwm_theme_set_loader_data(PWMTheme *theme, void *data);

/*********************************************/
/* THEME ALLOCATION/INITIALIZATION FUNCTIONS */
/*********************************************/
PWMTheme       *pwm_theme_alloc();
void            pwm_theme_init(PWMTheme *loader);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* _PWM_THEME_H_ */

