Skip to content

Commit ade7008

Browse files
committed
Added compatibility for lua events API change 6.2.1.
1 parent da0235a commit ade7008

32 files changed

+110
-57
lines changed

contrib/AutoGrouper.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ local dt = require "darktable"
4040
local MOD = 'autogrouper'
4141
local gettext = dt.gettext
4242
-- Tell gettext where to find the .mo file translating messages for a particular domain
43+
local CURR_API_STRING = dt.configuration_api_version_string
4344
gettext.bindtextdomain("AutoGrouper",dt.configuration.config_dir.."/lua/locale/")
4445
local function _(msgid)
4546
return gettext.dgettext("AutoGrouper", msgid)
@@ -174,7 +175,7 @@ if dt.gui.current_view().id == "lighttable" then
174175
else
175176
if not Ag.event_registered then
176177
dt.register_event(
177-
"view-changed",
178+
CURR_API_STRING >= "6.2.1" and "AutoGrouper", "view-changed" or "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/HDRMerge.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ local dsys = require 'lib/dtutils.system'
5050
local mod = 'module_HDRMerge'
5151
local os_path_seperator = '/'
5252
if dt.configuration.running_os == 'windows' then os_path_seperator = '\\' end
53+
local CURR_API_STRING = dt.configuration.api_version_string
5354

5455
-- Tell gettext where to find the .mo file translating messages for a particular domain
5556
local gettext = dt.gettext
@@ -437,7 +438,7 @@ if dt.gui.current_view().id == "lighttable" then
437438
else
438439
if not HDRM.event_registered then
439440
dt.register_event(
440-
"view-changed",
441+
CURR_API_STRING >= "6.2.1" and "HDRmerge", "view-changed" or "view-changed" ,
441442
function(event, old_view, new_view)
442443
if new_view.name == "lighttable" and old_view.name == "darkroom" then
443444
install_module()

contrib/LabelsToTags.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ ltt.module_installed = false
6060
ltt.event_registered = false
6161

6262
local LIB_ID = "LabelsToTags"
63+
local CURR_API_STRING = darktable.configuration.api_version_string
6364

6465
-- Helper functions: BEGIN
6566

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

contrib/OpenInExplorer.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ end
6565

6666
local act_os = dt.configuration.running_os
6767
local PS = act_os == "windows" and "\\" or "/"
68+
local CURR_API_STRING = dt.configuration.api_version_string
6869

6970
--Detect OS and quit if it is not supported.
7071
if act_os ~= "macos" and act_os ~= "windows" and act_os ~= "linux" then
@@ -208,7 +209,7 @@ if act_os ~= "windows" then
208209
end
209210

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

contrib/autostyle.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ local filelib = require "lib/dtutils.file"
4242

4343
-- Forward declare the functions
4444
local autostyle_apply_one_image,autostyle_apply_one_image_event,autostyle_apply,exiftool_attribute,capture
45+
local CURR_API_STRING = darktable.configuration.api_version_string
4546

4647
-- Tested it with darktable 1.6.1 and darktable git from 2014-01-25
4748
du.check_min_api_version("2.0.2", "autostyle")
@@ -151,11 +152,12 @@ function get_stdout(cmd)
151152
end
152153

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

157158
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","")
158159

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

161163

contrib/clear_GPS.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ local gettext = dt.gettext
4444
local NaN = 0/0
4545

4646
du.check_min_api_version("3.0.0", "clear_GPS")
47+
local CURR_API_STRING = dt.configuration.api_version_string
4748

4849

4950
-- Tell gettext where to find the .mo file translating messages for a particular domain
@@ -70,7 +71,7 @@ dt.gui.libs.image.register_action(
7071
)
7172

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

contrib/copy_attach_detach_tags.lua

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ local debug = require "darktable.debug"
4343
local gettext = dt.gettext
4444

4545
du.check_min_api_version("3.0.0", "copy_attach_detach_tags")
46+
local CURR_API_STRING = dt.configuration.api_version_string
4647

4748
-- Tell gettext where to find the .mo file translating messages for a particular domain
4849
gettext.bindtextdomain("copy_attach_detach_tags",dt.configuration.config_dir.."/lua/locale/")
@@ -233,7 +234,7 @@ if dt.gui.current_view().id == "lighttable" then
233234
else
234235
if not cadt.event_registered then
235236
dt.register_event(
236-
"view-changed",
237+
CURR_API_STRING >= "6.2.1" and "cadt", "view-changed" or "view-changed" ,
237238
function(event, old_view, new_view)
238239
if new_view.name == "lighttable" and old_view.name == "darkroom" then
239240
install_module()
@@ -246,22 +247,22 @@ end
246247

247248

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

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

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

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

contrib/cr2hdr.lua

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ local du = require "lib/dtutils"
3737

3838
-- Tested with darktable 2.0.1
3939
du.check_min_api_version("2.0.0", "cr2hdr")
40+
local CURR_API_STRING = darktable.configuration.api_version_string
4041

4142
local queue = {}
4243
local processed_files = {}
@@ -107,8 +108,11 @@ local function convert_action_images(shortcut)
107108
convert_images()
108109
end
109110

110-
darktable.register_event("shortcut", convert_action_images, "Run cr2hdr (Magic Lantern DualISO converter) on selected images")
111-
darktable.register_event("post-import-image", file_imported)
112-
darktable.register_event("post-import-film", film_imported)
111+
darktable.register_event(CURR_API_STRING >= "6.2.1" and "cr2hdr", "shortcut" or "shortcut" ,
112+
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+
file_imported)
115+
darktable.register_event(CURR_API_STRING >= "6.2.1" and "cr2hdr", "post-import-film" or "post-import-film" ,
116+
film_imported)
113117

114118
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
@@ -34,6 +34,7 @@ local ds = require("lib/dtutils.system")
3434
local gettext = dt.gettext
3535

3636
gettext.bindtextdomain("exportLUT",dt.configuration.config_dir.."/lua/locale/")
37+
local CURR_API_STRING = dt.configuration.api_version_string
3738

3839
local function _(msgid)
3940
return gettext.dgettext("exportLUT", msgid)
@@ -161,7 +162,7 @@ if dt.gui.current_view().id == "lighttable" then
161162
else
162163
if not eL.event_registered then
163164
dt.register_event(
164-
"view-changed",
165+
CURR_API_STRING >= "6.2.1" and "exportLUT", "view-changed" or "view-changed" ,
165166
function(event, old_view, new_view)
166167
if new_view.name == "lighttable" and old_view.name == "darkroom" then
167168
install_module()

contrib/ext_editor.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ local dtsys = require "lib/dtutils.system"
7575

7676
-- module name
7777
local MODULE_NAME = "ext_editor"
78+
local CURR_API_STRING = dt.configuration.api_version_string
7879

7980

8081
-- check API version
@@ -416,7 +417,7 @@ if dt.gui.current_view().id == "lighttable" then
416417
else
417418
if not ee.event_registered then
418419
dt.register_event(
419-
"view-changed",
420+
CURR_API_STRING >= "6.2.1" and MODULE_NAME, "view-changed" or "view-changed" ,
420421
function(event, old_view, new_view)
421422
if new_view.name == "lighttable" and old_view.name == "darkroom" then
422423
install_module()
@@ -451,7 +452,8 @@ for i = MAX_EDITORS, 1, -1 do
451452

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

457459

contrib/face_recognition.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ local gettext = dt.gettext
5151
local MODULE = "face_recognition"
5252
local PS = dt.configuration.running_os == "windows" and '\\' or '/'
5353
local OUTPUT = dt.configuration.tmp_dir .. PS .. "facerecognition.txt"
54+
local CURR_API_STRING = dt.configuration.api_version_string
5455

5556
-- namespace
5657

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

contrib/fujifilm_dynamic_range.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ local du = require "lib/dtutils"
6262
local df = require "lib/dtutils.file"
6363

6464
du.check_min_api_version("4.0.0", "fujifilm_dynamic_range")
65+
local CURR_API_STRING = dt.configuration.api_version_string
6566

6667
local function detect_dynamic_range(event, image)
6768
if image.exif_maker ~= "FUJIFILM" then
@@ -104,6 +105,7 @@ local function detect_dynamic_range(event, image)
104105
dt.print_log("[fujifilm_dynamic_range] raw exposure bias " .. tostring(raf_result))
105106
end
106107

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

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

contrib/fujifilm_ratings.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ local df = require "lib/dtutils.file"
2929
local gettext = dt.gettext
3030

3131
du.check_min_api_version("4.0.0", "fujifilm_ratings")
32+
local CURR_API_STRING = dt.configuration.api_version_string
3233

3334
gettext.bindtextdomain("fujifilm_ratings", dt.configuration.config_dir.."/lua/locale/")
3435

@@ -66,6 +67,7 @@ local function detect_rating(event, image)
6667
end
6768
end
6869

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

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

contrib/geoToolbox.lua

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ local df = require "lib/dtutils.file"
3131
local gettext = dt.gettext
3232

3333
du.check_min_api_version("3.0.0", "geoToolbox")
34+
local CURR_API_STRING = dt.configuration.api_version_string
3435

3536
-- Tell gettext where to find the .mo file translating messages for a particular domain
3637
gettext.bindtextdomain("geoToolbox",dt.configuration.config_dir.."/lua/locale/")
@@ -687,7 +688,7 @@ if dt.gui.current_view().id == "lighttable" then
687688
else
688689
if not gT.event_registered then
689690
dt.register_event(
690-
"view-changed",
691+
CURR_API_STRING >= "6.2.1" and "geoToolbox", "view-changed" or "view-chagned",
691692
function(event, old_view, new_view)
692693
if new_view.name == "lighttable" and old_view.name == "darkroom" then
693694
install_module()
@@ -707,11 +708,15 @@ dt.preferences.register("geoToolbox",
707708
'' )
708709

709710
-- Register
710-
dt.register_event("shortcut", print_calc_distance, _("Calculate the distance from latitude and longitude in km"))
711-
dt.register_event("mouse-over-image-changed", toolbox_calc_distance)
712-
713-
dt.register_event("shortcut", select_with_gps, _("Select all images with GPS information"))
714-
dt.register_event("shortcut", select_without_gps, _("Select all images without GPS information"))
711+
dt.register_event(CURR_API_STRING >= "6.2.1" and "geoToolbox_cd", "shortcut" or "shortcut" ,
712+
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+
toolbox_calc_distance)
715+
716+
dt.register_event(CURR_API_STRING >= "6.2.1" and "geoToolbox_wg", "shortcut" or "shortcut" ,
717+
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+
select_without_gps, _("Select all images without GPS information"))
715720

716721
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua
717722
-- kate: hl Lua;

contrib/gpx_export.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ local dl = require "lib/dtutils"
2828
local gettext = dt.gettext
2929

3030
dl.check_min_api_version("3.0.0", "gpx-export")
31+
local CURR_API_STRING = dt.configuration.api_version_string
3132

3233
-- Tell gettext where to find the .mo file translating messages for a particular domain
3334
gettext.bindtextdomain("gpx_export",dt.configuration.config_dir.."/lua/locale/")
@@ -173,7 +174,7 @@ if dt.gui.current_view().id == "lighttable" then
173174
else
174175
if not gpx.event_registered then
175176
dt.register_event(
176-
"view-changed",
177+
CURR_API_STRING >= "6.2.1" and "gpx_export", "view-changed" or "view-changed" ,
177178
function(event, old_view, new_view)
178179
if new_view.name == "lighttable" and old_view.name == "darkroom" then
179180
install_module()

contrib/image_time.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ img_time.module_installed = false
114114
img_time.event_registered = false
115115

116116
du.check_min_api_version("3.0.0", "image_time")
117+
local CURR_API_STRING = dt.configuration.api_version_string
117118

118119

119120
-- Tell gettext where to find the .mo file translating messages for a particular domain
@@ -551,7 +552,7 @@ if dt.gui.current_view().id == "lighttable" then
551552
else
552553
if not img_time.event_registered then
553554
dt.register_event(
554-
"view-changed",
555+
CURR_API_STRING >= "6.2.1" and "image_time", "view-changed" or "view-changed" ,
555556
function(event, old_view, new_view)
556557
if new_view.name == "lighttable" and old_view.name == "darkroom" then
557558
install_module()

contrib/photils.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ local dtsys = require "lib/dtutils.system"
4444
local MODULE_NAME = "photils"
4545
du.check_min_api_version("5.0.0", MODULE_NAME)
4646

47+
local CURR_API_STRING = dt.configuration.api_version_string
4748
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
4849
local gettext = dt.gettext
4950
gettext.bindtextdomain(MODULE_NAME,
@@ -433,14 +434,15 @@ dt.preferences.register(MODULE_NAME,
433434
_("if enabled, the confidence value for each tag is displayed"),
434435
true)
435436

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

438440
if dt.gui.current_view().id == "lighttable" then
439441
install_module()
440442
else
441443
if not PHOTILS.event_registered then
442444
dt.register_event(
443-
"view-changed",
445+
CURR_API_STRING >= "6.2.1" and "photils", "view-changed" or "view-changed",
444446
function(event, old_view, new_view)
445447
if new_view.name == "lighttable" and old_view.name == "darkroom" then
446448
install_module()

contrib/quicktag.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ qt.widget_table = {}
5757
local gettext = dt.gettext
5858

5959
du.check_min_api_version("3.0.0", "quicktag")
60+
local CURR_API_STRING = dt.configuration.api_version_string
6061

6162
-- Tell gettext where to find the .mo file translating messages for a particular domain
6263
gettext.bindtextdomain("quicktag",dt.configuration.config_dir.."/lua/locale/")
@@ -256,7 +257,7 @@ if dt.gui.current_view().id == "lighttable" then
256257
else
257258
if not qt.event_registered then
258259
dt.register_event(
259-
"view-changed",
260+
CURR_API_STRING >= "6.2.1" and "quicktag", "view-changed" or "view-changed" ,
260261
function(event, old_view, new_view)
261262
if new_view.name == "lighttable" and old_view.name == "darkroom" then
262263
install_module()
@@ -269,7 +270,7 @@ end
269270

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

0 commit comments

Comments
 (0)