Gtk2-Ex-WidgetBits
view release on metacpan or search on metacpan
devel/dynamic-context-statusbar.pl
devel/dynamic-context.pl
devel/entrybits-tie.pl
devel/foreach-destroy.pl
devel/grandom-array.c
devel/grandom-zero.c
devel/grandom.c
devel/hook.pl
devel/magic.pl
devel/Makefile
devel/menu-popup.pl
devel/messageuntilkey-multi-display.pl
devel/messageuntilkey.pl
devel/misc.pl
devel/overflow-dialog-bug.pl
devel/overflow-dialog.pl
devel/pixbuf-max.pl
devel/plug.pl
devel/position-menuitem.pl
devel/property-change.pl
devel/propname-translations.pl
SHA1 6579066fe00c62702086b0385cb7a489cbe557d8 devel/container-remove.pl
SHA1 86625849aa0eb74b1a2971fbd6af82dfc96f01d3 devel/dynamic-context-statusbar.pl
SHA1 81ebeb07c2fd032e4d1dbca1cd14687ebeea7b8c devel/dynamic-context.pl
SHA1 16fc25fc9df14e65e131085d742ad88bde680cb7 devel/entrybits-tie.pl
SHA1 73e06bfb8e8e2b761431ec580a873235ef737584 devel/foreach-destroy.pl
SHA1 b72b1891471d30f48c223cbc3ca031a26cc77067 devel/grandom-array.c
SHA1 c46d895965eb377e88ed67a8b827169dfa543058 devel/grandom-zero.c
SHA1 0e56c8d3e9d3ec8b45549fa4f225bf7f3b502b97 devel/grandom.c
SHA1 f5953e423e9ae60de3b437344e46572cfe2d4347 devel/hook.pl
SHA1 6c1abd5e1ef7ff9fb88a9d9c3b847794c42ca5b5 devel/magic.pl
SHA1 72ee5c2a91966bf9498381ca1d8bdd687fff2dc0 devel/menu-popup.pl
SHA1 4552f2d63e27e6b4617cd3ad0e1d0f57f109360e devel/messageuntilkey-multi-display.pl
SHA1 0be0ef24ac51d7b62632d934f87def1e2e4168bb devel/messageuntilkey.pl
SHA1 7459d5b2ff2e285c319c18f25e262143293e734f devel/misc.pl
SHA1 30c4b011fa428780fa722b27aaa7c734162813cc devel/overflow-dialog-bug.pl
SHA1 7f7dd7be39235c69e226d83151a63492bb97859f devel/overflow-dialog.pl
SHA1 85758f71660a52fb35503cd2bcc4c56d2f5ae6e3 devel/pixbuf-max.pl
SHA1 98e437f06559b516e526b2e9fcbd7edcfd2a706b devel/plug.pl
SHA1 098ed25ef7194778f7c97dcb145d358f2e185254 devel/position-menuitem.pl
SHA1 78d5d752cb2aab5414261d78285fad21e64fcbd6 devel/property-change.pl
SHA1 e4b687545f3f27fdbf0e3a5caa854ec5d96c7b41 devel/propname-translations.pl
devel/menu-popup.pl view on Meta::CPAN
$vbox->pack_start ($button, 0,0,0);
$button->signal_connect
(button_press_event => sub {
my ($button, $event) = @_;
print "$progname: event ",$event,"x\n";
print "$progname: e cur ", Gtk2->get_current_event, "\n";
print "$progname: event screen ", $event->window->get_screen, "\n";
print "$progname: e cur screen ", Gtk2->get_current_event->window->get_screen, "\n";
print "$progname: parent ", $menu->parent, "\n";
# $menu->set_screen ($s);
$menu->popup (undef, undef,
\&my_position, $toplevel,
$event->button, $event->time);
print "$progname: pmenu screen ", $menu->get_screen, "\n";
# Glib::Timeout->add (2000, # milliseconds
# sub {
# $menu->set_screen ($s);
# });
return Gtk2::EVENT_PROPAGATE;
devel/menu-popup.pl view on Meta::CPAN
my $button = Gtk2::Button->new_with_label ("Iconify");
$vbox->pack_start ($button, 0,0,0);
$button->signal_connect
(button_press_event => sub {
my ($button, $event) = @_;
print "$progname: iconify\n";
$toplevel->iconify;
Glib::Timeout->add
(1000, # milliseconds
sub {
print "$progname: popup\n";
$menu->popup (undef, undef,
\&my_position, $toplevel,
0, 0);
});
return Gtk2::EVENT_PROPAGATE;
});
}
$toplevel->show_all;
print "$progname: toplevel screen ", $toplevel->get_screen, "\n";
# $menu->popup (undef, undef,
# # \&Gtk2::Ex::MenuBits::position_screen_centre, undef,
# \&Gtk2::Ex::MenuBits::position_widget_topcentre, $toplevel,
# # undef, undef,
# 1, 0);
Gtk2->main;
exit 0;
devel/position-menuitem.pl view on Meta::CPAN
my $item = Gtk2::MenuItem->new ('ZZZZZZZZZZZZ');
$item->show;
$menu->append ($item);
}
$zitem = Gtk2::MenuItem->new ('ZZZZZZZZZZZZ');
$zitem->show;
$menu->append ($zitem);
});
$menu->popup (undef, undef, undef, undef,
1, 0);
my $submenu = Gtk2::Menu->new;
$zitem->set_submenu ($submenu);
my $item;
$submenu->signal_connect
(show => sub {
{
my $item = Gtk2::MenuItem->new ('SSSSSSSSSS');
examples/action-tooltips.pl view on Meta::CPAN
<toolitem action='Quit'/>
</toolbar>
</ui>
HERE
$vbox->pack_start ($ui->get_widget('/MenuBar'), 0,0,0);
$vbox->pack_start ($ui->get_widget('/ToolBar'), 0,0,0);
my $label = Gtk2::Label->new (<<'HERE');
Move the mouse over the tool items or
the menu items (after you popup the menu)
to see the tooltips.
HERE
$vbox->pack_start ($label, 1,1,0);
$toplevel->show_all;
Gtk2->main;
exit 0;
lib/Gtk2/Ex/MenuBits.pm view on Meta::CPAN
# sub _mnemonic_to_markup {
# my ($str) = @_;
# $str =~ s{_(.)}
# {$1 eq '_' ? '_' : "<u>$1</u>"}ge;
# return $str;
# }
1;
__END__
=for stopwords userdata multi-screen iconified toplevel un-iconified Ryde Gtk2 Gtk2-Ex-WidgetBits popup
=head1 NAME
Gtk2::Ex::MenuBits -- miscellaneous Gtk2::Menu helpers
=head1 SYNOPSIS
use Gtk2::Ex::MenuBits;
=head1 FUNCTIONS
=over 4
=item C<< ($x,$y,$push_in) = Gtk2::Ex::MenuBits::position_widget_topcentre ($menu, $x, $y, $userdata) >>
Position a menu with its top edge centred in a given C<$userdata> widget.
This is good for a menu popped up by a keystroke in a "strip" type widget
which is wide but has only a small height.
$menu->popup (undef, # no parent menushell
undef, # no parent menuitem
\&Gtk2::Ex::MenuBits::position_widget_topcentre,
$widget, # userdata
0, # no button for keyboard popup
$event_time);
C<$userdata> can be either a widget or a reference to a widget. The latter
can be a weak reference so as to avoid a circular reference between a widget
and a menu within it (C<< $menu->popup >> holds C<$userdata> within the menu
for later C<reposition>).
If C<$userdata> is C<undef> or a ref to C<undef>, or if the widget is not
mapped or is on a different screen than C<$menu>, then the return is the
given C<$x>,C<$y> input parameters. This is the mouse pointer position if
called straight from C<Gtk2::Menu>.
A multi-screen program should C<set_screen> on the menu to ensure it's the
same as the widget. This is left to the application because it's probably
not safe within the positioning function, especially not if the positioning
is called from C<set_screen> itself due to moving a popped-up menu to a
different screen.
In the current implementation if the widget is in an iconified toplevel then
the position is based on its un-iconified location. The intention in the
future is to go to the mouse position fallback in this case, since the
widget is not on-screen. Of course when iconified a widget won't get
keyboard or button events to cause a menu popup, so in practice this doesn't
arise.
=back
=head2 Mnemonic Strings
=over
=item C<$mstr = Gtk2::Ex::MenuBits::mnemonic_escape ($str)>
lib/Gtk2/Ex/MenuBits.pm view on Meta::CPAN
# gives "Save As X_Y_Z"
=back
=head1 EXPORTS
Nothing is exported by default, but C<position_widget_topcentre> can be
requested in usual C<Exporter> style,
use Gtk2::Ex::MenuBits 'position_widget_topcentre';
$menu->popup (undef, undef,
\&position_widget_topcentre, $widget,
0, 0);
There's no C<:all> tag since this module is meant as a grab-bag of functions
and to import as-yet unknown things would be asking for name clashes!
=head1 SEE ALSO
L<Gtk2::Menu>, L<Gtk2::Ex::WidgetBits>, L<Exporter>
t/WidgetBits.t view on Meta::CPAN
my $check_version = $want_version + 1000;
ok (! eval { Gtk2::Ex::WidgetBits->VERSION($check_version); 1 },
"VERSION class check $check_version");
}
#-----------------------------------------------------------------------------
# get_root_position()
#
{
# use 'popup' to stop any window manager moving
my $toplevel = Gtk2::Window->new('popup');
$toplevel->set_size_request (100, 100);
is_deeply ([ Gtk2::Ex::WidgetBits::get_root_position ($toplevel) ],
[], 'get_root_position() on unrealized');
$toplevel->show_all;
MyTestHelpers::wait_for_event ($toplevel, 'map-event');
{
my @top_xy = Gtk2::Ex::WidgetBits::get_root_position ($toplevel);
diag ("toplevel at $top_xy[0], $top_xy[1]");
is (scalar @top_xy, 2, 'get_root_position() on realized, num retvals');
( run in 0.891 second using v1.01-cache-2.11-cpan-364913b4093 )