eumandy/eugtk/examples/test150.ex
2016-11-25 00:33:18 -07:00

74 lines
1.9 KiB
Elixir

------------------------------------------------------------------------------
--# GtkPrinter
------------------------------------------------------------------------------
include GtkEngine.e
include GtkPrinter.e
constant docs = `<b><u>Printing</u></b>
Print a long file with heading and page numbers.
In this case: GtkEngine.e.
Includes an optional progress-bar to show what's happening.
`
constant win = create(GtkWindow,"border=10,position=1,$destroy=Quit")
printer:parent = win
constant panel = create(GtkBox,VERTICAL,5)
add(win,panel)
constant lbl = create(GtkLabel)
set(lbl,"markup",docs)
pack(panel,lbl)
constant img = create(GtkImage,"thumbnails/document-print.png")
pack(panel,img)
pack(panel,printer:progress)
set(printer:progress,"show text",TRUE)
-- header for first page;
printer:header = "<span font='Georgia bold 16'><b>[1]</b>"
& " "
&"<span font='10'> Page [5] of [6]</span></span> \n\n"
-- header for pg. 2..last;
printer:subheader = "<span font='Georgia 16'><b>[1]</b>"
& " "
&"<span font='10'>Page [5]</span></span> \n\n"
printer:use_line_numbers = TRUE
printer:sourcecode = TRUE
ifdef WINDOWS then -- don't know why this is needed!
printer:font = "Courier 14"
printer:lines_per_page=70
elsedef
printer:font = "Ubuntu mono 6"
printer:auto_lpp = FALSE
printer:lines_per_page = 80
end ifdef
constant
btn1 = create(GtkButton,"gtk-quit","Quit"),
btn2 = create(GtkButton,"gtk-print",print_file,canonical_path(locate_file("GtkEngine.e")))
set(btn2,"tooltip text","Click to print a file")
constant
btnbox = create(GtkButtonBox)
pack(panel,-btnbox)
add(btnbox,{btn1,btn2})
show_all(win)
set(printer:progress,"hide") -- hide it until printing is started.
main()