#ifndef PLAYLIST_H
#define PLAYLIST_H

#include <gtk/gtk.h>
#include "player.h"

typedef struct Playlist Playlist;

/* Playlist modes */
typedef enum {
    PLAYLIST_REPEAT_NONE,
    PLAYLIST_REPEAT_ONE,
    PLAYLIST_REPEAT_ALL
} PlaylistRepeatMode;

/* Callbacks */
typedef void (*PlaylistItemActivatedCallback)(const char *path, gpointer user_data);

/* Create playlist widget */
Playlist* playlist_new(Player *player);
void playlist_destroy(Playlist *playlist);

/* Get main widget */
GtkWidget* playlist_get_widget(Playlist *playlist);

/* Add/remove items */
void playlist_add_file(Playlist *playlist, const char *path, gboolean append);
void playlist_add_files(Playlist *playlist, GSList *paths);
void playlist_remove_selected(Playlist *playlist);
void playlist_clear(Playlist *playlist);
void playlist_refill_player(Playlist *playlist);
void playlist_save_to_file(Playlist *playlist, const char *filename);

/* Navigation */
void playlist_play_selected(Playlist *playlist);
void playlist_play_index(Playlist *playlist, int index);
void playlist_play_next(Playlist *playlist);
void playlist_play_prev(Playlist *playlist);
int playlist_get_count(Playlist *playlist);
int playlist_get_current_index(Playlist *playlist);
void playlist_set_current_index(Playlist *playlist, int index);

/* Modes */
void playlist_set_repeat_mode(Playlist *playlist, PlaylistRepeatMode mode);
PlaylistRepeatMode playlist_get_repeat_mode(Playlist *playlist);
void playlist_set_shuffle(Playlist *playlist, gboolean shuffle);
gboolean playlist_get_shuffle(Playlist *playlist);
void playlist_shuffle_now(Playlist *playlist);

/* Move items */
void playlist_move_up(Playlist *playlist);
void playlist_move_down(Playlist *playlist);

/* Set callback */
void playlist_set_item_activated_callback(Playlist *playlist,
                                          PlaylistItemActivatedCallback callback,
                                          gpointer user_data);

/* Sync with mpv playlist events */
void playlist_sync_from_player(Playlist *playlist);

#endif /* PLAYLIST_H */
