Re: Subclasses

Ephrem Boudonnet <[email protected]> Mon, 30 Jan 2006 14:24:18 +0100
Newsgroups gmane.lisp.clg.devel
Message-ID <[email protected]>
Espen S Johnsen wrote:

>Ephrem Boudonnet <[email protected]> writes:
>
>  
>
>>Thanx for your work.
>>I'm using clg for a project running with SBCL 0.9. (You've ever heard
>>of it, it's Open Music)
>>My first question would be:
>>Is it possible in my lisp code to define subclasses for "gtk classes",
>>for example a subclass for window, and to make instances of this
>>class.  
>>    
>>
>
>Currently this is not possible, but it is one of the features I would
>like to add. Unfortunately, until Gtk gets full introspection this is
>not very likely to happen. Full introspection is targeted at gtk 2.12,
>which is probably a year away.
>
>  
>
>>For the moment, I make it work using the "change-class"
>>function on my "gtk instance". (I know, it's quite not "beautiful") :
>>    
>>
>
>Just keep in mind that if you loose all references to the proxy instance
>in lisp, it could revert back to the original class if a reference is
>passed back from the C code.
> 
>  
>
>>(defclass my-window (gtk::window) ())
>>(make-instance 'my-window)
>>
>> >Type not registered: my-window
>> > [Condition of type simple-error]
>>    
>>
>
>When I get some time I'll see if I can come up with a solution to this
>(but real sub-classing of gtk classes would still have to wait until
>full introspection is available).
>
>But when that's said, do you have some code samples which shows what you
>are trying to do? Because I am really wondering if you need sub-classing
>at all. Could you not use composition in the way testgtk.lisp does?
>
>  
>
Hi Espen,

Thanx for your answer.
In fact, I need to specialize some gtk classes in order to assign them 
some special behaviours, for example, to catch differently the events, etc.
The OpenMusic environment that I am trying to port on Linux with CLG 
requires a lot of flexibility for this kind of things: almost every 
graphical component must be able to be subclassed.

We actually found another possible solution for subclassing gtk windows:

(setf gtkwindow-type (cdr (find 'window  glib::*registered-types* :key 
'car) ))
(glib::register-type 'om-window gtkwindow-type)

(defclass om-window (om-graphic-object gtk::window) ()
  (:metaclass gdk::gobject-class))

... this seems to work for the moment (I can create instances of 
om-window like this)

Would you mind let me know what you think about it?



I've got another question:
When I try to colorize a layout, or any other widget, it seems that it 
doesn't give the right color
for example blue is:
 (make-instance 'gdk::color :red 0  :green 65535 :blue 0)
Any idea?



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642