Skip to content

Commit

Permalink
prepare to migrate box
Browse files Browse the repository at this point in the history
  • Loading branch information
dterrahe committed Jan 23, 2025
1 parent fb22287 commit 49c34b6
Show file tree
Hide file tree
Showing 42 changed files with 286 additions and 621 deletions.
39 changes: 14 additions & 25 deletions src/develop/blend_gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -2681,9 +2681,7 @@ void dt_iop_gui_init_blendif(GtkWidget *blendw, dt_iop_module_t *module)
g_signal_connect(G_OBJECT(sl->polarity), "toggled",
G_CALLBACK(_blendop_blendif_polarity_callback), bd);

sl->box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, DT_BAUHAUS_SPACE));
gtk_box_pack_start(GTK_BOX(sl->box), GTK_WIDGET(label_box), TRUE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(sl->box), GTK_WIDGET(slider_box), TRUE, FALSE, 0);
sl->box = GTK_BOX(dt_gui_vbox(label_box, slider_box));
gtk_box_pack_start(GTK_BOX(bd->blendif_box), GTK_WIDGET(sl->box), TRUE, FALSE, 0);
}

Expand Down Expand Up @@ -3722,34 +3720,25 @@ void dt_iop_gui_init_blending(GtkWidget *iopw,
dt_gui_add_help_link(GTK_WIDGET(bd->masks_modes_box), "masks_blending");
gtk_widget_set_name(GTK_WIDGET(bd->masks_modes_box), "blending-tabs");

bd->top_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
gtk_box_pack_start(GTK_BOX(bd->top_box), gbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(bd->top_box), blend_modes_hbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(bd->top_box), bd->blend_mode_parameter_slider, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(bd->top_box), bd->opacity_slider, TRUE, TRUE, 0);
bd->top_box = GTK_BOX(dt_gui_vbox
(gbox,
blend_modes_hbox,
bd->blend_mode_parameter_slider,
bd->opacity_slider));
_add_wrapped_box(box, bd->top_box, NULL);

dt_iop_gui_init_masks(iopw, module);
dt_iop_gui_init_raster(iopw, module);
dt_iop_gui_init_blendif(iopw, module);

bd->bottom_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
gtk_box_pack_start(GTK_BOX(bd->bottom_box),
GTK_WIDGET(bd->masks_combine_combo), TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(bd->bottom_box),
hbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(bd->bottom_box),
bd->details_slider, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(bd->bottom_box),
bd->masks_feathering_guide_combo, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(bd->bottom_box),
bd->feathering_radius_slider, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(bd->bottom_box),
bd->blur_radius_slider, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(bd->bottom_box),
bd->brightness_slider, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(bd->bottom_box),
bd->contrast_slider, TRUE, TRUE, 0);
bd->bottom_box = GTK_BOX(dt_gui_vbox
(bd->masks_combine_combo, hbox,
bd->details_slider,
bd->masks_feathering_guide_combo,
bd->feathering_radius_slider,
bd->blur_radius_slider,
bd->brightness_slider,
bd->contrast_slider));
_add_wrapped_box(iopw, bd->bottom_box, "masks_refinement");

gtk_widget_set_name(GTK_WIDGET(bd->top_box), "blending-box");
Expand Down
6 changes: 3 additions & 3 deletions src/develop/imageop_gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ GtkWidget *dt_bauhaus_slider_from_params(dt_iop_module_t *self, const char *para
}

if(!self->widget) self->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, DT_BAUHAUS_SPACE);
gtk_box_pack_start(GTK_BOX(self->widget), slider, FALSE, FALSE, 0);
dt_gui_box_add(self->widget, slider);

g_free(param_name);

Expand Down Expand Up @@ -230,7 +230,7 @@ GtkWidget *dt_bauhaus_combobox_from_params(dt_iop_module_t *self, const char *pa
g_free(str);

if(!self->widget) self->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, DT_BAUHAUS_SPACE);
gtk_box_pack_start(GTK_BOX(self->widget), combobox, FALSE, FALSE, 0);
dt_gui_box_add(self->widget, combobox);

return combobox;
}
Expand Down Expand Up @@ -274,7 +274,7 @@ GtkWidget *dt_bauhaus_toggle_from_params(dt_iop_module_t *self, const char *para

g_free(str);
if(!self->widget) self->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, DT_BAUHAUS_SPACE);
gtk_box_pack_start(GTK_BOX(self->widget), button, FALSE, FALSE, 0);
dt_gui_box_add(self->widget, button);

return button;
}
Expand Down
2 changes: 2 additions & 0 deletions src/gui/accelerators.c
Original file line number Diff line number Diff line change
Expand Up @@ -5145,6 +5145,7 @@ GtkWidget *dt_action_button_new(dt_lib_module_t *self,
GdkModifierType mods)
{
GtkWidget *button = gtk_button_new_with_label(Q_(label));
gtk_widget_set_hexpand(button, TRUE);
gtk_label_set_ellipsize(GTK_LABEL(gtk_bin_get_child(GTK_BIN(button))),
PANGO_ELLIPSIZE_END);
if(tooltip) gtk_widget_set_tooltip_text(button, tooltip);
Expand All @@ -5171,6 +5172,7 @@ GtkWidget *dt_action_entry_new(dt_action_t *ac,
const gchar *text)
{
GtkWidget *entry = dt_ui_entry_new(5);
gtk_widget_set_hexpand(entry, TRUE);
if(text)
gtk_entry_set_text (GTK_ENTRY(entry), text);
if(tooltip)
Expand Down
14 changes: 14 additions & 0 deletions src/gui/gtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -4541,6 +4541,20 @@ void dt_gui_simulate_button_event(GtkWidget *widget,
}
}

GtkWidget *(dt_gui_box_add)(const char *file, const int line, const char *function, GtkBox *box, gpointer list[])
{
int i = 1;
for(; *list != (gpointer)-1; list++, i++)
{
if(GTK_IS_WIDGET(*list))
gtk_container_add(GTK_CONTAINER(box), GTK_WIDGET(*list));
else
dt_print(DT_DEBUG_ALWAYS, "%s:%d %s: trying to add invalid widget to box (#%d)", file, line, function, i);
}

return GTK_WIDGET(box);
}

// 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
21 changes: 18 additions & 3 deletions src/gui/gtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,7 @@ static inline GtkWidget *dt_ui_section_label_new(const gchar *str)
static inline GtkWidget *dt_ui_label_new(const gchar *str)
{
GtkWidget *label = gtk_label_new(str);
gtk_widget_set_halign(label, GTK_ALIGN_START);
gtk_label_set_xalign (GTK_LABEL(label), 0.0f);
gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_END);
g_object_set(label, "halign", GTK_ALIGN_START, "xalign", 0.0f, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
return label;
};

Expand Down Expand Up @@ -547,6 +545,23 @@ void dt_gui_cursor_clear_busy();
// (i.e. the current function will do a lot of work before returning)
void dt_gui_process_events();

GtkWidget *(dt_gui_box_add)(const char *file, const int line, const char *function, GtkBox *box, gpointer list[]);
#define dt_gui_box_add(box, ...) dt_gui_box_add(__FILE__, __LINE__, __FUNCTION__, GTK_BOX(box), (gpointer[]){ __VA_ARGS__, (gpointer)-1 })
#define dt_gui_hbox(...) dt_gui_box_add(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0), __VA_ARGS__)
#define dt_gui_vbox(...) dt_gui_box_add(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0), __VA_ARGS__)

static inline GtkWidget *dt_gui_expand(GtkWidget *widget)
{
gtk_widget_set_hexpand(widget, TRUE);
return widget;
}

static inline GtkWidget *dt_gui_right(GtkWidget *widget)
{
gtk_widget_set_halign(widget, GTK_ALIGN_END);
return dt_gui_expand(widget);
}

// Simulate a mouse button event (button is 1, 2, 3 - mouse button) sent to a Widget
void dt_gui_simulate_button_event(GtkWidget *widget,
const GdkEventType eventtype,
Expand Down
61 changes: 18 additions & 43 deletions src/gui/splash.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static GtkWidget *splash_screen = NULL;
static GtkWidget *progress_text = NULL;
static GtkWidget *remaining_text = NULL;
static gboolean showing_remaining = FALSE;
static GtkBox *remaining_box = NULL;
static GtkWidget *remaining_box = NULL;

static GtkWidget *exit_screen = NULL;

Expand Down Expand Up @@ -177,15 +177,14 @@ void darktable_splash_screen_create(GtkWindow *parent_window,
GtkWidget *logo = _get_logo();
GtkWidget *program_name = _get_program_name();
GtkBox *content = GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(splash_screen)));
GtkBox *main_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));

#ifdef USE_FEATURED_IMAGE
// make a random selection of featured image based on the current
// time
const int imgnum = (int)(1 + (clock()%MAX_IMAGES));
//FIXME: if user overrides --datadir, we won't find the image...
image_file = g_strdup_printf("%s/pixmaps/splashscreen-%02d.jpg",
darktable.datadir, imgnum);
gchar *image_file = g_strdup_printf("%s/pixmaps/splashscreen-%02d.jpg",
darktable.datadir, imgnum);
GtkWidget *image = gtk_image_new_from_file(image_file);
g_free(image_file);
gtk_widget_set_name(GTK_WIDGET(image), "splashscreen-image");
Expand All @@ -195,63 +194,39 @@ void darktable_splash_screen_create(GtkWindow *parent_window,
GTK_WIDGET(gtk_label_new(_("Photography workflow\napplication and\nRAW developer")));
gtk_label_set_justify(GTK_LABEL(program_desc), GTK_JUSTIFY_CENTER);
gtk_widget_set_name(program_desc, "splashscreen-description");
GtkBox *title_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
gtk_box_pack_start(title_box, logo, FALSE, FALSE, 0);
gtk_box_pack_start(title_box, version, FALSE, FALSE, 0);
gtk_box_pack_start(title_box, program_name, FALSE, FALSE, 0);
gtk_box_pack_start(title_box, program_desc, FALSE, FALSE, 0);
// now put the featured image to the right of the logo/name/description
gtk_box_pack_start(main_box, GTK_WIDGET(title_box), FALSE, FALSE, 0);
gtk_box_pack_start(main_box, image, FALSE, FALSE, 0);
gtk_box_pack_start(content, GTK_WIDGET(main_box), FALSE, FALSE, 0);

dt_gui_box_add(content, dt_gui_hbox(dt_gui_vbox(logo, version, program_name, program_desc), image));
#else
// put the darktable logo and version number together
GtkBox *logo_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
gtk_image_set_pixel_size(GTK_IMAGE(logo), 220);
gtk_label_set_justify(GTK_LABEL(version), GTK_JUSTIFY_LEFT);
gtk_box_pack_start(logo_box, logo, FALSE, FALSE, 0);
gtk_box_pack_start(logo_box, version, FALSE, FALSE, 0);
gtk_box_pack_start(logo_box, copyright, FALSE, FALSE, 0);

// put the darktable wordmark and description in a vertical stack
GtkWidget *program_desc = GTK_WIDGET(gtk_label_new(_("Photography workflow application\nand RAW developer")));
gtk_label_set_justify(GTK_LABEL(program_desc), GTK_JUSTIFY_RIGHT);
gtk_widget_set_halign(program_desc, GTK_ALIGN_END);
gtk_widget_set_name(program_desc, "splashscreen-description");
GtkWidget *desc_padding = gtk_label_new(NULL);
GtkBox *desc_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
gtk_box_pack_end(desc_box, desc_padding, FALSE, FALSE, 0);
gtk_box_pack_end(desc_box, program_desc, FALSE, FALSE, 0);
GtkBox *text_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
GtkWidget *padding1 = gtk_label_new(NULL); // ensure that text is vertically centered
GtkWidget *padding2 = gtk_label_new(""); // with respect to logo

GtkWidget *prepare = gtk_label_new(_("get ready to unleash your creativity"));
gtk_widget_set_name(prepare, "splashscreen-prepare");
gtk_box_pack_start(text_box, padding1, TRUE, TRUE, 0);
gtk_box_pack_start(text_box, program_name, FALSE, FALSE, 0);
gtk_box_pack_start(text_box, GTK_WIDGET(desc_box), FALSE, FALSE, 0);
gtk_box_pack_start(text_box, padding2, TRUE, TRUE, 0);
gtk_box_pack_start(text_box, prepare, FALSE, FALSE, 0);
// put the text to the right of the logo/version
gtk_box_pack_start(main_box, GTK_WIDGET(logo_box), FALSE, FALSE, 0);
gtk_box_pack_start(main_box, GTK_WIDGET(text_box), FALSE, FALSE, 0);
// and make that the top portion of the splash screen
gtk_box_pack_start(content, GTK_WIDGET(main_box), FALSE, FALSE, 0);

dt_gui_box_add(content,
dt_gui_hbox(dt_gui_vbox(logo, version, copyright),
dt_gui_vbox(gtk_label_new(NULL), program_name, program_desc, gtk_label_new(NULL), prepare)));
#endif

GtkWidget *hbar = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
gtk_widget_set_name(hbar, "splashscreen-separator");
gtk_widget_show(hbar);
gtk_box_pack_start(content, hbar, FALSE, FALSE, 0);
gtk_box_pack_start(content, progress_text, FALSE, FALSE, 0);

remaining_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
gtk_box_pack_start(remaining_box, dtgtk_button_new(dtgtk_cairo_paint_clock, 0, 0), FALSE, FALSE, 0);
gtk_box_pack_start(remaining_box, remaining_text, FALSE, FALSE, 0);
gtk_box_pack_start(content, GTK_WIDGET(remaining_box), FALSE, FALSE, 0);
remaining_box = dt_gui_hbox(dtgtk_button_new(dtgtk_cairo_paint_clock, 0, 0), remaining_text);
gtk_widget_set_halign(GTK_WIDGET(remaining_box), GTK_ALIGN_CENTER);

dt_gui_box_add(content, hbar, progress_text, remaining_box);

gtk_window_set_decorated(GTK_WINDOW(splash_screen), FALSE);
gtk_widget_show_all(splash_screen);
gtk_widget_hide(GTK_WIDGET(remaining_box));
gtk_widget_hide(remaining_box);
gtk_window_set_keep_above(GTK_WINDOW(splash_screen), TRUE);
_process_all_gui_events();
}
Expand All @@ -264,7 +239,7 @@ void darktable_splash_screen_set_progress(const char *msg)
gtk_widget_show(progress_text);
if(showing_remaining)
{
gtk_widget_hide(GTK_WIDGET(remaining_box));
gtk_widget_hide(remaining_box);
showing_remaining = FALSE;
}
_process_all_gui_events();
Expand All @@ -291,7 +266,7 @@ void darktable_splash_screen_set_progress_percent(const char *msg,
char *rem_text = g_strdup_printf(" %4d:%02d", minutes, seconds);
gtk_label_set_text(GTK_LABEL(remaining_text), rem_text);
g_free(rem_text);
gtk_widget_queue_draw(GTK_WIDGET(remaining_box));
gtk_widget_queue_draw(remaining_box);
}
else
{
Expand Down
22 changes: 3 additions & 19 deletions src/imageio/format/avif.c
Original file line number Diff line number Diff line change
Expand Up @@ -833,8 +833,6 @@ void gui_init(dt_imageio_module_format_t *self)

self->gui_data = (void *)gui;

self->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);

/*
* Bit depth combo box
*/
Expand All @@ -855,8 +853,6 @@ void gui_init(dt_imageio_module_format_t *self)
gtk_widget_set_tooltip_text(gui->bit_depth,
_("color information stored in an image, higher is better"));

gtk_box_pack_start(GTK_BOX(self->widget), gui->bit_depth, TRUE, TRUE, 0);

/*
* Color mode combo box
*/
Expand All @@ -867,8 +863,6 @@ void gui_init(dt_imageio_module_format_t *self)
dt_bauhaus_combobox_set_default(gui->color_mode,
dt_confgen_get_bool("plugins/imageio/format/avif/color_mode", DT_DEFAULT));

gtk_box_pack_start(GTK_BOX(self->widget), gui->color_mode, TRUE, TRUE, 0);

/*
* Tiling combo box
*/
Expand All @@ -878,11 +872,6 @@ void gui_init(dt_imageio_module_format_t *self)
"the loss of image quality is negligible."),
tiling, tiling_changed, self,
N_("on"), N_("off"));
gtk_box_pack_start(GTK_BOX(self->widget),
gui->tiling,
TRUE,
TRUE,
0);

/*
* Compression type combo box
Expand All @@ -903,12 +892,6 @@ void gui_init(dt_imageio_module_format_t *self)
dt_bauhaus_combobox_set_default(gui->compression_type,
dt_confgen_get_int("plugins/imageio/format/avif/compression_type", DT_DEFAULT));

gtk_box_pack_start(GTK_BOX(self->widget),
gui->compression_type,
TRUE,
TRUE,
0);

/*
* Quality combo box
*/
Expand All @@ -929,8 +912,6 @@ void gui_init(dt_imageio_module_format_t *self)

dt_bauhaus_slider_set(gui->quality, quality);

gtk_box_pack_start(GTK_BOX(self->widget), gui->quality, TRUE, TRUE, 0);

gtk_widget_set_visible(gui->quality, compression_type != AVIF_COMP_LOSSLESS);
gtk_widget_set_no_show_all(gui->quality, TRUE);

Expand All @@ -946,6 +927,9 @@ void gui_init(dt_imageio_module_format_t *self)
"value-changed",
G_CALLBACK(quality_changed),
NULL);

self->widget = dt_gui_vbox(gui->bit_depth, gui->color_mode, gui->tiling,
gui->compression_type, gui->quality);
}

void gui_cleanup(dt_imageio_module_format_t *self)
Expand Down
5 changes: 2 additions & 3 deletions src/imageio/format/j2k.c
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,6 @@ void gui_init(dt_imageio_module_format_t *self)
{
dt_imageio_j2k_gui_t *gui = malloc(sizeof(dt_imageio_j2k_gui_t));
self->gui_data = (void *)gui;
self->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);

const int preset_last = dt_conf_get_int("plugins/imageio/format/j2k/preset");
const int quality_last = dt_conf_get_int("plugins/imageio/format/j2k/quality");
Expand All @@ -673,7 +672,6 @@ void gui_init(dt_imageio_module_format_t *self)
0);
dt_bauhaus_widget_set_label(gui->quality, NULL, N_("quality"));
dt_bauhaus_slider_set(gui->quality, quality_last);
gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(gui->quality), TRUE, TRUE, 0);
g_signal_connect(G_OBJECT(gui->quality), "value-changed", G_CALLBACK(quality_changed), NULL);

DT_BAUHAUS_COMBOBOX_NEW_FULL(gui->preset, self, NULL, N_("DCP mode"), NULL,
Expand All @@ -682,7 +680,8 @@ void gui_init(dt_imageio_module_format_t *self)
N_("Cinema2K, 24FPS"),
N_("Cinema2K, 48FPS"),
N_("Cinema4K, 24FPS"));
gtk_box_pack_start(GTK_BOX(self->widget), gui->preset, TRUE, TRUE, 0);

self->widget = dt_gui_vbox(gui->quality, gui->preset);

// TODO: options for "off"
}
Expand Down
Loading

0 comments on commit 49c34b6

Please sign in to comment.