File: 013.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 (25 lines) | stat: -rwxr-xr-x 375 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
#! /usr/bin/env lua
-- vim:sw=4:sts=4
require "gtk"

ok = false

-- let it be called 10 times, then cause the main loop to exit.
function my_idle(data)
    n = data[1] + 1
    if n < 10 then
	data[1] = n
	return true
    end
    data:destroy()
    gtk.main_quit()
    ok = true
    return false
end

cl = gnome.closure(my_idle)
glib.idle_add(cl, {0})
gtk.main()

assert(ok)