Skip to content

Commit

Permalink
Bauhaus: refactor: remove unused section arg
Browse files Browse the repository at this point in the history
  • Loading branch information
aurelienpierre committed Feb 3, 2025
1 parent 489cb50 commit 427a5ee
Show file tree
Hide file tree
Showing 56 changed files with 267 additions and 289 deletions.
15 changes: 4 additions & 11 deletions src/bauhaus/bauhaus.c
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,6 @@ static void _widget_finalize(GObject *widget)
g_ptr_array_free(d->entries, TRUE);
free(d->text);
}
g_free(w->section);
gtk_border_free(w->margin);
gtk_border_free(w->padding);

Expand Down Expand Up @@ -984,7 +983,6 @@ static void _bauhaus_widget_init(dt_bauhaus_t *bauhaus, dt_bauhaus_widget_t *w,
w->module = self;
w->field = NULL;

w->section = NULL;
w->no_accels = FALSE;
w->bauhaus = bauhaus;
w->use_default_callback = FALSE;
Expand Down Expand Up @@ -1123,7 +1121,7 @@ float dt_bauhaus_slider_get_default(GtkWidget *widget)
}


void dt_bauhaus_widget_set_label(GtkWidget *widget, const char *section, const char *label)
void dt_bauhaus_widget_set_label(GtkWidget *widget, const char *label)
{
struct dt_bauhaus_widget_t *w = DT_BAUHAUS_WIDGET(widget);
memset(w->label, 0, sizeof(w->label)); // keep valgrind happy
Expand All @@ -1133,8 +1131,6 @@ void dt_bauhaus_widget_set_label(GtkWidget *widget, const char *section, const c
dt_capitalize_label(w->label);
}

if(section) w->section = g_strdup(_(section));

if(w->module)
{
// Widgets auto-set by params introspection need to be added to the list of stuff to auto-update
Expand Down Expand Up @@ -1314,11 +1310,11 @@ GtkWidget *dt_bauhaus_combobox_new(dt_bauhaus_t *bh, dt_gui_module_t *self)
return GTK_WIDGET(w);
}

GtkWidget *dt_bauhaus_combobox_new_full(dt_bauhaus_t *bh, dt_gui_module_t *self, const char *section, const char *label, const char *tip,
GtkWidget *dt_bauhaus_combobox_new_full(dt_bauhaus_t *bh, dt_gui_module_t *self, const char *label, const char *tip,
int pos, GtkCallback callback, gpointer data, const char **texts)
{
GtkWidget *combo = dt_bauhaus_combobox_new(bh, self);
dt_bauhaus_widget_set_label(combo, section, label);
dt_bauhaus_widget_set_label(combo, label);
dt_bauhaus_combobox_add_list(combo, texts);
dt_bauhaus_combobox_set(combo, pos);
gtk_widget_set_tooltip_text(combo, tip ? tip : _(label));
Expand Down Expand Up @@ -1946,10 +1942,7 @@ static void dt_bauhaus_widget_accept(struct dt_bauhaus_widget_t *w, gboolean tim

static gchar *_build_label(const struct dt_bauhaus_widget_t *w)
{
if(w->show_extended_label && w->section)
return g_strdup_printf("%s - %s", w->section, w->label);
else
return g_strdup(w->label);
return g_strdup(w->label);
}

static gboolean dt_bauhaus_popup_draw(GtkWidget *widget, cairo_t *crf, gpointer user_data)
Expand Down
17 changes: 4 additions & 13 deletions src/bauhaus/bauhaus.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,6 @@ typedef struct dt_bauhaus_widget_t
// label text, short
char label[256];
gboolean show_label;
// section, short
gchar *section;
gboolean show_extended_label;
// callback function to draw the quad icon
dt_bauhaus_quad_paint_f quad_paint;
// minimal modifiers for paint function.
Expand All @@ -161,8 +158,6 @@ typedef struct dt_bauhaus_widget_t
int quad_toggle;
// show quad icon or space
gboolean show_quad;
// if a section label
gboolean is_section;

// margin and padding structure, defined in css, retrieve on each draw
GtkBorder *margin, *padding;
Expand Down Expand Up @@ -264,13 +259,9 @@ void dt_bauhaus_cleanup(dt_bauhaus_t *bauhaus);
// load theme colors, fonts, etc
void dt_bauhaus_load_theme(dt_bauhaus_t *bauhaus);

// set the bauhaus widget as a module section and in this case the font used will be the one
// from the CSS section_label.
void dt_bauhaus_widget_set_section(GtkWidget *w, const gboolean is_section);

// common functions:
// set the label text:
void dt_bauhaus_widget_set_label(GtkWidget *w, const char *section, const char *label);
void dt_bauhaus_widget_set_label(GtkWidget *w, const char *label);
const char* dt_bauhaus_widget_get_label(GtkWidget *w);
// attach a custom painted quad to the space at the right side (overwriting the default icon if any):
void dt_bauhaus_widget_set_quad_paint(GtkWidget *w, dt_bauhaus_quad_paint_f f, int paint_flags, void *paint_data);
Expand Down Expand Up @@ -336,14 +327,14 @@ float dt_bauhaus_slider_get_default(GtkWidget *widget);
// combobox:
void dt_bauhaus_combobox_from_widget(dt_bauhaus_t *bh, dt_bauhaus_widget_t* widget,dt_gui_module_t *self);
GtkWidget *dt_bauhaus_combobox_new(dt_bauhaus_t *bh, dt_gui_module_t *self);
GtkWidget *dt_bauhaus_combobox_new_full(dt_bauhaus_t *bh, dt_gui_module_t *self, const char *section,
GtkWidget *dt_bauhaus_combobox_new_full(dt_bauhaus_t *bh, dt_gui_module_t *self,
const char *label, const char *tip, int pos, GtkCallback callback,
gpointer data, const char **texts);

#define DT_BAUHAUS_COMBOBOX_NEW_FULL(bauhaus, widget, action, section, label, tip, pos, callback, data, ...) \
#define DT_BAUHAUS_COMBOBOX_NEW_FULL(bauhaus, widget, action, label, tip, pos, callback, data, ...) \
{ \
static const gchar *texts[] = { __VA_ARGS__, NULL }; \
widget = dt_bauhaus_combobox_new_full(bauhaus, action, section, label, tip, pos, callback, data, texts); \
widget = dt_bauhaus_combobox_new_full(bauhaus, action, label, tip, pos, callback, data, texts); \
}

void dt_bauhaus_combobox_add(GtkWidget *widget, const char *text);
Expand Down
24 changes: 12 additions & 12 deletions src/develop/blend_gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -2313,7 +2313,7 @@ void dt_iop_gui_init_blendif(GtkBox *blendw, dt_iop_module_t *module)
bd->channel_boost_factor_slider = dt_bauhaus_slider_new_with_range(darktable.bauhaus, DT_GUI_MODULE(module), 0.0f, 18.0f, 0, 0.0f, 3);
dt_bauhaus_set_use_default_callback(bd->channel_boost_factor_slider);
dt_bauhaus_slider_set_format(bd->channel_boost_factor_slider, _(" EV"));
dt_bauhaus_widget_set_label(bd->channel_boost_factor_slider, N_("blend"), N_("boost factor"));
dt_bauhaus_widget_set_label(bd->channel_boost_factor_slider, N_("boost factor"));
dt_bauhaus_slider_set_soft_range(bd->channel_boost_factor_slider, 0.0, 3.0);
gtk_widget_set_tooltip_text(bd->channel_boost_factor_slider, _("adjust the boost factor of the channel mask"));
gtk_widget_set_sensitive(bd->channel_boost_factor_slider, FALSE);
Expand Down Expand Up @@ -2409,7 +2409,7 @@ void dt_iop_gui_init_masks(GtkBox *blendw, dt_iop_module_t *module)

bd->masks_combo = dt_bauhaus_combobox_new(darktable.bauhaus, DT_GUI_MODULE(module));
dt_bauhaus_set_use_default_callback(bd->masks_combo);
dt_bauhaus_widget_set_label(bd->masks_combo, N_("blend"), N_("drawn mask"));
dt_bauhaus_widget_set_label(bd->masks_combo, N_("drawn mask"));

dt_bauhaus_combobox_add(bd->masks_combo, _("no mask used"));
g_signal_connect(G_OBJECT(bd->masks_combo), "value-changed",
Expand Down Expand Up @@ -2592,7 +2592,7 @@ void dt_iop_gui_init_raster(GtkBox *blendw, dt_iop_module_t *module)

bd->raster_combo = dt_bauhaus_combobox_new(darktable.bauhaus, DT_GUI_MODULE(module));
dt_bauhaus_set_use_default_callback(bd->raster_combo);
dt_bauhaus_widget_set_label(bd->raster_combo, N_("blend"), N_("raster mask"));
dt_bauhaus_widget_set_label(bd->raster_combo, N_("raster mask"));
dt_bauhaus_combobox_add(bd->raster_combo, _("no mask used"));
g_signal_connect(G_OBJECT(bd->raster_combo), "value-changed",
G_CALLBACK(_raster_value_changed_callback), module);
Expand Down Expand Up @@ -2655,7 +2655,7 @@ static GtkWidget *_combobox_new_from_list(dt_iop_module_t *module, const gchar *

if(field)
dt_bauhaus_widget_set_field(combo, field, DT_INTROSPECTION_TYPE_ENUM);
dt_bauhaus_widget_set_label(combo, N_("blend"), label);
dt_bauhaus_widget_set_label(combo, label);
gtk_widget_set_tooltip_text(combo, tooltip);
for(; *list->name; list++)
dt_bauhaus_combobox_add_full(combo, _(list->name), DT_BAUHAUS_COMBOBOX_ALIGN_RIGHT,
Expand Down Expand Up @@ -3060,7 +3060,7 @@ void dt_iop_gui_init_blending(GtkWidget *iopw, dt_iop_module_t *module)
bd->blend_modes_combo = dt_bauhaus_combobox_new(darktable.bauhaus, DT_GUI_MODULE(module));
dt_bauhaus_set_use_default_callback(bd->blend_modes_combo);
dt_bauhaus_disable_accels(bd->blend_modes_combo);
dt_bauhaus_widget_set_label(bd->blend_modes_combo, N_("blend"), N_("blend mode"));
dt_bauhaus_widget_set_label(bd->blend_modes_combo, N_("blend mode"));
gtk_widget_set_tooltip_text(bd->blend_modes_combo, _("choose blending mode"));

g_signal_connect(G_OBJECT(bd->blend_modes_combo), "value-changed",
Expand All @@ -3079,7 +3079,7 @@ void dt_iop_gui_init_blending(GtkWidget *iopw, dt_iop_module_t *module)
dt_bauhaus_set_use_default_callback(bd->blend_mode_parameter_slider);
dt_bauhaus_disable_accels(bd->blend_mode_parameter_slider);
dt_bauhaus_widget_set_field(bd->blend_mode_parameter_slider, &module->blend_params->blend_parameter, DT_INTROSPECTION_TYPE_FLOAT);
dt_bauhaus_widget_set_label(bd->blend_mode_parameter_slider, N_("blend"), N_("blend fulcrum"));
dt_bauhaus_widget_set_label(bd->blend_mode_parameter_slider, N_("blend fulcrum"));
dt_bauhaus_slider_set_format(bd->blend_mode_parameter_slider, _(" EV"));
dt_bauhaus_slider_set_soft_range(bd->blend_mode_parameter_slider, -3.0, 3.0);
gtk_widget_set_tooltip_text(bd->blend_mode_parameter_slider, _("adjust the fulcrum used by some blending"
Expand All @@ -3090,7 +3090,7 @@ void dt_iop_gui_init_blending(GtkWidget *iopw, dt_iop_module_t *module)
dt_bauhaus_set_use_default_callback(bd->opacity_slider);
dt_bauhaus_disable_accels(bd->opacity_slider);
dt_bauhaus_widget_set_field(bd->opacity_slider, &module->blend_params->opacity, DT_INTROSPECTION_TYPE_FLOAT);
dt_bauhaus_widget_set_label(bd->opacity_slider, N_("blend"), N_("opacity"));
dt_bauhaus_widget_set_label(bd->opacity_slider, N_("opacity"));
dt_bauhaus_slider_set_format(bd->opacity_slider, "%");
module->fusion_slider = bd->opacity_slider;
gtk_widget_set_tooltip_text(bd->opacity_slider, _("set the opacity of the blending"));
Expand All @@ -3109,7 +3109,7 @@ void dt_iop_gui_init_blending(GtkWidget *iopw, dt_iop_module_t *module)
bd->details_slider = dt_bauhaus_slider_new_with_range(darktable.bauhaus, DT_GUI_MODULE(module), -1.0f, 1.0f, 0, 0.0f, 2);
dt_bauhaus_set_use_default_callback(bd->details_slider);
dt_bauhaus_disable_accels(bd->details_slider);
dt_bauhaus_widget_set_label(bd->details_slider, N_("blend"), N_("details threshold"));
dt_bauhaus_widget_set_label(bd->details_slider, N_("details threshold"));
dt_bauhaus_slider_set_format(bd->details_slider, "%");
gtk_widget_set_tooltip_text(bd->details_slider, _("adjust the threshold for the details mask (using raw data), "
"\npositive values selects areas with strong details, "
Expand All @@ -3125,23 +3125,23 @@ void dt_iop_gui_init_blending(GtkWidget *iopw, dt_iop_module_t *module)
dt_bauhaus_set_use_default_callback(bd->feathering_radius_slider);
dt_bauhaus_disable_accels(bd->feathering_radius_slider);
dt_bauhaus_widget_set_field(bd->feathering_radius_slider, &module->blend_params->feathering_radius, DT_INTROSPECTION_TYPE_FLOAT);
dt_bauhaus_widget_set_label(bd->feathering_radius_slider, N_("blend"), N_("feathering radius"));
dt_bauhaus_widget_set_label(bd->feathering_radius_slider, N_("feathering radius"));
dt_bauhaus_slider_set_format(bd->feathering_radius_slider, " px");
gtk_widget_set_tooltip_text(bd->feathering_radius_slider, _("spatial radius of feathering"));

bd->blur_radius_slider = dt_bauhaus_slider_new_with_range(darktable.bauhaus, DT_GUI_MODULE(module), 0.0, 100.0, 0, 0.0, 1);
dt_bauhaus_set_use_default_callback(bd->blur_radius_slider);
dt_bauhaus_disable_accels(bd->blur_radius_slider);
dt_bauhaus_widget_set_field(bd->blur_radius_slider, &module->blend_params->blur_radius, DT_INTROSPECTION_TYPE_FLOAT);
dt_bauhaus_widget_set_label(bd->blur_radius_slider, N_("blend"), N_("blurring radius"));
dt_bauhaus_widget_set_label(bd->blur_radius_slider, N_("blurring radius"));
dt_bauhaus_slider_set_format(bd->blur_radius_slider, " px");
gtk_widget_set_tooltip_text(bd->blur_radius_slider, _("radius for gaussian blur of blend mask"));

bd->brightness_slider = dt_bauhaus_slider_new_with_range(darktable.bauhaus, DT_GUI_MODULE(module), -1.0, 1.0, 0, 0.0, 2);
dt_bauhaus_set_use_default_callback(bd->brightness_slider);
dt_bauhaus_disable_accels(bd->brightness_slider);
dt_bauhaus_widget_set_field(bd->brightness_slider, &module->blend_params->brightness, DT_INTROSPECTION_TYPE_FLOAT);
dt_bauhaus_widget_set_label(bd->brightness_slider, N_("blend"), N_("mask opacity"));
dt_bauhaus_widget_set_label(bd->brightness_slider, N_("mask opacity"));
dt_bauhaus_slider_set_format(bd->brightness_slider, "%");
gtk_widget_set_tooltip_text(bd->brightness_slider, _("shifts and tilts the tone curve of the blend mask to adjust its "
"brightness without affecting fully transparent/fully opaque "
Expand All @@ -3151,7 +3151,7 @@ void dt_iop_gui_init_blending(GtkWidget *iopw, dt_iop_module_t *module)
dt_bauhaus_set_use_default_callback(bd->contrast_slider);
dt_bauhaus_disable_accels(bd->contrast_slider);
dt_bauhaus_widget_set_field(bd->contrast_slider, &module->blend_params->contrast, DT_INTROSPECTION_TYPE_FLOAT);
dt_bauhaus_widget_set_label(bd->contrast_slider, N_("blend"), N_("mask contrast"));
dt_bauhaus_widget_set_label(bd->contrast_slider, N_("mask contrast"));
dt_bauhaus_slider_set_format(bd->contrast_slider, "%");
gtk_widget_set_tooltip_text(bd->contrast_slider, _("gives the tone curve of the blend mask an s-like shape to "
"adjust its contrast"));
Expand Down
16 changes: 8 additions & 8 deletions src/develop/imageop_gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ GtkWidget *dt_bauhaus_slider_from_params(dt_iop_module_t *self, const char *para
if (*f->header.description)
{
// we do not want to support a context as it break all translations see #5498
// dt_bauhaus_widget_set_label(slider, NULL, g_dpgettext2(NULL, "introspection description", f->header.description));
dt_bauhaus_widget_set_label(slider, NULL, f->header.description);
// dt_bauhaus_widget_set_label(slider, g_dpgettext2(NULL, "introspection description", f->header.description));
dt_bauhaus_widget_set_label(slider, f->header.description);
}
else
{
gchar *str = dt_util_str_replace(f->header.field_name, "_", " ");

dt_bauhaus_widget_set_label(slider, NULL, str);
dt_bauhaus_widget_set_label(slider, str);

g_free(str);
}
Expand All @@ -150,7 +150,7 @@ GtkWidget *dt_bauhaus_slider_from_params(dt_iop_module_t *self, const char *para
gchar *str = g_strdup_printf("'%s' is not a float/int/unsigned short/slider parameter", param_name);

slider = dt_bauhaus_slider_new(darktable.bauhaus, DT_GUI_MODULE(self));
dt_bauhaus_widget_set_label(slider, NULL, str);
dt_bauhaus_widget_set_label(slider, str);

g_free(str);
}
Expand Down Expand Up @@ -184,14 +184,14 @@ GtkWidget *dt_bauhaus_combobox_from_params(dt_iop_module_t *self, const char *pa
if (*f->header.description)
{
// we do not want to support a context as it break all translations see #5498
// dt_bauhaus_widget_set_label(combobox, NULL, g_dpgettext2(NULL, "introspection description", f->header.description));
dt_bauhaus_widget_set_label(combobox, NULL, f->header.description);
// dt_bauhaus_widget_set_label(combobox, g_dpgettext2(NULL, "introspection description", f->header.description));
dt_bauhaus_widget_set_label(combobox, f->header.description);
}
else
{
str = dt_util_str_replace(f->header.field_name, "_", " ");

dt_bauhaus_widget_set_label(combobox, NULL, str);
dt_bauhaus_widget_set_label(combobox, str);

g_free(str);
}
Expand All @@ -216,7 +216,7 @@ GtkWidget *dt_bauhaus_combobox_from_params(dt_iop_module_t *self, const char *pa
{
str = g_strdup_printf("'%s' is not an enum/int/bool/combobox parameter", param);

dt_bauhaus_widget_set_label(combobox, NULL, str);
dt_bauhaus_widget_set_label(combobox, str);

g_free(str);
}
Expand Down
Loading

0 comments on commit 427a5ee

Please sign in to comment.