Project module

Project initialization, saving and loading.

Contents

Classes

struct Project
Contains all of the info that will be serialized into a project file.

Enums

enum ProjectPath { PROJECT_PATH_PROJECT_FILE, PROJECT_PATH_BACKUPS, PROJECT_PATH_PLUGINS, PROJECT_PATH_PLUGIN_STATES, PROJECT_PATH_PLUGIN_EXT_COPIES, PROJECT_PATH_PLUGIN_EXT_LINKS, PROJECT_PATH_EXPORTS, PROJECT_PATH_POOL }
enum SelectionType { SELECTION_TYPE_TRACK, SELECTION_TYPE_PLUGIN, SELECTION_TYPE_EDITOR }
Selection type, used for displaying info in the inspector.
enum ProjectCompressionFlag { PROJECT_COMPRESS_FILE, PROJECT_COMPRESS_DATA }
Flag to pass to project_compress() and project_decompress().

Typedefs

using SelectionType = enum SelectionType
Selection type, used for displaying info in the inspector.
using ProjectCompressionFlag = enum ProjectCompressionFlag
Flag to pass to project_compress() and project_decompress().
using Project = struct Project
Contains all of the info that will be serialized into a project file.

Functions

void project_sanity_check(Project* self)
Checks that everything is okay with the project.
auto project_load(char* filename, const int is_template) -> int
If project has a filename set, it loads that.
auto project_save(Project* self, const char* _dir, const bool is_backup, const bool show_notification, const bool async) -> int
Saves the project to a project file in the given dir.
auto project_autosave_cb(void* data) -> int
Autosave callback.
auto project_get_path(Project* self, ProjectPath path, bool backup) -> char*
Returns the requested project path as a newly allocated string.
void project_init_selections(Project* self)
Initializes the selections in the project.
auto _project_compress(bool compress, char** dest, size_t* dest_size, ProjectCompressionFlag dest_type, const char* src, const size_t src_size, ProjectCompressionFlag src_type) -> char*
Compresses/decompress a project from a file/data to a file/data.
auto project_new(Zrythm* zrythm) -> Project*
Creates an empty project object.
void project_free(Project* self)
Tears down the project.
auto settings_new(void) -> Settings*
Initializes settings.
void settings_reset_to_factory(int confirm, int exit_on_finish)
Resets settings to defaults.
void settings_print(int pretty_print)
Prints the current settings.
void settings_free(Settings* self)
Frees settings.

Enum documentation

enum ProjectPath

Enumerators
PROJECT_PATH_PROJECT_FILE
PROJECT_PATH_BACKUPS
PROJECT_PATH_PLUGINS

Plugins path.

PROJECT_PATH_PLUGIN_STATES

Path for state .ttl files.

PROJECT_PATH_PLUGIN_EXT_COPIES

External files for plugin states, under the STATES dir.

PROJECT_PATH_PLUGIN_EXT_LINKS

External files for plugin states, under the STATES dir.

PROJECT_PATH_EXPORTS
PROJECT_PATH_POOL

Function documentation

int project_load(char* filename, const int is_template)

If project has a filename set, it loads that.

Parameters
filename
is_template Load the project as a template and create a new project from it.
Returns 0 if successful, non-zero otherwise.

Otherwise it loads the default project.

int project_save(Project* self, const char* _dir, const bool is_backup, const bool show_notification, const bool async)

Saves the project to a project file in the given dir.

Parameters
self
_dir
is_backup 1 if this is a backup. Backups will be saved as <original filename>.bak<num>.
show_notification Show a notification in the UI that the project was saved.
async Save asynchronously in another thread.
Returns Non-zero if error.

int project_autosave_cb(void* data)

Autosave callback.

This will keep getting called at regular short intervals, and if enough time has passed and it's okay to save it will autosave, otherwise it will wait until the next interval and check again.

char* project_get_path(Project* self, ProjectPath path, bool backup)

Returns the requested project path as a newly allocated string.

Parameters
self
path
backup Whether to get the path for the current backup instead of the main project.

void project_init_selections(Project* self)

Initializes the selections in the project.

char* _project_compress(bool compress, char** dest, size_t* dest_size, ProjectCompressionFlag dest_type, const char* src, const size_t src_size, ProjectCompressionFlag src_type)

Compresses/decompress a project from a file/data to a file/data.

Parameters
compress True to compress, false to decompress.
dest out Pointer to a location to allocate memory.
dest_size out Pointer to a location to store the size of the allocated memory.
dest_type
src Input buffer or filepath.
src_size Input buffer size, if not filepath.
src_type
Returns Error message if error, otherwise NULL.

Settings* settings_new(void)

Initializes settings.

void settings_reset_to_factory(int confirm, int exit_on_finish)

Resets settings to defaults.

Parameters
confirm
exit_on_finish Exit with a code on finish.

void settings_print(int pretty_print)

Prints the current settings.

void settings_free(Settings* self)

Frees settings.