Re: Subclassing a Gtk2::TreeStore

2007-10-27 Thread Torsten Schoenfeld
On Fri, 2007-10-26 at 17:22 +0100, Dave Howorth wrote:

 My [non-working] code looks like this:

I haven't tested it in a complete application, but this seems to work:

  package MyTreeStore;

  use Glib qw(TRUE FALSE);
  use Gtk2;

  use Glib::Object::Subclass
'Gtk2::TreeStore',
  ;

  sub drag_data_received
  {
  my ($self, $dest_path, $selection_data) = @_;
  return $self-SUPER::drag_data_received ($dest_path, $selection_data);
  }

  1;

  package main;

  my $store = MyTreeStore-new (qw/Glib::String/);
  $store-drag_data_received (undef, undef);

Note how drag_data_received is overridden simply how you'd override any
other method in normal Perl code, and how the parent's
drag_data_received is invoked.

-- 
Bye,
-Torsten

___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list


Re: Subclassing a Gtk2::TreeStore

2007-10-27 Thread muppet

On Oct 26, 2007, at 6:37 AM, Torsten Schoenfeld wrote:

 On Fri, 2007-10-26 at 17:22 +0100, Dave Howorth wrote:

 My [non-working] code looks like this:

 Note how drag_data_received is overridden simply how you'd override  
 any
 other method in normal Perl code, and how the parent's
 drag_data_received is invoked.

To be a little more explicit, this works because where you need it to  
be overridden is in your own code, where perl's method lookup can  
work normally.

Trying to override drag_data_received as a signal won't work, because  
it's not a signal.

I think the root of the problem you were seeing, Dave, is that  
drag_data_received comes from a GInterface, and as such is not  
actually a virtual method that may be overridden by a class deriving  
from the class implementing the interface.  You can't add the  
interface in your own class, because the base class already  
implements it.

So, Torsten's solution effectively creates a wrapper function -- your  
perl code first calls a wrapper instead of the real thing, and then  
chains up to the real thing.

--
elysse:  You dance better than some.
me:  Some what?
elysse:  Some asparagus.


___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list