File: gladedemo2.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 (53 lines) | stat: -rwxr-xr-x 1,110 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#! /usr/bin/env lua
-- vim:sw=4:sts=4
-- Another simple example for the Glade library.
-- by Wolfgang Oertl

require "gtk"
require "gtk.glade"

widgets = nil

-- Signal handlers for Menu
function window1_destroy_cb()
    gtk.main_quit()
end

function on_menu_quit()
    gtk.main_quit()
end

function on_comboboxentry1_changed(entry)
    local s = entry:get_active_text()
    widgets.comboboxentry_entry1:set_text(s)
end

function on_spinbutton1_value_changed(spin)
    local v = spin:get_value()
    widgets.progressbar1:set_fraction(v/100.0)
end

function main()
    local tree, file

    file = string.gsub(arg[0], "%.lua", ".glade")
    tree = gtk.glade.read(file)
    widgets = gtk.glade.create(tree, "window1")
end

main()
collectgarbage("collect")
gtk.main()
widgets = nil

-- Show widgets that are still referenced.  The list should be empty, at
-- least after the garbage collection has run.

print(collectgarbage("count"), "kB")
collectgarbage("collect")
print(collectgarbage("count"), "kB")

-- print "** WIDGETS **"
-- for k, v in pairs(gtk.widgets) do print(v) end
-- print "** END OF WIDGETS **"