Project

General

Profile

Hello world » History » Version 5

iri, 02/22/2011 02:24 PM

1 1 iri
h1. Hello world
2
3
Here is a famous "Hello world" !
4
5 3 iri
<pre><code class="php">
6 1 iri
typeof win = ObjGtkWidget;;
7
typeof button = ObjGtkWidget;;
8
9
fun CBend (obj, uparam)=
10 5 iri
    /* Stop the GTK+ loop */
11 1 iri
    _gtkMainQuit;
12 5 iri
    _closemachine;
13 1 iri
    0;;
14
15
fun CBbutton (obj, uparam)=
16
    _fooS strcat "user param is : " uparam;
17
    _fooS if (obj == button) then "Ok, same button" else "No !!";
18
    0;;
19
20
fun main ()=
21
    /* display the console */
22
    _showconsole;
23
24
    /* create a window */
25
    set win = _gtkWindowNew _channel nil "First example" [320 50] [500 400];
26
    /* define acallback when the window will be destroyed */
27
    _gtkWindowCBdestroyed win @CBend 0;
28
29 4 iri
    /* create a button with a simple label */
30 1 iri
    set button = _gtkButtonNew _channel "Hello World !" SCOL_GTK_BUTTON_LABEL nil;
31
    /* define a callback when the button will be clicked */
32
    _gtkButtonCBclicked button @CBbutton "It's great !";
33
34
    /* Add the button to the window */
35
    _gtkWindowAddChild win button;
36
    /* Show all */
37
    _gtkWidgetShowAll win;
38
    /* Run the GTK+ loop */
39
    _gtkMain;
40
    0;;   
41
</code></pre>
42 2 iri
43
Return [[Examples]]