Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
dev_history_gui.c File Reference
#include "develop/imageop_gui.h"
#include "widgets/widget_settings.h"
#include "develop/dev_history_gui.h"
#include "develop/blend_gui.h"
#include "develop/dev_history.h"
#include "develop/gui_throttle.h"
#include "develop/develop.h"
#include "develop/imageop.h"
#include "develop/masks_gui.h"
#include "develop/pixelpipe_hb.h"
#include "system/macros.h"
#include <gtk/gtk.h>
Include dependency graph for dev_history_gui.c:

Go to the source code of this file.

Data Structures

struct  dt_dev_pending_commit_t

Typedefs

typedef struct dt_dev_pending_commit_t dt_dev_pending_commit_t

Functions

static void _history_gui_refresh (dt_develop_t *dev)
static void _undo_restore_gui (dt_develop_t *dev, const int mask_edit_mode, const int request_mask_display)
void dt_dev_history_gui_update (dt_develop_t *dev)
 Apply history-loaded params to module GUIs.
static gboolean _drain_pending_commits (gpointer user_data)
static gboolean _request_is_switch (void)
static void _queue_pending_commit (dt_develop_t *dev, dt_iop_module_t *module, const gboolean enable)
void dt_dev_history_commit_item_from_gui (dt_develop_t *dev, dt_iop_module_t *module, const gboolean enable)
 Commit one history item from a GUI control now, after the commits queued before it.
void dt_dev_history_flush_pending_commits (dt_develop_t *dev)
 Run every history commit still queued for dev, now.
void dt_dev_history_drop_pending_commits (dt_develop_t *dev)
 Discard every history commit still queued for dev, without running it.
void dt_dev_add_history_item_real (dt_develop_t *dev, dt_iop_module_t *module, gboolean enable, gboolean redraw)
 Thread-safe wrapper around dt_dev_add_history_item_ext().
static void _commit_gui (dt_develop_t *dev, dt_iop_module_t *module)
void dt_dev_history_gui_init (void)
 Install the history engine's GUI handlers. Called once from dt_init() beside the other handler installs – safe under ansel-cli too, because every handler fires only for a dev with a focused GUI module, which a headless dev never has.

Variables

static GQueue _pending_commits = G_QUEUE_INIT
static guint _pending_commit_source = 0
static guint32 _last_choice_time = 0

Typedef Documentation

◆ dt_dev_pending_commit_t

typedef struct dt_dev_pending_commit_t dt_dev_pending_commit_t

Function Documentation

◆ _commit_gui()

◆ _drain_pending_commits()

◆ _history_gui_refresh()

◆ _queue_pending_commit()

◆ _request_is_switch()

◆ _undo_restore_gui()

void _undo_restore_gui ( dt_develop_t * dev,
const int mask_edit_mode,
const int request_mask_display )
static

◆ dt_dev_add_history_item_real()

void dt_dev_add_history_item_real ( struct dt_develop_t * dev,
struct dt_iop_module_t * module,
gboolean enable,
gboolean redraw )

Thread-safe wrapper around dt_dev_add_history_item_ext().

Locks history mutex, invalidates pipelines, triggers recomputation and saves history. This is the typical entry point for GUI actions.

Parameters
devDevelop context.
moduleModule instance.
enableEnable state.
redrawWhether to force a GUI redraw.

Definition at line 342 of file dev_history_gui.c.

References _queue_pending_commit(), dev, dt_masks_form_exit_creation(), enable(), and void().

◆ dt_dev_history_commit_item_from_gui()

void dt_dev_history_commit_item_from_gui ( struct dt_develop_t * dev,
struct dt_iop_module_t * module,
gboolean enable )

Commit one history item from a GUI control now, after the commits queued before it.

For a choice made in a GUI control that must land before the next statement, where dt_dev_add_history_item() would be wrong (it ends the shape creation session the edit belongs to): a shape tool setting. A shape drawn or edited on the canvas is not a choice and commits with dt_dev_history_commit_item_now(..., FALSE), even when a key ends it. It flushes the pending commits, so the edits queued before it keep their order, then commits with the switched rule of the queue: a key press, a combobox choice or a check box click keeps the outputs of the state it replaces (see dt_dev_history_commit_item_now()). GUI thread only.

Definition at line 270 of file dev_history_gui.c.

References _request_is_switch(), dev, dt_dev_history_commit_item_now(), dt_dev_history_flush_pending_commits(), and enable().

Referenced by dt_iop_gui_changed(), and rt_select_algorithm_callback().

◆ dt_dev_history_drop_pending_commits()

void dt_dev_history_drop_pending_commits ( struct dt_develop_t * dev)

Discard every history commit still queued for dev, without running it.

Last-resort counterpart to dt_dev_history_flush_pending_commits(), for a dev already too far torn down to commit to. Prefer the flush wherever the edit can still be saved.

Parameters
devthe develop context, or NULL to drop every pending request.

Definition at line 313 of file dev_history_gui.c.

References _pending_commit_source, _pending_commits, dev, dt_dev_pending_commit_t::dev, dt_free, and IS_NULL_PTR.

Referenced by cleanup(), and dt_dev_cleanup().

◆ dt_dev_history_flush_pending_commits()

void dt_dev_history_flush_pending_commits ( struct dt_develop_t * dev)

Run every history commit still queued for dev, now.

dt_dev_add_history_item_real() queues its commit rather than running it, so that a slider drag or a combobox scroll does not run one per step. A queued request IS the user's last edit, so it is run here, not discarded.

Any code about to tear down dev's pipe nodes, iop list or history MUST call this while dev is still whole – it is the last moment at which committing is safe, and a request draining after teardown is the darkroom race described in CLAUDE.md, which crashes far from where it is caused.

Parameters
devthe develop context, or NULL to flush every pending request.

Definition at line 277 of file dev_history_gui.c.

References _drain_pending_commits(), _pending_commit_source, _pending_commits, dev, dt_dev_pending_commit_t::dev, dt_dev_history_commit_item_now(), dt_free, dt_gui_throttle_get_timeout_ms(), dt_dev_pending_commit_t::enable, IS_NULL_PTR, dt_dev_pending_commit_t::module, and dt_dev_pending_commit_t::switched.

Referenced by _delayed_history_commit(), dt_dev_history_commit_item_from_gui(), dt_iop_gui_duplicate(), dt_masks_gui_form_save_creation(), and leave().

◆ dt_dev_history_gui_init()

void dt_dev_history_gui_init ( void )

Install the history engine's GUI handlers. Called once from dt_init() beside the other handler installs – safe under ansel-cli too, because every handler fires only for a dev with a focused GUI module, which a headless dev never has.

Definition at line 366 of file dev_history_gui.c.

References _commit_gui(), _undo_restore_gui(), dt_dev_history_set_commit_gui_handler(), and dt_dev_history_set_undo_restore_gui_handler().

Referenced by gui_init().

◆ dt_dev_history_gui_update()

void dt_dev_history_gui_update ( struct dt_develop_t * dev)

Apply history-loaded params to module GUIs.

Ensures module instances shown in the GUI match the history state.

Parameters
devDevelop context.

Definition at line 115 of file dev_history_gui.c.

References _history_gui_refresh(), dev, and dt_masks_form_exit_creation().

Referenced by _darkroom_image_loaded_callback(), _history_apply_history_end(), dt_apply_dev_history_update(), dt_ioppr_migrate_iop_order(), and dt_lightroom_import().

Variable Documentation

◆ _last_choice_time

guint32 _last_choice_time = 0
static

Definition at line 183 of file dev_history_gui.c.

Referenced by _request_is_switch().

◆ _pending_commit_source

guint _pending_commit_source = 0
static

◆ _pending_commits

GQueue _pending_commits = G_QUEUE_INIT
static