Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
supported_file.h
Go to the documentation of this file.
1// clang-format off
2// SPDX-FileCopyrightText: © 2019-2021, 2023 Alexandros Theodotou <alex@zrythm.org>
3// SPDX-License-Identifier: LicenseRef-ZrythmLicense
4// clang-format on
5
12#ifndef __AUDIO_SUPPORTED_FILE_H__
13#define __AUDIO_SUPPORTED_FILE_H__
14
15#include <stdbool.h>
16
17#include "utils/yaml.h"
18
19typedef struct _WrappedObjectWithChangeSignal WrappedObjectWithChangeSignal;
20
27#define SUPPORTED_FILE_DND_PREFIX Z_DND_STRING_PREFIX "SupportedFile::"
28
32typedef enum ZFileType
33{
34 FILE_TYPE_MIDI,
35 FILE_TYPE_MP3,
36 FILE_TYPE_FLAC,
37 FILE_TYPE_OGG,
38 FILE_TYPE_WAV,
39 FILE_TYPE_DIR,
42 FILE_TYPE_OTHER,
43 NUM_FILE_TYPES,
44} ZFileType;
45
46static const cyaml_strval_t file_type_strings[] = {
47 {"MIDI", FILE_TYPE_MIDI },
48 { "mp3", FILE_TYPE_MP3 },
49 { "FLAC", FILE_TYPE_FLAC },
50 { "ogg", FILE_TYPE_OGG },
51 { "wav", FILE_TYPE_WAV },
52 { "directory", FILE_TYPE_DIR },
53 { "parent dir", FILE_TYPE_PARENT_DIR},
54 { "other", FILE_TYPE_OTHER },
55};
56
60typedef struct SupportedFile
61{
63 char * abs_path;
64
67
69 char * label;
70
72 int hidden;
73
75 // MidiFile * midi_file;
76
78 // AudioFile * midi_file;
79
83
84static const cyaml_schema_field_t supported_file_fields_schema[] = {
85 YAML_FIELD_STRING_PTR (SupportedFile, abs_path),
86 YAML_FIELD_ENUM (SupportedFile, type, file_type_strings),
87 YAML_FIELD_STRING_PTR_OPTIONAL (SupportedFile, label),
88 YAML_FIELD_INT (SupportedFile, hidden),
89
90 CYAML_FIELD_END
91};
92
93static const cyaml_schema_value_t supported_file_schema = {
94 YAML_VALUE_PTR_NULLABLE (SupportedFile, supported_file_fields_schema),
95};
96
103
105supported_file_new_from_uri (const char * uri, GError ** error);
106
113char *
115
121
125int
127
131int
133
137int
139
144const char *
146
150NONNULL ZFileType
151supported_file_get_type (const char * file);
152
157NONNULL bool
159
164const char *
166
170NONNULL char *
172
176void
178
183#endif
int supported_file_type_is_midi(ZFileType type)
Returns if the SupportedFile is a midi file.
ZFileType
File type.
SupportedFile * supported_file_new_from_path(const char *path)
Creates a new SupportedFile from the given absolute path.
void supported_file_free(SupportedFile *self)
Frees the instance and all its members.
int supported_file_type_is_supported(ZFileType type)
Returns if the given type is supported.
char * supported_file_type_get_description(ZFileType type)
Returns a human readable description of the given file type.
int supported_file_type_is_audio(ZFileType type)
Returns if the SupportedFile is an audio file.
NONNULL char * supported_file_get_info_text_for_label(const SupportedFile *self)
Returns a pango markup to be used in GTK labels.
NONNULL bool supported_file_should_autoplay(const SupportedFile *self)
Returns whether the given file should auto-play (shorter than 1 min).
NONNULL ZFileType supported_file_get_type(const char *file)
Returns the file type of the given file path.
SupportedFile * supported_file_clone(const SupportedFile *src)
Clones the given SupportedFile.
#define YAML_VALUE_PTR_NULLABLE(cc, fields_schema)
Schema to be used as a pointer that can be NULL.
Definition yaml.h:209
const char * supported_file_type_get_ext(ZFileType type)
Returns the most common extension for the given filetype.
const char * supported_file_get_icon_name(const SupportedFile *const self)
Gets the corresponding icon name for the given SupportedFile's type.
@ FILE_TYPE_PARENT_DIR
Special entry ".." for the parent dir.
Metadata for a supported file.
int hidden
Hidden or not.
char * label
Human readable label.
char * abs_path
Absolute path.
ZFileType type
Type of file.
WrappedObjectWithChangeSignal * gobj
MIDI file, if midi.
A GObject-ified normal C object with a signal that interested parties can listen to for changes.
YAML utils.