view release on metacpan or search on metacpan
Copyright 2010, 2011, 2019 Kevin Ryde
This file is part of Gtk2-Ex-MenuView.
Gtk2-Ex-MenuView is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
Gtk2-Ex-MenuView 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-MenuView. If not, see <http://www.gnu.org/licenses/>.
Version 5, September 2019
- new email
Version 4, January 2011
- new item_get_path() and item_get_mmpi()
Version 3, September 2010
debian/changelog
debian/compat
debian/control
debian/copyright
debian/rules
debian/source/format
debian/watch
devel/cellview-timer.pl
devel/cellview.pl
devel/child-toggled.pl
devel/junk/ArrayMenu.pm
devel/junk/t-arraymenu.pl
devel/model-signals.pl
devel/param-type.pl
devel/run.pl
devel/screenshot.pl
devel/size-request-container.pl
devel/size-request-sig.pl
devel/size-request.pl
devel/two-radios.pl
examples/builder.pl
examples/cellview.pl
examples/checkitem.pl
examples/radiogroup.pl
examples/simple.pl
examples/twiddle.pl
inc/my_pod2html
lib/Gtk2/Ex/MenuView.pm
lib/Gtk2/Ex/MenuView/Menu.pm
Makefile.PL
MANIFEST This list of files
MANIFEST.SKIP
README
SIGNATURE
t/MenuView-display.t
t/MenuView-weaken.t
t/MenuView.t
t/MyTestHelpers.pm
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
META.yml Module YAML meta-data (added by MakeMaker)
{
"abstract" : "Menu of items from a TreeModel.",
"author" : [
"Kevin Ryde <user42_kevin@yahoo.com.au>"
],
"dynamic_config" : 1,
"generated_by" : "ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150010",
"license" : [
"gpl_3"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : 2
},
"name" : "Gtk2-Ex-MenuView",
"no_index" : {
"directory" : [
"t",
"inc",
"devel",
"xt"
]
},
"optional_features" : {
"maximum_interoperation" : {
---
abstract: 'Menu of items from a TreeModel.'
author:
- 'Kevin Ryde <user42_kevin@yahoo.com.au>'
build_requires:
ExtUtils::MakeMaker: '0'
configure_requires:
ExtUtils::MakeMaker: '0'
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150010'
license: gpl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: Gtk2-Ex-MenuView
no_index:
directory:
- t
- inc
- devel
- xt
optional_features:
maximum_interoperation:
description: 'Have maximum inter-operation with other modules (optional other stuff).'
requires:
Makefile.PL view on Meta::CPAN
#!/usr/bin/perl -w
# Copyright 2008, 2009, 2010, 2011, 2012, 2014, 2015 Kevin Ryde
# This file is part of Gtk2-Ex-MenuView.
#
# Gtk2-Ex-MenuView is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# Gtk2-Ex-MenuView 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-MenuView. If not, see <http://www.gnu.org/licenses/>.
use 5.008;
use strict;
use warnings;
use ExtUtils::MakeMaker;
WriteMakefile
(NAME => 'Gtk2::Ex::MenuView',
ABSTRACT => 'Menu of items from a TreeModel.',
VERSION_FROM => 'lib/Gtk2/Ex/MenuView.pm',
AUTHOR => 'Kevin Ryde <user42_kevin@yahoo.com.au>',
LICENSE => 'gpl_3',
SIGN => 1,
MIN_PERL_VERSION => '5.008',
PREREQ_PM => {
'Gtk2' => '1.200',
'Glib::Object::Subclass' => 0,
# my Glib-Ex-ObjectBits
Makefile.PL view on Meta::CPAN
{
maximum_interoperation =>
{ description => 'Have maximum inter-operation with other modules (optional other stuff).',
requires => { 'Locale::Messages' => 0 },
},
},
},
# exclude capital INIT_INSTANCE etc
MyMakeMakerExtras_Pod_Coverage =>
[ 'Gtk2::Ex::MenuView,also_private=>[qr/^[A-Z_]+$$/]' ],
);
Copyright 2010 Kevin Ryde
This file is part of Gtk2-Ex-MenuView.
Gtk2-Ex-MenuView is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
Gtk2-Ex-MenuView 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-MenuView. If not, see <http://www.gnu.org/licenses/>.
Gtk2::Ex::MenuView presents rows from a TreeModel as items in a menu,
with an "activate" signal when one of them is chosen. CheckMenuItem
and RadioMenuItem items can be used too.
The MenuView home page is
http://user42.tuxfamily.org/gtk2-ex-menuview/index.html
SHA256 7053fe339fac55ac3abe148f831e88e0b5a0d392f271daa6598edfb1566350a2 debian/changelog
SHA256 2e6d31a5983a91251bfae5aefa1c0a19d8ba3cf601d0e8a706b4cfa9661a6b8a debian/compat
SHA256 d7e9d5b0e365d4f4f591dbd88d04b85696179e98b194a6829c50d8bec597d5cf debian/control
SHA256 099518e8039cc5b977bad8654ec69c27a9961eab514fd5079d0873e8cab26127 debian/copyright
SHA256 22b44cba540f8517d209b4b5d76cd8e2eea4e6fabb06de99918d64b010d8447d debian/rules
SHA256 5717e7c840171019a4eeab5b79a7f894a4986eaff93d04ec5b12c9a189f594bf debian/source/format
SHA256 7a8bcd7fcdbb087145d0f984c726c71d4cf7791767b688f8ea43dff5c1b9e8ac debian/watch
SHA256 33ba0ea2da2022a9908cb54afeeb6b7e7d434f7d1a36d2a0611ce8ebc153620c devel/cellview-timer.pl
SHA256 b5b45193013989065241e16b5e169ed80b8f451119395046847c4207e33b5cdd devel/cellview.pl
SHA256 671dd8739e7935c5688e52091a8edc0ff23ee956bda306b1be0eabf5ecf1b130 devel/child-toggled.pl
SHA256 1b86875f79e5695812837e83f902071b085f308207c8a0da95732bbaddacebbf devel/junk/ArrayMenu.pm
SHA256 f4d7b4b7b9c42b97f35f59c539afb28320df7d56bdd3341a98bfd8fbc19d3272 devel/junk/t-arraymenu.pl
SHA256 03a966d4fa2982ab38840bec17ff6d0e11826d41067be4b935465b130702b7fb devel/model-signals.pl
SHA256 60f7c3823fbd9c5db8fafa360fbfba2bfcda6436e0dc36e82d23a984f5193b73 devel/param-type.pl
SHA256 7559f514c074cf6d6b8cc06baa1708d2c90f27b080bc3897cb8e0e1885468ad1 devel/run.pl
SHA256 f683817c4fe31a15306bef2eb7b59adb070f7a59eb739e829588a54ab925e27b devel/screenshot.pl
SHA256 641c4b0e0b9031a688e9e4b149d6a750d60f800c8e6c46b77af8f5d553ad3e93 devel/size-request-container.pl
SHA256 90eae3f6b7444fcc05efb938b75ec8fa84f55b362dafafc4b618e9f955bf5b91 devel/size-request-sig.pl
SHA256 6e055ffd480432783abdf2833771a556fff0524102896a2dffdda9c06db71ff8 devel/size-request.pl
SHA256 081258c1cbdab32229d9a0851244a31055d4e4aa884572675bf8c8bd4a653e0f devel/two-radios.pl
SHA256 78a05839414d391bf5c526c68d820ae783a5ce63bb3f976e7981cfe49d360dbf examples/builder.pl
SHA256 450996ae1ebf217723eeef43a6606af0f9f2f706fce3f563ac70372d5e1b031b examples/cellview.pl
SHA256 95ff403b66d4f02904305f05c956f776558f8c95ec4c3e779a5879a02231162b examples/checkitem.pl
SHA256 e96f90fa2de6ad17403b3819348ef7371c5fd43d6307e5e7d5e8a00010ed0d43 examples/radiogroup.pl
SHA256 d13edab4b63e63d40ec10803cd3620b946b1f72dec82005ec648da8936f568c4 examples/simple.pl
SHA256 6ddfd51c4b99471b28acad1be50e27139ef0ec953d9c942a37dd3f7502bceeb7 examples/twiddle.pl
SHA256 28bec8fe29b497164cfeac7aa1707d8ed81874bb08ccda5b7a490b0869f4a3ca inc/my_pod2html
SHA256 9a4843a45f028ee9c79d11d2981732dc250bc439fdb76473b04334641e2dfc50 lib/Gtk2/Ex/MenuView.pm
SHA256 690053b65d865a4aa1688ee4c0f10852090127666c629b34452afde6bf95c26c lib/Gtk2/Ex/MenuView/Menu.pm
SHA256 8c25c28c2e01dcf1ec8d9fe377939b0b5a08ba17f98c28f2c575652d357d8b85 t/MenuView-display.t
SHA256 6fbf67fe0573e42427fb37fdbe52a8d5cc01d8e384b6c8b691431f398557665b t/MenuView-weaken.t
SHA256 197f63a8e50f231f03a4d4a8d3ac113accaa84e73fa906d3fd910ab53dbc8e15 t/MenuView.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 75a73148514fad2715873d1e02a6fa8e3b9cc43f7aff97aaffac9721c086a319 xt/0-file-is-part-of.t
SHA256 6bdbe1a3a52562b120ddac9fab256ef581e65f5b189422c0ccdb968915b6269c xt/0-no-debug-left-on.t
-----BEGIN PGP SIGNATURE-----
debian/control view on Meta::CPAN
# Copyright 2008, 2010, 2011, 2012, 2013, 2014, 2016, 2017, 2018 Kevin Ryde
# This file is part of Gtk2-Ex-MenuView.
#
# Gtk2-Ex-MenuView is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# Gtk2-Ex-MenuView 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-MenuView. If not, see <http://www.gnu.org/licenses/>.
Source: libgtk2-ex-menuview-perl
Section: perl
Priority: optional
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-menuview/index.html
Bugs: mailto:user42_kevin@yahoo.com.au
Package: libgtk2-ex-menuview-perl
Architecture: all
Depends: perl (>= 5.8.0), libglib-perl, libglib-ex-objectbits-perl (>= 9), libgtk2-perl (>= 1:1.200), ${perl:Depends}, ${misc:Depends}
Description: Menu of items from a TreeModel
Gtk2::Ex::MenuView presents rows of a TreeModel as menu items,
updating with changes in the model.
debian/copyright view on Meta::CPAN
Gtk2-Ex-MenuView is Copyright 2007, 2008, 2009, 2010, 2011, 2019 Kevin Ryde
Gtk2-Ex-MenuView is licensed under the GNU General Public License GPL
version 3, or at your option any later version. The complete text of
GPL version 3 is in the file
/usr/share/common-licenses/GPL-3
Program home page:
http://user42.tuxfamily.org/gtk2-ex-menuview/index.html
debian/rules view on Meta::CPAN
#!/usr/bin/make -f
# Copyright 2010, 2014 Kevin Ryde
# This file is part of Gtk2-Ex-MenuView.
#
# Gtk2-Ex-MenuView is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# Gtk2-Ex-MenuView 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-MenuView. If not, see <http://www.gnu.org/licenses/>.
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/perl-makemaker.mk
DEB_INSTALL_EXAMPLES_libgtk2-ex-menuview-perl = examples/*
debian/watch view on Meta::CPAN
# Web site version watch, for devscripts uscan program.
# Copyright 2010, 2017 Kevin Ryde
#
# This file is part of Gtk2-Ex-MenuView.
#
# Gtk2-Ex-MenuView is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3, or (at
# your option) any later version.
#
# Gtk2-Ex-MenuView 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-MenuView. If not, see <http://www.gnu.org/licenses/>.
# Crib notes:
# "man uscan" describes the format.
# test with: uscan --report --verbose --watchfile=debian/watch
version=3
https://user42.tuxfamily.org/gtk2-ex-menuview/index.html \
.*/Gtk2-Ex-MenuView-([0-9]+)\.tar\.gz
devel/cellview-timer.pl view on Meta::CPAN
#!/usr/bin/perl -w
# Copyright 2010 Kevin Ryde
# This file is part of Gtk2-Ex-MenuView.
#
# Gtk2-Ex-MenuView is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# Gtk2-Ex-MenuView 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-MenuView. If not, see <http://www.gnu.org/licenses/>.
use strict;
use warnings;
use Gtk2 '-init';
use POSIX ();
use FindBin;
my $progname = $FindBin::Script;
devel/cellview.pl view on Meta::CPAN
#!/usr/bin/perl -w
# Copyright 2008, 2009, 2010, 2016 Kevin Ryde
# This file is part of Gtk2-Ex-MenuView.
#
# Gtk2-Ex-MenuView is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# Gtk2-Ex-MenuView 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-MenuView. If not, see <http://www.gnu.org/licenses/>.
use strict;
use warnings;
use Gtk2 '-init';
use Gtk2::Ex::MenuView;
use Data::Dumper;
use FindBin;
my $progname = $FindBin::Script;
my $toplevel = Gtk2::Window->new('toplevel');
$toplevel->signal_connect (destroy => sub { Gtk2->main_quit });
my $hbox = Gtk2::HBox->new (0, 0);
$toplevel->add ($hbox);
devel/cellview.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 $menu = Gtk2::Ex::MenuView->new (model => $model);
$menu->signal_connect (item_create_or_update => \&item_create);
sub item_create {
my ($menu, $item, $model, $path, $iter) = @_;
print "$progname: item_create at ",$path->to_string,"\n";
if ($item) { return $item; }
my $cellview = Gtk2::CellView->new;
$cellview->set_model ($model);
$cellview->set_displayed_row ($path);
my $renderer = Gtk2::CellRendererText->new;
$renderer->set (xalign => 1); # right align
$cellview->pack_start ($renderer, 1);
$cellview->add_attribute ($renderer, text => 0);
$item = Gtk2::MenuItem->new;
$item->add ($cellview);
return $item;
}
$menu->signal_connect (separator_create_or_update => \&separator_create);
sub separator_create {
my ($menu, $separator, $model, $path, $iter) = @_;
if ($path->get_depth == 1) {
my $i = ($path->get_indices)[0];
if (($i % 2) == 1) {
print "$progname: separator_create at 0\n";
my $item = Gtk2::SeparatorMenuItem->new;
$item->show;
return $item;
}
}
return undef;
}
$menu->signal_connect (activate => sub {
my ($menu, $item, $model, $path, $iter) = @_;
print "$progname: activate path ",
$path->to_string,"\n";
});
my $tearoff = Gtk2::TearoffMenuItem->new;
$menu->prepend ($tearoff);
{
my $treeview = Gtk2::TreeView->new_with_model ($model);
$treeview->set (reorderable => 1);
$right_vbox->pack_start ($treeview, 1,1,0);
my $renderer = Gtk2::CellRendererText->new;
$renderer->set (editable => 1);
$renderer->signal_connect
devel/cellview.pl view on Meta::CPAN
$model->set_value ($iter, 0 => $newstr);
});
my $column = Gtk2::TreeViewColumn->new_with_attributes
("TreeView:", $renderer, text => 0);
$column->set (resizable => 1);
$treeview->append_column ($column);
}
{
my $menubar = Gtk2::MenuBar->new;
$left_vbox->pack_start ($menubar, 0,0,0);
my $item = Gtk2::MenuItem->new_with_label ('Menu');
$item->set_submenu ($menu);
$menubar->add ($item);
}
{
my $label = Gtk2::Label->new (' ');
$left_vbox->add ($label);
}
{
my $button = Gtk2::Button->new_with_label ('Insert');
$button->signal_connect
devel/child-toggled.pl view on Meta::CPAN
#!/usr/bin/perl -w
# Copyright 2010, 2016 Kevin Ryde
# This file is part of Gtk2-Ex-MenuView.
#
# Gtk2-Ex-MenuView is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# Gtk2-Ex-MenuView 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-MenuView. If not, see <http://www.gnu.org/licenses/>.
use strict;
use warnings;
use Gtk2 '-init';
use FindBin;
my $progname = $FindBin::Script;
my $model = Gtk2::TreeStore->new ('Glib::String');
$model->signal_connect
devel/junk/ArrayMenu.pm view on Meta::CPAN
# Menu of items from an array.
# Copyright 2007, 2008, 2009, 2010 Kevin Ryde
# This file is part of Gtk2-Ex-MenuView.
#
# Gtk2-Ex-MenuView is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# Gtk2-Ex-MenuView 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-MenuView. If not, see <http://www.gnu.org/licenses/>.
package Gtk2::Ex::ArrayMenu;
use 5.008;
use strict;
use warnings;
use Carp;
use Gtk2;
# Version 1 - the first version
#
our $VERSION = 0;
use constant DEBUG => 0;
use Glib::Object::Subclass
'Gtk2::Menu',
signals => { show => \&_do_show,
activate => { param_types => ['Glib::Scalar'],
return_type => undef },
},
properties => [Glib::ParamSpec->scalar
('array',
'array',
'Array reference of menu items.',
Glib::G_PARAM_READWRITE),
devel/junk/ArrayMenu.pm view on Meta::CPAN
my $item_proc = $self->{'item_proc'} || \&noop;
my $use_mnemonic = $self->get('use-mnemonic');
my @children = $self->get_children;
my $i;
for ($i = 0; $i < @$array; $i++) {
my $item;
if ($i < @children) {
$item = $children[$i]
} else {
$item = Gtk2::MenuItem->new_with_label ('');
$item->signal_connect ('activate', \&_do_activate, $i);
$self->append ($item);
}
my $elem = $array->[$i];
my $str = $name_proc->($self, $elem);
my $label = $item->get_child;
if ($use_mnemonic) {
$label->set_text_with_mnemonic ($str);
} else {
$label->set_text ($str);
devel/junk/ArrayMenu.pm view on Meta::CPAN
# my ($self) = @_;
# }
1;
__END__
=for stopwords VAxis Eg arraymenu boolean stringize stringizing
=head1 NAME
Gtk2::Ex::ArrayMenu -- menu of items from an array
=for test_synopsis my ($item)
=head1 SYNOPSIS
use Gtk2::Ex::ArrayMenu;
my $menu = Gtk2::Ex::ArrayMenu->new (array => ['One', 'Two']);
# standalone popup
$menu->popup;
# or as a submenu
$item->set_submenu ($menu);
=head1 WIDGET HIERARCHY
C<Gtk2::Ex::ArrayMenu> is a subclass of C<Gtk2::Menu>.
Gtk2::Widget
Gtk2::Container
Gtk2::MenuShell
Gtk2::Menu
Gtk2::Ex::ArrayMenu
=head1 DESCRIPTION
A C<Gtk2::Ex::ArrayMenu> presents menu items from a given array of values.
Those values can be strings to show directly, or functions can be set to
form the strings, and make other setups. A single C<activate> signal on the
C<ArrayMenu> is called for any item activated.
A new array of desired items to show can be set at any time and the number
of items and their contents are changed accordingly. The work in doing that
is left until the menu is popped up.
=head1 FUNCTIONS
=over 4
=item C<< Gtk2::Ex::ArrayMenu->new (key=>value,...) >>
Create and return a new VAxis widget. Optional key/value pairs set initial
properties, as per C<< Glib::Object->new >>. Eg.
my $adj = Gtk2::Adjustment->new (5,0,20, 1,8, 10);
Gtk2::Ex::VAxis->new (adjustment => $adj,
decimals => 1);
=back
devel/junk/ArrayMenu.pm view on Meta::CPAN
The default stringizing means that if the elements are objects then they can
overload the stringizing operator C<""> (see L<overload>). But unless
you've want a stringize like that for other purposes it's far clearer to set
a specific C<name-proc> here.
=back
=head1 SEE ALSO
L<Gtk2::Menu>, L<Gtk2::MenuItem>, L<Gtk2::Label>
=cut
devel/junk/t-arraymenu.pl view on Meta::CPAN
#!/usr/bin/perl
# Copyright 2008, 2009, 2010 Kevin Ryde
# This file is part of Gtk2-Ex-MenuView.
#
# Gtk2-Ex-MenuView is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# Gtk2-Ex-MenuView 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-MenuView. If not, see <http://www.gnu.org/licenses/>.
use strict;
use warnings;
use Data::Dumper;
use Gtk2 '-init';
use Gtk2::Ex::ArrayMenu;
sub my_activate {
print Dumper (\@_);
print join(',', @_), "\n";
}
sub my_name {
my ($arraymenu, $str) = @_;
return 'x' . $str . 'z';
}
my $menu = Gtk2::Ex::ArrayMenu->new (array => ['<s>AA</s>',
'B_BB',
'C_C'],
name_proc => \&my_name,
use_mnemonic => 1,
);
$menu->signal_connect (activate => \&my_activate);
$menu->show;
$menu->popup (undef, undef, undef, undef, 0, 0);
Gtk2->main();
devel/model-signals.pl view on Meta::CPAN
#!/usr/bin/perl -w
# Copyright 2008, 2009, 2010 Kevin Ryde
# This file is part of Gtk2-Ex-MenuView.
#
# Gtk2-Ex-MenuView is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# Gtk2-Ex-MenuView 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-MenuView. If not, see <http://www.gnu.org/licenses/>.
use 5.010;
use strict;
use warnings;
use Gtk2 '-init';
use Gtk2::Ex::MenuView;
use Data::Dumper;
use FindBin;
my $progname = $FindBin::Script;
my $treestore = Gtk2::TreeStore->new ('Glib::String');
foreach my $str ('Item one',
'Item two',
'Item three',
'Item four',
devel/param-type.pl view on Meta::CPAN
#!/usr/bin/perl -w
# Copyright 2008, 2009, 2010 Kevin Ryde
# This file is part of Gtk2-Ex-MenuView.
#
# Gtk2-Ex-MenuView is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# Gtk2-Ex-MenuView 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-MenuView. If not, see <http://www.gnu.org/licenses/>.
use strict;
use warnings;
use Gtk2 '-init';
use Gtk2::Ex::MenuView;
use Data::Dumper;
my $menuview = Gtk2::Ex::MenuView->new;
# $menuview->set (item_type => 'Gtk2::MenuItem');
my $info = $menuview->find_property ('model');
print Dumper($info);
# my $info = $menuview->find_property ('label-column');
# print Dumper($info);
#
# my $info = $menuview->find_property ('item_type');
# print Dumper($info);
devel/run.pl view on Meta::CPAN
#!/usr/bin/perl -w
# Copyright 2008, 2009, 2010, 2011 Kevin Ryde
# This file is part of Gtk2-Ex-MenuView.
#
# Gtk2-Ex-MenuView is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# Gtk2-Ex-MenuView 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-MenuView. If not, see <http://www.gnu.org/licenses/>.
use 5.010;
use strict;
use warnings;
use Glib 1.220;
use Gtk2 '-init';
use Gtk2::Ex::MenuView;
use Data::Dumper;
use FindBin;
my $progname = $FindBin::Script;
my $toplevel = Gtk2::Window->new('toplevel');
$toplevel->signal_connect (destroy => sub { Gtk2->main_quit });
my $hbox = Gtk2::HBox->new (0, 0);
$toplevel->add ($hbox);
devel/run.pl view on Meta::CPAN
my $treestore = Gtk2::TreeStore->new ('Glib::String');
foreach my $str ('Item one',
'Item two',
'Item three',
'Item four',
'Item five') {
$treestore->set ($treestore->append(undef), 0 => $str);
}
my $menuview = Gtk2::Ex::MenuView->new (model => $treestore);
{
my $tearoff = Gtk2::TearoffMenuItem->new;
$tearoff->show;
$menuview->prepend ($tearoff);
}
$menuview->signal_connect (item_create_or_update => \&do_item_create_or_update);
sub do_item_create_or_update {
my ($menuview, $item, $model, $path, $iter) = @_;
print "$progname: create/update\n";
if (! $item) {
$item = Gtk2::MenuItem->new_with_label ('');
}
my $label = $item->get_child;
my $str = $model->get_value ($iter, 0);
print "$progname: data $item path ",$path->to_string,
" str \"", defined $str ? $str : 'undef', "\"\n";
$label->set_text ($str);
print " return $item\n";
return $item;
}
devel/run.pl view on Meta::CPAN
$treestore->set_value ($iter, 0 => $newstr);
});
my $column = Gtk2::TreeViewColumn->new_with_attributes
("TreeView:", $renderer, text => 0);
$column->set (resizable => 1);
$treeview->append_column ($column);
}
{
my $menubar = Gtk2::MenuBar->new;
$left_vbox->pack_start ($menubar, 0,0,0);
my $item = Gtk2::MenuItem->new_with_label ('Menu');
$item->set_submenu ($menuview);
$menubar->add ($item);
}
{
my $label = Gtk2::Label->new (' ');
$left_vbox->add ($label);
}
{
my $button = Gtk2::Button->new_with_label ('Append');
$button->signal_connect
devel/screenshot.pl view on Meta::CPAN
#!/usr/bin/perl -w
# Copyright 2008, 2009, 2010 Kevin Ryde
# This file is part of Gtk2-Ex-MenuView.
#
# Gtk2-Ex-MenuView is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 3, or (at your option) any later
# version.
#
# Gtk2-Ex-MenuView 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-MenuView. If not, see <http://www.gnu.org/licenses/>.
# Usage: perl screenshot.pl [outputfile.png]
#
# Popup a MenuView and write it to the given output file in PNG format.
# The default output file is /tmp/screenshot.png
#
# Must manually wave the mouse over the submenu to make it display. Then
# there's some weirdness needing $submenu->popup before its $submenu->window
# is set to get its root position ...
use 5.010;
use strict;
use warnings;
use File::Basename;
use FindBin;
use POSIX;
use Gtk2 1.220 '-init';
use Gtk2::Ex::MenuView;
use Gtk2::Ex::WidgetBits;
# PNG spec 11.3.4.2 suggests RFC822 (or rather RFC1123) for CreationTime
use constant STRFTIME_FORMAT_RFC822 => '%a, %d %b %Y %H:%M:%S %z';
my $progname = $FindBin::Script; # basename part
print "progname '$progname'\n";
my $output_filename = (@ARGV >= 1 ? $ARGV[0] : '/tmp/screenshot.png');
devel/screenshot.pl view on Meta::CPAN
$treestore->insert_with_values ($iter, 9999, 0 => 'Sub-Row One');
$treestore->insert_with_values ($iter, 9999, 0 => 'Sub-Row Two');
}
my $toplevel = Gtk2::Window->new('toplevel');
$toplevel->modify_bg ('normal', Gtk2::Gdk::Color->parse('black'));
$toplevel->set_default_size (500, 500);
$toplevel->signal_connect (destroy => sub { Gtk2->main_quit });
$toplevel->show_all;
my $menuview = Gtk2::Ex::MenuView->new (model => $treestore);
$menuview->signal_connect (item_create_or_update => \&do_item_create_or_update);
sub do_item_create_or_update {
my ($menuview, $item, $treestore, $path, $iter) = @_;
return Gtk2::MenuItem->new_with_label ($treestore->get_value ($iter, 0));
}
$toplevel->signal_connect
(map_event => sub {
$menuview->popup (undef, undef,
\&position_in_toplevel, undef,
1, 0);
return Gtk2::EVENT_PROPAGATE;
});
sub position_in_toplevel {
devel/screenshot.pl view on Meta::CPAN
my $height = $ry - $y;
my $screen = $toplevel->get_screen;
my $rootwin = $screen->get_root_window;
my $pixbuf = Gtk2::Gdk::Pixbuf->get_from_drawable ($rootwin,
undef, # colormap
$x,$y, 0,0,
$width, $height);
$pixbuf->save
($output_filename, 'png',
'tEXt::Title' => 'MenuView Screenshot',
'tEXt::Author' => 'Kevin Ryde',
'tEXt::Copyright' => 'Copyright 2010 Kevin Ryde',
'tEXt::Creation Time' => POSIX::strftime (STRFTIME_FORMAT_RFC822,
localtime(time)),
'tEXt::Description' => 'A sample screenshot of a Gtk2::Ex::MenuView display',
'tEXt::Software' => "Generated by $progname",
'tEXt::Homepage' => 'http://user42.tuxfamily.org/gtk2-ex-menuview/index.html',
# must be last or gtk 2.18 botches the text keys
compression => 9,
);
print "wrote $output_filename\n";
Gtk2->main_quit;
return 0; # Glib::SOURCE_REMOVE
}
devel/size-request-container.pl view on Meta::CPAN
#!/usr/bin/perl -w
# Copyright 2010, 2016 Kevin Ryde
# This file is part of Gtk2-Ex-MenuView.
#
# Gtk2-Ex-MenuView is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# Gtk2-Ex-MenuView 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-MenuView. If not, see <http://www.gnu.org/licenses/>.
use strict;
use warnings;
use Gtk2 '-init';
{
package MyMenu;
use Gtk2;
use Glib::Object::Subclass
'Gtk2::Menu',
signals => { size_request => \&_do_size_request };
sub _do_size_request {
my ($self, $req) = @_;
print "_do_size_request()\n";
my @children = $self->get_children;
unless (@children) {
my $item = Gtk2::MenuItem->new('Foo');
$item->show;
$self->add ($item);
}
return shift->signal_chain_from_overridden(@_);
}
}
{
my $menu = Gtk2::Menu->new;
my $req = $menu->size_request;
print "empty ",$req->width,"x",$req->height,"\n";
}
{
my $menu = Gtk2::Menu->new;
my $item = Gtk2::MenuItem->new('Foo');
$item->show;
$menu->add ($item);
my $req = $menu->size_request;
print "with item ",$req->width,"x",$req->height,"\n";
}
{
my $menu = MyMenu->new;
my $req = $menu->size_request;
print "MyMenu ",$req->width,"x",$req->height,"\n";
}
exit 0;
devel/size-request-sig.pl view on Meta::CPAN
#!/usr/bin/perl -w
# Copyright 2010, 2016 Kevin Ryde
# This file is part of Gtk2-Ex-MenuView.
#
# Gtk2-Ex-MenuView is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# Gtk2-Ex-MenuView 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-MenuView. If not, see <http://www.gnu.org/licenses/>.
use strict;
use warnings;
use Glib::Ex::SignalIds;
use Gtk2 '-init';
{
package MyLabel;
use Gtk2;
devel/size-request.pl view on Meta::CPAN
#!/usr/bin/perl -w
# Copyright 2010, 2016 Kevin Ryde
# This file is part of Gtk2-Ex-MenuView.
#
# Gtk2-Ex-MenuView is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# Gtk2-Ex-MenuView 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-MenuView. If not, see <http://www.gnu.org/licenses/>.
use strict;
use warnings;
use Gtk2 '-init';
{
package MyLabel;
use Gtk2;
use Glib::Object::Subclass
devel/two-radios.pl view on Meta::CPAN
#!/usr/bin/perl -w
# Copyright 2008, 2010, 2012 Kevin Ryde
# This file is part of Gtk2-Ex-MenuView.
#
# Gtk2-Ex-MenuView is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# Gtk2-Ex-MenuView 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-MenuView. If not, see <http://www.gnu.org/licenses/>.
# Doesn't work properly ...
use strict;
use warnings;
use Gtk2 '-init';
use Gtk2::Ex::MenuView;
my $toplevel = Gtk2::Window->new('toplevel');
$toplevel->signal_connect (destroy => sub { Gtk2->main_quit });
my $menubar = Gtk2::MenuBar->new;
$toplevel->add ($menubar);
my $baritem = Gtk2::MenuItem->new_with_label ('Click to Popup');
$menubar->add ($baritem);
my $liststore = Gtk2::ListStore->new ('Glib::Int', 'Glib::String');
foreach my $row ([0, 'Red'],
[0, 'Green'],
[0, 'Blue'],
[3, 'Apple'],
[3, 'Orange'],
[3, 'Pear']) {
$liststore->set ($liststore->append,
0 => $row->[0],
1 => $row->[1]);
}
sub my_item_create {
my ($menu) = @_;
return Gtk2::RadioMenuItem->new_with_label ([], rand());
}
sub my_item_data {
my ($menu, $model, $iter, $item) = @_;
my $groupnum = $model->get_value ($iter, 0);
my $group_item = $menu->get_nth_item ($groupnum);
if ($item == $group_item) {
$item->set_group (undef);
} else {
$item->set_group ($group_item);
}
my $str = $model->get_value ($iter, 1);
$item->get_child->set_text ($str);
}
my $menu = Gtk2::Ex::MenuView->new (model => $liststore);
$menu->signal_connect (item_create_or_update => \&my_item_create);
# item_data_func => \&my_item_data);
$baritem->set_submenu ($menu);
my $tearoff = Gtk2::TearoffMenuItem->new;
$tearoff->show;
$menu->prepend ($tearoff);
$toplevel->show_all;
Gtk2->main;
exit 0;
examples/builder.pl view on Meta::CPAN
#!/usr/bin/perl -w
# Copyright 2007, 2008, 2010 Kevin Ryde
# This file is part of Gtk2-Ex-MenuView.
#
# Gtk2-Ex-MenuView is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# Gtk2-Ex-MenuView 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-MenuView. If not, see <http://www.gnu.org/licenses/>.
# This is an example of making a MenuView with Gtk2::Builder. The class
# name is "Gtk2__Ex__MenuView" per Perl-Gtk2 package name to Gtk type name
# conversion.
#
# Notice the MenuView is a top-level object, as usual for Gtk2::Window
# classes. It's then hooked into the GUI as the submenu of an item in the
# toplevel MenuBar.
#
# The ListStore model and its data are created in the builder here, but in a
# real program it's more likely the data would be from some external source,
# since the whole point of MenuView is to display dynamic things.
#
# Builder doesn't really add much for MenuView. You still have to write an
# item-create-or-update handler. But builder does swap tedious and
# repetitive code making widgets for tedious and repetitive pseudo-xml
# making widgets!
#
use strict;
use warnings;
use Gtk2 '-init';
use Gtk2::Ex::MenuView;
my $builder = Gtk2::Builder->new;
$builder->add_from_string (<<'HERE');
<interface>
<object class="GtkListStore" id="liststore">
<columns>
<column type="gchararray"/>
</columns>
<data>
<row> <col id="0">Choice one</col> </row>
<row> <col id="0">Choice the second</col> </row>
<row> <col id="0">The choice third</col> </row>
</data>
</object>
<object class="Gtk2__Ex__MenuView" id="menu">
<property name="model">liststore</property>
<signal name="item-create-or-update" handler="do_item_create_or_update"/>
<signal name="activate" handler="do_activate"/>
</object>
<object class="GtkWindow" id="toplevel">
<property name="type">toplevel</property>
<signal name="destroy" handler="do_quit"/>
<child>
<object class="GtkMenuBar" id="menubar">
<child>
<object class="GtkMenuItem" id="popup_item">
<property name="submenu">menu</property>
<child>
<object class="GtkLabel" id="popup_label">
<property name="label">Click to Popup</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>
HERE
sub do_item_create_or_update {
my ($menuview, $item, $model, $path, $iter) = @_;
# don't bother updating existing $item, just create a new one each time
my $str = $model->get($iter, 0); # display column 0
return Gtk2::MenuItem->new_with_label ($str);
}
sub do_activate {
my ($menuview, $item, $model, $path, $iter) = @_;
print "activate path = ", $path->to_string, "\n";
print " model str = ", $model->get($iter,0), "\n";
}
sub do_quit {
Gtk2->main_quit;
}
examples/cellview.pl view on Meta::CPAN
#!/usr/bin/perl -w
# Copyright 2008, 2009, 2010 Kevin Ryde
# This file is part of Gtk2-Ex-MenuView.
#
# Gtk2-Ex-MenuView is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# Gtk2-Ex-MenuView 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-MenuView. If not, see <http://www.gnu.org/licenses/>.
# This example ues Gtk2::CellView in each menu item, similar to what
# Gtk2::ComboBox does.
#
# The renderer here is only a CellRendererText, which is not very exciting,
# but in principle it could be anything, including multiple renderers side
# by side, etc.
use strict;
use warnings;
use Gtk2 '-init';
use Gtk2::Ex::MenuView;
use POSIX ();
my $liststore = Gtk2::ListStore->new ('Glib::String');
foreach my $str ('Item one',
'Item <u>two</u>',
'Item three',
'Item <b>four</b>',
'Time item') {
$liststore->set ($liststore->append, 0 => $str);
}
examples/cellview.pl view on Meta::CPAN
sub timer_callback {
my $str = POSIX::strftime ("Time <tt>%H:%M:%S</tt>", localtime(time()));
$liststore->set_value ($liststore->iter_nth_child(undef,4), 0, $str);
return 1; # Glib::SOURCE_CONTINUE
}
timer_callback(); # initial time display
Glib::Timeout->add (1000, \&timer_callback); # periodic updates
#------------------------------------------------------------------------------
my $menuview = Gtk2::Ex::MenuView->new (model => $liststore);
$menuview->signal_connect (item_create_or_update => \&my_create_or_update);
$menuview->signal_connect (activate => \&my_activate);
my $renderer = Gtk2::CellRendererText->new;
sub my_create_or_update {
my ($menuview, $item, $model, $path, $iter) = @_;
if (! $item) {
$item = Gtk2::MenuItem->new;
my $cellview = Gtk2::CellView->new;
$cellview->pack_start ($renderer, 1);
$cellview->add_attribute ($renderer, markup => 0); # from column 0
$item->add ($cellview);
}
# Set the model in case it changes.
# Set displayed-row each time to force the CellView to redraw changed row
# contents.
my $cellview = $item->get_child;
$cellview->set_model ($menuview->get('model'));
examples/cellview.pl view on Meta::CPAN
sub my_activate {
my ($menuview, $item, $model, $path, $iter) = @_;
print "activate '", $model->get($iter,0), "\n";
}
#------------------------------------------------------------------------------
my $toplevel = Gtk2::Window->new('toplevel');
$toplevel->signal_connect (destroy => sub { Gtk2->main_quit });
my $menubar = Gtk2::MenuBar->new;
$toplevel->add ($menubar);
my $item = Gtk2::MenuItem->new_with_label ('Click to Popup');
$item->set_submenu ($menuview);
$menubar->add ($item);
$toplevel->show_all;
Gtk2->main;
exit 0;
examples/checkitem.pl view on Meta::CPAN
#!/usr/bin/perl -w
# Copyright 2010 Kevin Ryde
# This file is part of Gtk2-Ex-MenuView.
#
# Gtk2-Ex-MenuView is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# Gtk2-Ex-MenuView 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-MenuView. If not, see <http://www.gnu.org/licenses/>.
# This program displays some Gtk2::CheckMenuItem widgets with their tick
# marks reflecting a column from the model.
use 5.008;
use strict;
use warnings;
use Gtk2 '-init';
use Gtk2::Ex::MenuView;
use constant { COLUMN_TEXT => 0,
COLUMN_FLAG => 1 };
my $liststore = Gtk2::ListStore->new ('Glib::String', 'Glib::Boolean');
$liststore->set ($liststore->append,
COLUMN_TEXT, 'Tick One',
COLUMN_FLAG, 0);
$liststore->set ($liststore->append,
COLUMN_TEXT, 'Tick Two',
examples/checkitem.pl view on Meta::CPAN
COLUMN_TEXT, 'Tick Three',
COLUMN_FLAG, 0);
my $toplevel = Gtk2::Window->new('toplevel');
$toplevel->signal_connect (destroy => sub { Gtk2->main_quit });
my $vbox = Gtk2::VBox->new (0, 0);
$toplevel->add ($vbox);
#------------------------------------------------------------------------------
# menubar popping up a MenuView
my $menubar = Gtk2::MenuBar->new;
$vbox->pack_start ($menubar, 0,0,0);
my $baritem = Gtk2::MenuItem->new_with_label ('Click to popup menu');
$menubar->add ($baritem);
my $menuview = Gtk2::Ex::MenuView->new (model => $liststore);
$baritem->set_submenu ($menuview);
$menuview->signal_connect (item_create_or_update => \&my_item_create_or_update);
$menuview->signal_connect (activate => \&my_activate);
sub my_item_create_or_update {
my ($menuview, $item, $model, $path, $iter) = @_;
$item ||= Gtk2::CheckMenuItem->new_with_label ('');
my $str = $model->get ($iter, COLUMN_TEXT);
my $label = $item->get_child;
$label->set_text ($str);
my $flag = $model->get ($iter, COLUMN_FLAG);
print "item-create-or-update path=",$path->to_string," flag='$flag'\n";
$item->set_active ($flag);
return $item;
}
sub my_activate {
my ($menuview, $item, $model, $path, $iter) = @_;
my $flag = $item->get_active;
print "CheckMenuItem activate, set path=",$path->to_string," to '$flag'\n";
$model->set ($iter, COLUMN_FLAG, $flag);
}
#------------------------------------------------------------------------------
# TreeView displaying the model data too
my $treeview = Gtk2::TreeView->new_with_model ($liststore);
$treeview->set (reorderable => 1);
$vbox->pack_start ($treeview, 1,1,0);
examples/radiogroup.pl view on Meta::CPAN
#!/usr/bin/perl -w
# Copyright 2010 Kevin Ryde
# This file is part of Gtk2-Ex-MenuView.
#
# Gtk2-Ex-MenuView is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# Gtk2-Ex-MenuView 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-MenuView. If not, see <http://www.gnu.org/licenses/>.
# This program displays a group of RadioMenuItems.
#
# The only thing to note is that because RadioMenuItem is a sub-class of
# CheckMenuItem its "activate" signal, and in turn the MenuView "activate",
# is emitted for both on the item losing the radio selection and the item
# gaining it. Sometimes this is good, or other times only the new choice is
# interesting. In the MenuView "activate" handler an $item->get_active
# gives the current state.
use strict;
use warnings;
use Gtk2 '-init';
use Gtk2::Ex::MenuView;
my $toplevel = Gtk2::Window->new('toplevel');
$toplevel->signal_connect (destroy => sub { Gtk2->main_quit });
my $label = Gtk2::Label->new ("Press mouse button\nto popup menu");
$toplevel->add ($label);
my $liststore = Gtk2::ListStore->new ('Glib::String');
foreach my $str ('Choice One',
'Choice Two',
'Choice Three') {
$liststore->set ($liststore->append, 0 => $str);
}
my $menuview = Gtk2::Ex::MenuView->new (model => $liststore);
$menuview->signal_connect (item_create_or_update => \&my_create_or_update);
$menuview->signal_connect (activate => \&my_activate);
sub my_create_or_update {
my ($menuview, $item, $model, $path, $iter) = @_;
my $n = ($path->get_indices)[-1];
my $group = ($menuview->get_children)[0];
return Gtk2::RadioMenuItem->new_with_label ($group, $model->get($iter,0));
}
sub my_activate {
my ($menuview, $item, $model, $path, $iter) = @_;
if ($item->get_active) {
print $model->get($iter,0), " is now active\n";
}
}
$toplevel->add_events ('button-press-mask');
examples/simple.pl view on Meta::CPAN
#!/usr/bin/perl -w
# Copyright 2008, 2010 Kevin Ryde
# This file is part of Gtk2-Ex-MenuView.
#
# Gtk2-Ex-MenuView is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# Gtk2-Ex-MenuView 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-MenuView. If not, see <http://www.gnu.org/licenses/>.
# This is pretty much the simplest program that displays a MenuView. The
# model is a ListStore and the item-create-or-update handler shows column 0
# from it.
#
# The menu is popped-up from a mouse button press. Generally a menu is
# handled in one of two ways, either the submenu of a MenuItem in a MenuBar
# etc, or an explicit popup from an event like below.
use strict;
use warnings;
use Gtk2 '-init';
use Gtk2::Ex::MenuView;
my $liststore = Gtk2::ListStore->new ('Glib::String');
$liststore->set ($liststore->append, 0 => 'One');
$liststore->set ($liststore->append, 0 => 'Two');
$liststore->set ($liststore->append, 0 => 'Three');
my $menuview = Gtk2::Ex::MenuView->new (model => $liststore);
$menuview->signal_connect
(item_create_or_update => sub {
my ($menuview, $item, $model, $path, $iter) = @_;
my $str = $model->get ($iter, 0); # column 0
return Gtk2::MenuItem->new_with_label ($str);
});
$menuview->signal_connect
(activate => sub {
my ($menuview, $item, $model, $path, $iter) = @_;
print "activate, path=", $path->to_string, "\n";
print " data=", $model->get($iter,0), "\n";
});
#-----------------------------------------------------------------
examples/twiddle.pl view on Meta::CPAN
#!/usr/bin/perl -w
# Copyright 2008, 2009, 2010 Kevin Ryde
# This file is part of Gtk2-Ex-MenuView.
#
# Gtk2-Ex-MenuView is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# Gtk2-Ex-MenuView 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-MenuView. If not, see <http://www.gnu.org/licenses/>.
# This contrivance shows how displayed menu items update when model data
# changes, in this case a twirling char and a clock. The extra tearoff item
# lets you keep it open to look at.
use strict;
use warnings;
use Gtk2 '-init';
use POSIX ();
use Gtk2::Ex::MenuView;
my $toplevel = Gtk2::Window->new('toplevel');
$toplevel->signal_connect (destroy => sub { Gtk2->main_quit });
my $menubar = Gtk2::MenuBar->new;
$toplevel->add ($menubar);
my $baritem = Gtk2::MenuItem->new_with_label ('Click to Popup');
$menubar->add ($baritem);
#----------------------------------------------------------------------------
my $liststore = Gtk2::ListStore->new ('Glib::String');
foreach my $str ('One',
'Two',
'Three') {
$liststore->set ($liststore->append, 0 => $str);
}
my $menuview = Gtk2::Ex::MenuView->new (model => $liststore);
$baritem->set_submenu ($menuview);
$menuview->signal_connect (item_create_or_update => \&my_create_or_update);
$menuview->signal_connect (activate => \&my_item_activate);
sub my_create_or_update {
my ($menuview, $item, $model, $path, $iter) = @_;
$item ||= Gtk2::MenuItem->new_with_label ('');
my $str = $model->get ($iter, 0); # column 0
$item->get_child->set_text ($str); # the Gtk2::Label child widget
return $item;
}
sub my_item_activate {
my ($menuview, $item, $model, $path, $iter) = @_;
print "activate, path=",$path->to_string,"\n";
}
my $tearoff = Gtk2::TearoffMenuItem->new;
$tearoff->show;
$menuview->prepend ($tearoff);
#----------------------------------------------------------------------------
my @one_n_str = ('One /', 'One -', 'One \\', 'One |');
my $one_n = 0;
sub one_callback {
$one_n++;
$one_n %= scalar(@one_n_str);
$liststore->set_value ($liststore->iter_nth_child (undef,0),