33#include <glib/gi18n.h>
37#define DT_CLOSING_NOTICE_DELAY (G_USEC_PER_SEC)
39#define DT_CLOSING_POLL_INTERVAL 100
42#define DT_CLOSING_KIND_DARKROOM DT_JOB_QUEUE_MAX
84 g_main_loop_quit(closing->
loop);
105 _(
"Ansel is finishing its work before closing"));
111 gtk_widget_set_no_show_all(closing->
names,
TRUE);
115 "closes once the running ones are done.")
116 : _(
"This window closes by itself as soon as it is done."));
118 closing->
details = gtk_expander_new(_(
"Details"));
119 gtk_expander_set_resize_toplevel(GTK_EXPANDER(closing->
details),
TRUE);
120 gtk_widget_set_no_show_all(closing->
details,
TRUE);
125 g_object_unref(closing->
store);
126 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(
view),
FALSE);
127 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(
view)), GTK_SELECTION_NONE);
129 GtkCellRenderer *renderer = gtk_cell_renderer_text_new();
130 GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes(C_(
"closing jobs",
"Type"), renderer,
132 gtk_tree_view_append_column(GTK_TREE_VIEW(
view), column);
134 renderer = gtk_cell_renderer_text_new();
135 g_object_set(renderer,
"ellipsize", PANGO_ELLIPSIZE_END, NULL);
136 column = gtk_tree_view_column_new_with_attributes(C_(
"closing jobs",
"Description"), renderer,
"text",
138 gtk_tree_view_column_set_expand(column,
TRUE);
139 gtk_tree_view_append_column(GTK_TREE_VIEW(
view), column);
143 GtkWidget *scroll = gtk_scrolled_window_new(NULL, NULL);
145 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
146 gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(scroll),
DT_PIXEL_APPLY_DPI(420));
147 gtk_scrolled_window_set_max_content_height(GTK_SCROLLED_WINDOW(scroll),
DT_PIXEL_APPLY_DPI(300));
148 gtk_scrolled_window_set_propagate_natural_height(GTK_SCROLLED_WINDOW(scroll),
TRUE);
149 gtk_container_add(GTK_CONTAINER(scroll),
view);
151 closing->
dropped = gtk_label_new(NULL);
152 gtk_label_set_xalign(GTK_LABEL(closing->
dropped), 0.0);
153 gtk_widget_set_no_show_all(closing->
dropped,
TRUE);
157 gtk_box_pack_start(GTK_BOX(content), scroll,
FALSE,
FALSE, 0);
159 gtk_container_add(GTK_CONTAINER(closing->
details), content);
162 gtk_widget_show_all(content);
178 if(
names->len > 0) g_string_append_c(
names,
'\n');
179 gchar *
name = g_markup_printf_escaped(
"<i>%s</i>", message);
189 return C_(
"job type",
"Image operation");
191 return C_(
"job type",
"Thumbnail");
193 return C_(
"job type",
"Background task");
195 return C_(
"job type",
"Export");
197 return C_(
"job type",
"Maintenance");
199 return C_(
"job type",
"Darkroom rendering");
212 GArray *running = (GArray *)
data;
217 g_array_append_val(running, job);
231 for(guint
i = running->len;
i > 0;
i--)
233 g_array_remove_index(running,
i - 1);
235 GString *listed = g_string_new(NULL);
236 for(guint
i = 0;
i < running->len;
i++)
239 g_string_append_printf(listed,
"%d\t%s\n", job->
kind, job->
description);
242 if(g_strcmp0(listed->str, closing->
listed) != 0)
244 gtk_list_store_clear(closing->
store);
245 for(guint
i = 0;
i < running->len;
i++)
255 g_string_free(listed,
TRUE);
258 if(queued != closing->
queued)
261 ? g_strdup_printf(ngettext(
"%d other task, not started, would be dropped",
262 "%d other tasks, not started, would be dropped", queued),
264 : g_strdup_printf(ngettext(
"%d other task, not started, is dropped",
265 "%d other tasks, not started, are dropped", queued),
267 gtk_label_set_text(GTK_LABEL(closing->
dropped), dropped);
269 gtk_widget_set_visible(closing->
dropped, queued > 0);
273 gtk_widget_set_visible(closing->
details, running->len > 0 || queued > 0);
274 g_array_free(running,
TRUE);
286 (*(int32_t *)
data)++;
302 const int32_t running
304 gchar *count = g_strdup_printf(ngettext(
"%d task is still running",
"%d tasks are still running", running),
306 gtk_label_set_text(GTK_LABEL(closing->
count), count);
309 GString *
names = g_string_new(NULL);
311 gtk_label_set_markup(GTK_LABEL(closing->
names),
names->str);
312 gtk_widget_set_visible(closing->
names,
names->len > 0);
323 g_main_loop_quit(closing->
loop);
324 return G_SOURCE_REMOVE;
334 return G_SOURCE_CONTINUE;
350 return G_SOURCE_CONTINUE;
353 return G_SOURCE_CONTINUE;
364 static gboolean asking =
FALSE;
365 if(asking)
return FALSE;
372 g_main_loop_run(closing.
loop);
373 g_source_remove(poll);
374 g_main_loop_unref(closing.
loop);
400 gtk_widget_realize(grab);
404 .start = g_get_monotonic_time(), .queued = -1 };
406 g_main_loop_run(closing.
loop);
407 g_main_loop_unref(closing.
loop);
409 gtk_grab_remove(grab);
410 gtk_widget_destroy(grab);
413 (g_get_monotonic_time() - closing.
start) / (
double)G_USEC_PER_SEC);
void dt_gui_alert_destroy(dt_gui_alert_t *alert)
dt_gui_alert_t * dt_gui_alert_new(const dt_gui_alert_kind_t kind, const char *title, const char *heading)
void dt_gui_alert_add_widget(dt_gui_alert_t *alert, GtkWidget *widget)
GtkWidget * dt_gui_alert_add_text(dt_gui_alert_t *alert, const char *text)
void dt_gui_alert_set_cancel(dt_gui_alert_t *alert, dt_gui_alert_callback_t callback, void *data)
void dt_gui_alert_add_button(dt_gui_alert_t *alert, const char *label, dt_gui_alert_callback_t callback, void *data)
void dt_gui_alert_show(dt_gui_alert_t *alert)
GtkWidget * dt_gui_main_window(void)
const char ** description(struct dt_iop_module_t *self)
static const dt_adaptation_t kind
static void _closing_details_update(dt_closing_t *closing)
#define DT_CLOSING_KIND_DARKROOM
static gboolean _closing_nothing_pending(void)
static void _closing_refresh(dt_closing_t *closing)
void dt_gui_closing_quit(void)
static void _closing_job_clear(gpointer data)
static void _closing_append_name(const gchar *message, void *data)
static gboolean _closing_confirm(void)
static void _closing_window_new(dt_closing_t *closing)
void dt_gui_closing_wait(void)
static gboolean _closing_poll(gpointer user_data)
static void _closing_count_job(const char *description __attribute__((unused)), const dt_job_queue_t queue __attribute__((unused)), const gboolean reserved, void *data)
#define DT_CLOSING_NOTICE_DELAY
static gboolean _closing_confirm_poll(gpointer user_data)
static void _closing_back_clicked(dt_gui_alert_t *alert __attribute__((unused)), void *data)
@ DT_CLOSING_COL_DESCRIPTION
static void _closing_answer(dt_closing_t *closing, const gboolean quit)
static const char * _closing_kind_name(const int kind)
static int32_t _closing_running_jobs(void)
static void _closing_quit_clicked(dt_gui_alert_t *alert __attribute__((unused)), void *data)
static void _closing_collect_job(const char *description, const dt_job_queue_t queue, const gboolean reserved, void *data)
#define DT_CLOSING_POLL_INTERVAL
struct _GtkWidget GtkWidget
GtkWidget, opaque, spelled exactly as GTK spells it.
struct dt_control_t * dt_control_get_global(void)
void dt_gui_refocus_parent(GtkWindow *parent)
GtkWidget * view
the tree view
void dt_control_running_jobs_foreach(dt_control_t *control, dt_control_running_jobs_foreach_callback_t callback, void *data)
int32_t dt_control_queued_jobs_count(dt_control_t *control)
int32_t dt_control_workers_alive(void)
@ DT_JOB_QUEUE_USER_EXPORT
void dt_print(dt_debug_thread_t thread, const char *msg,...) __attribute__((format(printf
Print to stdout when thread is enabled, prefixed with seconds since startup.
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
#define dt_free(ptr)
g_free() ptr and set it to NULL, skipping both if it is already NULL.
void dt_control_progress_foreach(dt_control_t *control, dt_progress_foreach_callback_t callback, void *data)
float dt_aligned_pixel_simd_t __attribute__((vector_size(16), aligned(16)))
Apply one channel's tone curve to each of the three colour channels, or pass the channel through unto...