forked from darktable-org/lua-scripts
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
--[[ | ||
This file is part of darktable, | ||
copyright (c) 2023 Dirk Dittmar | ||
darktable is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
darktable is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with darktable. If not, see <http://www.gnu.org/licenses/>. | ||
]] | ||
--[[ | ||
Enable selection of non-existing images in the the currently worked on images, e.g. the ones selected by the collection module. | ||
]] | ||
|
||
local dt = require "darktable" | ||
local du = require "lib/dtutils" | ||
local df = require "lib/dtutils.file" | ||
|
||
-- module name | ||
local MODULE = "select_non_existing" | ||
|
||
du.check_min_api_version("9.1.0", MODULE) | ||
|
||
-- figure out the path separator | ||
local PS = dt.configuration.running_os == "windows" and "\\" or "/" | ||
|
||
local gettext = dt.gettext | ||
gettext.bindtextdomain(MODULE, dt.configuration.config_dir..PS.."lua"..PS.."locale"..PS) | ||
|
||
local function _(msgid) | ||
return gettext.dgettext(MODULE, msgid) | ||
end | ||
|
||
local function stop_job(job) | ||
job.valid = false | ||
end | ||
|
||
local function select_nonexisting_images(event, images) | ||
local selection = {} | ||
|
||
local job = dt.gui.create_job(_("select non existing images"), true, stop_job) | ||
for key,image in ipairs(images) do | ||
if(job.valid) then | ||
job.percent = (key - 1)/#images | ||
local filepath = image.path..PS..image.filename | ||
local file_exists = df.test_file(filepath, "e") | ||
dt.print_log(filepath.." exists? => "..tostring(file_exists)) | ||
if (not file_exists) then | ||
table.insert(selection, image) | ||
end | ||
else | ||
break | ||
end | ||
end | ||
stop_job(job) | ||
|
||
return selection | ||
end | ||
|
||
local function destroy() | ||
dt.gui.libs.select.destroy_selection(MODULE) | ||
end | ||
|
||
dt.gui.libs.select.register_selection( | ||
MODULE, | ||
_("select non existing"), | ||
select_nonexisting_images, | ||
_("select all non-existing images in the current images")) | ||
|
||
local script_data = {} | ||
script_data.destroy = destroy | ||
return script_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
msgid "" | ||
msgstr "" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
|
||
msgid "select non existing images" | ||
msgstr "nicht vorhandene Bilder auswählen" | ||
|
||
msgid "select non existing" | ||
msgstr "nicht vorhandene auswählen" | ||
|
||
msgid "select all non-existing images in the current images" | ||
msgstr "alle nicht vorhandenen Bilder in den aktuellen Bildern auswählen" |