Skip to content

Commit f35cea7

Browse files
authored
Merge pull request darktable-org#324 from wpferguson/API_6_2_3_register_action_changes
API 6.2.3 compatibility
2 parents 448da35 + 4053ceb commit f35cea7

File tree

5 files changed

+127
-44
lines changed

5 files changed

+127
-44
lines changed

contrib/CollectHelper.lua

Lines changed: 53 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ local all_active = false
5353
-- Tell gettext where to find the .mo file translating messages for a particular domain
5454
gettext.bindtextdomain("CollectHelper",dt.configuration.config_dir.."/lua/locale/")
5555

56+
local CURR_API_STRING = dt.configuration.api_version_string
57+
5658
local function _(msgid)
5759
return gettext.dgettext("CollectHelper", msgid)
5860
end
@@ -173,31 +175,63 @@ local function CollectOnAll_AND()
173175
end
174176

175177
-- GUI --
176-
dt.gui.libs.image.register_action(
177-
_("collect: previous"),
178-
function() PreviousCollection() end,
179-
_("Sets the Collect parameters to be the previously active parameters")
180-
)
181-
if dt.preferences.read('module_CollectHelper','folder','bool') then
178+
if CURR_API_STRING < "6.2.3" then
182179
dt.gui.libs.image.register_action(
183-
_("collect: folder"),
184-
function() CollectOnFolder(_ , false) end,
185-
_("Sets the Collect parameters to be the selected images's folder")
180+
_("collect: previous"),
181+
function() PreviousCollection() end,
182+
_("Sets the Collect parameters to be the previously active parameters")
186183
)
187-
end
188-
if dt.preferences.read('module_CollectHelper','colors','bool') then
184+
else
189185
dt.gui.libs.image.register_action(
190-
_("collect: color label(s)"),
191-
function() CollectOnColors(_ , false) end,
192-
_("Sets the Collect parameters to be the selected images's color label(s)")
186+
"CollectHelper_prev", _("collect: previous"),
187+
function() PreviousCollection() end,
188+
_("Sets the Collect parameters to be the previously active parameters")
193189
)
194190
end
191+
if dt.preferences.read('module_CollectHelper','folder','bool') then
192+
if CURR_API_STRING < "6.2.3" then
193+
dt.gui.libs.image.register_action(
194+
_("collect: folder"),
195+
function() CollectOnFolder(_ , false) end,
196+
_("Sets the Collect parameters to be the selected images's folder")
197+
)
198+
else
199+
dt.gui.libs.image.register_action(
200+
"CollectHelper_folder", _("collect: folder"),
201+
function() CollectOnFolder(_ , false) end,
202+
_("Sets the Collect parameters to be the selected images's folder")
203+
)
204+
end
205+
end
206+
if dt.preferences.read('module_CollectHelper','colors','bool') then
207+
if CURR_API_STRING < "6.2.3" then
208+
dt.gui.libs.image.register_action(
209+
_("collect: color label(s)"),
210+
function() CollectOnColors(_ , false) end,
211+
_("Sets the Collect parameters to be the selected images's color label(s)")
212+
)
213+
else
214+
dt.gui.libs.image.register_action(
215+
"CollectHelper_labels", _("collect: color label(s)"),
216+
function() CollectOnColors(_ , false) end,
217+
_("Sets the Collect parameters to be the selected images's color label(s)")
218+
)
219+
end
220+
end
195221
if dt.preferences.read('module_CollectHelper','all_and','bool') then
196-
dt.gui.libs.image.register_action(
197-
_("collect: all (AND)"),
198-
function() CollectOnAll_AND() end,
199-
_("Sets the Collect parameters based on all activated CollectHelper options")
200-
)
222+
if CURR_API_STRING < "6.2.3" then
223+
dt.gui.libs.image.register_action(
224+
_("collect: all (AND)"),
225+
function() CollectOnAll_AND() end,
226+
_("Sets the Collect parameters based on all activated CollectHelper options")
227+
)
228+
else
229+
dt.gui.libs.image.register_action(
230+
"CollectHelper_and", _("collect: all (AND)"),
231+
function() CollectOnAll_AND() end,
232+
_("Sets the Collect parameters based on all activated CollectHelper options")
233+
)
234+
end
201235
end
202236

203237
-- PREFERENCES --

contrib/OpenInExplorer.lua

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,21 @@ end
184184

185185

186186
-- GUI --
187-
dt.gui.libs.image.register_action(
188-
_("show in file explorer"),
189-
function() open_in_fmanager() end,
190-
_("Open the file manager at the selected image's location")
191-
)
187+
if CURR_API_STRING < "6.2.3" then
188+
dt.gui.libs.image.register_action(
189+
_("show in file explorer"),
190+
function() open_in_fmanager() end,
191+
_("Open the file manager at the selected image's location")
192+
)
193+
else
194+
dt.gui.libs.image.register_action(
195+
"OpenInExplorer", _("show in file explorer"),
196+
function() open_in_fmanager() end,
197+
_("Open the file manager at the selected image's location")
198+
)
199+
end
200+
201+
192202
if act_os ~= "windows" then
193203
dt.preferences.register("OpenInExplorer", "linked_image_files_dir", -- name
194204
"directory", -- type

contrib/clear_GPS.lua

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,21 @@ local function clear_GPS(images)
6464
end
6565
end
6666

67+
if CURR_API_STRING < "6.2.3" then
68+
dt.gui.libs.image.register_action(
69+
_("clear GPS data"),
70+
function(event, images) clear_GPS(images) end,
71+
_("Clear GPS data from selected images")
72+
)
73+
else
74+
dt.gui.libs.image.register_action(
75+
_"clear_GPS", ("clear GPS data"),
76+
function(event, images) clear_GPS(images) end,
77+
_("Clear GPS data from selected images")
78+
)
79+
end
80+
6781

68-
dt.gui.libs.image.register_action(
69-
_("clear GPS data"),
70-
function(event, images) clear_GPS(images) end,
71-
_("Clear GPS data from selected images")
72-
)
7382

7483
dt.register_event(
7584
"clearGPS", "shortcut",

examples/multi_os.lua

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,21 @@ end
231231
Add a button to the selected images module in lighttable
232232
]]
233233

234-
dt.gui.libs.image.register_action(
235-
_("extract embedded jpeg"),
236-
function(event, images) extract_embedded_jpeg(images) end,
237-
"extract embedded jpeg"
238-
)
234+
if CURR_API_STRING < "6.2.3" then
235+
dt.gui.libs.image.register_action(
236+
_("extract embedded jpeg"),
237+
function(event, images) extract_embedded_jpeg(images) end,
238+
"extract embedded jpeg"
239+
)
240+
else
241+
dt.gui.libs.image.register_action(
242+
"multi_os", _("extract embedded jpeg"),
243+
function(event, images) extract_embedded_jpeg(images) end,
244+
"extract embedded jpeg"
245+
)
246+
end
247+
248+
239249

240250
--[[
241251
Add a shortcut

official/copy_paste_metadata.lua

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,37 @@ local function paste(images)
114114
end
115115
end
116116

117-
dt.gui.libs.image.register_action(
118-
_("copy metadata"),
119-
function(event, images) copy(images[1]) end,
120-
_("copy metadata of the first selected image")
121-
)
117+
if CURR_API_STRING < "6.2.3" then
118+
dt.gui.libs.image.register_action(
119+
_("copy metadata"),
120+
function(event, images) copy(images[1]) end,
121+
_("copy metadata of the first selected image")
122+
)
123+
else
124+
dt.gui.libs.image.register_action(
125+
"metadata_copy", _("copy metadata"),
126+
function(event, images) copy(images[1]) end,
127+
_("copy metadata of the first selected image")
128+
)
129+
end
130+
131+
132+
133+
if CURR_API_STRING < "6.2.3" then
134+
dt.gui.libs.image.register_action(
135+
_("paste metadata"),
136+
function(event, images) paste(images) end,
137+
_("paste metadata to the selected images")
138+
)
139+
else
140+
dt.gui.libs.image.register_action(
141+
"metadata_paste", _("paste metadata"),
142+
function(event, images) paste(images) end,
143+
_("paste metadata to the selected images")
144+
)
145+
end
146+
122147

123-
dt.gui.libs.image.register_action(
124-
_("paste metadata"),
125-
function(event, images) paste(images) end,
126-
_("paste metadata to the selected images")
127-
)
128148

129149
dt.register_event(
130150
"capmd1", "shortcut",

0 commit comments

Comments
 (0)