summary refs log tree commit diff stats
path: root/examples/gtk/ex5.nim
blob: 841ebc681f89ee895ca9b5f4535a6567af34efd4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import 
  glib2, gtk2

proc destroy(widget: pWidget, data: pgpointer){.cdecl.} = 
  main_quit()

proc widgetDestroy(w: PWidget) {.cdecl.} = 
  destroy(w)

nimrod_init()
var window = window_new(WINDOW_TOPLEVEL)
var button = button_new("Click me")
set_border_width(Window, 5)
add(window, button)
discard signal_connect(window, "destroy", 
                       SIGNAL_FUNC(ex5.destroy), nil)
discard signal_connect_object(button, "clicked", 
                              SIGNAL_FUNC(widgetDestroy), 
                              window)
show(button)
show(window)
main()