package Foo;
use 5.008;
use strict;
use warnings;
use Glib;
use Data::Dumper;

use Glib::Object::Subclass
  'Glib::Object',
  signals => { add => { param_types => ['Glib::Object'], class_closure => \&_do_add },
               notify => \&_do_notify,
             };

sub _do_notify {
  my ($self, $pspec) = @_;
  print "Foo::_do_notify()\n";
}

sub _do_add {
  my ($self, $child) = @_;
  print "Foo::_do_add()\n";
}

sub add {
  my ($self, $child) = @_;
  $self->signal_emit (add => $child);
}

package FooToo;

use Glib::Object::Subclass
  'Foo',
  signals => { add => \&_do_add,
               notify => \&_do_notify,
             },
  properties => [ Glib::ParamSpec->int
                  ('foo',
                   'foo',
                   'Blurb.',
                   0,100,0,
                   Glib::G_PARAM_READWRITE),
                ];

sub _do_notify {
  my ($self, $pspec) = @_;

  print "_do_notify() begins\n";
  my $invocation_hint = $self->signal_get_invocation_hint;
  print Data::Dumper->Indent(1)->Dump([$invocation_hint],
                                      ['invocation_hint']);

  print "_do_notify(), chain up\n";
  $self->signal_chain_from_overridden ($pspec);
  print "_do_notify(), chain returned\n";
}

sub _do_add {
  my ($self, $child) = @_;

  print "_do_add(), chain up\n";
  $self->signal_chain_from_overridden ($child);
  print "_do_add(), chain returned()\n";

  print "_do_add(), call notify()\n";
  $self->notify('foo');
  print "_do_add() ends()\n";
}

package main;

my $child_widget = FooToo->new;
my $toolitem = FooToo->new;
$toolitem->add ($child_widget);
