Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
history_actions_gui.c
Go to the documentation of this file.
1/*
2 This file is part of Ansel,
3 Copyright (C) 2026 Aurélien PIERRE.
4
5 Ansel is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 Ansel is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with Ansel. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19/* The three history actions that need to ask the user something.
20 *
21 * They were in common/history_actions.c, which is otherwise pure backend -- and were the
22 * only reason it included gui/hist_dialog.h, gui/gtk.h and gui/actions/menu.h. Nothing
23 * about them is shared with the batch machinery there: two open the module-picker dialog
24 * and store its answer in the copy/paste proxy, the third is a GtkAccelGroup accelerator.
25 *
26 * Every caller already lives at or above this layer (gui/actions/edit.c, libs/history.c),
27 * so this is a relocation, not an inversion: no handler slot is needed.
28 */
29
31
32#include "common/act_on.h"
33#include "common/conf.h"
35#include "system/macros.h"
36#include "control/control.h"
37#include "develop/develop.h"
38#include "develop/dev_history.h"
39#include "gui/actions/menu.h"
40#include "gui/application.h"
41#include "gui/hist_dialog.h"
42#include "views/view.h"
43
44#include <glib/gi18n.h>
45#include "widgets/dialog.h"
46
47#ifdef GDK_WINDOWING_QUARTZ
48#include "osx/osx.h"
49#endif
50
51gboolean dt_history_copy_parts(int32_t imgid)
52{
53 if(dt_history_copy(imgid))
54 {
55 // run dialog, it will insert into selops the selected moduel
56
58 return FALSE;
59 return TRUE;
60 }
61 else
62 return FALSE;
63}
64
65
67{
69 if(copy_paste->copied_imageid <= 0) return FALSE;
70
71 // we launch the dialog
72 const int res = dt_gui_hist_dialog_new(copy_paste, copy_paste->copied_imageid, FALSE);
73
74 if(res != GTK_RESPONSE_OK)
75 {
76 return FALSE;
77 }
78
79 return TRUE;
80}
81
82
83gboolean delete_history_callback(GtkAccelGroup *group, GObject *acceleratable, guint keyval, GdkModifierType mods, gpointer user_data)
84{
85 if(!has_active_images()) return FALSE;
86
88 if(IS_NULL_PTR(imgs)) return FALSE;
89
90 if(dt_conf_get_bool("ask_before_discard"))
91 {
92 const int img_count = g_list_length(imgs);
96 ngettext("Do you really want to clear history of %d image?",
97 "Do you really want to clear history of %d images?", img_count),
98 img_count);
99#ifdef GDK_WINDOWING_QUARTZ
101#endif
102 gtk_window_set_title(GTK_WINDOW(dialog), ngettext("Delete image's history?", "Delete images' history?", img_count));
103
107 _("when unchecked, history will be deleted silently from now on without this confirmation.\n"
108 "you can turn it back on from preferences."));
112
113 const gint res = gtk_dialog_run(GTK_DIALOG(dialog));
115 gtk_widget_destroy(dialog);
117 if(res != GTK_RESPONSE_YES)
118 {
119 g_list_free(imgs);
120 return TRUE;
121 }
122 }
123
125
127
129 {
131 }
132
134
136 {
139 }
140
142 g_list_free(imgs);
143 imgs = NULL;
144 return TRUE;
145}
146
147
148// clang-format off
149// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
150// vim: shiftwidth=2 expandtab tabstop=2 cindent
151// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
152// clang-format on
GList * dt_act_on_get_images()
Definition act_on.c:38
GtkWidget * dt_gui_main_window(void)
#define TRUE
Definition ashift_lsd.c:162
#define FALSE
Definition ashift_lsd.c:158
struct _GtkWidget GtkWidget
GtkWidget, opaque, spelled exactly as GTK spells it.
Definition colorspaces.h:98
void dt_conf_set_bool(const char *name, int val)
int dt_conf_get_bool(const char *name)
void dt_control_queue_redraw_center()
request redraw of center window. This redraws the center view within a gdk critical section to preven...
Definition control.c:874
struct dt_develop_t * dt_dev_get_global(void)
Definition darktable.c:528
void dt_apply_dev_history_update(dt_develop_t *dev)
Reload the current darkroom history and refresh every dependent GUI.
gboolean dt_dev_history_is_image_in_dev(GList *imgs)
Check whether any image of the list is the one currently loaded in the darkroom.
void dt_dev_undo_start_record(dt_develop_t *dev)
Definition develop.c:1742
void dt_dev_undo_end_record(dt_develop_t *dev)
Definition develop.c:1753
void dt_gui_refocus_parent(GtkWindow *parent)
Definition dialog.c:64
int dt_gui_hist_dialog_new(dt_history_copy_item_t *d, int32_t imgid, gboolean iscopy)
gboolean dt_history_copy(int32_t imgid)
dt_history_copy_item_t * dt_history_copy_paste_get(void)
The history clipboard: what "copy history" put there, for "paste" to read.
gboolean dt_history_delete_on_list(const GList *list, gboolean undo)
gboolean delete_history_callback(GtkAccelGroup *group, GObject *acceleratable, guint keyval, GdkModifierType mods, gpointer user_data)
gboolean dt_history_paste_parts_prepare(void)
gboolean dt_history_copy_parts(int32_t imgid)
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
Definition macros.h:65
gboolean has_active_images()
Definition menu.c:633
void dt_osx_disallow_fullscreen(GtkWidget *widget)
Definition osx.mm:105