------------------------------------------------------------------------------------ --# Using GtkPrinter.e, print from in-line or generated text; ------------------------------------------------------------------------------------ include GtkEngine.e include GtkPrinter.e include std/primes.e constant docs = `Demos how to print from generated or in-line text. We are using some markup to change the size and style of this paragraph. You can print in color using this feature, as well as different font styles. ` sequence list = prime_list(100) for i = 1 to length(list) do list[i] = sprintf("%2d = %d\n",{i,list[i]}) end for list = flatten(list) ifdef WINDOWS then printer:font = "16" end ifdef constant win = create(GtkWindow,{ {"border width",10}, {"default size",300,100}, {"position",GTK_WIN_POS_CENTER}, {"icon","printer"}, {"signal","destroy","Quit"}}) constant panel = create(GtkBox,VERTICAL) add(win,panel) constant img = create(GtkImage,"thumbnails/document-print.png") add(panel,img) constant lbl = create(GtkLabel) set(lbl,"markup",docs) add(panel,lbl) printer:confirm = TRUE printer:use_line_numbers = FALSE printer:sourcecode = FALSE -- allow using markup printer:settings_file = "MyPrintSettings" printer:setup_file = "MyPrintSetup" constant btn1 = create(GtkButton,"gtk-quit","Quit"), btn2 = create(GtkButton,"Print _1","PrintPrimes"), btn3 = create(GtkButton,"Print _2",printer:print_text,docs & list), btn4 = create(GtkButton,"Print _3",printer:print_text,docs & LGPL), btn5 = create(GtkButton,"gnome-mime-application-pdf# _PDF","Print2PDF") set(btn1,"tooltip markup","Alt+Q\nClick to quit") set(btn2,"tooltip markup", "Alt+1\nPrint 25 prime numbers via a function call") set(btn3,"tooltip markup", "Alt+2\nPrint from text stored in a sequence") set(btn4,"tooltip markup", "Alt+3\nPrint from text stored in a variable") set(btn5,"tooltip markup", "Alt+P\nPrint to a PDF file in your home directory") constant btnbox = create(GtkButtonBox) set(btnbox,"spacing",5) pack(panel,-btnbox) add(btnbox,{btn1,btn2,btn3,btn4,btn5}) constant box2 = create(GtkButtonBox), btn6 = create(GtkCheckButton,"_Confirm Print Status/preview pdf","ToggleCkStatus") set(btn6,"active",TRUE) pack(panel,-box2) add(box2,btn6) show_all(win) main() ------------------------------------------------------------------------ global function PrintPrimes() ------------------------------------------------------------------------ PrintText("First 25 primes",docs & list) return 1 end function ------------------------------------------------------------------------ global function Print2PDF() ------------------------------------------------------------------------ printer:action = GTK_PRINT_OPERATION_ACTION_EXPORT printer:export_file = canonical_path("~/First 25 Primes.pdf") PrintText("First 25 Prime Numbers",docs & list) return 1 end function ------------------------------------------------------------------------ global function ToggleCkStatus(atom ctl) ------------------------------------------------------------------------ printer:confirm = get(ctl,"active") return 1 end function