Skip to content

Commit

Permalink
Merge pull request #400 from wpferguson/update_change_group_leader
Browse files Browse the repository at this point in the history
Update contrib/change_group_leader
  • Loading branch information
wpferguson committed Oct 16, 2022
2 parents c2b3f29 + 6748a71 commit 42a194b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Name|Standalone|OS |Purpose
----|:--------:|:---:|-------
[AutoGrouper](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/autogrouper)|Yes|LMW|Group images together by time
[autostyle](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/autostyle)|Yes|LMW|Automatically apply styles on import
change_group_leader|Yes|LMW|Change which image leads group
[clear_GPS](https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/clear_gps)|Yes|LMW|Reset GPS information for selected images
[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
[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
Expand Down
50 changes: 43 additions & 7 deletions contrib/change_group_leader.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
--[[
change group leader
copyright (c) 2022 Bill Ferguson <wpferguson@gmail.com>
copyright (c) 2020, 2022 Bill Ferguson <wpferguson@gmail.com>
copyright (c) 2021 Angel Angelov
darktable is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -34,12 +35,28 @@ USAGE

local dt = require "darktable"
local du = require "lib/dtutils"
local debug = require "darktable.debug"

local gettext = dt.gettext

local MODULE = "change_group_leader"

du.check_min_api_version("3.0.0", MODULE)

-- return data structure for script_manager

local script_data = {}

script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again

-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain(MODULE, dt.configuration.config_dir.."/lua/locale/")

local function _(msgid)
return gettext.dgettext(MODULE, msgid)
end

-- create a namespace to contain persistent data and widgets
chg_grp_ldr = {}

Expand All @@ -58,7 +75,7 @@ local function install_module()
if not cgl.module_installed then
dt.register_lib(
MODULE, -- Module name
"change_group_leader", -- Visible name
_("change_group_leader"), -- Visible name
true, -- expandable
false, -- resetable
{[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 700}}, -- containers
Expand Down Expand Up @@ -103,7 +120,7 @@ end

local function process_image_groups(images)
if #images < 1 then
dt.print("No images selected.")
dt.print(_("No images selected."))
dt.print_log(MODULE .. "no images seletected, returning...")
else
local mode = cgl.widgets.mode.value
Expand All @@ -119,19 +136,31 @@ local function process_image_groups(images)
end
end

-- - - - - - - - - - - - - - - - - - - - - - - -
-- S C R I P T M A N A G E R I N T E G R A T I O N
-- - - - - - - - - - - - - - - - - - - - - - - -

local function destroy()
dt.gui.libs[MODULE].visible = false
end

local function restart()
dt.gui.libs[MODULE].visible = true
end

-- - - - - - - - - - - - - - - - - - - - - - - -
-- W I D G E T S
-- - - - - - - - - - - - - - - - - - - - - - - -

cgl.widgets.mode = dt.new_widget("combobox"){
label = "select new group leader",
tooltip = "select type of image to be group leader",
label = _("select new group leader"),
tooltip = _("select type of image to be group leader"),
selected = 1,
"jpg", "raw", "non-raw",
}

cgl.widgets.execute = dt.new_widget("button"){
label = "Execute",
label = _("Execute"),
clicked_callback = function()
process_image_groups(dt.gui.action_images)
end
Expand Down Expand Up @@ -162,3 +191,10 @@ else
cgl.event_registered = true
end
end

script_data.destroy = destroy
script_data.restart = restart
script_data.destroy_method = "hide"
script_data.show = restart

return script_data

0 comments on commit 42a194b

Please sign in to comment.