Skip to content

Commit 42a194b

Browse files
authored
Merge pull request #400 from wpferguson/update_change_group_leader
Update contrib/change_group_leader
2 parents c2b3f29 + 6748a71 commit 42a194b

File tree

2 files changed

+44
-7
lines changed

2 files changed

+44
-7
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Name|Standalone|OS |Purpose
3636
----|:--------:|:---:|-------
3737
[AutoGrouper](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/autogrouper)|Yes|LMW|Group images together by time
3838
[autostyle](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/autostyle)|Yes|LMW|Automatically apply styles on import
39+
change_group_leader|Yes|LMW|Change which image leads group
3940
[clear_GPS](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/clear_gps)|Yes|LMW|Reset GPS information for selected images
4041
[CollectHelper](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/collecthelper)|Yes|LMW|Add buttons to selected images module to manipulate the collection
4142
[copy_attach_detach_tags](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/copy_attach_detach_tags)|Yes|LMW|Copy and paste tags from/to images

contrib/change_group_leader.lua

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
--[[
22
change group leader
33
4-
copyright (c) 2022 Bill Ferguson <[email protected]>
4+
copyright (c) 2020, 2022 Bill Ferguson <[email protected]>
5+
copyright (c) 2021 Angel Angelov
56
67
darktable is free software: you can redistribute it and/or modify
78
it under the terms of the GNU General Public License as published by
@@ -34,12 +35,28 @@ USAGE
3435

3536
local dt = require "darktable"
3637
local du = require "lib/dtutils"
37-
local debug = require "darktable.debug"
38+
39+
local gettext = dt.gettext
3840

3941
local MODULE = "change_group_leader"
4042

4143
du.check_min_api_version("3.0.0", MODULE)
4244

45+
-- return data structure for script_manager
46+
47+
local script_data = {}
48+
49+
script_data.destroy = nil -- function to destory the script
50+
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
51+
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
52+
53+
-- Tell gettext where to find the .mo file translating messages for a particular domain
54+
gettext.bindtextdomain(MODULE, dt.configuration.config_dir.."/lua/locale/")
55+
56+
local function _(msgid)
57+
return gettext.dgettext(MODULE, msgid)
58+
end
59+
4360
-- create a namespace to contain persistent data and widgets
4461
chg_grp_ldr = {}
4562

@@ -58,7 +75,7 @@ local function install_module()
5875
if not cgl.module_installed then
5976
dt.register_lib(
6077
MODULE, -- Module name
61-
"change_group_leader", -- Visible name
78+
_("change_group_leader"), -- Visible name
6279
true, -- expandable
6380
false, -- resetable
6481
{[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 700}}, -- containers
@@ -103,7 +120,7 @@ end
103120

104121
local function process_image_groups(images)
105122
if #images < 1 then
106-
dt.print("No images selected.")
123+
dt.print(_("No images selected."))
107124
dt.print_log(MODULE .. "no images seletected, returning...")
108125
else
109126
local mode = cgl.widgets.mode.value
@@ -119,19 +136,31 @@ local function process_image_groups(images)
119136
end
120137
end
121138

139+
-- - - - - - - - - - - - - - - - - - - - - - - -
140+
-- S C R I P T M A N A G E R I N T E G R A T I O N
141+
-- - - - - - - - - - - - - - - - - - - - - - - -
142+
143+
local function destroy()
144+
dt.gui.libs[MODULE].visible = false
145+
end
146+
147+
local function restart()
148+
dt.gui.libs[MODULE].visible = true
149+
end
150+
122151
-- - - - - - - - - - - - - - - - - - - - - - - -
123152
-- W I D G E T S
124153
-- - - - - - - - - - - - - - - - - - - - - - - -
125154

126155
cgl.widgets.mode = dt.new_widget("combobox"){
127-
label = "select new group leader",
128-
tooltip = "select type of image to be group leader",
156+
label = _("select new group leader"),
157+
tooltip = _("select type of image to be group leader"),
129158
selected = 1,
130159
"jpg", "raw", "non-raw",
131160
}
132161

133162
cgl.widgets.execute = dt.new_widget("button"){
134-
label = "Execute",
163+
label = _("Execute"),
135164
clicked_callback = function()
136165
process_image_groups(dt.gui.action_images)
137166
end
@@ -162,3 +191,10 @@ else
162191
cgl.event_registered = true
163192
end
164193
end
194+
195+
script_data.destroy = destroy
196+
script_data.restart = restart
197+
script_data.destroy_method = "hide"
198+
script_data.show = restart
199+
200+
return script_data

0 commit comments

Comments
 (0)