Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
style_repository.h File Reference
#include <glib.h>
#include <inttypes.h>
+ Include dependency graph for style_repository.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef void(* dt_style_repository_style_cb) (void *user_data, const char *name, const char *description)
 
typedef void(* dt_style_repository_item_cb) (void *user_data, const int num, const int multi_priority, const int module_version, const char *operation, const int enabled, const void *params, const int32_t params_size, const void *blendop_params, const int32_t blendop_params_size, const int blendop_version, const char *multi_name, const int selimg_num, const double iop_order)
 

Functions

int32_t dt_style_repository_get_id_by_name (const char *name)
 
char * dt_style_repository_get_description (const int32_t styleid)
 
char * dt_style_repository_get_iop_list (const char *name)
 
gboolean dt_style_repository_insert_header (const char *name, const char *description, const char *iop_list_txt)
 
gboolean dt_style_repository_set_iop_list (const int32_t styleid, const char *iop_list_txt)
 
gboolean dt_style_repository_update_header (const int32_t styleid, const char *newname, const char *description)
 
gboolean dt_style_repository_delete (const int32_t styleid)
 
void dt_style_repository_foreach_style (const char *filter, dt_style_repository_style_cb cb, void *user_data)
 
gboolean dt_style_repository_get_style (const char *name, dt_style_repository_style_cb cb, void *user_data)
 
void dt_style_repository_foreach_apply_item (const int32_t styleid, dt_style_repository_item_cb cb, void *user_data)
 
void dt_style_repository_foreach_item_for_export (const int32_t styleid, dt_style_repository_item_cb cb, void *user_data)
 
void dt_style_repository_foreach_item_with_params (const int32_t styleid, dt_style_repository_item_cb cb, void *user_data)
 
void dt_style_repository_foreach_item (const int32_t styleid, dt_style_repository_item_cb cb, void *user_data)
 
void dt_style_repository_foreach_item_against_image (const int32_t styleid, const int32_t imgid, dt_style_repository_item_cb cb, void *user_data)
 
gboolean dt_style_repository_copy_items_from_history (const int32_t styleid, const int32_t imgid, GList *nums)
 
gboolean dt_style_repository_copy_items_from_style (const int32_t dest_styleid, const int32_t source_styleid, GList *nums)
 
gboolean dt_style_repository_delete_items_except (const int32_t styleid, GList *nums)
 
void dt_style_repository_update_item_from_history (const int32_t styleid, const int item_num, const int32_t imgid, const int history_num)
 
void dt_style_repository_append_item_from_history (const int32_t styleid, const int32_t imgid, const int history_num)
 
gboolean dt_style_repository_insert_item (const int32_t styleid, const int num, const int module_version, const char *operation, const void *params, const int32_t params_size, const int enabled, const void *blendop_params, const int32_t blendop_params_size, const int blendop_version, const int multi_priority, const char *multi_name)
 
gboolean dt_style_repository_normalize_multi_priority (const int32_t styleid)
 
void dt_style_repository_cleanup (void)
 

Typedef Documentation

◆ dt_style_repository_item_cb

typedef void(* dt_style_repository_item_cb) (void *user_data, const int num, const int multi_priority, const int module_version, const char *operation, const int enabled, const void *params, const int32_t params_size, const void *blendop_params, const int32_t blendop_params_size, const int blendop_version, const char *multi_name, const int selimg_num, const double iop_order)

one item row.

num is -1 when the column is SQL NULL. selimg_num is -1 unless the query was asked to match the style against an image, in which case it carries that image's own history num for the same module, or -1 where the image does not have it.

params / blendop_params are NULL for the listing queries that do not select them. Where they are not NULL they point INTO the statement and die with the row – copy them in the callback.

iop_order is read from the same column as blendop_version, because that is what the original query did; see dt_style_repository_foreach_item_with_params().

Definition at line 107 of file style_repository.h.

◆ dt_style_repository_style_cb

typedef void(* dt_style_repository_style_cb) (void *user_data, const char *name, const char *description)

one data.styles row

Definition at line 79 of file style_repository.h.

Function Documentation

◆ dt_style_repository_append_item_from_history()

void dt_style_repository_append_item_from_history ( const int32_t  styleid,
const int32_t  imgid,
const int  history_num 
)

append one of an image's history items to the style, numbered after its current last item

Definition at line 580 of file style_repository.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_EXEC, dt_free, and L.

Referenced by _dt_style_update_from_image().

◆ dt_style_repository_cleanup()

void dt_style_repository_cleanup ( void  )

finalise every cached statement. Must run before the connection closes.

Definition at line 712 of file style_repository.c.

References _styles_apply_items_stmt, _styles_get_list_stmt, _styles_stmt_mutex, _styles_stmt_mutex_ensure(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), and L.

Referenced by dt_styles_cleanup(), and testdb_teardown().

◆ dt_style_repository_copy_items_from_history()

gboolean dt_style_repository_copy_items_from_history ( const int32_t  styleid,
const int32_t  imgid,
GList nums 
)

copy an image's history into a style as items. nums is a GList of history nums to include (as GINT_TO_POINTER); NULL takes the whole history.

Definition at line 443 of file style_repository.c.

References _num_set_predicate(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, dt_free, FALSE, and L.

Referenced by dt_styles_create_from_image().

◆ dt_style_repository_copy_items_from_style()

gboolean dt_style_repository_copy_items_from_style ( const int32_t  dest_styleid,
const int32_t  source_styleid,
GList nums 
)

copy another style's items. nums selects which, as above; NULL takes all of them.

Definition at line 490 of file style_repository.c.

References _num_set_predicate(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, dt_free, FALSE, and L.

Referenced by dt_styles_create_from_style().

◆ dt_style_repository_delete()

gboolean dt_style_repository_delete ( const int32_t  styleid)

delete the header row and every item under it

Definition at line 197 of file style_repository.c.

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

Referenced by dt_styles_delete_by_name_adv().

◆ dt_style_repository_delete_items_except()

gboolean dt_style_repository_delete_items_except ( const int32_t  styleid,
GList nums 
)

drop every item whose num is NOT in nums

Definition at line 537 of file style_repository.c.

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

Referenced by dt_styles_update().

◆ dt_style_repository_foreach_apply_item()

void dt_style_repository_foreach_apply_item ( const int32_t  styleid,
dt_style_repository_item_cb  cb,
void user_data 
)

every item of the style with its parameter blobs, ordered (num, operation, multi_priority) – the order applying a style walks them in

Definition at line 272 of file style_repository.c.

References _styles_apply_items_stmt, _styles_stmt_mutex, _styles_stmt_mutex_ensure(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), IS_NULL_PTR, and L.

Referenced by _dt_styles_get_apply_items().

◆ dt_style_repository_foreach_item()

void dt_style_repository_foreach_item ( const int32_t  styleid,
dt_style_repository_item_cb  cb,
void user_data 
)

every item of the style, no blobs, highest num first – for listing it in the GUI.

NOTE this query selects only 8 columns, so there is no blendop_version/iop_order column at all; both come back 0, which is what the original read out of range. Preserved verbatim.

Definition at line 368 of file style_repository.c.

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

Referenced by dt_styles_get_item_list().

◆ dt_style_repository_foreach_item_against_image()

void dt_style_repository_foreach_item_against_image ( const int32_t  styleid,
const int32_t  imgid,
dt_style_repository_item_cb  cb,
void user_data 
)

the style's items UNION the image's own enabled history items that the style does not cover, so the GUI can show what applying it would replace and what it would add. No blobs; each row carries selimg_num.

Definition at line 397 of file style_repository.c.

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

Referenced by dt_styles_get_item_list().

◆ dt_style_repository_foreach_item_for_export()

void dt_style_repository_foreach_item_for_export ( const int32_t  styleid,
dt_style_repository_item_cb  cb,
void user_data 
)

every item of the style with its parameter blobs, in whatever order SQLite returns them – writing a style to its .dtstyle file, which restores by num and does not depend on the order. Deliberately a separate query from foreach_apply_item(): same columns, no ORDER BY.

Definition at line 311 of file style_repository.c.

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

Referenced by dt_styles_save_to_file().

◆ dt_style_repository_foreach_item_with_params()

void dt_style_repository_foreach_item_with_params ( const int32_t  styleid,
dt_style_repository_item_cb  cb,
void user_data 
)

every item of the style with its parameter blobs, highest num first.

NOTE this query selects blendop_version as its last column and the original read that same column BOTH as blendop_version (int) and as iop_order (double). Preserved verbatim: the callback receives it twice, once each way.

Definition at line 338 of file style_repository.c.

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

Referenced by dt_styles_get_item_list().

◆ dt_style_repository_foreach_style()

void dt_style_repository_foreach_style ( const char *  filter,
dt_style_repository_style_cb  cb,
void user_data 
)

every style whose name or description matches filter (a bare substring – this module wraps it in the LIKE wildcards), in name order

Definition at line 221 of file style_repository.c.

References _styles_get_list_stmt, _styles_stmt_mutex, _styles_stmt_mutex_ensure(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), IS_NULL_PTR, and L.

Referenced by dt_styles_get_list().

◆ dt_style_repository_get_description()

char * dt_style_repository_get_description ( const int32_t  styleid)

the style's description, or NULL. Caller owns it. NULL means either "no such style" or "the description column is NULL" – the two are not distinguishable here, and never were.

Definition at line 92 of file style_repository.c.

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

Referenced by dt_styles_get_description().

◆ dt_style_repository_get_id_by_name()

int32_t dt_style_repository_get_id_by_name ( const char *  name)

data.styles and data.style_items, plus the reads and writes of main.history that copy a development into a style and back.

Nothing here returns a dt_style_t or a dt_style_item_t. Those live in common/styles.h, which includes three develop/ headers to declare dt_iop_params_t and dt_develop_blend_params_t – four layers above this one. Rows are handed to a callback as scalars and common/styles.c builds the structs, which is also where a module's localized name has to come from (dt_iop_get_localized_name(), same layer problem).

A row callback runs while this module holds its statement mutex, so a callback must not call back into this repository. In practice they only build a list.

The iop_list column crosses the same boundary: this module stores and returns it as the TEXT it is, and styles.c serialises it through dt_ioppr_*. the id of the newest style with this name, or 0 if there is none

Definition at line 74 of file style_repository.c.

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

Referenced by dt_styles_get_id_by_name().

◆ dt_style_repository_get_iop_list()

char * dt_style_repository_get_iop_list ( const char *  name)

the style's iop_list column as stored, or NULL when the style has none (or does not exist). That is also the answer to "does this style carry a module order?". Caller owns it.

Definition at line 108 of file style_repository.c.

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

Referenced by dt_styles_has_module_order(), and dt_styles_module_order_list().

◆ dt_style_repository_get_style()

gboolean dt_style_repository_get_style ( const char *  name,
dt_style_repository_style_cb  cb,
void user_data 
)

the one style with this exact name; FALSE if there is none

Definition at line 249 of file style_repository.c.

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

Referenced by dt_styles_get_by_name().

◆ dt_style_repository_insert_header()

gboolean dt_style_repository_insert_header ( const char *  name,
const char *  description,
const char *  iop_list_txt 
)

insert a header row, taking the next free id. iop_list_txt may be NULL.

Definition at line 131 of file style_repository.c.

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

Referenced by dt_styles_create_style_header().

◆ dt_style_repository_insert_item()

gboolean dt_style_repository_insert_item ( const int32_t  styleid,
const int  num,
const int  module_version,
const char *  operation,
const void params,
const int32_t  params_size,
const int  enabled,
const void blendop_params,
const int32_t  blendop_params_size,
const int  blendop_version,
const int  multi_priority,
const char *  multi_name 
)

insert one fully specified item – what reading a style back from its XML file does

Definition at line 606 of file style_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, FALSE, L, and params_size().

Referenced by dt_style_plugin_save().

◆ dt_style_repository_normalize_multi_priority()

gboolean dt_style_repository_normalize_multi_priority ( const int32_t  styleid)

give every item a unique multi_priority per operation, numbered from 0 in multi_priority order. SQLite has no ROW_NUMBER, so this reads the rows and writes them back one by one.

Definition at line 641 of file style_repository.c.

References d, dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, dt_free_gpointer(), FALSE, L, and TRUE.

Referenced by dt_styles_create_from_image(), dt_styles_create_from_style(), and dt_styles_update().

◆ dt_style_repository_set_iop_list()

gboolean dt_style_repository_set_iop_list ( const int32_t  styleid,
const char *  iop_list_txt 
)

replace a style's module order; a NULL iop_list_txt clears the column

Definition at line 157 of file style_repository.c.

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

Referenced by _dt_style_update_iop_order().

◆ dt_style_repository_update_header()

gboolean dt_style_repository_update_header ( const int32_t  styleid,
const char *  newname,
const char *  description 
)

rename and re-describe an existing style

Definition at line 181 of file style_repository.c.

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

Referenced by dt_styles_update().

◆ dt_style_repository_update_item_from_history()

void dt_style_repository_update_item_from_history ( const int32_t  styleid,
const int  item_num,
const int32_t  imgid,
const int  history_num 
)

overwrite one style item from one of an image's history items.

These two are the only writes here that interpolate their integers into the query text rather than binding them, because that is what the originals did and a move is the wrong place to rewrite a query. They go through sqlite3_exec(), which reports nothing back, hence void. Every interpolated value is an int, so there is nothing to escape.

Definition at line 556 of file style_repository.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_EXEC, dt_free, FALSE, k, and L.

Referenced by _dt_style_update_from_image().