Glib-Ex-ConnectProperties

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

Version 19, September 2012
    - new Glib::Ex::ConnectProperties::Element

Version 18, August 2012
    - new textbuffer# empty,not-empty,char-count

Version 17, August 2011
    - new screen-size# width,height,width-mm,height-mm

Version 16, May 2011
    - new combobox-active# exists,path,iter,text

Version 15, May 2011
    - new tree-selection# and iconview-selection# with
      empty, not-empty, count, selected-path

Version 14, November 2010
    - new response-sensitive#ID

Version 13, November 2010
    - new child#prop

MANIFEST  view on Meta::CPAN

COPYING
debian/changelog
debian/compat
debian/control
debian/copyright
debian/rules
debian/source/format
debian/watch
devel/child-run.pl
devel/child.pl
devel/combobox.pl
devel/combobox_active.pl
devel/container.pm
devel/goo_child.pl
devel/goo_child.pm
devel/hash-undef.pl
devel/infinite-notify.pl
devel/misc.pl
devel/model.pl
devel/naive-handlers.pl
devel/proptypes.pl
devel/read-on-signal.pl

MANIFEST  view on Meta::CPAN

devel/value-validate-boxed.pl
devel/widget-direction.pl
devel/widget-toplevel.pl
examples/func-transform.pl
examples/hash-transform.pl
examples/sensitive.pl
examples/unidirectional.pl
lib/Glib/Ex/ConnectProperties.pm
lib/Glib/Ex/ConnectProperties/Element.pm
lib/Glib/Ex/ConnectProperties/Element/child.pm
lib/Glib/Ex/ConnectProperties/Element/combobox_active.pm
lib/Glib/Ex/ConnectProperties/Element/iconview_selection.pm
lib/Glib/Ex/ConnectProperties/Element/model_rows.pm
lib/Glib/Ex/ConnectProperties/Element/object.pm
lib/Glib/Ex/ConnectProperties/Element/response_sensitive.pm
lib/Glib/Ex/ConnectProperties/Element/screen_size.pm
lib/Glib/Ex/ConnectProperties/Element/textbuffer.pm
lib/Glib/Ex/ConnectProperties/Element/tree_selection.pm
lib/Glib/Ex/ConnectProperties/Element/widget.pm
lib/Glib/Ex/ConnectProperties/Element/widget_allocation.pm
Makefile.PL
MANIFEST			This list of files
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

SIGNATURE  view on Meta::CPAN

SHA256 0509692e7183e8ae84e8373e488d669251167e6544ffe53a214ba70a67ce1487 README
SHA256 438d77f7d095e42a714d3e6cc87e6404f83cf68cdb6dbc847e0eedb2a6837422 debian/changelog
SHA256 2e6d31a5983a91251bfae5aefa1c0a19d8ba3cf601d0e8a706b4cfa9661a6b8a debian/compat
SHA256 db2b5766d172075cde18675d47e16758a5d81ead0e97a60c65a9e2f1972124ba debian/control
SHA256 da3aa424390f7397fd8f5d735edb7f1add358c2ce1df8ad4b22877b0db4a3363 debian/copyright
SHA256 23248e99b1cd607cc3b26de414788253d7f41dc02c65539dc5274aeb86a49a79 debian/rules
SHA256 5717e7c840171019a4eeab5b79a7f894a4986eaff93d04ec5b12c9a189f594bf debian/source/format
SHA256 e883783d4fdf654b7473d4adbb3cd7db3667ea9b10774a7fec232e1a90bad825 debian/watch
SHA256 792f53ad4ee5b05a2b3f41fecf752e4f19a3960d19f8d7caf471e8423fb1bb23 devel/child-run.pl
SHA256 e74e776ade26e610892534cbf66110364ef805636aa138b22541bbd88200454c devel/child.pl
SHA256 10d1021a95e2ae7b61501144df289335aad2df2e17abc7c3e02cd02ea6c7bb2b devel/combobox.pl
SHA256 6c64793fdca5473a70fa83d54e84360293bdee6d63d9be3526ded4049909a774 devel/combobox_active.pl
SHA256 255f038d7a196306459742041ab11091ab544286b39ff0f777bd9d3cc08f1222 devel/container.pm
SHA256 10347c24eea9824e4821e3739aae65ba1c202bd087512f6bb3bc2fa4ae9b31ba devel/goo_child.pl
SHA256 34dd8ec7cc63cb3e25f994803ea000e333529f6fb52361b15e113ed8363ff1e7 devel/goo_child.pm
SHA256 976f9369afdcd8702ebf13f712343a8dbc8123c8bc71e8eb99b9f5cd77677ba5 devel/hash-undef.pl
SHA256 14179624114f3dbe2a6b6aac90badf3600d0f22f16a93aaa58f7cc39cf413b84 devel/infinite-notify.pl
SHA256 900de462d60340168cdd73c2ab0fec15f0b1d8faa34a2fd161991e157e886d72 devel/misc.pl
SHA256 b61e5bb9b27885bcb7d10712439cb5bd978c78ffad729a3f639ebda5ff29b3ad devel/model.pl
SHA256 2d62557679c20e5b8c5ccead4321a544ca26ee6eb7c1d8db36e615d9ebfd631c devel/naive-handlers.pl
SHA256 f73c3fec4bada174bef211df3b9a6f0471b443946da92b9ec601a78d661b75e8 devel/proptypes.pl
SHA256 c3145b54fe7aeab0f85f0ce1ec85a872297b6c99352c390da56168b21bac6573 devel/read-on-signal.pl

SIGNATURE  view on Meta::CPAN

SHA256 24bef5cbc5a45443aef797db9f9fa15a55bfc3f078fed41433291a78ae113e10 devel/value-validate-boxed.pl
SHA256 b7d95b80f21834ce5029009c82cb360fc9431a80b81a6b97bfec2ffe8d5dd793 devel/widget-direction.pl
SHA256 31829d596a495e731a207f448d39b068dd0b867bfb7d68051678c675e33dabd0 devel/widget-toplevel.pl
SHA256 7e2892e56297ec7fa35c2ac38bfd2a3380ad012f4d30e4a4a7933351f7d90709 examples/func-transform.pl
SHA256 e3d10bcecf1a10a9a030d18db1af6c3e90beb5838cd412298fe76db34f4bd3ba examples/hash-transform.pl
SHA256 640575ebf1404cf187378095a1bb90f852a0fb7f7f79e68d18e8d9dc2ccdf3a2 examples/sensitive.pl
SHA256 6c39cc534706c9b1508bea75cbeb156ceb0afce82052e7ee389eaed41bc92f8b examples/unidirectional.pl
SHA256 1905e70bb8e3729cd6e11b9bac2196b20c9132a25dd79ca8c055520a7cfd622f lib/Glib/Ex/ConnectProperties.pm
SHA256 48ef4153eb86c624057744dfc3dd7ae3214e6ca9c83479f57e55b4ee9301d9ad lib/Glib/Ex/ConnectProperties/Element.pm
SHA256 a687b70906dc60ac2ab70789cdc26bb618fe35881d48828c8649e13ef2c8ac83 lib/Glib/Ex/ConnectProperties/Element/child.pm
SHA256 3da5bcb9dd12c369f8838b81a650e4effcf4d9ecccd8276c56e11d33258de114 lib/Glib/Ex/ConnectProperties/Element/combobox_active.pm
SHA256 26fa4574f56321eeb84d9446c1039d92fc33b72f35b9b36641dcd19f1c2908a7 lib/Glib/Ex/ConnectProperties/Element/iconview_selection.pm
SHA256 038b71ddc6ea682ddebc19dda9d743ac5083aac2c57ab429ca891538ed1e9140 lib/Glib/Ex/ConnectProperties/Element/model_rows.pm
SHA256 8054ee01011ccabdcf7b8e41e975c58b71cd3d16e67ee269e6ac19fef3cb27de lib/Glib/Ex/ConnectProperties/Element/object.pm
SHA256 baea3441c3a1d700bfe38cb089e3c5084c987b812f2d718ff6eed0c14fba3a64 lib/Glib/Ex/ConnectProperties/Element/response_sensitive.pm
SHA256 b80c9fe3220919e067bc38344478ab5ae0df4de5d0d23776eae9c2c079ae55c0 lib/Glib/Ex/ConnectProperties/Element/screen_size.pm
SHA256 af7df348edaa3f06beec68d2de8735fcc9397ba3b053a77f45b3523c1cf0b657 lib/Glib/Ex/ConnectProperties/Element/textbuffer.pm
SHA256 21ae096c1e9edd43621eec1458c255611d6390b00d246291f6b046aab3dadd0c lib/Glib/Ex/ConnectProperties/Element/tree_selection.pm
SHA256 54b8e07d1392a5810041f2fd29d542b856e8f277832831b47c4e0f27920a2cf4 lib/Glib/Ex/ConnectProperties/Element/widget.pm
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

devel/combobox.pl  view on Meta::CPAN


use 5.010;
use strict;
use warnings;
use Glib::Ex::ConnectProperties;
use Gtk2 '-init';

use FindBin;
my $progname = $FindBin::Script;

my $combobox = Gtk2::ComboBox->new;
$combobox->destroy;

### active: $combobox->get_active
### iter: $combobox->get_active_iter

exit 0;

devel/combobox_active.pl  view on Meta::CPAN

                 'Item four',
                 'Item five') {
  $model->insert_with_values (undef, 9999, 0 => $str);
}
{
  my $iter = $model->iter_nth_child (undef, 2);
  $model->insert_with_values ($iter, 9999, 0 => 'Subitem one');
  $model->insert_with_values ($iter, 9999, 0 => 'Subitem two');
}

my $combobox = Gtk2::ComboBox->new; #  ($model);
$combobox->set_active (13);
### active: $combobox->get_active
### active_iter: $combobox->get_active_iter

$combobox->set_active_iter (undef);
### active: $combobox->get_active
### active_iter: $combobox->get_active_iter


$combobox->set_model ($model);

### active: $combobox->get_active
### active_iter: $combobox->get_active_iter

exit 0;

lib/Glib/Ex/ConnectProperties.pm  view on Meta::CPAN

    "child#propname"

See the following modules for Gtk related settings,

=over

=over

=item L<Glib::Ex::ConnectProperties::Element::child>

=item L<Glib::Ex::ConnectProperties::Element::combobox_active>

=item L<Glib::Ex::ConnectProperties::Element::model_rows>

=item L<Glib::Ex::ConnectProperties::Element::response_sensitive>

=item L<Glib::Ex::ConnectProperties::Element::screen_size>

=item L<Glib::Ex::ConnectProperties::Element::tree_selection>

=item L<Glib::Ex::ConnectProperties::Element::iconview_selection>

lib/Glib/Ex/ConnectProperties/Element/combobox_active.pm  view on Meta::CPAN

#
# Glib-Ex-ConnectProperties is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with Glib-Ex-ConnectProperties.  If not, see <http://www.gnu.org/licenses/>.


package Glib::Ex::ConnectProperties::Element::combobox_active;
use 5.008;
use strict;
use warnings;
use Carp;
use Glib;
use Gtk2;
use Gtk2::Ex::ComboBoxBits 32; # v.32 for get_active_text()

use base 'Glib::Ex::ConnectProperties::Element';
our $VERSION = 20;

lib/Glib/Ex/ConnectProperties/Element/combobox_active.pm  view on Meta::CPAN


use constant read_signal => 'changed';

my %get_method = (exists => sub { !! $_[0]->get_active_iter },
                  iter   => 'get_active_iter',
                  path   => \&Gtk2::Ex::ComboBoxBits::get_active_path,
                  text   => 'get_active_text',
                 );
sub get_value {
  my ($self) = @_;
  ### combobox_active get_value()
  my $method = $get_method{$self->{'pname'}};
  return $self->{'object'}->$method;
}

my %set_method = (iter => (eval{Gtk2->VERSION(1.240);1}
                           ? 'set_active_iter'
                           # no $iter==undef support until Perl-Gtk2 1.240
                           : sub {
                             my ($combobox, $iter) = @_;
                             if ($iter) {
                               $combobox->set_active_iter($iter);
                             } else {
                               $combobox->set_active(-1);
                             }
                           }),
                  path => \&Gtk2::Ex::ComboBoxBits::set_active_path,
                  text => \&Gtk2::Ex::ComboBoxBits::set_active_text,
                 );
sub set_value {
  my ($self, $value) = @_;
  ### combobox_active set_value()
  my $method = $set_method{$self->{'pname'}};
  return $self->{'object'}->$method ($value);
}

1;
__END__

# 'combobox-active#exists'
# 'combobox-active#iter'
# 'combobox-active#path'
# 'combobox-active#text'


# maybe ...
# 'combobox-active#column-N'



# maybe ...
#
# 'path-string' => Glib::ParamSpec->string ('path-string',
#                                           '',  # nick
#                                           '',  # blurb
#                                           '',  # default, unused
#                                           Glib::G_PARAM_READWRITE),
#                   'path-string' => \&_combobox_get_active_path_string,
#                   'path-string' => \&_combobox_set_active_path_string,
# sub _combobox_get_active_path_string {
#   my ($combobox) = @_;
#   my $path;
#   return (($path = _combobox_get_active_path($_[0]))
#           && $path->to_string);
# }
# sub _combobox_set_active_path_string {
#   my ($combobox, $str) = @_;
#   Gtk2::Ex::ComboBoxBits::set_active_path
#       ($combobox, Gtk2::TreePath->new_from_string($str));
# }

=for stopwords Glib-Ex-ConnectProperties ConnectProperties combobox ComboBox toplevel Ryde

=head1 NAME

Glib::Ex::ConnectProperties::Element::combobox_active -- combobox active item

=for test_synopsis my ($combobox,$another);

=head1 SYNOPSIS

 Glib::Ex::ConnectProperties->new([$combobox, 'combobox-active#exists'],
                                  [$another,  'something']);

=head1 DESCRIPTION

This element class implements ConnectProperties access to the "active" item
of a L<Gtk2::ComboBox>.  These elements require the
C<Gtk2::Ex::ComboBoxBits> helper module.

    combobox-active#exists     boolean, read-only
    combobox-active#path       Gtk2::TreePath
    combobox-active#iter       Gtk2::TreeIter
    combobox-active#text       string

For just toplevel rows the plain ComboBox C<active> property is enough.
C<combobox-active#path> and C<combobox-active#iter> are good for a combobox
with sub-rows.

C<combobox-active#text> is for use with a "simplified text" ComboBox as
created by C<< Gtk2::ComboBox->new_text() >> etc.

=head1 SEE ALSO

L<Glib::Ex::ConnectProperties>,
L<Glib::Ex::ConnectProperties::Element::tree_selection>,
L<Gtk2::ComboBox>

=head1 HOME PAGE

lib/Glib/Ex/ConnectProperties/Element/tree_selection.pm  view on Meta::CPAN

For reference a C<selected-iter> of type C<Gtk2::TreeIter> might mostly
work, but not sure about comparing on storing.  Would prefer an C<equal()>
or C<compare()> method on C<Gtk2::TreeIter> rather than going via the model.
(Perl-Gtk2's C<to_arrayref()> access only suits Perl code models.)

=head1 SEE ALSO

L<Glib::Ex::ConnectProperties>,
L<Glib::Ex::ConnectProperties::Element::iconview_selection>,
L<Glib::Ex::ConnectProperties::Element::model_rows>,
L<Glib::Ex::ConnectProperties::Element::combobox_active>,
L<Gtk2::TreeSelection>,
L<Gtk2::TreeView>,
L<Gtk2::TreePath>

=head1 HOME PAGE

L<http://user42.tuxfamily.org/glib-ex-connectproperties/index.html>

=head1 LICENSE

t/combobox-active.t  view on Meta::CPAN

                      Glib::ParamSpec->string
                      ('mystring',
                       'mystring',
                       'Blurb.',
                       '', # default
                       Glib::G_PARAM_READWRITE),
                    ];
}

#------------------------------------------------------------------------------
# combobox-active#exists

{
  my $model = Gtk2::TreeStore->new ('Glib::String');
  $model->insert (undef, 0);
  $model->insert (undef, 1);
  $model->insert (undef, 2);
  $model->insert ($model->iter_nth_child(undef,2), 0);
  $model->insert ($model->iter_nth_child(undef,2), 1);

  my $foo = Foo->new (mybool => 1);
  my $combobox = Gtk2::ComboBox->new;

  Glib::Ex::ConnectProperties->new
      ([$combobox, 'combobox-active#exists'],
       [$foo, 'mybool']);
  is ($foo->get('mybool'),0);

  $combobox->set_model ($model);
  $combobox->set_active (0);
  is ($foo->get('mybool'),1);

  $combobox->set_active (-1);
  is ($foo->get('mybool'),0);

  $combobox->set_active_iter ($model->get_iter
                              (Gtk2::TreePath->new_from_indices(2,1)));
  is ($foo->get('mybool'),1);
}

#------------------------------------------------------------------------------
# combobox-active#path

sub _active_path_str {
  my ($combobox) = @_;
  my ($model, $iter, $path);
  return (($model = $combobox->get_model)
          && ($iter = $combobox->get_active_iter)
          && ($path = $model->get_path($iter))
          && $path->to_string);
}

{
  my $model = Gtk2::TreeStore->new ('Glib::String');
  $model->insert (undef, 0);
  $model->insert (undef, 1);
  $model->insert (undef, 2);
  $model->insert ($model->iter_nth_child(undef,2), 0);
  $model->insert ($model->iter_nth_child(undef,2), 1);

  my $c1 = Gtk2::ComboBox->new;
  my $c2 = Gtk2::ComboBox->new;

  Glib::Ex::ConnectProperties->new
      ([$c1, 'combobox-active#path'],
       [$c2, 'combobox-active#path']);
  is ($c1->get_active_iter, undef);
  is ($c2->get_active_iter, undef);
  is (_active_path_str($c1), undef);
  is (_active_path_str($c2), undef);

  $c1->set_model ($model);
  $c2->set_model ($model);
  is (_active_path_str($c1), undef);
  is (_active_path_str($c2), undef);

t/combobox-active.t  view on Meta::CPAN

  is (_active_path_str($c2), undef);

  $c1->set_active_iter ($model->get_iter
                        (Gtk2::TreePath->new_from_indices(2,1)));
  is (_active_path_str($c1), '2:1');
  is (_active_path_str($c2), '2:1');
}


#------------------------------------------------------------------------------
# combobox-active#iter

{
  my $model = Gtk2::TreeStore->new ('Glib::String');
  $model->insert (undef, 0);
  $model->insert (undef, 1);
  $model->insert (undef, 2);
  $model->insert ($model->iter_nth_child(undef,2), 0);
  $model->insert ($model->iter_nth_child(undef,2), 1);

  my $c1 = Gtk2::ComboBox->new;
  my $c2 = Gtk2::ComboBox->new;

  Glib::Ex::ConnectProperties->new
      ([$c1, 'combobox-active#iter'],
       [$c2, 'combobox-active#iter']);
  is ($c1->get_active_iter, undef);
  is ($c2->get_active_iter, undef);
  is (_active_path_str($c1), undef);
  is (_active_path_str($c2), undef);

  $c1->set_model ($model);
  $c2->set_model ($model);
  is (_active_path_str($c1), undef);
  is (_active_path_str($c2), undef);

t/combobox-active.t  view on Meta::CPAN

  is (_active_path_str($c2), undef);

  $c1->set_active_iter ($model->get_iter
                        (Gtk2::TreePath->new_from_indices(2,1)));
  is (_active_path_str($c1), '2:1');
  is (_active_path_str($c2), '2:1');
}


#------------------------------------------------------------------------------
# combobox-active#text

{
  my $foo = Foo->new (mystring => 'blah');
  my $combobox = Gtk2::ComboBox->new_text;
  $combobox->append_text ('foo');
  $combobox->append_text ('bar');
  $combobox->append_text ('quux');
  $combobox->append_text ('blah');

  Glib::Ex::ConnectProperties->new
      ([$foo, 'mystring'],
       [$combobox, 'combobox-active#text']);
  is ($foo->get('mystring'),'blah');
  is ($combobox->get_active, 3);

  $combobox->set_active(1);
  is ($combobox->get_active, 1);
  is ($foo->get('mystring'),'bar');

  $foo->set (mystring => 'quux');
  is ($foo->get('mystring'),'quux');
  is ($combobox->get_active, 2);
}




exit 0;



( run in 1.440 second using v1.01-cache-2.11-cpan-8dfa8b56332 )