--- Begin Message ---
Thank you,

This the translation of the perl script given as an example of
interfacing with libgtk-server.so. It works now and it is a lot
simpler.

I will have a lot of fun.

Jean-Marc.
DLD addLibrary: 'libgtk-server.so' printNl.

Object subclass: GtkServer [
    <comment: 'I implement access to gtk server library'>

    debug := true.

    "Instance Methods"
    gtk: aString [
        <category: 'c callout'>
        "This is the basic interface to gtk-server shared library"
         <cCall: 'gtk' returning: #string args: #(#string)>
     ]
    
    "The call methods are able to build the string without always
     thinking about space characters between parameters"
    call: aFunc [
        debug ifTrue: [ aFunc printNl ].
        ^self gtk: aFunc
    ]

    call: aFunc with: param1 [
        debug ifTrue: [ (aFunc, ' ', param1) printNl ].
        ^self gtk: (aFunc, ' ', param1)
    ]
    
    call: aFunc with: param1 with: param2 [
        debug ifTrue: [ (aFunc, ' ', param1, ' ', param2) printNl ].
        ^self gtk: (aFunc, ' ', param1, ' ', param2)
    ]

    call: aFunc with: param1 with: param2 with: param3 [
        debug ifTrue: [ (aFunc, ' ', param1, ' ', param2, ' ',param3) printNl ].
        ^self gtk: (aFunc, ' ', param1, ' ', param2, ' ', param3)
        
    ]
        
]

Eval [
    | win tbl but event |
    WS := GtkServer new.
    WS call: 'gtk_init NULL NULL'.
    win := WS call: 'gtk_window_new 0'.
    WS call: 'gtk_window_set_title' with:  win  with: '"GST test window"'.
    WS call: 'gtk_window_set_default_size' with: win with: '400 200'.
    WS call: 'gtk_window_set_position' with: win with:  '1'.

    tbl := WS call: 'gtk_table_new 10 10 1'.
    WS call: 'gtk_container_add' with: win with: tbl.

    but := WS call: 'gtk_button_new_with_label "Click to Quit"'.
    WS call: 'gtk_table_attach_defaults' with: tbl with: but with: '5 9 5 9'.

    WS call: 'gtk_widget_show_all ' with: win.

    [( event = win) or: [ event = but ]] whileFalse: [
        event := WS call: 'gtk_server_callback wait'.
        event printNl.
    ].
    
    WS call: 'gtk_exit 0'.
]

--- End Message ---
_______________________________________________
help-smalltalk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to