Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
textnotes.c File Reference
#include "common/darktable.h"
#include "gui/gdkkeys.h"
#include "common/datetime.h"
#include "common/debug.h"
#include "common/image.h"
#include "common/image_cache.h"
#include "common/variables.h"
#include "control/control.h"
#include "control/jobs.h"
#include "control/signal.h"
#include "gui/gtk.h"
#include "gui/gtkentry.h"
#include "libs/lib.h"
#include "views/view.h"
#include <glib.h>
#include <glib/gstdio.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
+ Include dependency graph for textnotes.c:

Go to the source code of this file.

Data Structures

struct  dt_lib_textnotes_t
 
struct  dt_textnotes_load_job_t
 
struct  dt_textnotes_load_result_t
 

Typedefs

typedef struct dt_lib_textnotes_t dt_lib_textnotes_t
 
typedef struct dt_textnotes_load_job_t dt_textnotes_load_job_t
 
typedef struct dt_textnotes_load_result_t dt_textnotes_load_result_t
 

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 void _save_now (dt_lib_module_t *self)
 
static void _render_preview (dt_lib_textnotes_t *d, const char *text)
 
static void _update_for_current_image (dt_lib_module_t *self)
 
static gboolean _image_has_txt_flag (const int32_t imgid)
 
static gboolean _set_image_paths (dt_lib_textnotes_t *d, const int32_t imgid)
 
static void _clear_variables_cache (dt_lib_textnotes_t *d)
 
static gboolean _textnotes_load_finish_idle (gpointer user_data)
 
static int32_t _textnotes_load_job_run (dt_job_t *job)
 
static void _textnotes_load_job_state (dt_job_t *job, dt_job_state_t state)
 
static void _textnotes_load_job_cleanup (void *data)
 
static gchar * _get_buffer_text (GtkTextBuffer *buffer)
 
static gchar * _get_edit_text (dt_lib_textnotes_t *d)
 
static void _set_edit_text (dt_lib_textnotes_t *d, const char *text)
 
voidget_params (dt_lib_module_t *self, int *size)
 
int set_params (dt_lib_module_t *self, const void *params, int size)
 
void init_presets (dt_lib_module_t *self)
 
static int _preview_text_window_width_px (dt_lib_textnotes_t *d)
 
static void _render_preview_from_edit (dt_lib_textnotes_t *d)
 
static void _preview_width_changed (GtkWidget *widget, GdkRectangle *allocation, gpointer user_data)
 Re-render the preview when the panel-given width changes, so embedded images rescale to fit the available width instead of forcing their parents to grow.
 
static void _completion_hide (dt_lib_textnotes_t *d)
 
static gboolean _completion_match (const char *item, const char *prefix)
 
static void _completion_fill (dt_lib_textnotes_t *d, const char *prefix)
 
static gboolean _completion_find_prefix (dt_lib_textnotes_t *d, GtkTextIter *cursor, GtkTextIter *start_iter, gchar **prefix_out)
 
static gboolean _completion_apply_selected (dt_lib_module_t *self)
 
static void _completion_update (dt_lib_module_t *self)
 
static gboolean _completion_focus_out_idle (gpointer user_data)
 
static gboolean _edit_key_press (GtkWidget *widget, GdkEventKey *event, dt_lib_module_t *self)
 
static gboolean _edit_key_release (GtkWidget *widget, GdkEventKey *event, dt_lib_module_t *self)
 
static gboolean _edit_button_release (GtkWidget *widget, GdkEventButton *event, dt_lib_module_t *self)
 
static void _completion_row_activated (GtkTreeView *tree, GtkTreePath *path, GtkTreeViewColumn *column, dt_lib_module_t *self)
 
static void _setup_completion (dt_lib_module_t *self, GtkWidget *textview)
 
static gboolean _alloc_row_buffers (const int width, guchar **row_in, guchar **row_out)
 
static void _free_row_buffers (guchar *row_in, guchar *row_out)
 
static void _colorcorrect_row (cmsHTRANSFORM transform, guchar *src, const int width, const int n_channels, const gboolean has_alpha, guchar *row_in, guchar *row_out)
 
static void _colorcorrect_pixbuf (GdkPixbuf *pixbuf)
 
static void _toggle_mode (GtkToggleButton *button, dt_lib_module_t *self)
 
static void _load_for_image (dt_lib_module_t *self, const int32_t imgid)
 
static gboolean _refresh_preview_idle (gpointer user_data)
 
static void _open_uri (const char *uri)
 
static gchar * _expand_text_for_preview (dt_lib_textnotes_t *d, const char *source_text)
 
static void _clear_mtime_label (dt_lib_textnotes_t *d)
 
static void _update_mtime_label (dt_lib_module_t *self)
 
static void _toggle_checklist_at_line (dt_lib_module_t *self, const int line_no)
 
static gboolean _preview_button_press (GtkWidget *widget, GdkEventButton *event, dt_lib_module_t *self)
 
static void _preview_map (GtkWidget *widget, dt_lib_module_t *self)
 
static void _edit_map (GtkWidget *widget, dt_lib_module_t *self)
 
static gboolean _initial_load_idle (gpointer user_data)
 
static void _ensure_has_txt_flag (const int32_t imgid)
 
static char * _text_sidecar_save_path (dt_lib_textnotes_t *d, const int32_t imgid)
 
static void _save_and_render (dt_lib_module_t *self)
 
static gboolean _save_timeout_cb (gpointer user_data)
 
static void _textbuffer_changed (GtkTextBuffer *buffer, dt_lib_module_t *self)
 
static gboolean _textview_focus_out (GtkWidget *widget, GdkEventFocus *event, dt_lib_module_t *self)
 
static void _image_changed_callback (gpointer instance, gpointer user_data)
 
static void _mouse_over_image_callback (gpointer instance, gpointer user_data)
 
void gui_init (dt_lib_module_t *self)
 
void gui_cleanup (dt_lib_module_t *self)
 

Typedef Documentation

◆ dt_lib_textnotes_t

◆ dt_textnotes_load_job_t

◆ dt_textnotes_load_result_t

Function Documentation

◆ _alloc_row_buffers()

static gboolean _alloc_row_buffers ( const int  width,
guchar **  row_in,
guchar **  row_out 
)
static

Definition at line 539 of file textnotes.c.

References dt_free, FALSE, TRUE, and width.

Referenced by _colorcorrect_pixbuf().

◆ _clear_mtime_label()

static void _clear_mtime_label ( dt_lib_textnotes_t d)
static

Definition at line 1640 of file textnotes.c.

References d, FALSE, and IS_NULL_PTR.

Referenced by _load_for_image(), _textnotes_load_finish_idle(), and _update_mtime_label().

◆ _clear_variables_cache()

static void _clear_variables_cache ( dt_lib_textnotes_t d)
static

Definition at line 1872 of file textnotes.c.

References d, dt_variables_params_destroy(), and IS_NULL_PTR.

Referenced by _load_for_image(), and gui_cleanup().

◆ _colorcorrect_pixbuf()

◆ _colorcorrect_row()

static void _colorcorrect_row ( cmsHTRANSFORM  transform,
guchar *  src,
const int  width,
const int  n_channels,
const gboolean  has_alpha,
guchar *  row_in,
guchar *  row_out 
)
static

Definition at line 560 of file textnotes.c.

References d, transform(), width, and x.

Referenced by _colorcorrect_pixbuf().

◆ _completion_apply_selected()

static gboolean _completion_apply_selected ( dt_lib_module_t self)
static

◆ _completion_fill()

static void _completion_fill ( dt_lib_textnotes_t d,
const char *  prefix 
)
static

◆ _completion_find_prefix()

static gboolean _completion_find_prefix ( dt_lib_textnotes_t d,
GtkTextIter *  cursor,
GtkTextIter *  start_iter,
gchar **  prefix_out 
)
static

Definition at line 305 of file textnotes.c.

References d, dt_free, FALSE, IS_NULL_PTR, p, and TRUE.

Referenced by _completion_update().

◆ _completion_focus_out_idle()

static gboolean _completion_focus_out_idle ( gpointer  user_data)
static

Definition at line 440 of file textnotes.c.

References _completion_hide(), _save_now(), d, dt_lib_module_t::data, and IS_NULL_PTR.

Referenced by _textview_focus_out().

◆ _completion_hide()

static void _completion_hide ( dt_lib_textnotes_t d)
static

◆ _completion_match()

static gboolean _completion_match ( const char *  item,
const char *  prefix 
)
static

Definition at line 265 of file textnotes.c.

References dt_free, FALSE, IS_NULL_PTR, and TRUE.

Referenced by _completion_fill().

◆ _completion_row_activated()

static void _completion_row_activated ( GtkTreeView *  tree,
GtkTreePath *  path,
GtkTreeViewColumn *  column,
dt_lib_module_t self 
)
static

Definition at line 501 of file textnotes.c.

References _completion_apply_selected(), and void().

Referenced by _setup_completion().

◆ _completion_update()

◆ _edit_button_release()

static gboolean _edit_button_release ( GtkWidget widget,
GdkEventButton *  event,
dt_lib_module_t self 
)
static

Definition at line 493 of file textnotes.c.

References _completion_update(), FALSE, and void().

Referenced by gui_init().

◆ _edit_key_press()

static gboolean _edit_key_press ( GtkWidget widget,
GdkEventKey *  event,
dt_lib_module_t self 
)
static

◆ _edit_key_release()

static gboolean _edit_key_release ( GtkWidget widget,
GdkEventKey *  event,
dt_lib_module_t self 
)
static

Definition at line 485 of file textnotes.c.

References _completion_update(), FALSE, and void().

Referenced by gui_init().

◆ _edit_map()

static void _edit_map ( GtkWidget widget,
dt_lib_module_t self 
)
static

Definition at line 1833 of file textnotes.c.

References _update_for_current_image().

Referenced by gui_init().

◆ _ensure_has_txt_flag()

static void _ensure_has_txt_flag ( const int32_t  imgid)
static

◆ _expand_text_for_preview()

◆ _free_row_buffers()

static void _free_row_buffers ( guchar *  row_in,
guchar *  row_out 
)
static

Definition at line 554 of file textnotes.c.

References dt_free.

Referenced by _colorcorrect_pixbuf().

◆ _get_buffer_text()

static gchar * _get_buffer_text ( GtkTextBuffer *  buffer)
static

Definition at line 133 of file textnotes.c.

References TRUE.

Referenced by _get_edit_text(), and _toggle_checklist_at_line().

◆ _get_edit_text()

static gchar * _get_edit_text ( dt_lib_textnotes_t d)
static

Definition at line 140 of file textnotes.c.

References _get_buffer_text(), d, and IS_NULL_PTR.

Referenced by _render_preview_from_edit(), _save_and_render(), _toggle_mode(), and get_params().

◆ _image_changed_callback()

static void _image_changed_callback ( gpointer  instance,
gpointer  user_data 
)
static

Definition at line 2134 of file textnotes.c.

References _update_for_current_image().

Referenced by gui_cleanup(), and gui_init().

◆ _image_has_txt_flag()

static gboolean _image_has_txt_flag ( const int32_t  imgid)
static

◆ _initial_load_idle()

static gboolean _initial_load_idle ( gpointer  user_data)
static

Definition at line 1838 of file textnotes.c.

References _update_for_current_image(), d, dt_lib_module_t::data, and IS_NULL_PTR.

Referenced by gui_init().

◆ _load_for_image()

◆ _mouse_over_image_callback()

static void _mouse_over_image_callback ( gpointer  instance,
gpointer  user_data 
)
static

Definition at line 2140 of file textnotes.c.

References _update_for_current_image().

Referenced by gui_cleanup(), and gui_init().

◆ _open_uri()

static void _open_uri ( const char *  uri)
static

◆ _preview_button_press()

static gboolean _preview_button_press ( GtkWidget widget,
GdkEventButton *  event,
dt_lib_module_t self 
)
static

Definition at line 1739 of file textnotes.c.

References _open_uri(), _toggle_checklist_at_line(), FALSE, t, TRUE, and view().

Referenced by gui_init().

◆ _preview_map()

static void _preview_map ( GtkWidget widget,
dt_lib_module_t self 
)
static

Definition at line 1823 of file textnotes.c.

References _render_preview_from_edit(), d, dt_lib_module_t::data, IS_NULL_PTR, and void().

Referenced by gui_init().

◆ _preview_text_window_width_px()

static int _preview_text_window_width_px ( dt_lib_textnotes_t d)
static

Definition at line 212 of file textnotes.c.

References d, and IS_NULL_PTR.

◆ _preview_width_changed()

static void _preview_width_changed ( GtkWidget widget,
GdkRectangle *  allocation,
gpointer  user_data 
)
static

Re-render the preview when the panel-given width changes, so embedded images rescale to fit the available width instead of forcing their parents to grow.

The handler is connected to the preview scrolled window, whose width is driven top-down by the panel (not by the rendered content), so it is a stable reference. We only re-render on a meaningful width change and never while a render is already running, which keeps this from looping (a re-render at an unchanged width produces the same layout, hence no further width change).

Definition at line 240 of file textnotes.c.

References _render_preview_from_edit(), ABS, d, dt_lib_module_t::data, DT_PIXEL_APPLY_DPI, and IS_NULL_PTR.

Referenced by gui_init().

◆ _refresh_preview_idle()

static gboolean _refresh_preview_idle ( gpointer  user_data)
static

Definition at line 1810 of file textnotes.c.

References _render_preview_from_edit(), d, dt_lib_module_t::data, and IS_NULL_PTR.

◆ _render_preview()

static void _render_preview ( dt_lib_textnotes_t d,
const char *  text 
)
static

◆ _render_preview_from_edit()

static void _render_preview_from_edit ( dt_lib_textnotes_t d)
static

◆ _save_and_render()

◆ _save_now()

static void _save_now ( dt_lib_module_t self)
static

◆ _save_timeout_cb()

static gboolean _save_timeout_cb ( gpointer  user_data)
static

Definition at line 1978 of file textnotes.c.

References _save_and_render(), d, and dt_lib_module_t::data.

Referenced by _textbuffer_changed().

◆ _set_edit_text()

static void _set_edit_text ( dt_lib_textnotes_t d,
const char *  text 
)
static

Definition at line 147 of file textnotes.c.

References d, FALSE, IS_NULL_PTR, and TRUE.

Referenced by _load_for_image(), _textnotes_load_finish_idle(), and set_params().

◆ _set_image_paths()

static gboolean _set_image_paths ( dt_lib_textnotes_t d,
const int32_t  imgid 
)
static

Definition at line 1879 of file textnotes.c.

References d, dt_free, dt_image_full_path(), FALSE, IS_NULL_PTR, PATH_MAX, and TRUE.

Referenced by _expand_text_for_preview(), and _text_sidecar_save_path().

◆ _setup_completion()

static void _setup_completion ( dt_lib_module_t self,
GtkWidget textview 
)
static

◆ _text_sidecar_save_path()

static char * _text_sidecar_save_path ( dt_lib_textnotes_t d,
const int32_t  imgid 
)
static

Definition at line 1907 of file textnotes.c.

References _set_image_paths(), d, dt_image_build_text_path_from_path(), and IS_NULL_PTR.

Referenced by _load_for_image().

◆ _textbuffer_changed()

static void _textbuffer_changed ( GtkTextBuffer *  buffer,
dt_lib_module_t self 
)
static

Definition at line 1998 of file textnotes.c.

References _completion_update(), _save_timeout_cb(), d, dt_lib_module_t::data, and TRUE.

Referenced by gui_init().

◆ _textnotes_load_finish_idle()

◆ _textnotes_load_job_cleanup()

static void _textnotes_load_job_cleanup ( void data)
static

Definition at line 1927 of file textnotes.c.

References dt_free, and IS_NULL_PTR.

Referenced by _load_for_image().

◆ _textnotes_load_job_run()

static int32_t _textnotes_load_job_run ( dt_job_t job)
static

Definition at line 1915 of file textnotes.c.

References dt_control_job_get_params(), IS_NULL_PTR, and TRUE.

Referenced by _load_for_image().

◆ _textnotes_load_job_state()

◆ _textview_focus_out()

static gboolean _textview_focus_out ( GtkWidget widget,
GdkEventFocus *  event,
dt_lib_module_t self 
)
static

Definition at line 2015 of file textnotes.c.

References _completion_focus_out_idle(), d, dt_lib_module_t::data, FALSE, and void().

Referenced by gui_init().

◆ _toggle_checklist_at_line()

static void _toggle_checklist_at_line ( dt_lib_module_t self,
const int  line_no 
)
static

◆ _toggle_mode()

static void _toggle_mode ( GtkToggleButton *  button,
dt_lib_module_t self 
)
static

◆ _update_for_current_image()

◆ _update_mtime_label()

◆ container()

uint32_t container ( dt_lib_module_t self)

Definition at line 95 of file textnotes.c.

References DT_UI_CONTAINER_PANEL_LEFT_CENTER.

◆ get_params()

void * get_params ( dt_lib_module_t self,
int *  size 
)

Definition at line 156 of file textnotes.c.

References _get_edit_text(), d, dt_lib_module_t::data, IS_NULL_PTR, and size.

◆ gui_cleanup()

◆ gui_init()

◆ init_presets()

void init_presets ( dt_lib_module_t self)

Definition at line 185 of file textnotes.c.

References dt_lib_presets_add(), dt_lib_module_t::plugin_name, and TRUE.

◆ name()

const char * name ( dt_lib_module_t self)

Definition at line 84 of file textnotes.c.

◆ position()

int position ( )

Definition at line 100 of file textnotes.c.

◆ set_params()

int set_params ( dt_lib_module_t self,
const void params,
int  size 
)

Definition at line 169 of file textnotes.c.

References _save_now(), _set_edit_text(), d, dt_lib_module_t::data, dt_free, IS_NULL_PTR, size, and TRUE.

◆ views()

const char ** views ( dt_lib_module_t self)

Definition at line 89 of file textnotes.c.

References v.