Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/bauhaus/bauhaus.c
Original file line number Diff line number Diff line change
Expand Up @@ -1522,6 +1522,10 @@ void dt_bauhaus_combobox_add_list(GtkWidget *widget,
if(action)
g_hash_table_insert(darktable.bauhaus->combo_list, action, texts);

if(!darktable.control->accel_initialised
&& DT_BAUHAUS_WIDGET(widget)->module->type == DT_ACTION_TYPE_IOP_INSTANCE)
return;

while(texts && *texts)
dt_bauhaus_combobox_add(widget, Q_(*(texts++)));
}
Expand All @@ -1538,6 +1542,10 @@ gboolean dt_bauhaus_combobox_add_introspection
if(action)
g_hash_table_insert(darktable.bauhaus->combo_introspection, action, (gpointer)list);

if(!darktable.control->accel_initialised
&& DT_BAUHAUS_WIDGET(widget)->module->type == DT_ACTION_TYPE_IOP_INSTANCE)
return FALSE;

while(item->name && item->value != start) item++;
for(; item->name; item++)
{
Expand Down Expand Up @@ -1580,9 +1588,8 @@ void dt_bauhaus_combobox_add_full(GtkWidget *widget,
gpointer data, void (free_func)(void *data),
const gboolean sensitive)
{
if(darktable.control->accel_initialising) return;

dt_bauhaus_widget_t *w = DT_BAUHAUS_WIDGET(widget);

if(w->type != DT_BAUHAUS_COMBOBOX) return;
dt_bauhaus_combobox_data_t *d = &w->data.combobox;
if(!data && d->entries->len > 0 && !_combobox_entry(d, 0)->data)
Expand Down
3 changes: 3 additions & 0 deletions src/common/darktable.c
Original file line number Diff line number Diff line change
Expand Up @@ -1869,6 +1869,9 @@ int dt_init(int argc, char *argv[], const gboolean init_gui, const gboolean load
{
dt_ctl_switch_mode_to("lighttable");

// all the default shortcuts have been registered
darktable.control->accel_initialised = TRUE;

// Save the default shortcuts
dt_shortcuts_save(".defaults", FALSE);

Expand Down
2 changes: 0 additions & 2 deletions src/control/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ void dt_control_init(const gboolean withgui)

dt_action_insert_sorted(&s->actions_iops, &s->actions_focus);

s->widgets = g_hash_table_new(NULL, NULL);
s->shortcuts = g_sequence_new(g_free);
s->enable_fallbacks = dt_conf_get_bool("accel/enable_fallbacks");
s->mapping_widget = NULL;
Expand Down Expand Up @@ -381,7 +380,6 @@ void dt_control_cleanup(const gboolean withgui)
dt_pthread_mutex_destroy(&s->log_mutex);
dt_pthread_mutex_destroy(&s->res_mutex);
dt_pthread_mutex_destroy(&s->progress_system.mutex);
if(s->widgets) g_hash_table_destroy(s->widgets);
if(s->shortcuts) g_sequence_free(s->shortcuts);
if(s->input_drivers) g_slist_free_full(s->input_drivers, g_free);
}
Expand Down
3 changes: 1 addition & 2 deletions src/control/control.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,14 @@ typedef enum dt_control_state_t

typedef struct dt_control_t
{
gboolean accel_initialising;
gboolean accel_initialised;

dt_action_t *actions, actions_global,
actions_views, actions_thumb,
actions_libs, actions_format, actions_storage,
actions_iops, actions_blend, actions_focus,
actions_lua, actions_fallbacks, *actions_modifiers;

GHashTable *widgets;
GSequence *shortcuts;
gboolean enable_fallbacks;
GtkWidget *mapping_widget;
Expand Down
3 changes: 0 additions & 3 deletions src/develop/imageop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1685,7 +1685,6 @@ static void _init_module_so(void *m)
if(module->gui_init
&& !dt_iop_load_module_by_so(module_instance, module, NULL))
{
darktable.control->accel_initialising = TRUE;
dt_iop_gui_init(module_instance);

static gboolean blending_accels_initialized = FALSE;
Expand All @@ -1708,8 +1707,6 @@ static void _init_module_so(void *m)

dt_iop_gui_cleanup_module(module_instance);
dt_iop_cleanup_module(module_instance);

darktable.control->accel_initialising = FALSE;
}

free(module_instance);
Expand Down
16 changes: 15 additions & 1 deletion src/develop/imageop_gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "bauhaus/bauhaus.h"
#include "dtgtk/button.h"
#include "gui/accelerators.h"
#include "common/curve_tools.h"

#ifdef GDK_WINDOWING_QUARTZ
#include "osx/osx.h"
Expand Down Expand Up @@ -323,7 +324,6 @@ GtkWidget *dt_iop_button_new(dt_iop_module_t *self, const gchar *label,
g_signal_connect(G_OBJECT(button), "clicked", callback, (gpointer)self);

dt_action_t *ac = dt_action_define_iop(self, NULL, label, button, &dt_action_def_button);
if(darktable.control->accel_initialising)
dt_shortcut_register(ac, 0, 0, accel_key, mods);

if(GTK_IS_BOX(box)) gtk_box_pack_start(GTK_BOX(box), button, TRUE, TRUE, 0);
Expand All @@ -337,6 +337,20 @@ gboolean dt_mask_scroll_increases(int up)
return up ? !mask_down : mask_down;
}

GtkWidget *dt_bauhaus_combobox_new_interpolation(dt_iop_module_t *self)
{
static const dt_introspection_type_enum_tuple_t interpolation_names[]
= { { N_("cubic spline"), CUBIC_SPLINE },
{ N_("centripetal spline"), CATMULL_ROM },
{ N_("monotonic spline"), MONOTONE_HERMITE },
{ } };
GtkWidget *w = dt_bauhaus_combobox_new(self);
dt_action_t *ac = dt_bauhaus_widget_set_label(w, NULL, N_("interpolation method"));
dt_bauhaus_combobox_add_introspection(w, ac, interpolation_names, 0, -1);

return w;
}

// clang-format off
// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
// vim: shiftwidth=2 expandtab tabstop=2 cindent
Expand Down
2 changes: 2 additions & 0 deletions src/develop/imageop_gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ GtkWidget *dt_iop_button_new(dt_iop_module_t *self, const gchar *label,
/* returns up or !up depending on the masks_updown preference */
gboolean dt_mask_scroll_increases(int up);

GtkWidget *dt_bauhaus_combobox_new_interpolation(dt_iop_module_t *self);

G_END_DECLS

// clang-format off
Expand Down
38 changes: 16 additions & 22 deletions src/gui/accelerators.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ static dt_shortcut_t _sc = { 0 }; // shortcut under construction
static guint _previous_move = DT_SHORTCUT_MOVE_NONE;
static dt_action_t *_selected_action = NULL;
static dt_shortcut_t *_selected_shortcut = NULL;
static GQuark _action_quark = 0;

#define ELEMENT_IS(type, shortcut, elements) ((elements) && (elements)[(shortcut)->element].effects == dt_action_effect_##type)

Expand Down Expand Up @@ -479,7 +480,7 @@ static const gchar *_action_find_effect_combo(dt_action_t *ac,

dt_action_t *dt_action_widget(GtkWidget *widget)
{
return g_hash_table_lookup(darktable.control->widgets, widget);
return widget ? g_object_get_qdata(G_OBJECT(widget), _action_quark) : NULL;
}

static gboolean _is_kp_key(guint keycode)
Expand Down Expand Up @@ -4670,17 +4671,6 @@ gboolean dt_shortcut_dispatcher(GtkWidget *w,
return TRUE;
}

static void _remove_widget_from_hashtable(GtkWidget *widget, gpointer user_data)
{
dt_action_t *action = dt_action_widget(widget);
if(action)
{
if(action->target == widget) action->target = NULL;

g_hash_table_remove(darktable.control->widgets, widget);
}
}

void dt_action_insert_sorted(dt_action_t *owner, dt_action_t *new_action)
{
new_action->owner = owner;
Expand Down Expand Up @@ -4822,16 +4812,22 @@ dt_action_t *dt_action_define(dt_action_t *owner,
{
ac->target = widget;
}
else if(!darktable.control->accel_initialising && widget)
else if(widget)
{
if(label && action_def && !ac->target) ac->target = widget;
g_hash_table_insert(darktable.control->widgets, widget, ac);
if(!_action_quark)
_action_quark = g_quark_from_static_string("dt_action");

if(!g_object_get_qdata(G_OBJECT(widget), _action_quark))
{
g_object_set_qdata(G_OBJECT(widget), _action_quark, ac);

if(label && action_def && !ac->target)
g_set_weak_pointer(&ac->target, widget);
}

gtk_widget_set_has_tooltip(widget, TRUE);
g_signal_connect(G_OBJECT(widget), "leave-notify-event",
G_CALLBACK(_reset_element_on_leave), NULL);
g_signal_connect(G_OBJECT(widget), "destroy",
G_CALLBACK(_remove_widget_from_hashtable), NULL);
}
}

Expand Down Expand Up @@ -4918,7 +4914,7 @@ void dt_shortcut_register(dt_action_t *owner,
guint accel_key,
GdkModifierType mods)
{
if(accel_key != 0)
if(accel_key != 0 && !darktable.control->accel_initialised)
{
GdkKeymap *keymap = gdk_keymap_get_for_display(gdk_display_get_default());

Expand Down Expand Up @@ -5144,7 +5140,7 @@ void dt_accel_connect_instance_iop(dt_iop_module_t *module)
const dt_action_target_t *const referral = w->data;
dt_action_t *const ac = referral->action;
if(focused || (ac->owner != blend && ac->owner->owner != blend))
ac->target = referral->target;
g_set_weak_pointer(&ac->target, referral->target);
}
}

Expand Down Expand Up @@ -5172,9 +5168,7 @@ GtkWidget *dt_action_button_new(dt_lib_module_t *self,
{
dt_action_t *ac = dt_action_define(DT_ACTION(self), NULL, label,
button, &dt_action_def_button);
if(accel_key && (self->actions.type != DT_ACTION_TYPE_IOP_INSTANCE
|| darktable.control->accel_initialising))
dt_shortcut_register(ac, 0, 0, accel_key, mods);
dt_shortcut_register(ac, 0, 0, accel_key, mods);
g_object_set_data(G_OBJECT(button), "module", self);
}

Expand Down
4 changes: 4 additions & 0 deletions src/iop/ashift.c
Original file line number Diff line number Diff line change
Expand Up @@ -5963,6 +5963,10 @@ void gui_init(dt_iop_module_t *self)
g->rotation = dt_bauhaus_slider_from_params(self, N_("rotation"));
dt_bauhaus_slider_set_format(g->rotation, "°");
dt_bauhaus_slider_set_soft_range(g->rotation, -ROTATION_RANGE, ROTATION_RANGE);
dt_action_t *ac = dt_action_widget(g->rotation);
dt_shortcut_register(ac, 0, DT_ACTION_EFFECT_UP, GDK_KEY_bracketleft, GDK_MOD1_MASK);
dt_shortcut_register(ac, 0, DT_ACTION_EFFECT_DOWN, GDK_KEY_bracketright, GDK_MOD1_MASK);
dt_shortcut_register(ac, 0, 0, GDK_KEY_r, GDK_MOD1_MASK);

g->cropmode = dt_bauhaus_combobox_from_params(self, "cropmode");
g_signal_connect(G_OBJECT(g->cropmode), "value-changed",
Expand Down
11 changes: 1 addition & 10 deletions src/iop/colorzones.c
Original file line number Diff line number Diff line change
Expand Up @@ -2727,16 +2727,7 @@ void gui_init(dt_iop_module_t *self)
G_CALLBACK(_bottom_area_button_press_callback),
self);

/* From src/common/curve_tools.h :
#define CUBIC_SPLINE 0
#define CATMULL_ROM 1
#define MONOTONE_HERMITE 2
*/
g->interpolator = dt_bauhaus_combobox_new(self);
dt_bauhaus_widget_set_label(g->interpolator, NULL, N_("interpolation method"));
dt_bauhaus_combobox_add(g->interpolator, _("cubic spline"));
dt_bauhaus_combobox_add(g->interpolator, _("centripetal spline"));
dt_bauhaus_combobox_add(g->interpolator, _("monotonic spline"));
g->interpolator = dt_bauhaus_combobox_new_interpolation(self);
dt_gui_box_add(self->widget, g->interpolator);
gtk_widget_set_tooltip_text(g->interpolator,
_("change this method if you see oscillations or cusps in the curve\n"
Expand Down
2 changes: 2 additions & 0 deletions src/iop/crop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,8 @@ void gui_init(dt_iop_module_t *self)

darktable.develop->cropping.flip_handler = self;
darktable.develop->cropping.flip_callback = _crop_handle_flip;

dt_shortcut_register(DT_ACTION(self->so), 0, 0, GDK_KEY_c, 0);
}

static void _aspect_free(gpointer data)
Expand Down
1 change: 1 addition & 0 deletions src/iop/exposure.c
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,7 @@ void gui_init(dt_iop_module_t *self)
dt_bauhaus_slider_set_format(g->exposure, _(" EV"));
dt_bauhaus_slider_set_soft_range(g->exposure, -3.0, 4.0);
dt_bauhaus_widget_set_quad_tooltip(g->exposure, _("set the exposure adjustment using the selected area"));
dt_shortcut_register(dt_action_widget(g->exposure), 0, 0, GDK_KEY_e, 0);

GtkWidget *vbox_deflicker = self->widget = dt_gui_vbox();
gtk_stack_add_named(GTK_STACK(g->mode_stack), vbox_deflicker, "deflicker");
Expand Down
1 change: 0 additions & 1 deletion src/iop/negadoctor.c
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,6 @@ void gui_init(dt_iop_module_t *self)
"to adjust the global contrast while avoiding clipping shadows."));

g->gamma = dt_bauhaus_slider_from_params(self, "gamma");
dt_bauhaus_widget_set_label(g->gamma, NULL, N_("paper grade (gamma)"));
gtk_widget_set_tooltip_text(g->gamma, _("select the grade of the virtual paper, which is actually\n"
"equivalent to applying a gamma. it compensates the film D max\n"
"and recovers the contrast. use a high grade for high D max."));
Expand Down
11 changes: 1 addition & 10 deletions src/iop/rgbcurve.c
Original file line number Diff line number Diff line change
Expand Up @@ -1545,16 +1545,7 @@ void gui_init(dt_iop_module_t *self)
g_signal_connect(G_OBJECT(g->area), "key-press-event",
G_CALLBACK(_area_key_press_callback), self);

/* From src/common/curve_tools.h :
#define CUBIC_SPLINE 0
#define CATMULL_ROM 1
#define MONOTONE_HERMITE 2
*/
g->interpolator = dt_bauhaus_combobox_new(self);
dt_bauhaus_widget_set_label(g->interpolator, NULL, N_("interpolation method"));
dt_bauhaus_combobox_add(g->interpolator, _("cubic spline"));
dt_bauhaus_combobox_add(g->interpolator, _("centripetal spline"));
dt_bauhaus_combobox_add(g->interpolator, _("monotonic spline"));
g->interpolator = dt_bauhaus_combobox_new_interpolation(self);
gtk_widget_set_tooltip_text(g->interpolator,
_("change this method if you see oscillations or cusps in the curve\n"
"- cubic spline is better to produce smooth curves but oscillates when nodes are too close\n"
Expand Down
11 changes: 1 addition & 10 deletions src/iop/tonecurve.c
Original file line number Diff line number Diff line change
Expand Up @@ -1306,16 +1306,7 @@ void gui_init(dt_iop_module_t *self)
g_signal_connect(G_OBJECT(g->area), "key-press-event",
G_CALLBACK(dt_iop_tonecurve_key_press), self);

/* From src/common/curve_tools.h :
#define CUBIC_SPLINE 0
#define CATMULL_ROM 1
#define MONOTONE_HERMITE 2
*/
g->interpolator = dt_bauhaus_combobox_new(self);
dt_bauhaus_widget_set_label(g->interpolator, NULL, N_("interpolation method"));
dt_bauhaus_combobox_add(g->interpolator, _("cubic spline"));
dt_bauhaus_combobox_add(g->interpolator, _("centripetal spline"));
dt_bauhaus_combobox_add(g->interpolator, _("monotonic spline"));
g->interpolator = dt_bauhaus_combobox_new_interpolation(self);
gtk_widget_set_tooltip_text
(g->interpolator,
_("change this method if you see oscillations or cusps in the curve\n"
Expand Down
3 changes: 1 addition & 2 deletions src/iop/toneequal.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ typedef struct dt_iop_toneequalizer_params_t
float quantization; // $MIN: 0.0 $MAX: 2.0 $DEFAULT: 0.0 $DESCRIPTION: "mask quantization"
float contrast_boost; // $MIN: -16.0 $MAX: 16.0 $DEFAULT: 0.0 $DESCRIPTION: "mask contrast compensation"
float exposure_boost; // $MIN: -16.0 $MAX: 16.0 $DEFAULT: 0.0 $DESCRIPTION: "mask exposure compensation"
dt_iop_toneequalizer_filter_t details; // $DEFAULT: DT_TONEEQ_EIGF
dt_iop_toneequalizer_filter_t details; // $DEFAULT: DT_TONEEQ_EIGF $DESCRIPTION: "preserve details"
dt_iop_luminance_mask_method_t method; // $DEFAULT: DT_TONEEQ_NORM_2 $DESCRIPTION: "luminance estimator"
int iterations; // $MIN: 1 $MAX: 20 $DEFAULT: 1 $DESCRIPTION: "filter diffusion"
} dt_iop_toneequalizer_params_t;
Expand Down Expand Up @@ -3392,7 +3392,6 @@ void gui_init(dt_iop_module_t *self)
"higher contrast between areas to dodge and areas to burn"));

g->details = dt_bauhaus_combobox_from_params(self, N_("details"));
dt_bauhaus_widget_set_label(g->details, NULL, N_("preserve details"));
gtk_widget_set_tooltip_text
(g->details,
_("'no' affects global and local contrast (safe if you only add contrast)\n"
Expand Down
2 changes: 0 additions & 2 deletions src/libs/filtering.c
Original file line number Diff line number Diff line change
Expand Up @@ -2181,7 +2181,6 @@ void gui_init(dt_lib_module_t *self)
d->nb_rules = 0;
d->params = (dt_lib_filtering_params_t *)g_malloc0(sizeof(dt_lib_filtering_params_t));

darktable.control->accel_initialising = TRUE;
const int nb = sizeof(filters) / sizeof(_filter_t);
for(int i = 0; i < nb; i++)
{
Expand All @@ -2193,7 +2192,6 @@ void gui_init(dt_lib_module_t *self)
gtk_widget_destroy(temp_rule.w_special_box);
g_free(temp_rule.w_specific);
}
darktable.control->accel_initialising = FALSE;

for(int i = 0; i < DT_COLLECTION_MAX_RULES; i++)
{
Expand Down
13 changes: 5 additions & 8 deletions src/libs/filters/colors.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,11 @@ static void _colors_widget_init(dt_lib_filtering_rule_t *rule, const dt_collecti
GINT_TO_POINTER(-1));
dt_action_t *ac = dt_action_define(DT_ACTION(self), N_("rules"), N_("color label"), colors->operator, &dt_action_def_colors_rule);

if(darktable.control->accel_initialising)
{
dt_shortcut_register(ac, DT_COLORLABELS_RED + 1, DT_ACTION_EFFECT_TOGGLE, GDK_KEY_F1, GDK_SHIFT_MASK);
dt_shortcut_register(ac, DT_COLORLABELS_YELLOW + 1, DT_ACTION_EFFECT_TOGGLE, GDK_KEY_F2, GDK_SHIFT_MASK);
dt_shortcut_register(ac, DT_COLORLABELS_GREEN + 1, DT_ACTION_EFFECT_TOGGLE, GDK_KEY_F3, GDK_SHIFT_MASK);
dt_shortcut_register(ac, DT_COLORLABELS_BLUE + 1, DT_ACTION_EFFECT_TOGGLE, GDK_KEY_F4, GDK_SHIFT_MASK);
dt_shortcut_register(ac, DT_COLORLABELS_PURPLE + 1, DT_ACTION_EFFECT_TOGGLE, GDK_KEY_F5, GDK_SHIFT_MASK);
}
dt_shortcut_register(ac, DT_COLORLABELS_RED + 1, DT_ACTION_EFFECT_TOGGLE, GDK_KEY_F1, GDK_SHIFT_MASK);
dt_shortcut_register(ac, DT_COLORLABELS_YELLOW + 1, DT_ACTION_EFFECT_TOGGLE, GDK_KEY_F2, GDK_SHIFT_MASK);
dt_shortcut_register(ac, DT_COLORLABELS_GREEN + 1, DT_ACTION_EFFECT_TOGGLE, GDK_KEY_F3, GDK_SHIFT_MASK);
dt_shortcut_register(ac, DT_COLORLABELS_BLUE + 1, DT_ACTION_EFFECT_TOGGLE, GDK_KEY_F4, GDK_SHIFT_MASK);
dt_shortcut_register(ac, DT_COLORLABELS_PURPLE + 1, DT_ACTION_EFFECT_TOGGLE, GDK_KEY_F5, GDK_SHIFT_MASK);

if(top)
{
Expand Down
4 changes: 1 addition & 3 deletions src/libs/tools/global_toolbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,10 +514,8 @@ void gui_init(dt_lib_module_t *self)
g_signal_connect(G_OBJECT(d->preferences_button), "clicked", G_CALLBACK(_lib_preferences_button_clicked),
NULL);

#ifdef __APPLE__
// Register CMD+, for preferences on macOS
// Register CMD+, for preferences (this is standard on macOS)
dt_shortcut_register(ac, 0, DT_ACTION_EFFECT_ACTIVATE, GDK_KEY_comma, GDK_CONTROL_MASK);
#endif

self->widget = dt_gui_hbox(d->grouping_button, d->overlays_button,
d->help_button, d->keymap_button, d->preferences_button);
Expand Down
Loading
Loading