Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
user_shortcuts.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: © 2021 Alexandros Theodotou <alex@zrythm.org>
3 *
4 * SPDX-License-Identifier: LicenseRef-ZrythmLicense
5 */
6
13#ifndef __SETTINGS_USER_SHORTCUTS_H__
14#define __SETTINGS_USER_SHORTCUTS_H__
15
16#include <stdbool.h>
17
18#include "utils/yaml.h"
19
26#define USER_SHORTCUTS_SCHEMA_VERSION 2
27
28typedef struct UserShortcut
29{
30 char * action;
31 char * primary;
32 char * secondary;
34
38typedef struct UserShortcuts
39{
42
45 int num_shortcuts;
47
48static const cyaml_schema_field_t user_shortcut_fields_schema[] = {
49 YAML_FIELD_STRING_PTR (UserShortcut, action),
50 YAML_FIELD_STRING_PTR (UserShortcut, primary),
51 YAML_FIELD_STRING_PTR_OPTIONAL (UserShortcut, secondary),
52
53 CYAML_FIELD_END
54};
55
56static const cyaml_schema_value_t user_shortcut_schema = {
57 YAML_VALUE_PTR (UserShortcut, user_shortcut_fields_schema),
58};
59
60static const cyaml_schema_field_t user_shortcuts_fields_schema[] = {
61 YAML_FIELD_INT (UserShortcuts, schema_version),
64 shortcuts,
65 user_shortcut_schema),
66
67 CYAML_FIELD_END
68};
69
70static const cyaml_schema_value_t user_shortcuts_schema = {
71 YAML_VALUE_PTR (UserShortcuts, user_shortcuts_fields_schema),
72};
73
74void
75user_shortcut_free (UserShortcut * shortcut);
76
82
90const char *
92 UserShortcuts * self,
93 bool primary,
94 const char * action,
95 const char * default_shortcut);
96
97void
98user_shortcuts_free (UserShortcuts * self);
99
104#endif
const char * user_shortcuts_get(UserShortcuts *self, bool primary, const char *action, const char *default_shortcut)
Returns a shortcut for the given action, or default_shortcut if not found.
UserShortcuts * user_shortcuts_new(void)
Reads the file and fills up the object.
#define YAML_VALUE_PTR(cc, fields_schema)
Schema to be used as a pointer.
Definition yaml.h:202
#define YAML_FIELD_FIXED_SIZE_PTR_ARRAY_VAR_COUNT(owner, member, schema)
Fixed-width array of pointers with variable count.
Definition yaml.h:55
User shortcuts read from yaml.
int schema_version
Version of the file.
UserShortcut * shortcuts[900]
Valid descriptors.
YAML utils.