1
1
--[[
2
2
This file is part of darktable,
3
- copyright (c) 2018, 2020, 2023 Bill Ferguson <[email protected] >
3
+ copyright (c) 2018, 2020, 2023, 2024 Bill Ferguson <[email protected] >
4
4
5
5
darktable is free software: you can redistribute it and/or modify
6
6
it under the terms of the GNU General Public License as published by
@@ -60,7 +60,7 @@ local gettext = dt.gettext
60
60
61
61
62
62
-- Tell gettext where to find the .mo file translating messages for a particular domain
63
- dt .gettext .bindtextdomain (" script_manager" ,dt .configuration .config_dir .. " /lua/locale/" )
63
+ dt .gettext .bindtextdomain (" script_manager" , dt .configuration .config_dir .. " /lua/locale/" )
64
64
65
65
local function _ (msgid )
66
66
return gettext .dgettext (" script_manager" , msgid )
241
241
local function get_repo_status (repo )
242
242
local old_log_level = set_log_level (sm .log_level )
243
243
244
- local p = io.popen (" cd " .. repo .. CS .. " git status" )
244
+ local p = dtsys . io_popen (" cd " .. repo .. CS .. " git status" )
245
245
246
246
if p then
247
247
local data = p :read (" *a" )
@@ -259,7 +259,7 @@ local function get_current_repo_branch(repo)
259
259
260
260
local branch = nil
261
261
262
- local p = io.popen (" cd " .. repo .. CS .. " git branch --all" )
262
+ local p = dtsys . io_popen (" cd " .. repo .. CS .. " git branch --all" )
263
263
264
264
if p then
265
265
local data = p :read (" *a" )
@@ -289,7 +289,7 @@ local function get_repo_branches(repo)
289
289
local old_log_level = set_log_level (sm .log_level )
290
290
291
291
local branches = {}
292
- local p = io.popen (" cd " .. repo .. CS .. " git pull --all" .. CS .. " git branch --all" )
292
+ local p = dtsys . io_popen (" cd " .. repo .. CS .. " git pull --all" .. CS .. " git branch --all" )
293
293
294
294
if p then
295
295
local data = p :read (" *a" )
@@ -329,7 +329,7 @@ local function checkout_repo_branch(repo, branch)
329
329
330
330
log .msg (log .info , " checkout out branch " .. branch .. " from repository " .. repo )
331
331
332
- os.execute (" cd " .. repo .. CS .. " git checkout " .. branch )
332
+ dtsys . os_execute (" cd " .. repo .. CS .. " git checkout " .. branch )
333
333
334
334
restore_log_level (old_log_level )
335
335
end
@@ -417,7 +417,7 @@ local function get_script_metadata(script)
417
417
-- grab the script_data.metadata table
418
418
description = string.match (content , " script_data%.metadata = %{\r ?\n (.-)\r ?\n %}" )
419
419
else
420
- log .msg (log .error , _ ( " Cant read from " .. script ) )
420
+ log .msg (log .error , " cant read from " .. script )
421
421
end
422
422
423
423
if description then
@@ -459,7 +459,7 @@ local function get_script_doc(script)
459
459
-- assume that the second block comment is the documentation
460
460
description = string.match (content , " %-%-%[%[.-%]%].-%-%-%[%[(.-)%]%]" )
461
461
else
462
- log .msg (log .error , _ ( " Cant read from " .. script ) )
462
+ log .msg (log .error , " can't read from " .. script )
463
463
end
464
464
if description then
465
465
restore_log_level (old_log_level )
@@ -489,7 +489,7 @@ local function activate(script)
489
489
490
490
if status then
491
491
pref_write (script .script_name , " bool" , true )
492
- log .msg (log .screen , _ (" Loaded " ) .. script .script_name )
492
+ log .msg (log .screen , _ (string.format ( " loaded %s " , script .script_name )) )
493
493
script .running = true
494
494
495
495
if err ~= true then
@@ -503,9 +503,9 @@ local function activate(script)
503
503
end
504
504
505
505
else
506
- log .msg (log .screen , script . script_name .. _ ( " failed to load" ))
507
- log .msg (log .error , " Error loading " .. script .script_name )
508
- log .msg (log .error , " Error message: " .. err )
506
+ log .msg (log .screen , _ ( string.format ( " %s failed to load" , script . script_name ) ))
507
+ log .msg (log .error , " error loading " .. script .script_name )
508
+ log .msg (log .error , " error message: " .. err )
509
509
end
510
510
511
511
else -- script is a lib and loaded but hidden and the user wants to reload
@@ -549,13 +549,13 @@ local function deactivate(script)
549
549
end
550
550
551
551
log .msg (log .info , " turned off " .. script .script_name )
552
- log .msg (log .screen , script . name .. _ ( " stopped" ))
552
+ log .msg (log .screen , _ ( string.format ( " %s stopped" , script . name ) ))
553
553
554
554
else
555
555
script .running = false
556
556
557
557
log .msg (log .info , " setting " .. script .script_name .. " to not start" )
558
- log .msg (log .screen , script . name .. _ ( " will not start when darktable is restarted" ))
558
+ log .msg (log .screen , _ ( string.format ( " %s will not start when darktable is restarted" , script . name ) ))
559
559
end
560
560
561
561
restore_log_level (old_log_level )
@@ -665,7 +665,7 @@ local function scan_scripts(script_dir)
665
665
log .msg (log .debug , " find command is " .. find_cmd )
666
666
667
667
-- scan the scripts
668
- local output = io.popen (find_cmd )
668
+ local output = dtsys . io_popen (find_cmd )
669
669
for line in output :lines () do
670
670
log .msg (log .debug , " line is " .. line )
671
671
local l = string.gsub (line , ds .sanitize_lua (LUA_DIR ) .. PS , " " ) -- strip the lua dir off
@@ -695,7 +695,7 @@ local function update_scripts()
695
695
local git = sm .executables .git
696
696
697
697
if not git then
698
- dt . print ( _ (" ERROR: git not found. Install or specify the location of the git executable." ))
698
+ log . msg ( log . screen , _ (" ERROR: git not found. Install or specify the location of the git executable." ))
699
699
return
700
700
end
701
701
@@ -709,7 +709,7 @@ local function update_scripts()
709
709
end
710
710
711
711
if result == 0 then
712
- dt . print ( _ (" lua scripts successfully updated" ))
712
+ log . msg ( log . screen , _ (" lua scripts successfully updated" ))
713
713
end
714
714
715
715
restore_log_level (old_log_level )
@@ -749,9 +749,9 @@ local function scan_repositories()
749
749
find_cmd = " dir /b/s /a:d " .. LUA_DIR .. PS .. " *.git | sort"
750
750
end
751
751
752
- log .msg (log .debug , _ ( " find command is " ) .. find_cmd )
752
+ log .msg (log .debug , " find command is " .. find_cmd )
753
753
754
- local output = io.popen (find_cmd )
754
+ local output = dtsys . io_popen (find_cmd )
755
755
756
756
for line in output :lines () do
757
757
local l = string.gsub (line , ds .sanitize_lua (LUA_DIR ) .. PS , " " ) -- strip the lua dir off
@@ -799,7 +799,7 @@ local function install_scripts()
799
799
local folder = sm .widgets .new_folder .text
800
800
801
801
if string.match (du .join (sm .folders , " " ), ds .sanitize_lua (folder )) then
802
- log .msg (log .screen , _ (" folder " ) .. folder .. _ ( " is already in use. Please specify a different folder name." ))
802
+ log .msg (log .screen , _ (string.format ( " folder %s is already in use. Please specify a different folder name." , folder ) ))
803
803
log .msg (log .error , " folder " .. folder .. " already exists, returning..." )
804
804
restore_log_level (old_log_level )
805
805
return
@@ -810,7 +810,7 @@ local function install_scripts()
810
810
local git = sm .executables .git
811
811
812
812
if not git then
813
- dt . print ( _ (" ERROR: git not found. Install or specify the location of the git executable." ))
813
+ log . msg ( log . screen , _ (" ERROR: git not found. Install or specify the location of the git executable." ))
814
814
restore_log_level (old_log_level )
815
815
return
816
816
end
@@ -849,12 +849,12 @@ local function install_scripts()
849
849
sm .widgets .new_folder .text = " "
850
850
sm .widgets .main_menu .selected = 3
851
851
else
852
- dt . print ( _ (" No scripts found to install" ))
852
+ log . msg ( log . screen , _ (" No scripts found to install" ))
853
853
log .msg (log .error , " scan_scripts returned " .. count .. " scripts found. Not adding to folder_selector" )
854
854
end
855
855
856
856
else
857
- dt . print ( _ (" failed to download scripts" ))
857
+ log . msg ( log . screen , _ (" failed to download scripts" ))
858
858
end
859
859
860
860
restore_log_level (old_log_level )
@@ -1006,7 +1006,7 @@ local function paginate(direction)
1006
1006
last = first + sm .page_status .num_buttons - 1
1007
1007
end
1008
1008
1009
- sm .widgets .page_status .label = _ (" Page " ) .. cur_page .. _ ( " of " ) .. max_pages
1009
+ sm .widgets .page_status .label = _ (string.format ( " page %d of %d " , cur_page , max_pages ))
1010
1010
1011
1011
populate_buttons (folder , first , last )
1012
1012
@@ -1177,17 +1177,6 @@ local function install_module()
1177
1177
log .msg (log .debug , " set run to true, loading preferences" )
1178
1178
load_preferences ()
1179
1179
scan_repositories ()
1180
- --[[ dt.print_log("\n\nsetting sm visible false\n\n")
1181
- dt.gui.libs["script_manager"].visible = false
1182
- dt.control.sleep(5000)
1183
- dt.print_log("setting sm visible true")
1184
- dt.gui.libs["script_manager"].visible = true
1185
- --[[dt.control.sleep(5000)
1186
- dt.print_log("setting sm expanded false")
1187
- dt.gui.libs["script_manager"].expanded = false
1188
- dt.control.sleep(5000)
1189
- dt.print_log("setting sm expanded true")
1190
- dt.gui.libs["script_manager"].expanded = true]]
1191
1180
1192
1181
restore_log_level (old_log_level )
1193
1182
end
@@ -1217,7 +1206,7 @@ if check_for_updates then
1217
1206
-- probably upgraded from an earlier api version so get back to master
1218
1207
-- to use the latest version of script_manager to get the proper API
1219
1208
checkout_repo_branch (repo , " master" )
1220
- log .msg (log .screen , " lua API version reset, please restart darktable" )
1209
+ log .msg (log .screen , _ ( " lua API version reset, please restart darktable" ) )
1221
1210
1222
1211
elseif LUA_API_VER == current_branch then
1223
1212
-- do nothing, we are fine
@@ -1353,7 +1342,7 @@ sm.widgets.disable_scripts = dt.new_widget("button"){
1353
1342
local LUARC = dt .configuration .config_dir .. PS .. " luarc"
1354
1343
df .file_move (LUARC , LUARC .. " .disabled" )
1355
1344
log .msg (log .info , " lua scripts disabled" )
1356
- dt . print ( _ (" lua scripts will not run the next time darktable is started" ))
1345
+ log . msg ( log . screen , _ (" lua scripts will not run the next time darktable is started" ))
1357
1346
end
1358
1347
}
1359
1348
@@ -1414,7 +1403,7 @@ end
1414
1403
local page_back = " <"
1415
1404
local page_forward = " >"
1416
1405
1417
- sm .widgets .page_status = dt .new_widget (" label" ){label = _ (" Page :" )}
1406
+ sm .widgets .page_status = dt .new_widget (" label" ){label = _ (" page :" )}
1418
1407
1419
1408
sm .widgets .page_back = dt .new_widget (" button" ){
1420
1409
label = page_back ,
@@ -1445,7 +1434,7 @@ sm.widgets.scripts = dt.new_widget("box"){
1445
1434
orientation = vertical ,
1446
1435
dt .new_widget (" section_label" ){label = _ (" " )},
1447
1436
dt .new_widget (" label" ){label = " " },
1448
- dt .new_widget (" label" ){label = _ (" Scripts " )},
1437
+ dt .new_widget (" label" ){label = _ (" scripts " )},
1449
1438
sm .widgets .folder_selector ,
1450
1439
sm .widgets .page_control ,
1451
1440
table.unpack (sm .widgets .boxes ),
@@ -1529,7 +1518,7 @@ else
1529
1518
function (event , old_view , new_view )
1530
1519
if new_view .name == " lighttable" and old_view .name == " darkroom" then
1531
1520
install_module ()
1532
- end
1521
+ end
1533
1522
end
1534
1523
)
1535
1524
sm .event_registered = true
0 commit comments