Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
image_jobs.c
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2010, 2014 Henrik Andersson.
4 Copyright (C) 2010-2011, 2014 johannes hanika.
5 Copyright (C) 2012 Richard Wonka.
6 Copyright (C) 2012, 2014, 2016 Tobias Ellinghaus.
7 Copyright (C) 2014-2016 Roman Lebedev.
8 Copyright (C) 2018-2021 Pascal Obry.
9 Copyright (C) 2019 Bill Ferguson.
10 Copyright (C) 2020-2021 Aldric Renaudin.
11 Copyright (C) 2020 Hubert Kowalski.
12 Copyright (C) 2022 Martin Bařinka.
13 Copyright (C) 2023, 2025 Aurélien PIERRE.
14
15 darktable is free software: you can redistribute it and/or modify
16 it under the terms of the GNU General Public License as published by
17 the Free Software Foundation, either version 3 of the License, or
18 (at your option) any later version.
19
20 darktable is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with darktable. If not, see <http://www.gnu.org/licenses/>.
27*/
28
30#include "control/control.h"
31#include "system/macros.h"
32#include "system/mem_alloc.h"
33
39
40
41typedef struct dt_image_import_t
42{
43 uint32_t film_id;
44 gchar *filename;
46
48{
49 char message[512] = { 0 };
51
52 snprintf(message, sizeof(message), _("Importing image %s"), params->filename);
54
55 const int id = dt_image_import(params->film_id, params->filename, TRUE);
56 if(id)
59 return 0;
60}
61
63{
64 dt_image_import_t *params = p;
65
66 dt_free(params->filename);
67
68 dt_free(params);
69}
70
71dt_job_t *dt_image_import_job_create(uint32_t filmid, const char *filename)
72{
73 dt_image_import_t *params;
75 if(IS_NULL_PTR(job)) return NULL;
76 params = (dt_image_import_t *)calloc(1, sizeof(dt_image_import_t));
77 if(IS_NULL_PTR(params))
78 {
80 return NULL;
81 }
82 dt_control_job_add_progress(job, _("import image"), FALSE);
84 params->filename = g_strdup(filename);
85 params->film_id = filmid;
86 return job;
87}
88
89// clang-format off
90// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
91// vim: shiftwidth=2 expandtab tabstop=2 cindent
92// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
93// clang-format on
#define TRUE
Definition ashift_lsd.c:162
#define FALSE
Definition ashift_lsd.c:158
int32_t dt_image_import(const int32_t film_id, const char *filename, gboolean raise_signals)
void dt_control_queue_redraw()
Request a redraw of the whole workspace.
Definition control.c:919
static void dt_image_import_job_cleanup(void *p)
Definition image_jobs.c:62
static int32_t dt_image_import_job_run(dt_job_t *job)
Definition image_jobs.c:47
dt_job_t * dt_image_import_job_create(uint32_t filmid, const char *filename)
Definition image_jobs.c:71
dt_job_t * dt_control_job_create(dt_job_execute_callback execute, const char *msg,...)
Definition jobs.c:137
void * dt_control_job_get_params(const _dt_job_t *job)
Definition jobs.c:131
void dt_control_job_set_progress(dt_job_t *job, double value)
Definition jobs.c:628
void dt_control_job_add_progress(dt_job_t *job, const char *message, gboolean cancellable)
Definition jobs.c:614
void dt_control_job_set_progress_message(dt_job_t *job, const char *message)
Definition jobs.c:622
void dt_control_job_set_params(_dt_job_t *job, void *params, dt_job_destroy_callback callback)
Definition jobs.c:114
void dt_control_job_dispose(_dt_job_t *job)
Definition jobs.c:155
#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:96
#define dt_free(ptr)
g_free() ptr and set it to NULL, skipping both if it is already NULL.
Definition mem_alloc.h:171
dt_mipmap_size_t
dt_mipmap_size_t mip
Definition image_jobs.c:37