Re: Subclasses
Espen S Johnsen <[email protected]> 06 Feb 2006 16:52:29 +0100
| Newsgroups | gmane.lisp.clg.devel |
|---|---|
| Message-ID | <[email protected]> |
Ephrem Boudonnet <[email protected]> writes: > Thanx again for your time. The last CVS version, at the moment, > doesn't seem to work on my computer, so I'm trying the composition, as > you've told me to do. Yesterday I was making some modifications deep inside the proxy library to get drag and drop working, and I know that at some point the code in CVS was not working. But I think I've fixed that, so could you check out the code and try it once more? And if it is still not working post the error message to the list. And then about subclassing... With the code in CVS it is now possible to do subclassing without explicit registering the type with the gobject system first. Adding slots with instance allocation should work as expected (but gtk 2.8 is recommended when doing this). It is still not possible to specialize on gtk "methods" but many methods where this would be useful, just emit a signal. So by overriding default class signal handlers, it should be possible to customize the behavior of subclasses. I've added a macro to do this, with the following syntax: (define-signal-handler signal-name ((object class) &rest args) (do-something) (call-next-handler) (do-more)) Call-next-handler is more or less equivalent to call-next-method in standard methods. So I guess my advise to use composition instead of subclassing isn't valid any more. > But I'm trying now to add a slot in a gtk::window. > Can I do that in the file gtktypes.lisp, in the function > define-types-by-introspection? > > Something like: > > ... > > ("GtkWindow" > :slots > ((focus-widget > :allocation :virtual > :getter "gtk_window_get_focus" > :setter "gtk_window_set_focus" > :accessor window-focus-widget > :initarg :focus-widget > :type widget) > (myslot > :allocation :virtual > :getter "my_slot_getter" > :setter "my_slot_setter" > :accessor myslot > :initarg 1 > :type integer) This is possible, but I wouldn't recommend modifying existing class definitions as it may become hard to maintain your code. If you don't want to do subclassing to add new slots, you could use the user data mechanism to hang arbitrary data on any gobject. -- 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