Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
selection.h File Reference
#include <glib.h>
#include <inttypes.h>
#include "common/debug.h"
+ Include dependency graph for selection.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define dt_selection_reload_from_database(selection)   DT_DEBUG_TRACE_WRAPPER(DT_DEBUG_SQL, dt_selection_reload_from_database_real, (selection))
 

Functions

struct dt_selection_tdt_selection_new ()
 
void dt_selection_free (struct dt_selection_t *selection)
 
struct dt_selection_tdt_selection_get_global (void)
 
void dt_selection_init_global (void)
 
void dt_selection_cleanup_global (void)
 
int32_t dt_selection_get_first_id (struct dt_selection_t *selection)
 
void dt_selection_clear (struct dt_selection_t *selection)
 
void dt_selection_select (struct dt_selection_t *selection, int32_t imgid)
 
void dt_selection_deselect (struct dt_selection_t *selection, int32_t imgid)
 
void dt_selection_select_single (struct dt_selection_t *selection, int32_t imgid)
 
void dt_selection_toggle (struct dt_selection_t *selection, int32_t imgid)
 
void dt_selection_select_list (struct dt_selection_t *selection, const GList *list)
 
void dt_selection_deselect_list (struct dt_selection_t *selection, const GList *list)
 
GList * dt_selection_get_list (struct dt_selection_t *selection)
 
void dt_selection_push (struct dt_selection_t *selection)
 
void dt_selection_pop (struct dt_selection_t *selection)
 
int dt_selection_get_length (struct dt_selection_t *selection)
 
gchar * dt_selection_ids_to_string (struct dt_selection_t *selection)
 
gboolean dt_selection_is_id_selected (struct dt_selection_t *selection, int32_t imgid)
 
void dt_selection_reload_from_database_real (struct dt_selection_t *selection)
 

Detailed Description

The old design built selections from collections, through SQL, to ensure selections were always a subset of collections. That didn't work well with the GUI option to show/hide grouped images, because then, every SQL query needed to be modified according to a GUI parameter, which was complicated, hard to debug, tiring to maintain.

Collections now are immune to GUI parameters. It is in the thumbtable that we decide to show/hide the thumbnail widgets of grouped images, and collections contain all of them. In order to select grouped images depending on whether they are shown or not, it is also from the thumbtable that batch selection events need to be dispatched, using visible images. It is assumed that users expect selections to include everything visible but only what's visible and nothing more.

Because the thumbtable is populated from collections, we know it contains only valid imgid, and contains at most the whole current collection. So we can safely assume any imgid coming from the thumbtable is a valid image ID with regard to the current collection, without additional checks.

We synchronize here 2 representations of the selections:

  • a memory DB table: memory.selected_images, that is saved to be restored between reboots,
  • a GList of imgid, selection->ids, cached, that allows us direct access from C loops.

Selections subscribe to the COLLECTION_CHANGED signal to ensure the selected imgids are a subset of the current collection at all time. But that doesn't deal with images that might be hidden from GUI, for example image group members.

It is up to the thumbtable code (aka GUI) to resync selection imgids with visible widgets.

No insertions or deletions should be made into the main.selected_images database table, outside of selection.c. Interactions with selections should use the public API here.

SELECT imgid FROM main.seleted_images should be reserved to SQL JOIN, when fetching metadata from DB for the list of IDs. All other cases should iterate over the GList of imgids returned by dt_selection_get_list()

Definition in file selection.h.

Macro Definition Documentation

◆ dt_selection_reload_from_database

#define dt_selection_reload_from_database (   selection)    DT_DEBUG_TRACE_WRAPPER(DT_DEBUG_SQL, dt_selection_reload_from_database_real, (selection))

Definition at line 123 of file selection.h.

Function Documentation

◆ dt_selection_cleanup_global()

void dt_selection_cleanup_global ( void  )

frees the application-wide selection.

Definition at line 90 of file selection.c.

References _selection_global, and dt_selection_free().

Referenced by dt_cleanup().

◆ dt_selection_clear()

◆ dt_selection_deselect()

void dt_selection_deselect ( struct dt_selection_t selection,
int32_t  imgid 
)

removes a single imgid from the current selection. use the optimized dt_selection_deselect_list() to process batches.

Definition at line 288 of file selection.c.

References _remove_id_link(), _selection_deselect(), _update_gui(), IS_NULL_PTR, and UNKNOWN_IMAGE.

Referenced by _collection_lut_row(), and dt_selection_toggle().

◆ dt_selection_deselect_list()

void dt_selection_deselect_list ( struct dt_selection_t selection,
const GList *  list 
)

deselects a set of images from a list in a fast, optimized fashion. the list is unaltered

Definition at line 354 of file selection.c.

References _list_iterate(), _update_gui(), dt_free, dt_selection_repository_deselect_list(), dt_util_dstrcat(), FALSE, dt_selection_t::ids, and IS_NULL_PTR.

Referenced by dt_thumbtable_invert_selection().

◆ dt_selection_free()

◆ dt_selection_get_first_id()

◆ dt_selection_get_global()

struct dt_selection_t * dt_selection_get_global ( void  )

Definition at line 80 of file selection.c.

References _selection_global.

Referenced by _act_folders_remove(), _collection_lut_row(), _concatenate_multiple_images(), _create_tag_from_entry(), _culling_mode(), _darkroom_image_loaded_callback(), _dt_ctl_open_image_in_darkroom(), _event_main_release(), _film_strip_activated(), _grid_handle_key(), _grid_is_thumb_highlighted(), _grid_on_drag_begin(), _grid_pre_activate(), _init_treeview(), _metadata_view_update_values(), _print_setup_initial_image(), _select_images(), _setup_selected_images_list(), _single_selected_imgid(), _studio_set_image(), _tag_get_tags(), _update_preview(), _view_map_button_press_callback(), _view_map_filmstrip_activate_callback(), _view_map_filmstrip_drag_begin_callback(), _view_map_selection_changed(), _view_print_filmstrip_drag_begin_callback(), clear_image_cache(), clear_selection_callback(), clear_selection_sensitive_callback(), copy_callback(), copy_parts_callback(), dt_act_on_get_first_image(), dt_act_on_get_images(), dt_act_on_get_images_nb(), dt_collection_hint_message(), dt_collection_load_filmroll(), dt_culling_mode_to_selection(), dt_image_read_duplicates(), dt_selection_to_culling_mode(), dt_tag_get_attached(), dt_tag_get_suggestions(), dt_tag_get_with_usage(), dt_thumbnail_new(), dt_thumbtable_invert_selection(), dt_thumbtable_key_pressed_grid(), dt_thumbtable_scroll_to_selection(), dt_thumbtable_select_all(), dt_thumbtable_select_range(), duplicate_callback(), enter(), export_image_list_callback(), group_images_callback(), has_selection(), leave(), new_history_callback(), paste_all_callback(), paste_parts_callback(), preload_image_cache(), select_all_sensitive_callback(), try_enter(), and ungroup_images_callback().

◆ dt_selection_get_length()

◆ dt_selection_get_list()

◆ dt_selection_ids_to_string()

gchar * dt_selection_ids_to_string ( struct dt_selection_t selection)

concatenate all image ids from the selection as a string, separated with coma, for SQL queries

Definition at line 377 of file selection.c.

References i, dt_selection_t::ids, IS_NULL_PTR, and dt_selection_t::length.

Referenced by _tag_get_tags().

◆ dt_selection_init_global()

void dt_selection_init_global ( void  )

creates the application-wide selection. Called by the GUI bootstrap only.

Definition at line 85 of file selection.c.

References _selection_global, dt_selection_new(), and IS_NULL_PTR.

Referenced by dt_gui_gtk_init().

◆ dt_selection_is_id_selected()

gboolean dt_selection_is_id_selected ( struct dt_selection_t selection,
int32_t  imgid 
)

see if the imgid is known from the selection

Definition at line 404 of file selection.c.

References FALSE, dt_selection_t::ids, and IS_NULL_PTR.

Referenced by _grid_is_thumb_highlighted(), and dt_thumbnail_new().

◆ dt_selection_new()

◆ dt_selection_pop()

void dt_selection_pop ( struct dt_selection_t selection)

restore the previous selection from a temp memory database table

Definition at line 230 of file selection.c.

References _update_gui(), dt_selection_reload_from_database, dt_selection_repository_pop(), FALSE, IS_NULL_PTR, and dt_selection_t::stacked.

Referenced by dt_culling_mode_to_selection().

◆ dt_selection_push()

void dt_selection_push ( struct dt_selection_t selection)

backup the current selection to a temp memory database table

Definition at line 214 of file selection.c.

References _update_gui(), dt_selection_reload_from_database, dt_selection_repository_push(), IS_NULL_PTR, dt_selection_t::stacked, and TRUE.

Referenced by dt_selection_to_culling_mode().

◆ dt_selection_reload_from_database_real()

void dt_selection_reload_from_database_real ( struct dt_selection_t selection)

call this right after the selection got changed directly in memory database, to resync the GList representation of the selection

Definition at line 142 of file selection.c.

References _reset_ids_list(), _selection_database_to_glist(), _update_last_ids(), dt_selection_t::ids, IS_NULL_PTR, and dt_selection_t::length.

◆ dt_selection_select()

void dt_selection_select ( struct dt_selection_t selection,
int32_t  imgid 
)

adds a single imgid to the current selection. use the optimized dt_selection_select_list() to process batches.

Definition at line 279 of file selection.c.

References _add_id_link(), _selection_select(), _update_gui(), IS_NULL_PTR, and UNKNOWN_IMAGE.

Referenced by _grid_on_drag_begin(), dt_collection_load_filmroll(), dt_selection_select_single(), and dt_selection_toggle().

◆ dt_selection_select_list()

void dt_selection_select_list ( struct dt_selection_t selection,
const GList *  list 
)

selects a set of images from a list in a fast, optimized fashion. the list is unaltered

Definition at line 330 of file selection.c.

References _list_iterate(), _update_gui(), dt_free, dt_selection_repository_select_list(), dt_util_dstrcat(), dt_selection_t::ids, IS_NULL_PTR, and TRUE.

Referenced by _act_folders_remove(), _select_images(), dt_thumbtable_select_all(), dt_thumbtable_select_range(), and leave().

◆ dt_selection_select_single()

◆ dt_selection_toggle()

void dt_selection_toggle ( struct dt_selection_t selection,
int32_t  imgid 
)

toggles selection of a single image in the current selection

Definition at line 305 of file selection.c.

References dt_selection_deselect(), dt_selection_select(), dt_selection_t::ids, IS_NULL_PTR, and UNKNOWN_IMAGE.

Referenced by _event_main_release(), and _grid_handle_key().