Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
thumbnail.c File Reference
+ Include dependency graph for thumbnail.c:

Go to the source code of this file.

Macros

#define thumb_return_if_fails(thumb, ...)   { if(!thumb || !thumb->widget || !thumb->w_main) return __VA_ARGS__; }
 
#define DEBUG   0
 

Functions

static void _set_flag (GtkWidget *w, GtkStateFlags flag, gboolean activate)
 
static void _image_update_group_tooltip (dt_thumbnail_t *thumb)
 
static void _thumb_update_rating_class (dt_thumbnail_t *thumb)
 
static void _thumb_write_extension (dt_thumbnail_t *thumb)
 
static GtkWidget_gtk_menu_item_new_with_markup (const char *label, GtkWidget *menu, void(*activate_callback)(GtkWidget *widget, dt_thumbnail_t *thumb), dt_thumbnail_t *thumb)
 
static GtkWidget_menuitem_from_text (const char *label, const char *value, GtkWidget *menu, void(*activate_callback)(GtkWidget *widget, dt_thumbnail_t *thumb), dt_thumbnail_t *thumb)
 
static void _color_label_callback (GtkWidget *widget, dt_thumbnail_t *thumb)
 
static void _preview_window_open (GtkWidget *widget, dt_thumbnail_t *thumb)
 
static void _active_module_row (void *user_data, const int num, const char *op, const char *multi)
 
static void _active_modules_popup (GtkWidget *widget, dt_thumbnail_t *thumb)
 
static GtkWidget_create_menu (dt_thumbnail_t *thumb)
 
static gboolean _event_cursor_draw (GtkWidget *widget, cairo_t *cr, gpointer user_data)
 
static void _free_image_surface (dt_thumbnail_t *thumb)
 
static void _thumbnail_free (dt_thumbnail_t *thumb)
 
static void _thumbnail_release (void *data)
 
static gboolean _main_context_queue_draw (GtkWidget *widget)
 
static void _thumb_job_state_changed (dt_job_t *job, dt_job_state_t state)
 
static int _finish_buffer_thread (dt_thumbnail_t *thumb, dt_job_t *job, gboolean success)
 
int32_t _get_image_buffer (dt_job_t *job)
 
int dt_thumbnail_get_image_buffer (dt_thumbnail_t *thumb)
 
static gboolean _thumb_draw_image (GtkWidget *widget, cairo_t *cr, gpointer user_data)
 
static void _thumb_update_icons (dt_thumbnail_t *thumb)
 
static gboolean _event_main_press (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
 
static gboolean _event_main_release (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
 
static gboolean _event_rating_release (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
 
static gboolean _event_grouping_release (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
 
static gboolean _event_audio_release (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
 
void dt_thumbnail_update_selection (dt_thumbnail_t *thumb, gboolean selected)
 
void _create_alternative_view (dt_thumbnail_t *thumb)
 
void dt_thumbnail_alternative_mode (dt_thumbnail_t *thumb, gboolean enable)
 
static gboolean _event_star_enter (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data)
 
static gboolean _event_star_leave (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data)
 
gboolean _event_expose (GtkWidget *self, cairo_t *cr, gpointer user_data)
 
static gboolean _event_main_motion (GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
 
static gboolean _event_main_enter (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data)
 
static gboolean _event_main_leave (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data)
 
static gboolean _altered_enter (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data)
 
static gboolean _group_enter (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data)
 
static gboolean _event_image_press (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
 
static gboolean _event_image_motion (GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
 
static gboolean _event_image_release (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
 
GtkWidgetdt_thumbnail_create_widget (dt_thumbnail_t *thumb)
 
void dt_thumbnail_resync_info (dt_thumbnail_t *thumb, const dt_image_t *const info)
 
dt_thumbnail_tdt_thumbnail_new (int rowid, dt_thumbnail_overlay_t over, dt_thumbtable_t *table, dt_image_t *info)
 
int dt_thumbnail_destroy (dt_thumbnail_t *thumb)
 
void dt_thumbnail_update_gui (dt_thumbnail_t *thumb)
 
void dt_thumbnail_set_overlay (dt_thumbnail_t *thumb, dt_thumbnail_overlay_t mode)
 
void _widget_set_size (GtkWidget *w, int *parent_width, int *parent_height, const gboolean update)
 
static int _thumb_resize_overlays (dt_thumbnail_t *thumb, int width, int height)
 
void dt_thumbnail_resize (dt_thumbnail_t *thumb, int width, int height)
 
void dt_thumbnail_set_group_border (dt_thumbnail_t *thumb, dt_thumbnail_border_t border)
 
void dt_thumbnail_set_mouseover (dt_thumbnail_t *thumb, gboolean over)
 
void dt_thumbnail_set_drop (dt_thumbnail_t *thumb, gboolean accept_drop)
 
int dt_thumbnail_image_refresh_real (dt_thumbnail_t *thumb)
 

Detailed Description

this is the thumbnail class for the lighttable module.

WARNING: because we create and destroy thumbnail objects dynamically when scrolling, and we don't manually cleanup the Gtk signal handlers attached to widgets, some callbacks/handlers can be left hanging, still record events, but send them to non-existing objects. This is why we need to ensure user_data is not NULL everywhere.

Definition in file thumbnail.c.

Macro Definition Documentation

◆ DEBUG

#define DEBUG   0

Definition at line 753 of file thumbnail.c.

◆ thumb_return_if_fails

#define thumb_return_if_fails (   thumb,
  ... 
)    { if(!thumb || !thumb->widget || !thumb->w_main) return __VA_ARGS__; }

Definition at line 78 of file thumbnail.c.

Function Documentation

◆ _active_module_row()

static void _active_module_row ( void user_data,
const int  num,
const char *  op,
const char *  multi 
)
static

Definition at line 210 of file thumbnail.c.

Referenced by _active_modules_popup().

◆ _active_modules_popup()

◆ _altered_enter()

static gboolean _altered_enter ( GtkWidget widget,
GdkEventCrossing *  event,
gpointer  user_data 
)
static

◆ _color_label_callback()

static void _color_label_callback ( GtkWidget widget,
dt_thumbnail_t thumb 
)
static

Definition at line 197 of file thumbnail.c.

References color, dt_colorlabels_toggle_label_on_list(), dt_image_t::id, dt_thumbnail_t::info, and TRUE.

Referenced by _create_menu().

◆ _create_alternative_view()

◆ _create_menu()

◆ _event_audio_release()

static gboolean _event_audio_release ( GtkWidget widget,
GdkEventButton *  event,
gpointer  user_data 
)
static

◆ _event_cursor_draw()

static gboolean _event_cursor_draw ( GtkWidget widget,
cairo_t *  cr,
gpointer  user_data 
)
static

Definition at line 328 of file thumbnail.c.

References state, thumb_return_if_fails, TRUE, and dt_thumbnail_t::w_cursor.

Referenced by dt_thumbnail_create_widget().

◆ _event_expose()

gboolean _event_expose ( GtkWidget self,
cairo_t *  cr,
gpointer  user_data 
)

Definition at line 1023 of file thumbnail.c.

References FALSE, thumb_return_if_fails, and TRUE.

Referenced by dt_thumbnail_create_widget().

◆ _event_grouping_release()

static gboolean _event_grouping_release ( GtkWidget widget,
GdkEventButton *  event,
gpointer  user_data 
)
static

◆ _event_image_motion()

static gboolean _event_image_motion ( GtkWidget widget,
GdkEventMotion *  event,
gpointer  user_data 
)
static

◆ _event_image_press()

static gboolean _event_image_press ( GtkWidget widget,
GdkEventButton *  event,
gpointer  user_data 
)
static

◆ _event_image_release()

static gboolean _event_image_release ( GtkWidget widget,
GdkEventButton *  event,
gpointer  user_data 
)
static

Definition at line 1157 of file thumbnail.c.

References dt_thumbnail_t::dragging, FALSE, thumb_return_if_fails, and TRUE.

Referenced by dt_thumbnail_create_widget().

◆ _event_main_enter()

static gboolean _event_main_enter ( GtkWidget widget,
GdkEventCrossing *  event,
gpointer  user_data 
)
static

◆ _event_main_leave()

static gboolean _event_main_leave ( GtkWidget widget,
GdkEventCrossing *  event,
gpointer  user_data 
)
static

◆ _event_main_motion()

static gboolean _event_main_motion ( GtkWidget widget,
GdkEventMotion *  event,
gpointer  user_data 
)
static

◆ _event_main_press()

◆ _event_main_release()

◆ _event_rating_release()

◆ _event_star_enter()

static gboolean _event_star_enter ( GtkWidget widget,
GdkEventCrossing *  event,
gpointer  user_data 
)
static

◆ _event_star_leave()

static gboolean _event_star_leave ( GtkWidget widget,
GdkEventCrossing *  event,
gpointer  user_data 
)
static

◆ _finish_buffer_thread()

◆ _free_image_surface()

static void _free_image_surface ( dt_thumbnail_t thumb)
static

Definition at line 349 of file thumbnail.c.

References dt_thumbnail_t::img_surf.

Referenced by _get_image_buffer(), and _thumbnail_free().

◆ _get_image_buffer()

◆ _group_enter()

static gboolean _group_enter ( GtkWidget widget,
GdkEventCrossing *  event,
gpointer  user_data 
)
static

Definition at line 1099 of file thumbnail.c.

References _image_update_group_tooltip(), FALSE, thumb_return_if_fails, and TRUE.

Referenced by dt_thumbnail_create_widget().

◆ _gtk_menu_item_new_with_markup()

static GtkWidget * _gtk_menu_item_new_with_markup ( const char *  label,
GtkWidget menu,
void(*)(GtkWidget *widget, dt_thumbnail_t *thumb)  activate_callback,
dt_thumbnail_t thumb 
)
static

Definition at line 171 of file thumbnail.c.

References FALSE.

Referenced by _create_menu(), and _menuitem_from_text().

◆ _image_update_group_tooltip()

◆ _main_context_queue_draw()

static gboolean _main_context_queue_draw ( GtkWidget widget)
static

Definition at line 424 of file thumbnail.c.

Referenced by _finish_buffer_thread(), and _thumb_job_state_changed().

◆ _menuitem_from_text()

static GtkWidget * _menuitem_from_text ( const char *  label,
const char *  value,
GtkWidget menu,
void(*)(GtkWidget *widget, dt_thumbnail_t *thumb)  activate_callback,
dt_thumbnail_t thumb 
)
static

Definition at line 187 of file thumbnail.c.

References _gtk_menu_item_new_with_markup(), dt_free, and value.

Referenced by _create_menu().

◆ _preview_window_open()

static void _preview_window_open ( GtkWidget widget,
dt_thumbnail_t thumb 
)
static

Definition at line 205 of file thumbnail.c.

References dt_preview_window_spawn(), dt_image_t::id, and dt_thumbnail_t::info.

Referenced by _create_menu().

◆ _set_flag()

static void _set_flag ( GtkWidget w,
GtkStateFlags  flag,
gboolean  activate 
)
static

◆ _thumb_draw_image()

static gboolean _thumb_draw_image ( GtkWidget widget,
cairo_t *  cr,
gpointer  user_data 
)
static

thumb->image_inited is the validity flag for the image surface. While it is FALSE, pending a new thumbnail, we may still hold an outdated thumbnail that can be painted into the widget, pending the new one.

can_draw means we have a size mismatch between the surface and the widget.

Definition at line 691 of file thumbnail.c.

References dt_control_draw_busy_msg(), DT_DEBUG_LIGHTTABLE, dt_print(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_thumbnail_get_image_buffer(), DT_THUMBTABLE_ZOOM_FIT, dt_image_t::id, dt_thumbnail_t::image_inited, dt_thumbnail_t::img_height, dt_thumbnail_t::img_surf, dt_thumbnail_t::img_width, dt_thumbnail_t::info, IS_NULL_PTR, dt_thumbnail_t::lock, dt_thumbnail_t::table, thumb_return_if_fails, TRUE, dt_thumbnail_t::w_image, dt_thumbtable_t::zoom, dt_thumbnail_t::zoomx, and dt_thumbnail_t::zoomy.

Referenced by dt_thumbnail_create_widget().

◆ _thumb_job_state_changed()

static void _thumb_job_state_changed ( dt_job_t job,
dt_job_state_t  state 
)
static

The widget re-requests a render only while thumb->job is NULL, so every way a job can stop existing without committing its surface must clear thumb->job, or the widget stays on the "Working..." overlay forever with an idle CPU (issue #972). The render thread handles the nominal paths, but the job system can also kill a job behind the widget's back: dt_control_add_job() silently disposes a job it deems a duplicate (equality is the description string, i.e. the image id, so two widgets or a refresh-orphaned job collide), the DT_JOB_QUEUE_SYSTEM_FG stack drops its oldest entries past DT_CONTROL_MAX_JOBS, and queue flushes cancel jobs that then get disposed without ever running. This state hook fires on every terminal transition (params are still valid on DISPOSED: dt_control_job_dispose() sets the state before destroying params), re-arms the widget when the dying job is still the gating one, and queues a redraw so the next expose re-requests.

Definition at line 390 of file thumbnail.c.

References _main_context_queue_draw(), dt_thumbnail_t::destroying, dt_atomic_get_int(), dt_control_job_get_params(), DT_JOB_STATE_CANCELLED, DT_JOB_STATE_DISCARDED, DT_JOB_STATE_DISPOSED, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), IS_NULL_PTR, dt_thumbnail_t::job, dt_thumbnail_t::lock, state, and dt_thumbnail_t::w_image.

Referenced by dt_thumbnail_get_image_buffer().

◆ _thumb_resize_overlays()

◆ _thumb_update_icons()

◆ _thumb_update_rating_class()

◆ _thumb_write_extension()

◆ _thumbnail_free()

static void _thumbnail_free ( dt_thumbnail_t thumb)
static

◆ _thumbnail_release()

static void _thumbnail_release ( void data)
static

◆ _widget_set_size()

void _widget_set_size ( GtkWidget w,
int *  parent_width,
int *  parent_height,
const gboolean  update 
)

Definition at line 1515 of file thumbnail.c.

References height, state, and width.

Referenced by dt_thumbnail_resize().

◆ dt_thumbnail_alternative_mode()

void dt_thumbnail_alternative_mode ( dt_thumbnail_t thumb,
gboolean  enable 
)

◆ dt_thumbnail_create_widget()

GtkWidget * dt_thumbnail_create_widget ( dt_thumbnail_t thumb)

Definition at line 1165 of file thumbnail.c.

References _altered_enter(), _event_audio_release(), _event_cursor_draw(), _event_expose(), _event_grouping_release(), _event_image_motion(), _event_image_press(), _event_image_release(), _event_main_enter(), _event_main_leave(), _event_main_motion(), _event_main_press(), _event_main_release(), _event_rating_release(), _event_star_enter(), _event_star_leave(), _group_enter(), _thumb_draw_image(), bbox, dt_image_t::color_labels, dt_gui_add_class(), DT_GUI_BOX_SPACING, dtgtk_cairo_paint_altered(), dtgtk_cairo_paint_audio(), dtgtk_cairo_paint_grouping(), dtgtk_cairo_paint_label_flower(), dtgtk_cairo_paint_local_copy(), dtgtk_cairo_paint_reject(), dtgtk_cairo_paint_star(), dtgtk_thumbnail_btn_new(), FALSE, i, dt_thumbnail_t::info, MAX_STARS, n_targets_all, target_list_all, TRUE, dt_thumbnail_t::w_altered, dt_thumbnail_t::w_alternative, dt_thumbnail_t::w_audio, dt_thumbnail_t::w_background, dt_thumbnail_t::w_bottom_eb, dt_thumbnail_t::w_camera, dt_thumbnail_t::w_color, dt_thumbnail_t::w_cursor, dt_thumbnail_t::w_datetime, dt_thumbnail_t::w_exposure, dt_thumbnail_t::w_exposure_bias, dt_thumbnail_t::w_ext, dt_thumbnail_t::w_filename, dt_thumbnail_t::w_focal, dt_thumbnail_t::w_folder, dt_thumbnail_t::w_group, dt_thumbnail_t::w_image, dt_thumbnail_t::w_lens, dt_thumbnail_t::w_local_copy, dt_thumbnail_t::w_main, dt_thumbnail_t::w_reject, dt_thumbnail_t::w_stars, dt_thumbnail_t::w_top_eb, and dt_thumbnail_t::widget.

Referenced by dt_thumbnail_new().

◆ dt_thumbnail_destroy()

◆ dt_thumbnail_get_image_buffer()

◆ dt_thumbnail_image_refresh_real()

◆ dt_thumbnail_new()

◆ dt_thumbnail_resize()

◆ dt_thumbnail_resync_info()

◆ dt_thumbnail_set_drop()

void dt_thumbnail_set_drop ( dt_thumbnail_t thumb,
gboolean  accept_drop 
)

◆ dt_thumbnail_set_group_border()

◆ dt_thumbnail_set_mouseover()

◆ dt_thumbnail_set_overlay()

void dt_thumbnail_set_overlay ( dt_thumbnail_t thumb,
dt_thumbnail_overlay_t  mode 
)

Definition at line 1508 of file thumbnail.c.

References dt_thumbnail_t::over, and thumb_return_if_fails.

Referenced by _add_thumbnail_at_rowid(), and _resize_thumbnails().

◆ dt_thumbnail_update_gui()

◆ dt_thumbnail_update_selection()