Glib-Ex-ConnectProperties
view release on metacpan or search on metacpan
MANIFEST.SKIP
README
SIGNATURE
t/child.t
t/combobox-active.t
t/ConnectProperties-load.t
t/ConnectProperties.t
t/Gtk2-display.t
t/Gtk2.t
t/iconview_selection.t
t/model-rows-weaken.t
t/model-rows.t
t/MyTestHelpers.pm
t/POSIX.t
t/response-sensitive-infobar.t
t/response-sensitive-read.t
t/response-sensitive.t
t/screen_size.t
t/test-weaken.t
t/textbuffer.t
t/tree_selection.t
t/widget-load.t
t/widget.t
t/widget_allocation.t
xt/0-examples-xrefs.t
xt/0-file-is-part-of.t
xt/0-META-read.t
xt/0-no-debug-left-on.t
xt/0-Test-ConsistentVersion.t
SHA256 ec30eaa99f5916e0c4a45059c246c2a3e1987237f366b5d2904bc7fb4307da9a lib/Glib/Ex/ConnectProperties/Element/widget_allocation.pm
SHA256 62e4c7e4f94002307d7b3859ae52a35270e7c9dabfd7486ec3a7f0a101c00418 t/ConnectProperties-load.t
SHA256 49c92324aef8b292a04ab5950a4cd2d5741b374b86122f0af6331f296f07f6b0 t/ConnectProperties.t
SHA256 5c58d6308bef3b9fbdb883fecf600e558193d88c7a3a89602926033be743471f t/Gtk2-display.t
SHA256 c70abfb7b970fee5d0dba51dce3552edc7a1a4129127b009b09169361b2af95d t/Gtk2.t
SHA256 91cd2bba3e246abf05c342ed549ed6d902e8a77a43b6c9c4e092e4c918732ac0 t/MyTestHelpers.pm
SHA256 32e7f25f9a5757002980d6534e4fa912f60a11c80e9cf4b874093f4882396131 t/POSIX.t
SHA256 292f6ca98a3a335d3b25445892a01fb583e94edebdb516b73f86b6167c2385a4 t/child.t
SHA256 62a72e5af0d6314598dd930fbd66f1da4d0ecb370d150db4511c72b97ae556d3 t/combobox-active.t
SHA256 fa46b9c4f9abdb560a36f0ff7cec32a751c76367c029d5e92422bb7c4ed10c72 t/iconview_selection.t
SHA256 d83c77f239761b4f868229f75cd781c90ba84c64ce5ca47b3e6bb5ccbdafa9f1 t/model-rows-weaken.t
SHA256 5e2e49cb666131262708cd45e271b4be6cabc2d4ef48befdb42b7205a43ad376 t/model-rows.t
SHA256 fa89a5bc0825fca1f80cf7bd01c32273bf2727bcbfba4e0f5c3e92a8a0e38a24 t/response-sensitive-infobar.t
SHA256 43e6c83b4ef3dc5fe582c18ce4bf464f23836aed92cb26ae82deeaca2232fece t/response-sensitive-read.t
SHA256 daa78685918f65597d6caa8a17b07cbb63ceb5c1dce25aedf4e8e990177d9fe0 t/response-sensitive.t
SHA256 44b00edd50ea811682bd7bd6b5adc9b058c645e12b078a4f1725ec1c6dc0ce43 t/screen_size.t
SHA256 9ac68ae3fecfe0cbb8e81a7ed2b9b1af18e4584dd9c1b1cca8576798c4c68683 t/test-weaken.t
SHA256 f4be1ada659b8f9653f5ae5436b9028e1b590c5b406e62f53e7db8be097defe4 t/textbuffer.t
SHA256 2e299b99da94c235303a063f84137364c1787cb561e84f56ff9852106e080c41 t/tree_selection.t
SHA256 8cc4b9f850c331cee9f7e65e427bcfc2a62d8580786bdf1aaeb80a4f9053aa8e t/widget-load.t
SHA256 7747971cc125aa49bf7c00fe4d4c8e8adddfc11eb3a76b09a7db38cdbd910686 t/widget.t
SHA256 fe26f5c47d18aa49be9de7bbbf5f0ad6d23378c79b07304a7936137b63e9da48 t/widget_allocation.t
SHA256 ef75312e02ddcfed7095de7eecebc6b7b863d56acd9b64142737ab7a5edb57e3 xt/0-META-read.t
SHA256 f03d4741c4e6dd385c7bafa06118082bad4809a64e28a094635324ef8ab4f3e5 xt/0-Test-ConsistentVersion.t
SHA256 be42622f3841d04240cb1284e6b30e1af81cb0fcb56d29e853c70af656653488 xt/0-Test-DistManifest.t
SHA256 48b441e0c335e93946d913897e342662387788833229c5ba5fac57f0ff3d567c xt/0-Test-Pod.t
SHA256 2e1e1d896a226aeb190cdcfbe83969f634c1be3e7344302e023915e3f7150732 xt/0-Test-Synopsis.t
devel/container.pm view on Meta::CPAN
};
my $emission_hook_id;
my $instance_count = 0;
sub new {
$emission_hook_id ||= Gtk2::Widget->signal_add_emission_hook
(parent_set => \&_do_parent_set);
my $self = shift->SUPER::new(@_);
Scalar::Util::weaken
($self->{'object'}->{'Glib_Ex_ConnectProperties_container'}->{$self+0} = $self);
return $self;
}
sub DESTROY {
my ($self) = @_;
if (my $object = $self->{'object'}) {
my $href = $object->{'Glib_Ex_ConnectProperties_container'};
delete $href->{$self+0};
if (! %$href) {
devel/run.pl view on Meta::CPAN
('notify::active' => sub {
print "$progname: press_button active now ",
$sensitive_button->get('active'),"\n"; });
my $conn = Glib::Ex::ConnectProperties->new ([$label,'sensitive'],
[$sensitive_button,'active'],
[$label2,'label']);
require Data::Dumper;
print Data::Dumper->new([$conn],['conn'])->Sortkeys(1)->Dump;
require Scalar::Util;
Scalar::Util::weaken ($conn);
{
my $button = Gtk2::CheckButton->new_with_label ('Another Sensitive');
$vbox->add ($button);
Glib::Ex::ConnectProperties->new ([$label,'sensitive'],
[$button,'active']);
}
if (1) {
lib/Glib/Ex/ConnectProperties.pm view on Meta::CPAN
}
if (my $h = delete $elem->{'hash_out'}) {
### hash_out func: "@{[keys %$h]}"
$elem->{'func_out'} = _make_hash_func ($h);
}
if (delete $elem->{'bool_not'}) {
$elem->{'func_in'} = $elem->{'func_out'} = \&_bool_not;
}
Scalar::Util::weaken ($elem->{'object'});
if (! delete $elem->{'write_only'} && $elem->is_readable) {
$first_readable_elem ||= $elem;
$elem->{'self'} = $self;
$elem->connect_signals;
Scalar::Util::weaken ($elem); # the element of $self->{'array'}
}
}
# set initially from first readable, in case not already the same
if ($first_readable_elem) {
### initial propagate
_do_read_handler ($first_readable_elem->{'object'}, $first_readable_elem);
}
return $self;
}
sub dynamic {
my $self = shift->new(@_);
foreach my $elem (@{$self->{'array'}}) {
Scalar::Util::weaken ($elem->{'self'});
}
return $self;
}
# For a permanent new() style connection DESTROY is only reached when all
# readable objects are gone already, so there's nothing to disconnect. But
# a dynamic() is garbage collected with signal connections still present,
# hence an explicit disconnect() here.
#
sub DESTROY {
lib/Glib/Ex/ConnectProperties/Element/model_rows.pm view on Meta::CPAN
# my $h = $self->{'href'} = ($model->{__PACKAGE__} ||= do {
# my $empty = ! $self->{'object'}->get_iter_first;
# my $href = { empty => $empty,
# elems => [ $self ]};
# $href->{'signal_ids'} = Glib::Ex::SignalIds->new
# ($model,
# $object->signal_connect ($empty ? 'row-inserted' : 'row-deleted',
# \&_do_signal,
# $href))
# });
# Scalar::Util::weaken ($h->{'elems'}->[@$h] = $self);
# }
# sub _do_signal {
# my $href = $_[-1];
# my $signame;
# if ($href->{'empty'}) {
# $href->{'empty'} = 0;
# $signame = 'row-deleted';
# } else {
# if ($self->{'object'}->get_iter_first) {
# return; # still not empty
t/ConnectProperties.t view on Meta::CPAN
#-----------------------------------------------------------------------------
# dynamic ()
{
my $obj1 = Foo->new (myprop_one => 1);
my $obj2 = Foo->new (myprop_one => 0);
my $conn = Glib::Ex::ConnectProperties->dynamic ([$obj1,'myprop-one'],
[$obj2,'myprop-one']);
isa_ok ($conn, 'Glib::Ex::ConnectProperties');
require Scalar::Util;
Scalar::Util::weaken ($conn);
is ($conn, undef, 'dynamic() gc when weakened');
$obj1->set (myprop_one => 0);
is ($obj1->get ('myprop-one'), 0);
is ($obj2->get ('myprop-one'), 1, 'dynamic() no propagate after gc');
}
#-----------------------------------------------------------------------------
# read_signal
{
my $obj1 = Foo->new (mystring => 'one');
t/ConnectProperties.t view on Meta::CPAN
$obj2->set('mystring','x');
is ($obj1->get('mystring'), 'a');
is ($obj2->get('mystring'), 'x');
$obj2->set('mystring','z');
is ($obj1->get('mystring'), undef);
is ($obj2->get('mystring'), 'z');
}
#-----------------------------------------------------------------------------
# weaken
{
my $obj1 = Foo->new (myprop_one => 1, myprop_two => 1);
my $obj2 = Foo->new (myprop_one => 0, myprop_two => 0);
my $conn = Glib::Ex::ConnectProperties->new ([$obj1,'myprop-one'],
[$obj2,'myprop-two']);
require Scalar::Util;
my $weak_obj1 = $obj1;
Scalar::Util::weaken ($weak_obj1);
$obj1 = undef;
is ($weak_obj1, undef, 'obj1 not kept alive');
my $weak_obj2 = $obj2;
Scalar::Util::weaken ($weak_obj2);
$obj2 = undef;
is ($weak_obj2, undef, 'obj2 not kept alive');
Scalar::Util::weaken ($conn);
is ($conn, undef, 'conn garbage collected when none left');
}
{
my $obj1 = Foo->new (myprop_one => 1, myprop_two => 0);
my $obj2 = Foo->new (myprop_one => 0, myprop_two => 1);
my $conn = Glib::Ex::ConnectProperties->new ([$obj1,'myprop-one'],
[$obj2,'myprop-two']);
$obj1 = undef;
t/ConnectProperties.t view on Meta::CPAN
{
my $obj1 = Foo->new (myprop_one => 1, myprop_two => 1);
my $obj2 = Foo->new (myprop_one => 0, myprop_two => 0);
my $conn = Glib::Ex::ConnectProperties->new ([$obj1,'myprop-one'],
[$obj2,'myprop-two',
write_only => 1]);
require Scalar::Util;
my $weak_obj1 = $obj1;
Scalar::Util::weaken ($weak_obj1);
$obj1 = undef;
is ($weak_obj1, undef, 'obj1 not kept alive');
Scalar::Util::weaken ($conn);
is ($conn, undef, 'conn garbage collected when last readable gone');
}
#-----------------------------------------------------------------------------
# write-only
{
my $obj1 = Foo->new;
my $obj2 = Foo->new;
my $obj3 = Foo->new; $obj3->{'readonly-float'} = 999;
t/MyTestHelpers.pm view on Meta::CPAN
? "$obj->{$_}" : '[undef]')}
keys %$obj));
}
if (eval { require Devel::FindRef }) {
MyTestHelpers::diag (Devel::FindRef::track($obj, 8));
} else {
MyTestHelpers::diag ("Devel::FindRef not available -- ", $@);
}
}
sub test_weaken_show_leaks {
my ($leaks) = @_;
$leaks || return;
my $unfreed = $leaks->unfreed_proberefs;
my $unfreed_count = scalar(@$unfreed);
MyTestHelpers::diag ("Test-Weaken leaks $unfreed_count objects");
MyTestHelpers::dump ($leaks);
my $proberef;
foreach $proberef (@$unfreed) {
( run in 2.530 seconds using v1.01-cache-2.11-cpan-65fba6d93b7 )