Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
textnotes.c File Reference
#include "system/macros.h"
#include "common/act_on.h"
#include "colorprofiles/colorspaces.h"
#include "system/mem_alloc.h"
#include "common/module_versioning.h"
#include "common/paths.h"
#include "widgets/gdkkeys.h"
#include "common/datetime.h"
#include "common/file_location.h"
#include "common/image.h"
#include "caches/image_cache.h"
#include "common/variables.h"
#include "control/control.h"
#include "control/jobs.h"
#include "control/signal.h"
#include "gui/application.h"
#include "widgets/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 "widgets/label.h"
#include "widgets/popup.h"
#include "widgets/scroll_wrap.h"
#include "widgets/widget_settings.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 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

◆ _clear_mtime_label()

static void _clear_mtime_label ( dt_lib_textnotes_t d)
static

Definition at line 1517 of file textnotes.c.

References d, FALSE, IS_NULL_PTR, and L.

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 1749 of file textnotes.c.

References d, dt_variables_params_destroy(), IS_NULL_PTR, and L.

Referenced by _load_for_image(), and gui_cleanup().

◆ _colorcorrect_pixbuf()

static void _colorcorrect_pixbuf ( GdkPixbuf pixbuf)
static

Definition at line 544 of file textnotes.c.

References dt_colorprofiles_srgb_to_display_strided(), IS_NULL_PTR, and L.

◆ _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 310 of file textnotes.c.

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

Referenced by _completion_update().

◆ _completion_focus_out_idle()

static gboolean _completion_focus_out_idle ( gpointer  user_data)
static

Definition at line 445 of file textnotes.c.

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

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 270 of file textnotes.c.

References dt_free, FALSE, IS_NULL_PTR, L, 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 506 of file textnotes.c.

References _completion_apply_selected(), L, 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 498 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 490 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 1710 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()

◆ _get_buffer_text()

static gchar * _get_buffer_text ( GtkTextBuffer buffer)
static

Definition at line 138 of file textnotes.c.

References L, and 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 145 of file textnotes.c.

References _get_buffer_text(), d, IS_NULL_PTR, and L.

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 2011 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 1715 of file textnotes.c.

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

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 2017 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 1616 of file textnotes.c.

References _open_uri(), _toggle_checklist_at_line(), FALSE, L, 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 1700 of file textnotes.c.

References _render_preview_from_edit(), d, dt_lib_module_t::data, IS_NULL_PTR, L, 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 217 of file textnotes.c.

References d, IS_NULL_PTR, and L.

◆ _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 245 of file textnotes.c.

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

Referenced by gui_init().

◆ _refresh_preview_idle()

static gboolean _refresh_preview_idle ( gpointer  user_data)
static

Definition at line 1687 of file textnotes.c.

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

◆ _render_preview()

◆ _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 1855 of file textnotes.c.

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

Referenced by _textbuffer_changed().

◆ _set_edit_text()

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

Definition at line 152 of file textnotes.c.

References d, FALSE, IS_NULL_PTR, L, 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 1756 of file textnotes.c.

References d, dt_free, dt_image_full_path(), DT_PATH_MAX, FALSE, IS_NULL_PTR, L, 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 1784 of file textnotes.c.

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

Referenced by _load_for_image().

◆ _textbuffer_changed()

static void _textbuffer_changed ( GtkTextBuffer buffer,
dt_lib_module_t self 
)
static

Definition at line 1875 of file textnotes.c.

References _completion_update(), _save_timeout_cb(), d, dt_lib_module_t::data, L, 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 1804 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 1792 of file textnotes.c.

References dt_control_job_get_params(), IS_NULL_PTR, L, 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 1892 of file textnotes.c.

References _completion_focus_out_idle(), d, dt_lib_module_t::data, FALSE, L, 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 100 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 161 of file textnotes.c.

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

◆ gui_cleanup()

◆ gui_init()

◆ init_presets()

void init_presets ( dt_lib_module_t self)

Definition at line 190 of file textnotes.c.

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

◆ name()

const char * name ( dt_lib_module_t self)

Definition at line 89 of file textnotes.c.

References L.

◆ position()

int position ( )

Definition at line 105 of file textnotes.c.

◆ set_params()

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

Definition at line 174 of file textnotes.c.

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

◆ views()

const char ** views ( dt_lib_module_t self)

Definition at line 94 of file textnotes.c.

References L, and v.