summary refs log tree commit diff stats
path: root/examples/gtk/ex3.nim
diff options
context:
space:
mode:
Diffstat (limited to 'examples/gtk/ex3.nim')
-rwxr-xr-xexamples/gtk/ex3.nim59
1 files changed, 27 insertions, 32 deletions
diff --git a/examples/gtk/ex3.nim b/examples/gtk/ex3.nim
index 460b1e4dc..257ec3eda 100755
--- a/examples/gtk/ex3.nim
+++ b/examples/gtk/ex3.nim
@@ -2,38 +2,33 @@
 import 
   glib2, gtk2
 
-proc newbutton(ALabel: cstring): PGtkWidget = 
-  Result = gtk_button_new_with_label(ALabel)
-  gtk_widget_show(result)
+proc newbutton(ALabel: cstring): PWidget = 
+  Result = button_new_with_label(ALabel)
+  show(result)
 
-proc destroy(widget: pGtkWidget, data: pgpointer){.cdecl.} = 
-  gtk_main_quit()
+proc destroy(widget: pWidget, data: pgpointer){.cdecl.} = 
+  main_quit()
 
-var 
-  window, totalbox, hbox, vbox: PgtkWidget
+nimrod_init()
+var window = window_new(WINDOW_TOPLEVEL) # Box to divide window in 2 halves:
+var totalbox = vbox_new(true, 10)
+show(totalbox)   # A box for each half of the screen:
+var hbox = hbox_new(false, 5)
+show(hbox)
+var vbox = vbox_new(true, 5)
+show(vbox)       # Put boxes in their halves
+pack_start(totalbox, hbox, true, true, 0)
+pack_start(totalbox, vbox, true, true, 0) # Now fill boxes with buttons.
+
+pack_start(hbox, newbutton("Button 1"), false, false, 0)
+pack_start(hbox, newbutton("Button 2"), false, false, 0)
+pack_start(hbox, newbutton("Button 3"), false, false, 0) # Vertical box
+pack_start(vbox, newbutton("Button A"), true, true, 0)
+pack_start(vbox, newbutton("Button B"), true, true, 0)
+pack_start(vbox, newbutton("Button C"), true, true, 0) # Put totalbox in window
+set_border_width(PCONTAINER(Window), 5)
+add(PContainer(window), totalbox)
+discard signal_connect(window, "destroy", SIGNAL_FUNC(ex3.destroy), nil)
+show(window)
+main()
 
-gtk_nimrod_init()
-window = gtk_window_new(GTK_WINDOW_TOPLEVEL) # Box to divide window in 2 halves:
-totalbox = gtk_vbox_new(true, 10)
-gtk_widget_show(totalbox)   # A box for each half of the screen:
-hbox = gtk_hbox_new(false, 5)
-gtk_widget_show(hbox)
-vbox = gtk_vbox_new(true, 5)
-gtk_widget_show(vbox)       # Put boxes in their halves
-gtk_box_pack_start(GTK_BOX(totalbox), hbox, true, true, 0)
-gtk_box_pack_start(GTK_BOX(totalbox), vbox, true, true, 0) # Now fill boxes with buttons.
-                                                           # Horizontal box
-gtk_box_pack_start(GTK_BOX(hbox), newbutton("Button 1"), false, false, 0)
-gtk_box_pack_start(GTK_BOX(hbox), newbutton("Button 2"), false, false, 0)
-gtk_box_pack_start(GTK_BOX(hbox), newbutton("Button 3"), false, false, 0) # 
-                                                                          # Vertical box
-gtk_box_pack_start(GTK_BOX(vbox), newbutton("Button A"), true, true, 0)
-gtk_box_pack_start(GTK_BOX(vbox), newbutton("Button B"), true, true, 0)
-gtk_box_pack_start(GTK_BOX(vbox), newbutton("Button C"), true, true, 0) # Put 
-                                                                        # totalbox in window
-gtk_container_set_border_width(GTK_CONTAINER(Window), 5)
-gtk_container_add(GTK_Container(window), totalbox)
-discard gtk_signal_connect(GTKOBJECT(window), "destroy", 
-                           GTK_SIGNAL_FUNC(destroy), nil)
-gtk_widget_show(window)
-gtk_main()