version 0.8.8

This commit is contained in:
Andreas Rumpf 2010-03-14 01:25:25 +01:00
commit 7bf98411b6
52 changed files with 15732 additions and 6193 deletions

View file

@ -3,10 +3,10 @@ import
gtk2, glib2, atk, gdk2, gdk2pixbuf, libglade2, pango,
pangoutils
proc hello(widget: PGtkWidget, data: pointer) {.cdecl.} =
proc hello(widget: PWidget, data: pointer) {.cdecl.} =
write(stdout, "Hello World\n")
proc delete_event(widget: PGtkWidget, event: PGdkEvent,
proc delete_event(widget: PWidget, event: PEvent,
data: pointer): bool {.cdecl.} =
# If you return FALSE in the "delete_event" signal handler,
# GTK will emit the "destroy" signal. Returning TRUE means
@ -19,43 +19,33 @@ proc delete_event(widget: PGtkWidget, event: PGdkEvent,
return false
# Another callback
proc destroy(widget: PGtkWidget, data: pointer) {.cdecl.} =
gtk_main_quit()
proc mydestroy(widget: PWidget, data: pointer) {.cdecl.} =
gtk2.main_quit()
proc main() =
proc mymain() =
# GtkWidget is the storage type for widgets
var
window: PGtkWindow
button: PGtkButton
gtk_nimrod_init()
window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL))
gtk2.nimrod_init()
var window = window_new(gtk2.WINDOW_TOPLEVEL)
discard g_signal_connect(window, "delete_event",
Gcallback(delete_event), nil)
discard g_signal_connect(window, "destroy", Gcallback(destroy), nil)
discard g_signal_connect(window, "destroy", Gcallback(mydestroy), nil)
# Sets the border width of the window.
gtk_container_set_border_width(window, 10)
set_border_width(window, 10)
# Creates a new button with the label "Hello World".
button = GTK_BUTTON(gtk_button_new_with_label("Hello World"))
var button = button_new("Hello World")
discard g_signal_connect(button, "clicked", Gcallback(hello), nil)
# This will cause the window to be destroyed by calling
# gtk_widget_destroy(window) when "clicked". Again, the destroy
# signal could come from here, or the window manager.
discard g_signal_connect_swapped(button, "clicked",
Gcallback(gtk_widget_destroy), window)
# This packs the button into the window (a gtk container).
gtk_container_add(window, button)
add(window, button)
# The final step is to display this newly created widget.
gtk_widget_show(button)
show(button)
# and the window
gtk_widget_show(window)
show(window)
gtk_main()
gtk2.main()
main()
mymain()