Skip to content

Commit b1498aa

Browse files
committed
inline if didn't work. Added intermediate register_event function in transition library
1 parent 2b28f02 commit b1498aa

33 files changed

+139
-57
lines changed

contrib/AutoGrouper.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ selected images, the other button performs grouping on the entire active collect
3737
]]
3838

3939
local dt = require "darktable"
40+
require "lib/darktable_transition"
4041
local MOD = 'autogrouper'
4142
local gettext = dt.gettext
4243
-- Tell gettext where to find the .mo file translating messages for a particular domain
@@ -175,7 +176,7 @@ if dt.gui.current_view().id == "lighttable" then
175176
else
176177
if not Ag.event_registered then
177178
dt.register_event(
178-
CURR_API_STRING >= "6.2.1" and "AutoGrouper", "view-changed" or "view-changed" ,
179+
"AutoGrouper", "view-changed",
179180
function(event, old_view, new_view)
180181
if new_view.name == "lighttable" and old_view.name == "darkroom" then
181182
install_module()

contrib/HDRMerge.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Select a style, whether you want tags to be copied from the original, and any ad
4646

4747
local dt = require 'darktable'
4848
local df = require 'lib/dtutils.file'
49+
require "lib/darktable_transition"
4950
local dsys = require 'lib/dtutils.system'
5051
local mod = 'module_HDRMerge'
5152
local os_path_seperator = '/'
@@ -438,7 +439,7 @@ if dt.gui.current_view().id == "lighttable" then
438439
else
439440
if not HDRM.event_registered then
440441
dt.register_event(
441-
CURR_API_STRING >= "6.2.1" and "HDRmerge", "view-changed" or "view-changed" ,
442+
"HDRmerge", "view-changed",
442443
function(event, old_view, new_view)
443444
if new_view.name == "lighttable" and old_view.name == "darkroom" then
444445
install_module()

contrib/LabelsToTags.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949

5050
local darktable = require("darktable")
5151
local du = require "lib/dtutils"
52+
require "lib/darktable_transition"
5253

5354
du.check_min_api_version("3.0.0", "LabelsToTags")
5455

@@ -248,7 +249,7 @@ if darktable.gui.current_view().id == "lighttable" then
248249
else
249250
if not ltt.event_registered then
250251
darktable.register_event(
251-
CURR_API_STRING >= "6.2.1" and LIB_ID, "view-changed" or "view-changed" ,
252+
LIB_ID, "view-changed",
252253
function(event, old_view, new_view)
253254
if new_view.name == "lighttable" and old_view.name == "darkroom" then
254255
install_module()

contrib/OpenInExplorer.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ As an alternative option you can choose to show the image file names as symbolic
5050
local dt = require "darktable"
5151
local du = require "lib/dtutils"
5252
local df = require "lib/dtutils.file"
53+
require "lib/darktable_transition"
5354
local dsys = require "lib/dtutils.system"
5455
local gettext = dt.gettext
5556

@@ -209,7 +210,7 @@ if act_os ~= "windows" then
209210
end
210211

211212
dt.register_event(
212-
CURR_API_STRING >= "6.2.1" and "OpenInExplorer", "shortcut" or "shortcut",
213+
"OpenInExplorer", "shortcut",
213214
function(event, shortcut) open_in_fmanager() end,
214215
"OpenInExplorer"
215216
)

contrib/autostyle.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ GPLv2
3838

3939
local darktable = require "darktable"
4040
local du = require "lib/dtutils"
41+
require "lib/darktable_transition"
4142
local filelib = require "lib/dtutils.file"
4243

4344
-- Forward declare the functions
@@ -152,12 +153,12 @@ function get_stdout(cmd)
152153
end
153154

154155
-- Registering events
155-
darktable.register_event(CURR_API_STRING >= "6.2.1" and "autostyle", "shortcut" or "shortcut" ,autostyle_apply,
156+
darktable.register_event("autostyle", "shortcut", autostyle_apply,
156157
"Apply your chosen style from exiftool tags")
157158

158159
darktable.preferences.register("autostyle","exif_tag","string","Autostyle: EXIF_tag=value=>style","apply a style automatically if an EXIF_tag matches value. Find the tag with exiftool","")
159160

160-
darktable.register_event(CURR_API_STRING >= "6.2.1" and "autostyle", "post-import-image" or "post-import-image" ,
161+
darktable.register_event("autostyle", "post-import-image",
161162
autostyle_apply_one_image_event)
162163

163164

contrib/clear_GPS.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
local dt = require "darktable"
4040
local du = require "lib/dtutils"
41+
require "lib/darktable_transition"
4142
local gettext = dt.gettext
4243

4344
-- not a number
@@ -71,7 +72,7 @@ dt.gui.libs.image.register_action(
7172
)
7273

7374
dt.register_event(
74-
CURR_API_STRING >= "6.2.1" and "clearGPS", "shortcut" or "shortcut" ,
75+
"clearGPS", "shortcut",
7576
function(event, shortcut) clear_GPS(dt.gui.action_images) end,
7677
_("Clear GPS data")
7778
)

contrib/copy_attach_detach_tags.lua

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ USAGE
3939
local dt = require "darktable"
4040
local du = require "lib/dtutils"
4141
local debug = require "darktable.debug"
42+
require "lib/darktable_transition"
4243

4344
local gettext = dt.gettext
4445

@@ -234,7 +235,7 @@ if dt.gui.current_view().id == "lighttable" then
234235
else
235236
if not cadt.event_registered then
236237
dt.register_event(
237-
CURR_API_STRING >= "6.2.1" and "cadt", "view-changed" or "view-changed" ,
238+
"cadt", "view-changed",
238239
function(event, old_view, new_view)
239240
if new_view.name == "lighttable" and old_view.name == "darkroom" then
240241
install_module()
@@ -247,22 +248,22 @@ end
247248

248249

249250
-- shortcut for copy
250-
dt.register_event(CURR_API_STRING >= "6.2.1" and "cadt_ct", "shortcut" or "shortcut" ,
251+
dt.register_event("cadt_ct", "shortcut",
251252
mcopy_tags,
252253
_('copy tags from selected image(s)'))
253254

254255
-- shortcut for attach
255-
dt.register_event(CURR_API_STRING >= "6.2.1" and "cadt_at", "shortcut" or "shortcut" ,
256+
dt.register_event("cadt_at", "shortcut",
256257
attach_tags,
257258
_('paste tags to selected image(s)'))
258259

259260
-- shortcut for detaching tags
260-
dt.register_event(CURR_API_STRING >= "6.2.1" and "cadt_dt", "shortcut" or "shortcut" ,
261+
dt.register_event("cadt_dt", "shortcut",
261262
detach_tags,
262263
_('remove tags from selected image(s)'))
263264

264265
-- shortcut for replace tags
265-
dt.register_event(CURR_API_STRING >= "6.2.1" and "cadt_rt", "shortcut" or "shortcut" ,
266+
dt.register_event("cadt_rt", "shortcut",
266267
replace_tags,
267268
_('replace tags from selected image(s)'))
268269

contrib/cr2hdr.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ USAGE
3434

3535
local darktable = require "darktable"
3636
local du = require "lib/dtutils"
37+
require "lib/darktable_transition"
3738

3839
-- Tested with darktable 2.0.1
3940
du.check_min_api_version("2.0.0", "cr2hdr")
@@ -108,11 +109,11 @@ local function convert_action_images(shortcut)
108109
convert_images()
109110
end
110111

111-
darktable.register_event(CURR_API_STRING >= "6.2.1" and "cr2hdr", "shortcut" or "shortcut" ,
112+
darktable.register_event("cr2hdr", "shortcut",
112113
convert_action_images, "Run cr2hdr (Magic Lantern DualISO converter) on selected images")
113-
darktable.register_event(CURR_API_STRING >= "6.2.1" and "cr2hdr", "post-import-image" or "post-import-image" ,
114+
darktable.register_event("cr2hdr", "post-import-image",
114115
file_imported)
115-
darktable.register_event(CURR_API_STRING >= "6.2.1" and "cr2hdr", "post-import-film" or "post-import-film" ,
116+
darktable.register_event("cr2hdr", "post-import-film",
116117
film_imported)
117118

118119
darktable.preferences.register("cr2hdr", "onimport", "bool", "Invoke on import", "If true then cr2hdr will try to proccess every file during importing. Warning: cr2hdr is quite slow even in figuring out on whether the file is Dual ISO or not.", false)

contrib/exportLUT.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ local dt = require "darktable"
3030
local du = require "lib/dtutils"
3131
local df = require("lib/dtutils.file")
3232
local ds = require("lib/dtutils.system")
33+
require "lib/darktable_transition"
3334

3435
local gettext = dt.gettext
3536

@@ -162,7 +163,7 @@ if dt.gui.current_view().id == "lighttable" then
162163
else
163164
if not eL.event_registered then
164165
dt.register_event(
165-
CURR_API_STRING >= "6.2.1" and "exportLUT", "view-changed" or "view-changed" ,
166+
"exportLUT", "view-changed",
166167
function(event, old_view, new_view)
167168
if new_view.name == "lighttable" and old_view.name == "darkroom" then
168169
install_module()

contrib/ext_editor.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
local dt = require "darktable"
7171
local du = require "lib/dtutils"
7272
local df = require "lib/dtutils.file"
73+
require "lib/darktable_transition"
7374
local dtsys = require "lib/dtutils.system"
7475

7576

@@ -417,7 +418,7 @@ if dt.gui.current_view().id == "lighttable" then
417418
else
418419
if not ee.event_registered then
419420
dt.register_event(
420-
CURR_API_STRING >= "6.2.1" and MODULE_NAME, "view-changed" or "view-changed" ,
421+
MODULE_NAME, "view-changed",
421422
function(event, old_view, new_view)
422423
if new_view.name == "lighttable" and old_view.name == "darkroom" then
423424
install_module()
@@ -452,7 +453,7 @@ for i = MAX_EDITORS, 1, -1 do
452453

453454
-- register the new shortcuts -------------------------------------------------
454455
for i = 1, MAX_EDITORS do
455-
dt.register_event(CURR_API_STRING >= "6.2.1" and MODULE_NAME .. i, "shortcut" or "shortcut" ,
456+
dt.register_event(MODULE_NAME .. i, "shortcut",
456457
program_shortcut, _("edit with program ")..string.format("%02d", i))
457458
end
458459

contrib/face_recognition.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ local dt = require "darktable"
4444
local du = require "lib/dtutils"
4545
local df = require "lib/dtutils.file"
4646
local dtsys = require "lib/dtutils.system"
47+
require "lib/darktable_transition"
4748
local gettext = dt.gettext
4849

4950
-- constants
@@ -490,7 +491,7 @@ if dt.gui.current_view().id == "lighttable" then
490491
else
491492
if not fc.event_registered then
492493
dt.register_event(
493-
CURR_API_STRING >= "6.2.1" and MODULE, "view-changed" or "view-changed" ,
494+
MODULE, "view-changed",
494495
function(event, old_view, new_view)
495496
if new_view.name == "lighttable" and old_view.name == "darkroom" then
496497
install_module()

contrib/fujifilm_dynamic_range.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ cameras may behave in other ways.
6060
local dt = require "darktable"
6161
local du = require "lib/dtutils"
6262
local df = require "lib/dtutils.file"
63+
require "lib/darktable_transition"
6364

6465
du.check_min_api_version("4.0.0", "fujifilm_dynamic_range")
6566
local CURR_API_STRING = dt.configuration.api_version_string
@@ -105,7 +106,7 @@ local function detect_dynamic_range(event, image)
105106
dt.print_log("[fujifilm_dynamic_range] raw exposure bias " .. tostring(raf_result))
106107
end
107108

108-
dt.register_event(CURR_API_STRING >= "6.2.1" and "fujifilm_dr", "post-import-image" or "post-import-image" ,
109+
dt.register_event("fujifilm_dr", "post-import-image",
109110
detect_dynamic_range)
110111

111112
dt.print_log("[fujifilm_dynamic_range] loaded")

contrib/fujifilm_ratings.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Dependencies:
2626
local dt = require "darktable"
2727
local du = require "lib/dtutils"
2828
local df = require "lib/dtutils.file"
29+
require "lib/darktable_transition"
2930
local gettext = dt.gettext
3031

3132
du.check_min_api_version("4.0.0", "fujifilm_ratings")
@@ -67,7 +68,7 @@ local function detect_rating(event, image)
6768
end
6869
end
6970

70-
dt.register_event(CURR_API_STRING >= "6.2.1" and "fujifilm_rat", "post-import-image" or "post-import-image" ,
71+
dt.register_event("fujifilm_rat", "post-import-image",
7172
detect_rating)
7273

7374
print(_("fujifilm_ratings loaded."))

contrib/geoToolbox.lua

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ require "geoToolbox"
2828
local dt = require "darktable"
2929
local du = require "lib/dtutils"
3030
local df = require "lib/dtutils.file"
31+
require "lib/darktable_transition"
3132
local gettext = dt.gettext
3233

3334
du.check_min_api_version("3.0.0", "geoToolbox")
@@ -688,7 +689,7 @@ if dt.gui.current_view().id == "lighttable" then
688689
else
689690
if not gT.event_registered then
690691
dt.register_event(
691-
CURR_API_STRING >= "6.2.1" and "geoToolbox", "view-changed" or "view-chagned",
692+
"geoToolbox", "view-changed",
692693
function(event, old_view, new_view)
693694
if new_view.name == "lighttable" and old_view.name == "darkroom" then
694695
install_module()
@@ -708,14 +709,14 @@ dt.preferences.register("geoToolbox",
708709
'' )
709710

710711
-- Register
711-
dt.register_event(CURR_API_STRING >= "6.2.1" and "geoToolbox_cd", "shortcut" or "shortcut" ,
712+
dt.register_event("geoToolbox_cd", "shortcut",
712713
print_calc_distance, _("Calculate the distance from latitude and longitude in km"))
713-
dt.register_event(CURR_API_STRING >= "6.2.1" and "geoToolbox", "mouse-over-image-changed" or "mouse-over-image-changed" ,
714+
dt.register_event("geoToolbox", "mouse-over-image-changed",
714715
toolbox_calc_distance)
715716

716-
dt.register_event(CURR_API_STRING >= "6.2.1" and "geoToolbox_wg", "shortcut" or "shortcut" ,
717+
dt.register_event("geoToolbox_wg", "shortcut",
717718
select_with_gps, _("Select all images with GPS information"))
718-
dt.register_event(CURR_API_STRING >= "6.2.1" and "geoToolbox_ng", "shortcut" or "shortcut" ,
719+
dt.register_event("geoToolbox_ng", "shortcut",
719720
select_without_gps, _("Select all images without GPS information"))
720721

721722
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua

contrib/gpx_export.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ For each source folder, a separate <trk> is generated in the gpx file.
2525
local dt = require "darktable"
2626
local df = require "lib/dtutils.file"
2727
local dl = require "lib/dtutils"
28+
require "lib/darktable_transition"
2829
local gettext = dt.gettext
2930

3031
dl.check_min_api_version("3.0.0", "gpx-export")
@@ -174,7 +175,7 @@ if dt.gui.current_view().id == "lighttable" then
174175
else
175176
if not gpx.event_registered then
176177
dt.register_event(
177-
CURR_API_STRING >= "6.2.1" and "gpx_export", "view-changed" or "view-changed" ,
178+
"gpx_export", "view-changed",
178179
function(event, old_view, new_view)
179180
if new_view.name == "lighttable" and old_view.name == "darkroom" then
180181
install_module()

contrib/image_time.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ local dt = require "darktable"
107107
local du = require "lib/dtutils"
108108
local df = require "lib/dtutils.file"
109109
local ds = require "lib/dtutils.string"
110+
require "lib/darktable_transition"
110111
local gettext = dt.gettext
111112

112113
local img_time = {}
@@ -552,7 +553,7 @@ if dt.gui.current_view().id == "lighttable" then
552553
else
553554
if not img_time.event_registered then
554555
dt.register_event(
555-
CURR_API_STRING >= "6.2.1" and "image_time", "view-changed" or "view-changed" ,
556+
"image_time", "view-changed",
556557
function(event, old_view, new_view)
557558
if new_view.name == "lighttable" and old_view.name == "darkroom" then
558559
install_module()

contrib/photils.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
local dt = require "darktable"
4040
local du = require "lib/dtutils"
4141
local df = require "lib/dtutils.file"
42+
require "lib/darktable_transition"
4243
local dtsys = require "lib/dtutils.system"
4344

4445
local MODULE_NAME = "photils"
@@ -434,15 +435,15 @@ dt.preferences.register(MODULE_NAME,
434435
_("if enabled, the confidence value for each tag is displayed"),
435436
true)
436437

437-
dt.register_event(CURR_API_STRING >= "6.2.1" and "photils", "mouse-over-image-changed" or "mouse-over-image-changed" ,
438+
dt.register_event("photils", "mouse-over-image-changed",
438439
PHOTILS.image_changed)
439440

440441
if dt.gui.current_view().id == "lighttable" then
441442
install_module()
442443
else
443444
if not PHOTILS.event_registered then
444445
dt.register_event(
445-
CURR_API_STRING >= "6.2.1" and "photils", "view-changed" or "view-changed",
446+
"photils", "view-changed",
446447
function(event, old_view, new_view)
447448
if new_view.name == "lighttable" and old_view.name == "darkroom" then
448449
install_module()

contrib/quicktag.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ USAGE
4545

4646
local dt = require "darktable"
4747
local du = require "lib/dtutils"
48+
require "lib/darktable_transition"
4849
local debug = require "darktable.debug"
4950

5051
local qt = {}
@@ -257,7 +258,7 @@ if dt.gui.current_view().id == "lighttable" then
257258
else
258259
if not qt.event_registered then
259260
dt.register_event(
260-
CURR_API_STRING >= "6.2.1" and "quicktag", "view-changed" or "view-changed" ,
261+
"quicktag", "view-changed",
261262
function(event, old_view, new_view)
262263
if new_view.name == "lighttable" and old_view.name == "darkroom" then
263264
install_module()
@@ -270,7 +271,7 @@ end
270271

271272
-- create shortcuts
272273
for i=1,qnr do
273-
dt.register_event(CURR_API_STRING >= "6.2.1" and "quicktag", "shortcut" or "shortcut" ,
274+
dt.register_event("quicktag", "shortcut",
274275
function(event, shortcut) tagattach(tostring(quicktag_table[i])) end,
275276
string.format(_("quicktag %i"),i))
276277
end

0 commit comments

Comments
 (0)