Pastey Gallery Update

-- BUG: you may have to change line 257 in GtkFileselector.e from
-- result = get(dlg,"filename") to result = get(dlg,"filenames")  
 
-- Simple example program in Euphoria language to create a html 
-- page with all the picture files in the current directory. 
 
-- Marco Achury, 2008 
-- Released to public domain.  Feel free to use and modify. 
 
-- Updated for Eu 4.1b2 by Irv Mullins 
-- Added EuGTK interface Mar 21, 2019 
 
include GtkEngine.e 
include GtkFileSelector.e 
include std/filesys.e 
include std/datetime.e 
include std/net/url.e 
 
integer FN -- File number for output 
sequence input = sprintf("~/%s/*",{user_name}) -- default home 
sequence output = canonical_path("~/output.html") -- default in home 
 
constant 
    win = create(GtkWindow,"title=Gallery Maker,size=300x200,border=10,$destroy=Quit"), 
    pan = create(GtkBox,"orientation=vertical,spacing=10"), 
    lbl = create(GtkLabel,"Click the Open button to choose files, then click view"), 
    box = create(GtkButtonBox), 
    btn1 = create(GtkButton,"gtk-quit","Quit"), 
    btn2 = create(GtkButton,"gtk-open","SelectFolder"), 
    btn3 = create(GtkButton, "gtk-ok","ViewHTML") 
 
    gtk:add(win,pan) 
    gtk:add(pan,lbl) 
    gtk:add(box,{btn1,btn2,btn3}) 
    pack_end(pan,box) 
 
    show_all(win) 
    main() 
 
---------------------------------------------------------------------------------- 
global function SelectFolder() 
---------------------------------------------------------------------------------- 
ifdef UNIX then fileselector:filters = {"images"} end ifdef 
ifdef WINDOWS then fileselector:filters = {"all"} end ifdef 
fileselector:show_preview = TRUE 
fileselector:select_multiple = TRUE 
input = fileselector:Open(input) 
 
GenerateHTML() 
 
return 1 
end function 
 
---------------------------------------------------------------------------------- 
global function GenerateHTML() 
---------------------------------------------------------------------------------- 
object fname, fdate, fpath = pathname(input[1]) 
 
object fpix, fsize 
 
FN = open (output, "w") 
if FN =-1 then Error(,,"Cannot open output file!") 
    abort(1) 
end if 
 
puts (FN, "<HTML>\n") 
puts (FN, " <HEAD>\n") 
puts (FN, sprintf("  <TITLE>Images in %s</TITLE> ",{fpath})) 
 
puts (FN, "<style>\n") 
puts (FN, """ 

 
    div.quote { 
        display: block; 
        border: 1px solid black; 
        padding: 15px; 
        background: #D0D0D0; 
        margin: 5px;}\n""") 
         
puts (FN, "</style>\n") 
 
puts (FN, " </HEAD>\n\n") 
puts (FN, "<BODY>\n") 
 
puts (FN, "<H1>Image Gallery</H1>\n\n") 
puts (FN, sprintf("%d Files from %s in %s\n<br>\n<br>\n<hr>",{length(input),fpath,output})) 
 
puts (FN, "<table border='0'\n") 
puts (FN, "<tr>\n") 
 
for i=1  to length(input) do 
 
    fname = url:decode(input[i]) 
    fpix = create(GdkPixbuf,fname) 
    fsize = get(fpix,"size") 
    fdate = file_timestamp(fname) 
 
    puts(FN,"<td width='25%'>\n") 
    printf(FN,"<a href='%s'>\n",{fname}) 
	printf(FN,"<img src='%s'",{fname}) 
	puts(FN," width='90%' height='50%'></a>\n") 
    puts(FN,"<br clear='all' />") 
    printf(FN,"<div class='quote' width='%d' align='bottom'>\n",fsize[1]) 
    printf(FN,"<small><b>Path:</b> %s </small><br />\n",{fpath}) 
    printf(FN,"<small><b>Name:</b> %s </small><br />\n",{filename(fname)}) 
 
    puts(FN,text:format("<small><b>File&nbsp;Size:</b> [,,] bytes</small><br>\n",file_length(fname))) 
    puts(FN,text:format("<small><b>Date:</b> []/[]/[] Time: []:[]:[]</small>\n</td>\n\n",fdate)) 
 
    if remainder(i,4)=0 then 
    puts (FN, "</div></tr>\n\n<tr>\n") 
    end if 
 
end for 
puts (FN, "</table>\n") 
 
printf(FN, "<address><b>Page generated: %s</b>",{datetime:format(now())}) 
puts (FN, " by a Euphoria powered script.</address>") 
puts (FN, "</BODY>\n</HTML>\n") 
close(FN) 
 
if Info(,,text:format("<b>Input folder:</b> []\n<b>Output file:</b> [] has <b>[]</b> images.", 
        {fpath,output,length(input)}),,GTK_BUTTONS_OK_CANCEL) = MB_OK then 
   show_uri("file://" & output) 
end if 
return 1 
end function 
 
----------------------------- 
global function ViewHTML() -- when OK button clicked 
----------------------------- 
    show_uri("file://" & output) 
return 1 
end function 
 
------------- END ------------ 
 

1. Comment by irv in April

Patch for GtkFileselector, line 256 should be:

 if result = MB_OK then  
    if select_multiple then result = get(dlg,"filenames") 	  
    else result = get(dlg,"filename")   
    end if  
end if  
--note: select_multiple is FALSE by default;