Skip to content

Commit 1c3533f

Browse files
committed
Fix copy/paste and module iop order setting.
The previous selection of iop-order in selective copy is not used as default when doing a full copy/paste. Also in non selective copy we now copy the module iop order. Related to #6528. Closes #22426.
1 parent 3fc4cfb commit 1c3533f

3 files changed

Lines changed: 33 additions & 40 deletions

File tree

‎RELEASE_NOTES.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ changes (where available).
153153
- Added a "copy to clipboard" export storage, which places the
154154
exported images on the system clipboard.
155155

156+
- In the "select parts to copy" and "select parts to paste" history
157+
dialogs, the module order is now a check box below the item list
158+
instead of a last entry in the list itself.
159+
156160
## Performance Improvements
157161

158162
- Replaced quadratic XMP history writes with a linear algorithm.
@@ -457,6 +461,9 @@ changes (where available).
457461
results depending on the number of CPU threads, and occasionally
458462
wrong colors near the left or right image edge.
459463

464+
- Copying a whole history stack no longer carries over the module order
465+
that was selected in an earlier "copy parts of the history" dialog.
466+
460467
## Lua
461468

462469
### API Version

‎src/common/history.c‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1951,8 +1951,14 @@ gboolean dt_history_copy(const dt_imgid_t imgid)
19511951
if(!dt_is_valid_imgid(imgid)) return FALSE;
19521952

19531953
darktable.view_manager->copy_paste.copied_imageid = imgid;
1954+
// a plain copy of the whole stack still has to skip the modules flagged as
1955+
// unsafe to copy, see dt_history_module_skip_copy(). Only a duplicate of the
1956+
// same image, where copy_full is passed explicitly, copies everything.
19541957
darktable.view_manager->copy_paste.full_copy = FALSE;
19551958

1959+
// in full copy mode, we also copy the module iop order
1960+
darktable.view_manager->copy_paste.copy_iop_order = TRUE;
1961+
19561962
if(darktable.view_manager->copy_paste.selops)
19571963
{
19581964
g_list_free(darktable.view_manager->copy_paste.selops);
@@ -1970,7 +1976,8 @@ gboolean dt_history_copy_parts(const dt_imgid_t imgid)
19701976
{
19711977
if(dt_history_copy(imgid))
19721978
{
1973-
// we want to copy all history and let user select the parts needed
1979+
// the user picks the modules in the dialog, so let anything they
1980+
// tick through.
19741981
darktable.view_manager->copy_paste.full_copy = TRUE;
19751982

19761983
// run dialog, it will insert into selops the selected module

‎src/gui/hist_dialog.c‎

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -41,29 +41,12 @@ typedef enum _style_items_columns_t
4141
DT_HIST_ITEMS_NUM_COLS
4242
} _styles_columns_t;
4343

44-
static gboolean _gui_hist_is_copy_module_order_set(dt_history_copy_item_t *d)
44+
static void _gui_hist_iop_order_toggled(GtkToggleButton *button,
45+
gpointer data)
4546
{
46-
/* iterate through TreeModel to find if module order was copied
47-
* (num=-1 and active) */
48-
GtkTreeIter iter;
49-
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(d->items));
50-
51-
gboolean active = FALSE;
52-
gboolean module_order_was_copied = FALSE;
53-
gint num = 0;
54-
55-
gtk_tree_model_get_iter_first(model, &iter);
56-
do
57-
{
58-
gtk_tree_model_get(model, &iter,
59-
DT_HIST_ITEMS_COL_ENABLED, &active,
60-
DT_HIST_ITEMS_COL_NUM, &num,
61-
-1);
62-
if(active && (num == -1)) module_order_was_copied = TRUE;
63-
}
64-
while(gtk_tree_model_iter_next(model, &iter));
47+
dt_history_copy_item_t *d = (dt_history_copy_item_t *)data;
6548

66-
return module_order_was_copied;
49+
d->copy_iop_order = gtk_toggle_button_get_active(button);
6750
}
6851

6952
static GList *_gui_hist_get_active_items(dt_history_copy_item_t *d)
@@ -86,7 +69,7 @@ static GList *_gui_hist_get_active_items(dt_history_copy_item_t *d)
8669
DT_HIST_ITEMS_COL_NUM, &num,
8770
-1);
8871

89-
if(active && num >= 0)
72+
if(active)
9073
result = g_list_prepend(result, GINT_TO_POINTER(autoinit ? -num : num));
9174

9275
} while(gtk_tree_model_iter_next(model, &iter));
@@ -130,13 +113,11 @@ static void _gui_hist_copy_response(GtkDialog *dialog,
130113

131114
case GTK_RESPONSE_OK:
132115
g->selops = _gui_hist_get_active_items(g);
133-
g->copy_iop_order = _gui_hist_is_copy_module_order_set(g);
134116
g->paste_mode = DT_HISTORY_COPY_APPEND;
135117
break;
136118

137119
case GTK_RESPONSE_APPLY:
138120
g->selops = _gui_hist_get_active_items(g);
139-
g->copy_iop_order = _gui_hist_is_copy_module_order_set(g);
140121
g->paste_mode = DT_HISTORY_COPY_OVERWRITE;
141122
break;
142123
}
@@ -352,21 +333,6 @@ int dt_gui_hist_dialog_new(dt_history_copy_item_t *d,
352333
}
353334
}
354335
g_list_free_full(items, dt_history_item_free);
355-
356-
/* last item is for copying the module order, or if paste and was selected */
357-
if(iscopy || d->copy_iop_order)
358-
{
359-
const dt_iop_order_t order = dt_ioppr_get_iop_order_version(imgid);
360-
char *label = g_strdup_printf("%s (%s)", _("module order"),
361-
dt_iop_order_string(order));
362-
gtk_list_store_insert_with_values(liststore, NULL, -1,
363-
DT_HIST_ITEMS_COL_ENABLED, d->copy_iop_order,
364-
DT_HIST_ITEMS_COL_ISACTIVE, is_active_pb,
365-
DT_HIST_ITEMS_COL_NAME, label,
366-
DT_HIST_ITEMS_COL_NUM, -1,
367-
-1);
368-
g_free(label);
369-
}
370336
}
371337
else
372338
{
@@ -378,6 +344,17 @@ int dt_gui_hist_dialog_new(dt_history_copy_item_t *d,
378344
G_CALLBACK(tree_on_row_activated), GTK_WIDGET(dialog));
379345
g_object_unref(liststore);
380346

347+
// the module order travels as a whole, not as one of the items above
348+
const dt_iop_order_t order = dt_ioppr_get_iop_order_version(imgid);
349+
char *label = g_strdup_printf("%s (%s)", _("module order"),
350+
dt_iop_order_string(order));
351+
GtkWidget *iop_order = gtk_check_button_new_with_label(label);
352+
g_free(label);
353+
354+
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(iop_order), d->copy_iop_order);
355+
g_signal_connect(iop_order, "toggled", G_CALLBACK(_gui_hist_iop_order_toggled), d);
356+
dt_gui_dialog_add(GTK_DIALOG(dialog), iop_order);
357+
381358
g_signal_connect(dialog, "response", G_CALLBACK(_gui_hist_copy_response), d);
382359

383360
gtk_widget_show_all(GTK_WIDGET(dialog));
@@ -404,6 +381,8 @@ void dt_gui_hist_dialog_init(dt_history_copy_item_t *d)
404381
d->selops = NULL;
405382
d->copied_imageid = NO_IMGID;
406383
d->copy_iop_order = FALSE;
384+
d->full_copy = FALSE;
385+
d->paste_mode = DT_HISTORY_COPY_APPEND;
407386
}
408387

409388
// clang-format off

0 commit comments

Comments
 (0)