Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
preset_repository.h File Reference

data.presets: a module's saved parameters, with the conditions under which it auto-applies. More...

#include <glib.h>
#include <stdint.h>
+ Include dependency graph for preset_repository.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  dt_preset_t
 One row of data.presets, owned by the caller. More...
 
struct  dt_module_preset_t
 
struct  dt_preset_match_t
 The facts about one image that decide whether a preset matches it. More...
 
struct  dt_preset_conditions_t
 
struct  dt_preset_row_t
 One row of the Preferences preset tree, with its auto-apply conditions. More...
 
struct  dt_preset_identity_t
 Identity of one preset, for callers listing rather than loading. More...
 

Typedefs

typedef G_BEGIN_DECLS struct dt_preset_t dt_preset_t
 One row of data.presets, owned by the caller.
 
typedef struct dt_module_preset_t dt_module_preset_t
 
typedef enum dt_preset_range_t dt_preset_range_t
 
typedef enum dt_preset_flag_t dt_preset_flag_t
 
typedef struct dt_preset_match_t dt_preset_match_t
 The facts about one image that decide whether a preset matches it.
 
typedef struct dt_preset_conditions_t dt_preset_conditions_t
 
typedef struct dt_preset_row_t dt_preset_row_t
 One row of the Preferences preset tree, with its auto-apply conditions.
 
typedef struct dt_preset_identity_t dt_preset_identity_t
 Identity of one preset, for callers listing rather than loading.
 

Enumerations

enum  dt_preset_range_t {
  DT_PRESET_RANGE_ISO = 0 ,
  DT_PRESET_RANGE_APERTURE ,
  DT_PRESET_RANGE_EXPOSURE ,
  DT_PRESET_RANGE_FOCAL_LENGTH ,
  DT_PRESET_RANGE_LAST
}
 
enum  dt_preset_flag_t {
  DT_PRESET_FLAG_FORMAT = 0 ,
  DT_PRESET_FLAG_AUTOAPPLY ,
  DT_PRESET_FLAG_FILTER ,
  DT_PRESET_FLAG_LAST
}
 

Functions

void dt_preset_free (dt_preset_t *preset)
 Release a dt_preset_t and everything it owns. NULL-safe.
 
dt_preset_tdt_preset_repository_get_by_rowid (const int rowid)
 The preset at rowid, or NULL when there is none. Free with dt_preset_free().
 
gboolean dt_preset_repository_insert (const dt_preset_t *preset)
 Insert preset, replacing any row that collides with it.
 
void dt_module_preset_free (gpointer data)
 Release one dt_module_preset_t. Suits g_list_free_full().
 
GListdt_preset_repository_list_for_module (const char *operation, const int op_version, const gboolean with_description, const gboolean shipped_first)
 Every preset of (operation, op_version).
 
GListdt_preset_repository_list_all_versions (const char *operation)
 Every preset of operation at ANY version, with rowid and op_version filled in, SHIPPED FIRST then by name then by rowid.
 
GListdt_preset_repository_list_for_version (const char *operation, const int op_version)
 As above, restricted to one op_version. Same columns, same order.
 
gboolean dt_preset_repository_module_preset_exists (const char *operation, const int op_version, const char *name)
 TRUE when (operation, op_version, name) exists.
 
int dt_preset_repository_find_rowid (const char *operation, const int op_version, const char *name)
 rowid of (operation, op_version, name), or -1.
 
dt_module_preset_tdt_preset_repository_get_module_preset (const char *operation, const int op_version, const char *name)
 One preset by name, or NULL. Free with dt_module_preset_free().
 
void dt_preset_repository_add_module_preset (const char *name, const char *operation, const int op_version, const void *params, const int params_size)
 Create an empty user preset holding params, as the "new preset" menu item does.
 
void dt_preset_repository_add_shipped_preset (const char *name, const char *operation, const int op_version, const void *params, const int params_size, const int writeprotect)
 Create a preset from code rather than from the menu – the built-in presets a module registers at startup.
 
void dt_preset_repository_update_module_params (const char *operation, const char *name, const int op_version, const void *params, const int params_size)
 Replace the parameters (and version) of (operation, name).
 
void dt_preset_repository_set_module_version (const char *operation, const char *name, const int op_version)
 Set ONLY the version of (operation, name), leaving the parameters alone.
 
void dt_preset_repository_set_blend_params (const char *operation, const char *name, const int blendop_version, const void *blend_params, const int blend_params_size)
 Replace the blend parameters (and blend version) of (operation, name), at any version. The op_params side is dt_preset_repository_update_module_params().
 
GListdt_preset_repository_list_for_upgrade (const char *operation)
 Every preset of operation at any version, with both parameter blobs.
 
void dt_preset_repository_rename_module_preset (const char *operation, const int op_version, const char *old_name, const char *new_name, const char *description, const void *params, const int params_size)
 Replace name, description and parameters of (operation, op_version, old_name).
 
void dt_preset_repository_duplicate_module_preset (const char *operation, const int op_version, const char *name, const char *new_name)
 Copy (operation, op_version, name) to new_name, unprotected.
 
void dt_preset_repository_delete_module_preset (const char *operation, const int op_version, const char *name)
 Delete (operation, op_version, name) unless it is write-protected.
 
void dt_preset_repository_delete_all_for_module (const char *operation)
 Delete every preset of operation, whatever its version or protection.
 
void dt_preset_repository_update_params_by_rowid (const int rowid, const int op_version, const void *params, const int params_size)
 Replace the parameters of one row, by rowid.
 
void dt_preset_repository_delete_by_rowid (const int rowid)
 Delete one row by rowid.
 
void dt_preset_repository_update_range (const char *operation, const int op_version, const char *name, const dt_preset_range_t range, const double min, const double max)
 Set the <range>_min / <range>_max pair of (operation, op_version, name).
 
void dt_preset_repository_update_flag (const char *operation, const int op_version, const char *name, const dt_preset_flag_t flag, const int value)
 Set one integer condition of (operation, op_version, name).
 
void dt_preset_repository_update_camera (const char *operation, const int op_version, const char *name, const char *maker, const char *model, const char *lens)
 Set the camera match of (operation, op_version, name).
 
void dt_preset_repository_add_iop_preset (const char *name, const char *operation, const int op_version, const void *params, const int params_size, const void *blend_params, const int blend_params_size, const int blendop_version, const int enabled)
 Store an IOP preset, blend parameters included, replacing any of the same name.
 
GListdt_preset_repository_list_for_iop (const char *operation, const int op_version)
 Every preset of (operation, op_version), with blend parameters.
 
GListdt_preset_repository_list_for_menu (const char *operation, const dt_preset_match_t *match, const gboolean shipped_first)
 Presets of operation to offer in a menu, in display order.
 
dt_module_preset_tdt_preset_repository_get_iop_preset (const char *operation, const int op_version, const char *name)
 One IOP preset by name, blend parameters included, or NULL.
 
GListdt_preset_repository_find_autoapply (const char *operation, const int op_version, const dt_preset_match_t *match, const char *always_name)
 Names of the presets that should be applied to this image automatically.
 
void dt_preset_conditions_free (dt_preset_conditions_t *c)
 Release the strings owned by c (not c itself).
 
gboolean dt_preset_repository_get_conditions (const char *operation, const int op_version, const char *name, dt_preset_conditions_t *c, int *rowid)
 Read the conditions of (operation, op_version, name).
 
void dt_preset_repository_update_conditions (const int rowid, const dt_preset_conditions_t *c)
 Overwrite the conditions of the row at rowid.
 
void dt_preset_repository_insert_with_conditions (const dt_preset_conditions_t *c, const char *operation, const int op_version, const void *params, const int params_size, const int enabled, const void *blend_params, const int blend_params_size, const int blendop_version)
 Create a preset from a full condition set plus its module payload.
 
gboolean dt_preset_repository_get_identity (const int rowid, gchar **operation, int *op_version)
 The (operation, op_version) a rowid belongs to. Returns FALSE if there is none; *operation is newly allocated on success.
 
void dt_preset_repository_update_iop_params (const char *operation, const char *name, const int op_version, const void *params, const int params_size, const int enabled, const void *blend_params, const int blend_params_size, const int blendop_version)
 Replace the module payload of (operation, name), at any version.
 
void dt_preset_repository_delete_by_rowid_unprotected (const int rowid)
 Delete the row at rowid unless it is write-protected.
 
void dt_preset_repository_delete_shipped (void)
 Delete every write-protected preset – the auto-generated ones, dropped at startup so module code can regenerate them.
 
void dt_preset_row_free (gpointer data)
 Free one dt_preset_row_t. Suits g_list_free_full().
 
GListdt_preset_repository_list_all (void)
 Every preset, ordered by (operation, name) – the grouping the tree relies on to start a new module node whenever operation changes.
 
void dt_preset_identity_free (gpointer data)
 Free one dt_preset_identity_t. Suits g_list_free_full().
 
GListdt_preset_repository_list_editable (void)
 Every preset the user may edit (writeprotect = 0), in row order.
 
void dt_preset_repository_cleanup (void)
 Finalise the cached statements. See dt_colorlabel_repository_cleanup().
 

Detailed Description

data.presets: a module's saved parameters, with the conditions under which it auto-applies.

Warning
Partial. gui/presets.c (281 SQL references), libs/lib.c (141), develop/imageop.c and libs/export.c all query this table directly, and two of those are a standing rule violation – CLAUDE.md says src/libs/ and src/views/ contain no raw SQL. They belong here. Extend this file; do not start a second preset repository.

Definition in file preset_repository.h.

Typedef Documentation

◆ dt_module_preset_t

One row as a preset menu wants it.

◆ dt_preset_conditions_t

Everything the edit dialog shows. Strings are owned by the struct when it comes out of dt_preset_repository_get_conditions(), and borrowed when it goes in.

◆ dt_preset_flag_t

◆ dt_preset_identity_t

Identity of one preset, for callers listing rather than loading.

◆ dt_preset_match_t

The facts about one image that decide whether a preset matches it.

Every field is bound, never interpolated. The _alias/_maker pair exists because a preset may name either the EXIF strings or rawspeed's canonical camera names, and the query tries both.

◆ dt_preset_range_t

◆ dt_preset_row_t

One row of the Preferences preset tree, with its auto-apply conditions.

◆ dt_preset_t

One row of data.presets, owned by the caller.

The whole row, because both users of it want the whole row: exporting a preset to a .dtpreset file writes every field, and importing one supplies every field. The table is wide and untyped-ish – filter, def and format are stored as REAL and read as int – and that is reproduced rather than corrected here.

Strings are never NULL in a struct that came from dt_preset_repository_get_by_rowid(); an absent column reads as "".

Enumeration Type Documentation

◆ dt_preset_flag_t

Enumerator
DT_PRESET_FLAG_FORMAT 

which of raw/LDR/HDR the preset applies to

DT_PRESET_FLAG_AUTOAPPLY 
DT_PRESET_FLAG_FILTER 

whether the preset is offered as a filter at all

DT_PRESET_FLAG_LAST 

Definition at line 267 of file preset_repository.h.

◆ dt_preset_range_t

Enumerator
DT_PRESET_RANGE_ISO 
DT_PRESET_RANGE_APERTURE 
DT_PRESET_RANGE_EXPOSURE 
DT_PRESET_RANGE_FOCAL_LENGTH 
DT_PRESET_RANGE_LAST 

Definition at line 258 of file preset_repository.h.

Function Documentation

◆ dt_module_preset_free()

◆ dt_preset_conditions_free()

void dt_preset_conditions_free ( dt_preset_conditions_t c)

Release the strings owned by c (not c itself).

Definition at line 1018 of file preset_repository.c.

References dt_free, and IS_NULL_PTR.

Referenced by _presets_show_edit_dialog().

◆ dt_preset_free()

void dt_preset_free ( dt_preset_t preset)

Release a dt_preset_t and everything it owns. NULL-safe.

Definition at line 31 of file preset_repository.c.

References dt_free, IS_NULL_PTR, and preset.

Referenced by dt_presets_save_to_file().

◆ dt_preset_identity_free()

void dt_preset_identity_free ( gpointer  data)

Free one dt_preset_identity_t. Suits g_list_free_full().

Definition at line 1285 of file preset_repository.c.

References dt_free, IS_NULL_PTR, and row.

Referenced by export_preset(), and test_list_editable_excludes_shipped().

◆ dt_preset_repository_add_iop_preset()

void dt_preset_repository_add_iop_preset ( const char *  name,
const char *  operation,
const int  op_version,
const void params,
const int  params_size,
const void blend_params,
const int  blend_params_size,
const int  blendop_version,
const int  enabled 
)

Store an IOP preset, blend parameters included, replacing any of the same name.

Definition at line 831 of file preset_repository.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_BLOB, DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, IS_NULL_PTR, L, name, and params_size().

Referenced by dt_gui_presets_add_with_blendop().

◆ dt_preset_repository_add_module_preset()

void dt_preset_repository_add_module_preset ( const char *  name,
const char *  operation,
const int  op_version,
const void params,
const int  params_size 
)

Create an empty user preset holding params, as the "new preset" menu item does.

Warning
Its auto-apply bounds are wildcards EXCEPT exposure_max, which is 1e8 here and 1e7 in dt_preset_repository_add_shipped_preset(). The two inserts have disagreed since they were written. Neither matters while autoapply is 0, which is the case for both – but the preset edit dialog opens on this row immediately after creation and shows the bound, so it is user-visible and the two are kept exactly as they were. Making them agree is a data change and belongs in its own commit.

Definition at line 417 of file preset_repository.c.

References _PRESET_COLUMNS, dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_BLOB, DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, L, name, and params_size().

Referenced by menuitem_new_preset(), test_list_all_carries_the_tree_row(), test_list_editable_excludes_shipped(), test_list_for_upgrade_returns_all_versions(), and test_set_module_version_leaves_params_alone().

◆ dt_preset_repository_add_shipped_preset()

void dt_preset_repository_add_shipped_preset ( const char *  name,
const char *  operation,
const int  op_version,
const void params,
const int  params_size,
const int  writeprotect 
)

Create a preset from code rather than from the menu – the built-in presets a module registers at startup.

Parameters
writeprotectnon-zero marks it as shipped and therefore undeletable.
Warning
exposure_max is 1e7 here. See dt_preset_repository_add_module_preset().

Definition at line 438 of file preset_repository.c.

References _PRESET_COLUMNS, dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_BLOB, DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, IS_NULL_PTR, L, name, and params_size().

Referenced by dt_lib_presets_add(), and test_list_editable_excludes_shipped().

◆ dt_preset_repository_cleanup()

void dt_preset_repository_cleanup ( void  )

Finalise the cached statements. See dt_colorlabel_repository_cleanup().

Definition at line 1317 of file preset_repository.c.

Referenced by dt_gui_presets_cleanup(), dt_lib_cleanup(), and testdb_teardown().

◆ dt_preset_repository_delete_all_for_module()

void dt_preset_repository_delete_all_for_module ( const char *  operation)

Delete every preset of operation, whatever its version or protection.

Definition at line 613 of file preset_repository.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, IS_NULL_PTR, and L.

Referenced by dt_lib_init_presets().

◆ dt_preset_repository_delete_by_rowid()

void dt_preset_repository_delete_by_rowid ( const int  rowid)

Delete one row by rowid.

Definition at line 644 of file preset_repository.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, and L.

Referenced by dt_lib_init_presets(), and init_presets().

◆ dt_preset_repository_delete_by_rowid_unprotected()

void dt_preset_repository_delete_by_rowid_unprotected ( const int  rowid)

Delete the row at rowid unless it is write-protected.

Definition at line 1208 of file preset_repository.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, and L.

Referenced by dt_gui_presets_confirm_and_delete().

◆ dt_preset_repository_delete_module_preset()

void dt_preset_repository_delete_module_preset ( const char *  operation,
const int  op_version,
const char *  name 
)

Delete (operation, op_version, name) unless it is write-protected.

Definition at line 594 of file preset_repository.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, IS_NULL_PTR, L, and name.

Referenced by dt_lib_presets_remove().

◆ dt_preset_repository_delete_shipped()

void dt_preset_repository_delete_shipped ( void  )

Delete every write-protected preset – the auto-generated ones, dropped at startup so module code can regenerate them.

Definition at line 1221 of file preset_repository.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_EXEC, and L.

Referenced by dt_gui_presets_init().

◆ dt_preset_repository_duplicate_module_preset()

void dt_preset_repository_duplicate_module_preset ( const char *  operation,
const int  op_version,
const char *  name,
const char *  new_name 
)

Copy (operation, op_version, name) to new_name, unprotected.

Definition at line 571 of file preset_repository.c.

References _PRESET_COLUMNS, dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, L, and name.

Referenced by dt_lib_presets_duplicate().

◆ dt_preset_repository_find_autoapply()

GList * dt_preset_repository_find_autoapply ( const char *  operation,
const int  op_version,
const dt_preset_match_t match,
const char *  always_name 
)

Names of the presets that should be applied to this image automatically.

Parameters
always_namea preset name matched regardless of the conditions – the workflow default. Pass a string no preset can be called to disable that leg.
Returns
a GList of newly allocated names, in database order. Free with g_list_free_full(l, g_free).

Definition at line 980 of file preset_repository.c.

References _bind_match(), _PRESET_MATCH_PREDICATE, dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, IS_NULL_PTR, L, and TRUE.

Referenced by dt_gui_presets_autoapply_for_module().

◆ dt_preset_repository_find_rowid()

int dt_preset_repository_find_rowid ( const char *  operation,
const int  op_version,
const char *  name 
)

rowid of (operation, op_version, name), or -1.

Definition at line 366 of file preset_repository.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, L, and name.

Referenced by edit_preset().

◆ dt_preset_repository_get_by_rowid()

dt_preset_t * dt_preset_repository_get_by_rowid ( const int  rowid)

The preset at rowid, or NULL when there is none. Free with dt_preset_free().

Definition at line 77 of file preset_repository.c.

References _column_blob(), _column_text(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, L, dt_preset_t::op_params, and p.

Referenced by dt_presets_save_to_file().

◆ dt_preset_repository_get_conditions()

gboolean dt_preset_repository_get_conditions ( const char *  operation,
const int  op_version,
const char *  name,
dt_preset_conditions_t c,
int *  rowid 
)

Read the conditions of (operation, op_version, name).

Parameters
rowidreceives the row's id, or -1 when there is no such preset.
Returns
TRUE when a row was found; c is only filled then.

Definition at line 1028 of file preset_repository.c.

References _column_text(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, FALSE, IS_NULL_PTR, L, name, and TRUE.

Referenced by _presets_show_edit_dialog().

◆ dt_preset_repository_get_identity()

gboolean dt_preset_repository_get_identity ( const int  rowid,
gchar **  operation,
int *  op_version 
)

The (operation, op_version) a rowid belongs to. Returns FALSE if there is none; *operation is newly allocated on success.

Definition at line 1156 of file preset_repository.c.

References _column_text(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, FALSE, IS_NULL_PTR, L, and TRUE.

Referenced by dt_gui_presets_show_edit_dialog(), and tree_key_press_presets().

◆ dt_preset_repository_get_iop_preset()

dt_module_preset_t * dt_preset_repository_get_iop_preset ( const char *  operation,
const int  op_version,
const char *  name 
)

One IOP preset by name, blend parameters included, or NULL.

Definition at line 944 of file preset_repository.c.

References _column_blob(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, L, name, and p.

Referenced by dt_gui_presets_apply_preset().

◆ dt_preset_repository_get_module_preset()

dt_module_preset_t * dt_preset_repository_get_module_preset ( const char *  operation,
const int  op_version,
const char *  name 
)

◆ dt_preset_repository_insert()

gboolean dt_preset_repository_insert ( const dt_preset_t preset)

Insert preset, replacing any row that collides with it.

Always writes writeprotect = 0: a preset arriving from a file is the user's, never one of the shipped read-only ones.

Returns
TRUE when the row was written.

Definition at line 140 of file preset_repository.c.

References _bind_text(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_BLOB, DT_DEBUG_SQLITE3_BIND_DOUBLE, DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, FALSE, IS_NULL_PTR, L, and preset.

Referenced by dt_presets_import_from_file().

◆ dt_preset_repository_insert_with_conditions()

void dt_preset_repository_insert_with_conditions ( const dt_preset_conditions_t c,
const char *  operation,
const int  op_version,
const void params,
const int  params_size,
const int  enabled,
const void blend_params,
const int  blend_params_size,
const int  blendop_version 
)

◆ dt_preset_repository_list_all()

GList * dt_preset_repository_list_all ( void  )

Every preset, ordered by (operation, name) – the grouping the tree relies on to start a new module node whenever operation changes.

Definition at line 1239 of file preset_repository.c.

References _column_text_or_null(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_PREPARE_V2, FALSE, IS_NULL_PTR, L, row, dt_preset_row_t::rowid, and TRUE.

Referenced by test_list_all_carries_the_tree_row(), and tree_insert_presets().

◆ dt_preset_repository_list_all_versions()

GList * dt_preset_repository_list_all_versions ( const char *  operation)

Every preset of operation at ANY version, with rowid and op_version filled in, SHIPPED FIRST then by name then by rowid.

The order is part of the contract: libs/ioporder.c takes the FIRST preset whose serialised module order matches the current one, so two presets with identical content must resolve to the shipped one. The startup upgrade pass acts per row by rowid and does not care.

Definition at line 280 of file preset_repository.c.

References _column_blob(), _column_text(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, L, and p.

Referenced by _ioporder_get_current_order_name(), dt_lib_init_presets(), and init_presets().

◆ dt_preset_repository_list_editable()

GList * dt_preset_repository_list_editable ( void  )

Every preset the user may edit (writeprotect = 0), in row order.

Definition at line 1294 of file preset_repository.c.

References _column_text_or_null(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_PREPARE_V2, IS_NULL_PTR, L, row, and dt_preset_identity_t::rowid.

Referenced by export_preset(), and test_list_editable_excludes_shipped().

◆ dt_preset_repository_list_for_iop()

GList * dt_preset_repository_list_for_iop ( const char *  operation,
const int  op_version 
)

Every preset of (operation, op_version), with blend parameters.

Ordered writeprotect ASC – user presets before shipped ones. The comment at the original call site explains why that direction: with DESC, a user's copy of a write-protected preset would resolve to the protected one and could not be deleted.

Definition at line 863 of file preset_repository.c.

References _iop_row(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, FALSE, L, and p.

Referenced by _get_active_preset_name().

◆ dt_preset_repository_list_for_menu()

GList * dt_preset_repository_list_for_menu ( const char *  operation,
const dt_preset_match_t match,
const gboolean  shipped_first 
)

Presets of operation to offer in a menu, in display order.

Parameters
matchthe image being edited, or NULL for "no particular image, show everything". When given, a preset with filter = 0 is always offered and the rest must match.
shipped_firstorder the read-only presets before the user's.

Definition at line 894 of file preset_repository.c.

References _bind_match(), _iop_row(), _PRESET_MATCH_PREDICATE, dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, dt_free, FALSE, L, p, and TRUE.

Referenced by _gui_presets_popup_menu_show_internal().

◆ dt_preset_repository_list_for_module()

GList * dt_preset_repository_list_for_module ( const char *  operation,
const int  op_version,
const gboolean  with_description,
const gboolean  shipped_first 
)

Every preset of (operation, op_version).

Parameters
with_descriptionalso read the description column. When FALSE the rows come back UNORDERED and shipped_first is ignored – faithful to the caller this branch replaced (get_active_preset_name), which scans every row for a params match and never cared about order.
shipped_firstorder the read-only presets before the user's, rather than after. A boolean rather than a sort direction: the caller used to interpolate "DESC" or "ASC" into the query text itself. Only meaningful with with_description.

Definition at line 222 of file preset_repository.c.

References _column_blob(), _column_text(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, dt_free, IS_NULL_PTR, L, and p.

Referenced by dt_lib_presets_popup_menu_show(), and get_active_preset_name().

◆ dt_preset_repository_list_for_upgrade()

GList * dt_preset_repository_list_for_upgrade ( const char *  operation)

Every preset of operation at any version, with both parameter blobs.

For the startup legacy-upgrade pass, which reads a preset, converts it and writes it straight back. It is the only reader that wants the blend blob alongside the op blob, and the only one that must not be holding a cursor on data.presets while it writes to it – so this materialises the rows and the caller's loop touches no statement.

Unordered, as that pass has always been: it acts on each row independently.

Definition at line 518 of file preset_repository.c.

References _column_blob(), _column_text(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, IS_NULL_PTR, L, and p.

Referenced by _init_presets(), and test_list_for_upgrade_returns_all_versions().

◆ dt_preset_repository_list_for_version()

GList * dt_preset_repository_list_for_version ( const char *  operation,
const int  op_version 
)

As above, restricted to one op_version. Same columns, same order.

Definition at line 313 of file preset_repository.c.

References _column_blob(), _column_text(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, L, and p.

Referenced by _ioporder_refresh_toolbar().

◆ dt_preset_repository_module_preset_exists()

gboolean dt_preset_repository_module_preset_exists ( const char *  operation,
const int  op_version,
const char *  name 
)

TRUE when (operation, op_version, name) exists.

Definition at line 347 of file preset_repository.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, L, and name.

Referenced by _edit_preset_response(), and dt_lib_presets_duplicate().

◆ dt_preset_repository_rename_module_preset()

void dt_preset_repository_rename_module_preset ( const char *  operation,
const int  op_version,
const char *  old_name,
const char *  new_name,
const char *  description,
const void params,
const int  params_size 
)

Replace name, description and parameters of (operation, op_version, old_name).

Definition at line 549 of file preset_repository.c.

References description(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_BLOB, DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, L, and params_size().

Referenced by dt_lib_presets_update().

◆ dt_preset_repository_set_blend_params()

void dt_preset_repository_set_blend_params ( const char *  operation,
const char *  name,
const int  blendop_version,
const void blend_params,
const int  blend_params_size 
)

Replace the blend parameters (and blend version) of (operation, name), at any version. The op_params side is dt_preset_repository_update_module_params().

Definition at line 497 of file preset_repository.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_BLOB, DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, IS_NULL_PTR, L, and name.

Referenced by _init_presets().

◆ dt_preset_repository_set_module_version()

void dt_preset_repository_set_module_version ( const char *  operation,
const char *  name,
const int  op_version 
)

Set ONLY the version of (operation, name), leaving the parameters alone.

Warning
Not a special case of dt_preset_repository_update_module_params(): that one also writes op_params. The startup upgrade pass uses this to stamp a version onto a preset whose blob is already correct, and writing the blob there would be wrong.

Like every (operation, name) predicate in this file, this can match more than one row – data.presets is UNIQUE on (name, operation, op_version), so the same name may exist at several versions. That is what the caller this replaced did, and it is preserved.

Definition at line 481 of file preset_repository.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, IS_NULL_PTR, L, and name.

Referenced by _init_presets(), and test_set_module_version_leaves_params_alone().

◆ dt_preset_repository_update_camera()

void dt_preset_repository_update_camera ( const char *  operation,
const int  op_version,
const char *  name,
const char *  maker,
const char *  model,
const char *  lens 
)

Set the camera match of (operation, op_version, name).

Parameters
makerstored wrapped in % on both sides, so it matches as a substring.
model,lensan empty string is stored as %, i.e. "any". That substitution is here rather than in the caller because it is about how the row has to look for the auto-apply query to match it.

Definition at line 730 of file preset_repository.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, IS_NULL_PTR, L, maker, model, and name.

Referenced by dt_gui_presets_update_mml().

◆ dt_preset_repository_update_conditions()

void dt_preset_repository_update_conditions ( const int  rowid,
const dt_preset_conditions_t c 
)

Overwrite the conditions of the row at rowid.

Definition at line 1096 of file preset_repository.c.

References _bind_conditions(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, IS_NULL_PTR, and L.

Referenced by _edit_preset_response().

◆ dt_preset_repository_update_flag()

void dt_preset_repository_update_flag ( const char *  operation,
const int  op_version,
const char *  name,
const dt_preset_flag_t  flag,
const int  value 
)

◆ dt_preset_repository_update_iop_params()

void dt_preset_repository_update_iop_params ( const char *  operation,
const char *  name,
const int  op_version,
const void params,
const int  params_size,
const int  enabled,
const void blend_params,
const int  blend_params_size,
const int  blendop_version 
)

Replace the module payload of (operation, name), at any version.

Definition at line 1181 of file preset_repository.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_BLOB, DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, L, name, and params_size().

Referenced by _menuitem_update_preset().

◆ dt_preset_repository_update_module_params()

void dt_preset_repository_update_module_params ( const char *  operation,
const char *  name,
const int  op_version,
const void params,
const int  params_size 
)

◆ dt_preset_repository_update_params_by_rowid()

void dt_preset_repository_update_params_by_rowid ( const int  rowid,
const int  op_version,
const void params,
const int  params_size 
)

Replace the parameters of one row, by rowid.

Definition at line 628 of file preset_repository.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_BLOB, DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, L, and params_size().

Referenced by dt_lib_init_presets(), and init_presets().

◆ dt_preset_repository_update_range()

void dt_preset_repository_update_range ( const char *  operation,
const int  op_version,
const char *  name,
const dt_preset_range_t  range,
const double  min,
const double  max 
)

◆ dt_preset_row_free()

void dt_preset_row_free ( gpointer  data)

Free one dt_preset_row_t. Suits g_list_free_full().

Definition at line 1227 of file preset_repository.c.

References dt_free, IS_NULL_PTR, and row.

Referenced by test_list_all_carries_the_tree_row(), and tree_insert_presets().