| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#include <libconfig.h> |
| 5 |
#include <stdbool.h> |
| 6 |
|
| 7 |
#include "config.h" |
| 8 |
#include "preset.h" |
| 9 |
#include "script.h" |
| 10 |
|
| 11 |
extern struct { |
| 12 |
const char *name; |
| 13 |
bool (*func)(struct win_script *output, config_setting_t *setting); |
| 14 |
} win_script_presets[]; |
| 15 |
|
| 16 |
bool win_script_parse_preset(struct win_script *output, config_setting_t *setting) { |
| 17 |
const char *preset = NULL; |
| 18 |
if (!config_setting_lookup_string(setting, "preset", &preset)) { |
| 19 |
log_error("Missing preset name in script"); |
| 20 |
return false; |
| 21 |
} |
| 22 |
for (unsigned i = 0; win_script_presets[i].name; i++) { |
| 23 |
if (strcmp(preset, win_script_presets[i].name) == 0) { |
| 24 |
log_debug("Using animation preset: %s", preset); |
| 25 |
return win_script_presets[i].func(output, setting); |
| 26 |
} |
| 27 |
} |
| 28 |
log_error("Unknown preset: %s", preset); |
| 29 |
return false; |
| 30 |
} |