From c8713a7f389feaf9937cb91ff369eb77a6e1c56d Mon Sep 17 00:00:00 2001 From: chrik5 Date: Tue, 4 Oct 2016 13:54:49 +0200 Subject: [PATCH 1/2] cleanup the code and create UI elements before --- contrib/copy_attach_detach_tags.lua | 60 +++++++++++++++-------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/contrib/copy_attach_detach_tags.lua b/contrib/copy_attach_detach_tags.lua index 9a89a2e..2cd4dde 100644 --- a/contrib/copy_attach_detach_tags.lua +++ b/contrib/copy_attach_detach_tags.lua @@ -144,42 +144,44 @@ end -- create modul Tagging addons taglist_label.reset_callback = mcopy_tags -dt.register_lib("tagging_addon","Tagging addon",true,false,{ - [dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER",500} - }, - dt.new_widget("box") - { - orientation = "vertical", - dt.new_widget("button") - { +-- create buttons and elements +local mc_button = dt.new_widget("button") { label = "multi copy tags", - clicked_callback = mcopy_tags - }, - dt.new_widget("button") - { + clicked_callback = mcopy_tags} + +local p_button = dt.new_widget("button") { label = "paste tags", - clicked_callback = attach_tags - }, - dt.new_widget("button") - { + clicked_callback = attach_tags} + +local rep_button = dt.new_widget("button") { label = "replace tags", - clicked_callback = replace_tags - }, - dt.new_widget("button") - { + clicked_callback = replace_tags} + +local rem_button = dt.new_widget("button") { label = "remove all tags", - clicked_callback = detach_tags - }, - dt.new_widget("label") - { + clicked_callback = detach_tags} + +local taglabel = dt.new_widget("label") { label = "tag clipboard", selectable = false, ellipsize = "middle", - halign = "start" - }, - dt.new_widget("separator"){}, - taglist_label - }, + halign = "start"} + + +-- create modul +dt.register_lib("tagging_addon","Tagging addon",true,false,{ + [dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER",500} + }, + dt.new_widget("box") { + orientation = "vertical", + mc_button, + p_button, + rep_button, + rem_button, + taglabel, + dt.new_widget("separator"){}, + taglist_label + }, nil, nil ) From f967e96aa55e3aa4ef68ed2ab18024c51d9af606 Mon Sep 17 00:00:00 2001 From: chrik5 Date: Tue, 4 Oct 2016 16:03:35 +0200 Subject: [PATCH 2/2] exit attach tags function if there are no tags to attach --- contrib/copy_attach_detach_tags.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/copy_attach_detach_tags.lua b/contrib/copy_attach_detach_tags.lua index 2cd4dde..d1ecb46 100644 --- a/contrib/copy_attach_detach_tags.lua +++ b/contrib/copy_attach_detach_tags.lua @@ -94,6 +94,7 @@ local function attach_tags() if next(image_tags) == nil then dt.print("No tags to attached, please copy tags first.") + return true end local sel_images = dt.gui.action_images