Re: Implementing TreeDragDest interface with a TreeModelSort model




On Mar 10, 2007, at 11:48 AM, Christian Jodar wrote:

{
    package MyTreeModelSort;
    use Glib::Object::Subclass
        Gtk2::TreeModelSort::,
        interfaces => [ Gtk2::TreeDragDest:: ],
        ;

    sub new
    {
        my ($proto, $childModel) = @_;
        my $class = ref($proto) || $proto;
        my $self = Gtk2::TreeModelSort->new($childModel);
        bless ($self, $class);
        return $self;
    }

Here's your problem --- you're setting up MyTreeModelSort with the interface and all that good stuff, but in the constructor, you're creating a TreeModelSort, *not* a MyTreeModelSort.

*Reblessing does *not* work with Glib::Object::Subclass!*

Your new() should look like this:

   sub new
   {
      my ($proto, $childModel) = @_;
      my $class = ref($proto) || $proto;
      return Glib::Object::new ($class, model => $childModel);
   }




--
If the monkey could type one keystroke every nanosecond, the expected waiting time until the monkey types out Hamlet is so long that the estimated age of the universe is insignificant by comparison ... this is not a practical method for writing plays.
  -- Gian-Carlo Rota





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