help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] questions about smalltalk and the c-call interface


From: Joachim Jaeckel
Subject: [Help-smalltalk] questions about smalltalk and the c-call interface
Date: Sat, 30 May 2009 13:18:24 +0200
User-agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103)

Hello,

I'm currently working on an exampel of GtkBuilder.

* Design the user-interface with glade, save it as a GtkBuilder project and use GTK.GtkBuilder to construct your interface on the screen. I think, it's nice to handle the user-interface in this way, because you don't have to struggle with all the ui-code in your app, except the callbacks and the initialization of GtkBuilder. (Ok, don't look at my open question about GtkComboBox with the model, that's something you allready have to know, even if you use glade, I think... and btw. I still didn't find my mistake...)

And here now my questions:

- The GTK.GtkBuilder getObject: method returns currently a #{GObject}. That's currently the same as in C. But this returning object could be anthing from the GTK. GtkWindow, GtkEntry and so on. But there is no casting in Smalltalk, how could I create a GtkWindow from a GObject?
(Because the GObject doesn't understand e.g. 'showAll'.

Because, I don't know how to do it - if that's possible et all - I extended the GtkBuilder object. First with:

getObject: name as: type [
    <cCall: 'gtk_builder_get_object' returning: type
        args: #( #self #string )>
]

but that isn't working, the type parameter could not be recognized...
than I tried:

getObject: name as: type [
    (Switch value: type)
        case: 'GtkWidget'
          do: [ <cCall: 'gtk_builder_get_object' returning: #{GtkWidget}
                    args: #( #self #string )> ];
          ... so on

but that also doesn't seems to work, maybe the <cCall> pragma is not containable in a block. I got a "parse error, expected ']' in the line of the cCall.

So I currently end up with several methods like

getObjectAsWindow: name [
<cCall: 'gtk_builder_get_object' returning: #{GtkWindow} args: #( #self #string)>
]

getObjectAsEntry ... and so on.

But I don't think, that this is the best solution. Maybe you can help me here with a tip how to write the cCall more generall (regarding the return-type) or something else. That would be nice!

Thanks in advance,
Joachim.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]