Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add buttons to the gui #3

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion git-annex.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,43 @@ dt.register_event("shortcut", function()
get_status(dt.gui.action_images)
end, "git annex: status")

dt.register_lib(
"gitAnnex", -- Module name
"git annex", -- Name
true, -- Expandable
false, -- Resetable
{[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 20}}, -- containers
dt.new_widget("box")
{
orientation = "vertical",
dt.new_widget("button")
{
label = "add",
tooltip = "Add to git annex",
clicked_callback = function() git_annex("add", dt.gui.action_images, "adding") end
},
dt.new_widget("button")
{
label = "get",
tooltip = "Get from remote repo",
clicked_callback = function() git_annex("get", dt.gui.action_images, "getting") end
},
dt.new_widget("button")
{
label = "drop",
tooltip = "Drop from local repo",
clicked_callback = function() git_annex("drop", dt.gui.action_images, "dropping") end
},
dt.new_widget("button")
{
label = "status",
tooltip = "Update status tags",
clicked_callback = function() get_status(dt.gui.action_images) end
},
},
nil, -- view enter
nil -- view leave
)

-- executes git annex with the given subcommand on the selected files
-- cmd - string, the git annex subcommand
Expand Down Expand Up @@ -136,7 +173,7 @@ function get_status(images)
if #filenames > 25 then
filenames = {}
end
out=call_git_annex_p(path, "whereis", "-j", unpack(filenames))
out=call_git_annex_p(path, "whereis", "-j", table.unpack(filenames))
for line in out:lines() do
status = json.decode(line)
whereis = status["whereis"]
Expand Down