Skip to content

Commit 8392f6f

Browse files
author
tejovanthn
committed
enables custom number of thumbnails per row
Changes the thumbs_per_line from a text field to a slider
1 parent 9a5ede0 commit 8392f6f

File tree

1 file changed

+39
-23
lines changed

1 file changed

+39
-23
lines changed

official/selection_to_pdf.lua

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
--[[
22
This file is part of darktable,
33
copyright (c) 2015 Jérémy Rosen & Pascal Obry
4+
edited 2016 Tejovanth N
45
56
darktable is free software: you can redistribute it and/or modify
67
it under the terms of the GNU General Public License as published by
@@ -28,6 +29,8 @@ USAGE
2829
2930
This plugin will add a new exporter that will allow you to generate the pdf file
3031
32+
Plugin allows you to choose how many thumbnails you need per row
33+
3134
3235
]]
3336
local dt = require "darktable"
@@ -40,20 +43,29 @@ dt.preferences.register
4043
"xdg-open")
4144

4245
local title_widget = dt.new_widget("entry") {
43-
placeholder="Title"
46+
placeholder="Title"
47+
}
48+
local no_of_thumbs_widget = dt.new_widget("slider")
49+
{
50+
label = "Thumbs per Line",
51+
soft_min = 1, -- The soft minimum value for the slider, the slider can't go beyond this point
52+
soft_max = 10, -- The soft maximum value for the slider, the slider can't go beyond this point
53+
hard_min = 1, -- The hard minimum value for the slider, the user can't manually enter a value beyond this point
54+
hard_max = 10, -- The hard maximum value for the slider, the user can't manually enter a value beyond this point
55+
value = 4 -- The current value of the slider
4456
}
4557
local widget = dt.new_widget("box") {
46-
orientation=horizontal,
47-
dt.new_widget("label"){label = "Title:"},
48-
title_widget
58+
orientation=horizontal,
59+
dt.new_widget("label"){label = "Title:"},
60+
title_widget,
61+
dt.new_widget("label"){label = "Thumbnails per row:"},
62+
no_of_thumbs_widget
4963
}
5064

5165
local ending = [[
5266
\end{document}
5367
]]
5468

55-
local thumbs_per_line=4;
56-
local width = 1/thumbs_per_line-0.01
5769

5870
local filename =dt.configuration.tmp_dir.."/pdfout.tex"
5971

@@ -93,23 +105,27 @@ dt.register_storage("export_pdf","Export thumbnails to pdf",
93105
local my_title = title_widget.text
94106
if my_title == "" then
95107
my_title = "Title"
96-
end
97-
local preamble = [[
98-
\documentclass[a4paper,10pt]{article}
99-
\usepackage{graphicx}
100-
\pagestyle{empty}
101-
\parindent0pt
102-
\usepackage{geometry}
103-
\geometry{a4paper,left=5mm,right=5mm, top=5mm, bottom=5mm}
104-
\begin{document}
105-
{\Large\bfseries ]]..my_title..[[} \\
106-
\bigskip\bigskip
107-
]]
108-
109-
local errmsg
110-
local latexfile
111-
latexfile,errmsg=io.open(filename,"w")
112-
if not latexfile then
108+
end
109+
local thumbs_per_line = no_of_thumbs_widget.value
110+
thumbs_per_line = tonumber(thumbs_per_line)
111+
width = (1/thumbs_per_line) - 0.01
112+
113+
local preamble = [[
114+
\documentclass[a4paper,10pt]{article}
115+
\usepackage{graphicx}
116+
\pagestyle{empty}
117+
\parindent0pt
118+
\usepackage{geometry}
119+
\geometry{a4paper,left=5mm,right=5mm, top=5mm, bottom=5mm}
120+
\begin{document}
121+
{\Large\bfseries ]]..my_title..[[} \\
122+
\bigskip\bigskip
123+
]]
124+
125+
local errmsg
126+
local latexfile
127+
latexfile,errmsg=io.open(filename,"w")
128+
if not latexfile then
113129
error(errmsg)
114130
end
115131
my_write(latexfile,preamble)

0 commit comments

Comments
 (0)