#ifndef KEYBINDS_H
#define KEYBINDS_H

#include <gtk/gtk.h>

/* All bindable actions */
typedef enum {
    KEYBIND_PLAY_PAUSE,
    KEYBIND_STOP,
    KEYBIND_FULLSCREEN,
    KEYBIND_EXIT_FULLSCREEN,
    KEYBIND_SEEK_FORWARD,
    KEYBIND_SEEK_BACKWARD,
    KEYBIND_VOLUME_UP,
    KEYBIND_VOLUME_DOWN,
    KEYBIND_MUTE,
    KEYBIND_PREV_CHAPTER,
    KEYBIND_NEXT_CHAPTER,
    KEYBIND_FRAME_STEP,
    KEYBIND_OPEN_FILE,
    KEYBIND_OPEN_URL,
    KEYBIND_GOTO_TIME,
    KEYBIND_SCREENSHOT,
    KEYBIND_TOGGLE_PLAYLIST,
    KEYBIND_QUIT,
    KEYBIND_COUNT /* must be last */
} KeybindAction;

typedef struct {
    KeybindAction action;
    const char *label;       /* Human-readable name */
    guint keyval;            /* GDK key value */
    GdkModifierType mods;    /* Modifier mask (Ctrl, Shift, etc.) */
} Keybind;

typedef struct {
    Keybind binds[KEYBIND_COUNT];
} KeybindManager;

/* Lifecycle */
KeybindManager* keybind_manager_new(void);
void keybind_manager_free(KeybindManager *km);

/* Persistence */
void keybind_manager_load(KeybindManager *km, GKeyFile *keyfile);
void keybind_manager_save(KeybindManager *km, GKeyFile *keyfile);

/* Modification */
void keybind_manager_reset_defaults(KeybindManager *km);
void keybind_manager_set_keybind(KeybindManager *km, KeybindAction action, guint keyval, GdkModifierType mods);

/* Lookup */
Keybind* keybind_manager_get(KeybindManager *km, KeybindAction action);
KeybindAction keybind_manager_find_action(KeybindManager *km, guint keyval, GdkModifierType mods);

/* Utility */
char* keybind_get_display_string(guint keyval, GdkModifierType mods);

#endif /* KEYBINDS_H */
