1 ! Copyright (C) 2010 Anton Gorenko.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: alien.strings gobject.ffi gtk.ffi io.encodings.utf8
5 IN: gtk-samples.hello-world
7 : on-button-clicked ( button label-user-data -- )
8 nip "Hello! :)" utf8 string>alien gtk_label_set_text ;
10 :: hello-world-win ( -- window )
11 GTK_WINDOW_TOPLEVEL gtk_window_new :> window
14 [ "Hello world!" utf8 string>alien gtk_window_set_title ]
15 [ 300 200 gtk_window_set_default_size ]
16 [ GTK_WIN_POS_CENTER gtk_window_set_position ] tri
18 gtk_fixed_new :> frame
19 window frame gtk_container_add
21 "Say 'Hello!'" utf8 string>alien gtk_button_new_with_label :> button
22 button 140 30 gtk_widget_set_size_request
23 frame button 80 60 gtk_fixed_put
25 "" utf8 string>alien gtk_label_new :> label
26 frame label 120 110 gtk_fixed_put
28 button "clicked" utf8 string>alien
29 [ on-button-clicked ] GtkButton:clicked label
34 :: hello-world-main ( -- )
36 hello-world-win :> window
38 window "destroy" utf8 string>alien
39 [ 2drop gtk_main_quit ] GtkObject:destroy f
42 window gtk_widget_show_all
46 MAIN: hello-world-main