view release on metacpan or search on metacpan
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-History. If not, see <http://www.gnu.org/licenses/>.
Version 8, November 2011
- tests fix MenuToolButton weakening maybe
Version 7, November 2010
- tests fix should be an is() not an ok()
Version 6, November 2010
- use ConnectProperties for button sensitivities
Version 5, September 2010
- tests fix non-string test name
Version 4, September 2010
- fix Dialog stray 5.010 should be 5.008
Version 3, September 2010
- new MenuToolButton
- fix Menu new_popup() to return new object per docs
Version 2, August 2010
- use WidgetEvents for action toolbar button release
Version 1, August 2010
- the first version.
devel/unused/ModelSensitive.t
devel/uri.pl
examples/iri.pl
inc/MyMakeMakerExtras.pm
inc/MyMakeMakerGettext.pm
lib/Gtk2/Ex/History.pm
lib/Gtk2/Ex/History/Action.pm
lib/Gtk2/Ex/History/Button.pm
lib/Gtk2/Ex/History/Dialog.pm
lib/Gtk2/Ex/History/ListStore.pm
lib/Gtk2/Ex/History/Menu.pm
lib/Gtk2/Ex/History/MenuToolButton.pm
Makefile.PL
MANIFEST This list of files
MANIFEST.SKIP
po/Gtk2-Ex-History.pot
po/header.pot
po/README
SIGNATURE
t/Button-weaken.t
t/Button.t
t/Dialog-weaken.t
t/Dialog.t
t/History-weaken.t
t/History.t
t/Menu-weaken.t
t/Menu.t
t/MenuToolButton-weaken.t
t/MenuToolButton.t
t/MyTestHelpers.pm
xt/0-examples-xrefs.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 meta-data (added by MakeMaker)
build_requires:
ExtUtils::MakeMaker: 0
requires:
Glib::Ex::ConnectProperties: 13
Glib::Ex::FreezeNotify: 1
Glib::Ex::ObjectBits: 12
Glib::Ex::SignalBits: 9
Glib::Ex::SignalIds: 1
Glib::Object::Subclass: 0
Gtk2: 1.220
Gtk2::Ex::Dashes::MenuItem: 0
Gtk2::Ex::MenuView: 0
Gtk2::Ex::TreeModelBits: 16
Gtk2::Ex::Units: 13
Gtk2::Ex::WidgetEvents: 21
Locale::Messages: 0
Locale::TextDomain: 1.16
perl: 5.008
Test::Weaken::Gtk2: 17
resources:
homepage: http://user42.tuxfamily.org/gtk2-ex-history/index.html
license: http://www.gnu.org/licenses/gpl.html
Makefile.PL view on Meta::CPAN
'Glib::Ex::FreezeNotify' => 1,
'Glib::Ex::SignalBits' => 9, # new in version 9
# my Gtk2 Ex WidgetBits
'Gtk2::Ex::TreeModelBits' => 16, # for extra remove args
'Gtk2::Ex::Units' => 13, # new in version 13
'Gtk2::Ex::WidgetEvents' => 21, # new in version 21
'Test::Weaken::Gtk2' => 17, # new in version 17
'Glib::Ex::ConnectProperties' => 13, # v.13 model-rows
'Gtk2::Ex::Dashes::MenuItem' => 0,
'Gtk2::Ex::MenuView' => 0,
# version 1.16 for bind_textdomain_filter() to mung
# gettext strings
'Locale::TextDomain' => 1.16,
# Locale::Messages doesn't declare a version, there's
# only one in Locale::TextDomain, until 1.18 or some such
'Locale::Messages' => 0,
},
META_MERGE =>
SHA1 c115e1d28c7a5df789b2613ca3c4115fa59c0277 devel/unused/ModelSensitive.t
SHA1 aa5d421c61420cb3bdb8829210a832517c2c1381 devel/uri.pl
SHA1 f984ee5fe1988bb1a01b68f7c56fc4084bfc463d examples/iri.pl
SHA1 e328d750fcfa81100759f3f48cb62dd0187ed1b9 inc/MyMakeMakerExtras.pm
SHA1 a2fa0855f3a1ea6140956ec567bea259e0099893 inc/MyMakeMakerGettext.pm
SHA1 b14a2da8d944253a21d6805b8e90bf7f914f4629 lib/Gtk2/Ex/History.pm
SHA1 003ab3ef234406231966937cb1a2367e02d15782 lib/Gtk2/Ex/History/Action.pm
SHA1 2fb414f598105bc9e0eb853760f0486a73389a37 lib/Gtk2/Ex/History/Button.pm
SHA1 2f1e69e75f8cfa800260b744c3dafb5fbe82b65b lib/Gtk2/Ex/History/Dialog.pm
SHA1 753d0bbdba7bfe88f34505c3fd4453a03fbf16e3 lib/Gtk2/Ex/History/ListStore.pm
SHA1 96ab5e9971fe1be4beca9a502e546c304b9a258f lib/Gtk2/Ex/History/Menu.pm
SHA1 4addbf54faabb6c7167d07a3a95582b4628806c5 lib/Gtk2/Ex/History/MenuToolButton.pm
SHA1 af54473651037466af9b1ddc332c079ff9609437 po/Gtk2-Ex-History.pot
SHA1 ceab03b1599a11baa24c259e5f74931ab99b9ef6 po/README
SHA1 8ab20e40dd4b97ac05dd46d8a9a89cc91ec5ce15 po/header.pot
SHA1 23b52b5c64ce39c8bd8abeb32f1b277c4ba94ebd t/Button-weaken.t
SHA1 891883c2c0b5e6a84c000ec15b473fb3b6e0836f t/Button.t
SHA1 abf5e54a31928af1ce7e94627ae9fce400a7c2e4 t/Dialog-weaken.t
SHA1 823bdac6059d45af988f8f4b2ef9951553c18c42 t/Dialog.t
SHA1 50bfe568023bde97421b3308985b926ca076447d t/History-weaken.t
SHA1 348d02eb7cb4566e87999ba84f4ec85c30c996a7 t/History.t
SHA1 f7d6c7076889c0c4b16df765706e93352753be40 t/Menu-weaken.t
SHA1 e75e0c37c79fcb7c9ec552fd08d04e1b37fcd77f t/Menu.t
SHA1 78f2c657a1f65820f829a62ec87e467bd762039e t/MenuToolButton-weaken.t
SHA1 914cbc40928f178be787d68b74d770f2e288a8ef t/MenuToolButton.t
SHA1 c403f69bce1a210d3e150de65a26d06320ef8a43 t/MyTestHelpers.pm
SHA1 0279c9310ec528d10a2a14e602bf98f1c776cce1 xt/0-META-read.t
SHA1 219395eb91b03829e6f14db4ebd57d88ea972e61 xt/0-Test-ConsistentVersion.t
SHA1 8a5e0f34131de34e584fbb1939c191a152566155 xt/0-Test-DistManifest.t
SHA1 cc04a5fe5d8b8b38bfd56453d5d2686c8ea58783 xt/0-Test-Pod.t
SHA1 8cc52e23427a82cfef5802bf512b13c65de2687a xt/0-Test-Synopsis.t
SHA1 4c14845872d6eb4280e12f862d6ba2c343358c60 xt/0-Test-YAML-Meta.t
SHA1 8609ab0ed7dfa7261d85dd7c9c11736fc4e8df0b xt/0-examples-xrefs.t
SHA1 3510bcc61725fe294e5a508bca4ae78cfe05684e xt/0-no-debug-left-on.t
-----BEGIN PGP SIGNATURE-----
debian/control view on Meta::CPAN
Maintainer: Kevin Ryde <user42@zip.com.au>
Standards-Version: 3.9.2
Homepage: http://user42.tuxfamily.org/gtk2-ex-history/index.html
Bugs: mailto:user42@zip.com.au
Package: libgtk2-ex-history-perl
Architecture: all
Depends: libglib-perl, libgtk2-perl (>= 1.220), libglib-ex-objectbits-perl (>= 12), libglib-ex-connectproperties-perl (>= 13), libgtk2-ex-widgetbits-perl (>= 21), libgtk2-ex-dashes-perl, libgtk2-ex-menuview-perl, libintl-perl (>= 1.16), ${perl:Depend...
Description: History of current, back and forward places for user navigation
A History object holds places such as filenames, URIs, or some sort
of position in a list. Action objects and Button, Menu and Dialog
user widgets elements move back or forward through the history.
devel/button.pl view on Meta::CPAN
#
# You should have received a copy of the GNU General Public License along
# with Gtk2-Ex-History. If not, see <http://www.gnu.org/licenses/>.
use 5.008;
use strict;
use warnings;
use Gtk2 '-init';
use Gtk2::Ex::History;
use Gtk2::Ex::History::Button;
use Gtk2::Ex::History::MenuToolButton;
# uncomment this to run the ### lines
use Smart::Comments;
use FindBin;
my $progname = $FindBin::Script;
my $history = Gtk2::Ex::History->new;
$history->goto ('AAA');
$history->goto ('BBB');
devel/button.pl view on Meta::CPAN
my $history2 = Gtk2::Ex::History->new;
my $toplevel = Gtk2::Window->new('toplevel');
$toplevel->signal_connect (destroy => sub { Gtk2->main_quit; });
my $vbox = Gtk2::VBox->new;
$toplevel->add ($vbox);
#my $histbutton = Gtk2::Ex::History::Button->new;
my $histbutton = Gtk2::Ex::History::MenuToolButton->new;
print "$progname: ", $histbutton->get('way'), "\n";
$vbox->pack_start ($histbutton, 1,1,0);
{
my $button = Gtk2::Button->new ('Set history');
$button->signal_connect
(clicked => sub {
$histbutton->set (history => $history);
});
$vbox->pack_start ($button, 0,0,0);
devel/menutoolbutton.pl view on Meta::CPAN
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with Gtk2-Ex-History. If not, see <http://www.gnu.org/licenses/>.
use 5.008;
use strict;
use warnings;
use Gtk2 '-init';
use Gtk2::Ex::History;
use Gtk2::Ex::History::MenuToolButton;
# uncomment this to run the ### lines
use Smart::Comments;
use FindBin;
my $progname = $FindBin::Script;
my $history = Gtk2::Ex::History->new;
$history->goto ('AAA');
$history->goto ('BBB');
devel/menutoolbutton.pl view on Meta::CPAN
$toplevel->set_default_size (100, 50);
$toplevel->signal_connect (destroy => sub { Gtk2->main_quit; });
my $vbox = Gtk2::VBox->new;
$toplevel->add ($vbox);
my $toolbar = Gtk2::Toolbar->new;
# my $toolbar = Gtk2::VBox->new;
$vbox->pack_start ($toolbar, 1,1,0);
# my $toolbutton = Gtk2::MenuToolButton->new_from_stock ('gtk-go-back');
# require Gtk2::Ex::History::Menu;
# my $menu = Gtk2::Ex::History::Menu->new (history => $history,
# way => 'back');
# $toolbutton->set_menu ($menu);
my $toolbutton = Gtk2::Ex::History::MenuToolButton->new (history => $history,
way => 'forward');
{
my $item = Gtk2::ToolButton->new (undef, 'ChangeWay');
$item->signal_connect (clicked => sub {
my $way = $toolbutton->get('way');
if ($way eq 'back') { $way = 'forward'; }
else { $way = 'back'; }
$toolbutton->set('way', $way);
});
devel/run.pl view on Meta::CPAN
my $toplevel = Gtk2::Window->new('toplevel');
if ($d2) {
$toplevel->set_screen ($d2->get_default_screen);
}
$toplevel->signal_connect (destroy => sub { Gtk2->main_quit; });
my $vbox = Gtk2::VBox->new;
$toplevel->add ($vbox);
{
my $menubar = Gtk2::MenuBar->new;
$vbox->pack_start ($menubar, 0,0,0);
my $foo_item = Gtk2::MenuItem->new_with_label ('Foo');
$menubar->add ($foo_item);
my $menu = Gtk2::Menu->new;
$foo_item->set_submenu ($menu);
my $back_item = Gtk2::MenuItem->new_with_label ('Back to');
$menu->add ($back_item);
require Gtk2::Ex::History::Menu;
my $histmenu = Gtk2::Ex::History::Menu->new (history => $history,
way => 'back');
$back_item->set_submenu ($histmenu);
}
my $hbox = Gtk2::HBox->new;
$vbox->pack_start ($hbox, 1,1,0);
{
my $button = Gtk2::Ex::History::Button->new (history => $history,
# way => 'back',
);
devel/run.pl view on Meta::CPAN
$hbox->pack_start ($button, 1,1,0);
}
{
my $button = Gtk2::Ex::History::Button->new (history => $history,
way => 'forward',
);
$hbox->pack_start ($button, 1,1,0);
}
{
my $button = Gtk2::Button->new ('Menu');
$vbox->pack_start ($button, 0,0,0);
$button->signal_connect
(clicked => sub {
require Gtk2::Ex::History::Menu;
my $menu = Gtk2::Ex::History::Menu->new_popup (history => $history);
});
}
{
my $button = Gtk2::Button->new ('Dialog');
$vbox->pack_start ($button, 0,0,0);
$button->signal_connect
(clicked => sub {
require Gtk2::Ex::History::Dialog;
my $menu = Gtk2::Ex::History::Dialog->popup ($history);
});
devel/toolbar.pl view on Meta::CPAN
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with Gtk2-Ex-History. If not, see <http://www.gnu.org/licenses/>.
use 5.008;
use strict;
use warnings;
use Gtk2 '-init';
use Gtk2::Ex::History;
use Gtk2::Ex::History::MenuToolButton;
# uncomment this to run the ### lines
use Smart::Comments;
use FindBin;
my $progname = $FindBin::Script;
my $history = Gtk2::Ex::History->new;
$history->goto ('AAA');
$history->goto ('BBB');
devel/toolbar.pl view on Meta::CPAN
# exit 0;
# }
my $toplevel = Gtk2::Window->new('toplevel');
$toplevel->signal_connect (destroy => sub { Gtk2->main_quit; });
my $toolbar = Gtk2::Toolbar->new;
$toplevel->add ($toolbar);
{
my $toolitem = Gtk2::Ex::History::MenuToolButton->new (history => $history,
# way => 'back',
);
$toolbar->add ($toolitem);
}
{
my $toolitem = Gtk2::Ex::History::MenuToolButton->new (history => $history,
way => 'forward',
);
$toolbar->add ($toolitem);
}
$toplevel->show_all;
Gtk2->main;
exit 0;
devel/ui.pl view on Meta::CPAN
$history->signal_connect
('notify::current' => sub {
print "$progname: notify::current ",$history->get('current'),"\n";
});
my $toplevel = Gtk2::Window->new('toplevel');
$toplevel->signal_connect (destroy => sub { Gtk2->main_quit; });
my $actiongroup = Gtk2::ActionGroup->new ("main");
$actiongroup->add_actions ([
{ name => 'FileMenu', label => '_File' },
{ name => 'Quit',
stock_id => 'gtk-quit',
callback => sub { $toplevel->destroy },
},
{ name => 'Hello',
stock_id => 'gtk-quit',
callback => sub { print "hello\n" },
},
]);
$actiongroup->add_action
(Gtk2::Ex::History::Action->new (name => 'Back',
way => 'back',
history => $history));
$actiongroup->add_action
(Gtk2::Ex::History::Action->new (name => 'Forward',
way => 'forward',
history => $history));
# makes a Gtk2::MenuToolButton
my $recentaction = Gtk2::RecentAction->new (name => 'Recent',
label => 'Recently',
stock_id => 'gtk-open');
$actiongroup->add_action ($recentaction);
my $ui = Gtk2::UIManager->new;
$ui->insert_action_group ($actiongroup, 0);
$toplevel->add_accel_group ($ui->get_accel_group);
$ui->add_ui_from_string ("
<ui>
<toolbar name='ToolBar'>
<toolitem action='Back'/>
<toolitem action='Recent'>
<menu action='FileMenu'>
<menuitem action='Quit'/>
</menu>
</toolitem>
</toolbar>
</ui>");
my $toolbar = $ui->get_widget ('/ToolBar');
$toplevel->add ($toolbar);
my $req = $toolbar->size_request;
devel/unused/ModelSensitive.pm view on Meta::CPAN
This is an internal part of C<Gtk2::Ex::History>, expect it to change or
disappear. It arranges for a button, action, etc, to be insensitive when
the treemodel in the corresponding direction is empty.
=head1 SEE ALSO
L<Gtk2::Ex::History>,
L<Gtk2::Ex::History::Button>,
L<Gtk2::Ex::History::Action>,
L<Gtk2::Ex::History::MenuToolButton>
=head1 HOME PAGE
L<http://user42.tuxfamily.org/gtk2-ex-history/index.html>
=head1 LICENSE
Gtk2-Ex-History is Copyright 2010, 2011 Kevin Ryde
Gtk2-Ex-History is free software; you can redistribute it and/or modify it
lib/Gtk2/Ex/History.pm view on Meta::CPAN
# uncomment this to run the ### lines
#use Smart::Comments;
our $VERSION = 8;
# place-to-icon-pixbuf
# $h->dialog_class, default sub of self
# $h->dialog_popup (parent => ...)
# $h->menu_popup (parent => ..., way => ..., event => ...)
# MenuBits popup_for_event (parent, event)
# place-to-renderers
# place-to-cellinfo
# place-serialize \ or Storable freeze
# place-unserialize /
# place-to-selectiondata
# default place-to-text
# flag for set, or emptiness of SelectionData
# selectiondata-to-place
lib/Gtk2/Ex/History.pm view on Meta::CPAN
=back
=head1 SIGNALS
=over 4
=item C<place-to-text> (scalar; return string)
This signal is emitted to turn a place object into text to display in the
Menu and Dialog user elements. The default is a Perl stringize C<"$place">.
A handler should return a wide-char string. If it's bytes then they're
"upgraded" in the usual way (treating the bytes as Latin-1).
For filenames C<Glib::filename_display_name()> (see L<Glib>) gives a
reasonable form to display, interpreting non-ASCII in the filesystem locale
charset.
See F<examples/iri.pl> in the Gtk2-Ex-History sources for a complete program
turning URL internationalized %-encodings into wide characters for display.
lib/Gtk2/Ex/History.pm view on Meta::CPAN
things use it to avoid pushing multiple copies of the same place onto the
history. The default handler compares with Perl C<eq>.
=back
=head1 SEE ALSO
L<Gtk2::Ex::History::Action>,
L<Gtk2::Ex::History::Button>,
L<Gtk2::Ex::History::Dialog>,
L<Gtk2::Ex::History::Menu>,
L<Glib::Object>
=head1 HOME PAGE
L<http://usr42.tuxfamily.org/gtk2-ex-history/index.html>
=head1 LICENSE
Gtk2-Ex-History is Copyright 2010, 2011 Kevin Ryde
lib/Gtk2/Ex/History/Action.pm view on Meta::CPAN
delete $widget->{(__PACKAGE__)};
return 1; # keep emission hook
}
# 'button-press-event' handler on a toolitem button child
sub _do_button_press_event {
my ($button, $event, $ref_weak_self) = @_;
### History-Action _do_button_press_event(): $event->button
my $self = $$ref_weak_self || return;
if ($event->button == 3 && (my $history = $self->{'history'})) {
require Gtk2::Ex::History::Menu;
Gtk2::Ex::History::Menu->new_popup (history => $history,
way => $self->get('way'),
event => $event);
}
return Gtk2::EVENT_PROPAGATE;
}
sub _update {
my ($self) = @_;
my $way = $self->get('way');
lib/Gtk2/Ex/History/Action.pm view on Meta::CPAN
Gtk2::Action
Gtk2::Ex::History::Action
=head1 DESCRIPTION
C<Gtk2::Ex::History::Action> invokes either C<back> or C<forward> on a given
C<Gtk2::Ex::History>. The "stock" icon and tooltip follow the direction.
The action is insensitive when the history is empty.
When the action is used on a toolbar button a mouse button-3 handler is
added to popup C<Gtk2::Ex::History::Menu>.
If you're not using UIManager and its actions system then see
L<Gtk2::Ex::History::Button> for similar button-3 behaviour.
There's no accelerator keys offered as yet. "B" and "F" would be natural,
but would depend what other things are in the UIManager and whether letters
should be reserved for text entry etc, or are available as accelerators.
Control-B and Control-F aren't good choices if using a text entry as they're
cursor movement in the Emacs style
F</usr/share/themes/Emacs/gtk-2.0-key/gtkrc>.
lib/Gtk2/Ex/History/Button.pm view on Meta::CPAN
# 'button-press-event' class closure
#
# Might like this popup to work even when there's no items in the model and
# the button is therefore insensitive, but the button-press-event doesn't
# come through when insensitive.
#
sub _do_button_press_event {
my ($self, $event) = @_;
### History-Button button-press-event: $event->button
if ($event->button == 3 && (my $history = $self->{'history'})) {
require Gtk2::Ex::History::Menu;
Gtk2::Ex::History::Menu->new_popup (history => $history,
way => $self->get('way'),
event => $event);
}
return shift->signal_chain_from_overridden(@_);
}
1;
__END__
=for stopwords enum Ryde Gtk2-Ex-History
lib/Gtk2/Ex/History/Button.pm view on Meta::CPAN
=head1 DESCRIPTION
A C<Gtk2::Ex::History::Button> invokes either C<back> or C<forward> on a
C<Gtk2::Ex::History> object.
+--------------+
| ==> Forward |
+--------------+
Mouse button-3 opens a C<Gtk2::Ex::History::Menu> to select an entry from a
menu to jump to, to go more than one place back or forward.
A button like this can be used anywhere desired. If it's put in a
C<Gtk2::ToolItem> it can be used in a C<Gtk2::Toolbar>, though if using
C<Gtk2::UIManager> then see L<Gtk2::Ex::History::Action> instead.
=head1 FUNCTIONS
=over 4
lib/Gtk2/Ex/History/Button.pm view on Meta::CPAN
It's something to do with object "constructor" stuff making the stock icon
setup in C<INIT_INSTANCE> not work. Usually you set a C<history> in
initially and that's jigged up to kick it into life.
my $button = Gtk2::Ex::History::Button->new
(history => $history); # ok, "back" button
=head1 SEE ALSO
L<Gtk2::Ex::History>,
L<Gtk2::Ex::History::Menu>,
L<Gtk2::Ex::History::MenuToolButton>,
L<Gtk2::Ex::History::Action>,
L<Gtk2::Button>
=head1 HOME PAGE
L<http://user42.tuxfamily.org/gtk2-ex-history/index.html>
=head1 LICENSE
Gtk2-Ex-History is Copyright 2010, 2011 Kevin Ryde
lib/Gtk2/Ex/History/Dialog.pm view on Meta::CPAN
=item C<history> (C<Gtk2::Ex::History> object, default C<undef>)
The history object to display and act on.
=back
=head1 SEE ALSO
L<Gtk2::Ex::History>,
L<Gtk2::Ex::History::Menu>,
L<Gtk2::Dialog>
=head1 HOME PAGE
L<http://user42.tuxfamily.org/gtk2-ex-history/index.html>
=head1 LICENSE
Gtk2-Ex-History is Copyright 2010, 2011 Kevin Ryde
lib/Gtk2/Ex/History/Menu.pm view on Meta::CPAN
# version.
#
# Gtk2-Ex-History 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-History. If not, see <http://www.gnu.org/licenses/>.
package Gtk2::Ex::History::Menu;
use 5.008;
use strict;
use warnings;
use Gtk2 1.220;
use Scalar::Util;
use Glib::Ex::ObjectBits;
use Gtk2::Ex::History;
use Gtk2::Ex::MenuView;
use Locale::TextDomain ('Gtk2-Ex-History');
use Locale::Messages;
BEGIN {
Locale::Messages::bind_textdomain_codeset ('Gtk2-Ex-History','UTF-8');
Locale::Messages::bind_textdomain_filter ('Gtk2-Ex-History',
\&Locale::Messages::turn_utf_8_on);
}
use Gtk2::Ex::Dashes::MenuItem;
# uncomment this to run the ### lines
#use Smart::Comments;
our $VERSION = 8;
use Glib::Object::Subclass
'Gtk2::Ex::MenuView',
signals => { item_create_or_update => \&_do_item_create_or_update,
activate => \&_do_activate,
},
properties => [ Glib::ParamSpec->object
('history',
__('History object'),
'The history object to present and act on.',
'Gtk2::Ex::History',
Glib::G_PARAM_READWRITE),
lib/Gtk2/Ex/History/Menu.pm view on Meta::CPAN
'Which way of the history to present, either back or forward.',
'Gtk2::Ex::History::Way',
'back',
Glib::G_PARAM_READWRITE),
];
sub INIT_INSTANCE {
my ($self) = @_;
my $dashesitem = Gtk2::Ex::Dashes::MenuItem->new (visible => 1);
$dashesitem->signal_connect (activate => \&_do_dashesitem_activate);
$self->prepend ($dashesitem);
Glib::Ex::ObjectBits::set_property_maybe
($dashesitem,
# tooltip-text new in Gtk 2.12
tooltip_text => __('Open the back/forward history dialog'));
}
sub SET_PROPERTY {
my ($self, $pspec, $newval) = @_;
my $pname = $pspec->get_name;
$self->{$pname} = $newval; # per default GET_PROPERTY
if ($pname eq 'history' || $pname eq 'way') {
my $history = $self->{'history'};
$self->set (model => $history && $history->model($self->get('way')));
#### History-Menu model: $self->get('model')
}
}
# 'activate' signal handler on Dashes::MenuItem tearoff
sub _do_dashesitem_activate {
my ($dashesitem) = @_;
my $self = $dashesitem->get_parent || return; # if orphaned somehow
require Gtk2::Ex::History::Dialog;
Gtk2::Ex::History::Dialog->popup ($self->{'history'}, $self);
}
# 'item-create-or-update' class closure handler
sub _do_item_create_or_update {
my ($self, $item, $model, $path, $iter) = @_;
#### History-Menu _do_item_create_or_update(): $path->to_string
$item ||= Gtk2::MenuItem->new_with_label ('');
my $place = $model->get ($iter, 0);
if (my $history = $self->{'history'}) {
# should always have the history obj when still have model ...
$item->get_child->set_use_markup ($history->get('use-markup'));
$place = $history->signal_emit ('place-to-text', $place);
}
$item->get_child->set_text ($place);
return $item;
}
lib/Gtk2/Ex/History/Menu.pm view on Meta::CPAN
sub _do_activate {
my ($self, $item, $model, $path, $iter) = @_;
my $history = $self->{'history'} || return;
my $way = $self->get('way');
my $n = ($path->get_indices)[0];
$history->$way ($n+1);
}
sub new_popup {
my ($class, %options) = @_;
### History-Menu new_popup()
my $event = delete $options{'event'};
my $self = $class->new (%options);
my $button = 0;
my $time = 0;
if ($event) {
if ($event->can('button')) {
$button = $event->button;
}
if ($event->can('time')) {
lib/Gtk2/Ex/History/Menu.pm view on Meta::CPAN
return $self;
}
1;
__END__
=for stopwords tearoff popup enum Ryde Gtk2-Ex-History
=head1 NAME
Gtk2::Ex::History::Menu -- menu of "back" or "forward" history items
=for test_synopsis my ($my_history)
=head1 SYNOPSIS
use Gtk2::Ex::History::Menu;
my $my_menu = Gtk2::Ex::History::Menu->new
(history => $my_history,
way => 'forward');
=head1 OBJECT HIERARCHY
C<Gtk2::Ex::History::Menu> is a subclass of C<Gtk2::Ex::MenuView>, though
that's only really an implementation detail and the suggestion is not to
rely on more than <Gtk2::Menu>.
Gtk2::Widget
Gtk2::Container
Gtk2::MenuShell
Gtk2::Menu
Gtk2::Ex::MenuView
Gtk2::Ex::History::Menu
=head1 DESCRIPTION
A C<Gtk2::Ex::History::Menu> presents a menu of either the "back" or
"forward" choices from a C<Gtk2::Ex::History> object. This menu is shown by
C<Gtk2::Ex::History::Button> and C<Gtk2::Ex::History::MenuToolButton>.
Selecting an item makes the History go back or forward to that item.
+--------------------+
| --- --- --- --- |
| Thing last visited |
| The thing before |
| An old thing |
+--------------------+
The dashed tearoff item opens a C<Gtk2::Ex::History::Dialog>. If there's no
items to go "back" or "forward" then that tearoff is all that's in the menu.
=head1 FUNCTIONS
=over 4
=item C<< $histmenu = Gtk2::Ex::History::Menu->new (key => value, ...) >>
Create and return a new history menu. Optional key/value pairs set initial
properties as per C<< Glib::Object->new >>. The C<history> property should
be set to say what to display, and C<way> for back or forward.
my $menu = Gtk2::Ex::History::Menu->new
(history => $my_history,
way => 'forward');
=item C<< $histmenu = Gtk2::Ex::History::Menu->new_popup (key => value, ...) >>
Create and popup a new history menu. The key/value parameters set initial
properties, plus an additional
event => Gtk2::Gdk::Event object or undef
If the event has C<button> and C<time> fields then they're used for the menu
popup, and if the C<window> field is set then that gives the screen
(C<Gtk2::Gdk::Screen>) the menu pops up on. For example,
sub my_button_press_handler {
my ($self, $event) = @_;
Gtk2::Ex::History::Menu->new_popup (history => $my_history,
way => 'back',
event => $event);
return Gtk2::EVENT_PROPAGATE; # other handlers
}
=back
=head1 PROPERTIES
=over 4
lib/Gtk2/Ex/History/Menu.pm view on Meta::CPAN
=item C<way> (enum C<Gtk2::Ex::History::Way>, default 'back')
The direction to display, either "back" or "forward".
=back
=head1 SEE ALSO
L<Gtk2::Ex::History>,
L<Gtk2::Ex::History::Button>,
L<Gtk2::Ex::History::MenuToolButton>,
L<Gtk2::Ex::History::Dialog>,
L<Gtk2::Ex::MenuView>,
L<Gtk2::Ex::Dashes::MenuItem>
=head1 HOME PAGE
L<http://user42.tuxfamily.org/gtk2-ex-history/index.html>
=head1 LICENSE
Gtk2-Ex-History is Copyright 2010, 2011 Kevin Ryde
Gtk2-Ex-History is free software; you can redistribute it and/or modify it
lib/Gtk2/Ex/History/MenuToolButton.pm view on Meta::CPAN
# version.
#
# Gtk2-Ex-History 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-History. If not, see <http://www.gnu.org/licenses/>.
package Gtk2::Ex::History::MenuToolButton;
use 5.008;
use strict;
use warnings;
use Gtk2 1.220;
use Glib::Ex::ConnectProperties 13; # v.13 for model-rows
use Gtk2::Ex::History;
# uncomment this to run the ### lines
#use Smart::Comments;
our $VERSION = 8;
use Glib::Object::Subclass
'Gtk2::MenuToolButton',
signals => { clicked => \&_do_clicked,
show_menu => \&_do_show_menu },
properties => [ Glib::ParamSpec->object
('history',
'History object',
'The history object to act on.',
'Gtk2::Ex::History',
Glib::G_PARAM_READWRITE),
Glib::ParamSpec->enum
lib/Gtk2/Ex/History/MenuToolButton.pm view on Meta::CPAN
$self->set_stock_id ('gtk-go-back');
}
sub SET_PROPERTY {
my ($self, $pspec, $newval) = @_;
my $pname = $pspec->get_name;
$self->{$pname} = $newval; # per default GET_PROPERTY
if ($pname eq 'history') {
unless ($self->get_menu) {
$self->set_menu (Gtk2::Menu->new); # dummy to make arrow sensitive
}
}
if ($pname eq 'way') {
$self->set_stock_id ("gtk-go-$newval");
}
my $history = $self->{'history'};
my $way = $self->get('way');
if (my $menu = $self->get_menu) {
if ($menu->isa('Gtk2::Ex::History::Menu')) {
$menu->set (history => $history,
way => $way);
}
}
$self->{'connp'} = $history && Glib::Ex::ConnectProperties->dynamic
([$history->model($way), 'model-rows#not-empty'],
[$self, 'sensitive']);
}
sub _do_show_menu {
my ($self) = @_;
### _do_show_menu()
if (my $history = $self->{'history'}) {
my $menu;
unless (($menu = $self->get_menu)
&& ($menu->isa('Gtk2::Ex::History::Menu'))) {
require Gtk2::Ex::History::Menu;
$self->set_menu (Gtk2::Ex::History::Menu->new (history => $history,
way => $self->get('way')));
}
}
shift->signal_chain_from_overridden(@_);
}
# 'clicked' class closure
sub _do_clicked {
my ($self) = @_;
### History-MenuToolButton clicked: $self->get('way')
my $history = $self->{'history'} || return;
my $way = $self->get('way');
$history->$way;
return shift->signal_chain_from_overridden(@_);
}
1;
__END__
=for stopwords enum MenuToolButton popup Ryde Gtk2-Ex-History
=head1 NAME
Gtk2::Ex::History::MenuToolButton -- toolbar button for history "back" or "forward"
=for test_synopsis my ($my_history, $toolbar)
=head1 SYNOPSIS
use Gtk2::Ex::History::MenuToolButton;
my $item = Gtk2::Ex::History::MenuToolButton->new
(history => $my_history,
way => 'forward');
$toolbar->add ($item);
=head1 OBJECT HIERARCHY
C<Gtk2::Ex::History::MenuToolButton> is a subclass of
C<Gtk2::MenuToolButton>.
Gtk2::Widget
Gtk2::Container
Gtk2::Bin
Gtk2::ToolItem
Gtk2::ToolButton
Gtk2::MenuToolButton
Gtk2::Ex::History::MenuToolButton
=head1 DESCRIPTION
This is a toolbar button which invokes either C<back> or C<forward> on a
C<Gtk2::Ex::History> object. The arrow part of the button presents a menu
of the history in that direction.
+-------------+---+
| | |
| ==> Forward | V |
lib/Gtk2/Ex/History/MenuToolButton.pm view on Meta::CPAN
A plain C<Gtk2::Ex::History::Button> can be put in a C<Gtk2::ToolItem> and
used in a toolbar for a similar result. The difference is whether you
prefer the menu popup with an arrow or with mouse button-3. The arrow has
the advantage of a visual indication that there's something available.
=head1 FUNCTIONS
=over 4
=item C<< $item = Gtk2::Ex::History::MenuToolButton->new (key => value, ...) >>
Create and return a new history button. Optional key/value pairs can be
given to set initial properties, as per C<< Glib::Object->new >>.
The C<history> property should be set to say what to display and act on, and
C<way> for back or forward.
my $item = Gtk2::Ex::History::MenuToolButton->new
(history => $history,
way => 'forward');
=back
=head1 PROPERTIES
=over 4
=item C<history> (C<Gtk2::Ex::History> object, default C<undef>)
lib/Gtk2/Ex/History/MenuToolButton.pm view on Meta::CPAN
The direction to go, either "back" or "forward".
The C<stock-id> property (per C<Gtk2::ToolButton>) is set from this, either
C<gtk-go-back> or C<gtk-go-forward>.
=back
=head1 SEE ALSO
L<Gtk2::Ex::History>,
L<Gtk2::Ex::History::Menu>,
L<Gtk2::Ex::History::Button>,
L<Gtk2::Ex::History::Action>,
L<Gtk2::MenuToolButton>
=head1 HOME PAGE
L<http://user42.tuxfamily.org/gtk2-ex-history/index.html>
=head1 LICENSE
Gtk2-Ex-History is Copyright 2010, 2011 Kevin Ryde
Gtk2-Ex-History is free software; you can redistribute it and/or modify it
po/Gtk2-Ex-History.pot view on Meta::CPAN
"Project-Id-Version: Gtk2-Ex-History @VERSION@\n"
"POT-Creation-Date: @DATE@\n"
"PO-Revision-Date: YYYY-MM-DD HH:MM+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: lib/Gtk2/Ex/History/Action.pm:46 lib/Gtk2/Ex/History/Dialog.pm:52
#: lib/Gtk2/Ex/History/Menu.pm:50
msgid "History object"
msgstr ""
#: lib/Gtk2/Ex/History/Action.pm:144
msgid "Go back."
msgstr ""
#: lib/Gtk2/Ex/History/Action.pm:145
msgid "Go forward."
msgstr ""
po/Gtk2-Ex-History.pot view on Meta::CPAN
msgstr ""
#: lib/Gtk2/Ex/History/Dialog.pm:125
msgid "Back"
msgstr ""
#: lib/Gtk2/Ex/History/Dialog.pm:125
msgid "Forward"
msgstr ""
#: lib/Gtk2/Ex/History/Menu.pm:74
msgid "Open the back/forward history dialog"
msgstr ""
t/Menu-weaken.t view on Meta::CPAN
use lib 't';
use MyTestHelpers;
BEGIN { MyTestHelpers::nowarnings() }
# Test::Weaken 3 for "contents"
eval "use Test::Weaken 3; 1"
or plan skip_all => "Test::Weaken 3 not available -- $@";
require Gtk2::Ex::History;
require Gtk2::Ex::History::Menu;
require Gtk2;
Gtk2->init_check
or plan skip_all => 'due to no DISPLAY available';
plan tests => 2;
require Test::Weaken::Gtk2;
{
my $leaks = Test::Weaken::leaks
({ constructor => sub {
my $history = Gtk2::Ex::History->new;
my $menu = Gtk2::Ex::History::Menu->new (history => $history);
return [ $menu, $history ];
},
destructor => \&Test::Weaken::Gtk2::destructor_destroy,
contents => \&Test::Weaken::Gtk2::contents_container,
});
is ($leaks, undef, 'Test::Weaken deep garbage collection');
MyTestHelpers::test_weaken_show_leaks($leaks);
}
{
my $leaks = Test::Weaken::leaks
({ constructor => sub {
my $history = Gtk2::Ex::History->new;
my $menu = Gtk2::Ex::History::Menu->new_popup (history => $history);
return [ $menu, $history ];
},
destructor => \&Test::Weaken::Gtk2::destructor_destroy,
contents => \&Test::Weaken::Gtk2::contents_container,
});
is ($leaks, undef, 'Test::Weaken deep garbage collection - with popup');
MyTestHelpers::test_weaken_show_leaks($leaks);
}
exit 0;
use 5.008;
use strict;
use warnings;
use Test::More;
use lib 't';
use MyTestHelpers;
BEGIN { MyTestHelpers::nowarnings() }
use Gtk2::Ex::History::Menu;
require Gtk2;
Gtk2->disable_setlocale; # leave LC_NUMERIC alone for version nums
Gtk2->init_check
or plan skip_all => 'due to no DISPLAY available';
plan tests => 11;
#-----------------------------------------------------------------------------
my $want_version = 8;
my $check_version = $want_version + 1000;
is ($Gtk2::Ex::History::Menu::VERSION, $want_version, 'VERSION variable');
is (Gtk2::Ex::History::Menu->VERSION, $want_version, 'VERSION class method');
{ ok (eval { Gtk2::Ex::History::Menu->VERSION($want_version); 1 },
"VERSION class check $want_version");
ok (! eval { Gtk2::Ex::History::Menu->VERSION($check_version); 1 },
"VERSION class check $check_version");
}
#------------------------------------------------------------------------------
# new()
{
my $menu = Gtk2::Ex::History::Menu->new;
isa_ok ($menu, 'Gtk2::Ex::History::Menu', 'new()');
is ($menu->VERSION, $want_version, 'VERSION object method');
ok (eval { $menu->VERSION($want_version); 1 },
"VERSION object check $want_version");
ok (! eval { $menu->VERSION($want_version + 1000); 1 },
"VERSION object check " . ($want_version + 1000));
$menu->destroy;
Scalar::Util::weaken ($menu);
is ($menu, undef, 'new() gc when weakened');
}
#------------------------------------------------------------------------------
# new_popup()
{
my $history = Gtk2::Ex::History->new;
my $menu = Gtk2::Ex::History::Menu->new_popup (history => $history);
isa_ok ($menu, 'Gtk2::Ex::History::Menu', 'new_popup()');
$menu->destroy;
Scalar::Util::weaken ($menu);
is ($menu, undef, 'new_popup() gc when weakened');
}
exit 0;
t/MenuToolButton-weaken.t view on Meta::CPAN
use lib 't';
use MyTestHelpers;
BEGIN { MyTestHelpers::nowarnings() }
# Test::Weaken 3 for "contents"
eval "use Test::Weaken 3; 1"
or plan skip_all => "Test::Weaken 3 not available -- $@";
require Gtk2::Ex::History;
require Gtk2::Ex::History::MenuToolButton;
require Gtk2;
Gtk2->init_check
or plan skip_all => 'due to no DISPLAY available';
plan tests => 3;
require Test::Weaken::Gtk2;
sub my_contents {
my ($ref) = @_;
return (Test::Weaken::Gtk2::contents_container ($ref),
Test::Weaken::Gtk2::contents_submenu ($ref));
}
{
my $leaks = Test::Weaken::leaks
({ constructor => sub {
return Gtk2::Ex::History::MenuToolButton->new;
},
contents => \&my_contents,
});
is ($leaks, undef, 'Test::Weaken deep garbage collection, no history');
MyTestHelpers::test_weaken_show_leaks($leaks);
}
{
my $leaks = Test::Weaken::leaks
({ constructor => sub {
my $history = Gtk2::Ex::History->new;
my $item = Gtk2::Ex::History::MenuToolButton->new (history=>$history);
return [ $item, $history ];
},
contents => \&my_contents,
});
is ($leaks, undef, 'Test::Weaken deep garbage collection, with history');
MyTestHelpers::test_weaken_show_leaks($leaks);
}
{
my $leaks = Test::Weaken::leaks
({ constructor => sub {
my $history = Gtk2::Ex::History->new;
my $item = Gtk2::Ex::History::MenuToolButton->new (history => $history);
my $menu1 = $item->get_menu;
# diag $menu1;
$item->signal_emit ('show-menu');
# diag $item->get_menu;
return [ $item, $history, $menu1 ];
},
destructor => \&Test::Weaken::Gtk2::destructor_destroy,
contents => \&my_contents,
});
is ($leaks, undef, 'Test::Weaken deep garbage collection, history and show-menu');
t/MenuToolButton.t view on Meta::CPAN
use 5.008;
use strict;
use warnings;
use Test::More;
use lib 't';
use MyTestHelpers;
BEGIN { MyTestHelpers::nowarnings() }
use Gtk2::Ex::History::MenuToolButton;
require Gtk2;
Gtk2->disable_setlocale; # leave LC_NUMERIC alone for version nums
Gtk2->init_check
or plan skip_all => 'due to no DISPLAY available';
plan tests => 14;
#-----------------------------------------------------------------------------
my $want_version = 8;
my $check_version = $want_version + 1000;
is ($Gtk2::Ex::History::MenuToolButton::VERSION, $want_version, 'VERSION variable');
is (Gtk2::Ex::History::MenuToolButton->VERSION, $want_version, 'VERSION class method');
{ ok (eval { Gtk2::Ex::History::MenuToolButton->VERSION($want_version); 1 },
"VERSION class check $want_version");
ok (! eval { Gtk2::Ex::History::MenuToolButton->VERSION($check_version); 1 },
"VERSION class check $check_version");
}
#------------------------------------------------------------------------------
# new()
{
my $item = Gtk2::Ex::History::MenuToolButton->new;
isa_ok ($item, 'Gtk2::Ex::History::MenuToolButton');
is ($item->VERSION, $want_version, 'VERSION object method');
ok (eval { $item->VERSION($want_version); 1 },
"VERSION object check $want_version");
ok (! eval { $item->VERSION($want_version + 1000); 1 },
"VERSION object check " . ($want_version + 1000));
Scalar::Util::weaken ($item);
is ($item, undef, 'gc when weakened');
}
#------------------------------------------------------------------------------
# show-menu
{
my $item = Gtk2::Ex::History::MenuToolButton->new;
$item->signal_emit ('show-menu');
is ($item->get_menu, undef, 'show-menu with no history leaves no menu');
}
{
my $item = Gtk2::Ex::History::MenuToolButton->new;
my $history = Gtk2::Ex::History->new;
$item->set (history => $history);
isnt ($item->get_menu, undef,
'with history have menu, so arrow is sensitive');
$item->signal_emit ('show-menu');
my $menu = $item->get_menu;
isa_ok ($menu, 'Gtk2::Ex::History::Menu',
'get_menu() is a history after show-menu');
Scalar::Util::weaken ($item);
Scalar::Util::weaken ($menu);
is ($item, undef, 'item gc when weakened with history');
MyTestHelpers::findrefs($item);
is ($menu, undef, 'menu gc when weakened with history');
MyTestHelpers::findrefs($menu);
}