Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
accelerators.c File Reference
#include "widgets/accelerators.h"
#include <glib/gi18n.h>
#include "widgets/widget_settings.h"
#include "widgets/widget_style.h"
#include "system/macros.h"
#include "system/mem_alloc.h"
#include "widgets/gtkentry.h"
#include "widgets/gdkkeys.h"
#include "widgets/icon_cell_renderer.h"
#include <assert.h>
#include <glib.h>
+ Include dependency graph for accelerators.c:

Go to the source code of this file.

Data Structures

struct  PayloadClosure
 
struct  _accel_removal_t
 
struct  _accel_lookup_t
 
struct  _accel_treeview_t
 
struct  _accel_window_params_t
 
struct  dt_accels_search_state_t
 
struct  dt_accels_dispatch_state_t
 

Macros

#define DT_ACCEL_SEARCH_INLINE_SEPARATOR   " > "
 
#define DT_ACCEL_SEARCH_DISPATCH_RETRY_DELAY_MS   50
 
#define DT_ACCEL_SEARCH_RECENT_KEY   "plugins/accel_search/recent_entries"
 
#define DT_ACCEL_SEARCH_RECENT_MAX   20
 

Typedefs

typedef struct _accel_removal_t _accel_removal_t
 
typedef struct _accel_lookup_t _accel_lookup_t
 
typedef struct _accel_treeview_t _accel_treeview_t
 
typedef struct _accel_window_params_t _accel_window_params_t
 
typedef struct dt_accels_search_state_t dt_accels_search_state_t
 
typedef struct dt_accels_dispatch_state_t dt_accels_dispatch_state_t
 

Enumerations

enum  {
  COL_NAME ,
  COL_KEYS ,
  COL_CLEAR ,
  COL_DESCRIPTION ,
  COL_PATH ,
  COL_SHORTCUT ,
  COL_KEYVAL ,
  COL_MODS ,
  COL_DISPLAY_MODS ,
  NUM_COLUMNS
}
 

Functions

void dt_accels_set_global (dt_accels_t *accels)
 
dt_accels_t * dt_accels_get_global (void)
 
void dt_accels_set_top_offset_handler (dt_accels_top_offset_handler_t handler)
 
void dt_accels_set_refocus_handler (dt_accels_refocus_handler_t handler)
 
void dt_accels_set_recent_handlers (dt_accels_recent_get_handler_t get, dt_accels_recent_set_handler_t set)
 
static void _g_list_closure_unref (gpointer data)
 
static void _shortcut_set_widget_data (GtkWidget *widget, dt_shortcut_t *shortcut)
 
static gboolean _accels_tooltip_query_hook (GSignalInvocationHint *hint, guint n_param_values, const GValue *param_values, gpointer data)
 
static void _accels_install_tooltip_hook (void)
 
static void _clean_shortcut (gpointer data)
 
PayloadClosure * dt_shortcut_get_payload_closure (dt_shortcut_t *shortcut)
 
GClosure * dt_shortcut_get_closure (dt_shortcut_t *shortcut)
 
void dt_shortcut_remove_closure (dt_shortcut_t *shortcut, gpointer data)
 
static void _find_parent_hashtable (gpointer _key, gpointer value, gpointer user_data)
 
static void _insert_parent_data_into_children (dt_shortcut_t *shortcut)
 
void dt_shortcut_set_closure (dt_shortcut_t *shortcut, gboolean(*action_callback)(GtkAccelGroup *group, GObject *acceleratable, guint keyval, GdkModifierType mods, gpointer user_data), gpointer data, GtkWidget *widget)
 
dt_accels_t * dt_accels_init (char *config_file, GtkAccelFlags flags)
 
void dt_accels_cleanup (dt_accels_t *accels)
 
void dt_accels_connect_active_group (dt_accels_t *accels, const gchar *group)
 Connect the contextual active accels group to the window. Views can declare their own set of contextual accels, which can override the global accels, in case they use the same keys.
 
void dt_accels_disconnect_active_group (dt_accels_t *accels)
 Disconnect the contextual active accels group from the window.
 
static gboolean _update_shortcut_state (dt_shortcut_t *shortcut, GtkAccelKey *key, gboolean init)
 
static void _add_widget_accel (dt_shortcut_t *shortcut, GtkAccelFlags flags)
 
static void _remove_widget_accel (dt_shortcut_t *shortcut, const GtkAccelKey *old_key)
 
static void _remove_generic_accel (dt_shortcut_t *shortcut)
 
static void _add_generic_accel (dt_shortcut_t *shortcut, GtkAccelFlags flags)
 
static void _connect_accel (dt_shortcut_t *shortcut)
 
static void _insert_accel (dt_accels_t *accels, dt_shortcut_t *shortcut)
 
static gboolean _widget_shortcut_callback (GtkAccelGroup *group, GObject *acceleratable, guint keyval, GdkModifierType mods, gpointer user_data)
 
static gboolean _virtual_shortcut_callback (GtkAccelGroup *group, GObject *acceleratable, guint keyval, GdkModifierType mods, gpointer user_data)
 
void dt_accels_new_virtual_shortcut (dt_accels_t *accels, GtkAccelGroup *accel_group, const gchar *accel_path, GtkWidget *widget, guint key_val, GdkModifierType accel_mods)
 Add a new virtual shortcut. Virtual shortcuts are immutable, read-only and don't trigger any action. They are meant to serve as placeholders, in a purely declarative way, for key combinations hardcoded in the key-pressed events handlers of widgets able to capture focus. Once declared here, they will prevent users from declaring their own shortcuts using hardcoded combinations for the corresponding accel_group.
 
void dt_accels_new_virtual_instance_shortcut (dt_accels_t *accels, gboolean(*action_callback)(GtkAccelGroup *group, GObject *acceleratable, guint keyval, GdkModifierType mods, gpointer user_data), gpointer data, GtkAccelGroup *accel_group, const gchar *action_scope, const gchar *action_name)
 
void dt_accels_new_widget_shortcut (dt_accels_t *accels, GtkWidget *widget, const gchar *signal, GtkAccelGroup *accel_group, const gchar *accel_path, guint key_val, GdkModifierType accel_mods, const gboolean lock)
 Register a new shortcut for a widget, setting up its path, default keys and accel group. This does everything but connecting it, so exists only as a defined slot to be connected later.
 
void dt_accels_new_action_shortcut (dt_accels_t *accels, gboolean(*action_callback)(GtkAccelGroup *group, GObject *acceleratable, guint keyval, GdkModifierType mods, gpointer user_data), gpointer data, GtkWidget *target_widget, GtkAccelGroup *accel_group, const gchar *action_scope, const gchar *action_name, guint key_val, GdkModifierType accel_mods, const gboolean lock, const char *description)
 Register a new shortcut for a generic action, setting up its path, default keys and accel group. This does everything but connecting it, so exists only as a defined slot to be connected later.
 
void dt_accels_load_user_config (dt_accels_t *accels)
 Loads keyboardrc.lang from config dir. This needs to run after we inited the accel map from widgets creation.
 
static void _connect_accel_hashtable (gpointer _key, gpointer value, gpointer user_data)
 
void dt_accels_connect_accels (dt_accels_t *accels)
 Actually enable accelerators after having loaded user config.
 
static void _remove_accel_hashtable (gpointer _key, gpointer value, gpointer user_data)
 
void dt_accels_remove_accel (dt_accels_t *accels, const char *path, gpointer data)
 Recursively remove all accels for all shortcuts containing path. This is unneeded for accels attached to Gtk widgets through dt_accels_new_widget_shortcut because Gtk will handle that internally when deleting a widget. But for our own widget-less dt_accels_new_action_shortcut, we need to handle that ourselves.
 
void dt_accels_remove_shortcut (dt_accels_t *accels, const char *path)
 Remove the shortcut object identified by path and all its accels.
 
gchar * dt_accels_build_path (const gchar *scope, const gchar *feature)
 Build the accel path of feature under scope.
 
static void _accels_keys_decode (dt_accels_t *accels, GdkEvent *event, guint *keyval, GdkModifierType *mods)
 
static guint _normalize_keyval (const guint keyval)
 
static void _for_each_accel (gpointer key, gpointer value, gpointer user_data)
 
static const char * _find_path_for_keys (dt_accels_t *accels, guint key, GdkModifierType modifier, GtkAccelGroup *group)
 
static void _for_each_non_virtual_accel (gpointer key, gpointer value, gpointer user_data)
 
static dt_shortcut_t * _find_non_virtual_shortcut (dt_accels_t *accels, GtkAccelGroup *group, guint keyval, GdkModifierType mods)
 
static gboolean _call_shortcut_cclosure (dt_shortcut_t *shortcut, GtkWindow *main_window, GClosure *closure)
 
static gboolean _key_pressed (GtkWidget *w, GdkEvent *event, dt_accels_t *accels, guint keyval, GdkModifierType mods)
 
gboolean dt_accels_dispatch (GtkWidget *w, GdkEvent *event, gpointer user_data)
 Force our listener for all key strokes to bypass reserved Gtk keys.
 
void dt_accels_attach_scroll_handler (dt_accels_t *accels, gboolean(*callback)(GdkEventScroll event, void *data), void *data)
 Attach a new global scroll event callback. So far this is used in darkroom to redirect scroll events to a Bauhaus widget when the focusing shortcut of that widget is held down on keyboard.
 
void dt_accels_detach_scroll_handler (dt_accels_t *accels)
 
static void _make_column_editable (GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
 
static void _make_column_clearable (GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
 
static int guess_key_group (dt_accels_t *accels, guint keyval, guint hardware_keycode)
 
static void _shortcut_edited (GtkCellRenderer *cell, const gchar *path_string, guint key, GdkModifierType mods, guint hardware_key, gpointer user_data)
 
static void _shortcut_cleared (GtkCellRendererAccel *renderer, const gchar *path_string, gpointer user_data)
 
static gboolean _icon_activate (GtkCellRenderer *cell, GdkEvent *event, GtkWidget *treeview, const gchar *path_str, GdkRectangle *background, GdkRectangle *cell_area, GtkCellRendererState flags, gpointer user_data)
 
static void _create_main_row (GtkTreeStore *store, GtkTreeIter *iter, const char *label, const char *path, dt_shortcut_t *shortcut)
 
void _for_each_accel_create_treeview_row (gpointer key, gpointer value, gpointer user_data)
 
static gchar * _shortcut_search_trim_display_path (const gchar *path)
 
void _for_each_path_create_treeview_row (gpointer key, gpointer value, gpointer user_data)
 
static gint _sort_model_by_relevance_func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer data)
 
static gint _sort_model_func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer data)
 
static gboolean filter_callback (GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
 
static void search_changed (GtkEntry *entry, gpointer user_data)
 
void dt_accels_window (dt_accels_t *accels, GtkWindow *main_window)
 Show the modal dialog listing all available keyboard shortcuts and letting user to set them.
 
static int _match_text (GtkTreeModel *model, GtkTreeIter *iter, const char *needle)
 
static void _find_and_rank_matches (GtkTreeModel *model, GtkWidget *search_entry)
 
static void _shortcut_search_load_recent_entries (GtkListStore *store)
 
static gint _shortcut_search_recent_sort_func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data)
 
static void _shortcut_search_save_recent_entry (const char *query, const dt_shortcut_t *shortcut)
 
static gboolean _dispatch_selected_shortcut_idle (gpointer data)
 
static void _search_entry_changed (GtkWidget *widget, gpointer user_data)
 
static gboolean _shortcut_search_recent_match_selected (GtkEntryCompletion *completion, GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
 
static gboolean _shortcut_search_recent_insert_prefix (GtkEntryCompletion *completion, gchar *prefix, gpointer user_data)
 
static void _dispatch_selected_shortcut (dt_accels_dispatch_state_t *state)
 
static gboolean _shortcut_search_visible (GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
 
static gboolean _shortcut_search_recent_completion_match (GtkEntryCompletion *completion, const gchar *key, GtkTreeIter *iter, gpointer user_data)
 
static gboolean _queue_action_from_shortcut (dt_shortcut_t *shortcut, GtkWidget *window, dt_accels_search_state_t *state)
 
static void _shortcut_search_selection_changed (GtkTreeSelection *selection, gpointer user_data)
 
static gboolean _shortcut_search_row_activated (GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data)
 
static gboolean _shortcut_search_move_selection (dt_accels_search_state_t *state, const gboolean forward)
 
static gboolean _search_entry_restore_space_idle (gpointer user_data)
 
static gboolean _search_entry_key_pressed (GtkWidget *widget __attribute__((unused)), GdkEventKey *event, gpointer user_data)
 
static gboolean _search_entry_button_pressed (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
 
static gboolean _shortcut_search_window_key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
 
static gboolean _shortcut_search_button_press (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
 
static void _shortcut_search_destroy (GtkWidget *widget, gpointer user_data)
 
void dt_accels_search (dt_accels_t *accels, GtkWindow *main_window, GtkWidget *anchor)
 
static gboolean _text_entry_focus_in_event (GtkWidget *self, GdkEventFocus event, gpointer user_data)
 
static gboolean _text_entry_focus_out_event (GtkWidget *self, GdkEventFocus event, gpointer user_data)
 
static gboolean _text_entry_key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
 
void dt_accels_disconnect_on_text_input (GtkWidget *widget)
 Disconnect accels while a text or search entry has the focus, and reconnect them when it loses it. This is what makes one-key shortcuts safe to have at all. Escape hands focus back to the host's main area via dt_widget_refocus().
 

Variables

static dt_accels_t * _accels_global = NULL
 
static dt_accels_top_offset_handler_t _top_offset_handler = NULL
 
static dt_accels_refocus_handler_t _refocus_handler = NULL
 
static dt_accels_recent_get_handler_t _recent_get = NULL
 
static dt_accels_recent_set_handler_t _recent_set = NULL
 
static dt_accels_t * accels_global_ref = NULL
 

Macro Definition Documentation

◆ DT_ACCEL_SEARCH_DISPATCH_RETRY_DELAY_MS

#define DT_ACCEL_SEARCH_DISPATCH_RETRY_DELAY_MS   50

Definition at line 101 of file accelerators.c.

◆ DT_ACCEL_SEARCH_INLINE_SEPARATOR

#define DT_ACCEL_SEARCH_INLINE_SEPARATOR   " > "

Definition at line 100 of file accelerators.c.

◆ DT_ACCEL_SEARCH_RECENT_KEY

#define DT_ACCEL_SEARCH_RECENT_KEY   "plugins/accel_search/recent_entries"

Definition at line 2099 of file accelerators.c.

◆ DT_ACCEL_SEARCH_RECENT_MAX

#define DT_ACCEL_SEARCH_RECENT_MAX   20

Definition at line 2100 of file accelerators.c.

Typedef Documentation

◆ _accel_lookup_t

◆ _accel_removal_t

◆ _accel_treeview_t

◆ _accel_window_params_t

◆ dt_accels_dispatch_state_t

◆ dt_accels_search_state_t

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
COL_NAME 
COL_KEYS 
COL_CLEAR 
COL_DESCRIPTION 
COL_PATH 
COL_SHORTCUT 
COL_KEYVAL 
COL_MODS 
COL_DISPLAY_MODS 
NUM_COLUMNS 

Definition at line 1335 of file accelerators.c.

Function Documentation

◆ _accels_install_tooltip_hook()

static void _accels_install_tooltip_hook ( void  )
static

Definition at line 245 of file accelerators.c.

References _accels_tooltip_query_hook().

Referenced by dt_accels_init().

◆ _accels_keys_decode()

static void _accels_keys_decode ( dt_accels_t *  accels,
GdkEvent *  event,
guint *  keyval,
GdkModifierType *  mods 
)
static

◆ _accels_tooltip_query_hook()

static gboolean _accels_tooltip_query_hook ( GSignalInvocationHint *  hint,
guint  n_param_values,
const GValue *  param_values,
gpointer  data 
)
static

◆ _add_generic_accel()

static void _add_generic_accel ( dt_shortcut_t *  shortcut,
GtkAccelFlags  flags 
)
static

◆ _add_widget_accel()

static void _add_widget_accel ( dt_shortcut_t *  shortcut,
GtkAccelFlags  flags 
)
static

For native Gtk widget accels, we create alternatives for numpad keys, in case we fail to decode them ourselves and defer to native Gtk. Otherwise, numpad keys are also converted at input event handling.

Definition at line 577 of file accelerators.c.

References dt_shortcut_t::accel_group, dt_keys_numpad_alternatives(), flags, dt_shortcut_t::key, dt_shortcut_t::mods, dt_shortcut_t::signal, and dt_shortcut_t::widget.

Referenced by _connect_accel(), and dt_accels_new_widget_shortcut().

◆ _call_shortcut_cclosure()

static gboolean _call_shortcut_cclosure ( dt_shortcut_t *  shortcut,
GtkWindow *  main_window,
GClosure *  closure 
)
static

◆ _clean_shortcut()

static void _clean_shortcut ( gpointer  data)
static

Definition at line 257 of file accelerators.c.

References _g_list_closure_unref(), dt_shortcut_t::closure, dt_free, and dt_shortcut_t::path.

Referenced by dt_accels_init().

◆ _connect_accel()

◆ _connect_accel_hashtable()

static void _connect_accel_hashtable ( gpointer  _key,
gpointer  value,
gpointer  user_data 
)
static

Definition at line 956 of file accelerators.c.

References _connect_accel(), and value.

Referenced by dt_accels_connect_accels().

◆ _create_main_row()

static void _create_main_row ( GtkTreeStore *  store,
GtkTreeIter *  iter,
const char *  label,
const char *  path,
dt_shortcut_t *  shortcut 
)
static

◆ _dispatch_selected_shortcut()

◆ _dispatch_selected_shortcut_idle()

static gboolean _dispatch_selected_shortcut_idle ( gpointer  data)
static

Definition at line 2804 of file accelerators.c.

References _dispatch_selected_shortcut(), dt_free, and state.

Referenced by _dispatch_selected_shortcut(), and dt_accels_search().

◆ _find_and_rank_matches()

static void _find_and_rank_matches ( GtkTreeModel *  model,
GtkWidget *  search_entry 
)
static

◆ _find_non_virtual_shortcut()

static dt_shortcut_t * _find_non_virtual_shortcut ( dt_accels_t *  accels,
GtkAccelGroup *  group,
guint  keyval,
GdkModifierType  mods 
)
static

◆ _find_parent_hashtable()

static void _find_parent_hashtable ( gpointer  _key,
gpointer  value,
gpointer  user_data 
)
static

◆ _find_path_for_keys()

static const char * _find_path_for_keys ( dt_accels_t *  accels,
guint  key,
GdkModifierType  modifier,
GtkAccelGroup *  group 
)
static

◆ _for_each_accel()

static void _for_each_accel ( gpointer  key,
gpointer  value,
gpointer  user_data 
)
inlinestatic

◆ _for_each_accel_create_treeview_row()

void _for_each_accel_create_treeview_row ( gpointer  key,
gpointer  value,
gpointer  user_data 
)

◆ _for_each_non_virtual_accel()

static void _for_each_non_virtual_accel ( gpointer  key,
gpointer  value,
gpointer  user_data 
)
inlinestatic

◆ _for_each_path_create_treeview_row()

◆ _g_list_closure_unref()

static void _g_list_closure_unref ( gpointer  data)
static

Definition at line 127 of file accelerators.c.

References PayloadClosure::base, dt_free, and PayloadClosure::widget.

Referenced by _clean_shortcut(), and dt_shortcut_remove_closure().

◆ _icon_activate()

static gboolean _icon_activate ( GtkCellRenderer *  cell,
GdkEvent *  event,
GtkWidget *  treeview,
const gchar *  path_str,
GdkRectangle *  background,
GdkRectangle *  cell_area,
GtkCellRendererState  flags,
gpointer  user_data 
)
static

Definition at line 1515 of file accelerators.c.

References _shortcut_edited(), and TRUE.

Referenced by dt_accels_window().

◆ _insert_accel()

◆ _insert_parent_data_into_children()

static void _insert_parent_data_into_children ( dt_shortcut_t *  shortcut)
static

◆ _key_pressed()

static gboolean _key_pressed ( GtkWidget *  w,
GdkEvent *  event,
dt_accels_t *  accels,
guint  keyval,
GdkModifierType  mods 
)
static

◆ _make_column_clearable()

static void _make_column_clearable ( GtkTreeViewColumn *  col,
GtkCellRenderer *  renderer,
GtkTreeModel *  model,
GtkTreeIter *  iter,
gpointer  data 
)
static

Definition at line 1372 of file accelerators.c.

References COL_SHORTCUT, IS_NULL_PTR, dt_shortcut_t::key, dt_shortcut_t::locked, and model.

Referenced by dt_accels_window().

◆ _make_column_editable()

static void _make_column_editable ( GtkTreeViewColumn *  col,
GtkCellRenderer *  renderer,
GtkTreeModel *  model,
GtkTreeIter *  iter,
gpointer  data 
)
static

Definition at line 1360 of file accelerators.c.

References COL_SHORTCUT, IS_NULL_PTR, dt_shortcut_t::locked, and model.

Referenced by dt_accels_window().

◆ _match_text()

static int _match_text ( GtkTreeModel *  model,
GtkTreeIter *  iter,
const char *  needle 
)
static

Definition at line 1987 of file accelerators.c.

References dt_free, FALSE, i, IS_NULL_PTR, model, t, and TRUE.

Referenced by _find_and_rank_matches().

◆ _normalize_keyval()

static guint _normalize_keyval ( const guint  keyval)
inlinestatic

Definition at line 1105 of file accelerators.c.

Referenced by _for_each_accel(), _for_each_non_virtual_accel(), and filter_callback().

◆ _queue_action_from_shortcut()

◆ _remove_accel_hashtable()

static void _remove_accel_hashtable ( gpointer  _key,
gpointer  value,
gpointer  user_data 
)
static

◆ _remove_generic_accel()

static void _remove_generic_accel ( dt_shortcut_t *  shortcut)
static

◆ _remove_widget_accel()

static void _remove_widget_accel ( dt_shortcut_t *  shortcut,
const GtkAccelKey *  old_key 
)
static

◆ _search_entry_button_pressed()

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

Definition at line 3099 of file accelerators.c.

References DT_ACCEL_SEARCH_INLINE_SEPARATOR, dt_free, FALSE, IS_NULL_PTR, state, and TRUE.

Referenced by dt_accels_search().

◆ _search_entry_changed()

static void _search_entry_changed ( GtkWidget *  widget,
gpointer  user_data 
)
static

◆ _search_entry_key_pressed()

◆ _search_entry_restore_space_idle()

static gboolean _search_entry_restore_space_idle ( gpointer  user_data)
static

◆ _shortcut_cleared()

static void _shortcut_cleared ( GtkCellRendererAccel *  renderer,
const gchar *  path_string,
gpointer  user_data 
)
static

Definition at line 1509 of file accelerators.c.

References _shortcut_edited().

Referenced by dt_accels_window().

◆ _shortcut_edited()

static void _shortcut_edited ( GtkCellRenderer *  cell,
const gchar *  path_string,
guint  key,
GdkModifierType  mods,
guint  hardware_key,
gpointer  user_data 
)
static

◆ _shortcut_search_button_press()

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

Definition at line 3125 of file accelerators.c.

References FALSE, IS_NULL_PTR, state, and TRUE.

Referenced by dt_accels_search().

◆ _shortcut_search_destroy()

static void _shortcut_search_destroy ( GtkWidget *  widget,
gpointer  user_data 
)
static

Definition at line 3157 of file accelerators.c.

References dt_free, IS_NULL_PTR, and state.

Referenced by dt_accels_search().

◆ _shortcut_search_load_recent_entries()

static void _shortcut_search_load_recent_entries ( GtkListStore *  store)
static

◆ _shortcut_search_move_selection()

static gboolean _shortcut_search_move_selection ( dt_accels_search_state_t *  state,
const gboolean  forward 
)
static

Definition at line 2907 of file accelerators.c.

References FALSE, IS_NULL_PTR, state, and TRUE.

Referenced by _search_entry_key_pressed().

◆ _shortcut_search_recent_completion_match()

static gboolean _shortcut_search_recent_completion_match ( GtkEntryCompletion *  completion,
const gchar *  key,
GtkTreeIter *  iter,
gpointer  user_data 
)
static

Definition at line 2820 of file accelerators.c.

References DT_ACCEL_SEARCH_INLINE_SEPARATOR, dt_free, FALSE, IS_NULL_PTR, key, and model.

Referenced by dt_accels_search().

◆ _shortcut_search_recent_insert_prefix()

static gboolean _shortcut_search_recent_insert_prefix ( GtkEntryCompletion *  completion,
gchar *  prefix,
gpointer  user_data 
)
static

◆ _shortcut_search_recent_match_selected()

static gboolean _shortcut_search_recent_match_selected ( GtkEntryCompletion *  completion,
GtkTreeModel *  model,
GtkTreeIter *  iter,
gpointer  user_data 
)
static

Definition at line 2384 of file accelerators.c.

References dt_free, IS_NULL_PTR, model, state, and TRUE.

Referenced by dt_accels_search().

◆ _shortcut_search_recent_sort_func()

static gint _shortcut_search_recent_sort_func ( GtkTreeModel *  model,
GtkTreeIter *  a,
GtkTreeIter *  b,
gpointer  user_data 
)
static

Definition at line 2154 of file accelerators.c.

References DT_ACCEL_SEARCH_INLINE_SEPARATOR, dt_free, IS_NULL_PTR, model, and state.

Referenced by dt_accels_search().

◆ _shortcut_search_row_activated()

static gboolean _shortcut_search_row_activated ( GtkTreeView *  tree_view,
GtkTreePath *  path,
GtkTreeViewColumn *  column,
gpointer  user_data 
)
static

Definition at line 2895 of file accelerators.c.

References _queue_action_from_shortcut(), FALSE, and state.

Referenced by dt_accels_search().

◆ _shortcut_search_save_recent_entry()

static void _shortcut_search_save_recent_entry ( const char *  query,
const dt_shortcut_t *  shortcut 
)
static

◆ _shortcut_search_selection_changed()

static void _shortcut_search_selection_changed ( GtkTreeSelection *  selection,
gpointer  user_data 
)
static

Definition at line 2881 of file accelerators.c.

References state.

Referenced by dt_accels_search().

◆ _shortcut_search_trim_display_path()

static gchar * _shortcut_search_trim_display_path ( const gchar *  path)
static

◆ _shortcut_search_visible()

static gboolean _shortcut_search_visible ( GtkTreeModel *  model,
GtkTreeIter *  iter,
gpointer  user_data 
)
static

Definition at line 2813 of file accelerators.c.

References model.

Referenced by dt_accels_search().

◆ _shortcut_search_window_key_pressed()

static gboolean _shortcut_search_window_key_pressed ( GtkWidget *  widget,
GdkEventKey *  event,
gpointer  user_data 
)
static

Definition at line 3120 of file accelerators.c.

References _search_entry_key_pressed().

Referenced by dt_accels_search().

◆ _shortcut_set_widget_data()

static void _shortcut_set_widget_data ( GtkWidget *  widget,
dt_shortcut_t *  shortcut 
)
inlinestatic

◆ _sort_model_by_relevance_func()

static gint _sort_model_by_relevance_func ( GtkTreeModel *  model,
GtkTreeIter *  a,
GtkTreeIter *  b,
gpointer  data 
)
static

Definition at line 1667 of file accelerators.c.

References dt_free, i, IS_NULL_PTR, and model.

Referenced by dt_accels_search().

◆ _sort_model_func()

static gint _sort_model_func ( GtkTreeModel *  model,
GtkTreeIter *  a,
GtkTreeIter *  b,
gpointer  data 
)
static

Definition at line 1724 of file accelerators.c.

References dt_free, model, and res.

Referenced by dt_accels_window().

◆ _text_entry_focus_in_event()

static gboolean _text_entry_focus_in_event ( GtkWidget *  self,
GdkEventFocus  event,
gpointer  user_data 
)
static

Definition at line 3359 of file accelerators.c.

References dt_accels_disable(), dt_accels_get_global(), FALSE, and TRUE.

Referenced by dt_accels_disconnect_on_text_input().

◆ _text_entry_focus_out_event()

static gboolean _text_entry_focus_out_event ( GtkWidget *  self,
GdkEventFocus  event,
gpointer  user_data 
)
static

Definition at line 3365 of file accelerators.c.

References dt_accels_disable(), dt_accels_get_global(), and FALSE.

Referenced by dt_accels_disconnect_on_text_input().

◆ _text_entry_key_pressed()

static gboolean _text_entry_key_pressed ( GtkWidget *  widget,
GdkEventKey *  event,
gpointer  user_data 
)
static

Definition at line 3371 of file accelerators.c.

References dt_widget_refocus(), FALSE, and TRUE.

Referenced by dt_accels_disconnect_on_text_input().

◆ _update_shortcut_state()

static gboolean _update_shortcut_state ( dt_shortcut_t *  shortcut,
GtkAccelKey *  key,
gboolean  init 
)
static

◆ _virtual_shortcut_callback()

static gboolean _virtual_shortcut_callback ( GtkAccelGroup *  group,
GObject *  acceleratable,
guint  keyval,
GdkModifierType  mods,
gpointer  user_data 
)
static

◆ _widget_shortcut_callback()

static gboolean _widget_shortcut_callback ( GtkAccelGroup *  group,
GObject *  acceleratable,
guint  keyval,
GdkModifierType  mods,
gpointer  user_data 
)
static

◆ dt_accels_attach_scroll_handler()

void dt_accels_attach_scroll_handler ( dt_accels_t *  accels,
gboolean(*)(GdkEventScroll event, void *data)  callback,
void *  data 
)

Attach a new global scroll event callback. So far this is used in darkroom to redirect scroll events to a Bauhaus widget when the focusing shortcut of that widget is held down on keyboard.

Parameters
callback
data

Definition at line 1316 of file accelerators.c.

References dt_accels_t::scroll::callback, dt_accels_t::scroll::data, and dt_accels_t::scroll.

Referenced by enter().

◆ dt_accels_build_path()

gchar * dt_accels_build_path ( const gchar *  scope,
const gchar *  feature 
)

Build the accel path of feature under scope.

scope is a hierarchy, its levels separated by "/", with or without the leading "<Ansel>/". feature is ONE level: it is a GUI label, often translated, and a "/" in it is written as "-", because the "/" is the only structure an accel path has. A label that holds one would otherwise add a level that no code asked for. To nest several labels, build the path one label at a time, passing the path built so far as the next scope.

Returns
a newly allocated path, to be freed with dt_free().

Definition at line 1024 of file accelerators.c.

References dt_free.

Referenced by _a_slash_in_the_feature_stays_one_level(), _iop_panel_label(), _nested_levels_are_built_one_at_a_time(), _styles_get_submenu(), _the_scope_keeps_its_levels(), add_generic_top_menu_entry(), add_generic_top_submenu_entry(), dt_accels_new_action_shortcut(), dt_accels_new_virtual_instance_shortcut(), dt_bauhaus_init(), dt_bauhaus_widget_set_label(), dt_iop_gui_init(), dt_lib_unload_module(), dt_thumbtable_new(), gui_cleanup(), gui_init(), gui_init(), and set_menu_entry().

◆ dt_accels_cleanup()

◆ dt_accels_connect_accels()

void dt_accels_connect_accels ( dt_accels_t *  accels)

Actually enable accelerators after having loaded user config.

Parameters
accels

Definition at line 963 of file accelerators.c.

References _connect_accel_hashtable(), dt_accels_t::acceleratables, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), and dt_accels_t::lock.

Referenced by dt_init(), and enter().

◆ dt_accels_connect_active_group()

void dt_accels_connect_active_group ( dt_accels_t *  accels,
const gchar *  group 
)

Connect the contextual active accels group to the window. Views can declare their own set of contextual accels, which can override the global accels, in case they use the same keys.

Parameters
accels
groupany of the following: "darkroom", "lighttable", "map", "print", "slideshow".

Definition at line 458 of file accelerators.c.

References dt_accels_t::active_group, dt_accels_t::darkroom_accels, IS_NULL_PTR, dt_accels_t::lighttable_accels, dt_accels_t::map_accels, dt_accels_t::print_accels, dt_accels_t::reset, and dt_accels_t::slideshow_accels.

Referenced by enter().

◆ dt_accels_detach_scroll_handler()

void dt_accels_detach_scroll_handler ( dt_accels_t *  accels)

Definition at line 1322 of file accelerators.c.

References dt_accels_t::scroll::callback, dt_accels_t::scroll::data, and dt_accels_t::scroll.

Referenced by leave().

◆ dt_accels_disconnect_active_group()

void dt_accels_disconnect_active_group ( dt_accels_t *  accels)

Disconnect the contextual active accels group from the window.

Parameters
accels

Definition at line 494 of file accelerators.c.

References dt_accels_t::active_group, IS_NULL_PTR, and dt_accels_t::reset.

Referenced by leave().

◆ dt_accels_disconnect_on_text_input()

void dt_accels_disconnect_on_text_input ( GtkWidget *  widget)

◆ dt_accels_dispatch()

gboolean dt_accels_dispatch ( GtkWidget *  w,
GdkEvent *  event,
gpointer  user_data 
)

Force our listener for all key strokes to bypass reserved Gtk keys.

Parameters
w
event
user_data
Returns
gboolean

Definition at line 1233 of file accelerators.c.

References _accels_keys_decode(), _key_pressed(), dt_accels_t::active_group, dt_accels_t::active_key, dt_accels_t::scroll::callback, dt_accels_t::scroll::data, dt_accels_t::disable_accels, dt_widget_log, FALSE, IS_NULL_PTR, dt_accels_t::reset, and dt_accels_t::scroll.

Referenced by dt_gui_gtk_init().

◆ dt_accels_get_global()

◆ dt_accels_init()

◆ dt_accels_load_user_config()

void dt_accels_load_user_config ( dt_accels_t *  accels)

Loads keyboardrc.lang from config dir. This needs to run after we inited the accel map from widgets creation.

Parameters
accels

Definition at line 911 of file accelerators.c.

References dt_accels_t::config_file.

Referenced by dt_gui_gtk_init().

◆ dt_accels_new_action_shortcut()

void dt_accels_new_action_shortcut ( dt_accels_t *  accels,
gboolean(*)(GtkAccelGroup *group, GObject *acceleratable, guint keyval, GdkModifierType mods, gpointer user_data)  action_callback,
gpointer  data,
GtkWidget *  target_widget,
GtkAccelGroup *  accel_group,
const gchar *  action_scope,
const gchar *  action_name,
guint  key_val,
GdkModifierType  accel_mods,
const gboolean  lock,
const char *  description 
)

Register a new shortcut for a generic action, setting up its path, default keys and accel group. This does everything but connecting it, so exists only as a defined slot to be connected later.

The callback should have the following signature:

gboolean action_callback(GtkAccelGroup *accel_group, GObject *accelerable, guint keyval, GdkModifierType
modifier, gpointer data)
Parameters
accels
dataOpaque payload handed back to action_callback. Its type is the caller's business and is never inspected here.
target_widgetThe widget this action acts on, or NULL when it acts on something that is not a widget. Pass data itself when data IS a widget. The dispatcher uses it to pick between several instances registered on the same path, and to decide whether invoking the action should first move focus back to the center view. It must be declared rather than derived: asking GTK whether an opaque pointer is a widget reads through it as if it were a GObject, which is undefined for every payload that is not one.
accel_group
action_scopeHuman-readable, translated, category or scope of the action. Will be turned into path internally
action_nameHuman-readable, translated, name or description of the action. Will be turned into path internally
key_val
accel_mods
lockprevent user edition

Definition at line 853 of file accelerators.c.

References _add_generic_accel(), _insert_accel(), _remove_generic_accel(), dt_shortcut_t::accel_group, dt_accels_t::acceleratables, dt_shortcut_t::accels, dt_shortcut_t::closure, description(), dt_shortcut_t::description, dt_accels_build_path(), dt_free, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_shortcut_get_closure(), dt_shortcut_set_closure(), DT_SHORTCUT_UNSET, FALSE, dt_accels_t::flags, dt_shortcut_t::key, lock, dt_accels_t::lock, dt_shortcut_t::locked, dt_shortcut_t::mods, dt_shortcut_t::path, dt_shortcut_t::signal, dt_shortcut_t::type, dt_shortcut_t::virtual_shortcut, and dt_shortcut_t::widget.

Referenced by dt_dev_toolbox_add_accels(), dt_lib_init_module(), gui_init(), and set_menu_entry().

◆ dt_accels_new_virtual_instance_shortcut()

void dt_accels_new_virtual_instance_shortcut ( dt_accels_t *  accels,
gboolean(*)(GtkAccelGroup *group, GObject *acceleratable, guint keyval, GdkModifierType mods, gpointer user_data)  action_callback,
gpointer  data,
GtkAccelGroup *  accel_group,
const gchar *  action_scope,
const gchar *  action_name 
)

◆ dt_accels_new_virtual_shortcut()

void dt_accels_new_virtual_shortcut ( dt_accels_t *  accels,
GtkAccelGroup *  accel_group,
const gchar *  accel_path,
GtkWidget *  widget,
guint  key_val,
GdkModifierType  accel_mods 
)

Add a new virtual shortcut. Virtual shortcuts are immutable, read-only and don't trigger any action. They are meant to serve as placeholders, in a purely declarative way, for key combinations hardcoded in the key-pressed events handlers of widgets able to capture focus. Once declared here, they will prevent users from declaring their own shortcuts using hardcoded combinations for the corresponding accel_group.

Parameters
accel_group
accel_path
key_val
accel_mods

Definition at line 722 of file accelerators.c.

References _insert_accel(), _shortcut_set_widget_data(), _virtual_shortcut_callback(), dt_shortcut_t::accel_group, dt_accels_t::acceleratables, dt_shortcut_t::accels, dt_shortcut_t::closure, dt_shortcut_t::description, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_shortcut_set_closure(), DT_SHORTCUT_UNSET, IS_NULL_PTR, dt_shortcut_t::key, dt_accels_t::lock, dt_shortcut_t::locked, dt_shortcut_t::mods, dt_shortcut_t::path, dt_shortcut_t::signal, TRUE, dt_shortcut_t::type, dt_shortcut_t::virtual_shortcut, and dt_shortcut_t::widget.

Referenced by dt_bauhaus_init(), dt_thumbtable_new(), and gui_init().

◆ dt_accels_new_widget_shortcut()

void dt_accels_new_widget_shortcut ( dt_accels_t *  accels,
GtkWidget *  widget,
const gchar *  signal,
GtkAccelGroup *  accel_group,
const gchar *  accel_path,
guint  key_val,
GdkModifierType  accel_mods,
const gboolean  lock 
)

Register a new shortcut for a widget, setting up its path, default keys and accel group. This does everything but connecting it, so exists only as a defined slot to be connected later.

Parameters
accels
widget
signal
accel_group
accel_path
key_val
accel_mods
lockprevent user edition

Definition at line 797 of file accelerators.c.

References _add_widget_accel(), _insert_accel(), _remove_widget_accel(), _shortcut_set_widget_data(), _widget_shortcut_callback(), dt_shortcut_t::accel_group, dt_accels_t::acceleratables, dt_shortcut_t::accels, dt_shortcut_t::closure, dt_shortcut_t::description, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_shortcut_set_closure(), DT_SHORTCUT_UNSET, FALSE, dt_accels_t::flags, key, dt_shortcut_t::key, lock, dt_accels_t::lock, dt_shortcut_t::locked, dt_shortcut_t::mods, dt_shortcut_t::path, dt_shortcut_t::signal, dt_shortcut_t::type, dt_shortcut_t::virtual_shortcut, and dt_shortcut_t::widget.

Referenced by gui_init().

◆ dt_accels_remove_accel()

void dt_accels_remove_accel ( dt_accels_t *  accels,
const char *  path,
gpointer  data 
)

Recursively remove all accels for all shortcuts containing path. This is unneeded for accels attached to Gtk widgets through dt_accels_new_widget_shortcut because Gtk will handle that internally when deleting a widget. But for our own widget-less dt_accels_new_action_shortcut, we need to handle that ourselves.

Accels are typically added at gui_init() time of their attached GUI object, and the typical use case of this API assumes those objects live until the app is closed. But IOP modules can be added/removed at runtime (instances), so we need to destroy accels when their target object (user_data pointer/callback) is destroyed. If some accels are left dangling with a reference to a non-existing callback/data/closure, the app will crash with segfault upon shortcut activation.

This will remove in one shot all accels attached to a parent and to all of its children, assuming that children will share their path root with their parent, and that rule is entirely up to the developer to enforce.

This does not remove the shortcut object.

Parameters
accels
pathaccel path
datathe user-data used by the initial callback, if any

Definition at line 1001 of file accelerators.c.

References _remove_accel_hashtable(), dt_accels_t::acceleratables, dt_free, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), IS_NULL_PTR, dt_accels_t::lock, and params.

Referenced by _widget_finalize(), dt_iop_gui_cleanup_module(), and gui_cleanup().

◆ dt_accels_remove_shortcut()

void dt_accels_remove_shortcut ( dt_accels_t *  accels,
const char *  path 
)

Remove the shortcut object identified by path and all its accels.

Parameters
accels
path

Definition at line 1016 of file accelerators.c.

References dt_accels_t::acceleratables, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), and dt_accels_t::lock.

Referenced by _iop_panel_label(), dt_iop_gui_cleanup_module(), dt_lib_unload_module(), and gui_cleanup().

◆ dt_accels_search()

◆ dt_accels_set_global()

void dt_accels_set_global ( dt_accels_t *  accels)

The accels instance this process uses. Set once by the host at GUI init.

Definition at line 65 of file accelerators.c.

References _accels_global.

Referenced by dt_gui_gtk_init().

◆ dt_accels_set_recent_handlers()

void dt_accels_set_recent_handlers ( dt_accels_recent_get_handler_t  get,
dt_accels_recent_set_handler_t  set 
)

Definition at line 85 of file accelerators.c.

References _recent_get, and _recent_set.

Referenced by dt_gui_gtk_init().

◆ dt_accels_set_refocus_handler()

void dt_accels_set_refocus_handler ( dt_accels_refocus_handler_t  handler)

Definition at line 80 of file accelerators.c.

References _refocus_handler.

Referenced by dt_gui_gtk_init().

◆ dt_accels_set_top_offset_handler()

void dt_accels_set_top_offset_handler ( dt_accels_top_offset_handler_t  handler)

Definition at line 75 of file accelerators.c.

References _top_offset_handler.

Referenced by dt_gui_gtk_init().

◆ dt_accels_window()

◆ dt_shortcut_get_closure()

◆ dt_shortcut_get_payload_closure()

PayloadClosure * dt_shortcut_get_payload_closure ( dt_shortcut_t *  shortcut)

◆ dt_shortcut_remove_closure()

void dt_shortcut_remove_closure ( dt_shortcut_t *  shortcut,
gpointer  data 
)

Definition at line 291 of file accelerators.c.

References _g_list_closure_unref(), dt_shortcut_t::closure, and IS_NULL_PTR.

Referenced by _remove_accel_hashtable().

◆ dt_shortcut_set_closure()

void dt_shortcut_set_closure ( dt_shortcut_t *  shortcut,
gboolean(*)(GtkAccelGroup *group, GObject *acceleratable, guint keyval, GdkModifierType mods, gpointer user_data)  action_callback,
gpointer  data,
GtkWidget *  widget 
)

◆ filter_callback()

static gboolean filter_callback ( GtkTreeModel *  model,
GtkTreeIter *  iter,
gpointer  user_data 
)
static

◆ guess_key_group()

static int guess_key_group ( dt_accels_t *  accels,
guint  keyval,
guint  hardware_keycode 
)
static

Definition at line 1388 of file accelerators.c.

References dt_free, i, and dt_accels_t::keymap.

Referenced by _shortcut_edited().

◆ search_changed()

static void search_changed ( GtkEntry *  entry,
gpointer  user_data 
)
static

Definition at line 1838 of file accelerators.c.

References IS_NULL_PTR, and params.

Referenced by dt_accels_window().

Variable Documentation

◆ _accels_global

dt_accels_t* _accels_global = NULL
static

Definition at line 59 of file accelerators.c.

Referenced by dt_accels_get_global(), and dt_accels_set_global().

◆ _recent_get

◆ _recent_set

dt_accels_recent_set_handler_t _recent_set = NULL
static

◆ _refocus_handler

dt_accels_refocus_handler_t _refocus_handler = NULL
static

Definition at line 61 of file accelerators.c.

Referenced by _dispatch_selected_shortcut(), and dt_accels_set_refocus_handler().

◆ _top_offset_handler

dt_accels_top_offset_handler_t _top_offset_handler = NULL
static

Definition at line 60 of file accelerators.c.

Referenced by dt_accels_search(), and dt_accels_set_top_offset_handler().

◆ accels_global_ref

dt_accels_t* accels_global_ref = NULL
static

Definition at line 1333 of file accelerators.c.

Referenced by _shortcut_edited(), and dt_accels_window().