|
| 1 | +--[[ |
| 2 | + This file is part of darktable, |
| 3 | + copyright (c) 2017 Jannis_V |
| 4 | +
|
| 5 | + darktable 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 | + darktable is distributed in the hope that it will be useful, |
| 10 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | + GNU General Public License for more details. |
| 13 | + You should have received a copy of the GNU General Public License |
| 14 | + along with darktable. If not, see <http://www.gnu.org/licenses/>. |
| 15 | +]] |
| 16 | + |
| 17 | +--[[ |
| 18 | +Enable selection of untagged images (darktable|* tags are ignored) |
| 19 | +]] |
| 20 | + |
| 21 | +local dt = require "darktable" |
| 22 | +require "official/yield" |
| 23 | +local gettext = dt.gettext |
| 24 | + |
| 25 | +dt.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0}) |
| 26 | + |
| 27 | +-- Tell gettext where to find the .mo file translating messages for a particular domain |
| 28 | +gettext.bindtextdomain("select_untagged",dt.configuration.config_dir.."/lua/locale/") |
| 29 | + |
| 30 | +local function _(msgid) |
| 31 | + return gettext.dgettext("select_untagged", msgid) |
| 32 | +end |
| 33 | + |
| 34 | +local function stop_job(job) |
| 35 | + job.valid = false |
| 36 | +end |
| 37 | + |
| 38 | +local function select_untagged_images() |
| 39 | + job = dt.gui.create_job(_("select untagged images"), true, stop_job) |
| 40 | + |
| 41 | + local selection = {} |
| 42 | + |
| 43 | + for key,image in ipairs(dt.collection) do |
| 44 | + if(job.valid) then |
| 45 | + job.percent = (key-1)/#dt.collection |
| 46 | + local tags = dt.tags.get_tags(image) |
| 47 | + local hasTags = false |
| 48 | + for _,tag in ipairs(tags) do |
| 49 | + if not string.match(tag.name,"darktable|") then |
| 50 | + hasTags = true |
| 51 | + end |
| 52 | + end |
| 53 | + if hasTags == false then |
| 54 | + table.insert(selection,image) |
| 55 | + end |
| 56 | + else |
| 57 | + break |
| 58 | + end |
| 59 | + end |
| 60 | + |
| 61 | + job.valid = false |
| 62 | + dt.gui.selection(selection) |
| 63 | +end |
| 64 | + |
| 65 | +dt.gui.libs.select.register_selection(_("select untagged"),select_untagged_images,_("select all images containing no tags or only tags added by darktable")) |
0 commit comments