package Foo;

use Glib;

sub import {
  my ($self, @packages) = @_;

  no strict "refs";

  foreach my $package (@packages) {
    my @signals = Glib::Type -> list_signals($package);

    foreach my $signal (@signals) {
      my $name = $signal -> { signal_name };

      $mangled = ucfirst($name);
      $mangled =~ s/-(\w)/uc($1)/ge;

      my $sub = sub : lvalue {
        my ($object) = @_;

        my $self = bless({}, "Foo::Overlord");

        $self -> { name } = $name;
        $self -> { object } = $object;

        $self;
      };

      *{$package . "::" . $mangled} = $sub;
    }
  }
}

package Foo::Overlord;

use overload
  "+=" => \&signal_connect;

sub signal_connect {
  my ($signal, $callback, undef) = @_;

  my $object = $signal -> { object };
  my $name = $signal -> { name };

  $object -> signal_connect($name => $callback);
}

1;
