fixes and new examples
This commit is contained in:
parent
c79299485c
commit
8979188f4c
9 changed files with 888 additions and 185 deletions
|
|
@ -1,9 +1,9 @@
|
|||
# nim c connect_args.nim
|
||||
import gintro/[gtk, glib, gobject, gio]
|
||||
import gintro/[gtk, gobject, gio]
|
||||
|
||||
type
|
||||
O = object
|
||||
i: int
|
||||
i, j: int
|
||||
|
||||
proc b1Callback(button: Button; str: string) =
|
||||
echo str
|
||||
|
|
@ -12,7 +12,7 @@ proc b2Callback(button: Button; o: O) =
|
|||
echo "Value of field i in object o = ", o.i
|
||||
|
||||
proc b3Callback(button: Button; r: ref O) =
|
||||
echo "Value of field i in ref to object O = ", r.i
|
||||
echo "Value of field i in ref to object o = ", r.i
|
||||
|
||||
proc b4Callback(button: Button; w: ApplicationWindow) =
|
||||
if w.title == "Nim with GTK3":
|
||||
|
|
@ -20,27 +20,23 @@ proc b4Callback(button: Button; w: ApplicationWindow) =
|
|||
else:
|
||||
w.title = "Nim with GTK3"
|
||||
|
||||
proc appActivate (app: Application) =
|
||||
var o: O
|
||||
var r: ref O
|
||||
new r
|
||||
o.i = 1234567
|
||||
r.i = 7654321
|
||||
let window = newApplicationWindow(app)
|
||||
let box = newBox(Orientation.vertical, 0)
|
||||
proc appActivate(app: Application) =
|
||||
let
|
||||
o = O(i: 1234567)
|
||||
r = (ref O)(i: 7654321)
|
||||
window = newApplicationWindow(app)
|
||||
box = newBox(Orientation.vertical, 0)
|
||||
b1 = newButton("Nim with GTK3")
|
||||
b2 = newButton("Passing an object from stack")
|
||||
b3 = newButton("Passing an object from heap")
|
||||
b4 = newButton("Passing a Widget")
|
||||
window.title = "Parameters for callbacks"
|
||||
let b1 = newButton("Nim with GTK3")
|
||||
let b2 = newButton("Passing an object from stack")
|
||||
let b3 = newButton("Passing an object from heap")
|
||||
let b4 = newButton("Passing a Widget")
|
||||
b1.connect("clicked", b1Callback, "is much fun.")
|
||||
b2.connect("clicked", b2Callback, o)
|
||||
b3.connect("clicked", b3Callback, r)
|
||||
b4.connect("clicked", b4Callback, window)
|
||||
box.add(b1)
|
||||
box.add(b2)
|
||||
box.add(b3)
|
||||
box.add(b4)
|
||||
b1.connect("clicked", b1Callback, "is much fun.")
|
||||
b2.connect("clicked", b2Callback, o)
|
||||
b3.connect("clicked", b3Callback, r)
|
||||
b4.connect("clicked", b4Callback, window)
|
||||
for b in [b1, b2, b3, b4]:
|
||||
box.add(b)
|
||||
window.add(box)
|
||||
window.showAll
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue