Browse code

Merge branch 'Version-0.6' into master

Lorenz Glaser authored onSun/Sep/2020 06:0:th
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,646 @@
1
+#!/boot/system/bin/yab
2
+REM Requires yab v 1.7
3
+REM Start of Creating 2020-08-07
4
+REM Copyright by Christian Albrecht, BeSly Software Solutions
5
+REM Developer: Christian Albrecht
6
+
7
+//Program directory
8
+if (peek("isbound")) then
9
+	ProgramFolder$ = peek$("directory")
10
+else
11
+	ProgramFolder$ = system$("pwd")
12
+	ProgramFolder$ = left$(ProgramFolder$, len(ProgramFolder$)-1)
13
+fi
14
+
15
+if(IfExists("/boot/home/config/settings/.besly")) then
16
+else
17
+	Output$=System$("mkdir /boot/home/.besly")
18
+endif
19
+
20
+if(IfExists("/boot/home/.besly/ghostscriptGUI")) then
21
+else
22
+	Output$=System$("mkdir /boot/home/.besly/ghostscriptGUI")
23
+endif
24
+
25
+if(IfExists("/boot/home/.besly/ghostscriptGUI/temp")) then
26
+else
27
+	Output$=System$("mkdir /boot/home/.besly/ghostscriptGUI/temp")
28
+endif
29
+
30
+if(IfExists("/boot/home/config/settings/.besly/GSGui")) then
31
+	if(IfExists("/boot/home/config/settings/.besly/GSGui/settings.cfg")) then
32
+	else
33
+		writefile = open("/boot/home/config/settings/.besly/GSGui/settings.cfg", "a")
34
+			Output$=System$("addattr -t string ExportFolder /boot/home /boot/home/config/settings/.besly/GSGui/settings.cfg")
35
+		close(writefile)
36
+	endif	
37
+else
38
+	Output$=System$("mkdir /boot/home/config/settings/.besly/GSGui")
39
+	writefile = open("/boot/home/config/settings/.besly/GSGui/settings.cfg", "a")
40
+		Output$=System$("addattr -t string ExportFolder /boot/home /boot/home/config/settings/.besly/GSGui/settings.cfg")
41
+	close(writefile)
42
+endif
43
+
44
+Version$="0.5"
45
+BuildDate$="2020-09-04"
46
+Developer$="Christian Albrecht (Lelldorin)"
47
+
48
+screenWidth = peek("desktopwidth")
49
+screenHeight = peek("desktopheight")
50
+
51
+ProgramName$="GhostScript GUI"
52
+ProgramID$="GSGUI"
53
+
54
+WINDOW OPEN screenWidth/2-300,screenHeight/2-350 to screenWidth/2+300,screenHeight/2+350, ProgramID$, ProgramName$
55
+	WindowWidth = WINDOW GET ProgramID$, "Width"
56
+	WindowHeight = WINDOW GET ProgramID$, "Height"
57
+	WINDOW SET ProgramID$, "Flags", "Not-Zoomable, Not-Minimizable, Not-H-Resizable, Not-V-Resizable, Not-Resizable"
58
+	//LAYOUT "Top, Left, Right, Bottom", ProgramID$
59
+	
60
+	MENU "App", "About", "a", ProgramID$
61
+	MENU "App", "--", "", ProgramID$
62
+	MENU "App", "Settings", "", ProgramID$
63
+	MENU "App", "--", "", ProgramID$
64
+	MENU "App", "Quit", "q", ProgramID$
65
+	
66
+	
67
+	STACKVIEW 0,0 TO 600,700, "SV:Main", 3, ProgramID$
68
+	 	//STACK MAIN 1
69
+		BOXVIEW 5,30 TO 210,330, "BV:Files", "Original files", 2, "SV:Main1"
70
+		VIEW 2,2 TO 196,275, "VI:Files", "BV:Files"
71
+			//DRAW SET "BGColor", 152,152,152, "VI:Files"
72
+			VIEW DROPZONE "VI:Files"
73
+			VIEW 1,1 TO 193,97, "VI:Dropzone", "VI:Files"
74
+					VIEW DROPZONE "VI:Dropzone"
75
+					draw set "highcolor", 255,255,255, "VI:Dropzone"
76
+					draw set "lowcolor", 0,0,0, "VI:Dropzone"
77
+					pattern$="000085042085042085042085"
78
+						draw set 0, pattern$
79
+						draw rect 0,0 to 205,95, "VI:Dropzone"
80
+						draw set 0, "lowsolid"
81
+					TOOLTIP "VI:Dropzone", "drop "+Chr$(34)+"file"+Chr$(34)+" or "+Chr$(34)+"folder"+Chr$(34)+" here."
82
+			VIEW 1,98 TO 193,273, "VI:Files2", "VI:Files"
83
+			COLUMNBOX 0,0 TO 192,175, "CB:Files", 3, "", "VI:Files2"
84
+				COLUMNBOX COLUMN "CB:Files", "", 1, 40, 40, 40, "align-center"
85
+				COLUMNBOX COLUMN "CB:Files", "Filename", 2, 140, 340, 140, "align-left"
86
+				COLUMNBOX COLUMN "CB:Files", "Path",3, 140, 140, 140, "align-center"
87
+				COLUMNBOX COLUMN "CB:Files", "",4, 140, 140, 140, "align-center"
88
+		
89
+		BOXVIEW 5,340 TO 210,685, "BV:Temp", "Temp files", 2, "SV:Main1"	
90
+			VIEW 2,2 TO 196,655, "VI:Temp", "BV:Temp"
91
+				COLUMNBOX 0,0 TO 194,318, "CB:Temp", 3, "", "VI:Temp"
92
+					COLUMNBOX COLUMN "CB:Temp", "", 1, 40, 40, 40, "align-center"
93
+					COLUMNBOX COLUMN "CB:Temp", "Filename", 2, 140, 340, 140, "align-left"
94
+					COLUMNBOX COLUMN "CB:Temp", "Path",3, 140, 140, 140, "align-center"
95
+					COLUMNBOX COLUMN "CB:Temp", "",4, 140, 140, 140, "align-center"
96
+												
97
+		BOXVIEW 220,30 TO 595,200, "BV:Menu", "Menu", 2, "SV:Main1"
98
+			VIEW 2,2 TO 366,145, "VI:Menu", "BV:Menu"
99
+				BUTTON 1,0 TO 364,30, "BT:Merge", "Merge PDF", "VI:Menu"
100
+					option set "BT:Merge", "enabled", false
101
+				BUTTON 1,31 TO 364,61, "BT:Split", "Split PDF", "VI:Menu"
102
+					option set "BT:Split", "enabled", false
103
+					TOOLTIP "BT:Split", "You need to select a orginal file first."
104
+				BUTTON 1,62 TO 364,92, "BT:Convert", "Convert PDF", "VI:Menu"
105
+					option set "BT:Convert", "enabled", false
106
+					TOOLTIP "BT:Split", "You need to select a orginal file first."
107
+		
108
+		BOXVIEW 220,210 TO 595,618, "BV:Options", "Options", 2, "SV:Main1"	
109
+			STACKVIEW 2,2 TO 366,382, "SV:Options", 10, "BV:Options"
110
+			
111
+			//Merge (Stack2)
112
+			TEXTCONTROL 5,5 TO 324,25, "TC:FilenameMerge", "Filename: ", "Filename", "SV:Options2"
113
+				DRAW TEXT 335,25, ".pdf", "SV:Options2"
114
+			DROPBOX 5,45 TO 324,65, "DB:DPI", "Downsample: ", "SV:Options2"
115
+				DROPBOX ADD "DB:DPI", "Without specification"
116
+				DROPBOX ADD "DB:DPI", "--"
117
+				DROPBOX ADD "DB:DPI", "100"
118
+				DROPBOX ADD "DB:DPI", "200"
119
+				DROPBOX ADD "DB:DPI", "300"				
120
+				DPI$="Without specification"
121
+				DRAW TEXT 335,65, "DPI", "SV:Options2"
122
+			
123
+			//Split (Stack3)
124
+			TEXTCONTROL 5,5 TO 324,25, "TC:FilenameSplit", "Filename: ", "Filename", "SV:Options3"
125
+				DRAW TEXT 335,25, ".pdf", "SV:Options3"
126
+			//Slider First Page 5,45
127
+			VIEW 5,45 TO 360,100, "VI:StartPage", "SV:Options3"			
128
+			VIEW 5,105 TO 360,150, "VI:LastPage", "SV:Options3"
129
+			
130
+			TEXTCONTROL 5,5 TO 324,25, "TC:FilenameConvert", "Filename: ", "Filename", "SV:Options4"
131
+				DRAW TEXT 335,25, ".***", "SV:Options4"
132
+			DROPBOX 5,40 TO 324,60, "DB:Format", "Convert to: ", "SV:Options4"
133
+				DROPBOX ADD "DB:Format", "Image"
134
+				DROPBOX ADD "DB:Format", "Text"
135
+			
136
+			DROPBOX 5,75 TO 324,95, "DB:ImageFormat", "Image format: ", "SV:Options4"
137
+				DROPBOX ADD "DB:ImageFormat", "jpeg"
138
+				DROPBOX ADD "DB:ImageFormat", "png alpha"
139
+				DROPBOX ADD "DB:ImageFormat", "png gray"
140
+				option set "DB:ImageFormat", "enabled", false
141
+			
142
+			//Slider First Page
143
+			VIEW 5,105 TO 360,160, "VI:StartPageConvert", "SV:Options4"
144
+			VIEW 5,165 TO 360,220, "VI:LastPageConvert", "SV:Options4"
145
+	
146
+		BOXVIEW 220,628 TO 595,685, "BV:Go", "Proceed", 2, "SV:Main1" 	
147
+			STACKVIEW 2,2 TO 366,32, "SV:Go", 2, "BV:Go"
148
+				BUTTON 1,0 TO 364,30, "BT:Proceed", "Proceed", "SV:Go1"
149
+					option set "BT:Proceed", "enabled", false
150
+				STATUSBAR 1,-20 TO 364,25, "SB:Go", "", "", "SV:Go2"
151
+			
152
+		SplitPDF=0
153
+		//STACK MAIN 2
154
+		BOXVIEW 5,30 TO 595,685, "BV:Settings", "Settings", 2, "SV:Main2"
155
+			ExportFolder$=System$("catattr ExportFolder /boot/home/config/settings/.besly/GSGui/settings.cfg | cut -f3 -d:")
156
+			TEXTCONTROL 5,5 TO 475,25, "TC:ExportFolder", "Export folder: ", ExportFolder$, "BV:Settings"
157
+				BUTTON 480,5 TO 580,29, "BT:ExportFolder", "Select", "BV:Settings"
158
+				
159
+				BUTTON 4,600 TO 580,630, "BT:Close", "Close", "BV:Settings"
160
+			
161
+		//STACK MAIN 3
162
+		BOXVIEW 5,30 TO 595,685, "BV:About", "About", 2, "SV:Main3"	
163
+			
164
+			DRAW TEXT 10,30, "Ghostscript GUI", "BV:About"
165
+			DRAW TEXT 10,50, "Version: "+Version$, "BV:About"
166
+			DRAW TEXT 10,70, "Build date: "+BuildDate$, "BV:About"
167
+			DRAW TEXT 10,90, "Developer: "+Developer$, "BV:About"
168
+			DRAW TEXT 10,110, "Vendor: BeSly Software Solutions", "BV:About"
169
+			
170
+			DRAW TEXT 10,200, "This is a simple GUI for the command line tool "+Chr$(34)+"ghostscript"+Chr$(34),"BV:About"
171
+			BUTTON 4,600 TO 580,630, "BT:Close", "Close", "BV:About"
172
+		
173
+		
174
+		
175
+		
176
+			
177
+//Main Loop
178
+dim part$(1)
179
+inloop = true
180
+while(inloop)
181
+
182
+	msg$ = message$
183
+	if (split(msg$, part$(), ":|") > 2) then
184
+		PartOne$=part$(1)
185
+		PartTwo$ = part$(2)
186
+		PartThree$ = part$(3)
187
+	fi
188
+	if (split(msg$, part$(), ":|") > 3) then
189
+		PartFour$ = part$(4)
190
+	fi
191
+	if (msg$ <> "") print msg$
192
+	
193
+	switch msg$
194
+	//Settings
195
+	case ProgramID$+":App:Settings|"
196
+		STACKVIEW SET "SV:Main" , 2		
197
+		break
198
+	
199
+	case "BT:ExportFolder|"
200
+		ExportFolder$=System$("catattr ExportFolder /boot/home/config/settings/.besly/GSGui/settings.cfg | cut -f3 -d:")
201
+		SetExportFolder$ = FILEPANEL "Load-Directory", "Select export folder:", trim$(ExportFolder$)
202
+		TEXTCONTROL SET "TC:ExportFolder", SetExportFolder$ 
203
+		Output$=System$("addattr -t string ExportFolder "+SetExportFolder$+" /boot/home /boot/home/config/settings/.besly/GSGui/settings.cfg")
204
+		break
205
+		
206
+	case "BT:Close|"
207
+		STACKVIEW SET "SV:Main" , 1		
208
+		break
209
+	
210
+	//App
211
+	case  ProgramID$+":App:Quit|" 
212
+      	case  ProgramID$+":_QuitRequested|"
213
+		WINDOW CLOSE ProgramID$
214
+		break
215
+		
216
+	case  ProgramID$+":App:About|" 
217
+		STACKVIEW SET "SV:Main" , 3		
218
+		break
219
+		
220
+		
221
+	case "VI:Dropzone:_Dropped:"+PartFour$+"|"
222
+		option set "BT:Merge", "enabled", false
223
+		option set "BT:Split", "enabled", false
224
+		option set "BT:Convert", "enabled", false
225
+		if(right$(PartFour$, 3) ="pdf")then
226
+			dim GetFileName$(1)
227
+			files = split(PartFour$, GetFileName$(), "/")
228
+			i=0
229
+			path$=""
230
+			for i = 1 to files-1
231
+				path$=path$+GetFileName$(i)+"/"
232
+			next i
233
+			print "path:"+path$
234
+		
235
+			coutfiles = COLUMNBOX COUNT "CB:Files"
236
+
237
+			COLUMNBOX ADD "CB:Files", 1, coutfiles+1, 40, "__Path__="+PartFour$
238
+			COLUMNBOX ADD "CB:Files", 2, coutfiles+1, 40, trim$(GetFileName$(files))
239
+			COLUMNBOX ADD "CB:Files", 3, coutfiles+1, 40, trim$(path$)
240
+			option set "BT:Merge", "enabled", true
241
+		else
242
+			ALERT "Filetype not supported", "Ok", "warning"
243
+		endif
244
+		option set "BT:Merge", "enabled", true
245
+		option set "BT:Split", "enabled", false
246
+		break	
247
+	
248
+	
249
+	case "BT:Merge|"
250
+		ClearTemp()
251
+		ProcessArea$="Merge"
252
+		STACKVIEW SET "SV:Options", 2
253
+		option set "BT:Proceed", "enabled", true
254
+		break
255
+		
256
+	case "DB:DPI:"+PartThree$+"|"
257
+		DPI$=PartThree$
258
+		break
259
+	
260
+		
261
+	//Split PDF
262
+	case "BT:Split|"
263
+		ClearTemp()
264
+		ProcessArea$="Split"
265
+		option set "BT:Merge", "enabled", false
266
+		option set "BT:Split", "enabled", false
267
+		option set "BT:Convert", "enabled", false
268
+		print SelectedPath$+SelectedItem$
269
+		pagecount$=system$("gs -dNODISPLAY  -dNOPAUSE -dBATCH "+"\""+SelectedPath$+SelectedItem$+"\""+"|grep Page|wc -l")
270
+		VIEW REMOVE "VI:StartPage"
271
+		VIEW 5,45 TO 360,100, "VI:StartPage", "SV:Options3"
272
+			SLIDER 0,0 TO 355,25, "SL:StartPage", "Start page: ", 1, val(pagecount$), "VI:StartPage"
273
+				SLIDER LABEL "SL:StartPage", "1", pagecount$
274
+		VIEW REMOVE "VI:LastPage"
275
+		VIEW 5,105 TO 360,160, "VI:LastPage", "SV:Options3"
276
+			SLIDER 0,0 TO 355,25, "SL:LastPage", "Last page: ", 1, val(pagecount$), "VI:LastPage"
277
+				SLIDER LABEL "SL:LastPage", "1", pagecount$
278
+					SLIDER SET "SL:LastPage", val(pagecount$)
279
+		FirstPageValue=1
280
+		LastPageValue=1
281
+		SplitPDF=1
282
+		STACKVIEW SET "SV:Options", 3
283
+		option set "BT:Proceed", "enabled", true
284
+		break
285
+		
286
+	case "CB:"+PartTwo$+":ON|"
287
+		if(PartTwo$="123")then
288
+			CHECKBOX SET "CB:123", 1
289
+			CHECKBOX SET "CB:135", 0
290
+			CHECKBOX SET "CB:246", 0
291
+		elseif(PartTwo$="135")then
292
+			CHECKBOX SET "CB:123", 0
293
+			CHECKBOX SET "CB:135", 1
294
+			CHECKBOX SET "CB:246", 0
295
+		elseif(PartTwo$="246")then
296
+			CHECKBOX SET "CB:123", 0
297
+			CHECKBOX SET "CB:135", 0
298
+			CHECKBOX SET "CB:246", 1
299
+		endif
300
+		Numbering$=PartTwo$
301
+		break
302
+	
303
+	case "CB:"+PartTwo$+":OFF|"
304
+		CHECKBOX SET "CB:123", 1
305
+		CHECKBOX SET "CB:135", 0
306
+		CHECKBOX SET "CB:246", 0
307
+		Numbering$="123"
308
+		break
309
+	
310
+	
311
+	//Convert
312
+	case "BT:Convert|"
313
+		ClearTemp()
314
+		option set "BT:Merge", "enabled", false
315
+		option set "BT:Split", "enabled", false
316
+		option set "BT:Convert", "enabled", false
317
+		print SelectedPath$+SelectedItem$
318
+		pagecount$=system$("gs -dNODISPLAY  -dNOPAUSE -dBATCH "+"\""+SelectedPath$+SelectedItem$+"\""+"|grep Page|wc -l")
319
+		VIEW REMOVE "VI:StartPageConvert"
320
+		VIEW 5,105 TO 360,160, "VI:StartPageConvert", "SV:Options4"
321
+			SLIDER 0,0 TO 355,25, "SL:StartPageConvert", "Start page: ", 1, val(pagecount$), "VI:StartPageConvert"
322
+				SLIDER LABEL "SL:StartPageConvert", "1", pagecount$
323
+		VIEW REMOVE "VI:LastPageConvert"
324
+		VIEW 5,165 TO 360,220, "VI:LastPageConvert", "SV:Options4"
325
+			SLIDER 0,0 TO 355,25, "SL:LastPageConvert", "Last page: ", 1, val(pagecount$), "VI:LastPageConvert"
326
+				SLIDER LABEL "SL:LastPageConvert", "1", pagecount$
327
+					SLIDER SET "SL:LastPageConvert", val(pagecount$)
328
+		FirstPageValue=1
329
+		LastPageValue=1
330
+		SplitPDFConv=1
331
+		ProcessArea$="Convert"
332
+		option set "BT:Merge", "enabled", false
333
+		option set "BT:Split", "enabled", false
334
+		option set "BT:Convert", "enabled", false
335
+		
336
+		STACKVIEW SET "SV:Options", 4
337
+		option set "BT:Proceed", "enabled", true
338
+		break
339
+	
340
+	case "DB:Format:"+PartThree$+"|"
341
+		OutputFormat$=PartThree$
342
+		if(OutputFormat$="Image")then
343
+			option set "DB:ImageFormat", "enabled", true
344
+		elseif(OutputFormat$="Text")then	
345
+		endif
346
+		break
347
+		
348
+	case "DB:ImageFormat:"+PartThree$+"|"
349
+		OutputImageFormat$=PartThree$
350
+		print OutputImageFormat$
351
+		break
352
+			
353
+	
354
+	case "BT:Proceed|"	
355
+		STACKVIEW SET "SV:Go", 2
356
+		option set "BT:Merge", "enabled", false
357
+		option set "BT:Split", "enabled", false
358
+		option set "BT:Convert", "enabled", false
359
+		if(ProcessArea$="Merge")then
360
+			option set "TC:FilenameMerge", "enabled", false
361
+			option set "DB:DPI", "enabled", false
362
+			OutputFilename$=TEXTCONTROL GET$ "TC:FilenameMerge"
363
+			ClearTemp()
364
+			FilesList$=""
365
+			coutfiles = COLUMNBOX COUNT "CB:Files"
366
+			i=0
367
+			process=100/coutfiles
368
+			status=process
369
+			for i = 1 to coutfiles
370
+				STATUSBAR SET "SB:Go", "", "", status
371
+				status=status+process
372
+				GetItem$ = COLUMNBOX GET$ "CB:Files", 2, i
373
+				GetPath$ = COLUMNBOX GET$ "CB:Files", 3, i
374
+				FilesList$=FilesList$+" "+trim$(GetPath$)+trim$(GetItem$)		
375
+				print GetItem$
376
+				print GetPath$
377
+			next i
378
+			if(DPI$="Without specification")then
379
+				print "in without DPI"
380
+				output$=system$("gs -dNOPAUSE  -sDEVICE=pdfwrite -sOUTPUTFILE=\"/boot/home/.besly/ghostscriptGUI/temp/"+OutputFilename$+".pdf\" -dBATCH "+FilesList$)
381
+			else
382
+				output$=system$("gs -dNOPAUSE -dDownsampleColorImages=true -dColorImageResolution="+DPI$+" -dDownsampleGrayImages=true -dGrayImageResolution="+DPI$+" -dDownsampleMonoImages=true -dMonoImageResolution="+DPI$+" -sDEVICE=pdfwrite -sOUTPUTFILE=\"/boot/home/.besly/ghostscriptGUI/temp/"+OutputFilename$+".pdf\" -dBATCH "+FilesList$)
383
+			endif	
384
+			STATUSBAR SET "SB:Go", "", "", status
385
+			status=status+process
386
+			ReadOutTemp()
387
+			option set "BT:Merge", "enabled", true
388
+			option set "TC:FilenameMerge", "enabled", true
389
+			option set "DB:DPI", "enabled", true
390
+		elseif(ProcessArea$="Split")then
391
+			SplitPDF=0
392
+			option set "TC:FilenameSplit", "enabled", false
393
+			option set "SL:StartPage", "enabled", false
394
+			option set "SL:LastPage", "enabled", false
395
+			OutputFilename$=TEXTCONTROL GET$ "TC:FilenameSplit"
396
+			ClearTemp()
397
+			print "pagcount: "+pagecount$
398
+			print "firstpage: "+str$(FirstPage)
399
+			print "lastapge: "+str$(LastPage)
400
+			pagecount=LastPage-FirstPage
401
+			print "pagcount: "+str$(pagecount)
402
+			if(pagecount<10)then
403
+				output$=system$("gs -dNOPAUSE -dBATCH -sOutputFile=\"/boot/home/.besly/ghostscriptGUI/temp/"+OutputFilename$+"%d.pdf\" -sDEVICE=pdfwrite -dFirstPage="+str$(FirstPage)+" -dLastPage="+str$(LastPage)+" "+SelectedPath$+SelectedItem$ )
404
+				print output$
405
+			elseif(pagecount>=10 and pagecount<100)then
406
+				output$=system$("gs -dNOPAUSE -dBATCH  -sOutputFile=\"/boot/home/.besly/ghostscriptGUI/temp/"+OutputFilename$+"%02d.pdf\" -sDEVICE=pdfwrite -dFirstPage="+str$(FirstPage)+" -dLastPage="+str$(LastPage)+" "+SelectedPath$+SelectedItem$)
407
+				print output$
408
+			elseif(pagecount>=100 and pagecount<1000)then
409
+				output$=system$("gs -dNOPAUSE -dBATCH -sOutputFile=\"/boot/home/.besly/ghostscriptGUI/temp/"+OutputFilename$+"%03d.pdf\" -sDEVICE=pdfwrite -dFirstPage="+str$(FirstPage)+" -dLastPage="+str$(LastPage)+" "+SelectedPath$+SelectedItem$)
410
+				print output$			
411
+			elseif(pagecount>=1000 and pagecount<10000)then
412
+				output$=system$("gs -dNOPAUSE -dBATCH -sOutputFile=\"/boot/home/.besly/ghostscriptGUI/temp/"+OutputFilename$+"%04d.pdf\" -sDEVICE=pdfwrite -dFirstPage="+str$(FirstPage)+" -dLastPage="+str$(LastPage)+" "+SelectedPath$+SelectedItem$)
413
+				print output$
414
+			endif
415
+			
416
+			
417
+			ReadOutTemp()
418
+			option set "BT:Merge", "enabled", true
419
+			option set "TC:FilenameSplit", "enabled", true
420
+			option set "SL:StartPage", "enabled", true
421
+			option set "SL:LastPage", "enabled", true
422
+		elseif(ProcessArea$="Convert")then
423
+			SplitPDFConv=0
424
+			ClearTemp()
425
+			OutputFilename$=TEXTCONTROL GET$ "TC:FilenameConvert"
426
+			print OutputFormat$
427
+			print OutputFolder$+"/"+OutputFilename$
428
+			if(OutputFormat$="Text")then
429
+				OutputFolder$ = FILEPANEL "Load-Directory", "Select output folder:", "/boot/home/Desktop"
430
+				output$=system$("gs -sDEVICE=txtwrite -sOutputFile="+OutputFolder$+"/"+OutputFilename$+".txt -dNOPAUSE -dBATCH "+SelectedPath$+SelectedItem$)
431
+				LAUNCH OutputFolder$
432
+			elseif(OutputFormat$="Image")then
433
+				print "in image"
434
+				if(OutputImageFormat$="png alpha")then
435
+					print "in alpha"
436
+					if(val(pagecount$)<10)then
437
+						output$=system$("gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pngalpha -dFirstPage="+str$(FirstPage)+" -dLastPage="+str$(LastPage)+" -sOutputFile=/boot/home/.besly/ghostscriptGUI/temp/"+OutputFilename$+"%d.png "+SelectedPath$+SelectedItem$)
438
+					elseif(val(pagecount$)<100)then
439
+						output$=system$("gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pngalpha -dFirstPage="+str$(FirstPage)+" -dLastPage="+str$(LastPage)+" -sOutputFile=/boot/home/.besly/ghostscriptGUI/temp/"+OutputFilename$+"%02d.png "+SelectedPath$+SelectedItem$)
440
+					elseif(val(pagecount$)<1000)then
441
+						output$=system$("gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pngalpha -dFirstPage="+str$(FirstPage)+" -dLastPage="+str$(LastPage)+" -sOutputFile=/boot/home/.besly/ghostscriptGUI/temp/"+OutputFilename$+"%03d.png "+SelectedPath$+SelectedItem$)
442
+					elseif(val(pagecount$)<10000)then
443
+						output$=system$("gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pngalpha -dFirstPage="+str$(FirstPage)+" -dLastPage="+str$(LastPage)+" -sOutputFile=/boot/home/.besly/ghostscriptGUI/temp/"+OutputFilename$+"%04d.png "+SelectedPath$+SelectedItem$)
444
+					endif				
445
+				elseif(OutputImageFormat$="png gray")then
446
+					print "in gray"
447
+					if(val(pagecount$)<10)then
448
+						output$=system$("gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pnggray -dFirstPage="+str$(FirstPage)+" -dLastPage="+str$(LastPage)+" -sOutputFile=/boot/home/.besly/ghostscriptGUI/temp/"+OutputFilename$+"%d.png "+SelectedPath$+SelectedItem$)
449
+					elseif(val(pagecount$)<100)then
450
+						output$=system$("gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pnggray -dFirstPage="+str$(FirstPage)+" -dLastPage="+str$(LastPage)+" -sOutputFile=/boot/home/.besly/ghostscriptGUI/temp/"+OutputFilename$+"%02d.png "+SelectedPath$+SelectedItem$)
451
+					elseif(val(pagecount$)<1000)then
452
+						output$=system$("gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pnggray -dFirstPage="+str$(FirstPage)+" -dLastPage="+str$(LastPage)+" -sOutputFile=/boot/home/.besly/ghostscriptGUI/temp/"+OutputFilename$+"%03d.png "+SelectedPath$+SelectedItem$)
453
+					elseif(val(pagecount$)<10000)then
454
+						output$=system$("gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pnggray -dFirstPage="+str$(FirstPage)+" -dLastPage="+str$(LastPage)+" -sOutputFile=/boot/home/.besly/ghostscriptGUI/temp/"+OutputFilename$+"%04d.png "+SelectedPath$+SelectedItem$)
455
+					endif	
456
+				elseif(OutputImageFormat$="jpeg")then
457
+					print "in gray"
458
+					if(val(pagecount$)<10)then
459
+						output$=system$("gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=jpeg -r144 -dFirstPage="+str$(FirstPage)+" -dLastPage="+str$(LastPage)+" -sOutputFile=/boot/home/.besly/ghostscriptGUI/temp/"+OutputFilename$+"%d.jpg "+SelectedPath$+SelectedItem$)
460
+					elseif(val(pagecount$)<100)then
461
+						output$=system$("gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=jpeg -r144 -dFirstPage="+str$(FirstPage)+" -dLastPage="+str$(LastPage)+" -sOutputFile=/boot/home/.besly/ghostscriptGUI/temp/"+OutputFilename$+"%02d.jpg "+SelectedPath$+SelectedItem$)
462
+					elseif(val(pagecount$)<1000)then
463
+						output$=system$("gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=jpeg -r144 -dFirstPage="+str$(FirstPage)+" -dLastPage="+str$(LastPage)+" -sOutputFile=/boot/home/.besly/ghostscriptGUI/temp/"+OutputFilename$+"%03d.jpg "+SelectedPath$+SelectedItem$)
464
+					elseif(val(pagecount$)<10000)then
465
+						output$=system$("gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=jpeg -r144 -dFirstPage="+str$(FirstPage)+" -dLastPage="+str$(LastPage)+" -sOutputFile=/boot/home/.besly/ghostscriptGUI/temp/"+OutputFilename$+"%04d.jpg "+SelectedPath$+SelectedItem$)
466
+					endif
467
+				endif
468
+				ReadOutTemp()
469
+			else
470
+			endif
471
+		endif
472
+		STACKVIEW SET "SV:Go", 1
473
+		break
474
+	
475
+	//Select file
476
+	case "CB:Files:_Select:"+PartFour$+"|"
477
+		option set "BT:Merge", "enabled", true
478
+		option set "BT:Split", "enabled", true
479
+		option set "BT:Convert", "enabled", true
480
+		wait 0.2
481
+		Selected$ = POPUPMENU 100,100, "Open|Remove|Remove All", "VI:Files2"
482
+		SelectedItem$ = COLUMNBOX GET$ "CB:Files", 2, val(PartFour$)
483
+		SelectedPath$ = COLUMNBOX GET$ "CB:Files", 3, val(PartFour$)
484
+		if(Selected$="Open")then
485
+			GetReadyItem$ = COLUMNBOX GET$ "CB:Files", 2, val(PartFour$)
486
+			GetReadyPath$ = COLUMNBOX GET$ "CB:Files", 3, val(PartFour$)
487
+			Launch GetReadyPath$+"/"+GetReadyItem$
488
+		elseif(Selected$="Remove")then
489
+			COLUMNBOX REMOVE  "CB:Files", val(PartFour$)
490
+		elseif(Selected$="Remove All")then
491
+			COLUMNBOX CLEAR "CB:Files"
492
+		endif
493
+		break
494
+	
495
+	case "CB:Temp:_Select:"+PartFour$+"|"
496
+		Selected$ = POPUPMENU 100,100, "Open|Export|Export All|Remove|Remove All", "VI:Temp"
497
+		GetItem$ = COLUMNBOX GET$ "CB:Temp", 2, val(PartFour$)
498
+		GetPath$ = COLUMNBOX GET$ "CB:Temp", 3, val(PartFour$)
499
+		if(Selected$="Open")then
500
+			GetReadyItem$ = COLUMNBOX GET$ "CB:Temp", 2, val(PartFour$)
501
+			GetReadyPath$ = COLUMNBOX GET$ "CB:Temp", 3, val(PartFour$)
502
+			if(GetReadyPath$+"/"+GetReadyItem$="")then
503
+			else
504
+				Launch GetReadyPath$+"/"+GetReadyItem$
505
+			endif
506
+		elseif(Selected$="Export")then
507
+			ExportFolder$=System$("catattr ExportFolder /boot/home/config/settings/.besly/GSGui/settings.cfg | cut -f3 -d:")
508
+			print ExportFolder$
509
+			CopyFile$ = FILEPANEL "Save-File", "Export "+GetItem$, trim$(ExportFolder$), GetItem$
510
+			Output$=System$("cp "+GetPath$+"/"+GetItem$+" "+CopyFile$)
511
+		elseif(Selected$="Export All")then
512
+			ExportFolder$=System$("catattr ExportFolder /boot/home/config/settings/.besly/GSGui/settings.cfg | cut -f3 -d:")
513
+			print ExportFolder$
514
+			ExportDirectory$ = FILEPANEL "Load-Directory", "Export "+GetItem$, trim$(ExportFolder$)
515
+			print ExportDirectory$
516
+			ReadoutFiles$=system$("ls -G -1 /boot/home/.besly/ghostscriptGUI/temp")
517
+			dim SplitDir$(1)
518
+				countfiles=0
519
+				countfiles= split(ReadoutFiles$, SplitDir$(), "\n")
520
+				countfiles=countfiles-1
521
+				i=0
522
+				x=0
523
+				for i = 1 to countfiles
524
+					x=x+1
525
+					print x
526
+					print "split:"+SplitDir$(x)
527
+					Output$=System$("cp /boot/home/.besly/ghostscriptGUI/temp/"+SplitDir$(x)+" "+ExportDirectory$+"/"+SplitDir$(x))
528
+				next i
529
+			Launch ExportDirectory$				
530
+		elseif(Selected$="Remove")then
531
+			Output$=System$("rm -r /boot/home/.besly/ghostscriptGUI/temp/"+GetItem$)
532
+			COLUMNBOX CLEAR "CB:Temp"
533
+			ReadOutTemp()
534
+		elseif(Selected$="Remove All")then
535
+			ReadoutFiles$=system$("ls -G -1 /boot/home/.besly/ghostscriptGUI/temp")
536
+			dim SplitDir$(1)
537
+				countfiles=0
538
+				countfiles= split(ReadoutFiles$, SplitDir$(), "\n")
539
+				countfiles=countfiles-1
540
+				i=0
541
+				x=0
542
+				for i = 1 to countfiles
543
+					x=x+1
544
+					Output$=System$("rm -r /boot/home/.besly/ghostscriptGUI/temp/"+SplitDir$(x))
545
+				next i
546
+			COLUMNBOX CLEAR "CB:Temp"
547
+		endif
548
+		break
549
+	
550
+	case "CB:Temp:_Invoke:"+PartFour$+"|"
551
+		GetItem$ = COLUMNBOX GET$ "CB:Temp", 2, val(PartFour$)
552
+		GetPath$ = COLUMNBOX GET$ "CB:Temp", 3, val(PartFour$)
553
+		SelectedTempItem$ = COLUMNBOX GET$ "CB:Temp", 2, val(PartFour$)
554
+		SelectedTempPath$ = COLUMNBOX GET$ "CB:Temp", 3, val(PartFour$)
555
+		Launch SelectedTempPath$+"/"+SelectedTempItem$
556
+		break
557
+	
558
+	
559
+		default:
560
+	
561
+	end switch
562
+	
563
+	
564
+	//Slider First and Last Page
565
+	if(SplitPDF=1)then
566
+		FirstPageValue = SLIDER GET "SL:StartPage"
567
+		LastPageValue = SLIDER GET "SL:LastPage"
568
+		if(LastPageValue<=FirstPageValue)then
569
+			SLIDER LABEL "SL:StartPage", str$(FirstPageValue), pagecount$
570
+				FirstPage=FirstPageValue		
571
+			SLIDER LABEL "SL:LastPage", "1", str$(FirstPageValue)
572
+				LastPage=LastPageValue
573
+				SLIDER SET  "SL:LastPage", FirstPageValue
574
+		else
575
+			SLIDER LABEL "SL:StartPage", str$(FirstPageValue), pagecount$
576
+				FirstPage=FirstPageValue
577
+			
578
+			SLIDER LABEL "SL:LastPage", "1", str$(LastPageValue)
579
+				LastPage=LastPageValue
580
+		endif
581
+	endif
582
+	
583
+	if(SplitPDFConv=1)then
584
+		FirstPageValue = SLIDER GET "SL:StartPageConvert"
585
+		LastPageValue = SLIDER GET "SL:LastPageConvert"
586
+		if(LastPageValue<=FirstPageValue)then
587
+			SLIDER LABEL "SL:StartPageConvert", str$(FirstPageValue), pagecount$
588
+				FirstPage=FirstPageValue		
589
+			SLIDER LABEL "SL:LastPageConvert", "1", str$(FirstPageValue)
590
+				LastPage=LastPageValue
591
+				SLIDER SET  "SL:LastPageConvert", FirstPageValue
592
+		else
593
+			SLIDER LABEL "SL:StartPageConvert", str$(FirstPageValue), pagecount$
594
+				FirstPage=FirstPageValue
595
+			
596
+			SLIDER LABEL "SL:LastPageConvert", "1", str$(LastPageValue)
597
+				LastPage=LastPageValue
598
+		endif
599
+	endif
600
+	
601
+	wait 0.05	
602
+	
603
+	
604
+	if(window count<1) inloop = false
605
+	sleep 0.05
606
+wend
607
+
608
+sub ReadOutTemp()
609
+	ReadoutFiles$=system$("ls -G -1 /boot/home/.besly/ghostscriptGUI/temp")
610
+	dim SplitDir$(1)
611
+		countfiles= split(ReadoutFiles$, SplitDir$(), "\n")
612
+		countfiles=countfiles-1
613
+		i=0
614
+		x=-1
615
+		for i = 1 to countfiles
616
+			x=x+1
617
+			COLUMNBOX ADD "CB:Temp", 1, x+1, 40, "__Path__=/boot/home/.besly/ghostscriptGUI/temp/"+SplitDir$(i)
618
+			COLUMNBOX ADD "CB:Temp", 2, x+1, 40, SplitDir$(i)
619
+			COLUMNBOX ADD "CB:Temp", 3, x+1, 40, "/boot/home/.besly/ghostscriptGUI/temp"
620
+		next i
621
+end sub
622
+
623
+sub ClearTemp()
624
+	ReadoutFiles$=system$("ls -G -1 /boot/home/.besly/ghostscriptGUI/temp")
625
+	countfiles=0
626
+	dim SplitDir$(1)
627
+		countfiles= split(ReadoutFiles$, SplitDir$(), "\n")
628
+		countfiles=countfiles-1
629
+		if(countfiles>0)then
630
+			i=0
631
+			for i = 1 to countfiles
632
+				Output$=System$("rm -r /boot/home/.besly/ghostscriptGUI/temp/"+SplitDir$(i))
633
+			next i
634
+		else
635
+		endif
636
+	COLUMNBOX CLEAR "CB:Temp"
637
+end sub
638
+
639
+
640
+//Check if a file or folder already exisits
641
+sub IfExists(filename$)
642
+     return not system("test -e "+filename$)
643
+end sub
644
+	
645
+	
646
+