Dictionary Lookup
Enter a word to be looked up in the Diccionario de la Real Academia Espaņola, and press Enter or click on "Start". The result is displayed in a GtkHtmlView widget.
The GUI is set up without using Glade in this case, the download is done using the gtk.http_co auxiliary library, which provides asynchronous HTTP access. The lookup handler is as follows:
function start_download(entry)
if download_running == 1 then
print "Download already running."
return
end
local s = entry:get_text()
if s == "" then
print "Please enter a search text"
return
end
set_status("Fetching " .. s)
download_running = 1
htmldoc = gtkhtml.document_new()
htmldoc:open_stream("text/html")
htmlview:set_document(htmldoc)
gtk.http_co.request_co{ host = rae_host, uri = rae_path .. s,
callback = download_callback,
sink = download_sink }
end