Gtk2-Ex-Dashes

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

debian/source/format
debian/watch
devel/run.pl
devel/screenshot.pl
devel/tearoff.pl
devel/vert.pl
examples/settings.pl
examples/simple.pl
examples/vertical.pl
lib/Gtk2/Ex/Dashes.pm
lib/Gtk2/Ex/Dashes/MenuItem.pm
Makefile.PL
MANIFEST			This list of files
MANIFEST.SKIP
SIGNATURE
t/Dashes-load.t
t/Dashes-weaken.t
t/Dashes.t
t/MenuItem-load.t
t/MenuItem-weaken.t
t/MenuItem.t
t/MyTestHelpers.pm
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
xt/0-Test-DistManifest.t
xt/0-Test-Pod.t
xt/0-Test-Synopsis.t
xt/0-Test-YAML-Meta.t

SIGNATURE  view on Meta::CPAN

SHA256 5717e7c840171019a4eeab5b79a7f894a4986eaff93d04ec5b12c9a189f594bf debian/source/format
SHA256 33a27e2f3547aaedc53337927c95de96123878ee769a42602c8bf4b7f9f50c5b debian/watch
SHA256 b1c0a005d3e47f9d27348a3707b75d66268bff0d4536b699493651f1c6bbc3d2 devel/run.pl
SHA256 bf1dd66d8686559a0a877927406af7bdf59275867a73ece4a55bca528696839c devel/screenshot.pl
SHA256 3509cc6716e94bb7b1ed155a8ac56a8235bd57d3a8c1ef2fa0980d1ef35458f1 devel/tearoff.pl
SHA256 7900258bfeb87c16d6962f5815e7761dc9f1ea12ae690684366d1cc6ab5d1b85 devel/vert.pl
SHA256 6f7e33f011e3a08c0da6c5020b32db23808a8d4e71df046fe563265122371ff8 examples/settings.pl
SHA256 4447ccb3483609df86d875fd11499ca8f9d1b1ae176cd825a8c9ce65d082e8a5 examples/simple.pl
SHA256 2b3e8056919b6e5ba9a06947bbe97ac67ae1a39afb974410e96c1fc2c452cda5 examples/vertical.pl
SHA256 d9f34b9bf19d229154a864400780044e4faaa24c8b6c7c1161938cad24748a9c lib/Gtk2/Ex/Dashes.pm
SHA256 4f91936177488a785f5cacf143a0b2f8a7578ff307d2ec9778fc817118a83180 lib/Gtk2/Ex/Dashes/MenuItem.pm
SHA256 a0f27a15cefe5797ed0e7d88c21d017d023c1e4ea415927d79ad7878ebc5e890 t/Dashes-load.t
SHA256 761b7845d72b0f9eaba6ca1cfeb75e383b7aa553f53f075f6d2f429de88f69a0 t/Dashes-weaken.t
SHA256 5f3cbb9f24120eafd07a7d4e3eb7e1ff77bcfecc4dbe4be6150f1ee183944963 t/Dashes.t
SHA256 1a62506b039eccdd65ce16249378854436255b1e56827d43962b5b5ad97e2793 t/MenuItem-load.t
SHA256 586714d334835ab91a047a0680383f09e318d8141dbfcb6405481cc8e4e0c9aa t/MenuItem-weaken.t
SHA256 0bc3128cef3260c635521dd98e0e4259ca685ac8621901d5336b18228710cd5d t/MenuItem.t
SHA256 91cd2bba3e246abf05c342ed549ed6d902e8a77a43b6c9c4e092e4c918732ac0 t/MyTestHelpers.pm
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
SHA256 d33b48c1986680cd934565250bd9e3879674dfe6aad69b1717ed76354a29ff44 xt/0-Test-YAML-Meta.t
SHA256 1ae41bbd04e6aba264df79250d525e8b2b2e6b311930ef191c5e432936706cdc xt/0-examples-xrefs.t
SHA256 75a73148514fad2715873d1e02a6fa8e3b9cc43f7aff97aaffac9721c086a319 xt/0-file-is-part-of.t
SHA256 6bdbe1a3a52562b120ddac9fab256ef581e65f5b189422c0ccdb968915b6269c xt/0-no-debug-left-on.t

debian/control  view on Meta::CPAN

Build-Depends: cdbs, debhelper (>= 5)
Maintainer: Kevin Ryde <user42_kevin@yahoo.com.au>
Standards-Version: 4.2.1
Homepage: http://user42.tuxfamily.org/gtk2-ex-dashes/index.html
Bugs: mailto:user42_kevin@yahoo.com.au

Package: libgtk2-ex-dashes-perl
Architecture: all
Depends: libglib-perl, libgtk2-perl, ${perl:Depends}, ${misc:Depends}
Description: Widget displaying a row of dashes
 Gtk2::Ex::Dashes displays a simple row of dashes.  A MenuItem
 subclass gives the look of a Gtk2::TearoffMenuItem, as a plain menu
 item.

devel/run.pl  view on Meta::CPAN

    (clicked => sub {
       foreach my $dashes (@dashes_list) {
         my $alloc = $dashes->allocation;
         my $x = int($alloc->width/2);
         $dashes->queue_draw_area ($alloc->x + $x, $alloc->y,
                                   $alloc->width-$x, $alloc->height);
       }
     });
}

my $tearoff = Gtk2::TearoffMenuItem->new;
print "$progname: tearoff border ", $tearoff->get_border_width,
  ",", $tearoff->get_border_width, "\n";

$toplevel->show_all;
print "$progname: ythickness after show ", $dashes_list[1]->style->ythickness, "\n";

Gtk2->main;
exit 0;

devel/tearoff.pl  view on Meta::CPAN

# 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 Gtk2-Ex-Dashes.  If not, see <http://www.gnu.org/licenses/>.

use 5.010;
use strict;
use warnings;
use Gtk2 '-init';
use Gtk2::Ex::Dashes::MenuItem;

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

my $menu = Gtk2::Menu->new;

my $tearoff = Gtk2::TearoffMenuItem->new;
$tearoff->show;
$menu->append ($tearoff);
$menu->set (reserve_toggle_size => 0);
print "$progname: tearoff border ", $tearoff->get_border_width,
  ",", $tearoff->get_border_width, "\n";

my $dashesitem = Gtk2::Ex::Dashes::MenuItem->new;
print "$progname: dashesitem $dashesitem\n";
$dashesitem->signal_connect
  (direction_changed => sub {
     print "$progname: dashesitem direction-changed\n";
   });
$dashesitem->signal_connect
  (show => sub {
     print "$progname: dashesitem show\n";
   });
$dashesitem->signal_connect

devel/tearoff.pl  view on Meta::CPAN

  (style_set => sub {
     my ($dashes, $prev_style) = @_;
     print "$progname: child style_set, was ",$prev_style//'undef'," now ",$dashes->get_style,"\n";
   });
print "$progname: dashesitem show\n";
$dashesitem->show;
print "$progname: dashesitem append\n";
$menu->append ($dashesitem);
print "$progname: done\n";

my $zitem = Gtk2::MenuItem->new ('ZZZZZZZZZZZZ');
$zitem->show;
$menu->append ($zitem);

$dashesitem->set_direction ('rtl');
print "$progname: child direction is ",$dashes->get_direction,"\n";

print "$progname: popup\n";
$menu->popup (undef, undef, undef, undef,
              1, 0);

lib/Gtk2/Ex/Dashes.pm  view on Meta::CPAN

                  ('orientation',
                   'Orientation',
                   'Horizontal or vertical line draw.',
                   'Gtk2::Orientation',
                   'horizontal',
                   Glib::G_PARAM_READWRITE),
                ];

# Multiplied by $widget->style->ythickness.
# For default theme thickness 2 pixels this gives dash segments 5 pixels
# same as Gtk2::TearoffMenuItem.
use constant _DASH_FACTOR => 2.5;

sub INIT_INSTANCE {
  my ($self) = @_;
  $self->set_flags('no-window');
}

sub SET_PROPERTY {
  my ($self, $pspec, $newval) = @_;
  my $pname = $pspec->get_name;

lib/Gtk2/Ex/Dashes.pm  view on Meta::CPAN

A C<Gtk2::Ex::Dashes> widget displays a line of dashes, either horizontally
or vertically.

    +--------------------------------+
    |                                |
    |  ====  ====  ====  ====  ====  |
    |                                |
    +--------------------------------+

It's similar to C<Gtk2::Separator>, but a dashed line, and the
C<Gtk2::Ex::Dashes::MenuItem> subclass looks like C<Gtk2::TearoffMenuItem>
but is a plain item, not driving the menu.

Line segments are drawn per the widget style (see L<Gtk2::Style>) and
positioned in the widget area per the C<Gtk2::Misc> properties described
below.  There's nothing to control the length and spacing of the line
segments, currently they just scale with the line thickness to keep the
display sensible.

See F<examples/simple.pl> or F<examples/vertical.pl> in the sources for the
simplest usage, or F<examples/settings.pl> to interactively see the effect

lib/Gtk2/Ex/Dashes.pm  view on Meta::CPAN

when vertical.

If the widget text direction (see C<set_direction> in L<Gtk2::Widget>) is
C<rtl> then the sense of C<xalign> is reversed, so 0 means the right edge
instead of the left.

=back

=head1 SEE ALSO

L<Gtk2::Ex::Dashes::MenuItem>,
L<Gtk2::Misc>, L<Gtk2::Separator>, L<Gtk2::TearoffMenuItem>

=head1 HOME PAGE

L<http://user42.tuxfamily.org/gtk2-ex-dashes/index.html>

=head1 LICENSE

Gtk2-Ex-Dashes is Copyright 2010, 2011, 2019 Kevin Ryde

Gtk2-Ex-Dashes is free software; you can redistribute it and/or modify it

lib/Gtk2/Ex/Dashes/MenuItem.pm  view on Meta::CPAN

# version.
#
# Gtk2-Ex-Dashes 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 Gtk2-Ex-Dashes.  If not, see <http://www.gnu.org/licenses/>.

package Gtk2::Ex::Dashes::MenuItem;
use 5.008;
use strict;
use warnings;
use Gtk2;

# uncomment this to run the commented-out ### lines
#use Smart::Comments;

our $VERSION = 3;

use Glib::Object::Subclass
  'Gtk2::MenuItem',
  signals => { direction_changed => \&_do_direction_changed };

sub INIT_INSTANCE {
  my ($self) = @_;

  require Gtk2::Ex::Dashes;
  my $dashes = Gtk2::Ex::Dashes->new (visible => 1,
                                      xalign => 0);
  $self->add ($dashes);

  # Is it necessary to set the initial direction, or will the initial be the
  # same for the two widgets anyway?
  ### initial child set_direction
  $self->get_child->set_direction ($self->get_direction);

  # The initial style is just the default, a real style is set later when
  # MenuItem gets into a toplevel tree, so must signal_connect() to set ypad
  # from the real thickness.  Or would a fixed 2 pixels be enough anyway?
  #
  ### initial _ypad_from_style_ythickness
  $dashes->signal_connect (style_set => \&_ypad_from_style_ythickness);
  _ypad_from_style_ythickness ($dashes); # initial setting

  ### done INIT_INSTANCE
}

sub _ypad_from_style_ythickness {
  my ($dashes) = @_;
  ### Dashes-MenuItem _ypad_from_style_ythickness(): $dashes->style->ythickness
  $dashes->set (ypad => $dashes->style->ythickness);
}

# Not certain if it's a great idea to propagate the direction from the
# parent to the child.  If the child is thought of as a display detail it
# makes sense, but not if it's supposed to be independently controlled.
#
sub _do_direction_changed {
  my ($self) = @_;  # ($self, $prev_direction)
  ### Dashes-MenuItem _do_direction_changed(): $self->get_direction
  $self->get_child->set_direction ($self->get_direction);
  return shift->signal_chain_from_overridden(@_);
}

1;
__END__

=head1 NAME

Gtk2::Ex::Dashes::MenuItem -- menu item showing a row of dashes

=for test_synopsis my ($menu)

=head1 SYNOPSIS

 use Gtk2::Ex::Dashes::MenuItem;
 my $item = Gtk2::Ex::Dashes::MenuItem->new;
 $menu->append ($item);

=head1 WIDGET HIERARCHY

C<Gtk2::Ex::Dashes::MenuItem> is a subclass of C<Gtk2::MenuItem>.

    Gtk2::Widget
      Gtk2::Container
        Gtk2::Bin
          Gtk2::Item
            Gtk2::MenuItem
              Gtk2::Ex::Dashes::MenuItem

=head1 DESCRIPTION

A C<Gtk2::Ex::Dashes::MenuItem> displays a line of dashes similar in
appearance to a C<Gtk2::TearoffMenuItem>, but as a plain menu item, not
driving the tearoff state.

    +--------------------------------+
    |                                |
    |  ====  ====  ====  ====  ====  |
    |                                |
    +--------------------------------+

Clicking on the item runs the MenuItem C<activate> handler etc in the usual
way.  Connect to that signal to run an action for the item.  The idea is you
can open a dialog box or toplevel toolbox representing the menu contents,
with more things or more features than just a torn-off menu would provide.

=head1 FUNCTIONS

=over 4

=item C<< $item = Gtk2::Ex::Dashes::MenuItem->new (key=>value,...) >>

Create and return a new C<Dashes::MenuItem> widget.  Optional key/value
pairs can be given to set initial properties, as per
C<< Glib::Object->new >>.

For example setting the C<visible> property saves the usual
C<< $item->show >> needed before adding to a menu.

    my $item = Gtk2::Ex::Dashes::MenuItem->new (visible => 1);

=back

=cut

=head1 PROPERTIES

There are properties beyond what C<Gtk2::MenuItem> offers.

The widget text direction (ie. C<set_direction>) on the C<Dashes::MenuItem>
controls which end the dashes start from.  The effect of this is that a
whole dash begins from the same end as the text (left to right or right to
left).

=head1 SEE ALSO

L<Gtk2::Ex::Dashes>, L<Gtk2::MenuItem>, L<Gtk2::TearoffMenuItem>

=head1 HOME PAGE

L<http://user42.tuxfamily.org/gtk2-ex-dashes/index.html>

=head1 LICENSE

Gtk2-Ex-Dashes is Copyright 2010, 2019 Kevin Ryde

Gtk2-Ex-Dashes is free software; you can redistribute it and/or modify it

t/MenuItem-load.t  view on Meta::CPAN

# version.
#
# Gtk2-Ex-Dashes 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 Gtk2-Ex-Dashes.  If not, see <http://www.gnu.org/licenses/>.

use Gtk2::Ex::Dashes::MenuItem;

use Test::More tests => 1;
ok (1, 'Gtk2::Ex::Dashes::MenuItem load as first thing');
exit 0;

t/MenuItem-weaken.t  view on Meta::CPAN

# Gtk2-Ex-Dashes 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 Gtk2-Ex-Dashes.  If not, see <http://www.gnu.org/licenses/>.

use strict;
use warnings;
use Gtk2::Ex::Dashes::MenuItem;
use Test::More;

use lib 't';
use MyTestHelpers;
BEGIN { MyTestHelpers::nowarnings() }

# Test::Weaken 3 for "contents"
eval 'use Test::Weaken 3;
      use Test::Weaken::Gtk2;
      1'
  or plan skip_all => "due to Test::Weaken 3 and/or Test::Weaken::Gtk2 not available -- $@";
diag ("Test::Weaken version ", Test::Weaken->VERSION);

plan tests => 1;

{
  my $leaks = Test::Weaken::leaks
    ({ constructor => sub { Gtk2::Ex::Dashes::MenuItem->new },
       contents => \&Test::Weaken::Gtk2::contents_container,
     });
  is ($leaks, undef, 'Test::Weaken deep garbage collection');
}

exit 0;

t/MenuItem.t  view on Meta::CPAN


use 5.008;
use strict;
use warnings;
use Test::More tests => 14;

use lib 't';
use MyTestHelpers;
BEGIN { MyTestHelpers::nowarnings() }

use Gtk2::Ex::Dashes::MenuItem;

my $want_version = 3;
my $check_version = $want_version + 1000;
{
  is ($Gtk2::Ex::Dashes::MenuItem::VERSION, $want_version,
      'VERSION variable');
  is (Gtk2::Ex::Dashes::MenuItem->VERSION,  $want_version,
      'VERSION class method');

  ok (eval { Gtk2::Ex::Dashes::MenuItem->VERSION($want_version); 1 },
      "VERSION class check $want_version");
  ok (! eval { Gtk2::Ex::Dashes::MenuItem->VERSION($check_version); 1 },
      "VERSION class check $check_version");
}

require Gtk2;
MyTestHelpers::glib_gtk_versions();

{
  my $item = Gtk2::Ex::Dashes::MenuItem->new;
  is ($item->VERSION, $want_version, 'VERSION object method');
  ok (eval { $item->VERSION($want_version); 1 },
      "VERSION object check $want_version");
  ok (! eval { $item->VERSION($check_version); 1 },
      "VERSION object check $check_version");
}

#-----------------------------------------------------------------------------
# set_direction

{
  my $item = Gtk2::Ex::Dashes::MenuItem->new;
  my $dashes = $item->get_child;
  is ($item->get_direction, $dashes->get_direction,
      'direction same initially');

  foreach my $dir ('ltr', 'rtl') {
    $item->set_direction ($dir);
    is ($item->get_direction, $dashes->get_direction,
        "'direction same on set $dir");
  }
}

t/MenuItem.t  view on Meta::CPAN

Gtk2->disable_setlocale;  # leave LC_NUMERIC alone for version nums
my $have_display = Gtk2->init_check;

#-----------------------------------------------------------------------------
# ypad from ythickness

SKIP: {
  $have_display or skip 'due to no DISPLAY available', 3;

  {
    my $item = Gtk2::Ex::Dashes::MenuItem->new;
    my $dashes = $item->get_child;
    my $yt = $dashes->style->ythickness;
    is ($dashes->get('ypad'), $yt, 'ypad initial');

    my $yt2 = $yt + 5;
    Gtk2::Rc->parse_string (<<"HERE");
style "my_style" {
  ythickness = $yt2
}
class "Gtk2__Ex__Dashes" style "my_style"

t/MenuItem.t  view on Meta::CPAN


    $dashes->set_style ($style2);
    is ($dashes->get('ypad'), $yt2, 'ypad with style2');
  }
}

#-----------------------------------------------------------------------------
# weaken()

{
  my $item = Gtk2::Ex::Dashes::MenuItem->new;
  require Scalar::Util;
  Scalar::Util::weaken ($item);
  is ($item, undef, 'garbage collect when weakened');
}

exit 0;



( run in 0.747 second using v1.01-cache-2.11-cpan-49f99fa48dc )