Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
studio_style.c File Reference
#include "common/darktable.h"
#include "common/debug.h"
#include "common/folder_survey.h"
#include "common/history_merge.h"
#include "common/image.h"
#include "common/styles.h"
#include "control/conf.h"
#include "control/control.h"
#include "gui/gtk.h"
#include "libs/lib.h"
#include "libs/lib_api.h"
#include "views/view.h"
+ Include dependency graph for studio_style.c:

Go to the source code of this file.

Data Structures

struct  dt_lib_studio_style_t
 

Typedefs

typedef enum dt_studio_pool_cols_t dt_studio_pool_cols_t
 
typedef enum dt_studio_styles_cols_t dt_studio_styles_cols_t
 
typedef struct dt_lib_studio_style_t dt_lib_studio_style_t
 

Enumerations

enum  dt_studio_pool_cols_t {
  POOL_COL_NAME = 0 ,
  POOL_NUM_COLS
}
 
enum  dt_studio_styles_cols_t {
  STYLES_COL_NAME = 0 ,
  STYLES_COL_FULLNAME ,
  STYLES_NUM_COLS
}
 

Functions

const char * name (dt_lib_module_t *self)
 
const char ** views (dt_lib_module_t *self)
 
uint32_t container (dt_lib_module_t *self)
 
int position ()
 
static gboolean _studio_style_pool_contains (dt_lib_studio_style_t *d, const char *name)
 
static void _studio_style_save (dt_lib_studio_style_t *d)
 Persist the pool, in order, to conf.
 
static void _studio_style_rebuild_pool_ui (dt_lib_studio_style_t *d)
 Rebuild the pool treeview, in order, from d->pool.
 
static void _studio_style_prune_pool (dt_lib_studio_style_t *d, GList *all_styles)
 Drop pool entries whose style no longer exists.
 
static gboolean _studio_style_get_node_for_name (GtkTreeModel *model, const gboolean root, GtkTreeIter *iter, const gchar *segment_name)
 Find, or create as a child of the last found/created sibling, the tree node for one "|"-separated path segment. Mirrors libs/styles.c's own category tree builder so both style browsers behave identically.
 
static void _studio_style_populate_styles_tree (dt_lib_studio_style_t *d)
 Rebuild the styles tree from every available style, grouping category segments split on "|" in the style name, and prune the pool of any name that no longer matches one.
 
static void _studio_style_name_cell_data_func (GtkTreeViewColumn *column, GtkCellRenderer *renderer, GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
 Gray a leaf's name when its style is already in the pool. Computed live at render time (not stored in the model), mirroring libs/history.c's _lib_history_view_cell_set_foreground for the same reason: cell renderers are not separate CSS nodes, so the theme cannot do this via :disabled.
 
static void _studio_style_add_cell_data_func (GtkTreeViewColumn *column, GtkCellRenderer *renderer, GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
 Show the add icon only on leaves, swapping in a pre-dimmed pixbuf when the leaf's style is already in the pool. Computed live at render time for the same reason as _studio_style_name_cell_data_func above.
 
static void _studio_style_pool_action_click (dt_lib_studio_style_t *d, GtkTreePath *path, GtkTreeViewColumn *column)
 Apply the up/down/remove action for the pool row under a click, identified by which icon column was hit.
 
static gboolean _studio_style_pool_button_pressed (GtkWidget *treeview, GdkEventButton *event, gpointer user_data)
 Left click on a pool row's up/down/remove icon column.
 
static gboolean _studio_style_pool_query_tooltip (GtkWidget *treeview, gint x, gint y, gboolean keyboard_tip, GtkTooltip *tooltip, gpointer user_data)
 
static gboolean _studio_style_add_click (dt_lib_studio_style_t *d, GtkWidget *treeview, GtkTreePath *path)
 Add the style leaf under a click to the end of the pool.
 
static gboolean _studio_style_styles_button_pressed (GtkWidget *treeview, GdkEventButton *event, gpointer user_data)
 
static gboolean _studio_style_styles_query_tooltip (GtkWidget *treeview, gint x, gint y, gboolean keyboard_tip, GtkTooltip *tooltip, gpointer user_data)
 
static void _studio_style_apply_callback (GtkWidget *widget, gpointer user_data)
 Re-apply the pool, in order, to the displayed image.
 
static void _studio_style_changed_callback (gpointer instance, gpointer user_data)
 
static void _studio_style_load_pool (dt_lib_studio_style_t *d)
 Load the persisted, ordered pool from conf, once at startup.
 
static GtkTreeViewColumn * _studio_style_add_name_column (GtkWidget *treeview, const int name_model_col, GtkCellRenderer **out_renderer)
 Append the text column carrying the row's display name. Packed with expand=TRUE so any later-appended icon columns stay flush right.
 
static GtkTreeViewColumn * _studio_style_add_icon_column (GtkWidget *treeview, const char *icon_name, GtkCellRenderer **out_renderer)
 Append one fixed-width icon column, for per-row action clicks handled by column identity (see the *_button_pressed handlers above).
 
static GdkPixbuf * _studio_style_load_icon (const char *icon_name, const double alpha)
 Load a themed icon at the menu icon size, optionally pre-blended to a lower alpha. Used for the styles tree's add icon: unlike a "sensitive" binding, a literal alpha blend is guaranteed to render dimmed regardless of theme/CSS quirks around cell renderers (see the struct comment above).
 
void gui_init (dt_lib_module_t *self)
 
void gui_cleanup (dt_lib_module_t *self)
 

Typedef Documentation

◆ dt_lib_studio_style_t

◆ dt_studio_pool_cols_t

Studio Capture: style module. "Pool" is the ordered treeview of styles actually applied, on import (first entry replaces the fresh history, the rest stack on top) or via the manual apply button. "Styles" below it is a tree of every available style, grouped into categories split on "|" in the style name (same convention as the library's own style panel). Both treeviews carry per-row action icons in dedicated columns (up/down/remove on pool rows, add on style leaves), matching the click-by-column pattern already used for mask group rows in develop/blend_gui.c.

◆ dt_studio_styles_cols_t

Enumeration Type Documentation

◆ dt_studio_pool_cols_t

Studio Capture: style module. "Pool" is the ordered treeview of styles actually applied, on import (first entry replaces the fresh history, the rest stack on top) or via the manual apply button. "Styles" below it is a tree of every available style, grouped into categories split on "|" in the style name (same convention as the library's own style panel). Both treeviews carry per-row action icons in dedicated columns (up/down/remove on pool rows, add on style leaves), matching the click-by-column pattern already used for mask group rows in develop/blend_gui.c.

Enumerator
POOL_COL_NAME 
POOL_NUM_COLS 

Definition at line 40 of file studio_style.c.

◆ dt_studio_styles_cols_t

Enumerator
STYLES_COL_NAME 
STYLES_COL_FULLNAME 
STYLES_NUM_COLS 

Definition at line 46 of file studio_style.c.

Function Documentation

◆ _studio_style_add_cell_data_func()

static void _studio_style_add_cell_data_func ( GtkTreeViewColumn *  column,
GtkCellRenderer *  renderer,
GtkTreeModel *  model,
GtkTreeIter *  iter,
gpointer  user_data 
)
static

Show the add icon only on leaves, swapping in a pre-dimmed pixbuf when the leaf's style is already in the pool. Computed live at render time for the same reason as _studio_style_name_cell_data_func above.

Definition at line 260 of file studio_style.c.

References _studio_style_pool_contains(), d, dt_free, FALSE, IS_NULL_PTR, model, STYLES_COL_FULLNAME, and TRUE.

Referenced by gui_init().

◆ _studio_style_add_click()

static gboolean _studio_style_add_click ( dt_lib_studio_style_t d,
GtkWidget treeview,
GtkTreePath *  path 
)
static

Add the style leaf under a click to the end of the pool.

Definition at line 371 of file studio_style.c.

References _studio_style_pool_contains(), _studio_style_rebuild_pool_ui(), _studio_style_save(), d, dt_free, FALSE, IS_NULL_PTR, model, STYLES_COL_FULLNAME, and TRUE.

Referenced by _studio_style_styles_button_pressed().

◆ _studio_style_add_icon_column()

static GtkTreeViewColumn * _studio_style_add_icon_column ( GtkWidget treeview,
const char *  icon_name,
GtkCellRenderer **  out_renderer 
)
static

Append one fixed-width icon column, for per-row action clicks handled by column identity (see the *_button_pressed handlers above).

Definition at line 517 of file studio_style.c.

References DT_PIXEL_APPLY_DPI, and FALSE.

Referenced by gui_init().

◆ _studio_style_add_name_column()

static GtkTreeViewColumn * _studio_style_add_name_column ( GtkWidget treeview,
const int  name_model_col,
GtkCellRenderer **  out_renderer 
)
static

Append the text column carrying the row's display name. Packed with expand=TRUE so any later-appended icon columns stay flush right.

Definition at line 499 of file studio_style.c.

References TRUE.

Referenced by gui_init().

◆ _studio_style_apply_callback()

static void _studio_style_apply_callback ( GtkWidget widget,
gpointer  user_data 
)
static

◆ _studio_style_changed_callback()

static void _studio_style_changed_callback ( gpointer  instance,
gpointer  user_data 
)
static

◆ _studio_style_get_node_for_name()

static gboolean _studio_style_get_node_for_name ( GtkTreeModel *  model,
const gboolean  root,
GtkTreeIter *  iter,
const gchar *  segment_name 
)
static

Find, or create as a child of the last found/created sibling, the tree node for one "|"-separated path segment. Mirrors libs/styles.c's own category tree builder so both style browsers behave identically.

Definition at line 160 of file studio_style.c.

References dt_free, FALSE, model, STYLES_COL_NAME, and TRUE.

Referenced by _studio_style_populate_styles_tree().

◆ _studio_style_load_icon()

static GdkPixbuf * _studio_style_load_icon ( const char *  icon_name,
const double  alpha 
)
static

Load a themed icon at the menu icon size, optionally pre-blended to a lower alpha. Used for the styles tree's add icon: unlike a "sensitive" binding, a literal alpha blend is guaranteed to render dimmed regardless of theme/CSS quirks around cell renderers (see the struct comment above).

Definition at line 537 of file studio_style.c.

References height, IS_NULL_PTR, and width.

Referenced by gui_init().

◆ _studio_style_load_pool()

static void _studio_style_load_pool ( dt_lib_studio_style_t d)
static

Load the persisted, ordered pool from conf, once at startup.

Definition at line 483 of file studio_style.c.

References d, dt_conf_get_string(), DT_FOLDER_SURVEY_STYLES_CONF_KEY, DT_FOLDER_SURVEY_STYLES_SEPARATOR, and dt_free.

Referenced by gui_init().

◆ _studio_style_name_cell_data_func()

static void _studio_style_name_cell_data_func ( GtkTreeViewColumn *  column,
GtkCellRenderer *  renderer,
GtkTreeModel *  model,
GtkTreeIter *  iter,
gpointer  user_data 
)
static

Gray a leaf's name when its style is already in the pool. Computed live at render time (not stored in the model), mirroring libs/history.c's _lib_history_view_cell_set_foreground for the same reason: cell renderers are not separate CSS nodes, so the theme cannot do this via :disabled.

Definition at line 240 of file studio_style.c.

References _studio_style_pool_contains(), d, dt_free, FALSE, IS_NULL_PTR, model, STYLES_COL_FULLNAME, and TRUE.

Referenced by gui_init().

◆ _studio_style_pool_action_click()

static void _studio_style_pool_action_click ( dt_lib_studio_style_t d,
GtkTreePath *  path,
GtkTreeViewColumn *  column 
)
static

Apply the up/down/remove action for the pool row under a click, identified by which icon column was hit.

Definition at line 285 of file studio_style.c.

References _studio_style_rebuild_pool_ui(), _studio_style_save(), d, dt_free, and IS_NULL_PTR.

Referenced by _studio_style_pool_button_pressed().

◆ _studio_style_pool_button_pressed()

static gboolean _studio_style_pool_button_pressed ( GtkWidget treeview,
GdkEventButton *  event,
gpointer  user_data 
)
static

Left click on a pool row's up/down/remove icon column.

Returns
TRUE when an action column was hit, so the treeview's default handler does not also change the row selection.

Definition at line 329 of file studio_style.c.

References _studio_style_pool_action_click(), d, FALSE, and IS_NULL_PTR.

Referenced by gui_init().

◆ _studio_style_pool_contains()

static gboolean _studio_style_pool_contains ( dt_lib_studio_style_t d,
const char *  name 
)
static

◆ _studio_style_pool_query_tooltip()

static gboolean _studio_style_pool_query_tooltip ( GtkWidget treeview,
gint  x,
gint  y,
gboolean  keyboard_tip,
GtkTooltip *  tooltip,
gpointer  user_data 
)
static

Definition at line 347 of file studio_style.c.

References d, FALSE, IS_NULL_PTR, tooltip, TRUE, and x.

Referenced by gui_init().

◆ _studio_style_populate_styles_tree()

static void _studio_style_populate_styles_tree ( dt_lib_studio_style_t d)
static

Rebuild the styles tree from every available style, grouping category segments split on "|" in the style name, and prune the pool of any name that no longer matches one.

Definition at line 201 of file studio_style.c.

References _studio_style_get_node_for_name(), _studio_style_prune_pool(), d, dt_style_free(), dt_styles_get_list(), k, dt_style_t::name, store(), STYLES_COL_FULLNAME, STYLES_COL_NAME, and STYLES_NUM_COLS.

Referenced by _studio_style_changed_callback(), and gui_init().

◆ _studio_style_prune_pool()

static void _studio_style_prune_pool ( dt_lib_studio_style_t d,
GList *  all_styles 
)
static

Drop pool entries whose style no longer exists.

Definition at line 137 of file studio_style.c.

References d, dt_free, and FALSE.

Referenced by _studio_style_populate_styles_tree().

◆ _studio_style_rebuild_pool_ui()

static void _studio_style_rebuild_pool_ui ( dt_lib_studio_style_t d)
static

Rebuild the pool treeview, in order, from d->pool.

Definition at line 121 of file studio_style.c.

References d, POOL_COL_NAME, POOL_NUM_COLS, and store().

Referenced by _studio_style_add_click(), _studio_style_changed_callback(), _studio_style_pool_action_click(), and gui_init().

◆ _studio_style_save()

static void _studio_style_save ( dt_lib_studio_style_t d)
static

◆ _studio_style_styles_button_pressed()

static gboolean _studio_style_styles_button_pressed ( GtkWidget treeview,
GdkEventButton *  event,
gpointer  user_data 
)
static

Definition at line 392 of file studio_style.c.

References _studio_style_add_click(), d, FALSE, and IS_NULL_PTR.

Referenced by gui_init().

◆ _studio_style_styles_query_tooltip()

static gboolean _studio_style_styles_query_tooltip ( GtkWidget treeview,
gint  x,
gint  y,
gboolean  keyboard_tip,
GtkTooltip *  tooltip,
gpointer  user_data 
)
static

Definition at line 409 of file studio_style.c.

References d, FALSE, tooltip, TRUE, and x.

Referenced by gui_init().

◆ container()

uint32_t container ( dt_lib_module_t self)

Definition at line 85 of file studio_style.c.

References DT_UI_CONTAINER_PANEL_LEFT_CENTER.

◆ gui_cleanup()

◆ gui_init()

◆ name()

const char * name ( dt_lib_module_t self)

Definition at line 74 of file studio_style.c.

◆ position()

int position ( )

Definition at line 90 of file studio_style.c.

◆ views()

const char ** views ( dt_lib_module_t self)

Definition at line 79 of file studio_style.c.

References v.