Re: Subclasses
Espen S Johnsen <[email protected]> 31 Jan 2006 15:23:10 +0100
| Newsgroups | gmane.lisp.clg.devel |
|---|---|
| Message-ID | <[email protected]> |
Ephrem Boudonnet <[email protected]> writes: > 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. Ok, but keep i mind that you can not specialize on gtk "methods" which could make subclassing less useful than it first may seem. > 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) Of course, I didn't think about this solution but it should work. Although the correct way to do it would be: (glib:register-type-alias 'om-window 'window) or even better, check out the latest code from CVS and use (glib:register-new-type 'om-window 'window) which will register om-window as a new type in the gobject type system. > (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 think it should work, as long as you keep at least one Lisp reference to instances of gtk subclasses (if you use register-new-type you only need to do this if you add slots). > 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 is a bug in the layout of the struct wrapper. I've committed a fix to CVS. -- Espen ------------------------------------------------------- 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