File: gtkhtml-demo.lua

package info (click to toggle)
lua-gtk 0.9%2B20100528-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 2,176 kB
  • ctags: 1,934
  • sloc: ansic: 9,571; sh: 373; makefile: 241
file content (34 lines) | stat: -rwxr-xr-x 730 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#! /usr/bin/env lua
-- vim:sw=4:sts=4

require "gtk"
require "gtkhtml"

-- Demonstrate the use of libgtkhtml-2.0

function build_gui()
    w = gtk.window_new(gtk.WINDOW_TOPLEVEL)
    w:connect('destroy', gtk.main_quit)
    w:set_title('GtkHTML Demo')

    -- create a HtmlDocument
    doc = gtkhtml.document_new()
    doc:open_stream("text/html")
    s = '<html><body><p style="color:#f00;">Hello, World!</p></body></html>'
    doc:write_stream(s, #s)
    doc:close_stream()

    -- create a HtmlView and set the document; note that it segfaults
    -- if no document is set and the mouse leaves the widget.
    view = gtkhtml.view_new()
    view:set_document(doc)

    w:add(view)

    w:show_all()
end


build_gui()
gtk.main()