Skip to content

Commit a5ad5e6

Browse files
authored
Remove executable preferences
The executable choosers have been moved to a box which is now element 4 in the GUI stack. Once the user configures these and presses update they are confirmed good or bad and the GUI changed to normal view if all works out.
1 parent f740d34 commit a5ad5e6

File tree

1 file changed

+81
-22
lines changed

1 file changed

+81
-22
lines changed

contrib/enfuseAdvanced.lua

Lines changed: 81 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,6 @@ local os_path_seperator = '/'
6565
if dt.configuration.running_os == 'windows' then os_path_seperator = '\\' end
6666

6767
du.check_min_api_version("5.0.0", "enfuseAdvanced")
68-
dt.preferences.register("executable_paths", "align_image_stack", -- name
69-
"file", -- type
70-
'enfuseAdvanced: Align Image Stack Location', -- label
71-
'Install location of align_image_stack. Requires restart to take effect.', -- tooltip
72-
"align_image_stack" -- default
73-
)
74-
dt.preferences.register("executable_paths", "enfuse", -- name
75-
"file", -- type
76-
'enfuseAdvanced: enfuse Location', -- label
77-
'Install location of enfuse. Requires restart to take effect.', -- tooltip
78-
'enfuse'
79-
)
80-
dt.preferences.register("executable_paths", "exiftool", -- name
81-
"file", -- type
82-
'enfuseAdvanced: exiftool Location', -- label
83-
'Install location of exiftool. Requires restart to take effect.', -- tooltip
84-
"exiftool" -- default
85-
)
8668

8769
-- INITS --
8870
local AIS = {
@@ -172,6 +154,12 @@ local GUI = {
172154
save ={};
173155
variants ={};
174156
variants_type ={}},
157+
exes = {
158+
align_image_stack = {},
159+
enfuse = {},
160+
exiftool = {},
161+
update = {}
162+
},
175163
align = {},
176164
options_contain = {},
177165
show_options = {}
@@ -228,12 +216,41 @@ local function PreCall(prog_tbls) --looks to see if this is the first call, if s
228216
prog.bin = df.check_if_bin_exists(prog.name)
229217
if not prog.bin then
230218
prog.install_error = true
219+
dt.preferences.write(mod, 'bin_exists', 'bool', false)
231220
else
232221
prog.bin = CleanSpaces(prog.bin)
233222
end
234223
prog.first_run = false
235224
end
236225
end
226+
if not dt.preferences.read(mod, 'bin_exists', 'bool') then
227+
GUI.options_contain.active = 4
228+
GUI.show_options.sensitive = false
229+
dt.print('please update your binary locations')
230+
end
231+
end
232+
233+
local function ExeUpdate(prog_tbl) --updates executable paths and verifies them
234+
dt.preferences.write(mod, 'bin_exists', 'bool', true)
235+
for _,prog in pairs(prog_tbl) do
236+
dt.preferences.write('executable_paths', prog.name, 'string', GUI.exes[prog.name].value)
237+
prog.bin = df.check_if_bin_exists(prog.name)
238+
if not prog.bin then
239+
prog.install_error = true
240+
dt.preferences.write(mod, 'bin_exists', 'bool', false)
241+
dt.print('issue with '..prog.name..' executable')
242+
else
243+
prog.bin = CleanSpaces(prog.bin)
244+
end
245+
prog.first_run = false
246+
end
247+
if dt.preferences.read(mod, 'bin_exists', 'bool') then
248+
GUI.options_contain.active = 2
249+
GUI.show_options.sensitive = true
250+
dt.print('update successful')
251+
else
252+
dt.print('update unsuccessful, please try again')
253+
end
237254
end
238255

239256
local function GetArgsFromPreference(prog_table, prefix) --for each arg in a program table reads in the associated value in the active preference (which is continually updated via clicked/changed callback in GUI elements
@@ -958,6 +975,35 @@ GUI.Presets.variants_type = dt.new_widget('combobox'){
958975
end
959976
}
960977
GUI.Presets.variants_type.sensitive = GUI.Presets.variants.value
978+
temp = df.get_executable_path_preference(AIS.name)
979+
GUI.exes.align_image_stack = dt.new_widget('file_chooser_button'){
980+
title = 'AIS binary path',
981+
value = temp,
982+
tooltip = temp,
983+
is_directory = false,
984+
changed_callback = function(self) self.tooltip = self.value end
985+
}
986+
temp = df.get_executable_path_preference(ENF.name)
987+
GUI.exes.enfuse = dt.new_widget('file_chooser_button'){
988+
title = 'enfuse binary path',
989+
value = temp,
990+
tooltip = temp,
991+
is_directory = false,
992+
changed_callback = function(self) self.tooltip = self.value end
993+
}
994+
temp = df.get_executable_path_preference(EXF.name)
995+
GUI.exes.exiftool = dt.new_widget('file_chooser_button'){
996+
title = 'Exiftool binary path',
997+
value = temp,
998+
tooltip = temp,
999+
is_directory = false,
1000+
changed_callback = function(self) self.tooltip = self.value end
1001+
}
1002+
GUI.exes.update = dt.new_widget('button'){
1003+
label = 'update',
1004+
tooltip ='update the binary paths with current values',
1005+
clicked_callback = function() ExeUpdate({AIS,ENF,EXF}) end
1006+
}
9611007
temp = GUI.Target.format.value
9621008
if temp == 'tif' then temp = 1
9631009
elseif temp == 'jpg' then temp = 2
@@ -1020,16 +1066,23 @@ local box_Target = dt.new_widget('box'){
10201066
GUI.Target.copy_tags,
10211067
GUI.Target.add_tags
10221068
}
1069+
local box_exes = dt.new_widget('box'){
1070+
orientation = 'vertical',
1071+
GUI.exes.align_image_stack,
1072+
GUI.exes.enfuse,
1073+
GUI.exes.exiftool,
1074+
GUI.exes.update
1075+
}
10231076
GUI.options_contain = dt.new_widget('stack'){
1024-
active = 2,
10251077
box_AIS,
10261078
box_ENF,
1027-
box_Target
1079+
box_Target,
1080+
box_exes
10281081
}
10291082
GUI.show_options = dt.new_widget('combobox'){
10301083
label = "show options",
10311084
tooltip = "show options for specified aspect of output",
1032-
selected = 1,
1085+
selected = 2,
10331086
'align image stack', 'enfuse/enblend', 'target file',
10341087
changed_callback = function(self)
10351088
GUI.options_contain.active = self.selected
@@ -1040,7 +1093,13 @@ GUI.show_options = dt.new_widget('combobox'){
10401093
dt.preferences.write(mod, 'active_current_preset_ind', 'integer', self.selected)
10411094
end
10421095
}
1043-
1096+
if dt.preferences.read(mod, 'bin_exists', 'bool') then
1097+
GUI.options_contain.active = 2
1098+
GUI.show_options.sensitive = true
1099+
else
1100+
GUI.options_contain.active = 4
1101+
GUI.show_options.sensitive = false
1102+
end
10441103
local storage_widget = dt.new_widget("box") {
10451104
orientation = "vertical",
10461105
GUI.show_options,

0 commit comments

Comments
 (0)