Skip to content

Commit

Permalink
add busy cursors to history paste/compress/discard
Browse files Browse the repository at this point in the history
Also add a verification popup if the operation is being applied to
1000 or more images.
  • Loading branch information
ralfbrown committed Aug 9, 2024
1 parent f6028c7 commit c708078
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 15 deletions.
9 changes: 8 additions & 1 deletion src/common/history.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "develop/blend.h"
#include "develop/develop.h"
#include "develop/masks.h"
#include "gui/gtk.h"
#include "gui/hist_dialog.h"
#include "imageio/imageio_common.h"

Expand Down Expand Up @@ -1371,6 +1372,7 @@ int dt_history_compress_on_list(const GList *imgs)
{
int uncompressed=0;

dt_gui_cursor_set_busy();
// Get the list of selected images
for(const GList *l = imgs; l; l = g_list_next(l))
{
Expand Down Expand Up @@ -1446,6 +1448,7 @@ int dt_history_compress_on_list(const GList *imgs)
dt_history_hash_write_from_history(imgid, DT_HISTORY_HASH_CURRENT);
}

dt_gui_cursor_clear_busy();
return uncompressed;
}

Expand Down Expand Up @@ -1904,6 +1907,7 @@ gboolean dt_history_paste_on_list(const GList *list,
if(undo)
dt_undo_start_group(darktable.undo, DT_UNDO_LT_HISTORY);

dt_gui_cursor_set_busy();
for(GList *l = (GList *)list; l; l = g_list_next(l))
{
const int dest = GPOINTER_TO_INT(l->data);
Expand All @@ -1923,6 +1927,7 @@ gboolean dt_history_paste_on_list(const GList *list,
{
dt_dev_pixelpipe_rebuild(darktable.develop);
}
dt_gui_cursor_clear_busy();

return TRUE;
}
Expand Down Expand Up @@ -1955,6 +1960,7 @@ gboolean dt_history_paste_parts_on_list(const GList *list,
return FALSE;
}

dt_gui_cursor_set_busy();
if(undo)
dt_undo_start_group(darktable.undo, DT_UNDO_LT_HISTORY);

Expand All @@ -1980,7 +1986,7 @@ gboolean dt_history_paste_parts_on_list(const GList *list,
{
dt_dev_pixelpipe_rebuild(darktable.develop);
}

dt_gui_cursor_clear_busy();
return TRUE;
}

Expand All @@ -1992,6 +1998,7 @@ gboolean dt_history_delete_on_list(const GList *list,

dt_gui_cursor_set_busy();
if(undo) dt_undo_start_group(darktable.undo, DT_UNDO_LT_HISTORY);
dt_gui_process_events();

for(GList *l = (GList *)list; l; l = g_list_next(l))
{
Expand Down
87 changes: 73 additions & 14 deletions src/libs/copy_history.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@

DT_MODULE(1)

// get confirmation if user asks to apply a history operation to at least this many images
#define MIN_ASK_IMAGES 1000

typedef enum dt_history_copy_mode_t
{
DT_COPY_HISTORY_APPEND = 0,
Expand Down Expand Up @@ -204,10 +207,28 @@ static void compress_button_clicked(GtkWidget *widget, gpointer user_data)
GList *imgs = dt_act_on_get_images(TRUE, TRUE, FALSE);
if(!imgs) return; // do nothing if no images to be acted on

const int missing = dt_history_compress_on_list(imgs);

dt_collection_update_query(darktable.collection,
DT_COLLECTION_CHANGE_RELOAD, DT_COLLECTION_PROP_UNDEF, imgs);
const int number = g_list_length((GList *)imgs);
int missing = 0;
if(number < MIN_ASK_IMAGES
|| dt_gui_show_yes_no_dialog(_("compress image histories?"),
_("do you really want to compress history for %d selected images?"),
number))
{
if(number >= MIN_ASK_IMAGES)
{
// ensure that the dialog is removed from the screen
dt_gui_process_events();
g_usleep(200000); // wait 0.2 seconds
dt_gui_process_events();
}
missing = dt_history_compress_on_list(imgs);
dt_collection_update_query(darktable.collection,
DT_COLLECTION_CHANGE_RELOAD, DT_COLLECTION_PROP_UNDEF, imgs);
}
else
{
g_list_free(imgs);
}
dt_control_queue_redraw_center();
if(missing)
dt_control_log(ngettext("no history compression of %d image",
Expand Down Expand Up @@ -259,6 +280,9 @@ static void discard_button_clicked(GtkWidget *widget, gpointer user_data)
if(ask && number > 10)
{
// ensure that the dialog window gets hidden on click
dt_gui_process_events();
g_usleep(100000);
dt_gui_process_events();
dt_control_queue_redraw_center();
dt_gui_process_events();
}
Expand Down Expand Up @@ -289,14 +313,32 @@ static void paste_button_clicked(GtkWidget *widget, gpointer user_data)

dt_conf_set_int("plugins/lighttable/copy_history/pastemode", mode);

/* copy history from previously copied image and past onto selection */
/* copy history from previously copied image and paste onto selection */
GList *imgs = dt_act_on_get_images(TRUE, TRUE, FALSE);

if(dt_history_paste_on_list(imgs, TRUE))
const int number = g_list_length((GList *)imgs);
if(number < MIN_ASK_IMAGES
|| dt_gui_show_yes_no_dialog(_("paste to images?"),
_("do you really want to paste history to %d selected images?"),
number))
{
dt_collection_update_query(darktable.collection,
DT_COLLECTION_CHANGE_RELOAD,
DT_COLLECTION_PROP_UNDEF, imgs);
if(number >= MIN_ASK_IMAGES)
{
// ensure that the dialog is removed from the screen
dt_gui_process_events();
g_usleep(200000); // wait 0.2 seconds
dt_gui_process_events();
}
if(dt_history_paste_on_list(imgs, TRUE))
{
dt_collection_update_query(darktable.collection,
DT_COLLECTION_CHANGE_RELOAD,
DT_COLLECTION_PROP_UNDEF, imgs);
}
else
{
g_list_free(imgs);
}
}
else
{
Expand All @@ -311,12 +353,29 @@ static void paste_parts_button_clicked(GtkWidget *widget, gpointer user_data)
{
/* copy history from previously copied image and past onto selection */
GList *imgs = dt_act_on_get_images(TRUE, TRUE, FALSE);

if(dt_history_paste_parts_on_list(imgs, TRUE))
const int number = g_list_length((GList *)imgs);
if(number < MIN_ASK_IMAGES
|| dt_gui_show_yes_no_dialog(_("paste to images?"),
_("do you really want to paste history to %d selected images?"),
number))
{
dt_collection_update_query(darktable.collection,
DT_COLLECTION_CHANGE_RELOAD, DT_COLLECTION_PROP_UNDEF,
imgs); // frees imgs
if(number >= MIN_ASK_IMAGES)
{
// ensure that the dialog is removed from the screen
dt_gui_process_events();
g_usleep(200000); // wait 0.2 seconds
dt_gui_process_events();
}
if(dt_history_paste_parts_on_list(imgs, TRUE))
{
dt_collection_update_query(darktable.collection,
DT_COLLECTION_CHANGE_RELOAD, DT_COLLECTION_PROP_UNDEF,
imgs); // frees imgs
}
else
{
g_list_free(imgs);
}
}
else
{
Expand Down

0 comments on commit c708078

Please sign in to comment.